summaryrefslogtreecommitdiff
path: root/python/py_amount.cc
diff options
context:
space:
mode:
Diffstat (limited to 'python/py_amount.cc')
-rw-r--r--python/py_amount.cc48
1 files changed, 44 insertions, 4 deletions
diff --git a/python/py_amount.cc b/python/py_amount.cc
index 16880f6f..4ec94132 100644
--- a/python/py_amount.cc
+++ b/python/py_amount.cc
@@ -48,12 +48,14 @@ amount_t py_round_1(const amount_t& amount, amount_t::precision_t prec) {
return amount.round(prec);
}
+#ifdef HAVE_GDTOA
double py_to_double_0(amount_t& amount) {
return amount.to_double();
}
double py_to_double_1(amount_t& amount, bool no_check) {
return amount.to_double(no_check);
}
+#endif
long py_to_long_0(amount_t& amount) {
return amount.to_long();
@@ -66,7 +68,7 @@ boost::optional<amount_t> py_value_0(const amount_t& amount) {
return amount.value();
}
boost::optional<amount_t> py_value_1(const amount_t& amount,
- const boost::optional<moment_t>& moment) {
+ const boost::optional<datetime_t>& moment) {
return amount.value(moment);
}
@@ -136,7 +138,9 @@ void export_amount()
.add_static_property("stream_fullstrings", &amount_t::stream_fullstrings)
+#ifdef HAVE_GDTOA
.def(init<double>())
+#endif
.def(init<long>())
.def(init<std::string>())
@@ -152,80 +156,108 @@ internal precision.")
.def(self == self)
.def(self == long())
.def(long() == self)
+#ifdef HAVE_GDTOA
.def(self == double())
.def(double() == self)
+#endif
.def(self != self)
.def(self != long())
.def(long() != self)
+#ifdef HAVE_GDTOA
.def(self != double())
.def(double() != self)
+#endif
.def(! self)
.def(self < self)
.def(self < long())
.def(long() < self)
+#ifdef HAVE_GDTOA
.def(self < double())
.def(double() < self)
+#endif
.def(self <= self)
.def(self <= long())
.def(long() <= self)
+#ifdef HAVE_GDTOA
.def(self <= double())
.def(double() <= self)
+#endif
.def(self > self)
.def(self > long())
.def(long() > self)
+#ifdef HAVE_GDTOA
.def(self > double())
.def(double() > self)
+#endif
.def(self >= self)
.def(self >= long())
.def(long() >= self)
+#ifdef HAVE_GDTOA
.def(self >= double())
.def(double() >= self)
+#endif
.def(self += self)
.def(self += long())
+#ifdef HAVE_GDTOA
.def(self += double())
+#endif
.def(self + self)
.def(self + long())
.def(long() + self)
+#ifdef HAVE_GDTOA
.def(self + double())
.def(double() + self)
+#endif
.def(self -= self)
.def(self -= long())
+#ifdef HAVE_GDTOA
.def(self -= double())
+#endif
.def(self - self)
.def(self - long())
.def(long() - self)
+#ifdef HAVE_GDTOA
.def(self - double())
.def(double() - self)
+#endif
.def(self *= self)
.def(self *= long())
+#ifdef HAVE_GDTOA
.def(self *= double())
+#endif
.def(self * self)
.def(self * long())
.def(long() * self)
+#ifdef HAVE_GDTOA
.def(self * double())
.def(double() * self)
+#endif
.def(self /= self)
.def(self /= long())
+#ifdef HAVE_GDTOA
.def(self /= double())
+#endif
.def(self / self)
.def(self / long())
.def(long() / self)
+#ifdef HAVE_GDTOA
.def(self / double())
.def(double() / self)
+#endif
.add_property("precision", &amount_t::precision)
@@ -259,9 +291,11 @@ internal precision.")
.def("is_realzero", &amount_t::is_realzero)
.def("is_null", &amount_t::is_null)
+#ifdef HAVE_GDTOA
.def("to_double", py_to_double_0)
.def("to_double", py_to_double_1)
.def("__float__", py_to_double_0)
+#endif
.def("to_long", py_to_long_0)
.def("to_long", py_to_long_1)
.def("__int__", py_to_long_0)
@@ -270,7 +304,9 @@ internal precision.")
.def("to_fullstring", &amount_t::to_fullstring)
.def("__repr__", &amount_t::to_fullstring)
+#ifdef HAVE_GDTOA
.def("fits_in_double", &amount_t::fits_in_double)
+#endif
.def("fits_in_long", &amount_t::fits_in_long)
.add_property("quantity_string", &amount_t::quantity_string)
@@ -285,9 +321,11 @@ internal precision.")
.def("clear_commodity", &amount_t::clear_commodity)
.add_property("number", &amount_t::number)
- .def("annotate_commodity", &amount_t::annotate_commodity)
- .def("commodity_annotated", &amount_t::commodity_annotated)
- .add_property("annotation_details", &amount_t::annotation_details)
+ .def("annotate", &amount_t::annotate)
+ .def("is_annotated", &amount_t::is_annotated)
+#if 0
+ .add_property("annotation", &amount_t::annotation)
+#endif
.def("strip_annotations", &amount_t::strip_annotations)
.def("parse", py_parse_1)
@@ -307,7 +345,9 @@ internal precision.")
register_optional_to_python<amount_t>();
+#ifdef HAVE_GDTOA
implicitly_convertible<double, amount_t>();
+#endif
implicitly_convertible<long, amount_t>();
implicitly_convertible<string, amount_t>();