{
SysTryReturnResult(NID_LCL, _LocaleImpl::IsSupported(locale), E_INVALID_ARG, "Given locale is not supported");
- _LocaleData localeData;
- result r = localeData.SetDateFormatSymbols(locale); // this will set ICU DateTimeSymbol in _LocaleData object for future use
-
- if (!IsFailed(r))
- {
- __pErasList = localeData.GetDateFormatSymbolAttrArrayN(DATE_FORMAT_SYM_ERA_LIST);
- __pMonthsList = localeData.GetDateFormatSymbolAttrArrayN(DATE_FORMAT_SYM_MONTH_LIST);
- __pShortMonthsList = localeData.GetDateFormatSymbolAttrArrayN(DATE_FORMAT_SYM_SHORT_MONTH_LIST);
- __pWeekdaysList = localeData.GetDateFormatSymbolAttrArrayN(DATE_FORMAT_SYM_WEEKDAY_LIST);
- __pShortWeekdaysList = localeData.GetDateFormatSymbolAttrArrayN(DATE_FORMAT_SYM_SHORT_WEEKDAY_LIST);
- __pAmPmList = localeData.GetDateFormatSymbolAttrArrayN(DATE_FORMAT_SYM_AM_PM_LIST);
- __CalendarType = calendarType;
-
- UErrorCode ec = U_ZERO_ERROR;
- __pIcuDateFormatSymbols = new IcuDateFormatSymbols(ec);
- }
-
- return r;
+ UErrorCode ec = U_ZERO_ERROR;
+ __pIcuDateFormatSymbols = new U_ICU_NAMESPACE::DateFormatSymbols(_LocaleData::GetIcuLocale(locale), ec);
+ SysTryReturnResult(NID_LCL, __pIcuDateFormatSymbols, E_OUT_OF_MEMORY, "It is not enough memory.");
+
+ __pErasList = GetSymbolAttributeArrayN(DATE_FORMAT_SYM_ERA_LIST);
+ __pMonthsList = GetSymbolAttributeArrayN(DATE_FORMAT_SYM_MONTH_LIST);
+ __pShortMonthsList = GetSymbolAttributeArrayN(DATE_FORMAT_SYM_SHORT_MONTH_LIST);
+ __pWeekdaysList = GetSymbolAttributeArrayN(DATE_FORMAT_SYM_WEEKDAY_LIST);
+ __pShortWeekdaysList = GetSymbolAttributeArrayN(DATE_FORMAT_SYM_SHORT_WEEKDAY_LIST);
+ __pAmPmList = GetSymbolAttributeArrayN(DATE_FORMAT_SYM_AM_PM_LIST);
+ __CalendarType = calendarType;
+
+ return E_SUCCESS;
}
void
{
SysTryReturnVoidResult(NID_LCL, pOther != null, E_INVALID_ARG,
"[%s] Invalid argument is used. pOther instance is invalid", GetErrorMessage(E_INVALID_ARG));
+ ReleaseAll();
- __pErasList = CloneArrayListN(pOther->__pErasList); // Copying EraList
- __pMonthsList = CloneArrayListN(pOther->__pMonthsList); // Copying Month List
- __pShortMonthsList = CloneArrayListN(pOther->__pShortMonthsList); // Copying Short Month List
- __pWeekdaysList = CloneArrayListN(pOther->__pWeekdaysList); // Copying Weekdays List
- __pShortWeekdaysList = CloneArrayListN(pOther->__pShortWeekdaysList); // Copying Short Weekdays List
- __pAmPmList = CloneArrayListN(pOther->__pAmPmList); // Copying AM/ PM String
+ __pErasList = CloneArrayListN(pOther->__pErasList);
+ __pMonthsList = CloneArrayListN(pOther->__pMonthsList);
+ __pShortMonthsList = CloneArrayListN(pOther->__pShortMonthsList);
+ __pWeekdaysList = CloneArrayListN(pOther->__pWeekdaysList);
+ __pShortWeekdaysList = CloneArrayListN(pOther->__pShortWeekdaysList);
+ __pAmPmList = CloneArrayListN(pOther->__pAmPmList);
if(pOther->__pTimeZonesMap)
{
- __pTimeZonesMap = CloneMultiHashMapN(pOther->__pTimeZonesMap); // Copying available TimeZone List
+ __pTimeZonesMap = CloneMultiHashMapN(pOther->__pTimeZonesMap);
}
- __CalendarType = pOther->__CalendarType; // Copying Calendar Type
+ __CalendarType = pOther->__CalendarType;
+
+ if(__pIcuDateFormatSymbols)
+ {
+ delete __pIcuDateFormatSymbols;
+ __pIcuDateFormatSymbols = null;
+ }
+ _DateTimeSymbolsImpl* pDTS = const_cast<_DateTimeSymbolsImpl*>(pOther);
+ __pIcuDateFormatSymbols = new U_ICU_NAMESPACE::DateFormatSymbols(*(pDTS->GetIcuSymbols()));
+ SysTryReturnVoidResult(NID_LCL, __pIcuDateFormatSymbols, E_OUT_OF_MEMORY, "It is not enough memory.");
}
if (!__pTimeZonesMap)
{
- MultiHashMap* pMultiHashMap = new (std::nothrow) MultiHashMap();
+ MultiHashMap* pMultiHashMap = new (std::nothrow) MultiHashMap(SingleObjectDeleter);
SysTryReturnResult(NID_LCL, pMultiHashMap, E_OUT_OF_MEMORY, "Memory allocation failed.");
pMultiHashMap->Construct();
{
SysAssertf(__pAmPmList != null, "Not yet constructed! Construct() should be called before use");
- ClearLastResult(); // Setting Last result to E_SUCCESS
+ ClearLastResult();
return __pAmPmList;
}
{
SysAssertf(__pAmPmList != null, "Not yet constructed! Construct() should be called before use");
- std::unique_ptr< ArrayList, AllElementsDeleter > pTempArrayList(new (std::nothrow) ArrayList());
+ std::unique_ptr< ArrayList > pTempArrayList(new (std::nothrow) ArrayList(SingleObjectDeleter));
SysTryReturnResult(NID_LCL, pTempArrayList != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
result r = SetList(pTempArrayList.get(), AM_PM_COUNT, amPm);
if (!IsFailed(r))
{
- __pAmPmList->RemoveAll(true);
delete __pAmPmList;
__pAmPmList = pTempArrayList.release();
+ int count = 0;
+ U_ICU_NAMESPACE::UnicodeString* pIcuArray = _LocaleData::ConvertOspArrayToIcuStringArrayN(__pAmPmList, count);
+ __pIcuDateFormatSymbols->setAmPmStrings(pIcuArray, count);
+ delete[] pIcuArray;
}
-
return r;
}
{
SysAssertf(__pErasList != null, "Not yet constructed! Construct() should be called before use");
- std::unique_ptr< ArrayList, AllElementsDeleter > pTempArrayList(new (std::nothrow) ArrayList());
+ std::unique_ptr< ArrayList > pTempArrayList(new (std::nothrow) ArrayList(SingleObjectDeleter));
SysTryReturnResult(NID_LCL, pTempArrayList != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
result r = SetList(pTempArrayList.get(), ERAS_COUNT, eras);
if (!IsFailed(r))
{
- __pErasList->RemoveAll(true);
delete __pErasList;
-
__pErasList = pTempArrayList.release();
+ int count = 0;
+ U_ICU_NAMESPACE::UnicodeString* pIcuArray = _LocaleData::ConvertOspArrayToIcuStringArrayN(__pErasList, count);
+ __pIcuDateFormatSymbols->setEras(pIcuArray, count);
+ delete[] pIcuArray;
}
return r;
{
SysAssertf(__pMonthsList != null, "Not yet constructed! Construct() should be called before use");
- ClearLastResult(); // Setting Last result to E_SUCCESS
+ ClearLastResult();
return __pMonthsList;
}
{
SysAssertf(__pMonthsList != null, "Not yet constructed! Construct() should be called before use");
- std::unique_ptr< ArrayList, AllElementsDeleter > pTempArrayList(new (std::nothrow) ArrayList());
+ std::unique_ptr< ArrayList > pTempArrayList(new (std::nothrow) ArrayList(SingleObjectDeleter));
SysTryReturnResult(NID_LCL, pTempArrayList != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
result r = SetList(pTempArrayList.get(), MONTH_COUNT, months);
if (!IsFailed(r))
{
- __pMonthsList->RemoveAll(true);
delete __pMonthsList;
-
__pMonthsList = pTempArrayList.release();
+ int count = 0;
+ U_ICU_NAMESPACE::UnicodeString* pIcuArray = _LocaleData::ConvertOspArrayToIcuStringArrayN(__pMonthsList, count);
+ __pIcuDateFormatSymbols->setMonths(pIcuArray, count);
+ delete[] pIcuArray;
}
return r;
{
SysAssertf(__pShortMonthsList != null, "Not yet constructed! Construct() should be called before use");
- ClearLastResult(); // Setting Last result to E_SUCCESS
+ ClearLastResult();
return __pShortMonthsList;
}
{
SysAssertf(__pShortMonthsList != null, "Not yet constructed! Construct() should be called before use");
- std::unique_ptr< ArrayList, AllElementsDeleter > pTempArrayList(new (std::nothrow) ArrayList());
+ std::unique_ptr< ArrayList > pTempArrayList(new (std::nothrow) ArrayList(SingleObjectDeleter));
SysTryReturnResult(NID_LCL, pTempArrayList != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
result r = SetList(pTempArrayList.get(), MONTH_COUNT, shortMonths);
if (!IsFailed(r))
{
- __pShortMonthsList->RemoveAll(true);
delete __pShortMonthsList;
-
__pShortMonthsList = pTempArrayList.release();
+ int count = 0;
+ U_ICU_NAMESPACE::UnicodeString* pIcuArray = _LocaleData::ConvertOspArrayToIcuStringArrayN(__pShortMonthsList, count);
+ __pIcuDateFormatSymbols->setShortMonths(pIcuArray, count);
+ delete[] pIcuArray;
}
return r;
{
SysAssertf(__pWeekdaysList != null, "Not yet constructed! Construct() should be called before use");
- ClearLastResult(); // Setting Last result to E_SUCCESS
+ ClearLastResult();
return __pWeekdaysList;
}
{
SysAssertf(__pWeekdaysList != null, "Not yet constructed! Construct() should be called before use");
- std::unique_ptr< ArrayList, AllElementsDeleter > pTempArrayList(new (std::nothrow) ArrayList());
+ std::unique_ptr< ArrayList > pTempArrayList(new (std::nothrow) ArrayList(SingleObjectDeleter));
SysTryReturnResult(NID_LCL, pTempArrayList != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
result r = SetList(pTempArrayList.get(), WEEKDAYS_COUNT, weekdays);
if (!IsFailed(r))
{
- __pWeekdaysList->RemoveAll(true);
delete __pWeekdaysList;
-
__pWeekdaysList = pTempArrayList.release();
+ int count = 0;
+ U_ICU_NAMESPACE::UnicodeString* pIcuArray = _LocaleData::ConvertOspArrayToIcuStringArrayN(__pWeekdaysList, count);
+ __pIcuDateFormatSymbols->setWeekdays(pIcuArray, count);
+ delete[] pIcuArray;
}
return r;
_DateTimeSymbolsImpl::GetShortWeekdays(void) const
{
SysAssertf(__pShortWeekdaysList != null, "Not yet constructed! Construct() should be called before use");
-
- ClearLastResult(); // Setting Last result to E_SUCCESS
+ ClearLastResult();
return __pShortWeekdaysList;
}
{
SysAssertf(__pShortWeekdaysList != null, "Not yet constructed! Construct() should be called before use");
- std::unique_ptr< ArrayList, AllElementsDeleter > pTempArrayList(new (std::nothrow) ArrayList());
+ std::unique_ptr< ArrayList > pTempArrayList(new (std::nothrow) ArrayList(SingleObjectDeleter));
SysTryReturnResult(NID_LCL, pTempArrayList != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
result r = SetList(pTempArrayList.get(), WEEKDAYS_COUNT, shortWeekdays);
if (!IsFailed(r))
{
- __pShortWeekdaysList->RemoveAll(true);
delete __pShortWeekdaysList;
-
__pShortWeekdaysList = pTempArrayList.release();
+ int count = 0;
+ U_ICU_NAMESPACE::UnicodeString* pIcuArray = _LocaleData::ConvertOspArrayToIcuStringArrayN(__pShortWeekdaysList, count);
+ __pIcuDateFormatSymbols->setShortWeekdays(pIcuArray, count);
+ delete[] pIcuArray;
}
return r;
result
_DateTimeSymbolsImpl::SetTimeZoneName(const Tizen::Base::String& timeZoneId, const Tizen::Base::String& concatenatedTimeZoneName)
{
- // checking if concatenatedTimeZoneName has 4 names
StringTokenizer tokenizer(concatenatedTimeZoneName, L"|");
SysTryReturnResult(NID_LCL, (tokenizer.GetTokenCount() == MAX_TIMEZONE_NAME),
E_INVALID_ARG, "Invalid argument is used. %ls is invalid.", concatenatedTimeZoneName.GetPointer());
}
-// internal function
-// This function makes a copy of input array list of strings
IList*
_DateTimeSymbolsImpl::CloneArrayListN(const IList* pList) const
{
SysTryReturn(NID_LCL, pList, null, E_INVALID_ARG, "[%s] Invalid argument is used. pList is Null", GetErrorMessage(E_INVALID_ARG));
- ClearLastResult(); // Setting last result to E_SUCCESS
- std::unique_ptr< ArrayList, AllElementsDeleter > pClonedArrayList(new (std::nothrow) ArrayList());
+ ClearLastResult();
+ std::unique_ptr< ArrayList > pClonedArrayList(new (std::nothrow) ArrayList(SingleObjectDeleter));
SysTryReturn(NID_LCL, pClonedArrayList, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
result r = pClonedArrayList->Construct(pList->GetCount());
ClearLastResult();
- std::unique_ptr< MultiHashMap, AllElementsDeleter > pClonedMultiHashMap(new (std::nothrow) MultiHashMap());
+ std::unique_ptr< MultiHashMap > pClonedMultiHashMap(new (std::nothrow) MultiHashMap(SingleObjectDeleter));
SysTryReturn(NID_LCL, pClonedMultiHashMap, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
result r = pClonedMultiHashMap->Construct();
SysTryReturnResult(NID_LCL, (tokenizer.GetTokenCount() == tokenCount), E_INVALID_ARG,
"Invalid argument is used. stringWillBeTokenized=%ls", stringWillBeTokenized.GetPointer());
+ SysTryReturnResult(NID_LCL, pArrayList, E_INVALID_ARG, "Invalid argument is used. pArrayList should not be null");
- std::unique_ptr< ArrayList, AllElementsDeleter > pTmpArrayList(pArrayList);
- SysTryReturnResult(NID_LCL, pTmpArrayList, E_INVALID_ARG, "Invalid argument is used. pArrayList should not be null");
-
- result r = pTmpArrayList->Construct(tokenCount); // Constructing list for tokenCount elements
+ result r = pArrayList->Construct(tokenCount);
if (!IsFailed(r))
{
String token;
pListStr.reset(new (std::nothrow) String(token));
SysTryReturnResult(NID_LCL, pListStr, E_OUT_OF_MEMORY, "Memory allocation failed.");
- r = pTmpArrayList->Add(pListStr.get());
+ r = pArrayList->Add(pListStr.get());
SysTryReturnResult(NID_LCL, r == E_SUCCESS, r, "Failed to add value to array list.");
pListStr.release();
}
}
-
- pTmpArrayList.release();
return r;
}
{
if (pList)
{
- pList->RemoveAll(true); // Remove elements and de-allocate memory used by them
delete pList;
+ pList = null;
}
}
-// This function release all the list after deleting their contents
void
_DateTimeSymbolsImpl::ReleaseAll(void)
{
- ReleaseList(__pErasList); // Deleting EraList after deleting its contents
- ReleaseList(__pMonthsList); // Deleting MonthsList after deleting its contents
- ReleaseList(__pShortMonthsList); // Deleting ShortMonthsList after deleting its contents
- ReleaseList(__pWeekdaysList); // Deleting WeekdaysList after deleting its contents
- ReleaseList(__pShortWeekdaysList); // Deleting ShortWeekdaysList after deleting its contents
- ReleaseList(__pAmPmList); // Deleting AmPmList after deleting its contents
+ ReleaseList(__pErasList);
+ ReleaseList(__pMonthsList);
+ ReleaseList(__pShortMonthsList);
+ ReleaseList(__pWeekdaysList);
+ ReleaseList(__pShortWeekdaysList);
+ ReleaseList(__pAmPmList);
if (__pTimeZonesMap)
{
- __pTimeZonesMap->RemoveAll(true); // Removing and deleting contents of TimeZonesMap
- delete __pTimeZonesMap; // Deleting TimeZonesMap
+ delete __pTimeZonesMap;
+ __pTimeZonesMap = null;
}
}
return pDateTimeSymbols->__pDateTimeSymbolsImpl;
}
+U_ICU_NAMESPACE::DateFormatSymbols*
+_DateTimeSymbolsImpl::GetIcuSymbols(void)
+{
+ return __pIcuDateFormatSymbols;
+}
+
+Tizen::Base::Collection::IList*
+_DateTimeSymbolsImpl::GetSymbolAttributeArrayN(DateFormatSymbolsAttributes attributeName)
+{
+ SysTryReturn(NID_LCL, __pIcuDateFormatSymbols, null, E_SYSTEM, "It is not initialized.");
+ ClearLastResult();
+ int count = 0;
+ const IcuUnicodeString* pIcuList = null;
+
+ switch (attributeName)
+ {
+ case DATE_FORMAT_SYM_ERA_LIST:
+ {
+ pIcuList = __pIcuDateFormatSymbols->getEras(count);
+ break;
+ }
+ case DATE_FORMAT_SYM_MONTH_LIST:
+ {
+ pIcuList = __pIcuDateFormatSymbols->getMonths(count);
+ break;
+ }
+ case DATE_FORMAT_SYM_SHORT_MONTH_LIST:
+ {
+ pIcuList = __pIcuDateFormatSymbols->getShortMonths(count);
+ break;
+ }
+ case DATE_FORMAT_SYM_WEEKDAY_LIST:
+ {
+ pIcuList = __pIcuDateFormatSymbols->getWeekdays(count);
+ break;
+ }
+ case DATE_FORMAT_SYM_SHORT_WEEKDAY_LIST:
+ {
+ pIcuList = __pIcuDateFormatSymbols->getShortWeekdays(count);
+ break;
+ }
+ case DATE_FORMAT_SYM_AM_PM_LIST:
+ {
+ pIcuList = __pIcuDateFormatSymbols->getAmPmStrings(count);
+ break;
+ }
+ default:
+ {
+ SetLastResult(E_UNSUPPORTED_OPERATION);
+ break;
+ }
+ }
+
+ SysTryReturn(NID_LCL, pIcuList, null, E_SYSTEM, "It is faile to get symbols.");
+ return _LocaleData::ConvertIcuStringArrayToOspArrayN(pIcuList, count);
+}
+
+
};
}; // Tizen::Locale