00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #if !defined( _WX_JSONWRITER_H )
00012 #define _WX_JSONWRITER_H
00013
00014 #ifdef __GNUG__
00015 #pragma interface "jsonwriter.h"
00016 #endif
00017
00018
00019 #include "wx/wxprec.h"
00020
00021 #ifdef __BORLANDC__
00022 #pragma hdrstop
00023 #endif
00024
00025
00026
00027 #ifndef WX_PRECOMP
00028 #include <wx/stream.h>
00029 #include <wx/string.h>
00030 #endif
00031
00032 #include "json_defs.h"
00033 #include "jsonval.h"
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 enum {
00051 wxJSONWRITER_NONE = 0,
00052 wxJSONWRITER_STYLED = 1,
00053 wxJSONWRITER_WRITE_COMMENTS = 2,
00054 wxJSONWRITER_COMMENTS_BEFORE = 4,
00055 wxJSONWRITER_COMMENTS_AFTER = 8,
00056 wxJSONWRITER_SPLIT_STRING = 16,
00057 wxJSONWRITER_NO_LINEFEEDS = 32,
00058 wxJSONWRITER_ESCAPE_SOLIDUS = 64,
00059 wxJSONWRITER_MULTILINE_STRING = 128,
00060 wxJSONWRITER_RECOGNIZE_UNSIGNED = 256,
00061 wxJSONWRITER_TAB_INDENT = 512,
00062 wxJSONWRITER_NO_INDENTATION = 1024
00063 };
00064
00065
00066
00067 class WXDLLIMPEXP_JSON wxJSONWriter
00068 {
00069 public:
00070 wxJSONWriter( int style = wxJSONWRITER_STYLED, int indent = 0, int step = 3 );
00071 ~wxJSONWriter();
00072
00073 void Write( const wxJSONValue& value, wxString& str );
00074 void Write( const wxJSONValue& value, wxOutputStream& os );
00075
00076 protected:
00077
00078 int DoWrite( const wxJSONValue& value, const wxString* key,
00079 bool comma );
00080 int WriteIndent();
00081 int WriteIndent( int num );
00082 bool IsSpace( wxChar ch );
00083 bool IsPunctuation( wxChar ch );
00084
00085 int WriteString( const wxString& str );
00086 int WriteStringValue( const wxString& str );
00087 int WritePrimitiveValue( const wxJSONValue& value );
00088 int WriteInvalid();
00089 int WriteSeparator();
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 int WriteKey( const wxString& key );
00100 int WriteComment( const wxJSONValue& value, bool indent );
00101 int WriteChar( wxChar ch );
00102
00103 int WriteError( const wxString& err );
00104
00105 private:
00107 int m_style;
00108
00110 int m_indent;
00111
00113 int m_step;
00114
00116 int m_level;
00117
00119 void* m_outObject;
00120
00122 int m_outType;
00123
00125
00130 wxMBConv* m_conv;
00131
00132
00133 int m_lineNo;
00134
00135
00136 int m_colNo;
00137
00138
00139 };
00140
00141
00142 #endif // not defined _WX_JSONWRITER_H
00143
00144
00145