Transactions, etc., are now accessed by iterators
This commit is contained in:
parent
111881f3ce
commit
40a430139e
7 changed files with 78 additions and 6 deletions
|
|
@ -114,11 +114,31 @@ public:
|
|||
account_t * find_account(const string& name, bool auto_create = true);
|
||||
account_t * find_account_re(const string& regexp);
|
||||
|
||||
typedef transform_iterator<function<account_t *(accounts_map::value_type&)>,
|
||||
accounts_map::iterator>
|
||||
accounts_map_seconds_iterator;
|
||||
|
||||
accounts_map_seconds_iterator accounts_begin() {
|
||||
return make_transform_iterator
|
||||
(accounts.begin(), bind(&accounts_map::value_type::second, _1));
|
||||
}
|
||||
accounts_map_seconds_iterator accounts_end() {
|
||||
return make_transform_iterator
|
||||
(accounts.end(), bind(&accounts_map::value_type::second, _1));
|
||||
}
|
||||
|
||||
void add_post(post_t * post) {
|
||||
posts.push_back(post);
|
||||
}
|
||||
bool remove_post(post_t * post);
|
||||
|
||||
posts_list::iterator posts_begin() {
|
||||
return posts.begin();
|
||||
}
|
||||
posts_list::iterator posts_end() {
|
||||
return posts.end();
|
||||
}
|
||||
|
||||
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
|
||||
const string& name);
|
||||
|
||||
|
|
|
|||
|
|
@ -128,6 +128,13 @@ public:
|
|||
journal_t();
|
||||
~journal_t();
|
||||
|
||||
std::list<fileinfo_t>::iterator sources_begin() {
|
||||
return sources.begin();
|
||||
}
|
||||
std::list<fileinfo_t>::iterator sources_end() {
|
||||
return sources.end();
|
||||
}
|
||||
|
||||
// These four methods are delegated to the current session, since all
|
||||
// accounts processed are gathered together at the session level.
|
||||
void add_account(account_t * acct);
|
||||
|
|
@ -138,6 +145,25 @@ public:
|
|||
bool add_xact(xact_t * xact);
|
||||
bool remove_xact(xact_t * xact);
|
||||
|
||||
xacts_list::iterator xacts_begin() {
|
||||
return xacts.begin();
|
||||
}
|
||||
xacts_list::iterator xacts_end() {
|
||||
return xacts.end();
|
||||
}
|
||||
auto_xacts_list::iterator auto_xacts_begin() {
|
||||
return auto_xacts.begin();
|
||||
}
|
||||
auto_xacts_list::iterator auto_xacts_end() {
|
||||
return auto_xacts.end();
|
||||
}
|
||||
period_xacts_list::iterator period_xacts_begin() {
|
||||
return period_xacts.begin();
|
||||
}
|
||||
period_xacts_list::iterator period_xacts_end() {
|
||||
return period_xacts.end();
|
||||
}
|
||||
|
||||
void add_xact_finalizer(xact_finalizer_t * finalizer) {
|
||||
xact_finalize_hooks.add_hook(finalizer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,8 +177,6 @@ void export_account()
|
|||
.def_readwrite("name", &account_t::name)
|
||||
.def_readwrite("note", &account_t::note)
|
||||
.def_readonly("depth", &account_t::depth)
|
||||
.def_readonly("accounts", &account_t::accounts)
|
||||
.def_readonly("posts", &account_t::posts)
|
||||
|
||||
.def(self_ns::str(self))
|
||||
|
||||
|
|
@ -201,6 +199,13 @@ void export_account()
|
|||
.def("__len__", accounts_len)
|
||||
.def("__getitem__", accounts_getitem, return_internal_reference<1>())
|
||||
|
||||
.def("__iter__", range<return_internal_reference<> >
|
||||
(&account_t::accounts_begin, &account_t::accounts_end))
|
||||
.def("accounts", range<return_internal_reference<> >
|
||||
(&account_t::accounts_begin, &account_t::accounts_end))
|
||||
.def("posts", range<return_internal_reference<> >
|
||||
(&account_t::posts_begin, &account_t::posts_end))
|
||||
|
||||
.def("has_xdata", &account_t::has_xdata)
|
||||
.def("clear_xdata", &account_t::clear_xdata)
|
||||
.def("xdata", py_xdata,
|
||||
|
|
|
|||
|
|
@ -192,7 +192,6 @@ void export_journal()
|
|||
make_getter(&journal_t::basket,
|
||||
return_internal_reference<1>()),
|
||||
make_setter(&journal_t::basket))
|
||||
.add_property("sources", make_getter(&journal_t::sources))
|
||||
.add_property("was_loaded", make_getter(&journal_t::was_loaded))
|
||||
.add_property("commodity_pool",
|
||||
make_getter(&journal_t::commodity_pool,
|
||||
|
|
@ -221,6 +220,17 @@ void export_journal()
|
|||
.def("__len__", xacts_len)
|
||||
.def("__getitem__", xacts_getitem, return_internal_reference<1>())
|
||||
|
||||
.def("__iter__", range<return_internal_reference<> >
|
||||
(&journal_t::xacts_begin, &journal_t::xacts_end))
|
||||
.def("xacts", range<return_internal_reference<> >
|
||||
(&journal_t::xacts_begin, &journal_t::xacts_end))
|
||||
.def("auto_xacts", range<return_internal_reference<> >
|
||||
(&journal_t::auto_xacts_begin, &journal_t::auto_xacts_end))
|
||||
.def("period_xacts", range<return_internal_reference<> >
|
||||
(&journal_t::period_xacts_begin, &journal_t::period_xacts_end))
|
||||
.def("sources", range<return_internal_reference<> >
|
||||
(&journal_t::sources_begin, &journal_t::sources_end))
|
||||
|
||||
.def("valid", &journal_t::valid)
|
||||
;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,9 +88,6 @@ void export_xact()
|
|||
return_value_policy<reference_existing_object>()),
|
||||
make_setter(&xact_base_t::journal,
|
||||
with_custodian_and_ward<1, 2>()))
|
||||
.add_property("posts",
|
||||
make_getter(&xact_base_t::posts),
|
||||
make_setter(&xact_base_t::posts))
|
||||
|
||||
.def("__len__", posts_len)
|
||||
.def("__getitem__", posts_getitem,
|
||||
|
|
@ -100,6 +97,12 @@ void export_xact()
|
|||
.def("remove_post", &xact_base_t::add_post)
|
||||
|
||||
.def("finalize", &xact_base_t::finalize)
|
||||
|
||||
.def("__iter__", range<return_internal_reference<> >
|
||||
(&xact_t::posts_begin, &xact_t::posts_end))
|
||||
.def("posts", range<return_internal_reference<> >
|
||||
(&xact_t::posts_begin, &xact_t::posts_end))
|
||||
|
||||
.def("valid", &xact_base_t::valid)
|
||||
;
|
||||
|
||||
|
|
|
|||
|
|
@ -155,6 +155,7 @@ typedef std::ostream::pos_type ostream_pos_type;
|
|||
#include <boost/iostreams/stream.hpp>
|
||||
#include <boost/iostreams/write.hpp>
|
||||
#include <boost/iostreams/device/file_descriptor.hpp>
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/operators.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
|
|
|||
|
|
@ -77,6 +77,13 @@ public:
|
|||
virtual void add_post(post_t * post);
|
||||
virtual bool remove_post(post_t * post);
|
||||
|
||||
posts_list::iterator posts_begin() {
|
||||
return posts.begin();
|
||||
}
|
||||
posts_list::iterator posts_end() {
|
||||
return posts.end();
|
||||
}
|
||||
|
||||
virtual bool finalize();
|
||||
virtual bool valid() const {
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue