summaryrefslogtreecommitdiff
path: root/value.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 /value.h
parent176b3044e355398a0c31e0c42a3cd7b8a2e3f3e5 (diff)
downloadfork-ledger-0a6b5726ec3bf402a953ea8a03b98ecbf4b90b0c.tar.gz
fork-ledger-0a6b5726ec3bf402a953ea8a03b98ecbf4b90b0c.tar.bz2
fork-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 'value.h')
-rw-r--r--value.h33
1 files changed, 17 insertions, 16 deletions
diff --git a/value.h b/value.h
index 81fb9371..87f9d2ba 100644
--- a/value.h
+++ b/value.h
@@ -400,14 +400,14 @@ class value_t
template <typename T>
operator T() const;
- void negate();
- value_t negated() const {
+ void in_place_negate();
+ value_t negate() const {
value_t temp = *this;
- temp.negate();
+ temp.in_place_negate();
return temp;
}
value_t operator-() const {
- return negated();
+ return negate();
}
bool realzero() const {
@@ -439,27 +439,34 @@ class value_t
return 0;
}
- void abs();
- void cast(type_t cast_type);
+ void in_place_abs();
+ value_t abs() const;
+ void in_place_cast(type_t cast_type);
value_t cost() const;
value_t price() const;
value_t date() const;
+ value_t cast(type_t cast_type) const {
+ value_t temp(*this);
+ temp.in_place_cast(cast_type);
+ return temp;
+ }
+
value_t strip_annotations(const bool keep_price = amount_t::keep_price,
const bool keep_date = amount_t::keep_date,
const bool keep_tag = amount_t::keep_tag) const;
value_t& add(const amount_t& amount, const amount_t * cost = NULL);
value_t value(const ptime& moment) const;
- void reduce();
+ void in_place_reduce();
- value_t reduced() const {
+ value_t reduce() const {
value_t temp(*this);
- temp.reduce();
+ temp.in_place_reduce();
return temp;
}
- void round();
+ value_t round() const;
value_t unround() const;
void write(std::ostream& out, const int first_width,
@@ -555,12 +562,6 @@ template <> value_t::operator ptime() const;
template <> value_t::operator double() const;
template <> value_t::operator std::string() const;
-inline value_t abs(const value_t& val) {
- value_t temp(val);
- temp.abs();
- return temp;
-}
-
std::ostream& operator<<(std::ostream& out, const value_t& val);
class value_context : public error_context