diff options
-rw-r--r-- | amount.cc | 2 | ||||
-rw-r--r-- | commodity.cc | 1 | ||||
-rw-r--r-- | commodity.h | 13 | ||||
-rw-r--r-- | csv.h | 14 | ||||
-rw-r--r-- | emacs.h | 13 | ||||
-rw-r--r-- | error.h | 2 | ||||
-rw-r--r-- | flags.h | 22 | ||||
-rw-r--r-- | format.cc | 2 | ||||
-rw-r--r-- | format.h | 40 | ||||
-rw-r--r-- | journal.cc | 1 | ||||
-rw-r--r-- | journal.h | 89 | ||||
-rw-r--r-- | mask.cc | 2 | ||||
-rw-r--r-- | mask.h | 11 | ||||
-rw-r--r-- | ofx.h | 2 | ||||
-rw-r--r-- | parser.h | 16 | ||||
-rw-r--r-- | parsexp.h | 8 | ||||
-rw-r--r-- | pushvar.h | 19 | ||||
-rw-r--r-- | pyfstream.h | 66 | ||||
-rw-r--r-- | pyinterp.cc | 16 | ||||
-rw-r--r-- | pyinterp.h | 44 | ||||
-rw-r--r-- | quotes.h | 16 | ||||
-rw-r--r-- | reconcile.h | 12 | ||||
-rw-r--r-- | report.cc | 5 | ||||
-rw-r--r-- | report.h | 8 | ||||
-rw-r--r-- | session.cc | 2 | ||||
-rw-r--r-- | session.h | 2 | ||||
-rw-r--r-- | textual.cc | 46 | ||||
-rw-r--r-- | textual.h | 3 | ||||
-rw-r--r-- | times.h | 16 | ||||
-rw-r--r-- | utils.cc | 13 | ||||
-rw-r--r-- | utils.h | 10 | ||||
-rw-r--r-- | valexpr.cc | 2 | ||||
-rw-r--r-- | valexpr.h | 132 | ||||
-rw-r--r-- | value.h | 2 | ||||
-rw-r--r-- | walk.cc | 5 | ||||
-rw-r--r-- | walk.h | 339 | ||||
-rw-r--r-- | xml.h | 9 |
37 files changed, 725 insertions, 280 deletions
@@ -87,7 +87,7 @@ struct amount_t::bigint_t : public supports_flags<> mpz_init_set(val, _val); } bigint_t(const bigint_t& other) - : supports_flags<>(other.flags() & BIGINT_KEEP_PREC), + : supports_flags<>(other.flags() & ~BIGINT_BULK_ALLOC), prec(other.prec), ref(1), index(0) { TRACE_CTOR(bigint_t, "copy"); mpz_init_set(val, other.val); diff --git a/commodity.cc b/commodity.cc index 37c4fab9..38b93a94 100644 --- a/commodity.cc +++ b/commodity.cc @@ -478,6 +478,7 @@ bool compare_amount_commodities::operator()(const amount_t * left, commodity_pool_t::commodity_pool_t() : default_commodity(NULL) { + TRACE_CTOR(commodity_pool_t, ""); null_commodity = create(""); null_commodity->add_flags(COMMODITY_STYLE_NOMARKET | COMMODITY_STYLE_BUILTIN); diff --git a/commodity.h b/commodity.h index 7bac7c18..ab3a908b 100644 --- a/commodity.h +++ b/commodity.h @@ -231,7 +231,17 @@ struct annotation_t : public equality_comparable<annotation_t> (const optional<amount_t>& _price = none, const optional<datetime_t>& _date = none, const optional<string>& _tag = none) - : price(_price), date(_date), tag(_tag) {} + : price(_price), date(_date), tag(_tag) { + TRACE_CTOR(annotation_t, "const optional<amount_t>& + datetime_t + string"); + } + annotation_t(const annotation_t& other) + : price(other.price), date(other.date), tag(other.tag) { + TRACE_CTOR(annotation_t, "copy"); + } + + ~annotation_t() { + TRACE_DTOR(annotation_t); + } operator bool() const { return price || date || tag; @@ -378,6 +388,7 @@ public: explicit commodity_pool_t(); ~commodity_pool_t() { + TRACE_DTOR(commodity_pool_t); commodities_by_ident& ident_index = commodities.get<0>(); for (commodities_by_ident::iterator i = ident_index.begin(); i != ident_index.end(); @@ -8,11 +8,19 @@ namespace ledger { class format_csv_transactions : public item_handler<transaction_t> { - protected: + format_csv_transactions(); + +protected: std::ostream& out; - public: - format_csv_transactions(std::ostream& _out) : out(_out) {} +public: + format_csv_transactions(std::ostream& _out) : out(_out) { + TRACE_CTOR(format_csv_transactions, "std::ostream&"); + } + ~format_csv_transactions() { + TRACE_DTOR(format_csv_transactions); + } + virtual void flush() { out.flush(); } @@ -8,13 +8,20 @@ namespace ledger { class format_emacs_transactions : public item_handler<transaction_t> { - protected: + format_emacs_transactions(); + +protected: std::ostream& out; entry_t * last_entry; - public: +public: format_emacs_transactions(std::ostream& _out) - : out(_out), last_entry(NULL) {} + : out(_out), last_entry(NULL) { + TRACE_CTOR(format_emacs_transactions, "std::ostream&"); + } + ~format_emacs_transactions() { + TRACE_DTOR(format_emacs_transactions); + } virtual void write_entry(entry_t& entry); virtual void flush() { @@ -12,7 +12,7 @@ namespace ledger { class error_context { - public: +public: string desc; error_context(const string& _desc) throw() : desc(_desc) {} @@ -42,8 +42,15 @@ protected: flags_t flags_; public: - supports_flags() : flags_(0) {} - supports_flags(const flags_t arg) : flags_(arg) {} + supports_flags() : flags_(0) { + TRACE_CTOR(supports_flags, ""); + } + supports_flags(const flags_t& arg) : flags_(arg) { + TRACE_CTOR(supports_flags, "copy"); + } + ~supports_flags() throw() { + TRACE_DTOR(supports_flags); + } flags_t flags() const { return flags_; @@ -76,8 +83,15 @@ protected: supports_flags<T>& flags_; public: - delegates_flags() : flags_() {} - delegates_flags(supports_flags<T>& arg) : flags_(arg) {} + delegates_flags() : flags_() { + TRACE_CTOR(delegates_flags, ""); + } + delegates_flags(supports_flags<T>& arg) : flags_(arg) { + TRACE_CTOR(delegates_flags, "const supports_flags<T>&"); + } + ~delegates_flags() throw() { + TRACE_DTOR(delegates_flags); + } flags_t flags() const { return flags_.flags(); @@ -757,6 +757,8 @@ format_transactions::format_transactions(std::ostream& _output_stream, const string& format) : output_stream(_output_stream), last_entry(NULL), last_xact(NULL) { + TRACE_CTOR(format_transactions, "std::ostream&, const string&"); + const char * f = format.c_str(); if (const char * p = std::strstr(f, "%/")) { first_line_format.reset(string(f, 0, p - f)); @@ -16,7 +16,7 @@ string partial_account_name(const account_t& account, #define ELEMENT_ALIGN_LEFT 0x01 #define ELEMENT_HIGHLIGHT 0x02 -struct element_t +struct element_t : public noncopyable { enum kind_t { STRING, @@ -59,16 +59,16 @@ struct element_t element_t() : type(STRING), flags(false), min_width(0), max_width(0), next(NULL) { - DEBUG("ledger.memory.ctors", "ctor element_t"); + TRACE_CTOR(element_t, ""); } ~element_t() { - DEBUG("ledger.memory.dtors", "dtor element_t"); + TRACE_DTOR(element_t); if (next) delete next; // recursive, but not too deep } }; -struct format_t +struct format_t : public noncopyable { string format_string; element_t * elements; @@ -87,14 +87,14 @@ struct format_t static bool ansi_invert; format_t() : elements(NULL) { - DEBUG("ledger.memory.ctors", "ctor format_t"); + TRACE_CTOR(format_t, ""); } format_t(const string& _format) : elements(NULL) { - DEBUG("ledger.memory.ctors", "ctor format_t"); + TRACE_CTOR(format_t, "const string&"); reset(_format); } ~format_t() { - DEBUG("ledger.memory.dtors", "dtor format_t"); + TRACE_DTOR(format_t); if (elements) delete elements; } @@ -115,16 +115,19 @@ struct format_t class format_transactions : public item_handler<transaction_t> { - protected: +protected: std::ostream& output_stream; format_t first_line_format; format_t next_lines_format; entry_t * last_entry; transaction_t * last_xact; - public: +public: format_transactions(std::ostream& _output_stream, const string& format); + ~format_transactions() throw() { + TRACE_DTOR(format_transactions); + } virtual void flush() { output_stream.flush(); @@ -136,7 +139,12 @@ class format_entries : public format_transactions { public: format_entries(std::ostream& output_stream, const string& format) - : format_transactions(output_stream, format) {} + : format_transactions(output_stream, format) { + TRACE_CTOR(format_entries, "std::ostream&, const string&"); + } + ~format_entries() throw() { + TRACE_DTOR(format_entries); + } virtual void format_last_entry(); @@ -174,11 +182,16 @@ class format_account : public item_handler<account_t> public: format_t format; - format_account(std::ostream& _output_stream, + format_account(std::ostream& _output_stream, const string& _format, const string& display_predicate = NULL) : output_stream(_output_stream), disp_pred(display_predicate), - format(_format) {} + format(_format) { + TRACE_CTOR(format_account, "std::ostream&, const string&, const string&"); + } + ~format_account() throw() { + TRACE_DTOR(format_account); + } virtual void flush() { output_stream.flush(); @@ -206,7 +219,8 @@ class format_equity : public item_handler<account_t> virtual void operator()(account_t& account); }; -class format_error : public error { +class format_error : public error +{ public: format_error(const string& reason, error_context * ctxt = NULL) throw() : error(reason, ctxt) {} @@ -375,6 +375,7 @@ entry_t::entry_t(const entry_t& e) code(e.code), payee(e.payee) { TRACE_CTOR(entry_t, "copy"); + for (transactions_list::const_iterator i = transactions.begin(); i != transactions.end(); i++) @@ -75,23 +75,23 @@ class transaction_t : public supports_flags<> static bool use_effective_date; transaction_t(account_t * _account = NULL, - unsigned int _flags = TRANSACTION_NORMAL) + flags_t _flags = TRANSACTION_NORMAL) : supports_flags<>(_flags), entry(NULL), state(UNCLEARED), account(_account), beg_pos(0), beg_line(0), end_pos(0), end_line(0), data(NULL) { - TRACE_CTOR(transaction_t, "account_t *"); + TRACE_CTOR(transaction_t, "account_t *, flags_t"); } - transaction_t(account_t * _account, - const amount_t& _amount, - unsigned int _flags = TRANSACTION_NORMAL, - const optional<string> _note = none) + transaction_t(account_t * _account, + const amount_t& _amount, + flags_t _flags = TRANSACTION_NORMAL, + const optional<string>& _note = none) : supports_flags<>(_flags), entry(NULL), state(UNCLEARED), account(_account), amount(_amount), note(_note), beg_pos(0), beg_line(0), end_pos(0), end_line(0), data(NULL) { TRACE_CTOR(transaction_t, - "account_t *, const amount_t&, unsigned int, const string&"); + "account_t *, const amount_t&, flags_t, const string&"); } transaction_t(const transaction_t& xact) : supports_flags<>(xact), @@ -168,8 +168,10 @@ class entry_base_t i++) transactions.push_back(new transaction_t(**i)); } + virtual ~entry_base_t() { TRACE_DTOR(entry_base_t); + for (transactions_list::iterator i = transactions.begin(); i != transactions.end(); i++) @@ -250,8 +252,7 @@ class entry_context : public error_context { }; -template <typename T> -class item_predicate; +template <typename T> class item_predicate; class auto_entry_t : public entry_base_t { @@ -261,6 +262,10 @@ public: auto_entry_t() { TRACE_CTOR(auto_entry_t, ""); } + auto_entry_t(const auto_entry_t& other) + : predicate(other.predicate) { + TRACE_CTOR(auto_entry_t, "copy"); + } auto_entry_t(const string& _predicate) : predicate(_predicate) { @@ -277,9 +282,24 @@ public: } }; -struct auto_entry_finalizer_t : public entry_finalizer_t { +struct auto_entry_finalizer_t : public entry_finalizer_t +{ journal_t * journal; - auto_entry_finalizer_t(journal_t * _journal) : journal(_journal) {} + + auto_entry_finalizer_t() : journal(NULL) { + TRACE_CTOR(auto_entry_finalizer_t, ""); + } + auto_entry_finalizer_t(const auto_entry_finalizer_t& other) + : journal(other.journal) { + TRACE_CTOR(auto_entry_finalizer_t, "copy"); + } + auto_entry_finalizer_t(journal_t * _journal) : journal(_journal) { + TRACE_CTOR(auto_entry_finalizer_t, "journal_t *"); + } + ~auto_entry_finalizer_t() throw() { + TRACE_DTOR(auto_entry_finalizer_t); + } + virtual bool operator()(entry_t& entry, bool post); }; @@ -293,16 +313,16 @@ class period_entry_t : public entry_base_t period_entry_t() { TRACE_CTOR(period_entry_t, ""); } - period_entry_t(const string& _period) - : period(_period), period_string(_period) { - TRACE_CTOR(period_entry_t, "const string&"); - } period_entry_t(const period_entry_t& e) : entry_base_t(e), period(e.period), period_string(e.period_string) { TRACE_CTOR(period_entry_t, "copy"); } + period_entry_t(const string& _period) + : period(_period), period_string(_period) { + TRACE_CTOR(period_entry_t, "const string&"); + } - virtual ~period_entry_t() { + virtual ~period_entry_t() throw() { TRACE_DTOR(period_entry_t); } @@ -337,6 +357,19 @@ class account_t depth(parent ? parent->depth + 1 : 0), data(NULL), ident(0) { TRACE_CTOR(account_t, "account_t *, const string&, const string&"); } + account_t(const account_t& other) + : journal(other.journal), + parent(other.parent), + name(other.name), + note(other.note), + depth(other.depth), + accounts(other.accounts), + data(NULL), + ident(0) { + TRACE_CTOR(account_t, "copy"); + assert(other.data == NULL); + assert(other.ident == 0); + } ~account_t(); operator string() const { @@ -364,12 +397,26 @@ class account_t std::ostream& operator<<(std::ostream& out, const account_t& account); -struct func_finalizer_t : public entry_finalizer_t { - typedef bool (*func_t)(entry_t& entry, bool post); +class func_finalizer_t : public entry_finalizer_t +{ + func_finalizer_t(); + +public: + typedef function<bool (entry_t& entry, bool post)> func_t; + func_t func; - func_finalizer_t(func_t _func) : func(_func) {} + + func_finalizer_t(func_t _func) : func(_func) { + TRACE_CTOR(func_finalizer_t, "func_t"); + } func_finalizer_t(const func_finalizer_t& other) : - entry_finalizer_t(), func(other.func) {} + entry_finalizer_t(), func(other.func) { + TRACE_CTOR(func_finalizer_t, "copy"); + } + ~func_finalizer_t() throw() { + TRACE_DTOR(func_finalizer_t); + } + virtual bool operator()(entry_t& entry, bool post) { return func(entry, post); } @@ -407,7 +454,7 @@ typedef std::list<string> strings_list; class session_t; -class journal_t +class journal_t : public noncopyable { public: session_t * owner; @@ -35,6 +35,8 @@ namespace ledger { mask_t::mask_t(const string& pat) : exclude(false) { + TRACE_CTOR(mask_t, "const string&"); + const char * p = pat.c_str(); if (*p == '-') { @@ -38,12 +38,19 @@ namespace ledger { class mask_t { - public: + mask_t(); + +public: bool exclude; boost::regex expr; explicit mask_t(const string& pattern); - mask_t(const mask_t& m) : exclude(m.exclude), expr(m.expr) {} + mask_t(const mask_t& m) : exclude(m.exclude), expr(m.expr) { + TRACE_CTOR(mask_t, "copy"); + } + ~mask_t() throw() { + TRACE_DTOR(mask_t); + } bool match(const string& str) const { return boost::regex_match(str, expr) && ! exclude; @@ -7,7 +7,7 @@ namespace ledger { class ofx_parser_t : public parser_t { - public: +public: virtual bool test(std::istream& in) const; virtual unsigned int parse(std::istream& in, @@ -9,10 +9,15 @@ class account_t; class journal_t; class session_t; -class parser_t +class parser_t : public noncopyable { - public: - virtual ~parser_t() {} +public: + parser_t() { + TRACE_CTOR(parser_t, ""); + } + virtual ~parser_t() { + TRACE_DTOR(parser_t); + } virtual bool test(std::istream& in) const = 0; @@ -41,8 +46,9 @@ unsigned int parse_ledger_data(session_t& session, parser_t * xml_parser = NULL, parser_t * stdin_parser = NULL); -class parse_error : public error { - public: +class parse_error : public error +{ +public: parse_error(const string& reason, error_context * ctxt = NULL) throw() : error(reason, ctxt) {} virtual ~parse_error() throw() {} @@ -39,7 +39,7 @@ namespace expr { DECLARE_EXCEPTION(error, parse_error); -class parser_t +class parser_t : public noncopyable { #define EXPR_PARSE_NORMAL 0x00 #define EXPR_PARSE_PARTIAL 0x01 @@ -52,7 +52,7 @@ public: typedef uint_least8_t flags_t; private: - struct token_t + struct token_t : public noncopyable { enum kind_t { VALUE, // any kind of literal value @@ -112,12 +112,14 @@ private: explicit token_t() : kind(UNKNOWN), length(0) { TRACE_CTOR(token_t, ""); } +#if 0 token_t(const token_t& other) { assert(false); TRACE_CTOR(token_t, "copy"); *this = other; } - ~token_t() { +#endif + ~token_t() throw() { TRACE_DTOR(token_t); } @@ -43,22 +43,35 @@ template <typename T> class push_variable : public boost::noncopyable { + push_variable(); + +public: T& var; T prev; bool enabled; -public: explicit push_variable(T& _var) - : var(_var), prev(var), enabled(true) {} + : var(_var), prev(var), enabled(true) { + TRACE_CTOR(push_variable, "T&"); + } explicit push_variable(T& _var, const T& value) : var(_var), prev(var), enabled(true) { + TRACE_CTOR(push_variable, "T&, constT&"); var = value; } - ~push_variable() { + ~push_variable() throw() { + TRACE_DTOR(push_variable); if (enabled) var = prev; } + T& operator*() { + return var; + } + T * operator->() { + return &var; + } + void clear() { enabled = false; } diff --git a/pyfstream.h b/pyfstream.h index f4650e0a..1a25d642 100644 --- a/pyfstream.h +++ b/pyfstream.h @@ -35,14 +35,23 @@ // pyofstream // - a stream that writes on a Python file object -class pyoutbuf : public std::streambuf { - protected: +class pyoutbuf : public boost::noncopyable, public std::streambuf +{ + pyoutbf(); + +protected: PyFileObject * fo; // Python file object - public: + +public: // constructor - pyoutbuf (PyFileObject * _fo) : fo(_fo) {} + pyoutbuf(PyFileObject * _fo) : fo(_fo) { + TRACE_CTOR(pyoutbuf, "PyFileObject *"); + } + ~pyoutbuf() : throw() { + TRACE_DTOR(pyoutbuf); + } - protected: +protected: // write one character virtual int_type overflow (int_type c) { if (c != EOF) { @@ -68,22 +77,34 @@ class pyoutbuf : public std::streambuf { } }; -class pyofstream : public std::ostream { - protected: +class pyofstream : public noncopyable, public std::ostream +{ + pyofstream(); + +protected: pyoutbuf buf; - public: + +public: pyofstream (PyFileObject * fo) : std::ostream(0), buf(fo) { + TRACE_CTOR(pyofstream, "PyFileObject *"); rdbuf(&buf); } + ~pyofstream() throw() { + TRACE_DTOR(pyofstream); + } }; // pyifstream // - a stream that reads on a file descriptor -class pyinbuf : public std::streambuf { - protected: +class pyinbuf : public noncopyable, public std::streambuf +{ + pyinbuf(); + +protected: PyFileObject * fo; // Python file object - protected: + +protected: /* data buffer: * - at most, pbSize characters in putback area plus * - at most, bufSize characters in ordinary read buffer @@ -92,7 +113,7 @@ class pyinbuf : public std::streambuf { static const int bufSize = 1024; // size of the data buffer char buffer[bufSize + pbSize]; // data buffer - public: +public: /* constructor * - initialize file descriptor * - initialize empty data buffer @@ -100,12 +121,17 @@ class pyinbuf : public std::streambuf { * => force underflow() */ pyinbuf (PyFileObject * _fo) : fo(_fo) { + TRACE_CTOR(pyinbuf, "PyFileObject *"); + setg (buffer+pbSize, // beginning of putback area buffer+pbSize, // read position buffer+pbSize); // end position } + ~pyinbuf() throw() { + TRACE_DTOR(pyinbuf); + } - protected: +protected: // insert new characters into the buffer virtual int_type underflow () { #ifndef _MSC_VER @@ -157,13 +183,21 @@ class pyinbuf : public std::streambuf { } }; -class pyifstream : public std::istream { - protected: +class pyifstream : public noncopyable, public std::istream +{ + pyifstream(); + +protected: pyinbuf buf; - public: + +public: pyifstream (PyFileObject * fo) : std::istream(0), buf(fo) { + TRACE_CTOR(pyifstream, "PyFileObject *"); rdbuf(&buf); } + ~pyifstream() throw() { + TRACE_DTOR(pyifstream); + } }; #endif // _PYFSTREAM_H diff --git a/pyinterp.cc b/pyinterp.cc index d521a0ee..43e3b0b0 100644 --- a/pyinterp.cc +++ b/pyinterp.cc @@ -86,11 +86,13 @@ struct python_run } }; -python_interpreter_t::python_interpreter_t(xml::xpath_t::scope_t& parent) - : xml::xpath_t::symbol_scope_t(parent), +python_interpreter_t::python_interpreter_t(expr::scope_t& parent) + : expr::symbol_scope_t(parent), mmodule(borrowed(PyImport_AddModule("__main__"))), nspace(handle<>(borrowed(PyModule_GetDict(mmodule.get())))) { + TRACE_CTOR(python_interpreter_t, "expr::scope_t&"); + Py_Initialize(); boost::python::detail::init_module("ledger", &initialize_for_python); } @@ -177,7 +179,7 @@ object python_interpreter_t::eval(const string& str, py_eval_mode_t mode) } value_t python_interpreter_t::functor_t::operator() - (xml::xpath_t::call_scope_t& args) + (expr::call_scope_t& args) { try { if (! PyCallable_Check(func.ptr())) { @@ -200,7 +202,7 @@ value_t python_interpreter_t::functor_t::operator() } else if (PyObject * err = PyErr_Occurred()) { PyErr_Print(); - throw_(xml::xpath_t::calc_error, + throw_(expr::calc_error, "While calling Python function '" /*<< name() <<*/ "': " << err); } else { assert(false); @@ -212,14 +214,14 @@ value_t python_interpreter_t::functor_t::operator() } catch (const error_already_set&) { PyErr_Print(); - throw_(xml::xpath_t::calc_error, + throw_(expr::calc_error, "While calling Python function '" /*<< name() <<*/ "'"); } return NULL_VALUE; } value_t python_interpreter_t::lambda_t::operator() - (xml::xpath_t::call_scope_t& args) + (expr::call_scope_t& args) { try { assert(args.size() == 1); @@ -229,7 +231,7 @@ value_t python_interpreter_t::lambda_t::operator() } catch (const error_already_set&) { PyErr_Print(); - throw_(xml::xpath_t::calc_error, + throw_(expr::calc_error, "While evaluating Python lambda expression"); } return NULL_VALUE; @@ -39,16 +39,21 @@ namespace ledger { -class python_interpreter_t : public xml::xpath_t::symbol_scope_t +class python_interpreter_t + : public noncopyable, public expr::symbol_scope_t { boost::python::handle<> mmodule; - public: + python_interpreter_t(); + +public: boost::python::dict nspace; - python_interpreter_t(xml::xpath_t::scope_t& parent); + python_interpreter_t(expr::scope_t& parent); virtual ~python_interpreter_t() { + TRACE_DTOR(python_interpreter_t); + Py_Finalize(); } @@ -71,25 +76,42 @@ class python_interpreter_t : public xml::xpath_t::symbol_scope_t } class functor_t { + functor_t(); protected: boost::python::object func; public: - functor_t(const string& name, boost::python::object _func) : func(_func) {} - virtual ~functor_t() {} - virtual value_t operator()(xml::xpath_t::call_scope_t& args); + functor_t(const string& name, boost::python::object _func) : func(_func) { + TRACE_CTOR(functor_t, "const string&, boost::python::object"); + } + functor_t(const functor_t& other) : func(other.func) { + TRACE_CTOR(functor_t, "copy"); + } + virtual ~functor_t() throw() { + TRACE_DTOR(functor_t); + } + virtual value_t operator()(expr::call_scope_t& args); }; - virtual xml::xpath_t::ptr_op_t lookup(const string& name) { + virtual expr::ptr_op_t lookup(const string& name) { if (boost::python::object func = eval(name)) return WRAP_FUNCTOR(functor_t(name, func)); else - return xml::xpath_t::symbol_scope_t::lookup(name); + return expr::symbol_scope_t::lookup(name); } class lambda_t : public functor_t { - public: - lambda_t(boost::python::object code) : functor_t("<lambda>", code) {} - virtual value_t operator()(xml::xpath_t::call_scope_t& args); + lambda_t(); + public: + lambda_t(boost::python::object code) : functor_t("<lambda>", code) { + TRACE_CTOR(functor_t, "boost::python::object"); + } + lambda_t(const lambda_t& other) : functor_t(other) { + TRACE_CTOR(lambda_t, "copy"); + } + virtual ~lambda_t() throw() { + TRACE_DTOR(lambda_t); + } + virtual value_t operator()(expr::call_scope_t& args); }; }; @@ -5,18 +5,26 @@ namespace ledger { -class quotes_by_script : public commodity_t::base_t::updater_t +class quotes_by_script + : public noncopyable, commodity_t::base_t::updater_t { - string price_db; + string price_db; unsigned long pricing_leeway; bool& cache_dirty; - public: + quotes_by_script(); + +public: quotes_by_script(path _price_db, unsigned long _pricing_leeway, bool& _cache_dirty) : price_db(_price_db), pricing_leeway(_pricing_leeway), - cache_dirty(_cache_dirty) {} + cache_dirty(_cache_dirty) { + TRACE_CTOR(quotes_by_script, "path, unsigned long, bool&"); + } + ~quotes_by_script() throw() { + TRACE_DTOR(quotes_by_script); + } virtual void operator()(commodity_base_t& commodity, const datetime_t& moment, diff --git a/reconcile.h b/reconcile.h index 7fd0d581..31bec511 100644 --- a/reconcile.h +++ b/reconcile.h @@ -13,12 +13,20 @@ class reconcile_transactions : public item_handler<transaction_t> transactions_list xacts; - public: + reconcile_transactions(); + +public: reconcile_transactions(item_handler<transaction_t> * handler, const value_t& _balance, const datetime_t& _cutoff) : item_handler<transaction_t>(handler), - balance(_balance), cutoff(_cutoff) {} + balance(_balance), cutoff(_cutoff) { + TRACE_CTOR(reconcile_transactions, + "item_handler<transaction_t> *, const value_t&, const datetime_t&"); + } + virtual ~reconcile_transactions() throw() { + TRACE_DTOR(reconcile_transactions); + } void push_to_handler(transaction_t * first); @@ -33,11 +33,6 @@ namespace ledger { -report_t::~report_t() -{ - TRACE_DTOR(report_t); -} - void report_t::apply_transforms(expr::scope_t& scope) { #if 0 @@ -36,10 +36,10 @@ namespace ledger { -typedef std::list<string> strings_list; - class report_t : public expr::symbol_scope_t { + report_t(); + public: optional<path> output_file; string format_string; @@ -78,7 +78,9 @@ public: #endif } - virtual ~report_t(); + virtual ~report_t() throw() { + TRACE_DTOR(report_t); + } void apply_transforms(expr::scope_t& scope); @@ -118,7 +118,7 @@ session_t::session_t() ansi_codes(false), ansi_invert(false) { - TRACE_CTOR(session_t, "expr::scope_t&"); + TRACE_CTOR(session_t, ""); } std::size_t session_t::read_journal(journal_t& journal, @@ -80,7 +80,7 @@ class session_t : public expr::symbol_scope_t ptr_list<parser_t> parsers; session_t(); - virtual ~session_t() { + virtual ~session_t() throw() { TRACE_DTOR(session_t); } @@ -23,20 +23,29 @@ static accounts_map account_aliases; static std::list<std::pair<path, int> > include_stack; #ifdef TIMELOG_SUPPORT -struct time_entry_t { +struct time_entry_t +{ datetime_t checkin; account_t * account; string desc; - time_entry_t() : account(NULL) {} - time_entry_t(datetime_t _checkin, - account_t * _account = NULL, - std::string _desc = "") - : checkin(_checkin), account(_account), desc(_desc) {} - + time_entry_t() : account(NULL) { + TRACE_CTOR(time_entry_t, ""); + } + time_entry_t(const datetime_t& _checkin, + account_t * _account = NULL, + const string& _desc = "") + : checkin(_checkin), account(_account), desc(_desc) { + TRACE_CTOR(time_entry_t, "const datetime_t&, account_t *, const string&"); + } time_entry_t(const time_entry_t& entry) : checkin(entry.checkin), account(entry.account), - desc(entry.desc) {} + desc(entry.desc) { + TRACE_CTOR(time_entry_t, "copy"); + } + ~time_entry_t() throw() { + TRACE_DTOR(time_entry_t); + } }; #endif @@ -457,14 +466,6 @@ entry_t * parse_entry(std::istream& in, char * line, account_t * master, return curr.release(); } -template <typename T> -struct push_var { - T& var; - T prev; - push_var(T& _var) : var(_var), prev(var) {} - ~push_var() { var = prev; } -}; - static inline void parse_symbol(char *& p, string& symbol) { if (*p == '"') { @@ -803,13 +804,12 @@ unsigned int textual_parser_t::parse(std::istream& in, char * p = next_element(line); string word(line + 1); if (word == "include") { - push_var<path> save_pathname(pathname); - push_var<unsigned int> save_src_idx(src_idx); - push_var<unsigned long> save_beg_pos(beg_pos); - push_var<unsigned long> save_end_pos(end_pos); - push_var<unsigned int> save_linenum(linenum); + push_variable<path> save_pathname(pathname); + push_variable<unsigned int> save_src_idx(src_idx); + push_variable<unsigned long> save_beg_pos(beg_pos); + push_variable<unsigned long> save_end_pos(end_pos); + push_variable<unsigned int> save_linenum(linenum); - // jww (2008-04-22): Fix this! pathname = p; #if 0 if (pathname[0] != '/' && pathname[0] != '\\' && pathname[0] != '~') { @@ -820,12 +820,10 @@ unsigned int textual_parser_t::parse(std::istream& in, pathname = string(save_pathname.prev, 0, pos + 1) + pathname; } pathname = resolve_path(pathname); -#endif DEBUG("ledger.textual.include", "line " << linenum << ": " << "Including path '" << pathname << "'"); -#if 0 include_stack.push_back(std::pair<path, int> (journal.sources.back(), linenum - 1)); count += parse_journal_file(pathname, config, journal, @@ -27,7 +27,8 @@ void write_textual_journal(journal_t& journal, path pathname, const string& write_hdr_format, std::ostream& out); -class include_context : public file_context { +class include_context : public file_context +{ public: include_context(const path& file, unsigned long line, const string& desc = "") throw() @@ -86,6 +86,20 @@ struct interval_t TRACE_CTOR(interval_t, "int, int, int, const datetime_t&, const datetime_t&"); } + interval_t(const interval_t& other) + : years(other.years), + months(other.months), + days(other.days), + hours(other.hours), + minutes(other.minutes), + seconds(other.seconds), + + begin(other.begin), + end(other.end), + + advanced(other.advanced) { + TRACE_CTOR(interval_t, "copy"); + } interval_t(const string& desc) : years(0), months(0), days(0), @@ -149,7 +163,7 @@ extern bool day_before_month; #if 0 struct intorchar { - int ival; + int ival; string sval; intorchar() : ival(-1) {} @@ -306,7 +306,11 @@ void trace_dtor_func(void * ptr, const char * cls_name, std::size_t cls_size) DEBUG("memory.debug", "TRACE_DTOR " << ptr << " " << cls_name); live_objects_map::iterator i = live_objects->find(ptr); - VERIFY(i != live_objects->end()); + if (i == live_objects->end()) { + std::cerr << "Attempting to delete " << ptr << " a non-living " << cls_name + << std::endl; + assert(false); + } int ptr_count = live_objects->count(ptr); for (int x = 0; x < ptr_count; x++, i++) { @@ -389,7 +393,7 @@ string::string() : std::string() { TRACE_CTOR(string, ""); } string::string(const string& str) : std::string(str) { - TRACE_CTOR(string, "const string&"); + TRACE_CTOR(string, "copy"); } string::string(const std::string& str) : std::string(str) { TRACE_CTOR(string, "const std::string&"); @@ -415,7 +419,7 @@ string::string(const char * str, int x) : std::string(str, x) { string::string(const char * str, int x, int y) : std::string(str, x, y) { TRACE_CTOR(string, "const char *, int, int"); } -string::~string() { +string::~string() throw() { TRACE_DTOR(string); } @@ -541,7 +545,8 @@ optional<std::string> _log_category; namespace ledger { -struct timer_t { +struct timer_t +{ log_level_t level; ptime begin; time_duration spent; @@ -95,6 +95,8 @@ namespace ledger { typedef std::string string; #endif + typedef std::list<string> strings_list; + typedef posix_time::ptime ptime; typedef ptime::time_duration_type time_duration; typedef gregorian::date date; @@ -161,9 +163,11 @@ void trace_ctor_func(void * ptr, const char * cls_name, const char * args, void trace_dtor_func(void * ptr, const char * cls_name, std::size_t cls_size); #define TRACE_CTOR(cls, args) \ - (DO_VERIFY() ? trace_ctor_func(this, #cls, args, sizeof(cls)) : ((void)0)) + (DO_VERIFY() ? \ + ledger::trace_ctor_func(this, #cls, args, sizeof(cls)) : ((void)0)) #define TRACE_DTOR(cls) \ - (DO_VERIFY() ? trace_dtor_func(this, #cls, sizeof(cls)) : ((void)0)) + (DO_VERIFY() ? \ + ledger::trace_dtor_func(this, #cls, sizeof(cls)) : ((void)0)) void report_memory(std::ostream& out, bool report_all = false); @@ -184,7 +188,7 @@ public: string(const string& str, int x, int y); string(const char * str, int x); string(const char * str, int x, int y); - ~string(); + ~string() throw(); }; inline string operator+(const string& __lhs, const string& __rhs) @@ -47,7 +47,7 @@ datetime_t terminus; details_t::details_t(const transaction_t& _xact) : entry(_xact.entry), xact(&_xact), account(xact_account(_xact)) { - DEBUG("ledger.memory.ctors", "ctor details_t"); + TRACE_CTOR(details_t, "const transaction_t&"); } bool compute_amount(ptr_op_t expr, amount_t& amt, @@ -101,21 +101,27 @@ struct details_t const transaction_t * xact; const account_t * account; - details_t() : entry(NULL), xact(NULL), account(NULL) {} + details_t() : entry(NULL), xact(NULL), account(NULL) { + TRACE_CTOR(details_t, ""); + } + details_t(const details_t& other) + : entry(other.entry), + xact(other.xact), + account(other.account) { + TRACE_CTOR(details_t, "copy"); + } details_t(const entry_t& _entry) : entry(&_entry), xact(NULL), account(NULL) { - DEBUG("ledger.memory.ctors", "ctor details_t"); + TRACE_CTOR(details_t, "const entry_t&"); } details_t(const transaction_t& _xact); details_t(const account_t& _account) : entry(NULL), xact(NULL), account(&_account) { - DEBUG("ledger.memory.ctors", "ctor details_t"); + TRACE_CTOR(details_t, "const account_t&"); } -#ifdef DEBUG_ENABLED - ~details_t() { - DEBUG("ledger.memory.dtors", "dtor details_t"); + ~details_t() throw() { + TRACE_DTOR(details_t); } -#endif }; struct op_t; @@ -130,6 +136,8 @@ typedef function<value_t (call_scope_t&)> function_t; class scope_t : public noncopyable { + scope_t(); + public: enum type_t { CHILD_SCOPE, @@ -139,10 +147,10 @@ public: } type_; explicit scope_t(type_t _type) : type_(_type) { - TRACE_CTOR(expr::scope_t, "type_t"); + TRACE_CTOR(scope_t, "type_t"); } - virtual ~scope_t() { - TRACE_DTOR(expr::scope_t); + virtual ~scope_t() throw() { + TRACE_DTOR(scope_t); } const type_t type() const { @@ -174,17 +182,19 @@ class child_scope_t : public scope_t { scope_t * parent; + child_scope_t(); + public: explicit child_scope_t(type_t _type = CHILD_SCOPE) : scope_t(_type), parent(NULL) { - TRACE_CTOR(expr::child_scope_t, "type_t"); + TRACE_CTOR(child_scope_t, "type_t"); } explicit child_scope_t(scope_t& _parent, type_t _type = CHILD_SCOPE) : scope_t(_type), parent(&_parent) { - TRACE_CTOR(expr::child_scope_t, "scope_t&, type_t"); + TRACE_CTOR(child_scope_t, "scope_t&, type_t"); } - virtual ~child_scope_t() { - TRACE_DTOR(expr::child_scope_t); + virtual ~child_scope_t() throw() { + TRACE_DTOR(child_scope_t); } public: virtual void define(const string& name, ptr_op_t def) { @@ -229,14 +239,14 @@ class symbol_scope_t : public child_scope_t public: explicit symbol_scope_t() : child_scope_t(SYMBOL_SCOPE) { - TRACE_CTOR(expr::symbol_scope_t, ""); + TRACE_CTOR(symbol_scope_t, ""); } explicit symbol_scope_t(scope_t& _parent) : child_scope_t(_parent, SYMBOL_SCOPE) { - TRACE_CTOR(expr::symbol_scope_t, "scope_t&"); + TRACE_CTOR(symbol_scope_t, "scope_t&"); } - virtual ~symbol_scope_t() { - TRACE_DTOR(expr::symbol_scope_t); + virtual ~symbol_scope_t() throw() { + TRACE_DTOR(symbol_scope_t); } virtual void define(const string& name, ptr_op_t def); @@ -250,13 +260,15 @@ class call_scope_t : public child_scope_t { value_t args; + call_scope_t(); + public: explicit call_scope_t(scope_t& _parent) : child_scope_t(_parent, CALL_SCOPE) { - TRACE_CTOR(expr::call_scope_t, "scope_t&"); + TRACE_CTOR(call_scope_t, "scope_t&"); } - virtual ~call_scope_t() { - TRACE_DTOR(expr::call_scope_t); + virtual ~call_scope_t() throw() { + TRACE_DTOR(call_scope_t); } void set_args(const value_t& _args) { @@ -289,20 +301,31 @@ public: }; template <typename T> -struct var_t +class var_t : public noncopyable { T * value; + var_t(); + +public: // jww (2008-07-21): Give a good exception here if we can't find "name" var_t(scope_t& scope, const string& name) - : value(scope.resolve(name).template as_pointer<T>()) {} + : value(scope.resolve(name).template as_pointer<T>()) { + TRACE_CTOR(var_t, "scope_t&, const string&"); + } var_t(call_scope_t& scope, const unsigned int idx) - : value(scope[idx].template as_pointer<T>()) {} + : value(scope[idx].template as_pointer<T>()) { + TRACE_CTOR(var_t, "call_scope_t&, const unsigned int"); + } + ~var_t() throw() { + TRACE_DTOR(var_t); + } T& operator *() { return *value; } T * operator->() { return value; } }; +#if 0 class context_scope_t : public child_scope_t { public: @@ -334,9 +357,13 @@ public: return current_element; } }; +#endif -struct op_t : public noncopyable +class op_t : public noncopyable { + op_t(); + +public: enum kind_t { // Constants VALUE, @@ -441,12 +468,10 @@ struct op_t : public noncopyable data; explicit op_t(const kind_t _kind) : kind(_kind), refc(0){ - TRACE_CTOR(expr::op_t, "const kind_t"); + TRACE_CTOR(op_t, "const kind_t"); } ~op_t() { - TRACE_DTOR(expr::op_t); - - DEBUG("ledger.xpath.memory", "Destroying " << this); + TRACE_DTOR(op_t); assert(refc == 0); } @@ -656,18 +681,27 @@ struct op_t : public noncopyable } }; -class op_predicate { +class op_predicate : public noncopyable +{ ptr_op_t op; + op_predicate(); + public: - explicit op_predicate(ptr_op_t _op) : op(_op) {} + explicit op_predicate(ptr_op_t _op) : op(_op) { + TRACE_CTOR(op_predicate, "ptr_op_t"); + } + ~op_predicate() throw() { + TRACE_DTOR(op_predicate); + } bool operator()(scope_t& scope) { return op->calc(scope).to_boolean(); } }; -class valexpr_context : public error_context { - public: +class valexpr_context : public error_context +{ +public: ptr_op_t expr; ptr_op_t error_node; @@ -679,15 +713,17 @@ class valexpr_context : public error_context { virtual void describe(std::ostream& out) const throw(); }; -class compute_error : public error { - public: +class compute_error : public error +{ +public: compute_error(const string& reason, error_context * ctxt = NULL) throw() : error(reason, ctxt) {} virtual ~compute_error() throw() {} }; -class value_expr_error : public error { - public: +class value_expr_error : public error +{ +public: value_expr_error(const string& reason, error_context * ctxt = NULL) throw() : error(reason, ctxt) {} @@ -748,6 +784,7 @@ scope_t::find_scope<call_scope_t>(bool skip_this) { return downcast<call_scope_t>(*scope); } +#if 0 template<> inline context_scope_t& scope_t::find_scope<context_scope_t>(bool skip_this) { @@ -755,6 +792,7 @@ scope_t::find_scope<context_scope_t>(bool skip_this) { assert(scope); return downcast<context_scope_t>(*scope); } +#endif #define FIND_SCOPE(scope_type, scope_ref) \ downcast<scope_t>(scope_ref).find_scope<scope_type>() @@ -763,8 +801,10 @@ scope_t::find_scope<context_scope_t>(bool skip_this) { FIND_SCOPE(call_scope_t, scope_ref) #define SYMBOL_SCOPE(scope_ref) \ FIND_SCOPE(symbol_scope_t, scope_ref) +#if 0 #define CONTEXT_SCOPE(scope_ref) \ FIND_SCOPE(context_scope_t, scope_ref) +#endif inline ptr_op_t op_t::new_node(kind_t _kind, ptr_op_t _left, ptr_op_t _right) { ptr_op_t node(new op_t(_kind)); @@ -798,7 +838,9 @@ public: typedef expr::details_t details_t; - value_expr() {} + value_expr() { + TRACE_CTOR(value_expr, ""); + } value_expr(const string& _expr_str); value_expr(const expr::ptr_op_t _ptr, const string& _expr_str = "") @@ -809,16 +851,16 @@ public: : ptr(other.ptr), expr_str(other.expr_str) { TRACE_CTOR(value_expr, "copy"); } + virtual ~value_expr() throw() { + TRACE_DTOR(value_expr); + } + value_expr& operator=(const value_expr& _expr) { expr_str = _expr.expr_str; reset(_expr.get()); return *this; } - virtual ~value_expr() throw() { - TRACE_DTOR(value_expr); - } - operator bool() const throw() { return ptr.get() != NULL; } @@ -900,14 +942,16 @@ public: item_predicate() { TRACE_CTOR(item_predicate, ""); } + item_predicate(const item_predicate& other) : predicate(other.predicate) { + TRACE_CTOR(item_predicate, "copy"); + } item_predicate(const value_expr& _predicate) : predicate(_predicate) { TRACE_CTOR(item_predicate, "const value_expr&"); } item_predicate(const string& _predicate) : predicate(_predicate) { TRACE_CTOR(item_predicate, "const string&"); } - - ~item_predicate() { + ~item_predicate() throw() { TRACE_DTOR(item_predicate); } @@ -163,7 +163,7 @@ private: */ explicit storage_t(const storage_t& rhs) : type(rhs.type), refc(0) { - TRACE_CTOR(value_t::storage_t, ""); + TRACE_CTOR(value_t::storage_t, "copy"); *this = rhs; } storage_t& operator=(const storage_t& rhs); @@ -424,8 +424,7 @@ void subtotal_transactions::operator()(transaction_t& xact) value_t temp; add_transaction_to(xact, temp); std::pair<values_map::iterator, bool> result - = values.insert(values_pair(acct->fullname(), - acct_value_t(acct, temp))); + = values.insert(values_pair(acct->fullname(), acct_value_t(acct, temp))); assert(result.second); if (remember_components) @@ -507,6 +506,8 @@ void interval_transactions::operator()(transaction_t& xact) by_payee_transactions::~by_payee_transactions() { + TRACE_DTOR(by_payee_transactions); + for (payee_subtotals_map::iterator i = payee_subtotals.begin(); i != payee_subtotals.end(); i++) @@ -12,18 +12,19 @@ namespace ledger { template <typename T> -struct item_handler { +struct item_handler : public noncopyable +{ item_handler * handler; - public: +public: item_handler() : handler(NULL) { - DEBUG("ledger.memory.ctors", "ctor item_handler<T>"); + TRACE_CTOR(item_handler, ""); } item_handler(item_handler * _handler) : handler(_handler) { - DEBUG("ledger.memory.ctors", "ctor item_handler<T>"); + TRACE_CTOR(item_handler, "item_handler *"); } virtual ~item_handler() { - DEBUG("ledger.memory.dtors", "dtor item_handler<T>"); + TRACE_DTOR(item_handler); } virtual void flush() { @@ -37,10 +38,22 @@ struct item_handler { }; template <typename T> -class compare_items { +class compare_items +{ value_expr sort_order; - public: - compare_items(value_expr _sort_order) : sort_order(_sort_order) {} + + compare_items(); + +public: + compare_items(const compare_items& other) : sort_order(other.sort_order) { + TRACE_CTOR(compare_items, "copy"); + } + compare_items(const value_expr& _sort_order) : sort_order(_sort_order) { + TRACE_CTOR(compare_items, "const value_expr&"); + } + ~compare_items() throw() { + TRACE_DTOR(compare_items); + } bool operator()(const T * left, const T * right); }; @@ -79,7 +92,7 @@ bool compare_items<account_t>::operator()(const account_t * left, #define TRANSACTION_COMPOUND 0x0040 #define TRANSACTION_MATCHES 0x0080 -struct transaction_xdata_t +struct transaction_xdata_t : public noncopyable { value_t total; value_t sort_value; @@ -95,13 +108,13 @@ struct transaction_xdata_t transaction_xdata_t() : index(0), dflags(0), account(NULL), ptr(NULL), component_xacts(NULL) { - DEBUG("ledger.memory.ctors", "ctor transaction_xdata_t " << this); + TRACE_CTOR(transaction_xdata_t, ""); } ~transaction_xdata_t() { - DEBUG("ledger.memory.dtors", "dtor transaction_xdata_t " << this); + TRACE_DTOR(transaction_xdata_t); if (component_xacts) - delete component_xacts; + checked_delete(component_xacts); } void remember_xact(transaction_t& xact) { @@ -181,13 +194,13 @@ inline void walk_entries(entries_list& list, class ignore_transactions : public item_handler<transaction_t> { - public: +public: virtual void operator()(transaction_t& xact) {} }; class clear_transaction_xdata : public item_handler<transaction_t> { - public: +public: virtual void operator()(transaction_t& xact) { if (xact.data) { delete (transaction_xdata_t *) xact.data; @@ -203,11 +216,18 @@ class truncate_entries : public item_handler<transaction_t> transactions_list xacts; - public: + truncate_entries(); + +public: truncate_entries(item_handler<transaction_t> * handler, int _head_count, int _tail_count) : item_handler<transaction_t>(handler), - head_count(_head_count), tail_count(_tail_count) {} + head_count(_head_count), tail_count(_tail_count) { + TRACE_CTOR(truncate_entries, "item_handler<transaction_t> *, int, int"); + } + virtual ~truncate_entries() { + TRACE_DTOR(truncate_entries); + } virtual void flush(); virtual void operator()(transaction_t& xact) { @@ -217,7 +237,7 @@ class truncate_entries : public item_handler<transaction_t> class set_account_value : public item_handler<transaction_t> { - public: +public: set_account_value(item_handler<transaction_t> * handler = NULL) : item_handler<transaction_t>(handler) {} @@ -226,11 +246,18 @@ class set_account_value : public item_handler<transaction_t> class push_to_transactions_list : public item_handler<transaction_t> { - public: + push_to_transactions_list(); + +public: transactions_list& xact_list; push_to_transactions_list(transactions_list& _xact_list) - : xact_list(_xact_list) {} + : xact_list(_xact_list) { + TRACE_CTOR(push_to_transactions_list, "transactions_list&"); + } + virtual ~push_to_transactions_list() { + TRACE_DTOR(push_to_transactions_list); + } virtual void operator()(transaction_t& xact) { xact_list.push_back(&xact); @@ -244,16 +271,26 @@ class sort_transactions : public item_handler<transaction_t> transactions_deque transactions; const value_expr sort_order; - public: + sort_transactions(); + +public: sort_transactions(item_handler<transaction_t> * handler, const value_expr& _sort_order) : item_handler<transaction_t>(handler), - sort_order(_sort_order) {} - + sort_order(_sort_order) { + TRACE_CTOR(sort_transactions, + "item_handler<transaction_t> *, const value_expr&"); + } sort_transactions(item_handler<transaction_t> * handler, const string& _sort_order) : item_handler<transaction_t>(handler), - sort_order(_sort_order) {} + sort_order(_sort_order) { + TRACE_CTOR(sort_transactions, + "item_handler<transaction_t> *, const string&"); + } + virtual ~sort_transactions() { + TRACE_DTOR(sort_transactions); + } virtual void post_accumulated_xacts(); @@ -270,16 +307,26 @@ class sort_transactions : public item_handler<transaction_t> class sort_entries : public item_handler<transaction_t> { sort_transactions sorter; - entry_t * last_entry; + entry_t * last_entry; - public: + sort_entries(); + +public: sort_entries(item_handler<transaction_t> * handler, const value_expr& _sort_order) - : sorter(handler, _sort_order) {} - + : sorter(handler, _sort_order) { + TRACE_CTOR(sort_entries, + "item_handler<transaction_t> *, const value_expr&"); + } sort_entries(item_handler<transaction_t> * handler, const string& _sort_order) - : sorter(handler, _sort_order) {} + : sorter(handler, _sort_order) { + TRACE_CTOR(sort_entries, + "item_handler<transaction_t> *, const string&"); + } + virtual ~sort_entries() { + TRACE_DTOR(sort_entries); + } virtual void flush() { sorter.flush(); @@ -300,14 +347,25 @@ class filter_transactions : public item_handler<transaction_t> { item_predicate<transaction_t> pred; - public: + filter_transactions(); + +public: filter_transactions(item_handler<transaction_t> * handler, const value_expr& predicate) - : item_handler<transaction_t>(handler), pred(predicate) {} + : item_handler<transaction_t>(handler), pred(predicate) { + TRACE_CTOR(filter_transactions, + "item_handler<transaction_t> *, const value_expr&"); + } filter_transactions(item_handler<transaction_t> * handler, const string& predicate) - : item_handler<transaction_t>(handler), pred(predicate) {} + : item_handler<transaction_t>(handler), pred(predicate) { + TRACE_CTOR(filter_transactions, + "item_handler<transaction_t> *, const string&"); + } + virtual ~filter_transactions() { + TRACE_DTOR(filter_transactions); + } virtual void operator()(transaction_t& xact) { if (pred(xact)) { @@ -321,16 +379,25 @@ class calc_transactions : public item_handler<transaction_t> { transaction_t * last_xact; - public: + calc_transactions(); + +public: calc_transactions(item_handler<transaction_t> * handler) - : item_handler<transaction_t>(handler), last_xact(NULL) {} + : item_handler<transaction_t>(handler), last_xact(NULL) { + TRACE_CTOR(calc_transactions, "item_handler<transaction_t> *"); + } + virtual ~calc_transactions() { + TRACE_DTOR(calc_transactions); + } virtual void operator()(transaction_t& xact); }; class invert_transactions : public item_handler<transaction_t> { - public: + invert_transactions(); + +public: invert_transactions(item_handler<transaction_t> * handler) : item_handler<transaction_t>(handler) {} @@ -355,13 +422,17 @@ class collapse_transactions : public item_handler<transaction_t> std::list<entry_t> entry_temps; std::list<transaction_t> xact_temps; - public: + collapse_transactions(); + +public: collapse_transactions(item_handler<transaction_t> * handler) : item_handler<transaction_t>(handler), count(0), last_entry(NULL), last_xact(NULL), - totals_account(NULL, "<Total>") {} - - ~collapse_transactions() { + totals_account(NULL, "<Total>") { + TRACE_CTOR(collapse_transactions, "item_handler<transaction_t> *"); + } + virtual ~collapse_transactions() { + TRACE_DTOR(collapse_transactions); clear_entries_transactions(entry_temps); } @@ -380,14 +451,24 @@ class component_transactions : public item_handler<transaction_t> { item_predicate<transaction_t> pred; - public: + component_transactions(); + +public: component_transactions(item_handler<transaction_t> * handler, const value_expr& predicate) - : item_handler<transaction_t>(handler), pred(predicate) {} - + : item_handler<transaction_t>(handler), pred(predicate) { + TRACE_CTOR(component_transactions, + "item_handler<transaction_t> *, const value_expr&"); + } component_transactions(item_handler<transaction_t> * handler, const string& predicate) - : item_handler<transaction_t>(handler), pred(predicate) {} + : item_handler<transaction_t>(handler), pred(predicate) { + TRACE_CTOR(component_transactions, + "item_handler<transaction_t> *, const string&"); + } + virtual ~component_transactions() throw() { + TRACE_DTOR(component_transactions); + } virtual void operator()(transaction_t& xact); }; @@ -397,11 +478,19 @@ class related_transactions : public item_handler<transaction_t> transactions_list transactions; bool also_matching; - public: + related_transactions(); + +public: related_transactions(item_handler<transaction_t> * handler, const bool _also_matching = false) : item_handler<transaction_t>(handler), - also_matching(_also_matching) {} + also_matching(_also_matching) { + TRACE_CTOR(related_transactions, + "item_handler<transaction_t> *, const bool"); + } + virtual ~related_transactions() throw() { + TRACE_DTOR(related_transactions); + } virtual void flush(); virtual void operator()(transaction_t& xact) { @@ -422,13 +511,18 @@ class changed_value_transactions : public item_handler<transaction_t> std::list<entry_t> entry_temps; std::list<transaction_t> xact_temps; - public: + changed_value_transactions(); + +public: changed_value_transactions(item_handler<transaction_t> * handler, bool _changed_values_only) : item_handler<transaction_t>(handler), - changed_values_only(_changed_values_only), last_xact(NULL) {} - - ~changed_value_transactions() { + changed_values_only(_changed_values_only), last_xact(NULL) { + TRACE_CTOR(changed_value_transactions, + "item_handler<transaction_t> *, bool"); + } + virtual ~changed_value_transactions() { + TRACE_DTOR(changed_value_transactions); clear_entries_transactions(entry_temps); } @@ -447,42 +541,57 @@ class changed_value_transactions : public item_handler<transaction_t> class subtotal_transactions : public item_handler<transaction_t> { - struct acct_value_t { + class acct_value_t + { + acct_value_t(); + + public: account_t * account; value_t value; transactions_list components; - acct_value_t(account_t * a) : account(a) {} - acct_value_t(account_t * a, value_t& v) : account(a), value(v) {} + acct_value_t(account_t * a) : account(a) { + TRACE_CTOR(acct_value_t, "acount_t *"); + } + acct_value_t(account_t * a, value_t& v) : account(a), value(v) { + TRACE_CTOR(acct_value_t, "acount_t *, value_t&"); + } acct_value_t(const acct_value_t& av) - : account(av.account), value(av.value) {} + : account(av.account), value(av.value), + components(av.components) { + TRACE_CTOR(acct_value_t, "copy"); + } + ~acct_value_t() throw() { + TRACE_DTOR(acct_value_t); + } }; typedef std::map<string, acct_value_t> values_map; typedef std::pair<string, acct_value_t> values_pair; - protected: + subtotal_transactions(); + +protected: values_map values; bool remember_components; std::list<entry_t> entry_temps; std::list<transaction_t> xact_temps; - public: +public: datetime_t start; datetime_t finish; subtotal_transactions(item_handler<transaction_t> * handler, bool _remember_components = false) : item_handler<transaction_t>(handler), - remember_components(_remember_components) {} -#ifdef DEBUG_ENABLED - subtotal_transactions(const subtotal_transactions&) { - assert(false); + remember_components(_remember_components) { + TRACE_CTOR(subtotal_transactions, + "item_handler<transaction_t> *, bool"); } -#endif virtual ~subtotal_transactions() { + TRACE_DTOR(subtotal_transactions); clear_entries_transactions(entry_temps); } @@ -510,18 +619,28 @@ class interval_transactions : public subtotal_transactions transaction_t * last_xact; bool started; - public: + interval_transactions(); + +public: interval_transactions(item_handler<transaction_t> * _handler, const interval_t& _interval, bool remember_components = false) : subtotal_transactions(_handler, remember_components), - interval(_interval), last_xact(NULL), started(false) {} - + interval(_interval), last_xact(NULL), started(false) { + TRACE_CTOR(interval_transactions, + "item_handler<transaction_t> *, const interval_t&, bool"); + } interval_transactions(item_handler<transaction_t> * _handler, const string& _interval, bool remember_components = false) : subtotal_transactions(_handler, remember_components), - interval(_interval), last_xact(NULL), started(false) {} + interval(_interval), last_xact(NULL), started(false) { + TRACE_CTOR(interval_transactions, + "item_handler<transaction_t> *, const string&, bool"); + } + virtual ~interval_transactions() throw() { + TRACE_DTOR(interval_transactions); + } void report_subtotal(const datetime_t& moment = datetime_t()); @@ -539,13 +658,18 @@ class by_payee_transactions : public item_handler<transaction_t> typedef std::pair<string, subtotal_transactions *> payee_subtotals_pair; payee_subtotals_map payee_subtotals; - bool remember_components; + bool remember_components; + + by_payee_transactions(); public: by_payee_transactions(item_handler<transaction_t> * handler, bool _remember_components = false) : item_handler<transaction_t>(handler), - remember_components(_remember_components) {} + remember_components(_remember_components) { + TRACE_CTOR(by_payee_transactions, + "item_handler<transaction_t> *, bool"); + } virtual ~by_payee_transactions(); virtual void flush(); @@ -557,11 +681,15 @@ class set_comm_as_payee : public item_handler<transaction_t> std::list<entry_t> entry_temps; std::list<transaction_t> xact_temps; - public: - set_comm_as_payee(item_handler<transaction_t> * handler) - : item_handler<transaction_t>(handler) {} + set_comm_as_payee(); - ~set_comm_as_payee() { +public: + set_comm_as_payee(item_handler<transaction_t> * handler) + : item_handler<transaction_t>(handler) { + TRACE_CTOR(set_comm_as_payee, "item_handler<transaction_t> *"); + } + virtual ~set_comm_as_payee() { + TRACE_DTOR(set_comm_as_payee); clear_entries_transactions(entry_temps); } @@ -573,11 +701,15 @@ class set_code_as_payee : public item_handler<transaction_t> std::list<entry_t> entry_temps; std::list<transaction_t> xact_temps; - public: - set_code_as_payee(item_handler<transaction_t> * handler) - : item_handler<transaction_t>(handler) {} + set_code_as_payee(); - ~set_code_as_payee() { +public: + set_code_as_payee(item_handler<transaction_t> * handler) + : item_handler<transaction_t>(handler) { + TRACE_CTOR(set_code_as_payee, "item_handler<transaction_t> *"); + } + virtual ~set_code_as_payee() { + TRACE_DTOR(set_code_as_payee); clear_entries_transactions(entry_temps); } @@ -588,10 +720,17 @@ class dow_transactions : public subtotal_transactions { transactions_list days_of_the_week[7]; - public: + dow_transactions(); + +public: dow_transactions(item_handler<transaction_t> * handler, bool remember_components = false) - : subtotal_transactions(handler, remember_components) {} + : subtotal_transactions(handler, remember_components) { + TRACE_CTOR(dow_transactions, "item_handler<transaction_t> *, bool"); + } + virtual ~dow_transactions() throw() { + TRACE_DTOR(dow_transactions); + } virtual void flush(); virtual void operator()(transaction_t& xact) { @@ -601,7 +740,9 @@ class dow_transactions : public subtotal_transactions class generate_transactions : public item_handler<transaction_t> { - protected: + generate_transactions(); + +protected: typedef std::pair<interval_t, transaction_t *> pending_xacts_pair; typedef std::list<pending_xacts_pair> pending_xacts_list; @@ -609,11 +750,14 @@ class generate_transactions : public item_handler<transaction_t> std::list<entry_t> entry_temps; std::list<transaction_t> xact_temps; - public: +public: generate_transactions(item_handler<transaction_t> * handler) - : item_handler<transaction_t>(handler) {} + : item_handler<transaction_t>(handler) { + TRACE_CTOR(dow_transactions, "item_handler<transaction_t> *"); + } - ~generate_transactions() { + virtual ~generate_transactions() { + TRACE_DTOR(generate_transactions); clear_entries_transactions(entry_temps); } @@ -630,10 +774,18 @@ class budget_transactions : public generate_transactions { unsigned short flags; - public: + budget_transactions(); + +public: budget_transactions(item_handler<transaction_t> * handler, unsigned long _flags = BUDGET_BUDGETED) - : generate_transactions(handler), flags(_flags) {} + : generate_transactions(handler), flags(_flags) { + TRACE_CTOR(budget_transactions, + "item_handler<transaction_t> *, unsigned long"); + } + virtual ~budget_transactions() throw() { + TRACE_DTOR(budget_transactions); + } void report_budget_items(const datetime_t& moment); @@ -647,11 +799,19 @@ class forecast_transactions : public generate_transactions public: forecast_transactions(item_handler<transaction_t> * handler, const value_expr& predicate) - : generate_transactions(handler), pred(predicate) {} - + : generate_transactions(handler), pred(predicate) { + TRACE_CTOR(forecast_transactions, + "item_handler<transaction_t> *, const value_expr&"); + } forecast_transactions(item_handler<transaction_t> * handler, const string& predicate) - : generate_transactions(handler), pred(predicate) {} + : generate_transactions(handler), pred(predicate) { + TRACE_CTOR(forecast_transactions, + "item_handler<transaction_t> *, const string&"); + } + virtual ~forecast_transactions() throw() { + TRACE_DTOR(forecast_transactions); + } virtual void add_transaction(const interval_t& period, transaction_t& xact); @@ -670,7 +830,7 @@ class forecast_transactions : public generate_transactions #define ACCOUNT_HAS_NON_VIRTUALS 0x0008 #define ACCOUNT_HAS_UNB_VIRTUALS 0x0010 -struct account_xdata_t +struct account_xdata_t : public noncopyable { value_t value; value_t total; @@ -680,7 +840,12 @@ struct account_xdata_t unsigned int virtuals; unsigned short dflags; - account_xdata_t() : count(0), total_count(0), virtuals(0), dflags(0) {} + account_xdata_t() : count(0), total_count(0), virtuals(0), dflags(0) { + TRACE_CTOR(account_xdata_t, ""); + } + ~account_xdata_t() throw() { + TRACE_DTOR(account_xdata_t); + } }; inline bool account_has_xdata(const account_t& account) { @@ -697,7 +862,7 @@ account_xdata_t& account_xdata(const account_t& account); class clear_account_xdata : public item_handler<account_t> { - public: +public: virtual void operator()(account_t& acct) { if (acct.data) { delete (account_xdata_t *) acct.data; @@ -25,13 +25,20 @@ class xml_parser_t : public parser_t class format_xml_entries : public format_entries { bool show_totals; - public: + + format_xml_entries(); + +public: format_xml_entries(std::ostream& output_stream, const bool _show_totals = false) : format_entries(output_stream, ""), show_totals(_show_totals) { + TRACE_CTOR(format_xml_entries, "std::ostream&, const bool"); output_stream << "<?xml version=\"1.0\"?>\n" << "<ledger version=\"2.5\">\n"; } + virtual ~format_xml_entries() throw() { + TRACE_DTOR(format_xml_entries); + } virtual void flush() { format_entries::flush(); |