summaryrefslogtreecommitdiff
path: root/amount.h
diff options
context:
space:
mode:
Diffstat (limited to 'amount.h')
-rw-r--r--amount.h25
1 files changed, 17 insertions, 8 deletions
diff --git a/amount.h b/amount.h
index 5e31d95f..c94b5dc1 100644
--- a/amount.h
+++ b/amount.h
@@ -41,15 +41,10 @@ class amount_t
commodity = amt.commodity;
}
amount_t(const std::string& value) {
- _init();
- std::istringstream str(value);
- str >> *this;
+ parse(value);
}
amount_t(const char * value) {
- _init();
- std::string valstr(value);
- std::istringstream str(valstr);
- str >> *this;
+ parse(value);
}
amount_t(const bool value);
amount_t(const int value);
@@ -122,12 +117,21 @@ class amount_t
// test for non-zero (use ! for zero)
operator bool() const;
- // comparisons to zero
+ // integer comparisons
bool operator<(const int num) const;
bool operator<=(const int num) const;
bool operator>(const int num) const;
bool operator>=(const int num) const;
+ bool operator<(const unsigned int num) const;
+ bool operator<=(const unsigned int num) const;
+ bool operator>(const unsigned int num) const;
+ bool operator>=(const unsigned int num) const;
+ bool operator==(const unsigned int num) const;
+ bool operator!=(const unsigned int num) const {
+ return ! (*this == num);
+ }
+
// comparisons between amounts
bool operator<(const amount_t& amt) const;
bool operator<=(const amount_t& amt) const;
@@ -142,6 +146,11 @@ class amount_t
amount_t value(const std::time_t moment) const;
+ void abs() {
+ if (*this < 0)
+ negate();
+ }
+
operator std::string() const;
void parse(std::istream& in);