MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / flatten_and_destroy

Method flatten_and_destroy

include/jsoncons/json_array.hpp:245–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243 private:
244
245 void flatten_and_destroy() noexcept
246 {
247 while (!elements_.empty())
248 {
249 value_type current = std::move(elements_.back());
250 elements_.pop_back();
251 switch (current.storage_kind())
252 {
253 case json_storage_kind::array:
254 {
255 for (auto&& item : current.array_range())
256 {
257 if ((item.storage_kind() == json_storage_kind::array || item.storage_kind() == json_storage_kind::object)
258 && !item.empty()) // non-empty object or array
259 {
260 elements_.push_back(std::move(item));
261 }
262 }
263 current.clear();
264 break;
265 }
266 case json_storage_kind::object:
267 {
268 for (auto&& kv : current.object_range())
269 {
270 if ((kv.value().storage_kind() == json_storage_kind::array || kv.value().storage_kind() == json_storage_kind::object)
271 && !kv.value().empty()) // non-empty object or array
272 {
273 elements_.push_back(std::move(kv.value()));
274 }
275 }
276 current.clear();
277 break;
278 }
279 default:
280 break;
281 }
282 }
283 }
284 };
285
286} // namespace jsoncons

Callers

nothing calls this directly

Calls 6

pop_backMethod · 0.80
emptyMethod · 0.45
backMethod · 0.45
push_backMethod · 0.45
clearMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected