| 3233 | |
| 3234 | #if __cplusplus < 201101L |
| 3235 | bool 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 |
| 3288 | bool CJsonObject::AddAsFirst(CJsonObject&& oJsonObject) |
| 3289 | { |
nothing calls this directly
no test coverage detected