]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/longlong.h
add event table for wxAuiNotebook (partially fixes #4175)
[wxWidgets.git] / interface / wx / longlong.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: longlong.h
3 // Purpose: interface of wxLongLong
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxLongLong
11
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.
17
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
21 also has operators for implicit construction from and conversion to the native
22 @e long long type if it exists and @e long.
23
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.
28
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.
31 Also, in this case only, two additional macros will be defined:
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.
35
36 @library{wxbase}
37 @category{data}
38 */
39 class wxLongLong
40 {
41 public:
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
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)
61 or modifying it in place (the second one). Not in wxULongLong.
62 */
63 wxLongLong Abs() const;
64 wxLongLong& Abs();
65 //@}
66
67 /**
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.
72 */
73 wxLongLong Assign(double d);
74
75 /**
76 Returns the high 32 bits of 64 bit integer.
77 */
78 long GetHi() const;
79
80 /**
81 Returns the low 32 bits of 64 bit integer.
82 */
83 unsigned long GetLo() const;
84
85 /**
86 Convert to native long long (only for compilers supporting it).
87 */
88 wxLongLong_t GetValue() const;
89
90 /**
91 Returns the value as @c double.
92 */
93 double ToDouble() const;
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 */
100 long ToLong() const;
101
102 /**
103 Returns the string representation of a wxLongLong.
104 */
105 wxString ToString() const;
106
107
108 /**
109 Adds 2 wxLongLongs together and returns the result.
110 */
111 wxLongLong operator+(const wxLongLong& ll) const;
112
113 /**
114 Add another wxLongLong to this one.
115 */
116 wxLongLong& operator+(const wxLongLong& ll);
117
118
119 /**
120 Subtracts 2 wxLongLongs and returns the result.
121 */
122 wxLongLong operator-(const wxLongLong& ll) const;
123
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
138 //@{
139 /**
140 Pre/post decrement operator.
141 */
142 wxLongLong operator--();
143 wxLongLong operator--(int);
144 //@}
145
146 /**
147 Returns the value of this wxLongLong with opposite sign. Not in wxULongLong.
148 */
149 wxLongLong operator-() const;
150
151 /**
152 Assignment operator from unsigned long long. The sign bit will be copied too.
153
154 @since 2.7.0
155 */
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
184 };
185
186
187
188 // ============================================================================
189 // Global functions/macros
190 // ============================================================================
191
192 /** @ingroup group_funcmacro_misc */
193 //@{
194
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:
199
200 @code
201 #ifdef wxLongLong_t
202 wxLongLong_t ll = wxLL(0x1234567890abcdef);
203 printf("Long long = %" wxLongLongFmtSpec "x\n", ll);
204 #endif
205 @endcode
206
207 @see wxLL()
208
209 @header{wx/longlong.h}
210 */
211 #define wxLongLongFmtSpec
212
213 /**
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:
216
217 @code
218 #ifdef wxLongLong_t
219 wxLongLong_t ll = wxLL(0x1234567890abcdef);
220 #endif
221 @endcode
222
223 @see wxULL(), wxLongLong
224
225 @header{wx/longlong.h}
226 */
227 wxLongLong_t wxLL(number);
228
229 /**
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:
232
233 @code
234 #ifdef wxLongLong_t
235 unsigned wxLongLong_t ll = wxULL(0x1234567890abcdef);
236 #endif
237 @endcode
238
239 @see wxLL(), wxLongLong
240
241 @header{wx/longlong.h}
242 */
243 wxLongLong_t wxULL(number);
244
245 //@}
246