sync with tizen_2.0
[platform/framework/native/appfw.git] / inc / FBaseNumber.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FBaseNumber.h
20  * @brief               This is the header file for the %Number class.
21  *
22  * This header file contains the declarations and definitions of the %Number class. @n
23  * This class is the abstract base class of all wrapped numeric types.
24  */
25 #ifndef _FBASE_NUMBER_H_
26 #define _FBASE_NUMBER_H_
27
28 #include <FBaseObject.h>
29 #include <FBaseString.h>
30
31
32 namespace Tizen { namespace Base
33 {
34 /**
35  *      @class  Number
36  *      @brief  This class is the base class of all wrapped numeric types.
37  *
38  *      @since 2.0
39  *
40  *      The %Number class is the abstract base class of all wrapped numeric classes.
41  *      The subclasses of %Number must provide methods to convert the represented
42  *      numeric value to @c char, @c short, @c int, @c long, @c float, and @c double.
43  *
44  * The following example demonstrates how to use the %Number class.
45  *
46  *      @code
47  *
48  *      #include <FBase.h>
49  *
50  *      using namespace Tizen::Base;
51  *
52  *      void
53  *      MyClass::NumberSample(void)
54  *      {
55  *              Long ld(0x12345678L);
56  *              int i = ld.Toint();             // i == 0x5678
57  *              char ch = ld.ToChar();  // ch == 0x78 or 120
58  *              // ...
59  *              Int8 j(ch);
60  *              Float f1(j.ToFloat()); // f1 == 120.0
61  *              // ...
62  *              Double d(120.100005L);
63  *              Float f2(d.ToFloat());  // f2 == 120.10001
64  *              Integer k(f2.ToInt());  // k == 120
65  *      }
66  *      @endcode
67  */
68 class _OSP_EXPORT_ Number
69         : public Object
70 {
71 public:
72         /**
73          * This destructor overrides Tizen::Base::Object::~Object().
74          *
75          * @since 2.0
76          */
77         virtual ~Number(void) { };
78
79         /**
80          *      Gets the @c signed @c char equivalent of the current instance of the %Number class.
81          *
82          *      @since 2.0
83          *
84          *      @return         The @c signed @c char equivalent of the current instance
85          */
86         virtual char ToChar(void) const = 0;
87
88         /**
89          *      Gets the @c signed @c short equivalent of the current instance of the %Number class.
90          *
91          *      @since 2.0
92          *
93          *      @return         The @c signed @c short equivalent of the current instance
94          */
95         virtual short ToShort(void) const = 0;
96
97         /**
98          *      Gets the @c signed @c int equivalent of the current instance of the %Number class.
99          *
100          *      @since 2.0
101          *
102          *      @return         The @c signed @c int equivalent of the current instance
103          */
104         virtual int ToInt(void) const = 0;
105
106         /**
107          *      Gets the @c signed @c long equivalent of the current instance of the %Number class.
108          *
109          *      @since 2.0
110          *
111          *      @return         The @c signed @c long equivalent of the current instance
112          */
113         virtual long ToLong(void) const = 0;
114
115         /**
116         *       Gets the @c signed @c long @c long equivalent of the current instance of the %Number class.
117         *
118         *       @since 2.0
119         *
120         *       @return         The @c signed @c long @c long equivalent of the current instance
121         */
122         virtual long long ToLongLong(void) const = 0;
123
124         /**
125          *      Gets the @c signed @c float equivalent of the current instance of the %Number class.
126          *
127          *      @since 2.0
128          *
129          *      @return         The @c signed @c float equivalent of the current instance
130          */
131         virtual float ToFloat(void) const = 0;
132
133         /**
134          *      Gets the @c signed @c double equivalent of the current instance of the %Number class.
135          *
136          *      @since 2.0
137          *
138          *      @return         The @c signed @c double equivalent of the current instance
139          */
140         virtual double ToDouble(void) const = 0;
141
142         /**
143          *      Gets the string representing the value of the current instance of the %Number class.
144          *
145          *      @since 2.0
146          *
147          *      @return         The string representing the value of the current instance
148          */
149         virtual String ToString(void) const = 0;
150
151 protected:
152         //
153         // This method is for internal use only. Using this method can cause behavioral, security-related,
154         // and consistency-related issues in the application.
155         // This method is reserved and may change its name at any time without prior notice.
156         //
157         // @since 2.0
158         //
159         virtual void Number_Reserved1(void) { }
160
161         //
162         // This method is for internal use only. Using this method can cause behavioral, security-related,
163         // and consistency-related issues in the application.
164         // This method is reserved and may change its name at any time without prior notice.
165         //
166         // @since 2.0
167         //
168         virtual void Number_Reserved2(void) { }
169
170 }; // Number
171
172 }}   // Tizen::Base
173
174 #endif // _FBASE_NUMBER_H_