11 #if !defined( _WX_JSONVAL_H )
15 #pragma interface "jsonval.h"
19 #include "wx/wxprec.h"
28 #include <wx/object.h>
29 #include <wx/hashmap.h>
30 #include <wx/dynarray.h>
31 #include <wx/arrstr.h>
35 #include "json_defs.h"
41 #if defined( wxJSON_USE_STL )
45 WX_DECLARE_OBJARRAY(
wxJSONValue, wxJSONInternalArray );
46 WX_DECLARE_STRING_HASH_MAP(
wxJSONValue, wxJSONInternalMap );
48 class WXDLLIMPEXP_JSON wxJSONInternalMap;
49 class WXDLLIMPEXP_JSON wxJSONInternalArray;
55 wxJSONTYPE_INVALID = 0,
77 wxJSONVALUE_COMMENT_DEFAULT = 0,
78 wxJSONVALUE_COMMENT_BEFORE,
79 wxJSONVALUE_COMMENT_AFTER,
80 wxJSONVALUE_COMMENT_INLINE,
106 #if defined( wxJSON_64BIT_INT)
120 wxJSONType GetType()
const;
121 bool IsValid()
const;
125 bool IsShort()
const;
126 bool IsUShort()
const;
128 bool IsULong()
const;
129 #if defined( wxJSON_64BIT_INT)
130 bool IsInt32()
const;
131 bool IsInt64()
const;
132 bool IsUInt32()
const;
133 bool IsUInt64()
const;
136 bool IsDouble()
const;
137 bool IsString()
const;
138 bool IsCString()
const;
139 bool IsArray()
const;
140 bool IsObject()
const;
141 bool IsMemoryBuff()
const;
145 unsigned int AsUInt()
const;
146 short AsShort()
const;
147 unsigned short AsUShort()
const;
148 long int AsLong()
const;
149 unsigned long AsULong()
const;
150 bool AsInt(
int& i )
const;
151 bool AsUInt(
unsigned int& ui )
const;
152 bool AsShort(
short int& s )
const;
153 bool AsUShort(
unsigned short& us )
const;
154 bool AsLong(
long int& l )
const;
155 bool AsULong(
unsigned long& ul )
const;
156 #if defined( wxJSON_64BIT_INT)
157 wxInt32 AsInt32()
const;
158 wxUint32 AsUInt32()
const;
159 wxInt64 AsInt64()
const;
160 wxUint64 AsUInt64()
const;
161 bool AsInt32( wxInt32& i32 )
const;
162 bool AsUInt32( wxUint32& ui32 )
const;
163 bool AsInt64( wxInt64& i64 )
const;
164 bool AsUInt64( wxUint64& ui64 )
const;
167 double AsDouble()
const;
168 wxString AsString()
const;
169 const wxChar* AsCString()
const;
170 bool AsBool(
bool& b )
const;
171 bool AsDouble(
double& d )
const;
172 bool AsString( wxString& str )
const;
173 bool AsCString( wxChar* ch )
const;
174 wxMemoryBuffer AsMemoryBuff()
const;
175 bool AsMemoryBuff( wxMemoryBuffer& buff )
const;
177 const wxJSONInternalMap* AsMap()
const;
178 const wxJSONInternalArray* AsArray()
const;
181 bool HasMember(
unsigned index )
const;
182 bool HasMember(
const wxString& key )
const;
184 wxArrayString GetMemberNames()
const;
195 #if defined( wxJSON_64BIT_INT )
203 wxJSONValue& Append(
const void* buff,
size_t len );
204 bool Remove(
int index );
205 bool Remove(
const wxString& key );
207 bool Cat(
const wxChar* str );
208 bool Cat(
const wxString& str );
209 bool Cat(
const wxMemoryBuffer& buff );
221 wxJSONValue operator [] (
const wxString& key )
const;
229 #if defined( wxJSON_64BIT_INT )
237 wxJSONValue& operator = (
const wxMemoryBuffer& buff );
248 int AddComment(
const wxString& str,
int position = wxJSONVALUE_COMMENT_DEFAULT );
249 int AddComment(
const wxArrayString& comments,
int position = wxJSONVALUE_COMMENT_DEFAULT );
250 wxString GetComment(
int idx = -1 )
const;
251 int GetCommentPos()
const;
252 int GetCommentCount()
const;
253 void ClearComments();
254 const wxArrayString& GetCommentArray()
const;
257 wxString GetInfo()
const;
258 wxString Dump(
bool deep =
false,
int mode = 0 )
const;
263 int GetLineNo()
const;
264 void SetLineNo(
int num );
267 static wxString TypeToString( wxJSONType type );
268 static wxString MemoryBuffToString(
const wxMemoryBuffer& buff,
size_t len = -1 );
269 static wxString MemoryBuffToString(
const void* buff,
size_t len,
size_t actualLen = -1 );
270 static int CompareMemoryBuff(
const wxMemoryBuffer& buff1,
const wxMemoryBuffer& buff2 );
271 static int CompareMemoryBuff(
const wxMemoryBuffer& buff1,
const void* buff2 );
272 static wxMemoryBuffer ArrayToMemoryBuff(
const wxJSONValue& value );
290 void AllocExclusive();
297 #if defined( WXJSON_USE_VALUE_COUNTER )
304 #if !defined( wxJSON_USE_STL )
307 WX_DECLARE_OBJARRAY(
wxJSONValue, wxJSONInternalArray );
308 WX_DECLARE_STRING_HASH_MAP(
wxJSONValue, wxJSONInternalMap );
334 unsigned int m_valUInt;
335 short int m_valShort;
336 unsigned short m_valUShort;
338 unsigned long m_valULong;
340 const wxChar* m_valCString;
342 #if defined( wxJSON_64BIT_INT )
344 wxUint64 m_valUInt64;
353 #if defined( wxJSON_64BIT_INT )
354 #define VAL_INT m_valInt64
355 #define VAL_UINT m_valUInt64
357 #define VAL_INT m_valLong
358 #define VAL_UINT m_valULong
375 int GetRefCount()
const;
434 #if defined( WXJSON_USE_VALUE_COUNTER )
442 #endif // not defined _WX_JSONVAL_H
wxJSONRefData * m_refData
the referenced data
Definition: jsonval.h:293
int m_commentPos
The position of the comment line(s), if any.
Definition: jsonval.h:410
wxArrayString m_comments
The array of comment lines; may be empty.
Definition: jsonval.h:413
The JSON value class implementation.
Definition: jsonval.h:91
int m_lineNo
The line number when this value was read.
Definition: jsonval.h:423
The actual value held by the wxJSONValue class (internal use)
Definition: jsonval.h:332
wxJSONInternalArray m_valArray
The JSON array value.
Definition: jsonval.h:398
wxJSONInternalMap m_valMap
The JSON object value.
Definition: jsonval.h:401
wxJSONType m_type
The actual type of the value held by this object.
Definition: jsonval.h:383
wxString m_valString
The JSON string value.
Definition: jsonval.h:395
The JSON parser.
Definition: jsonreader.h:55
The reference counted JSON value data (internal use).
Definition: jsonval.h:364
wxMemoryBuffer * m_memBuff
The pointer to the memory buffer object.
Definition: jsonval.h:431
int m_refCount
the references count
Definition: jsonval.h:380
The JSON document writer.
Definition: jsonwriter.h:54
wxJSONValueHolder m_value
The JSON value held by this object.
Definition: jsonval.h:392