sync with tizen_2.0
[platform/framework/native/appfw.git] / src / locales / FLcl_NumberSymbolsImpl.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file            FLclNumberSymbols.cpp
20  * @brief           This is the implementation file for NumberSymbols class.
21  */
22
23 #include <FBaseSysLog.h>
24 #include <FApp_AppInfo.h>
25 #include "FLcl_NumberSymbolsImpl.h"
26 #include "FLcl_LocaleData.h"
27
28
29 using namespace Tizen::Base;
30
31 namespace Tizen { namespace Locales
32 {
33
34
35 /////////////////////////////////////////////////////////////////////////////////////////////////////
36 // Public Method
37
38 _NumberSymbolsImpl::_NumberSymbolsImpl(void)
39         : __locale(LANGUAGE_INVALID, COUNTRY_INVALID)
40 {
41 }
42
43
44 _NumberSymbolsImpl::_NumberSymbolsImpl(const _NumberSymbolsImpl& other)
45         : __locale(LANGUAGE_INVALID, COUNTRY_INVALID)
46 {
47         this->__locale = other.__locale;
48
49         for (int i = 0; i < NUMBER_SYMBOL_COUNT; i++)
50         {
51                 this->__symbols[i] = other.__symbols[i];                               // Copying symbols
52         }
53 }
54
55
56 _NumberSymbolsImpl&
57 _NumberSymbolsImpl::operator =(const _NumberSymbolsImpl& rhs)
58 {
59         if (this != &rhs)
60         {
61                 for (int i = 0; i < (int) NUMBER_SYMBOL_COUNT; ++i)
62                 {
63                         __symbols[(NumberSymbol) i] = rhs.__symbols[(NumberSymbol) i];        // Copying symbols
64                 }
65
66                 __locale = rhs.__locale;
67         }
68
69         return *this;
70 }
71
72
73 _NumberSymbolsImpl::~_NumberSymbolsImpl(void)
74 {
75 }
76
77 result
78 _NumberSymbolsImpl::Construct(const Locale& locale)
79 {
80         result r = E_SUCCESS;
81         _LocaleData localeData;
82         r = localeData.GetNumberSymbols(locale, __symbols);                            // Get number symbols from ICU
83
84         if (!IsFailed(r))
85         {
86                 __locale = locale;
87                 return E_SUCCESS;
88         }
89
90         return (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat()) ? E_UNSUPPORTED_OPERATION : E_INVALID_ARG;
91 }
92
93
94 String
95 _NumberSymbolsImpl::GetNumberSymbol(NumberSymbol symbol) const
96 {
97         return (symbol < NUMBER_SYMBOL_COUNT) ? __symbols[symbol] : String();       // Get symbol value for symbol
98 }
99
100
101 result
102 _NumberSymbolsImpl::SetNumberSymbol(const NumberSymbol symbol, const String& str)
103 {
104         if (symbol < NUMBER_SYMBOL_COUNT)                                           // validate symbol value
105         {
106                 __symbols[symbol] = str;                                                // Set symbol
107         }
108
109         return E_SUCCESS;
110 }
111
112
113 const Locale*
114 _NumberSymbolsImpl::GetLocale(void) const
115 {
116         ClearLastResult();
117         return &__locale;                                                           // return locale object stored during construction
118 }
119
120
121 };
122 };      // Tizen::Locales
123