mirror of
https://github.com/zeux/pugixml.git
synced 2024-12-25 11:50:50 +08:00
Auto-detect std::string_view support by default
Instead of opting in std::string_view support via PUGIXML_STRING_VIEW define, always enable it when C++17 is supported; this still requires enabling C++17 support in the compiler, which this change doesn't attempt to do yet.
This commit is contained in:
parent
4d0043fb6c
commit
ca4f7cfecc
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@ -12,7 +12,7 @@ jobs:
|
||||
matrix:
|
||||
os: [ubuntu, macos]
|
||||
compiler: [g++, clang++]
|
||||
defines: [standard, PUGIXML_WCHAR_MODE, PUGIXML_COMPACT, PUGIXML_NO_EXCEPTIONS, PUGIXML_STRING_VIEW]
|
||||
defines: [standard, PUGIXML_WCHAR_MODE, PUGIXML_COMPACT, PUGIXML_NO_EXCEPTIONS]
|
||||
exclude:
|
||||
- os: macos
|
||||
compiler: g++
|
||||
@ -39,7 +39,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [Win32, x64]
|
||||
defines: [standard, PUGIXML_WCHAR_MODE, PUGIXML_COMPACT, PUGIXML_NO_EXCEPTIONS, PUGIXML_STRING_VIEW]
|
||||
defines: [standard, PUGIXML_WCHAR_MODE, PUGIXML_COMPACT, PUGIXML_NO_EXCEPTIONS]
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: cmake configure
|
||||
|
@ -32,7 +32,7 @@ set(PUGIXML_BUILD_DEFINES CACHE STRING "Build defines for custom options")
|
||||
separate_arguments(PUGIXML_BUILD_DEFINES)
|
||||
|
||||
# Technically not needed for this file. This is builtin CMAKE global variable.
|
||||
option(BUILD_SHARED_LIBS "Build shared instead of static library" OFF)
|
||||
option(BUILD_SHARED_LIBS "Build shared instead of static library" OFF)
|
||||
|
||||
# Expose option to build PUGIXML as static as well when the global BUILD_SHARED_LIBS variable is set
|
||||
cmake_dependent_option(PUGIXML_BUILD_SHARED_AND_STATIC_LIBS
|
||||
@ -48,8 +48,7 @@ option(PUGIXML_INSTALL "Enable installation rules" ON)
|
||||
option(PUGIXML_NO_XPATH "Disable XPath" OFF)
|
||||
option(PUGIXML_NO_STL "Disable STL" OFF)
|
||||
option(PUGIXML_NO_EXCEPTIONS "Disable Exceptions" OFF)
|
||||
option(PUGIXML_STRING_VIEW "Enable std::string_view overloads" OFF) # requires C++17 and for PUGIXML_NO_STL to be OFF
|
||||
mark_as_advanced(PUGIXML_NO_XPATH PUGIXML_NO_STL PUGIXML_NO_EXCEPTIONS PUGIXML_STRING_VIEW)
|
||||
mark_as_advanced(PUGIXML_NO_XPATH PUGIXML_NO_STL PUGIXML_NO_EXCEPTIONS)
|
||||
|
||||
set(PUGIXML_PUBLIC_DEFINITIONS
|
||||
$<$<BOOL:${PUGIXML_WCHAR_MODE}>:PUGIXML_WCHAR_MODE>
|
||||
@ -57,7 +56,6 @@ set(PUGIXML_PUBLIC_DEFINITIONS
|
||||
$<$<BOOL:${PUGIXML_NO_XPATH}>:PUGIXML_NO_XPATH>
|
||||
$<$<BOOL:${PUGIXML_NO_STL}>:PUGIXML_NO_STL>
|
||||
$<$<BOOL:${PUGIXML_NO_EXCEPTIONS}>:PUGIXML_NO_EXCEPTIONS>
|
||||
$<$<BOOL:${PUGIXML_STRING_VIEW}>:PUGIXML_STRING_VIEW>
|
||||
)
|
||||
|
||||
# This is used to backport a CMake 3.15 feature, but is also forwards compatible
|
||||
@ -66,10 +64,6 @@ if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
|
||||
MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<NOT:$<BOOL:${PUGIXML_STATIC_CRT}>>:DLL>)
|
||||
endif()
|
||||
|
||||
if (PUGIXML_STRING_VIEW AND (NOT DEFINED CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 17))
|
||||
message(WARNING "PUGIXML_STRING_VIEW requires CMAKE_CXX_STANDARD to be set to 17 or later")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
endif()
|
||||
|
@ -46,13 +46,11 @@
|
||||
// Uncomment this to switch to header-only version
|
||||
// #define PUGIXML_HEADER_ONLY
|
||||
|
||||
// Uncomment this to enable long long support
|
||||
// Uncomment this to enable long long support (usually enabled automatically)
|
||||
// #define PUGIXML_HAS_LONG_LONG
|
||||
|
||||
// Uncomment this to enable support for std::string_view (requires c++17 and for PUGIXML_NO_STL to not be set)
|
||||
// Note: In a future version of pugixml this macro will become obsolete.
|
||||
// Support will then be enabled automatically if the used C++ standard supports it.
|
||||
// #define PUGIXML_STRING_VIEW
|
||||
// Uncomment this to enable support for std::string_view (usually enabled automatically)
|
||||
// #define PUGIXML_HAS_STRING_VIEW
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -38,8 +38,8 @@
|
||||
# include <string>
|
||||
#endif
|
||||
|
||||
// Check if std::string_view is both requested and available
|
||||
#if defined(PUGIXML_STRING_VIEW) && !defined(PUGIXML_NO_STL)
|
||||
// Check if std::string_view is available
|
||||
#if !defined(PUGIXML_HAS_STRING_VIEW) && !defined(PUGIXML_NO_STL)
|
||||
# if __cplusplus >= 201703L
|
||||
# define PUGIXML_HAS_STRING_VIEW
|
||||
# elif defined(_MSVC_LANG) && _MSVC_LANG >= 201703L
|
||||
@ -231,7 +231,7 @@ namespace pugi
|
||||
// the document; this flag is only recommended for parsing documents with many PCDATA nodes in memory-constrained environments.
|
||||
// This flag is off by default.
|
||||
const unsigned int parse_embed_pcdata = 0x2000;
|
||||
|
||||
|
||||
// This flag determines whether determines whether the the two pcdata should be merged or not, if no intermediatory data are parsed in the document.
|
||||
// This flag is off by default.
|
||||
const unsigned int parse_merge_pcdata = 0x4000;
|
||||
|
Loading…
x
Reference in New Issue
Block a user