From bd455c98743ce354b875d67a1d607a682d604fe0 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 20 Nov 2009 23:23:22 -0500 Subject: Added string conversion op for amounts and balances --- src/balance.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/balance.h') 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")); -- cgit v1.2.3