void
JsonArray::RemoveAll(bool deallocate)
{
- ClearLastResult();
-
int count = GetCount();
- SysTryReturnVoidResult(NID_WEB_JSON, count > 0, E_SUCCESS, "[E_SUCCESS] Count is zero.");
- if (deallocate == true)
+ if (count > 0)
{
- unique_ptr<JsonValueList> pList(GetItemsN(0, count));
- SysTryReturnVoidResult(NID_WEB_JSON, pList.get(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
- result r = E_SUCCESS;
- for (int i = count-1; i >= 0 ; i--)
+ if (deallocate == true)
{
- IJsonValue* pValue = null;
- r = pList->GetAt(i, pValue);
- SysTryReturnVoidResult(NID_WEB_JSON, pValue, r, "[%s] Propagating.", GetErrorMessage(r));
-
- _JsonUtils::DeallocateItem(pValue);
+ unique_ptr<JsonValueList> pList(GetItemsN(0, count));
+ SysTryReturnVoidResult(NID_WEB_JSON, pList.get(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ result r = E_SUCCESS;
+ for (int i = count-1; i >= 0 ; i--)
+ {
+ IJsonValue* pValue = null;
+ r = pList->GetAt(i, pValue);
+ SysTryReturnVoidResult(NID_WEB_JSON, pValue, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ _JsonUtils::DeallocateItem(pValue);
+ }
}
+ //Call Base class function
+ ArrayListT<IJsonValue*>::RemoveAll();
}
- //Call Base class function
- ArrayListT<IJsonValue*>::RemoveAll();
}
void
JsonObject::RemoveAll(bool deallocate)
{
- ClearLastResult();
-
int paircount = GetCount();
- if (paircount <= 0)
- {
- return;
- }
-
- if (deallocate == true)
+ if (paircount > 0)
{
- const String* pKey = null;
- IJsonValue* pValue = null;
+ if (deallocate == true)
+ {
+ const String* pKey = null;
+ IJsonValue* pValue = null;
- unique_ptr<JsonKeyList> pKeyList(GetKeysN());
- SysTryReturnVoidResult(NID_WEB_JSON, pKeyList.get(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ unique_ptr<JsonKeyList> pKeyList(GetKeysN());
+ SysTryReturnVoidResult(NID_WEB_JSON, pKeyList.get(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
- result r = E_SUCCESS;
- for (int i = 0; i < paircount; i++)
- {
- //get value and key
- r = pKeyList->GetAt(i, pKey);
- SysTryReturnVoidResult(NID_WEB_JSON, pKey, r, "[%s] Propagating.", GetErrorMessage(r));
+ result r = E_SUCCESS;
+ for (int i = 0; i < paircount; i++)
+ {
+ //get value and key
+ r = pKeyList->GetAt(i, pKey);
+ SysTryReturnVoidResult(NID_WEB_JSON, pKey, r, "[%s] Propagating.", GetErrorMessage(r));
- r = GetValue(pKey, pValue);
- SysTryReturnVoidResult(NID_WEB_JSON, pValue, r, "[%s] Propagating.", GetErrorMessage(r));
+ r = GetValue(pKey, pValue);
+ SysTryReturnVoidResult(NID_WEB_JSON, pValue, r, "[%s] Propagating.", GetErrorMessage(r));
- //Remove entry from base class
- HashMapT<const String*, IJsonValue*>::Remove(pKey);
+ //Remove entry from base class
+ HashMapT<const String*, IJsonValue*>::Remove(pKey);
- //free key and value memory
- delete pKey;
- _JsonUtils::DeallocateItem(pValue);
+ //free key and value memory
+ delete pKey;
+ _JsonUtils::DeallocateItem(pValue);
+ }
}
+ //Call Baseclass function
+ HashMapT<const String*, IJsonValue*>::RemoveAll();
}
- //Call Baseclass function
- HashMapT<const String*, IJsonValue*>::RemoveAll();
}