Merge "Refactoy Locales for DateTimeFormatter." into devel_3.0_main
[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/decimfmt.h>
27 #include <unicode/calendar.h>
28 #include <unicode/gregocal.h>
29 #include <FLclLocale.h>
30 #include <FBaseDateTime.h>
31 #include <FBaseString.h>
32 #include <FBaseColHashMap.h>
33 #include <FBaseColArrayList.h>
34 #include "FLcl_NumberFormatterImpl.h"
35 #include "FLcl_FieldPosition.h"
36
37
38 typedef UParseError IcuUParseError;
39 typedef UDate IcuUDate;
40 typedef UChar IcuUChar;
41
42 typedef U_ICU_NAMESPACE::UnicodeString IcuUnicodeString;
43 typedef U_ICU_NAMESPACE::StringEnumeration IcuStringEnumeration;
44 typedef U_ICU_NAMESPACE::Locale IcuLocale;
45 typedef U_ICU_NAMESPACE::DecimalFormatSymbols IcuDecimalFormatSymbols;
46 typedef U_ICU_NAMESPACE::Calendar IcuCalendar;
47 typedef U_ICU_NAMESPACE::GregorianCalendar IcuGregorianCalendar;
48 typedef U_ICU_NAMESPACE::NumberFormat IcuNumberFormat;
49 typedef U_ICU_NAMESPACE::DecimalFormat IcuDecimalFormat;
50 typedef U_ICU_NAMESPACE::FieldPosition IcuFieldPosition;
51
52 namespace Tizen { namespace Locales
53 {
54
55 /**
56  * @class       _LocaleData
57  * @brief       This class is for loading the @e locale data.
58  * @since       1.0
59  *
60  * _LocaleData is represented locale data which is specific localized.
61  * This class is used by other classed in locale namespace to load the localized data.
62  *
63  */
64
65 class _LocaleData
66         : public Tizen::Base::Object
67 {
68
69
70 // Construct Operations
71 public:
72         /**
73          * Creates an @b uninitialized instance.
74          *
75          * @remarks     After creating an instance of this class, you must explicitly call the @e Construct() method
76          *              to initialize the instance.
77          * @see         Construct
78          */
79         _LocaleData(void);
80
81
82         /**
83          * Destroys this instance.
84          */
85         virtual ~_LocaleData(void);
86
87
88 // Operations
89 private:
90         const IcuLocale& GetIcuLocale(void);
91
92 public:
93         static Tizen::Base::String GetOspString(const IcuUnicodeString& icuStr);
94         static U_ICU_NAMESPACE::UnicodeString GetIcuString(const Tizen::Base::String& ospString);
95         static void GetIcuString(const Tizen::Base::String& ospStr, IcuUnicodeString& icuStr);
96         static IcuUnicodeString* ConvertOspArrayToIcuStringArrayN(const Tizen::Base::Collection::IList* pIcuStrList, int& count);
97         static Tizen::Base::Collection::ArrayList* ConvertIcuStringArrayToOspArrayN(const IcuUnicodeString* pIcuStrList, int count);
98
99         static IcuUDate GetIcuDate(Tizen::Base::DateTime date);
100         static IcuFieldPosition GetIcuFieldPosition(_FieldPosition pos);
101         static IcuLocale GetIcuLocale(const Tizen::Locales::Locale& ospLocale);
102         // Methods to support Locale
103         bool IsLocaleSupported();
104         result SetLocale(const Locale& ospLocale);
105
106         // Methods to support NumberSymbols
107         result GetNumberSymbols(const Locale &locale, Tizen::Base::String symbols[]);
108
109         // Methods to support NumberFormatter
110         result SetNumberFormatter(const Locale& locale, NumberFormatterStyle style);
111         result FormatNumber(long number, _FieldPosition& pos, Tizen::Base::String& str);
112         result FormatNumber(double number, _FieldPosition& pos, Tizen::Base::String& str);
113         result ApplyNumberPattern(const Tizen::Base::String& pattern, bool localized);
114
115         Tizen::Base::String GetNumberFormatterStringAttributes(NumberFormatterAttributes attrName);
116         void SetNumberFormatterAttributes(const Tizen::Base::String& newValue, NumberFormatterAttributes attrName);
117
118         int GetNumberFormatterIntAttributes(NumberFormatterAttributes attrName);
119         void SetNumberFormatterAttributes(const int newValue, NumberFormatterAttributes attrName);
120
121         bool GetNumberFormatterBoolAttributes(NumberFormatterAttributes attrName);
122         void SetNumberFormatterAttributes(const bool newValue, NumberFormatterAttributes attrName);
123
124 private:
125         _LocaleData(const _LocaleData& localeData);
126         _LocaleData& operator =(const _LocaleData& localeData);
127
128 private:
129         IcuLocale __icuLocale;
130         IcuDecimalFormat* __pIcuNumberFormatter;
131 }; // LocaleData
132
133 }} // Tizen::Locales
134
135 #endif // _FLCL_INTERNAL_LOCALE_DATA_H_
136