20 explicit ArrayParser(ItemParser& item_parser)
21 : item_parser_(item_parser)
23 this->item_parser_.Subscribe(*
this);
28 state_ = State::kStart;
31 if constexpr (meta::kIsVector<Array>) {
33
34
35
36
37
38
44 void StartArray()
override {
45 if (state_ == State::kStart) {
46 state_ = State::kInside;
49 Parser().StartArray();
52 void EndArray()
override {
53 if (state_ == State::kInside) {
54 this->SetResult(std::move(storage_));
58 this->Throw(
"end of array");
61 void Int64(int64_t i)
override {
62 PushParser(
"integer");
65 void Uint64(uint64_t i)
override {
66 PushParser(
"integer");
69 void Null()
override {
73 void Bool(
bool b)
override {
77 void Double(
double d)
override {
81 void String(std::string_view sw)
override {
85 void StartObject()
override {
87 Parser().StartObject();
90 std::string Expected()
const override {
return "array"; }
92 void PushParser(std::string_view what) {
93 if (state_ != State::kInside) {
95 this->parser_state_->PopMe(*
this);
97 this->Throw(std::string(what));
100 this->item_parser_.Reset();
101 this->parser_state_->PushParser(item_parser_.GetParser());
105 void OnSend(Item&& item)
override {
106 if constexpr (!meta::kIsVector<Array>) {
107 this->storage_.insert(std::move(item));
109 this->storage_.push_back(std::move(item));
115 BaseParser& Parser() {
return item_parser_.GetParser(); }
118 ItemParser& item_parser_;
119 std::optional<size_t> min_items_, max_items_;
126 State state_{State::kStart};