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) {
24 Throw(
"field '" + std::string(key) +
"'");
26 virtual void EndObject() { Throw(
"'}'"); }
27 virtual void StartArray() { Throw(
"array"); }
28 virtual void EndArray() { Throw(
"']'"); }
31 virtual void EndObject(size_t ) { EndObject(); }
32 virtual void EndArray(size_t ) { EndArray(); }
34 void SetState(ParserState& state) { parser_state_ = &state; }
36 virtual std::string GetPathItem()
const = 0;
39 [[
noreturn]]
void Throw(
const std::string& found) {
44 virtual std::string Expected()
const = 0;
47 ParserState* parser_state_{
nullptr};