diff options
author | John Wiegley <johnw@newartisans.com> | 2012-02-26 15:45:15 -0600 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2012-02-26 15:45:15 -0600 |
commit | aa9b07d79bff00506b913d1e56575c3859fc173f (patch) | |
tree | 70bf76b03217eec5d09855f2a7bda9d5b9230fa0 /src/csv.h | |
parent | 4cf95497f9afaead3d9d308dabe8e8b26949502f (diff) | |
download | fork-ledger-aa9b07d79bff00506b913d1e56575c3859fc173f.tar.gz fork-ledger-aa9b07d79bff00506b913d1e56575c3859fc173f.tar.bz2 fork-ledger-aa9b07d79bff00506b913d1e56575c3859fc173f.zip |
Added --rich-data for 'convert', and SHA1 checksum checking
Diffstat (limited to 'src/csv.h')
-rw-r--r-- | src/csv.h | 37 |
1 files changed, 29 insertions, 8 deletions
@@ -52,9 +52,13 @@ class account_t; class csv_reader { - static const std::size_t MAX_LINE = 1024; + static const std::size_t MAX_LINE = 4096; std::istream& in; + path pathname; + char linebuf[MAX_LINE]; + std::size_t linenum; + std::size_t sequence; enum headers_t { FIELD_DATE = 0, @@ -80,13 +84,11 @@ class csv_reader std::vector<int> index; std::vector<string> names; - std::vector<string> fields; - - typedef std::map<string, string> string_map; public: - csv_reader(std::istream& _in) - : in(_in), + csv_reader(std::istream& _in, const path& _pathname) + : in(_in), pathname(_pathname), + linenum(0), sequence(0), date_mask("date"), date_eff_mask("posted( ?date)?"), code_mask("code"), @@ -98,11 +100,30 @@ public: read_index(in); } + void read_index(std::istream& in); string read_field(std::istream& in); char * next_line(std::istream& in); - void read_index(std::istream& in); - xact_t * read_xact(journal_t& journal, account_t * bucket); + xact_t * read_xact(journal_t& journal, account_t * bucket, bool rich_data); + + const char * get_last_line() const { + return linebuf; + } + + path get_pathname() const { + return pathname; + } + std::size_t get_linenum() const { + return linenum; + } + + void reset() { + pathname.clear(); + index.clear(); + names.clear(); + linenum = 0; + sequence = 0; + } }; } // namespace ledger |