From 76e1ecfabd1f831bc1810aeae65c0faf61d80cee Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 1 Nov 2010 17:19:44 +0000 Subject: Maybe more minor fixes? --- src/dictionary.cpp | 55 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 24 deletions(-) (limited to 'src/dictionary.cpp') diff --git a/src/dictionary.cpp b/src/dictionary.cpp index f3a89c8..9791203 100644 --- a/src/dictionary.cpp +++ b/src/dictionary.cpp @@ -140,6 +140,13 @@ void Gats::Dictionary::insert( const Bu::FString &sKey, bool b ) ); }*/ +void Gats::Dictionary::insert( const Bu::FString &sKey, float d ) +{ + Bu::Hash::insert( + sKey, new Gats::Float( d ) + ); +} + void Gats::Dictionary::insert( const Bu::FString &sKey, double d ) { Bu::Hash::insert( @@ -165,8 +172,8 @@ bool Gats::Dictionary::getBool( const Bu::FString &sKey ) { Gats::Boolean *pOb = dynamic_cast( get( sKey ) ); if( !pOb ) - throw Bu::ExceptionBase("Cannot cast item '%s' to bool.", - sKey.getStr() ); + throw Bu::ExceptionBase("Cannot use %s item '%s' as bool.", + typeToStr( get( sKey )->getType() ), sKey.getStr() ); return pOb->getValue(); } @@ -175,8 +182,8 @@ int64_t Gats::Dictionary::getInt( const Bu::FString &sKey ) { Gats::Integer *pOb = dynamic_cast( get( sKey ) ); if( !pOb ) - throw Bu::ExceptionBase("Cannot cast item '%s' to int.", - sKey.getStr() ); + throw Bu::ExceptionBase("Cannot use %s item '%s' as int.", + typeToStr( get( sKey )->getType() ), sKey.getStr() ); return pOb->getValue(); } @@ -185,8 +192,8 @@ double Gats::Dictionary::getFloat( const Bu::FString &sKey ) { Gats::Float *pOb = dynamic_cast( get( sKey ) ); if( pOb ) - throw Bu::ExceptionBase("Cannot cast item '%s' to bool.", - sKey.getStr() ); + throw Bu::ExceptionBase("Cannot use %s item '%s' as float.", + typeToStr( get( sKey )->getType() ), sKey.getStr() ); return pOb->getValue(); } @@ -195,8 +202,8 @@ Bu::FString Gats::Dictionary::getStr( const Bu::FString &sKey ) { Gats::String *pOb = dynamic_cast( get( sKey ) ); if( !pOb ) - throw Bu::ExceptionBase("Cannot cast item '%s' to string.", - sKey.getStr() ); + throw Bu::ExceptionBase("Cannot use %s item '%s' as string.", + typeToStr( get( sKey )->getType() ), sKey.getStr() ); return *pOb; } @@ -205,8 +212,8 @@ Gats::List *Gats::Dictionary::getList( const Bu::FString &sKey ) { Gats::List *pOb = dynamic_cast( get( sKey ) ); if( !pOb ) - throw Bu::ExceptionBase("Cannot cast item '%s' to list.", - sKey.getStr() ); + throw Bu::ExceptionBase("Cannot use %s item '%s' as list.", + typeToStr( get( sKey )->getType() ), sKey.getStr() ); return pOb; } @@ -215,8 +222,8 @@ Gats::Dictionary *Gats::Dictionary::getDict( const Bu::FString &sKey ) { Gats::Dictionary *pOb = dynamic_cast( get( sKey ) ); if( !pOb ) - throw Bu::ExceptionBase("Cannot cast item '%s' to dictionary.", - sKey.getStr() ); + throw Bu::ExceptionBase("Cannot use %s item '%s' as dictionary.", + typeToStr( get( sKey )->getType() ), sKey.getStr() ); return pOb; } @@ -225,8 +232,8 @@ bool Gats::Dictionary::getBool( const Bu::FString &sKey ) const { Gats::Boolean *pOb = dynamic_cast( get( sKey ) ); if( !pOb ) - throw Bu::ExceptionBase("Cannot cast item '%s' to bool.", - sKey.getStr() ); + throw Bu::ExceptionBase("Cannot use %s item '%s' as bool.", + typeToStr( get( sKey )->getType() ), sKey.getStr() ); return pOb->getValue(); } @@ -235,8 +242,8 @@ int64_t Gats::Dictionary::getInt( const Bu::FString &sKey ) const { Gats::Integer *pOb = dynamic_cast( get( sKey ) ); if( !pOb ) - throw Bu::ExceptionBase("Cannot cast item '%s' to int.", - sKey.getStr() ); + throw Bu::ExceptionBase("Cannot use %s item '%s' as int.", + typeToStr( get( sKey )->getType() ), sKey.getStr() ); return pOb->getValue(); } @@ -245,8 +252,8 @@ double Gats::Dictionary::getFloat( const Bu::FString &sKey ) const { Gats::Float *pOb = dynamic_cast( get( sKey ) ); if( pOb ) - throw Bu::ExceptionBase("Cannot cast item '%s' to bool.", - sKey.getStr() ); + throw Bu::ExceptionBase("Cannot use %s item '%s' as float.", + typeToStr( get( sKey )->getType() ), sKey.getStr() ); return pOb->getValue(); } @@ -255,8 +262,8 @@ Bu::FString Gats::Dictionary::getStr( const Bu::FString &sKey ) const { Gats::String *pOb = dynamic_cast( get( sKey ) ); if( !pOb ) - throw Bu::ExceptionBase("Cannot cast item '%s' to string.", - sKey.getStr() ); + throw Bu::ExceptionBase("Cannot use %s item '%s' as string.", + typeToStr( get( sKey )->getType() ), sKey.getStr() ); return *pOb; } @@ -265,8 +272,8 @@ Gats::List *Gats::Dictionary::getList( const Bu::FString &sKey ) const { Gats::List *pOb = dynamic_cast( get( sKey ) ); if( !pOb ) - throw Bu::ExceptionBase("Cannot cast item '%s' to list.", - sKey.getStr() ); + throw Bu::ExceptionBase("Cannot use %s item '%s' as list.", + typeToStr( get( sKey )->getType() ), sKey.getStr() ); return pOb; } @@ -275,8 +282,8 @@ Gats::Dictionary *Gats::Dictionary::getDict( const Bu::FString &sKey ) const { Gats::Dictionary *pOb = dynamic_cast( get( sKey ) ); if( !pOb ) - throw Bu::ExceptionBase("Cannot cast item '%s' to dictionary.", - sKey.getStr() ); + throw Bu::ExceptionBase("Cannot use %s item '%s' as dictionary.", + typeToStr( get( sKey )->getType() ), sKey.getStr() ); return pOb; } -- cgit v1.2.3