]>
Commit | Line | Data |
---|---|---|
43f06cfd WS |
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
2 | %% Name: variant.tex | |
3 | %% Purpose: wxVariant docs | |
4 | %% Author: wxWidgets Team | |
5 | %% Modified by: | |
6 | %% Created: 01/30/2005 | |
7 | %% RCS-ID: $Id$ | |
8 | %% Copyright: (c) wxWidgets Team | |
9 | %% License: wxWindows license | |
10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
11 | ||
a974387a JS |
12 | \section{\class{wxVariant}}\label{wxvariant} |
13 | ||
14 | The {\bf wxVariant} class represents a container for any type. | |
15 | A variant's value can be changed at run time, possibly to a different type of value. | |
16 | ||
38f82bf6 | 17 | As standard, wxVariant can store values of type bool, wxChar, double, long, string, |
2562c823 RR |
18 | string list, time, date, void pointer, list of strings, and list of variants. |
19 | However, an application can extend wxVariant's capabilities by deriving from the | |
20 | class \helpref{wxVariantData}{wxvariantdata} and using the wxVariantData form of | |
21 | the wxVariant constructor or assignment operator to assign this data to a variant. | |
22 | Actual values for user-defined types will need to be accessed via the wxVariantData | |
23 | object, unlike the case for basic data types where convenience functions such as | |
24 | \helpref{GetLong}{wxvariantgetlong} can be used. | |
25 | ||
eb753b56 | 26 | Pointers to any \helpref{wxObject}{wxobject} derived class can also easily be stored |
2562c823 RR |
27 | in a wxVariant. wxVariant will then use wxWidgets' built-in RTTI system to set the |
28 | type name (returned by \helpref{GetType}{wxvariantgettype}) and to perform | |
29 | type-safety checks at runtime. | |
a974387a JS |
30 | |
31 | This class is useful for reducing the programming for certain tasks, such as an editor | |
32 | for different data types, or a remote procedure call protocol. | |
33 | ||
3f90a399 RR |
34 | An optional name member is associated with a wxVariant. This might be used, for example, |
35 | in CORBA or OLE automation classes, where named parameters are required. | |
a974387a | 36 | |
631787c4 VZ |
37 | Note that as of wxWidgets 2.7.1, wxVariant is \helpref{reference counted}{trefcount}. |
38 | Additionally, the convenience macros {\bf DECLARE\_VARIANT\_OBJECT} and | |
39 | {\bf IMPLEMENT\_VARIANT\_OBJECT} were added so that adding (limited) support | |
40 | for conversion to and from wxVariant can be very easily implemented without modifying | |
41 | either wxVariant or the class to be stored by wxVariant. Since assignment operators | |
42 | cannot be declared outside the class, the shift left operators are used like this: | |
3f90a399 RR |
43 | |
44 | \begin{verbatim} | |
45 | // in the header file | |
46 | DECLARE_VARIANT_OBJECT(MyClass) | |
47 | ||
48 | // in the implementation file | |
49 | IMPLMENT_VARIANT_OBJECT(MyClass) | |
50 | ||
51 | // in the user code | |
52 | wxVariant variant; | |
53 | MyClass value; | |
54 | variant << value; | |
55 | ||
56 | // or | |
57 | value << variant; | |
58 | \end{verbatim} | |
59 | ||
60 | For this to work, MyClass must derive from \helpref{wxObject}{wxobject}, implement | |
61 | the \helpref{wxWidgets RTTI system}{runtimeclassoverview} | |
62 | and support the assignment operator and equality operator for itself. Ideally, it | |
63 | should also be reference counted to make copying operations cheap and fast. This | |
64 | can be most easily implemented using the reference counting support offered by | |
65 | \helpref{wxObject}{wxobject} itself. By default, wxWidgets already implements | |
66 | the shift operator conversion for a few of its drawing related classes: | |
67 | ||
68 | \begin{verbatim} | |
69 | IMPLEMENT_VARIANT_OBJECT(wxColour) | |
3f90a399 RR |
70 | IMPLEMENT_VARIANT_OBJECT(wxImage) |
71 | IMPLEMENT_VARIANT_OBJECT(wxIcon) | |
72 | IMPLEMENT_VARIANT_OBJECT(wxBitmap) | |
73 | \end{verbatim} | |
2562c823 | 74 | |
a974387a JS |
75 | \wxheading{Derived from} |
76 | ||
77 | \helpref{wxObject}{wxobject} | |
78 | ||
954b8ae6 JS |
79 | \wxheading{Include files} |
80 | ||
81 | <wx/variant.h> | |
82 | ||
a7af285d VZ |
83 | \wxheading{Library} |
84 | ||
85 | \helpref{wxBase}{librarieslist} | |
86 | ||
a974387a JS |
87 | \wxheading{See also} |
88 | ||
89 | \helpref{wxVariantData}{wxvariantdata} | |
90 | ||
91 | \latexignore{\rtfignore{\wxheading{Members}}} | |
92 | ||
93 | \membersection{wxVariant::wxVariant}\label{wxvariantctor} | |
94 | ||
95 | \func{}{wxVariant}{\void} | |
96 | ||
97 | Default constructor. | |
98 | ||
99 | \func{}{wxVariant}{\param{const wxVariant\& }{variant}} | |
100 | ||
631787c4 | 101 | Copy constructor, uses \helpref{reference counting}{trefcount}. |
a974387a | 102 | |
38f82bf6 | 103 | \func{}{wxVariant}{\param{const wxChar*}{ value}, \param{const wxString\& }{name = ``"}} |
f6bcfd97 | 104 | |
a974387a JS |
105 | \func{}{wxVariant}{\param{const wxString\&}{ value}, \param{const wxString\& }{name = ``"}} |
106 | ||
107 | Construction from a string value. | |
108 | ||
38f82bf6 | 109 | \func{}{wxVariant}{\param{wxChar}{ value}, \param{const wxString\& }{name = ``"}} |
a974387a JS |
110 | |
111 | Construction from a character value. | |
112 | ||
113 | \func{}{wxVariant}{\param{long}{ value}, \param{const wxString\& }{name = ``"}} | |
114 | ||
115 | Construction from an integer value. You may need to cast to (long) to | |
116 | avoid confusion with other constructors (such as the bool constructor). | |
117 | ||
118 | \func{}{wxVariant}{\param{bool}{ value}, \param{const wxString\& }{name = ``"}} | |
119 | ||
120 | Construction from a boolean value. | |
121 | ||
122 | \func{}{wxVariant}{\param{double}{ value}, \param{const wxString\& }{name = ``"}} | |
123 | ||
124 | Construction from a double-precision floating point value. | |
125 | ||
126 | \func{}{wxVariant}{\param{const wxList\&}{ value}, \param{const wxString\& }{name = ``"}} | |
127 | ||
128 | Construction from a list of wxVariant objects. This constructor | |
129 | copies {\it value}, the application is still responsible for | |
130 | deleting {\it value} and its contents. | |
131 | ||
a974387a JS |
132 | \func{}{wxVariant}{\param{void*}{ value}, \param{const wxString\& }{name = ``"}} |
133 | ||
134 | Construction from a void pointer. | |
135 | ||
cf6ae290 RG |
136 | \func{}{wxVariant}{\param{wxObject*}{ value}, \param{const wxString\& }{name = ``"}} |
137 | ||
138 | Construction from a wxObject pointer. | |
139 | ||
a974387a JS |
140 | \func{}{wxVariant}{\param{wxVariantData*}{ data}, \param{const wxString\& }{name = ``"}} |
141 | ||
8715d2d3 RN |
142 | Construction from user-defined data. The variant holds onto the {\it data} pointer. |
143 | ||
144 | \func{}{wxVariant}{\param{wxDateTime\&}{ val}, \param{const wxString\& }{name = ``"}} | |
145 | ||
43f06cfd | 146 | Construction from a \helpref{wxDateTime}{wxdatetime}. |
8715d2d3 RN |
147 | |
148 | \func{}{wxVariant}{\param{wxArrayString\&}{ val}, \param{const wxString\& }{name = ``"}} | |
149 | ||
150 | Construction from an array of strings. This constructor copies {\it value} and its contents. | |
151 | ||
152 | \func{}{wxVariant}{\param{DATE\_STRUCT*}{ val}, \param{const wxString\& }{name = ``"}} | |
153 | ||
154 | Construction from a odbc date value. Represented internally by a \helpref{wxDateTime}{wxdatetime} value. | |
155 | ||
156 | \func{}{wxVariant}{\param{TIME\_STRUCT*}{ val}, \param{const wxString\& }{name = ``"}} | |
157 | ||
158 | Construction from a odbc time value. Represented internally by a \helpref{wxDateTime}{wxdatetime} value. | |
159 | ||
160 | \func{}{wxVariant}{\param{TIMESTAMP\_STRUCT*}{ val}, \param{const wxString\& }{name = ``"}} | |
161 | ||
162 | Construction from a odbc timestamp value. Represented internally by a \helpref{wxDateTime}{wxdatetime} value. | |
a974387a JS |
163 | |
164 | \membersection{wxVariant::\destruct{wxVariant}}\label{wxvariantdtor} | |
165 | ||
166 | \func{}{\destruct{wxVariant}}{\void} | |
167 | ||
168 | Destructor. | |
169 | ||
2562c823 RR |
170 | Note that destructor is protected, so wxVariantData cannot usually |
171 | be deleted. Instead, \helpref{DecRef}{wxvariantdatadecref} should be called. | |
631787c4 | 172 | See \helpref{reference-counted object destruction}{refcountdestruct} for more info. |
2562c823 | 173 | |
8715d2d3 | 174 | |
a974387a JS |
175 | \membersection{wxVariant::Append}\label{wxvariantappend} |
176 | ||
177 | \func{void}{Append}{\param{const wxVariant\&}{ value}} | |
178 | ||
179 | Appends a value to the list. | |
180 | ||
2562c823 RR |
181 | \membersection{wxVariant::Clear}\label{wxvariantclear} |
182 | ||
183 | \func{void}{Clear}{\void} | |
184 | ||
185 | Makes the variant null by deleting the internal data and | |
186 | set the name to {\it wxEmptyString}. | |
187 | ||
a974387a JS |
188 | \membersection{wxVariant::ClearList}\label{wxvariantclearlist} |
189 | ||
190 | \func{void}{ClearList}{\void} | |
191 | ||
192 | Deletes the contents of the list. | |
193 | ||
8715d2d3 RN |
194 | |
195 | \membersection{wxVariant::Convert}\label{wxvariantconvert} | |
196 | ||
0f353563 | 197 | \constfunc{bool}{Convert}{\param{long*}{ value}} |
8715d2d3 | 198 | |
0f353563 | 199 | \constfunc{bool}{Convert}{\param{bool*}{ value}} |
8715d2d3 | 200 | |
0f353563 | 201 | \constfunc{bool}{Convert}{\param{double*}{ value}} |
8715d2d3 | 202 | |
0f353563 | 203 | \constfunc{bool}{Convert}{\param{wxString*}{ value}} |
8715d2d3 | 204 | |
38f82bf6 | 205 | \constfunc{bool}{Convert}{\param{wxChar*}{ value}} |
8715d2d3 | 206 | |
0f353563 | 207 | \constfunc{bool}{Convert}{\param{wxDateTime*}{ value}} |
8715d2d3 RN |
208 | |
209 | Retrieves and converts the value of this variant to the type that {\it value} is. | |
210 | ||
211 | ||
a974387a JS |
212 | \membersection{wxVariant::GetCount}\label{wxvariantgetcount} |
213 | ||
0902898a | 214 | \constfunc{size\_t}{GetCount}{\void} |
a974387a JS |
215 | |
216 | Returns the number of elements in the list. | |
217 | ||
218 | \membersection{wxVariant::Delete}\label{wxvariantdelete} | |
219 | ||
0902898a | 220 | \func{bool}{Delete}{\param{size\_t }{item}} |
a974387a JS |
221 | |
222 | Deletes the zero-based {\it item} from the list. | |
223 | ||
8715d2d3 RN |
224 | \membersection{wxVariant::GetArrayString}\label{wxvariantgetarraystring} |
225 | ||
226 | \constfunc{wxArrayString}{GetArrayString}{\void} | |
227 | ||
228 | Returns the string array value. | |
229 | ||
a974387a JS |
230 | \membersection{wxVariant::GetBool}\label{wxvariantgetbool} |
231 | ||
232 | \constfunc{bool}{GetBool}{\void} | |
233 | ||
234 | Returns the boolean value. | |
235 | ||
236 | \membersection{wxVariant::GetChar}\label{wxvariantgetchar} | |
237 | ||
38f82bf6 | 238 | \constfunc{wxChar}{GetChar}{\void} |
a974387a JS |
239 | |
240 | Returns the character value. | |
241 | ||
242 | \membersection{wxVariant::GetData}\label{wxvariantgetdata} | |
243 | ||
244 | \constfunc{wxVariantData*}{GetData}{\void} | |
245 | ||
2562c823 RR |
246 | Returns a pointer to the internal variant data. To take ownership |
247 | of this data, you must call its \helpref{IncRef}{wxvariantdataincref} | |
248 | method. When you stop using it, \helpref{DecRef}{wxvariantdatadecref} | |
249 | must be likewise called. | |
a974387a | 250 | |
8715d2d3 RN |
251 | \membersection{wxVariant::GetDateTime}\label{wxvariantgetdatetime} |
252 | ||
253 | \constfunc{wxDateTime}{GetDateTime}{\void} | |
254 | ||
255 | Returns the date value. | |
256 | ||
a974387a JS |
257 | \membersection{wxVariant::GetDouble}\label{wxvariantgetdouble} |
258 | ||
259 | \constfunc{double}{GetDouble}{\void} | |
260 | ||
261 | Returns the floating point value. | |
262 | ||
263 | \membersection{wxVariant::GetLong}\label{wxvariantgetlong} | |
264 | ||
265 | \constfunc{long}{GetLong}{\void} | |
266 | ||
267 | Returns the integer value. | |
268 | ||
269 | \membersection{wxVariant::GetName}\label{wxvariantgetname} | |
270 | ||
271 | \constfunc{const wxString\&}{GetName}{\void} | |
272 | ||
273 | Returns a constant reference to the variant name. | |
274 | ||
275 | \membersection{wxVariant::GetString}\label{wxvariantgetstring} | |
276 | ||
277 | \constfunc{wxString}{GetString}{\void} | |
278 | ||
279 | Gets the string value. | |
280 | ||
a974387a JS |
281 | \membersection{wxVariant::GetType}\label{wxvariantgettype} |
282 | ||
283 | \constfunc{wxString}{GetType}{\void} | |
284 | ||
285 | Returns the value type as a string. The built-in types are: bool, char, date, double, list, long, string, stringlist, time, void*. | |
286 | ||
287 | If the variant is null, the value type returned is the string ``null" (not the empty string). | |
288 | ||
289 | \membersection{wxVariant::GetVoidPtr}\label{wxvariantgetvoidptr} | |
290 | ||
291 | \constfunc{void*}{GetVoidPtr}{\void} | |
292 | ||
293 | Gets the void pointer value. | |
294 | ||
cf6ae290 RG |
295 | \membersection{wxVariant::GetWxObjectPtr}\label{wxvariantgetwxobjectptr} |
296 | ||
cfd5930d | 297 | \constfunc{wxObject*}{GetWxObjectPtr}{\void} |
cf6ae290 RG |
298 | |
299 | Gets the wxObject pointer value. | |
300 | ||
a974387a JS |
301 | \membersection{wxVariant::Insert}\label{wxvariantinsert} |
302 | ||
303 | \func{void}{Insert}{\param{const wxVariant\&}{ value}} | |
304 | ||
305 | Inserts a value at the front of the list. | |
306 | ||
307 | \membersection{wxVariant::IsNull}\label{wxvariantisnull} | |
308 | ||
309 | \constfunc{bool}{IsNull}{\void} | |
310 | ||
cc81d32f | 311 | Returns true if there is no data associated with this variant, false if there is data. |
a974387a JS |
312 | |
313 | \membersection{wxVariant::IsType}\label{wxvariantistype} | |
314 | ||
315 | \constfunc{bool}{IsType}{\param{const wxString\&}{ type}} | |
316 | ||
cc81d32f | 317 | Returns true if {\it type} matches the type of the variant, false otherwise. |
a974387a | 318 | |
cf6ae290 RG |
319 | \membersection{wxVariant::IsValueKindOf}\label{wxvariantisvaluekindof} |
320 | ||
321 | \constfunc{bool}{IsValueKindOf}{\param{const wxClassInfo* type}{ type}} | |
322 | ||
323 | Returns true if the data is derived from the class described by {\it type}, false otherwise. | |
324 | ||
a974387a JS |
325 | \membersection{wxVariant::MakeNull}\label{wxvariantmakenull} |
326 | ||
327 | \func{void}{MakeNull}{\void} | |
328 | ||
329 | Makes the variant null by deleting the internal data. | |
330 | ||
331 | \membersection{wxVariant::MakeString}\label{wxvariantmakestring} | |
332 | ||
333 | \constfunc{wxString}{MakeString}{\void} | |
334 | ||
335 | Makes a string representation of the variant value (for any type). | |
336 | ||
337 | \membersection{wxVariant::Member}\label{wxvariantmember} | |
338 | ||
339 | \constfunc{bool}{Member}{\param{const wxVariant\&}{ value}} | |
340 | ||
cc81d32f | 341 | Returns true if {\it value} matches an element in the list. |
a974387a JS |
342 | |
343 | \membersection{wxVariant::NullList}\label{wxvariantnulllist} | |
344 | ||
345 | \func{void}{NullList}{\void} | |
346 | ||
347 | Makes an empty list. This differs from a null variant which has no data; a null list | |
348 | is of type list, but the number of elements in the list is zero. | |
349 | ||
350 | \membersection{wxVariant::SetData}\label{wxvariantsetdata} | |
351 | ||
352 | \func{void}{SetData}{\param{wxVariantData*}{ data}} | |
353 | ||
354 | Sets the internal variant data, deleting the existing data if there is any. | |
355 | ||
356 | \membersection{wxVariant::operator $=$}\label{wxvariantassignment} | |
357 | ||
358 | \func{void}{operator $=$}{\param{const wxVariant\& }{value}} | |
359 | ||
360 | \func{void}{operator $=$}{\param{wxVariantData* }{value}} | |
361 | ||
362 | \func{void}{operator $=$}{\param{const wxString\& }{value}} | |
363 | ||
38f82bf6 | 364 | \func{void}{operator $=$}{\param{const wxChar* }{value}} |
a974387a | 365 | |
38f82bf6 | 366 | \func{void}{operator $=$}{\param{wxChar }{value}} |
a974387a JS |
367 | |
368 | \func{void}{operator $=$}{\param{const long }{value}} | |
369 | ||
370 | \func{void}{operator $=$}{\param{const bool }{value}} | |
371 | ||
372 | \func{void}{operator $=$}{\param{const double }{value}} | |
373 | ||
a974387a JS |
374 | \func{void}{operator $=$}{\param{void* }{value}} |
375 | ||
2f620946 RR |
376 | \func{void}{operator $=$}{\param{wxObject* }{value}} |
377 | ||
a974387a JS |
378 | \func{void}{operator $=$}{\param{const wxList\& }{value}} |
379 | ||
8715d2d3 RN |
380 | \func{void}{operator $=$}{\param{const wxDateTime\& }{value}} |
381 | ||
382 | \func{void}{operator $=$}{\param{const wxArrayString\& }{value}} | |
383 | ||
384 | \func{void}{operator $=$}{\param{const DATE\_STRUCT* }{value}} | |
385 | ||
386 | \func{void}{operator $=$}{\param{const TIME\_STRUCT* }{value}} | |
387 | ||
388 | \func{void}{operator $=$}{\param{const TIMESTAMP\_STRUCT* }{value}} | |
389 | ||
631787c4 | 390 | Assignment operators, using \helpref{reference counting}{trefcount} when possible. |
a974387a JS |
391 | |
392 | \membersection{wxVariant::operator $==$}\label{wxvarianteq} | |
393 | ||
8715d2d3 RN |
394 | \constfunc{bool}{operator $==$}{\param{const wxVariant\& }{value}} |
395 | ||
396 | \constfunc{bool}{operator $==$}{\param{const wxString\& }{value}} | |
a974387a | 397 | |
38f82bf6 | 398 | \constfunc{bool}{operator $==$}{\param{const wxChar* }{value}} |
a974387a | 399 | |
38f82bf6 | 400 | \constfunc{bool}{operator $==$}{\param{wxChar }{value}} |
a974387a | 401 | |
8715d2d3 | 402 | \constfunc{bool}{operator $==$}{\param{const long }{value}} |
a974387a | 403 | |
8715d2d3 | 404 | \constfunc{bool}{operator $==$}{\param{const bool }{value}} |
a974387a | 405 | |
8715d2d3 | 406 | \constfunc{bool}{operator $==$}{\param{const double }{value}} |
a974387a | 407 | |
8715d2d3 | 408 | \constfunc{bool}{operator $==$}{\param{void* }{value}} |
a974387a | 409 | |
2f620946 RR |
410 | \constfunc{bool}{operator $==$}{\param{wxObject* }{value}} |
411 | ||
8715d2d3 | 412 | \constfunc{bool}{operator $==$}{\param{const wxList\& }{value}} |
a974387a | 413 | |
8715d2d3 RN |
414 | \constfunc{bool}{operator $==$}{\param{const wxArrayString\& }{value}} |
415 | ||
416 | \constfunc{bool}{operator $==$}{\param{const wxDateTime\& }{value}} | |
a974387a JS |
417 | |
418 | Equality test operators. | |
419 | ||
420 | \membersection{wxVariant::operator $!=$}\label{wxvariantneq} | |
421 | ||
8715d2d3 RN |
422 | \constfunc{bool}{operator $!=$}{\param{const wxVariant\& }{value}} |
423 | ||
424 | \constfunc{bool}{operator $!=$}{\param{const wxString\& }{value}} | |
a974387a | 425 | |
38f82bf6 | 426 | \constfunc{bool}{operator $!=$}{\param{const wxChar* }{value}} |
a974387a | 427 | |
38f82bf6 | 428 | \constfunc{bool}{operator $!=$}{\param{wxChar }{value}} |
a974387a | 429 | |
8715d2d3 | 430 | \constfunc{bool}{operator $!=$}{\param{const long }{value}} |
a974387a | 431 | |
8715d2d3 | 432 | \constfunc{bool}{operator $!=$}{\param{const bool }{value}} |
a974387a | 433 | |
8715d2d3 | 434 | \constfunc{bool}{operator $!=$}{\param{const double }{value}} |
a974387a | 435 | |
8715d2d3 | 436 | \constfunc{bool}{operator $!=$}{\param{void* }{value}} |
a974387a | 437 | |
2f620946 RR |
438 | \constfunc{bool}{operator $!=$}{\param{wxObject* }{value}} |
439 | ||
8715d2d3 | 440 | \constfunc{bool}{operator $!=$}{\param{const wxList\& }{value}} |
a974387a | 441 | |
8715d2d3 RN |
442 | \constfunc{bool}{operator $!=$}{\param{const wxArrayString\& }{value}} |
443 | ||
444 | \constfunc{bool}{operator $!=$}{\param{const wxDateTime\& }{value}} | |
a974387a JS |
445 | |
446 | Inequality test operators. | |
447 | ||
448 | \membersection{wxVariant::operator $[]$}\label{wxvariantarray} | |
449 | ||
450 | \constfunc{wxVariant}{operator $[]$}{\param{size\_t }{idx}} | |
451 | ||
452 | Returns the value at {\it idx} (zero-based). | |
453 | ||
454 | \func{wxVariant\&}{operator $[]$}{\param{size\_t }{idx}} | |
455 | ||
456 | Returns a reference to the value at {\it idx} (zero-based). This can be used | |
457 | to change the value at this index. | |
458 | ||
38f82bf6 | 459 | \membersection{wxVariant::operator wxChar}\label{wxvariantchar} |
a974387a | 460 | |
38f82bf6 | 461 | \constfunc{char}{operator wxChar}{\void} |
a974387a | 462 | |
38f82bf6 | 463 | Operator for implicit conversion to a wxChar, using \helpref{wxVariant::GetChar}{wxvariantgetchar}. |
a974387a JS |
464 | |
465 | \membersection{wxVariant::operator double}\label{wxvariantdouble} | |
466 | ||
467 | \constfunc{double}{operator double}{\void} | |
468 | ||
469 | Operator for implicit conversion to a double, using \helpref{wxVariant::GetDouble}{wxvariantgetdouble}. | |
470 | ||
471 | \constfunc{long}{operator long}{\void} | |
472 | ||
473 | Operator for implicit conversion to a long, using \helpref{wxVariant::GetLong}{wxvariantgetlong}. | |
474 | ||
a974387a JS |
475 | \membersection{wxVariant::operator wxString}\label{wxvariantwxstring} |
476 | ||
477 | \constfunc{wxString}{operator wxString}{\void} | |
478 | ||
479 | Operator for implicit conversion to a string, using \helpref{wxVariant::MakeString}{wxvariantmakestring}. | |
480 | ||
a974387a JS |
481 | \membersection{wxVariant::operator void*}\label{wxvariantvoid} |
482 | ||
483 | \constfunc{void*}{operator void*}{\void} | |
484 | ||
485 | Operator for implicit conversion to a pointer to a void, using \helpref{wxVariant::GetVoidPtr}{wxvariantgetvoidptr}. | |
486 | ||
8715d2d3 RN |
487 | \membersection{wxVariant::operator wxDateTime}\label{wxvariantdatetime} |
488 | ||
489 | \constfunc{void*}{operator wxDateTime}{\void} | |
490 | ||
491 | Operator for implicit conversion to a pointer to a \helpref{wxDateTime}{wxdatetime}, using \helpref{wxVariant::GetDateTime}{wxvariantgetdatetime}. | |
492 | ||
631787c4 VZ |
493 | |
494 | ||
495 | %% wxVariantData | |
496 | ||
497 | ||
a974387a JS |
498 | \section{\class{wxVariantData}}\label{wxvariantdata} |
499 | ||
631787c4 VZ |
500 | The {\bf wxVariantData} class is used to implement a new type for \helpref{wxVariant}{wxvariant}. |
501 | Derive from wxVariantData, and override the pure virtual functions. | |
a974387a | 502 | |
631787c4 VZ |
503 | wxVariantData is \helpref{reference counted}{refcount}, but you don't normally have to care about this, |
504 | as wxVariant manages the count automatically. However, in case your application needs to take | |
2562c823 RR |
505 | ownership of wxVariantData, be aware that the object is created with reference count of 1, |
506 | and passing it to wxVariant will not increase this. In other words, \helpref{IncRef}{wxvariantdataincref} | |
507 | needs to be called only if you both take ownership of wxVariantData and pass it to a wxVariant. | |
508 | Also note that the destructor is protected, so you can never explicitly delete a wxVariantData | |
509 | instance. Instead, \helpref{DecRef}{wxvariantdatadecref} will delete the object automatically | |
510 | when the reference count reaches zero. | |
511 | ||
a974387a JS |
512 | \wxheading{Derived from} |
513 | ||
514 | \helpref{wxObject}{wxobject} | |
515 | ||
954b8ae6 JS |
516 | \wxheading{Include files} |
517 | ||
518 | <wx/variant.h> | |
519 | ||
a7af285d VZ |
520 | \wxheading{Library} |
521 | ||
522 | \helpref{wxBase}{librarieslist} | |
523 | ||
a974387a JS |
524 | \wxheading{See also} |
525 | ||
526 | \helpref{wxVariant}{wxvariant} | |
527 | ||
528 | \latexignore{\rtfignore{\wxheading{Members}}} | |
529 | ||
530 | \membersection{wxVariantData::wxVariantData}\label{wxvariantdatactor} | |
531 | ||
532 | \func{}{wxVariantData}{\void} | |
533 | ||
534 | Default constructor. | |
535 | ||
2562c823 RR |
536 | \membersection{wxVariantData::DecRef}\label{wxvariantdatadecref} |
537 | ||
538 | \func{void}{DecRef}{\void} | |
a974387a | 539 | |
2562c823 RR |
540 | Decreases reference count. If the count reaches zero, the object is |
541 | automatically deleted. | |
a974387a | 542 | |
2562c823 | 543 | Note that destructor of wxVariantData is protected, so delete |
631787c4 VZ |
544 | cannot be used as normal. Instead, \helpref{DecRef}{wxvariantdatadecref} should be called. |
545 | ||
546 | ||
a974387a JS |
547 | |
548 | \membersection{wxVariantData::Eq}\label{wxvariantdataeq} | |
549 | ||
550 | \constfunc{bool}{Eq}{\param{wxVariantData\&}{ data}} | |
551 | ||
cc81d32f | 552 | Returns true if this object is equal to {\it data}. |
a974387a JS |
553 | |
554 | \membersection{wxVariantData::GetType}\label{wxvariantdatagettype} | |
555 | ||
556 | \constfunc{wxString}{GetType}{\void} | |
557 | ||
558 | Returns the string type of the data. | |
559 | ||
cf6ae290 RG |
560 | \membersection{wxVariantData::GetValueClassInfo}\label{wxvariantdatagetvalueclassinfo} |
561 | ||
562 | \constfunc{wxClassInfo*}{GetValueClassInfo}{\void} | |
563 | ||
564 | If the data is a wxObject returns a pointer to the objects wxClassInfo structure, if | |
565 | the data isn't a wxObject the method returns NULL. | |
566 | ||
2562c823 RR |
567 | \membersection{wxVariantData::IncRef}\label{wxvariantdataincref} |
568 | ||
569 | \func{void}{IncRef}{\void} | |
570 | ||
571 | Increases reference count. Note that initially wxVariantData has reference count of 1. | |
572 | ||
a974387a JS |
573 | \membersection{wxVariantData::Read}\label{wxvariantdataread} |
574 | ||
575 | \func{bool}{Read}{\param{ostream\&}{ stream}} | |
576 | ||
577 | \func{bool}{Read}{\param{wxString\&}{ string}} | |
578 | ||
579 | Reads the data from {\it stream} or {\it string}. | |
580 | ||
581 | \membersection{wxVariantData::Write}\label{wxvariantdatawrite} | |
582 | ||
583 | \constfunc{bool}{Write}{\param{ostream\&}{ stream}} | |
584 | ||
585 | \constfunc{bool}{Write}{\param{wxString\&}{ string}} | |
586 | ||
587 | Writes the data to {\it stream} or {\it string}. | |
588 | ||
589 | ||
cf6ae290 RG |
590 | \membersection{wxGetVariantCast}\label{wxgetvariantcast} |
591 | ||
592 | \func{classname *}{wxGetVariantCast}{wxVariant\&, classname} | |
593 | ||
594 | This macro returns the data stored in {\it variant} cast to the type {\it classname *} if | |
595 | the data is of this type (the check is done during the run-time) or | |
43f06cfd | 596 | {\tt NULL} otherwise. |
cf6ae290 RG |
597 | |
598 | ||
599 | \wxheading{See also} | |
a974387a | 600 | |
cf6ae290 | 601 | \helpref{RTTI overview}{runtimeclassoverview}\\ |
0497e172 | 602 | \helpref{wxDynamicCast}{wxdynamiccast} |
b67a86d5 | 603 |