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

Function erase

native/thirdpart/json/json.hpp:18240–18293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18238 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value, int>::type
18239 = 0>
18240 IteratorType erase(IteratorType pos)
18241 {
18242 // make sure iterator fits the current value
18243 if (JSON_HEDLEY_UNLIKELY(this != pos.m_object))
18244 {
18245 JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
18246 }
18247
18248 IteratorType result = end();
18249
18250 switch (m_type)
18251 {
18252 case value_t::boolean:
18253 case value_t::number_float:
18254 case value_t::number_integer:
18255 case value_t::number_unsigned:
18256 case value_t::string:
18257 {
18258 if (JSON_HEDLEY_UNLIKELY(not pos.m_it.primitive_iterator.is_begin()))
18259 {
18260 JSON_THROW(invalid_iterator::create(205, "iterator out of range"));
18261 }
18262
18263 if (is_string())
18264 {
18265 AllocatorType<string_t> alloc;
18266 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.string);
18267 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1);
18268 m_value.string = nullptr;
18269 }
18270
18271 m_type = value_t::null;
18272 assert_invariant();
18273 break;
18274 }
18275
18276 case value_t::object:
18277 {
18278 result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator);
18279 break;
18280 }
18281
18282 case value_t::array:
18283 {
18284 result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator);
18285 break;
18286 }
18287
18288 default:
18289 JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name())));
18290 }
18291
18292 return result;
18293 }
18294
18295 /*!
18296 @brief remove elements given an iterator range

Callers 1

merge_patchFunction · 0.85

Calls 12

createFunction · 0.85
is_stringFunction · 0.85
destroyFunction · 0.85
assert_invariantFunction · 0.85
is_objectFunction · 0.85
is_arrayFunction · 0.85
sizeFunction · 0.85
to_stringFunction · 0.85
is_beginMethod · 0.80
is_endMethod · 0.80
endFunction · 0.70
beginMethod · 0.45

Tested by

no test coverage detected