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 String::Format() 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 Float::ToString(). @n
106 * This method is affected by the specified @c pLocale.
110 * @return A string containing a Unicode representation of the specified @c float value
111 * @param[in] value A @c float 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 * @exception E_SUCCESS The method is successful.
118 * @exception E_INVALID_ARG The specified locale identifier is invalid.
120 * - If the input value is Not-a-Number(NaN), the result is the string "NaN".
121 * Furthermore, infinity produces the result "Infinity". @n
122 * 6 digits are given for the precision of this method. Use String::Format() to set the specific precision.
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(float value, const char* pLocale);
130 // This default constructor is intentionally declared as private because this class is not constructible.
134 _LocalizedNumParser(void);
137 // This destructor is intentionally declared as private because this class is not constructible.
141 ~_LocalizedNumParser(void);
144 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
148 // @param[in] rhs A reference to the %_LocalizedNumParser instance
150 _LocalizedNumParser(const _LocalizedNumParser& rhs);
153 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
157 // @return A reference to the %_LocalizedNumParser instance
158 // @param[in] rhs A reference to the %_LocalizedNumParser instance
160 _LocalizedNumParser& operator =(const _LocalizedNumParser& rhs);
162 static const int FLOAT_LENGTH_MAX = 7 + 38 + 3; // significant decimal digits + exponent + extra characters
163 static const int DBL_MAX_LENGTH = 17 + 308 + 3; // significant decimal digits + exponent + extra characters
166 #endif // _FBASE_INTERNAL_LOCALIZED_NUM_PARSER_H_