aboutsummaryrefslogtreecommitdiff
path: root/src/tests/variant.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-09-25 22:14:26 +0000
committerMike Buland <eichlan@xagasoft.com>2009-09-25 22:14:26 +0000
commite99509abde688315ac7a82d764b352e2e3312e61 (patch)
tree9dc82509b89d96f138eefe07674319fc987afb6a /src/tests/variant.cpp
parent1b7caf3368675eb6825e0dca77782a141dfa0392 (diff)
downloadlibbu++-e99509abde688315ac7a82d764b352e2e3312e61.tar.gz
libbu++-e99509abde688315ac7a82d764b352e2e3312e61.tar.bz2
libbu++-e99509abde688315ac7a82d764b352e2e3312e61.tar.xz
libbu++-e99509abde688315ac7a82d764b352e2e3312e61.zip
New Bu::Variant class. Store anything in it, get it out again, find out it's
type. It's really just that easy. More info, docs, and tweaks to come.
Diffstat (limited to 'src/tests/variant.cpp')
-rw-r--r--src/tests/variant.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/tests/variant.cpp b/src/tests/variant.cpp
new file mode 100644
index 0000000..a0ac1f2
--- /dev/null
+++ b/src/tests/variant.cpp
@@ -0,0 +1,45 @@
1#include <bu/sio.h>
2#include <bu/variant.h>
3#include <bu/list.h>
4
5using namespace Bu;
6
7Variant getThing( int i )
8{
9 Variant v;
10 switch( i )
11 {
12 case 0:
13 v = 45;
14 break;
15
16 case 1:
17 v = true;
18 break;
19
20 case 2:
21 v = List<int>(5).append(10).append(15);
22 break;
23 }
24
25 return v;
26}
27
28int main()
29{
30 Variant a;
31 Variant b;
32 Variant c;
33
34 a = getThing( 0 );
35 b = getThing( 1 );
36 c = getThing( 2 );
37
38 sio << "a = " << a << " or " << (int)a << sio.nl
39 << "b = " << b << " or " << b.toString() << sio.nl
40 << "c = " << c << " or " << c.toString() << sio.nl
41 << sio.nl;
42
43 return 0;
44}
45