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