]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/variant.tex
added wxTopLevelWindow::RequestUserAttention(); documented it and implemented it...
[wxWidgets.git] / docs / latex / wx / variant.tex
CommitLineData
a974387a
JS
1\section{\class{wxVariant}}\label{wxvariant}
2
3The {\bf wxVariant} class represents a container for any type.
4A variant's value can be changed at run time, possibly to a different type of value.
5
6As standard, wxVariant can store values of type bool, char, double, long, string,
7string list, time, date, void pointer, list of strings, and list of variants. However, an application can extend
8wxVariant's capabilities by deriving from the class \helpref{wxVariantData}{wxvariantdata} and
9using the wxVariantData form of the wxVariant constructor or assignment operator
10to assign this data to a variant. Actual values for user-defined types will need to be accessed
11via the wxVariantData object, unlike the case for basic data types where convenience
12functions such as GetLong can be used.
13
14This class is useful for reducing the programming for certain tasks, such as an editor
15for different data types, or a remote procedure call protocol.
16
17An optional name member is associated with a wxVariant. This might be used, for example, in CORBA
18or OLE automation classes, where named parameters are required.
19
a974387a
JS
20\wxheading{Derived from}
21
22\helpref{wxObject}{wxobject}
23
954b8ae6
JS
24\wxheading{Include files}
25
26<wx/variant.h>
27
a974387a
JS
28\wxheading{See also}
29
30\helpref{wxVariantData}{wxvariantdata}
31
32\latexignore{\rtfignore{\wxheading{Members}}}
33
34\membersection{wxVariant::wxVariant}\label{wxvariantctor}
35
36\func{}{wxVariant}{\void}
37
38Default constructor.
39
40\func{}{wxVariant}{\param{const wxVariant\& }{variant}}
41
42Copy constructor.
43
f6bcfd97
BP
44\func{}{wxVariant}{\param{const char*}{ value}, \param{const wxString\& }{name = ``"}}
45
a974387a
JS
46\func{}{wxVariant}{\param{const wxString\&}{ value}, \param{const wxString\& }{name = ``"}}
47
48Construction from a string value.
49
50\func{}{wxVariant}{\param{char}{ value}, \param{const wxString\& }{name = ``"}}
51
52Construction from a character value.
53
54\func{}{wxVariant}{\param{long}{ value}, \param{const wxString\& }{name = ``"}}
55
56Construction from an integer value. You may need to cast to (long) to
57avoid confusion with other constructors (such as the bool constructor).
58
59\func{}{wxVariant}{\param{bool}{ value}, \param{const wxString\& }{name = ``"}}
60
61Construction from a boolean value.
62
63\func{}{wxVariant}{\param{double}{ value}, \param{const wxString\& }{name = ``"}}
64
65Construction from a double-precision floating point value.
66
67\func{}{wxVariant}{\param{const wxList\&}{ value}, \param{const wxString\& }{name = ``"}}
68
69Construction from a list of wxVariant objects. This constructor
70copies {\it value}, the application is still responsible for
71deleting {\it value} and its contents.
72
73\func{}{wxVariant}{\param{const wxStringList\&}{ value}, \param{const wxString\& }{name = ``"}}
74
75Construction from a list of strings. This constructor
76copies {\it value}, the application is still responsible for
77deleting {\it value} and its contents.
78
a974387a
JS
79\func{}{wxVariant}{\param{void*}{ value}, \param{const wxString\& }{name = ``"}}
80
81Construction from a void pointer.
82
cf6ae290
RG
83\func{}{wxVariant}{\param{wxObject*}{ value}, \param{const wxString\& }{name = ``"}}
84
85Construction from a wxObject pointer.
86
a974387a
JS
87\func{}{wxVariant}{\param{wxVariantData*}{ data}, \param{const wxString\& }{name = ``"}}
88
89Construction from user-defined data. The variant holds on to the {\it data} pointer.
90
91\membersection{wxVariant::\destruct{wxVariant}}\label{wxvariantdtor}
92
93\func{}{\destruct{wxVariant}}{\void}
94
95Destructor.
96
97\membersection{wxVariant::Append}\label{wxvariantappend}
98
99\func{void}{Append}{\param{const wxVariant\&}{ value}}
100
101Appends a value to the list.
102
103\membersection{wxVariant::ClearList}\label{wxvariantclearlist}
104
105\func{void}{ClearList}{\void}
106
107Deletes the contents of the list.
108
109\membersection{wxVariant::GetCount}\label{wxvariantgetcount}
110
111\constfunc{int}{GetCount}{\void}
112
113Returns the number of elements in the list.
114
115\membersection{wxVariant::Delete}\label{wxvariantdelete}
116
117\func{bool}{Delete}{\param{int }{item}}
118
119Deletes the zero-based {\it item} from the list.
120
121\membersection{wxVariant::GetBool}\label{wxvariantgetbool}
122
123\constfunc{bool}{GetBool}{\void}
124
125Returns the boolean value.
126
127\membersection{wxVariant::GetChar}\label{wxvariantgetchar}
128
129\constfunc{char}{GetChar}{\void}
130
131Returns the character value.
132
133\membersection{wxVariant::GetData}\label{wxvariantgetdata}
134
135\constfunc{wxVariantData*}{GetData}{\void}
136
137Returns a pointer to the internal variant data.
138
a974387a
JS
139\membersection{wxVariant::GetDouble}\label{wxvariantgetdouble}
140
141\constfunc{double}{GetDouble}{\void}
142
143Returns the floating point value.
144
145\membersection{wxVariant::GetLong}\label{wxvariantgetlong}
146
147\constfunc{long}{GetLong}{\void}
148
149Returns the integer value.
150
151\membersection{wxVariant::GetName}\label{wxvariantgetname}
152
153\constfunc{const wxString\&}{GetName}{\void}
154
155Returns a constant reference to the variant name.
156
157\membersection{wxVariant::GetString}\label{wxvariantgetstring}
158
159\constfunc{wxString}{GetString}{\void}
160
161Gets the string value.
162
a974387a
JS
163\membersection{wxVariant::GetType}\label{wxvariantgettype}
164
165\constfunc{wxString}{GetType}{\void}
166
167Returns the value type as a string. The built-in types are: bool, char, date, double, list, long, string, stringlist, time, void*.
168
169If the variant is null, the value type returned is the string ``null" (not the empty string).
170
171\membersection{wxVariant::GetVoidPtr}\label{wxvariantgetvoidptr}
172
173\constfunc{void*}{GetVoidPtr}{\void}
174
175Gets the void pointer value.
176
cf6ae290
RG
177\membersection{wxVariant::GetWxObjectPtr}\label{wxvariantgetwxobjectptr}
178
179\constfunc{void*}{GetWxObjectPtr}{\void}
180
181Gets the wxObject pointer value.
182
a974387a
JS
183\membersection{wxVariant::Insert}\label{wxvariantinsert}
184
185\func{void}{Insert}{\param{const wxVariant\&}{ value}}
186
187Inserts a value at the front of the list.
188
189\membersection{wxVariant::IsNull}\label{wxvariantisnull}
190
191\constfunc{bool}{IsNull}{\void}
192
cc81d32f 193Returns true if there is no data associated with this variant, false if there is data.
a974387a
JS
194
195\membersection{wxVariant::IsType}\label{wxvariantistype}
196
197\constfunc{bool}{IsType}{\param{const wxString\&}{ type}}
198
cc81d32f 199Returns true if {\it type} matches the type of the variant, false otherwise.
a974387a 200
cf6ae290
RG
201\membersection{wxVariant::IsValueKindOf}\label{wxvariantisvaluekindof}
202
203\constfunc{bool}{IsValueKindOf}{\param{const wxClassInfo* type}{ type}}
204
205Returns true if the data is derived from the class described by {\it type}, false otherwise.
206
a974387a
JS
207\membersection{wxVariant::MakeNull}\label{wxvariantmakenull}
208
209\func{void}{MakeNull}{\void}
210
211Makes the variant null by deleting the internal data.
212
213\membersection{wxVariant::MakeString}\label{wxvariantmakestring}
214
215\constfunc{wxString}{MakeString}{\void}
216
217Makes a string representation of the variant value (for any type).
218
219\membersection{wxVariant::Member}\label{wxvariantmember}
220
221\constfunc{bool}{Member}{\param{const wxVariant\&}{ value}}
222
cc81d32f 223Returns true if {\it value} matches an element in the list.
a974387a
JS
224
225\membersection{wxVariant::NullList}\label{wxvariantnulllist}
226
227\func{void}{NullList}{\void}
228
229Makes an empty list. This differs from a null variant which has no data; a null list
230is of type list, but the number of elements in the list is zero.
231
232\membersection{wxVariant::SetData}\label{wxvariantsetdata}
233
234\func{void}{SetData}{\param{wxVariantData*}{ data}}
235
236Sets the internal variant data, deleting the existing data if there is any.
237
238\membersection{wxVariant::operator $=$}\label{wxvariantassignment}
239
240\func{void}{operator $=$}{\param{const wxVariant\& }{value}}
241
242\func{void}{operator $=$}{\param{wxVariantData* }{value}}
243
244\func{void}{operator $=$}{\param{const wxString\& }{value}}
245
246\func{void}{operator $=$}{\param{const char* }{value}}
247
248\func{void}{operator $=$}{\param{char }{value}}
249
250\func{void}{operator $=$}{\param{const long }{value}}
251
252\func{void}{operator $=$}{\param{const bool }{value}}
253
254\func{void}{operator $=$}{\param{const double }{value}}
255
a974387a
JS
256\func{void}{operator $=$}{\param{void* }{value}}
257
258\func{void}{operator $=$}{\param{const wxList\& }{value}}
259
260\func{void}{operator $=$}{\param{const wxStringList\& }{value}}
261
262Assignment operators.
263
264\membersection{wxVariant::operator $==$}\label{wxvarianteq}
265
266\func{bool}{operator $==$}{\param{const wxVariant\& }{value}}
267
268\func{bool}{operator $==$}{\param{const wxString\& }{value}}
269
270\func{bool}{operator $==$}{\param{const char* }{value}}
271
272\func{bool}{operator $==$}{\param{char }{value}}
273
274\func{bool}{operator $==$}{\param{const long }{value}}
275
276\func{bool}{operator $==$}{\param{const bool }{value}}
277
278\func{bool}{operator $==$}{\param{const double }{value}}
279
a974387a
JS
280\func{bool}{operator $==$}{\param{void* }{value}}
281
282\func{bool}{operator $==$}{\param{const wxList\& }{value}}
283
284\func{bool}{operator $==$}{\param{const wxStringList\& }{value}}
285
286Equality test operators.
287
288\membersection{wxVariant::operator $!=$}\label{wxvariantneq}
289
290\func{bool}{operator $!=$}{\param{const wxVariant\& }{value}}
291
292\func{bool}{operator $!=$}{\param{const wxString\& }{value}}
293
294\func{bool}{operator $!=$}{\param{const char* }{value}}
295
296\func{bool}{operator $!=$}{\param{char }{value}}
297
298\func{bool}{operator $!=$}{\param{const long }{value}}
299
300\func{bool}{operator $!=$}{\param{const bool }{value}}
301
302\func{bool}{operator $!=$}{\param{const double }{value}}
303
a974387a
JS
304\func{bool}{operator $!=$}{\param{void* }{value}}
305
306\func{bool}{operator $!=$}{\param{const wxList\& }{value}}
307
308\func{bool}{operator $!=$}{\param{const wxStringList\& }{value}}
309
310Inequality test operators.
311
312\membersection{wxVariant::operator $[]$}\label{wxvariantarray}
313
314\constfunc{wxVariant}{operator $[]$}{\param{size\_t }{idx}}
315
316Returns the value at {\it idx} (zero-based).
317
318\func{wxVariant\&}{operator $[]$}{\param{size\_t }{idx}}
319
320Returns a reference to the value at {\it idx} (zero-based). This can be used
321to change the value at this index.
322
323\membersection{wxVariant::operator char}\label{wxvariantchar}
324
325\constfunc{char}{operator char}{\void}
326
327Operator for implicit conversion to a char, using \helpref{wxVariant::GetChar}{wxvariantgetchar}.
328
329\membersection{wxVariant::operator double}\label{wxvariantdouble}
330
331\constfunc{double}{operator double}{\void}
332
333Operator for implicit conversion to a double, using \helpref{wxVariant::GetDouble}{wxvariantgetdouble}.
334
335\constfunc{long}{operator long}{\void}
336
337Operator for implicit conversion to a long, using \helpref{wxVariant::GetLong}{wxvariantgetlong}.
338
a974387a
JS
339\membersection{wxVariant::operator wxString}\label{wxvariantwxstring}
340
341\constfunc{wxString}{operator wxString}{\void}
342
343Operator for implicit conversion to a string, using \helpref{wxVariant::MakeString}{wxvariantmakestring}.
344
a974387a
JS
345\membersection{wxVariant::operator void*}\label{wxvariantvoid}
346
347\constfunc{void*}{operator void*}{\void}
348
349Operator for implicit conversion to a pointer to a void, using \helpref{wxVariant::GetVoidPtr}{wxvariantgetvoidptr}.
350
351\section{\class{wxVariantData}}\label{wxvariantdata}
352
353The {\bf wxVariantData} is used to implement a new type for wxVariant. Derive from wxVariantData,
354and override the pure virtual functions.
355
356\wxheading{Derived from}
357
358\helpref{wxObject}{wxobject}
359
954b8ae6
JS
360\wxheading{Include files}
361
362<wx/variant.h>
363
a974387a
JS
364\wxheading{See also}
365
366\helpref{wxVariant}{wxvariant}
367
368\latexignore{\rtfignore{\wxheading{Members}}}
369
370\membersection{wxVariantData::wxVariantData}\label{wxvariantdatactor}
371
372\func{}{wxVariantData}{\void}
373
374Default constructor.
375
376\membersection{wxVariantData::Copy}\label{wxvariantdatacopy}
377
378\func{void}{Copy}{\param{wxVariantData\&}{ data}}
379
380Copy the data from `this' object to {\it data}.
381
382\membersection{wxVariantData::Eq}\label{wxvariantdataeq}
383
384\constfunc{bool}{Eq}{\param{wxVariantData\&}{ data}}
385
cc81d32f 386Returns true if this object is equal to {\it data}.
a974387a
JS
387
388\membersection{wxVariantData::GetType}\label{wxvariantdatagettype}
389
390\constfunc{wxString}{GetType}{\void}
391
392Returns the string type of the data.
393
cf6ae290
RG
394\membersection{wxVariantData::GetValueClassInfo}\label{wxvariantdatagetvalueclassinfo}
395
396\constfunc{wxClassInfo*}{GetValueClassInfo}{\void}
397
398If the data is a wxObject returns a pointer to the objects wxClassInfo structure, if
399the data isn't a wxObject the method returns NULL.
400
a974387a
JS
401\membersection{wxVariantData::Read}\label{wxvariantdataread}
402
403\func{bool}{Read}{\param{ostream\&}{ stream}}
404
405\func{bool}{Read}{\param{wxString\&}{ string}}
406
407Reads the data from {\it stream} or {\it string}.
408
409\membersection{wxVariantData::Write}\label{wxvariantdatawrite}
410
411\constfunc{bool}{Write}{\param{ostream\&}{ stream}}
412
413\constfunc{bool}{Write}{\param{wxString\&}{ string}}
414
415Writes the data to {\it stream} or {\it string}.
416
417
cf6ae290
RG
418\membersection{wxGetVariantCast}\label{wxgetvariantcast}
419
420\func{classname *}{wxGetVariantCast}{wxVariant\&, classname}
421
422This macro returns the data stored in {\it variant} cast to the type {\it classname *} if
423the data is of this type (the check is done during the run-time) or
424{\tt NULL} otherwise.
425
426
427\wxheading{See also}
a974387a 428
cf6ae290 429\helpref{RTTI overview}{runtimeclassoverview}\\
0497e172
JS
430\helpref{wxDynamicCast}{wxdynamiccast}
431