summaryrefslogtreecommitdiff
path: root/src/py_amount.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-05-02 03:04:20 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:38:35 -0400
commit230e03166f061387e7e25591bd2df6acad4195ee (patch)
tree34d80727f5efa12714f592e1010b51efbc9ba587 /src/py_amount.cc
parente70b80d6fe1ed6da6812eb3f4c77570a18eb2bf3 (diff)
downloadfork-ledger-230e03166f061387e7e25591bd2df6acad4195ee.tar.gz
fork-ledger-230e03166f061387e7e25591bd2df6acad4195ee.tar.bz2
fork-ledger-230e03166f061387e7e25591bd2df6acad4195ee.zip
In the middle of switching to using boost/operators.hpp
Diffstat (limited to 'src/py_amount.cc')
-rw-r--r--src/py_amount.cc37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/py_amount.cc b/src/py_amount.cc
index 059322f1..e26ba35e 100644
--- a/src/py_amount.cc
+++ b/src/py_amount.cc
@@ -55,6 +55,21 @@ commodity_t * py_find_commodity(const string& symbol)
EXC_TRANSLATOR(amount_error)
+namespace {
+ template <typename T>
+ amount_t operator+(const amount_t& amt, const T val) {
+ amount_t temp(amt);
+ temp += amount_t(val);
+ return temp;
+ }
+ template <typename T>
+ amount_t operator+(const T val, const amount_t& amt) {
+ amount_t temp(val);
+ temp += amt;
+ return temp;
+ }
+}
+
void export_amount()
{
scope().attr("AMOUNT_PARSE_NO_MIGRATE") = AMOUNT_PARSE_NO_MIGRATE;
@@ -72,66 +87,86 @@ void export_amount()
.def(self += double())
.def(self + self)
+#if 0
.def(self + long())
.def(long() + self)
.def(self + double())
.def(double() + self)
+#endif
.def(self -= self)
.def(self -= long())
.def(self -= double())
.def(self - self)
+#if 0
.def(self - long())
.def(long() - self)
.def(self - double())
.def(double() - self)
+#endif
.def(self *= self)
.def(self *= long())
.def(self *= double())
.def(self * self)
+#if 0
.def(self * long())
.def(long() * self)
.def(self * double())
.def(double() * self)
+#endif
.def(self /= self)
.def(self /= long())
.def(self /= double())
.def(self / self)
+#if 0
.def(self / long())
.def(long() / self)
.def(self / double())
.def(double() / self)
+#endif
.def(- self)
.def(self < self)
+#if 0
.def(self < long())
.def(long() < self)
+#endif
.def(self <= self)
+#if 0
.def(self <= long())
.def(long() <= self)
+#endif
.def(self > self)
+#if 0
.def(self > long())
.def(long() > self)
+#endif
.def(self >= self)
+#if 0
.def(self >= long())
.def(long() >= self)
+#endif
.def(self == self)
+#if 0
.def(self == long())
.def(long() == self)
+#endif
.def(self != self)
+#if 0
.def(self != long())
.def(long() != self)
+#endif
.def(! self)
@@ -166,7 +201,7 @@ void export_amount()
.def("compare", &amount_t::compare)
.def("date", &amount_t::date)
.def("negate", &amount_t::negate)
- .def("null", &amount_t::null)
+ .def("is_null", &amount_t::is_null)
.def("parse", py_parse_1)
.def("parse", py_parse_2)
.def("price", &amount_t::price)