From 19223f8527ef1c0d36cf8b40b9f8d093ea702ca5 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 5 Jun 2017 07:39:05 -0700 Subject: Added better null helpers to libbu++/php --- c++-libbu++/src/dictionary.cpp | 25 +++++++++++++++++++++++++ c++-libbu++/src/dictionary.h | 3 +++ 2 files changed, 28 insertions(+) (limited to 'c++-libbu++') diff --git a/c++-libbu++/src/dictionary.cpp b/c++-libbu++/src/dictionary.cpp index 5ed3834..00d06f7 100644 --- a/c++-libbu++/src/dictionary.cpp +++ b/c++-libbu++/src/dictionary.cpp @@ -12,6 +12,7 @@ #include "gats/float.h" #include "gats/string.h" #include "gats/list.h" +#include "gats/null.h" #include @@ -249,6 +250,22 @@ Gats::Dictionary *Gats::Dictionary::insertDict( const Bu::String &sKey ) return pDict; } +void Gats::Dictionary::insertNull( const Bu::String &sKey ) +{ + Bu::Hash::insert( + sKey, + new Gats::Null() + ); +} + +bool Gats::Dictionary::isNull( const Bu::String &sKey ) +{ + Gats::Object *pObj = get( sKey ); + if( pObj->getType() == Gats::typeNull ) + return true; + return false; +} + bool Gats::Dictionary::getBool( const Bu::String &sKey ) { Gats::Boolean *pOb = dynamic_cast( get( sKey ) ); @@ -309,6 +326,14 @@ Gats::Dictionary *Gats::Dictionary::getDict( const Bu::String &sKey ) return pOb; } +bool Gats::Dictionary::isNull( const Bu::String &sKey ) const +{ + Gats::Object *pObj = get( sKey ); + if( pObj->getType() == Gats::typeNull ) + return true; + return false; +} + bool Gats::Dictionary::getBool( const Bu::String &sKey ) const { Gats::Boolean *pOb = dynamic_cast( get( sKey ) ); diff --git a/c++-libbu++/src/dictionary.h b/c++-libbu++/src/dictionary.h index d2cdec0..84cf69f 100644 --- a/c++-libbu++/src/dictionary.h +++ b/c++-libbu++/src/dictionary.h @@ -54,7 +54,9 @@ namespace Gats void insertDict( const Bu::String &sKey, Gats::Dictionary *pD ); Gats::List *insertList( const Bu::String &sKey ); Gats::Dictionary *insertDict( const Bu::String &sKey ); + void insertNull( const Bu::String &sKey ); + bool isNull( const Bu::String &sKey ); bool getBool( const Bu::String &sKey ); int64_t getInt( const Bu::String &sKey ); double getFloat( const Bu::String &sKey ); @@ -62,6 +64,7 @@ namespace Gats Gats::List *getList( const Bu::String &sKey ); Gats::Dictionary *getDict( const Bu::String &sKey ); + bool isNull( const Bu::String &sKey ) const; bool getBool( const Bu::String &sKey ) const; int64_t getInt( const Bu::String &sKey ) const; double getFloat( const Bu::String &sKey ) const; -- cgit v1.2.3