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 FLclDateTimeSymbols.cpp
19 * @brief This is the implementation file for DateTimeSymbols class.
22 #include <unique_ptr.h>
24 #include <FBaseSysLog.h>
25 #include <FApp_AppInfo.h>
26 #include <FLclDateTimeSymbols.h>
27 #include "FLcl_DateTimeSymbolsImpl.h"
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Base::Utility;
34 namespace Tizen { namespace Locales
38 /////////////////////////////////////////////////////////////////////////////////////////////////////
41 DateTimeSymbols::DateTimeSymbols(void)
42 : __pDateTimeSymbolsImpl(null)
46 DateTimeSymbols::~DateTimeSymbols(void)
48 delete __pDateTimeSymbolsImpl;
49 __pDateTimeSymbolsImpl = null;
53 DateTimeSymbols::AddTimeZoneName(const Tizen::Base::String& timeZoneId, const Tizen::Base::String& concatenatedTimeZoneName)
55 SysAssertf(__pDateTimeSymbolsImpl != null, "Not yet constructed! Construct() should be called before use.");
57 return __pDateTimeSymbolsImpl->AddTimeZoneName(timeZoneId, concatenatedTimeZoneName);
62 DateTimeSymbols::Construct(const Locale& locale, CalendarType calendarType)
64 SysAssertf(__pDateTimeSymbolsImpl == null,
65 "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
67 std::unique_ptr< _DateTimeSymbolsImpl > pDateTimeSymbolsImpl(new (std::nothrow) _DateTimeSymbolsImpl);
68 SysTryReturnResult(NID_LCL, pDateTimeSymbolsImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed");
70 result r = pDateTimeSymbolsImpl->Initialize(locale, calendarType);
73 if (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat())
75 return E_UNSUPPORTED_OPERATION;
80 __pDateTimeSymbolsImpl = pDateTimeSymbolsImpl.release();
86 DateTimeSymbols::Construct(CalendarType calendarType)
88 // Object is not allowed to construct twice
89 SysAssertf(__pDateTimeSymbolsImpl == null,
90 "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
92 std::unique_ptr< _DateTimeSymbolsImpl > pDateTimeSymbolsImpl(new (std::nothrow) _DateTimeSymbolsImpl);
93 SysTryReturnResult(NID_LCL, pDateTimeSymbolsImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed");
95 result r = pDateTimeSymbolsImpl->Initialize(calendarType);
98 if (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat())
100 return E_UNSUPPORTED_OPERATION;
102 return E_INVALID_ARG;
105 __pDateTimeSymbolsImpl = pDateTimeSymbolsImpl.release();
111 DateTimeSymbols::Construct(const DateTimeSymbols& other)
113 SysAssertf(__pDateTimeSymbolsImpl == null,
114 "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
116 if (other.__pDateTimeSymbolsImpl)
118 __pDateTimeSymbolsImpl = new (std::nothrow) _DateTimeSymbolsImpl;
119 SysTryReturnResult(NID_LCL, __pDateTimeSymbolsImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed");
121 __pDateTimeSymbolsImpl->Set(other.__pDateTimeSymbolsImpl);
128 DateTimeSymbols::GetAmPm(void) const
130 SysAssertf(__pDateTimeSymbolsImpl != null, "Not yet constructed! Construct() should be called before use.");
131 return __pDateTimeSymbolsImpl->GetAmPm();
135 DateTimeSymbols::SetAmPm(const String& amPm)
137 SysAssertf(__pDateTimeSymbolsImpl != null, "Not yet constructed! Construct() should be called before use.");
138 return __pDateTimeSymbolsImpl->SetAmPm(amPm);
142 DateTimeSymbols::GetEras(void) const
144 SysAssertf(__pDateTimeSymbolsImpl != null, "Not yet constructed! Construct() should be called before use.");
145 return __pDateTimeSymbolsImpl->GetEras();
149 DateTimeSymbols::SetEras(const String& eras)
151 SysAssertf(__pDateTimeSymbolsImpl != null, "Not yet constructed! Construct() should be called before use.");
152 return __pDateTimeSymbolsImpl->SetEras(eras);
156 DateTimeSymbols::GetMonths(void) const
158 SysAssertf(__pDateTimeSymbolsImpl != null, "Not yet constructed! Construct() should be called before use.");
159 return __pDateTimeSymbolsImpl->GetMonths();
163 DateTimeSymbols::SetMonths(const String& months)
165 SysAssertf(__pDateTimeSymbolsImpl != null, "Not yet constructed! Construct() should be called before use.");
166 return __pDateTimeSymbolsImpl->SetMonths(months);
170 DateTimeSymbols::GetShortMonths(void) const
172 SysAssertf(__pDateTimeSymbolsImpl != null, "Not yet constructed! Construct() should be called before use.");;
173 return __pDateTimeSymbolsImpl->GetShortMonths();
177 DateTimeSymbols::SetShortMonths(const String& shortMonths)
179 SysAssertf(__pDateTimeSymbolsImpl != null, "Not yet constructed! Construct() should be called before use.");
180 return __pDateTimeSymbolsImpl->SetShortMonths(shortMonths);
184 DateTimeSymbols::GetWeekdays(void) const
186 SysAssertf(__pDateTimeSymbolsImpl != null, "Not yet constructed! Construct() should be called before use.");
187 return __pDateTimeSymbolsImpl->GetWeekdays();
191 DateTimeSymbols::SetWeekdays(const String& weekdays)
193 SysAssertf(__pDateTimeSymbolsImpl != null, "Not yet constructed! Construct() should be called before use.");
194 return __pDateTimeSymbolsImpl->SetWeekdays(weekdays);
199 DateTimeSymbols::GetShortWeekdays(void) const
201 SysAssertf(__pDateTimeSymbolsImpl != null, "Not yet constructed! Construct() should be called before use.");
202 return __pDateTimeSymbolsImpl->GetShortWeekdays();
206 DateTimeSymbols::SetShortWeekdays(const String& shortWeekdays)
208 SysAssertf(__pDateTimeSymbolsImpl != null, "Not yet constructed! Construct() should be called before use.");
209 return __pDateTimeSymbolsImpl->SetShortWeekdays(shortWeekdays);
214 DateTimeSymbols::GetTimeZoneName(Tizen::Base::String& timeZoneId, int timeZoneStyle) const
216 SysAssertf(__pDateTimeSymbolsImpl != null, "Not yet constructed! Construct() should be called before use.");
217 return __pDateTimeSymbolsImpl->GetTimeZoneName(timeZoneId, timeZoneStyle);
222 DateTimeSymbols::SetTimeZoneName(const Tizen::Base::String& timeZoneId, const Tizen::Base::String& concatenatedTimeZoneName)
224 SysAssertf(__pDateTimeSymbolsImpl != null, "Not yet constructed! Construct() should be called before use.");
226 return __pDateTimeSymbolsImpl->SetTimeZoneName(timeZoneId, concatenatedTimeZoneName);