X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fparser.cpp;h=7d0bb3b465d7d2f1a8c36db3826aa60bdcdc90f8;hb=daca21051927eabee098e422fe5a0990acacfb96;hp=5972e2d98f832d312afa4373bfe66d4204d10f8f;hpb=ed78b585cfc4ecb44972e346857e887b183fd7a7;p=libs%2Fdatafile.git diff --git a/source/parser.cpp b/source/parser.cpp index 5972e2d..7d0bb3b 100644 --- a/source/parser.cpp +++ b/source/parser.cpp @@ -1,6 +1,7 @@ #include #include "binaryparser.h" #include "except.h" +#include "jsonparser.h" #include "parser.h" #include "statement.h" #include "textparser.h" @@ -14,9 +15,14 @@ Parser::Parser(IO::Base &i, const string &s): in(i), main_src(s), src(s), - good(true), - mode(new TextParser(in, src)) -{ } + good(true) +{ + char c = in.peek(); + if(c=='{' || c=='[') + mode = new JsonParser(in, src); + else + mode = new TextParser(in, src); +} Parser::~Parser() { @@ -97,7 +103,7 @@ const StatementKey *Parser::peek(unsigned level) return key; } - return 0; + return nullptr; } bool Parser::parse_and_load(unsigned level, Loader &ldr, const LoaderAction &act)