There are no more asserts or exceptions while parsing, but still there are
many balancing errors.
This commit is contained in:
parent
643f2d33cf
commit
171f79dda2
2 changed files with 48 additions and 5 deletions
25
balance.h
25
balance.h
|
|
@ -314,6 +314,31 @@ public:
|
|||
return temp;
|
||||
}
|
||||
|
||||
balance_t round() const {
|
||||
balance_t temp;
|
||||
for (amounts_map::const_iterator i = amounts.begin();
|
||||
i != amounts.end();
|
||||
i++)
|
||||
temp += i->second.round();
|
||||
return temp;
|
||||
}
|
||||
balance_t round(amount_t::precision_t prec) const {
|
||||
balance_t temp;
|
||||
for (amounts_map::const_iterator i = amounts.begin();
|
||||
i != amounts.end();
|
||||
i++)
|
||||
temp += i->second.round(prec);
|
||||
return temp;
|
||||
}
|
||||
balance_t unround() const {
|
||||
balance_t temp;
|
||||
for (amounts_map::const_iterator i = amounts.begin();
|
||||
i != amounts.end();
|
||||
i++)
|
||||
temp += i->second.unround();
|
||||
return temp;
|
||||
}
|
||||
|
||||
balance_t reduce() const {
|
||||
balance_t temp(*this);
|
||||
temp.in_place_reduce();
|
||||
|
|
|
|||
28
value.cc
28
value.cc
|
|
@ -1006,24 +1006,38 @@ void value_t::in_place_cast(type_t cast_type)
|
|||
}
|
||||
break;
|
||||
|
||||
case AMOUNT:
|
||||
case AMOUNT: {
|
||||
const amount_t& amt(as_amount());
|
||||
switch (cast_type) {
|
||||
case INTEGER:
|
||||
set_long(as_amount().to_long());
|
||||
if (amt.is_null())
|
||||
set_long(0L);
|
||||
else
|
||||
set_long(as_amount().to_long());
|
||||
return;
|
||||
case BALANCE:
|
||||
set_balance(as_amount());
|
||||
if (amt.is_null())
|
||||
set_balance(balance_t());
|
||||
else
|
||||
set_balance(as_amount());
|
||||
return;
|
||||
case BALANCE_PAIR:
|
||||
set_balance_pair(as_amount());
|
||||
if (amt.is_null())
|
||||
set_balance_pair(balance_pair_t());
|
||||
else
|
||||
set_balance_pair(as_amount());
|
||||
return;
|
||||
case STRING:
|
||||
set_string(as_amount().to_string());
|
||||
if (amt.is_null())
|
||||
set_string("");
|
||||
else
|
||||
set_string(as_amount().to_string());
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case BALANCE:
|
||||
switch (cast_type) {
|
||||
|
|
@ -1244,6 +1258,10 @@ value_t value_t::round() const
|
|||
return *this;
|
||||
case AMOUNT:
|
||||
return as_amount().round();
|
||||
case BALANCE:
|
||||
return as_balance().round();
|
||||
case BALANCE_PAIR:
|
||||
return as_balance_pair().round();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue