Add to retry to read DUID.
[platform/framework/native/appfw.git] / inc / FBaseLongLong.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                FBaseLongLong.h
19  * @brief               This is the header file for the %LongLong class.
20  *
21  * @see                 Tizen::Base::Number
22  *
23  * This header file contains the declarations of the %LongLong class.
24  */
25 #ifndef _FBASE_LONG_LONG_H_
26 #define _FBASE_LONG_LONG_H_
27
28 #include <FBaseNumber.h>
29
30 namespace Tizen { namespace Base
31 {
32 /**
33  *      @class  LongLong
34  *      @brief  This class is the wrapper class for the @c signed @c long @c long built-in type.
35  *
36  *      @since  2.0
37  *
38  *      The %LongLong class represents an integer value ranging from -9223372036854775808 to 9223372036854775807
39  *      , that is, -(2^63) to +((2^63)-1). The class is useful when passing a 64-bit @c signed
40  *      integral value to a method that accepts only an instance of Object. Furthermore,
41  *      this class provides methods for converting %LongLong (and @c long @c long) to String, and %String
42  *      to %LongLong (and @c long @c long).
43  *
44  * The following example demonstrates how to use the %LongLong class.
45  *
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 64-bit integral value
54  *      result
55  *      MyClass::Verify(String& string, bool& out)
56  *      {
57  *              static const LongLong MINIMUM(123456789);
58  *              result r = E_SUCCESS;
59  *
60  *              long long l;
61  *              r = LongLong::Parse(string, l);
62  *              if (IsFailed(r))
63  *              {
64  *                      goto CATCH;
65  *              }
66  *
67  *              out = (MINIMUM.CompareTo(l) == 0) ? true: false;
68  *
69  *              return r;
70  *      CATCH:
71  *              return r;
72  *      }
73  *      @endcode
74  */
75 class _OSP_EXPORT_ LongLong
76         : public Number
77 {
78 public:
79         /**
80          *      Initializes this instance of %LongLong with the specified value.
81          *
82          *      @since                  2.0
83          *
84          *      @param[in]      value   A @c long @c long value
85          */
86         LongLong(long long value = 0);
87
88         /**
89          *      Copying of objects using this copy constructor is allowed.
90          *
91          *      @since                  2.0
92          *
93          *      @param[in]      value   An instance of %LongLong
94          */
95         LongLong(const LongLong& value);
96
97         /**
98          *      This destructor overrides Tizen::Base::Object::~Object().
99          *
100          *      @since  2.0
101          */
102         virtual ~LongLong(void);
103
104         /**
105          *      Copying of objects using this copy assignment operator is allowed.
106          *
107          *      @since                  2.0
108          *
109          *      @param[in]      rhs     An instance of %LongLong
110          */
111         LongLong& operator =(const LongLong& rhs);
112
113         /**
114          *      Compares two @c long @c long values.
115          *
116          *      @since          2.0
117          *
118          *      @return         A 32-bit @c signed integer value
119          *      @code
120          *      <  0  if the value of @c l1 is less than the value of @c l2
121          *      == 0  if the value of @c l1 is equal to the value of @c l2
122          *      >  0  if the value of @c l1 is greater than the value of @c l2
123          *      @endcode
124          *      @param[in]      l1      The first @c long @c long value to compare
125          *      @param[in]      l2      The second @c long @c long value to compare
126          */
127         static int Compare(long long l1, long long l2);
128
129         /**
130          *      Compares the value of the current instance with the value of the specified instance of the %LongLong class.
131          *
132          *      @since          2.0
133          *
134          *      @return         A 32-bit @c signed integer value
135          *      @code
136          *      <  0  if the value of the current instance is less than the value of the specified instance
137          *      == 0  if the value of the current instance is equal to the value of the specified instance
138          *      >  0  if the value of the current instance is greater than the value of the specified instance
139          *      @endcode
140          *      @param[in]      value   An instance of the %LongLong class to compare
141          */
142         int CompareTo(const LongLong& value) const;
143
144         /**
145          *      Checks whether the value of the specified instance of Object is equal to the value of the current instance of %LongLong.
146          *
147          *      @since          2.0
148          *
149          *      @return         @c true if the value of the specified instance of Object is equal to the value of the current instance of %LongLong, @n
150          *                              else @c false
151          *      @param[in]      obj     An instance of Object to compare
152          *      @see            Tizen::Base::Object::Equals()
153          */
154         virtual bool Equals(const Object& obj) const;
155
156         /**
157          *      Gets the hash value of the current instance of %LongLong.
158          *
159          *      @since          2.0
160          *
161          *      @return         An integer value indicating the hash value of the current instance of %LongLong
162          *      @remarks        Two equal instances must return the same hash value. For better performance,
163          *                              the used hash function must generate a random distribution for all inputs. @n
164          *                              The default implementation of this method returns the value of the current instance.
165          */
166         virtual int GetHashCode(void) const;
167
168         /**
169         *        Gets the hash value of the specified @c long @c long value.
170         *
171         *        @since         2.0
172         *
173         *        @return                An integer value indicating the hash value of the specified @c long @c long value
174         *        @param[in]   val   A @c long @c long value to get the hash value
175         */
176         static int GetHashCode(long long val);
177
178         /**
179          *      Gets the @c signed @c char equivalent of the current instance of the %LongLong class.
180          *
181          *      @since          2.0
182          *
183          *      @return         The @c signed @c char equivalent of the current instance
184          */
185         virtual char ToChar(void) const;
186
187         /**
188          *      Gets the @c signed @c short equivalent of the current instance of the %LongLong class.
189          *
190          *      @since          2.0
191          *
192          *      @return         The @c signed @c short equivalent of the current instance
193          */
194         virtual short ToShort(void) const;
195
196         /**
197          *      Gets the @c signed @c int equivalent of the current instance of the %LongLong class.
198          *
199          *      @since          2.0
200          *
201          *      @return         The @c signed @c int equivalent of the current instance
202          */
203         virtual int ToInt(void) const;
204
205         /**
206          *      Gets the @c signed @c long equivalent of the current instance of the %LongLong class.
207          *
208          *      @since          2.0
209          *
210          *      @return         The @c signed @c long equivalent of the current instance
211          */
212         virtual long ToLong(void) const;
213
214         /**
215          *      Gets the @c signed @c float equivalent of the current instance of the %LongLong class.
216          *
217          *      @since          2.0
218          *
219          *      @return         The @c signed @c float equivalent of the current instance
220          */
221         virtual float ToFloat(void) const;
222
223         /**
224          *      Gets the @c signed @c double equivalent of the current instance of the %LongLong class.
225          *
226          *      @since          2.0
227          *
228          *      @return         The @c signed @c double equivalent of the current instance
229          */
230         virtual double ToDouble(void) const;
231
232         /**
233          *      Gets the @c signed @c long @c long equivalent of the current instance of the %LongLong class.
234          *
235          *      @since          2.0
236          *
237          *      @return         The @c signed @c long @c long equivalent of the current instance
238          */
239         virtual long long ToLongLong(void) const;
240
241         /**
242          *      Gets the string representing the value of the current instance of the %LongLong class.
243          *
244          *      @since          2.0
245          *
246          *      @return         The string representing the value of the current instance
247          */
248         virtual String ToString(void) const;
249
250         /**
251          *      Gets the string representing the specified @c signed @c long @c long value.
252          *
253          *      @since                  2.0
254          *
255          *      @return                         The string containing a Unicode representation of the specified @c signed @c long @c long value
256          *      @param[in]      value   A @c signed @c long @c long value to convert
257          */
258         static String ToString(long long value);
259
260         /**
261          *      Parses the specified string representing a numeric value and
262          *      returns the value as a @c signed @c long @c long (as out parameter).
263          *
264          *      @since                  2.0
265          *
266          *      @return                 An error code
267          *      @param[in]      s                               A string representing a numeric value
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          *      @remarks
272          *                              - This method assumes that the string representing the numeric value uses a radix 10.
273          *                              - This method guarantees that the original value of out-parameter is not changed when the method returns error.
274          */
275         static result Parse(const String& s, long long& ret);
276
277         /**
278          *      Parses the specified string representing a numeric value using the specified radix and
279          *      returns the value as a @c signed @c long @c long (as out parameter).
280          *
281          *      @since                  2.1
282          *
283          *      @return                 An error code
284          *      @param[in]      s                               A string representing a numeric value
285          *      @param[in]      radix                   The radix of the string representing a numeric value @n
286          *                                                              It must be either 2, 8, 10 or 16.
287          *      @param[out]     ret                             The result of the operation
288          *      @exception      E_SUCCESS               The method is successful.
289          *      @exception      E_NUM_FORMAT    The specified string does not contain a number that can be parsed.
290          *      @exception      E_OUT_OF_RANGE  The specified @c radix is invalid.
291          *      @remarks        This method guarantees that the original value of out-parameter is not changed when the method returns error.
292          */
293         static result Parse(const String& s, int radix, long long& ret);
294
295         /**
296          *      A constant holding the maximum value a @c long @c long can have; 2^63-1.
297          *
298          *      @since  2.0
299          */
300         static const long long VALUE_MAX = (long long) 0x7FFFFFFFFFFFFFFFLL;
301
302         /**
303          *      A constant holding the minimum value a @c long @c long can have; -2^63.
304          *
305          *      @since  2.0
306          */
307         static const long long VALUE_MIN = (long long) 0x8000000000000000LL;
308
309         /**
310          * A @c long @c long value of this instance.
311          *
312          * @since       2.0
313          */
314         long long value;
315
316
317 private:
318         friend class _LongLongImpl;
319         class _LongLongImpl* __pLongLongImpl;
320
321 }; // LongLong
322
323 }} // Tizen::Base
324
325 #endif //_FBASE_LONG_LONG_H_