aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <mbuland@penny-arcade.com>2017-08-22 11:58:37 -0700
committerMike Buland <mbuland@penny-arcade.com>2017-08-22 11:58:37 -0700
commitfeb899f0b0aaaf236577cacf16e4c3b25b292fe6 (patch)
tree2d4391dba6b06a15f3476e3d39c59b035da26aac
parent2fc7fcd7161121ab48cda40687d7d152e03b3079 (diff)
downloadlibbu++-feb899f0b0aaaf236577cacf16e4c3b25b292fe6.tar.gz
libbu++-feb899f0b0aaaf236577cacf16e4c3b25b292fe6.tar.bz2
libbu++-feb899f0b0aaaf236577cacf16e4c3b25b292fe6.tar.xz
libbu++-feb899f0b0aaaf236577cacf16e4c3b25b292fe6.zip
Updated json.
It needs a lot more work before it can be used to programattically build complex objects, but it's a great start.
-rw-r--r--src/stable/fmt.h2
-rw-r--r--src/unstable/json.cpp7
-rw-r--r--src/unstable/json.h2
3 files changed, 9 insertions, 2 deletions
diff --git a/src/stable/fmt.h b/src/stable/fmt.h
index 9ecaf80..a650062 100644
--- a/src/stable/fmt.h
+++ b/src/stable/fmt.h
@@ -59,7 +59,7 @@ namespace Bu
59 59
60 static Fmt bin( unsigned int uWidth=0 ) 60 static Fmt bin( unsigned int uWidth=0 )
61 { 61 {
62 return Fmt( uWidth, 1, Right, false, false, '0' ); 62 return Fmt( uWidth, 2, Right, false, false, '0' );
63 } 63 }
64 64
65 static Fmt ptr( bool bCaps=true ) 65 static Fmt ptr( bool bCaps=true )
diff --git a/src/unstable/json.cpp b/src/unstable/json.cpp
index f5a1696..d13f6e2 100644
--- a/src/unstable/json.cpp
+++ b/src/unstable/json.cpp
@@ -116,7 +116,7 @@ bool Bu::Json::isNull() const
116 116
117Bu::Json *Bu::Json::operator[]( const Bu::String &sKey ) const 117Bu::Json *Bu::Json::operator[]( const Bu::String &sKey ) const
118{ 118{
119 if( eType != Boolean ) 119 if( eType != Object )
120 throw Bu::ExceptionBase( 120 throw Bu::ExceptionBase(
121 "Object entry requested from non-object json object." 121 "Object entry requested from non-object json object."
122 ); 122 );
@@ -159,6 +159,11 @@ Bu::Json::const_iterator Bu::Json::end() const
159 return uDat.pArray->end(); 159 return uDat.pArray->end();
160} 160}
161 161
162void Bu::Json::insert( const Bu::String &sKey, Bu::Json *pObj )
163{
164 uDat.pObject->insert( sKey, pObj );
165}
166
162void Bu::Json::parse( Bu::Stream &sInput ) 167void Bu::Json::parse( Bu::Stream &sInput )
163{ 168{
164 reset(); 169 reset();
diff --git a/src/unstable/json.h b/src/unstable/json.h
index 76d96be..5a59b7e 100644
--- a/src/unstable/json.h
+++ b/src/unstable/json.h
@@ -51,6 +51,8 @@ namespace Bu
51 iterator end(); 51 iterator end();
52 const_iterator end() const; 52 const_iterator end() const;
53 53
54 void insert( const Bu::String &sKey, Bu::Json *pObj );
55
54 void parse( Bu::Stream &sInput ); 56 void parse( Bu::Stream &sInput );
55 void parse( const Bu::String &sInput ); 57 void parse( const Bu::String &sInput );
56 void reset(); 58 void reset();