summaryrefslogtreecommitdiff
path: root/amount.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-04-19 20:31:46 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:38:28 -0400
commit0a6b5726ec3bf402a953ea8a03b98ecbf4b90b0c (patch)
tree0a2c2aca7100d045f491b03f0a5bda92378d3ef9 /amount.h
parent176b3044e355398a0c31e0c42a3cd7b8a2e3f3e5 (diff)
downloadledger-0a6b5726ec3bf402a953ea8a03b98ecbf4b90b0c.tar.gz
ledger-0a6b5726ec3bf402a953ea8a03b98ecbf4b90b0c.tar.bz2
ledger-0a6b5726ec3bf402a953ea8a03b98ecbf4b90b0c.zip
Made the amount/balance/value interface a bit more rational; added
back a useless version of the register command (just to prove the command sequence); and added smart XML semantics to the XPath implementation so that nodes can be coerced to values.
Diffstat (limited to 'amount.h')
-rw-r--r--amount.h26
1 files changed, 10 insertions, 16 deletions
diff --git a/amount.h b/amount.h
index 6f88229b..4afe038d 100644
--- a/amount.h
+++ b/amount.h
@@ -244,15 +244,14 @@ class amount_t
}
// unary negation
- // jww (2007-04-17): change the name here
- void negate();
- amount_t negated() const {
+ void in_place_negate();
+ amount_t negate() const {
amount_t temp = *this;
- temp.negate();
+ temp.in_place_negate();
return temp;
}
amount_t operator-() const {
- return negated();
+ return negate();
}
// test for zero and non-zero
@@ -327,17 +326,16 @@ class amount_t
amount_t value(const ptime& moment) const;
- // jww (2007-04-17): change the name here
- void abs() {
+ amount_t abs() const {
if (*this < 0)
- negate();
+ return negate();
+ return *this;
}
- // jww (2007-04-17): change the name here
- void reduce();
- amount_t reduced() const {
+ void in_place_reduce();
+ amount_t reduce() const {
amount_t temp(*this);
- temp.reduce();
+ temp.in_place_reduce();
return temp;
}
@@ -409,10 +407,6 @@ inline std::string amount_t::quantity_string() const {
return bufstream.str();
}
-inline amount_t abs(const amount_t& amt) {
- return amt < 0 ? amt.negated() : amt;
-}
-
#define DEFINE_AMOUNT_OPERATORS(T) \
inline amount_t operator+(const T val, const amount_t& amt) { \
amount_t temp(val); \