aboutsummaryrefslogtreecommitdiff
path: root/c++-libbu++
diff options
context:
space:
mode:
authorMike Buland <mbuland@penny-arcade.com>2017-06-05 07:39:05 -0700
committerMike Buland <mbuland@penny-arcade.com>2017-06-05 07:39:05 -0700
commit19223f8527ef1c0d36cf8b40b9f8d093ea702ca5 (patch)
treed59222d22d96318948b52329e2ee4ec0e0745d1a /c++-libbu++
parentae3649ec44e9c08dac7553031573ea52c1dfdd82 (diff)
downloadlibgats-19223f8527ef1c0d36cf8b40b9f8d093ea702ca5.tar.gz
libgats-19223f8527ef1c0d36cf8b40b9f8d093ea702ca5.tar.bz2
libgats-19223f8527ef1c0d36cf8b40b9f8d093ea702ca5.tar.xz
libgats-19223f8527ef1c0d36cf8b40b9f8d093ea702ca5.zip
Added better null helpers to libbu++/php
Diffstat (limited to 'c++-libbu++')
-rw-r--r--c++-libbu++/src/dictionary.cpp25
-rw-r--r--c++-libbu++/src/dictionary.h3
2 files changed, 28 insertions, 0 deletions
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 @@
12#include "gats/float.h" 12#include "gats/float.h"
13#include "gats/string.h" 13#include "gats/string.h"
14#include "gats/list.h" 14#include "gats/list.h"
15#include "gats/null.h"
15 16
16#include <bu/formatter.h> 17#include <bu/formatter.h>
17 18
@@ -249,6 +250,22 @@ Gats::Dictionary *Gats::Dictionary::insertDict( const Bu::String &sKey )
249 return pDict; 250 return pDict;
250} 251}
251 252
253void Gats::Dictionary::insertNull( const Bu::String &sKey )
254{
255 Bu::Hash<Gats::String, Gats::Object *>::insert(
256 sKey,
257 new Gats::Null()
258 );
259}
260
261bool Gats::Dictionary::isNull( const Bu::String &sKey )
262{
263 Gats::Object *pObj = get( sKey );
264 if( pObj->getType() == Gats::typeNull )
265 return true;
266 return false;
267}
268
252bool Gats::Dictionary::getBool( const Bu::String &sKey ) 269bool Gats::Dictionary::getBool( const Bu::String &sKey )
253{ 270{
254 Gats::Boolean *pOb = dynamic_cast<Gats::Boolean *>( get( sKey ) ); 271 Gats::Boolean *pOb = dynamic_cast<Gats::Boolean *>( get( sKey ) );
@@ -309,6 +326,14 @@ Gats::Dictionary *Gats::Dictionary::getDict( const Bu::String &sKey )
309 return pOb; 326 return pOb;
310} 327}
311 328
329bool Gats::Dictionary::isNull( const Bu::String &sKey ) const
330{
331 Gats::Object *pObj = get( sKey );
332 if( pObj->getType() == Gats::typeNull )
333 return true;
334 return false;
335}
336
312bool Gats::Dictionary::getBool( const Bu::String &sKey ) const 337bool Gats::Dictionary::getBool( const Bu::String &sKey ) const
313{ 338{
314 Gats::Boolean *pOb = dynamic_cast<Gats::Boolean *>( get( sKey ) ); 339 Gats::Boolean *pOb = dynamic_cast<Gats::Boolean *>( 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
54 void insertDict( const Bu::String &sKey, Gats::Dictionary *pD ); 54 void insertDict( const Bu::String &sKey, Gats::Dictionary *pD );
55 Gats::List *insertList( const Bu::String &sKey ); 55 Gats::List *insertList( const Bu::String &sKey );
56 Gats::Dictionary *insertDict( const Bu::String &sKey ); 56 Gats::Dictionary *insertDict( const Bu::String &sKey );
57 void insertNull( const Bu::String &sKey );
57 58
59 bool isNull( const Bu::String &sKey );
58 bool getBool( const Bu::String &sKey ); 60 bool getBool( const Bu::String &sKey );
59 int64_t getInt( const Bu::String &sKey ); 61 int64_t getInt( const Bu::String &sKey );
60 double getFloat( const Bu::String &sKey ); 62 double getFloat( const Bu::String &sKey );
@@ -62,6 +64,7 @@ namespace Gats
62 Gats::List *getList( const Bu::String &sKey ); 64 Gats::List *getList( const Bu::String &sKey );
63 Gats::Dictionary *getDict( const Bu::String &sKey ); 65 Gats::Dictionary *getDict( const Bu::String &sKey );
64 66
67 bool isNull( const Bu::String &sKey ) const;
65 bool getBool( const Bu::String &sKey ) const; 68 bool getBool( const Bu::String &sKey ) const;
66 int64_t getInt( const Bu::String &sKey ) const; 69 int64_t getInt( const Bu::String &sKey ) const;
67 double getFloat( const Bu::String &sKey ) const; 70 double getFloat( const Bu::String &sKey ) const;