| 176 | } |
| 177 | |
| 178 | JSONCONS_VISITOR_RETURN_TYPE visit_end_array(const ser_context&, std::error_code&) override |
| 179 | { |
| 180 | JSONCONS_ASSERT(structure_stack_.size() > 1); |
| 181 | JSONCONS_ASSERT(structure_stack_.back().type_ == structure_type::array_t); |
| 182 | const size_t container_index = structure_stack_.back().container_index_; |
| 183 | JSONCONS_ASSERT(item_stack_.size() > container_index); |
| 184 | |
| 185 | auto& container = item_stack_[container_index].value; |
| 186 | |
| 187 | const size_t size = item_stack_.size() - (container_index + 1); |
| 188 | //std::cout << "size on item stack: " << size << "\n"; |
| 189 | |
| 190 | if (size > 0) |
| 191 | { |
| 192 | container.reserve(size); |
| 193 | auto first = item_stack_.begin() + (container_index+1); |
| 194 | auto last = first + size; |
| 195 | for (auto it = first; it != last; ++it) |
| 196 | { |
| 197 | container.push_back(std::move((*it).value)); |
| 198 | } |
| 199 | item_stack_.erase(first, item_stack_.end()); |
| 200 | } |
| 201 | |
| 202 | structure_stack_.pop_back(); |
| 203 | if (structure_stack_.back().type_ == structure_type::root_t) |
| 204 | { |
| 205 | result_.swap(item_stack_.front().value); |
| 206 | item_stack_.pop_back(); |
| 207 | is_valid_ = true; |
| 208 | JSONCONS_VISITOR_RETURN; |
| 209 | } |
| 210 | JSONCONS_VISITOR_RETURN; |
| 211 | } |
| 212 | |
| 213 | JSONCONS_VISITOR_RETURN_TYPE visit_key(const string_view_type& name, const ser_context&, std::error_code&) override |
| 214 | { |