Support GitLab experimental

Добавлена возможность сохранять SQL представления объектов в GitLab
Описание в Readme.MD
This commit is contained in:
lsv 2022-11-24 19:19:37 +05:00
parent 535538c6d9
commit 4f10ebc477
15 changed files with 9509 additions and 0 deletions

View file

@ -0,0 +1,209 @@
/////////////////////////////////////////////////////////////////////////////
// Name: json_defs.h
// Purpose: shared build defines
// Author: Luciano Cattani
// Created: 2007/10/20
// RCS-ID: $Id: json_defs.h,v 1.6 2008/03/12 10:48:19 luccat Exp $
// Copyright: (c) 2007 Luciano Cattani
// Licence: wxWidgets licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_JSON_DEFS_H_
#define _WX_JSON_DEFS_H_
// Defines for component version.
// The following symbols should be updated for each new component release
// since some kind of tests, like those of AM_WXCODE_CHECKFOR_COMPONENT_VERSION()
// for "configure" scripts under unix, use them.
#define wxJSON_MAJOR 1
#define wxJSON_MINOR 2
#define wxJSON_RELEASE 1
// For non-Unix systems (i.e. when building without a configure script),
// users of this component can use the following macro to check if the
// current version is at least major.minor.release
#define wxCHECK_JSON_VERSION(major,minor,release) \
(wxJSON_MAJOR > (major) || \
(wxJSON_MAJOR == (major) && wxJSON_MINOR > (minor)) || \
(wxJSON_MAJOR == (major) && wxJSON_MINOR == (minor) && wxJSON_RELEASE >= (release)))
// Defines for shared builds.
// Simple reference for using these macros and for writin components
// which support shared builds:
//
// 1) use the WXDLLIMPEXP_MYCOMP in each class declaration:
// class WXDLLIMPEXP_MYCOMP myCompClass { [...] };
//
// 2) use the WXDLLIMPEXP_MYCOMP in the declaration of each global function:
// WXDLLIMPEXP_MYCOMP int myGlobalFunc();
//
// 3) use the WXDLLIMPEXP_DATA_MYCOMP() in the declaration of each global
// variable:
// WXDLLIMPEXP_DATA_MYCOMP(int) myGlobalIntVar;
//
#ifdef WXMAKINGDLL_JSON
#define WXDLLIMPEXP_JSON WXEXPORT
#define WXDLLIMPEXP_DATA_JSON(type) WXEXPORT type
#elif defined(WXUSINGDLL11)
#define WXDLLIMPEXP_JSON WXIMPORT
#define WXDLLIMPEXP_DATA_JSON(type) WXIMPORT type
#else // not making nor using DLL
#define WXDLLIMPEXP_JSON
#define WXDLLIMPEXP_DATA_JSON(type) type
#endif
// the __PRETTY_FUNCTION__ macro expands to the full class's
// member name in the GNU GCC.
// For other compilers we use the standard __wxFUNCTION__ macro
#if !defined( __GNUC__ )
#define __PRETTY_FUNCTION__ __WXFUNCTION__
#endif
// define wxJSON_USE_UNICODE if wxWidgets was built with
// unicode support
#if defined( wxJSON_USE_UNICODE )
#undef wxJSON_USE_UNICODE
#endif
// do not modify the following lines
#if wxUSE_UNICODE == 1
#define wxJSON_USE_UNICODE
#endif
// the following macro, if defined, cause the wxJSONValue to store
// pointers to C-strings as pointers to statically allocated
// C-strings. By default this macro is not defined
// #define wxJSON_USE_CSTRING
// the following macro, if defined, cause the wxJSONvalue and its
// referenced data structure to store and increment a static
// progressive counter in the ctor.
// this is only usefull for debugging purposes
// #define WXJSON_USE_VALUE_COUNTER
// the following macro is used by wxJSON internally and you should not
// modify it. If the platform seems to support 64-bits integers,
// the following lines define the 'wxJSON_64BIT_INT' macro
#if defined( wxLongLong_t )
#define wxJSON_64BIT_INT
#endif
//
// the following macro, if defined, cause the wxJSON library to
// always use 32-bits integers also when the platform seems to
// have native 64-bits support: by default the macro if not defined
//
// #define wxJSON_NO_64BIT_INT
//
#if defined( wxJSON_NO_64BIT_INT ) && defined( wxJSON_64BIT_INT )
#undef wxJSON_64BIT_INT
#endif
//
// it seems that some compilers do not define 'long long int' limits
// constants. For example, this is the output of the Borland BCC 5.5
// compiler when I tried to compile wxJSON with 64-bits integer support:
// Error E2451 ..\src\jsonreader.cpp 1737: Undefined symbol 'LLONG_MAX'
// in function wxJSONReader::Strtoll(const wxString &,__int64 *)
// *** 1 errors in Compile ***
// so, if the constants are not defined, I define them by myself
#if !defined( LLONG_MAX )
#define LLONG_MAX 9223372036854775807
#endif
#if !defined( ULLONG_MAX )
#define ULLONG_MAX 18446744073709551615
#endif
#if !defined( LLONG_MIN )
#define LLONG_MIN -9223372036854775808
#endif
// the same applies for all other integer constants
#if !defined( INT_MIN )
#define INT_MIN -32768
#endif
#if !defined( INT_MAX )
#define INT_MAX 32767
#endif
#if !defined( UINT_MAX )
#define UINT_MAX 65535
#endif
#if !defined( LONG_MIN )
#define LONG_MIN -2147483648
#endif
#if !defined( LONG_MAX )
#define LONG_MAX 2147483647
#endif
#if !defined( ULONG_MAX )
#define ULONG_MAX 4294967295
#endif
#if !defined( SHORT_MAX )
#define SHORT_MAX 32767
#endif
#if !defined( SHORT_MIN )
#define SHORT_MIN -32768
#endif
#if !defined( USHORT_MAX )
#define USHORT_MAX 65535
#endif
//
// define the wxJSON_ASSERT() macro to expand to wxASSERT()
// unless the wxJSON_NOABORT_ASSERT is defined
// #define wxJSON_NOABORT_ASSERT
#if defined( wxJSON_NOABORT_ASSERT )
#define wxJSON_ASSERT( cond )
#else
#define wxJSON_ASSERT( cond ) wxASSERT( cond );
#endif
//
// the following macros are used by the wxJSONWriter::WriteStringValues()
// when the wxJSONWRITER_SPLIT_STRING flag is set
#define wxJSONWRITER_LAST_COL 50
#define wxJSONWRITER_SPLIT_COL 75
#define wxJSONWRITER_MIN_LENGTH 15
#define wxJSONWRITER_TAB_LENGTH 4
//
// some compilers (i.e. MSVC++) defines their own 'snprintf' function
// so if it is not defined, define it in the following lines
// please note that we cannot use the wxWidget's counterpart 'wxSnprintf'
// because the latter uses 'wxChar' but wxJSON only use 'char'
#if !defined(snprintf) && defined(_MSC_VER)
#define snprintf _snprintf
#endif
//
// check if wxWidgets is compiled using --enable-stl in which case
// we have to use different aproaches when declaring the array and
// key/value containers (see the docs: wxJSON internals: array and hash_map
#undef wxJSON_USE_STL
#if defined( wxUSE_STL ) && wxUSE_STL == 1
#define wxJSON_USE_STL
#endif
//
// defines the MIN and MAX macro for numeric arguments
// note that the safest way to define such functions is using templates
#define MIN(a,b) a < b ? a : b
#define MAX(a,b) a > b ? a : b
#endif // _WX_JSON_DEFS_H_

View file

@ -0,0 +1,148 @@
/////////////////////////////////////////////////////////////////////////////
// Name: jsonreader.h
// Purpose: the parser of JSON text
// Author: Luciano Cattani
// Created: 2007/09/15
// RCS-ID: $Id: jsonreader.h,v 1.3 2008/03/03 19:05:45 luccat Exp $
// Copyright: (c) 2007 Luciano Cattani
// Licence: wxWidgets licence
/////////////////////////////////////////////////////////////////////////////
#include "pgAdmin3.h"
#if !defined( _WX_JSONREADER_H )
#define _WX_JSONREADER_H
#ifdef __GNUG__
#pragma interface "jsonreader.h"
#endif
// For compilers that support precompilation, includes "wx/wx.h".
#ifdef __BORLANDC__
#pragma hdrstop
#endif
// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWidgets headers)
#ifndef WX_PRECOMP
#include <wx/stream.h>
#include <wx/string.h>
#include <wx/arrstr.h>
#endif
// The flags of the parser
enum {
wxJSONREADER_STRICT = 0,
wxJSONREADER_ALLOW_COMMENTS = 1,
wxJSONREADER_STORE_COMMENTS = 2,
wxJSONREADER_CASE = 4,
wxJSONREADER_MISSING = 8,
wxJSONREADER_MULTISTRING = 16,
wxJSONREADER_COMMENTS_AFTER = 32,
wxJSONREADER_NOUTF8_STREAM = 64,
wxJSONREADER_MEMORYBUFF = 128,
wxJSONREADER_TOLERANT = wxJSONREADER_ALLOW_COMMENTS | wxJSONREADER_CASE |
wxJSONREADER_MISSING | wxJSONREADER_MULTISTRING,
wxJSONREADER_COMMENTS_BEFORE = wxJSONREADER_ALLOW_COMMENTS | wxJSONREADER_STORE_COMMENTS
};
class WXDLLIMPEXP_JSON wxJSONReader
{
public:
wxJSONReader(int flags = wxJSONREADER_TOLERANT, int maxErrors = 30);
virtual ~wxJSONReader();
int Parse(const wxString& doc, wxJSONValue* val);
int Parse(wxInputStream& doc, wxJSONValue* val);
int GetDepth() const;
int GetErrorCount() const;
int GetWarningCount() const;
const wxArrayString& GetErrors() const;
const wxArrayString& GetWarnings() const;
static int UTF8NumBytes(char ch);
#if defined( wxJSON_64BIT_INT )
static bool Strtoll(const wxString& str, wxInt64* i64);
static bool Strtoull(const wxString& str, wxUint64* ui64);
static bool DoStrto_ll(const wxString& str, wxUint64* ui64, wxChar* sign);
#endif
protected:
int DoRead(wxInputStream& doc, wxJSONValue& val);
void AddError(const wxString& descr);
void AddError(const wxString& fmt, const wxString& str);
void AddError(const wxString& fmt, wxChar ch);
void AddWarning(int type, const wxString& descr);
int GetStart(wxInputStream& is);
int ReadChar(wxInputStream& is);
int PeekChar(wxInputStream& is);
void StoreValue(int ch, const wxString& key, wxJSONValue& value, wxJSONValue& parent);
int SkipWhiteSpace(wxInputStream& is);
int SkipComment(wxInputStream& is);
void StoreComment(const wxJSONValue* parent);
int ReadString(wxInputStream& is, wxJSONValue& val);
int ReadToken(wxInputStream& is, int ch, wxString& s);
int ReadValue(wxInputStream& is, int ch, wxJSONValue& val);
int ReadUES(wxInputStream& is, char* uesBuffer);
int AppendUES(wxMemoryBuffer& utf8Buff, const char* uesBuffer);
int NumBytes(char ch);
int ConvertCharByChar(wxString& s, const wxMemoryBuffer& utf8Buffer);
int ReadMemoryBuff(wxInputStream& is, wxJSONValue& val);
//! Flag that control the parser behaviour,
int m_flags;
//! Maximum number of errors stored in the error's array
int m_maxErrors;
//! The current line number (start at 1).
int m_lineNo;
//! The current column number (start at 1).
int m_colNo;
//! The current level of object/array annidation (start at ZERO).
int m_level;
//! The depth level of the read JSON text
int m_depth;
//! The pointer to the value object that is being read.
wxJSONValue* m_current;
//! The pointer to the value object that was last stored.
wxJSONValue* m_lastStored;
//! The pointer to the value object that will be read.
wxJSONValue* m_next;
//! The comment string read by SkipComment().
wxString m_comment;
//! The starting line of the comment string.
int m_commentLine;
//! The array of error messages.
wxArrayString m_errors;
//! The array of warning messages.
wxArrayString m_warnings;
//! The character read by the PeekChar() function (-1 none)
int m_peekChar;
//! ANSI: do not convert UTF-8 strings
bool m_noUtf8;
};
#endif // not defined _WX_JSONREADER_H

View file

@ -0,0 +1,440 @@
/////////////////////////////////////////////////////////////////////////////
// Name: jsonval.h
// Purpose: the wxJSONValue class: it holds a JSON value
// Author: Luciano Cattani
// Created: 2007/09/15
// RCS-ID: $Id: jsonval.h,v 1.4 2008/01/10 21:27:15 luccat Exp $
// Copyright: (c) 2007 Luciano Cattani
// Licence: wxWidgets licence
/////////////////////////////////////////////////////////////////////////////
#if !defined( _WX_JSONVAL_H )
#define _WX_JSONVAL_H
#ifdef __GNUG__
#pragma interface "jsonval.h"
#endif
// For compilers that support precompilation, includes "wx/wx.h".
#ifdef __BORLANDC__
#pragma hdrstop
#endif
// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWidgets headers)
#ifndef WX_PRECOMP
#include <wx/object.h>
#include <wx/hashmap.h>
#include <wx/dynarray.h>
#include <wx/arrstr.h>
#endif
#include "utils/json/json_defs.h"
// forward declarations
class WXDLLIMPEXP_JSON wxJSONReader;
class WXDLLIMPEXP_JSON wxJSONRefData;
#if defined( wxJSON_USE_STL )
// if compiling on MinGW we use the STL-style declaration of wxWidget's
// container classes
class WXDLLIMPEXP_JSON wxJSONValue;
WX_DECLARE_OBJARRAY(wxJSONValue, wxJSONInternalArray);
WX_DECLARE_STRING_HASH_MAP(wxJSONValue, wxJSONInternalMap);
#else
class WXDLLIMPEXP_JSON wxJSONInternalMap;
class WXDLLIMPEXP_JSON wxJSONInternalArray;
#endif
//! The type of the value held by the wxJSONRefData class
enum wxJSONType {
wxJSONTYPE_INVALID = 0, /*!< the object is not uninitialized */
wxJSONTYPE_NULL, /*!< the object contains a NULL value */
wxJSONTYPE_INT, /*!< the object contains an integer */
wxJSONTYPE_UINT, /*!< the object contains an unsigned integer */
wxJSONTYPE_DOUBLE, /*!< the object contains a double */
wxJSONTYPE_STRING, /*!< the object contains a wxString object */
wxJSONTYPE_CSTRING, /*!< the object contains a static C-string */
wxJSONTYPE_BOOL, /*!< the object contains a boolean */
wxJSONTYPE_ARRAY, /*!< the object contains an array of values */
wxJSONTYPE_OBJECT, /*!< the object contains a map of keys/values */
wxJSONTYPE_LONG, /*!< the object contains a 32-bit integer */
wxJSONTYPE_INT64, /*!< the object contains a 64-bit integer */
wxJSONTYPE_ULONG, /*!< the object contains an unsigned 32-bit integer */
wxJSONTYPE_UINT64, /*!< the object contains an unsigned 64-bit integer */
wxJSONTYPE_SHORT, /*!< the object contains a 16-bit integer */
wxJSONTYPE_USHORT, /*!< the object contains a 16-bit unsigned integer */
wxJSONTYPE_MEMORYBUFF /*!< the object contains a binary memory buffer */
};
// the comment position: every value only has one comment position
// althrough comments may be splitted into several lines
enum {
wxJSONVALUE_COMMENT_DEFAULT = 0,
wxJSONVALUE_COMMENT_BEFORE,
wxJSONVALUE_COMMENT_AFTER,
wxJSONVALUE_COMMENT_INLINE,
};
/***********************************************************************
class wxJSONValue
***********************************************************************/
// class WXDLLIMPEXP_JSON wxJSONValue : public wxObject
class WXDLLIMPEXP_JSON wxJSONValue
{
friend class wxJSONReader;
public:
// ctors and dtor
wxJSONValue();
wxJSONValue(wxJSONType type);
wxJSONValue(int i);
wxJSONValue(unsigned int i);
wxJSONValue(short i);
wxJSONValue(unsigned short i);
wxJSONValue(long int i);
wxJSONValue(unsigned long int i);
#if defined( wxJSON_64BIT_INT)
wxJSONValue(wxInt64 i);
wxJSONValue(wxUint64 ui);
#endif
wxJSONValue(bool b);
wxJSONValue(double d);
wxJSONValue(const wxChar* str); // assume static ASCIIZ strings
wxJSONValue(const wxString& str);
wxJSONValue(const wxMemoryBuffer& buff);
wxJSONValue(const void* buff, size_t len);
wxJSONValue(const wxJSONValue& other);
virtual ~wxJSONValue();
// functions for retrieving the value type
wxJSONType GetType() const;
bool IsValid() const;
bool IsNull() const;
bool IsInt() const;
bool IsUInt() const;
bool IsShort() const;
bool IsUShort() const;
bool IsLong() const;
bool IsULong() const;
#if defined( wxJSON_64BIT_INT)
bool IsInt32() const;
bool IsInt64() const;
bool IsUInt32() const;
bool IsUInt64() const;
#endif
bool IsBool() const;
bool IsDouble() const;
bool IsString() const;
bool IsCString() const;
bool IsArray() const;
bool IsObject() const;
bool IsMemoryBuff() const;
// function for retireving the value as ...
int AsInt() const;
unsigned int AsUInt() const;
short AsShort() const;
unsigned short AsUShort() const;
long int AsLong() const;
unsigned long AsULong() const;
bool AsInt(int& i) const;
bool AsUInt(unsigned int& ui) const;
bool AsShort(short int& s) const;
bool AsUShort(unsigned short& us) const;
bool AsLong(long int& l) const;
bool AsULong(unsigned long& ul) const;
#if defined( wxJSON_64BIT_INT)
wxInt32 AsInt32() const;
wxUint32 AsUInt32() const;
wxInt64 AsInt64() const;
wxUint64 AsUInt64() const;
bool AsInt32(wxInt32& i32) const;
bool AsUInt32(wxUint32& ui32) const;
bool AsInt64(wxInt64& i64) const;
bool AsUInt64(wxUint64& ui64) const;
#endif
bool AsBool() const;
double AsDouble() const;
wxString AsString() const;
const wxChar* AsCString() const;
bool AsBool(bool& b) const;
bool AsDouble(double& d) const;
bool AsString(wxString& str) const;
bool AsCString(wxChar* ch) const;
wxMemoryBuffer AsMemoryBuff() const;
bool AsMemoryBuff(wxMemoryBuffer& buff) const;
const wxJSONInternalMap* AsMap() const;
const wxJSONInternalArray* AsArray() const;
// get members names, size and other info
bool HasMember(unsigned index) const;
bool HasMember(const wxString& key) const;
int Size() const;
wxArrayString GetMemberNames() const;
// appending items, resizing and deleting items
wxJSONValue& Append(const wxJSONValue& value);
wxJSONValue& Append(bool b);
wxJSONValue& Append(int i);
wxJSONValue& Append(unsigned int ui);
wxJSONValue& Append(short int i);
wxJSONValue& Append(unsigned short int ui);
wxJSONValue& Append(long int l);
wxJSONValue& Append(unsigned long int ul);
#if defined( wxJSON_64BIT_INT )
wxJSONValue& Append(wxInt64 i);
wxJSONValue& Append(wxUint64 ui);
#endif
wxJSONValue& Append(double d);
wxJSONValue& Append(const wxChar* str);
wxJSONValue& Append(const wxString& str);
wxJSONValue& Append(const wxMemoryBuffer& buff);
wxJSONValue& Append(const void* buff, size_t len);
bool Remove(int index);
bool Remove(const wxString& key);
void Clear();
bool Cat(const wxChar* str);
bool Cat(const wxString& str);
bool Cat(const wxMemoryBuffer& buff);
// retrieve an item
wxJSONValue& Item(unsigned index);
wxJSONValue& Item(const wxString& key);
wxJSONValue ItemAt(unsigned index) const;
wxJSONValue ItemAt(const wxString& key) const;
wxJSONValue& operator [] (unsigned index);
wxJSONValue& operator [] (const wxString& key);
wxJSONValue& operator = (int i);
wxJSONValue& operator = (unsigned int ui);
wxJSONValue& operator = (short int i);
wxJSONValue& operator = (unsigned short int ui);
wxJSONValue& operator = (long int l);
wxJSONValue& operator = (unsigned long int ul);
#if defined( wxJSON_64BIT_INT )
wxJSONValue& operator = (wxInt64 i);
wxJSONValue& operator = (wxUint64 ui);
#endif
wxJSONValue& operator = (bool b);
wxJSONValue& operator = (double d);
wxJSONValue& operator = (const wxChar* str);
wxJSONValue& operator = (const wxString& str);
wxJSONValue& operator = (const wxMemoryBuffer& buff);
// wxJSONValue& operator = ( const void* buff, size_t len ); cannot be declared
wxJSONValue& operator = (const wxJSONValue& value);
// get the value or a default value
wxJSONValue Get(const wxString& key, const wxJSONValue& defaultValue) const;
// comparison function
bool IsSameAs(const wxJSONValue& other) const;
// comment-related functions
int AddComment(const wxString& str, int position = wxJSONVALUE_COMMENT_DEFAULT);
int AddComment(const wxArrayString& comments, int position = wxJSONVALUE_COMMENT_DEFAULT);
wxString GetComment(int idx = -1) const;
int GetCommentPos() const;
int GetCommentCount() const;
void ClearComments();
const wxArrayString& GetCommentArray() const;
// debugging functions
wxString GetInfo() const;
wxString Dump(bool deep = false, int mode = 0) const;
//misc functions
wxJSONRefData* GetRefData() const;
wxJSONRefData* SetType(wxJSONType type);
int GetLineNo() const;
void SetLineNo(int num);
// public static functions: mainly used for debugging
static wxString TypeToString(wxJSONType type);
static wxString MemoryBuffToString(const wxMemoryBuffer& buff, size_t len = -1);
static wxString MemoryBuffToString(const void* buff, size_t len, size_t actualLen = -1);
static int CompareMemoryBuff(const wxMemoryBuffer& buff1, const wxMemoryBuffer& buff2);
static int CompareMemoryBuff(const wxMemoryBuffer& buff1, const void* buff2);
static wxMemoryBuffer ArrayToMemoryBuff(const wxJSONValue& value);
protected:
wxJSONValue* Find(unsigned index) const;
wxJSONValue* Find(const wxString& key) const;
void DeepCopy(const wxJSONValue& other);
wxJSONRefData* Init(wxJSONType type);
wxJSONRefData* COW();
// overidden from wxObject
virtual wxJSONRefData* CloneRefData(const wxJSONRefData* data) const;
virtual wxJSONRefData* CreateRefData() const;
void SetRefData(wxJSONRefData* data);
void Ref(const wxJSONValue& clone);
void UnRef();
void UnShare();
void AllocExclusive();
//! the referenced data
wxJSONRefData* m_refData;
// used for debugging purposes: only in debug builds.
#if defined( WXJSON_USE_VALUE_COUNTER )
int m_progr;
static int sm_progr;
#endif
};
#if !defined( wxJSON_USE_STL )
// if using wxWidget's implementation of container classes we declare
// the OBJARRAY are HASH_MAP _after_ the wxJSONValue is fully known
WX_DECLARE_OBJARRAY(wxJSONValue, wxJSONInternalArray);
WX_DECLARE_STRING_HASH_MAP(wxJSONValue, wxJSONInternalMap);
#endif
/***********************************************************************
class wxJSONRefData
***********************************************************************/
//! The actual value held by the wxJSONValue class (internal use)
/*!
Note that this structure is a \b union as in versions prior to 0.4.x
The union just stores primitive types and not complex types which are
stored in separate data members of the wxJSONRefData structure.
This organization give us more flexibility when retrieving compatible
types such as ints unsigned ints, long and so on.
To know more about the internal structure of the wxJSONValue class
see \ref pg_json_internals.
*/
union wxJSONValueHolder {
int m_valInt;
unsigned int m_valUInt;
short int m_valShort;
unsigned short m_valUShort;
long int m_valLong;
unsigned long m_valULong;
double m_valDouble;
const wxChar* m_valCString;
bool m_valBool;
#if defined( wxJSON_64BIT_INT )
wxInt64 m_valInt64;
wxUint64 m_valUInt64;
#endif
};
//
// access to the (unsigned) integer value is done through
// the VAL_INT macro which expands to the 'long' integer
// data member of the 'long long' integer if 64-bits integer
// support is enabled
#if defined( wxJSON_64BIT_INT )
#define VAL_INT m_valInt64
#define VAL_UINT m_valUInt64
#else
#define VAL_INT m_valLong
#define VAL_UINT m_valULong
#endif
// class WXDLLIMPEXP_JSON wxJSONRefData : public wxObjectRefData
class WXDLLIMPEXP_JSON wxJSONRefData
{
// friend class wxJSONReader;
friend class wxJSONValue;
friend class wxJSONWriter;
public:
wxJSONRefData();
virtual ~wxJSONRefData();
int GetRefCount() const;
// there is no need to define copy ctor
//! the references count
int m_refCount;
//! The actual type of the value held by this object.
wxJSONType m_type;
//! The JSON value held by this object.
/*!
This data member contains the JSON data types defined by the
JSON syntax with the exception of the complex objects.
This data member is an union of the primitive types
so that it is simplier to cast them in other compatible types.
*/
wxJSONValueHolder m_value;
//! The JSON string value.
wxString m_valString;
//! The JSON array value.
wxJSONInternalArray m_valArray;
//! The JSON object value.
wxJSONInternalMap m_valMap;
//! The position of the comment line(s), if any.
/*!
The data member contains one of the following constants:
\li \c wxJSONVALUE_COMMENT_BEFORE
\li \c wxJSONVALUE_COMMENT_AFTER
\li \c wxJSONVALUE_COMMENT_INLINE
*/
int m_commentPos;
//! The array of comment lines; may be empty.
wxArrayString m_comments;
//! The line number when this value was read
/*!
This data member is used by the wxJSONReader class and it is
used to store the line number of the JSON text document where
the value appeared. This value is compared to the line number
of a comment line in order to obtain the value which a
comment refersto.
*/
int m_lineNo;
//! The pointer to the memory buffer object
/*!
Note that despite using reference counting, the \b wxMemoryBuffer is not a
\e copy-on-write structure so the wxJSON library uses some tricks in order to
avoid the side effects of copying / assigning wxMemoryBuffer objects
*/
wxMemoryBuffer* m_memBuff;
// used for debugging purposes: only in debug builds.
#if defined( WXJSON_USE_VALUE_COUNTER )
int m_progr;
static int sm_progr;
#endif
};
#endif // not defined _WX_JSONVAL_H

View file

@ -0,0 +1,121 @@
/////////////////////////////////////////////////////////////////////////////
// Name: jsonwriter.h
// Purpose: the generator of JSON text from a JSON value
// Author: Luciano Cattani
// Created: 2007/09/15
// RCS-ID: $Id: jsonwriter.h,v 1.4 2008/03/03 19:05:45 luccat Exp $
// Copyright: (c) 2007 Luciano Cattani
// Licence: wxWidgets licence
/////////////////////////////////////////////////////////////////////////////
#include "pgAdmin3.h"
#if !defined( _WX_JSONWRITER_H )
#define _WX_JSONWRITER_H
#ifdef __GNUG__
#pragma interface "jsonwriter.h"
#endif
// For compilers that support precompilation, includes "wx/wx.h".
#ifdef __BORLANDC__
#pragma hdrstop
#endif
// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWidgets headers)
#ifndef WX_PRECOMP
#include <wx/stream.h>
#include <wx/string.h>
#endif
#include "utils/json/json_defs.h"
#include "utils/json/jsonval.h"
enum {
wxJSONWRITER_NONE = 0,
wxJSONWRITER_STYLED = 1,
wxJSONWRITER_WRITE_COMMENTS = 2,
wxJSONWRITER_COMMENTS_BEFORE = 4,
wxJSONWRITER_COMMENTS_AFTER = 8,
wxJSONWRITER_SPLIT_STRING = 16,
wxJSONWRITER_NO_LINEFEEDS = 32,
wxJSONWRITER_ESCAPE_SOLIDUS = 64,
wxJSONWRITER_MULTILINE_STRING = 128,
wxJSONWRITER_RECOGNIZE_UNSIGNED = 256,
wxJSONWRITER_TAB_INDENT = 512,
wxJSONWRITER_NO_INDENTATION = 1024,
wxJSONWRITER_NOUTF8_STREAM = 2048,
wxJSONWRITER_MEMORYBUFF = 4096
};
// class declaration
class WXDLLIMPEXP_JSON wxJSONWriter
{
public:
wxJSONWriter(int style = wxJSONWRITER_STYLED, int indent = 0, int step = 3);
~wxJSONWriter();
void Write(const wxJSONValue& value, wxString& str);
void Write(const wxJSONValue& value, wxOutputStream& os);
void SetDoubleFmtString(const char* fmt);
protected:
int DoWrite(wxOutputStream& os, const wxJSONValue& value, const wxString* key, bool comma);
int WriteIndent(wxOutputStream& os);
int WriteIndent(wxOutputStream& os, int num);
bool IsSpace(wxChar ch);
bool IsPunctuation(wxChar ch);
int WriteString(wxOutputStream& os, const wxString& str);
int WriteStringValue(wxOutputStream& os, const wxString& str);
int WriteNullValue(wxOutputStream& os);
int WriteIntValue(wxOutputStream& os, const wxJSONValue& v);
int WriteUIntValue(wxOutputStream& os, const wxJSONValue& v);
int WriteBoolValue(wxOutputStream& os, const wxJSONValue& v);
int WriteDoubleValue(wxOutputStream& os, const wxJSONValue& v);
int WriteMemoryBuff(wxOutputStream& os, const wxMemoryBuffer& buff);
int WriteInvalid(wxOutputStream& os);
int WriteSeparator(wxOutputStream& os);
int WriteKey(wxOutputStream& os, const wxString& key);
int WriteComment(wxOutputStream& os, const wxJSONValue& value, bool indent);
int WriteError(const wxString& err);
private:
//! The style flag is a combination of wxJSONWRITER_(something) constants.
int m_style;
//! The initial indentation value, in number of spaces.
int m_indent;
//! The indentation increment, in number of spaces.
int m_step;
//! JSON value objects can be nested; this is the level of annidation (used internally).
int m_level;
// The line number when printing JSON text output (not yet used)
int m_lineNo;
// The column number when printing JSON text output
int m_colNo;
// Flag used in ANSI mode that controls UTF-8 conversion
bool m_noUtf8;
// The format string for printing doubles
char* m_fmt;
};
#endif // not defined _WX_JSONWRITER_H