]> git.saurik.com Git - wxWidgets.git/blame - interface/longlong.h
revised base64.h;bitmap.h
[wxWidgets.git] / interface / longlong.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: longlong.h
e54c96f1 3// Purpose: interface of wxLongLong
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxLongLong
11 @wxheader{longlong.h}
7c913512 12
23324ae1
FM
13 This class represents a signed 64 bit long number. It is implemented using the
14 native 64 bit type where available (machines with 64 bit longs or compilers
15 which have (an analog of) @e long long type) and uses the emulation code in
16 the other cases which ensures that it is the most efficient solution for
17 working with 64 bit integers independently of the architecture.
7c913512 18
23324ae1
FM
19 wxLongLong defines all usual arithmetic operations such as addition,
20 subtraction, bitwise shifts and logical operations as well as multiplication
21 and division (not yet for the machines without native @e long long). It
7c913512 22 also has operators for implicit construction from and conversion to the native
23324ae1 23 @e long long type if it exists and @e long.
7c913512 24
23324ae1
FM
25 You would usually use this type in exactly the same manner as any other
26 (built-in) arithmetic type. Note that wxLongLong is a signed type, if you
27 want unsigned values use wxULongLong which has exactly the same API as
28 wxLongLong except when explicitly mentioned otherwise.
7c913512 29
23324ae1
FM
30 If a native (i.e. supported directly by the compiler) 64 bit integer type was
31 found to exist, @e wxLongLong_t macro will be defined to correspond to it.
7c913512 32 Also, in this case only, two additional macros will be defined:
e54c96f1 33 wxLongLongFmtSpec() for printing 64 bit integers
7c913512 34 using the standard @c printf() function (but see also
23324ae1 35 wxLongLong::ToString for a more portable solution) and
e54c96f1 36 wxLL() for defining 64 bit integer compile-time constants.
7c913512 37
23324ae1
FM
38 @library{wxbase}
39 @category{data}
40*/
7c913512 41class wxLongLong
23324ae1
FM
42{
43public:
44 /**
45 Constructor from 2 longs: the high and low part are combined into one
46 wxLongLong.
47 */
48 wxLongLong(long hi, unsigned long lo);
49
50 //@{
51 /**
52 Returns an absolute value of wxLongLong - either making a copy (const version)
53 or modifying it in place (the second one). Not in wxULongLong.
54 */
55 wxLongLong Abs();
328f5751 56 const wxLongLong& Abs();
23324ae1
FM
57 //@}
58
59 /**
60 This allows to convert a double value to wxLongLong type. Such conversion is
61 not always possible in which case the result will be silently truncated in a
62 platform-dependent way. Not in wxULongLong.
63 */
64 wxLongLong Assign(double d);
65
66 /**
67 Returns the high 32 bits of 64 bit integer.
68 */
328f5751 69 long GetHi() const;
23324ae1
FM
70
71 /**
72 Returns the low 32 bits of 64 bit integer.
73 */
328f5751 74 unsigned long GetLo() const;
23324ae1
FM
75
76 /**
77 Convert to native long long (only for compilers supporting it)
78 */
328f5751 79 wxLongLong_t GetValue() const;
23324ae1
FM
80
81 /**
82 Returns the value as @c double.
83 */
328f5751 84 double ToDouble() const;
23324ae1
FM
85
86 /**
87 Truncate wxLongLong to long. If the conversion loses data (i.e. the wxLongLong
88 value is outside the range of built-in long type), an assert will be triggered
89 in debug mode.
90 */
328f5751 91 long ToLong() const;
23324ae1
FM
92
93 /**
94 Returns the string representation of a wxLongLong.
95 */
328f5751 96 wxString ToString() const;
23324ae1
FM
97
98 /**
99 Adds 2 wxLongLongs together and returns the result.
100 */
328f5751 101 wxLongLong operator+(const wxLongLong& ll) const;
23324ae1
FM
102
103 //@{
104 /**
105 Pre/post increment operator.
106 */
107 wxLongLong operator++();
7c913512 108 wxLongLong operator++(int );
23324ae1
FM
109 //@}
110
111 /**
112 Add another wxLongLong to this one.
113 */
114 wxLongLong operator+(const wxLongLong& ll);
115
116 /**
117 Subtracts 2 wxLongLongs and returns the result.
118 */
328f5751 119 wxLongLong operator-(const wxLongLong& ll) const;
23324ae1
FM
120
121 //@{
122 /**
123 Pre/post decrement operator.
124 */
125 wxLongLong operator--();
7c913512 126 wxLongLong operator--(int );
23324ae1
FM
127 //@}
128
129 /**
130 Subtracts another wxLongLong from this one.
131 */
132 wxLongLong operator-(const wxLongLong& ll);
133
134 /**
135 Assignment operator from unsigned long long. The sign bit will be copied too.
e54c96f1
FM
136
137 @wxsince{2.7.0}
23324ae1 138 */
4cc4bfaf 139 wxLongLong& operator operator=(const wxULongLong& ll);
23324ae1
FM
140};
141
142
e54c96f1 143
23324ae1
FM
144// ============================================================================
145// Global functions/macros
146// ============================================================================
147
148/**
149 This macro is defined to contain the @c printf() format specifier using
150 which 64 bit integer numbers (i.e. those of type @c wxLongLong_t) can be
151 printed. Example of using it:
4cc4bfaf 152
23324ae1
FM
153 @code
154 #ifdef wxLongLong_t
155 wxLongLong_t ll = wxLL(0x1234567890abcdef);
156 printf("Long long = %" wxLongLongFmtSpec "x\n", ll);
157 #endif
158 @endcode
7c913512 159
e54c96f1 160 @see wxLL()
23324ae1
FM
161*/
162
163
164/**
165 This macro is defined for the platforms with a native 64 bit integer type and
166 allows to define unsigned 64 bit compile time constants:
4cc4bfaf 167
23324ae1
FM
168 @code
169 #ifdef wxLongLong_t
170 unsigned wxLongLong_t ll = wxULL(0x1234567890abcdef);
171 #endif
172 @endcode
7c913512 173
e54c96f1 174 @see wxLL(), wxLongLong
23324ae1 175*/
4cc4bfaf 176wxLongLong_t wxULL(number);
23324ae1
FM
177
178/**
179 This macro is defined for the platforms with a native 64 bit integer type and
180 allows to define 64 bit compile time constants:
4cc4bfaf 181
23324ae1
FM
182 @code
183 #ifdef wxLongLong_t
184 wxLongLong_t ll = wxLL(0x1234567890abcdef);
185 #endif
186 @endcode
7c913512 187
e54c96f1 188 @see wxULL(), wxLongLong
23324ae1 189*/
4cc4bfaf 190wxLongLong_t wxLL(number);
23324ae1 191