Enable build with iniparser v 3.1
[platform/framework/native/appfw.git] / src / locales / FLclNumberFormatter.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            FLclNumberFormatter.cpp
19  * @brief           This is the implementation file for NumberFormatter class.
20  */
21
22 // Includes
23 #include <FBaseSysLog.h>
24 #include <FLclNumberFormatter.h>
25 #include "FLcl_NumberFormatterImpl.h"
26
27 using namespace Tizen::Base;
28 using namespace Tizen::Base::Collection;
29
30 namespace Tizen { namespace Locales
31 {
32
33 NumberFormatter*
34 NumberFormatter::CreateNumberFormatterN(void)
35 {
36         NumberFormatter* pNumberFormatter = _NumberFormatterImpl::CreateNumberFormatterN(NUM_FORMATTER_STYLE_NUMBER);
37         if (GetLastResult() == E_INVALID_ARG)
38         {
39                 SetLastResult( E_UNSUPPORTED_OPERATION );
40                 return null;
41         }
42         return pNumberFormatter;
43 }
44
45
46 NumberFormatter*
47 NumberFormatter::CreateNumberFormatterN(const Locale& locale)
48 {
49         return _NumberFormatterImpl::CreateNumberFormatterN(locale, NUM_FORMATTER_STYLE_NUMBER);
50 }
51
52
53 NumberFormatter*
54 NumberFormatter::CreateCurrencyFormatterN(void)
55 {
56         NumberFormatter* pNumberFormatter = _NumberFormatterImpl::CreateNumberFormatterN(NUM_FORMATTER_STYLE_CURRENCY);
57         if (GetLastResult() == E_INVALID_ARG)
58         {
59                 SetLastResult( E_UNSUPPORTED_OPERATION );
60                 return null;
61         }
62         return pNumberFormatter;
63 }
64
65
66 NumberFormatter*
67 NumberFormatter::CreateCurrencyFormatterN(const Locale& locale)
68 {
69         return _NumberFormatterImpl::CreateNumberFormatterN(locale, NUM_FORMATTER_STYLE_CURRENCY);
70 }
71
72
73 NumberFormatter*
74 NumberFormatter::CreatePercentFormatterN(void)
75 {
76         NumberFormatter* pNumberFormatter = _NumberFormatterImpl::CreateNumberFormatterN(NUM_FORMATTER_STYLE_PERCENT);
77         if (GetLastResult() == E_INVALID_ARG)
78         {
79                 SetLastResult( E_UNSUPPORTED_OPERATION );
80                 return null;
81         }
82         return pNumberFormatter;
83 }
84
85
86 NumberFormatter*
87 NumberFormatter::CreatePercentFormatterN(const Locale& locale)
88 {
89         return _NumberFormatterImpl::CreateNumberFormatterN(locale, NUM_FORMATTER_STYLE_PERCENT);
90 }
91
92 NumberFormatter::~NumberFormatter(void)
93 {
94         delete __pNumberFormatterImpl;
95 }
96
97 const Currency*
98 NumberFormatter::GetCurrency(void) const
99 {
100         return __pNumberFormatterImpl->GetCurrency();
101 }
102
103
104 void
105 NumberFormatter::SetCurrency(const Currency& currency)
106 {
107         __pNumberFormatterImpl->SetCurrency(currency);
108 }
109
110
111 int
112 NumberFormatter::GetMaxIntegerDigits(void) const
113 {
114         return __pNumberFormatterImpl->GetMaxIntegerDigits();
115 }
116
117
118 void
119 NumberFormatter::SetMaxIntegerDigits(int newValue)
120 {
121         __pNumberFormatterImpl->SetMaxIntegerDigits(newValue);
122 }
123
124
125 int
126 NumberFormatter::GetMinIntegerDigits(void) const
127 {
128         return __pNumberFormatterImpl->GetMinIntegerDigits();
129 }
130
131
132 void
133 NumberFormatter::SetMinIntegerDigits(int newValue)
134 {
135         __pNumberFormatterImpl->SetMinIntegerDigits(newValue);
136 }
137
138
139 int
140 NumberFormatter::GetMaxFractionDigits(void) const
141 {
142         return __pNumberFormatterImpl->GetMaxFractionDigits();
143 }
144
145
146 void
147 NumberFormatter::SetMaxFractionDigits(int newValue)
148 {
149         __pNumberFormatterImpl->SetMaxFractionDigits(newValue);
150 }
151
152
153 int
154 NumberFormatter::GetMinFractionDigits(void) const
155 {
156         return __pNumberFormatterImpl->GetMinFractionDigits();
157 }
158
159
160 void
161 NumberFormatter::SetMinFractionDigits(int newValue)
162 {
163         __pNumberFormatterImpl->SetMinFractionDigits(newValue);
164 }
165
166
167 bool
168 NumberFormatter::IsGroupingUsed(void) const
169 {
170         return __pNumberFormatterImpl->IsGroupingUsed();
171 }
172
173
174 void
175 NumberFormatter::SetGroupingUsed(bool newValue)
176 {
177         __pNumberFormatterImpl->SetGroupingUsed(newValue);
178 }
179
180 NumberFormatter::NumberFormatter(void)
181         : __pNumberFormatterImpl(null)
182 {
183 }
184
185 result
186 NumberFormatter::ApplyPattern(const Tizen::Base::String& pattern, bool localized)
187 {
188         SysTryReturnResult(NID_LCL, pattern.GetLength() > 0, E_INVALID_ARG, "Invalid argument is used. Length of the pattern is 0");
189         return __pNumberFormatterImpl->ApplyPattern(pattern, localized);
190 }
191
192
193 result
194 NumberFormatter::Format(long number, Tizen::Base::String& strBuf) const
195 {
196         return __pNumberFormatterImpl->Format(number, strBuf);
197 }
198
199
200 result
201 NumberFormatter::Format(double number, Tizen::Base::String& strBuf) const
202 {
203         return __pNumberFormatterImpl->Format(number, strBuf);
204 }
205
206
207 String
208 NumberFormatter::GetPositivePrefix(void) const
209 {
210         return __pNumberFormatterImpl->GetPositivePrefix();
211 }
212
213
214 void
215 NumberFormatter::SetPositivePrefix(const Tizen::Base::String& newValue)
216 {
217         __pNumberFormatterImpl->SetPositivePrefix(newValue);
218 }
219
220
221 String
222 NumberFormatter::GetNegativePrefix(void) const
223 {
224         return __pNumberFormatterImpl->GetNegativePrefix();
225 }
226
227
228 void
229 NumberFormatter::SetNegativePrefix(const Tizen::Base::String& newValue)
230 {
231         __pNumberFormatterImpl->SetNegativePrefix(newValue);
232 }
233
234
235 String
236 NumberFormatter::GetPositiveSuffix(void) const
237 {
238         return __pNumberFormatterImpl->GetPositiveSuffix();
239 }
240
241
242 void
243 NumberFormatter::SetPositiveSuffix(const Tizen::Base::String& newValue)
244 {
245         __pNumberFormatterImpl->SetPositiveSuffix(newValue);
246 }
247
248
249 String
250 NumberFormatter::GetNegativeSuffix(void) const
251 {
252         return __pNumberFormatterImpl->GetNegativeSuffix();
253 }
254
255
256 void
257 NumberFormatter::SetNegativeSuffix(const Tizen::Base::String& newValue)
258 {
259         __pNumberFormatterImpl->SetNegativeSuffix(newValue);
260 }
261
262
263 int
264 NumberFormatter::GetMultiplier(void) const
265 {
266         return __pNumberFormatterImpl->GetMultiplier();
267 }
268
269
270 result
271 NumberFormatter::SetMultiplier(int newValue)
272 {
273         SysTryReturnResult(NID_LCL, 0 < newValue, E_INVALID_ARG,
274                         "Invalid argument is used. newvalue(%d) is not a positive value.", newValue);
275
276         __pNumberFormatterImpl->SetMultiplier(newValue);
277         return E_SUCCESS;
278 }
279
280
281 int
282 NumberFormatter::GetGroupingSize(void) const
283 {
284         return __pNumberFormatterImpl->GetGroupingSize();
285 }
286
287
288 result
289 NumberFormatter::SetGroupingSize(int newValue)
290 {
291         SysTryReturnResult(NID_LCL, 0 < newValue, E_INVALID_ARG,
292                         "Invalid argument is used. newvalue(%d) is not a positive value.", newValue);
293
294         __pNumberFormatterImpl->SetGroupingSize(newValue);
295         return E_SUCCESS;
296 }
297
298
299 bool
300 NumberFormatter::IsDecimalSeparatorAlwaysShown(void) const
301 {
302         return __pNumberFormatterImpl->IsDecimalSeparatorAlwaysShown();
303 }
304
305
306 void
307 NumberFormatter::SetDecimalSeparatorAlwaysShown(bool newValue)
308 {
309         __pNumberFormatterImpl->SetDecimalSeparatorAlwaysShown(newValue);
310 }
311
312
313 bool
314 NumberFormatter::IsPositiveSignAlwaysShown(void) const
315 {
316         return __pNumberFormatterImpl->IsPositiveSignAlwaysShown();
317 }
318
319
320 void
321 NumberFormatter::SetPositiveSignAlwaysShown(bool newValue)
322 {
323         __pNumberFormatterImpl->SetPositiveSignAlwaysShown(newValue);
324 }
325
326
327 };
328 };      // Tizen::Locales
329