2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FLclNumberSymbols.cpp
19 * @brief This is the implementation file for NumberSymbols class.
21 #include <unicode/locid.h>
22 #include <FBaseSysLog.h>
23 #include <FApp_AppInfo.h>
24 #include "FLcl_NumberSymbolsImpl.h"
25 #include "FLcl_LocaleData.h"
27 using namespace Tizen::Base;
29 namespace Tizen { namespace Locales
32 static U_ICU_NAMESPACE::DecimalFormatSymbols::ENumberFormatSymbol NUMBER_SYMBOL_TYPE_CONVERT_TABLE[NUMBER_SYMBOL_COUNT] =
33 { U_ICU_NAMESPACE::DecimalFormatSymbols::kDecimalSeparatorSymbol
34 , U_ICU_NAMESPACE::DecimalFormatSymbols::kGroupingSeparatorSymbol
35 , U_ICU_NAMESPACE::DecimalFormatSymbols::kPatternSeparatorSymbol
36 , U_ICU_NAMESPACE::DecimalFormatSymbols::kPercentSymbol
37 , U_ICU_NAMESPACE::DecimalFormatSymbols::kZeroDigitSymbol
38 , U_ICU_NAMESPACE::DecimalFormatSymbols::kDigitSymbol
39 , U_ICU_NAMESPACE::DecimalFormatSymbols::kCurrencySymbol
40 , U_ICU_NAMESPACE::DecimalFormatSymbols::kIntlCurrencySymbol
41 , U_ICU_NAMESPACE::DecimalFormatSymbols::kMonetarySeparatorSymbol
42 , U_ICU_NAMESPACE::DecimalFormatSymbols::kPerMillSymbol
43 , U_ICU_NAMESPACE::DecimalFormatSymbols::kExponentialSymbol
44 , U_ICU_NAMESPACE::DecimalFormatSymbols::kPlusSignSymbol
45 , U_ICU_NAMESPACE::DecimalFormatSymbols::kMinusSignSymbol
48 _NumberSymbolsImpl::_NumberSymbolsImpl(void)
49 : __locale(LANGUAGE_INVALID, COUNTRY_INVALID)
50 , __pIcuDecimalFormatSymbols(null)
55 _NumberSymbolsImpl::_NumberSymbolsImpl(const _NumberSymbolsImpl& other)
56 : __locale(LANGUAGE_INVALID, COUNTRY_INVALID)
57 , __pIcuDecimalFormatSymbols(null)
59 __locale = other.__locale;
60 __pIcuDecimalFormatSymbols = new U_ICU_NAMESPACE::DecimalFormatSymbols(*other.__pIcuDecimalFormatSymbols);
61 SysTryReturn(NID_LCL, __pIcuDecimalFormatSymbols, , E_OUT_OF_MEMORY, "It is not enough memory.");
66 _NumberSymbolsImpl::operator =(const _NumberSymbolsImpl& rhs)
70 __locale = rhs.__locale;
71 if (__pIcuDecimalFormatSymbols)
73 delete __pIcuDecimalFormatSymbols;
74 __pIcuDecimalFormatSymbols = null;
76 __pIcuDecimalFormatSymbols = new U_ICU_NAMESPACE::DecimalFormatSymbols(*rhs.__pIcuDecimalFormatSymbols);
83 _NumberSymbolsImpl::~_NumberSymbolsImpl(void)
85 if (__pIcuDecimalFormatSymbols)
87 delete __pIcuDecimalFormatSymbols;
92 _NumberSymbolsImpl::Construct(const Locale& locale)
94 result r = (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat())
95 ? E_UNSUPPORTED_OPERATION
98 U_ICU_NAMESPACE::Locale icuLocale = _LocaleData::GetIcuLocale(locale);
99 SysTryReturnResult(NID_LCL, icuLocale.isBogus() != true, r, "It is an invalid locale.");
101 UErrorCode status = U_ZERO_ERROR;
102 __pIcuDecimalFormatSymbols = new U_ICU_NAMESPACE::DecimalFormatSymbols(icuLocale, status);
103 SysTryReturnResult(NID_LCL, __pIcuDecimalFormatSymbols, E_OUT_OF_MEMORY, "It is not enough memory.");
111 _NumberSymbolsImpl::GetNumberSymbol(NumberSymbol symbol) const
113 SysTryReturn(NID_LCL, symbol < NUMBER_SYMBOL_COUNT, String(), E_INVALID_ARG, "It is an invalid argument.");
114 return _LocaleData::GetOspString(__pIcuDecimalFormatSymbols->getSymbol(NUMBER_SYMBOL_TYPE_CONVERT_TABLE[symbol]));
119 _NumberSymbolsImpl::SetNumberSymbol(const NumberSymbol symbol, const String& str)
121 SysTryReturnResult(NID_LCL, symbol < NUMBER_SYMBOL_COUNT, E_INVALID_ARG, "It is an invalid argument.");
122 U_ICU_NAMESPACE::UnicodeString icuStr = _LocaleData::GetIcuString(str);
123 __pIcuDecimalFormatSymbols->setSymbol(NUMBER_SYMBOL_TYPE_CONVERT_TABLE[symbol], icuStr);
129 _NumberSymbolsImpl::GetLocale(void) const