summaryrefslogtreecommitdiff
path: root/src/py_value.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-11-20 17:40:15 -0500
committerJohn Wiegley <johnw@newartisans.com>2009-11-20 17:40:15 -0500
commitaa086686ea2eb4efcb4684a48de8c15a97004a80 (patch)
treead53f1c9c3fc94717a5020602587c27fcc310cc6 /src/py_value.cc
parentb00e7ac19a096a7b736863dced616d552843ed6e (diff)
downloadfork-ledger-aa086686ea2eb4efcb4684a48de8c15a97004a80.tar.gz
fork-ledger-aa086686ea2eb4efcb4684a48de8c15a97004a80.tar.bz2
fork-ledger-aa086686ea2eb4efcb4684a48de8c15a97004a80.zip
Normalized the value() method for Python numerics
Diffstat (limited to 'src/py_value.cc')
-rw-r--r--src/py_value.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/py_value.cc b/src/py_value.cc
index 98f3f079..1a77da72 100644
--- a/src/py_value.cc
+++ b/src/py_value.cc
@@ -47,6 +47,19 @@ BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(set_string_overloads, set_string, 0, 2)
namespace {
+ boost::optional<value_t> py_value_0(const value_t& value) {
+ return value.value(false, CURRENT_TIME());
+ }
+ boost::optional<value_t> py_value_1(const value_t& value,
+ commodity_t& in_terms_of) {
+ return value.value(false, CURRENT_TIME(), in_terms_of);
+ }
+ boost::optional<value_t> py_value_2(const value_t& value,
+ commodity_t& in_terms_of,
+ datetime_t& moment) {
+ return value.value(false, moment, in_terms_of);
+ }
+
PyObject * py_base_type(value_t& value)
{
if (value.is_boolean()) {
@@ -244,6 +257,10 @@ void export_value()
.def("unreduced", &value_t::unreduced)
.def("in_place_unreduce", &value_t::in_place_unreduce)
+ .def("value", py_value_0)
+ .def("value", py_value_1, args("in_terms_of"))
+ .def("value", py_value_2, args("in_terms_of", "moment"))
+
.def("value", &value_t::value, value_overloads())
.def("price", &value_t::price)
.def("exchange_commodities", &value_t::exchange_commodities,