| 1726 | |
| 1727 | #if __cplusplus < 201101L |
| 1728 | bool CJsonObject::ReplaceWithMove(const std::string& strKey, CJsonObject& oJsonObject) |
| 1729 | { |
| 1730 | cJSON* pFocusData = NULL; |
| 1731 | if (m_pJsonData == NULL) |
| 1732 | { |
| 1733 | pFocusData = m_pExternJsonDataRef; |
| 1734 | } |
| 1735 | else |
| 1736 | { |
| 1737 | pFocusData = m_pJsonData; |
| 1738 | } |
| 1739 | if (pFocusData == NULL) |
| 1740 | { |
| 1741 | m_strErrMsg = "json data is null!"; |
| 1742 | return(false); |
| 1743 | } |
| 1744 | if (pFocusData->type != cJSON_Object) |
| 1745 | { |
| 1746 | m_strErrMsg = "not a json object! json array?"; |
| 1747 | return(false); |
| 1748 | } |
| 1749 | cJSON* pJsonStruct = oJsonObject.m_pJsonData; |
| 1750 | oJsonObject.m_pJsonData = NULL; |
| 1751 | if (pJsonStruct == NULL) |
| 1752 | { |
| 1753 | m_strErrMsg = "can not move a non-independent(internal) CJsonObject from one to another."; |
| 1754 | return(false); |
| 1755 | } |
| 1756 | cJSON_ReplaceItemInObject(pFocusData, strKey.c_str(), pJsonStruct); |
| 1757 | if (cJSON_GetObjectItem(pFocusData, strKey.c_str()) == NULL) |
| 1758 | { |
| 1759 | return(false); |
| 1760 | } |
| 1761 | std::map<std::string, CJsonObject*>::iterator iter = m_mapJsonObjectRef.find(strKey); |
| 1762 | if (iter != m_mapJsonObjectRef.end()) |
| 1763 | { |
| 1764 | if (iter->second != NULL) |
| 1765 | { |
| 1766 | delete (iter->second); |
| 1767 | iter->second = NULL; |
| 1768 | } |
| 1769 | m_mapJsonObjectRef.erase(iter); |
| 1770 | } |
| 1771 | return(true); |
| 1772 | } |
| 1773 | #else |
| 1774 | bool CJsonObject::Replace(const std::string& strKey, CJsonObject&& oJsonObject) |
| 1775 | { |
nothing calls this directly
no test coverage detected