MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / at

Function at

include/behaviortree_cpp/contrib/json.hpp:21240–21254  ·  view source on GitHub ↗

@brief access specified array element with bounds checking @sa https://json.nlohmann.me/api/basic_json/at/

Source from the content-addressed store, hash-verified

21238 /// @brief access specified array element with bounds checking
21239 /// @sa https://json.nlohmann.me/api/basic_json/at/
21240 reference at(size_type idx)
21241 {
21242 // at only works for arrays
21243 if (JSON_HEDLEY_LIKELY(is_array()))
21244 {
21245 JSON_TRY
21246 {
21247 return set_parent(m_data.m_value.array->at(idx));
21248 }
21249 JSON_CATCH (std::out_of_range&)
21250 {
21251 // create better exception explanation
21252 JSON_THROW(out_of_range::create(401, detail::concat("array index ", std::to_string(idx), " is out of range"), this));
21253 }
21254 }
21255 else
21256 {
21257 JSON_THROW(type_error::create(304, detail::concat("cannot use at() with ", type_name()), this));

Callers 2

operator==Method · 0.85
json.hppFile · 0.85

Calls 7

is_arrayFunction · 0.85
set_parentFunction · 0.85
is_objectFunction · 0.85
createFunction · 0.85
concatFunction · 0.85
type_nameFunction · 0.70
endMethod · 0.45

Tested by

no test coverage detected