2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FLclCurrency.cpp
20 * @brief This is the implementation file for Currency class.
24 #include <FBaseSysLog.h>
25 #include <FLclCurrency.h>
26 #include <FLclLocale.h>
27 #include <FApp_AppInfo.h>
28 #include "FLcl_LocaleData.h"
29 #include "FLcl_CurrencyImpl.h"
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
34 namespace Tizen { namespace Locales
38 /////////////////////////////////////////////////////////////////////////////////////////////////////
39 // Currency class Lifecycle
41 Currency::Currency(void)
42 : __currencyCodeSymbol()
43 , __pCurrencyImpl(null)
48 Currency::~Currency(void)
54 Currency::Construct(const Locale& locale)
56 result r = _CurrencyImpl::GetCurrencyCodeSymbol(locale, __currencyCodeSymbol);
59 r = (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat()) ? E_UNSUPPORTED_OPERATION : E_INVALID_ARG;
66 Currency::Construct(const String& currencyCode)
68 result r = (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat()) ? E_UNSUPPORTED_OPERATION : E_INVALID_ARG;
69 SysTryReturnResult(NID_LCL, !currencyCode.IsEmpty(), r, "Currency code is empty");
71 r = _CurrencyImpl::GetCurrencyCodeSymbol(currencyCode, __currencyCodeSymbol);
74 r = (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat()) ? E_UNSUPPORTED_OPERATION : E_INVALID_ARG;
80 /////////////////////////////////////////////////////////////////////////////////////////////////////
81 // Currency class operations
84 Currency::GetCurrencyCode(void) const
89 // if __currencyCodeSymbol is valid, will be in <Currency Code>_<Currency Symbol> format
90 if (!__currencyCodeSymbol.IsEmpty())
92 result r = __currencyCodeSymbol.IndexOf(L'_', 0, index); // get index till '_'
93 if (r != E_OBJ_NOT_FOUND)
95 __currencyCodeSymbol.SubString(0, index, retStr); // get string till index, it will be Currency Code
104 Currency::GetSymbol(void) const
109 // if __currencyCodeSymbol is valid, will be in <Currency Code>_<Currency Symbol> format
110 if (!__currencyCodeSymbol.IsEmpty())
112 result r = __currencyCodeSymbol.IndexOf(L'_', 0, index); // get index till '_'
113 if (r != E_OBJ_NOT_FOUND)
115 __currencyCodeSymbol.SubString(index + 1, retStr); // get string after index, it will be Currency symbol
123 Currency::Equals(const Object& obj) const
125 const Currency* pOtherCurrency = dynamic_cast< const Currency* >(&obj);
128 return __currencyCodeSymbol.Equals(pOtherCurrency->__currencyCodeSymbol, true);
134 Currency::GetHashCode(void) const
136 return __currencyCodeSymbol.GetHashCode();
140 Currency::GetAvailableCurrenciesN(void)
142 return _CurrencyImpl::GetAvailableCurrenciesN();