diff options
Diffstat (limited to '')
-rw-r--r-- | src/variant.h | 20 |
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 ) |