]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/longlong.h
Convert wxFSW_EVENT_{WARNING,ERROR} to string correctly.
[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 licence
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).
21 It 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 @class wxULongLong
189
190 This class represents an unsigned 64 bit long number.
191
192 Since wxULongLong has exactly the same API as wxLongLong, please refer
193 to wxLongLong documentation (this page exists only as redirection).
194
195 @library{wxbase}
196 @category{data}
197 */
198 class wxULongLong
199 {
200 };
201
202
203 // ============================================================================
204 // Global functions/macros
205 // ============================================================================
206
207 /** @addtogroup group_funcmacro_misc */
208 //@{
209
210 /**
211 This macro is defined to contain the @c printf() format specifier using
212 which 64 bit integer numbers (i.e. those of type @c wxLongLong_t) can be
213 printed. Example of using it:
214
215 @code
216 #ifdef wxLongLong_t
217 wxLongLong_t ll = wxLL(0x1234567890abcdef);
218 printf("Long long = %" wxLongLongFmtSpec "x\n", ll);
219 #endif
220 @endcode
221
222 @see wxLL()
223
224 @header{wx/longlong.h}
225 */
226 #define wxLongLongFmtSpec
227
228 /**
229 This macro is defined for the platforms with a native 64 bit integer type
230 and allow the use of 64 bit compile time constants:
231
232 @code
233 #ifdef wxLongLong_t
234 wxLongLong_t ll = wxLL(0x1234567890abcdef);
235 #endif
236 @endcode
237
238 @see wxULL(), wxLongLong
239
240 @header{wx/longlong.h}
241 */
242 wxLongLong_t wxLL(number);
243
244 /**
245 This macro is defined for the platforms with a native 64 bit integer type
246 and allow the use of 64 bit compile time constants:
247
248 @code
249 #ifdef wxLongLong_t
250 unsigned wxLongLong_t ll = wxULL(0x1234567890abcdef);
251 #endif
252 @endcode
253
254 @see wxLL(), wxLongLong
255
256 @header{wx/longlong.h}
257 */
258 wxLongLong_t wxULL(number);
259
260 //@}
261