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 FLclNumberFormatter.cpp
19 * @brief This is the implementation file for NumberFormatter class.
23 #include <FBaseSysLog.h>
24 #include <FLclNumberFormatter.h>
25 #include "FLcl_NumberFormatterImpl.h"
27 using namespace Tizen::Base;
28 using namespace Tizen::Base::Collection;
30 namespace Tizen { namespace Locales
34 NumberFormatter::CreateNumberFormatterN(void)
36 NumberFormatter* pNumberFormatter = _NumberFormatterImpl::CreateNumberFormatterN(NUM_FORMATTER_STYLE_NUMBER);
37 if (GetLastResult() == E_INVALID_ARG)
39 SetLastResult( E_UNSUPPORTED_OPERATION );
42 return pNumberFormatter;
47 NumberFormatter::CreateNumberFormatterN(const Locale& locale)
49 return _NumberFormatterImpl::CreateNumberFormatterN(locale, NUM_FORMATTER_STYLE_NUMBER);
54 NumberFormatter::CreateCurrencyFormatterN(void)
56 NumberFormatter* pNumberFormatter = _NumberFormatterImpl::CreateNumberFormatterN(NUM_FORMATTER_STYLE_CURRENCY);
57 if (GetLastResult() == E_INVALID_ARG)
59 SetLastResult( E_UNSUPPORTED_OPERATION );
62 return pNumberFormatter;
67 NumberFormatter::CreateCurrencyFormatterN(const Locale& locale)
69 return _NumberFormatterImpl::CreateNumberFormatterN(locale, NUM_FORMATTER_STYLE_CURRENCY);
74 NumberFormatter::CreatePercentFormatterN(void)
76 NumberFormatter* pNumberFormatter = _NumberFormatterImpl::CreateNumberFormatterN(NUM_FORMATTER_STYLE_PERCENT);
77 if (GetLastResult() == E_INVALID_ARG)
79 SetLastResult( E_UNSUPPORTED_OPERATION );
82 return pNumberFormatter;
87 NumberFormatter::CreatePercentFormatterN(const Locale& locale)
89 return _NumberFormatterImpl::CreateNumberFormatterN(locale, NUM_FORMATTER_STYLE_PERCENT);
92 NumberFormatter::~NumberFormatter(void)
94 delete __pNumberFormatterImpl;
98 NumberFormatter::GetCurrency(void) const
100 return __pNumberFormatterImpl->GetCurrency();
105 NumberFormatter::SetCurrency(const Currency& currency)
107 __pNumberFormatterImpl->SetCurrency(currency);
112 NumberFormatter::GetMaxIntegerDigits(void) const
114 return __pNumberFormatterImpl->GetMaxIntegerDigits();
119 NumberFormatter::SetMaxIntegerDigits(int newValue)
121 __pNumberFormatterImpl->SetMaxIntegerDigits(newValue);
126 NumberFormatter::GetMinIntegerDigits(void) const
128 return __pNumberFormatterImpl->GetMinIntegerDigits();
133 NumberFormatter::SetMinIntegerDigits(int newValue)
135 __pNumberFormatterImpl->SetMinIntegerDigits(newValue);
140 NumberFormatter::GetMaxFractionDigits(void) const
142 return __pNumberFormatterImpl->GetMaxFractionDigits();
147 NumberFormatter::SetMaxFractionDigits(int newValue)
149 __pNumberFormatterImpl->SetMaxFractionDigits(newValue);
154 NumberFormatter::GetMinFractionDigits(void) const
156 return __pNumberFormatterImpl->GetMinFractionDigits();
161 NumberFormatter::SetMinFractionDigits(int newValue)
163 __pNumberFormatterImpl->SetMinFractionDigits(newValue);
168 NumberFormatter::IsGroupingUsed(void) const
170 return __pNumberFormatterImpl->IsGroupingUsed();
175 NumberFormatter::SetGroupingUsed(bool newValue)
177 __pNumberFormatterImpl->SetGroupingUsed(newValue);
180 NumberFormatter::NumberFormatter(void)
181 : __pNumberFormatterImpl(null)
186 NumberFormatter::ApplyPattern(const Tizen::Base::String& pattern, bool localized)
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);
194 NumberFormatter::Format(long number, Tizen::Base::String& strBuf) const
196 return __pNumberFormatterImpl->Format(number, strBuf);
201 NumberFormatter::Format(double number, Tizen::Base::String& strBuf) const
203 return __pNumberFormatterImpl->Format(number, strBuf);
208 NumberFormatter::GetPositivePrefix(void) const
210 return __pNumberFormatterImpl->GetPositivePrefix();
215 NumberFormatter::SetPositivePrefix(const Tizen::Base::String& newValue)
217 __pNumberFormatterImpl->SetPositivePrefix(newValue);
222 NumberFormatter::GetNegativePrefix(void) const
224 return __pNumberFormatterImpl->GetNegativePrefix();
229 NumberFormatter::SetNegativePrefix(const Tizen::Base::String& newValue)
231 __pNumberFormatterImpl->SetNegativePrefix(newValue);
236 NumberFormatter::GetPositiveSuffix(void) const
238 return __pNumberFormatterImpl->GetPositiveSuffix();
243 NumberFormatter::SetPositiveSuffix(const Tizen::Base::String& newValue)
245 __pNumberFormatterImpl->SetPositiveSuffix(newValue);
250 NumberFormatter::GetNegativeSuffix(void) const
252 return __pNumberFormatterImpl->GetNegativeSuffix();
257 NumberFormatter::SetNegativeSuffix(const Tizen::Base::String& newValue)
259 __pNumberFormatterImpl->SetNegativeSuffix(newValue);
264 NumberFormatter::GetMultiplier(void) const
266 return __pNumberFormatterImpl->GetMultiplier();
271 NumberFormatter::SetMultiplier(int newValue)
273 SysTryReturnResult(NID_LCL, 0 < newValue, E_INVALID_ARG,
274 "Invalid argument is used. newvalue(%d) is not a positive value.", newValue);
276 __pNumberFormatterImpl->SetMultiplier(newValue);
282 NumberFormatter::GetGroupingSize(void) const
284 return __pNumberFormatterImpl->GetGroupingSize();
289 NumberFormatter::SetGroupingSize(int newValue)
291 SysTryReturnResult(NID_LCL, 0 < newValue, E_INVALID_ARG,
292 "Invalid argument is used. newvalue(%d) is not a positive value.", newValue);
294 __pNumberFormatterImpl->SetGroupingSize(newValue);
300 NumberFormatter::IsDecimalSeparatorAlwaysShown(void) const
302 return __pNumberFormatterImpl->IsDecimalSeparatorAlwaysShown();
307 NumberFormatter::SetDecimalSeparatorAlwaysShown(bool newValue)
309 __pNumberFormatterImpl->SetDecimalSeparatorAlwaysShown(newValue);
314 NumberFormatter::IsPositiveSignAlwaysShown(void) const
316 return __pNumberFormatterImpl->IsPositiveSignAlwaysShown();
321 NumberFormatter::SetPositiveSignAlwaysShown(bool newValue)
323 __pNumberFormatterImpl->SetPositiveSignAlwaysShown(newValue);