mirror of
https://github.com/levinsv/pgadmin3.git
synced 2026-09-02 14:23:05 -06:00
Support GitLab experimental
Добавлена возможность сохранять SQL представления объектов в GitLab Описание в Readme.MD
This commit is contained in:
parent
535538c6d9
commit
4f10ebc477
15 changed files with 9509 additions and 0 deletions
43
README.md
43
README.md
|
|
@ -220,3 +220,46 @@ English version issue #18
|
|||
- поддержка списка колонок при задании FK
|
||||
- поддержка NULLS NOT DISTINCT для уникальных индексов
|
||||
|
||||
24.11.2022
|
||||
Добавлена эксперементальная функция работы с gitLab.
|
||||
Для работы с gitlab необходимо положить файл gitlab.json в каталог %APPDATA%\postgresql.
|
||||
Вот пример содержимого файла:
|
||||
{
|
||||
"url": "https://gl.mympany.ru:4443/api/v4/",
|
||||
"private_token": "V3JYpw2x5rr61yGe_M2e",
|
||||
"project_id": "532"
|
||||
}
|
||||
После запуска pgAdmin3 появится вкладка Git на которой будут дополнительные закладки.
|
||||
Пока для работы с GitLab можно выполнять только коммиты на дополнительной вкладке Commit.
|
||||
В GitLab сохраняются только содержимое объектов схем. Сохраняется только SQL представления.
|
||||
Алгоритм работы такой:
|
||||
- из файл gitlab.json берётся информация для соединения с gitLab
|
||||
- из ветки по умолчанию (обычно это main) считывается файл pgadmin3.json с общими настройки.
|
||||
- если такого файла не то настройки беруться из gitlab.json
|
||||
- вот пример настроек из pgadmin3.json
|
||||
{
|
||||
"ignore_schema": ["public","repack","schedule"],
|
||||
"control_objects": ["Functions","Views","Tables","Trigger Functions","Procedures","Schemas","Schema","Database"],
|
||||
"maps_branch_to_dbname":[
|
||||
{"branch": "asu",
|
||||
"list_db": ["asu"]
|
||||
}
|
||||
,
|
||||
{"branch": "common_db",
|
||||
"list_db": ["dbname1","dbname2"]
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
Где:
|
||||
"ignore_schema" - список схем которые не нужно сохранять и git
|
||||
"control_objects" - перечень типов объектов схемы которые нужно сохранять.
|
||||
"maps_branch_to_dbname" - сопостовление имен веток и имен БД.
|
||||
- нажимается кнопка "Load Git" и загружается SQL предствления объектов из GitLab
|
||||
После этой операции список "List commit files" будет заполнен расхождениями текущей БД и веткой в GitLab
|
||||
- Если выбрать несколько элементов (или все нажав Ctrl+A) то указав название коммита и нажав на
|
||||
кнопку "commit" можно закомитить текущее SQL представление выбранных элементов в GitLab
|
||||
- нажатие правой кнопки мыши на каком либо элементе списка покажет различия между объектов в БД и GitLab.
|
||||
Все прочие кнопки и закладки использовать не нужно.
|
||||
Типовой способ использования, ведение историй изменений объектов БД в GitLab.
|
||||
|
||||
|
|
|
|||
1418
ctl/ctlGitPanel.cpp
Normal file
1418
ctl/ctlGitPanel.cpp
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -171,6 +171,9 @@ frmMain::frmMain(const wxString &title)
|
|||
statistics = new ctlListView(listViews, CTL_STATVIEW, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER);
|
||||
dependencies = new ctlListView(listViews, CTL_DEPVIEW, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER);
|
||||
dependents = new ctlListView(listViews, CTL_REFVIEW, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER);
|
||||
git = NULL;
|
||||
wxJSONValue cfg=ctlGitPanel::GetConfig();
|
||||
if (!cfg.IsNull()) git = new ctlGitPanel(listViews, this,cfg);
|
||||
|
||||
|
||||
|
||||
|
|
@ -183,6 +186,9 @@ frmMain::frmMain(const wxString &title)
|
|||
listViews->AddPage(statistics, _("Statistics")); // NBP_STATISTICS
|
||||
listViews->AddPage(dependencies, _("Dependencies")); // NBP_DEPENDENCIES
|
||||
listViews->AddPage(dependents, _("Dependents")); // NBP_DEPENDENTS
|
||||
if (git) {
|
||||
listViews->AddPage(git, _("Git")); //
|
||||
}
|
||||
|
||||
properties->SetImageList(imageList, wxIMAGE_LIST_SMALL);
|
||||
statistics->SetImageList(imageList, wxIMAGE_LIST_SMALL);
|
||||
|
|
@ -817,6 +823,12 @@ void frmMain::ShowObjStatistics(pgObject *data, wxWindow *ctrl)
|
|||
data->ShowDependents(this, dependents);
|
||||
dependents->Thaw();
|
||||
}
|
||||
if ((!ctrl && git && git->IsShownOnScreen()) || ctrl == git)
|
||||
{
|
||||
|
||||
//data->ShowDependents(this, dependents);
|
||||
if (git && data) git->ShowPage(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
111
include/ctl/ctlGitPanel.h
Normal file
111
include/ctl/ctlGitPanel.h
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef _WX_ctlGitPanel_H_
|
||||
#define _WX_ctlGitPanel_H_
|
||||
#include "wx/wx.h"
|
||||
#include "wx/notebook.h"
|
||||
#include "wx/artprov.h"
|
||||
#include "wx/creddlg.h"
|
||||
#include "wx/webrequest.h"
|
||||
#include "wx/filedlg.h"
|
||||
#include "wx/image.h"
|
||||
#include "utils/json/jsonval.h"
|
||||
#include <wx/hyperlink.h>
|
||||
#include "images/ddAddColumn.pngc"
|
||||
#include "images/ddRemoveColumn.pngc"
|
||||
#include "images/conversion.pngc"
|
||||
|
||||
|
||||
class ctlGitPanel : public wxPanel
|
||||
{
|
||||
public:
|
||||
enum Pages
|
||||
{
|
||||
Page_Image,
|
||||
Page_Text,
|
||||
Page_Download,
|
||||
Page_Advanced
|
||||
};
|
||||
enum Files
|
||||
{
|
||||
Add_File,
|
||||
Remove_File,
|
||||
Update_File
|
||||
};
|
||||
|
||||
ctlGitPanel(wxWindow* parent, frmMain* form,wxJSONValue cf);
|
||||
~ctlGitPanel();
|
||||
void ShowPage(pgObject* data);
|
||||
void getFileRepository(pgObject* data);
|
||||
wxJSONValue execRequest(wxString url, wxJSONValue args, wxString cmd);
|
||||
//wxJSONValue setComonnArgs();
|
||||
void GetBranchList(bool refresh);
|
||||
void GetRepositoryTree(wxString branchName,wxString path,wxString typeElement,wxString value);
|
||||
wxString GetRepositoryFile(wxString branchName, wxString path);
|
||||
wxString getCurBranch(wxString dbname);
|
||||
bool CheckValidObject(pgObject *o);
|
||||
void CommandBranch(wxString branchName, wxString cmd);
|
||||
bool ApplyCommit(wxString branchName, wxJSONValue params);
|
||||
wxString ArgsForGet(wxJSONValue r);
|
||||
int ReplaceItem(wxString path, int image);
|
||||
static wxJSONValue GetConfig();
|
||||
void OnBranchListButton(wxCommandEvent& WXUNUSED(evt)) {
|
||||
GetBranchList(true);
|
||||
};
|
||||
void GetExpandedChildNodes(wxTreeItemId node, wxArrayString& expandedNodes, wxString pat, int lvl);
|
||||
void OnBranchDeleteButton(wxCommandEvent& WXUNUSED(evt)) {};
|
||||
|
||||
void OnListRClick(wxListEvent& evt);
|
||||
void OnLoadGitButton(wxCommandEvent& WXUNUSED(evt));
|
||||
void OnCommitButton(wxCommandEvent& WXUNUSED(evt));
|
||||
void OnCancelButton(wxCommandEvent& WXUNUSED(evt));
|
||||
void OnKEY_UP(wxKeyEvent& event);
|
||||
void OnProgressTimer(wxTimerEvent& WXUNUSED(evt));
|
||||
void OnPostCheckBox(wxCommandEvent& WXUNUSED(evt));
|
||||
void OnNotebookPageChanged(wxBookCtrlEvent& event);
|
||||
void OnClose(wxCloseEvent& event);
|
||||
|
||||
|
||||
private:
|
||||
frmMain* formMain;
|
||||
wxJSONValue cfg;
|
||||
wxString currentDBname;
|
||||
wxString syncDBname;
|
||||
wxTreeItemId nodeDB;
|
||||
wxStringToStringHashMap m_git_content,m_base_content;
|
||||
wxStringToStringHashMap m_treeName,m_base_tree;
|
||||
wxString response_link,error_msg;
|
||||
int m_count_git, m_count_db;
|
||||
wxListView* m_commit_List_View;
|
||||
|
||||
wxComboBox* m_Branch_List_Ctrl;
|
||||
wxButton *m_branchDeleteButton, *m_branchListButton, *m_commitButton;
|
||||
wxHyperlinkCtrl* m_link;
|
||||
wxNotebook* m_notebook;
|
||||
wxTextCtrl* m_urlTextCtrl;
|
||||
wxButton* m_startButton;
|
||||
wxButton* m_cancelButton;
|
||||
wxStaticBitmap* m_imageStaticBitmap;
|
||||
wxWebRequest m_currentRequest;
|
||||
|
||||
wxCheckBox* m_postCheckBox;
|
||||
wxTextCtrl* m_postContentTypeTextCtrl;
|
||||
wxTextCtrl* m_postRequestTextCtrl;
|
||||
wxTextCtrl* m_textResponseTextCtrl;
|
||||
wxTextCtrl* m_CommentTextCtrl;
|
||||
wxGauge* m_downloadGauge;
|
||||
wxStaticText* m_downloadStaticText;
|
||||
wxTimer m_downloadProgressTimer;
|
||||
|
||||
wxStaticText* m_advCountStaticText;
|
||||
wxLongLong m_advCount;
|
||||
|
||||
// Normally it would be a bad idea to permanently store credentials like
|
||||
// this, we should use wxSecretStore to load them as needed, but let's keep
|
||||
// things simple in this example.
|
||||
wxWebCredentials m_credentials;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -25,6 +25,7 @@
|
|||
#include "dlg/dlgClasses.h"
|
||||
#include "utils/factory.h"
|
||||
#include "frm/frmLog.h"
|
||||
#include "ctl/ctlGitPanel.h"
|
||||
|
||||
//
|
||||
// This number MUST be incremented if changing any of the default perspectives
|
||||
|
|
@ -206,6 +207,7 @@ private:
|
|||
ctlListView *properties;
|
||||
ctlListView *statistics;
|
||||
ctlListView *dependents, *dependencies;
|
||||
ctlGitPanel* git;
|
||||
ctlAuiNotebook *listViews;
|
||||
ctlSQLBox *sqlPane;
|
||||
wxMenu *newMenu, *debuggingMenu, *reportMenu, *toolsMenu, *pluginsMenu, *viewMenu,
|
||||
|
|
|
|||
|
|
@ -247,5 +247,8 @@
|
|||
#include "utils/sysProcess.h"
|
||||
#include "utils/sysSettings.h"
|
||||
#include "utils/utffile.h"
|
||||
#include "utils/json/jsonval.h"
|
||||
#include "utils/json/jsonreader.h"
|
||||
#include "utils/json/jsonwriter.h"
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
209
include/utils/json/json_defs.h
Normal file
209
include/utils/json/json_defs.h
Normal 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_
|
||||
|
||||
|
||||
148
include/utils/json/jsonreader.h
Normal file
148
include/utils/json/jsonreader.h
Normal 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
|
||||
|
||||
|
||||
440
include/utils/json/jsonval.h
Normal file
440
include/utils/json/jsonval.h
Normal 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
|
||||
|
||||
|
||||
121
include/utils/json/jsonwriter.h
Normal file
121
include/utils/json/jsonwriter.h
Normal 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
|
||||
|
||||
|
||||
|
||||
|
|
@ -745,6 +745,7 @@
|
|||
<ClCompile Include="ctl\ctlColourPicker.cpp" />
|
||||
<ClCompile Include="ctl\ctlComboBox.cpp" />
|
||||
<ClCompile Include="ctl\ctlDefaultSecurityPanel.cpp" />
|
||||
<ClCompile Include="ctl\ctlGitPanel.cpp" />
|
||||
<ClCompile Include="ctl\ctlListView.cpp" />
|
||||
<ClCompile Include="ctl\ctlMenuToolbar.cpp" />
|
||||
<ClCompile Include="ctl\ctlSeclabelPanel.cpp" />
|
||||
|
|
@ -1021,6 +1022,9 @@
|
|||
</ClCompile>
|
||||
<ClCompile Include="utils\factory.cpp" />
|
||||
<ClCompile Include="utils\favourites.cpp" />
|
||||
<ClCompile Include="utils\json\jsonreader.cpp" />
|
||||
<ClCompile Include="utils\json\jsonval.cpp" />
|
||||
<ClCompile Include="utils\json\jsonwriter.cpp" />
|
||||
<ClCompile Include="utils\log\MyDataViewCtrl.cpp" />
|
||||
<ClCompile Include="utils\log\Storage.cpp" />
|
||||
<ClCompile Include="utils\log\StorageModel.cpp" />
|
||||
|
|
@ -1548,6 +1552,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\copyright.h" />
|
||||
<ClInclude Include="include\ctl\ctlGitPanel.h" />
|
||||
<ClInclude Include="include\dlg\dlgProJob.h" />
|
||||
<ClInclude Include="include\dlg\dlgResourceGroup.h" />
|
||||
<ClInclude Include="include\frm\frmLog.h" />
|
||||
|
|
@ -1565,6 +1570,10 @@
|
|||
<ClInclude Include="include\schema\pgPublication.h" />
|
||||
<ClInclude Include="include\schema\pgSubscription.h" />
|
||||
<ClInclude Include="include\svnversion.h" />
|
||||
<ClInclude Include="include\utils\json\jsonreader.h" />
|
||||
<ClInclude Include="include\utils\json\jsonval.h" />
|
||||
<ClInclude Include="include\utils\json\jsonwriter.h" />
|
||||
<ClInclude Include="include\utils\json\json_defs.h" />
|
||||
<ClInclude Include="include\utils\sshTunnel.h" />
|
||||
<ClInclude Include="include\version.h" />
|
||||
<ClInclude Include="include\utils\csvfiles.h" />
|
||||
|
|
@ -2250,6 +2259,7 @@
|
|||
<png2c Include="include\images\serverbad-sm.png" />
|
||||
<png2c Include="include\images\serverbad.png" />
|
||||
<png2c Include="include\images\servers.png" />
|
||||
<png2c Include="include\images\server_status.png" />
|
||||
<png2c Include="include\images\setBreak.png" />
|
||||
<png2c Include="include\images\slcluster.png" />
|
||||
<png2c Include="include\images\slclusters.png" />
|
||||
|
|
|
|||
|
|
@ -1656,6 +1656,18 @@
|
|||
<ClCompile Include="frm\mathplot.cpp">
|
||||
<Filter>frm</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="utils\json\jsonval.cpp">
|
||||
<Filter>utils</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="utils\json\jsonreader.cpp">
|
||||
<Filter>utils</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="utils\json\jsonwriter.cpp">
|
||||
<Filter>utils</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ctl\ctlGitPanel.cpp">
|
||||
<Filter>ctl</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="agent\module.mk">
|
||||
|
|
@ -3560,6 +3572,21 @@
|
|||
<ClInclude Include="include\frm\mathplot.h">
|
||||
<Filter>include\frm</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\utils\json\json_defs.h">
|
||||
<Filter>include\utils</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\utils\json\jsonreader.h">
|
||||
<Filter>include\utils</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\utils\json\jsonwriter.h">
|
||||
<Filter>include\utils</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\utils\json\jsonval.h">
|
||||
<Filter>include\utils</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\ctl\ctlGitPanel.h">
|
||||
<Filter>include\ctl</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<png2c Include="include\images\aggregate-sm.png">
|
||||
|
|
@ -4513,6 +4540,9 @@
|
|||
<png2c Include="include\images\sortfilterclear.png">
|
||||
<Filter>include\images</Filter>
|
||||
</png2c>
|
||||
<png2c Include="include\images\server_status.png">
|
||||
<Filter>include\images</Filter>
|
||||
</png2c>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="pgAdmin3.rc" />
|
||||
|
|
|
|||
2131
utils/json/jsonreader.cpp
Normal file
2131
utils/json/jsonreader.cpp
Normal file
File diff suppressed because it is too large
Load diff
3555
utils/json/jsonval.cpp
Normal file
3555
utils/json/jsonval.cpp
Normal file
File diff suppressed because it is too large
Load diff
1276
utils/json/jsonwriter.cpp
Normal file
1276
utils/json/jsonwriter.cpp
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue