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 %Int8 class.
21 * @see Tizen::Base::Number
23 * This header file contains the declarations of the %Int8 class.
25 #ifndef _FBASE_INT8_H_
26 #define _FBASE_INT8_H_
28 #include <FBaseNumber.h>
30 namespace Tizen { namespace Base
34 * @brief <i> [Deprecated] </i>
35 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
37 * @brief This class is the wrapper class for the @c signed @c char built-in type.
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).
45 * The following example demonstrates how to use the %Int8 class.
50 * using namespace Tizen::Base;
52 * // This method checks whether the given string object contains a string
53 * // representation of the pre-defined minimum 8-bit integral value.
55 * MyClass::Verify(String& string, bool& out)
57 * static const Int8 MINIMUM(123);
59 * result r = E_SUCCESS;
62 * r = Int8::Parse(string, ch);
68 * out = (MINIMUM.CompareTo(ch) == 0) ? true: false;
76 class _OSP_EXPORT_ Int8
81 * Initializes this instance of %Int8 with the specified value.
84 * @brief <i> [Deprecated] </i>
85 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
88 * @param[in] value A @c char value
93 * Copying of objects using this copy constructor is allowed.
96 * @brief <i> [Deprecated] </i>
97 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
100 * @param[in] value An instance of %Int8
102 Int8(const Int8& value);
105 * This destructor overrides Tizen::Base::Object::~Object().
108 * @brief <i> [Deprecated] </i>
109 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
115 * Copying of objects using this copy assignment operator is allowed.
118 * @brief <i> [Deprecated] </i>
119 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
121 * @param[in] rhs An instance of %Int8
123 Int8& operator =(const Int8& rhs);
126 * Compares two @c char values.
129 * @brief <i> [Deprecated] </i>
130 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
132 * @return A 32-bit @c signed integer value
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
138 * @param[in] ch1 The first @c char value to compare
139 * @param[in] ch2 The second @c char value to compare
141 static int Compare(char ch1, char ch2);
144 * Compares the value of the current instance with the value of the specified instance of the %Int8 class.
147 * @brief <i> [Deprecated] </i>
148 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
150 * @return A 32-bit @c signed integer value
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
156 * @param[in] value An instance of the %Int8 class to compare
158 int CompareTo(const Int8& value) const;
161 * Checks whether the value of the specified instance of %Int8 is equal to the value of the current instance.
164 * @brief <i> [Deprecated] </i>
165 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
167 * @return @c true if the value of the specified instance is equal to the value of the current instance, @n
169 * @param[in] obj An instance of Object to compare
170 * @see Tizen::Base::Object::Equals()
172 virtual bool Equals(const Object& obj) const;
175 * Gets the hash value of the current instance of %Int8.
178 * @brief <i> [Deprecated] </i>
179 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
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.
186 virtual int GetHashCode(void) const;
189 * Gets the hash value of the specified @c char value.
192 * @brief <i> [Deprecated] </i>
193 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
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
198 static int GetHashCode(char val);
201 * Decodes a string into a @c signed @c char.
204 * @brief <i> [Deprecated] </i>
205 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
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.
213 * @remarks This method accepts decimal, hexadecimal, and octal numbers given by the
217 * Sign[opt] DecimalNumeral
218 * Sign[opt] 0x HexDigits
219 * Sign[opt] 0X HexDigits
220 * Sign[opt] # HexDigits
221 * Sign[opt] 0 OctalDigits
225 * @remarks This method has portability issue. @n
226 * When the specified string is nagative number in the ARM architecture, type casting is needed like following code.
229 * Int8::Decode(L"-0X20", ret);
230 * SomeOutputFunction(static_cast< signed char >(ret));
233 static result Decode(const String& s, char& ret);
236 * Parses the @c signed @c char equivalent of the specified string representing a numeric value.
239 * @brief <i> [Deprecated] </i>
240 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
242 * @return An error code
243 * @param[in] s A string representing a numeric value
244 * @param[out] ret The result of the operation
245 * @exception E_SUCCESS The method is successful.
246 * @exception E_NUM_FORMAT The specified string does not contain a byte that can be parsed.
249 * - This method assumes that the string representing the numeric value uses a radix 10.
250 * - This method guarantees that the original value of out-parameter is not changed when the method returns error.
252 static result Parse(const String& s, char& ret);
255 * Parses the specified string representing a numeric value and
256 * returns the value as @c signed @c char (as out parameter).
259 * @brief <i> [Deprecated] </i>
260 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
262 * @return The @c signed @c char equivalent of the specified string representing the numeric value using the specified index
263 * @param[in] s A string representing a numeric value
264 * @param[in] radix The radix of the string representing a numeric value @n
265 * Radix value range is from 2 to 36.
266 * @param[out] ret The result of the operation
267 * @exception E_SUCCESS The method is successful.
268 * @exception E_NUM_FORMAT The specified string does not contain a number that can be parsed.
270 * @remarks This method guarantees that the original value of out-parameter is not changed when the method returns error.
272 static result Parse(const String& s, int radix, char& ret);
275 * Gets the @c char equivalent of the current instance of %Int8.
278 * @brief <i> [Deprecated] </i>
280 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
281 * This method has portability issue.
282 * Return value may not be @c signed @c char since char is treated as unsigned char in ARM architecture. @n
283 * Use ToInt8() method to get @c int8_t
284 * @return The @c char equivalent of the current instance
287 virtual char ToChar(void) const;
290 * Gets the @c int8_t equivalent of the current instance of %Int8.
294 * @return The @c int8_t equivalent of the current instance
295 * @remarks This method always returns 0. Use Integer8::ToInt8() to get the @int8_t
297 virtual int8_t ToInt8(void) const;
300 * Gets the @c signed @c short equivalent of the current instance of %Int8.
303 * @brief <i> [Deprecated] </i>
304 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
306 * @return The @c signed @c short equivalent of the current instance
308 virtual short ToShort(void) const;
311 * Gets the @c signed @c int equivalent of the current instance of %Int8.
314 * @brief <i> [Deprecated] </i>
315 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
317 * @return The @c signed @c int equivalent of the current instance
319 virtual int ToInt(void) const;
322 * Gets the @c signed @c long equivalent of the current instance of %Int8.
325 * @brief <i> [Deprecated] </i>
326 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
328 * @return The @c signed @c long equivalent of the current instance
330 virtual long ToLong(void) const;
333 * Gets the @c signed @c long @c long equivalent of the current instance of %Int8.
336 * @brief <i> [Deprecated] </i>
337 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
339 * @return The @c signed @c long @c long equivalent of the current instance
341 virtual long long ToLongLong(void) const;
344 * Gets the @c signed @c float equivalent of the current instance of %Int8.
347 * @brief <i> [Deprecated] </i>
348 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
350 * @return The @c signed @c float equivalent of the current instance
352 virtual float ToFloat(void) const;
355 * Gets the @c signed @c double equivalent of the current instance of %Int8.
358 * @brief <i> [Deprecated] </i>
359 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
361 * @return The @c signed @c double equivalent of the current instance
363 virtual double ToDouble(void) const;
366 * Gets the string representing the value of the current instance of %Int8.
369 * @brief <i> [Deprecated] </i>
370 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
372 * @return A string representing the value of the current instance
374 virtual String ToString(void) const;
377 * Gets the string representing the specified @c signed @c char value using radix @c 10.
380 * @brief <i> [Deprecated] </i>
381 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
383 * @return A string containing a Unicode representation of the specified @c char value using radix 10
384 * @param[in] value A @c char value
386 static String ToString(char value);
389 * A constant holding the maximum value of type @c char. @n
390 * A @c short character can hold a value of upto 2^7-1.
393 * @brief <i> [Deprecated] </i>
394 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
397 static const char VALUE_MAX = static_cast< signed char >(0x7F);
400 * A constant holding the minimum value of type @c char. @n
401 * A @c short character can hold a value of upto -2^7.
404 * @brief <i> [Deprecated] </i>
405 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
408 static const char VALUE_MIN = static_cast< signed char >(0x80);
411 * A @c signed @c char value of this instance.
414 * @brief <i> [Deprecated] </i>
415 * @deprecated This class is deprecated because char is treated as unsigned char in ARM architecture. Use Integer8 class.
422 friend class _Int8Impl;
423 class _Int8Impl* __pInt8Impl;
429 #endif //_FBASE_INT8_H_