From 9dc8cc535ef5fc4ea78f967fe285fe4424ff4458 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 18 Aug 2010 16:17:15 +0000 Subject: getting it all tuned up. --- src/dictionary.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/dictionary.cpp') 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 ) } } +void Gats::Dictionary::insert( const Bu::FString &sKey, int32_t i ) +{ + ((Bu::Hash *)this)->insert( + sKey, new Gats::Integer( i ) + ); +} + void Gats::Dictionary::insert( const Bu::FString &sKey, int64_t i ) { ((Bu::Hash *)this)->insert( @@ -75,6 +82,13 @@ void Gats::Dictionary::insert( const Bu::FString &sKey, double d ) // ); } +void Gats::Dictionary::insert( const Bu::FString &sKey, const char *s ) +{ + Bu::Hash::insert( + sKey, new Gats::String( s ) + ); +} + void Gats::Dictionary::insert( const Bu::FString &sKey, const Bu::FString &s ) { Bu::Hash::insert( @@ -85,7 +99,7 @@ void Gats::Dictionary::insert( const Bu::FString &sKey, const Bu::FString &s ) bool Gats::Dictionary::getBool( const Bu::FString &sKey ) { Gats::Boolean *pOb = dynamic_cast( get( sKey ) ); - if( pOb ) + if( !pOb ) throw Bu::ExceptionBase("Cannot cast item '%s' to bool.", sKey.getStr() ); @@ -95,7 +109,7 @@ bool Gats::Dictionary::getBool( const Bu::FString &sKey ) int64_t Gats::Dictionary::getInt( const Bu::FString &sKey ) { Gats::Integer *pOb = dynamic_cast( get( sKey ) ); - if( pOb ) + if( !pOb ) throw Bu::ExceptionBase("Cannot cast item '%s' to int.", sKey.getStr() ); @@ -116,7 +130,7 @@ double Gats::Dictionary::getFloat( const Bu::FString &sKey ) Bu::FString Gats::Dictionary::getStr( const Bu::FString &sKey ) { Gats::String *pOb = dynamic_cast( get( sKey ) ); - if( pOb ) + if( !pOb ) throw Bu::ExceptionBase("Cannot cast item '%s' to string.", sKey.getStr() ); @@ -126,7 +140,7 @@ Bu::FString Gats::Dictionary::getStr( const Bu::FString &sKey ) Gats::List *Gats::Dictionary::getList( const Bu::FString &sKey ) { Gats::List *pOb = dynamic_cast( get( sKey ) ); - if( pOb ) + if( !pOb ) throw Bu::ExceptionBase("Cannot cast item '%s' to list.", sKey.getStr() ); @@ -136,7 +150,7 @@ Gats::List *Gats::Dictionary::getList( const Bu::FString &sKey ) Gats::Dictionary *Gats::Dictionary::getDict( const Bu::FString &sKey ) { Gats::Dictionary *pOb = dynamic_cast( get( sKey ) ); - if( pOb ) + if( !pOb ) throw Bu::ExceptionBase("Cannot cast item '%s' to dictionary.", sKey.getStr() ); -- cgit v1.2.3