Modified an api call flow
[platform/framework/native/appfw.git] / src / locales / FLcl_LocaleData.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FLcl_LocaleData.h
20  * @brief       This is the header file for _LocaleData class.
21  */
22 #ifndef _FLCL_INTERNAL_LOCALE_DATA_H_
23 #define _FLCL_INTERNAL_LOCALE_DATA_H_
24
25 // Includes
26 #include <unicode/locid.h>
27 #include <unicode/timezone.h>
28 #include <unicode/basictz.h>
29 #include <unicode/simpletz.h>
30 #include <unicode/decimfmt.h>
31 #include <unicode/dtfmtsym.h>
32 #include <unicode/smpdtfmt.h>
33 #include <unicode/calendar.h>
34 #include <unicode/gregocal.h>
35 #include <FLclLocale.h>
36 #include <FLclDateTimeSymbols.h>
37 #include <FLclDateTimeFormatter.h>
38 #include <FBaseString.h>
39 #include <FBaseColHashMap.h>
40 #include <FBaseColArrayList.h>
41 #include "FLcl_NumberFormatterImpl.h"
42 #include "FLcl_DateTimeSymbolsImpl.h"
43 #include "FLcl_FieldPosition.h"
44
45
46 typedef UParseError IcuUParseError;
47 typedef UDate IcuUDate;
48 typedef UChar IcuUChar;
49
50 typedef U_ICU_NAMESPACE::UnicodeString IcuUnicodeString;
51 typedef U_ICU_NAMESPACE::StringEnumeration IcuStringEnumeration;
52 typedef U_ICU_NAMESPACE::Locale IcuLocale;
53 typedef U_ICU_NAMESPACE::TimeZone IcuTimeZone;
54 typedef U_ICU_NAMESPACE::BasicTimeZone IcuBasicTimeZone;
55 typedef U_ICU_NAMESPACE::SimpleTimeZone IcuSimpleTimeZone;
56 typedef U_ICU_NAMESPACE::DecimalFormatSymbols IcuDecimalFormatSymbols;
57 typedef U_ICU_NAMESPACE::Calendar IcuCalendar;
58 typedef U_ICU_NAMESPACE::GregorianCalendar IcuGregorianCalendar;
59 typedef U_ICU_NAMESPACE::InitialTimeZoneRule IcuInitialTimeZoneRule;
60 typedef U_ICU_NAMESPACE::AnnualTimeZoneRule IcuAnnualTimeZoneRule;
61 typedef U_ICU_NAMESPACE::DateTimeRule IcuDateTimeRule;
62 typedef U_ICU_NAMESPACE::NumberFormat IcuNumberFormat;
63 typedef U_ICU_NAMESPACE::DecimalFormat IcuDecimalFormat;
64 typedef U_ICU_NAMESPACE::FieldPosition IcuFieldPosition;
65
66 typedef U_ICU_NAMESPACE::DateFormatSymbols IcuDateFormatSymbols;
67 typedef U_ICU_NAMESPACE::DateFormat IcuDateFormat;
68 typedef U_ICU_NAMESPACE::SimpleDateFormat IcuSimpleDateFormat;
69
70 namespace Tizen { namespace Locales
71 {
72
73 /**
74  * @enum DstRuleMode
75  * Possible DST rule mode
76  *
77  * @since               1.0
78  */
79 enum DstRuleMode
80 {
81         EXACT_DAY = 0,
82         DAY_OF_WEEK_IN_MONTH,
83         AFTER_THE_SPECIFIED_DAY,
84         BEFORE_THE_SPECIFIED_DAY,
85         BACKWARD_FROM_END_OF_MONTH
86 };
87
88 /**
89  * @class       _LocaleData
90  * @brief       This class is for loading the @e locale data.
91  * @since       1.0
92  *
93  * _LocaleData is represented locale data which is specific localized.
94  * This class is used by other classed in locale namespace to load the localized data.
95  *
96  */
97
98 class _LocaleData
99         : public Tizen::Base::Object
100 {
101
102
103 // Construct Operations
104 public:
105         /**
106          * Creates an @b uninitialized instance.
107          *
108          * @remarks     After creating an instance of this class, you must explicitly call the @e Construct() method
109          *              to initialize the instance.
110          * @see         Construct
111          */
112         _LocaleData(void);
113
114
115         /**
116          * Destroys this instance.
117          */
118         virtual ~_LocaleData(void);
119
120
121 // Operations
122 private:
123
124         Tizen::Base::Collection::ArrayList* ConvertIcuStringArrayToOspArrayN(const IcuUnicodeString* pIcuStrList, int count);
125         IcuUnicodeString* ConvertOspArrayToIcuStringArrayN(const Tizen::Base::Collection::IList* pIcuStrList, int& count);
126
127         // Methods to support Locale
128         const IcuLocale& GetIcuLocale(void);
129         IcuLocale GetIcuLocale(const Tizen::Locales::Locale& ospLocale);
130
131 public:
132         static Tizen::Base::String GetOspString(const IcuUnicodeString& icuStr);
133         static U_ICU_NAMESPACE::UnicodeString GetIcuString(const Tizen::Base::String& ospString);
134         static void GetIcuString(const Tizen::Base::String& ospStr, IcuUnicodeString& icuStr);
135
136         static IcuUDate GetIcuDate(Tizen::Base::DateTime date);
137         static IcuFieldPosition GetIcuFieldPosition(_FieldPosition pos);
138
139         // Methods to support Locale
140         bool IsLocaleSupported();
141         result SetLocale(const Locale& ospLocale);
142
143         // Methods to support NumberSymbols
144         result GetNumberSymbols(const Locale &locale, Tizen::Base::String symbols[]);
145
146         // Methods to support NumberFormatter
147         result SetNumberFormatter(const Locale& locale, NumberFormatterStyle style);
148         result FormatNumber(long number, _FieldPosition& pos, Tizen::Base::String& str);
149         result FormatNumber(double number, _FieldPosition& pos, Tizen::Base::String& str);
150         result ApplyNumberPattern(const Tizen::Base::String& pattern, bool localized);
151
152         Tizen::Base::String GetNumberFormatterStringAttributes(NumberFormatterAttributes attrName);
153         void SetNumberFormatterAttributes(const Tizen::Base::String& newValue, NumberFormatterAttributes attrName);
154
155         int GetNumberFormatterIntAttributes(NumberFormatterAttributes attrName);
156         void SetNumberFormatterAttributes(const int newValue, NumberFormatterAttributes attrName);
157
158         bool GetNumberFormatterBoolAttributes(NumberFormatterAttributes attrName);
159         void SetNumberFormatterAttributes(const bool newValue, NumberFormatterAttributes attrName);
160
161
162         // Methods to support DateTimeSymbols
163         result SetDateFormatSymbols(const Locale& locale);
164         Tizen::Base::Collection::IList* GetDateFormatSymbolAttrArrayN(DateFormatSymbolsAttributes attrName);
165
166         // Methods to support DateTimeFormatter
167         result SetDateTimeFormatter(DateTimeStyle dateStyle, DateTimeStyle timeStyle, const Locale& locale);
168         result FormatDateTime(const Tizen::Base::DateTime& date, Tizen::Base::String& str);
169         result FormatDateTime(const Calendar& calendar, Tizen::Base::String& str);
170         Tizen::Base::String GetDateTimePattern();
171         result SetDateTimePattern(const Tizen::Base::String& pattern);
172         DateTimeSymbols* GetDateTimeSymbolsN(DateTimeSymbols* pDateTimeSymbols);
173         result SetDateTimeSymbols(const DateTimeSymbols& newValue);
174
175
176         // Methods to support TimeZone
177         result SetStartTimeRule(IcuSimpleTimeZone& zone, const TimeRule* pOspTimeRule);
178         result SetEndTimeRule(IcuSimpleTimeZone& zone, const TimeRule* pOspTimeRule);
179
180         // Methods to support Calendar
181         void SetGregorianWeekCountData(const Locale& ospLocale, DayOfWeek& firstDayOfWeek, short& minDaysInFirstWeek);
182
183         // Lists from ICU TimeZone
184         Tizen::Base::Collection::IList* GetAvailableTimeZonesN(void);
185         Tizen::Base::Collection::IList* GetAvailableTimeZonesN(int rawOffset);
186
187 private:
188         _LocaleData(const _LocaleData& localeData);
189         _LocaleData& operator =(const _LocaleData& localeData);
190
191 private:
192         IcuLocale __icuLocale;
193         IcuDecimalFormat* __pIcuNumberFormatter;
194         IcuDateFormatSymbols* __pIcuDateFormatSymbols;
195         IcuSimpleDateFormat* __pIcuDateFormat;
196
197 }; // LocaleData
198
199 }} // Tizen::Locales
200
201 #endif // _FLCL_INTERNAL_LOCALE_DATA_H_
202