49 #include "common/array.h" 50 #include "common/hashmap.h" 51 #include "common/hash-str.h" 52 #include "common/memstream.h" 53 #include "common/str.h" 56 #if (defined(WIN32) && !defined(__GNUC__)) 57 static inline bool isnan(
double x) {
61 static inline bool isinf(
double x) {
62 return !isnan(x) && isnan(x - x);
67 static inline bool simplejson_wcsnlen(
const char *s,
size_t n) {
73 if (*(save++) == 0)
return false;
83 typedef Array<JSONValue*> JSONArray;
84 typedef HashMap<String, JSONValue*> JSONObject;
88 enum JSONType { JSONType_Null, JSONType_String, JSONType_Bool, JSONType_Number, JSONType_IntegerNumber, JSONType_Array, JSONType_Object };
101 JSONValue(
const JSONObject &objectValue);
106 bool isString()
const;
108 bool isNumber()
const;
109 bool isIntegerNumber()
const;
110 bool isArray()
const;
111 bool isObject()
const;
113 const String &asString()
const;
115 double asNumber()
const;
116 long long int asIntegerNumber()
const;
117 const JSONArray &asArray()
const;
118 const JSONObject &asObject()
const;
120 size_t countChildren()
const;
121 bool hasChild(
size_t index)
const;
123 bool hasChild(
const char *name)
const;
127 String stringify(
bool const prettyprint =
false)
const;
129 static JSONValue *parse(
const char **data);
133 static uint32 decodeUtf8Char(String::const_iterator &begin,
const String::const_iterator &end);
134 static uint8 decodeUtf8Byte(uint8 state, uint32 &codepoint, uint8 byte);
135 String stringifyImpl(
size_t const indentDepth)
const;
136 static String indent(
size_t depth);
143 long long int _integerValue;
145 JSONArray *_arrayValue;
146 JSONObject *_objectValue;
158 static JSONValue *parse(
const char *data);
161 static bool skipWhitespace(
const char **data);
162 static bool extractString(
const char **data,
String &str);
163 static uint32 parseUnicode(
const char **data);
164 static double parseInt(
const char **data);
165 static double parseDecimal(
const char **data);
Definition: memstream.h:194
Definition: algorithm.h:29