From 31bae0662ad7b579af22912df420571c26c2f0b8 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 30 Jul 2010 23:34:31 +0000 Subject: A few fixes and stuff in the Variant. --- src/variant.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src') diff --git a/src/variant.h b/src/variant.h index 1eda584..809aab9 100644 --- a/src/variant.h +++ b/src/variant.h @@ -133,6 +133,20 @@ namespace Bu return dynamic_cast *>(pCore)->getData(); } + template + t &get() const + { + if( !pCore ) + { + throw Bu::ExceptionBase("No data!"); + } + if( pCore->getType() != typeid(t) ) + { + throw Bu::ExceptionBase("Invalid type conversion."); + } + return dynamic_cast *>(pCore)->getData(); + } + template void set( const t &val ) { @@ -145,6 +159,12 @@ namespace Bu (*dynamic_cast *>(pCore)) = val; } + template + bool isType() const + { + return pCore->getType() == typeid(t); + } + template operator t() { -- cgit v1.2.3