summaryrefslogtreecommitdiff
path: root/src/unstable/json.h
diff options
context:
space:
mode:
authorMike Buland <mbuland@penny-arcade.com>2017-06-06 22:45:21 -0700
committerMike Buland <mbuland@penny-arcade.com>2017-06-06 22:45:21 -0700
commitdc759b40b9a18b20454b68244dd063ab56155c3e (patch)
treee16c5b024f44c30b9aeef8fc3bb85087039cf1f0 /src/unstable/json.h
parentb7751f0136502592e9b1897b51859b1133339a93 (diff)
downloadlibbu++-dc759b40b9a18b20454b68244dd063ab56155c3e.tar.gz
libbu++-dc759b40b9a18b20454b68244dd063ab56155c3e.tar.bz2
libbu++-dc759b40b9a18b20454b68244dd063ab56155c3e.tar.xz
libbu++-dc759b40b9a18b20454b68244dd063ab56155c3e.zip
Reading, writing, and accessing loaded data all work.
Diffstat (limited to '')
-rw-r--r--src/unstable/json.h30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/unstable/json.h b/src/unstable/json.h
index 47009cb..2d1770d 100644
--- a/src/unstable/json.h
+++ b/src/unstable/json.h
@@ -11,7 +11,14 @@ namespace Bu
11 11
12 class Json 12 class Json
13 { 13 {
14 private:
15 Json( char &c, Bu::Stream &sInput );
16 typedef Bu::Hash<Bu::String, Json *> JsonHash;
17 typedef Bu::List<Json *> JsonList;
18
14 public: 19 public:
20 typedef JsonList::iterator iterator;
21 typedef JsonList::const_iterator const_iterator;
15 enum Type 22 enum Type
16 { 23 {
17 Invalid, 24 Invalid,
@@ -29,10 +36,28 @@ namespace Bu
29 Json( Bu::Stream &sInput ); 36 Json( Bu::Stream &sInput );
30 virtual ~Json(); 37 virtual ~Json();
31 38
39 Type getType() const;
40 Bu::String getString() const;
41 double getNumber() const;
42 bool getBoolean() const;
43 bool isNull() const;
44 Json *operator[]( const Bu::String &sKey ) const;
45 int getSize() const;
46 iterator begin();
47 const_iterator begin() const;
48 iterator end();
49 const_iterator end() const;
50
32 void parse( Bu::Stream &sInput ); 51 void parse( Bu::Stream &sInput );
33 void reset(); 52 void reset();
34 53
54 void write( Bu::Stream &sOutput ) const;
55 void writeStable( Bu::Stream &sOutput ) const;
56 Bu::String toString() const;
57 Bu::String toStringStable() const;
58
35 private: 59 private:
60 void parse( char &c, Bu::Stream &sInput );
36 void parseString( char &c, Bu::Stream &sInput, Bu::String &sOut ); 61 void parseString( char &c, Bu::Stream &sInput, Bu::String &sOut );
37 void parseString( char &c, Bu::Stream &sInput ); 62 void parseString( char &c, Bu::Stream &sInput );
38 void parseObject( char &c, Bu::Stream &sInput ); 63 void parseObject( char &c, Bu::Stream &sInput );
@@ -42,11 +67,10 @@ namespace Bu
42 bool readChar( char &c, Bu::Stream &sInput ); 67 bool readChar( char &c, Bu::Stream &sInput );
43 void readChar( char &c, Bu::Stream &sInput, const char *sSection ); 68 void readChar( char &c, Bu::Stream &sInput, const char *sSection );
44 bool isWs( char c ); 69 bool isWs( char c );
70 void skipWs( char &c, Bu::Stream &sInput );
71 void writeStr( const Bu::String &sStr, Bu::Stream &sOutput ) const;
45 72
46 private: 73 private:
47 typedef Bu::Hash<Bu::String, Json *> JsonHash;
48 typedef Bu::List<Json *> JsonList;
49
50 Type eType; 74 Type eType;
51 union DatUnion 75 union DatUnion
52 { 76 {