File: wx256.htm

package info (click to toggle)
wxwin2-doc 2.01-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 6,540 kB
  • ctags: 5,968
  • sloc: cpp: 15,157; makefile: 434; sh: 6
file content (387 lines) | stat: -rw-r--r-- 15,744 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
<HTML>
<head><title>wxVariant</title></head>

<BODY BGCOLOR=#FFFFFF>
<A NAME="wxvariant"></A><CENTER>
<A HREF="wx.htm"><img align=center src="contents.gif" BORDER=0 ALT="Contents"></A> <A HREF="wx22.htm#classref"><img align=center src="up.gif" BORDER=0 ALT="Up"></A> <A HREF="wx255.htm#wxvalidator"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx257.htm#wxvariantdata"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>

<H2>wxVariant</H2>
<P>
The <B>wxVariant</B> class represents a container for any type.
A variant's value can be changed at run time, possibly to a different type of value.<P>
As standard, wxVariant can store values of type bool, char, double, long, string,
string list, time, date, void pointer, list of strings, and list of variants. However, an application can extend
wxVariant's capabilities by deriving from the class <A HREF="wx257.htm#wxvariantdata">wxVariantData</A> and
using the wxVariantData form of the wxVariant constructor or assignment operator
to assign this data to a variant. Actual values for user-defined types will need to be accessed
via the wxVariantData object, unlike the case for basic data types where convenience
functions such as GetLong can be used.<P>
This class is useful for reducing the programming for certain tasks, such as an editor
for different data types, or a remote procedure call protocol.<P>
An optional name member is associated with a wxVariant. This might be used, for example, in CORBA
or OLE automation classes, where named parameters are required.<P>
wxVariant is similar to wxExpr and also to wxPropertyValue. However, wxExpr is efficiency-optimized for
a restricted range of data types, whereas wxVariant is less efficient but more extensible.
wxPropertyValue may be replaced by wxVariant eventually.<P>
<B><FONT COLOR="#FF0000">Derived from</FONT></B><P>
<A HREF="wx158.htm#wxobject">wxObject</A><P>
<B><FONT COLOR="#FF0000">Include files</FONT></B><P>
&lt;wx/variant.h&gt;<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx257.htm#wxvariantdata">wxVariantData</A><P>
<B><FONT COLOR="#FF0000">Members</FONT></B><P>
<A HREF="#wxvariantctor">wxVariant::wxVariant</A><BR>
<A HREF="#wxvariantdtor">wxVariant::~wxVariant</A><BR>
<A HREF="#wxvariantappend">wxVariant::Append</A><BR>
<A HREF="#wxvariantclearlist">wxVariant::ClearList</A><BR>
<A HREF="#wxvariantgetcount">wxVariant::GetCount</A><BR>
<A HREF="#wxvariantdelete">wxVariant::Delete</A><BR>
<A HREF="#wxvariantgetbool">wxVariant::GetBool</A><BR>
<A HREF="#wxvariantgetchar">wxVariant::GetChar</A><BR>
<A HREF="#wxvariantgetdata">wxVariant::GetData</A><BR>
<A HREF="#wxvariantgetdate">wxVariant::GetDate</A><BR>
<A HREF="#wxvariantgetdouble">wxVariant::GetDouble</A><BR>
<A HREF="#wxvariantgetlong">wxVariant::GetLong</A><BR>
<A HREF="#wxvariantgetname">wxVariant::GetName</A><BR>
<A HREF="#wxvariantgetstring">wxVariant::GetString</A><BR>
<A HREF="#wxvariantgettime">wxVariant::GetTime</A><BR>
<A HREF="#wxvariantgettype">wxVariant::GetType</A><BR>
<A HREF="#wxvariantgetvoidptr">wxVariant::GetVoidPtr</A><BR>
<A HREF="#wxvariantinsert">wxVariant::Insert</A><BR>
<A HREF="#wxvariantisnull">wxVariant::IsNull</A><BR>
<A HREF="#wxvariantistype">wxVariant::IsType</A><BR>
<A HREF="#wxvariantmakenull">wxVariant::MakeNull</A><BR>
<A HREF="#wxvariantmakestring">wxVariant::MakeString</A><BR>
<A HREF="#wxvariantmember">wxVariant::Member</A><BR>
<A HREF="#wxvariantnulllist">wxVariant::NullList</A><BR>
<A HREF="#wxvariantsetdata">wxVariant::SetData</A><BR>
<A HREF="#wxvariantassignment">wxVariant::operator =</A><BR>
<A HREF="#wxvarianteq">wxVariant::operator ==</A><BR>
<A HREF="#wxvariantneq">wxVariant::operator !=</A><BR>
<A HREF="#wxvariantarray">wxVariant::operator []</A><BR>
<A HREF="#wxvariantchar">wxVariant::operator char</A><BR>
<A HREF="#wxvariantdouble">wxVariant::operator double</A><BR>
<A HREF="#wxvariantwxdate">wxVariant::operator wxDate</A><BR>
<A HREF="#wxvariantwxstring">wxVariant::operator wxString</A><BR>
<A HREF="#wxvariantwxtime">wxVariant::operator wxTime</A><BR>
<A HREF="#wxvariantvoid">wxVariant::operator void*</A><BR>
<P>

<HR>
<A NAME="wxvariantctor"></A>
<H3>wxVariant::wxVariant</H3>
<P>
<B></B> <B>wxVariant</B>()<P>
Default constructor.<P>
<B></B> <B>wxVariant</B>(<B>const wxVariant&amp; </B><I>variant</I>)<P>
Copy constructor.<P>
<B></B> <B>wxVariant</B>(<B>const char*</B><I> value</I>, <B>const wxString&amp; </B><I>name = ""</I>)<BR>

<B></B> <B>wxVariant</B>(<B>const wxString&amp;</B><I> value</I>, <B>const wxString&amp; </B><I>name = ""</I>)<P>
Construction from a string value.<P>
<B></B> <B>wxVariant</B>(<B>char</B><I> value</I>, <B>const wxString&amp; </B><I>name = ""</I>)<P>
Construction from a character value.<P>
<B></B> <B>wxVariant</B>(<B>long</B><I> value</I>, <B>const wxString&amp; </B><I>name = ""</I>)<P>
Construction from an integer value. You may need to cast to (long) to
avoid confusion with other constructors (such as the bool constructor).<P>
<B></B> <B>wxVariant</B>(<B>bool</B><I> value</I>, <B>const wxString&amp; </B><I>name = ""</I>)<P>
Construction from a boolean value.<P>
<B></B> <B>wxVariant</B>(<B>double</B><I> value</I>, <B>const wxString&amp; </B><I>name = ""</I>)<P>
Construction from a double-precision floating point value.<P>
<B></B> <B>wxVariant</B>(<B>const wxList&amp;</B><I> value</I>, <B>const wxString&amp; </B><I>name = ""</I>)<P>
Construction from a list of wxVariant objects. This constructor
copies <I>value</I>, the application is still responsible for
deleting <I>value</I> and its contents.<P>
<B></B> <B>wxVariant</B>(<B>const wxStringList&amp;</B><I> value</I>, <B>const wxString&amp; </B><I>name = ""</I>)<P>
Construction from a list of strings. This constructor
copies <I>value</I>, the application is still responsible for
deleting <I>value</I> and its contents.<P>
<B></B> <B>wxVariant</B>(<B>const wxTime&amp;</B><I> value</I>, <B>const wxString&amp; </B><I>name = ""</I>)<P>
Construction from a time.<P>
<B></B> <B>wxVariant</B>(<B>const wxDate&amp;</B><I> value</I>, <B>const wxString&amp; </B><I>name = ""</I>)<P>
Construction from a date.<P>
<B></B> <B>wxVariant</B>(<B>void*</B><I> value</I>, <B>const wxString&amp; </B><I>name = ""</I>)<P>
Construction from a void pointer.<P>
<B></B> <B>wxVariant</B>(<B>wxVariantData*</B><I> data</I>, <B>const wxString&amp; </B><I>name = ""</I>)<P>
Construction from user-defined data. The variant holds on to the <I>data</I> pointer.<P>

<HR>
<A NAME="wxvariantdtor"></A>
<H3>wxVariant::~wxVariant</H3>
<P>
<B></B> <B>~wxVariant</B>()<P>
Destructor.<P>

<HR>
<A NAME="wxvariantappend"></A>
<H3>wxVariant::Append</H3>
<P>
<B>void</B> <B>Append</B>(<B>const wxVariant&amp;</B><I> value</I>)<P>
Appends a value to the list.<P>

<HR>
<A NAME="wxvariantclearlist"></A>
<H3>wxVariant::ClearList</H3>
<P>
<B>void</B> <B>ClearList</B>()<P>
Deletes the contents of the list.<P>

<HR>
<A NAME="wxvariantgetcount"></A>
<H3>wxVariant::GetCount</H3>
<P>
<B>int</B> <B>GetCount</B>() <B>const</B><P>
Returns the number of elements in the list.<P>

<HR>
<A NAME="wxvariantdelete"></A>
<H3>wxVariant::Delete</H3>
<P>
<B>bool</B> <B>Delete</B>(<B>int </B><I>item</I>)<P>
Deletes the zero-based <I>item</I> from the list.<P>

<HR>
<A NAME="wxvariantgetbool"></A>
<H3>wxVariant::GetBool</H3>
<P>
<B>bool</B> <B>GetBool</B>() <B>const</B><P>
Returns the boolean value.<P>

<HR>
<A NAME="wxvariantgetchar"></A>
<H3>wxVariant::GetChar</H3>
<P>
<B>char</B> <B>GetChar</B>() <B>const</B><P>
Returns the character value.<P>

<HR>
<A NAME="wxvariantgetdata"></A>
<H3>wxVariant::GetData</H3>
<P>
<B>wxVariantData*</B> <B>GetData</B>() <B>const</B><P>
Returns a pointer to the internal variant data.<P>

<HR>
<A NAME="wxvariantgetdate"></A>
<H3>wxVariant::GetDate</H3>
<P>
<B>wxDate</B> <B>GetDate</B>() <B>const</B><P>
Gets the date value.<P>

<HR>
<A NAME="wxvariantgetdouble"></A>
<H3>wxVariant::GetDouble</H3>
<P>
<B>double</B> <B>GetDouble</B>() <B>const</B><P>
Returns the floating point value.<P>

<HR>
<A NAME="wxvariantgetlong"></A>
<H3>wxVariant::GetLong</H3>
<P>
<B>long</B> <B>GetLong</B>() <B>const</B><P>
Returns the integer value.<P>

<HR>
<A NAME="wxvariantgetname"></A>
<H3>wxVariant::GetName</H3>
<P>
<B>const wxString&amp;</B> <B>GetName</B>() <B>const</B><P>
Returns a constant reference to the variant name.<P>

<HR>
<A NAME="wxvariantgetstring"></A>
<H3>wxVariant::GetString</H3>
<P>
<B>wxString</B> <B>GetString</B>() <B>const</B><P>
Gets the string value.<P>

<HR>
<A NAME="wxvariantgettime"></A>
<H3>wxVariant::GetTime</H3>
<P>
<B>wxTime</B> <B>GetTime</B>() <B>const</B><P>
Gets the time value.<P>

<HR>
<A NAME="wxvariantgettype"></A>
<H3>wxVariant::GetType</H3>
<P>
<B>wxString</B> <B>GetType</B>() <B>const</B><P>
Returns the value type as a string. The built-in types are: bool, char, date, double, list, long, string, stringlist, time, void*.<P>
If the variant is null, the value type returned is the string "null" (not the empty string).<P>

<HR>
<A NAME="wxvariantgetvoidptr"></A>
<H3>wxVariant::GetVoidPtr</H3>
<P>
<B>void*</B> <B>GetVoidPtr</B>() <B>const</B><P>
Gets the void pointer value.<P>

<HR>
<A NAME="wxvariantinsert"></A>
<H3>wxVariant::Insert</H3>
<P>
<B>void</B> <B>Insert</B>(<B>const wxVariant&amp;</B><I> value</I>)<P>
Inserts a value at the front of the list.<P>

<HR>
<A NAME="wxvariantisnull"></A>
<H3>wxVariant::IsNull</H3>
<P>
<B>bool</B> <B>IsNull</B>() <B>const</B><P>
Returns TRUE if there is no data associated with this variant, FALSE if there is data.<P>

<HR>
<A NAME="wxvariantistype"></A>
<H3>wxVariant::IsType</H3>
<P>
<B>bool</B> <B>IsType</B>(<B>const wxString&amp;</B><I> type</I>) <B>const</B><P>
Returns TRUE if <I>type</I> matches the type of the variant, FALSE otherwise.<P>

<HR>
<A NAME="wxvariantmakenull"></A>
<H3>wxVariant::MakeNull</H3>
<P>
<B>void</B> <B>MakeNull</B>()<P>
Makes the variant null by deleting the internal data.<P>

<HR>
<A NAME="wxvariantmakestring"></A>
<H3>wxVariant::MakeString</H3>
<P>
<B>wxString</B> <B>MakeString</B>() <B>const</B><P>
Makes a string representation of the variant value (for any type).<P>

<HR>
<A NAME="wxvariantmember"></A>
<H3>wxVariant::Member</H3>
<P>
<B>bool</B> <B>Member</B>(<B>const wxVariant&amp;</B><I> value</I>) <B>const</B><P>
Returns TRUE if <I>value</I> matches an element in the list.<P>

<HR>
<A NAME="wxvariantnulllist"></A>
<H3>wxVariant::NullList</H3>
<P>
<B>void</B> <B>NullList</B>()<P>
Makes an empty list. This differs from a null variant which has no data; a null list
is of type list, but the number of elements in the list is zero.<P>

<HR>
<A NAME="wxvariantsetdata"></A>
<H3>wxVariant::SetData</H3>
<P>
<B>void</B> <B>SetData</B>(<B>wxVariantData*</B><I> data</I>)<P>
Sets the internal variant data, deleting the existing data if there is any.<P>

<HR>
<A NAME="wxvariantassignment"></A>
<H3>wxVariant::operator =</H3>
<P>
<B>void</B> <B>operator =</B>(<B>const wxVariant&amp; </B><I>value</I>)<P>
<B>void</B> <B>operator =</B>(<B>wxVariantData* </B><I>value</I>)<P>
<B>void</B> <B>operator =</B>(<B>const wxString&amp; </B><I>value</I>)<P>
<B>void</B> <B>operator =</B>(<B>const char* </B><I>value</I>)<P>
<B>void</B> <B>operator =</B>(<B>char </B><I>value</I>)<P>
<B>void</B> <B>operator =</B>(<B>const long </B><I>value</I>)<P>
<B>void</B> <B>operator =</B>(<B>const bool </B><I>value</I>)<P>
<B>void</B> <B>operator =</B>(<B>const double </B><I>value</I>)<P>
<B>void</B> <B>operator =</B>(<B>const wxDate&amp; </B><I>value</I>)<P>
<B>void</B> <B>operator =</B>(<B>const wxTime&amp; </B><I>value</I>)<P>
<B>void</B> <B>operator =</B>(<B>void* </B><I>value</I>)<P>
<B>void</B> <B>operator =</B>(<B>const wxList&amp; </B><I>value</I>)<P>
<B>void</B> <B>operator =</B>(<B>const wxStringList&amp; </B><I>value</I>)<P>
Assignment operators.<P>

<HR>
<A NAME="wxvarianteq"></A>
<H3>wxVariant::operator ==</H3>
<P>
<B>bool</B> <B>operator ==</B>(<B>const wxVariant&amp; </B><I>value</I>)<P>
<B>bool</B> <B>operator ==</B>(<B>const wxString&amp; </B><I>value</I>)<P>
<B>bool</B> <B>operator ==</B>(<B>const char* </B><I>value</I>)<P>
<B>bool</B> <B>operator ==</B>(<B>char </B><I>value</I>)<P>
<B>bool</B> <B>operator ==</B>(<B>const long </B><I>value</I>)<P>
<B>bool</B> <B>operator ==</B>(<B>const bool </B><I>value</I>)<P>
<B>bool</B> <B>operator ==</B>(<B>const double </B><I>value</I>)<P>
<B>bool</B> <B>operator ==</B>(<B>const wxDate&amp; </B><I>value</I>)<P>
<B>bool</B> <B>operator ==</B>(<B>const wxTime&amp; </B><I>value</I>)<P>
<B>bool</B> <B>operator ==</B>(<B>void* </B><I>value</I>)<P>
<B>bool</B> <B>operator ==</B>(<B>const wxList&amp; </B><I>value</I>)<P>
<B>bool</B> <B>operator ==</B>(<B>const wxStringList&amp; </B><I>value</I>)<P>
Equality test operators.<P>

<HR>
<A NAME="wxvariantneq"></A>
<H3>wxVariant::operator !=</H3>
<P>
<B>bool</B> <B>operator !=</B>(<B>const wxVariant&amp; </B><I>value</I>)<P>
<B>bool</B> <B>operator !=</B>(<B>const wxString&amp; </B><I>value</I>)<P>
<B>bool</B> <B>operator !=</B>(<B>const char* </B><I>value</I>)<P>
<B>bool</B> <B>operator !=</B>(<B>char </B><I>value</I>)<P>
<B>bool</B> <B>operator !=</B>(<B>const long </B><I>value</I>)<P>
<B>bool</B> <B>operator !=</B>(<B>const bool </B><I>value</I>)<P>
<B>bool</B> <B>operator !=</B>(<B>const double </B><I>value</I>)<P>
<B>bool</B> <B>operator !=</B>(<B>const wxDate&amp; </B><I>value</I>)<P>
<B>bool</B> <B>operator !=</B>(<B>const wxTime&amp; </B><I>value</I>)<P>
<B>bool</B> <B>operator !=</B>(<B>void* </B><I>value</I>)<P>
<B>bool</B> <B>operator !=</B>(<B>const wxList&amp; </B><I>value</I>)<P>
<B>bool</B> <B>operator !=</B>(<B>const wxStringList&amp; </B><I>value</I>)<P>
Inequality test operators.<P>

<HR>
<A NAME="wxvariantarray"></A>
<H3>wxVariant::operator []</H3>
<P>
<B>wxVariant</B> <B>operator []</B>(<B>size_t </B><I>idx</I>) <B>const</B><P>
Returns the value at <I>idx</I> (zero-based).<P>
<B>wxVariant&amp;</B> <B>operator []</B>(<B>size_t </B><I>idx</I>)<P>
Returns a reference to the value at <I>idx</I> (zero-based). This can be used
to change the value at this index.<P>

<HR>
<A NAME="wxvariantchar"></A>
<H3>wxVariant::operator char</H3>
<P>
<B>char</B> <B>operator char</B>() <B>const</B><P>
Operator for implicit conversion to a char, using <A HREF="wx256.htm#wxvariantgetchar">wxVariant::GetChar</A>.<P>

<HR>
<A NAME="wxvariantdouble"></A>
<H3>wxVariant::operator double</H3>
<P>
<B>double</B> <B>operator double</B>() <B>const</B><P>
Operator for implicit conversion to a double, using <A HREF="wx256.htm#wxvariantgetdouble">wxVariant::GetDouble</A>.<P>
<B>long</B> <B>operator long</B>() <B>const</B><P>
Operator for implicit conversion to a long, using <A HREF="wx256.htm#wxvariantgetlong">wxVariant::GetLong</A>.<P>

<HR>
<A NAME="wxvariantwxdate"></A>
<H3>wxVariant::operator wxDate</H3>
<P>
<B>wxDate</B> <B>operator wxDate</B>() <B>const</B><P>
Operator for implicit conversion to a wxDate, using <A HREF="wx256.htm#wxvariantgetdate">wxVariant::GetDate</A>.<P>

<HR>
<A NAME="wxvariantwxstring"></A>
<H3>wxVariant::operator wxString</H3>
<P>
<B>wxString</B> <B>operator wxString</B>() <B>const</B><P>
Operator for implicit conversion to a string, using <A HREF="wx256.htm#wxvariantmakestring">wxVariant::MakeString</A>.<P>

<HR>
<A NAME="wxvariantwxtime"></A>
<H3>wxVariant::operator wxTime</H3>
<P>
<B>wxTime</B> <B>operator wxTime</B>() <B>const</B><P>
Operator for implicit conversion to a wxTime, using <A HREF="wx256.htm#wxvariantgettime">wxVariant::GetTime</A>.<P>

<HR>
<A NAME="wxvariantvoid"></A>
<H3>wxVariant::operator void*</H3>
<P>
<B>void*</B> <B>operator void*</B>() <B>const</B><P>
Operator for implicit conversion to a pointer to a void, using <A HREF="wx256.htm#wxvariantgetvoidptr">wxVariant::GetVoidPtr</A>.<P>

</BODY></HTML>