{
std::unique_ptr<String> pTz(new (std::nothrow) String(*((String*)(pList->GetAt(i)))));
SysTryReturn(NID_LCL, pTz, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- result r = pArrayList->Add(*(pTz.get()));
+ result r = pArrayList->Add(pTz.get());
SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "[E_SYSTEM] It is failed to get the tz list.");
pTz.release();
}
{
std::unique_ptr<String> pTz(new (std::nothrow) String(*((String*)(pList->GetAt(i)))));
SysTryReturn(NID_LCL, pTz, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- result r = pArrayList->Add(*(pTz.get()));
+ result r = pArrayList->Add(pTz.get());
SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "[E_SYSTEM] It is failed to get the tz list.");
pTz.release();
}
pCurr->__currencyCodeSymbol = currCode + "_" + currSymbol;
if (!pNewList->Contains(*(pCurr.get())))
{
- result r = pNewList->Add(*(pCurr.get()));
+ result r = pNewList->Add(pCurr.get());
SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "Itis fail to make the currency list.");
pCurr.release();
}
std::unique_ptr< String > pClonedString(new (std::nothrow) String(*(static_cast<const String*>(pList->GetAt(i)))));
SysTryReturn(NID_LCL, pClonedString, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
- r = pClonedArrayList->Add(*pClonedString);
+ r = pClonedArrayList->Add(pClonedString.get());
SysTryReturn(NID_LCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
pClonedString.release();
std::unique_ptr< String > pTimeZoneName(new (std::nothrow) String(*(static_cast<String*> (pValueEnum->GetCurrent()))));
if (pTimeZoneName)
{
- r = pClonedMultiHashMap->Add(*pMapKey, *pTimeZoneName);
+ r = pClonedMultiHashMap->Add(pMapKey.get(), pTimeZoneName.get());
if (IsFailed(r))
{
pClonedMultiHashMap->Remove(*pMapKey,true);
pListStr.reset(new (std::nothrow) String(token));
SysTryReturnResult(NID_LCL, pListStr, E_OUT_OF_MEMORY, "Memory allocation failed.");
- r = pTmpArrayList->Add(*pListStr);
+ r = pTmpArrayList->Add(pListStr.get());
SysTryReturnResult(NID_LCL, r == E_SUCCESS, r, "Failed to add value to array list.");
pListStr.release();
ArrayList*
_LocaleData::ConvertIcuStringArrayToOspArrayN(const IcuUnicodeString* pIcuStrList, int count)
{
+ SysTryReturn(NID_LCL, pIcuStrList && count > 0, null, E_INVALID_ARG, "It is invalid argument.");
+
result r = E_SUCCESS;
- ArrayList* pTempArrayList = null;
- if (pIcuStrList && count > 0) // validating inputs
+ std::unique_ptr< ArrayList> pTempArrayList(new (std::nothrow) ArrayList(SingleObjectDeleter));
+ SysTryReturn(NID_LCL, pTempArrayList, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ pTempArrayList->Construct(count);
+
+ for (int i = 0; i < count; i++)
{
- pTempArrayList = new (std::nothrow) ArrayList();
- if (pTempArrayList) // If allocation is successful
+ std::unique_ptr< String > pString(new (std::nothrow) String(_LocaleData::GetOspString(pIcuStrList[i])));
+ SysTryReturn(NID_LCL, pString, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ if (!pString->IsEmpty())
{
- r = pTempArrayList->Construct(count);
- if (!IsFailed(r)) // If ArrayList::Construct() is successful
- {
- for (int i = 0; i < count; i++)
- {
- String* pString = new (std::nothrow) String();
- if (pString != null)
- {
- *pString = _LocaleData::GetOspString(pIcuStrList[i]); // Get OSP string from ICU string
-
- if (!pString->IsEmpty())
- {
- pTempArrayList->Add(*pString); // Add OSP string to arraylist if it is not empty
- }
- else
- {
- delete pString;
- }
- }
- }
- }
+ r = pTempArrayList->Add(pString.get()); // Add OSP string to arraylist if it is not empty
+ SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "It is failed to add string [%ls]", pString->GetPointer());
+ pString.release();
}
}
SetLastResult(r); // Setting last result value
- return pTempArrayList; // Return array list
+ return pTempArrayList.release(); // Return array list
}
// this function convert OSP string array list to ICU string array list