2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FBaseLongLong.h
20 * @brief This is the header file for the %LongLong class.
22 * @see Tizen::Base::Number
24 * This header file contains the declarations of the %LongLong class.
26 #ifndef _FBASE_LONG_LONG_H_
27 #define _FBASE_LONG_LONG_H_
29 #include <FBaseNumber.h>
32 namespace Tizen { namespace Base
36 * @brief This class is the wrapper class for the @c signed @c long @c long built-in type.
40 * The %LongLong class represents an integer value ranging from -9223372036854775808 to 9223372036854775807
41 * , that is, -(2^63) to +((2^63)-1). The class is useful when passing a 64-bit @c signed
42 * integral value to a method that accepts only an instance of Object. Furthermore,
43 * this class provides methods for converting %LongLong (and @c long @c long) to String, and %String
44 * to %LongLong (and @c long @c long).
46 * The following example demonstrates how to use the %LongLong class.
52 * using namespace Tizen::Base;
54 * // This method checks whether the given string object contains a string
55 * // representation of the pre-defined minimum 64-bit integral value
57 * MyClass::Verify(String& string, bool& out)
59 * static const LongLong MINIMUM(123456789);
60 * result r = E_SUCCESS;
63 * r = LongLong::Parse(string, l);
69 * out = (MINIMUM.CompareTo(l) == 0) ? true: false;
77 class _OSP_EXPORT_ LongLong
82 * Initializes this instance of %LongLong with the specified value.
86 * @param[in] value A @c long @c long value
88 LongLong(long long value = 0);
91 * Copying of objects using this copy constructor is allowed.
95 * @param[in] value An instance of %LongLong
97 LongLong(const LongLong& value);
100 * This destructor overrides Tizen::Base::Object::~Object().
104 virtual ~LongLong(void);
107 * Copying of objects using this copy assignment operator is allowed.
111 * @param[in] rhs An instance of %LongLong
113 LongLong& operator =(const LongLong& rhs);
116 * Compares two @c long @c long values.
120 * @return A 32-bit @c signed integer value
122 * < 0 if the value of @c l1 is less than the value of @c l2
123 * == 0 if the value of @c l1 is equal to the value of @c l2
124 * > 0 if the value of @c l1 is greater than the value of @c l2
126 * @param[in] l1 The first @c long @c long value to compare
127 * @param[in] l2 The second @c long @c long value to compare
129 static int Compare(long long l1, long long l2);
132 * Compares the value of the current instance with the value of the specified instance of the %LongLong class.
136 * @return A 32-bit @c signed integer value
138 * < 0 if the value of the current instance is less than the value of the specified instance
139 * == 0 if the value of the current instance is equal to the value of the specified instance
140 * > 0 if the value of the current instance is greater than the value of the specified instance
142 * @param[in] value An instance of the %LongLong class to compare
144 int CompareTo(const LongLong& value) const;
147 * Checks whether the value of the specified instance of Object is equal to the value of the current instance of %LongLong.
151 * @return @c true if the value of the specified instance of Object is equal to the value of the current instance of %LongLong, @n
153 * @param[in] obj An instance of Object to compare
154 * @see Tizen::Base::Object::Equals()
156 virtual bool Equals(const Object& obj) const;
159 * Gets the hash value of the current instance of %LongLong.
163 * @return An integer value indicating the hash value of the current instance of %LongLong
164 * @remarks Two equal instances must return the same hash value. For better performance,
165 * the used hash function must generate a random distribution for all inputs. @n
166 * The default implementation of this method returns the value of the current instance.
168 virtual int GetHashCode(void) const;
171 * Gets the hash value of the specified @c long @c long value.
175 * @return An integer value indicating the hash value of the specified @c long @c long value
176 * @param[in] val A @c long @c long value to get the hash value
178 static int GetHashCode(long long val);
181 * Gets the @c signed @c char equivalent of the current instance of the %LongLong class.
185 * @return The @c signed @c char equivalent of the current instance
187 virtual char ToChar(void) const;
190 * Gets the @c signed @c short equivalent of the current instance of the %LongLong class.
194 * @return The @c signed @c short equivalent of the current instance
196 virtual short ToShort(void) const;
199 * Gets the @c signed @c int equivalent of the current instance of the %LongLong class.
203 * @return The @c signed @c int equivalent of the current instance
205 virtual int ToInt(void) const;
208 * Gets the @c signed @c long equivalent of the current instance of the %LongLong class.
212 * @return The @c signed @c long equivalent of the current instance
214 virtual long ToLong(void) const;
217 * Gets the @c signed @c float equivalent of the current instance of the %LongLong class.
221 * @return The @c signed @c float equivalent of the current instance
223 virtual float ToFloat(void) const;
226 * Gets the @c signed @c double equivalent of the current instance of the %LongLong class.
230 * @return The @c signed @c double equivalent of the current instance
232 virtual double ToDouble(void) const;
235 * Gets the @c signed @c long @c long equivalent of the current instance of the %LongLong class.
239 * @return The @c signed @c long @c long equivalent of the current instance
241 virtual long long ToLongLong(void) const;
244 * Gets the string representing the value of the current instance of the %LongLong class.
248 * @return The string representing the value of the current instance
250 virtual String ToString(void) const;
253 * Gets the string representing the specified @c signed @c long @c long value.
257 * @return The string containing a Unicode representation of the specified @c signed @c long @c long value
258 * @param[in] value A @c signed @c long @c long value to convert
260 static String ToString(long long value);
263 * Parses the specified string representing a numeric value and
264 * returns the value as a @c signed @c long @c long (as out parameter).
268 * @return An error code
269 * @param[in] s A string representing a numeric value
270 * @param[out] ret The result of the operation
271 * @exception E_SUCCESS The method is successful.
272 * @exception E_NUM_FORMAT The specified string does not contain a number that can be parsed.
274 * - This method assumes that the string representing the numeric value uses a radix 10.
275 * - This method guarantees that the original value of out-parameter is not changed when the method returns error.
277 static result Parse(const String& s, long long& ret);
280 * Parses the specified string representing a numeric value using the specified radix and
281 * returns the value as a @c signed @c long @c long (as out parameter).
285 * @return An error code
286 * @param[in] s A string representing a numeric value
287 * @param[in] radix The radix of the string representing a unmeric value @n
288 * It must be either 2, 8, 10 or 16.
289 * @param[out] ret The result of the operation
290 * @exception E_SUCCESS The method is successful.
291 * @exception E_NUM_FORMAT The specified string does not contain a number that can be parsed.
292 * @exception E_OUT_OF_RANGE The specified @c radix is invalid.
293 * @remarks This method guarantees that the original value of out-parameter is not changed when the method returns error.
295 static result Parse(const String& s, int radix, long long& ret);
298 * A constant holding the maximum value a @c long @c long can have; 2^63-1.
302 static const long long VALUE_MAX = (long long) 0x7FFFFFFFFFFFFFFFLL;
305 * A constant holding the minimum value a @c long @c long can have; -2^63.
309 static const long long VALUE_MIN = (long long) 0x8000000000000000LL;
312 * A @c long @c long value of this instance.
320 friend class _LongLongImpl;
321 class _LongLongImpl * __pLongLongImpl;
327 #endif //_FBASE_LONG_LONG_H_