diff options
author | Mike Buland <eichlan@xagasoft.com> | 2010-09-27 14:47:21 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2010-09-27 14:47:21 +0000 |
commit | d14a4c34d01102baa830c6762ef80b0dc6db6389 (patch) | |
tree | f7a7e6c1b0df80d30c0c1e6552353b622200a28c /src | |
parent | 7bced34486b3151aeac04dd1657af955565e2322 (diff) | |
download | libgats-d14a4c34d01102baa830c6762ef80b0dc6db6389.tar.gz libgats-d14a4c34d01102baa830c6762ef80b0dc6db6389.tar.bz2 libgats-d14a4c34d01102baa830c6762ef80b0dc6db6389.tar.xz libgats-d14a4c34d01102baa830c6762ef80b0dc6db6389.zip |
Damn boolean overloads, always getting in the way...
Diffstat (limited to 'src')
-rw-r--r-- | src/dictionary.cpp | 64 | ||||
-rw-r--r-- | src/dictionary.h | 9 |
2 files changed, 70 insertions, 3 deletions
diff --git a/src/dictionary.cpp b/src/dictionary.cpp index b789bbf..29bbd4e 100644 --- a/src/dictionary.cpp +++ b/src/dictionary.cpp | |||
@@ -70,12 +70,12 @@ void Gats::Dictionary::insert( const Bu::FString &sKey, int64_t i ) | |||
70 | ); | 70 | ); |
71 | } | 71 | } |
72 | 72 | ||
73 | void Gats::Dictionary::insert( const Bu::FString &sKey, bool b ) | 73 | /*void Gats::Dictionary::insert( const Bu::FString &sKey, bool b ) |
74 | { | 74 | { |
75 | Bu::Hash<Gats::String, Gats::Object *>::insert( | 75 | Bu::Hash<Gats::String, Gats::Object *>::insert( |
76 | sKey, new Gats::Boolean( b ) | 76 | sKey, new Gats::Boolean( b ) |
77 | ); | 77 | ); |
78 | } | 78 | }*/ |
79 | 79 | ||
80 | void Gats::Dictionary::insert( const Bu::FString &sKey, double d ) | 80 | void Gats::Dictionary::insert( const Bu::FString &sKey, double d ) |
81 | { | 81 | { |
@@ -158,6 +158,66 @@ Gats::Dictionary *Gats::Dictionary::getDict( const Bu::FString &sKey ) | |||
158 | return pOb; | 158 | return pOb; |
159 | } | 159 | } |
160 | 160 | ||
161 | bool Gats::Dictionary::getBool( const Bu::FString &sKey ) const | ||
162 | { | ||
163 | Gats::Boolean *pOb = dynamic_cast<Gats::Boolean *>( get( sKey ) ); | ||
164 | if( !pOb ) | ||
165 | throw Bu::ExceptionBase("Cannot cast item '%s' to bool.", | ||
166 | sKey.getStr() ); | ||
167 | |||
168 | return pOb->getValue(); | ||
169 | } | ||
170 | |||
171 | int64_t Gats::Dictionary::getInt( const Bu::FString &sKey ) const | ||
172 | { | ||
173 | Gats::Integer *pOb = dynamic_cast<Gats::Integer *>( get( sKey ) ); | ||
174 | if( !pOb ) | ||
175 | throw Bu::ExceptionBase("Cannot cast item '%s' to int.", | ||
176 | sKey.getStr() ); | ||
177 | |||
178 | return pOb->getValue(); | ||
179 | } | ||
180 | |||
181 | double Gats::Dictionary::getFloat( const Bu::FString &sKey ) const | ||
182 | { | ||
183 | Gats::Boolean *pOb = dynamic_cast<Gats::Boolean *>( get( sKey ) ); | ||
184 | if( pOb ) | ||
185 | throw Bu::ExceptionBase("Cannot cast item '%s' to bool.", | ||
186 | sKey.getStr() ); | ||
187 | |||
188 | return pOb->getValue(); | ||
189 | } | ||
190 | |||
191 | Bu::FString Gats::Dictionary::getStr( const Bu::FString &sKey ) const | ||
192 | { | ||
193 | Gats::String *pOb = dynamic_cast<Gats::String *>( get( sKey ) ); | ||
194 | if( !pOb ) | ||
195 | throw Bu::ExceptionBase("Cannot cast item '%s' to string.", | ||
196 | sKey.getStr() ); | ||
197 | |||
198 | return *pOb; | ||
199 | } | ||
200 | |||
201 | Gats::List *Gats::Dictionary::getList( const Bu::FString &sKey ) const | ||
202 | { | ||
203 | Gats::List *pOb = dynamic_cast<Gats::List *>( get( sKey ) ); | ||
204 | if( !pOb ) | ||
205 | throw Bu::ExceptionBase("Cannot cast item '%s' to list.", | ||
206 | sKey.getStr() ); | ||
207 | |||
208 | return pOb; | ||
209 | } | ||
210 | |||
211 | Gats::Dictionary *Gats::Dictionary::getDict( const Bu::FString &sKey ) const | ||
212 | { | ||
213 | Gats::Dictionary *pOb = dynamic_cast<Gats::Dictionary *>( get( sKey ) ); | ||
214 | if( !pOb ) | ||
215 | throw Bu::ExceptionBase("Cannot cast item '%s' to dictionary.", | ||
216 | sKey.getStr() ); | ||
217 | |||
218 | return pOb; | ||
219 | } | ||
220 | |||
161 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Dictionary &d ) | 221 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Dictionary &d ) |
162 | { | 222 | { |
163 | f << "(dict) {"; | 223 | f << "(dict) {"; |
diff --git a/src/dictionary.h b/src/dictionary.h index 39248d2..c9bf1cb 100644 --- a/src/dictionary.h +++ b/src/dictionary.h | |||
@@ -24,7 +24,7 @@ namespace Gats | |||
24 | void insert( const Bu::FString &sKey, const Bu::FString &s ); | 24 | void insert( const Bu::FString &sKey, const Bu::FString &s ); |
25 | void insert( const Bu::FString &sKey, int32_t i ); | 25 | void insert( const Bu::FString &sKey, int32_t i ); |
26 | void insert( const Bu::FString &sKey, int64_t i ); | 26 | void insert( const Bu::FString &sKey, int64_t i ); |
27 | void insert( const Bu::FString &sKey, bool b ); | 27 | //void insert( const Bu::FString &sKey, bool b ); |
28 | void insert( const Bu::FString &sKey, double d ); | 28 | void insert( const Bu::FString &sKey, double d ); |
29 | using Bu::Hash<Gats::String, Gats::Object *>::insert; | 29 | using Bu::Hash<Gats::String, Gats::Object *>::insert; |
30 | 30 | ||
@@ -34,6 +34,13 @@ namespace Gats | |||
34 | Bu::FString getStr( const Bu::FString &sKey ); | 34 | Bu::FString getStr( const Bu::FString &sKey ); |
35 | Gats::List *getList( const Bu::FString &sKey ); | 35 | Gats::List *getList( const Bu::FString &sKey ); |
36 | Gats::Dictionary *getDict( const Bu::FString &sKey ); | 36 | Gats::Dictionary *getDict( const Bu::FString &sKey ); |
37 | |||
38 | bool getBool( const Bu::FString &sKey ) const; | ||
39 | int64_t getInt( const Bu::FString &sKey ) const; | ||
40 | double getFloat( const Bu::FString &sKey ) const; | ||
41 | Bu::FString getStr( const Bu::FString &sKey ) const; | ||
42 | Gats::List *getList( const Bu::FString &sKey ) const; | ||
43 | Gats::Dictionary *getDict( const Bu::FString &sKey ) const; | ||
37 | }; | 44 | }; |
38 | }; | 45 | }; |
39 | 46 | ||