MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / push_back

Function push_back

native/thirdpart/json/json.hpp:19406–19427  ·  view source on GitHub ↗

! @brief add an object to an array Appends the given element @a val to the end of the JSON value. If the function is called on a JSON null value, an empty array is created before appending @a val. @param[in] val the value to add to the JSON array @throw type_error.308 when called on a type other than JSON array or null; example: `"cannot use push_back() with number"`

Source from the content-addressed store, hash-verified

19404 @since version 1.0.0
19405 */
19406 void push_back(basic_json&& val)
19407 {
19408 // push_back only works for null objects or arrays
19409 if (JSON_HEDLEY_UNLIKELY(not(is_null() or is_array())))
19410 {
19411 JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name())));
19412 }
19413
19414 // transform null object into an array
19415 if (is_null())
19416 {
19417 m_type = value_t::array;
19418 m_value = value_t::array;
19419 assert_invariant();
19420 }
19421
19422 // add element to array (move semantics)
19423 m_value.array->push_back(std::move(val));
19424 // invalidate object: mark it null so we do not call the destructor
19425 // cppcheck-suppress accessMoved
19426 val.m_type = value_t::null;
19427 }
19428
19429 /*!
19430 @brief add an object to an array

Callers 2

json_pointerClass · 0.85
operator+=Function · 0.85

Calls 10

is_nullFunction · 0.85
is_arrayFunction · 0.85
createFunction · 0.85
assert_invariantFunction · 0.85
is_objectFunction · 0.85
push_backMethod · 0.80
moved_or_copiedMethod · 0.80
basic_jsonFunction · 0.70
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected