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

Function contains

dependencies/json/json.hpp:12268–12337  ·  view source on GitHub ↗

! @throw parse_error.106 if an array index begins with '0' @throw parse_error.109 if an array index was not a number */

Source from the content-addressed store, hash-verified

12266 @throw parse_error.109 if an array index was not a number
12267 */
12268 bool contains(const BasicJsonType* ptr) const
12269 {
12270 for (const auto& reference_token : reference_tokens)
12271 {
12272 switch (ptr->type())
12273 {
12274 case detail::value_t::object:
12275 {
12276 if (!ptr->contains(reference_token))
12277 {
12278 // we did not find the key in the object
12279 return false;
12280 }
12281
12282 ptr = &ptr->operator[](reference_token);
12283 break;
12284 }
12285
12286 case detail::value_t::array:
12287 {
12288 if (JSON_HEDLEY_UNLIKELY(reference_token == "-"))
12289 {
12290 // "-" always fails the range check
12291 return false;
12292 }
12293 if (JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !("0" <= reference_token && reference_token <= "9")))
12294 {
12295 // invalid char
12296 return false;
12297 }
12298 if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1))
12299 {
12300 if (JSON_HEDLEY_UNLIKELY(!('1' <= reference_token[0] && reference_token[0] <= '9')))
12301 {
12302 // first char should be between '1' and '9'
12303 return false;
12304 }
12305 for (std::size_t i = 1; i < reference_token.size(); i++)
12306 {
12307 if (JSON_HEDLEY_UNLIKELY(!('0' <= reference_token[i] && reference_token[i] <= '9')))
12308 {
12309 // other char should be between '0' and '9'
12310 return false;
12311 }
12312 }
12313 }
12314
12315 const auto idx = array_index(reference_token);
12316 if (idx >= ptr->size())
12317 {
12318 // index out of range
12319 return false;
12320 }
12321
12322 ptr = &ptr->operator[](idx);
12323 break;
12324 }
12325

Callers

nothing calls this directly

Calls 6

containsMethod · 0.80
is_objectFunction · 0.70
operator[]Method · 0.45
sizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected