15 explicit ArrayParser(ItemParser& item_parser)
16 : item_parser_(item_parser)
18 this->item_parser_.Subscribe(*
this);
23 state_ = State::kStart;
26 if constexpr (meta::kIsVector<Array>) {
28
29
30
31
32
33
39 void StartArray()
override {
40 if (state_ == State::kStart) {
41 state_ = State::kInside;
44 Parser().StartArray();
47 void EndArray()
override {
48 if (state_ == State::kInside) {
49 this->SetResult(std::move(storage_));
53 this->Throw(
"end of array");
56 void Int64(int64_t i)
override {
57 PushParser(
"integer");
60 void Uint64(uint64_t i)
override {
61 PushParser(
"integer");
64 void Null()
override {
68 void Bool(
bool b)
override {
72 void Double(
double d)
override {
76 void String(std::string_view sw)
override {
80 void StartObject()
override {
82 Parser().StartObject();
85 std::string Expected()
const override {
return "array"; }
87 void PushParser(std::string_view what) {
88 if (state_ != State::kInside) {
90 this->parser_state_->PopMe(*
this);
92 this->Throw(std::string(what));
95 this->item_parser_.Reset();
96 this->parser_state_->PushParser(item_parser_.GetParser());
100 void OnSend(Item&& item)
override {
101 if constexpr (!meta::kIsVector<Array>) {
102 this->storage_.insert(std::move(item));
104 this->storage_.push_back(std::move(item));
110 BaseParser& Parser() {
return item_parser_.GetParser(); }
113 ItemParser& item_parser_;
114 std::optional<size_t> min_items_, max_items_;
121 State state_{State::kStart};