MCPcopy Create free account
hub / github.com/OpenDriveLab/OpenLane / AddNullAsFirst

Method AddNullAsFirst

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

Source from the content-addressed store, hash-verified

3676}
3677
3678bool CJsonObject::AddNullAsFirst()
3679{
3680 cJSON* pFocusData = NULL;
3681 if (m_pJsonData != NULL)
3682 {
3683 pFocusData = m_pJsonData;
3684 }
3685 else if (m_pExternJsonDataRef != NULL)
3686 {
3687 pFocusData = m_pExternJsonDataRef;
3688 }
3689 else
3690 {
3691 m_pJsonData = cJSON_CreateArray();
3692 pFocusData = m_pJsonData;
3693 }
3694
3695 if (pFocusData == NULL)
3696 {
3697 m_strErrMsg = "json data is null!";
3698 return(false);
3699 }
3700 if (pFocusData->type != cJSON_Array)
3701 {
3702 m_strErrMsg = "not a json array! json object?";
3703 return(false);
3704 }
3705 cJSON* pJsonStruct = cJSON_CreateNull();
3706 if (pJsonStruct == NULL)
3707 {
3708 return(false);
3709 }
3710 int iArraySizeBeforeAdd = cJSON_GetArraySize(pFocusData);
3711 cJSON_AddItemToArrayHead(pFocusData, pJsonStruct);
3712 int iArraySizeAfterAdd = cJSON_GetArraySize(pFocusData);
3713 if (iArraySizeAfterAdd == iArraySizeBeforeAdd)
3714 {
3715 return(false);
3716 }
3717 return(true);
3718}
3719
3720bool CJsonObject::Delete(int iWhich)
3721{

Callers

nothing calls this directly

Calls 4

cJSON_CreateArrayFunction · 0.85
cJSON_CreateNullFunction · 0.85
cJSON_GetArraySizeFunction · 0.85
cJSON_AddItemToArrayHeadFunction · 0.85

Tested by

no test coverage detected