MCPcopy Create free account
hub / github.com/OpenDriveLab/OpenLane / operator()

Method operator()

eval/LANE_evaluation/lane2d/src/CJsonObject.cpp:349–431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

347}
348
349std::string CJsonObject::operator()(const std::string& strKey) const
350{
351 cJSON* pJsonStruct = NULL;
352 if (m_pJsonData != NULL)
353 {
354 if (m_pJsonData->type == cJSON_Object)
355 {
356 pJsonStruct = cJSON_GetObjectItem(m_pJsonData, strKey.c_str());
357 }
358 }
359 else if (m_pExternJsonDataRef != NULL)
360 {
361 if(m_pExternJsonDataRef->type == cJSON_Object)
362 {
363 pJsonStruct = cJSON_GetObjectItem(m_pExternJsonDataRef, strKey.c_str());
364 }
365 }
366 if (pJsonStruct == NULL)
367 {
368 return(std::string(""));
369 }
370 if (pJsonStruct->type == cJSON_String)
371 {
372 return(pJsonStruct->valuestring);
373 }
374 else if (pJsonStruct->type == cJSON_Int)
375 {
376 char szNumber[128] = {0};
377 if (pJsonStruct->sign == -1)
378 {
379 if (pJsonStruct->valueint <= (int64)INT_MAX && (int64)pJsonStruct->valueint >= (int64)INT_MIN)
380 {
381 snprintf(szNumber, sizeof(szNumber), "%d", (int32)pJsonStruct->valueint);
382 }
383 else
384 {
385#if LLONG_MAX==LONG_MAX
386 snprintf(szNumber, sizeof(szNumber), "%ld", (int64)pJsonStruct->valueint);
387#else
388 snprintf(szNumber, sizeof(szNumber), "%lld", (int64)pJsonStruct->valueint);
389#endif
390 }
391 }
392 else
393 {
394 if ((uint64)pJsonStruct->valueint <= (uint64)UINT_MAX)
395 {
396 snprintf(szNumber, sizeof(szNumber), "%u", (uint32)pJsonStruct->valueint);
397 }
398 else
399 {
400#if LLONG_MAX==LONG_MAX
401 snprintf(szNumber, sizeof(szNumber), "%lu", pJsonStruct->valueint);
402#else
403 snprintf(szNumber, sizeof(szNumber), "%llu", pJsonStruct->valueint);
404#endif
405 }
406 }

Callers

nothing calls this directly

Calls 2

cJSON_GetObjectItemFunction · 0.85
cJSON_GetArrayItemFunction · 0.85

Tested by

no test coverage detected