summaryrefslogtreecommitdiff
path: root/src/csv.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/csv.h')
-rw-r--r--src/csv.h45
1 files changed, 43 insertions, 2 deletions
diff --git a/src/csv.h b/src/csv.h
index 7029d482..5ff8b59e 100644
--- a/src/csv.h
+++ b/src/csv.h
@@ -56,10 +56,51 @@ class csv_reader
std::istream& in;
+ enum headers_t {
+ FIELD_DATE = 0,
+ FIELD_DATE_EFF,
+ FIELD_CODE,
+ FIELD_PAYEE,
+ FIELD_AMOUNT,
+ FIELD_COST,
+ FIELD_TOTAL,
+ FIELD_NOTE,
+
+ FIELD_UNKNOWN
+ };
+
+ mask_t date_mask;
+ mask_t date_eff_mask;
+ mask_t code_mask;
+ mask_t payee_mask;
+ mask_t amount_mask;
+ mask_t cost_mask;
+ mask_t total_mask;
+ mask_t note_mask;
+
+ 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)
+ : in(_in),
+ date_mask("date"),
+ date_eff_mask("posted( ?date)?"),
+ code_mask("code"),
+ payee_mask("(payee|desc(ription)?|title)"),
+ amount_mask("amount"),
+ cost_mask("cost"),
+ total_mask("total"),
+ note_mask("note") {
+ read_index(in);
+ }
- string read_field();
+ 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);
};