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