Merge "Remove the memory leak on osp-security-service" into tizen_2.2
[platform/framework/native/appfw.git] / inc / FBaseNumber.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                FBaseNumber.h
19  * @brief               This is the header file for the %Number class.
20  *
21  * This header file contains the declarations and definitions of the %Number class.
22  *
23  */
24 #ifndef _FBASE_NUMBER_H_
25 #define _FBASE_NUMBER_H_
26
27 #include <FBaseObject.h>
28 #include <FBaseString.h>
29
30 namespace Tizen { namespace Base
31 {
32 /**
33  *      @class  Number
34  *      @brief  This class is the base class of all wrapped numeric types.
35  *
36  *      @since 2.0
37  *
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.
41  *
42  * The following example demonstrates how to use the %Number class.
43  *
44  *      @code
45  *
46  *      #include <FBase.h>
47  *
48  *      using namespace Tizen::Base;
49  *
50  *      void
51  *      MyClass::NumberSample(void)
52  *      {
53  *              Long ld(0x12345678L);
54  *              int i = ld.Toint();             // i == 0x5678
55  *              char ch = ld.ToChar();  // ch == 0x78 or 120
56  *              // ...
57  *              Int8 j(ch);
58  *              Float f1(j.ToFloat()); // f1 == 120.0
59  *              // ...
60  *              Double d(120.100005L);
61  *              Float f2(d.ToFloat());  // f2 == 120.10001
62  *              Integer k(f2.ToInt());  // k == 120
63  *      }
64  *      @endcode
65  */
66 class _OSP_EXPORT_ Number
67         : public Object
68 {
69 public:
70         /**
71          * This destructor overrides Tizen::Base::Object::~Object().
72          *
73          * @since 2.0
74          */
75         virtual ~Number(void) { };
76
77         /**
78          *      Gets the @c signed @c char equivalent of the current instance of %Number.
79          *
80          *      @since 2.0
81          *
82          *      @return         The @c signed @c char equivalent of the current instance
83          */
84         virtual char ToChar(void) const = 0;
85
86         /**
87          *      Gets the @c signed @c short equivalent of the current instance of %Number.
88          *
89          *      @since 2.0
90          *
91          *      @return         The @c signed @c short equivalent of the current instance
92          */
93         virtual short ToShort(void) const = 0;
94
95         /**
96          *      Gets the @c signed @c int equivalent of the current instance of %Number.
97          *
98          *      @since 2.0
99          *
100          *      @return         The @c signed @c int equivalent of the current instance
101          */
102         virtual int ToInt(void) const = 0;
103
104         /**
105          *      Gets the @c signed @c long equivalent of the current instance of %Number.
106          *
107          *      @since 2.0
108          *
109          *      @return         The @c signed @c long equivalent of the current instance
110          */
111         virtual long ToLong(void) const = 0;
112
113         /**
114         *       Gets the @c signed @c long @c long equivalent of the current instance of %Number.
115         *
116         *       @since 2.0
117         *
118         *       @return         The @c signed @c long @c long equivalent of the current instance
119         */
120         virtual long long ToLongLong(void) const = 0;
121
122         /**
123          *      Gets the @c signed @c float equivalent of the current instance of %Number.
124          *
125          *      @since 2.0
126          *
127          *      @return         The @c signed @c float equivalent of the current instance
128          */
129         virtual float ToFloat(void) const = 0;
130
131         /**
132          *      Gets the @c signed @c double equivalent of the current instance of %Number.
133          *
134          *      @since 2.0
135          *
136          *      @return         The @c signed @c double equivalent of the current instance
137          */
138         virtual double ToDouble(void) const = 0;
139
140         /**
141          *      Gets the string that represents the value of the current instance of %Number.
142          *
143          *      @since 2.0
144          *
145          *      @return         The string that represents the value of the current instance
146          */
147         virtual String ToString(void) const = 0;
148
149 protected:
150         //
151         // This method is for internal use only. Using this method can cause behavioral, security-related,
152         // and consistency-related issues in the application.
153         // This method is reserved and may change its name at any time without prior notice.
154         //
155         // @since 2.0
156         //
157         virtual void Number_Reserved1(void) { }
158
159         //
160         // This method is for internal use only. Using this method can cause behavioral, security-related,
161         // and consistency-related issues in the application.
162         // This method is reserved and may change its name at any time without prior notice.
163         //
164         // @since 2.0
165         //
166         virtual void Number_Reserved2(void) { }
167
168 }; // Number
169
170 }}   // Tizen::Base
171
172 #endif // _FBASE_NUMBER_H_