MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / operator[]

Function operator[]

include/behaviortree_cpp/contrib/json.hpp:13552–13584  ·  view source on GitHub ↗

! @brief access to successor @pre The iterator is initialized; i.e. `m_object != nullptr`. */

Source from the content-addressed store, hash-verified

13550 @pre The iterator is initialized; i.e. `m_object != nullptr`.
13551 */
13552 reference operator[](difference_type n) const
13553 {
13554 JSON_ASSERT(m_object != nullptr);
13555
13556 switch (m_object->m_data.m_type)
13557 {
13558 case value_t::object:
13559 JSON_THROW(invalid_iterator::create(208, "cannot use operator[] for object iterators", m_object));
13560
13561 case value_t::array:
13562 return *std::next(m_it.array_iterator, n);
13563
13564 case value_t::null:
13565 JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object));
13566
13567 case value_t::string:
13568 case value_t::boolean:
13569 case value_t::number_integer:
13570 case value_t::number_unsigned:
13571 case value_t::number_float:
13572 case value_t::binary:
13573 case value_t::discarded:
13574 default:
13575 {
13576 if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.get_value() == -n))
13577 {
13578 return *m_object;
13579 }
13580
13581 JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object));
13582 }
13583 }
13584 }
13585
13586 /*!
13587 @brief return the key of an object iterator

Callers

nothing calls this directly

Calls 14

createFunction · 0.85
is_nullFunction · 0.85
is_arrayFunction · 0.85
set_parentsFunction · 0.85
concatFunction · 0.85
is_objectFunction · 0.85
moveFunction · 0.85
set_parentFunction · 0.85
get_valueMethod · 0.80
operator[]Method · 0.80
beginFunction · 0.70
type_nameFunction · 0.70

Tested by

no test coverage detected