/src/jsoncons/include/jsoncons/json_decoder.hpp
Line | Count | Source |
1 | | // Copyright 2013-2025 Daniel Parker |
2 | | // Distributed under the Boost license, Version 1.0. |
3 | | // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
4 | | |
5 | | // See https://github.com/danielaparker/jsoncons for latest version |
6 | | |
7 | | #ifndef JSONCONS_JSON_DECODER_HPP |
8 | | #define JSONCONS_JSON_DECODER_HPP |
9 | | |
10 | | #include <cstddef> |
11 | | #include <cstdint> |
12 | | #include <memory> // std::allocator |
13 | | #include <system_error> |
14 | | #include <utility> // std::move |
15 | | #include <vector> |
16 | | |
17 | | #include <jsoncons/json_object.hpp> |
18 | | #include <jsoncons/json_type.hpp> |
19 | | #include <jsoncons/json_visitor.hpp> |
20 | | #include <jsoncons/semantic_tag.hpp> |
21 | | #include <jsoncons/ser_util.hpp> |
22 | | |
23 | | namespace jsoncons { |
24 | | |
25 | | template <typename Json,typename TempAlloc =std::allocator<char>> |
26 | | class json_decoder final : public basic_json_visitor<typename Json::char_type> |
27 | | { |
28 | | public: |
29 | | using char_type = typename Json::char_type; |
30 | | using typename basic_json_visitor<char_type>::string_view_type; |
31 | | |
32 | | using key_value_type = typename Json::key_value_type; |
33 | | using key_type = typename Json::key_type; |
34 | | using array = typename Json::array; |
35 | | using object = typename Json::object; |
36 | | using allocator_type = typename Json::allocator_type; |
37 | | using json_string_allocator = typename key_type::allocator_type; |
38 | | using json_array_allocator = typename array::allocator_type; |
39 | | using json_object_allocator = typename object::allocator_type; |
40 | | using json_byte_allocator_type = typename std::allocator_traits<allocator_type>:: template rebind_alloc<uint8_t>; |
41 | | private: |
42 | | |
43 | | enum class structure_type {root_t, array_t, object_t}; |
44 | | |
45 | | struct structure_info |
46 | | { |
47 | | structure_type type_; |
48 | | std::size_t container_index_{0}; |
49 | | |
50 | | structure_info(structure_type type, std::size_t offset) noexcept |
51 | 362k | : type_(type), container_index_(offset) |
52 | 362k | { |
53 | 362k | } |
54 | | ~structure_info() = default; |
55 | | }; |
56 | | |
57 | | using temp_allocator_type = TempAlloc; |
58 | | using stack_item_allocator_type = typename std::allocator_traits<allocator_type>:: template rebind_alloc<index_key_value<Json>>; |
59 | | using structure_info_allocator_type = typename std::allocator_traits<temp_allocator_type>:: template rebind_alloc<structure_info>; |
60 | | |
61 | | allocator_type allocator_; |
62 | | |
63 | | Json result_; |
64 | | |
65 | | std::size_t index_{0}; |
66 | | key_type name_; |
67 | | std::vector<index_key_value<Json>,stack_item_allocator_type> item_stack_; |
68 | | std::vector<structure_info,structure_info_allocator_type> structure_stack_; |
69 | | bool is_valid_{false}; |
70 | | |
71 | | public: |
72 | | json_decoder(const allocator_type& alloc = allocator_type(), |
73 | | const temp_allocator_type& temp_alloc = temp_allocator_type()) |
74 | 5.42k | : allocator_(alloc), |
75 | 5.42k | result_(), |
76 | 5.42k | name_(alloc), |
77 | 5.42k | item_stack_(alloc), |
78 | 5.42k | structure_stack_(temp_alloc) |
79 | 5.42k | { |
80 | 5.42k | item_stack_.reserve(1000); |
81 | 5.42k | structure_stack_.reserve(100); |
82 | 5.42k | structure_stack_.emplace_back(structure_type::root_t, 0); |
83 | 5.42k | } |
84 | | |
85 | | json_decoder(temp_allocator_arg_t, |
86 | | const temp_allocator_type& temp_alloc = temp_allocator_type()) |
87 | | : allocator_(), |
88 | | result_(), |
89 | | name_(), |
90 | | item_stack_(), |
91 | | structure_stack_(temp_alloc) |
92 | | { |
93 | | item_stack_.reserve(1000); |
94 | | structure_stack_.reserve(100); |
95 | | structure_stack_.emplace_back(structure_type::root_t, 0); |
96 | | } |
97 | | |
98 | | void reset() |
99 | | { |
100 | | is_valid_ = false; |
101 | | index_ = 0; |
102 | | item_stack_.clear(); |
103 | | structure_stack_.clear(); |
104 | | structure_stack_.emplace_back(structure_type::root_t, 0); |
105 | | } |
106 | | |
107 | | bool is_valid() const |
108 | 2.15k | { |
109 | 2.15k | return is_valid_; |
110 | 2.15k | } jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::is_valid() const Line | Count | Source | 108 | 2.15k | { | 109 | 2.15k | return is_valid_; | 110 | 2.15k | } |
Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::is_valid() const Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::is_valid() const Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::is_valid() const |
111 | | |
112 | | Json get_result() |
113 | 2.15k | { |
114 | 2.15k | JSONCONS_ASSERT(is_valid_); |
115 | 2.15k | is_valid_ = false; |
116 | 2.15k | return std::move(result_); |
117 | 2.15k | } jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::get_result() Line | Count | Source | 113 | 2.15k | { | 114 | 2.15k | JSONCONS_ASSERT(is_valid_); | 115 | 2.15k | is_valid_ = false; | 116 | 2.15k | return std::move(result_); | 117 | 2.15k | } |
Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::get_result() Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::get_result() Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::get_result() |
118 | | |
119 | | private: |
120 | | |
121 | | void visit_flush() override |
122 | 2.34k | { |
123 | 2.34k | } jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_flush() Line | Count | Source | 122 | 2.34k | { | 123 | 2.34k | } |
Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_flush() Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_flush() Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_flush() |
124 | | |
125 | | JSONCONS_VISITOR_RETURN_TYPE visit_begin_object(semantic_tag tag, const ser_context&, std::error_code&) override |
126 | 172k | { |
127 | 172k | if (structure_stack_.back().type_ == structure_type::root_t) |
128 | 1.98k | { |
129 | 1.98k | index_ = 0; |
130 | 1.98k | item_stack_.clear(); |
131 | 1.98k | is_valid_ = false; |
132 | 1.98k | } |
133 | 172k | item_stack_.emplace_back(std::move(name_), index_++, json_object_arg, tag); |
134 | 172k | structure_stack_.emplace_back(structure_type::object_t, item_stack_.size()-1); |
135 | 172k | JSONCONS_VISITOR_RETURN; |
136 | 172k | } jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_begin_object(jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Line | Count | Source | 126 | 172k | { | 127 | 172k | if (structure_stack_.back().type_ == structure_type::root_t) | 128 | 1.98k | { | 129 | 1.98k | index_ = 0; | 130 | 1.98k | item_stack_.clear(); | 131 | 1.98k | is_valid_ = false; | 132 | 1.98k | } | 133 | 172k | item_stack_.emplace_back(std::move(name_), index_++, json_object_arg, tag); | 134 | 172k | structure_stack_.emplace_back(structure_type::object_t, item_stack_.size()-1); | 135 | 172k | JSONCONS_VISITOR_RETURN; | 136 | 172k | } |
Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_begin_object(jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_begin_object(jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_begin_object(jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) |
137 | | |
138 | | JSONCONS_VISITOR_RETURN_TYPE visit_end_object(const ser_context&, std::error_code&) override |
139 | 169k | { |
140 | 169k | JSONCONS_ASSERT(structure_stack_.size() > 0); |
141 | 169k | JSONCONS_ASSERT(structure_stack_.back().type_ == structure_type::object_t); |
142 | 169k | const size_t structure_index = structure_stack_.back().container_index_; |
143 | 169k | JSONCONS_ASSERT(item_stack_.size() > structure_index); |
144 | 169k | const size_t count = item_stack_.size() - (structure_index + 1); |
145 | 169k | auto first = item_stack_.begin() + (structure_index+1); |
146 | | |
147 | 169k | if (count > 0) |
148 | 17.3k | { |
149 | 17.3k | item_stack_[structure_index].value.template cast<typename Json::object_storage>().value().uninitialized_init( |
150 | 17.3k | &item_stack_[structure_index+1], count); |
151 | 17.3k | } |
152 | | |
153 | 169k | item_stack_.erase(first, item_stack_.end()); |
154 | 169k | structure_stack_.pop_back(); |
155 | 169k | if (structure_stack_.back().type_ == structure_type::root_t) |
156 | 1.50k | { |
157 | 1.50k | result_.swap(item_stack_.front().value); |
158 | 1.50k | item_stack_.pop_back(); |
159 | 1.50k | is_valid_ = true; |
160 | 1.50k | JSONCONS_VISITOR_RETURN; |
161 | 1.50k | } |
162 | 169k | JSONCONS_VISITOR_RETURN; |
163 | 169k | } jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_end_object(jsoncons::ser_context const&, std::__1::error_code&) Line | Count | Source | 139 | 169k | { | 140 | 169k | JSONCONS_ASSERT(structure_stack_.size() > 0); | 141 | 169k | JSONCONS_ASSERT(structure_stack_.back().type_ == structure_type::object_t); | 142 | 169k | const size_t structure_index = structure_stack_.back().container_index_; | 143 | 169k | JSONCONS_ASSERT(item_stack_.size() > structure_index); | 144 | 169k | const size_t count = item_stack_.size() - (structure_index + 1); | 145 | 169k | auto first = item_stack_.begin() + (structure_index+1); | 146 | | | 147 | 169k | if (count > 0) | 148 | 17.3k | { | 149 | 17.3k | item_stack_[structure_index].value.template cast<typename Json::object_storage>().value().uninitialized_init( | 150 | 17.3k | &item_stack_[structure_index+1], count); | 151 | 17.3k | } | 152 | | | 153 | 169k | item_stack_.erase(first, item_stack_.end()); | 154 | 169k | structure_stack_.pop_back(); | 155 | 169k | if (structure_stack_.back().type_ == structure_type::root_t) | 156 | 1.50k | { | 157 | 1.50k | result_.swap(item_stack_.front().value); | 158 | 1.50k | item_stack_.pop_back(); | 159 | 1.50k | is_valid_ = true; | 160 | 1.50k | JSONCONS_VISITOR_RETURN; | 161 | 1.50k | } | 162 | 168k | JSONCONS_VISITOR_RETURN; | 163 | 169k | } |
Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_end_object(jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_end_object(jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_end_object(jsoncons::ser_context const&, std::__1::error_code&) |
164 | | |
165 | | JSONCONS_VISITOR_RETURN_TYPE visit_begin_array(semantic_tag tag, const ser_context&, std::error_code&) override |
166 | 184k | { |
167 | 184k | if (structure_stack_.back().type_ == structure_type::root_t) |
168 | 1.75k | { |
169 | 1.75k | index_ = 0; |
170 | 1.75k | item_stack_.clear(); |
171 | 1.75k | is_valid_ = false; |
172 | 1.75k | } |
173 | 184k | item_stack_.emplace_back(std::move(name_), index_++, json_array_arg, tag); |
174 | 184k | structure_stack_.emplace_back(structure_type::array_t, item_stack_.size()-1); |
175 | 184k | JSONCONS_VISITOR_RETURN; |
176 | 184k | } jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_begin_array(jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Line | Count | Source | 166 | 184k | { | 167 | 184k | if (structure_stack_.back().type_ == structure_type::root_t) | 168 | 1.75k | { | 169 | 1.75k | index_ = 0; | 170 | 1.75k | item_stack_.clear(); | 171 | 1.75k | is_valid_ = false; | 172 | 1.75k | } | 173 | 184k | item_stack_.emplace_back(std::move(name_), index_++, json_array_arg, tag); | 174 | 184k | structure_stack_.emplace_back(structure_type::array_t, item_stack_.size()-1); | 175 | 184k | JSONCONS_VISITOR_RETURN; | 176 | 184k | } |
Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_begin_array(jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_begin_array(jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_begin_array(jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) |
177 | | |
178 | | JSONCONS_VISITOR_RETURN_TYPE visit_end_array(const ser_context&, std::error_code&) override |
179 | 27.0k | { |
180 | 27.0k | JSONCONS_ASSERT(structure_stack_.size() > 1); |
181 | 27.0k | JSONCONS_ASSERT(structure_stack_.back().type_ == structure_type::array_t); |
182 | 27.0k | const size_t container_index = structure_stack_.back().container_index_; |
183 | 27.0k | JSONCONS_ASSERT(item_stack_.size() > container_index); |
184 | | |
185 | 27.0k | auto& container = item_stack_[container_index].value; |
186 | | |
187 | 27.0k | const size_t size = item_stack_.size() - (container_index + 1); |
188 | | //std::cout << "size on item stack: " << size << "\n"; |
189 | | |
190 | 27.0k | if (size > 0) |
191 | 7.89k | { |
192 | 7.89k | container.reserve(size); |
193 | 7.89k | auto first = item_stack_.begin() + (container_index+1); |
194 | 7.89k | auto last = first + size; |
195 | 4.65M | for (auto it = first; it != last; ++it) |
196 | 4.64M | { |
197 | 4.64M | container.push_back(std::move((*it).value)); |
198 | 4.64M | } |
199 | 7.89k | item_stack_.erase(first, item_stack_.end()); |
200 | 7.89k | } |
201 | | |
202 | 27.0k | structure_stack_.pop_back(); |
203 | 27.0k | if (structure_stack_.back().type_ == structure_type::root_t) |
204 | 253 | { |
205 | 253 | result_.swap(item_stack_.front().value); |
206 | 253 | item_stack_.pop_back(); |
207 | 253 | is_valid_ = true; |
208 | 253 | JSONCONS_VISITOR_RETURN; |
209 | 253 | } |
210 | 27.0k | JSONCONS_VISITOR_RETURN; |
211 | 27.0k | } jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_end_array(jsoncons::ser_context const&, std::__1::error_code&) Line | Count | Source | 179 | 27.0k | { | 180 | 27.0k | JSONCONS_ASSERT(structure_stack_.size() > 1); | 181 | 27.0k | JSONCONS_ASSERT(structure_stack_.back().type_ == structure_type::array_t); | 182 | 27.0k | const size_t container_index = structure_stack_.back().container_index_; | 183 | 27.0k | JSONCONS_ASSERT(item_stack_.size() > container_index); | 184 | | | 185 | 27.0k | auto& container = item_stack_[container_index].value; | 186 | | | 187 | 27.0k | const size_t size = item_stack_.size() - (container_index + 1); | 188 | | //std::cout << "size on item stack: " << size << "\n"; | 189 | | | 190 | 27.0k | if (size > 0) | 191 | 7.89k | { | 192 | 7.89k | container.reserve(size); | 193 | 7.89k | auto first = item_stack_.begin() + (container_index+1); | 194 | 7.89k | auto last = first + size; | 195 | 4.65M | for (auto it = first; it != last; ++it) | 196 | 4.64M | { | 197 | 4.64M | container.push_back(std::move((*it).value)); | 198 | 4.64M | } | 199 | 7.89k | item_stack_.erase(first, item_stack_.end()); | 200 | 7.89k | } | 201 | | | 202 | 27.0k | structure_stack_.pop_back(); | 203 | 27.0k | if (structure_stack_.back().type_ == structure_type::root_t) | 204 | 253 | { | 205 | 253 | result_.swap(item_stack_.front().value); | 206 | 253 | item_stack_.pop_back(); | 207 | 253 | is_valid_ = true; | 208 | 253 | JSONCONS_VISITOR_RETURN; | 209 | 253 | } | 210 | 26.7k | JSONCONS_VISITOR_RETURN; | 211 | 27.0k | } |
Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_end_array(jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_end_array(jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_end_array(jsoncons::ser_context const&, std::__1::error_code&) |
212 | | |
213 | | JSONCONS_VISITOR_RETURN_TYPE visit_key(const string_view_type& name, const ser_context&, std::error_code&) override |
214 | 2.95M | { |
215 | 2.95M | name_ = key_type(name.data(),name.length(),allocator_); |
216 | 2.95M | JSONCONS_VISITOR_RETURN; |
217 | 2.95M | } jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_key(std::__1::basic_string_view<char, std::__1::char_traits<char> > const&, jsoncons::ser_context const&, std::__1::error_code&) Line | Count | Source | 214 | 2.95M | { | 215 | 2.95M | name_ = key_type(name.data(),name.length(),allocator_); | 216 | 2.95M | JSONCONS_VISITOR_RETURN; | 217 | 2.95M | } |
Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_key(std::__1::basic_string_view<wchar_t, std::__1::char_traits<wchar_t> > const&, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_key(std::__1::basic_string_view<char, std::__1::char_traits<char> > const&, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_key(std::__1::basic_string_view<wchar_t, std::__1::char_traits<wchar_t> > const&, jsoncons::ser_context const&, std::__1::error_code&) |
218 | | |
219 | | JSONCONS_VISITOR_RETURN_TYPE visit_string(const string_view_type& sv, semantic_tag tag, const ser_context&, std::error_code&) override |
220 | 86.6k | { |
221 | 86.6k | switch (structure_stack_.back().type_) |
222 | 86.6k | { |
223 | 6.23k | case structure_type::object_t: |
224 | 86.3k | case structure_type::array_t: |
225 | 86.3k | item_stack_.emplace_back(std::move(name_), index_++, sv, tag); |
226 | 86.3k | break; |
227 | 300 | case structure_type::root_t: |
228 | 300 | result_ = Json(sv, tag, allocator_); |
229 | 300 | is_valid_ = true; |
230 | 300 | JSONCONS_VISITOR_RETURN; |
231 | 86.6k | } |
232 | 86.6k | JSONCONS_VISITOR_RETURN; |
233 | 86.6k | } jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_string(std::__1::basic_string_view<char, std::__1::char_traits<char> > const&, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Line | Count | Source | 220 | 86.6k | { | 221 | 86.6k | switch (structure_stack_.back().type_) | 222 | 86.6k | { | 223 | 6.23k | case structure_type::object_t: | 224 | 86.3k | case structure_type::array_t: | 225 | 86.3k | item_stack_.emplace_back(std::move(name_), index_++, sv, tag); | 226 | 86.3k | break; | 227 | 300 | case structure_type::root_t: | 228 | 300 | result_ = Json(sv, tag, allocator_); | 229 | 300 | is_valid_ = true; | 230 | 300 | JSONCONS_VISITOR_RETURN; | 231 | 86.6k | } | 232 | 86.3k | JSONCONS_VISITOR_RETURN; | 233 | 86.6k | } |
Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_string(std::__1::basic_string_view<wchar_t, std::__1::char_traits<wchar_t> > const&, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_string(std::__1::basic_string_view<char, std::__1::char_traits<char> > const&, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_string(std::__1::basic_string_view<wchar_t, std::__1::char_traits<wchar_t> > const&, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) |
234 | | |
235 | | JSONCONS_VISITOR_RETURN_TYPE visit_byte_string(const byte_string_view& b, |
236 | | semantic_tag tag, |
237 | | const ser_context&, |
238 | | std::error_code&) override |
239 | 0 | { |
240 | 0 | switch (structure_stack_.back().type_) |
241 | 0 | { |
242 | 0 | case structure_type::object_t: |
243 | 0 | case structure_type::array_t: |
244 | 0 | item_stack_.emplace_back(std::move(name_), index_++, byte_string_arg, b, tag); |
245 | 0 | break; |
246 | 0 | case structure_type::root_t: |
247 | 0 | result_ = Json(byte_string_arg, b, tag, allocator_); |
248 | 0 | is_valid_ = true; |
249 | 0 | JSONCONS_VISITOR_RETURN; |
250 | 0 | } |
251 | 0 | JSONCONS_VISITOR_RETURN; |
252 | 0 | } Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_byte_string(jsoncons::byte_string_view const&, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_byte_string(jsoncons::byte_string_view const&, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_byte_string(jsoncons::byte_string_view const&, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_byte_string(jsoncons::byte_string_view const&, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) |
253 | | |
254 | | JSONCONS_VISITOR_RETURN_TYPE visit_byte_string(const byte_string_view& b, |
255 | | uint64_t ext_tag, |
256 | | const ser_context&, |
257 | | std::error_code&) override |
258 | 0 | { |
259 | 0 | switch (structure_stack_.back().type_) |
260 | 0 | { |
261 | 0 | case structure_type::object_t: |
262 | 0 | case structure_type::array_t: |
263 | 0 | item_stack_.emplace_back(std::move(name_), index_++, byte_string_arg, b, ext_tag); |
264 | 0 | break; |
265 | 0 | case structure_type::root_t: |
266 | 0 | result_ = Json(byte_string_arg, b, ext_tag, allocator_); |
267 | 0 | is_valid_ = true; |
268 | 0 | JSONCONS_VISITOR_RETURN; |
269 | 0 | } |
270 | 0 | JSONCONS_VISITOR_RETURN; |
271 | 0 | } Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_byte_string(jsoncons::byte_string_view const&, unsigned long, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_byte_string(jsoncons::byte_string_view const&, unsigned long, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_byte_string(jsoncons::byte_string_view const&, unsigned long, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_byte_string(jsoncons::byte_string_view const&, unsigned long, jsoncons::ser_context const&, std::__1::error_code&) |
272 | | |
273 | | JSONCONS_VISITOR_RETURN_TYPE visit_int64(int64_t value, |
274 | | semantic_tag tag, |
275 | | const ser_context&, |
276 | | std::error_code&) override |
277 | 57.1k | { |
278 | 57.1k | switch (structure_stack_.back().type_) |
279 | 57.1k | { |
280 | 6.66k | case structure_type::object_t: |
281 | 57.0k | case structure_type::array_t: |
282 | 57.0k | item_stack_.emplace_back(std::move(name_), index_++, value, tag); |
283 | 57.0k | break; |
284 | 124 | case structure_type::root_t: |
285 | 124 | result_ = Json(value,tag); |
286 | 124 | is_valid_ = true; |
287 | 124 | JSONCONS_VISITOR_RETURN; |
288 | 57.1k | } |
289 | 57.1k | JSONCONS_VISITOR_RETURN; |
290 | 57.1k | } jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_int64(long, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Line | Count | Source | 277 | 57.1k | { | 278 | 57.1k | switch (structure_stack_.back().type_) | 279 | 57.1k | { | 280 | 6.66k | case structure_type::object_t: | 281 | 57.0k | case structure_type::array_t: | 282 | 57.0k | item_stack_.emplace_back(std::move(name_), index_++, value, tag); | 283 | 57.0k | break; | 284 | 124 | case structure_type::root_t: | 285 | 124 | result_ = Json(value,tag); | 286 | 124 | is_valid_ = true; | 287 | 124 | JSONCONS_VISITOR_RETURN; | 288 | 57.1k | } | 289 | 57.0k | JSONCONS_VISITOR_RETURN; | 290 | 57.1k | } |
Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_int64(long, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_int64(long, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_int64(long, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) |
291 | | |
292 | | JSONCONS_VISITOR_RETURN_TYPE visit_uint64(uint64_t value, |
293 | | semantic_tag tag, |
294 | | const ser_context&, |
295 | | std::error_code&) override |
296 | 15.9M | { |
297 | 15.9M | switch (structure_stack_.back().type_) |
298 | 15.9M | { |
299 | 2.86M | case structure_type::object_t: |
300 | 15.9M | case structure_type::array_t: |
301 | 15.9M | item_stack_.emplace_back(std::move(name_), index_++, value, tag); |
302 | 15.9M | break; |
303 | 147 | case structure_type::root_t: |
304 | 147 | result_ = Json(value,tag); |
305 | 147 | is_valid_ = true; |
306 | 147 | JSONCONS_VISITOR_RETURN; |
307 | 15.9M | } |
308 | 15.9M | JSONCONS_VISITOR_RETURN; |
309 | 15.9M | } jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_uint64(unsigned long, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Line | Count | Source | 296 | 15.9M | { | 297 | 15.9M | switch (structure_stack_.back().type_) | 298 | 15.9M | { | 299 | 2.86M | case structure_type::object_t: | 300 | 15.9M | case structure_type::array_t: | 301 | 15.9M | item_stack_.emplace_back(std::move(name_), index_++, value, tag); | 302 | 15.9M | break; | 303 | 147 | case structure_type::root_t: | 304 | 147 | result_ = Json(value,tag); | 305 | 147 | is_valid_ = true; | 306 | 147 | JSONCONS_VISITOR_RETURN; | 307 | 15.9M | } | 308 | 15.9M | JSONCONS_VISITOR_RETURN; | 309 | 15.9M | } |
Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_uint64(unsigned long, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_uint64(unsigned long, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_uint64(unsigned long, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) |
310 | | |
311 | | JSONCONS_VISITOR_RETURN_TYPE visit_half(uint16_t value, |
312 | | semantic_tag tag, |
313 | | const ser_context&, |
314 | | std::error_code&) override |
315 | 0 | { |
316 | 0 | switch (structure_stack_.back().type_) |
317 | 0 | { |
318 | 0 | case structure_type::object_t: |
319 | 0 | case structure_type::array_t: |
320 | 0 | item_stack_.emplace_back(std::move(name_), index_++, half_arg, value, tag); |
321 | 0 | break; |
322 | 0 | case structure_type::root_t: |
323 | 0 | result_ = Json(half_arg, value, tag); |
324 | 0 | is_valid_ = true; |
325 | 0 | JSONCONS_VISITOR_RETURN; |
326 | 0 | } |
327 | 0 | JSONCONS_VISITOR_RETURN; |
328 | 0 | } Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_half(unsigned short, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_half(unsigned short, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_half(unsigned short, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_half(unsigned short, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) |
329 | | |
330 | | JSONCONS_VISITOR_RETURN_TYPE visit_double(double value, |
331 | | semantic_tag tag, |
332 | | const ser_context&, |
333 | | std::error_code&) override |
334 | 51.8k | { |
335 | 51.8k | switch (structure_stack_.back().type_) |
336 | 51.8k | { |
337 | 2.88k | case structure_type::object_t: |
338 | 51.8k | case structure_type::array_t: |
339 | 51.8k | item_stack_.emplace_back(std::move(name_), index_++, value, tag); |
340 | 51.8k | break; |
341 | 19 | case structure_type::root_t: |
342 | 19 | result_ = Json(value, tag); |
343 | 19 | is_valid_ = true; |
344 | 19 | JSONCONS_VISITOR_RETURN; |
345 | 51.8k | } |
346 | 51.8k | JSONCONS_VISITOR_RETURN; |
347 | 51.8k | } jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_double(double, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Line | Count | Source | 334 | 51.8k | { | 335 | 51.8k | switch (structure_stack_.back().type_) | 336 | 51.8k | { | 337 | 2.88k | case structure_type::object_t: | 338 | 51.8k | case structure_type::array_t: | 339 | 51.8k | item_stack_.emplace_back(std::move(name_), index_++, value, tag); | 340 | 51.8k | break; | 341 | 19 | case structure_type::root_t: | 342 | 19 | result_ = Json(value, tag); | 343 | 19 | is_valid_ = true; | 344 | 19 | JSONCONS_VISITOR_RETURN; | 345 | 51.8k | } | 346 | 51.8k | JSONCONS_VISITOR_RETURN; | 347 | 51.8k | } |
Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_double(double, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_double(double, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_double(double, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) |
348 | | |
349 | | JSONCONS_VISITOR_RETURN_TYPE visit_bool(bool value, semantic_tag tag, const ser_context&, std::error_code&) override |
350 | 5.56k | { |
351 | 5.56k | switch (structure_stack_.back().type_) |
352 | 5.56k | { |
353 | 226 | case structure_type::object_t: |
354 | 5.56k | case structure_type::array_t: |
355 | 5.56k | item_stack_.emplace_back(std::move(name_), index_++, value, tag); |
356 | 5.56k | break; |
357 | 2 | case structure_type::root_t: |
358 | 2 | result_ = Json(value, tag); |
359 | 2 | is_valid_ = true; |
360 | 2 | JSONCONS_VISITOR_RETURN; |
361 | 5.56k | } |
362 | 5.56k | JSONCONS_VISITOR_RETURN; |
363 | 5.56k | } jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_bool(bool, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Line | Count | Source | 350 | 5.56k | { | 351 | 5.56k | switch (structure_stack_.back().type_) | 352 | 5.56k | { | 353 | 226 | case structure_type::object_t: | 354 | 5.56k | case structure_type::array_t: | 355 | 5.56k | item_stack_.emplace_back(std::move(name_), index_++, value, tag); | 356 | 5.56k | break; | 357 | 2 | case structure_type::root_t: | 358 | 2 | result_ = Json(value, tag); | 359 | 2 | is_valid_ = true; | 360 | 2 | JSONCONS_VISITOR_RETURN; | 361 | 5.56k | } | 362 | 5.56k | JSONCONS_VISITOR_RETURN; | 363 | 5.56k | } |
Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_bool(bool, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_bool(bool, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_bool(bool, jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) |
364 | | |
365 | | JSONCONS_VISITOR_RETURN_TYPE visit_null(semantic_tag tag, const ser_context&, std::error_code&) override |
366 | 9.63k | { |
367 | 9.63k | switch (structure_stack_.back().type_) |
368 | 9.63k | { |
369 | 282 | case structure_type::object_t: |
370 | 9.63k | case structure_type::array_t: |
371 | 9.63k | item_stack_.emplace_back(std::move(name_), index_++, null_type(), tag); |
372 | 9.63k | break; |
373 | 1 | case structure_type::root_t: |
374 | 1 | result_ = Json(null_type(), tag); |
375 | 1 | is_valid_ = true; |
376 | 1 | JSONCONS_VISITOR_RETURN; |
377 | 9.63k | } |
378 | 9.63k | JSONCONS_VISITOR_RETURN; |
379 | 9.63k | } jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_null(jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Line | Count | Source | 366 | 9.63k | { | 367 | 9.63k | switch (structure_stack_.back().type_) | 368 | 9.63k | { | 369 | 282 | case structure_type::object_t: | 370 | 9.63k | case structure_type::array_t: | 371 | 9.63k | item_stack_.emplace_back(std::move(name_), index_++, null_type(), tag); | 372 | 9.63k | break; | 373 | 1 | case structure_type::root_t: | 374 | 1 | result_ = Json(null_type(), tag); | 375 | 1 | is_valid_ = true; | 376 | 1 | JSONCONS_VISITOR_RETURN; | 377 | 9.63k | } | 378 | 9.63k | JSONCONS_VISITOR_RETURN; | 379 | 9.63k | } |
Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::sorted_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_null(jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<char, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_null(jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) Unexecuted instantiation: jsoncons::json_decoder<jsoncons::basic_json<wchar_t, jsoncons::order_preserving_policy, std::__1::allocator<char> >, std::__1::allocator<char> >::visit_null(jsoncons::semantic_tag, jsoncons::ser_context const&, std::__1::error_code&) |
380 | | }; |
381 | | |
382 | | } // namespace jsoncons |
383 | | |
384 | | #endif // JSONCONS_JSON_DECODER_HPP |