summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2010-07-30 23:34:31 +0000
committerMike Buland <eichlan@xagasoft.com>2010-07-30 23:34:31 +0000
commit31bae0662ad7b579af22912df420571c26c2f0b8 (patch)
tree53013d2a2c891e29d08e2149fd68d4ceafb1ad5b
parentd473e27a38126a58b9a793e6cc62768cd02c0c46 (diff)
downloadlibbu++-31bae0662ad7b579af22912df420571c26c2f0b8.tar.gz
libbu++-31bae0662ad7b579af22912df420571c26c2f0b8.tar.bz2
libbu++-31bae0662ad7b579af22912df420571c26c2f0b8.tar.xz
libbu++-31bae0662ad7b579af22912df420571c26c2f0b8.zip
A few fixes and stuff in the Variant.
-rw-r--r--src/variant.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/variant.h b/src/variant.h
index 1eda584..809aab9 100644
--- a/src/variant.h
+++ b/src/variant.h
@@ -134,6 +134,20 @@ namespace Bu
134 } 134 }
135 135
136 template<class t> 136 template<class t>
137 t &get() const
138 {
139 if( !pCore )
140 {
141 throw Bu::ExceptionBase("No data!");
142 }
143 if( pCore->getType() != typeid(t) )
144 {
145 throw Bu::ExceptionBase("Invalid type conversion.");
146 }
147 return dynamic_cast<VariantType<t> *>(pCore)->getData();
148 }
149
150 template<class t>
137 void set( const t &val ) 151 void set( const t &val )
138 { 152 {
139 if( pCore && pCore->getType() != typeid(t) ) 153 if( pCore && pCore->getType() != typeid(t) )
@@ -146,6 +160,12 @@ namespace Bu
146 } 160 }
147 161
148 template<class t> 162 template<class t>
163 bool isType() const
164 {
165 return pCore->getType() == typeid(t);
166 }
167
168 template<class t>
149 operator t() 169 operator t()
150 { 170 {
151 if( !pCore ) 171 if( !pCore )