diff --git a/cmake/PluginConfigure.cmake b/cmake/PluginConfigure.cmake index 8d584ef3..90bcb37b 100644 --- a/cmake/PluginConfigure.cmake +++ b/cmake/PluginConfigure.cmake @@ -85,6 +85,7 @@ ENDIF(DEFINED _wx_selected_config) MESSAGE (STATUS "*** Staging to build ${PACKAGE_NAME} ***") include ("VERSION.cmake") +configure_file(${PROJECT_SOURCE_DIR}/cmake/wxWTranslateCatalog.h.in ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include/wxWTranslateCatalog.h) # Do the version.h configuration into the build output directory, # thereby allowing building from a read-only source tree. @@ -95,7 +96,7 @@ ENDIF(NOT SKIP_VERSION_CONFIG) SET(PLUGIN_VERSION "${PLUGIN_VERSION_MAJOR}.${PLUGIN_VERSION_MINOR}.${PLUGIN_VERSION_PATCH}" ) -INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/src) +INCLUDE_DIRECTORIES(BEFORE ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/src) # SET(PROFILING 1) @@ -276,13 +277,6 @@ IF(NOT WIN32) ENDIF(NOT WIN32) - -# Add some definitions to satisfy MS -IF(WIN32) - ADD_DEFINITIONS(-D__MSVC__) - ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE) -ENDIF(WIN32) - # Let cmake find additional modules private LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) diff --git a/cmake/PluginGL.cmake b/cmake/PluginGL.cmake index 8ccdfc5a..3519ec15 100644 --- a/cmake/PluginGL.cmake +++ b/cmake/PluginGL.cmake @@ -11,5 +11,5 @@ SET(SRC_PLUGINGL src/plugingl/qtstylesheet.cpp ) -ADD_LIBRARY(LIB_PLUGINGL STATIC ${SRC_PLUGINGL}) -TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} LIB_PLUGINGL ) +ADD_LIBRARY(${PACKAGE_NAME}_LIB_PLUGINGL STATIC ${SRC_PLUGINGL}) +TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} ${PACKAGE_NAME}_LIB_PLUGINGL ) diff --git a/cmake/PluginJSON.cmake b/cmake/PluginJSON.cmake index 50a8eaed..e2865f71 100755 --- a/cmake/PluginJSON.cmake +++ b/cmake/PluginJSON.cmake @@ -17,5 +17,5 @@ ENDIF(QT_ANDROID) INCLUDE_DIRECTORIES(${PLUGIN_SOURCE_DIR}/src/jsoncpp) -ADD_LIBRARY(LIB_PLUGINJSON STATIC ${SRC_JSON}) -TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} LIB_PLUGINJSON ) +ADD_LIBRARY(${PACKAGE_NAME}_LIB_PLUGINJSON STATIC ${SRC_JSON}) +TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} ${PACKAGE_NAME}_LIB_PLUGINJSON ) diff --git a/cmake/PluginNMEA.cmake b/cmake/PluginNMEA.cmake index d8ad5e49..2cd4923b 100755 --- a/cmake/PluginNMEA.cmake +++ b/cmake/PluginNMEA.cmake @@ -42,5 +42,5 @@ SET(SRC_NMEA0183 INCLUDE_DIRECTORIES(src/nmea0183) -ADD_LIBRARY(LIB_PLUGINNMEA0183 STATIC ${SRC_NMEA0183}) -TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} LIB_PLUGINNMEA0183 ) +ADD_LIBRARY(${PACKAGE_NAME}_LIB_PLUGINNMEA0183 STATIC ${SRC_NMEA0183}) +TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} ${PACKAGE_NAME}_LIB_PLUGINNMEA0183 ) diff --git a/cmake/PluginXML.cmake b/cmake/PluginXML.cmake index b5b7c1c4..a969803c 100644 --- a/cmake/PluginXML.cmake +++ b/cmake/PluginXML.cmake @@ -11,8 +11,8 @@ SET(SRC_TINYXML src/tinyxml/tinyxmlparser.cpp src/tinyxml/tinyxmlerror.cpp ) -ADD_LIBRARY(LIB_PLUGINXML STATIC ${SRC_TINYXML}) -TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} LIB_PLUGINXML ) +ADD_LIBRARY(${PACKAGE_NAME}_LIB_PLUGINXML STATIC ${SRC_TINYXML}) +TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} ${PACKAGE_NAME}_LIB_PLUGINXML ) ENDIF(WIN32) ADD_DEFINITIONS(-DTIXML_USE_STL) diff --git a/include/GL/gl.h b/include/GL/gl.h index ce5e90e8..05c09a32 100644 --- a/include/GL/gl.h +++ b/include/GL/gl.h @@ -86,7 +86,7 @@ #if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) \ && !defined(OPENSTEP) && !defined(__CYGWIN__) || defined(__MINGW32__) -#include +// #include #endif #if defined(macintosh) && PRAGMA_IMPORT_SUPPORTED diff --git a/src/RouteMap.cpp b/src/RouteMap.cpp index f7a71144..7a11364a 100644 --- a/src/RouteMap.cpp +++ b/src/RouteMap.cpp @@ -80,8 +80,6 @@ #include "weather_routing_pi.h" #include "georef.h" -#include "wx/jsonreader.h" -#include "wx/jsonwriter.h" #define distance(X, Y) sqrt((X)*(X) + (Y)*(Y)) // much faster than hypot @@ -1376,10 +1374,10 @@ void IsoRoute::FindIsoRouteBounds(double bounds[4]) SkipPosition *s = skippoints->next; while(s != skippoints) { p = s->point; - bounds[MINLAT] = MIN(p->lat, bounds[MINLAT]); - bounds[MAXLAT] = MAX(p->lat, bounds[MAXLAT]); - bounds[MINLON] = MIN(p->lon, bounds[MINLON]); - bounds[MAXLON] = MAX(p->lon, bounds[MAXLON]); + bounds[MINLAT] = wxMin(p->lat, bounds[MINLAT]); + bounds[MAXLAT] = wxMax(p->lat, bounds[MAXLAT]); + bounds[MINLON] = wxMin(p->lon, bounds[MINLON]); + bounds[MAXLON] = wxMax(p->lon, bounds[MAXLON]); if(p->lat == bounds[MAXLAT]) maxlat = s; diff --git a/src/RouteMapOverlay.cpp b/src/RouteMapOverlay.cpp index 47730fdd..b25bba57 100644 --- a/src/RouteMapOverlay.cpp +++ b/src/RouteMapOverlay.cpp @@ -28,9 +28,7 @@ #include "ocpn_plugin.h" #include "plugingl/pidc.h" -#include "wx/jsonreader.h" -#include "wx/jsonwriter.h" - +#include "json/json.h" #include "Utilities.h" #include "Boat.h" #include "RouteMapOverlay.h" @@ -1251,20 +1249,18 @@ void RouteMapOverlay::GetLLBounds(double &latmin, double &latmax, double &lonmin void RouteMapOverlay::RequestGrib(wxDateTime time) { - wxJSONValue v; + Json::Value v; time = time.FromUTC(); - v[_T("Day")] = time.GetDay(); - v[_T("Month")] = time.GetMonth(); - v[_T("Year")] = time.GetYear(); - v[_T("Hour")] = time.GetHour(); - v[_T("Minute")] = time.GetMinute(); - v[_T("Second")] = time.GetSecond(); + v["Day"] = time.GetDay(); + v["Month"] = time.GetMonth(); + v["Year"] = time.GetYear(); + v["Hour"] = time.GetHour(); + v["Minute"] = time.GetMinute(); + v["Second"] = time.GetSecond(); - wxJSONWriter w; - wxString out; - w.Write(v, out); + Json::FastWriter w; - SendPluginMessage(wxString(_T("GRIB_TIMELINE_RECORD_REQUEST")), out); + SendPluginMessage("GRIB_TIMELINE_RECORD_REQUEST", w.write(v)); Lock(); m_bNeedsGrib = false; diff --git a/src/plugingl/pidc.h b/src/plugingl/pidc.h index ab9ea6af..58eb49a0 100644 --- a/src/plugingl/pidc.h +++ b/src/plugingl/pidc.h @@ -45,6 +45,18 @@ //class ViewPort; class GLUtesselator; +#ifndef DECL_EXP +#ifdef __WXMSW__ +# define DECL_EXP __declspec(dllexport) +#else +# ifdef __GNUC__ +# define DECL_EXP __attribute__((visibility("default"))) +#else +# define DECL_EXP +# endif +#endif +#endif + void DrawGLThickLine( float x1, float y1, float x2, float y2, wxPen pen, bool b_hiqual ); //---------------------------------------------------------------------------- diff --git a/src/weather_routing_pi.cpp b/src/weather_routing_pi.cpp index 2c357108..8cb95c23 100644 --- a/src/weather_routing_pi.cpp +++ b/src/weather_routing_pi.cpp @@ -46,27 +46,25 @@ #define CLIMATOLOGY_MIN_MAJOR 0 #define CLIMATOLOGY_MIN_MINOR 10 -static wxJSONValue g_ReceivedODVersionJSONMsg; +static Json::Value g_ReceivedODVersionJSONMsg; static bool ODVersionNewerThan(int major, int minor, int patch) { - wxJSONValue jMsg; - wxJSONWriter writer; - wxString MsgString; - jMsg[wxS("Source")] = wxS("WEATHER_ROUTING_PI"); - jMsg[wxT("Type")] = wxT("Request"); - jMsg[wxT("Msg")] = wxS("Version"); - jMsg[wxT("MsgId")] = wxS("version"); - writer.Write( jMsg, MsgString ); - SendPluginMessage( wxS("OCPN_DRAW_PI"), MsgString ); - - if(g_ReceivedODVersionJSONMsg.Size() <= 0) + Json::Value jMsg; + Json::FastWriter writer; + jMsg["Source"] = "WEATHER_ROUTING_PI"; + jMsg["Type"] = "Request"; + jMsg["Msg"] = "Version"; + jMsg["MsgId"] = "version"; + SendPluginMessage( wxS("OCPN_DRAW_PI"), writer.write( jMsg ) ); + + if(g_ReceivedODVersionJSONMsg.size() <= 0) return false; - if(g_ReceivedODVersionJSONMsg[wxS("Major")].AsInt() > major) return true; - if(g_ReceivedODVersionJSONMsg[wxS("Major")].AsInt() == major && - g_ReceivedODVersionJSONMsg[wxS("Minor")].AsInt() > minor) return true; - if(g_ReceivedODVersionJSONMsg[wxS("Major")].AsInt() == major && - g_ReceivedODVersionJSONMsg[wxS("Minor")].AsInt() == minor && - g_ReceivedODVersionJSONMsg[wxS("Patch")].AsInt() >= patch) return true; + if(g_ReceivedODVersionJSONMsg["Major"].asInt() > major) return true; + if(g_ReceivedODVersionJSONMsg["Major"].asInt() == major && + g_ReceivedODVersionJSONMsg["Minor"].asInt() > minor) return true; + if(g_ReceivedODVersionJSONMsg["Major"].asInt() == major && + g_ReceivedODVersionJSONMsg["Minor"].asInt() == minor && + g_ReceivedODVersionJSONMsg["Patch"].asInt() >= patch) return true; return false; } @@ -216,16 +214,16 @@ void weather_routing_pi::SetPluginMessage(wxString &message_id, wxString &messag { if(message_id == _T("GRIB_TIMELINE")) { - wxJSONReader r; - wxJSONValue v; - r.Parse(message_body, &v); + Json::Reader r; + Json::Value v; + r.parse(static_cast(message_body), v); - if (v[_T("Day")].AsInt() != -1) { + if (v["Day"].asInt() != -1) { wxDateTime time; time.Set - (v[_T("Day")].AsInt(), (wxDateTime::Month)v[_T("Month")].AsInt(), v[_T("Year")].AsInt(), - v[_T("Hour")].AsInt(), v[_T("Minute")].AsInt(), v[_T("Second")].AsInt()); + (v["Day"].asInt(), (wxDateTime::Month)v["Month"].asInt(), v["Year"].asInt(), + v["Hour"].asInt(), v["Minute"].asInt(), v["Second"].asInt()); if (m_pWeather_Routing && time.IsValid()) { m_pWeather_Routing->m_ConfigurationDialog.m_GribTimelineTime = time.ToUTC(); @@ -236,16 +234,16 @@ void weather_routing_pi::SetPluginMessage(wxString &message_id, wxString &messag } if(message_id == _T("GRIB_TIMELINE_RECORD")) { - wxJSONReader r; - wxJSONValue v; - r.Parse(message_body, &v); + Json::Reader r; + Json::Value v; + r.parse(static_cast(message_body), v); static bool shown_warnings; if(!shown_warnings) { shown_warnings = true; - int grib_version_major = v[_T("GribVersionMajor")].AsInt(); - int grib_version_minor = v[_T("GribVersionMinor")].AsInt(); + int grib_version_major = v["GribVersionMajor"].asInt(); + int grib_version_minor = v["GribVersionMinor"].asInt(); int grib_version = 1000*grib_version_major + grib_version_minor; int grib_min = 1000*GRIB_MIN_MAJOR + GRIB_MIN_MINOR; @@ -261,7 +259,7 @@ void weather_routing_pi::SetPluginMessage(wxString &message_id, wxString &messag } } - wxString sptr = v[_T("TimelineSetPtr")].AsString(); + wxString sptr = v["TimelineSetPtr"].asString(); wxCharBuffer bptr = sptr.To8BitData(); const char* ptr = bptr.data(); @@ -282,16 +280,16 @@ void weather_routing_pi::SetPluginMessage(wxString &message_id, wxString &messag if(!m_pWeather_Routing) return; /* not ready */ - wxJSONReader r; - wxJSONValue v; - r.Parse(message_body, &v); + Json::Reader r; + Json::Value v; + r.parse(static_cast(message_body), v); static bool shown_warnings; if(!shown_warnings) { shown_warnings = true; - int climatology_version_major = v[_T("ClimatologyVersionMajor")].AsInt(); - int climatology_version_minor = v[_T("ClimatologyVersionMinor")].AsInt(); + int climatology_version_major = v["ClimatologyVersionMajor"].asInt(); + int climatology_version_minor = v["ClimatologyVersionMinor"].asInt(); int climatology_version = 1000*climatology_version_major + climatology_version_minor; int climatology_min = 1000*CLIMATOLOGY_MIN_MAJOR + CLIMATOLOGY_MIN_MINOR; @@ -308,13 +306,13 @@ void weather_routing_pi::SetPluginMessage(wxString &message_id, wxString &messag } } - wxString sptr = v[_T("ClimatologyDataPtr")].AsString(); + wxString sptr = v["ClimatologyDataPtr"].asString(); sscanf(sptr.To8BitData().data(), "%p", &RouteMap::ClimatologyData); - sptr = v[_T("ClimatologyWindAtlasDataPtr")].AsString(); + sptr = v["ClimatologyWindAtlasDataPtr"].asString(); sscanf(sptr.To8BitData().data(), "%p", &RouteMap::ClimatologyWindAtlasData); - sptr = v[_T("ClimatologyCycloneTrackCrossingsPtr")].AsString(); + sptr = v["ClimatologyCycloneTrackCrossingsPtr"].asString(); sscanf(sptr.To8BitData().data(), "%p", &RouteMap::ClimatologyCycloneTrackCrossings); if(m_pWeather_Routing) { @@ -327,34 +325,27 @@ void weather_routing_pi::SetPluginMessage(wxString &message_id, wxString &messag if(message_id == wxS("WEATHER_ROUTING_PI")) { - // construct the JSON root object - wxJSONValue root; - // construct a JSON parser - wxJSONReader reader; // now read the JSON text and store it in the 'root' structure + Json::Value root; + Json::Reader reader; // check for errors before retreiving values... - int numErrors = reader.Parse( message_body, &root ); - if ( numErrors > 0 ) { - wxLogMessage(_T("weather_routing_pi: Error parsing JSON message - ")); - const wxArrayString& errors = reader.GetErrors(); - for(int i = 0; i < (int)errors.GetCount(); i++) { - wxLogMessage( errors.Item( i ) ); - return; - } + if (!reader.parse( static_cast(message_body), root )) { + wxLogMessage(_T("weather_routing_pi: Error parsing JSON message - ") + +reader.getFormattedErrorMessages() + " : " + message_body ); } - if(root[wxS("Type")].AsString() == wxS("Response") && root[wxS("Source")].AsString() == wxS("OCPN_DRAW_PI")) { - if(root[wxS("Msg")].AsString() == wxS("Version") ) { - if(root[wxS("MsgId")].AsString() == wxS("version")) + if(root["Type"].asString() == "Response" && root["Source"].asString() == "OCPN_DRAW_PI") { + if(root["Msg"].asString() == "Version" ) { + if(root["MsgId"].asString() == "version") g_ReceivedODVersionJSONMsg = root; } else - if(root[wxS("Msg")].AsString() == wxS("GetAPIAddresses") ) { - wxString sptr = root[_T("OD_FindClosestBoundaryLineCrossing")].AsString(); + if(root["Msg"].asString() == "GetAPIAddresses" ) { + wxString sptr = root["OD_FindClosestBoundaryLineCrossing"].asString(); sscanf(sptr.To8BitData().data(), "%p", &RouteMap::ODFindClosestBoundaryLineCrossing); } - else if (root[wxS("Msg")].AsString() == wxS("FindPointInAnyBoundary") ) { - if (root[wxS("MsgId")].AsString() == wxS("exist")) { - b_in_boundary_reply = root[wxS("Found")].AsBool() == true; + else if (root["Msg"].asString() == "FindPointInAnyBoundary" ) { + if (root["MsgId"].asString() == "exist") { + b_in_boundary_reply = root["Found"].asBool() == true; // if (b_in_boundary_reply) printf("collision with %s\n", (const char*)root[wxS("GUID")].AsString().mb_str()); } } @@ -367,25 +358,23 @@ void weather_routing_pi::SetPluginMessage(wxString &message_id, wxString &messag // use JSON msg rather than binary it's not time sensitive. bool weather_routing_pi::InBoundary(double lat, double lon) { - wxJSONValue jMsg; - wxJSONWriter writer; - wxString MsgString; + Json::Value jMsg; + Json::FastWriter writer; - jMsg[wxS("Source")] = wxS("WEATHER_ROUTING_PI"); - jMsg[wxT("Type")] = wxT("Request"); + jMsg["Source"] = "WEATHER_ROUTING_PI"; + jMsg["Type"] = "Request"; - jMsg[wxT("Msg")] = wxS("FindPointInAnyBoundary"); - jMsg[wxT("MsgId")] = wxS("exist"); + jMsg["Msg"] = "FindPointInAnyBoundary"; + jMsg["MsgId"] = "exist"; - jMsg[wxS("lat")] = lat; - jMsg[wxS("lon")] = lon; + jMsg["lat"] = lat; + jMsg["lon"] = lon; - jMsg[wxS("BoundaryState")] = wxT("Active"); - jMsg[wxS("BoundaryType")] = wxT("Exclusion"); + jMsg["BoundaryState"] = "Active"; + jMsg["BoundaryType"] = "Exclusion"; - writer.Write( jMsg, MsgString ); b_in_boundary_reply = false; - SendPluginMessage( wxS("OCPN_DRAW_PI"), MsgString ); + SendPluginMessage( "OCPN_DRAW_PI", writer.write( jMsg ) ); return b_in_boundary_reply; } @@ -412,15 +401,14 @@ void weather_routing_pi::OnToolbarToolCallback(int id) SendPluginMessage(wxString(_T("CLIMATOLOGY_REQUEST")), _T("")); if(ODVersionNewerThan( 1, 1, 15)) { - wxJSONValue jMsg; - wxJSONWriter writer; - wxString MsgString; - jMsg[wxT("Source")] = wxT("WEATHER_ROUTING_PI"); - jMsg[wxT("Type")] = wxT("Request"); - jMsg[wxT("Msg")] = wxS("GetAPIAddresses"); - jMsg[wxT("MsgId")] = wxS("GetAPIAddresses"); - writer.Write( jMsg, MsgString ); - SendPluginMessage( wxS("OCPN_DRAW_PI"), MsgString ); + Json::Value jMsg; + Json::FastWriter writer; + + jMsg["Source"] = "WEATHER_ROUTING_PI"; + jMsg["Type"] = "Request"; + jMsg["Msg"] = "GetAPIAddresses"; + jMsg["MsgId"] = "GetAPIAddresses"; + SendPluginMessage( wxS("OCPN_DRAW_PI"), writer.write( jMsg) ); } m_pWeather_Routing->Reset(); @@ -440,10 +428,10 @@ void weather_routing_pi::OnContextMenuItemCallback(int id) m_pWeather_Routing->Reset(); } -bool weather_routing_pi::RenderOverlay(wxDC &dc, PlugIn_ViewPort *vp) +bool weather_routing_pi::RenderOverlay(wxDC &wxdc, PlugIn_ViewPort *vp) { if(m_pWeather_Routing && m_pWeather_Routing->IsShown()) { - piDC dc(dc); + piDC dc(wxdc); m_pWeather_Routing->Render(dc, *vp); return true; } @@ -523,10 +511,15 @@ wxString weather_routing_pi::StandardPath() #ifdef __WXOSX__ // Compatibility with pre-OCPN-4.2; move config dir to // ~/Library/Preferences/opencpn if it exists - wxString oldPath = (std_path.GetUserConfigDir() + s + _T("plugins") + s + _T("weather_routing")); - if (wxDirExists(oldPath) && !wxDirExists(stdPath)) { - wxLogMessage("weather_routing_pi: moving config dir %s to %s", oldPath, stdPath); - wxRenameFile(oldPath, stdPath); + { + wxStandardPathsBase& std_path = wxStandardPathsBase::Get(); + wxString s = wxFileName::GetPathSeparator(); + // should be ~/Library/Preferences/opencpn + wxString oldPath = (std_path.GetUserConfigDir() +s + _T("plugins") +s + _T("weather_routing")); + if (wxDirExists(oldPath) && !wxDirExists(stdPath)) { + wxLogMessage("weather_routing_pi: moving config dir %s to %s", oldPath, stdPath); + wxRenameFile(oldPath, stdPath); + } } #endif diff --git a/src/weather_routing_pi.h b/src/weather_routing_pi.h index 93d52b7e..7b1b706d 100644 --- a/src/weather_routing_pi.h +++ b/src/weather_routing_pi.h @@ -77,8 +77,7 @@ std::cout << x << std::endl; } while (0) #undef MAX #endif -#include "wx/jsonreader.h" -#include "wx/jsonwriter.h" +#include "json/json.h" //---------------------------------------------------------------------------------------------------------- // The PlugIn Class Definition diff --git a/src/wx/json_defs.h b/src/wx/json_defs.h deleted file mode 100644 index 0fc98482..00000000 --- a/src/wx/json_defs.h +++ /dev/null @@ -1,219 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// 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(WXUSINGDLL) - #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 - -//dsr -#undef WXDLLIMPEXP_JSON -#undef WXDLLIMPEXP_DATA_JSON - - #define WXDLLIMPEXP_JSON - #define WXDLLIMPEXP_DATA_JSON(type) type - -//dsr - - -// 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_ - - diff --git a/src/wx/jsonreader.h b/src/wx/jsonreader.h deleted file mode 100644 index 83f77985..00000000 --- a/src/wx/jsonreader.h +++ /dev/null @@ -1,150 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// 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 -///////////////////////////////////////////////////////////////////////////// - -#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". -#include "wx/wxprec.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 - #include - #include -#endif - - -#include "json_defs.h" -#include "jsonval.h" - -// 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 - - diff --git a/src/wx/jsonval.h b/src/wx/jsonval.h deleted file mode 100644 index 511719a7..00000000 --- a/src/wx/jsonval.h +++ /dev/null @@ -1,441 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// 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". -#include "wx/wxprec.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 - #include - #include - #include -#endif - - -#include "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 - - diff --git a/src/wx/jsonwriter.h b/src/wx/jsonwriter.h deleted file mode 100644 index 1cbda96d..00000000 --- a/src/wx/jsonwriter.h +++ /dev/null @@ -1,119 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// 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 -///////////////////////////////////////////////////////////////////////////// - -#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". -#include "wx/wxprec.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 - #include -#endif - -#include "json_defs.h" -#include "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 - - - diff --git a/src/zuFile.cpp b/src/zuFile.cpp index 03cdbc4c..6cf46aff 100644 --- a/src/zuFile.cpp +++ b/src/zuFile.cpp @@ -107,6 +107,7 @@ ZUFILE * zu_open(const char *fname, const char *mode, int type) } if (f->zfile == NULL) { + free(f->fname); free(f); f = NULL; }