2 // Copyright (c) 2012 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.
19 * @brief This is the header file for the %Number class.
21 * This header file contains the declarations and definitions of the %Number class. @n
22 * This class is the abstract base class of all wrapped numeric types.
24 #ifndef _FBASE_NUMBER_H_
25 #define _FBASE_NUMBER_H_
27 #include <FBaseObject.h>
28 #include <FBaseString.h>
30 namespace Tizen { namespace Base
34 * @brief This class is the base class of all wrapped numeric types.
38 * The %Number class is the abstract base class of all wrapped numeric classes.
39 * The subclasses of %Number must provide methods to convert the represented
40 * numeric value to @c char, @c short, @c int, @c long, @c float, and @c double.
42 * The following example demonstrates how to use the %Number class.
48 * using namespace Tizen::Base;
51 * MyClass::NumberSample(void)
53 * Long ld(0x12345678L);
54 * int i = ld.Toint(); // i == 0x5678
55 * char ch = ld.ToChar(); // ch == 0x78 or 120
58 * Float f1(j.ToFloat()); // f1 == 120.0
60 * Double d(120.100005L);
61 * Float f2(d.ToFloat()); // f2 == 120.10001
62 * Integer k(f2.ToInt()); // k == 120
66 class _OSP_EXPORT_ Number
71 * This destructor overrides Tizen::Base::Object::~Object().
75 virtual ~Number(void) { };
78 * Gets the @c char equivalent of the current instance of the %Number class.
81 * @brief <i> [Deprecated] </i>
83 * @deprecated This method has portability issue.
84 * Return value may not be @c signed @c char since char is treated as unsigned char in ARM architecture. @n
85 * Use ToInt8() method to get @c int8_t
87 * @return The @c char equivalent of the current instance
89 virtual char ToChar(void) const = 0;
92 * Gets the @c signed @c short equivalent of the current instance of the %Number class.
96 * @return The @c signed @c short equivalent of the current instance
98 virtual short ToShort(void) const = 0;
101 * Gets the @c signed @c int equivalent of the current instance of the %Number class.
105 * @return The @c signed @c int equivalent of the current instance
107 virtual int ToInt(void) const = 0;
110 * Gets the @c signed @c long equivalent of the current instance of the %Number class.
114 * @return The @c signed @c long equivalent of the current instance
116 virtual long ToLong(void) const = 0;
119 * Gets the @c signed @c long @c long equivalent of the current instance of the %Number class.
123 * @return The @c signed @c long @c long equivalent of the current instance
125 virtual long long ToLongLong(void) const = 0;
128 * Gets the @c signed @c float equivalent of the current instance of the %Number class.
132 * @return The @c signed @c float equivalent of the current instance
134 virtual float ToFloat(void) const = 0;
137 * Gets the @c signed @c double equivalent of the current instance of the %Number class.
141 * @return The @c signed @c double equivalent of the current instance
143 virtual double ToDouble(void) const = 0;
146 * Gets the string representing the value of the current instance of the %Number class.
150 * @return The string representing the value of the current instance
152 virtual String ToString(void) const = 0;
155 * Gets the @c int8_t equivalent of the current instance of the %Number class.
159 * @return The @c int8_t equivalent of the current instance
161 virtual int8_t ToInt8(void) const
168 // This method is for internal use only. Using this method can cause behavioral, security-related,
169 // and consistency-related issues in the application.
170 // This method is reserved and may change its name at any time without prior notice.
174 virtual void Number_Reserved1(void) { }
180 #endif // _FBASE_NUMBER_H_