summaryrefslogtreecommitdiff
path: root/src/csv.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-02-26 15:45:15 -0600
committerJohn Wiegley <johnw@newartisans.com>2012-02-26 15:45:15 -0600
commitaa9b07d79bff00506b913d1e56575c3859fc173f (patch)
tree70bf76b03217eec5d09855f2a7bda9d5b9230fa0 /src/csv.h
parent4cf95497f9afaead3d9d308dabe8e8b26949502f (diff)
downloadfork-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.h37
1 files changed, 29 insertions, 8 deletions
diff --git a/src/csv.h b/src/csv.h
index 5ff8b59e..cf350e9d 100644
--- a/src/csv.h
+++ b/src/csv.h
@@ -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