Merge "[2.2.1] Change FBase_String.h to FBaseUtil_AtomicOperations.h" into tizen_2.2
[platform/framework/native/appfw.git] / src / locales / FLcl_DateTimeFormatterImpl.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_DateTimeFormatterImpl.h
19  * @brief       This is the header file for the _DateTimeFormatterImpl class.
20  *
21  * This header file contains the declarations of the _DateTimeFormatterImpl class.
22  *
23  */
24 #ifndef _FLCL_INTERNAL_DATE_TIME_FORMATTER_IMPL_H_
25 #define _FLCL_INTERNAL_DATE_TIME_FORMATTER_IMPL_H_
26
27 // Includes
28 #include <FLclLocale.h>
29 #include <FLclCalendar.h>
30 #include <FLclDateTimeSymbols.h>
31 #include <FLclDateTimeFormatter.h>
32
33
34 namespace Tizen { namespace Locales
35 {
36 class NumberFormatter;
37 class _LocaleData;
38 };
39 };
40
41
42 namespace Tizen { namespace Locales
43 {
44
45 class _DateTimeFormatterImpl
46         : public Tizen::Base::Object
47 {
48
49 public:
50         _DateTimeFormatterImpl(void);
51         ~_DateTimeFormatterImpl(void);
52
53
54         static DateTimeFormatter* CreateInstanceN(const Locale& locale, DateTimeStyle dateStyle, DateTimeStyle timeStyle);
55         static DateTimeFormatter* CreateInstanceN(DateTimeStyle dateStyle, DateTimeStyle timeStyle);
56
57
58 // Operations
59 public:
60         /**
61          * Formats a DateTime object into a date/time string and appends the resulting string to the specified string buffer.
62          *
63          * @since               1.0
64          * @return          An error code
65          * @param[in]       date                The DateTime object to format
66          * @param[out]      str                 The String to append the resulting string to
67          * @exception       E_SUCCESS           The method was successful.
68          * @remarks         This method does not handle the time zone information, so "z" pattern always returns "GMT+00:00".
69          * @see                 Tizen::Base::DateTime
70          */
71         virtual result Format(const Tizen::Base::DateTime& date, Tizen::Base::String& str) const;
72
73
74         /**
75          * Formats a Calendar object into a date/time string and appends the resulting string to the specified string buffer.
76          *
77          * @since               1.0
78          * @return          An error code
79          * @param[in]       calendar                The Calendar object to format
80          * @param[out]      str                     The String to append the resulting string to
81          * @exception       E_SUCCESS               The method was successful.
82          * @see                 Tizen::Base::DateTime
83          */
84         virtual result Format(const Calendar& calendar, Tizen::Base::String& str) const;
85
86
87 //private:
88
89 // Operation
90 public:
91         /**
92         * Applies the specified pattern string to the date format.
93         *
94         * @since                    1.0
95         * @param[in]            pattern                 The new date and time pattern for the date format
96         * @exception            E_SUCCESS               The method was successful.
97         * @exception            E_INVALID_ARG           The length of specified @c pattern is 0.
98         */
99         result ApplyPattern(const Tizen::Base::String& pattern);
100
101
102         /**
103         * Gets a pattern string describing the date format.
104         *
105         * @since            1.0
106         * @return           A String describing the date format
107         */
108         Tizen::Base::String GetPattern(void) const;
109
110
111         /**
112         * Gets the date and time format symbols of the formatter.
113         *
114         * @since                1.0
115         * @return               A pointer to DateTimeSymbols for the formatter instance
116         * @see                  SetDateTimeSymbols()
117         */
118         const DateTimeSymbols* GetDateTimeSymbols(void) const;
119
120
121         /**
122         * Sets the date and time format symbols of the date format.
123         *
124         * @since                1.0
125         * @param[in]        newSymbols          The new date and time format symbols
126         * @see                  GetDateTimeSymbols()
127         */
128         void SetDateTimeSymbols(const DateTimeSymbols& newSymbols);
129
130         /**
131          * Formats a DateTime into a date/time string and appends the result string to a given string buffer.
132          *
133          * @return              An error code
134          * @param[in]           date                    The DateTime object to format
135          * @param[in]           pos                     On input: an alignment field, if desired @n
136          *                                              On output: the offsets of the alignment field
137          * @param[out]          str                     The String where the formatted string is to be appended
138          * @exception           E_SUCCESS               The method was successful.
139          * @see                 Tizen::Base::DateTime
140          */
141         result Format(const Tizen::Base::DateTime& date, _FieldPosition& pos, Tizen::Base::String& str) const;
142
143
144         /**
145          * Formats a Calendar into a date/time string and appends the result string to a given string buffer.
146          *
147          * @return              An error code
148          * @param[in]           cal                     The Calendar object to format
149          * @param[in]           pos                     On input: an alignment field, if desired @n
150          *                                              On output: the offsets of the alignment field
151          * @param[out]          str                     The String where the formatted string is to be appended
152          * @exception           E_SUCCESS               The method was successful.
153          * @see                 Calendar()
154          */
155         result Format(const Calendar& calendar, _FieldPosition& pos, Tizen::Base::String& str) const;
156
157         static bool ValidateDateTimeStyle(DateTimeStyle dateTimeStyle);
158 private:
159         _DateTimeFormatterImpl(const _DateTimeFormatterImpl& dateTimeFormatterImpl);
160         _DateTimeFormatterImpl& operator =(const _DateTimeFormatterImpl& dateTimeFormatterImpl);
161
162 // Attribute
163         _LocaleData* __pLocaleData;
164         DateTimeSymbols* __pSymbols;
165
166 }; // _DateTimeFormatterImpl
167 };
168 };      // Tizen::Locales
169
170 #endif //_FLCL_INTERNAL_DATE_TIME_FORMATTER_IMPL_H_
171