MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / insert

Function insert

external/json/json.hpp:17274–17290  ·  view source on GitHub ↗

! @brief inserts element Inserts element @a val before iterator @a pos. @param[in] pos iterator before which the content will be inserted; may be the end() iterator @param[in] val element to insert @return iterator pointing to the inserted @a val. @throw type_error.309 if called on JSON values other than arrays; example: `"cannot use insert() with string"` @t

Source from the content-addressed store, hash-verified

17272 @since version 1.0.0
17273 */
17274 iterator insert(const_iterator pos, const basic_json& val)
17275 {
17276 // insert only works for arrays
17277 if (JSON_LIKELY(is_array()))
17278 {
17279 // check if iterator pos fits to this JSON value
17280 if (JSON_UNLIKELY(pos.m_object != this))
17281 {
17282 JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
17283 }
17284
17285 // insert to array and return iterator
17286 return insert_iterator(pos, val);
17287 }
17288
17289 JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
17290 }
17291
17292 /*!
17293 @brief inserts element

Callers 1

fillMethod · 0.85

Calls 8

createFunction · 0.85
insert_iteratorFunction · 0.85
type_nameFunction · 0.85
is_objectFunction · 0.85
is_arrayFunction · 0.70
beginMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by 1

fillMethod · 0.68