diff options
author | John Wiegley <johnw@newartisans.com> | 2008-07-29 05:10:16 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-07-29 05:59:38 -0400 |
commit | 4518ea95408e2d5fe90a87159b88bb41734ec1dc (patch) | |
tree | 3026169803aaea580d8b452cb9bb8a569c92fb2a /journal.h | |
parent | 63039ade9209bced70b3e4dbb673ad90286d310a (diff) | |
download | fork-ledger-4518ea95408e2d5fe90a87159b88bb41734ec1dc.tar.gz fork-ledger-4518ea95408e2d5fe90a87159b88bb41734ec1dc.tar.bz2 fork-ledger-4518ea95408e2d5fe90a87159b88bb41734ec1dc.zip |
Value expression architecture is now rewritten, but the functionality of the
old system (for example, the meaning of 'a') has yet to be restored. In the
new scheme, this will be done by definition a function outside of the value
expression logic, rather than the tight coupling between journal innards and
value expressions that occurred in 2.x.
Diffstat (limited to 'journal.h')
-rw-r--r-- | journal.h | 61 |
1 files changed, 56 insertions, 5 deletions
@@ -34,8 +34,8 @@ #include "amount.h" #include "value.h" -#include "valexpr.h" -#include "utils.h" +#include "expr.h" +#include "predicate.h" namespace ledger { @@ -62,9 +62,9 @@ class transaction_t : public supports_flags<> optional<datetime_t> _date; optional<datetime_t> _date_eff; amount_t amount; - value_expr amount_expr; + expr_t amount_expr; optional<amount_t> cost; - optional<value_expr> cost_expr; + optional<expr_t> cost_expr; optional<string> note; istream_pos_type beg_pos; unsigned long beg_line; @@ -452,7 +452,7 @@ class session_t; class journal_t : public noncopyable { - public: +public: session_t * owner; account_t * master; account_t * basket; @@ -488,6 +488,57 @@ class journal_t : public noncopyable } bool valid() const; + +/** + * @class journal_t::parser_t + * + * @brief Provides an abstract interface for writing journal parsers. + * + * Any data format for Ledger data is possible, as long as it can be parsed + * into a journal_t data tree. This class provides the basic interface which + * must be implemented by every such journal parser. + */ + class parser_t : public noncopyable + { + public: + parser_t() { + TRACE_CTOR(parser_t, ""); + } + virtual ~parser_t() { + TRACE_DTOR(parser_t); + } + + virtual bool test(std::istream& in) const = 0; + + virtual unsigned int parse(std::istream& in, + session_t& session, + journal_t& journal, + account_t * master = NULL, + const path * original_file = NULL) = 0; + }; + + class binary_parser_t : public parser_t + { + public: + virtual bool test(std::istream& in) const; + + virtual unsigned int parse(std::istream& in, + session_t& session, + journal_t& journal, + account_t * master = NULL, + const path * original_file = NULL); + }; + + unsigned int read(std::istream& in, const path& file, account_t * master); + void write(std::ostream& out); + + class parse_error : public error + { + public: + parse_error(const string& reason, error_context * ctxt = NULL) throw() + : error(reason, ctxt) {} + virtual ~parse_error() throw() {} + }; }; inline void extend_entry_base(journal_t * journal, entry_base_t& entry, |