]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/longlong.h
Document that throwing exceptions from wxTimer::Notify() is unsupported.
[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
7b8b7304
FM
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
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
7b8b7304
FM
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*/
198class wxULongLong
199{
200};
201
e54c96f1 202
23324ae1
FM
203// ============================================================================
204// Global functions/macros
205// ============================================================================
206
b21126db 207/** @addtogroup group_funcmacro_misc */
7fa7088e
BP
208//@{
209
23324ae1
FM
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:
4cc4bfaf 214
23324ae1
FM
215 @code
216 #ifdef wxLongLong_t
7fa7088e
BP
217 wxLongLong_t ll = wxLL(0x1234567890abcdef);
218 printf("Long long = %" wxLongLongFmtSpec "x\n", ll);
219 #endif
23324ae1 220 @endcode
7c913512 221
e54c96f1 222 @see wxLL()
23324ae1 223
7fa7088e
BP
224 @header{wx/longlong.h}
225*/
226#define wxLongLongFmtSpec
23324ae1
FM
227
228/**
7fa7088e
BP
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:
4cc4bfaf 231
23324ae1
FM
232 @code
233 #ifdef wxLongLong_t
7fa7088e
BP
234 wxLongLong_t ll = wxLL(0x1234567890abcdef);
235 #endif
23324ae1 236 @endcode
7c913512 237
7fa7088e
BP
238 @see wxULL(), wxLongLong
239
240 @header{wx/longlong.h}
23324ae1 241*/
7fa7088e 242wxLongLong_t wxLL(number);
23324ae1
FM
243
244/**
7fa7088e
BP
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:
4cc4bfaf 247
23324ae1
FM
248 @code
249 #ifdef wxLongLong_t
7fa7088e
BP
250 unsigned wxLongLong_t ll = wxULL(0x1234567890abcdef);
251 #endif
23324ae1 252 @endcode
7c913512 253
7fa7088e
BP
254 @see wxLL(), wxLongLong
255
256 @header{wx/longlong.h}
23324ae1 257*/
7fa7088e
BP
258wxLongLong_t wxULL(number);
259
260//@}
23324ae1 261