2 // Copyright (c) 2013 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 FBase_LocalizedNumParser.h
19 * @brief This is the header file for the %_LocalizedNumParser class.
21 * This header file contains the declarations of the %_LocalizedNumParser class.
23 #ifndef _FBASE_INTERNAL_LOCALIZED_NUM_PARSER_H_
24 #define _FBASE_INTERNAL_LOCALIZED_NUM_PARSER_H_
26 #include <FBaseString.h>
28 namespace Tizen { namespace Base
31 class _OSP_EXPORT_ _LocalizedNumParser
35 * Locale specifiable version of Double::Parse(). @n
36 * This method is affected by the specified @c pLocale.
40 * @return The converted numeric value
41 * @param[in] str A unicode representation of @c signed @c double value
42 * @param[in] pLocale A specific locale identifier. @n
43 * The @c pLocale can have below values.
44 * - "" : the system default locale
45 * - "C" or "POSIX" : the POSIX locale
46 * - "language[_territory][.codeset]" : an implementation-provided locale, e.g. "en_US.utf8", "fr_FR.utf8", etc.
47 * @exception E_SUCCESS The method is successful.
48 * @exception E_NUM_FORMAT The specified string does not contain a number that can be parsed.
49 * @exception E_INVALID_ARG The specified locale identifier is invalid.
51 * - When an error is occurred, this method returns Not-a-Number(NaN).
52 * - The behavior of this method is dependent on the specified locale setting.
53 * - The specific error code can be accessed using the GetLastResult() method.
55 static double ToDouble(const String& str, const char* pLocale);
58 * Locale specifiable version of Float::Parse(). @n
59 * This method is affected by the specified @c pLocale.
63 * @return The converted numeric value
64 * @param[in] str A unicode representation of @c signed @c float value
65 * @param[in] pLocale A specific locale identifier. @n
66 * The @c pLocale can have below values.
67 * - "" : the system default locale
68 * - "C" or "POSIX" : the POSIX locale
69 * - "language[_territory][.codeset]" : an implementation-provided locale, e.g. "en_US.utf8", "fr_FR.utf8", etc.
70 * @exception E_SUCCESS The method is successful.
71 * @exception E_NUM_FORMAT The specified string does not contain a number that can be parsed.
72 * @exception E_INVALID_ARG The specified locale identifier is invalid.
74 * - When an error is occurred, this method returns Not-a-Number(NaN).
75 * - The behavior of this method is dependent on the specified locale setting.
76 * - The specific error code can be accessed using the GetLastResult() method.
78 static float ToFloat(const String& str, const char* pLocale);
81 * Locale specifiable version of Double::ToString(). @n
82 * This method is affected by the specified @c pLocale.
86 * @return A string containing a Unicode representation of the specified @c double value
87 * @param[in] value A @c double value to convert
88 * @param[in] pLocale A specific locale identifier. @n
89 * The @c pLocale can have below values.
90 * - "" : the system default locale
91 * - "C" or "POSIX" : the POSIX locale
92 * - "language[_territory][.codeset]" : an implementation-provided locale, e.g. "en_US.utf8", "fr_FR.utf8", etc.
93 * @exception E_SUCCESS The method is successful.
94 * @exception E_INVALID_ARG The specified locale identifier is invalid.
96 * - If the input value is Not-a-Number(NaN), the result is the string "NaN".
97 * Furthermore, infinity produces the result "Infinity". @n
98 * 6 digits are given for the precision of this method. Use Double::ToString(int precision) to set the specific precision.
99 * - The behavior of this method is dependent on the specified locale setting.
100 * - The specific error code can be accessed using the GetLastResult() method.
102 static String ToString(double value, const char* pLocale);
105 * Locale specifiable version of Double::ToString(int precision). @n
106 * This method is affected by the specified @c pLocale.
110 * @return A string containing a Unicode representation of the specified @c double value
111 * @param[in] value A @c double value to convert
112 * @param[in] pLocale A specific locale identifier. @n
113 * The @c pLocale can have below values.
114 * - "" : the system default locale
115 * - "C" or "POSIX" : the POSIX locale
116 * - "language[_territory][.codeset]" : an implementation-provided locale, e.g. "en_US.utf8", "fr_FR.utf8", etc.
117 * @param[in] precision Number of digits after a decimal separator
118 * @exception E_SUCCESS The method is successful.
119 * @exception E_INVALID_ARG The specified locale identifier is invalid.
121 * - If the input value is Not-a-Number(NaN), the result is the string "NaN".
122 * Furthermore, infinity produces the result "Infinity". @n
123 * - The behavior of this method is dependent on the specified locale setting.
124 * - The specific error code can be accessed using the GetLastResult() method.
126 static String ToString(double value, const char* pLocale, int precision);
129 * Locale specifiable version of Float::ToString(). @n
130 * This method is affected by the specified @c pLocale.
134 * @return A string containing a Unicode representation of the specified @c float value
135 * @param[in] value A @c float value to convert
136 * @param[in] pLocale A specific locale identifier. @n
137 * The @c pLocale can have below values.
138 * - "" : the system default locale
139 * - "C" or "POSIX" : the POSIX locale
140 * - "language[_territory][.codeset]" : an implementation-provided locale, e.g. "en_US.utf8", "fr_FR.utf8", etc.
141 * @exception E_SUCCESS The method is successful.
142 * @exception E_INVALID_ARG The specified locale identifier is invalid.
144 * - If the input value is Not-a-Number(NaN), the result is the string "NaN".
145 * Furthermore, infinity produces the result "Infinity". @n
146 * 6 digits are given for the precision of this method. Use Float::ToString(int precision) to set the specific precision.
147 * - The behavior of this method is dependent on the specified locale setting.
148 * - The specific error code can be accessed using the GetLastResult() method.
150 static String ToString(float value, const char* pLocale);
153 * Locale specifiable version of Float::ToString(int precision). @n
154 * This method is affected by the specified @c pLocale.
158 * @return A string containing a Unicode representation of the specified @c float value
159 * @param[in] value A @c float value to convert
160 * @param[in] pLocale A specific locale identifier. @n
161 * The @c pLocale can have below values.
162 * - "" : the system default locale
163 * - "C" or "POSIX" : the POSIX locale
164 * - "language[_territory][.codeset]" : an implementation-provided locale, e.g. "en_US.utf8", "fr_FR.utf8", etc.
165 * @param[in] precision Number of digits after a decimal separator
166 * @exception E_SUCCESS The method is successful.
167 * @exception E_INVALID_ARG The specified locale identifier is invalid.
169 * - If the input value is Not-a-Number(NaN), the result is the string "NaN".
170 * Furthermore, infinity produces the result "Infinity". @n
171 * - The behavior of this method is dependent on the specified locale setting.
172 * - The specific error code can be accessed using the GetLastResult() method.
174 static String ToString(float value, const char* pLocale, int precision);
178 // This default constructor is intentionally declared as private because this class is not constructible.
182 _LocalizedNumParser(void);
185 // This destructor is intentionally declared as private because this class is not constructible.
189 ~_LocalizedNumParser(void);
192 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
196 // @param[in] rhs A reference to the %_LocalizedNumParser instance
198 _LocalizedNumParser(const _LocalizedNumParser& rhs);
201 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
205 // @return A reference to the %_LocalizedNumParser instance
206 // @param[in] rhs A reference to the %_LocalizedNumParser instance
208 _LocalizedNumParser& operator =(const _LocalizedNumParser& rhs);
210 static const int FLOAT_LENGTH_MAX = 7 + 38 + 3; // significant decimal digits + exponent + extra characters
211 static const int DBL_MAX_LENGTH = 17 + 308 + 3; // significant decimal digits + exponent + extra characters
214 #endif // _FBASE_INTERNAL_LOCALIZED_NUM_PARSER_H_