summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/amount.h3
-rw-r--r--src/balance.h9
2 files changed, 12 insertions, 0 deletions
diff --git a/src/amount.h b/src/amount.h
index a8c08905..a37efdb8 100644
--- a/src/amount.h
+++ b/src/amount.h
@@ -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;
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"));