3#include <userver/formats/json/parser/exception.hpp>
4#include <userver/formats/json/parser/parser_state.hpp>
14 virtual ~BaseParser() =
default;
16 virtual void Null() { Throw(
"null"); }
17 virtual void Bool(
bool) { Throw(
"bool"); }
18 virtual void Int64(int64_t) { Throw(
"integer"); }
19 virtual void Uint64(uint64_t) { Throw(
"integer"); }
20 virtual void Double(
double) { Throw(
"double"); }
21 virtual void String(std::string_view) { Throw(
"string"); }
22 virtual void StartObject() { Throw(
"object"); }
23 virtual void Key(std::string_view key) { Throw(
"field '" + std::string(key) +
"'"); }
24 virtual void EndObject() { Throw(
"'}'"); }
25 virtual void StartArray() { Throw(
"array"); }
26 virtual void EndArray() { Throw(
"']'"); }
29 virtual void EndObject(size_t ) { EndObject(); }
30 virtual void EndArray(size_t ) { EndArray(); }
32 void SetState(ParserState& state) { parser_state_ = &state; }
34 virtual std::string GetPathItem()
const = 0;
37 [[
noreturn]]
void Throw(
const std::string& found) {
41 virtual std::string Expected()
const = 0;
44 ParserState* parser_state_{
nullptr};