diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2010-08-18 16:17:15 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2010-08-18 16:17:15 +0000 |
| commit | 9dc8cc535ef5fc4ea78f967fe285fe4424ff4458 (patch) | |
| tree | a8a267bf5b8f8ca74bc767964fe47a97b33be01a /src/dictionary.cpp | |
| parent | cebb8eca644ff772b169178810372971176ebe9d (diff) | |
| download | libgats-9dc8cc535ef5fc4ea78f967fe285fe4424ff4458.tar.gz libgats-9dc8cc535ef5fc4ea78f967fe285fe4424ff4458.tar.bz2 libgats-9dc8cc535ef5fc4ea78f967fe285fe4424ff4458.tar.xz libgats-9dc8cc535ef5fc4ea78f967fe285fe4424ff4458.zip | |
getting it all tuned up.
Diffstat (limited to 'src/dictionary.cpp')
| -rw-r--r-- | src/dictionary.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/dictionary.cpp b/src/dictionary.cpp index 385960f..2223c8b 100644 --- a/src/dictionary.cpp +++ b/src/dictionary.cpp | |||
| @@ -54,6 +54,13 @@ void Gats::Dictionary::read( Bu::Stream &rIn, char cType ) | |||
| 54 | } | 54 | } |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | void Gats::Dictionary::insert( const Bu::FString &sKey, int32_t i ) | ||
| 58 | { | ||
| 59 | ((Bu::Hash<Gats::String, Gats::Object *> *)this)->insert( | ||
| 60 | sKey, new Gats::Integer( i ) | ||
| 61 | ); | ||
| 62 | } | ||
| 63 | |||
| 57 | void Gats::Dictionary::insert( const Bu::FString &sKey, int64_t i ) | 64 | void Gats::Dictionary::insert( const Bu::FString &sKey, int64_t i ) |
| 58 | { | 65 | { |
| 59 | ((Bu::Hash<Gats::String, Gats::Object *> *)this)->insert( | 66 | ((Bu::Hash<Gats::String, Gats::Object *> *)this)->insert( |
| @@ -75,6 +82,13 @@ void Gats::Dictionary::insert( const Bu::FString &sKey, double d ) | |||
| 75 | // ); | 82 | // ); |
| 76 | } | 83 | } |
| 77 | 84 | ||
| 85 | void Gats::Dictionary::insert( const Bu::FString &sKey, const char *s ) | ||
| 86 | { | ||
| 87 | Bu::Hash<Gats::String, Gats::Object *>::insert( | ||
| 88 | sKey, new Gats::String( s ) | ||
| 89 | ); | ||
| 90 | } | ||
| 91 | |||
| 78 | void Gats::Dictionary::insert( const Bu::FString &sKey, const Bu::FString &s ) | 92 | void Gats::Dictionary::insert( const Bu::FString &sKey, const Bu::FString &s ) |
| 79 | { | 93 | { |
| 80 | Bu::Hash<Gats::String, Gats::Object *>::insert( | 94 | Bu::Hash<Gats::String, Gats::Object *>::insert( |
| @@ -85,7 +99,7 @@ void Gats::Dictionary::insert( const Bu::FString &sKey, const Bu::FString &s ) | |||
| 85 | bool Gats::Dictionary::getBool( const Bu::FString &sKey ) | 99 | bool Gats::Dictionary::getBool( const Bu::FString &sKey ) |
| 86 | { | 100 | { |
| 87 | Gats::Boolean *pOb = dynamic_cast<Gats::Boolean *>( get( sKey ) ); | 101 | Gats::Boolean *pOb = dynamic_cast<Gats::Boolean *>( get( sKey ) ); |
| 88 | if( pOb ) | 102 | if( !pOb ) |
| 89 | throw Bu::ExceptionBase("Cannot cast item '%s' to bool.", | 103 | throw Bu::ExceptionBase("Cannot cast item '%s' to bool.", |
| 90 | sKey.getStr() ); | 104 | sKey.getStr() ); |
| 91 | 105 | ||
| @@ -95,7 +109,7 @@ bool Gats::Dictionary::getBool( const Bu::FString &sKey ) | |||
| 95 | int64_t Gats::Dictionary::getInt( const Bu::FString &sKey ) | 109 | int64_t Gats::Dictionary::getInt( const Bu::FString &sKey ) |
| 96 | { | 110 | { |
| 97 | Gats::Integer *pOb = dynamic_cast<Gats::Integer *>( get( sKey ) ); | 111 | Gats::Integer *pOb = dynamic_cast<Gats::Integer *>( get( sKey ) ); |
| 98 | if( pOb ) | 112 | if( !pOb ) |
| 99 | throw Bu::ExceptionBase("Cannot cast item '%s' to int.", | 113 | throw Bu::ExceptionBase("Cannot cast item '%s' to int.", |
| 100 | sKey.getStr() ); | 114 | sKey.getStr() ); |
| 101 | 115 | ||
| @@ -116,7 +130,7 @@ double Gats::Dictionary::getFloat( const Bu::FString &sKey ) | |||
| 116 | Bu::FString Gats::Dictionary::getStr( const Bu::FString &sKey ) | 130 | Bu::FString Gats::Dictionary::getStr( const Bu::FString &sKey ) |
| 117 | { | 131 | { |
| 118 | Gats::String *pOb = dynamic_cast<Gats::String *>( get( sKey ) ); | 132 | Gats::String *pOb = dynamic_cast<Gats::String *>( get( sKey ) ); |
| 119 | if( pOb ) | 133 | if( !pOb ) |
| 120 | throw Bu::ExceptionBase("Cannot cast item '%s' to string.", | 134 | throw Bu::ExceptionBase("Cannot cast item '%s' to string.", |
| 121 | sKey.getStr() ); | 135 | sKey.getStr() ); |
| 122 | 136 | ||
| @@ -126,7 +140,7 @@ Bu::FString Gats::Dictionary::getStr( const Bu::FString &sKey ) | |||
| 126 | Gats::List *Gats::Dictionary::getList( const Bu::FString &sKey ) | 140 | Gats::List *Gats::Dictionary::getList( const Bu::FString &sKey ) |
| 127 | { | 141 | { |
| 128 | Gats::List *pOb = dynamic_cast<Gats::List *>( get( sKey ) ); | 142 | Gats::List *pOb = dynamic_cast<Gats::List *>( get( sKey ) ); |
| 129 | if( pOb ) | 143 | if( !pOb ) |
| 130 | throw Bu::ExceptionBase("Cannot cast item '%s' to list.", | 144 | throw Bu::ExceptionBase("Cannot cast item '%s' to list.", |
| 131 | sKey.getStr() ); | 145 | sKey.getStr() ); |
| 132 | 146 | ||
| @@ -136,7 +150,7 @@ Gats::List *Gats::Dictionary::getList( const Bu::FString &sKey ) | |||
| 136 | Gats::Dictionary *Gats::Dictionary::getDict( const Bu::FString &sKey ) | 150 | Gats::Dictionary *Gats::Dictionary::getDict( const Bu::FString &sKey ) |
| 137 | { | 151 | { |
| 138 | Gats::Dictionary *pOb = dynamic_cast<Gats::Dictionary *>( get( sKey ) ); | 152 | Gats::Dictionary *pOb = dynamic_cast<Gats::Dictionary *>( get( sKey ) ); |
| 139 | if( pOb ) | 153 | if( !pOb ) |
| 140 | throw Bu::ExceptionBase("Cannot cast item '%s' to dictionary.", | 154 | throw Bu::ExceptionBase("Cannot cast item '%s' to dictionary.", |
| 141 | sKey.getStr() ); | 155 | sKey.getStr() ); |
| 142 | 156 | ||
