Merge "Making changes in number classes to maintain compatibility with 2.1 applicat...
[platform/framework/native/appfw.git] / inc / FBaseInt8.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                FBaseInt8.h
19  * @brief               This is the header file for the %Int8 class.
20  *
21  * @see                 Tizen::Base::Number
22  *
23  * This header file contains the declarations of the %Int8 class.
24  */
25 #ifndef _FBASE_INT8_H_
26 #define _FBASE_INT8_H_
27
28 #include <FBaseNumber.h>
29
30 namespace Tizen { namespace Base
31 {
32 /**
33  * @class       Int8
34  * @brief       <i> [Deprecated] </i>
35  * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
36  *
37  * @brief       This class is the wrapper class for the @c signed @c char built-in type.
38  *
39  * @since 2.0
40  *
41  * The %Int8 class represents an integer value ranging from -128 to 127. The class is useful when passing an 8-bit
42  * signed integral value to a method that accepts only an instance of Object. Furthermore, this class provides
43  * methods for converting %Int8 (and @c char) to String, and %String to %Int8 (and @c char).
44  *
45  * The following example demonstrates how to use the %Int8 class.
46  * @code
47  *
48  *      #include <FBase.h>
49  *
50  *      using namespace Tizen::Base;
51  *
52  *      // This method checks whether the given string object contains a string
53  *      // representation of the pre-defined minimum 8-bit integral value.
54  *      result
55  *      MyClass::Verify(String& string, bool& out)
56  *      {
57  *              static const Int8 MINIMUM(123);
58  *
59  *              result r = E_SUCCESS;
60  *
61  *              char ch;
62  *              r = Int8::Parse(string, ch);
63  *              if (IsFailed(r))
64  *              {
65  *                      goto CATCH;
66  *              }
67  *
68  *              out = (MINIMUM.CompareTo(ch) == 0) ? true: false;
69  *
70  *              return r;
71  *      CATCH:
72  *              return r;
73  *      }
74  * @endcode
75  */
76 class _OSP_EXPORT_ Int8
77         : public Number
78 {
79 public:
80         /**
81          * Initializes this instance of %Int8 with the specified value.
82          *
83          * @since 2.0
84          * @brief       <i> [Deprecated] </i>
85          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
86          *
87          *
88          * @param[in]   value   A @c char value
89          */
90         Int8(char value = 0);
91
92         /**
93          * Copying of objects using this copy constructor is allowed.
94          *
95          * @since 2.0
96          * @brief       <i> [Deprecated] </i>
97          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
98          *
99          *
100          * @param[in]   value   An instance of %Int8
101          */
102         Int8(const Int8& value);
103
104         /**
105          * This destructor overrides Tizen::Base::Object::~Object().
106          *
107          * @since 2.0
108          * @brief       <i> [Deprecated] </i>
109          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
110          *
111          */
112         virtual ~Int8(void);
113
114         /**
115          * Copying of objects using this copy assignment operator is allowed.
116          *
117          * @since 2.0
118          * @brief       <i> [Deprecated] </i>
119          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
120          *
121          * @param[in]   rhs     An instance of %Int8
122          */
123         Int8& operator =(const Int8& rhs);
124
125         /**
126          * Compares two @c char values.
127          *
128          * @since 2.0
129          * @brief       <i> [Deprecated] </i>
130          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
131          *
132          * @return              A 32-bit @c signed integer value
133          * @code
134          * <  0  if the value of ch1 is less than the value of ch2
135          * == 0  if the value of ch1 is equal to the value of ch2
136          * >  0  if the value of ch1 is greater than the value of ch2
137          * @endcode
138          * @param[in]   ch1     The first @c char value to compare
139          * @param[in]   ch2     The second @c char value to compare
140          */
141         static int Compare(char ch1, char ch2);
142
143         /**
144          * Compares the value of the current instance with the value of the specified instance of the %Int8 class.
145          *
146          * @since 2.0
147          * @brief       <i> [Deprecated] </i>
148          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
149          *
150          * @return              A 32-bit @c signed integer value
151          * @code
152          * <  0  if the value of the current instance is less than the value of the specified instance
153          * == 0  if the value of the current instance is equal to the value of the specified instance
154          * >  0  if the value of the current instance is greater than the value of the specified instance
155          * @endcode
156          * @param[in]   value   An instance of the %Int8 class to compare
157          */
158         int CompareTo(const Int8& value) const;
159
160         /**
161          * Checks whether the value of the specified instance of %Int8 is equal to the value of the current instance.
162          *
163          * @since 2.0
164          * @brief       <i> [Deprecated] </i>
165          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
166          *
167          * @return              @c true if the value of the specified instance is equal to the value of the current instance, @n
168          *                              else @c false
169          * @param[in]   obj An instance of Object to compare
170          * @see                 Tizen::Base::Object::Equals()
171          */
172         virtual bool Equals(const Object& obj) const;
173
174         /**
175          * Gets the hash value of the current instance of %Int8.
176          *
177          * @since 2.0
178          * @brief       <i> [Deprecated] </i>
179          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
180          *
181          *      @return         An integer value indicating the hash value of the current instance of %Int8
182          *      @remarks        Two equal instances must return the same hash value. For better performance,
183          *                              the used hash function must generate a random distribution for all inputs. @n
184          *                              The default implementation of this method returns the value of the current instance.
185          */
186         virtual int GetHashCode(void) const;
187
188         /**
189          * Gets the hash value of the specified @c char value.
190          *
191          * @since 2.0
192          * @brief       <i> [Deprecated] </i>
193          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
194          *
195          *   @return            An integer value indicating the hash value of the specified @c char value
196          *   @param[in] val   A @c char value to get the hash value
197          */
198         static int GetHashCode(char val);
199
200         /**
201          * Decodes a string into a @c signed @c char.
202          *
203          * @since 2.0
204          * @brief       <i> [Deprecated] </i>
205          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
206          *
207          * @return              An error code
208          * @param[in]   s       A string representing a numeric value
209          * @param[out]  ret     The result of the operation
210          * @exception   E_SUCCESS       The method is successful.
211          * @exception   E_NUM_FORMAT    The specified string does not contain a number that can be parsed.
212          * @exception   E_OUT_OF_RANGE  The decoded value is not between VALUE_MIN and VALUE_MAX range. @b Since: @b 3.0
213          *
214          * @remarks             This method accepts decimal, hexadecimal, and octal numbers given by the
215          *                              following grammar:
216          * @code
217          *      - DecodableString:
218          *              Sign[opt] DecimalNumeral
219          *              Sign[opt] 0x HexDigits
220          *              Sign[opt] 0X HexDigits
221          *              Sign[opt] # HexDigits
222          *              Sign[opt] 0 OctalDigits
223          *      - Sign:
224          *              '-'
225          * @endcode
226          * @remarks             This method has portability issue. @n
227          *                              When the specified string is nagative number in the ARM architecture, type casting is needed like following code.
228          * @code
229          *      char ret;
230          *      Int8::Decode(L"-0X20", ret);
231          *      SomeOutputFunction(static_cast< signed char >(ret));
232          * @endcode
233          */
234         static result Decode(const String& s, char& ret);
235
236         /**
237          * Parses the @c signed @c char equivalent of the specified string representing a numeric value.
238          *
239          * @since 2.0
240          * @brief       <i> [Deprecated] </i>
241          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
242          *
243          * @return              An error code
244          * @param[in]   s       A string representing a numeric value
245          * @param[out]  ret     The result of the operation
246          * @exception   E_SUCCESS       The method is successful.
247          * @exception   E_NUM_FORMAT    The specified string does not contain a byte that can be parsed.
248          * @exception   E_OUT_OF_RANGE  The parsed value is not between VALUE_MIN and VALUE_MAX range. @b Since: @b 3.0
249          *
250          * @remarks
251          *                              - This method assumes that the string representing the numeric value uses a radix 10.
252          *                              - This method guarantees that the original value of out-parameter is not changed when the method returns error.
253          */
254         static result Parse(const String& s, char& ret);
255
256         /**
257          * Parses the specified string representing a numeric value and
258          * returns the value as @c signed @c char (as out parameter).
259          *
260          * @since 2.0
261          * @brief       <i> [Deprecated] </i>
262          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
263          *
264          * @return              The @c signed @c char equivalent of the specified string representing the numeric value using the specified index
265          * @param[in]   s       A string representing a numeric value
266          * @param[in]   radix   The radix of the string representing a numeric value @n
267          *                      Radix value range is from 2 to 36.
268          * @param[out]  ret             The result of the operation
269          * @exception   E_SUCCESS       The method is successful.
270          * @exception   E_NUM_FORMAT    The specified string does not contain a number that can be parsed.
271          * @exception   E_OUT_OF_RANGE  The specified @c radix is invalid or
272          *                              The parsed value is not between VALUE_MIN and VALUE_MAX range. @b Since: @b 3.0
273          *
274          * @remarks             This method guarantees that the original value of out-parameter is not changed when the method returns error.
275          */
276         static result Parse(const String& s, int radix, char& ret);
277
278         /**
279          * Gets the @c signed @c char equivalent of the current instance of %Int8.
280          *
281          * @since 2.0
282          * @brief       <i> [Deprecated] </i>
283          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
284          *
285          * @return      The @c signed @c char equivalent of the current instance
286          */
287         virtual char ToChar(void) const;
288
289         /**
290          * Gets the @c signed @c short equivalent of the current instance of %Int8.
291          *
292          * @since 2.0
293          * @brief       <i> [Deprecated] </i>
294          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
295          *
296          * @return      The @c signed @c short equivalent of the current instance
297          */
298         virtual short ToShort(void) const;
299
300         /**
301          * Gets the @c signed @c int equivalent of the current instance of %Int8.
302          *
303          * @since 2.0
304          * @brief       <i> [Deprecated] </i>
305          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
306          *
307          * @return      The @c signed @c int equivalent of the current instance
308          */
309         virtual int ToInt(void) const;
310
311         /**
312          * Gets the @c signed @c long equivalent of the current instance of %Int8.
313          *
314          * @since 2.0
315          * @brief       <i> [Deprecated] </i>
316          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
317          *
318          * @return      The @c signed @c long equivalent of the current instance
319          */
320         virtual long ToLong(void) const;
321
322         /**
323          * Gets the @c signed @c long @c long equivalent of the current instance of %Int8.
324          *
325          * @since 2.0
326          * @brief       <i> [Deprecated] </i>
327          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
328          *
329          * @return      The @c signed @c long @c long equivalent of the current instance
330          */
331         virtual long long ToLongLong(void) const;
332
333         /**
334          * Gets the @c signed @c float equivalent of the current instance of %Int8.
335          *
336          * @since 2.0
337          * @brief       <i> [Deprecated] </i>
338          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
339          *
340          * @return      The @c signed @c float equivalent of the current instance
341          */
342         virtual float ToFloat(void) const;
343
344         /**
345          * Gets the @c signed @c double equivalent of the current instance of %Int8.
346          *
347          * @since 2.0
348          * @brief       <i> [Deprecated] </i>
349          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
350          *
351          * @return      The @c signed @c double equivalent of the current instance
352          */
353         virtual double ToDouble(void) const;
354
355         /**
356          * Gets the string representing the value of the current instance of %Int8.
357          *
358          * @since 2.0
359          * @brief       <i> [Deprecated] </i>
360          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
361          *
362          * @return              A string representing the value of the current instance
363          */
364         virtual String ToString(void) const;
365
366         /**
367          * Gets the string representing the specified @c signed @c char value using radix @c 10.
368          *
369          * @since 2.0
370          * @brief       <i> [Deprecated] </i>
371          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
372          *
373          * @return              A string containing a Unicode representation of the specified @c char value using radix 10
374          * @param[in]   value   A @c char value
375          */
376         static String ToString(char value);
377
378         /**
379          * A constant holding the maximum value of type @c char. @n
380          * A @c short character can hold a value of upto 2^7-1.
381          *
382          * @since 2.0
383          * @brief       <i> [Deprecated] </i>
384          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
385          *
386          */
387         static const char VALUE_MAX = (signed char) 0x7F;
388
389         /**
390          * A constant holding the minimum value of type @c char. @n
391          * A @c short character can hold a value of upto -2^7.
392          *
393          * @since 2.0
394          * @brief       <i> [Deprecated] </i>
395          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
396          *
397          */
398         static const char VALUE_MIN = (signed char) 0x80;
399
400         /**
401          * A @c signed @c char value of this instance.
402          *
403          * @since 2.0
404          * @brief       <i> [Deprecated] </i>
405          * @deprecated  This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
406          *
407          */
408         signed char value;
409
410
411 private:
412         friend class _Int8Impl;
413         class _Int8Impl* __pInt8Impl;
414
415 }; // Int8
416
417 }} // Tizen::Base
418
419 #endif //_FBASE_INT8_H_