MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / erase

Function erase

dependencies/json/json.hpp:20599–20660  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20597 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value, int >::type
20598 = 0 >
20599 IteratorType erase(IteratorType pos)
20600 {
20601 // make sure iterator fits the current value
20602 if (JSON_HEDLEY_UNLIKELY(this != pos.m_object))
20603 {
20604 JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
20605 }
20606
20607 IteratorType result = end();
20608
20609 switch (m_type)
20610 {
20611 case value_t::boolean:
20612 case value_t::number_float:
20613 case value_t::number_integer:
20614 case value_t::number_unsigned:
20615 case value_t::string:
20616 case value_t::binary:
20617 {
20618 if (JSON_HEDLEY_UNLIKELY(!pos.m_it.primitive_iterator.is_begin()))
20619 {
20620 JSON_THROW(invalid_iterator::create(205, "iterator out of range"));
20621 }
20622
20623 if (is_string())
20624 {
20625 AllocatorType<string_t> alloc;
20626 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.string);
20627 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1);
20628 m_value.string = nullptr;
20629 }
20630 else if (is_binary())
20631 {
20632 AllocatorType<binary_t> alloc;
20633 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.binary);
20634 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.binary, 1);
20635 m_value.binary = nullptr;
20636 }
20637
20638 m_type = value_t::null;
20639 assert_invariant();
20640 break;
20641 }
20642
20643 case value_t::object:
20644 {
20645 result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator);
20646 break;
20647 }
20648
20649 case value_t::array:
20650 {
20651 result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator);
20652 break;
20653 }
20654
20655 default:
20656 JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name())));

Callers 1

merge_patchFunction · 0.70

Calls 14

to_stringFunction · 0.85
createFunction · 0.70
endFunction · 0.70
is_stringFunction · 0.70
destroyFunction · 0.70
is_binaryFunction · 0.70
type_nameFunction · 0.70
is_objectFunction · 0.70
is_arrayFunction · 0.70
sizeFunction · 0.70
is_beginMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected