From 0f49ce8fc6aa54224e4c0d6fda8c4527ad39cce1 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Thu, 24 Jul 2014 16:47:31 -0700 Subject: 0.4 Win-Beta --- LibOVR/Src/OVR_JSON.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'LibOVR/Src/OVR_JSON.h') diff --git a/LibOVR/Src/OVR_JSON.h b/LibOVR/Src/OVR_JSON.h index a2a603c..28fcc6e 100644 --- a/LibOVR/Src/OVR_JSON.h +++ b/LibOVR/Src/OVR_JSON.h @@ -71,12 +71,13 @@ public: // *** Creation of NEW JSON objects - static JSON* CreateObject() { return new JSON(JSON_Object);} - static JSON* CreateNull() { return new JSON(JSON_Null); } - static JSON* CreateArray() { return new JSON(JSON_Array); } - static JSON* CreateBool(bool b) { return createHelper(JSON_Bool, b ? 1.0 : 0.0); } - static JSON* CreateNumber(double num) { return createHelper(JSON_Number, num); } - static JSON* CreateString(const char *s) { return createHelper(JSON_String, 0.0, s); } + static JSON* CreateObject() { return new JSON(JSON_Object);} + static JSON* CreateNull() { return new JSON(JSON_Null); } + static JSON* CreateArray() { return new JSON(JSON_Array); } + static JSON* CreateBool(bool b); + static JSON* CreateNumber(double num); + static JSON* CreateInt(int num); + static JSON* CreateString(const char *s); // Creates a new JSON object from parsing string. // Returns null pointer and fills in *perror in case of parse error. @@ -120,6 +121,7 @@ public: void AddItem(const char *string, JSON* item); void AddNullItem(const char* name) { AddItem(name, CreateNull()); } void AddBoolItem(const char* name, bool b) { AddItem(name, CreateBool(b)); } + void AddIntItem(const char* name, int n) { AddItem(name, CreateInt(n)); } void AddNumberItem(const char* name, double n) { AddItem(name, CreateNumber(n)); } void AddStringItem(const char* name, const char* s) { AddItem(name, CreateString(s)); } // void ReplaceItem(unsigned index, JSON* new_item); @@ -132,6 +134,7 @@ public: void AddArrayElement(JSON *item); void InsertArrayElement(int index, JSON* item); void AddArrayNumber(double n) { AddArrayElement(CreateNumber(n)); } + void AddArrayInt(int n) { AddArrayElement(CreateInt(n)); } void AddArrayString(const char* s) { AddArrayElement(CreateString(s)); } // Accessed array elements; currently inefficient. @@ -144,8 +147,6 @@ public: protected: JSON(JSONItemType itemType = JSON_Object); - static JSON* createHelper(JSONItemType itemType, double dval, const char* strVal = 0); - // JSON Parsing helper functions. const char* parseValue(const char *buff, const char** perror); const char* parseNumber(const char *num); -- cgit v1.2.3