LocaleManager::GetAvailableTimeZonesN(void) const
{
ClearLastResult();
- IMap* pTimeZoneMap = _LocaleManagerImpl::GetAvailableTimeZonesN();
- IList* pTimeZoneList = pTimeZoneMap->GetKeysN();
- pTimeZoneMap->RemoveAll();
- delete pTimeZoneMap;
- return pTimeZoneList;
+ std::unique_ptr<IMap> pTimeZoneMap(_LocaleManagerImpl::GetAvailableTimeZonesN());
+ std::unique_ptr<IList> pList(pTimeZoneMap->GetKeysN());
+ std::unique_ptr<ArrayList> pArrayList(new (std::nothrow) ArrayList(SingleObjectDeleter));
+ SysTryReturn(NID_LCL, pArrayList, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ pArrayList->Construct();
+
+ for (int i = 0; i < pList->GetCount(); i++)
+ {
+ 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()));
+ SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "[E_SYSTEM] It is failed to get the tz list.");
+ pTz.release();
+ }
+ return pArrayList.release();
}
LocaleManager::GetAvailableTimeZonesN(int rawOffset) const
{
ClearLastResult();
- IMap* pTimeZoneMap =_LocaleManagerImpl::GetAvailableTimeZonesN(rawOffset);
- IList* pTimeZoneList = pTimeZoneMap->GetKeysN();
- pTimeZoneMap->RemoveAll();
- delete pTimeZoneMap;
- return pTimeZoneList;
+ std::unique_ptr<IMap> pTimeZoneMap(_LocaleManagerImpl::GetAvailableTimeZonesN(rawOffset));
+ std::unique_ptr<IList> pList(pTimeZoneMap->GetKeysN());
+ std::unique_ptr<ArrayList> pArrayList(new (std::nothrow) ArrayList(SingleObjectDeleter));
+ SysTryReturn(NID_LCL, pArrayList, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ pArrayList->Construct();
+
+ for (int i = 0; i < pList->GetCount(); i++)
+ {
+ 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()));
+ SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "[E_SYSTEM] It is failed to get the tz list.");
+ pTz.release();
+ }
+ return pArrayList.release();
}
TimeZone
_LocaleManagerImpl::GetAvailableTimeZonesN(U_ICU_NAMESPACE::StringEnumeration* pIcuTZStrList)
{
SysTryReturn(NID_LCL, pIcuTZStrList, null, E_SYSTEM,
- "[%s] The method cannot proceed due to a severe system error.",GetErrorMessage(E_SYSTEM));
+ "[%s] The method cannot proceed due to a severe system error.",GetErrorMessage(E_SYSTEM));
- std::unique_ptr<HashMap, AllElementsDeleter> pTimeZoneMap(new (std::nothrow) HashMap());
-
- SysTryReturn(NID_LCL, pTimeZoneMap, null, E_OUT_OF_MEMORY,
- "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
+ std::unique_ptr<HashMap> pTimeZoneMap(new (std::nothrow) HashMap(SingleObjectDeleter));
+ SysTryReturn(NID_LCL, pTimeZoneMap, null, E_OUT_OF_MEMORY,
+ "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
pTimeZoneMap->Construct();
+
result r = E_SUCCESS;
int resultLength = -1;
UErrorCode ec = U_ZERO_ERROR;
const char* pIcuTZStr = pIcuTZStrList->next(&resultLength, ec);
- IMap* pTZMap = GetAvailableTimeZonesN();
-
+ std::unique_ptr<IMap> pTZMap(GetAvailableTimeZonesN());
r = GetLastResult();
SysTryReturn(NID_LCL, pTZMap, null, r, "[%s] Fail to get available time zone list", GetErrorMessage(r));
std::unique_ptr< String > pDummyValue(new (std::nothrow) String());
SysTryReturn(NID_LCL, pDummyValue, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
r = pTimeZoneMap->Add(*(pTimeZone.get()), *(pDummyValue.get()));
- if (IsFailed(r))
- {
- pTZMap->RemoveAll();
- delete pTZMap;
- SetLastResult(E_SYSTEM);
- return null;
- }
+ SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "[E_SYSTEM] It is failed to add a TZ into Map.");
pTimeZone.release();
pDummyValue.release();
}
pIcuTZStr = pIcuTZStrList->next(&resultLength, ec);
}
SetLastResult(E_SUCCESS);
- pTZMap->RemoveAll();
- delete pTZMap;
return pTimeZoneMap.release();
}
String tzFilePath(TIMEZONE_LIST_FILE_PATH);
result r = E_SUCCESS;
- std::unique_ptr<HashMap, AllElementsDeleter> pTimeZoneMap(new (std::nothrow) HashMap());
+ std::unique_ptr<HashMap> pTimeZoneMap(new (std::nothrow) HashMap(SingleObjectDeleter));
SysTryCatch(NID_LCL, pTimeZoneMap, null, E_OUT_OF_MEMORY,
"[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
r = file.Construct(tzFilePath, "r");
"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
r = pTimeZoneMap->Add(*(pTimeZone.get()), *(pDummyValue.get()));
- SysTryCatch(NID_LCL, r == E_SUCCESS, , r,"[%s] It is failed to add the tz into the tz map.", GetErrorMessage(r));
+ SysTryCatch(NID_LCL, r == E_SUCCESS, , r,"[%s] It is failed to make the tz list.", GetErrorMessage(r));
pTimeZone.release();
pDummyValue.release();
}
IMap*
_LocaleManagerImpl::GetAvailableTimeZonesFallbackN(void)
{
- std::unique_ptr<HashMap, AllElementsDeleter> pTimeZoneMap(new (std::nothrow) HashMap());
+ std::unique_ptr<HashMap> pTimeZoneMap(new (std::nothrow) HashMap(SingleObjectDeleter));
SysTryReturn(NID_LCL, pTimeZoneMap, null, E_OUT_OF_MEMORY,
"[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
IMap*
_LocaleManagerImpl::GetAvailableTimeZonesN(int rawOffset)
{
- return GetAvailableTimeZonesN(U_ICU_NAMESPACE::TimeZone::createEnumeration(rawOffset * _TimeZoneImpl::ONE_MIN_IN_MILLISEC));
+ std::unique_ptr<U_ICU_NAMESPACE::StringEnumeration> pIcuTzList(U_ICU_NAMESPACE::TimeZone::createEnumeration(rawOffset * _TimeZoneImpl::ONE_MIN_IN_MILLISEC));
+ SysTryReturn(NID_LCL, pIcuTzList, null, E_SYSTEM, "[E_SYSTEM] It is failed to get Icu TZ list.");
+ IMap* pTzList = GetAvailableTimeZonesN(pIcuTzList.get());
+ return pTzList;
}