diff options
author | John Wiegley <johnw@newartisans.com> | 2004-08-15 02:39:13 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2004-08-15 02:39:13 -0400 |
commit | b10ff955a370b7fd2add5c5493f1987b5d7b6600 (patch) | |
tree | 9e5b0cd0022862766cda8b62aca7c7336bbc4c51 /textual.cc | |
parent | 972ed4c386f8beeafda3519f6769f6dd9670e69a (diff) | |
download | fork-ledger-b10ff955a370b7fd2add5c5493f1987b5d7b6600.tar.gz fork-ledger-b10ff955a370b7fd2add5c5493f1987b5d7b6600.tar.bz2 fork-ledger-b10ff955a370b7fd2add5c5493f1987b5d7b6600.zip |
cleaned up binary data writing, and file handling
Diffstat (limited to 'textual.cc')
-rw-r--r-- | textual.cc | 28 |
1 files changed, 13 insertions, 15 deletions
@@ -296,6 +296,14 @@ entry_t * parse_entry(std::istream& in, account_t * master) return curr; } +template <typename T> +struct push_var { + T& var; + T prev; + push_var(T& _var) : var(_var), prev(var) {} + ~push_var() { var = prev; } +}; + unsigned int parse_textual_journal(std::istream& in, journal_t * journal, account_t * master) { @@ -496,9 +504,9 @@ unsigned int parse_textual_journal(std::istream& in, journal_t * journal, linenum++; break; - case ':': { // option setting + case '-': { // option setting std::string opt; - in >> c; + in >> c >> c; in >> opt; in.getline(line, MAX_LINE); linenum++; @@ -533,19 +541,9 @@ unsigned int parse_textual_journal(std::istream& in, journal_t * journal, in.getline(line, MAX_LINE); linenum++; - char * p = skip_ws(line); - std::ifstream stream(p); - - journal->sources.push_back(p); - - unsigned int curr_linenum = linenum; - std::string curr_path = path; - - count += parse_textual_journal(stream, journal, - account_stack.front()); - - linenum = curr_linenum; - path = curr_path; + push_var<unsigned int> save_linenum(linenum); + push_var<std::string> save_path(path); + count += parse_journal_file(skip_ws(line), journal); } break; |