From f3bb2f3ba8a91653bd92c4c14b5be10126d563e3 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas <8551443+dudantas@users.noreply.github.com> Date: Sat, 25 Mar 2023 17:50:48 -0300 Subject: [PATCH 1/2] improve: remove boosts library and add json manual library Removed boosts (replaced with equivalent on std 14/17/20) Removed manual json library implementation using boost and added nlohmann-json So two additional libraries will be needed to compile: asio, nlohmann-json I also removed OTGZ support by default and disabled it, making it optional (needs to be enabled). Anyone who wants to use it will need to activate this, I think it's ideal since few should use it, so a majority don't use it, which is fairer that those who need to activate it to use it than those who don't need to have this in their program. --- .gitignore | 3 + CMakeLists.txt | 58 +- CMakeSettings.json | 16 + source/CMakeLists.txt | 5 - source/about_window.cpp | 14 +- source/action.cpp | 2 +- source/application.cpp | 11 + source/client_version.cpp | 32 +- source/client_version.h | 8 +- source/common.cpp | 10 + source/common.h | 1 + source/definitions.h | 3 +- source/doodad_brush.cpp | 18 +- source/filehandle.h | 6 +- source/iomap_otbm.cpp | 6 +- source/item_attributes.h | 2 - source/json.h | 27 - source/json/json_spirit.h | 18 - source/json/json_spirit_error_position.h | 56 -- source/json/json_spirit_reader.cpp | 137 ----- source/json/json_spirit_reader.h | 62 -- source/json/json_spirit_reader_template.h | 613 -------------------- source/json/json_spirit_stream_reader.h | 70 --- source/json/json_spirit_utils.h | 61 -- source/json/json_spirit_value.cpp | 8 - source/json/json_spirit_value.h | 532 ----------------- source/json/json_spirit_writer.cpp | 95 ---- source/json/json_spirit_writer.h | 50 -- source/json/json_spirit_writer_template.h | 243 -------- source/live_client.cpp | 40 +- source/live_client.h | 8 +- source/live_peer.cpp | 26 +- source/live_peer.h | 6 +- source/live_server.cpp | 12 +- source/live_server.h | 4 +- source/main.h | 26 +- source/net_connection.cpp | 6 +- source/net_connection.h | 4 +- source/otml.h | 74 ++- source/updater.cpp | 2 - vcproj/Project/RME.vcxproj | 32 +- vcproj/Project/RME.vcxproj.filters | 665 ---------------------- 42 files changed, 236 insertions(+), 2836 deletions(-) create mode 100644 CMakeSettings.json delete mode 100644 source/json.h delete mode 100644 source/json/json_spirit.h delete mode 100644 source/json/json_spirit_error_position.h delete mode 100644 source/json/json_spirit_reader.cpp delete mode 100644 source/json/json_spirit_reader.h delete mode 100644 source/json/json_spirit_reader_template.h delete mode 100644 source/json/json_spirit_stream_reader.h delete mode 100644 source/json/json_spirit_utils.h delete mode 100644 source/json/json_spirit_value.cpp delete mode 100644 source/json/json_spirit_value.h delete mode 100644 source/json/json_spirit_writer.cpp delete mode 100644 source/json/json_spirit_writer.h delete mode 100644 source/json/json_spirit_writer_template.h delete mode 100644 vcproj/Project/RME.vcxproj.filters diff --git a/.gitignore b/.gitignore index d2464f23..473f5610 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ data/user *.obj *.db *.opendb +*.vs vcproj/ipch/ vcproj/Beta Release/ @@ -38,6 +39,8 @@ vcproj/Installer/Beta Release/ vcproj/Installer/Debug/ vcproj/Installer/Release/ .vscode/ +*.filters +*.users # Xcode xcuserdata diff --git a/CMakeLists.txt b/CMakeLists.txt index 896b501a..5daaf7de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,35 +6,47 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE RelWithDebInfo) endif() -set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-unused-variable -Wno-deprecated-declarations -Wno-overloaded-virtual -Wno-strict-aliasing -Wno-sign-compare -Wno-unused-function -Wunused-result") -set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -D__DEBUG__") -set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG") -set(CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") - find_package(OpenGL REQUIRED) -if(APPLE) - set(CMAKE_PREFIX_PATH /usr/local/opt/libarchive) -endif() -find_package(LibArchive REQUIRED) +# LibArchive disabled in compilation level by default, see "#define OTGZ_SUPPORT" in the "definitions.h" file +#if(APPLE) +# set(CMAKE_PREFIX_PATH /usr/local/opt/libarchive) +#endif() +# If you need use, enable this: +#find_package(LibArchive REQUIRED) +#${LibArchive_INCLUDE_DIRS} ${LibArchive_LIBRARIES} -if(WIN32) - set(Boost_THREADAPI win32) -endif() -find_package(Boost 1.34.0 COMPONENTS thread system REQUIRED) - -find_package(wxWidgets COMPONENTS html aui gl adv core net base REQUIRED) +find_package(asio CONFIG REQUIRED) +find_package(Threads REQUIRED) +find_package(wxWidgets COMPONENTS html aui gl adv core net base CONFIG REQUIRED) find_package(GLUT REQUIRED) find_package(ZLIB REQUIRED) +find_package(fmt CONFIG REQUIRED) +find_package(nlohmann_json CONFIG REQUIRED) -include(${wxWidgets_USE_FILE}) include(source/CMakeLists.txt) -add_executable(rme ${rme_H} ${rme_SRC}) - -set_target_properties(rme PROPERTIES CXX_STANDARD 17) -set_target_properties(rme PROPERTIES CXX_STANDARD_REQUIRED ON) -include_directories(${Boost_INCLUDE_DIRS} ${LibArchive_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}) -target_link_libraries(rme ${wxWidgets_LIBRARIES} ${Boost_LIBRARIES} ${LibArchive_LIBRARIES} ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ${ZLIB_LIBRARIES}) +add_executable(${PROJECT_NAME} ${rme_H} ${rme_SRC}) + +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD_REQUIRED ON) + +# === PRECOMPILED HEADER === +target_precompile_headers(${PROJECT_NAME} PRIVATE source/main.h) + +include_directories( + ${OPENGL_INCLUDE_DIR} + ${GLUT_INCLUDE_DIRS} + ${ZLIB_INCLUDE_DIR} +) + +target_link_libraries(${PROJECT_NAME} + ${wxWidgets_LIBRARIES} + ${OPENGL_LIBRARIES} + ${GLUT_LIBRARIES} + ${ZLIB_LIBRARIES} + fmt::fmt + asio::asio + nlohmann_json::nlohmann_json +) diff --git a/CMakeSettings.json b/CMakeSettings.json new file mode 100644 index 00000000..f876ee21 --- /dev/null +++ b/CMakeSettings.json @@ -0,0 +1,16 @@ +{ + "configurations": [ + { + "name": "x64-Release", + "generator": "Ninja", + "configurationType": "RelWithDebInfo", + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "msvc_x64_x64" ], + "variables": [] + } + ] +} \ No newline at end of file diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 901f31ee..8a5b4181 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -38,11 +38,9 @@ ${CMAKE_CURRENT_LIST_DIR}/house_brush.h ${CMAKE_CURRENT_LIST_DIR}/house_exit_brush.h ${CMAKE_CURRENT_LIST_DIR}/iomap.h ${CMAKE_CURRENT_LIST_DIR}/iomap_otbm.h -#${CMAKE_CURRENT_LIST_DIR}/iomap_otmm.h ${CMAKE_CURRENT_LIST_DIR}/item.h ${CMAKE_CURRENT_LIST_DIR}/item_attributes.h ${CMAKE_CURRENT_LIST_DIR}/items.h -${CMAKE_CURRENT_LIST_DIR}/json.h ${CMAKE_CURRENT_LIST_DIR}/live_action.h ${CMAKE_CURRENT_LIST_DIR}/live_client.h ${CMAKE_CURRENT_LIST_DIR}/live_packets.h @@ -209,7 +207,4 @@ ${CMAKE_CURRENT_LIST_DIR}/wall_brush.cpp ${CMAKE_CURRENT_LIST_DIR}/waypoint_brush.cpp ${CMAKE_CURRENT_LIST_DIR}/waypoints.cpp ${CMAKE_CURRENT_LIST_DIR}/welcome_dialog.cpp -${CMAKE_CURRENT_LIST_DIR}/json/json_spirit_reader.cpp -${CMAKE_CURRENT_LIST_DIR}/json/json_spirit_value.cpp -${CMAKE_CURRENT_LIST_DIR}/json/json_spirit_writer.cpp ) diff --git a/source/about_window.cpp b/source/about_window.cpp index 595ae50c..b38a62fb 100644 --- a/source/about_window.cpp +++ b/source/about_window.cpp @@ -161,6 +161,18 @@ AboutWindow::AboutWindow(wxWindow* parent) : wxDialog(parent, wxID_ANY, "About", wxDefaultPosition, wxSize(300, 320), wxRESIZE_BORDER | wxCAPTION | wxCLOSE_BOX), game_panel(nullptr) { + + std::string compiler; +#if defined(__clang__) + compiler = fmt::format("Clang++ {}.{}.{}", __clang_major__, __clang_minor__, __clang_patchlevel__); +#elif defined(_MSC_VER) + compiler = fmt::format("Microsoft Visual Studio {}", _MSC_VER); +#elif defined(__GNUC__) + compiler = fmt::format("G++ {}.{}.{}", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); +#else + compiler = "unknown"; +#endif + wxString about; about << "This is an OpenTibia Map Editor created by Remere.\n"; @@ -186,7 +198,7 @@ AboutWindow::AboutWindow(wxWindow* parent) : about << "under certain conditions.\n"; about << "\n"; about << "Compiled on: " << __TDATE__ << " : " << __TTIME__ << "\n"; - about << "Compiled with: " << BOOST_COMPILER << "\n"; + about << "Compiled with: " << compiler << "\n"; topsizer = newd wxBoxSizer(wxVERTICAL); diff --git a/source/action.cpp b/source/action.cpp index 6c2b5e33..f426ffc2 100644 --- a/source/action.cpp +++ b/source/action.cpp @@ -532,7 +532,7 @@ void BatchAction::commit() void BatchAction::undo() { - for(Action* action : boost::adaptors::reverse(batch)) { + for(Action* action : std::views::reverse(batch)) { action->undo(nullptr); } } diff --git a/source/application.cpp b/source/application.cpp index f0a6b3b1..ba0ad1ad 100644 --- a/source/application.cpp +++ b/source/application.cpp @@ -659,3 +659,14 @@ void MainFrame::PrepareDC(wxDC& dc) dc.SetUserScale( 1.0, 1.0 ); dc.SetMapMode( wxMM_TEXT ); } + +// This is necessary for cmake to understand that it needs to set the executable +int main(int argc, char** argv) +{ + wxEntryStart(argc, argv); // Start the wxWidgets library + Application* app = new Application(); // Create the application object + wxApp::SetInstance(app); // Informs wxWidgets that app is the application object + wxEntry(); // Call the wxEntry() function to start the application execution + wxEntryCleanup(); // Clear the wxWidgets library + return 0; +} diff --git a/source/client_version.cpp b/source/client_version.cpp index f5dda39b..0e828bf8 100644 --- a/source/client_version.cpp +++ b/source/client_version.cpp @@ -24,7 +24,8 @@ #include "client_version.h" #include "otml.h" -#include + +using json = nlohmann::json; // Static methods to load/save @@ -122,15 +123,14 @@ void ClientVersion::loadVersions() // Load the data directory info try { - json::mValue read_obj; - json::read_or_throw(g_settings.getString(Config::ASSETS_DATA_DIRS), read_obj); - json::mArray& vers_obj = read_obj.get_array(); - for(json::mArray::iterator ver_iter = vers_obj.begin(); ver_iter != vers_obj.end(); ++ver_iter) { - json::mObject& ver_obj = ver_iter->get_obj(); - ClientVersion* version = get(ver_obj["id"].get_str()); - if(version == nullptr) + json read_obj = json::parse(g_settings.getString(Config::ASSETS_DATA_DIRS)); + auto vers_obj = read_obj.get>(); + for (const auto& ver_iter : vers_obj) { + const auto& ver_obj = ver_iter.get(); + auto version = get(ver_obj.at("id").get()); + if (version == nullptr) continue; - version->setClientPath(wxstr(ver_obj["path"].get_str())); + version->setClientPath(wxstr(ver_obj.at("path").get())); } } catch (std::runtime_error&) @@ -329,17 +329,17 @@ void ClientVersion::loadVersionExtensions(pugi::xml_node versionNode) void ClientVersion::saveVersions() { - json::Array vers_obj; + json vers_obj; - for(VersionMap::iterator i = client_versions.begin(); i != client_versions.end(); ++i) { - ClientVersion* version = i->second; - json::Object ver_obj; - ver_obj.push_back(json::Pair("id", version->getName())); - ver_obj.push_back(json::Pair("path", nstr(version->getClientPath().GetFullPath()))); + for(auto& [id, version] : client_versions) { + json ver_obj; + ver_obj["id"] = version->getName(); + ver_obj["path"] = version->getClientPath().GetFullPath().ToStdString(); vers_obj.push_back(ver_obj); } + std::ostringstream out; - json::write(vers_obj, out); + out << vers_obj; g_settings.setString(Config::ASSETS_DATA_DIRS, out.str()); } diff --git a/source/client_version.h b/source/client_version.h index 441a4510..a775d33c 100644 --- a/source/client_version.h +++ b/source/client_version.h @@ -185,12 +185,16 @@ struct ClientData class ClientVersion; typedef std::vector ClientVersionList; -class ClientVersion : boost::noncopyable +class ClientVersion { public: ClientVersion(OtbVersion otb, std::string versionName, wxString path); ~ClientVersion() = default; + // Ensures we don't accidentally copy it. + ClientVersion(const ClientVersion &) = delete; + ClientVersion &operator=(const ClientVersion &) = delete; + static void loadVersions(); static void unloadVersions(); static void saveVersions(); @@ -248,7 +252,7 @@ class ClientVersion : boost::noncopyable static void loadVersionExtensions(pugi::xml_node client_node); // All versions - typedef std::map VersionMap; + using VersionMap = std::map; static VersionMap client_versions; static ClientVersion* latest_version; diff --git a/source/common.cpp b/source/common.cpp index a9d4d980..8047ae44 100644 --- a/source/common.cpp +++ b/source/common.cpp @@ -126,6 +126,16 @@ void trim_left(std::string& source, const std::string& t) source.erase(0, source.find_first_not_of(t)); } +void trim(std::string& str) { + // Trim from start + str.erase(str.begin(), std::find_if(str.begin(), str.end(), + [](int ch) { return !std::isspace(ch); })); + + // Trim from end + str.erase(std::find_if(str.rbegin(), str.rend(), + [](int ch) { return !std::isspace(ch); }).base(), str.end()); +} + void to_lower_str(std::string& source) { std::transform(source.begin(), source.end(), source.begin(), tolower); diff --git a/source/common.h b/source/common.h index 4b8a8d77..0e91594d 100644 --- a/source/common.h +++ b/source/common.h @@ -50,6 +50,7 @@ void replaceString(std::string& str, const std::string sought, const std::string // Removes all characters in t from source (from either start or beginning of the string) void trim_right(std::string& source, const std::string& t); void trim_left(std::string& source, const std::string& t); +void trim(std::string& str); // Converts the argument to lower/uppercase void to_lower_str(std::string& source); void to_upper_str(std::string& source); diff --git a/source/definitions.h b/source/definitions.h index 2071cc78..902b3226 100644 --- a/source/definitions.h +++ b/source/definitions.h @@ -50,7 +50,8 @@ #endif // OS -#define OTGZ_SUPPORT 1 +#define OTGZ_SUPPORT 0 + #define ASSETS_NAME "Tibia" #ifdef __VISUALC__ diff --git a/source/doodad_brush.cpp b/source/doodad_brush.cpp index 1fa67f08..de9bc660 100644 --- a/source/doodad_brush.cpp +++ b/source/doodad_brush.cpp @@ -20,8 +20,6 @@ #include "doodad_brush.h" #include "basemap.h" -#include - //============================================================================= // Doodad brush @@ -219,8 +217,20 @@ bool DoodadBrush::load(pugi::xml_node node, wxArrayString& warnings) if(!thicknessString.empty()) { size_t slash = thicknessString.find('/'); if(slash != std::string::npos) { - thickness = boost::lexical_cast(thicknessString.substr(0, slash)); - thickness_ceiling = std::max(thickness, boost::lexical_cast(thicknessString.substr(slash + 1))); + try { + thickness = std::stoi(thicknessString.substr(0, slash)); + } catch (const std::invalid_argument&) { + thickness = 0; + } catch (const std::out_of_range&) { + thickness = 0; + } + try { + thickness_ceiling = std::stoi(thicknessString.substr(slash + 1)); + } catch (const std::invalid_argument&) { + thickness_ceiling = 0; + } catch (const std::out_of_range&) { + thickness_ceiling = 0; + } } } diff --git a/source/filehandle.h b/source/filehandle.h index 9d160104..c5907568 100644 --- a/source/filehandle.h +++ b/source/filehandle.h @@ -50,12 +50,16 @@ enum NodeType { ESCAPE_CHAR = 0xfd, }; -class FileHandle : boost::noncopyable +class FileHandle { public: FileHandle() : error_code(FILE_NO_ERROR), file(nullptr) {} virtual ~FileHandle() {close();} + // Ensures we don't accidentally copy it. + FileHandle(const FileHandle &) = delete; + FileHandle &operator=(const FileHandle &) = delete; + virtual void close(); virtual bool isOpen() {return file != nullptr;} virtual bool isOk() {return isOpen() && error_code == FILE_NO_ERROR && ferror(file) == 0;} diff --git a/source/iomap_otbm.cpp b/source/iomap_otbm.cpp index 8372fc3f..22324ce4 100644 --- a/source/iomap_otbm.cpp +++ b/source/iomap_otbm.cpp @@ -410,7 +410,7 @@ bool Container::serializeItemNode_OTBM(const IOMap& maphandle, NodeFileWriteHand bool IOMapOTBM::getVersionInfo(const FileName& filename, MapVersion& out_ver) { -#ifdef OTGZ_SUPPORT +#if OTGZ_SUPPORT > 0 if(filename.GetExt() == "otgz") { // Open the archive std::shared_ptr a(archive_read_new(), archive_read_free); @@ -485,7 +485,7 @@ bool IOMapOTBM::getVersionInfo(NodeFileReadHandle* f, MapVersion& out_ver) bool IOMapOTBM::loadMap(Map& map, const FileName& filename) { -#ifdef OTGZ_SUPPORT +#if OTGZ_SUPPORT > 0 if(filename.GetExt() == "otgz") { // Open the archive std::shared_ptr a(archive_read_new(), archive_read_free); @@ -1331,7 +1331,7 @@ bool IOMapOTBM::loadSpawnsNpc(Map& map, pugi::xml_document& doc) bool IOMapOTBM::saveMap(Map& map, const FileName& identifier) { -#ifdef OTGZ_SUPPORT +#if OTGZ_SUPPORT > 0 if(identifier.GetExt() == "otgz") { // Create the archive struct archive* a = archive_write_new(); diff --git a/source/item_attributes.h b/source/item_attributes.h index 7bca79c1..5cc4b79d 100644 --- a/source/item_attributes.h +++ b/source/item_attributes.h @@ -23,8 +23,6 @@ #include "filehandle.h" -#include - class IOMap; class ItemAttribute; diff --git a/source/json.h b/source/json.h deleted file mode 100644 index d142db66..00000000 --- a/source/json.h +++ /dev/null @@ -1,27 +0,0 @@ -////////////////////////////////////////////////////////////////////// -// This file is part of Remere's Map Editor -////////////////////////////////////////////////////////////////////// -// Remere's Map Editor is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Remere's Map Editor is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -////////////////////////////////////////////////////////////////////// - -#ifndef RME_JSON_H_ -#define RME_JSON_H_ - -#include "json/json_spirit.h" - -namespace json { - using namespace json_spirit; -} - -#endif diff --git a/source/json/json_spirit.h b/source/json/json_spirit.h deleted file mode 100644 index ac1879d5..00000000 --- a/source/json/json_spirit.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef JSON_SPIRIT -#define JSON_SPIRIT - -// Copyright John W. Wilkinson 2007 - 2009. -// Distributed under the MIT License, see accompanying file LICENSE.txt - -// json spirit version 4.03 - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -#include "json_spirit_value.h" -#include "json_spirit_reader.h" -#include "json_spirit_writer.h" -#include "json_spirit_utils.h" - -#endif diff --git a/source/json/json_spirit_error_position.h b/source/json/json_spirit_error_position.h deleted file mode 100644 index fe4af6ff..00000000 --- a/source/json/json_spirit_error_position.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef JSON_SPIRIT_ERROR_POSITION -#define JSON_SPIRIT_ERROR_POSITION - -// Copyright John W. Wilkinson 2007 - 2009. -// Distributed under the MIT License, see accompanying file LICENSE.txt - -// json spirit version 4.03 - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -#include - -namespace json_spirit -{ - // An Error_position exception is thrown by the "read_or_throw" functions below on finding an error. - // Note the "read_or_throw" functions are around 3 times slower than the standard functions "read" - // functions that return a bool. - // - struct Error_position : std::runtime_error - { - Error_position(); - Error_position( unsigned int line, unsigned int column, const std::string& reason ); - bool operator==( const Error_position& lhs ) const; - unsigned int line_; - unsigned int column_; - std::string reason_; - }; - - inline Error_position::Error_position() - : std::runtime_error("Error_position") - , line_( 0 ) - , column_( 0 ) - { - } - - inline Error_position::Error_position( unsigned int line, unsigned int column, const std::string& reason ) - : std::runtime_error("Error_position") - , line_( line ) - , column_( column ) - , reason_( reason ) - { - } - - inline bool Error_position::operator==( const Error_position& lhs ) const - { - if( this == &lhs ) return true; - - return ( reason_ == lhs.reason_ ) && - ( line_ == lhs.line_ ) && - ( column_ == lhs.column_ ); -} -} - -#endif diff --git a/source/json/json_spirit_reader.cpp b/source/json/json_spirit_reader.cpp deleted file mode 100644 index aa4f6372..00000000 --- a/source/json/json_spirit_reader.cpp +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright John W. Wilkinson 2007 - 2009. -// Distributed under the MIT License, see accompanying file LICENSE.txt - -// json spirit version 4.03 - -#include "json_spirit_reader.h" -#include "json_spirit_reader_template.h" - -using namespace json_spirit; - -bool json_spirit::read( const std::string& s, Value& value ) -{ - return read_string( s, value ); -} - -void json_spirit::read_or_throw( const std::string& s, Value& value ) -{ - read_string_or_throw( s, value ); -} - -bool json_spirit::read( std::istream& is, Value& value ) -{ - return read_stream( is, value ); -} - -void json_spirit::read_or_throw( std::istream& is, Value& value ) -{ - read_stream_or_throw( is, value ); -} - -bool json_spirit::read( std::string::const_iterator& begin, std::string::const_iterator end, Value& value ) -{ - return read_range( begin, end, value ); -} - -void json_spirit::read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, Value& value ) -{ - begin = read_range_or_throw( begin, end, value ); -} - -#ifndef BOOST_NO_STD_WSTRING - -bool json_spirit::read( const std::wstring& s, wValue& value ) -{ - return read_string( s, value ); -} - -void json_spirit::read_or_throw( const std::wstring& s, wValue& value ) -{ - read_string_or_throw( s, value ); -} - -bool json_spirit::read( std::wistream& is, wValue& value ) -{ - return read_stream( is, value ); -} - -void json_spirit::read_or_throw( std::wistream& is, wValue& value ) -{ - read_stream_or_throw( is, value ); -} - -bool json_spirit::read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value ) -{ - return read_range( begin, end, value ); -} - -void json_spirit::read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value ) -{ - begin = read_range_or_throw( begin, end, value ); -} - -#endif - -bool json_spirit::read( const std::string& s, mValue& value ) -{ - return read_string( s, value ); -} - -void json_spirit::read_or_throw( const std::string& s, mValue& value ) -{ - read_string_or_throw( s, value ); -} - -bool json_spirit::read( std::istream& is, mValue& value ) -{ - return read_stream( is, value ); -} - -void json_spirit::read_or_throw( std::istream& is, mValue& value ) -{ - read_stream_or_throw( is, value ); -} - -bool json_spirit::read( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value ) -{ - return read_range( begin, end, value ); -} - -void json_spirit::read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value ) -{ - begin = read_range_or_throw( begin, end, value ); -} - -#ifndef BOOST_NO_STD_WSTRING - -bool json_spirit::read( const std::wstring& s, wmValue& value ) -{ - return read_string( s, value ); -} - -void json_spirit::read_or_throw( const std::wstring& s, wmValue& value ) -{ - read_string_or_throw( s, value ); -} - -bool json_spirit::read( std::wistream& is, wmValue& value ) -{ - return read_stream( is, value ); -} - -void json_spirit::read_or_throw( std::wistream& is, wmValue& value ) -{ - read_stream_or_throw( is, value ); -} - -bool json_spirit::read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value ) -{ - return read_range( begin, end, value ); -} - -void json_spirit::read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value ) -{ - begin = read_range_or_throw( begin, end, value ); -} - -#endif diff --git a/source/json/json_spirit_reader.h b/source/json/json_spirit_reader.h deleted file mode 100644 index 19de2a51..00000000 --- a/source/json/json_spirit_reader.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef JSON_SPIRIT_READER -#define JSON_SPIRIT_READER - -// Copyright John W. Wilkinson 2007 - 2009. -// Distributed under the MIT License, see accompanying file LICENSE.txt - -// json spirit version 4.03 - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -#include "json_spirit_value.h" -#include "json_spirit_error_position.h" -#include - -namespace json_spirit -{ - // functions to reads a JSON values - - bool read( const std::string& s, Value& value ); - bool read( std::istream& is, Value& value ); - bool read( std::string::const_iterator& begin, std::string::const_iterator end, Value& value ); - - void read_or_throw( const std::string& s, Value& value ); - void read_or_throw( std::istream& is, Value& value ); - void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, Value& value ); - -#ifndef BOOST_NO_STD_WSTRING - - bool read( const std::wstring& s, wValue& value ); - bool read( std::wistream& is, wValue& value ); - bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value ); - - void read_or_throw( const std::wstring& s, wValue& value ); - void read_or_throw( std::wistream& is, wValue& value ); - void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value ); - -#endif - - bool read( const std::string& s, mValue& value ); - bool read( std::istream& is, mValue& value ); - bool read( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value ); - - void read_or_throw( const std::string& s, mValue& value ); - void read_or_throw( std::istream& is, mValue& value ); - void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value ); - -#ifndef BOOST_NO_STD_WSTRING - - bool read( const std::wstring& s, wmValue& value ); - bool read( std::wistream& is, wmValue& value ); - bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value ); - - void read_or_throw( const std::wstring& s, wmValue& value ); - void read_or_throw( std::wistream& is, wmValue& value ); - void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value ); - -#endif -} - -#endif diff --git a/source/json/json_spirit_reader_template.h b/source/json/json_spirit_reader_template.h deleted file mode 100644 index a9cabc95..00000000 --- a/source/json/json_spirit_reader_template.h +++ /dev/null @@ -1,613 +0,0 @@ -#ifndef JSON_SPIRIT_READER_TEMPLATE -#define JSON_SPIRIT_READER_TEMPLATE - -// Copyright John W. Wilkinson 2007 - 2009. -// Distributed under the MIT License, see accompanying file LICENSE.txt - -// json spirit version 4.03 - -#include "json_spirit_value.h" -#include "json_spirit_error_position.h" - -#define BOOST_SPIRIT_THREADSAFE // uncomment for multithreaded use, requires linking to boost.thread - -#include -#include -#include - -#if BOOST_VERSION >= 103800 - #include - #include - #include - #include - #include - #define spirit_namespace boost::spirit::classic -#else - #include - #include - #include - #include - #include - #define spirit_namespace boost::spirit -#endif - -namespace json_spirit -{ - const spirit_namespace::int_parser < boost::int64_t > int64_p = spirit_namespace::int_parser < boost::int64_t >(); - const spirit_namespace::uint_parser< boost::uint64_t > uint64_p = spirit_namespace::uint_parser< boost::uint64_t >(); - - template< class Iter_type > - bool is_eq( Iter_type first, Iter_type last, const char* c_str ) - { - for( Iter_type i = first; i != last; ++i, ++c_str ) - { - if( *c_str == 0 ) return false; - - if( *i != *c_str ) return false; - } - - return true; - } - - template< class Char_type > - Char_type hex_to_num( const Char_type c ) - { - if( ( c >= '0' ) && ( c <= '9' ) ) return c - '0'; - if( ( c >= 'a' ) && ( c <= 'f' ) ) return c - 'a' + 10; - if( ( c >= 'A' ) && ( c <= 'F' ) ) return c - 'A' + 10; - return 0; - } - - template< class Char_type, class Iter_type > - Char_type hex_str_to_char( Iter_type& begin ) - { - const Char_type c1( *( ++begin ) ); - const Char_type c2( *( ++begin ) ); - - return ( hex_to_num( c1 ) << 4 ) + hex_to_num( c2 ); - } - - template< class Char_type, class Iter_type > - Char_type unicode_str_to_char( Iter_type& begin ) - { - const Char_type c1( *( ++begin ) ); - const Char_type c2( *( ++begin ) ); - const Char_type c3( *( ++begin ) ); - const Char_type c4( *( ++begin ) ); - - return ( hex_to_num( c1 ) << 12 ) + - ( hex_to_num( c2 ) << 8 ) + - ( hex_to_num( c3 ) << 4 ) + - hex_to_num( c4 ); - } - - template< class String_type > - void append_esc_char_and_incr_iter( String_type& s, - typename String_type::const_iterator& begin, - typename String_type::const_iterator end ) - { - typedef typename String_type::value_type Char_type; - - const Char_type c2( *begin ); - - switch( c2 ) - { - case 't': s += '\t'; break; - case 'b': s += '\b'; break; - case 'f': s += '\f'; break; - case 'n': s += '\n'; break; - case 'r': s += '\r'; break; - case '\\': s += '\\'; break; - case '/': s += '/'; break; - case '"': s += '"'; break; - case 'x': - { - if( end - begin >= 3 ) // expecting "xHH..." - { - s += hex_str_to_char< Char_type >( begin ); - } - break; - } - case 'u': - { - if( end - begin >= 5 ) // expecting "uHHHH..." - { - s += unicode_str_to_char< Char_type >( begin ); - } - break; - } - } - } - - template< class String_type > - String_type substitute_esc_chars( typename String_type::const_iterator begin, - typename String_type::const_iterator end ) - { - typedef typename String_type::const_iterator Iter_type; - - if( end - begin < 2 ) return String_type( begin, end ); - - String_type result; - - result.reserve( end - begin ); - - const Iter_type end_minus_1( end - 1 ); - - Iter_type substr_start = begin; - Iter_type i = begin; - - for( ; i < end_minus_1; ++i ) - { - if( *i == '\\' ) - { - result.append( substr_start, i ); - - ++i; // skip the '\' - - append_esc_char_and_incr_iter( result, i, end ); - - substr_start = i + 1; - } - } - - result.append( substr_start, end ); - - return result; - } - - template< class String_type > - String_type get_str_( typename String_type::const_iterator begin, - typename String_type::const_iterator end ) - { - assert( end - begin >= 2 ); - - typedef typename String_type::const_iterator Iter_type; - - Iter_type str_without_quotes( ++begin ); - Iter_type end_without_quotes( --end ); - - return substitute_esc_chars< String_type >( str_without_quotes, end_without_quotes ); - } - - inline std::string get_str( std::string::const_iterator begin, std::string::const_iterator end ) - { - return get_str_< std::string >( begin, end ); - } - - inline std::wstring get_str( std::wstring::const_iterator begin, std::wstring::const_iterator end ) - { - return get_str_< std::wstring >( begin, end ); - } - - template< class String_type, class Iter_type > - String_type get_str( Iter_type begin, Iter_type end ) - { - const String_type tmp( begin, end ); // convert multipass iterators to string iterators - - return get_str( tmp.begin(), tmp.end() ); - } - - // this class's methods get called by the spirit parse resulting - // in the creation of a JSON object or array - // - // NB Iter_type could be a std::string iterator, wstring iterator, a position iterator or a multipass iterator - // - template< class Value_type, class Iter_type > - class Semantic_actions - { - public: - - typedef typename Value_type::Config_type Config_type; - typedef typename Config_type::String_type String_type; - typedef typename Config_type::Object_type Object_type; - typedef typename Config_type::Array_type Array_type; - typedef typename String_type::value_type Char_type; - - Semantic_actions( Value_type& value ) - : value_( value ) - , current_p_( 0 ) - { - } - - void begin_obj( Char_type c ) - { - assert( c == '{' ); - - begin_compound< Object_type >(); - } - - void end_obj( Char_type c ) - { - assert( c == '}' ); - - end_compound(); - } - - void begin_array( Char_type c ) - { - assert( c == '[' ); - - begin_compound< Array_type >(); - } - - void end_array( Char_type c ) - { - assert( c == ']' ); - - end_compound(); - } - - void new_name( Iter_type begin, Iter_type end ) - { - assert( current_p_->type() == obj_type ); - - name_ = get_str< String_type >( begin, end ); - } - - void new_str( Iter_type begin, Iter_type end ) - { - add_to_current( get_str< String_type >( begin, end ) ); - } - - void new_true( Iter_type begin, Iter_type end ) - { - assert( is_eq( begin, end, "true" ) ); - - add_to_current( true ); - } - - void new_false( Iter_type begin, Iter_type end ) - { - assert( is_eq( begin, end, "false" ) ); - - add_to_current( false ); - } - - void new_null( Iter_type begin, Iter_type end ) - { - assert( is_eq( begin, end, "null" ) ); - - add_to_current( Value_type() ); - } - - void new_int( boost::int64_t i ) - { - add_to_current( i ); - } - - void new_uint64( boost::uint64_t ui ) - { - add_to_current( ui ); - } - - void new_real( double d ) - { - add_to_current( d ); - } - - private: - - Semantic_actions& operator=( const Semantic_actions& ); - // to prevent "assignment operator could not be generated" warning - - Value_type* add_first( const Value_type& value ) - { - assert( current_p_ == 0 ); - - value_ = value; - current_p_ = &value_; - return current_p_; - } - - template< class Array_or_obj > - void begin_compound() - { - if( current_p_ == 0 ) - { - add_first( Array_or_obj() ); - } - else - { - stack_.push_back( current_p_ ); - - Array_or_obj new_array_or_obj; // avoid copy by building newd array or object in place - - current_p_ = add_to_current( new_array_or_obj ); - } - } - - void end_compound() - { - if( current_p_ != &value_ ) - { - current_p_ = stack_.back(); - - stack_.pop_back(); - } - } - - Value_type* add_to_current( const Value_type& value ) - { - if( current_p_ == 0 ) - { - return add_first( value ); - } - else if( current_p_->type() == array_type ) - { - current_p_->get_array().push_back( value ); - - return ¤t_p_->get_array().back(); - } - - assert( current_p_->type() == obj_type ); - - return &Config_type::add( current_p_->get_obj(), name_, value ); - } - - Value_type& value_; // this is the object or array that is being created - Value_type* current_p_; // the child object or array that is currently being constructed - - std::vector< Value_type* > stack_; // previous child objects and arrays - - String_type name_; // of current name/value pair - }; - - template< typename Iter_type > - void throw_error( spirit_namespace::position_iterator< Iter_type > i, const std::string& reason ) - { - throw Error_position( i.get_position().line, i.get_position().column, reason ); - } - - template< typename Iter_type > - void throw_error( Iter_type i, const std::string& reason ) - { - throw reason; - } - - // the spirit grammer - // - template< class Value_type, class Iter_type > - class Json_grammer : public spirit_namespace::grammar< Json_grammer< Value_type, Iter_type > > - { - public: - - typedef Semantic_actions< Value_type, Iter_type > Semantic_actions_t; - - Json_grammer( Semantic_actions_t& semantic_actions ) - : actions_( semantic_actions ) - { - } - - static void throw_not_value( Iter_type begin, Iter_type end ) - { - throw_error( begin, "not a value" ); - } - - static void throw_not_array( Iter_type begin, Iter_type end ) - { - throw_error( begin, "not an array" ); - } - - static void throw_not_object( Iter_type begin, Iter_type end ) - { - throw_error( begin, "not an object" ); - } - - static void throw_not_pair( Iter_type begin, Iter_type end ) - { - throw_error( begin, "not a pair" ); - } - - static void throw_not_colon( Iter_type begin, Iter_type end ) - { - throw_error( begin, "no colon in pair" ); - } - - static void throw_not_string( Iter_type begin, Iter_type end ) - { - throw_error( begin, "not a string" ); - } - - template< typename ScannerT > - class definition - { - public: - - definition( const Json_grammer& self ) - { - using namespace spirit_namespace; - - typedef typename Value_type::String_type::value_type Char_type; - - // first we convert the semantic action class methods to functors with the - // parameter signature expected by spirit - - typedef boost::function< void( Char_type ) > Char_action; - typedef boost::function< void( Iter_type, Iter_type ) > Str_action; - typedef boost::function< void( double ) > Real_action; - typedef boost::function< void( boost::int64_t ) > Int_action; - typedef boost::function< void( boost::uint64_t ) > Uint64_action; - - Char_action begin_obj ( boost::bind( &Semantic_actions_t::begin_obj, &self.actions_, _1 ) ); - Char_action end_obj ( boost::bind( &Semantic_actions_t::end_obj, &self.actions_, _1 ) ); - Char_action begin_array( boost::bind( &Semantic_actions_t::begin_array, &self.actions_, _1 ) ); - Char_action end_array ( boost::bind( &Semantic_actions_t::end_array, &self.actions_, _1 ) ); - Str_action new_name ( boost::bind( &Semantic_actions_t::new_name, &self.actions_, _1, _2 ) ); - Str_action new_str ( boost::bind( &Semantic_actions_t::new_str, &self.actions_, _1, _2 ) ); - Str_action new_true ( boost::bind( &Semantic_actions_t::new_true, &self.actions_, _1, _2 ) ); - Str_action new_false ( boost::bind( &Semantic_actions_t::new_false, &self.actions_, _1, _2 ) ); - Str_action new_null ( boost::bind( &Semantic_actions_t::new_null, &self.actions_, _1, _2 ) ); - Real_action new_real ( boost::bind( &Semantic_actions_t::new_real, &self.actions_, _1 ) ); - Int_action new_int ( boost::bind( &Semantic_actions_t::new_int, &self.actions_, _1 ) ); - Uint64_action new_uint64 ( boost::bind( &Semantic_actions_t::new_uint64, &self.actions_, _1 ) ); - - // actual grammer - - json_ - = value_ | eps_p[ &throw_not_value ] - ; - - value_ - = string_[ new_str ] - | number_ - | object_ - | array_ - | str_p( "true" ) [ new_true ] - | str_p( "false" )[ new_false ] - | str_p( "null" ) [ new_null ] - ; - - object_ - = ch_p('{')[ begin_obj ] - >> !members_ - >> ( ch_p('}')[ end_obj ] | eps_p[ &throw_not_object ] ) - ; - - members_ - = pair_ >> *( ',' >> pair_ ) - ; - - pair_ - = string_[ new_name ] - >> ( ':' | eps_p[ &throw_not_colon ] ) - >> ( value_ | eps_p[ &throw_not_value ] ) - ; - - array_ - = ch_p('[')[ begin_array ] - >> !elements_ - >> ( ch_p(']')[ end_array ] | eps_p[ &throw_not_array ] ) - ; - - elements_ - = value_ >> *( ',' >> value_ ) - ; - - string_ - = lexeme_d // this causes white space inside a string to be retained - [ - confix_p - ( - '"', - *lex_escape_ch_p, - '"' - ) - ] - ; - - number_ - = strict_real_p[ new_real ] - | int64_p [ new_int ] - | uint64_p [ new_uint64 ] - ; - } - - spirit_namespace::rule< ScannerT > json_, object_, members_, pair_, array_, elements_, value_, string_, number_; - - const spirit_namespace::rule< ScannerT >& start() const { return json_; } - }; - - private: - - Json_grammer& operator=( const Json_grammer& ); // to prevent "assignment operator could not be generated" warning - - Semantic_actions_t& actions_; - }; - - template< class Iter_type, class Value_type > - Iter_type read_range_or_throw( Iter_type begin, Iter_type end, Value_type& value ) - { - Semantic_actions< Value_type, Iter_type > semantic_actions( value ); - - const spirit_namespace::parse_info< Iter_type > info = - spirit_namespace::parse( begin, end, - Json_grammer< Value_type, Iter_type >( semantic_actions ), - spirit_namespace::space_p ); - - if( !info.hit ) - { - assert( false ); // in theory exception should already have been thrown - throw_error( info.stop, "error" ); - } - - return info.stop; - } - - template< class Iter_type, class Value_type > - void add_posn_iter_and_read_range_or_throw( Iter_type begin, Iter_type end, Value_type& value ) - { - typedef spirit_namespace::position_iterator< Iter_type > Posn_iter_t; - - const Posn_iter_t posn_begin( begin, end ); - const Posn_iter_t posn_end( end, end ); - - read_range_or_throw( posn_begin, posn_end, value ); - } - - template< class Iter_type, class Value_type > - bool read_range( Iter_type& begin, Iter_type end, Value_type& value ) - { - try - { - begin = read_range_or_throw( begin, end, value ); - - return true; - } - catch( ... ) - { - return false; - } - } - - template< class String_type, class Value_type > - void read_string_or_throw( const String_type& s, Value_type& value ) - { - add_posn_iter_and_read_range_or_throw( s.begin(), s.end(), value ); - } - - template< class String_type, class Value_type > - bool read_string( const String_type& s, Value_type& value ) - { - typename String_type::const_iterator begin = s.begin(); - - return read_range( begin, s.end(), value ); - } - - template< class Istream_type > - struct Multi_pass_iters - { - typedef typename Istream_type::char_type Char_type; - typedef std::istream_iterator< Char_type, Char_type > istream_iter; - typedef spirit_namespace::multi_pass< istream_iter > Mp_iter; - - Multi_pass_iters( Istream_type& is ) - { - is.unsetf( std::ios::skipws ); - - begin_ = spirit_namespace::make_multi_pass( istream_iter( is ) ); - end_ = spirit_namespace::make_multi_pass( istream_iter() ); - } - - Mp_iter begin_; - Mp_iter end_; - }; - - template< class Istream_type, class Value_type > - bool read_stream( Istream_type& is, Value_type& value ) - { - Multi_pass_iters< Istream_type > mp_iters( is ); - - return read_range( mp_iters.begin_, mp_iters.end_, value ); - } - - template< class Istream_type, class Value_type > - void read_stream_or_throw( Istream_type& is, Value_type& value ) - { - const Multi_pass_iters< Istream_type > mp_iters( is ); - - add_posn_iter_and_read_range_or_throw( mp_iters.begin_, mp_iters.end_, value ); - } -} - -#endif - diff --git a/source/json/json_spirit_stream_reader.h b/source/json/json_spirit_stream_reader.h deleted file mode 100644 index 1a94392a..00000000 --- a/source/json/json_spirit_stream_reader.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef JSON_SPIRIT_READ_STREAM -#define JSON_SPIRIT_READ_STREAM - -// Copyright John W. Wilkinson 2007 - 2009. -// Distributed under the MIT License, see accompanying file LICENSE.txt - -// json spirit version 4.03 - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -#include "json_spirit_reader_template.h" - -namespace json_spirit -{ - // these classes allows you to read multiple top level contiguous values from a stream, - // the normal stream read functions have a bug that prevent multiple top level values - // from being read unless they are separated by spaces - - template< class Istream_type, class Value_type > - class Stream_reader - { - public: - - Stream_reader( Istream_type& is ) - : iters_( is ) - { - } - - bool read_next( Value_type& value ) - { - return read_range( iters_.begin_, iters_.end_, value ); - } - - private: - - typedef Multi_pass_iters< Istream_type > Mp_iters; - - Mp_iters iters_; - }; - - template< class Istream_type, class Value_type > - class Stream_reader_thrower - { - public: - - Stream_reader_thrower( Istream_type& is ) - : iters_( is ) - , posn_begin_( iters_.begin_, iters_.end_ ) - , posn_end_( iters_.end_, iters_.end_ ) - { - } - - void read_next( Value_type& value ) - { - posn_begin_ = read_range_or_throw( posn_begin_, posn_end_, value ); - } - - private: - - typedef Multi_pass_iters< Istream_type > Mp_iters; - typedef spirit_namespace::position_iterator< typename Mp_iters::Mp_iter > Posn_iter_t; - - Mp_iters iters_; - Posn_iter_t posn_begin_, posn_end_; - }; -} - -#endif diff --git a/source/json/json_spirit_utils.h b/source/json/json_spirit_utils.h deleted file mode 100644 index 0d3bc8a4..00000000 --- a/source/json/json_spirit_utils.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef JSON_SPIRIT_UTILS -#define JSON_SPIRIT_UTILS - -// Copyright John W. Wilkinson 2007 - 2009. -// Distributed under the MIT License, see accompanying file LICENSE.txt - -// json spirit version 4.03 - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -#include "json_spirit_value.h" -#include - -namespace json_spirit -{ - template< class Obj_t, class Map_t > - void obj_to_map( const Obj_t& obj, Map_t& mp_obj ) - { - mp_obj.clear(); - - for( typename Obj_t::const_iterator i = obj.begin(); i != obj.end(); ++i ) - { - mp_obj[ i->name_ ] = i->value_; - } - } - - template< class Obj_t, class Map_t > - void map_to_obj( const Map_t& mp_obj, Obj_t& obj ) - { - obj.clear(); - - for( typename Map_t::const_iterator i = mp_obj.begin(); i != mp_obj.end(); ++i ) - { - obj.push_back( typename Obj_t::value_type( i->first, i->second ) ); - } - } - - typedef std::map< std::string, Value > Mapped_obj; - -#ifndef BOOST_NO_STD_WSTRING - typedef std::map< std::wstring, wValue > wMapped_obj; -#endif - - template< class Object_type, class String_type > - const typename Object_type::value_type::Value_type& find_value( const Object_type& obj, const String_type& name ) - { - for( typename Object_type::const_iterator i = obj.begin(); i != obj.end(); ++i ) - { - if( i->name_ == name ) - { - return i->value_; - } - } - - return Object_type::value_type::Value_type::null; - } -} - -#endif diff --git a/source/json/json_spirit_value.cpp b/source/json/json_spirit_value.cpp deleted file mode 100644 index 44d2f06a..00000000 --- a/source/json/json_spirit_value.cpp +++ /dev/null @@ -1,8 +0,0 @@ -/* Copyright (c) 2007 John W Wilkinson - - This source code can be used for any purpose as long as - this comment is retained. */ - -// json spirit version 2.00 - -#include "json_spirit_value.h" diff --git a/source/json/json_spirit_value.h b/source/json/json_spirit_value.h deleted file mode 100644 index 10281d8a..00000000 --- a/source/json/json_spirit_value.h +++ /dev/null @@ -1,532 +0,0 @@ -#ifndef JSON_SPIRIT_VALUE -#define JSON_SPIRIT_VALUE - -// Copyright John W. Wilkinson 2007 - 2009. -// Distributed under the MIT License, see accompanying file LICENSE.txt - -// json spirit version 4.03 - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace json_spirit -{ - enum Value_type{ obj_type, array_type, str_type, bool_type, int_type, real_type, null_type }; - - template< class Config > // Config determines whether the value uses std::string or std::wstring and - // whether JSON Objects are represented as vectors or maps - class Value_impl - { - public: - - typedef Config Config_type; - typedef typename Config::String_type String_type; - typedef typename Config::Object_type Object; - typedef typename Config::Array_type Array; - typedef typename String_type::const_pointer Const_str_ptr; // eg const char* - - Value_impl(); // creates null value - Value_impl( Const_str_ptr value ); - Value_impl( const String_type& value ); - Value_impl( const Object& value ); - Value_impl( const Array& value ); - Value_impl( bool value ); - Value_impl( int value ); - Value_impl( boost::int64_t value ); - Value_impl( boost::uint64_t value ); - Value_impl( double value ); - - Value_impl( const Value_impl& other ); - - bool operator==( const Value_impl& lhs ) const; - - Value_impl& operator=( const Value_impl& lhs ); - - Value_type type() const; - - bool is_uint64() const; - bool is_null() const; - - const String_type& get_str() const; - const Object& get_obj() const; - const Array& get_array() const; - bool get_bool() const; - int get_int() const; - boost::int64_t get_int64() const; - boost::uint64_t get_uint64() const; - double get_real() const; - - Object& get_obj(); - Array& get_array(); - - template< typename T > T get_value() const; // example usage: int i = value.get_value< int >(); - // or double d = value.get_value< double >(); - - static const Value_impl null; - - private: - - void check_type( const Value_type vtype ) const; - - typedef boost::variant< String_type, - boost::recursive_wrapper< Object >, boost::recursive_wrapper< Array >, - bool, boost::int64_t, double > Variant; - - Value_type type_; - Variant v_; - bool is_uint64_; - }; - - // vector objects - - template< class Config > - struct Pair_impl - { - typedef typename Config::String_type String_type; - typedef typename Config::Value_type Value_type; - - Pair_impl( const String_type& name, const Value_type& value ); - - bool operator==( const Pair_impl& lhs ) const; - - String_type name_; - Value_type value_; - }; - - template< class String > - struct Config_vector - { - typedef String String_type; - typedef Value_impl< Config_vector > Value_type; - typedef Pair_impl < Config_vector > Pair_type; - typedef std::vector< Value_type > Array_type; - typedef std::vector< Pair_type > Object_type; - - static Value_type& add( Object_type& obj, const String_type& name, const Value_type& value ) - { - obj.push_back( Pair_type( name , value ) ); - - return obj.back().value_; - } - - static String_type get_name( const Pair_type& pair ) - { - return pair.name_; - } - - static Value_type get_value( const Pair_type& pair ) - { - return pair.value_; - } - }; - - // typedefs for ASCII - - typedef Config_vector< std::string > Config; - - typedef Config::Value_type Value; - typedef Config::Pair_type Pair; - typedef Config::Object_type Object; - typedef Config::Array_type Array; - - // typedefs for Unicode - -#ifndef BOOST_NO_STD_WSTRING - - typedef Config_vector< std::wstring > wConfig; - - typedef wConfig::Value_type wValue; - typedef wConfig::Pair_type wPair; - typedef wConfig::Object_type wObject; - typedef wConfig::Array_type wArray; -#endif - - // map objects - - template< class String > - struct Config_map - { - typedef String String_type; - typedef Value_impl< Config_map > Value_type; - typedef std::vector< Value_type > Array_type; - typedef std::map< String_type, Value_type > Object_type; - typedef typename Object_type::value_type Pair_type; - - static Value_type& add( Object_type& obj, const String_type& name, const Value_type& value ) - { - return obj[ name ] = value; - } - - static String_type get_name( const Pair_type& pair ) - { - return pair.first; - } - - static Value_type get_value( const Pair_type& pair ) - { - return pair.second; - } - }; - - // typedefs for ASCII - - typedef Config_map< std::string > mConfig; - - typedef mConfig::Value_type mValue; - typedef mConfig::Object_type mObject; - typedef mConfig::Array_type mArray; - - // typedefs for Unicode - -#ifndef BOOST_NO_STD_WSTRING - - typedef Config_map< std::wstring > wmConfig; - - typedef wmConfig::Value_type wmValue; - typedef wmConfig::Object_type wmObject; - typedef wmConfig::Array_type wmArray; - -#endif - - /////////////////////////////////////////////////////////////////////////////////////////////// - // - // implementation - - template< class Config > - const Value_impl< Config > Value_impl< Config >::null; - - template< class Config > - Value_impl< Config >::Value_impl() - : type_( null_type ) - , is_uint64_( false ) - { - } - - template< class Config > - Value_impl< Config >::Value_impl( const Const_str_ptr value ) - : type_( str_type ) - , v_( String_type( value ) ) - , is_uint64_( false ) - { - } - - template< class Config > - Value_impl< Config >::Value_impl( const String_type& value ) - : type_( str_type ) - , v_( value ) - , is_uint64_( false ) - { - } - - template< class Config > - Value_impl< Config >::Value_impl( const Object& value ) - : type_( obj_type ) - , v_( value ) - , is_uint64_( false ) - { - } - - template< class Config > - Value_impl< Config >::Value_impl( const Array& value ) - : type_( array_type ) - , v_( value ) - , is_uint64_( false ) - { - } - - template< class Config > - Value_impl< Config >::Value_impl( bool value ) - : type_( bool_type ) - , v_( value ) - , is_uint64_( false ) - { - } - - template< class Config > - Value_impl< Config >::Value_impl( int value ) - : type_( int_type ) - , v_( static_cast< boost::int64_t >( value ) ) - , is_uint64_( false ) - { - } - - template< class Config > - Value_impl< Config >::Value_impl( boost::int64_t value ) - : type_( int_type ) - , v_( value ) - , is_uint64_( false ) - { - } - - template< class Config > - Value_impl< Config >::Value_impl( boost::uint64_t value ) - : type_( int_type ) - , v_( static_cast< boost::int64_t >( value ) ) - , is_uint64_( true ) - { - } - - template< class Config > - Value_impl< Config >::Value_impl( double value ) - : type_( real_type ) - , v_( value ) - , is_uint64_( false ) - { - } - - template< class Config > - Value_impl< Config >::Value_impl( const Value_impl< Config >& other ) - : type_( other.type() ) - , v_( other.v_ ) - , is_uint64_( other.is_uint64_ ) - { - } - - template< class Config > - Value_impl< Config >& Value_impl< Config >::operator=( const Value_impl& lhs ) - { - Value_impl tmp( lhs ); - - std::swap( type_, tmp.type_ ); - std::swap( v_, tmp.v_ ); - std::swap( is_uint64_, tmp.is_uint64_ ); - - return *this; - } - - template< class Config > - bool Value_impl< Config >::operator==( const Value_impl& lhs ) const - { - if( this == &lhs ) return true; - - if( type() != lhs.type() ) return false; - - return v_ == lhs.v_; - } - - template< class Config > - Value_type Value_impl< Config >::type() const - { - return type_; - } - - template< class Config > - bool Value_impl< Config >::is_uint64() const - { - return is_uint64_; - } - - template< class Config > - bool Value_impl< Config >::is_null() const - { - return type() == null_type; - } - - template< class Config > - void Value_impl< Config >::check_type( const Value_type vtype ) const - { - if( type() != vtype ) - { - std::ostringstream os; - - os << "value type is " << type() << " not " << vtype; - - throw std::runtime_error( os.str() ); - } - } - - template< class Config > - const typename Config::String_type& Value_impl< Config >::get_str() const - { - check_type( str_type ); - - return *boost::get< String_type >( &v_ ); - } - - template< class Config > - const typename Value_impl< Config >::Object& Value_impl< Config >::get_obj() const - { - check_type( obj_type ); - - return *boost::get< Object >( &v_ ); - } - - template< class Config > - const typename Value_impl< Config >::Array& Value_impl< Config >::get_array() const - { - check_type( array_type ); - - return *boost::get< Array >( &v_ ); - } - - template< class Config > - bool Value_impl< Config >::get_bool() const - { - check_type( bool_type ); - - return boost::get< bool >( v_ ); - } - - template< class Config > - int Value_impl< Config >::get_int() const - { - check_type( int_type ); - - return static_cast< int >( get_int64() ); - } - - template< class Config > - boost::int64_t Value_impl< Config >::get_int64() const - { - check_type( int_type ); - - return boost::get< boost::int64_t >( v_ ); - } - - template< class Config > - boost::uint64_t Value_impl< Config >::get_uint64() const - { - check_type( int_type ); - - return static_cast< boost::uint64_t >( get_int64() ); - } - - template< class Config > - double Value_impl< Config >::get_real() const - { - if( type() == int_type ) - { - return is_uint64() ? static_cast< double >( get_uint64() ) - : static_cast< double >( get_int64() ); - } - - check_type( real_type ); - - return boost::get< double >( v_ ); - } - - template< class Config > - typename Value_impl< Config >::Object& Value_impl< Config >::get_obj() - { - check_type( obj_type ); - - return *boost::get< Object >( &v_ ); - } - - template< class Config > - typename Value_impl< Config >::Array& Value_impl< Config >::get_array() - { - check_type( array_type ); - - return *boost::get< Array >( &v_ ); - } - - template< class Config > - Pair_impl< Config >::Pair_impl( const String_type& name, const Value_type& value ) - : name_( name ) - , value_( value ) - { - } - - template< class Config > - bool Pair_impl< Config >::operator==( const Pair_impl< Config >& lhs ) const - { - if( this == &lhs ) return true; - - return ( name_ == lhs.name_ ) && ( value_ == lhs.value_ ); - } - - // converts a C string, ie. 8 bit char array, to a string object - // - template < class String_type > - String_type to_str( const char* c_str ) - { - String_type result; - - for( const char* p = c_str; *p != 0; ++p ) - { - result += *p; - } - - return result; - } - - // - - namespace internal_ - { - template< typename T > - struct Type_to_type - { - }; - - template< class Value > - int get_value( const Value& value, Type_to_type< int > ) - { - return value.get_int(); - } - - template< class Value > - boost::int64_t get_value( const Value& value, Type_to_type< boost::int64_t > ) - { - return value.get_int64(); - } - - template< class Value > - boost::uint64_t get_value( const Value& value, Type_to_type< boost::uint64_t > ) - { - return value.get_uint64(); - } - - template< class Value > - double get_value( const Value& value, Type_to_type< double > ) - { - return value.get_real(); - } - - template< class Value > - typename Value::String_type get_value( const Value& value, Type_to_type< typename Value::String_type > ) - { - return value.get_str(); - } - - template< class Value > - typename Value::Array get_value( const Value& value, Type_to_type< typename Value::Array > ) - { - return value.get_array(); - } - - template< class Value > - typename Value::Object get_value( const Value& value, Type_to_type< typename Value::Object > ) - { - return value.get_obj(); - } - - template< class Value > - bool get_value( const Value& value, Type_to_type< bool > ) - { - return value.get_bool(); - } - } - - template< class Config > - template< typename T > - T Value_impl< Config >::get_value() const - { - return internal_::get_value( *this, internal_::Type_to_type< T >() ); - } -} - -#endif diff --git a/source/json/json_spirit_writer.cpp b/source/json/json_spirit_writer.cpp deleted file mode 100644 index d24a632c..00000000 --- a/source/json/json_spirit_writer.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright John W. Wilkinson 2007 - 2009. -// Distributed under the MIT License, see accompanying file LICENSE.txt - -// json spirit version 4.03 - -#include "json_spirit_writer.h" -#include "json_spirit_writer_template.h" - -void json_spirit::write( const Value& value, std::ostream& os ) -{ - write_stream( value, os, false ); -} - -void json_spirit::write_formatted( const Value& value, std::ostream& os ) -{ - write_stream( value, os, true ); -} - -std::string json_spirit::write( const Value& value ) -{ - return write_string( value, false ); -} - -std::string json_spirit::write_formatted( const Value& value ) -{ - return write_string( value, true ); -} - -#ifndef BOOST_NO_STD_WSTRING - -void json_spirit::write( const wValue& value, std::wostream& os ) -{ - write_stream( value, os, false ); -} - -void json_spirit::write_formatted( const wValue& value, std::wostream& os ) -{ - write_stream( value, os, true ); -} - -std::wstring json_spirit::write( const wValue& value ) -{ - return write_string( value, false ); -} - -std::wstring json_spirit::write_formatted( const wValue& value ) -{ - return write_string( value, true ); -} - -#endif - -void json_spirit::write( const mValue& value, std::ostream& os ) -{ - write_stream( value, os, false ); -} - -void json_spirit::write_formatted( const mValue& value, std::ostream& os ) -{ - write_stream( value, os, true ); -} - -std::string json_spirit::write( const mValue& value ) -{ - return write_string( value, false ); -} - -std::string json_spirit::write_formatted( const mValue& value ) -{ - return write_string( value, true ); -} - -#ifndef BOOST_NO_STD_WSTRING - -void json_spirit::write( const wmValue& value, std::wostream& os ) -{ - write_stream( value, os, false ); -} - -void json_spirit::write_formatted( const wmValue& value, std::wostream& os ) -{ - write_stream( value, os, true ); -} - -std::wstring json_spirit::write( const wmValue& value ) -{ - return write_string( value, false ); -} - -std::wstring json_spirit::write_formatted( const wmValue& value ) -{ - return write_string( value, true ); -} - -#endif diff --git a/source/json/json_spirit_writer.h b/source/json/json_spirit_writer.h deleted file mode 100644 index 108a07f4..00000000 --- a/source/json/json_spirit_writer.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef JSON_SPIRIT_WRITER -#define JSON_SPIRIT_WRITER - -// Copyright John W. Wilkinson 2007 - 2009. -// Distributed under the MIT License, see accompanying file LICENSE.txt - -// json spirit version 4.03 - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -#include "json_spirit_value.h" -#include - -namespace json_spirit -{ - // functions to convert JSON Values to text, - // the "formatted" versions add whitespace to format the output nicely - - void write ( const Value& value, std::ostream& os ); - void write_formatted( const Value& value, std::ostream& os ); - std::string write ( const Value& value ); - std::string write_formatted( const Value& value ); - -#ifndef BOOST_NO_STD_WSTRING - - void write ( const wValue& value, std::wostream& os ); - void write_formatted( const wValue& value, std::wostream& os ); - std::wstring write ( const wValue& value ); - std::wstring write_formatted( const wValue& value ); - -#endif - - void write ( const mValue& value, std::ostream& os ); - void write_formatted( const mValue& value, std::ostream& os ); - std::string write ( const mValue& value ); - std::string write_formatted( const mValue& value ); - -#ifndef BOOST_NO_STD_WSTRING - - void write ( const wmValue& value, std::wostream& os ); - void write_formatted( const wmValue& value, std::wostream& os ); - std::wstring write ( const wmValue& value ); - std::wstring write_formatted( const wmValue& value ); - -#endif -} - -#endif diff --git a/source/json/json_spirit_writer_template.h b/source/json/json_spirit_writer_template.h deleted file mode 100644 index 3dc9228b..00000000 --- a/source/json/json_spirit_writer_template.h +++ /dev/null @@ -1,243 +0,0 @@ -#ifndef JSON_SPIRIT_WRITER_TEMPLATE -#define JSON_SPIRIT_WRITER_TEMPLATE - -// Copyright John W. Wilkinson 2007 - 2009. -// Distributed under the MIT License, see accompanying file LICENSE.txt - -// json spirit version 4.03 - -#include "json_spirit_value.h" - -#include -#include -#include - -namespace json_spirit -{ - inline char to_hex_char( unsigned int c ) - { - assert( c <= 0xF ); - - const char ch = static_cast< char >( c ); - - if( ch < 10 ) return '0' + ch; - - return 'A' - 10 + ch; - } - - template< class String_type > - String_type non_printable_to_string( unsigned int c ) - { - String_type result( 6, '\\' ); - - result[1] = 'u'; - - result[ 5 ] = to_hex_char( c & 0x000F ); c >>= 4; - result[ 4 ] = to_hex_char( c & 0x000F ); c >>= 4; - result[ 3 ] = to_hex_char( c & 0x000F ); c >>= 4; - result[ 2 ] = to_hex_char( c & 0x000F ); - - return result; - } - - template< typename Char_type, class String_type > - bool add_esc_char( Char_type c, String_type& s ) - { - switch( c ) - { - case '"': s += to_str< String_type >( "\\\"" ); return true; - case '\\': s += to_str< String_type >( "\\\\" ); return true; - case '\b': s += to_str< String_type >( "\\b" ); return true; - case '\f': s += to_str< String_type >( "\\f" ); return true; - case '\n': s += to_str< String_type >( "\\n" ); return true; - case '\r': s += to_str< String_type >( "\\r" ); return true; - case '\t': s += to_str< String_type >( "\\t" ); return true; - } - - return false; - } - - template< class String_type > - String_type add_esc_chars( const String_type& s ) - { - typedef typename String_type::const_iterator Iter_type; - typedef typename String_type::value_type Char_type; - - String_type result; - - const Iter_type end( s.end() ); - - for( Iter_type i = s.begin(); i != end; ++i ) - { - const Char_type c( *i ); - - if( add_esc_char( c, result ) ) continue; - - const wint_t unsigned_c( ( c >= 0 ) ? c : 256 + c ); - - if( iswprint( unsigned_c ) ) - { - result += c; - } - else - { - result += non_printable_to_string< String_type >( unsigned_c ); - } - } - - return result; - } - - // this class generates the JSON text, - // it keeps track of the indentation level etc. - // - template< class Value_type, class Ostream_type > - class Generator - { - typedef typename Value_type::Config_type Config_type; - typedef typename Config_type::String_type String_type; - typedef typename Config_type::Object_type Object_type; - typedef typename Config_type::Array_type Array_type; - typedef typename String_type::value_type Char_type; - typedef typename Object_type::value_type Obj_member_type; - - public: - - Generator( const Value_type& value, Ostream_type& os, bool pretty ) - : os_( os ) - , indentation_level_( 0 ) - , pretty_( pretty ) - { - output( value ); - } - - private: - - void output( const Value_type& value ) - { - switch( value.type() ) - { - case obj_type: output( value.get_obj() ); break; - case array_type: output( value.get_array() ); break; - case str_type: output( value.get_str() ); break; - case bool_type: output( value.get_bool() ); break; - case int_type: output_int( value ); break; - case real_type: os_ << std::showpoint << std::setprecision( 16 ) - << value.get_real(); break; - case null_type: os_ << "null"; break; - default: assert( false ); - } - } - - void output( const Object_type& obj ) - { - output_array_or_obj( obj, '{', '}' ); - } - - void output( const Array_type& arr ) - { - output_array_or_obj( arr, '[', ']' ); - } - - void output( const Obj_member_type& member ) - { - output( Config_type::get_name( member ) ); space(); - os_ << ':'; space(); - output( Config_type::get_value( member ) ); - } - - void output_int( const Value_type& value ) - { - if( value.is_uint64() ) - { - os_ << value.get_uint64(); - } - else - { - os_ << value.get_int64(); - } - } - - void output( const String_type& s ) - { - os_ << '"' << add_esc_chars( s ) << '"'; - } - - void output( bool b ) - { - os_ << to_str< String_type >( b ? "true" : "false" ); - } - - template< class T > - void output_array_or_obj( const T& t, Char_type start_char, Char_type end_char ) - { - os_ << start_char; new_line(); - - ++indentation_level_; - - for( typename T::const_iterator i = t.begin(); i != t.end(); ++i ) - { - indent(); output( *i ); - - typename T::const_iterator next = i; - - if( ++next != t.end()) - { - os_ << ','; - } - - new_line(); - } - - --indentation_level_; - - indent(); os_ << end_char; - } - - void indent() - { - if( !pretty_ ) return; - - for( int i = 0; i < indentation_level_; ++i ) - { - os_ << " "; - } - } - - void space() - { - if( pretty_ ) os_ << ' '; - } - - void new_line() - { - if( pretty_ ) os_ << '\n'; - } - - Generator& operator=( const Generator& ); // to prevent "assignment operator could not be generated" warning - - Ostream_type& os_; - int indentation_level_; - bool pretty_; - }; - - template< class Value_type, class Ostream_type > - void write_stream( const Value_type& value, Ostream_type& os, bool pretty ) - { - Generator< Value_type, Ostream_type >( value, os, pretty ); - } - - template< class Value_type > - typename Value_type::String_type write_string( const Value_type& value, bool pretty ) - { - typedef typename Value_type::String_type::value_type Char_type; - - std::basic_ostringstream< Char_type > os; - - write_stream( value, os, pretty ); - - return os.str(); - } -} - -#endif diff --git a/source/live_client.cpp b/source/live_client.cpp index 975a661c..659a8403 100644 --- a/source/live_client.cpp +++ b/source/live_client.cpp @@ -46,15 +46,15 @@ bool LiveClient::connect(const std::string& address, uint16_t port) auto& service = connection.get_service(); if(!resolver) { - resolver = std::make_shared(service); + resolver = std::make_shared(service); } if(!socket) { - socket = std::make_shared(service); + socket = std::make_shared(service); } - boost::asio::ip::tcp::resolver::query query(address, std::to_string(port)); - resolver->async_resolve(query, [this](const boost::system::error_code& error, boost::asio::ip::tcp::resolver::iterator endpoint_iterator) -> void + asio::ip::tcp::resolver::query query(address, std::to_string(port)); + resolver->async_resolve(query, [this](const std::error_code& error, asio::ip::tcp::resolver::iterator endpoint_iterator) -> void { if(error) { logMessage("Error: " + error.message()); @@ -90,19 +90,19 @@ bool LiveClient::connect(const std::string& address, uint16_t port) return true; } -void LiveClient::tryConnect(boost::asio::ip::tcp::resolver::iterator endpoint_iterator) +void LiveClient::tryConnect(asio::ip::tcp::resolver::iterator endpoint_iterator) { if(stopped) { return; } - if(endpoint_iterator == boost::asio::ip::tcp::resolver::iterator()) { + if(endpoint_iterator == asio::ip::tcp::resolver::iterator()) { return; } logMessage("Joining server " + endpoint_iterator->host_name() + ":" + endpoint_iterator->service_name() + "..."); - boost::asio::async_connect(*socket, endpoint_iterator, [this](boost::system::error_code error, boost::asio::ip::tcp::resolver::iterator endpoint_iterator) -> void + asio::async_connect(*socket, endpoint_iterator, [this](std::error_code error, asio::ip::tcp::resolver::iterator endpoint_iterator) -> void { if(!socket->is_open()) { tryConnect(++endpoint_iterator); @@ -116,7 +116,7 @@ void LiveClient::tryConnect(boost::asio::ip::tcp::resolver::iterator endpoint_it }); } } else { - socket->set_option(boost::asio::ip::tcp::no_delay(true), error); + socket->set_option(asio::ip::tcp::no_delay(true), error); if(error) { wxTheApp->CallAfter([this]() { close(); @@ -148,15 +148,15 @@ void LiveClient::close() stopped = true; } -bool LiveClient::handleError(const boost::system::error_code& error) +bool LiveClient::handleError(const std::error_code& error) { - if(error == boost::asio::error::eof || error == boost::asio::error::connection_reset) { + if(error == asio::error::eof || error == asio::error::connection_reset) { wxTheApp->CallAfter([this]() { log->Message(wxString() + getHostName() + ": disconnected."); close(); }); return true; - } else if(error == boost::asio::error::connection_aborted) { + } else if(error == asio::error::connection_aborted) { logMessage("You have left the server."); return true; } @@ -174,9 +174,9 @@ std::string LiveClient::getHostName() const void LiveClient::receiveHeader() { readMessage.position = 0; - boost::asio::async_read(*socket, - boost::asio::buffer(readMessage.buffer, 4), - [this](const boost::system::error_code& error, size_t bytesReceived) -> void { + asio::async_read(*socket, + asio::buffer(readMessage.buffer, 4), + [this](const std::error_code& error, size_t bytesReceived) -> void { if(error) { if(!handleError(error)) { logMessage(wxString() + getHostName() + ": " + error.message()); @@ -193,9 +193,9 @@ void LiveClient::receiveHeader() void LiveClient::receive(uint32_t packetSize) { readMessage.buffer.resize(readMessage.position + packetSize); - boost::asio::async_read(*socket, - boost::asio::buffer(&readMessage.buffer[readMessage.position], packetSize), - [this](const boost::system::error_code& error, size_t bytesReceived) -> void { + asio::async_read(*socket, + asio::buffer(&readMessage.buffer[readMessage.position], packetSize), + [this](const std::error_code& error, size_t bytesReceived) -> void { if(error) { if(!handleError(error)) { logMessage(wxString() + getHostName() + ": " + error.message()); @@ -215,9 +215,9 @@ void LiveClient::receive(uint32_t packetSize) void LiveClient::send(NetworkMessage& message) { memcpy(&message.buffer[0], &message.size, 4); - boost::asio::async_write(*socket, - boost::asio::buffer(message.buffer, message.size + 4), - [this](const boost::system::error_code& error, size_t bytesTransferred) -> void { + asio::async_write(*socket, + asio::buffer(message.buffer, message.size + 4), + [this](const std::error_code& error, size_t bytesTransferred) -> void { if(error) { logMessage(wxString() + getHostName() + ": " + error.message()); } diff --git a/source/live_client.h b/source/live_client.h index f5fb70b5..13b9937f 100644 --- a/source/live_client.h +++ b/source/live_client.h @@ -34,10 +34,10 @@ class LiveClient : public LiveSocket // bool connect(const std::string& address, uint16_t port); - void tryConnect(boost::asio::ip::tcp::resolver::iterator endpoint); + void tryConnect(asio::ip::tcp::resolver::iterator endpoint); void close(); - bool handleError(const boost::system::error_code& error); + bool handleError(const std::error_code& error); // std::string getHostName() const; @@ -83,8 +83,8 @@ class LiveClient : public LiveSocket std::set queryNodeList; wxString currentOperation; - std::shared_ptr resolver; - std::shared_ptr socket; + std::shared_ptr resolver; + std::shared_ptr socket; Editor* editor; diff --git a/source/live_peer.cpp b/source/live_peer.cpp index 8cd1eda8..72b1df43 100644 --- a/source/live_peer.cpp +++ b/source/live_peer.cpp @@ -24,7 +24,7 @@ #include "editor.h" -LivePeer::LivePeer(LiveServer* server, boost::asio::ip::tcp::socket socket) : LiveSocket(), +LivePeer::LivePeer(LiveServer* server, asio::ip::tcp::socket socket) : LiveSocket(), readMessage(), server(server), socket(std::move(socket)), color(), id(0), clientId(0), connected(false) { ASSERT(server != nullptr); @@ -42,13 +42,13 @@ void LivePeer::close() server->removeClient(id); } -bool LivePeer::handleError(const boost::system::error_code& error) +bool LivePeer::handleError(const std::error_code& error) { - if(error == boost::asio::error::eof || error == boost::asio::error::connection_reset) { + if(error == asio::error::eof || error == asio::error::connection_reset) { logMessage(wxString() + getHostName() + ": disconnected."); close(); return true; - } else if(error == boost::asio::error::connection_aborted) { + } else if(error == asio::error::connection_aborted) { logMessage(name + " have left the server."); return true; } @@ -63,9 +63,9 @@ std::string LivePeer::getHostName() const void LivePeer::receiveHeader() { readMessage.position = 0; - boost::asio::async_read(socket, - boost::asio::buffer(readMessage.buffer, 4), - [this](const boost::system::error_code& error, size_t bytesReceived) -> void { + asio::async_read(socket, + asio::buffer(readMessage.buffer, 4), + [this](const std::error_code& error, size_t bytesReceived) -> void { if(error) { if(!handleError(error)) { logMessage(wxString() + getHostName() + ": " + error.message()); @@ -82,9 +82,9 @@ void LivePeer::receiveHeader() void LivePeer::receive(uint32_t packetSize) { readMessage.buffer.resize(readMessage.position + packetSize); - boost::asio::async_read(socket, - boost::asio::buffer(&readMessage.buffer[readMessage.position], packetSize), - [this](const boost::system::error_code& error, size_t bytesReceived) -> void { + asio::async_read(socket, + asio::buffer(&readMessage.buffer[readMessage.position], packetSize), + [this](const std::error_code& error, size_t bytesReceived) -> void { if(error) { if(!handleError(error)) { logMessage(wxString() + getHostName() + ": " + error.message()); @@ -108,9 +108,9 @@ void LivePeer::receive(uint32_t packetSize) void LivePeer::send(NetworkMessage& message) { memcpy(&message.buffer[0], &message.size, 4); - boost::asio::async_write(socket, - boost::asio::buffer(message.buffer, message.size + 4), - [this](const boost::system::error_code& error, size_t bytesTransferred) -> void { + asio::async_write(socket, + asio::buffer(message.buffer, message.size + 4), + [this](const std::error_code& error, size_t bytesTransferred) -> void { if(error) { logMessage(wxString() + getHostName() + ": " + error.message()); } diff --git a/source/live_peer.h b/source/live_peer.h index b167a1ad..d119313f 100644 --- a/source/live_peer.h +++ b/source/live_peer.h @@ -25,11 +25,11 @@ class LiveServer; class LivePeer : public LiveSocket { public: - LivePeer(LiveServer* server, boost::asio::ip::tcp::socket socket); + LivePeer(LiveServer* server, asio::ip::tcp::socket socket); ~LivePeer(); void close(); - bool handleError(const boost::system::error_code& error); + bool handleError(const std::error_code& error); // uint32_t getId() const { return id; } @@ -69,7 +69,7 @@ class LivePeer : public LiveSocket NetworkMessage readMessage; LiveServer* server; - boost::asio::ip::tcp::socket socket; + asio::ip::tcp::socket socket; wxColor color; diff --git a/source/live_server.cpp b/source/live_server.cpp index 70d60ee1..cc44e155 100644 --- a/source/live_server.cpp +++ b/source/live_server.cpp @@ -45,13 +45,13 @@ bool LiveServer::bind() } auto& service = connection.get_service(); - acceptor = std::make_shared(service); + acceptor = std::make_shared(service); - boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::tcp::v4(), port); + asio::ip::tcp::endpoint endpoint(asio::ip::tcp::v4(), port); acceptor->open(endpoint.protocol()); - boost::system::error_code error; - acceptor->set_option(boost::asio::ip::tcp::no_delay(true), error); + std::error_code error; + acceptor->set_option(asio::ip::tcp::no_delay(true), error); if(error) { setLastError("Error: " + error.message()); return false; @@ -95,12 +95,12 @@ void LiveServer::acceptClient() } if(!socket) { - socket = std::make_shared( + socket = std::make_shared( NetworkConnection::getInstance().get_service() ); } - acceptor->async_accept(*socket, [this](const boost::system::error_code& error) -> void + acceptor->async_accept(*socket, [this](const std::error_code& error) -> void { if(error) { // diff --git a/source/live_server.h b/source/live_server.h index bc43624a..fd440ac1 100644 --- a/source/live_server.h +++ b/source/live_server.h @@ -73,8 +73,8 @@ class LiveServer : public LiveSocket protected: std::unordered_map clients; - std::shared_ptr acceptor; - std::shared_ptr socket; + std::shared_ptr acceptor; + std::shared_ptr socket; Editor* editor; diff --git a/source/main.h b/source/main.h index a1af7a91..ca608a73 100644 --- a/source/main.h +++ b/source/main.h @@ -30,9 +30,6 @@ #define _CRTDBG_MAP_ALLOC -#include -#include - #pragma warning(disable: 4291) _Ret_bytecap_(_Size) inline void * __CRTDECL operator new(size_t _Size, const char* file, int line) { return ::operator new(_Size, _NORMAL_BLOCK, file, line); } @@ -46,18 +43,18 @@ _Ret_bytecap_(_Size) inline void* __CRTDECL operator new[](size_t _Size, const c #endif -// Boost libraries -#include -#include -#include +#include +#include +#include -#include #include "definitions.h" #include #ifndef WX_PRECOMP # include #endif +#include +#include #include #include #include @@ -87,7 +84,7 @@ _Ret_bytecap_(_Size) inline void* __CRTDECL operator new[](size_t _Size, const c #include "ext/pugixml.hpp" // Libarchive, for OTGZ -#ifdef OTGZ_SUPPORT +#if OTGZ_SUPPORT > 0 #include #include #endif @@ -104,6 +101,8 @@ _Ret_bytecap_(_Size) inline void* __CRTDECL operator new[](size_t _Size, const c #endif // The complete STL ?, well, almost ;) +#include +#include #include #include #include @@ -121,12 +120,11 @@ _Ret_bytecap_(_Size) inline void* __CRTDECL operator new[](size_t _Size, const c #include #include #include +#include +#include - -typedef std::vector StringVector; -typedef wxFileName FileName; - -#include "json.h" +using StringVector = std::vector; +using FileName= wxFileName; #include "con_vector.h" #include "common.h" diff --git a/source/net_connection.cpp b/source/net_connection.cpp index 14a3adff..68291148 100644 --- a/source/net_connection.cpp +++ b/source/net_connection.cpp @@ -101,11 +101,11 @@ bool NetworkConnection::start() stopped = false; if(!service) { - service = new boost::asio::io_service; + service = new asio::io_service; } thread = std::thread([this]() -> void { - boost::asio::io_service& serviceRef = *service; + asio::io_service& serviceRef = *service; try { while(!stopped) { serviceRef.run_one(); @@ -132,7 +132,7 @@ void NetworkConnection::stop() service = nullptr; } -boost::asio::io_service& NetworkConnection::get_service() +asio::io_service& NetworkConnection::get_service() { return *service; } diff --git a/source/net_connection.h b/source/net_connection.h index 520175b2..e6657a5a 100644 --- a/source/net_connection.h +++ b/source/net_connection.h @@ -73,10 +73,10 @@ class NetworkConnection bool start(); void stop(); - boost::asio::io_service& get_service(); + asio::io_service& get_service(); private: - boost::asio::io_service* service; + asio::io_service* service; std::thread thread; bool stopped; }; diff --git a/source/otml.h b/source/otml.h index e3126896..cdac5e03 100644 --- a/source/otml.h +++ b/source/otml.h @@ -26,29 +26,18 @@ #include #include #include -#include -#include +#include class OTMLNode; class OTMLDocument; class OTMLParser; class OTMLEmitter; -#ifdef __GXX_EXPERIMENTAL_CXX0X__ -typedef std::shared_ptr OTMLNodePtr; -typedef std::enable_shared_from_this OTMLNodeEnableSharedFromThis; -typedef std::shared_ptr OTMLDocumentPtr; -typedef std::weak_ptr OTMLNodeWeakPtr; -#else -#include -#include -typedef boost::shared_ptr OTMLNodePtr; -typedef boost::enable_shared_from_this OTMLNodeEnableSharedFromThis; -typedef boost::shared_ptr OTMLDocumentPtr; -typedef boost::weak_ptr OTMLNodeWeakPtr; -#endif - -typedef std::vector OTMLNodeList; +using OTMLNodePtr = std::shared_ptr; +using OTMLNodeEnableSharedFromThis = std::enable_shared_from_this; +using OTMLDocumentPtr = std::shared_ptr; +using OTMLNodeWeakPtr = std::weak_ptr; +using OTMLNodeList = std::vector; namespace otml_util { template @@ -148,7 +137,6 @@ namespace otml_util { } }; - class OTMLException : public std::exception { public: OTMLException(const std::string& error) : m_what(error) { } @@ -482,13 +470,13 @@ inline std::string OTMLNode::emit() { template<> inline std::string OTMLNode::value() { std::string value = m_value; - if(boost::starts_with(value, "\"") && boost::ends_with(value, "\"")) { + if (value.starts_with("\"") && value.ends_with("\"")) { value = value.substr(1, value.length() - 2); - boost::replace_all(value, "\\\\", "\\"); - boost::replace_all(value, "\\\"", "\""); - boost::replace_all(value, "\\t", "\t"); - boost::replace_all(value, "\\n", "\n"); - boost::replace_all(value, "\\'", "\'"); + value = std::regex_replace(value, std::regex("\\\\"), "\\"); + value = std::regex_replace(value, std::regex("\\\""), "\""); + value = std::regex_replace(value, std::regex("\\t"), "\t"); + value = std::regex_replace(value, std::regex("\\n"), "\n"); + value = std::regex_replace(value, std::regex("\\'"), "\'"); } return value; } @@ -665,22 +653,24 @@ inline int OTMLParser::getLineDepth(const std::string& line, bool multilining) { inline void OTMLParser::parseLine(std::string line) { int depth = getLineDepth(line); - if(depth == -1) + if (depth == -1) return; - boost::trim(line); - if(line.empty()) + + trim(line); + if (line.empty()) return; - if(line.substr(0, 2) == "//") + if (line.substr(0, 2) == "//") return; - if(depth == currentDepth + 1) { + if (depth == currentDepth + 1) { currentParent = previousNode; } - else if(depth < currentDepth) { - for(int i = 0; iparent(); } - else if(depth != currentDepth) + else if (depth != currentDepth) { throw OTMLException(doc, "invalid indentation depth, are you indenting correctly?", currentLine); + } currentDepth = depth; parseNode(line); } @@ -692,7 +682,7 @@ inline void OTMLParser::parseNode(const std::string& data) { int nodeLine = currentLine; if(!data.empty() && data[0] == '-') { value = data.substr(1); - boost::trim(value); + trim(value); } else if(dotsPos != std::string::npos) { tag = data.substr(0, dotsPos); @@ -702,8 +692,8 @@ inline void OTMLParser::parseNode(const std::string& data) { else { tag = data; } - boost::trim(tag); - boost::trim(value); + trim(tag); + trim(value); if(value == "|" || value == "|-" || value == "|+") { std::string multiLineData; do { @@ -714,7 +704,7 @@ inline void OTMLParser::parseNode(const std::string& data) { multiLineData += line.substr((currentDepth + 1) * 2); } else { - boost::trim(line); + trim(line); if(!line.empty()) { in.seekg(lastPos, std::ios::beg); currentLine--; @@ -740,13 +730,15 @@ inline void OTMLParser::parseNode(const std::string& data) { if(value == "~") node->setNull(true); else { - if(boost::starts_with(value, "[") && boost::ends_with(value, "]")) { - typedef boost::tokenizer > Tokenizer; + if (value.starts_with("[") && value.ends_with("]")) { std::string tmp = value.substr(1, value.length() - 2); - Tokenizer tok(tmp); - for(Tokenizer::iterator it = tok.begin(), end = tok.end(); it != end; ++it) { + std::regex sep(","); + std::sregex_token_iterator it(tmp.begin(), tmp.end(), sep, -1); + std::sregex_token_iterator end; + std::vector tokens(it, end); + for (const auto& token : tokens) { std::string v = *it; - boost::trim(v); + trim(v); node->writeIn(v); } } diff --git a/source/updater.cpp b/source/updater.cpp index c7798547..d4f48ad4 100644 --- a/source/updater.cpp +++ b/source/updater.cpp @@ -21,8 +21,6 @@ #include -#include "json.h" - #include "updater.h" const wxEventType EVT_UPDATE_CHECK_FINISHED = wxNewEventType(); diff --git a/vcproj/Project/RME.vcxproj b/vcproj/Project/RME.vcxproj index 5ff74c8d..1232791d 100644 --- a/vcproj/Project/RME.vcxproj +++ b/vcproj/Project/RME.vcxproj @@ -163,7 +163,7 @@ main.h true false - stdcpp17 + stdcpp20 comctl32.lib;WS2_32.lib;%(AdditionalDependencies) @@ -196,7 +196,7 @@ -Zm114 %(AdditionalOptions) - stdcpp17 + stdcpp20 comctl32.lib;WS2_32.lib;%(AdditionalDependencies) @@ -406,16 +406,6 @@ - - - - - - - - - - @@ -430,24 +420,6 @@ Create - - NotUsing - NotUsing - NotUsing - NotUsing - - - NotUsing - NotUsing - NotUsing - NotUsing - - - NotUsing - NotUsing - NotUsing - NotUsing - diff --git a/vcproj/Project/RME.vcxproj.filters b/vcproj/Project/RME.vcxproj.filters deleted file mode 100644 index eedc7906..00000000 --- a/vcproj/Project/RME.vcxproj.filters +++ /dev/null @@ -1,665 +0,0 @@ - - - - - {36c9f3e9-0346-426b-976c-14a472c01a93} - - - {a82f2533-e188-43a1-ac5b-b1df510dd6f1} - - - {d223bab0-0cb4-4527-81e4-0c4f57103321} - - - {a720d52e-535a-4ff4-bec1-22d2759dbf38} - - - {0cde07af-af94-45e2-835e-08050e01aa12} - - - {346cd898-254a-49be-b31c-6c1fbccd71cd} - - - {0ceb558e-6637-444e-908a-73018678d05e} - - - {6ea05490-c25b-4fed-b92b-b38d750431c2} - - - {dab9c9fe-8368-4d72-ade9-2e601597bd38} - - - {1e2eb3db-ae1f-4c1a-91b1-02a38b980e34} - - - {3c2a64b5-bce7-48f5-b3e4-81cca5b7c153} - - - {36763409-2fe7-4482-9863-3e17d4deb599} - - - {0e11270a-3f6c-4af2-8862-67490845912b} - - - {a643de00-a65c-4c43-a3be-abba8208e654} - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - {053b3f61-2179-4de8-9730-6c7f10063023} - - - - - gui\dialogs - - - editor - - - gui - - - objects - - - editor\brushes - - - editor\brushes - - - managers - - - common - - - common - - - gui\dialogs - - - objects - - - common - - - editor - - - objects - - - managers - - - gui\controls - - - common - - - editor - - - gui\map window - - - common - - - gui\graphics - - - gui - - - gui - - - objects - - - editor\io - - - editor\io - - - objects - - - managers - - - objects - - - json - - - json - - - json - - - json - - - json - - - json - - - json - - - json - - - json - - - json - - - live - - - live - - - live - - - live - - - live - - - live - - - - gui - - - objects - - - objects - - - gui\map window - - - gui\map window - - - objects - - - gui\map window - - - gui\map window - - - managers - - - gui\dialogs - - - common - - - live - - - objects - - - gui\palette - - - gui\palette - - - gui\palette - - - gui\palette - - - gui\palette - - - gui\palette - - - - objects - - - gui\dialogs - - - editor - - - gui\dialogs - - - live - - - editor - - - common - - - objects - - - gui\graphics - - - managers\templates - - - common - - - objects - - - objects - - - objects - - - editor - - - objects - - - editor\brushes - - - editor\brushes - - - editor\brushes - - - editor\brushes - - - editor\brushes - - - editor\brushes - - - editor\brushes - - - editor\brushes - - - editor\brushes - - - editor\brushes - - - editor\brushes - - - gui\dialogs - - - live - - - - gui\controls - - - gui\dialogs - - - gui\dialogs - - - gui\dialogs - - - gui\dialogs - - - editor - - - gui\dialogs - - - gui\controls - - - gui\dialogs - - - gui - - - gui - - - gui\dialogs - - - gui\dialogs - - - - - json - - - json - - - json - - - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - gui\dialogs - - - gui\dialogs - - - gui\dialogs - - - gui\dialogs - - - gui\dialogs - - - gui\dialogs - - - gui\graphics - - - gui\map window - - - gui\map window - - - gui\map window - - - gui\map window - - - gui\map window - - - common - - - common - - - common - - - common - - - gui\controls - - - objects - - - objects - - - objects - - - objects - - - objects - - - objects - - - objects - - - objects - - - objects - - - objects - - - objects - - - objects - - - objects - - - managers\templates - - - managers\templates - - - managers\templates - - - managers - - - managers - - - managers - - - managers - - - live - - - live - - - live - - - live - - - live - - - live - - - live - - - live - - - gui - - - gui\palette - - - gui\palette - - - gui\palette - - - gui\palette - - - gui\palette - - - gui\palette - - - gui - - - editor\brushes - - - editor\brushes - - - editor\brushes - - - editor\brushes - - - editor\brushes - - - editor\brushes - - - editor\brushes - - - editor\brushes - - - editor\brushes - - - editor\brushes - - - editor\brushes - - - editor\brushes - - - editor\brushes - - - editor\io - - - editor\io - - - editor\brushes - - - gui\controls - - - gui\dialogs - - - gui\dialogs - - - gui\dialogs - - - managers\templates - - - gui - - - gui\dialogs - - - editor - - - gui\dialogs - - - gui\controls - - - gui\dialogs - - - gui - - - gui - - - gui\dialogs - - - gui\dialogs - - - - - resources - - - \ No newline at end of file From 692f8dabfb932572a25ef0ac2b73869ee19d9bec Mon Sep 17 00:00:00 2001 From: Eduardo Dantas <8551443+dudantas@users.noreply.github.com> Date: Sat, 25 Mar 2023 18:37:38 -0300 Subject: [PATCH 2/2] improve: add github actions workflow and rework cmakelists --- .github/workflows/analysis-sonarcloud.yml | 101 ++++++ .github/workflows/build-ubuntu.yml | 84 +++++ .github/workflows/build-windows.yml | 49 +++ CMakeLists.txt | 138 ++++++--- CMakeSettings.json | 21 +- cmake/LoggingHelper.cmake | 27 ++ cmake/MessageColors.cmake | 13 + cmake/remeres.ico | Bin 0 -> 16958 bytes cmake/remeres.rc | 1 + source/CMakeLists.txt | 360 +++++++++------------- source/application.cpp | 4 +- source/main.h | 4 +- vcpkg.json | 13 + 13 files changed, 554 insertions(+), 261 deletions(-) create mode 100644 .github/workflows/analysis-sonarcloud.yml create mode 100644 .github/workflows/build-ubuntu.yml create mode 100644 .github/workflows/build-windows.yml create mode 100644 cmake/LoggingHelper.cmake create mode 100644 cmake/MessageColors.cmake create mode 100644 cmake/remeres.ico create mode 100644 cmake/remeres.rc create mode 100644 vcpkg.json diff --git a/.github/workflows/analysis-sonarcloud.yml b/.github/workflows/analysis-sonarcloud.yml new file mode 100644 index 00000000..8e768150 --- /dev/null +++ b/.github/workflows/analysis-sonarcloud.yml @@ -0,0 +1,101 @@ +--- +name: Analysis - SonarCloud + +on: + pull_request_target: + types: [opened, synchronize, reopened] + push: + branches: + - main + +env: + VCPKG_BUILD_TYPE: release + CMAKE_BUILD_PARALLEL_LEVEL: 2 + MAKEFLAGS: '-j 2' + NUMBER_OF_PROCESSORS: 2 + +jobs: + sonarcloud: + name: SonarCloud + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v3 + if: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target' }} + with: + fetch-depth: 0 + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + + - uses: actions/checkout@v3 + if: ${{ github.event_name == 'push' }} + with: + fetch-depth: 0 + + - name: Install Linux Dependencies + run: > + sudo apt-get update && sudo apt-get install ccache linux-headers-$(uname -r) + + - name: Switch to gcc-11 + run: | + sudo apt install gcc-11 g++-11 + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11 + sudo update-alternatives --set gcc /usr/bin/gcc-11 + + - name: CCache + id: ccache + uses: actions/cache@main + with: + path: $HOME/.ccache + key: ccache-${{ runner.os }}-${{ hashFiles('**/src') }} + restore-keys: | + ccache-${{ runner.os}}- + + - name: Cache SonarCloud packages + uses: actions/cache@main + with: + path: $HOME/.sonar/cache + key: sonar-${{ runner.os}}-${{ hashFiles('**/src') }} + restore-keys: | + sonar-${{ runner.os}}- + + - name: Restore artifacts and install vcpkg + id: vcpkg-step + run: | + vcpkgCommitId=$(grep '.builtin-baseline' vcpkg.json | awk -F: '{print $2}' | tr -d '," ') + echo "vcpkg commit ID: $vcpkgCommitId" + echo "::set-output name=vcpkgGitCommitId::$vcpkgCommitId" + - name: Get vcpkg commit id from vcpkg.json + uses: lukka/run-vcpkg@main + with: + vcpkgGitURL: "https://github.com/microsoft/vcpkg.git" + vcpkgGitCommitId: ${{ steps.vcpkg-step.outputs.vcpkgGitCommitId }} + + - name: Install sonar-scanner + uses: SonarSource/sonarcloud-github-c-cpp@v1 + + - name: Generate compilation database + run: | + mkdir -p build + cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" -DOPTIONS_ENABLE_CCACHE=ON -S . -B build + + - name: Run PR sonar-scanner + if: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: | + sonar-scanner \ + --define sonar.cfamily.compile-commands=build/compile_commands.json \ + --define sonar.pullrequest.key=${{ github.event.pull_request.number }} \ + --define sonar.pullrequest.branch=${{ github.event.pull_request.head.ref }} \ + --define sonar.pullrequest.base=${{ github.event.pull_request.base_ref }} + + - name: Run sonar-scanner + if: ${{ github.event_name == 'push' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: | + sonar-scanner \ + --define sonar.cfamily.compile-commands=build/compile_commands.json diff --git a/.github/workflows/build-ubuntu.yml b/.github/workflows/build-ubuntu.yml new file mode 100644 index 00000000..22edbd42 --- /dev/null +++ b/.github/workflows/build-ubuntu.yml @@ -0,0 +1,84 @@ +--- +name: Build - Ubuntu + +on: + workflow_dispatch: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + push: + branches: + - main + +env: + CMAKE_BUILD_PARALLEL_LEVEL: 2 + MAKEFLAGS: '-j 2' + +jobs: + job: + if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} + name: ${{ matrix.os }}-${{ matrix.buildtype }} + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: [ubuntu-22.04] + buildtype: [Release, Debug] + include: + - os: ubuntu-22.04 + triplet: x64-linux + + steps: + - name: Checkout repository + uses: actions/checkout@main + + - name: Install Linux Dependencies + run: > + sudo apt-get update && sudo apt-get install ccache linux-headers-$(uname -r) + + - name: Switch to gcc-11 + run: | + sudo apt install gcc-11 g++-11 + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11 + sudo update-alternatives --set gcc /usr/bin/gcc-11 + + - name: CCache + uses: hendrikmuhs/ccache-action@main + with: + max-size: "1G" + key: ccache-${{ matrix.os }}-${{ matrix.buildtype }} + restore-keys: | + ccache-${{ matrix.os }} + + - name: Restore artifacts and install vcpkg + id: vcpkg-step + run: | + vcpkgCommitId=$(grep '.builtin-baseline' vcpkg.json | awk -F: '{print $2}' | tr -d '," ') + echo "vcpkg commit ID: $vcpkgCommitId" + echo "::set-output name=vcpkgGitCommitId::$vcpkgCommitId" + - name: Get vcpkg commit id from vcpkg.json + uses: lukka/run-vcpkg@main + with: + vcpkgGitURL: "https://github.com/microsoft/vcpkg.git" + vcpkgGitCommitId: ${{ steps.vcpkg-step.outputs.vcpkgGitCommitId }} + + - name: Get latest CMake and ninja + uses: lukka/get-cmake@main + + - name: Install additional libraries + run: sudo apt-get install libasio-dev nlohmann-json3-dev libfmt-dev libxi-dev libgl1-mesa-dev libglu1-mesa-dev mesa-common-dev libxrandr-dev libxxf86vm-dev libglib2.0-dev at-spi2-core libwxgtk3.0-gtk3-dev libarchive-dev freeglut3-dev libxmu-dev libdbus-1-dev libxtst-dev + + - name: Run CMake Cache and Build + uses: lukka/run-cmake@v3 + with: + cmakeListsTxtPath: ${{ github.workspace }}/CMakeLists.txt + useVcpkgToolchainFile: true + buildDirectory: ${{ github.workspace }}/build/ + cmakeBuildType: ${{ matrix.buildtype }} + + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.os }}-${{ matrix.buildtype }} + path: | + ${{ github.workspace }}/remeres diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml new file mode 100644 index 00000000..71aaed43 --- /dev/null +++ b/.github/workflows/build-windows.yml @@ -0,0 +1,49 @@ +--- +name: Build - Windows + +on: + workflow_dispatch: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + push: + branches: + - main + - master + +jobs: + job: + if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} + name: ${{ matrix.os }}-${{ matrix.buildtype }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-2022] + buildtype: [Release, Debug] + include: + - os: windows-2022 + triplet: x64-windows + packages: > + sccache + steps: + - name: Setup MSBuild.exe + uses: microsoft/setup-msbuild@v1.1 + + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install vcpkg + run: | + git clone https://github.com/Microsoft/vcpkg.git + cd vcpkg + ./bootstrap-vcpkg.bat + ./vcpkg integrate install + + - name: Build project + run: msbuild.exe /p:VcpkgEnableManifest=true /p:Configuration=Release /p:Platform=x64 /p:VcpkgRoot=$env:GITHUB_WORKSPACE/vcpkg vcproj/RME.sln + + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.os }}-${{ matrix.buildtype }} + path: | + ${{ github.workspace }}/vcproj/x64/${{ matrix.buildtype }}/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 5daaf7de..9dd9c90e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,52 +1,96 @@ cmake_minimum_required(VERSION 3.1) -project(rme) +project(cmake) -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE RelWithDebInfo) +# ***************************************************************************** +# Vcpkg Configs +# ***************************************************************************** + +if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) + set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "") +endif() + +if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET) + set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "") +endif() + +set(VCPKG_FEATURE_FLAGS "versions") +set(VCPKG_BUILD_TYPE "release") + +# ***************************************************************************** +# Set Configs +# ***************************************************************************** + +set(CMAKE_CXX_STANDARD 20) +set(GNUCXX_MINIMUM_VERSION 11) +set(MSVC_MINIMUM_VERSION "19.32") +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# ***************************************************************************** +# Options +# ***************************************************************************** +option(OPTIONS_ENABLE_CCACHE "Enable ccache" OFF) +option(OPTIONS_ENABLE_SCCACHE "Use sccache to speed up compilation process" OFF) + +# ***************************************************************************** +# Set Sanity Check +# ***************************************************************************** + +# === GCC Minimum Version === +if (CMAKE_COMPILER_IS_GNUCXX) + message("-- Compiler: GCC - Version: ${CMAKE_CXX_COMPILER_VERSION}") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS GNUCXX_MINIMUM_VERSION) + message(FATAL_ERROR "GCC version must be at least ${GNUCXX_MINIMUM_VERSION}!") + endif() +endif() + +# === Minimum required version for visual studio === +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + message("-- Compiler: Visual Studio - Version: ${CMAKE_CXX_COMPILER_VERSION}") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS MSVC_MINIMUM_VERSION) + message(FATAL_ERROR "Visual Studio version must be at least ${MSVC_MINIMUM_VERSION}") + endif() +endif() + +# ***************************************************************************** +# Append cmake search path +# ***************************************************************************** +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + +# ***************************************************************************** +# Include cmake tools +# ***************************************************************************** +include(MessageColors) +include(LoggingHelper) + +# ***************************************************************************** +# Options Code +# ***************************************************************************** + +# === CCACHE === +if(OPTIONS_ENABLE_CCACHE) + find_program(CCACHE ccache) + if(CCACHE) + log_option_enabled("ccache") + set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE}) + else() + log_option_disabled("ccache") + endif() +endif() + +# === SCCACHE === +if(OPTIONS_ENABLE_SCCACHE) + find_program(SCCACHE_PATH sccache) + if(SCCACHE_PATH) + log_option_enabled("sccache") + set(CMAKE_C_COMPILER_LAUNCHER ${SCCACHE_PATH}) + set(CMAKE_CXX_COMPILER_LAUNCHER ${SCCACHE_PATH}) + else() + log_option_disabled("sccache") + endif() endif() -find_package(OpenGL REQUIRED) - -# LibArchive disabled in compilation level by default, see "#define OTGZ_SUPPORT" in the "definitions.h" file -#if(APPLE) -# set(CMAKE_PREFIX_PATH /usr/local/opt/libarchive) -#endif() -# If you need use, enable this: -#find_package(LibArchive REQUIRED) -#${LibArchive_INCLUDE_DIRS} ${LibArchive_LIBRARIES} - -find_package(asio CONFIG REQUIRED) -find_package(Threads REQUIRED) -find_package(wxWidgets COMPONENTS html aui gl adv core net base CONFIG REQUIRED) - -find_package(GLUT REQUIRED) -find_package(ZLIB REQUIRED) -find_package(fmt CONFIG REQUIRED) -find_package(nlohmann_json CONFIG REQUIRED) - -include(source/CMakeLists.txt) - -add_executable(${PROJECT_NAME} ${rme_H} ${rme_SRC}) - -set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20) -set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD_REQUIRED ON) - -# === PRECOMPILED HEADER === -target_precompile_headers(${PROJECT_NAME} PRIVATE source/main.h) - -include_directories( - ${OPENGL_INCLUDE_DIR} - ${GLUT_INCLUDE_DIRS} - ${ZLIB_INCLUDE_DIR} -) - -target_link_libraries(${PROJECT_NAME} - ${wxWidgets_LIBRARIES} - ${OPENGL_LIBRARIES} - ${GLUT_LIBRARIES} - ${ZLIB_LIBRARIES} - fmt::fmt - asio::asio - nlohmann_json::nlohmann_json -) +# ***************************************************************************** +# Add source project +# ***************************************************************************** +add_subdirectory(source) diff --git a/CMakeSettings.json b/CMakeSettings.json index f876ee21..c825dfc9 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -1,11 +1,22 @@ -{ +{ "configurations": [ { "name": "x64-Release", "generator": "Ninja", - "configurationType": "RelWithDebInfo", - "buildRoot": "${projectDir}\\out\\build\\${name}", - "installRoot": "${projectDir}\\out\\install\\${name}", + "configurationType": "Release", + "buildRoot": "${projectDir}\\build\\${name}", + "installRoot": "${projectDir}\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "msvc_x64_x64" ] + }, + { + "name": "x64-Debug", + "generator": "Ninja", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\build\\${name}", + "installRoot": "${projectDir}\\install\\${name}", "cmakeCommandArgs": "", "buildCommandArgs": "", "ctestCommandArgs": "", @@ -13,4 +24,4 @@ "variables": [] } ] -} \ No newline at end of file +} diff --git a/cmake/LoggingHelper.cmake b/cmake/LoggingHelper.cmake new file mode 100644 index 00000000..662769b0 --- /dev/null +++ b/cmake/LoggingHelper.cmake @@ -0,0 +1,27 @@ +function(log_info MSG) + message(STATUS "${MsgOk}${MSG}${MsgClr}") +endfunction() + +function(log_war MSG) + message(STATUS "${MsgWar}${MSG}${MsgClr}") +endfunction() + +function(log_err MSG) + message(SEND_ERROR "${MsgErr}${MSG}${MsgClr}") +endfunction() + +function(log_fatal MSG) + message(FATAL_ERROR "${MsgErr}${MSG}${MsgClr}") +endfunction() + +function(log_option_enabled OPTION) + message(STATUS "${MsgBold}Enabled:${MsgClr} ${MsgOk}${OPTION}${MsgClr}") +endfunction() + +function(log_option_disabled OPTION) + message(STATUS "${MsgBold}Disabled:${MsgClr} ${MsgWar}${OPTION}${MsgClr}") +endfunction() + +function(log_program_missing PROGRAM) + message(SEND_ERROR "${MsgErr}Unable to find ${PROGRAM}${MsgClr}") +endfunction() diff --git a/cmake/MessageColors.cmake b/cmake/MessageColors.cmake new file mode 100644 index 00000000..fa14557c --- /dev/null +++ b/cmake/MessageColors.cmake @@ -0,0 +1,13 @@ +if(NOT WIN32) + string(ASCII 27 Esc) + set(ColorReset "${Esc}[m") + set(ColorBold "${Esc}[1m") + set(ColorRed "${Esc}[31m") + set(ColorYellow "${Esc}[33m") + set(ColorGreen "${Esc}[32m") + + set(MsgErr "${ColorRed}${ColorBold}") + set(MsgWar "${ColorYellow}${ColorBold}") + set(MsgOk "${ColorGreen}${ColorBold}") + set(MsgClr "${ColorReset}") +endif() diff --git a/cmake/remeres.ico b/cmake/remeres.ico new file mode 100644 index 0000000000000000000000000000000000000000..e646d9fe7f1df810d01920ad905d4e3a39f252e3 GIT binary patch literal 16958 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ptp7&jS2`22!|~0w6I%KVLx}Rl;kpc?$Lkkv;R@|)mJ2s z4YfRQ-0{lnQs=94dxLGaBje6ZR8lQeRFi<##$1}SB+&chLENK!zo|Bz#tDNcDo93G zcRTKOiO}(+75BT_&~jgdjJ#x2@Uu`?lZX1MINZs!MP>o*Icx0@ovZ{0t)*he8|$B0 z8LJu+m&t@bB*yM({`c@7`plya(dZc0v+~>mDG7B)&V={Gn_UU}U*d?%1=`7`D3e^u@}^lbmk{?UEWczTC)+E;&_gNyRK8tV(w z`piy^h4FE!qpQq?m+MXh1^|(9Tew@ zxteR9M7Uf^7gXe|=<9p)Pl;`RlwQKJ_%X>oN(VyBrK7yHzH4$(p8vvLao&KX>}O(g zna^NGpnkyO{AaIhFVE?5RQ$TvLt|Bozwxe!IL|9e)rB!%z3O@KFZ1m`N(c5meSNQo zJ-jcPz|Y|=$%!(TOb@-eGBrqdURsFZth^YTnHAZ*KXu)!|Fplq?>}me|45Dg`(6K4 J;9sf0{{yQeKfeF~ literal 0 HcmV?d00001 diff --git a/cmake/remeres.rc b/cmake/remeres.rc new file mode 100644 index 00000000..eb23831e --- /dev/null +++ b/cmake/remeres.rc @@ -0,0 +1 @@ +MAINICON ICON "remeres.ico" diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 8a5b4181..7f2964a0 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -1,210 +1,156 @@ -set(rme_H -${CMAKE_CURRENT_LIST_DIR}/about_window.h -${CMAKE_CURRENT_LIST_DIR}/action.h -${CMAKE_CURRENT_LIST_DIR}/application.h -${CMAKE_CURRENT_LIST_DIR}/artprovider.h -${CMAKE_CURRENT_LIST_DIR}/basemap.h -${CMAKE_CURRENT_LIST_DIR}/browse_tile_window.h -${CMAKE_CURRENT_LIST_DIR}/brush.h -${CMAKE_CURRENT_LIST_DIR}/brush_enums.h -${CMAKE_CURRENT_LIST_DIR}/carpet_brush.h -${CMAKE_CURRENT_LIST_DIR}/client_version.h -${CMAKE_CURRENT_LIST_DIR}/common.h -${CMAKE_CURRENT_LIST_DIR}/common_windows.h -${CMAKE_CURRENT_LIST_DIR}/complexitem.h -${CMAKE_CURRENT_LIST_DIR}/con_vector.h -${CMAKE_CURRENT_LIST_DIR}/container_properties_window.h -${CMAKE_CURRENT_LIST_DIR}/copybuffer.h -${CMAKE_CURRENT_LIST_DIR}/monster.h -${CMAKE_CURRENT_LIST_DIR}/monster_brush.h -${CMAKE_CURRENT_LIST_DIR}/monsters.h -${CMAKE_CURRENT_LIST_DIR}/dat_debug_view.h -${CMAKE_CURRENT_LIST_DIR}/dcbutton.h -${CMAKE_CURRENT_LIST_DIR}/definitions.h -${CMAKE_CURRENT_LIST_DIR}/doodad_brush.h -${CMAKE_CURRENT_LIST_DIR}/editor.h -${CMAKE_CURRENT_LIST_DIR}/editor_tabs.h -${CMAKE_CURRENT_LIST_DIR}/enums.h -${CMAKE_CURRENT_LIST_DIR}/extension.h -${CMAKE_CURRENT_LIST_DIR}/extension_window.h -${CMAKE_CURRENT_LIST_DIR}/find_item_window.h -${CMAKE_CURRENT_LIST_DIR}/filehandle.h -${CMAKE_CURRENT_LIST_DIR}/graphics.h -${CMAKE_CURRENT_LIST_DIR}/ground_brush.h -${CMAKE_CURRENT_LIST_DIR}/gui.h -${CMAKE_CURRENT_LIST_DIR}/gui_ids.h -${CMAKE_CURRENT_LIST_DIR}/house.h -${CMAKE_CURRENT_LIST_DIR}/house_brush.h -${CMAKE_CURRENT_LIST_DIR}/house_exit_brush.h -${CMAKE_CURRENT_LIST_DIR}/iomap.h -${CMAKE_CURRENT_LIST_DIR}/iomap_otbm.h -${CMAKE_CURRENT_LIST_DIR}/item.h -${CMAKE_CURRENT_LIST_DIR}/item_attributes.h -${CMAKE_CURRENT_LIST_DIR}/items.h -${CMAKE_CURRENT_LIST_DIR}/live_action.h -${CMAKE_CURRENT_LIST_DIR}/live_client.h -${CMAKE_CURRENT_LIST_DIR}/live_packets.h -${CMAKE_CURRENT_LIST_DIR}/live_peer.h -${CMAKE_CURRENT_LIST_DIR}/live_server.h -${CMAKE_CURRENT_LIST_DIR}/live_socket.h -${CMAKE_CURRENT_LIST_DIR}/live_tab.h -${CMAKE_CURRENT_LIST_DIR}/main.h -${CMAKE_CURRENT_LIST_DIR}/main_menubar.h -${CMAKE_CURRENT_LIST_DIR}/main_toolbar.h -${CMAKE_CURRENT_LIST_DIR}/map.h -${CMAKE_CURRENT_LIST_DIR}/map_allocator.h -${CMAKE_CURRENT_LIST_DIR}/map_display.h -${CMAKE_CURRENT_LIST_DIR}/map_drawer.h -${CMAKE_CURRENT_LIST_DIR}/map_region.h -${CMAKE_CURRENT_LIST_DIR}/map_tab.h -${CMAKE_CURRENT_LIST_DIR}/map_window.h -${CMAKE_CURRENT_LIST_DIR}/materials.h -${CMAKE_CURRENT_LIST_DIR}/minimap_window.h -${CMAKE_CURRENT_LIST_DIR}/mt_rand.h -${CMAKE_CURRENT_LIST_DIR}/net_connection.h -${CMAKE_CURRENT_LIST_DIR}/npc.h -${CMAKE_CURRENT_LIST_DIR}/npc_brush.h -${CMAKE_CURRENT_LIST_DIR}/npcs.h -${CMAKE_CURRENT_LIST_DIR}/numbertextctrl.h -${CMAKE_CURRENT_LIST_DIR}/old_properties_window.h -${CMAKE_CURRENT_LIST_DIR}/otml.h -${CMAKE_CURRENT_LIST_DIR}/outfit.h -${CMAKE_CURRENT_LIST_DIR}/palette_brushlist.h -${CMAKE_CURRENT_LIST_DIR}/palette_common.h -${CMAKE_CURRENT_LIST_DIR}/palette_monster.h -${CMAKE_CURRENT_LIST_DIR}/palette_house.h -${CMAKE_CURRENT_LIST_DIR}/palette_npc.h -${CMAKE_CURRENT_LIST_DIR}/palette_waypoints.h -${CMAKE_CURRENT_LIST_DIR}/palette_window.h -${CMAKE_CURRENT_LIST_DIR}/pngfiles.h -${CMAKE_CURRENT_LIST_DIR}/position.h -${CMAKE_CURRENT_LIST_DIR}/positionctrl.h -${CMAKE_CURRENT_LIST_DIR}/preferences.h -${CMAKE_CURRENT_LIST_DIR}/process_com.h -${CMAKE_CURRENT_LIST_DIR}/properties_window.h -${CMAKE_CURRENT_LIST_DIR}/raw_brush.h -${CMAKE_CURRENT_LIST_DIR}/replace_items_window.h -${CMAKE_CURRENT_LIST_DIR}/result_window.h -${CMAKE_CURRENT_LIST_DIR}/rme_forward_declarations.h -${CMAKE_CURRENT_LIST_DIR}/rme_net.h -${CMAKE_CURRENT_LIST_DIR}/selection.h -${CMAKE_CURRENT_LIST_DIR}/settings.h -${CMAKE_CURRENT_LIST_DIR}/spawn_monster.h -${CMAKE_CURRENT_LIST_DIR}/spawn_monster_brush.h -${CMAKE_CURRENT_LIST_DIR}/spawn_npc.h -${CMAKE_CURRENT_LIST_DIR}/spawn_npc_brush.h -${CMAKE_CURRENT_LIST_DIR}/sprites.h -${CMAKE_CURRENT_LIST_DIR}/table_brush.h -${CMAKE_CURRENT_LIST_DIR}/templates.h -${CMAKE_CURRENT_LIST_DIR}/threads.h -${CMAKE_CURRENT_LIST_DIR}/tile.h -${CMAKE_CURRENT_LIST_DIR}/tileset.h -${CMAKE_CURRENT_LIST_DIR}/town.h -${CMAKE_CURRENT_LIST_DIR}/updater.h -${CMAKE_CURRENT_LIST_DIR}/wall_brush.h -${CMAKE_CURRENT_LIST_DIR}/waypoint_brush.h -${CMAKE_CURRENT_LIST_DIR}/waypoints.h -${CMAKE_CURRENT_LIST_DIR}/welcome_dialog.h + +# ***************************************************************************** +# Project remeres +# ***************************************************************************** +project(remeres) + +find_package(asio CONFIG REQUIRED) +find_package(fmt CONFIG REQUIRED) +find_package(GLUT REQUIRED) +find_package(nlohmann_json CONFIG REQUIRED) +find_package(OpenGL REQUIRED) +find_package(Threads REQUIRED) +find_package(wxWidgets COMPONENTS html aui gl adv core net base CONFIG REQUIRED) +find_package(ZLIB REQUIRED) + +# LibArchive disabled in compilation level by default, see "#define OTGZ_SUPPORT" in the "definitions.h" file +#if(APPLE) +# set(CMAKE_PREFIX_PATH /usr/local/opt/libarchive) +#endif() +# If you need use, enable this: +#find_package(LibArchive REQUIRED) +#${LibArchive_INCLUDE_DIRS} ${LibArchive_LIBRARIES} + +if (MSVC) + add_executable(${PROJECT_NAME} "" ../cmake/remeres.rc) +else() + add_executable(${PROJECT_NAME} "") +endif() + +# === PRECOMPILED HEADER === +#target_precompile_headers(${PROJECT_NAME} PRIVATE main.h) + +target_sources(${PROJECT_NAME} + PRIVATE + about_window.cpp + action.cpp + application.cpp + artprovider.cpp + basemap.cpp + brush.cpp + brush_tables.cpp + browse_tile_window.cpp + positionctrl.cpp + carpet_brush.cpp + client_version.cpp + common.cpp + common_windows.cpp + complexitem.cpp + container_properties_window.cpp + copybuffer.cpp + monster_brush.cpp + monster.cpp + monsters.cpp + dat_debug_view.cpp + dcbutton.cpp + doodad_brush.cpp + editor.cpp + editor_tabs.cpp + eraser_brush.cpp + extension.cpp + extension_window.cpp + find_item_window.cpp + filehandle.cpp + graphics.cpp + ground_brush.cpp + gui.cpp + house_brush.cpp + house.cpp + house_exit_brush.cpp + iomap.cpp + iomap_otbm.cpp + item_attributes.cpp + item.cpp + items.cpp + live_action.cpp + live_client.cpp + live_peer.cpp + live_server.cpp + live_socket.cpp + live_tab.cpp + main_menubar.cpp + main_toolbar.cpp + map.cpp + map_display.cpp + map_drawer.cpp + map_region.cpp + map_tab.cpp + map_window.cpp + materials.cpp + minimap_window.cpp + mkpch.cpp + mt_rand.cpp + net_connection.cpp + npc.cpp + npc_brush.cpp + npcs.cpp + numbertextctrl.cpp + old_properties_window.cpp + palette_brushlist.cpp + palette_common.cpp + palette_monster.cpp + palette_house.cpp + palette_npc.cpp + palette_waypoints.cpp + palette_window.cpp + pngfiles.cpp + preferences.cpp + process_com.cpp + properties_window.cpp + raw_brush.cpp + replace_items_window.cpp + result_window.cpp + rme_net.cpp + selection.cpp + settings.cpp + spawn_monster_brush.cpp + spawn_monster.cpp + spawn_npc.cpp + spawn_npc_brush.cpp + table_brush.cpp + templatemap76-74.cpp + templatemap81.cpp + templatemap854.cpp + templatemapclassic.cpp + tile.cpp + tileset.cpp + town.cpp + updater.cpp + wall_brush.cpp + waypoint_brush.cpp + waypoints.cpp + welcome_dialog.cpp +) + +target_include_directories(${PROJECT_NAME} + PRIVATE + ${CMAKE_SOURCE_DIR}/source + ${OPENGL_INCLUDE_DIR} + ${GLUT_INCLUDE_DIRS} + ${ZLIB_INCLUDE_DIR} +) + +target_link_libraries(${PROJECT_NAME} + ${OPENGL_LIBRARIES} + ${GLUT_LIBRARIES} + ${ZLIB_LIBRARIES} + fmt::fmt + asio::asio + nlohmann_json::nlohmann_json + wx::base wx::core wx::net wx::gl wx::html wx::aui wx::adv ) -set(rme_SRC -${CMAKE_CURRENT_LIST_DIR}/about_window.cpp -${CMAKE_CURRENT_LIST_DIR}/action.cpp -${CMAKE_CURRENT_LIST_DIR}/application.cpp -${CMAKE_CURRENT_LIST_DIR}/artprovider.cpp -${CMAKE_CURRENT_LIST_DIR}/basemap.cpp -${CMAKE_CURRENT_LIST_DIR}/brush.cpp -${CMAKE_CURRENT_LIST_DIR}/brush_tables.cpp -${CMAKE_CURRENT_LIST_DIR}/browse_tile_window.cpp -${CMAKE_CURRENT_LIST_DIR}/positionctrl.cpp -${CMAKE_CURRENT_LIST_DIR}/carpet_brush.cpp -${CMAKE_CURRENT_LIST_DIR}/client_version.cpp -${CMAKE_CURRENT_LIST_DIR}/common.cpp -${CMAKE_CURRENT_LIST_DIR}/common_windows.cpp -${CMAKE_CURRENT_LIST_DIR}/complexitem.cpp -${CMAKE_CURRENT_LIST_DIR}/container_properties_window.cpp -${CMAKE_CURRENT_LIST_DIR}/copybuffer.cpp -${CMAKE_CURRENT_LIST_DIR}/monster_brush.cpp -${CMAKE_CURRENT_LIST_DIR}/monster.cpp -${CMAKE_CURRENT_LIST_DIR}/monsters.cpp -${CMAKE_CURRENT_LIST_DIR}/dat_debug_view.cpp -${CMAKE_CURRENT_LIST_DIR}/dcbutton.cpp -${CMAKE_CURRENT_LIST_DIR}/doodad_brush.cpp -${CMAKE_CURRENT_LIST_DIR}/editor.cpp -${CMAKE_CURRENT_LIST_DIR}/editor_tabs.cpp -${CMAKE_CURRENT_LIST_DIR}/eraser_brush.cpp -${CMAKE_CURRENT_LIST_DIR}/extension.cpp -${CMAKE_CURRENT_LIST_DIR}/extension_window.cpp -${CMAKE_CURRENT_LIST_DIR}/find_item_window.cpp -${CMAKE_CURRENT_LIST_DIR}/filehandle.cpp -${CMAKE_CURRENT_LIST_DIR}/graphics.cpp -${CMAKE_CURRENT_LIST_DIR}/ground_brush.cpp -${CMAKE_CURRENT_LIST_DIR}/gui.cpp -${CMAKE_CURRENT_LIST_DIR}/house_brush.cpp -${CMAKE_CURRENT_LIST_DIR}/house.cpp -${CMAKE_CURRENT_LIST_DIR}/house_exit_brush.cpp -${CMAKE_CURRENT_LIST_DIR}/iomap.cpp -${CMAKE_CURRENT_LIST_DIR}/iomap_otbm.cpp -#${CMAKE_CURRENT_LIST_DIR}/iomap_otmm.cpp -${CMAKE_CURRENT_LIST_DIR}/item_attributes.cpp -${CMAKE_CURRENT_LIST_DIR}/item.cpp -${CMAKE_CURRENT_LIST_DIR}/items.cpp -${CMAKE_CURRENT_LIST_DIR}/live_action.cpp -${CMAKE_CURRENT_LIST_DIR}/live_client.cpp -${CMAKE_CURRENT_LIST_DIR}/live_peer.cpp -${CMAKE_CURRENT_LIST_DIR}/live_server.cpp -${CMAKE_CURRENT_LIST_DIR}/live_socket.cpp -${CMAKE_CURRENT_LIST_DIR}/live_tab.cpp -${CMAKE_CURRENT_LIST_DIR}/main_menubar.cpp -${CMAKE_CURRENT_LIST_DIR}/main_toolbar.cpp -${CMAKE_CURRENT_LIST_DIR}/map.cpp -${CMAKE_CURRENT_LIST_DIR}/map_display.cpp -${CMAKE_CURRENT_LIST_DIR}/map_drawer.cpp -${CMAKE_CURRENT_LIST_DIR}/map_region.cpp -${CMAKE_CURRENT_LIST_DIR}/map_tab.cpp -${CMAKE_CURRENT_LIST_DIR}/map_window.cpp -${CMAKE_CURRENT_LIST_DIR}/materials.cpp -${CMAKE_CURRENT_LIST_DIR}/minimap_window.cpp -${CMAKE_CURRENT_LIST_DIR}/mkpch.cpp -${CMAKE_CURRENT_LIST_DIR}/mt_rand.cpp -${CMAKE_CURRENT_LIST_DIR}/net_connection.cpp -${CMAKE_CURRENT_LIST_DIR}/npc.cpp -${CMAKE_CURRENT_LIST_DIR}/npc_brush.cpp -${CMAKE_CURRENT_LIST_DIR}/npcs.cpp -${CMAKE_CURRENT_LIST_DIR}/numbertextctrl.cpp -${CMAKE_CURRENT_LIST_DIR}/old_properties_window.cpp -${CMAKE_CURRENT_LIST_DIR}/palette_brushlist.cpp -${CMAKE_CURRENT_LIST_DIR}/palette_common.cpp -${CMAKE_CURRENT_LIST_DIR}/palette_monster.cpp -${CMAKE_CURRENT_LIST_DIR}/palette_house.cpp -${CMAKE_CURRENT_LIST_DIR}/palette_npc.cpp -${CMAKE_CURRENT_LIST_DIR}/palette_waypoints.cpp -${CMAKE_CURRENT_LIST_DIR}/palette_window.cpp -${CMAKE_CURRENT_LIST_DIR}/pngfiles.cpp -${CMAKE_CURRENT_LIST_DIR}/preferences.cpp -${CMAKE_CURRENT_LIST_DIR}/process_com.cpp -${CMAKE_CURRENT_LIST_DIR}/properties_window.cpp -${CMAKE_CURRENT_LIST_DIR}/raw_brush.cpp -${CMAKE_CURRENT_LIST_DIR}/replace_items_window.cpp -${CMAKE_CURRENT_LIST_DIR}/result_window.cpp -${CMAKE_CURRENT_LIST_DIR}/rme_net.cpp -${CMAKE_CURRENT_LIST_DIR}/selection.cpp -${CMAKE_CURRENT_LIST_DIR}/settings.cpp -${CMAKE_CURRENT_LIST_DIR}/spawn_monster_brush.cpp -${CMAKE_CURRENT_LIST_DIR}/spawn_monster.cpp -${CMAKE_CURRENT_LIST_DIR}/spawn_npc.cpp -${CMAKE_CURRENT_LIST_DIR}/spawn_npc_brush.cpp -${CMAKE_CURRENT_LIST_DIR}/table_brush.cpp -${CMAKE_CURRENT_LIST_DIR}/templatemap76-74.cpp -${CMAKE_CURRENT_LIST_DIR}/templatemap81.cpp -${CMAKE_CURRENT_LIST_DIR}/templatemap854.cpp -${CMAKE_CURRENT_LIST_DIR}/templatemapclassic.cpp -${CMAKE_CURRENT_LIST_DIR}/tile.cpp -${CMAKE_CURRENT_LIST_DIR}/tileset.cpp -${CMAKE_CURRENT_LIST_DIR}/town.cpp -${CMAKE_CURRENT_LIST_DIR}/updater.cpp -${CMAKE_CURRENT_LIST_DIR}/wall_brush.cpp -${CMAKE_CURRENT_LIST_DIR}/waypoint_brush.cpp -${CMAKE_CURRENT_LIST_DIR}/waypoints.cpp -${CMAKE_CURRENT_LIST_DIR}/welcome_dialog.cpp +set_target_properties(${PROJECT_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}" ) diff --git a/source/application.cpp b/source/application.cpp index ba0ad1ad..1926f39f 100644 --- a/source/application.cpp +++ b/source/application.cpp @@ -660,7 +660,8 @@ void MainFrame::PrepareDC(wxDC& dc) dc.SetMapMode( wxMM_TEXT ); } -// This is necessary for cmake to understand that it needs to set the executable +#ifdef _MSC_VER +// This is necessary for cmake with visual studio link the executable int main(int argc, char** argv) { wxEntryStart(argc, argv); // Start the wxWidgets library @@ -670,3 +671,4 @@ int main(int argc, char** argv) wxEntryCleanup(); // Clear the wxWidgets library return 0; } +#endif diff --git a/source/main.h b/source/main.h index ca608a73..6e2d89f3 100644 --- a/source/main.h +++ b/source/main.h @@ -102,7 +102,9 @@ _Ret_bytecap_(_Size) inline void* __CRTDECL operator new[](size_t _Size, const c // The complete STL ?, well, almost ;) #include -#include +#ifdef _WIN32 + #include +#endif #include #include #include diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 00000000..cda67548 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,13 @@ +{ + "name": "remeres", + "version-string": "1.0.0", + "dependencies": [ + "asio", + "freeglut", + "nlohmann-json", + "fmt", + "wxwidgets", + "opengl" + ], + "builtin-baseline":"0e67f312e831b4b897c7f492cf1e2858522c6e18" +}