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