Added string conversion op for amounts and balances
This commit is contained in:
parent
92d2310548
commit
bd455c9874
2 changed files with 12 additions and 0 deletions
|
|
@ -496,6 +496,9 @@ public:
|
|||
long to_long() const;
|
||||
bool fits_in_long() const;
|
||||
|
||||
operator string() const {
|
||||
return to_string();
|
||||
}
|
||||
string to_string() const;
|
||||
string to_fullstring() const;
|
||||
string quantity_string() const;
|
||||
|
|
|
|||
|
|
@ -461,6 +461,15 @@ public:
|
|||
* Conversion methods. A balance can be converted to an amount, but
|
||||
* only if contains a single component amount.
|
||||
*/
|
||||
operator string() const {
|
||||
return to_string();
|
||||
}
|
||||
string to_string() const {
|
||||
std::ostringstream buf;
|
||||
print(buf);
|
||||
return buf.str();
|
||||
}
|
||||
|
||||
amount_t to_amount() const {
|
||||
if (is_empty())
|
||||
throw_(balance_error, _("Cannot convert an empty balance to an amount"));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue