| virtual ~evariant();␊ |
| };␊ |
| ␊ |
| /*␊ |
| Added by Nathan Adams - the following is not apart of the original ptypes␊ |
| */␊ |
| ␊ |
| enum {␊ |
| ␉ARR_ASSOCIATIVE,␊ |
| ␉ARR_LIST,␊ |
|
| inline bool islist(const tparray& t) { return t.tag == ARR_LIST; }␊ |
| inline bool isnull(const tparray& t) { return t.tag == ARR_NULL; }␊ |
| ␊ |
| ␊ |
| //http://stackoverflow.com/a/7936901/195722␍␊ |
| template<typename T> class ByRef {␍␊ |
| public:␍␊ |
| ByRef() {␍␊ |
| }␍␊ |
| ␍␊ |
| ByRef(const T value) : mValue(value) {␍␊ |
| }␍␊ |
| ␍␊ |
| operator T&() const {␍␊ |
| return((T&)mValue);␍␊ |
| }␍␊ |
| ␍␊ |
| private:␍␊ |
| T mValue;␍␊ |
| };␊ |
| ␊ |
| ␊ |
| class json␍␊ |
| {␍␊ |
| ␉␉␍␊ |
| ␉␉protected:␍␊ |
| ␉␉␉string ParseString(const string & json, int & index, bool & success);␍␊ |
| ␉␉␉large ParseNumber(const string & json, int & index, bool & success);␍␊ |
| #ifndef USE_VARIANT␍␊ |
| ␉␉␉tparray * ParseObject(const string & json, int & index, bool & success);␍␊ |
| ␉␉␉tparray * ParseArray(const string & json, int & index, bool & success);␍␊ |
| #else␍␊ |
| ␉␉␉variant ParseObject(const string & json, int & index, bool & success);␍␊ |
| ␉␉␉variant ParseArray(const string & json, int & index, bool & success);␍␊ |
| #endif␍␊ |
| ␉␉␉int GetLastIndexOfNumber(const string & json, int index);␍␊ |
| ␉␉␉variant ParseValue(const string & json, int & index, bool & success);␍␊ |
| ␉␉␉int LookAhead(const string & json, int index);␍␊ |
| ␉␉␉void EatWhiteSpace(const string & json, int & index);␍␊ |
| ␉␉␉int NextToken(const string & json, int & index);␍␊ |
| ␉␉␉bool SerializeValue(const variant & value, string & builder);␍␊ |
| ␉␉␉bool SerializeString(const string & aString, string & builder);␍␊ |
| ␉␉␉bool SerializeObject(const tparray & anObject, string & builder);␍␊ |
| ␉␉␉bool SerializeArray(const tparray & anArray, string & builder);␍␊ |
| ␉␉␉bool SerializeNumber(large number, string & builder);␍␊ |
| ␉␉public:␍␊ |
| ␉␉␉enum Token { TOKEN_NONE, ␍␊ |
| ␉␉␉␉␉ TOKEN_CURLY_OPEN, ␍␊ |
| ␉␉␉␉␉ TOKEN_CURLY_CLOSE, ␍␊ |
| ␉␉␉␉␉ TOKEN_SQUARED_OPEN, ␍␊ |
| ␉␉␉␉␉ TOKEN_SQUARED_CLOSE, ␍␊ |
| ␉␉␉␉␉ TOKEN_COLON, ␍␊ |
| ␉␉␉␉␉ TOKEN_COMMA, ␍␊ |
| ␉␉␉␉␉ TOKEN_STRING, ␍␊ |
| ␉␉␉␉␉ TOKEN_NUMBER,␍␊ |
| ␉␉␉␉␉ TOKEN_TRUE,␍␊ |
| ␉␉␉␉␉ TOKEN_FALSE,␍␊ |
| ␉␉␉␉␉ TOKEN_NULL };␍␊ |
| ␉␉␉variant JsonDecode(const string & json, bool & success = ByRef<bool>(true));␍␊ |
| ␉␉␉string JsonEncode(const variant & v);␍␊ |
| ␍␊ |
| };␊ |
| ␊ |
| // -------------------------------------------------------------------- //␊ |
| // --- pre-2.0 compatibility declarations ----------------------------- //␊ |
| // -------------------------------------------------------------------- //␊ |