summaryrefslogtreecommitdiff
path: root/src/balance.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-11-20 23:23:22 -0500
committerJohn Wiegley <johnw@newartisans.com>2009-11-20 23:23:22 -0500
commitbd455c98743ce354b875d67a1d607a682d604fe0 (patch)
tree8f06ee6e3833b519f7e6dadc12157fe7500e85a4 /src/balance.h
parent92d2310548e8e51b6496385d8808cca8eaf1aa04 (diff)
downloadfork-ledger-bd455c98743ce354b875d67a1d607a682d604fe0.tar.gz
fork-ledger-bd455c98743ce354b875d67a1d607a682d604fe0.tar.bz2
fork-ledger-bd455c98743ce354b875d67a1d607a682d604fe0.zip
Added string conversion op for amounts and balances
Diffstat (limited to 'src/balance.h')
-rw-r--r--src/balance.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/balance.h b/src/balance.h
index 8a40dea9..a8a46d53 100644
--- a/src/balance.h
+++ b/src/balance.h
@@ -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"));