From e99509abde688315ac7a82d764b352e2e3312e61 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 25 Sep 2009 22:14:26 +0000 Subject: 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. --- src/tests/variant.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/tests/variant.cpp (limited to 'src/tests') 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 @@ +#include +#include +#include + +using namespace Bu; + +Variant getThing( int i ) +{ + Variant v; + switch( i ) + { + case 0: + v = 45; + break; + + case 1: + v = true; + break; + + case 2: + v = List(5).append(10).append(15); + break; + } + + return v; +} + +int main() +{ + Variant a; + Variant b; + Variant c; + + a = getThing( 0 ); + b = getThing( 1 ); + c = getThing( 2 ); + + sio << "a = " << a << " or " << (int)a << sio.nl + << "b = " << b << " or " << b.toString() << sio.nl + << "c = " << c << " or " << c.toString() << sio.nl + << sio.nl; + + return 0; +} + -- cgit v1.2.3