summaryrefslogtreecommitdiff
path: root/src/parser.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-05-14 11:09:06 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:38:49 -0400
commit77db7eb92f730af315d4bcdf831cc67acb386b58 (patch)
tree566a413e47d8d9f2f82d257c4ad3988c0a38d919 /src/parser.h
parent3cc14c70d47f6f7674b587eb08b9d0e02a90e662 (diff)
downloadfork-ledger-77db7eb92f730af315d4bcdf831cc67acb386b58.tar.gz
fork-ledger-77db7eb92f730af315d4bcdf831cc67acb386b58.tar.bz2
fork-ledger-77db7eb92f730af315d4bcdf831cc67acb386b58.zip
Added initial support for using builders from the various parsers; at the moment is just uses the xml_writer_t builder to output the contents of the ledger journal as XML
Diffstat (limited to 'src/parser.h')
-rw-r--r--src/parser.h29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/parser.h b/src/parser.h
index 8e9ccd4a..7cb1cd49 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -33,6 +33,7 @@
#define _PARSER_H
#include "utils.h"
+#include "builder.h"
namespace ledger {
@@ -46,10 +47,9 @@ class parser_t
virtual bool test(std::istream& in) const = 0;
- virtual unsigned int parse(std::istream& in,
- journal_t * journal,
- account_t * master = NULL,
- const optional<path>& original = none) = 0;
+ virtual void parse(std::istream& in,
+ const path& pathname,
+ xml::builder_t& builder) = 0;
};
DECLARE_EXCEPTION(parse_error);
@@ -65,6 +65,27 @@ inline char * skip_ws(char * ptr) {
return ptr;
}
+inline char * next_element(char * buf, bool variable = false) {
+ for (char * p = buf; *p; p++) {
+ if (! (*p == ' ' || *p == '\t'))
+ continue;
+
+ if (! variable) {
+ *p = '\0';
+ return skip_ws(p + 1);
+ }
+ else if (*p == '\t') {
+ *p = '\0';
+ return skip_ws(p + 1);
+ }
+ else if (*(p + 1) == ' ') {
+ *p = '\0';
+ return skip_ws(p + 2);
+ }
+ }
+ return NULL;
+}
+
inline char peek_next_nonws(std::istream& in) {
char c = in.peek();
while (! in.eof() && std::isspace(c)) {