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

Method AddAsFirstWithMove

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

Source from the content-addressed store, hash-verified

3233
3234#if __cplusplus < 201101L
3235bool CJsonObject::AddAsFirstWithMove(CJsonObject& oJsonObject)
3236{
3237 cJSON* pFocusData = NULL;
3238 if (m_pJsonData != NULL)
3239 {
3240 pFocusData = m_pJsonData;
3241 }
3242 else if (m_pExternJsonDataRef != NULL)
3243 {
3244 pFocusData = m_pExternJsonDataRef;
3245 }
3246 else
3247 {
3248 m_pJsonData = cJSON_CreateArray();
3249 pFocusData = m_pJsonData;
3250 }
3251
3252 if (pFocusData == NULL)
3253 {
3254 m_strErrMsg = "json data is null!";
3255 return(false);
3256 }
3257 if (pFocusData->type != cJSON_Array)
3258 {
3259 m_strErrMsg = "not a json array! json object?";
3260 return(false);
3261 }
3262 cJSON* pJsonStruct = oJsonObject.m_pJsonData;
3263 oJsonObject.m_pJsonData = NULL;
3264 if (pJsonStruct == NULL)
3265 {
3266 m_strErrMsg = "can not move a non-independent(internal) CJsonObject from one to another.";
3267 return(false);
3268 }
3269 int iArraySizeBeforeAdd = cJSON_GetArraySize(pFocusData);
3270 cJSON_AddItemToArrayHead(pFocusData, pJsonStruct);
3271 int iArraySizeAfterAdd = cJSON_GetArraySize(pFocusData);
3272 if (iArraySizeAfterAdd == iArraySizeBeforeAdd)
3273 {
3274 return(false);
3275 }
3276 for (std::map<unsigned int, CJsonObject*>::iterator iter = m_mapJsonArrayRef.begin(); iter != m_mapJsonArrayRef.end(); )
3277 {
3278 if (iter->second != NULL)
3279 {
3280 delete (iter->second);
3281 iter->second = NULL;
3282 }
3283 m_mapJsonArrayRef.erase(iter++);
3284 }
3285 return(true);
3286}
3287#else
3288bool CJsonObject::AddAsFirst(CJsonObject&& oJsonObject)
3289{

Callers

nothing calls this directly

Calls 3

cJSON_CreateArrayFunction · 0.85
cJSON_GetArraySizeFunction · 0.85
cJSON_AddItemToArrayHeadFunction · 0.85

Tested by

no test coverage detected