#ifndef TEST_WEBSITE_SRC_MODULE_JSON_LIBJSONINCPP_PARSER_H #define TEST_WEBSITE_SRC_MODULE_JSON_LIBJSONINCPP_PARSER_H /* DO NOT EXPORT THIS FILE! User parser API is in string_representation.h */ #include "jsonobj.h" #include #include namespace json { constexpr int endOfFile = 999999; struct bad_syntax: public std::exception { inline bad_syntax() { assert(false); } }; struct ParserContext { const std::string& text; size_t pos = 0; size_t line = 0; size_t column = 0; explicit ParserContext(const std::string& text); }; bool isEof(ParserContext& pctx); int peep(ParserContext& pctx); int skip(ParserContext& pctx); void demandSkip(ParserContext& pctx, char ch); bool isWhitespace(int vch); void skipWhitespaces(ParserContext& pctx); /* Function that parses string value */ std::string demandStringJson(ParserContext& pctx); struct ParsingCall { virtual std::unique_ptr here(ParserContext& pctx); virtual ~ParsingCall() = default; }; struct ValueParseCall: public ParsingCall { JSON& result; bool got_him = false; std::unique_ptr here(ParserContext& pctx) override; ValueParseCall(JSON& result); }; struct ArrayParseCall : public ParsingCall { std::vector& result; bool got_one = false; explicit ArrayParseCall(std::vector& result); std::unique_ptr here(ParserContext& pctx) override; }; struct DictionaryParseCall: public ParsingCall { std::map& result; bool got_one = false; explicit DictionaryParseCall(std::map& result); std::unique_ptr here(ParserContext& pctx) override; }; } #endif