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 FLclCurrency.cpp
19 * @brief This is the implementation file for Currency class.
23 #include <FBaseSysLog.h>
24 #include <FLclCurrency.h>
25 #include <FLclLocale.h>
26 #include <FApp_AppInfo.h>
27 #include "FLcl_LocaleData.h"
28 #include "FLcl_CurrencyImpl.h"
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
33 namespace Tizen { namespace Locales
37 /////////////////////////////////////////////////////////////////////////////////////////////////////
38 // Currency class Lifecycle
40 Currency::Currency(void)
41 : __currencyCodeSymbol()
42 , __pCurrencyImpl(null)
47 Currency::~Currency(void)
53 Currency::Construct(const Locale& locale)
55 result r = _CurrencyImpl::GetCurrencyCodeSymbol(locale, __currencyCodeSymbol);
58 r = (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat()) ? E_UNSUPPORTED_OPERATION : E_INVALID_ARG;
65 Currency::Construct(const String& currencyCode)
67 result r = (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat()) ? E_UNSUPPORTED_OPERATION : E_INVALID_ARG;
68 SysTryReturnResult(NID_LCL, !currencyCode.IsEmpty(), r, "Currency code is empty");
70 r = _CurrencyImpl::GetCurrencyCodeSymbol(currencyCode, __currencyCodeSymbol);
73 r = (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat()) ? E_UNSUPPORTED_OPERATION : E_INVALID_ARG;
79 /////////////////////////////////////////////////////////////////////////////////////////////////////
80 // Currency class operations
83 Currency::GetCurrencyCode(void) const
88 // if __currencyCodeSymbol is valid, will be in <Currency Code>_<Currency Symbol> format
89 if (!__currencyCodeSymbol.IsEmpty())
91 result r = __currencyCodeSymbol.IndexOf(L'_', 0, index); // get index till '_'
92 if (r != E_OBJ_NOT_FOUND)
94 __currencyCodeSymbol.SubString(0, index, retStr); // get string till index, it will be Currency Code
103 Currency::GetSymbol(void) const
108 // if __currencyCodeSymbol is valid, will be in <Currency Code>_<Currency Symbol> format
109 if (!__currencyCodeSymbol.IsEmpty())
111 result r = __currencyCodeSymbol.IndexOf(L'_', 0, index); // get index till '_'
112 if (r != E_OBJ_NOT_FOUND)
114 __currencyCodeSymbol.SubString(index + 1, retStr); // get string after index, it will be Currency symbol
122 Currency::Equals(const Object& obj) const
124 const Currency* pOtherCurrency = dynamic_cast< const Currency* >(&obj);
127 return __currencyCodeSymbol.Equals(pOtherCurrency->__currencyCodeSymbol, true);
133 Currency::GetHashCode(void) const
135 return __currencyCodeSymbol.GetHashCode();
139 Currency::GetAvailableCurrenciesN(void)
141 return _CurrencyImpl::GetAvailableCurrenciesN();