[Native][25/11/2013][Add]Adding BigInteger class
[platform/framework/native/appfw.git] / src / locales / FLclNumberSymbols.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 // Includes
23 #include <new>
24 #include <FBaseResult.h>
25 #include <FBaseSysLog.h>
26 #include <FApp_AppInfo.h>
27 #include <FLclNumberSymbols.h>
28 #include "FLcl_NumberSymbolsImpl.h"
29 #include "FLcl_LocaleImpl.h"
30
31
32 using namespace Tizen::Base;
33
34 namespace Tizen { namespace Locales
35 {
36
37 NumberSymbols::NumberSymbols(void)
38         : __pNumberSymbolsImpl(null)
39 {
40 }
41
42 NumberSymbols::~NumberSymbols(void)
43 {
44         delete __pNumberSymbolsImpl;
45         __pNumberSymbolsImpl = null;
46 }
47
48 result
49 NumberSymbols::Construct(const Locale& locale)
50 {
51         SysAssertf(__pNumberSymbolsImpl == null,
52                 "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
53
54         result r = E_INVALID_ARG;
55
56         if (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat())
57         {
58                 r = E_UNSUPPORTED_OPERATION;
59         }
60         SysTryReturnResult(NID_LCL, _LocaleImpl::IsSupported(locale), r, "Given locale is not supported");
61
62         __pNumberSymbolsImpl = new (std::nothrow) _NumberSymbolsImpl;
63         SysTryReturnResult(NID_LCL, __pNumberSymbolsImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed");
64
65         r = __pNumberSymbolsImpl->Construct(locale);
66         if (IsFailed(r))
67         {
68                 delete __pNumberSymbolsImpl;
69                 __pNumberSymbolsImpl = null;
70         }
71         return r;
72 }
73
74
75 String
76 NumberSymbols::GetNumberSymbol(NumberSymbol symbol) const
77 {
78         SysAssertf(__pNumberSymbolsImpl != null, "Not yet constructed! Construct() should be called before use.");
79         return __pNumberSymbolsImpl->GetNumberSymbol(symbol);
80 }
81
82
83 result
84 NumberSymbols::SetNumberSymbol(const NumberSymbol symbol, const String& str)
85 {
86         SysAssertf(__pNumberSymbolsImpl != null, "Not yet constructed! Construct() should be called before use.");
87         return __pNumberSymbolsImpl->SetNumberSymbol(symbol, str);
88 }
89
90
91 const Locale*
92 NumberSymbols::GetLocale(void) const
93 {
94         SysAssertf(__pNumberSymbolsImpl != null, "Not yet constructed! Construct() should be called before use.");
95         return __pNumberSymbolsImpl->GetLocale();
96 }
97
98
99 };
100 };      // Tizen::Locales
101