diff options
author | John Wiegley <johnw@newartisans.com> | 2004-09-10 19:52:51 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2004-09-10 19:52:51 -0400 |
commit | 435b9ed7794958626a66b2490a7ec67033508eaa (patch) | |
tree | cd2f6da8de07095f99231c243d86525878628bba /format.cc | |
parent | e1d6c4bff27f41fbe57738205ba3548554380a73 (diff) | |
download | fork-ledger-435b9ed7794958626a66b2490a7ec67033508eaa.tar.gz fork-ledger-435b9ed7794958626a66b2490a7ec67033508eaa.tar.bz2 fork-ledger-435b9ed7794958626a66b2490a7ec67033508eaa.zip |
added python support for Format() objects. see main.py
Diffstat (limited to 'format.cc')
-rw-r--r-- | format.cc | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -185,8 +185,7 @@ element_t * format_t::parse_elements(const std::string& fmt) return result.release(); } -void format_t::format_elements(std::ostream& out, - const details_t& details) const +void format_t::format(std::ostream& out, const details_t& details) const { for (const element_t * elem = elements; elem; elem = elem->next) { if (elem->align_left) @@ -439,15 +438,22 @@ bool format_account::display_account(const account_t& account, using namespace boost::python; using namespace ledger; +template <typename T> +std::string py_format(format_t& format, T& item) { + std::ostringstream out; + format.format(out, details_t(item)); + return out.str(); +} + void export_format() { -#if 0 - class_< format_transactions > ("FormatTransactions") - .def(init<item_handler<transaction_t> *>()) - .def("flush", &format_transactions::flush) - .def("__call__", &format_transactions::operator()); + class_< format_t > ("Format") + .def(init<std::string>()) + .def("reset", &format_t::reset) + .def("format", py_format<account_t>) + .def("format", py_format<entry_t>) + .def("format", py_format<transaction_t>) ; -#endif } #endif // USE_BOOST_PYTHON |