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

Method Replace

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

Source from the content-addressed store, hash-verified

1676}
1677
1678bool CJsonObject::Replace(const std::string& strKey, const CJsonObject& oJsonObject)
1679{
1680 cJSON* pFocusData = NULL;
1681 if (m_pJsonData == NULL)
1682 {
1683 pFocusData = m_pExternJsonDataRef;
1684 }
1685 else
1686 {
1687 pFocusData = m_pJsonData;
1688 }
1689 if (pFocusData == NULL)
1690 {
1691 m_strErrMsg = "json data is null!";
1692 return(false);
1693 }
1694 if (pFocusData->type != cJSON_Object)
1695 {
1696 m_strErrMsg = "not a json object! json array?";
1697 return(false);
1698 }
1699 cJSON* pJsonStruct = cJSON_Parse(oJsonObject.ToString().c_str(), &mc_pError);
1700 if (pJsonStruct == NULL)
1701 {
1702 m_strErrMsg = std::string("prase json string error at ") + mc_pError;
1703 return(false);
1704 }
1705 cJSON_ReplaceItemInObject(pFocusData, strKey.c_str(), pJsonStruct);
1706 if (cJSON_GetObjectItem(pFocusData, strKey.c_str()) == NULL)
1707 {
1708 return(false);
1709 }
1710#if __cplusplus < 201101L
1711 std::map<std::string, CJsonObject*>::iterator iter = m_mapJsonObjectRef.find(strKey);
1712#else
1713 auto iter = m_mapJsonObjectRef.find(strKey);
1714#endif
1715 if (iter != m_mapJsonObjectRef.end())
1716 {
1717 if (iter->second != NULL)
1718 {
1719 delete (iter->second);
1720 iter->second = NULL;
1721 }
1722 m_mapJsonObjectRef.erase(iter);
1723 }
1724 return(true);
1725}
1726
1727#if __cplusplus < 201101L
1728bool CJsonObject::ReplaceWithMove(const std::string& strKey, CJsonObject& oJsonObject)

Callers

nothing calls this directly

Calls 10

cJSON_ParseFunction · 0.85
cJSON_GetObjectItemFunction · 0.85
cJSON_CreateStringFunction · 0.85
cJSON_CreateIntFunction · 0.85
cJSON_CreateBoolFunction · 0.85
cJSON_CreateDoubleFunction · 0.85
cJSON_ReplaceItemInArrayFunction · 0.85
cJSON_GetArrayItemFunction · 0.85
ToStringMethod · 0.80

Tested by

no test coverage detected