b0faf5e8fecc23549ff083ea60317ae85ae0113c
[platform/framework/native/appfw.git] / src / locales / FLcl_LocaleData.h
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        FLcl_LocaleData.h
19  * @brief       This is the header file for _LocaleData class.
20  */
21 #ifndef _FLCL_INTERNAL_LOCALE_DATA_H_
22 #define _FLCL_INTERNAL_LOCALE_DATA_H_
23
24 // Includes
25 #include <unicode/locid.h>
26 #include <unicode/timezone.h>
27 #include <unicode/basictz.h>
28 #include <unicode/simpletz.h>
29 #include <unicode/decimfmt.h>
30 #include <unicode/dtfmtsym.h>
31 #include <unicode/smpdtfmt.h>
32 #include <unicode/calendar.h>
33 #include <unicode/gregocal.h>
34 #include <FLclLocale.h>
35 #include <FLclDateTimeSymbols.h>
36 #include <FLclDateTimeFormatter.h>
37 #include <FBaseString.h>
38 #include <FBaseColHashMap.h>
39 #include <FBaseColArrayList.h>
40 #include "FLcl_NumberFormatterImpl.h"
41 #include "FLcl_DateTimeSymbolsImpl.h"
42 #include "FLcl_FieldPosition.h"
43
44
45 typedef UParseError IcuUParseError;
46 typedef UDate IcuUDate;
47 typedef UChar IcuUChar;
48
49 typedef U_ICU_NAMESPACE::UnicodeString IcuUnicodeString;
50 typedef U_ICU_NAMESPACE::StringEnumeration IcuStringEnumeration;
51 typedef U_ICU_NAMESPACE::Locale IcuLocale;
52 typedef U_ICU_NAMESPACE::TimeZone IcuTimeZone;
53 typedef U_ICU_NAMESPACE::BasicTimeZone IcuBasicTimeZone;
54 typedef U_ICU_NAMESPACE::SimpleTimeZone IcuSimpleTimeZone;
55 typedef U_ICU_NAMESPACE::DecimalFormatSymbols IcuDecimalFormatSymbols;
56 typedef U_ICU_NAMESPACE::Calendar IcuCalendar;
57 typedef U_ICU_NAMESPACE::GregorianCalendar IcuGregorianCalendar;
58 typedef U_ICU_NAMESPACE::InitialTimeZoneRule IcuInitialTimeZoneRule;
59 typedef U_ICU_NAMESPACE::AnnualTimeZoneRule IcuAnnualTimeZoneRule;
60 typedef U_ICU_NAMESPACE::DateTimeRule IcuDateTimeRule;
61 typedef U_ICU_NAMESPACE::NumberFormat IcuNumberFormat;
62 typedef U_ICU_NAMESPACE::DecimalFormat IcuDecimalFormat;
63 typedef U_ICU_NAMESPACE::FieldPosition IcuFieldPosition;
64
65 typedef U_ICU_NAMESPACE::DateFormatSymbols IcuDateFormatSymbols;
66 typedef U_ICU_NAMESPACE::DateFormat IcuDateFormat;
67 typedef U_ICU_NAMESPACE::SimpleDateFormat IcuSimpleDateFormat;
68
69 namespace Tizen { namespace Locales
70 {
71
72 /**
73  * @enum DstRuleMode
74  * Possible DST rule mode
75  *
76  * @since               1.0
77  */
78 enum DstRuleMode
79 {
80         EXACT_DAY = 0,
81         DAY_OF_WEEK_IN_MONTH,
82         AFTER_THE_SPECIFIED_DAY,
83         BEFORE_THE_SPECIFIED_DAY,
84         BACKWARD_FROM_END_OF_MONTH
85 };
86
87 /**
88  * @class       _LocaleData
89  * @brief       This class is for loading the @e locale data.
90  * @since       1.0
91  *
92  * _LocaleData is represented locale data which is specific localized.
93  * This class is used by other classed in locale namespace to load the localized data.
94  *
95  */
96
97 class _LocaleData
98         : public Tizen::Base::Object
99 {
100
101
102 // Construct Operations
103 public:
104         /**
105          * Creates an @b uninitialized instance.
106          *
107          * @remarks     After creating an instance of this class, you must explicitly call the @e Construct() method
108          *              to initialize the instance.
109          * @see         Construct
110          */
111         _LocaleData(void);
112
113
114         /**
115          * Destroys this instance.
116          */
117         virtual ~_LocaleData(void);
118
119
120 // Operations
121 private:
122
123         Tizen::Base::Collection::ArrayList* ConvertIcuStringArrayToOspArrayN(const IcuUnicodeString* pIcuStrList, int count);
124         IcuUnicodeString* ConvertOspArrayToIcuStringArrayN(const Tizen::Base::Collection::IList* pIcuStrList, int& count);
125
126         // Methods to support Locale
127         const IcuLocale& GetIcuLocale(void);
128         IcuLocale GetIcuLocale(const Tizen::Locales::Locale& ospLocale);
129
130 public:
131         static Tizen::Base::String GetOspString(const IcuUnicodeString& icuStr);
132         static U_ICU_NAMESPACE::UnicodeString GetIcuString(const Tizen::Base::String& ospString);
133         static void GetIcuString(const Tizen::Base::String& ospStr, IcuUnicodeString& icuStr);
134
135         static IcuUDate GetIcuDate(Tizen::Base::DateTime date);
136         static IcuFieldPosition GetIcuFieldPosition(_FieldPosition pos);
137
138         // Methods to support Locale
139         bool IsLocaleSupported();
140         result SetLocale(const Locale& ospLocale);
141
142         // Methods to support NumberSymbols
143         result GetNumberSymbols(const Locale &locale, Tizen::Base::String symbols[]);
144
145         // Methods to support NumberFormatter
146         result SetNumberFormatter(const Locale& locale, NumberFormatterStyle style);
147         result FormatNumber(long number, _FieldPosition& pos, Tizen::Base::String& str);
148         result FormatNumber(double number, _FieldPosition& pos, Tizen::Base::String& str);
149         result ApplyNumberPattern(const Tizen::Base::String& pattern, bool localized);
150
151         Tizen::Base::String GetNumberFormatterStringAttributes(NumberFormatterAttributes attrName);
152         void SetNumberFormatterAttributes(const Tizen::Base::String& newValue, NumberFormatterAttributes attrName);
153
154         int GetNumberFormatterIntAttributes(NumberFormatterAttributes attrName);
155         void SetNumberFormatterAttributes(const int newValue, NumberFormatterAttributes attrName);
156
157         bool GetNumberFormatterBoolAttributes(NumberFormatterAttributes attrName);
158         void SetNumberFormatterAttributes(const bool newValue, NumberFormatterAttributes attrName);
159
160
161         // Methods to support DateTimeSymbols
162         result SetDateFormatSymbols(const Locale& locale);
163         Tizen::Base::Collection::IList* GetDateFormatSymbolAttrArrayN(DateFormatSymbolsAttributes attrName);
164
165         // Methods to support DateTimeFormatter
166         result SetDateTimeFormatter(DateTimeStyle dateStyle, DateTimeStyle timeStyle, const Locale& locale);
167         result FormatDateTime(const Tizen::Base::DateTime& date, Tizen::Base::String& str);
168         result FormatDateTime(const Calendar& calendar, Tizen::Base::String& str);
169         Tizen::Base::String GetDateTimePattern();
170         result SetDateTimePattern(const Tizen::Base::String& pattern);
171         DateTimeSymbols* GetDateTimeSymbolsN(DateTimeSymbols* pDateTimeSymbols);
172         result SetDateTimeSymbols(const DateTimeSymbols& newValue);
173
174 private:
175         _LocaleData(const _LocaleData& localeData);
176         _LocaleData& operator =(const _LocaleData& localeData);
177
178 private:
179         IcuLocale __icuLocale;
180         IcuDecimalFormat* __pIcuNumberFormatter;
181         IcuDateFormatSymbols* __pIcuDateFormatSymbols;
182         IcuSimpleDateFormat* __pIcuDateFormat;
183
184 }; // LocaleData
185
186 }} // Tizen::Locales
187
188 #endif // _FLCL_INTERNAL_LOCALE_DATA_H_
189