diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index c2e11a33..e144d59d 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -33,12 +33,16 @@ jobs: sudo apt-get install -y --no-install-recommends \ qtbase5-dev qtbase5-dev-tools qt5-qmake \ qttools5-dev qttools5-dev-tools \ - libqt5svg5-dev + libqt5svg5-dev\ + qtdeclarative5-dev \ + qtquickcontrols2-5-dev\ + python3 \ + uuid-dev - name: Configure with CMake (headless) - run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DSD_BUILD_DESIGNER=OFF -DSD_BUILD_DEMOS=OFF -DQt5_DIR=/usr/lib/x86_64-linux-gnu/cmake/Qt5 + run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DSD_BUILD_DESIGNER=ON -DSD_BUILD_DEMOS=ON -DQt5_DIR=/usr/lib/x86_64-linux-gnu/cmake/Qt5 - name: Build run: cmake --build build --config Release --parallel diff --git a/Alice b/Alice index 2c0fa708..bdba4c52 160000 --- a/Alice +++ b/Alice @@ -1 +1 @@ -Subproject commit 2c0fa70860ddee7de179b531bf28a18758b14131 +Subproject commit bdba4c526da2b8e9d0a39b1ff8d182eaa4ede3a9 diff --git a/Demos/DemoDependencyPlugin/CMakeLists.txt b/Demos/DemoDependencyPlugin/CMakeLists.txt index 00f39de4..a93cf1ef 100644 --- a/Demos/DemoDependencyPlugin/CMakeLists.txt +++ b/Demos/DemoDependencyPlugin/CMakeLists.txt @@ -5,9 +5,6 @@ ########################################################################################################## message("*--*--*--*--*--*--*--*--*--*--*--*--*--Start SolidDemoDependencyPlugin--*--*--*--*--*--*--*--*--*--*--**--*--*--*") -add_definitions(-DSOLID_DESIGNER_UI_HOME) -add_definitions(-DALICE_DEMO_DEPEND_PLUGIN_HOME) - set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_PREFIX_PATH "C:/Qt/Qt5.15.14/5.15.14/msvc2019_64") @@ -93,6 +90,12 @@ add_library(SolidDemoDependencyPlugin SHARED ${SDP_FILES}) set_target_properties(SolidDemoDependencyPlugin PROPERTIES FOLDER "Demos") #============================================================================= +# 目标级编译宏(代替全局 add_definitions) +target_compile_definitions(SolidDemoDependencyPlugin + PRIVATE + ALICE_DEMO_DEPEND_PLUGIN_HOME +) + #----------------------------------------------------------------------------- # 根据系统及机器位数设置链接的位数 diff --git a/Demos/DemoPlugin/CMakeLists.txt b/Demos/DemoPlugin/CMakeLists.txt index 7d01c44f..7213f2b4 100644 --- a/Demos/DemoPlugin/CMakeLists.txt +++ b/Demos/DemoPlugin/CMakeLists.txt @@ -5,9 +5,6 @@ ########################################################################################################## message("*--*--*--*--*--*--*--*--*--*--*--*--*--Start SolidDemoPlugin--*--*--*--*--*--*--*--*--*--*--**--*--*--*") -add_definitions(-DSOLID_DESIGNER_UI_HOME) -add_definitions(-DALICE_DEMO_PLUGIN_HOME) - set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_PREFIX_PATH "C:/Qt/Qt5.15.14/5.15.14/msvc2019_64") @@ -93,6 +90,12 @@ add_library(SolidDemoPlugin SHARED ${SDP_FILES}) set_target_properties(SolidDemoPlugin PROPERTIES FOLDER "Demos") #============================================================================= +# 目标级编译宏(代替全局 add_definitions) +target_compile_definitions(SolidDemoPlugin + PRIVATE + ALICE_DEMO_PLUGIN_HOME +) + #----------------------------------------------------------------------------- # 根据系统及机器位数设置链接的位数 diff --git a/Designer/APP/CMakeLists.txt b/Designer/APP/CMakeLists.txt index 6d1d3b28..ff0a3e63 100644 --- a/Designer/APP/CMakeLists.txt +++ b/Designer/APP/CMakeLists.txt @@ -9,8 +9,7 @@ message(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Designer app Directory<<<<<<<<< message("CMAKE_SOURCE_DIR == ") message("${CMAKE_SOURCE_DIR}") message("${CMAKE_CURRENT_SOURCE_DIR}") -add_definitions(-D_USRDLL) -add_definitions(-D_CRT_SECURE_NO_WARNINGS) + # 批量添加程序文件,包括源文件 头文件 资源文件等 # 注意路径是当前目录,不然的话文件无法正确添加到VS中 FILE(GLOB APP_FILES "${PROJECT_SOURCE_DIR}/Designer/APP/*.cpp" "${PROJECT_SOURCE_DIR}/Designer/APP/*.h") @@ -51,32 +50,36 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) #============================================================================# # 给SolidRender这个工程配置第三方的库 #============================================================================# +if(WIN32) set(CMAKE_PREFIX_PATH "C:/Qt/Qt5.15.14/5.15.14/msvc2019_64") -find_package(Qt5 COMPONENTS Core Gui Widgets NetWork Quick Qml REQUIRED) - # 设置QT的头文件包含路径 # 如果找不到环境变量QTDIR的路径,那么自己设置吧; 也可以在GUI交互界面上手动设置 SET(QTDIR C:/Qt/Qt5.15.14/5.15.14/msvc2019_64) +endif() -# QT5头文件路径 -message("----------------qt5 files include directory--------------------") -include_directories(${QTDIR}/include) -include_directories(${QTDIR}/include/QtWidgets) -include_directories(${QTDIR}/include/QtCore) -include_directories(${QTDIR}/include/QtGui) -include_directories(${QTDIR}/include/QtOpenGL) -include_directories(${QTDIR}/include/QtMultimedia) -include_directories(${QTDIR}/include/QtQuick) -include_directories(${QTDIR}/include/QtQml) -include_directories(${QTDIR}/include/QtNetwork) -include_directories(${QTDIR}/mkspecs/win32-msvc2012) +find_package(Qt5 COMPONENTS Core Gui Widgets Network Quick Qml REQUIRED) -#----------------------------------------------------------------------------- -# 添加需要链接的库文件目录LINK_DIRECTORIES -# 例如QT库 -#----------------------------------------------------------------------------- -link_directories(${QTDIR}/lib) +# QT5头文件路径 +if(WIN32) + message("----------------qt5 files include directory--------------------") + include_directories(${QTDIR}/include) + include_directories(${QTDIR}/include/QtWidgets) + include_directories(${QTDIR}/include/QtCore) + include_directories(${QTDIR}/include/QtGui) + include_directories(${QTDIR}/include/QtOpenGL) + include_directories(${QTDIR}/include/QtMultimedia) + include_directories(${QTDIR}/include/QtQuick) + include_directories(${QTDIR}/include/QtQml) + include_directories(${QTDIR}/include/QtNetwork) + include_directories(${QTDIR}/mkspecs/win32-msvc2012) + + #----------------------------------------------------------------------------- + # 添加需要链接的库文件目录LINK_DIRECTORIES + # 例如QT库 + #----------------------------------------------------------------------------- + link_directories(${QTDIR}/lib) +endif() #----------------------------------------------------------------------------- #---------------------------第三方库的头文件和二进制文件---------------------- @@ -138,16 +141,42 @@ add_executable(${PROJECT_NAME} ${HEADER_HPP_FILES} ${APP_FILES}) - # 定义:如何生成 .rcc + +# 目标级编译宏(代替全局 add_definitions) +target_compile_definitions(${PROJECT_NAME} + PRIVATE + _USRDLL + _CRT_SECURE_NO_WARNINGS +) + + +# 定义:如何生成 .rcc +if(WIN32) add_custom_command(OUTPUT "${SD_RCC_FILE}" COMMAND ${CMAKE_COMMAND} -E make_directory "${SD_RCC_DIR}" COMMAND ${CMAKE_COMMAND} -E echo ">>> GenerateRCC: ${GEN_RCC_BAT} -> ${SD_RCC_FILE}" - COMMAND ${CMAKE_COMMAND} -E env "QTDIR_X64=$ENV{QTDIR_X64}" "${GEN_RCC_BAT}" "${SD_RCC_DIR}" + COMMAND ${CMAKE_COMMAND} -E env "QTDIR_X64=$ENV{QTDIR_X64}" "${GEN_RCC_BAT}" "${SD_RCC_DIR}" #real execution WORKING_DIRECTORY "${GEN_RCC_WD}" DEPENDS ${SD_QRCS} # .qrc 变更触发 VERBATIM ) +else() + # Linux/macOS:用 Qt 的 rcc 直接生成二进制 rcc + find_program(QT_RCC_EXECUTABLE NAMES rcc rcc-qt5) + if(NOT QT_RCC_EXECUTABLE) + message(FATAL_ERROR "Qt rcc not found. Ensure Qt is installed and rcc is in PATH.") + endif() + + add_custom_command( + OUTPUT "${SD_RCC_FILE}" + COMMAND ${CMAKE_COMMAND} -E make_directory "${SD_RCC_DIR}" + COMMAND "${QT_RCC_EXECUTABLE}" -binary ${SD_QRCS} -o "${SD_RCC_FILE}" + WORKING_DIRECTORY "${GEN_RCC_WD}" + DEPENDS ${SD_QRCS} + VERBATIM +) +endif() # 声明一个“资源生成”目标,并让可执行程序依赖它 add_custom_target(SolidDesignerRes ALL DEPENDS "${SD_RCC_FILE}") @@ -205,20 +234,31 @@ install(DIRECTORY "${CMAKE_SOURCE_DIR}/source/resource/Script" DESTINATION "${IN # 链接第三方的库 # @1、链接的动作需要放到add_library之后 #----------------------------------------------------------------------------- -message("PROJECT_NAME = ${PROJECT_NAME}") -target_link_libraries(${PROJECT_NAME} - glu32 - glew32 - opengl32 - freeimage - log4cplusU - AliceCoreApplicationInterface - AliceUiFrameWork - AliceBasicTool - AliceComponentSystem - AliceLaunchInterface -) +find_package(OpenGL REQUIRED) +message("PROJECT_NAME = ${PROJECT_NAME}") +if(WIN32) + target_link_libraries(${PROJECT_NAME} PRIVATE + glu32 + glew32 + opengl32 + freeimage + log4cplusU + AliceCoreApplicationInterface + AliceUiFrameWork + AliceBasicTool + AliceLaunchInterface + ) +else() + target_link_libraries(${PROJECT_NAME} PRIVATE + OpenGL::GL + OpenGL::GLU + AliceCoreApplicationInterface + AliceUiFrameWork + AliceBasicTool + AliceLaunchInterface + ) +endif() message(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>End Designer APP<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") \ No newline at end of file diff --git a/Designer/DB/SolidDesignerModel/CMakeLists.txt b/Designer/DB/SolidDesignerModel/CMakeLists.txt index f4e3d217..47738326 100644 --- a/Designer/DB/SolidDesignerModel/CMakeLists.txt +++ b/Designer/DB/SolidDesignerModel/CMakeLists.txt @@ -5,13 +5,7 @@ ########################################################################################################## message("*--*--*--*--*--*--*--*--*--*--*--*--*--Start SolidDesignerModel--*--*--*--*--*--*--*--*--*--*--**--*--*--*") -add_definitions(-DSOLID_DESIGNER_MODEL_HOME) -add_definitions(-DALICE_BASIC_SERVICE_HOME) - - message("${PROJECT_SOURCE_DIR}") - - FILE(GLOB SOURCE_FILES "${PROJECT_SOURCE_DIR}/Designer/DB/SolidDesignerModel/*.cpp") FILE(GLOB HEADER_FILES "${PROJECT_SOURCE_DIR}/Designer/DB/SolidDesignerModel/*.h") @@ -38,6 +32,12 @@ set_target_properties(SolidDesignerModel PROPERTIES FOLDER "Designer/DB") #============================================================================= +# 目标级编译宏(代替全局 add_definitions) +target_compile_definitions(SolidDesignerModel + PRIVATE + SOLID_DESIGNER_MODEL_HOME +) + #----------------------------------------------------------------------------- # 根据系统及机器位数设置链接的位数 # 必须放在link之后,否则设置无效 @@ -100,7 +100,6 @@ endif() target_link_libraries(SolidDesignerModel PRIVATE AliceBasicTool AliceFoundation - AliceDatabaseInterface AliceModelInterface ) diff --git a/Designer/Interaction/SolidDesignerInteraction/CMakeLists.txt b/Designer/Interaction/SolidDesignerInteraction/CMakeLists.txt index dc358c65..c4a85b89 100644 --- a/Designer/Interaction/SolidDesignerInteraction/CMakeLists.txt +++ b/Designer/Interaction/SolidDesignerInteraction/CMakeLists.txt @@ -5,12 +5,7 @@ ########################################################################################################## message("*--*--*--*--*--*--*--*--*--*--*--*--*--Start SolidDesignerInteraction--*--*--*--*--*--*--*--*--*--*--**--*--*--*") -add_definitions(-DSOLID_DESIGNER_INTERACTION_HOME) -add_definitions(-DALICE_BASIC_SERVICE_HOME) - message("${PROJECT_SOURCE_DIR}") - - FILE(GLOB SOURCE_FILES "${PROJECT_SOURCE_DIR}/Designer/Interaction/SolidDesignerInteraction/*.cpp") FILE(GLOB HEADER_FILES "${PROJECT_SOURCE_DIR}/Designer/Interaction/SolidDesignerInteraction/*.h") @@ -36,6 +31,11 @@ add_library(SolidDesignerInteraction SHARED ${SOURCE_FILES} ${HEADER_FILES}) set_target_properties(SolidDesignerInteraction PROPERTIES FOLDER "Designer/Interaction") #============================================================================= +# 目标级编译宏(代替全局 add_definitions) +target_compile_definitions(SolidDesignerInteraction + PRIVATE + SOLID_DESIGNER_INTERACTION_HOME +) #----------------------------------------------------------------------------- diff --git a/Designer/UI/SolidDesignerCommand/CMakeLists.txt b/Designer/UI/SolidDesignerCommand/CMakeLists.txt index 8321434d..c25a8f40 100644 --- a/Designer/UI/SolidDesignerCommand/CMakeLists.txt +++ b/Designer/UI/SolidDesignerCommand/CMakeLists.txt @@ -4,14 +4,20 @@ #--Author: hananiah ########################################################################################################## message("*--*--*--*--*--*--*--*--*--*--*--*--*--Start SolidDesignerCommand--*--*--*--*--*--*--*--*--*--*--**--*--*--*") - -add_definitions(-DSOLID_DESIGNER_UI_HOME) -add_definitions(-DSOLID_DESIGNER_COMMAND_HOME) - message("CMAKE_SOURCE_DIR = ${CMAKE_SOURCE_DIR}") # 先指定你项目内置的 Python 解释器 -set(_SD_PY_ROOT "${CMAKE_SOURCE_DIR}/ToolChain/Python310") -set(Python3_EXECUTABLE "${_SD_PY_ROOT}/python.exe" CACHE FILEPATH "SolidDesigner bundled Python" FORCE) +if(WIN32) + # Windows: use repo toolchain python + set(_SD_PY_ROOT "${CMAKE_SOURCE_DIR}/ToolChain/Python310") + set(Python3_EXECUTABLE "${_SD_PY_ROOT}/python.exe" CACHE FILEPATH "SolidDesigner bundled Python" FORCE) +else() + message("Here is linux python... ...") + # Linux/macOS: use system python3 + find_program(_PY3 NAMES python3 python REQUIRED) + set(Python3_EXECUTABLE "${_PY3}" CACHE FILEPATH "Python3 interpreter" FORCE) + +endif() + # 然后再找 Python3 find_package(Python3 REQUIRED COMPONENTS Interpreter) @@ -57,6 +63,12 @@ add_library(SolidDesignerCommand SHARED ${SDC_FILES}) set_target_properties(SolidDesignerCommand PROPERTIES FOLDER "Designer/UI") #============================================================================= +# 目标级编译宏(代替全局 add_definitions) +target_compile_definitions(SolidDesignerCommand + PRIVATE + SOLID_DESIGNER_COMMAND_HOME +) + #----------------------------------------------------------------------------- # 根据系统及机器位数设置链接的位数 diff --git a/Designer/UI/SolidDesignerCommand/GeneralCommands/SolidFileOpenCommand.cpp b/Designer/UI/SolidDesignerCommand/GeneralCommands/SolidFileOpenCommand.cpp index fb2e09ad..96822c1c 100644 --- a/Designer/UI/SolidDesignerCommand/GeneralCommands/SolidFileOpenCommand.cpp +++ b/Designer/UI/SolidDesignerCommand/GeneralCommands/SolidFileOpenCommand.cpp @@ -1,4 +1,4 @@ -#include "SolidFileOpenCommand.h" +#include "SolidFileOpenCommand.h" #include "AliceIMainWindow.h" #include "AliceIDocumentManager.h" @@ -53,7 +53,7 @@ std::unique_ptr SolidFileOpenCommand::Execute(const CommandParameter std::wstring filePath = showOpenFileDialog_(); if (filePath.empty()) - return nullptr; // ûȡ + return nullptr; // 用户取消 IDocument* doc = openDocument_(filePath); if (!doc) @@ -75,8 +75,8 @@ std::wstring SolidFileOpenCommand::showOpenFileDialog_() const { //QWidget* parent = m_mainWindow ? m_mainWindow->AsQMainWindow() : nullptr; - //// ˿Դ UiApplicationConfig / CommandsConfig profile ã˴һ - //// .alice + CAD ʽʾ + //// 过滤可以从 UiApplicationConfig / CommandsConfig 的 profile 中拿,此处给一个 + //// 针对 .alice + 常规 CAD 格式的示例。 //const QString filter = // QObject::tr("Alice Documents (*.alice);;" // "STEP Files (*.step *.stp);;" diff --git a/Designer/UI/SolidDesignerCommand/GeneralCommands/SolidFileSaveCommand.cpp b/Designer/UI/SolidDesignerCommand/GeneralCommands/SolidFileSaveCommand.cpp index 1683bad0..cadf178c 100644 --- a/Designer/UI/SolidDesignerCommand/GeneralCommands/SolidFileSaveCommand.cpp +++ b/Designer/UI/SolidDesignerCommand/GeneralCommands/SolidFileSaveCommand.cpp @@ -94,7 +94,7 @@ IDocument* SolidFileSaveCommand::getActiveDocument_() const // return nullptr; //return m_docManager->GetActiveDocument(); - return false; + return nullptr; } bool SolidFileSaveCommand::hasFilePath_(IDocument& doc) const diff --git a/Designer/UI/SolidDesignerUI/CMakeLists.txt b/Designer/UI/SolidDesignerUI/CMakeLists.txt index e00d269e..85d20e72 100644 --- a/Designer/UI/SolidDesignerUI/CMakeLists.txt +++ b/Designer/UI/SolidDesignerUI/CMakeLists.txt @@ -5,12 +5,12 @@ ########################################################################################################## message("*--*--*--*--*--*--*--*--*--*--*--*--*--Start SolidDesigner UI--*--*--*--*--*--*--*--*--*--*--**--*--*--*") -add_definitions(-DSOLID_DESIGNER_UI_HOME) -add_definitions(-DALICE_BASIC_SERVICE_HOME) - set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) -set(CMAKE_PREFIX_PATH "C:/Qt/Qt5.15.14/5.15.14/msvc2019_64") +if(WIN32) + set(CMAKE_PREFIX_PATH "C:/Qt/Qt5.15.14/5.15.14/msvc2019_64") +endif() + find_package(Qt5Core 5.15 REQUIRED) find_package(Qt5Gui 5.15 REQUIRED) find_package(Qt5Widgets 5.15 REQUIRED) @@ -49,6 +49,11 @@ add_library(SolidDesignerUI SHARED ${SOURCE_FILES} ${HEADER_FILES}) set_target_properties(SolidDesignerUI PROPERTIES FOLDER "Designer/UI") #============================================================================= +# 目标级编译宏(代替全局 add_definitions) +target_compile_definitions(SolidDesignerUI + PRIVATE + SOLID_DESIGNER_UI_HOME +) #----------------------------------------------------------------------------- # 根据系统及机器位数设置链接的位数 diff --git a/Externals/pugixml/CMakeLists.txt b/Externals/pugixml/CMakeLists.txt index 9651c5b4..a42936c4 100644 --- a/Externals/pugixml/CMakeLists.txt +++ b/Externals/pugixml/CMakeLists.txt @@ -6,10 +6,6 @@ message("=====================================Start pugixml=======================================") message("${PROJECT_SOURCE_DIR}") -if(WIN32) - add_definitions(-D_WINDOWS) -endif() - FILE(GLOB SOURCE_CPP_FILES "${PROJECT_SOURCE_DIR}/Externals/pugixml/*.cpp") FILE(GLOB HEADER_H_FILES "${PROJECT_SOURCE_DIR}/Externals/pugixml/*.hpp") @@ -62,6 +58,10 @@ add_library(pugixml SHARED ${HEADER_H_FILES} ${SOURCE_CPP_FILES} ) set_target_properties(pugixml PROPERTIES FOLDER "Externals") #============================================================================= +if(WIN32) + target_compile_definitions(pugixml PRIVATE _WINDOWS) +endif() + #----------------------------------------------------------------------------- # 头文件搜索路径 #----------------------------------------------------------------------------- diff --git a/Externals/pugixml/pugixml.hpp b/Externals/pugixml/pugixml.hpp index d690dbca..0f87c5b5 100644 --- a/Externals/pugixml/pugixml.hpp +++ b/Externals/pugixml/pugixml.hpp @@ -11,8 +11,8 @@ * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) */ -// Define version macro; evaluates to major * 1000 + minor * 10 + patch so that it's safe to use in less-than comparisons -// Note: pugixml used major * 100 + minor * 10 + patch format up until 1.9 (which had version identifier 190); starting from pugixml 1.10, the minor version number is two digits + // Define version macro; evaluates to major * 1000 + minor * 10 + patch so that it's safe to use in less-than comparisons + // Note: pugixml used major * 100 + minor * 10 + patch format up until 1.9 (which had version identifier 190); starting from pugixml 1.10, the minor version number is two digits #ifndef PUGIXML_VERSION # define PUGIXML_VERSION 1130 // 1.13 #endif @@ -54,9 +54,17 @@ // @hananiah // @add export to generate lib files #ifndef PUGIXML_API -# define PUGIXML_API __declspec(dllexport) +# ifdef _WIN32 +# define PUGIXML_API __declspec(dllexport) +# else +# define PUGIXML_API +# endif #else -# define PUGIXML_API __declspec(dllimport) +# ifdef _WIN32 +# define PUGIXML_API __declspec(dllimport) +# else +# define PUGIXML_API +# endif #endif // If no API for classes is defined, assume default @@ -298,12 +306,12 @@ namespace pugi class xml_text; - #ifndef PUGIXML_NO_XPATH +#ifndef PUGIXML_NO_XPATH class xpath_node; class xpath_node_set; class xpath_query; class xpath_variable_set; - #endif +#endif // Range-based for loop support template class xml_object_range @@ -312,7 +320,7 @@ namespace pugi typedef It const_iterator; typedef It iterator; - xml_object_range(It b, It e): _begin(b), _end(e) + xml_object_range(It b, It e) : _begin(b), _end(e) { } @@ -336,7 +344,7 @@ namespace pugi }; // xml_writer implementation for FILE* - class PUGIXML_CLASS xml_writer_file: public xml_writer + class PUGIXML_CLASS xml_writer_file : public xml_writer { public: // Construct writer from a FILE* object; void* is used to avoid header dependencies on stdio @@ -348,9 +356,9 @@ namespace pugi void* file; }; - #ifndef PUGIXML_NO_STL +#ifndef PUGIXML_NO_STL // xml_writer implementation for streams - class PUGIXML_CLASS xml_writer_stream: public xml_writer + class PUGIXML_CLASS xml_writer_stream : public xml_writer { public: // Construct writer from an output stream object @@ -363,7 +371,7 @@ namespace pugi std::basic_ostream >* narrow_stream; std::basic_ostream >* wide_stream; }; - #endif +#endif // A light-weight handle for manipulating attributes in DOM tree class PUGIXML_CLASS xml_attribute @@ -413,10 +421,10 @@ namespace pugi double as_double(double def = 0) const; float as_float(float def = 0) const; - #ifdef PUGIXML_HAS_LONG_LONG +#ifdef PUGIXML_HAS_LONG_LONG long long as_llong(long long def = 0) const; unsigned long long as_ullong(unsigned long long def = 0) const; - #endif +#endif // Get attribute value as bool (returns true if first character is in '1tTyY' set), or the default value if attribute is empty bool as_bool(bool def = false) const; @@ -437,10 +445,10 @@ namespace pugi bool set_value(float rhs, int precision); bool set_value(bool rhs); - #ifdef PUGIXML_HAS_LONG_LONG +#ifdef PUGIXML_HAS_LONG_LONG bool set_value(long long rhs); bool set_value(unsigned long long rhs); - #endif +#endif // Set attribute value (equivalent to set_value without error checking) xml_attribute& operator=(const char_t* rhs); @@ -452,10 +460,10 @@ namespace pugi xml_attribute& operator=(float rhs); xml_attribute& operator=(bool rhs); - #ifdef PUGIXML_HAS_LONG_LONG +#ifdef PUGIXML_HAS_LONG_LONG xml_attribute& operator=(long long rhs); xml_attribute& operator=(unsigned long long rhs); - #endif +#endif // Get next/previous attribute in the attribute list of the parent node xml_attribute next_attribute() const; @@ -668,10 +676,10 @@ namespace pugi xml_node find_child_by_attribute(const char_t* name, const char_t* attr_name, const char_t* attr_value) const; xml_node find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const; - #ifndef PUGIXML_NO_STL +#ifndef PUGIXML_NO_STL // Get the absolute node path from root as a text string. string_t path(char_t delimiter = '/') const; - #endif +#endif // Search for a node by path consisting of node names and . or .. elements. xml_node first_element_by_path(const char_t* path, char_t delimiter = '/') const; @@ -679,7 +687,7 @@ namespace pugi // Recursively traverse subtree with xml_tree_walker bool traverse(xml_tree_walker& walker); - #ifndef PUGIXML_NO_XPATH +#ifndef PUGIXML_NO_XPATH // Select single node by evaluating XPath query. Returns first node from the resulting node set. xpath_node select_node(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL) const; xpath_node select_node(const xpath_query& query) const; @@ -692,16 +700,16 @@ namespace pugi PUGIXML_DEPRECATED xpath_node select_single_node(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL) const; PUGIXML_DEPRECATED xpath_node select_single_node(const xpath_query& query) const; - #endif +#endif // Print subtree using a writer object void print(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const; - #ifndef PUGIXML_NO_STL +#ifndef PUGIXML_NO_STL // Print subtree to stream void print(std::basic_ostream >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const; void print(std::basic_ostream >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, unsigned int depth = 0) const; - #endif +#endif // Child nodes iterators typedef xml_node_iterator iterator; @@ -778,10 +786,10 @@ namespace pugi double as_double(double def = 0) const; float as_float(float def = 0) const; - #ifdef PUGIXML_HAS_LONG_LONG +#ifdef PUGIXML_HAS_LONG_LONG long long as_llong(long long def = 0) const; unsigned long long as_ullong(unsigned long long def = 0) const; - #endif +#endif // Get text as bool (returns true if first character is in '1tTyY' set), or the default value if object is empty bool as_bool(bool def = false) const; @@ -801,10 +809,10 @@ namespace pugi bool set(float rhs, int precision); bool set(bool rhs); - #ifdef PUGIXML_HAS_LONG_LONG +#ifdef PUGIXML_HAS_LONG_LONG bool set(long long rhs); bool set(unsigned long long rhs); - #endif +#endif // Set text (equivalent to set without error checking) xml_text& operator=(const char_t* rhs); @@ -816,10 +824,10 @@ namespace pugi xml_text& operator=(float rhs); xml_text& operator=(bool rhs); - #ifdef PUGIXML_HAS_LONG_LONG +#ifdef PUGIXML_HAS_LONG_LONG xml_text& operator=(long long rhs); xml_text& operator=(unsigned long long rhs); - #endif +#endif // Get the data node (node_pcdata or node_cdata) for this object xml_node data() const; @@ -849,9 +857,9 @@ namespace pugi typedef xml_node* pointer; typedef xml_node& reference; - #ifndef PUGIXML_NO_STL +#ifndef PUGIXML_NO_STL typedef std::bidirectional_iterator_tag iterator_category; - #endif +#endif // Default constructor xml_node_iterator(); @@ -891,9 +899,9 @@ namespace pugi typedef xml_attribute* pointer; typedef xml_attribute& reference; - #ifndef PUGIXML_NO_STL +#ifndef PUGIXML_NO_STL typedef std::bidirectional_iterator_tag iterator_category; - #endif +#endif // Default constructor xml_attribute_iterator(); @@ -927,9 +935,9 @@ namespace pugi typedef xml_node* pointer; typedef xml_node& reference; - #ifndef PUGIXML_NO_STL +#ifndef PUGIXML_NO_STL typedef std::bidirectional_iterator_tag iterator_category; - #endif +#endif // Default constructor xml_named_node_iterator(); @@ -1035,7 +1043,7 @@ namespace pugi }; // Document class (DOM tree root) - class PUGIXML_CLASS xml_document: public xml_node + class PUGIXML_CLASS xml_document : public xml_node { private: char_t* _buffer; @@ -1057,11 +1065,11 @@ namespace pugi // Destructor, invalidates all node/attribute handles to this document ~xml_document(); - #ifdef PUGIXML_HAS_MOVE +#ifdef PUGIXML_HAS_MOVE // Move semantics support xml_document(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT; xml_document& operator=(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT; - #endif +#endif // Removes all nodes, leaving the empty document void reset(); @@ -1069,11 +1077,11 @@ namespace pugi // Removes all nodes, then copies the entire contents of the specified document void reset(const xml_document& proto); - #ifndef PUGIXML_NO_STL +#ifndef PUGIXML_NO_STL // Load document from stream. xml_parse_result load(std::basic_istream >& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); xml_parse_result load(std::basic_istream >& stream, unsigned int options = parse_default); - #endif +#endif // (deprecated: use load_string instead) Load document from zero-terminated string. No encoding conversions are applied. PUGIXML_DEPRECATED xml_parse_result load(const char_t* contents, unsigned int options = parse_default); @@ -1099,11 +1107,11 @@ namespace pugi // Save XML document to writer (semantics is slightly different from xml_node::print, see documentation for details). void save(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; - #ifndef PUGIXML_NO_STL +#ifndef PUGIXML_NO_STL // Save XML document to stream (semantics is slightly different from xml_node::print, see documentation for details). void save(std::basic_ostream >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; void save(std::basic_ostream >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default) const; - #endif +#endif // Save XML to file bool save_file(const char* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; @@ -1201,11 +1209,11 @@ namespace pugi xpath_variable_set(const xpath_variable_set& rhs); xpath_variable_set& operator=(const xpath_variable_set& rhs); - #ifdef PUGIXML_HAS_MOVE +#ifdef PUGIXML_HAS_MOVE // Move semantics support xpath_variable_set(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT; xpath_variable_set& operator=(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT; - #endif +#endif // Add a new variable or get the existing one, if the types match xpath_variable* add(const char_t* name, xpath_value_type type); @@ -1245,11 +1253,11 @@ namespace pugi // Destructor ~xpath_query(); - #ifdef PUGIXML_HAS_MOVE +#ifdef PUGIXML_HAS_MOVE // Move semantics support xpath_query(xpath_query&& rhs) PUGIXML_NOEXCEPT; xpath_query& operator=(xpath_query&& rhs) PUGIXML_NOEXCEPT; - #endif +#endif // Get query expression return type xpath_value_type return_type() const; @@ -1262,11 +1270,11 @@ namespace pugi // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors. double evaluate_number(const xpath_node& n) const; - #ifndef PUGIXML_NO_STL +#ifndef PUGIXML_NO_STL // Evaluate expression as string value in the specified context; performs type conversion if necessary. // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors. string_t evaluate_string(const xpath_node& n) const; - #endif +#endif // Evaluate expression as string value in the specified context; performs type conversion if necessary. // At most capacity characters are written to the destination buffer, full result size is returned (includes terminating zero). @@ -1295,15 +1303,15 @@ namespace pugi bool operator!() const; }; - #ifndef PUGIXML_NO_EXCEPTIONS - #if defined(_MSC_VER) - // C4275 can be ignored in Visual C++ if you are deriving - // from a type in the Standard C++ Library - #pragma warning(push) - #pragma warning(disable: 4275) - #endif - // XPath exception class - class PUGIXML_CLASS xpath_exception: public std::exception +#ifndef PUGIXML_NO_EXCEPTIONS +#if defined(_MSC_VER) + // C4275 can be ignored in Visual C++ if you are deriving + // from a type in the Standard C++ Library +#pragma warning(push) +#pragma warning(disable: 4275) +#endif +// XPath exception class + class PUGIXML_CLASS xpath_exception : public std::exception { private: xpath_parse_result _result; @@ -1318,10 +1326,10 @@ namespace pugi // Get parse result const xpath_parse_result& result() const; }; - #if defined(_MSC_VER) - #pragma warning(pop) - #endif - #endif +#if defined(_MSC_VER) +#pragma warning(pop) +#endif +#endif // XPath node class (either xml_node or xml_attribute) class PUGIXML_CLASS xpath_node @@ -1395,11 +1403,11 @@ namespace pugi xpath_node_set(const xpath_node_set& ns); xpath_node_set& operator=(const xpath_node_set& ns); - #ifdef PUGIXML_HAS_MOVE +#ifdef PUGIXML_HAS_MOVE // Move semantics support xpath_node_set(xpath_node_set&& rhs) PUGIXML_NOEXCEPT; xpath_node_set& operator=(xpath_node_set&& rhs) PUGIXML_NOEXCEPT; - #endif +#endif // Get collection type type_t type() const;