You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bc...@apache.org on 2022/10/11 21:42:20 UTC
[trafficserver] branch 9.1.x updated: Updates yaml-cpp to 0.7.0 (#8232)
This is an automated email from the ASF dual-hosted git repository.
bcall pushed a commit to branch 9.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/9.1.x by this push:
new 45d4bf6e4 Updates yaml-cpp to 0.7.0 (#8232)
45d4bf6e4 is described below
commit 45d4bf6e4ea193185d582bef7a747cbbcac7d676
Author: Randall Meyer <rr...@apache.org>
AuthorDate: Thu Aug 12 12:37:50 2021 -0700
Updates yaml-cpp to 0.7.0 (#8232)
(cherry picked from commit c51c6f7441c3ef326920f6bc5430d7141ee8f16d)
---
lib/yamlcpp/.gitignore | 1 +
lib/yamlcpp/.travis.yml | 51 +-
lib/yamlcpp/BUILD.bazel | 14 +
lib/yamlcpp/CMakeLists.txt | 447 +++++----------
lib/yamlcpp/Makefile.am | 3 +-
lib/yamlcpp/README.md | 10 +
lib/yamlcpp/WORKSPACE | 10 +
lib/yamlcpp/appveyor.yml | 28 +
lib/yamlcpp/include/yaml-cpp/anchor.h | 2 +-
.../include/yaml-cpp/contrib/graphbuilder.h | 8 +-
lib/yamlcpp/include/yaml-cpp/depthguard.h | 77 +++
lib/yamlcpp/include/yaml-cpp/emitfromevents.h | 24 +-
lib/yamlcpp/include/yaml-cpp/emitter.h | 14 +-
lib/yamlcpp/include/yaml-cpp/emittermanip.h | 19 +-
lib/yamlcpp/include/yaml-cpp/eventhandler.h | 2 +-
lib/yamlcpp/include/yaml-cpp/exceptions.h | 66 +--
lib/yamlcpp/include/yaml-cpp/node/convert.h | 200 ++++---
.../include/yaml-cpp/node/detail/bool_type.h | 26 -
lib/yamlcpp/include/yaml-cpp/node/detail/impl.h | 67 ++-
.../include/yaml-cpp/node/detail/iterator.h | 2 +-
.../include/yaml-cpp/node/detail/iterator_fwd.h | 4 +-
lib/yamlcpp/include/yaml-cpp/node/detail/memory.h | 2 +-
lib/yamlcpp/include/yaml-cpp/node/detail/node.h | 22 +-
.../include/yaml-cpp/node/detail/node_data.h | 22 +-
.../include/yaml-cpp/node/detail/node_iterator.h | 33 +-
lib/yamlcpp/include/yaml-cpp/node/impl.h | 102 +---
lib/yamlcpp/include/yaml-cpp/node/iterator.h | 2 +-
lib/yamlcpp/include/yaml-cpp/node/node.h | 7 +-
lib/yamlcpp/include/yaml-cpp/node/ptr.h | 10 +-
lib/yamlcpp/include/yaml-cpp/noexcept.h | 18 +
lib/yamlcpp/include/yaml-cpp/stlemitter.h | 9 +-
lib/yamlcpp/include/yaml-cpp/traits.h | 4 +-
lib/yamlcpp/src/binary.cpp | 4 +-
lib/yamlcpp/src/contrib/graphbuilder.cpp | 5 +-
lib/yamlcpp/src/contrib/graphbuilderadapter.cpp | 2 +-
lib/yamlcpp/src/convert.cpp | 21 +-
lib/yamlcpp/src/depthguard.cpp | 9 +
lib/yamlcpp/src/directives.cpp | 2 +-
lib/yamlcpp/src/emit.cpp | 2 +-
lib/yamlcpp/src/emitfromevents.cpp | 4 +
lib/yamlcpp/src/emitter.cpp | 80 ++-
lib/yamlcpp/src/emitterstate.cpp | 51 +-
lib/yamlcpp/src/emitterstate.h | 8 +
lib/yamlcpp/src/emitterutils.cpp | 80 +--
lib/yamlcpp/src/emitterutils.h | 9 +-
lib/yamlcpp/src/exceptions.cpp | 41 +-
lib/yamlcpp/src/exp.cpp | 21 +-
lib/yamlcpp/src/exp.h | 4 +-
lib/yamlcpp/src/memory.cpp | 4 +-
lib/yamlcpp/src/node.cpp | 2 +-
lib/yamlcpp/src/node_data.cpp | 76 +--
lib/yamlcpp/src/nodebuilder.cpp | 5 +-
lib/yamlcpp/src/nodebuilder.h | 30 +-
lib/yamlcpp/src/nodeevents.cpp | 27 +-
lib/yamlcpp/src/nodeevents.h | 4 +-
lib/yamlcpp/src/null.cpp | 2 +-
lib/yamlcpp/src/ostream_wrapper.cpp | 6 +-
lib/yamlcpp/src/parse.cpp | 14 +-
lib/yamlcpp/src/parser.cpp | 22 +-
lib/yamlcpp/src/regex_yaml.h | 2 +-
lib/yamlcpp/src/regeximpl.h | 23 +-
lib/yamlcpp/src/scanner.cpp | 6 +-
lib/yamlcpp/src/scanscalar.cpp | 7 +-
lib/yamlcpp/src/scanscalar.h | 2 +-
lib/yamlcpp/src/scantag.cpp | 2 +-
lib/yamlcpp/src/scantoken.cpp | 6 +-
lib/yamlcpp/src/setting.h | 49 +-
lib/yamlcpp/src/simplekey.cpp | 8 +-
lib/yamlcpp/src/singledocparser.cpp | 32 +-
lib/yamlcpp/src/singledocparser.h | 4 +-
lib/yamlcpp/src/stream.cpp | 28 +-
lib/yamlcpp/src/stream.h | 3 +
lib/yamlcpp/src/streamcharsource.h | 12 +-
lib/yamlcpp/src/token.h | 4 +-
lib/yamlcpp/test/BUILD.bazel | 14 +
lib/yamlcpp/test/CMakeLists.txt | 100 ++--
lib/yamlcpp/test/create-emitter-tests.py | 1 +
lib/yamlcpp/test/integration/emitter_test.cpp | 613 ++++++++++++++++++++-
.../test/integration/error_messages_test.cpp | 21 +-
lib/yamlcpp/test/integration/handler_spec_test.cpp | 67 ++-
lib/yamlcpp/test/integration/load_node_test.cpp | 139 ++++-
lib/yamlcpp/test/integration/node_spec_test.cpp | 5 +
lib/yamlcpp/test/mock_event_handler.h | 3 +
lib/yamlcpp/test/node/node_test.cpp | 208 +++++++
lib/yamlcpp/test/ostream_wrapper_test.cpp | 2 +-
lib/yamlcpp/test/parser_test.cpp | 64 +++
lib/yamlcpp/test/specexamples.h | 24 +-
lib/yamlcpp/util/CMakeLists.txt | 44 +-
lib/yamlcpp/util/read.cpp | 36 +-
lib/yamlcpp/util/sandbox.cpp | 30 +-
lib/yamlcpp/yaml-cpp-config-version.cmake.in | 11 -
lib/yamlcpp/{yaml-cpp.pc.cmake => yaml-cpp.pc.in} | 4 +-
92 files changed, 2283 insertions(+), 1132 deletions(-)
diff --git a/lib/yamlcpp/.gitignore b/lib/yamlcpp/.gitignore
index 0e29154b5..2f9d10f06 100644
--- a/lib/yamlcpp/.gitignore
+++ b/lib/yamlcpp/.gitignore
@@ -1,2 +1,3 @@
build/
/tags
+/bazel-*
diff --git a/lib/yamlcpp/.travis.yml b/lib/yamlcpp/.travis.yml
index d0b6a04ef..46beb1d12 100644
--- a/lib/yamlcpp/.travis.yml
+++ b/lib/yamlcpp/.travis.yml
@@ -1,28 +1,37 @@
language: c++
-os:
- - linux
- - osx
-compiler:
- - clang
- - gcc
-before_install:
- - |
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y \
- && sudo apt-get update -qq \
- && if [ "$CXX" == "g++" ]; then
- sudo apt-get install -qq g++-4.7 && export CXX="g++-4.7" CC="gcc-4.7"
- fi
- fi
+
+matrix:
+ include:
+ - os: linux
+ compiler: gcc
+ - os: osx
+ compiler: clang
+ - os: osx
+ compiler: gcc
+env:
+ - CTEST_OUTPUT_ON_FAILURE=1
+
before_script:
- mkdir build
- cd build
- cmake ..
+ - cd ..
script:
- - make
- - test/run-tests
+ - cmake --build build
+ - cmake --build build --target test
-matrix:
- exclude:
- - os: linux
- compiler: clang
+addons:
+ apt:
+ sources:
+ - ubuntu-toolchain-r-test
+ - llvm-toolchain-precise-3.9
+ packages:
+ - g++-4.9
+ - clang-3.9
+ update: true
+ homebrew:
+ packages:
+ - ccache
+ - gcc@4.9
+ - llvm@4
+ update: true
diff --git a/lib/yamlcpp/BUILD.bazel b/lib/yamlcpp/BUILD.bazel
new file mode 100644
index 000000000..b0b901606
--- /dev/null
+++ b/lib/yamlcpp/BUILD.bazel
@@ -0,0 +1,14 @@
+cc_library(
+ name = "yaml-cpp_internal",
+ visibility = ["//:__subpackages__"],
+ strip_include_prefix = "src",
+ hdrs = glob(["src/**/*.h"]),
+)
+
+cc_library(
+ name = "yaml-cpp",
+ visibility = ["//visibility:public"],
+ includes = ["include"],
+ hdrs = glob(["include/**/*.h"]),
+ srcs = glob(["src/**/*.cpp", "src/**/*.h"]),
+)
diff --git a/lib/yamlcpp/CMakeLists.txt b/lib/yamlcpp/CMakeLists.txt
index 4732a453f..b230b9e6d 100644
--- a/lib/yamlcpp/CMakeLists.txt
+++ b/lib/yamlcpp/CMakeLists.txt
@@ -1,367 +1,174 @@
-###
-### CMake settings
-###
-# see http://www.cmake.org/Wiki/CMake_Policies
-cmake_minimum_required(VERSION 3.1)
+# 3.5 is actually available almost everywhere, but this a good minimum
+cmake_minimum_required(VERSION 3.4)
-include(CheckCXXCompilerFlag)
-
-###
-### Project settings
-###
-project(YAML_CPP VERSION 0.6.3)
-
-###
-### Project options
-###
-## Project stuff
-option(YAML_CPP_BUILD_TESTS "Enable testing" ON)
-option(YAML_CPP_BUILD_TOOLS "Enable parse tools" ON)
-option(YAML_CPP_BUILD_CONTRIB "Enable contrib stuff in library" ON)
-option(YAML_CPP_INSTALL "Enable generation of install target" ON)
-
-## Build options
-# --> General
-# see http://www.cmake.org/cmake/help/cmake2.6docs.html#variable:BUILD_SHARED_LIBS
-# http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_library
-option(YAML_BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
-
-# --> Apple
-if(APPLE)
- option(YAML_APPLE_UNIVERSAL_BIN "Apple: Build universal binary" OFF)
+# enable MSVC_RUNTIME_LIBRARY target property
+# see https://cmake.org/cmake/help/latest/policy/CMP0091.html
+if(POLICY CMP0091)
+ cmake_policy(SET CMP0091 NEW)
endif()
-# --> Microsoft Visual C++
-# see http://msdn.microsoft.com/en-us/library/aa278396(v=VS.60).aspx
-# http://msdn.microsoft.com/en-us/library/2kzt1wy3(v=VS.71).aspx
-if(MSVC)
- option(YAML_MSVC_SHARED_RT "MSVC: Build with shared runtime libs (/MD)" ON)
- option(YAML_MSVC_STHREADED_RT "MSVC: Build with single-threaded static runtime libs (/ML until VS .NET 2003)" OFF)
-endif()
-
-###
-### Sources, headers, directories and libs
-###
-
-# From http://www.cmake.org/pipermail/cmake/2010-March/035992.html:
-# function to collect all the sources from sub-directories
-# into a single list
-function(add_sources)
- get_property(is_defined GLOBAL PROPERTY SRCS_LIST DEFINED)
- if(NOT is_defined)
- define_property(GLOBAL PROPERTY SRCS_LIST
- BRIEF_DOCS "List of source files"
- FULL_DOCS "List of all source files in the entire project")
- endif()
- # make absolute paths
- set(SRCS)
- foreach(s IN LISTS ARGN)
- if(NOT IS_ABSOLUTE "${s}")
- get_filename_component(s "${s}" ABSOLUTE)
- endif()
- list(APPEND SRCS "${s}")
- endforeach()
- # append to global list
- set_property(GLOBAL APPEND PROPERTY SRCS_LIST "${SRCS}")
-endfunction(add_sources)
-
-set(header_directory "include/yaml-cpp/")
-
-file(GLOB sources "src/[a-zA-Z]*.cpp")
-file(GLOB_RECURSE public_headers "include/yaml-cpp/[a-zA-Z]*.h")
-file(GLOB private_headers "src/[a-zA-Z]*.h")
-
-if(YAML_CPP_BUILD_CONTRIB)
- file(GLOB contrib_sources "src/contrib/[a-zA-Z]*.cpp")
- file(GLOB contrib_public_headers "include/yaml-cpp/contrib/[a-zA-Z]*.h")
- file(GLOB contrib_private_headers "src/contrib/[a-zA-Z]*.h")
-else()
- add_definitions(-DYAML_CPP_NO_CONTRIB)
-endif()
+project(YAML_CPP VERSION 0.7.0 LANGUAGES CXX)
-set(library_sources
- ${sources}
- ${public_headers}
- ${private_headers}
- ${contrib_sources}
- ${contrib_public_headers}
- ${contrib_private_headers}
-)
-add_sources(${library_sources})
-
-if(VERBOSE)
- message(STATUS "sources: ${sources}")
- message(STATUS "public_headers: ${public_headers}")
- message(STATUS "private_headers: ${private_headers}")
- message(STATUS "contrib_sources: ${contrib_sources}")
- message(STATUS "contrib_public_headers: ${contrib_public_headers}")
- message(STATUS "contrib_private_headers: ${contrib_private_headers}")
-endif()
+include(CMakePackageConfigHelpers)
+include(CMakeDependentOption)
+include(CheckCXXCompilerFlag)
+include(GNUInstallDirs)
+include(CTest)
-if (CMAKE_VERSION VERSION_LESS 2.8.12)
- include_directories(${YAML_CPP_SOURCE_DIR}/src)
- include_directories(${YAML_CPP_SOURCE_DIR}/include)
-endif()
+find_program(YAML_CPP_CLANG_FORMAT_EXE NAMES clang-format)
+option(YAML_CPP_BUILD_CONTRIB "Enable yaml-cpp contrib in library" ON)
+option(YAML_CPP_BUILD_TOOLS "Enable parse tools" ON)
+option(YAML_BUILD_SHARED_LIBS "Build yaml-cpp shared library" ${BUILD_SHARED_LIBS})
-###
-### General compilation settings
-###
-set(yaml_c_flags ${CMAKE_C_FLAGS})
-set(yaml_cxx_flags ${CMAKE_CXX_FLAGS})
+cmake_dependent_option(YAML_CPP_BUILD_TESTS
+ "Enable yaml-cpp tests" ON
+ "BUILD_TESTING;CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)
+cmake_dependent_option(YAML_CPP_INSTALL
+ "Enable generation of yaml-cpp install targets" ON
+ "CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)
+cmake_dependent_option(YAML_MSVC_SHARED_RT
+ "MSVC: Build yaml-cpp with shared runtime libs (/MD)" ON
+ "MSVC" OFF)
-if(YAML_BUILD_SHARED_LIBS)
- set(LABEL_SUFFIX "shared")
-else()
- set(LABEL_SUFFIX "static")
+set(yaml-cpp-type STATIC)
+set(yaml-cpp-label-postfix "static")
+if (YAML_BUILD_SHARED_LIBS)
+ set(yaml-cpp-type SHARED)
+ set(yaml-cpp-label-postfix "shared")
endif()
-if(APPLE)
- if(YAML_APPLE_UNIVERSAL_BIN)
- set(CMAKE_OSX_ARCHITECTURES ppc;i386)
- endif()
-endif()
+set(build-shared $<BOOL:${YAML_BUILD_SHARED_LIBS}>)
+set(build-windows-dll $<AND:$<BOOL:${CMAKE_HOST_WIN32}>,${build-shared}>)
+set(not-msvc $<NOT:$<CXX_COMPILER_ID:MSVC>>)
+set(msvc-shared_rt $<BOOL:${YAML_MSVC_SHARED_RT}>)
-if(IPHONE)
- set(CMAKE_OSX_SYSROOT "iphoneos4.2")
- set(CMAKE_OSX_ARCHITECTURES "armv6;armv7")
+if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
+ set(CMAKE_MSVC_RUNTIME_LIBRARY
+ MultiThreaded$<$<CONFIG:Debug>:Debug>$<${msvc-shared_rt}:DLL>)
endif()
-if(WIN32)
- if(YAML_BUILD_SHARED_LIBS)
- add_definitions(-D${PROJECT_NAME}_DLL) # use or build Windows DLL
- endif()
- if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
- set(CMAKE_INSTALL_PREFIX "C:/")
- endif()
+set(contrib-pattern "src/contrib/*.cpp")
+set(src-pattern "src/*.cpp")
+if (CMAKE_VERSION VERSION_GREATER 3.12)
+ list(INSERT contrib-pattern 0 CONFIGURE_DEPENDS)
+ list(INSERT src-pattern 0 CONFIGURE_DEPENDS)
endif()
-# GCC or Clang or Intel Compiler specialities
-if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
- (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") OR
- CMAKE_CXX_COMPILER_ID MATCHES "Intel")
-
- ### General stuff
- if(WIN32)
- set(CMAKE_SHARED_LIBRARY_PREFIX "") # DLLs do not have a "lib" prefix
- set(CMAKE_IMPORT_LIBRARY_PREFIX "") # same for DLL import libs
- set(CMAKE_LINK_DEF_FILE_FLAG "") # CMake workaround (2.8.3)
- endif()
-
- ### Project stuff
- if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE Release)
- endif()
- #
- set(GCC_EXTRA_OPTIONS "")
- #
- if(YAML_BUILD_SHARED_LIBS)
- set(GCC_EXTRA_OPTIONS "${GCC_EXTRA_OPTIONS} -fPIC")
- endif()
- #
- set(FLAG_TESTED "-Wextra -Wshadow -Weffc++ -pedantic -pedantic-errors")
- check_cxx_compiler_flag(${FLAG_TESTED} FLAG_WEXTRA)
- if(FLAG_WEXTRA)
- set(GCC_EXTRA_OPTIONS "${GCC_EXTRA_OPTIONS} ${FLAG_TESTED}")
- endif()
- #
- set(yaml_cxx_flags "-Wall ${GCC_EXTRA_OPTIONS} -pedantic -Wno-long-long ${yaml_cxx_flags}")
-
- ### Make specific
- if(${CMAKE_BUILD_TOOL} MATCHES make OR ${CMAKE_BUILD_TOOL} MATCHES gmake)
- add_custom_target(debuggable ${CMAKE_MAKE_PROGRAM} clean
- COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR}
- COMMENT "Adjusting settings for debug compilation"
- VERBATIM)
- add_custom_target(releasable ${CMAKE_MAKE_PROGRAM} clean
- COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR}
- COMMENT "Adjusting settings for release compilation"
- VERBATIM)
- endif()
-endif()
+file(GLOB yaml-cpp-contrib-sources ${contrib-pattern})
+file(GLOB yaml-cpp-sources ${src-pattern})
-# Microsoft VisualC++ specialities
-if(MSVC)
- ### General stuff
- # a) Change MSVC runtime library settings (/MD[d], /MT[d], /ML[d] (single-threaded until VS 2003))
- # plus set lib suffix for later use and project label accordingly
- # see http://msdn.microsoft.com/en-us/library/aa278396(v=VS.60).aspx
- # http://msdn.microsoft.com/en-us/library/2kzt1wy3(v=VS.71).aspx
- set(LIB_RT_SUFFIX "md") # CMake defaults to /MD for MSVC
- set(LIB_RT_OPTION "/MD")
- #
- if(NOT YAML_MSVC_SHARED_RT) # User wants to have static runtime libraries (/MT, /ML)
- if(YAML_MSVC_STHREADED_RT) # User wants to have old single-threaded static runtime libraries
- set(LIB_RT_SUFFIX "ml")
- set(LIB_RT_OPTION "/ML")
- if(NOT ${MSVC_VERSION} LESS 1400)
- message(FATAL_ERROR "Single-threaded static runtime libraries (/ML) only available until VS .NET 2003 (7.1).")
- endif()
- else()
- set(LIB_RT_SUFFIX "mt")
- set(LIB_RT_OPTION "/MT")
- endif()
-
- # correct linker options
- foreach(flag_var CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
- foreach(config_name "" DEBUG RELEASE MINSIZEREL RELWITHDEBINFO)
- set(var_name "${flag_var}")
- if(NOT "${config_name}" STREQUAL "")
- set(var_name "${var_name}_${config_name}")
- endif()
- string(REPLACE "/MD" "${LIB_RT_OPTION}" ${var_name} "${${var_name}}")
- set(${var_name} "${${var_name}}" CACHE STRING "" FORCE)
- endforeach()
- endforeach()
- endif()
- #
- set(LABEL_SUFFIX "${LABEL_SUFFIX} ${LIB_RT_SUFFIX}")
-
- # b) Change prefix for static libraries
- set(CMAKE_STATIC_LIBRARY_PREFIX "lib") # to distinguish static libraries from DLL import libs
-
- # c) Correct suffixes for static libraries
- if(NOT YAML_BUILD_SHARED_LIBS)
- ### General stuff
- set(LIB_TARGET_SUFFIX "${LIB_SUFFIX}${LIB_RT_SUFFIX}")
- endif()
-
- ### Project stuff
- # /W3 = set warning level; see http://msdn.microsoft.com/en-us/library/thxezb7y.aspx
- # /wd4127 = disable warning C4127 "conditional expression is constant"; see http://msdn.microsoft.com/en-us/library/6t66728h.aspx
- # /wd4355 = disable warning C4355 "'this' : used in base member initializer list"; http://msdn.microsoft.com/en-us/library/3c594ae3.aspx
- set(yaml_cxx_flags "/W3 /wd4127 /wd4355 ${yaml_cxx_flags}")
-endif()
+set(msvc-rt $<TARGET_PROPERTY:MSVC_RUNTIME_LIBRARY>)
+set(msvc-rt-mtd-static $<STREQUAL:${msvc-rt},MultiThreadedDebug>)
+set(msvc-rt-mt-static $<STREQUAL:${msvc-rt},MultiThreaded>)
-###
-### General install settings
-###
-set(INCLUDE_INSTALL_ROOT_DIR include)
+set(msvc-rt-mtd-dll $<STREQUAL:${msvc-rt},MultiThreadedDebugDLL>)
+set(msvc-rt-mt-dll $<STREQUAL:${msvc-rt},MultiThreadedDLL>)
-set(INCLUDE_INSTALL_DIR ${INCLUDE_INSTALL_ROOT_DIR}/yaml-cpp)
-set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}")
+set(backport-msvc-runtime $<VERSION_LESS:${CMAKE_VERSION},3.15>)
-set(_INSTALL_DESTINATIONS
- RUNTIME DESTINATION bin
- LIBRARY DESTINATION ${LIB_INSTALL_DIR}
- ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
-)
+add_library(yaml-cpp ${yaml-cpp-type} "")
+add_library(yaml-cpp::yaml-cpp ALIAS yaml-cpp)
+set_property(TARGET yaml-cpp
+ PROPERTY
+ MSVC_RUNTIME_LIBRARY ${CMAKE_MSVC_RUNTIME_LIBRARY})
+set_property(TARGET yaml-cpp
+ PROPERTY
+ CXX_STANDARD_REQUIRED ON)
-###
-### Library
-###
-if(YAML_BUILD_SHARED_LIBS)
- add_library(yaml-cpp SHARED ${library_sources})
-else()
- add_library(yaml-cpp STATIC ${library_sources})
-endif()
+target_include_directories(yaml-cpp
+ PUBLIC
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+ PRIVATE
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>)
-if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
- target_include_directories(yaml-cpp
- PUBLIC $<BUILD_INTERFACE:${YAML_CPP_SOURCE_DIR}/include>
- $<INSTALL_INTERFACE:${INCLUDE_INSTALL_ROOT_DIR}>
- PRIVATE $<BUILD_INTERFACE:${YAML_CPP_SOURCE_DIR}/src>)
+if (NOT DEFINED CMAKE_CXX_STANDARD)
+ set_target_properties(yaml-cpp
+ PROPERTIES
+ CXX_STANDARD 11)
endif()
-set_target_properties(yaml-cpp PROPERTIES
- CXX_STANDARD 11
- CXX_STANDARD_REQUIRED ON
-)
+target_compile_options(yaml-cpp
+ PRIVATE
+ $<${not-msvc}:-Wall -Wextra -Wshadow -Weffc++ -Wno-long-long>
+ $<${not-msvc}:-pedantic -pedantic-errors>
-set_target_properties(yaml-cpp PROPERTIES
- COMPILE_FLAGS "${yaml_c_flags} ${yaml_cxx_flags}"
-)
-
-set_target_properties(yaml-cpp PROPERTIES
- VERSION "${YAML_CPP_VERSION}"
- SOVERSION "${YAML_CPP_VERSION_MAJOR}.${YAML_CPP_VERSION_MINOR}"
- PROJECT_LABEL "yaml-cpp ${LABEL_SUFFIX}"
-)
-
-if(IPHONE)
- set_target_properties(yaml-cpp PROPERTIES
- XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "3.0"
- )
-endif()
+ $<$<AND:${backport-msvc-runtime},${msvc-rt-mtd-static}>:-MTd>
+ $<$<AND:${backport-msvc-runtime},${msvc-rt-mt-static}>:-MT>
+ $<$<AND:${backport-msvc-runtime},${msvc-rt-mtd-dll}>:-MDd>
+ $<$<AND:${backport-msvc-runtime},${msvc-rt-mt-dll}>:-MD>
-if(MSVC)
- if(NOT YAML_BUILD_SHARED_LIBS)
- # correct library names
- set_target_properties(yaml-cpp PROPERTIES
- DEBUG_POSTFIX "${LIB_TARGET_SUFFIX}d"
- RELEASE_POSTFIX "${LIB_TARGET_SUFFIX}"
- MINSIZEREL_POSTFIX "${LIB_TARGET_SUFFIX}"
- RELWITHDEBINFO_POSTFIX "${LIB_TARGET_SUFFIX}"
- )
- endif()
-endif()
-
-if (YAML_CPP_INSTALL)
- install(TARGETS yaml-cpp EXPORT yaml-cpp-targets ${_INSTALL_DESTINATIONS})
- install(
- DIRECTORY ${header_directory}
- DESTINATION ${INCLUDE_INSTALL_DIR}
- FILES_MATCHING PATTERN "*.h"
- )
-endif()
+ # /wd4127 = disable warning C4127 "conditional expression is constant"
+ # http://msdn.microsoft.com/en-us/library/6t66728h.aspx
+ # /wd4355 = disable warning C4355 "'this' : used in base member initializer list
+ # http://msdn.microsoft.com/en-us/library/3c594ae3.aspx
+ $<$<CXX_COMPILER_ID:MSVC>:/W3 /wd4127 /wd4355>)
-export(
- TARGETS yaml-cpp
- FILE "${PROJECT_BINARY_DIR}/yaml-cpp-targets.cmake")
-export(PACKAGE yaml-cpp)
-set(EXPORT_TARGETS yaml-cpp CACHE INTERNAL "export targets")
+target_compile_definitions(yaml-cpp
+ PRIVATE
+ $<${build-windows-dll}:${PROJECT_NAME}_DLL>
+ $<$<NOT:$<BOOL:${YAML_CPP_BUILD_CONTRIB}>>:YAML_CPP_NO_CONTRIB>)
-set(CONFIG_INCLUDE_DIRS "${YAML_CPP_SOURCE_DIR}/include")
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/yaml-cpp-config.cmake.in
- "${PROJECT_BINARY_DIR}/yaml-cpp-config.cmake" @ONLY)
+target_sources(yaml-cpp
+ PRIVATE
+ $<$<BOOL:${YAML_CPP_BUILD_CONTRIB}>:${yaml-cpp-contrib-sources}>
+ ${yaml-cpp-sources})
-if(WIN32 AND NOT CYGWIN)
- set(INSTALL_CMAKE_DIR CMake)
-else()
- set(INSTALL_CMAKE_DIR ${LIB_INSTALL_DIR}/cmake/yaml-cpp)
+if (NOT DEFINED CMAKE_DEBUG_POSTFIX)
+ set(CMAKE_DEBUG_POSTFIX "d")
endif()
+set_target_properties(yaml-cpp PROPERTIES
+ VERSION "${PROJECT_VERSION}"
+ SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
+ PROJECT_LABEL "yaml-cpp ${yaml-cpp-label-postfix}"
+ DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
+
+configure_package_config_file(
+ "${PROJECT_SOURCE_DIR}/yaml-cpp-config.cmake.in"
+ "${PROJECT_BINARY_DIR}/yaml-cpp-config.cmake"
+ INSTALL_DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/yaml-cpp")
-file(RELATIVE_PATH REL_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/${INSTALL_CMAKE_DIR}" "${CMAKE_INSTALL_PREFIX}/${INCLUDE_INSTALL_ROOT_DIR}")
-set(CONFIG_INCLUDE_DIRS "\${YAML_CPP_CMAKE_DIR}/${REL_INCLUDE_DIR}")
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/yaml-cpp-config.cmake.in
- "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/yaml-cpp-config.cmake" @ONLY)
+write_basic_package_version_file(
+ "${PROJECT_BINARY_DIR}/yaml-cpp-config-version.cmake"
+ COMPATIBILITY AnyNewerVersion)
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/yaml-cpp-config-version.cmake.in
- "${PROJECT_BINARY_DIR}/yaml-cpp-config-version.cmake" @ONLY)
+configure_file(yaml-cpp.pc.in yaml-cpp.pc @ONLY)
if (YAML_CPP_INSTALL)
+ install(TARGETS yaml-cpp
+ EXPORT yaml-cpp-targets
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+ FILES_MATCHING PATTERN "*.h")
+ install(EXPORT yaml-cpp-targets
+ DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/yaml-cpp")
install(FILES
- "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/yaml-cpp-config.cmake"
+ "${PROJECT_BINARY_DIR}/yaml-cpp-config.cmake"
"${PROJECT_BINARY_DIR}/yaml-cpp-config-version.cmake"
- DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev)
- install(EXPORT yaml-cpp-targets DESTINATION ${INSTALL_CMAKE_DIR})
-
- if(UNIX)
- set(PC_FILE ${CMAKE_BINARY_DIR}/yaml-cpp.pc)
- configure_file("yaml-cpp.pc.cmake" ${PC_FILE} @ONLY)
- install(FILES ${PC_FILE} DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
- endif()
-
+ DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/yaml-cpp")
+ install(FILES "${PROJECT_BINARY_DIR}/yaml-cpp.pc"
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/pkgconfig)
endif()
-
-###
-### Extras
-###
if(YAML_CPP_BUILD_TESTS)
- enable_testing()
add_subdirectory(test)
endif()
+
if(YAML_CPP_BUILD_TOOLS)
add_subdirectory(util)
endif()
-### Formatting
-get_property(all_sources GLOBAL PROPERTY SRCS_LIST)
-add_custom_target(format
- COMMAND clang-format --style=file -i ${all_sources}
- COMMENT "Running clang-format"
- VERBATIM)
+if (YAML_CPP_CLANG_FORMAT_EXE)
+ add_custom_target(format
+ COMMAND clang-format --style=file -i $<TARGET_PROPERTY:yaml-cpp,SOURCES>
+ COMMAND_EXPAND_LISTS
+ COMMENT "Running clang-format"
+ VERBATIM)
+endif()
diff --git a/lib/yamlcpp/Makefile.am b/lib/yamlcpp/Makefile.am
index 0bb0ab01f..655e3dff3 100644
--- a/lib/yamlcpp/Makefile.am
+++ b/lib/yamlcpp/Makefile.am
@@ -23,6 +23,7 @@ noinst_LTLIBRARIES = libyamlcpp.la
libyamlcpp_la_SOURCES = src/binary.cpp \
src/convert.cpp \
+src/depthguard.cpp \
src/directives.cpp \
src/emit.cpp \
src/emitfromevents.cpp \
@@ -62,4 +63,4 @@ yamlcpp_node_include_HEADERS = \
yamlcpp_node_detail_includedir=$(includedir)/yaml-cpp/node/detail
yamlcpp_node_detail_include_HEADERS = \
$(srcdir)/include/yaml-cpp/node/detail/*.h
-
+
diff --git a/lib/yamlcpp/README.md b/lib/yamlcpp/README.md
index e793143af..627d44125 100644
--- a/lib/yamlcpp/README.md
+++ b/lib/yamlcpp/README.md
@@ -49,3 +49,13 @@ cmake [-G generator] [-DYAML_BUILD_SHARED_LIBS=ON|OFF] ..
[yaml-cpp 0.3.0](https://github.com/jbeder/yaml-cpp/releases/tag/release-0.3.0) is still available if you want the old API.
**The old API will continue to be supported, and will still receive bugfixes!** The 0.3.x and 0.4.x versions will be old API releases, and 0.5.x and above will all be new API releases.
+
+# API Documentation
+
+The autogenerated API reference is hosted on [CodeDocs](https://codedocs.xyz/jbeder/yaml-cpp/index.html)
+
+# Third Party Integrations
+
+The following projects are not officially supported:
+
+- [Qt wrapper](https://gist.github.com/brcha/d392b2fe5f1e427cc8a6)
diff --git a/lib/yamlcpp/WORKSPACE b/lib/yamlcpp/WORKSPACE
new file mode 100644
index 000000000..d5ecc0b54
--- /dev/null
+++ b/lib/yamlcpp/WORKSPACE
@@ -0,0 +1,10 @@
+workspace(name = "com_github_jbeder_yaml_cpp")
+
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
+http_archive(
+ name = "com_google_googletest",
+ strip_prefix = "googletest-release-1.8.1",
+ url = "https://github.com/google/googletest/archive/release-1.8.1.tar.gz",
+ sha256 = "9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c",
+)
diff --git a/lib/yamlcpp/appveyor.yml b/lib/yamlcpp/appveyor.yml
new file mode 100644
index 000000000..54bcc80c5
--- /dev/null
+++ b/lib/yamlcpp/appveyor.yml
@@ -0,0 +1,28 @@
+version: 1.0.{build}
+
+environment:
+ matrix:
+ - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
+ CMAKE_GENERATOR: Visual Studio 14 2015
+ CMAKE_PLATFORM: win32
+ - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
+ CMAKE_GENERATOR: Visual Studio 14 2015
+ CMAKE_PLATFORM: x64
+ - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
+ CMAKE_GENERATOR: Visual Studio 15 2017
+ CMAKE_PLATFORM: win32
+ - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
+ CMAKE_GENERATOR: Visual Studio 15 2017
+ CMAKE_PLATFORM: x64
+
+before_build:
+ - cmd: mkdir build
+ - cmd: cd build
+ - cmd: cmake .. -G "%CMAKE_GENERATOR%" -DCMAKE_GENERATOR_PLATFORM=%CMAKE_PLATFORM%
+ - cmd: cd ..
+
+build_script:
+ - cmake --build build
+test_script:
+ - cmd: cd build
+ - ctest
diff --git a/lib/yamlcpp/include/yaml-cpp/anchor.h b/lib/yamlcpp/include/yaml-cpp/anchor.h
index 06759c724..f46d1d79d 100644
--- a/lib/yamlcpp/include/yaml-cpp/anchor.h
+++ b/lib/yamlcpp/include/yaml-cpp/anchor.h
@@ -10,7 +10,7 @@
#include <cstddef>
namespace YAML {
-typedef std::size_t anchor_t;
+using anchor_t = std::size_t;
const anchor_t NullAnchor = 0;
}
diff --git a/lib/yamlcpp/include/yaml-cpp/contrib/graphbuilder.h b/lib/yamlcpp/include/yaml-cpp/contrib/graphbuilder.h
index f0a38f288..dbffd921e 100644
--- a/lib/yamlcpp/include/yaml-cpp/contrib/graphbuilder.h
+++ b/lib/yamlcpp/include/yaml-cpp/contrib/graphbuilder.h
@@ -15,7 +15,7 @@ class Parser;
// GraphBuilderInterface
// . Abstraction of node creation
-// . pParentNode is always NULL or the return value of one of the NewXXX()
+// . pParentNode is always nullptr or the return value of one of the NewXXX()
// functions.
class GraphBuilderInterface {
public:
@@ -73,9 +73,9 @@ class GraphBuilder : public GraphBuilderInterface {
typedef typename Impl::Map Map;
GraphBuilder(Impl &impl) : m_impl(impl) {
- Map *pMap = NULL;
- Sequence *pSeq = NULL;
- Node *pNode = NULL;
+ Map *pMap = nullptr;
+ Sequence *pSeq = nullptr;
+ Node *pNode = nullptr;
// Type consistency checks
pNode = pMap;
diff --git a/lib/yamlcpp/include/yaml-cpp/depthguard.h b/lib/yamlcpp/include/yaml-cpp/depthguard.h
new file mode 100644
index 000000000..8ca61ac6c
--- /dev/null
+++ b/lib/yamlcpp/include/yaml-cpp/depthguard.h
@@ -0,0 +1,77 @@
+#ifndef DEPTH_GUARD_H_00000000000000000000000000000000000000000000000000000000
+#define DEPTH_GUARD_H_00000000000000000000000000000000000000000000000000000000
+
+#if defined(_MSC_VER) || \
+ (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
+ (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
+#pragma once
+#endif
+
+#include "exceptions.h"
+
+namespace YAML {
+
+/**
+ * @brief The DeepRecursion class
+ * An exception class which is thrown by DepthGuard. Ideally it should be
+ * a member of DepthGuard. However, DepthGuard is a templated class which means
+ * that any catch points would then need to know the template parameters. It is
+ * simpler for clients to not have to know at the catch point what was the
+ * maximum depth.
+ */
+class DeepRecursion : public ParserException {
+public:
+ virtual ~DeepRecursion() = default;
+
+ DeepRecursion(int depth, const Mark& mark_, const std::string& msg_);
+
+ // Returns the recursion depth when the exception was thrown
+ int depth() const {
+ return m_depth;
+ }
+
+private:
+ int m_depth = 0;
+};
+
+/**
+ * @brief The DepthGuard class
+ * DepthGuard takes a reference to an integer. It increments the integer upon
+ * construction of DepthGuard and decrements the integer upon destruction.
+ *
+ * If the integer would be incremented past max_depth, then an exception is
+ * thrown. This is ideally geared toward guarding against deep recursion.
+ *
+ * @param max_depth
+ * compile-time configurable maximum depth.
+ */
+template <int max_depth = 2000>
+class DepthGuard final {
+public:
+ DepthGuard(int & depth_, const Mark& mark_, const std::string& msg_) : m_depth(depth_) {
+ ++m_depth;
+ if ( max_depth <= m_depth ) {
+ throw DeepRecursion{m_depth, mark_, msg_};
+ }
+ }
+
+ DepthGuard(const DepthGuard & copy_ctor) = delete;
+ DepthGuard(DepthGuard && move_ctor) = delete;
+ DepthGuard & operator=(const DepthGuard & copy_assign) = delete;
+ DepthGuard & operator=(DepthGuard && move_assign) = delete;
+
+ ~DepthGuard() {
+ --m_depth;
+ }
+
+ int current_depth() const {
+ return m_depth;
+ }
+
+private:
+ int & m_depth;
+};
+
+} // namespace YAML
+
+#endif // DEPTH_GUARD_H_00000000000000000000000000000000000000000000000000000000
diff --git a/lib/yamlcpp/include/yaml-cpp/emitfromevents.h b/lib/yamlcpp/include/yaml-cpp/emitfromevents.h
index f14b051ab..1f389c5a1 100644
--- a/lib/yamlcpp/include/yaml-cpp/emitfromevents.h
+++ b/lib/yamlcpp/include/yaml-cpp/emitfromevents.h
@@ -24,21 +24,21 @@ class EmitFromEvents : public EventHandler {
public:
EmitFromEvents(Emitter& emitter);
- virtual void OnDocumentStart(const Mark& mark);
- virtual void OnDocumentEnd();
+ void OnDocumentStart(const Mark& mark) override;
+ void OnDocumentEnd() override;
- virtual void OnNull(const Mark& mark, anchor_t anchor);
- virtual void OnAlias(const Mark& mark, anchor_t anchor);
- virtual void OnScalar(const Mark& mark, const std::string& tag,
- anchor_t anchor, const std::string& value);
+ void OnNull(const Mark& mark, anchor_t anchor) override;
+ void OnAlias(const Mark& mark, anchor_t anchor) override;
+ void OnScalar(const Mark& mark, const std::string& tag,
+ anchor_t anchor, const std::string& value) override;
- virtual void OnSequenceStart(const Mark& mark, const std::string& tag,
- anchor_t anchor, EmitterStyle::value style);
- virtual void OnSequenceEnd();
+ void OnSequenceStart(const Mark& mark, const std::string& tag,
+ anchor_t anchor, EmitterStyle::value style) override;
+ void OnSequenceEnd() override;
- virtual void OnMapStart(const Mark& mark, const std::string& tag,
- anchor_t anchor, EmitterStyle::value style);
- virtual void OnMapEnd();
+ void OnMapStart(const Mark& mark, const std::string& tag,
+ anchor_t anchor, EmitterStyle::value style) override;
+ void OnMapEnd() override;
private:
void BeginNode();
diff --git a/lib/yamlcpp/include/yaml-cpp/emitter.h b/lib/yamlcpp/include/yaml-cpp/emitter.h
index 6f142b011..210b1ec97 100644
--- a/lib/yamlcpp/include/yaml-cpp/emitter.h
+++ b/lib/yamlcpp/include/yaml-cpp/emitter.h
@@ -50,6 +50,7 @@ class YAML_CPP_API Emitter {
bool SetOutputCharset(EMITTER_MANIP value);
bool SetStringFormat(EMITTER_MANIP value);
bool SetBoolFormat(EMITTER_MANIP value);
+ bool SetNullFormat(EMITTER_MANIP value);
bool SetIntBase(EMITTER_MANIP value);
bool SetSeqFormat(EMITTER_MANIP value);
bool SetMapFormat(EMITTER_MANIP value);
@@ -58,6 +59,7 @@ class YAML_CPP_API Emitter {
bool SetPostCommentIndent(std::size_t n);
bool SetFloatPrecision(std::size_t n);
bool SetDoublePrecision(std::size_t n);
+ void RestoreGlobalModifiedSettings();
// local setters
Emitter& SetLocalValue(EMITTER_MANIP value);
@@ -123,6 +125,7 @@ class YAML_CPP_API Emitter {
void SpaceOrIndentTo(bool requireSpace, std::size_t indent);
const char* ComputeFullBoolName(bool b) const;
+ const char* ComputeNullName() const;
bool CanEmitNewline() const;
private:
@@ -164,13 +167,12 @@ inline Emitter& Emitter::WriteStreamable(T value) {
std::isnan(value)) {
special = true;
stream << ".nan";
- } else if (std::numeric_limits<T>::has_infinity) {
- if (value == std::numeric_limits<T>::infinity()) {
- special = true;
- stream << ".inf";
- } else if (value == -std::numeric_limits<T>::infinity()) {
- special = true;
+ } else if (std::numeric_limits<T>::has_infinity && std::isinf(value)) {
+ special = true;
+ if (std::signbit(value)) {
stream << "-.inf";
+ } else {
+ stream << ".inf";
}
}
}
diff --git a/lib/yamlcpp/include/yaml-cpp/emittermanip.h b/lib/yamlcpp/include/yaml-cpp/emittermanip.h
index 89f725671..976d14950 100644
--- a/lib/yamlcpp/include/yaml-cpp/emittermanip.h
+++ b/lib/yamlcpp/include/yaml-cpp/emittermanip.h
@@ -19,6 +19,7 @@ enum EMITTER_MANIP {
// output character set
EmitNonAscii,
EscapeNonAscii,
+ EscapeAsJson,
// string manipulators
// Auto, // duplicate
@@ -26,6 +27,12 @@ enum EMITTER_MANIP {
DoubleQuoted,
Literal,
+ // null manipulators
+ LowerNull,
+ UpperNull,
+ CamelNull,
+ TildeNull,
+
// bool manipulators
YesNoBool, // yes, no
TrueFalseBool, // true, false
@@ -74,14 +81,14 @@ struct _Alias {
std::string content;
};
-inline _Alias Alias(const std::string content) { return _Alias(content); }
+inline _Alias Alias(const std::string& content) { return _Alias(content); }
struct _Anchor {
_Anchor(const std::string& content_) : content(content_) {}
std::string content;
};
-inline _Anchor Anchor(const std::string content) { return _Anchor(content); }
+inline _Anchor Anchor(const std::string& content) { return _Anchor(content); }
struct _Tag {
struct Type {
@@ -96,11 +103,11 @@ struct _Tag {
Type::value type;
};
-inline _Tag VerbatimTag(const std::string content) {
+inline _Tag VerbatimTag(const std::string& content) {
return _Tag("", content, _Tag::Type::Verbatim);
}
-inline _Tag LocalTag(const std::string content) {
+inline _Tag LocalTag(const std::string& content) {
return _Tag("", content, _Tag::Type::PrimaryHandle);
}
@@ -108,7 +115,7 @@ inline _Tag LocalTag(const std::string& prefix, const std::string content) {
return _Tag(prefix, content, _Tag::Type::NamedHandle);
}
-inline _Tag SecondaryTag(const std::string content) {
+inline _Tag SecondaryTag(const std::string& content) {
return _Tag("", content, _Tag::Type::NamedHandle);
}
@@ -117,7 +124,7 @@ struct _Comment {
std::string content;
};
-inline _Comment Comment(const std::string content) { return _Comment(content); }
+inline _Comment Comment(const std::string& content) { return _Comment(content); }
struct _Precision {
_Precision(int floatPrecision_, int doublePrecision_)
diff --git a/lib/yamlcpp/include/yaml-cpp/eventhandler.h b/lib/yamlcpp/include/yaml-cpp/eventhandler.h
index 29718ffa1..7242fe1f5 100644
--- a/lib/yamlcpp/include/yaml-cpp/eventhandler.h
+++ b/lib/yamlcpp/include/yaml-cpp/eventhandler.h
@@ -17,7 +17,7 @@ struct Mark;
class EventHandler {
public:
- virtual ~EventHandler() {}
+ virtual ~EventHandler() = default;
virtual void OnDocumentStart(const Mark& mark) = 0;
virtual void OnDocumentEnd() = 0;
diff --git a/lib/yamlcpp/include/yaml-cpp/exceptions.h b/lib/yamlcpp/include/yaml-cpp/exceptions.h
index eef22833a..c3f44747e 100644
--- a/lib/yamlcpp/include/yaml-cpp/exceptions.h
+++ b/lib/yamlcpp/include/yaml-cpp/exceptions.h
@@ -8,19 +8,12 @@
#endif
#include "yaml-cpp/mark.h"
+#include "yaml-cpp/noexcept.h"
#include "yaml-cpp/traits.h"
#include <sstream>
#include <stdexcept>
#include <string>
-// This is here for compatibility with older versions of Visual Studio
-// which don't support noexcept
-#if defined(_MSC_VER) && _MSC_VER < 1900
- #define YAML_CPP_NOEXCEPT _NOEXCEPT
-#else
- #define YAML_CPP_NOEXCEPT noexcept
-#endif
-
namespace YAML {
// error messages
namespace ErrorMsg {
@@ -107,6 +100,12 @@ inline const std::string KEY_NOT_FOUND_WITH_KEY(const std::string& key) {
return stream.str();
}
+inline const std::string KEY_NOT_FOUND_WITH_KEY(const char* key) {
+ std::stringstream stream;
+ stream << KEY_NOT_FOUND << ": " << key;
+ return stream.str();
+}
+
template <typename T>
inline const std::string KEY_NOT_FOUND_WITH_KEY(
const T& key, typename enable_if<is_numeric<T>>::type* = 0) {
@@ -127,6 +126,12 @@ inline const std::string BAD_SUBSCRIPT_WITH_KEY(const std::string& key) {
return stream.str();
}
+inline const std::string BAD_SUBSCRIPT_WITH_KEY(const char* key) {
+ std::stringstream stream;
+ stream << BAD_SUBSCRIPT << " (key: \"" << key << "\")";
+ return stream.str();
+}
+
template <typename T>
inline const std::string BAD_SUBSCRIPT_WITH_KEY(
const T& key, typename enable_if<is_numeric<T>>::type* = nullptr) {
@@ -143,13 +148,13 @@ inline const std::string INVALID_NODE_WITH_KEY(const std::string& key) {
stream << "invalid node; first invalid key: \"" << key << "\"";
return stream.str();
}
-}
+} // namespace ErrorMsg
class YAML_CPP_API Exception : public std::runtime_error {
public:
Exception(const Mark& mark_, const std::string& msg_)
: std::runtime_error(build_what(mark_, msg_)), mark(mark_), msg(msg_) {}
- virtual ~Exception() YAML_CPP_NOEXCEPT;
+ ~Exception() YAML_CPP_NOEXCEPT override;
Exception(const Exception&) = default;
@@ -175,7 +180,7 @@ class YAML_CPP_API ParserException : public Exception {
ParserException(const Mark& mark_, const std::string& msg_)
: Exception(mark_, msg_) {}
ParserException(const ParserException&) = default;
- virtual ~ParserException() YAML_CPP_NOEXCEPT;
+ ~ParserException() YAML_CPP_NOEXCEPT override;
};
class YAML_CPP_API RepresentationException : public Exception {
@@ -183,7 +188,7 @@ class YAML_CPP_API RepresentationException : public Exception {
RepresentationException(const Mark& mark_, const std::string& msg_)
: Exception(mark_, msg_) {}
RepresentationException(const RepresentationException&) = default;
- virtual ~RepresentationException() YAML_CPP_NOEXCEPT;
+ ~RepresentationException() YAML_CPP_NOEXCEPT override;
};
// representation exceptions
@@ -192,7 +197,7 @@ class YAML_CPP_API InvalidScalar : public RepresentationException {
InvalidScalar(const Mark& mark_)
: RepresentationException(mark_, ErrorMsg::INVALID_SCALAR) {}
InvalidScalar(const InvalidScalar&) = default;
- virtual ~InvalidScalar() YAML_CPP_NOEXCEPT;
+ ~InvalidScalar() YAML_CPP_NOEXCEPT override;
};
class YAML_CPP_API KeyNotFound : public RepresentationException {
@@ -202,7 +207,7 @@ class YAML_CPP_API KeyNotFound : public RepresentationException {
: RepresentationException(mark_, ErrorMsg::KEY_NOT_FOUND_WITH_KEY(key_)) {
}
KeyNotFound(const KeyNotFound&) = default;
- virtual ~KeyNotFound() YAML_CPP_NOEXCEPT;
+ ~KeyNotFound() YAML_CPP_NOEXCEPT override;
};
template <typename T>
@@ -210,7 +215,7 @@ class YAML_CPP_API TypedKeyNotFound : public KeyNotFound {
public:
TypedKeyNotFound(const Mark& mark_, const T& key_)
: KeyNotFound(mark_, key_), key(key_) {}
- virtual ~TypedKeyNotFound() YAML_CPP_NOEXCEPT {}
+ ~TypedKeyNotFound() YAML_CPP_NOEXCEPT override = default;
T key;
};
@@ -223,11 +228,11 @@ inline TypedKeyNotFound<T> MakeTypedKeyNotFound(const Mark& mark,
class YAML_CPP_API InvalidNode : public RepresentationException {
public:
- InvalidNode(std::string key)
+ InvalidNode(const std::string& key)
: RepresentationException(Mark::null_mark(),
ErrorMsg::INVALID_NODE_WITH_KEY(key)) {}
InvalidNode(const InvalidNode&) = default;
- virtual ~InvalidNode() YAML_CPP_NOEXCEPT;
+ ~InvalidNode() YAML_CPP_NOEXCEPT override;
};
class YAML_CPP_API BadConversion : public RepresentationException {
@@ -235,7 +240,7 @@ class YAML_CPP_API BadConversion : public RepresentationException {
explicit BadConversion(const Mark& mark_)
: RepresentationException(mark_, ErrorMsg::BAD_CONVERSION) {}
BadConversion(const BadConversion&) = default;
- virtual ~BadConversion() YAML_CPP_NOEXCEPT;
+ ~BadConversion() YAML_CPP_NOEXCEPT override;
};
template <typename T>
@@ -249,17 +254,16 @@ class YAML_CPP_API BadDereference : public RepresentationException {
BadDereference()
: RepresentationException(Mark::null_mark(), ErrorMsg::BAD_DEREFERENCE) {}
BadDereference(const BadDereference&) = default;
- virtual ~BadDereference() YAML_CPP_NOEXCEPT;
+ ~BadDereference() YAML_CPP_NOEXCEPT override;
};
class YAML_CPP_API BadSubscript : public RepresentationException {
public:
template <typename Key>
- BadSubscript(const Key& key)
- : RepresentationException(Mark::null_mark(),
- ErrorMsg::BAD_SUBSCRIPT_WITH_KEY(key)) {}
+ BadSubscript(const Mark& mark_, const Key& key)
+ : RepresentationException(mark_, ErrorMsg::BAD_SUBSCRIPT_WITH_KEY(key)) {}
BadSubscript(const BadSubscript&) = default;
- virtual ~BadSubscript() YAML_CPP_NOEXCEPT;
+ ~BadSubscript() YAML_CPP_NOEXCEPT override;
};
class YAML_CPP_API BadPushback : public RepresentationException {
@@ -267,7 +271,7 @@ class YAML_CPP_API BadPushback : public RepresentationException {
BadPushback()
: RepresentationException(Mark::null_mark(), ErrorMsg::BAD_PUSHBACK) {}
BadPushback(const BadPushback&) = default;
- virtual ~BadPushback() YAML_CPP_NOEXCEPT;
+ ~BadPushback() YAML_CPP_NOEXCEPT override;
};
class YAML_CPP_API BadInsert : public RepresentationException {
@@ -275,7 +279,7 @@ class YAML_CPP_API BadInsert : public RepresentationException {
BadInsert()
: RepresentationException(Mark::null_mark(), ErrorMsg::BAD_INSERT) {}
BadInsert(const BadInsert&) = default;
- virtual ~BadInsert() YAML_CPP_NOEXCEPT;
+ ~BadInsert() YAML_CPP_NOEXCEPT override;
};
class YAML_CPP_API EmitterException : public Exception {
@@ -283,17 +287,17 @@ class YAML_CPP_API EmitterException : public Exception {
EmitterException(const std::string& msg_)
: Exception(Mark::null_mark(), msg_) {}
EmitterException(const EmitterException&) = default;
- virtual ~EmitterException() YAML_CPP_NOEXCEPT;
+ ~EmitterException() YAML_CPP_NOEXCEPT override;
};
class YAML_CPP_API BadFile : public Exception {
public:
- BadFile() : Exception(Mark::null_mark(), ErrorMsg::BAD_FILE) {}
+ explicit BadFile(const std::string& filename)
+ : Exception(Mark::null_mark(),
+ std::string(ErrorMsg::BAD_FILE) + ": " + filename) {}
BadFile(const BadFile&) = default;
- virtual ~BadFile() YAML_CPP_NOEXCEPT;
+ ~BadFile() YAML_CPP_NOEXCEPT override;
};
-}
-
-#undef YAML_CPP_NOEXCEPT
+} // namespace YAML
#endif // EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
diff --git a/lib/yamlcpp/include/yaml-cpp/node/convert.h b/lib/yamlcpp/include/yaml-cpp/node/convert.h
index d61b73d09..596898da6 100644
--- a/lib/yamlcpp/include/yaml-cpp/node/convert.h
+++ b/lib/yamlcpp/include/yaml-cpp/node/convert.h
@@ -8,10 +8,12 @@
#endif
#include <array>
+#include <cmath>
#include <limits>
#include <list>
#include <map>
#include <sstream>
+#include <type_traits>
#include <vector>
#include "yaml-cpp/binary.h"
@@ -21,6 +23,7 @@
#include "yaml-cpp/node/type.h"
#include "yaml-cpp/null.h"
+
namespace YAML {
class Binary;
struct _Null;
@@ -71,12 +74,17 @@ struct convert<std::string> {
// C-strings can only be encoded
template <>
struct convert<const char*> {
- static Node encode(const char*& rhs) { return Node(rhs); }
+ static Node encode(const char* rhs) { return Node(rhs); }
+};
+
+template <>
+struct convert<char*> {
+ static Node encode(const char* rhs) { return Node(rhs); }
};
template <std::size_t N>
-struct convert<const char[N]> {
- static Node encode(const char(&rhs)[N]) { return Node(rhs); }
+struct convert<char[N]> {
+ static Node encode(const char* rhs) { return Node(rhs); }
};
template <>
@@ -88,43 +96,98 @@ struct convert<_Null> {
}
};
-#define YAML_DEFINE_CONVERT_STREAMABLE(type, negative_op) \
- template <> \
- struct convert<type> { \
- static Node encode(const type& rhs) { \
- std::stringstream stream; \
- stream.precision(std::numeric_limits<type>::max_digits10); \
- stream << rhs; \
- return Node(stream.str()); \
- } \
- \
- static bool decode(const Node& node, type& rhs) { \
- if (node.Type() != NodeType::Scalar) \
- return false; \
- const std::string& input = node.Scalar(); \
- std::stringstream stream(input); \
- stream.unsetf(std::ios::dec); \
- if ((stream >> std::noskipws >> rhs) && (stream >> std::ws).eof()) \
- return true; \
- if (std::numeric_limits<type>::has_infinity) { \
- if (conversion::IsInfinity(input)) { \
- rhs = std::numeric_limits<type>::infinity(); \
- return true; \
- } else if (conversion::IsNegativeInfinity(input)) { \
- rhs = negative_op std::numeric_limits<type>::infinity(); \
- return true; \
- } \
- } \
- \
- if (std::numeric_limits<type>::has_quiet_NaN) { \
- if (conversion::IsNaN(input)) { \
- rhs = std::numeric_limits<type>::quiet_NaN(); \
- return true; \
- } \
- } \
- \
- return false; \
- } \
+namespace conversion {
+template <typename T>
+typename std::enable_if< std::is_floating_point<T>::value, void>::type
+inner_encode(const T& rhs, std::stringstream& stream){
+ if (std::isnan(rhs)) {
+ stream << ".nan";
+ } else if (std::isinf(rhs)) {
+ if (std::signbit(rhs)) {
+ stream << "-.inf";
+ } else {
+ stream << ".inf";
+ }
+ } else {
+ stream << rhs;
+ }
+}
+
+template <typename T>
+typename std::enable_if<!std::is_floating_point<T>::value, void>::type
+inner_encode(const T& rhs, std::stringstream& stream){
+ stream << rhs;
+}
+
+template <typename T>
+typename std::enable_if<(std::is_same<T, unsigned char>::value ||
+ std::is_same<T, signed char>::value), bool>::type
+ConvertStreamTo(std::stringstream& stream, T& rhs) {
+ int num;
+ if ((stream >> std::noskipws >> num) && (stream >> std::ws).eof()) {
+ if (num >= (std::numeric_limits<T>::min)() &&
+ num <= (std::numeric_limits<T>::max)()) {
+ rhs = (T)num;
+ return true;
+ }
+ }
+ return false;
+}
+
+template <typename T>
+typename std::enable_if<!(std::is_same<T, unsigned char>::value ||
+ std::is_same<T, signed char>::value), bool>::type
+ConvertStreamTo(std::stringstream& stream, T& rhs) {
+ if ((stream >> std::noskipws >> rhs) && (stream >> std::ws).eof()) {
+ return true;
+ }
+ return false;
+}
+}
+
+#define YAML_DEFINE_CONVERT_STREAMABLE(type, negative_op) \
+ template <> \
+ struct convert<type> { \
+ \
+ static Node encode(const type& rhs) { \
+ std::stringstream stream; \
+ stream.precision(std::numeric_limits<type>::max_digits10); \
+ conversion::inner_encode(rhs, stream); \
+ return Node(stream.str()); \
+ } \
+ \
+ static bool decode(const Node& node, type& rhs) { \
+ if (node.Type() != NodeType::Scalar) { \
+ return false; \
+ } \
+ const std::string& input = node.Scalar(); \
+ std::stringstream stream(input); \
+ stream.unsetf(std::ios::dec); \
+ if ((stream.peek() == '-') && std::is_unsigned<type>::value) { \
+ return false; \
+ } \
+ if (conversion::ConvertStreamTo(stream, rhs)) { \
+ return true; \
+ } \
+ if (std::numeric_limits<type>::has_infinity) { \
+ if (conversion::IsInfinity(input)) { \
+ rhs = std::numeric_limits<type>::infinity(); \
+ return true; \
+ } else if (conversion::IsNegativeInfinity(input)) { \
+ rhs = negative_op std::numeric_limits<type>::infinity(); \
+ return true; \
+ } \
+ } \
+ \
+ if (std::numeric_limits<type>::has_quiet_NaN) { \
+ if (conversion::IsNaN(input)) { \
+ rhs = std::numeric_limits<type>::quiet_NaN(); \
+ return true; \
+ } \
+ } \
+ \
+ return false; \
+ } \
}
#define YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(type) \
@@ -163,81 +226,78 @@ struct convert<bool> {
};
// std::map
-template <typename K, typename V>
-struct convert<std::map<K, V>> {
- static Node encode(const std::map<K, V>& rhs) {
+template <typename K, typename V, typename C, typename A>
+struct convert<std::map<K, V, C, A>> {
+ static Node encode(const std::map<K, V, C, A>& rhs) {
Node node(NodeType::Map);
- for (typename std::map<K, V>::const_iterator it = rhs.begin();
- it != rhs.end(); ++it)
- node.force_insert(it->first, it->second);
+ for (const auto& element : rhs)
+ node.force_insert(element.first, element.second);
return node;
}
- static bool decode(const Node& node, std::map<K, V>& rhs) {
+ static bool decode(const Node& node, std::map<K, V, C, A>& rhs) {
if (!node.IsMap())
return false;
rhs.clear();
- for (const_iterator it = node.begin(); it != node.end(); ++it)
+ for (const auto& element : node)
#if defined(__GNUC__) && __GNUC__ < 4
// workaround for GCC 3:
- rhs[it->first.template as<K>()] = it->second.template as<V>();
+ rhs[element.first.template as<K>()] = element.second.template as<V>();
#else
- rhs[it->first.as<K>()] = it->second.as<V>();
+ rhs[element.first.as<K>()] = element.second.as<V>();
#endif
return true;
}
};
// std::vector
-template <typename T>
-struct convert<std::vector<T>> {
- static Node encode(const std::vector<T>& rhs) {
+template <typename T, typename A>
+struct convert<std::vector<T, A>> {
+ static Node encode(const std::vector<T, A>& rhs) {
Node node(NodeType::Sequence);
- for (typename std::vector<T>::const_iterator it = rhs.begin();
- it != rhs.end(); ++it)
- node.push_back(*it);
+ for (const auto& element : rhs)
+ node.push_back(element);
return node;
}
- static bool decode(const Node& node, std::vector<T>& rhs) {
+ static bool decode(const Node& node, std::vector<T, A>& rhs) {
if (!node.IsSequence())
return false;
rhs.clear();
- for (const_iterator it = node.begin(); it != node.end(); ++it)
+ for (const auto& element : node)
#if defined(__GNUC__) && __GNUC__ < 4
// workaround for GCC 3:
- rhs.push_back(it->template as<T>());
+ rhs.push_back(element.template as<T>());
#else
- rhs.push_back(it->as<T>());
+ rhs.push_back(element.as<T>());
#endif
return true;
}
};
// std::list
-template <typename T>
-struct convert<std::list<T>> {
- static Node encode(const std::list<T>& rhs) {
+template <typename T, typename A>
+struct convert<std::list<T,A>> {
+ static Node encode(const std::list<T,A>& rhs) {
Node node(NodeType::Sequence);
- for (typename std::list<T>::const_iterator it = rhs.begin();
- it != rhs.end(); ++it)
- node.push_back(*it);
+ for (const auto& element : rhs)
+ node.push_back(element);
return node;
}
- static bool decode(const Node& node, std::list<T>& rhs) {
+ static bool decode(const Node& node, std::list<T,A>& rhs) {
if (!node.IsSequence())
return false;
rhs.clear();
- for (const_iterator it = node.begin(); it != node.end(); ++it)
+ for (const auto& element : node)
#if defined(__GNUC__) && __GNUC__ < 4
// workaround for GCC 3:
- rhs.push_back(it->template as<T>());
+ rhs.push_back(element.template as<T>());
#else
- rhs.push_back(it->as<T>());
+ rhs.push_back(element.as<T>());
#endif
return true;
}
diff --git a/lib/yamlcpp/include/yaml-cpp/node/detail/bool_type.h b/lib/yamlcpp/include/yaml-cpp/node/detail/bool_type.h
deleted file mode 100644
index 2c80705c9..000000000
--- a/lib/yamlcpp/include/yaml-cpp/node/detail/bool_type.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef NODE_DETAIL_BOOL_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
-#define NODE_DETAIL_BOOL_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
-
-#if defined(_MSC_VER) || \
- (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
- (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
-#pragma once
-#endif
-
-namespace YAML {
-namespace detail {
-struct unspecified_bool {
- struct NOT_ALLOWED;
- static void true_value(NOT_ALLOWED*) {}
-};
-typedef void (*unspecified_bool_type)(unspecified_bool::NOT_ALLOWED*);
-}
-}
-
-#define YAML_CPP_OPERATOR_BOOL() \
- operator YAML::detail::unspecified_bool_type() const { \
- return this->operator!() ? 0 \
- : &YAML::detail::unspecified_bool::true_value; \
- }
-
-#endif // NODE_DETAIL_BOOL_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
diff --git a/lib/yamlcpp/include/yaml-cpp/node/detail/impl.h b/lib/yamlcpp/include/yaml-cpp/node/detail/impl.h
index 4123b85da..b38038dfd 100644
--- a/lib/yamlcpp/include/yaml-cpp/node/detail/impl.h
+++ b/lib/yamlcpp/include/yaml-cpp/node/detail/impl.h
@@ -9,6 +9,8 @@
#include "yaml-cpp/node/detail/node.h"
#include "yaml-cpp/node/detail/node_data.h"
+
+#include <algorithm>
#include <type_traits>
namespace YAML {
@@ -33,7 +35,7 @@ struct get_idx<Key,
static node* get(std::vector<node*>& sequence, const Key& key,
shared_memory_holder pMemory) {
if (key > sequence.size() || (key > 0 && !sequence[key - 1]->is_defined()))
- return 0;
+ return nullptr;
if (key == sequence.size())
sequence.push_back(&pMemory->create_node());
return sequence[key];
@@ -58,7 +60,9 @@ struct get_idx<Key, typename std::enable_if<std::is_signed<Key>::value>::type> {
template <typename Key, typename Enable = void>
struct remove_idx {
- static bool remove(std::vector<node*>&, const Key&) { return false; }
+ static bool remove(std::vector<node*>&, const Key&, std::size_t&) {
+ return false;
+ }
};
template <typename Key>
@@ -66,11 +70,15 @@ struct remove_idx<
Key, typename std::enable_if<std::is_unsigned<Key>::value &&
!std::is_same<Key, bool>::value>::type> {
- static bool remove(std::vector<node*>& sequence, const Key& key) {
+ static bool remove(std::vector<node*>& sequence, const Key& key,
+ std::size_t& seqSize) {
if (key >= sequence.size()) {
return false;
} else {
sequence.erase(sequence.begin() + key);
+ if (seqSize > key) {
+ --seqSize;
+ }
return true;
}
}
@@ -80,9 +88,10 @@ template <typename Key>
struct remove_idx<Key,
typename std::enable_if<std::is_signed<Key>::value>::type> {
- static bool remove(std::vector<node*>& sequence, const Key& key) {
+ static bool remove(std::vector<node*>& sequence, const Key& key,
+ std::size_t& seqSize) {
return key >= 0 ? remove_idx<std::size_t>::remove(
- sequence, static_cast<std::size_t>(key))
+ sequence, static_cast<std::size_t>(key), seqSize)
: false;
}
};
@@ -97,7 +106,11 @@ inline bool node::equals(const T& rhs, shared_memory_holder pMemory) {
}
inline bool node::equals(const char* rhs, shared_memory_holder pMemory) {
- return equals<std::string>(rhs, pMemory);
+ std::string lhs;
+ if (convert<std::string>::decode(Node(*this, std::move(pMemory)), lhs)) {
+ return lhs == rhs;
+ }
+ return false;
}
// indexing
@@ -115,16 +128,14 @@ inline node* node_data::get(const Key& key,
return pNode;
return nullptr;
case NodeType::Scalar:
- throw BadSubscript(key);
+ throw BadSubscript(m_mark, key);
}
- for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) {
- if (it->first->equals(key, pMemory)) {
- return it->second;
- }
- }
+ auto it = std::find_if(m_map.begin(), m_map.end(), [&](const kv_pair m) {
+ return m.first->equals(key, pMemory);
+ });
- return nullptr;
+ return it != m_map.end() ? it->second : nullptr;
}
template <typename Key>
@@ -143,13 +154,15 @@ inline node& node_data::get(const Key& key, shared_memory_holder pMemory) {
convert_to_map(pMemory);
break;
case NodeType::Scalar:
- throw BadSubscript(key);
+ throw BadSubscript(m_mark, key);
}
- for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) {
- if (it->first->equals(key, pMemory)) {
- return *it->second;
- }
+ auto it = std::find_if(m_map.begin(), m_map.end(), [&](const kv_pair m) {
+ return m.first->equals(key, pMemory);
+ });
+
+ if (it != m_map.end()) {
+ return *it->second;
}
node& k = convert_to_node(key, pMemory);
@@ -161,8 +174,10 @@ inline node& node_data::get(const Key& key, shared_memory_holder pMemory) {
template <typename Key>
inline bool node_data::remove(const Key& key, shared_memory_holder pMemory) {
if (m_type == NodeType::Sequence) {
- return remove_idx<Key>::remove(m_sequence, key);
- } else if (m_type == NodeType::Map) {
+ return remove_idx<Key>::remove(m_sequence, key, m_seqSize);
+ }
+
+ if (m_type == NodeType::Map) {
kv_pairs::iterator it = m_undefinedPairs.begin();
while (it != m_undefinedPairs.end()) {
kv_pairs::iterator jt = std::next(it);
@@ -172,11 +187,13 @@ inline bool node_data::remove(const Key& key, shared_memory_holder pMemory) {
it = jt;
}
- for (node_map::iterator iter = m_map.begin(); iter != m_map.end(); ++iter) {
- if (iter->first->equals(key, pMemory)) {
- m_map.erase(iter);
- return true;
- }
+ auto iter = std::find_if(m_map.begin(), m_map.end(), [&](const kv_pair m) {
+ return m.first->equals(key, pMemory);
+ });
+
+ if (iter != m_map.end()) {
+ m_map.erase(iter);
+ return true;
}
}
diff --git a/lib/yamlcpp/include/yaml-cpp/node/detail/iterator.h b/lib/yamlcpp/include/yaml-cpp/node/detail/iterator.h
index 966107d95..997c69a14 100644
--- a/lib/yamlcpp/include/yaml-cpp/node/detail/iterator.h
+++ b/lib/yamlcpp/include/yaml-cpp/node/detail/iterator.h
@@ -26,7 +26,7 @@ class iterator_base {
template <typename>
friend class iterator_base;
struct enabler {};
- typedef node_iterator base_type;
+ using base_type = node_iterator;
struct proxy {
explicit proxy(const V& x) : m_ref(x) {}
diff --git a/lib/yamlcpp/include/yaml-cpp/node/detail/iterator_fwd.h b/lib/yamlcpp/include/yaml-cpp/node/detail/iterator_fwd.h
index 5f1ffe743..75c9de086 100644
--- a/lib/yamlcpp/include/yaml-cpp/node/detail/iterator_fwd.h
+++ b/lib/yamlcpp/include/yaml-cpp/node/detail/iterator_fwd.h
@@ -20,8 +20,8 @@ template <typename V>
class iterator_base;
}
-typedef detail::iterator_base<detail::iterator_value> iterator;
-typedef detail::iterator_base<const detail::iterator_value> const_iterator;
+using iterator = detail::iterator_base<detail::iterator_value>;
+using const_iterator = detail::iterator_base<const detail::iterator_value>;
}
#endif // VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66
diff --git a/lib/yamlcpp/include/yaml-cpp/node/detail/memory.h b/lib/yamlcpp/include/yaml-cpp/node/detail/memory.h
index a4df0f758..e881545bf 100644
--- a/lib/yamlcpp/include/yaml-cpp/node/detail/memory.h
+++ b/lib/yamlcpp/include/yaml-cpp/node/detail/memory.h
@@ -27,7 +27,7 @@ class YAML_CPP_API memory {
void merge(const memory& rhs);
private:
- typedef std::set<shared_node> Nodes;
+ using Nodes = std::set<shared_node>;
Nodes m_nodes;
};
diff --git a/lib/yamlcpp/include/yaml-cpp/node/detail/node.h b/lib/yamlcpp/include/yaml-cpp/node/detail/node.h
index a2cc52b76..b881c2c5e 100644
--- a/lib/yamlcpp/include/yaml-cpp/node/detail/node.h
+++ b/lib/yamlcpp/include/yaml-cpp/node/detail/node.h
@@ -13,12 +13,18 @@
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/type.h"
#include <set>
+#include <atomic>
namespace YAML {
namespace detail {
class node {
+ private:
+ struct less {
+ bool operator ()(const node* l, const node* r) const {return l->m_index < r->m_index;}
+ };
+
public:
- node() : m_pRef(new node_ref), m_dependencies{} {}
+ node() : m_pRef(new node_ref), m_dependencies{}, m_index{} {}
node(const node&) = delete;
node& operator=(const node&) = delete;
@@ -42,9 +48,8 @@ class node {
return;
m_pRef->mark_defined();
- for (nodes::iterator it = m_dependencies.begin();
- it != m_dependencies.end(); ++it)
- (*it)->mark_defined();
+ for (node* dependency : m_dependencies)
+ dependency->mark_defined();
m_dependencies.clear();
}
@@ -109,6 +114,7 @@ class node {
void push_back(node& input, shared_memory_holder pMemory) {
m_pRef->push_back(input, pMemory);
input.add_dependency(*this);
+ m_index = m_amount.fetch_add(1);
}
void insert(node& key, node& value, shared_memory_holder pMemory) {
m_pRef->insert(key, value, pMemory);
@@ -120,7 +126,7 @@ class node {
template <typename Key>
node* get(const Key& key, shared_memory_holder pMemory) const {
// NOTE: this returns a non-const node so that the top-level Node can wrap
- // it, and returns a pointer so that it can be NULL (if there is no such
+ // it, and returns a pointer so that it can be nullptr (if there is no such
// key).
return static_cast<const node_ref&>(*m_pRef).get(key, pMemory);
}
@@ -137,7 +143,7 @@ class node {
node* get(node& key, shared_memory_holder pMemory) const {
// NOTE: this returns a non-const node so that the top-level Node can wrap
- // it, and returns a pointer so that it can be NULL (if there is no such
+ // it, and returns a pointer so that it can be nullptr (if there is no such
// key).
return static_cast<const node_ref&>(*m_pRef).get(key, pMemory);
}
@@ -160,8 +166,10 @@ class node {
private:
shared_node_ref m_pRef;
- typedef std::set<node*> nodes;
+ using nodes = std::set<node*, less>;
nodes m_dependencies;
+ size_t m_index;
+ static std::atomic<size_t> m_amount;
};
} // namespace detail
} // namespace YAML
diff --git a/lib/yamlcpp/include/yaml-cpp/node/detail/node_data.h b/lib/yamlcpp/include/yaml-cpp/node/detail/node_data.h
index 82fb79ade..07cf81aa0 100644
--- a/lib/yamlcpp/include/yaml-cpp/node/detail/node_data.h
+++ b/lib/yamlcpp/include/yaml-cpp/node/detail/node_data.h
@@ -60,8 +60,8 @@ class YAML_CPP_API node_data {
node_iterator end();
// sequence
- void push_back(node& node, shared_memory_holder pMemory);
- void insert(node& key, node& value, shared_memory_holder pMemory);
+ void push_back(node& node, const shared_memory_holder& pMemory);
+ void insert(node& key, node& value, const shared_memory_holder& pMemory);
// indexing
template <typename Key>
@@ -71,9 +71,9 @@ class YAML_CPP_API node_data {
template <typename Key>
bool remove(const Key& key, shared_memory_holder pMemory);
- node* get(node& key, shared_memory_holder pMemory) const;
- node& get(node& key, shared_memory_holder pMemory);
- bool remove(node& key, shared_memory_holder pMemory);
+ node* get(node& key, const shared_memory_holder& pMemory) const;
+ node& get(node& key, const shared_memory_holder& pMemory);
+ bool remove(node& key, const shared_memory_holder& pMemory);
// map
template <typename Key, typename Value>
@@ -91,8 +91,8 @@ class YAML_CPP_API node_data {
void reset_map();
void insert_map_pair(node& key, node& value);
- void convert_to_map(shared_memory_holder pMemory);
- void convert_sequence_to_map(shared_memory_holder pMemory);
+ void convert_to_map(const shared_memory_holder& pMemory);
+ void convert_sequence_to_map(const shared_memory_holder& pMemory);
template <typename T>
static node& convert_to_node(const T& rhs, shared_memory_holder pMemory);
@@ -108,17 +108,17 @@ class YAML_CPP_API node_data {
std::string m_scalar;
// sequence
- typedef std::vector<node*> node_seq;
+ using node_seq = std::vector<node *>;
node_seq m_sequence;
mutable std::size_t m_seqSize;
// map
- typedef std::vector<std::pair<node*, node*>> node_map;
+ using node_map = std::vector<std::pair<node*, node*>>;
node_map m_map;
- typedef std::pair<node*, node*> kv_pair;
- typedef std::list<kv_pair> kv_pairs;
+ using kv_pair = std::pair<node*, node*>;
+ using kv_pairs = std::list<kv_pair>;
mutable kv_pairs m_undefinedPairs;
};
}
diff --git a/lib/yamlcpp/include/yaml-cpp/node/detail/node_iterator.h b/lib/yamlcpp/include/yaml-cpp/node/detail/node_iterator.h
index ab6916fea..49dcf958d 100644
--- a/lib/yamlcpp/include/yaml-cpp/node/detail/node_iterator.h
+++ b/lib/yamlcpp/include/yaml-cpp/node/detail/node_iterator.h
@@ -24,7 +24,7 @@ struct iterator_type {
template <typename V>
struct node_iterator_value : public std::pair<V*, V*> {
- typedef std::pair<V*, V*> kv;
+ using kv = std::pair<V*, V*>;
node_iterator_value() : kv(), pNode(nullptr) {}
explicit node_iterator_value(V& rhs) : kv(), pNode(&rhs) {}
@@ -36,26 +36,23 @@ struct node_iterator_value : public std::pair<V*, V*> {
V* pNode;
};
-typedef std::vector<node*> node_seq;
-typedef std::vector<std::pair<node*, node*>> node_map;
+using node_seq = std::vector<node *>;
+using node_map = std::vector<std::pair<node*, node*>>;
template <typename V>
struct node_iterator_type {
- typedef node_seq::iterator seq;
- typedef node_map::iterator map;
+ using seq = node_seq::iterator;
+ using map = node_map::iterator;
};
template <typename V>
struct node_iterator_type<const V> {
- typedef node_seq::const_iterator seq;
- typedef node_map::const_iterator map;
+ using seq = node_seq::const_iterator;
+ using map = node_map::const_iterator;
};
template <typename V>
-class node_iterator_base
- : public std::iterator<std::forward_iterator_tag, node_iterator_value<V>,
- std::ptrdiff_t, node_iterator_value<V>*,
- node_iterator_value<V>> {
+class node_iterator_base {
private:
struct enabler {};
@@ -68,9 +65,13 @@ class node_iterator_base
};
public:
- typedef typename node_iterator_type<V>::seq SeqIter;
- typedef typename node_iterator_type<V>::map MapIter;
- typedef node_iterator_value<V> value_type;
+ using iterator_category = std::forward_iterator_tag;
+ using value_type = node_iterator_value<V>;
+ using difference_type = std::ptrdiff_t;
+ using pointer = node_iterator_value<V>*;
+ using reference = node_iterator_value<V>;
+ using SeqIter = typename node_iterator_type<V>::seq;
+ using MapIter = typename node_iterator_type<V>::map;
node_iterator_base()
: m_type(iterator_type::NoneType), m_seqIt(), m_mapIt(), m_mapEnd() {}
@@ -172,8 +173,8 @@ class node_iterator_base
MapIter m_mapIt, m_mapEnd;
};
-typedef node_iterator_base<node> node_iterator;
-typedef node_iterator_base<const node> const_node_iterator;
+using node_iterator = node_iterator_base<node>;
+using const_node_iterator = node_iterator_base<const node>;
}
}
diff --git a/lib/yamlcpp/include/yaml-cpp/node/impl.h b/lib/yamlcpp/include/yaml-cpp/node/impl.h
index 7a3deacf9..97dc282d9 100644
--- a/lib/yamlcpp/include/yaml-cpp/node/impl.h
+++ b/lib/yamlcpp/include/yaml-cpp/node/impl.h
@@ -42,11 +42,7 @@ inline Node::Node(const detail::iterator_value& rhs)
m_pMemory(rhs.m_pMemory),
m_pNode(rhs.m_pNode) {}
-inline Node::Node(const Node& rhs)
- : m_isValid(rhs.m_isValid),
- m_invalidKey(rhs.m_invalidKey),
- m_pMemory(rhs.m_pMemory),
- m_pNode(rhs.m_pNode) {}
+inline Node::Node(const Node& rhs) = default;
inline Node::Node(Zombie)
: m_isValid(false), m_invalidKey{}, m_pMemory{}, m_pNode(nullptr) {}
@@ -57,7 +53,7 @@ inline Node::Node(Zombie, const std::string& key)
inline Node::Node(detail::node& node, detail::shared_memory_holder pMemory)
: m_isValid(true), m_invalidKey{}, m_pMemory(pMemory), m_pNode(&node) {}
-inline Node::~Node() {}
+inline Node::~Node() = default;
inline void Node::EnsureNodeExists() const {
if (!m_isValid)
@@ -114,6 +110,8 @@ struct as_if<std::string, S> {
const Node& node;
std::string operator()(const S& fallback) const {
+ if (node.Type() == NodeType::Null)
+ return "null";
if (node.Type() != NodeType::Scalar)
return fallback;
return node.Scalar();
@@ -142,6 +140,8 @@ struct as_if<std::string, void> {
const Node& node;
std::string operator()() const {
+ if (node.Type() == NodeType::Null)
+ return "null";
if (node.Type() != NodeType::Scalar)
throw TypedBadConversion<std::string>(node.Mark());
return node.Scalar();
@@ -176,8 +176,6 @@ inline const std::string& Node::Tag() const {
}
inline void Node::SetTag(const std::string& tag) {
- if (!m_isValid)
- throw InvalidNode(m_invalidKey);
EnsureNodeExists();
m_pNode->set_tag(tag);
}
@@ -189,8 +187,6 @@ inline EmitterStyle::value Node::Style() const {
}
inline void Node::SetStyle(EmitterStyle::value style) {
- if (!m_isValid)
- throw InvalidNode(m_invalidKey);
EnsureNodeExists();
m_pNode->set_style(style);
}
@@ -206,15 +202,11 @@ inline bool Node::is(const Node& rhs) const {
template <typename T>
inline Node& Node::operator=(const T& rhs) {
- if (!m_isValid)
- throw InvalidNode(m_invalidKey);
Assign(rhs);
return *this;
}
inline Node& Node::operator=(const Node& rhs) {
- if (!m_isValid || !rhs.m_isValid)
- throw InvalidNode(m_invalidKey);
if (is(rhs))
return *this;
AssignNode(rhs);
@@ -237,29 +229,21 @@ inline void Node::Assign(const T& rhs) {
template <>
inline void Node::Assign(const std::string& rhs) {
- if (!m_isValid)
- throw InvalidNode(m_invalidKey);
EnsureNodeExists();
m_pNode->set_scalar(rhs);
}
inline void Node::Assign(const char* rhs) {
- if (!m_isValid)
- throw InvalidNode(m_invalidKey);
EnsureNodeExists();
m_pNode->set_scalar(rhs);
}
inline void Node::Assign(char* rhs) {
- if (!m_isValid)
- throw InvalidNode(m_invalidKey);
EnsureNodeExists();
m_pNode->set_scalar(rhs);
}
inline void Node::AssignData(const Node& rhs) {
- if (!m_isValid || !rhs.m_isValid)
- throw InvalidNode(m_invalidKey);
EnsureNodeExists();
rhs.EnsureNodeExists();
@@ -268,7 +252,7 @@ inline void Node::AssignData(const Node& rhs) {
}
inline void Node::AssignNode(const Node& rhs) {
- if (!m_isValid || !rhs.m_isValid)
+ if (!m_isValid)
throw InvalidNode(m_invalidKey);
rhs.EnsureNodeExists();
@@ -324,8 +308,6 @@ inline void Node::push_back(const T& rhs) {
}
inline void Node::push_back(const Node& rhs) {
- if (!m_isValid || !rhs.m_isValid)
- throw InvalidNode(m_invalidKey);
EnsureNodeExists();
rhs.EnsureNodeExists();
@@ -333,51 +315,6 @@ inline void Node::push_back(const Node& rhs) {
m_pMemory->merge(*rhs.m_pMemory);
}
-// helpers for indexing
-namespace detail {
-template <typename T>
-struct to_value_t {
- explicit to_value_t(const T& t_) : t(t_) {}
- const T& t;
- typedef const T& return_type;
-
- const T& operator()() const { return t; }
-};
-
-template <>
-struct to_value_t<const char*> {
- explicit to_value_t(const char* t_) : t(t_) {}
- const char* t;
- typedef std::string return_type;
-
- const std::string operator()() const { return t; }
-};
-
-template <>
-struct to_value_t<char*> {
- explicit to_value_t(char* t_) : t(t_) {}
- const char* t;
- typedef std::string return_type;
-
- const std::string operator()() const { return t; }
-};
-
-template <std::size_t N>
-struct to_value_t<char[N]> {
- explicit to_value_t(const char* t_) : t(t_) {}
- const char* t;
- typedef std::string return_type;
-
- const std::string operator()() const { return t; }
-};
-
-// converts C-strings to std::strings so they can be copied
-template <typename T>
-inline typename to_value_t<T>::return_type to_value(const T& t) {
- return to_value_t<T>(t)();
-}
-} // namespace detail
-
template<typename Key>
std::string key_to_string(const Key& key) {
return streamable_to_string<Key, is_streamable<std::stringstream, Key>::value>().impl(key);
@@ -386,11 +323,9 @@ std::string key_to_string(const Key& key) {
// indexing
template <typename Key>
inline const Node Node::operator[](const Key& key) const {
- if (!m_isValid)
- throw InvalidNode(m_invalidKey);
EnsureNodeExists();
- detail::node* value = static_cast<const detail::node&>(*m_pNode).get(
- detail::to_value(key), m_pMemory);
+ detail::node* value =
+ static_cast<const detail::node&>(*m_pNode).get(key, m_pMemory);
if (!value) {
return Node(ZombieNode, key_to_string(key));
}
@@ -399,24 +334,18 @@ inline const Node Node::operator[](const Key& key) const {
template <typename Key>
inline Node Node::operator[](const Key& key) {
- if (!m_isValid)
- throw InvalidNode(m_invalidKey);
EnsureNodeExists();
- detail::node& value = m_pNode->get(detail::to_value(key), m_pMemory);
+ detail::node& value = m_pNode->get(key, m_pMemory);
return Node(value, m_pMemory);
}
template <typename Key>
inline bool Node::remove(const Key& key) {
- if (!m_isValid)
- throw InvalidNode(m_invalidKey);
EnsureNodeExists();
- return m_pNode->remove(detail::to_value(key), m_pMemory);
+ return m_pNode->remove(key, m_pMemory);
}
inline const Node Node::operator[](const Node& key) const {
- if (!m_isValid || !key.m_isValid)
- throw InvalidNode(m_invalidKey);
EnsureNodeExists();
key.EnsureNodeExists();
m_pMemory->merge(*key.m_pMemory);
@@ -429,8 +358,6 @@ inline const Node Node::operator[](const Node& key) const {
}
inline Node Node::operator[](const Node& key) {
- if (!m_isValid || !key.m_isValid)
- throw InvalidNode(m_invalidKey);
EnsureNodeExists();
key.EnsureNodeExists();
m_pMemory->merge(*key.m_pMemory);
@@ -439,8 +366,6 @@ inline Node Node::operator[](const Node& key) {
}
inline bool Node::remove(const Node& key) {
- if (!m_isValid || !key.m_isValid)
- throw InvalidNode(m_invalidKey);
EnsureNodeExists();
key.EnsureNodeExists();
return m_pNode->remove(*key.m_pNode, m_pMemory);
@@ -449,11 +374,8 @@ inline bool Node::remove(const Node& key) {
// map
template <typename Key, typename Value>
inline void Node::force_insert(const Key& key, const Value& value) {
- if (!m_isValid)
- throw InvalidNode(m_invalidKey);
EnsureNodeExists();
- m_pNode->force_insert(detail::to_value(key), detail::to_value(value),
- m_pMemory);
+ m_pNode->force_insert(key, value, m_pMemory);
}
// free functions
diff --git a/lib/yamlcpp/include/yaml-cpp/node/iterator.h b/lib/yamlcpp/include/yaml-cpp/node/iterator.h
index 366a9c807..b44723817 100644
--- a/lib/yamlcpp/include/yaml-cpp/node/iterator.h
+++ b/lib/yamlcpp/include/yaml-cpp/node/iterator.h
@@ -18,7 +18,7 @@
namespace YAML {
namespace detail {
struct iterator_value : public Node, std::pair<Node, Node> {
- iterator_value() {}
+ iterator_value() = default;
explicit iterator_value(const Node& rhs)
: Node(rhs),
std::pair<Node, Node>(Node(Node::ZombieNode), Node(Node::ZombieNode)) {}
diff --git a/lib/yamlcpp/include/yaml-cpp/node/node.h b/lib/yamlcpp/include/yaml-cpp/node/node.h
index 49af58e5c..c9e9a0a4b 100644
--- a/lib/yamlcpp/include/yaml-cpp/node/node.h
+++ b/lib/yamlcpp/include/yaml-cpp/node/node.h
@@ -13,7 +13,6 @@
#include "yaml-cpp/dll.h"
#include "yaml-cpp/emitterstyle.h"
#include "yaml-cpp/mark.h"
-#include "yaml-cpp/node/detail/bool_type.h"
#include "yaml-cpp/node/detail/iterator_fwd.h"
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/type.h"
@@ -39,8 +38,8 @@ class YAML_CPP_API Node {
template <typename T, typename S>
friend struct as_if;
- typedef YAML::iterator iterator;
- typedef YAML::const_iterator const_iterator;
+ using iterator = YAML::iterator;
+ using const_iterator = YAML::const_iterator;
Node();
explicit Node(NodeType::value type);
@@ -59,7 +58,7 @@ class YAML_CPP_API Node {
bool IsMap() const { return Type() == NodeType::Map; }
// bool conversions
- YAML_CPP_OPERATOR_BOOL()
+ explicit operator bool() const { return IsDefined(); }
bool operator!() const { return !IsDefined(); }
// access
diff --git a/lib/yamlcpp/include/yaml-cpp/node/ptr.h b/lib/yamlcpp/include/yaml-cpp/node/ptr.h
index ce085dd5c..062d77ea0 100644
--- a/lib/yamlcpp/include/yaml-cpp/node/ptr.h
+++ b/lib/yamlcpp/include/yaml-cpp/node/ptr.h
@@ -18,11 +18,11 @@ class node_data;
class memory;
class memory_holder;
-typedef std::shared_ptr<node> shared_node;
-typedef std::shared_ptr<node_ref> shared_node_ref;
-typedef std::shared_ptr<node_data> shared_node_data;
-typedef std::shared_ptr<memory_holder> shared_memory_holder;
-typedef std::shared_ptr<memory> shared_memory;
+using shared_node = std::shared_ptr<node>;
+using shared_node_ref = std::shared_ptr<node_ref>;
+using shared_node_data = std::shared_ptr<node_data>;
+using shared_memory_holder = std::shared_ptr<memory_holder>;
+using shared_memory = std::shared_ptr<memory>;
}
}
diff --git a/lib/yamlcpp/include/yaml-cpp/noexcept.h b/lib/yamlcpp/include/yaml-cpp/noexcept.h
new file mode 100644
index 000000000..6aac63516
--- /dev/null
+++ b/lib/yamlcpp/include/yaml-cpp/noexcept.h
@@ -0,0 +1,18 @@
+#ifndef NOEXCEPT_H_768872DA_476C_11EA_88B8_90B11C0C0FF8
+#define NOEXCEPT_H_768872DA_476C_11EA_88B8_90B11C0C0FF8
+
+#if defined(_MSC_VER) || \
+ (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
+ (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
+#pragma once
+#endif
+
+// This is here for compatibility with older versions of Visual Studio
+// which don't support noexcept.
+#if defined(_MSC_VER) && _MSC_VER < 1900
+ #define YAML_CPP_NOEXCEPT _NOEXCEPT
+#else
+ #define YAML_CPP_NOEXCEPT noexcept
+#endif
+
+#endif
diff --git a/lib/yamlcpp/include/yaml-cpp/stlemitter.h b/lib/yamlcpp/include/yaml-cpp/stlemitter.h
index 06780c861..210a2f64e 100644
--- a/lib/yamlcpp/include/yaml-cpp/stlemitter.h
+++ b/lib/yamlcpp/include/yaml-cpp/stlemitter.h
@@ -16,8 +16,8 @@ namespace YAML {
template <typename Seq>
inline Emitter& EmitSeq(Emitter& emitter, const Seq& seq) {
emitter << BeginSeq;
- for (typename Seq::const_iterator it = seq.begin(); it != seq.end(); ++it)
- emitter << *it;
+ for (const auto& v : seq)
+ emitter << v;
emitter << EndSeq;
return emitter;
}
@@ -39,10 +39,9 @@ inline Emitter& operator<<(Emitter& emitter, const std::set<T>& v) {
template <typename K, typename V>
inline Emitter& operator<<(Emitter& emitter, const std::map<K, V>& m) {
- typedef typename std::map<K, V> map;
emitter << BeginMap;
- for (typename map::const_iterator it = m.begin(); it != m.end(); ++it)
- emitter << Key << it->first << Value << it->second;
+ for (const auto& v : m)
+ emitter << Key << v.first << Value << v.second;
emitter << EndMap;
return emitter;
}
diff --git a/lib/yamlcpp/include/yaml-cpp/traits.h b/lib/yamlcpp/include/yaml-cpp/traits.h
index 36d406ba4..9a62db257 100644
--- a/lib/yamlcpp/include/yaml-cpp/traits.h
+++ b/lib/yamlcpp/include/yaml-cpp/traits.h
@@ -84,7 +84,7 @@ struct is_numeric<long double> {
template <bool, class T = void>
struct enable_if_c {
- typedef T type;
+ using type = T;
};
template <class T>
@@ -95,7 +95,7 @@ struct enable_if : public enable_if_c<Cond::value, T> {};
template <bool, class T = void>
struct disable_if_c {
- typedef T type;
+ using type = T;
};
template <class T>
diff --git a/lib/yamlcpp/src/binary.cpp b/lib/yamlcpp/src/binary.cpp
index 4db6d0b97..4311a2d06 100644
--- a/lib/yamlcpp/src/binary.cpp
+++ b/lib/yamlcpp/src/binary.cpp
@@ -66,7 +66,7 @@ static const unsigned char decoding[] = {
};
std::vector<unsigned char> DecodeBase64(const std::string &input) {
- typedef std::vector<unsigned char> ret_type;
+ using ret_type = std::vector<unsigned char>;
if (input.empty())
return ret_type();
@@ -97,4 +97,4 @@ std::vector<unsigned char> DecodeBase64(const std::string &input) {
ret.resize(out - &ret[0]);
return ret;
}
-}
+} // namespace YAML
diff --git a/lib/yamlcpp/src/contrib/graphbuilder.cpp b/lib/yamlcpp/src/contrib/graphbuilder.cpp
index bf2516279..0352054cd 100644
--- a/lib/yamlcpp/src/contrib/graphbuilder.cpp
+++ b/lib/yamlcpp/src/contrib/graphbuilder.cpp
@@ -10,8 +10,7 @@ void* BuildGraphOfNextDocument(Parser& parser,
GraphBuilderAdapter eventHandler(graphBuilder);
if (parser.HandleNextDocument(eventHandler)) {
return eventHandler.RootNode();
- } else {
- return nullptr;
}
+ return nullptr;
}
-}
+} // namespace YAML
diff --git a/lib/yamlcpp/src/contrib/graphbuilderadapter.cpp b/lib/yamlcpp/src/contrib/graphbuilderadapter.cpp
index b9e0b6571..c386a9277 100644
--- a/lib/yamlcpp/src/contrib/graphbuilderadapter.cpp
+++ b/lib/yamlcpp/src/contrib/graphbuilderadapter.cpp
@@ -91,4 +91,4 @@ void GraphBuilderAdapter::DispositionNode(void *pNode) {
m_builder.AppendToSequence(pContainer, pNode);
}
}
-}
+} // namespace YAML
diff --git a/lib/yamlcpp/src/convert.cpp b/lib/yamlcpp/src/convert.cpp
index ec05b7782..9658b3603 100644
--- a/lib/yamlcpp/src/convert.cpp
+++ b/lib/yamlcpp/src/convert.cpp
@@ -16,11 +16,7 @@ std::string tolower(const std::string& str) {
template <typename T>
bool IsEntirely(const std::string& str, T func) {
- for (std::size_t i = 0; i < str.size(); i++)
- if (!func(str[i]))
- return false;
-
- return true;
+ return std::all_of(str.begin(), str.end(), [=](char ch) { return func(ch); });
}
// IsFlexibleCase
@@ -39,7 +35,7 @@ bool IsFlexibleCase(const std::string& str) {
std::string rest = str.substr(1);
return firstcaps && (IsEntirely(rest, IsLower) || IsEntirely(rest, IsUpper));
}
-}
+} // namespace
namespace YAML {
bool convert<bool>::decode(const Node& node, bool& rhs) {
@@ -52,19 +48,22 @@ bool convert<bool>::decode(const Node& node, bool& rhs) {
static const struct {
std::string truename, falsename;
} names[] = {
- {"y", "n"}, {"yes", "no"}, {"true", "false"}, {"on", "off"},
+ {"y", "n"},
+ {"yes", "no"},
+ {"true", "false"},
+ {"on", "off"},
};
if (!IsFlexibleCase(node.Scalar()))
return false;
- for (unsigned i = 0; i < sizeof(names) / sizeof(names[0]); i++) {
- if (names[i].truename == tolower(node.Scalar())) {
+ for (const auto& name : names) {
+ if (name.truename == tolower(node.Scalar())) {
rhs = true;
return true;
}
- if (names[i].falsename == tolower(node.Scalar())) {
+ if (name.falsename == tolower(node.Scalar())) {
rhs = false;
return true;
}
@@ -72,4 +71,4 @@ bool convert<bool>::decode(const Node& node, bool& rhs) {
return false;
}
-}
+} // namespace YAML
diff --git a/lib/yamlcpp/src/depthguard.cpp b/lib/yamlcpp/src/depthguard.cpp
new file mode 100644
index 000000000..5bf6cdf03
--- /dev/null
+++ b/lib/yamlcpp/src/depthguard.cpp
@@ -0,0 +1,9 @@
+#include "yaml-cpp/depthguard.h"
+
+namespace YAML {
+
+DeepRecursion::DeepRecursion(int depth, const Mark& mark_,
+ const std::string& msg_)
+ : ParserException(mark_, msg_), m_depth(depth) {}
+
+} // namespace YAML
diff --git a/lib/yamlcpp/src/directives.cpp b/lib/yamlcpp/src/directives.cpp
index 0c85d0ff3..f6e9587c6 100644
--- a/lib/yamlcpp/src/directives.cpp
+++ b/lib/yamlcpp/src/directives.cpp
@@ -5,7 +5,7 @@ Directives::Directives() : version{true, 1, 2}, tags{} {}
const std::string Directives::TranslateTagHandle(
const std::string& handle) const {
- std::map<std::string, std::string>::const_iterator it = tags.find(handle);
+ auto it = tags.find(handle);
if (it == tags.end()) {
if (handle == "!!")
return "tag:yaml.org,2002:";
diff --git a/lib/yamlcpp/src/emit.cpp b/lib/yamlcpp/src/emit.cpp
index 51bc79153..b0efb8401 100644
--- a/lib/yamlcpp/src/emit.cpp
+++ b/lib/yamlcpp/src/emit.cpp
@@ -1,7 +1,7 @@
#include "yaml-cpp/node/emit.h"
+#include "nodeevents.h"
#include "yaml-cpp/emitfromevents.h"
#include "yaml-cpp/emitter.h"
-#include "nodeevents.h"
namespace YAML {
Emitter& operator<<(Emitter& out, const Node& node) {
diff --git a/lib/yamlcpp/src/emitfromevents.cpp b/lib/yamlcpp/src/emitfromevents.cpp
index 5a51bb471..2e97187b9 100644
--- a/lib/yamlcpp/src/emitfromevents.cpp
+++ b/lib/yamlcpp/src/emitfromevents.cpp
@@ -59,6 +59,8 @@ void EmitFromEvents::OnSequenceStart(const Mark&, const std::string& tag,
default:
break;
}
+ // Restore the global settings to eliminate the override from node style
+ m_emitter.RestoreGlobalModifiedSettings();
m_emitter << BeginSeq;
m_stateStack.push(State::WaitingForSequenceEntry);
}
@@ -83,6 +85,8 @@ void EmitFromEvents::OnMapStart(const Mark&, const std::string& tag,
default:
break;
}
+ // Restore the global settings to eliminate the override from node style
+ m_emitter.RestoreGlobalModifiedSettings();
m_emitter << BeginMap;
m_stateStack.push(State::WaitingForKey);
}
diff --git a/lib/yamlcpp/src/emitter.cpp b/lib/yamlcpp/src/emitter.cpp
index 016beb12c..644b3129b 100644
--- a/lib/yamlcpp/src/emitter.cpp
+++ b/lib/yamlcpp/src/emitter.cpp
@@ -16,7 +16,7 @@ Emitter::Emitter() : m_pState(new EmitterState), m_stream{} {}
Emitter::Emitter(std::ostream& stream)
: m_pState(new EmitterState), m_stream(stream) {}
-Emitter::~Emitter() {}
+Emitter::~Emitter() = default;
const char* Emitter::c_str() const { return m_stream.str(); }
@@ -49,6 +49,10 @@ bool Emitter::SetBoolFormat(EMITTER_MANIP value) {
return ok;
}
+bool Emitter::SetNullFormat(EMITTER_MANIP value) {
+ return m_pState->SetNullFormat(value, FmtScope::Global);
+}
+
bool Emitter::SetIntBase(EMITTER_MANIP value) {
return m_pState->SetIntFormat(value, FmtScope::Global);
}
@@ -86,6 +90,10 @@ bool Emitter::SetDoublePrecision(std::size_t n) {
return m_pState->SetDoublePrecision(n, FmtScope::Global);
}
+void Emitter::RestoreGlobalModifiedSettings() {
+ m_pState->RestoreGlobalModifiedSettings();
+}
+
// SetLocalValue
// . Either start/end a group, or set a modifier locally
Emitter& Emitter::SetLocalValue(EMITTER_MANIP value) {
@@ -197,6 +205,7 @@ void Emitter::EmitBeginSeq() {
void Emitter::EmitEndSeq() {
if (!good())
return;
+ FlowType::value originalType = m_pState->CurGroupFlowType();
if (m_pState->CurGroupChildCount() == 0)
m_pState->ForceFlow();
@@ -205,8 +214,12 @@ void Emitter::EmitEndSeq() {
if (m_stream.comment())
m_stream << "\n";
m_stream << IndentTo(m_pState->CurIndent());
- if (m_pState->CurGroupChildCount() == 0)
+ if (originalType == FlowType::Block) {
m_stream << "[";
+ } else {
+ if (m_pState->CurGroupChildCount() == 0 && !m_pState->HasBegunNode())
+ m_stream << "[";
+ }
m_stream << "]";
}
@@ -227,6 +240,7 @@ void Emitter::EmitBeginMap() {
void Emitter::EmitEndMap() {
if (!good())
return;
+ FlowType::value originalType = m_pState->CurGroupFlowType();
if (m_pState->CurGroupChildCount() == 0)
m_pState->ForceFlow();
@@ -235,8 +249,12 @@ void Emitter::EmitEndMap() {
if (m_stream.comment())
m_stream << "\n";
m_stream << IndentTo(m_pState->CurIndent());
- if (m_pState->CurGroupChildCount() == 0)
+ if (originalType == FlowType::Block) {
m_stream << "{";
+ } else {
+ if (m_pState->CurGroupChildCount() == 0 && !m_pState->HasBegunNode())
+ m_stream << "{";
+ }
m_stream << "}";
}
@@ -486,6 +504,9 @@ void Emitter::FlowMapPrepareSimpleKeyValue(EmitterNodeType::value child) {
if (m_stream.comment())
m_stream << "\n";
m_stream << IndentTo(lastIndent);
+ if (m_pState->HasAlias()) {
+ m_stream << " ";
+ }
m_stream << ":";
}
@@ -556,6 +577,8 @@ void Emitter::BlockMapPrepareLongKey(EmitterNodeType::value child) {
break;
case EmitterNodeType::BlockSeq:
case EmitterNodeType::BlockMap:
+ if (m_pState->HasBegunContent())
+ m_stream << "\n";
break;
}
}
@@ -579,8 +602,12 @@ void Emitter::BlockMapPrepareLongKeyValue(EmitterNodeType::value child) {
case EmitterNodeType::Scalar:
case EmitterNodeType::FlowSeq:
case EmitterNodeType::FlowMap:
+ SpaceOrIndentTo(true, curIndent + 1);
+ break;
case EmitterNodeType::BlockSeq:
case EmitterNodeType::BlockMap:
+ if (m_pState->HasBegunContent())
+ m_stream << "\n";
SpaceOrIndentTo(true, curIndent + 1);
break;
}
@@ -619,6 +646,9 @@ void Emitter::BlockMapPrepareSimpleKeyValue(EmitterNodeType::value child) {
const std::size_t nextIndent = curIndent + m_pState->CurGroupIndent();
if (!m_pState->HasBegunNode()) {
+ if (m_pState->HasAlias()) {
+ m_stream << " ";
+ }
m_stream << ":";
}
@@ -672,16 +702,29 @@ void Emitter::StartedScalar() { m_pState->StartedScalar(); }
// *******************************************************************************************
// overloads of Write
+StringEscaping::value GetStringEscapingStyle(const EMITTER_MANIP emitterManip) {
+ switch (emitterManip) {
+ case EscapeNonAscii:
+ return StringEscaping::NonAscii;
+ case EscapeAsJson:
+ return StringEscaping::JSON;
+ default:
+ return StringEscaping::None;
+ break;
+ }
+}
+
Emitter& Emitter::Write(const std::string& str) {
if (!good())
return *this;
- const bool escapeNonAscii = m_pState->GetOutputCharset() == EscapeNonAscii;
+ StringEscaping::value stringEscaping = GetStringEscapingStyle(m_pState->GetOutputCharset());
+
const StringFormat::value strFormat =
Utils::ComputeStringFormat(str, m_pState->GetStringFormat(),
- m_pState->CurGroupFlowType(), escapeNonAscii);
+ m_pState->CurGroupFlowType(), stringEscaping == StringEscaping::NonAscii);
- if (strFormat == StringFormat::Literal)
+ if (strFormat == StringFormat::Literal || str.size() > 1024)
m_pState->SetMapKeyFormat(YAML::LongKey, FmtScope::Local);
PrepareNode(EmitterNodeType::Scalar);
@@ -694,7 +737,7 @@ Emitter& Emitter::Write(const std::string& str) {
Utils::WriteSingleQuotedString(m_stream, str);
break;
case StringFormat::DoubleQuoted:
- Utils::WriteDoubleQuotedString(m_stream, str, escapeNonAscii);
+ Utils::WriteDoubleQuotedString(m_stream, str, stringEscaping);
break;
case StringFormat::Literal:
Utils::WriteLiteralString(m_stream, str,
@@ -764,6 +807,21 @@ const char* Emitter::ComputeFullBoolName(bool b) const {
// these answers
}
+const char* Emitter::ComputeNullName() const {
+ switch (m_pState->GetNullFormat()) {
+ case LowerNull:
+ return "null";
+ case UpperNull:
+ return "NULL";
+ case CamelNull:
+ return "Null";
+ case TildeNull:
+ // fallthrough
+ default:
+ return "~";
+ }
+}
+
Emitter& Emitter::Write(bool b) {
if (!good())
return *this;
@@ -785,8 +843,10 @@ Emitter& Emitter::Write(char ch) {
if (!good())
return *this;
+
+
PrepareNode(EmitterNodeType::Scalar);
- Utils::WriteChar(m_stream, ch);
+ Utils::WriteChar(m_stream, ch, GetStringEscapingStyle(m_pState->GetOutputCharset()));
StartedScalar();
return *this;
@@ -810,6 +870,8 @@ Emitter& Emitter::Write(const _Alias& alias) {
StartedScalar();
+ m_pState->SetAlias();
+
return *this;
}
@@ -887,7 +949,7 @@ Emitter& Emitter::Write(const _Null& /*null*/) {
PrepareNode(EmitterNodeType::Scalar);
- m_stream << "~";
+ m_stream << ComputeNullName();
StartedScalar();
diff --git a/lib/yamlcpp/src/emitterstate.cpp b/lib/yamlcpp/src/emitterstate.cpp
index 890b4f0d2..3dbe40110 100644
--- a/lib/yamlcpp/src/emitterstate.cpp
+++ b/lib/yamlcpp/src/emitterstate.cpp
@@ -13,6 +13,7 @@ EmitterState::EmitterState()
m_boolFmt(TrueFalseBool),
m_boolLengthFmt(LongBool),
m_boolCaseFmt(LowerCase),
+ m_nullFmt(TildeNull),
m_intFmt(Dec),
m_indent(2),
m_preCommentIndent(2),
@@ -28,11 +29,12 @@ EmitterState::EmitterState()
m_groups{},
m_curIndent(0),
m_hasAnchor(false),
+ m_hasAlias(false),
m_hasTag(false),
m_hasNonContent(false),
m_docCount(0) {}
-EmitterState::~EmitterState() {}
+EmitterState::~EmitterState() = default;
// SetLocalValue
// . We blindly tries to set all possible formatters to this value
@@ -43,6 +45,7 @@ void EmitterState::SetLocalValue(EMITTER_MANIP value) {
SetBoolFormat(value, FmtScope::Local);
SetBoolCaseFormat(value, FmtScope::Local);
SetBoolLengthFormat(value, FmtScope::Local);
+ SetNullFormat(value, FmtScope::Local);
SetIntFormat(value, FmtScope::Local);
SetFlowType(GroupType::Seq, value, FmtScope::Local);
SetFlowType(GroupType::Map, value, FmtScope::Local);
@@ -51,6 +54,8 @@ void EmitterState::SetLocalValue(EMITTER_MANIP value) {
void EmitterState::SetAnchor() { m_hasAnchor = true; }
+void EmitterState::SetAlias() { m_hasAlias = true; }
+
void EmitterState::SetTag() { m_hasTag = true; }
void EmitterState::SetNonContent() { m_hasNonContent = true; }
@@ -85,6 +90,7 @@ void EmitterState::StartedNode() {
}
m_hasAnchor = false;
+ m_hasAlias = false;
m_hasTag = false;
m_hasNonContent = false;
}
@@ -94,15 +100,13 @@ EmitterNodeType::value EmitterState::NextGroupType(
if (type == GroupType::Seq) {
if (GetFlowType(type) == Block)
return EmitterNodeType::BlockSeq;
- else
- return EmitterNodeType::FlowSeq;
- } else {
- if (GetFlowType(type) == Block)
- return EmitterNodeType::BlockMap;
- else
- return EmitterNodeType::FlowMap;
+ return EmitterNodeType::FlowSeq;
}
+ if (GetFlowType(type) == Block)
+ return EmitterNodeType::BlockMap;
+ return EmitterNodeType::FlowMap;
+
// can't happen
assert(false);
return EmitterNodeType::NoType;
@@ -156,9 +160,15 @@ void EmitterState::EndedGroup(GroupType::value type) {
if (m_groups.empty()) {
if (type == GroupType::Seq) {
return SetError(ErrorMsg::UNEXPECTED_END_SEQ);
- } else {
- return SetError(ErrorMsg::UNEXPECTED_END_MAP);
}
+ return SetError(ErrorMsg::UNEXPECTED_END_MAP);
+ }
+
+ if (m_hasTag) {
+ SetError(ErrorMsg::INVALID_TAG);
+ }
+ if (m_hasAnchor) {
+ SetError(ErrorMsg::INVALID_ANCHOR);
}
// get rid of the current group
@@ -180,6 +190,9 @@ void EmitterState::EndedGroup(GroupType::value type) {
m_globalModifiedSettings.restore();
ClearModifiedSettings();
+ m_hasAnchor = false;
+ m_hasTag = false;
+ m_hasNonContent = false;
}
EmitterNodeType::value EmitterState::CurGroupNodeType() const {
@@ -220,11 +233,16 @@ std::size_t EmitterState::LastIndent() const {
void EmitterState::ClearModifiedSettings() { m_modifiedSettings.clear(); }
+void EmitterState::RestoreGlobalModifiedSettings() {
+ m_globalModifiedSettings.restore();
+}
+
bool EmitterState::SetOutputCharset(EMITTER_MANIP value,
FmtScope::value scope) {
switch (value) {
case EmitNonAscii:
case EscapeNonAscii:
+ case EscapeAsJson:
_Set(m_charset, value, scope);
return true;
default:
@@ -282,6 +300,19 @@ bool EmitterState::SetBoolCaseFormat(EMITTER_MANIP value,
}
}
+bool EmitterState::SetNullFormat(EMITTER_MANIP value, FmtScope::value scope) {
+ switch (value) {
+ case LowerNull:
+ case UpperNull:
+ case CamelNull:
+ case TildeNull:
+ _Set(m_nullFmt, value, scope);
+ return true;
+ default:
+ return false;
+ }
+}
+
bool EmitterState::SetIntFormat(EMITTER_MANIP value, FmtScope::value scope) {
switch (value) {
case Dec:
diff --git a/lib/yamlcpp/src/emitterstate.h b/lib/yamlcpp/src/emitterstate.h
index 75e216695..8f379ca95 100644
--- a/lib/yamlcpp/src/emitterstate.h
+++ b/lib/yamlcpp/src/emitterstate.h
@@ -43,6 +43,7 @@ class EmitterState {
// node handling
void SetAnchor();
+ void SetAlias();
void SetTag();
void SetNonContent();
void SetLongKey();
@@ -65,6 +66,7 @@ class EmitterState {
std::size_t LastIndent() const;
std::size_t CurIndent() const { return m_curIndent; }
bool HasAnchor() const { return m_hasAnchor; }
+ bool HasAlias() const { return m_hasAlias; }
bool HasTag() const { return m_hasTag; }
bool HasBegunNode() const {
return m_hasAnchor || m_hasTag || m_hasNonContent;
@@ -72,6 +74,7 @@ class EmitterState {
bool HasBegunContent() const { return m_hasAnchor || m_hasTag; }
void ClearModifiedSettings();
+ void RestoreGlobalModifiedSettings();
// formatters
void SetLocalValue(EMITTER_MANIP value);
@@ -91,6 +94,9 @@ class EmitterState {
bool SetBoolCaseFormat(EMITTER_MANIP value, FmtScope::value scope);
EMITTER_MANIP GetBoolCaseFormat() const { return m_boolCaseFmt.get(); }
+ bool SetNullFormat(EMITTER_MANIP value, FmtScope::value scope);
+ EMITTER_MANIP GetNullFormat() const { return m_nullFmt.get(); }
+
bool SetIntFormat(EMITTER_MANIP value, FmtScope::value scope);
EMITTER_MANIP GetIntFormat() const { return m_intFmt.get(); }
@@ -131,6 +137,7 @@ class EmitterState {
Setting<EMITTER_MANIP> m_boolFmt;
Setting<EMITTER_MANIP> m_boolLengthFmt;
Setting<EMITTER_MANIP> m_boolCaseFmt;
+ Setting<EMITTER_MANIP> m_nullFmt;
Setting<EMITTER_MANIP> m_intFmt;
Setting<std::size_t> m_indent;
Setting<std::size_t> m_preCommentIndent, m_postCommentIndent;
@@ -182,6 +189,7 @@ class EmitterState {
std::vector<std::unique_ptr<Group>> m_groups;
std::size_t m_curIndent;
bool m_hasAnchor;
+ bool m_hasAlias;
bool m_hasTag;
bool m_hasNonContent;
std::size_t m_docCount;
diff --git a/lib/yamlcpp/src/emitterutils.cpp b/lib/yamlcpp/src/emitterutils.cpp
index e348599d5..c6ad5e5d9 100644
--- a/lib/yamlcpp/src/emitterutils.cpp
+++ b/lib/yamlcpp/src/emitterutils.cpp
@@ -1,3 +1,4 @@
+#include <algorithm>
#include <iomanip>
#include <sstream>
@@ -199,15 +200,10 @@ bool IsValidPlainScalar(const std::string& str, FlowType::value flowType,
bool IsValidSingleQuotedScalar(const std::string& str, bool escapeNonAscii) {
// TODO: check for non-printable characters?
- for (std::size_t i = 0; i < str.size(); i++) {
- if (escapeNonAscii && (0x80 <= static_cast<unsigned char>(str[i]))) {
- return false;
- }
- if (str[i] == '\n') {
- return false;
- }
- }
- return true;
+ return std::none_of(str.begin(), str.end(), [=](char ch) {
+ return (escapeNonAscii && (0x80 <= static_cast<unsigned char>(ch))) ||
+ (ch == '\n');
+ });
}
bool IsValidLiteralScalar(const std::string& str, FlowType::value flowType,
@@ -217,28 +213,39 @@ bool IsValidLiteralScalar(const std::string& str, FlowType::value flowType,
}
// TODO: check for non-printable characters?
- for (std::size_t i = 0; i < str.size(); i++) {
- if (escapeNonAscii && (0x80 <= static_cast<unsigned char>(str[i]))) {
- return false;
- }
- }
- return true;
+ return std::none_of(str.begin(), str.end(), [=](char ch) {
+ return (escapeNonAscii && (0x80 <= static_cast<unsigned char>(ch)));
+ });
+}
+
+std::pair<uint16_t, uint16_t> EncodeUTF16SurrogatePair(int codePoint) {
+ const uint32_t leadOffset = 0xD800 - (0x10000 >> 10);
+
+ return {
+ leadOffset | (codePoint >> 10),
+ 0xDC00 | (codePoint & 0x3FF),
+ };
}
-void WriteDoubleQuoteEscapeSequence(ostream_wrapper& out, int codePoint) {
+void WriteDoubleQuoteEscapeSequence(ostream_wrapper& out, int codePoint, StringEscaping::value stringEscapingStyle) {
static const char hexDigits[] = "0123456789abcdef";
out << "\\";
int digits = 8;
- if (codePoint < 0xFF) {
+ if (codePoint < 0xFF && stringEscapingStyle != StringEscaping::JSON) {
out << "x";
digits = 2;
} else if (codePoint < 0xFFFF) {
out << "u";
digits = 4;
- } else {
+ } else if (stringEscapingStyle != StringEscaping::JSON) {
out << "U";
digits = 8;
+ } else {
+ auto surrogatePair = EncodeUTF16SurrogatePair(codePoint);
+ WriteDoubleQuoteEscapeSequence(out, surrogatePair.first, stringEscapingStyle);
+ WriteDoubleQuoteEscapeSequence(out, surrogatePair.second, stringEscapingStyle);
+ return;
}
// Write digits into the escape sequence
@@ -310,7 +317,7 @@ bool WriteSingleQuotedString(ostream_wrapper& out, const std::string& str) {
}
bool WriteDoubleQuotedString(ostream_wrapper& out, const std::string& str,
- bool escapeNonAscii) {
+ StringEscaping::value stringEscaping) {
out << "\"";
int codePoint;
for (std::string::const_iterator i = str.begin();
@@ -334,16 +341,19 @@ bool WriteDoubleQuotedString(ostream_wrapper& out, const std::string& str,
case '\b':
out << "\\b";
break;
+ case '\f':
+ out << "\\f";
+ break;
default:
if (codePoint < 0x20 ||
(codePoint >= 0x80 &&
codePoint <= 0xA0)) { // Control characters and non-breaking space
- WriteDoubleQuoteEscapeSequence(out, codePoint);
+ WriteDoubleQuoteEscapeSequence(out, codePoint, stringEscaping);
} else if (codePoint == 0xFEFF) { // Byte order marks (ZWNS) should be
// escaped (YAML 1.2, sec. 5.2)
- WriteDoubleQuoteEscapeSequence(out, codePoint);
- } else if (escapeNonAscii && codePoint > 0x7E) {
- WriteDoubleQuoteEscapeSequence(out, codePoint);
+ WriteDoubleQuoteEscapeSequence(out, codePoint, stringEscaping);
+ } else if (stringEscaping == StringEscaping::NonAscii && codePoint > 0x7E) {
+ WriteDoubleQuoteEscapeSequence(out, codePoint, stringEscaping);
} else {
WriteCodePoint(out, codePoint);
}
@@ -356,37 +366,41 @@ bool WriteDoubleQuotedString(ostream_wrapper& out, const std::string& str,
bool WriteLiteralString(ostream_wrapper& out, const std::string& str,
std::size_t indent) {
out << "|\n";
- out << IndentTo(indent);
int codePoint;
for (std::string::const_iterator i = str.begin();
GetNextCodePointAndAdvance(codePoint, i, str.end());) {
if (codePoint == '\n') {
- out << "\n" << IndentTo(indent);
+ out << "\n";
} else {
+ out<< IndentTo(indent);
WriteCodePoint(out, codePoint);
}
}
return true;
}
-bool WriteChar(ostream_wrapper& out, char ch) {
+bool WriteChar(ostream_wrapper& out, char ch, StringEscaping::value stringEscapingStyle) {
if (('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z')) {
out << ch;
} else if (ch == '\"') {
- out << "\"\\\"\"";
+ out << R"("\"")";
} else if (ch == '\t') {
- out << "\"\\t\"";
+ out << R"("\t")";
} else if (ch == '\n') {
- out << "\"\\n\"";
+ out << R"("\n")";
} else if (ch == '\b') {
- out << "\"\\b\"";
+ out << R"("\b")";
+ } else if (ch == '\r') {
+ out << R"("\r")";
+ } else if (ch == '\f') {
+ out << R"("\f")";
} else if (ch == '\\') {
- out << "\"\\\\\"";
+ out << R"("\\")";
} else if (0x20 <= ch && ch <= 0x7e) {
out << "\"" << ch << "\"";
} else {
out << "\"";
- WriteDoubleQuoteEscapeSequence(out, ch);
+ WriteDoubleQuoteEscapeSequence(out, ch, stringEscapingStyle);
out << "\"";
}
return true;
@@ -476,7 +490,7 @@ bool WriteTagWithPrefix(ostream_wrapper& out, const std::string& prefix,
bool WriteBinary(ostream_wrapper& out, const Binary& binary) {
WriteDoubleQuotedString(out, EncodeBase64(binary.data(), binary.size()),
- false);
+ StringEscaping::None);
return true;
}
} // namespace Utils
diff --git a/lib/yamlcpp/src/emitterutils.h b/lib/yamlcpp/src/emitterutils.h
index 6cc731914..3a7d59825 100644
--- a/lib/yamlcpp/src/emitterutils.h
+++ b/lib/yamlcpp/src/emitterutils.h
@@ -24,6 +24,10 @@ struct StringFormat {
enum value { Plain, SingleQuoted, DoubleQuoted, Literal };
};
+struct StringEscaping {
+ enum value { None, NonAscii, JSON };
+};
+
namespace Utils {
StringFormat::value ComputeStringFormat(const std::string& str,
EMITTER_MANIP strFormat,
@@ -32,10 +36,11 @@ StringFormat::value ComputeStringFormat(const std::string& str,
bool WriteSingleQuotedString(ostream_wrapper& out, const std::string& str);
bool WriteDoubleQuotedString(ostream_wrapper& out, const std::string& str,
- bool escapeNonAscii);
+ StringEscaping::value stringEscaping);
bool WriteLiteralString(ostream_wrapper& out, const std::string& str,
std::size_t indent);
-bool WriteChar(ostream_wrapper& out, char ch);
+bool WriteChar(ostream_wrapper& out, char ch,
+ StringEscaping::value stringEscapingStyle);
bool WriteComment(ostream_wrapper& out, const std::string& str,
std::size_t postCommentIndent);
bool WriteAlias(ostream_wrapper& out, const std::string& str);
diff --git a/lib/yamlcpp/src/exceptions.cpp b/lib/yamlcpp/src/exceptions.cpp
index 841549e0d..43a7976e9 100644
--- a/lib/yamlcpp/src/exceptions.cpp
+++ b/lib/yamlcpp/src/exceptions.cpp
@@ -1,31 +1,20 @@
#include "yaml-cpp/exceptions.h"
-
-// This is here for compatibility with older versions of Visual Studio
-// which don't support noexcept
-#if defined(_MSC_VER) && _MSC_VER < 1900
- #define YAML_CPP_NOEXCEPT _NOEXCEPT
-#else
- #define YAML_CPP_NOEXCEPT noexcept
-#endif
+#include "yaml-cpp/noexcept.h"
namespace YAML {
// These destructors are defined out-of-line so the vtable is only emitted once.
-Exception::~Exception() YAML_CPP_NOEXCEPT {}
-ParserException::~ParserException() YAML_CPP_NOEXCEPT {}
-RepresentationException::~RepresentationException() YAML_CPP_NOEXCEPT {}
-InvalidScalar::~InvalidScalar() YAML_CPP_NOEXCEPT {}
-KeyNotFound::~KeyNotFound() YAML_CPP_NOEXCEPT {}
-InvalidNode::~InvalidNode() YAML_CPP_NOEXCEPT {}
-BadConversion::~BadConversion() YAML_CPP_NOEXCEPT {}
-BadDereference::~BadDereference() YAML_CPP_NOEXCEPT {}
-BadSubscript::~BadSubscript() YAML_CPP_NOEXCEPT {}
-BadPushback::~BadPushback() YAML_CPP_NOEXCEPT {}
-BadInsert::~BadInsert() YAML_CPP_NOEXCEPT {}
-EmitterException::~EmitterException() YAML_CPP_NOEXCEPT {}
-BadFile::~BadFile() YAML_CPP_NOEXCEPT {}
-}
-
-#undef YAML_CPP_NOEXCEPT
-
-
+Exception::~Exception() YAML_CPP_NOEXCEPT = default;
+ParserException::~ParserException() YAML_CPP_NOEXCEPT = default;
+RepresentationException::~RepresentationException() YAML_CPP_NOEXCEPT = default;
+InvalidScalar::~InvalidScalar() YAML_CPP_NOEXCEPT = default;
+KeyNotFound::~KeyNotFound() YAML_CPP_NOEXCEPT = default;
+InvalidNode::~InvalidNode() YAML_CPP_NOEXCEPT = default;
+BadConversion::~BadConversion() YAML_CPP_NOEXCEPT = default;
+BadDereference::~BadDereference() YAML_CPP_NOEXCEPT = default;
+BadSubscript::~BadSubscript() YAML_CPP_NOEXCEPT = default;
+BadPushback::~BadPushback() YAML_CPP_NOEXCEPT = default;
+BadInsert::~BadInsert() YAML_CPP_NOEXCEPT = default;
+EmitterException::~EmitterException() YAML_CPP_NOEXCEPT = default;
+BadFile::~BadFile() YAML_CPP_NOEXCEPT = default;
+} // namespace YAML
diff --git a/lib/yamlcpp/src/exp.cpp b/lib/yamlcpp/src/exp.cpp
index 695440aec..992620ff9 100644
--- a/lib/yamlcpp/src/exp.cpp
+++ b/lib/yamlcpp/src/exp.cpp
@@ -12,8 +12,7 @@ namespace YAML {
namespace Exp {
unsigned ParseHex(const std::string& str, const Mark& mark) {
unsigned value = 0;
- for (std::size_t i = 0; i < str.size(); i++) {
- char ch = str[i];
+ for (char ch : str) {
int digit = 0;
if ('a' <= ch && ch <= 'f')
digit = ch - 'a' + 10;
@@ -55,14 +54,16 @@ std::string Escape(Stream& in, int codeLength) {
// now break it up into chars
if (value <= 0x7F)
return Str(value);
- else if (value <= 0x7FF)
+
+ if (value <= 0x7FF)
return Str(0xC0 + (value >> 6)) + Str(0x80 + (value & 0x3F));
- else if (value <= 0xFFFF)
+
+ if (value <= 0xFFFF)
return Str(0xE0 + (value >> 12)) + Str(0x80 + ((value >> 6) & 0x3F)) +
Str(0x80 + (value & 0x3F));
- else
- return Str(0xF0 + (value >> 18)) + Str(0x80 + ((value >> 12) & 0x3F)) +
- Str(0x80 + ((value >> 6) & 0x3F)) + Str(0x80 + (value & 0x3F));
+
+ return Str(0xF0 + (value >> 18)) + Str(0x80 + ((value >> 12) & 0x3F)) +
+ Str(0x80 + ((value >> 6) & 0x3F)) + Str(0x80 + (value & 0x3F));
}
// Escape
@@ -104,7 +105,7 @@ std::string Escape(Stream& in) {
case 'e':
return "\x1B";
case ' ':
- return "\x20";
+ return R"( )";
case '\"':
return "\"";
case '\'':
@@ -132,5 +133,5 @@ std::string Escape(Stream& in) {
std::stringstream msg;
throw ParserException(in.mark(), std::string(ErrorMsg::INVALID_ESCAPE) + ch);
}
-}
-}
+} // namespace Exp
+} // namespace YAML
diff --git a/lib/yamlcpp/src/exp.h b/lib/yamlcpp/src/exp.h
index fe36535b5..301449e8f 100644
--- a/lib/yamlcpp/src/exp.h
+++ b/lib/yamlcpp/src/exp.h
@@ -110,7 +110,7 @@ inline const RegEx& Value() {
return e;
}
inline const RegEx& ValueInFlow() {
- static const RegEx e = RegEx(':') + (BlankOrBreak() | RegEx(",}", REGEX_OR));
+ static const RegEx e = RegEx(':') + (BlankOrBreak() | RegEx(",]}", REGEX_OR));
return e;
}
inline const RegEx& ValueInJSONFlow() {
@@ -155,7 +155,7 @@ inline const RegEx& PlainScalar() {
inline const RegEx& PlainScalarInFlow() {
static const RegEx e =
!(BlankOrBreak() | RegEx("?,[]{}#&*!|>\'\"%@`", REGEX_OR) |
- (RegEx("-:", REGEX_OR) + Blank()));
+ (RegEx("-:", REGEX_OR) + (Blank() | RegEx())));
return e;
}
inline const RegEx& EndScalar() {
diff --git a/lib/yamlcpp/src/memory.cpp b/lib/yamlcpp/src/memory.cpp
index e5f8a9d3f..676e4c7f1 100644
--- a/lib/yamlcpp/src/memory.cpp
+++ b/lib/yamlcpp/src/memory.cpp
@@ -22,5 +22,5 @@ node& memory::create_node() {
void memory::merge(const memory& rhs) {
m_nodes.insert(rhs.m_nodes.begin(), rhs.m_nodes.end());
}
-}
-}
+} // namespace detail
+} // namespace YAML
diff --git a/lib/yamlcpp/src/node.cpp b/lib/yamlcpp/src/node.cpp
index 2088e13c9..badc3110e 100644
--- a/lib/yamlcpp/src/node.cpp
+++ b/lib/yamlcpp/src/node.cpp
@@ -9,4 +9,4 @@ Node Clone(const Node& node) {
events.Emit(builder);
return builder.Root();
}
-}
+} // namespace YAML
diff --git a/lib/yamlcpp/src/node_data.cpp b/lib/yamlcpp/src/node_data.cpp
index 6cfedfc3c..da2aefce9 100644
--- a/lib/yamlcpp/src/node_data.cpp
+++ b/lib/yamlcpp/src/node_data.cpp
@@ -1,4 +1,5 @@
-#include <assert.h>
+#include <algorithm>
+#include <cassert>
#include <iterator>
#include <sstream>
@@ -12,6 +13,7 @@
namespace YAML {
namespace detail {
+std::atomic<size_t> node::m_amount{0};
const std::string& node_data::empty_scalar() {
static const std::string svalue;
@@ -108,9 +110,9 @@ void node_data::compute_seq_size() const {
}
void node_data::compute_map_size() const {
- kv_pairs::iterator it = m_undefinedPairs.begin();
+ auto it = m_undefinedPairs.begin();
while (it != m_undefinedPairs.end()) {
- kv_pairs::iterator jt = std::next(it);
+ auto jt = std::next(it);
if (it->first->is_defined() && it->second->is_defined())
m_undefinedPairs.erase(it);
it = jt;
@@ -119,7 +121,7 @@ void node_data::compute_map_size() const {
const_node_iterator node_data::begin() const {
if (!m_isDefined)
- return const_node_iterator();
+ return {};
switch (m_type) {
case NodeType::Sequence:
@@ -127,13 +129,13 @@ const_node_iterator node_data::begin() const {
case NodeType::Map:
return const_node_iterator(m_map.begin(), m_map.end());
default:
- return const_node_iterator();
+ return {};
}
}
node_iterator node_data::begin() {
if (!m_isDefined)
- return node_iterator();
+ return {};
switch (m_type) {
case NodeType::Sequence:
@@ -141,13 +143,13 @@ node_iterator node_data::begin() {
case NodeType::Map:
return node_iterator(m_map.begin(), m_map.end());
default:
- return node_iterator();
+ return {};
}
}
const_node_iterator node_data::end() const {
if (!m_isDefined)
- return const_node_iterator();
+ return {};
switch (m_type) {
case NodeType::Sequence:
@@ -155,13 +157,13 @@ const_node_iterator node_data::end() const {
case NodeType::Map:
return const_node_iterator(m_map.end(), m_map.end());
default:
- return const_node_iterator();
+ return {};
}
}
node_iterator node_data::end() {
if (!m_isDefined)
- return node_iterator();
+ return {};
switch (m_type) {
case NodeType::Sequence:
@@ -169,12 +171,13 @@ node_iterator node_data::end() {
case NodeType::Map:
return node_iterator(m_map.end(), m_map.end());
default:
- return node_iterator();
+ return {};
}
}
// sequence
-void node_data::push_back(node& node, shared_memory_holder /* pMemory */) {
+void node_data::push_back(node& node,
+ const shared_memory_holder& /* pMemory */) {
if (m_type == NodeType::Undefined || m_type == NodeType::Null) {
m_type = NodeType::Sequence;
reset_sequence();
@@ -186,7 +189,8 @@ void node_data::push_back(node& node, shared_memory_holder /* pMemory */) {
m_sequence.push_back(&node);
}
-void node_data::insert(node& key, node& value, shared_memory_holder pMemory) {
+void node_data::insert(node& key, node& value,
+ const shared_memory_holder& pMemory) {
switch (m_type) {
case NodeType::Map:
break;
@@ -196,27 +200,28 @@ void node_data::insert(node& key, node& value, shared_memory_holder pMemory) {
convert_to_map(pMemory);
break;
case NodeType::Scalar:
- throw BadSubscript(key);
+ throw BadSubscript(m_mark, key);
}
insert_map_pair(key, value);
}
// indexing
-node* node_data::get(node& key, shared_memory_holder /* pMemory */) const {
+node* node_data::get(node& key,
+ const shared_memory_holder& /* pMemory */) const {
if (m_type != NodeType::Map) {
return nullptr;
}
- for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) {
- if (it->first->is(key))
- return it->second;
+ for (const auto& it : m_map) {
+ if (it.first->is(key))
+ return it.second;
}
return nullptr;
}
-node& node_data::get(node& key, shared_memory_holder pMemory) {
+node& node_data::get(node& key, const shared_memory_holder& pMemory) {
switch (m_type) {
case NodeType::Map:
break;
@@ -226,12 +231,12 @@ node& node_data::get(node& key, shared_memory_holder pMemory) {
convert_to_map(pMemory);
break;
case NodeType::Scalar:
- throw BadSubscript(key);
+ throw BadSubscript(m_mark, key);
}
- for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) {
- if (it->first->is(key))
- return *it->second;
+ for (const auto& it : m_map) {
+ if (it.first->is(key))
+ return *it.second;
}
node& value = pMemory->create_node();
@@ -239,23 +244,26 @@ node& node_data::get(node& key, shared_memory_holder pMemory) {
return value;
}
-bool node_data::remove(node& key, shared_memory_holder /* pMemory */) {
+bool node_data::remove(node& key, const shared_memory_holder& /* pMemory */) {
if (m_type != NodeType::Map)
return false;
- for (kv_pairs::iterator it = m_undefinedPairs.begin();
- it != m_undefinedPairs.end();) {
- kv_pairs::iterator jt = std::next(it);
+ for (auto it = m_undefinedPairs.begin(); it != m_undefinedPairs.end();) {
+ auto jt = std::next(it);
if (it->first->is(key))
m_undefinedPairs.erase(it);
it = jt;
}
- for (node_map::iterator it = m_map.begin(); it != m_map.end(); ++it) {
- if (it->first->is(key)) {
- m_map.erase(it);
- return true;
- }
+ auto it =
+ std::find_if(m_map.begin(), m_map.end(),
+ [&](std::pair<YAML::detail::node*, YAML::detail::node*> j) {
+ return (j.first->is(key));
+ });
+
+ if (it != m_map.end()) {
+ m_map.erase(it);
+ return true;
}
return false;
@@ -278,7 +286,7 @@ void node_data::insert_map_pair(node& key, node& value) {
m_undefinedPairs.emplace_back(&key, &value);
}
-void node_data::convert_to_map(shared_memory_holder pMemory) {
+void node_data::convert_to_map(const shared_memory_holder& pMemory) {
switch (m_type) {
case NodeType::Undefined:
case NodeType::Null:
@@ -296,7 +304,7 @@ void node_data::convert_to_map(shared_memory_holder pMemory) {
}
}
-void node_data::convert_sequence_to_map(shared_memory_holder pMemory) {
+void node_data::convert_sequence_to_map(const shared_memory_holder& pMemory) {
assert(m_type == NodeType::Sequence);
reset_map();
diff --git a/lib/yamlcpp/src/nodebuilder.cpp b/lib/yamlcpp/src/nodebuilder.cpp
index c90a66cb8..bbaefac8a 100644
--- a/lib/yamlcpp/src/nodebuilder.cpp
+++ b/lib/yamlcpp/src/nodebuilder.cpp
@@ -1,4 +1,3 @@
-#include <assert.h>
#include <cassert>
#include "nodebuilder.h"
@@ -20,7 +19,7 @@ NodeBuilder::NodeBuilder()
m_anchors.push_back(nullptr); // since the anchors start at 1
}
-NodeBuilder::~NodeBuilder() {}
+NodeBuilder::~NodeBuilder() = default;
Node NodeBuilder::Root() {
if (!m_pRoot)
@@ -93,7 +92,7 @@ void NodeBuilder::Push(detail::node& node) {
m_stack.push_back(&node);
if (needsKey)
- m_keys.push_back(PushedKey(&node, false));
+ m_keys.emplace_back(&node, false);
}
void NodeBuilder::Pop() {
diff --git a/lib/yamlcpp/src/nodebuilder.h b/lib/yamlcpp/src/nodebuilder.h
index 642da36cc..c580d40e2 100644
--- a/lib/yamlcpp/src/nodebuilder.h
+++ b/lib/yamlcpp/src/nodebuilder.h
@@ -31,25 +31,25 @@ class NodeBuilder : public EventHandler {
NodeBuilder(NodeBuilder&&) = delete;
NodeBuilder& operator=(const NodeBuilder&) = delete;
NodeBuilder& operator=(NodeBuilder&&) = delete;
- virtual ~NodeBuilder();
+ ~NodeBuilder() override;
Node Root();
- virtual void OnDocumentStart(const Mark& mark);
- virtual void OnDocumentEnd();
+ void OnDocumentStart(const Mark& mark) override;
+ void OnDocumentEnd() override;
- virtual void OnNull(const Mark& mark, anchor_t anchor);
- virtual void OnAlias(const Mark& mark, anchor_t anchor);
- virtual void OnScalar(const Mark& mark, const std::string& tag,
- anchor_t anchor, const std::string& value);
+ void OnNull(const Mark& mark, anchor_t anchor) override;
+ void OnAlias(const Mark& mark, anchor_t anchor) override;
+ void OnScalar(const Mark& mark, const std::string& tag,
+ anchor_t anchor, const std::string& value) override;
- virtual void OnSequenceStart(const Mark& mark, const std::string& tag,
- anchor_t anchor, EmitterStyle::value style);
- virtual void OnSequenceEnd();
+ void OnSequenceStart(const Mark& mark, const std::string& tag,
+ anchor_t anchor, EmitterStyle::value style) override;
+ void OnSequenceEnd() override;
- virtual void OnMapStart(const Mark& mark, const std::string& tag,
- anchor_t anchor, EmitterStyle::value style);
- virtual void OnMapEnd();
+ void OnMapStart(const Mark& mark, const std::string& tag,
+ anchor_t anchor, EmitterStyle::value style) override;
+ void OnMapEnd() override;
private:
detail::node& Push(const Mark& mark, anchor_t anchor);
@@ -61,11 +61,11 @@ class NodeBuilder : public EventHandler {
detail::shared_memory_holder m_pMemory;
detail::node* m_pRoot;
- typedef std::vector<detail::node*> Nodes;
+ using Nodes = std::vector<detail::node *>;
Nodes m_stack;
Nodes m_anchors;
- typedef std::pair<detail::node*, bool> PushedKey;
+ using PushedKey = std::pair<detail::node*, bool>;
std::vector<PushedKey> m_keys;
std::size_t m_mapDepth;
};
diff --git a/lib/yamlcpp/src/nodeevents.cpp b/lib/yamlcpp/src/nodeevents.cpp
index b7222e068..b1774fef3 100644
--- a/lib/yamlcpp/src/nodeevents.cpp
+++ b/lib/yamlcpp/src/nodeevents.cpp
@@ -13,7 +13,7 @@ void NodeEvents::AliasManager::RegisterReference(const detail::node& node) {
anchor_t NodeEvents::AliasManager::LookupAnchor(
const detail::node& node) const {
- AnchorByIdentity::const_iterator it = m_anchorByIdentity.find(node.ref());
+ auto it = m_anchorByIdentity.find(node.ref());
if (it == m_anchorByIdentity.end())
return 0;
return it->second;
@@ -32,13 +32,12 @@ void NodeEvents::Setup(const detail::node& node) {
return;
if (node.type() == NodeType::Sequence) {
- for (detail::const_node_iterator it = node.begin(); it != node.end(); ++it)
- Setup(**it);
+ for (auto element : node)
+ Setup(*element);
} else if (node.type() == NodeType::Map) {
- for (detail::const_node_iterator it = node.begin(); it != node.end();
- ++it) {
- Setup(*it->first);
- Setup(*it->second);
+ for (auto element : node) {
+ Setup(*element.first);
+ Setup(*element.second);
}
}
}
@@ -77,17 +76,15 @@ void NodeEvents::Emit(const detail::node& node, EventHandler& handler,
break;
case NodeType::Sequence:
handler.OnSequenceStart(Mark(), node.tag(), anchor, node.style());
- for (detail::const_node_iterator it = node.begin(); it != node.end();
- ++it)
- Emit(**it, handler, am);
+ for (auto element : node)
+ Emit(*element, handler, am);
handler.OnSequenceEnd();
break;
case NodeType::Map:
handler.OnMapStart(Mark(), node.tag(), anchor, node.style());
- for (detail::const_node_iterator it = node.begin(); it != node.end();
- ++it) {
- Emit(*it->first, handler, am);
- Emit(*it->second, handler, am);
+ for (auto element : node) {
+ Emit(*element.first, handler, am);
+ Emit(*element.second, handler, am);
}
handler.OnMapEnd();
break;
@@ -95,7 +92,7 @@ void NodeEvents::Emit(const detail::node& node, EventHandler& handler,
}
bool NodeEvents::IsAliased(const detail::node& node) const {
- RefCount::const_iterator it = m_refCount.find(node.ref());
+ auto it = m_refCount.find(node.ref());
return it != m_refCount.end() && it->second > 1;
}
} // namespace YAML
diff --git a/lib/yamlcpp/src/nodeevents.h b/lib/yamlcpp/src/nodeevents.h
index dbed5d206..efca9149e 100644
--- a/lib/yamlcpp/src/nodeevents.h
+++ b/lib/yamlcpp/src/nodeevents.h
@@ -45,7 +45,7 @@ class NodeEvents {
anchor_t _CreateNewAnchor() { return ++m_curAnchor; }
private:
- typedef std::map<const detail::node_ref*, anchor_t> AnchorByIdentity;
+ using AnchorByIdentity = std::map<const detail::node_ref*, anchor_t>;
AnchorByIdentity m_anchorByIdentity;
anchor_t m_curAnchor;
@@ -60,7 +60,7 @@ class NodeEvents {
detail::shared_memory_holder m_pMemory;
detail::node* m_root;
- typedef std::map<const detail::node_ref*, int> RefCount;
+ using RefCount = std::map<const detail::node_ref*, int>;
RefCount m_refCount;
};
} // namespace YAML
diff --git a/lib/yamlcpp/src/null.cpp b/lib/yamlcpp/src/null.cpp
index d12dd08ce..db7daebf1 100644
--- a/lib/yamlcpp/src/null.cpp
+++ b/lib/yamlcpp/src/null.cpp
@@ -7,4 +7,4 @@ bool IsNullString(const std::string& str) {
return str.empty() || str == "~" || str == "null" || str == "Null" ||
str == "NULL";
}
-}
+} // namespace YAML
diff --git a/lib/yamlcpp/src/ostream_wrapper.cpp b/lib/yamlcpp/src/ostream_wrapper.cpp
index 5fa585897..047a9f7c8 100644
--- a/lib/yamlcpp/src/ostream_wrapper.cpp
+++ b/lib/yamlcpp/src/ostream_wrapper.cpp
@@ -21,7 +21,7 @@ ostream_wrapper::ostream_wrapper(std::ostream& stream)
m_col(0),
m_comment(false) {}
-ostream_wrapper::~ostream_wrapper() {}
+ostream_wrapper::~ostream_wrapper() = default;
void ostream_wrapper::write(const std::string& str) {
if (m_pStream) {
@@ -31,8 +31,8 @@ void ostream_wrapper::write(const std::string& str) {
std::copy(str.begin(), str.end(), m_buffer.begin() + m_pos);
}
- for (std::size_t i = 0; i < str.size(); i++) {
- update_pos(str[i]);
+ for (char ch : str) {
+ update_pos(ch);
}
}
diff --git a/lib/yamlcpp/src/parse.cpp b/lib/yamlcpp/src/parse.cpp
index 0b2ae4a4f..262536b85 100644
--- a/lib/yamlcpp/src/parse.cpp
+++ b/lib/yamlcpp/src/parse.cpp
@@ -3,10 +3,10 @@
#include <fstream>
#include <sstream>
-#include "yaml-cpp/node/node.h"
+#include "nodebuilder.h"
#include "yaml-cpp/node/impl.h"
+#include "yaml-cpp/node/node.h"
#include "yaml-cpp/parser.h"
-#include "nodebuilder.h"
namespace YAML {
Node Load(const std::string& input) {
@@ -30,9 +30,9 @@ Node Load(std::istream& input) {
}
Node LoadFile(const std::string& filename) {
- std::ifstream fin(filename.c_str());
+ std::ifstream fin(filename);
if (!fin) {
- throw BadFile();
+ throw BadFile(filename);
}
return Load(fin);
}
@@ -51,7 +51,7 @@ std::vector<Node> LoadAll(std::istream& input) {
std::vector<Node> docs;
Parser parser(input);
- while (1) {
+ while (true) {
NodeBuilder builder;
if (!parser.HandleNextDocument(builder)) {
break;
@@ -63,9 +63,9 @@ std::vector<Node> LoadAll(std::istream& input) {
}
std::vector<Node> LoadAllFromFile(const std::string& filename) {
- std::ifstream fin(filename.c_str());
+ std::ifstream fin(filename);
if (!fin) {
- throw BadFile();
+ throw BadFile(filename);
}
return LoadAll(fin);
}
diff --git a/lib/yamlcpp/src/parser.cpp b/lib/yamlcpp/src/parser.cpp
index 7bc0c7828..b8b78ebab 100644
--- a/lib/yamlcpp/src/parser.cpp
+++ b/lib/yamlcpp/src/parser.cpp
@@ -15,11 +15,9 @@ Parser::Parser() : m_pScanner{}, m_pDirectives{} {}
Parser::Parser(std::istream& in) : Parser() { Load(in); }
-Parser::~Parser() {}
+Parser::~Parser() = default;
-Parser::operator bool() const {
- return m_pScanner.get() && !m_pScanner->empty();
-}
+Parser::operator bool() const { return m_pScanner && !m_pScanner->empty(); }
void Parser::Load(std::istream& in) {
m_pScanner.reset(new Scanner(in));
@@ -27,7 +25,7 @@ void Parser::Load(std::istream& in) {
}
bool Parser::HandleNextDocument(EventHandler& eventHandler) {
- if (!m_pScanner.get())
+ if (!m_pScanner)
return false;
ParseDirectives();
@@ -43,11 +41,7 @@ bool Parser::HandleNextDocument(EventHandler& eventHandler) {
void Parser::ParseDirectives() {
bool readDirective = false;
- while (1) {
- if (m_pScanner->empty()) {
- break;
- }
-
+ while (!m_pScanner->empty()) {
Token& token = m_pScanner->peek();
if (token.type != Token::DIRECTIVE) {
break;
@@ -113,15 +107,11 @@ void Parser::HandleTagDirective(const Token& token) {
}
void Parser::PrintTokens(std::ostream& out) {
- if (!m_pScanner.get()) {
+ if (!m_pScanner) {
return;
}
- while (1) {
- if (m_pScanner->empty()) {
- break;
- }
-
+ while (!m_pScanner->empty()) {
out << m_pScanner->peek() << "\n";
m_pScanner->pop();
}
diff --git a/lib/yamlcpp/src/regex_yaml.h b/lib/yamlcpp/src/regex_yaml.h
index 3a347bbd0..c70ab60dc 100644
--- a/lib/yamlcpp/src/regex_yaml.h
+++ b/lib/yamlcpp/src/regex_yaml.h
@@ -34,7 +34,7 @@ class YAML_CPP_API RegEx {
explicit RegEx(char ch);
RegEx(char a, char z);
RegEx(const std::string& str, REGEX_OP op = REGEX_SEQ);
- ~RegEx() {}
+ ~RegEx() = default;
friend YAML_CPP_API RegEx operator!(const RegEx& ex);
friend YAML_CPP_API RegEx operator|(const RegEx& ex1, const RegEx& ex2);
diff --git a/lib/yamlcpp/src/regeximpl.h b/lib/yamlcpp/src/regeximpl.h
index 709124f00..a742cdc30 100644
--- a/lib/yamlcpp/src/regeximpl.h
+++ b/lib/yamlcpp/src/regeximpl.h
@@ -8,8 +8,8 @@
#endif
#include "stream.h"
-#include "stringsource.h"
#include "streamcharsource.h"
+#include "stringsource.h"
namespace YAML {
// query matches
@@ -106,9 +106,8 @@ inline int RegEx::MatchOpEmpty(const Source& source) const {
template <>
inline int RegEx::MatchOpEmpty<StringCharSource>(
const StringCharSource& source) const {
- return !source
- ? 0
- : -1; // the empty regex only is successful on the empty string
+ return !source ? 0 : -1; // the empty regex only is successful on the empty
+ // string
}
// MatchOperator
@@ -130,8 +129,8 @@ inline int RegEx::MatchOpRange(const Source& source) const {
// OrOperator
template <typename Source>
inline int RegEx::MatchOpOr(const Source& source) const {
- for (std::size_t i = 0; i < m_params.size(); i++) {
- int n = m_params[i].MatchUnchecked(source);
+ for (const RegEx& param : m_params) {
+ int n = param.MatchUnchecked(source);
if (n >= 0)
return n;
}
@@ -169,11 +168,11 @@ inline int RegEx::MatchOpNot(const Source& source) const {
template <typename Source>
inline int RegEx::MatchOpSeq(const Source& source) const {
int offset = 0;
- for (std::size_t i = 0; i < m_params.size(); i++) {
- int n = m_params[i].Match(source + offset); // note Match, not
- // MatchUnchecked because we
- // need to check validity after
- // the offset
+ for (const RegEx& param : m_params) {
+ int n = param.Match(source + offset); // note Match, not
+ // MatchUnchecked because we
+ // need to check validity after
+ // the offset
if (n == -1)
return -1;
offset += n;
@@ -181,6 +180,6 @@ inline int RegEx::MatchOpSeq(const Source& source) const {
return offset;
}
-}
+} // namespace YAML
#endif // REGEXIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
diff --git a/lib/yamlcpp/src/scanner.cpp b/lib/yamlcpp/src/scanner.cpp
index 49a4c3325..ea5511a11 100644
--- a/lib/yamlcpp/src/scanner.cpp
+++ b/lib/yamlcpp/src/scanner.cpp
@@ -19,7 +19,7 @@ Scanner::Scanner(std::istream& in)
m_indentRefs{},
m_flows{} {}
-Scanner::~Scanner() {}
+Scanner::~Scanner() = default;
bool Scanner::empty() {
EnsureTokensInQueue();
@@ -51,7 +51,7 @@ Token& Scanner::peek() {
Mark Scanner::mark() const { return INPUT.mark(); }
void Scanner::EnsureTokensInQueue() {
- while (1) {
+ while (true) {
if (!m_tokens.empty()) {
Token& token = m_tokens.front();
@@ -174,7 +174,7 @@ void Scanner::ScanNextToken() {
}
void Scanner::ScanToNextToken() {
- while (1) {
+ while (true) {
// first eat whitespace
while (INPUT && IsWhitespaceToBeEaten(INPUT.peek())) {
if (InBlockContext() && Exp::Tab().Matches(INPUT)) {
diff --git a/lib/yamlcpp/src/scanscalar.cpp b/lib/yamlcpp/src/scanscalar.cpp
index e5b0973ee..be57b1cd5 100644
--- a/lib/yamlcpp/src/scanscalar.cpp
+++ b/lib/yamlcpp/src/scanscalar.cpp
@@ -47,7 +47,8 @@ std::string ScanScalar(Stream& INPUT, ScanScalarParams& params) {
if (INPUT.column() == 0 && Exp::DocIndicator().Matches(INPUT)) {
if (params.onDocIndicator == BREAK) {
break;
- } else if (params.onDocIndicator == THROW) {
+ }
+ if (params.onDocIndicator == THROW) {
throw ParserException(INPUT.mark(), ErrorMsg::DOC_IN_SCALAR);
}
}
@@ -203,7 +204,7 @@ std::string ScanScalar(Stream& INPUT, ScanScalarParams& params) {
// post-processing
if (params.trimTrailingSpaces) {
- std::size_t pos = scalar.find_last_not_of(' ');
+ std::size_t pos = scalar.find_last_not_of(" \t");
if (lastEscapedChar != std::string::npos) {
if (pos < lastEscapedChar || pos == std::string::npos) {
pos = lastEscapedChar;
@@ -247,4 +248,4 @@ std::string ScanScalar(Stream& INPUT, ScanScalarParams& params) {
return scalar;
}
-}
+} // namespace YAML
diff --git a/lib/yamlcpp/src/scanscalar.h b/lib/yamlcpp/src/scanscalar.h
index c3a574ad9..296b885a5 100644
--- a/lib/yamlcpp/src/scanscalar.h
+++ b/lib/yamlcpp/src/scanscalar.h
@@ -57,7 +57,7 @@ struct ScanScalarParams {
bool leadingSpaces;
};
-std::string ScanScalar(Stream& INPUT, ScanScalarParams& info);
+std::string ScanScalar(Stream& INPUT, ScanScalarParams& params);
}
#endif // SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
diff --git a/lib/yamlcpp/src/scantag.cpp b/lib/yamlcpp/src/scantag.cpp
index c5b39652a..176cc5c71 100644
--- a/lib/yamlcpp/src/scantag.cpp
+++ b/lib/yamlcpp/src/scantag.cpp
@@ -78,4 +78,4 @@ const std::string ScanTagSuffix(Stream& INPUT) {
return tag;
}
-}
+} // namespace YAML
diff --git a/lib/yamlcpp/src/scantoken.cpp b/lib/yamlcpp/src/scantoken.cpp
index 325de5715..1a94ab1d7 100644
--- a/lib/yamlcpp/src/scantoken.cpp
+++ b/lib/yamlcpp/src/scantoken.cpp
@@ -37,7 +37,7 @@ void Scanner::ScanDirective() {
token.value += INPUT.get();
// read parameters
- while (1) {
+ while (true) {
// first get rid of whitespace
while (Exp::Blank().Matches(INPUT))
INPUT.eat(1);
@@ -171,7 +171,7 @@ void Scanner::ScanBlockEntry() {
// Key
void Scanner::ScanKey() {
- // handle keys diffently in the block context (and manage indents)
+ // handle keys differently in the block context (and manage indents)
if (InBlockContext()) {
if (!m_simpleKeyAllowed)
throw ParserException(INPUT.mark(), ErrorMsg::MAP_KEY);
@@ -199,7 +199,7 @@ void Scanner::ScanValue() {
// seems fine)
m_simpleKeyAllowed = false;
} else {
- // handle values diffently in the block context (and manage indents)
+ // handle values differently in the block context (and manage indents)
if (InBlockContext()) {
if (!m_simpleKeyAllowed)
throw ParserException(INPUT.mark(), ErrorMsg::MAP_VALUE);
diff --git a/lib/yamlcpp/src/setting.h b/lib/yamlcpp/src/setting.h
index 280d1e72b..4960bbf75 100644
--- a/lib/yamlcpp/src/setting.h
+++ b/lib/yamlcpp/src/setting.h
@@ -7,12 +7,18 @@
#pragma once
#endif
+#include "yaml-cpp/noexcept.h"
#include <memory>
#include <utility>
#include <vector>
namespace YAML {
-class SettingChangeBase;
+
+class SettingChangeBase {
+ public:
+ virtual ~SettingChangeBase() = default;
+ virtual void pop() = 0;
+};
template <typename T>
class Setting {
@@ -28,12 +34,6 @@ class Setting {
T m_value;
};
-class SettingChangeBase {
- public:
- virtual ~SettingChangeBase() {}
- virtual void pop() = 0;
-};
-
template <typename T>
class SettingChange : public SettingChangeBase {
public:
@@ -46,7 +46,7 @@ class SettingChange : public SettingChangeBase {
SettingChange& operator=(const SettingChange&) = delete;
SettingChange& operator=(SettingChange&&) = delete;
- virtual void pop() { m_pCurSetting->restore(m_oldSetting); }
+ void pop() override { m_pCurSetting->restore(m_oldSetting); }
private:
Setting<T>* m_pCurSetting;
@@ -64,38 +64,35 @@ class SettingChanges {
public:
SettingChanges() : m_settingChanges{} {}
SettingChanges(const SettingChanges&) = delete;
- SettingChanges(SettingChanges&&) = default;
+ SettingChanges(SettingChanges&&) YAML_CPP_NOEXCEPT = default;
SettingChanges& operator=(const SettingChanges&) = delete;
+ SettingChanges& operator=(SettingChanges&& rhs) YAML_CPP_NOEXCEPT {
+ if (this == &rhs)
+ return *this;
+
+ clear();
+ std::swap(m_settingChanges, rhs.m_settingChanges);
+
+ return *this;
+ }
~SettingChanges() { clear(); }
- void clear() {
+ void clear() YAML_CPP_NOEXCEPT {
restore();
m_settingChanges.clear();
}
- void restore() {
- for (setting_changes::const_iterator it = m_settingChanges.begin();
- it != m_settingChanges.end(); ++it)
- (*it)->pop();
+ void restore() YAML_CPP_NOEXCEPT {
+ for (const auto& setting : m_settingChanges)
+ setting->pop();
}
void push(std::unique_ptr<SettingChangeBase> pSettingChange) {
m_settingChanges.push_back(std::move(pSettingChange));
}
- // like std::unique_ptr - assignment is transfer of ownership
- SettingChanges& operator=(SettingChanges&& rhs) {
- if (this == &rhs)
- return *this;
-
- clear();
- std::swap(m_settingChanges, rhs.m_settingChanges);
-
- return *this;
- }
-
private:
- typedef std::vector<std::unique_ptr<SettingChangeBase>> setting_changes;
+ using setting_changes = std::vector<std::unique_ptr<SettingChangeBase>>;
setting_changes m_settingChanges;
};
} // namespace YAML
diff --git a/lib/yamlcpp/src/simplekey.cpp b/lib/yamlcpp/src/simplekey.cpp
index c7a213552..67c2d712e 100644
--- a/lib/yamlcpp/src/simplekey.cpp
+++ b/lib/yamlcpp/src/simplekey.cpp
@@ -5,7 +5,11 @@ namespace YAML {
struct Mark;
Scanner::SimpleKey::SimpleKey(const Mark& mark_, std::size_t flowLevel_)
- : mark(mark_), flowLevel(flowLevel_), pIndent(nullptr), pMapStart(nullptr), pKey(nullptr) {}
+ : mark(mark_),
+ flowLevel(flowLevel_),
+ pIndent(nullptr),
+ pMapStart(nullptr),
+ pKey(nullptr) {}
void Scanner::SimpleKey::Validate() {
// Note: pIndent will *not* be garbage here;
@@ -125,4 +129,4 @@ void Scanner::PopAllSimpleKeys() {
while (!m_simpleKeys.empty())
m_simpleKeys.pop();
}
-}
+} // namespace YAML
diff --git a/lib/yamlcpp/src/singledocparser.cpp b/lib/yamlcpp/src/singledocparser.cpp
index be8274153..6bad448d9 100644
--- a/lib/yamlcpp/src/singledocparser.cpp
+++ b/lib/yamlcpp/src/singledocparser.cpp
@@ -7,6 +7,7 @@
#include "singledocparser.h"
#include "tag.h"
#include "token.h"
+#include "yaml-cpp/depthguard.h"
#include "yaml-cpp/emitterstyle.h"
#include "yaml-cpp/eventhandler.h"
#include "yaml-cpp/exceptions.h" // IWYU pragma: keep
@@ -21,7 +22,7 @@ SingleDocParser::SingleDocParser(Scanner& scanner, const Directives& directives)
m_anchors{},
m_curAnchor(0) {}
-SingleDocParser::~SingleDocParser() {}
+SingleDocParser::~SingleDocParser() = default;
// HandleDocument
// . Handles the next document
@@ -47,6 +48,8 @@ void SingleDocParser::HandleDocument(EventHandler& eventHandler) {
}
void SingleDocParser::HandleNode(EventHandler& eventHandler) {
+ DepthGuard<500> depthguard(depth, m_scanner.mark(), ErrorMsg::BAD_FILE);
+
// an empty node *is* a possibility
if (m_scanner.empty()) {
eventHandler.OnNull(m_scanner.mark(), NullAnchor);
@@ -79,18 +82,25 @@ void SingleDocParser::HandleNode(EventHandler& eventHandler) {
if (!anchor_name.empty())
eventHandler.OnAnchor(mark, anchor_name);
- const Token& token = m_scanner.peek();
-
- if (token.type == Token::PLAIN_SCALAR && IsNullString(token.value)) {
+ // after parsing properties, an empty node is again a possibility
+ if (m_scanner.empty()) {
eventHandler.OnNull(mark, anchor);
- m_scanner.pop();
return;
}
+ const Token& token = m_scanner.peek();
+
// add non-specific tags
if (tag.empty())
tag = (token.type == Token::NON_PLAIN_SCALAR ? "!" : "?");
+ if (token.type == Token::PLAIN_SCALAR
+ && tag.compare("?") == 0 && IsNullString(token.value)) {
+ eventHandler.OnNull(mark, anchor);
+ m_scanner.pop();
+ return;
+ }
+
// now split based on what kind of node we should be
switch (token.type) {
case Token::PLAIN_SCALAR:
@@ -157,7 +167,7 @@ void SingleDocParser::HandleBlockSequence(EventHandler& eventHandler) {
m_scanner.pop();
m_pCollectionStack->PushCollectionType(CollectionType::BlockSeq);
- while (1) {
+ while (true) {
if (m_scanner.empty())
throw ParserException(m_scanner.mark(), ErrorMsg::END_OF_SEQ);
@@ -190,7 +200,7 @@ void SingleDocParser::HandleFlowSequence(EventHandler& eventHandler) {
m_scanner.pop();
m_pCollectionStack->PushCollectionType(CollectionType::FlowSeq);
- while (1) {
+ while (true) {
if (m_scanner.empty())
throw ParserException(m_scanner.mark(), ErrorMsg::END_OF_SEQ_FLOW);
@@ -243,7 +253,7 @@ void SingleDocParser::HandleBlockMap(EventHandler& eventHandler) {
m_scanner.pop();
m_pCollectionStack->PushCollectionType(CollectionType::BlockMap);
- while (1) {
+ while (true) {
if (m_scanner.empty())
throw ParserException(m_scanner.mark(), ErrorMsg::END_OF_MAP);
@@ -282,7 +292,7 @@ void SingleDocParser::HandleFlowMap(EventHandler& eventHandler) {
m_scanner.pop();
m_pCollectionStack->PushCollectionType(CollectionType::FlowMap);
- while (1) {
+ while (true) {
if (m_scanner.empty())
throw ParserException(m_scanner.mark(), ErrorMsg::END_OF_MAP_FLOW);
@@ -367,7 +377,7 @@ void SingleDocParser::ParseProperties(std::string& tag, anchor_t& anchor,
anchor_name.clear();
anchor = NullAnchor;
- while (1) {
+ while (true) {
if (m_scanner.empty())
return;
@@ -413,7 +423,7 @@ anchor_t SingleDocParser::RegisterAnchor(const std::string& name) {
anchor_t SingleDocParser::LookupAnchor(const Mark& mark,
const std::string& name) const {
- Anchors::const_iterator it = m_anchors.find(name);
+ auto it = m_anchors.find(name);
if (it == m_anchors.end())
throw ParserException(mark, ErrorMsg::UNKNOWN_ANCHOR);
diff --git a/lib/yamlcpp/src/singledocparser.h b/lib/yamlcpp/src/singledocparser.h
index 392453ec7..f484eb1f9 100644
--- a/lib/yamlcpp/src/singledocparser.h
+++ b/lib/yamlcpp/src/singledocparser.h
@@ -15,6 +15,7 @@
namespace YAML {
class CollectionStack;
+template <int> class DepthGuard; // depthguard.h
class EventHandler;
class Node;
class Scanner;
@@ -55,11 +56,12 @@ class SingleDocParser {
anchor_t LookupAnchor(const Mark& mark, const std::string& name) const;
private:
+ int depth = 0;
Scanner& m_scanner;
const Directives& m_directives;
std::unique_ptr<CollectionStack> m_pCollectionStack;
- typedef std::map<std::string, anchor_t> Anchors;
+ using Anchors = std::map<std::string, anchor_t>;
Anchors m_anchors;
anchor_t m_curAnchor;
diff --git a/lib/yamlcpp/src/stream.cpp b/lib/yamlcpp/src/stream.cpp
index 592802d17..b1aa092f6 100644
--- a/lib/yamlcpp/src/stream.cpp
+++ b/lib/yamlcpp/src/stream.cpp
@@ -151,7 +151,8 @@ inline UtfIntroCharType IntroCharTypeOf(std::istream::int_type ch) {
inline char Utf8Adjust(unsigned long ch, unsigned char lead_bits,
unsigned char rshift) {
- const unsigned char header = ((1 << lead_bits) - 1) << (8 - lead_bits);
+ const unsigned char header =
+ static_cast<unsigned char>(((1 << lead_bits) - 1) << (8 - lead_bits));
const unsigned char mask = (0xFF >> (lead_bits + 1));
return static_cast<char>(
static_cast<unsigned char>(header | ((ch >> rshift) & mask)));
@@ -189,14 +190,14 @@ Stream::Stream(std::istream& input)
m_pPrefetched(new unsigned char[YAML_PREFETCH_SIZE]),
m_nPrefetchedAvailable(0),
m_nPrefetchedUsed(0) {
- typedef std::istream::traits_type char_traits;
+ using char_traits = std::istream::traits_type;
if (!input)
return;
// Determine (or guess) the character-set by reading the BOM, if any. See
// the YAML specification for the determination algorithm.
- char_traits::int_type intro[4];
+ char_traits::int_type intro[4]{};
int nIntroUsed = 0;
UtfIntroState state = uis_start;
for (; !s_introFinalState[state];) {
@@ -273,9 +274,11 @@ char Stream::get() {
// . Extracts 'n' characters from the stream and updates our position
std::string Stream::get(int n) {
std::string ret;
- ret.reserve(n);
- for (int i = 0; i < n; i++)
- ret += get();
+ if (n > 0) {
+ ret.reserve(static_cast<std::string::size_type>(n));
+ for (int i = 0; i < n; i++)
+ ret += get();
+ }
return ret;
}
@@ -326,7 +329,7 @@ bool Stream::_ReadAheadTo(size_t i) const {
void Stream::StreamInUtf8() const {
unsigned char b = GetNextByte();
if (m_input.good()) {
- m_readahead.push_back(b);
+ m_readahead.push_back(static_cast<char>(b));
}
}
@@ -347,7 +350,9 @@ void Stream::StreamInUtf16() const {
// Trailing (low) surrogate...ugh, wrong order
QueueUnicodeCodepoint(m_readahead, CP_REPLACEMENT_CHARACTER);
return;
- } else if (ch >= 0xD800 && ch < 0xDC00) {
+ }
+
+ if (ch >= 0xD800 && ch < 0xDC00) {
// ch is a leading (high) surrogate
// Four byte UTF-8 code point
@@ -372,11 +377,10 @@ void Stream::StreamInUtf16() const {
// Easiest case: queue the codepoint and return
QueueUnicodeCodepoint(m_readahead, ch);
return;
- } else {
- // Start the loop over with the new high surrogate
- ch = chLow;
- continue;
}
+ // Start the loop over with the new high surrogate
+ ch = chLow;
+ continue;
}
// Select the payload bits from the high surrogate
diff --git a/lib/yamlcpp/src/stream.h b/lib/yamlcpp/src/stream.h
index ff5149e97..2bc7a1521 100644
--- a/lib/yamlcpp/src/stream.h
+++ b/lib/yamlcpp/src/stream.h
@@ -16,6 +16,9 @@
#include <string>
namespace YAML {
+
+class StreamCharSource;
+
class Stream {
public:
friend class StreamCharSource;
diff --git a/lib/yamlcpp/src/streamcharsource.h b/lib/yamlcpp/src/streamcharsource.h
index 4b6a143ea..826ba5347 100644
--- a/lib/yamlcpp/src/streamcharsource.h
+++ b/lib/yamlcpp/src/streamcharsource.h
@@ -7,18 +7,20 @@
#pragma once
#endif
+#include "yaml-cpp/noexcept.h"
+#include "stream.h"
#include <cstddef>
namespace YAML {
+
class StreamCharSource {
public:
StreamCharSource(const Stream& stream) : m_offset(0), m_stream(stream) {}
- StreamCharSource(const StreamCharSource& source)
- : m_offset(source.m_offset), m_stream(source.m_stream) {}
- StreamCharSource(StreamCharSource&&) = default;
+ StreamCharSource(const StreamCharSource& source) = default;
+ StreamCharSource(StreamCharSource&&) YAML_CPP_NOEXCEPT = default;
StreamCharSource& operator=(const StreamCharSource&) = delete;
StreamCharSource& operator=(StreamCharSource&&) = delete;
- ~StreamCharSource() {}
+ ~StreamCharSource() = default;
operator bool() const;
char operator[](std::size_t i) const { return m_stream.CharAt(m_offset + i); }
@@ -38,7 +40,7 @@ inline StreamCharSource::operator bool() const {
inline const StreamCharSource StreamCharSource::operator+(int i) const {
StreamCharSource source(*this);
if (static_cast<int>(source.m_offset) + i >= 0)
- source.m_offset += i;
+ source.m_offset += static_cast<std::size_t>(i);
else
source.m_offset = 0;
return source;
diff --git a/lib/yamlcpp/src/token.h b/lib/yamlcpp/src/token.h
index 9a27f3d6c..9c9a5b779 100644
--- a/lib/yamlcpp/src/token.h
+++ b/lib/yamlcpp/src/token.h
@@ -53,8 +53,8 @@ struct Token {
friend std::ostream& operator<<(std::ostream& out, const Token& token) {
out << TokenNames[token.type] << std::string(": ") << token.value;
- for (std::size_t i = 0; i < token.params.size(); i++)
- out << std::string(" ") << token.params[i];
+ for (const std::string& param : token.params)
+ out << std::string(" ") << param;
return out;
}
diff --git a/lib/yamlcpp/test/BUILD.bazel b/lib/yamlcpp/test/BUILD.bazel
new file mode 100644
index 000000000..d30fa73cb
--- /dev/null
+++ b/lib/yamlcpp/test/BUILD.bazel
@@ -0,0 +1,14 @@
+cc_test(
+ name = "test",
+ srcs = glob([
+ "*.cpp",
+ "*.h",
+ "integrations/*.cpp",
+ "node/*.cpp",
+ ]),
+ deps = [
+ "//:yaml-cpp",
+ "//:yaml-cpp_internal",
+ "@com_google_googletest//:gtest_main",
+ ],
+)
diff --git a/lib/yamlcpp/test/CMakeLists.txt b/lib/yamlcpp/test/CMakeLists.txt
index 0a669d5cc..5ebc1a6b3 100644
--- a/lib/yamlcpp/test/CMakeLists.txt
+++ b/lib/yamlcpp/test/CMakeLists.txt
@@ -1,69 +1,49 @@
-include(ExternalProject)
+find_package(Threads REQUIRED)
-if(MSVC)
- # MS Visual Studio expects lib prefix on static libraries,
- # but CMake compiles them without prefix
- # See https://gitlab.kitware.com/cmake/cmake/issues/17338
- set(CMAKE_STATIC_LIBRARY_PREFIX "")
-endif()
-
-ExternalProject_Add(
- googletest_project
- SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/gtest-1.8.0"
- INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/prefix"
- CMAKE_ARGS
- -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
- -DBUILD_GMOCK=ON
- -Dgtest_force_shared_crt=ON
-)
-
-add_library(gmock UNKNOWN IMPORTED)
-set_target_properties(gmock PROPERTIES
- IMPORTED_LOCATION
- ${PROJECT_BINARY_DIR}/test/prefix/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gmock${CMAKE_STATIC_LIBRARY_SUFFIX}
-)
+set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
+set(BUILD_MOCK ON CACHE BOOL "" FORCE)
+set(CMAKE_POLICY_DEFAULT_CMP0048 NEW)
-find_package(Threads)
+add_subdirectory(
+ "${CMAKE_CURRENT_SOURCE_DIR}/gtest-1.10.0"
+ "${CMAKE_CURRENT_BINARY_DIR}/prefix")
-include_directories(SYSTEM "${PROJECT_BINARY_DIR}/test/prefix/include")
+include_directories(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/gtest-1.10.0/googletest/include")
-if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
- CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- set(yaml_test_flags "-Wno-variadic-macros -Wno-sign-compare")
-
- if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- set(yaml_test_flags "${yaml_test_flags} -Wno-c99-extensions")
- endif()
+set(test-new-api-pattern "new-api/*.cpp")
+set(test-source-pattern "*.cpp" "integration/*.cpp" "node/*.cpp")
+if (CMAKE_VERSION VERSION_GREATER 3.11)
+ list(INSERT test-new-api-pattern 0 CONFIGURE_DEPENDS)
+ list(INSERT test-source-pattern 0 CONFIGURE_DEPENDS)
endif()
-file(GLOB test_headers [a-z_]*.h)
-file(GLOB test_sources [a-z_]*.cpp integration/[a-z_]*.cpp node/[a-z_]*.cpp)
-file(GLOB test_new_api_sources new-api/[a-z]*.cpp)
-
-list(APPEND test_sources ${test_new_api_sources})
-add_sources(${test_sources} ${test_headers})
-
-include_directories(${YAML_CPP_SOURCE_DIR}/src)
-include_directories(${YAML_CPP_SOURCE_DIR}/test)
-
-add_executable(run-tests
- ${test_sources}
- ${test_headers}
-)
-
-set_target_properties(run-tests PROPERTIES
- CXX_STANDARD 11
- CXX_STANDARD_REQUIRED ON
-)
+file(GLOB test-new-api-sources ${test-new-api-pattern})
+file(GLOB test-sources ${test-source-pattern})
+
+add_executable(yaml-cpp-tests "")
+target_sources(yaml-cpp-tests
+ PRIVATE
+ ${test-new-api-sources}
+ ${test-sources})
+target_include_directories(yaml-cpp-tests
+ PRIVATE
+ ${CMAKE_CURRENT_SOURCE_DIR}/integration
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${PROJECT_SOURCE_DIR}/src)
+target_compile_options(yaml-cpp-tests
+ PRIVATE
+ $<$<CXX_COMPILER_ID:Clang>:-Wno-c99-extensions -Wno-variadic-macros -Wno-sign-compare>
+ $<$<CXX_COMPILER_ID:GNU>:-Wno-variadic-macros -Wno-sign-compare>)
+target_link_libraries(yaml-cpp-tests
+ PRIVATE
+ Threads::Threads
+ yaml-cpp
+ gmock)
-add_dependencies(run-tests googletest_project)
+set_property(TARGET yaml-cpp-tests PROPERTY CXX_STANDARD_REQUIRED ON)
+if (NOT DEFINED CMAKE_CXX_STANDARD)
+ set_target_properties(yaml-cpp-tests PROPERTIES CXX_STANDARD 11)
+endif()
-set_target_properties(run-tests PROPERTIES
- COMPILE_FLAGS "${yaml_c_flags} ${yaml_cxx_flags} ${yaml_test_flags}"
-)
-target_link_libraries(run-tests
- yaml-cpp
- gmock
- ${CMAKE_THREAD_LIBS_INIT})
-add_test(yaml-test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/run-tests)
+add_test(yaml-cpp::test yaml-cpp-tests)
diff --git a/lib/yamlcpp/test/create-emitter-tests.py b/lib/yamlcpp/test/create-emitter-tests.py
index e202522ce..eb753791e 100644
--- a/lib/yamlcpp/test/create-emitter-tests.py
+++ b/lib/yamlcpp/test/create-emitter-tests.py
@@ -134,6 +134,7 @@ def expand(template):
for cdr in expand(template[1:]):
yield car + cdr
+
def gen_events():
for template in gen_templates():
for events in expand(template):
diff --git a/lib/yamlcpp/test/integration/emitter_test.cpp b/lib/yamlcpp/test/integration/emitter_test.cpp
index 3a5783bff..0ddc67006 100644
--- a/lib/yamlcpp/test/integration/emitter_test.cpp
+++ b/lib/yamlcpp/test/integration/emitter_test.cpp
@@ -52,6 +52,63 @@ TEST_F(EmitterTest, SimpleQuotedScalar) {
ExpectEmit("test");
}
+TEST_F(EmitterTest, DumpAndSize) {
+ Node n(Load("test"));
+ EXPECT_EQ("test", Dump(n));
+ out << n;
+ EXPECT_EQ(4, out.size());
+}
+
+TEST_F(EmitterTest, NullScalar) {
+ Node n(Load("null"));
+ out << n;
+ ExpectEmit("~");
+}
+
+TEST_F(EmitterTest, AliasScalar) {
+ Node n(Load("[&a str, *a]"));
+ out << n;
+ ExpectEmit("[&1 str, *1]");
+}
+
+TEST_F(EmitterTest, StringFormat) {
+ out << BeginSeq;
+ out.SetStringFormat(SingleQuoted);
+ out << "string";
+ out.SetStringFormat(DoubleQuoted);
+ out << "string";
+ out.SetStringFormat(Literal);
+ out << "string";
+ out << EndSeq;
+
+ ExpectEmit("- 'string'\n- \"string\"\n- |\n string");
+}
+
+TEST_F(EmitterTest, IntBase) {
+ out << BeginSeq;
+ out.SetIntBase(Dec);
+ out << 1024;
+ out.SetIntBase(Hex);
+ out << 1024;
+ out.SetIntBase(Oct);
+ out << 1024;
+ out << EndSeq;
+
+ ExpectEmit("- 1024\n- 0x400\n- 02000");
+}
+
+TEST_F(EmitterTest, NumberPrecision) {
+ out.SetFloatPrecision(3);
+ out.SetDoublePrecision(2);
+ out << BeginSeq;
+ out << 3.1425926f;
+ out << 53.5893;
+ out << 2384626.4338;
+ out << EndSeq;
+
+ ExpectEmit("- 3.14\n- 54\n- 2.4e+06");
+}
+
TEST_F(EmitterTest, SimpleSeq) {
out << BeginSeq;
out << "eggs";
@@ -81,6 +138,56 @@ TEST_F(EmitterTest, EmptyFlowSeq) {
ExpectEmit("[]");
}
+TEST_F(EmitterTest, EmptyBlockSeqWithBegunContent) {
+ out << BeginSeq;
+ out << BeginSeq << Comment("comment") << EndSeq;
+ out << BeginSeq << Newline << EndSeq;
+ out << EndSeq;
+
+ ExpectEmit(R"(-
+# comment
+ []
+-
+
+ [])");
+}
+
+TEST_F(EmitterTest, EmptyBlockMapWithBegunContent) {
+ out << BeginSeq;
+ out << BeginMap << Comment("comment") << EndMap;
+ out << BeginMap << Newline << EndMap;
+ out << EndSeq;
+
+ ExpectEmit(R"(- # comment
+ {}
+-
+ {})");
+}
+
+TEST_F(EmitterTest, EmptyFlowSeqWithBegunContent) {
+ out << Flow;
+ out << BeginSeq;
+ out << BeginSeq << Comment("comment") << EndSeq;
+ out << BeginSeq << Newline << EndSeq;
+ out << EndSeq;
+
+ ExpectEmit(R"([[ # comment
+ ], [
+ ]])");
+}
+
+TEST_F(EmitterTest, EmptyFlowMapWithBegunContent) {
+ out << Flow;
+ out << BeginSeq;
+ out << BeginMap << Comment("comment") << EndMap;
+ out << BeginMap << Newline << EndMap;
+ out << EndSeq;
+
+ ExpectEmit(R"([{ # comment
+ }, {
+ }])");
+}
+
TEST_F(EmitterTest, NestedBlockSeq) {
out << BeginSeq;
out << "item 1";
@@ -209,6 +316,8 @@ TEST_F(EmitterTest, SimpleLongKey) {
}
TEST_F(EmitterTest, SingleLongKey) {
+ const std::string shortKey(1024, 'a');
+ const std::string longKey(1025, 'a');
out << BeginMap;
out << Key << "age";
out << Value << "24";
@@ -216,9 +325,14 @@ TEST_F(EmitterTest, SingleLongKey) {
out << Value << "5'9\"";
out << Key << "weight";
out << Value << 145;
+ out << Key << shortKey;
+ out << Value << "1";
+ out << Key << longKey;
+ out << Value << "1";
out << EndMap;
- ExpectEmit("age: 24\n? height\n: 5'9\"\nweight: 145");
+ ExpectEmit("age: 24\n? height\n: 5'9\"\nweight: 145\n" + shortKey +
+ ": 1\n? " + longKey + "\n: 1");
}
TEST_F(EmitterTest, ComplexLongKey) {
@@ -268,6 +382,20 @@ TEST_F(EmitterTest, ScalarFormat) {
"crazy\tsymbols that we like");
}
+TEST_F(EmitterTest, LiteralWithoutTrailingSpaces) {
+ out << YAML::BeginMap;
+ out << YAML::Key << "key";
+ out << YAML::Value << YAML::Literal;
+ out << "expect that with two newlines\n\n"
+ "no spaces are emitted in the empty line";
+ out << YAML::EndMap;
+
+ ExpectEmit(
+ "key: |\n"
+ " expect that with two newlines\n\n"
+ " no spaces are emitted in the empty line");
+}
+
TEST_F(EmitterTest, AutoLongKeyScalar) {
out << BeginMap;
out << Key << Literal << "multi-line\nscalar";
@@ -316,6 +444,21 @@ TEST_F(EmitterTest, AliasAndAnchor) {
ExpectEmit("- &fred\n name: Fred\n age: 42\n- *fred");
}
+TEST_F(EmitterTest, AliasOnKey) {
+ out << BeginSeq;
+ out << Anchor("name") << "Name";
+ out << BeginMap;
+ out << Key << Alias("name") << Value << "Fred";
+ out << EndMap;
+ out << Flow << BeginMap;
+ out << Key << Alias("name") << Value << "Mike";
+ out << EndMap;
+ out << EndSeq;
+ ExpectEmit(R"(- &name Name
+- *name : Fred
+- {*name : Mike})");
+}
+
TEST_F(EmitterTest, AliasAndAnchorWithNull) {
out << BeginSeq;
out << Anchor("fred") << Null;
@@ -429,6 +572,12 @@ TEST_F(EmitterTest, ByKindTagWithScalar) {
ExpectEmit("- \"12\"\n- 12\n- ! 12");
}
+TEST_F(EmitterTest, LocalTagInNameHandle) {
+ out << LocalTag("a", "foo") << "bar";
+
+ ExpectEmit("!a!foo bar");
+}
+
TEST_F(EmitterTest, LocalTagWithScalar) {
out << LocalTag("foo") << "bar";
@@ -516,6 +665,17 @@ TEST_F(EmitterTest, STLContainers) {
ExpectEmit("- [2, 3, 5, 7, 11, 13]\n- Daniel: 26\n Jesse: 24");
}
+TEST_F(EmitterTest, CommentStyle) {
+ out.SetPreCommentIndent(1);
+ out.SetPostCommentIndent(2);
+ out << BeginMap;
+ out << Key << "method";
+ out << Value << "least squares" << Comment("should we change this method?");
+ out << EndMap;
+
+ ExpectEmit("method: least squares # should we change this method?");
+}
+
TEST_F(EmitterTest, SimpleComment) {
out << BeginMap;
out << Key << "method";
@@ -612,6 +772,77 @@ TEST_F(EmitterTest, SimpleGlobalSettings) {
ExpectEmit("- ? key 1\n : value 1\n ? key 2\n : [a, b, c]");
}
+TEST_F(EmitterTest, GlobalLongKeyOnSeq) {
+ out.SetMapFormat(LongKey);
+
+ out << BeginMap;
+ out << Key << Anchor("key");
+ out << BeginSeq << "a"
+ << "b" << EndSeq;
+ out << Value << Anchor("value");
+ out << BeginSeq << "c"
+ << "d" << EndSeq;
+ out << Key << Alias("key") << Value << Alias("value");
+ out << EndMap;
+
+ ExpectEmit(R"(? &key
+ - a
+ - b
+: &value
+ - c
+ - d
+? *key
+: *value)");
+}
+
+TEST_F(EmitterTest, GlobalLongKeyOnMap) {
+ out.SetMapFormat(LongKey);
+
+ out << BeginMap;
+ out << Key << Anchor("key");
+ out << BeginMap << "a"
+ << "b" << EndMap;
+ out << Value << Anchor("value");
+ out << BeginMap << "c"
+ << "d" << EndMap;
+ out << Key << Alias("key") << Value << Alias("value");
+ out << EndMap;
+
+ ExpectEmit(R"(? &key
+ ? a
+ : b
+: &value
+ ? c
+ : d
+? *key
+: *value)");
+}
+
+TEST_F(EmitterTest, GlobalSettingStyleOnSeqNode) {
+ Node n(Load(R"(foo:
+ - 1
+ - 2
+ - 3
+bar: aa)"));
+ out.SetSeqFormat(YAML::Flow);
+ out << n;
+ ExpectEmit(R"(foo: [1, 2, 3]
+bar: aa)");
+}
+
+TEST_F(EmitterTest, GlobalSettingStyleOnMapNode) {
+ Node n(Load(R"(-
+ foo: a
+ bar: b
+- 2
+- 3)"));
+ out.SetMapFormat(YAML::Flow);
+ out << n;
+ ExpectEmit(R"(- {foo: a, bar: b}
+- 2
+- 3)");
+}
+
TEST_F(EmitterTest, ComplexGlobalSettings) {
out << BeginSeq;
out << Block;
@@ -644,6 +875,17 @@ TEST_F(EmitterTest, Null) {
ExpectEmit("- ~\n- null value: ~\n ~: null key");
}
+TEST_F(EmitterTest, OutputCharset) {
+ out << BeginSeq;
+ out.SetOutputCharset(EmitNonAscii);
+ out << "\x24 \xC2\xA2 \xE2\x82\xAC";
+ out.SetOutputCharset(EscapeNonAscii);
+ out << "\x24 \xC2\xA2 \xE2\x82\xAC";
+ out << EndSeq;
+
+ ExpectEmit("- \x24 \xC2\xA2 \xE2\x82\xAC\n- \"\x24 \\xa2 \\u20ac\"");
+}
+
TEST_F(EmitterTest, EscapedUnicode) {
out << EscapeNonAscii << "\x24 \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2";
@@ -660,6 +902,47 @@ TEST_F(EmitterTest, DoubleQuotedUnicode) {
ExpectEmit("\"\x24 \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2\"");
}
+TEST_F(EmitterTest, EscapedJsonString) {
+ out.SetStringFormat(DoubleQuoted);
+ out.SetOutputCharset(EscapeAsJson);
+ out << "\" \\ "
+ "\x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0A \x0B \x0C \x0D \x0E \x0F "
+ "\x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1F "
+ "\x24 \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2";
+
+ ExpectEmit(R"("\" \\ \u0001 \u0002 \u0003 \u0004 \u0005 \u0006 \u0007 \b \t )"
+ R"(\n \u000b \f \r \u000e \u000f \u0010 \u0011 \u0012 \u0013 )"
+ R"(\u0014 \u0015 \u0016 \u0017 \u0018 \u0019 \u001a \u001b )"
+ R"(\u001c \u001d \u001e \u001f )"
+ "$ \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2\"");
+}
+
+TEST_F(EmitterTest, EscapedCharacters) {
+ out << BeginSeq
+ << '\x00'
+ << '\x0C'
+ << '\x0D'
+ << EndSeq;
+
+ ExpectEmit("- \"\\x00\"\n- \"\\f\"\n- \"\\r\"");
+}
+
+TEST_F(EmitterTest, CharactersEscapedAsJson) {
+ out.SetOutputCharset(EscapeAsJson);
+ out << BeginSeq
+ << '\x00'
+ << '\x0C'
+ << '\x0D'
+ << EndSeq;
+
+ ExpectEmit("- \"\\u0000\"\n- \"\\f\"\n- \"\\r\"");
+}
+
+TEST_F(EmitterTest, DoubleQuotedString) {
+ out << DoubleQuoted << "\" \\ \n \t \r \b \x15 \xEF\xBB\xBF \x24";
+ ExpectEmit("\"\\\" \\\\ \\n \\t \\r \\b \\x15 \\ufeff $\"");
+}
+
struct Foo {
Foo() : x(0) {}
Foo(int x_, const std::string& bar_) : x(x_), bar(bar_) {}
@@ -826,6 +1109,57 @@ TEST_F(EmitterTest, ColonAtEndOfScalarInFlow) {
ExpectEmit("{\"C:\": \"C:\"}");
}
+TEST_F(EmitterTest, GlobalBoolFormatting) {
+ out << BeginSeq;
+ out.SetBoolFormat(UpperCase);
+ out.SetBoolFormat(YesNoBool);
+ out << true;
+ out << false;
+ out.SetBoolFormat(TrueFalseBool);
+ out << true;
+ out << false;
+ out.SetBoolFormat(OnOffBool);
+ out << true;
+ out << false;
+ out.SetBoolFormat(LowerCase);
+ out.SetBoolFormat(YesNoBool);
+ out << true;
+ out << false;
+ out.SetBoolFormat(TrueFalseBool);
+ out << true;
+ out << false;
+ out.SetBoolFormat(OnOffBool);
+ out << true;
+ out << false;
+ out.SetBoolFormat(CamelCase);
+ out.SetBoolFormat(YesNoBool);
+ out << true;
+ out << false;
+ out.SetBoolFormat(TrueFalseBool);
+ out << true;
+ out << false;
+ out.SetBoolFormat(OnOffBool);
+ out << true;
+ out << false;
+ out.SetBoolFormat(ShortBool);
+ out.SetBoolFormat(UpperCase);
+ out.SetBoolFormat(YesNoBool);
+ out << true;
+ out << false;
+ out.SetBoolFormat(TrueFalseBool);
+ out << true;
+ out << false;
+ out.SetBoolFormat(OnOffBool);
+ out << true;
+ out << false;
+ out << EndSeq;
+ ExpectEmit(
+ "- YES\n- NO\n- TRUE\n- FALSE\n- ON\n- OFF\n"
+ "- yes\n- no\n- true\n- false\n- on\n- off\n"
+ "- Yes\n- No\n- True\n- False\n- On\n- Off\n"
+ "- Y\n- N\n- Y\n- N\n- Y\n- N");
+}
+
TEST_F(EmitterTest, BoolFormatting) {
out << BeginSeq;
out << TrueFalseBool << UpperCase << true;
@@ -860,6 +1194,45 @@ TEST_F(EmitterTest, BoolFormatting) {
"- Y\n- Y\n- y\n- N\n- N\n- n");
}
+TEST_F(EmitterTest, GlobalNullFormatting) {
+ out << Flow << BeginSeq;
+ out.SetNullFormat(LowerNull);
+ out << Null;
+ out.SetNullFormat(UpperNull);
+ out << Null;
+ out.SetNullFormat(CamelNull);
+ out << Null;
+ out.SetNullFormat(TildeNull);
+ out << Null;
+ out << EndSeq;
+ ExpectEmit("[null, NULL, Null, ~]");
+}
+
+TEST_F(EmitterTest, NullFormatting) {
+ out << Flow << BeginSeq;
+ out << LowerNull << Null;
+ out << UpperNull << Null;
+ out << CamelNull << Null;
+ out << TildeNull << Null;
+ out << EndSeq;
+ ExpectEmit("[null, NULL, Null, ~]");
+}
+
+TEST_F(EmitterTest, NullFormattingOnNode) {
+ Node n(Load("null"));
+ out << Flow << BeginSeq;
+ out.SetNullFormat(LowerNull);
+ out << n;
+ out.SetNullFormat(UpperNull);
+ out << n;
+ out.SetNullFormat(CamelNull);
+ out << n;
+ out.SetNullFormat(TildeNull);
+ out << n;
+ out << EndSeq;
+ ExpectEmit("[null, NULL, Null, ~]");
+}
+
// TODO: Fix this test.
// TEST_F(EmitterTest, DocStartAndEnd) {
// out << BeginDoc;
@@ -1025,6 +1398,224 @@ TEST_F(EmitterTest, NaN) {
"bar: .nan");
}
+TEST_F(EmitterTest, ComplexFlowSeqEmbeddingAMapWithNewLine) {
+ out << YAML::BeginMap;
+
+ out << YAML::Key << "NodeA" << YAML::Value << YAML::BeginMap;
+ out << YAML::Key << "k" << YAML::Value << YAML::Flow << YAML::BeginSeq;
+ out << YAML::BeginMap << YAML::Key << "i" << YAML::Value << 0 << YAML::EndMap
+ << YAML::Newline;
+ out << YAML::BeginMap << YAML::Key << "i" << YAML::Value << 1 << YAML::EndMap
+ << YAML::Newline;
+ out << YAML::EndSeq;
+ out << YAML::EndMap;
+
+ out << YAML::Key << "NodeB" << YAML::Value << YAML::BeginMap;
+ out << YAML::Key << "k" << YAML::Value << YAML::Flow << YAML::BeginSeq;
+ out << YAML::BeginMap << YAML::Key << "i" << YAML::Value << 0 << YAML::EndMap
+ << YAML::Newline;
+ out << YAML::BeginMap << YAML::Key << "i" << YAML::Value << 1 << YAML::EndMap
+ << YAML::Newline;
+ out << YAML::EndSeq;
+ out << YAML::EndMap;
+
+ out << YAML::EndMap;
+
+ ExpectEmit(R"(NodeA:
+ k: [{i: 0},
+ {i: 1},
+ ]
+NodeB:
+ k: [{i: 0},
+ {i: 1},
+ ])");
+}
+
+TEST_F(EmitterTest, ComplexFlowSeqEmbeddingAMapWithNewLineUsingAliases) {
+ out << BeginMap;
+
+ out << Key << "Node" << Anchor("Node") << Value << BeginMap;
+ out << Key << "k" << Value << Flow << BeginSeq;
+ out << BeginMap << Key << "i" << Value << 0 << EndMap;
+ out << YAML::Newline;
+ out << BeginMap << Key << "i" << Value << 1 << EndMap;
+ out << YAML::Newline;
+ out << EndSeq << EndMap;
+
+ out << Key << "NodeA" << Alias("Node");
+ out << Key << "NodeB" << Alias("Node");
+
+ out << EndMap;
+
+ ExpectEmit(R"(Node: &Node
+ k: [{i: 0},
+ {i: 1},
+ ]
+NodeA: *Node
+NodeB: *Node)");
+}
+
+TEST_F(EmitterTest, ComplexFlowSeqEmbeddingAMapUsingAliases) {
+ out << BeginMap;
+
+ out << Key << "Node" << Anchor("Node") << Value << BeginMap;
+ out << Key << "k" << Value << Flow << BeginSeq;
+ out << BeginMap << Key << "i" << Value << 0 << EndMap;
+ out << BeginMap << Key << "i" << Value << 1 << EndMap;
+ out << EndSeq << EndMap;
+
+ out << Key << "NodeA" << Alias("Node");
+ out << Key << "NodeB" << Alias("Node");
+
+ out << EndMap;
+
+ ExpectEmit(R"(Node: &Node
+ k: [{i: 0}, {i: 1}]
+NodeA: *Node
+NodeB: *Node)");
+}
+
+TEST_F(EmitterTest, ComplexFlowSeqEmbeddingAMapWithNewLineUsingAliases2) {
+ out << BeginMap;
+
+ out << Key << "Seq" << Anchor("Seq") << Flow << BeginSeq;
+ out << BeginMap << Key << "i" << Value << 0 << EndMap;
+ out << YAML::Newline;
+ out << BeginMap << Key << "i" << Value << 1 << EndMap;
+ out << YAML::Newline;
+ out << EndSeq;
+
+ out << Key << "NodeA" << Value << BeginMap;
+ out << Key << "k" << Value << Alias("Seq") << EndMap;
+ out << Key << "NodeB" << Value << BeginMap;
+ out << Key << "k" << Value << Alias("Seq") << EndMap;
+
+ out << EndMap;
+
+ ExpectEmit(R"(Seq: &Seq [{i: 0},
+ {i: 1},
+ ]
+NodeA:
+ k: *Seq
+NodeB:
+ k: *Seq)");
+}
+
+TEST_F(EmitterTest, ComplexFlowSeqEmbeddingAMapUsingAliases2) {
+ out << BeginMap;
+
+ out << Key << "Seq" << Anchor("Seq") << Value << Flow << BeginSeq;
+ out << BeginMap << Key << "i" << Value << 0 << EndMap;
+ out << BeginMap << Key << "i" << Value << 1 << EndMap;
+ out << EndSeq;
+
+ out << Key << "NodeA" << Value << BeginMap;
+ out << Key << "k" << Value << Alias("Seq") << EndMap;
+ out << Key << "NodeB" << Value << BeginMap;
+ out << Key << "k" << Value << Alias("Seq") << EndMap;
+
+ out << EndMap;
+
+ ExpectEmit(R"(Seq: &Seq [{i: 0}, {i: 1}]
+NodeA:
+ k: *Seq
+NodeB:
+ k: *Seq)");
+}
+
+TEST_F(EmitterTest, ComplexFlowSeqEmbeddingAMapWithNewLineUsingAliases3) {
+ out << BeginMap;
+
+ out << Key << "Keys" << Value << Flow << BeginSeq;
+ out << Anchor("k0") << BeginMap << Key << "i" << Value << 0 << EndMap
+ << Newline;
+ out << Anchor("k1") << BeginMap << Key << "i" << Value << 1 << EndMap
+ << Newline;
+ out << EndSeq;
+
+ out << Key << "NodeA" << Value << BeginMap;
+ out << Key << "k" << Value << Flow << BeginSeq;
+ out << Alias("k0") << Newline << Alias("k1") << Newline;
+ out << EndSeq << EndMap;
+
+ out << Key << "NodeB" << Value << BeginMap;
+ out << Key << "k" << Value << Flow << BeginSeq;
+ out << Alias("k0") << Newline << Alias("k1") << Newline;
+ out << EndSeq << EndMap;
+
+ out << EndMap;
+
+ ExpectEmit(R"(Keys: [&k0 {i: 0},
+&k1 {i: 1},
+ ]
+NodeA:
+ k: [*k0,
+ *k1,
+ ]
+NodeB:
+ k: [*k0,
+ *k1,
+ ])");
+}
+
+TEST_F(EmitterTest, ComplexFlowSeqEmbeddingAMapUsingAliases3a) {
+ out << BeginMap;
+
+ out << Key << "Keys" << Value << BeginSeq;
+ out << Anchor("k0") << BeginMap << Key << "i" << Value << 0 << EndMap;
+ out << Anchor("k1") << BeginMap << Key << "i" << Value << 1 << EndMap;
+ out << EndSeq;
+
+ out << Key << "NodeA" << Value << BeginMap;
+ out << Key << "k" << Value << Flow << BeginSeq;
+ out << Alias("k0") << Alias("k1");
+ out << EndSeq << EndMap;
+
+ out << Key << "NodeB" << Value << BeginMap;
+ out << Key << "k" << Value << Flow << BeginSeq;
+ out << Alias("k0") << Alias("k1");
+ out << EndSeq << EndMap;
+
+ out << EndMap;
+
+ ExpectEmit(R"(Keys:
+ - &k0
+ i: 0
+ - &k1
+ i: 1
+NodeA:
+ k: [*k0, *k1]
+NodeB:
+ k: [*k0, *k1])");
+}
+
+TEST_F(EmitterTest, ComplexFlowSeqEmbeddingAMapUsingAliases3b) {
+ out << BeginMap;
+
+ out << Key << "Keys" << Value << Flow << BeginSeq;
+ out << Anchor("k0") << BeginMap << Key << "i" << Value << 0 << EndMap;
+ out << Anchor("k1") << BeginMap << Key << "i" << Value << 1 << EndMap;
+ out << EndSeq;
+
+ out << Key << "NodeA" << Value << BeginMap;
+ out << Key << "k" << Value << Flow << BeginSeq;
+ out << Alias("k0") << Alias("k1");
+ out << EndSeq << EndMap;
+
+ out << Key << "NodeB" << Value << BeginMap;
+ out << Key << "k" << Value << Flow << BeginSeq;
+ out << Alias("k0") << Alias("k1");
+ out << EndSeq << EndMap;
+
+ out << EndMap;
+
+ ExpectEmit(R"(Keys: [&k0 {i: 0}, &k1 {i: 1}]
+NodeA:
+ k: [*k0, *k1]
+NodeB:
+ k: [*k0, *k1])");
+}
+
class EmitterErrorTest : public ::testing::Test {
protected:
void ExpectEmitError(const std::string& expectedError) {
@@ -1041,6 +1632,26 @@ TEST_F(EmitterErrorTest, BadLocalTag) {
ExpectEmitError("invalid tag");
}
+TEST_F(EmitterErrorTest, BadTagAndTag) {
+ out << VerbatimTag("!far") << VerbatimTag("!foo") << "bar";
+ ExpectEmitError(ErrorMsg::INVALID_TAG);
+}
+
+TEST_F(EmitterErrorTest, BadAnchorAndAnchor) {
+ out << Anchor("far") << Anchor("foo") << "bar";
+ ExpectEmitError(ErrorMsg::INVALID_ANCHOR);
+}
+
+TEST_F(EmitterErrorTest, BadEmptyAnchorOnGroup) {
+ out << BeginSeq << "bar" << Anchor("foo") << EndSeq;
+ ExpectEmitError(ErrorMsg::INVALID_ANCHOR);
+}
+
+TEST_F(EmitterErrorTest, BadEmptyTagOnGroup) {
+ out << BeginSeq << "bar" << VerbatimTag("!foo") << EndSeq;
+ ExpectEmitError(ErrorMsg::INVALID_TAG);
+}
+
TEST_F(EmitterErrorTest, ExtraEndSeq) {
out << BeginSeq;
out << "Hello";
diff --git a/lib/yamlcpp/test/integration/error_messages_test.cpp b/lib/yamlcpp/test/integration/error_messages_test.cpp
index ea921ce36..16d51c710 100644
--- a/lib/yamlcpp/test/integration/error_messages_test.cpp
+++ b/lib/yamlcpp/test/integration/error_messages_test.cpp
@@ -6,7 +6,7 @@
ASSERT_THROW(statement, exception_type); \
try { \
statement; \
- } catch (const exception_type &e) { \
+ } catch (const exception_type& e) { \
EXPECT_EQ(e.msg, message); \
}
@@ -14,10 +14,9 @@ namespace YAML {
namespace {
TEST(ErrorMessageTest, BadSubscriptErrorMessage) {
- const char *example_yaml =
- "first:\n"
- " second: 1\n"
- " third: 2\n";
+ const char *example_yaml = "first:\n"
+ " second: 1\n"
+ " third: 2\n";
Node doc = Load(example_yaml);
@@ -28,6 +27,7 @@ TEST(ErrorMessageTest, BadSubscriptErrorMessage) {
EXPECT_THROW_EXCEPTION(YAML::BadSubscript, doc["first"]["second"][37],
"operator[] call on a scalar (key: \"37\")");
+
// Non-printable key is not included in error message
EXPECT_THROW_EXCEPTION(YAML::BadSubscript,
doc["first"]["second"][std::vector<int>()],
@@ -38,10 +38,9 @@ TEST(ErrorMessageTest, BadSubscriptErrorMessage) {
}
TEST(ErrorMessageTest, Ex9_1_InvalidNodeErrorMessage) {
- const char *example_yaml =
- "first:\n"
- " second: 1\n"
- " third: 2\n";
+ const char *example_yaml = "first:\n"
+ " second: 1\n"
+ " third: 2\n";
const Node doc = Load(example_yaml);
@@ -58,5 +57,5 @@ TEST(ErrorMessageTest, Ex9_1_InvalidNodeErrorMessage) {
"invalid node; this may result from using a map "
"iterator as a sequence iterator, or vice-versa");
}
-} // namespace
-} // namespace YAML
+}
+}
diff --git a/lib/yamlcpp/test/integration/handler_spec_test.cpp b/lib/yamlcpp/test/integration/handler_spec_test.cpp
index fcb76d583..8cba9023d 100644
--- a/lib/yamlcpp/test/integration/handler_spec_test.cpp
+++ b/lib/yamlcpp/test/integration/handler_spec_test.cpp
@@ -347,7 +347,72 @@ TEST_F(HandlerSpecTest, Ex2_18_MultiLineFlowScalars) {
Parse(ex2_18);
}
-// TODO: 2.19 - 2.22 schema tags
+TEST_F(HandlerSpecTest, Ex2_19_Integers) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "canonical"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "12345"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "decimal"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "+12345"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "octal"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "0o14"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "hexadecimal"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "0xC"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_19);
+}
+
+TEST_F(HandlerSpecTest, Ex2_20_FloatingPoint) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "canonical"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "1.23015e+3"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "exponential"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "12.3015e+02"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "fixed"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "1230.15"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "negative infinity"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "-.inf"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "not a number"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, ".NaN"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_20);
+}
+
+TEST_F(HandlerSpecTest, Ex2_21_Miscellaneous) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnNull(_, 0));
+ EXPECT_CALL(handler, OnNull(_, 0));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "booleans"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "true"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "false"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "string"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "012345"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_21);
+}
+
+TEST_F(HandlerSpecTest, Ex2_22_Timestamps) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "canonical"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "2001-12-15T02:59:43.1Z"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "iso8601"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "2001-12-14t21:59:43.10-05:00"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "spaced"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "2001-12-14 21:59:43.10 -5"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "date"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "2002-12-14"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_22);
+}
TEST_F(HandlerSpecTest, Ex2_23_VariousExplicitTags) {
EXPECT_CALL(handler, OnDocumentStart(_));
diff --git a/lib/yamlcpp/test/integration/load_node_test.cpp b/lib/yamlcpp/test/integration/load_node_test.cpp
index 8ed3b0c39..958e73512 100644
--- a/lib/yamlcpp/test/integration/load_node_test.cpp
+++ b/lib/yamlcpp/test/integration/load_node_test.cpp
@@ -7,6 +7,7 @@ namespace {
TEST(LoadNodeTest, Reassign) {
Node node = Load("foo");
node = Node();
+ EXPECT_TRUE(node.IsNull());
}
TEST(LoadNodeTest, FallbackValues) {
@@ -20,17 +21,35 @@ TEST(LoadNodeTest, FallbackValues) {
}
TEST(LoadNodeTest, NumericConversion) {
- Node node = Load("[1.5, 1, .nan, .inf, -.inf, 0x15, 015]");
- EXPECT_EQ(1.5f, node[0].as<float>());
- EXPECT_EQ(1.5, node[0].as<double>());
- EXPECT_THROW(node[0].as<int>(), TypedBadConversion<int>);
- EXPECT_EQ(1, node[1].as<int>());
- EXPECT_EQ(1.0f, node[1].as<float>());
- EXPECT_NE(node[2].as<float>(), node[2].as<float>());
- EXPECT_EQ(std::numeric_limits<float>::infinity(), node[3].as<float>());
- EXPECT_EQ(-std::numeric_limits<float>::infinity(), node[4].as<float>());
- EXPECT_EQ(21, node[5].as<int>());
- EXPECT_EQ(13, node[6].as<int>());
+ EXPECT_EQ(1.5f, Load("1.5").as<float>());
+ EXPECT_EQ(1.5, Load("1.5").as<double>());
+ EXPECT_THROW(Load("1.5").as<int>(), TypedBadConversion<int>);
+ EXPECT_EQ(1, Load("1").as<int>());
+ EXPECT_EQ(1.0f, Load("1").as<float>());
+ EXPECT_NE(Load(".nan").as<float>(), Load(".nan").as<float>());
+ EXPECT_EQ(std::numeric_limits<float>::infinity(), Load(".inf").as<float>());
+ EXPECT_EQ(-std::numeric_limits<float>::infinity(), Load("-.inf").as<float>());
+ EXPECT_EQ(21, Load("0x15").as<int>());
+ EXPECT_EQ(13, Load("015").as<int>());
+ EXPECT_EQ(-128, +Load("-128").as<int8_t>());
+ EXPECT_EQ(127, +Load("127").as<int8_t>());
+ EXPECT_THROW(Load("128").as<int8_t>(), TypedBadConversion<signed char>);
+ EXPECT_EQ(255, +Load("255").as<uint8_t>());
+ EXPECT_THROW(Load("256").as<uint8_t>(), TypedBadConversion<unsigned char>);
+ // test as<char>/as<uint8_t> with ‘a’,"ab",'1',"127"
+ EXPECT_EQ('a', Load("a").as<char>());
+ EXPECT_THROW(Load("ab").as<char>(), TypedBadConversion<char>);
+ EXPECT_EQ('1', Load("1").as<char>());
+ EXPECT_THROW(Load("127").as<char>(), TypedBadConversion<char>);
+ EXPECT_THROW(Load("a").as<uint8_t>(), TypedBadConversion<unsigned char>);
+ EXPECT_THROW(Load("ab").as<uint8_t>(), TypedBadConversion<unsigned char>);
+ EXPECT_EQ(1, +Load("1").as<uint8_t>());
+ // Throw exception: convert a negative number to an unsigned number.
+ EXPECT_THROW(Load("-128").as<unsigned>(), TypedBadConversion<unsigned int>);
+ EXPECT_THROW(Load("-128").as<unsigned short>(), TypedBadConversion<unsigned short>);
+ EXPECT_THROW(Load("-128").as<unsigned long>(), TypedBadConversion<unsigned long>);
+ EXPECT_THROW(Load("-128").as<unsigned long long>(), TypedBadConversion<unsigned long long>);
+ EXPECT_THROW(Load("-128").as<uint8_t>(), TypedBadConversion<unsigned char>);
}
TEST(LoadNodeTest, Binary) {
@@ -58,20 +77,11 @@ TEST(LoadNodeTest, Binary) {
TEST(LoadNodeTest, BinaryWithWhitespaces) {
Node node = Load(
"binaryText: !binary |-\n"
- " "
- "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieS\n"
- " "
- "B0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIG"
- "\n"
- " "
- "x1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbi"
- "\n"
- " "
- "B0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZG"
- "\n"
- " "
- "dlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS"
- "\n"
+ " TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieS\n"
+ " B0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIG\n"
+ " x1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbi\n"
+ " B0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZG\n"
+ " dlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS\n"
" 4K");
EXPECT_EQ(Binary(reinterpret_cast<const unsigned char*>(
"Man is distinguished, not only by his reason, "
@@ -237,13 +247,64 @@ struct ParserExceptionTestCase {
TEST(NodeTest, IncompleteJson) {
std::vector<ParserExceptionTestCase> tests = {
{"JSON map without value", "{\"access\"", ErrorMsg::END_OF_MAP_FLOW},
- {"JSON map with colon but no value",
- "{\"access\":", ErrorMsg::END_OF_MAP_FLOW},
+ {"JSON map with colon but no value", "{\"access\":",
+ ErrorMsg::END_OF_MAP_FLOW},
{"JSON map with unclosed value quote", "{\"access\":\"",
ErrorMsg::END_OF_MAP_FLOW},
{"JSON map without end brace", "{\"access\":\"abc\"",
ErrorMsg::END_OF_MAP_FLOW},
};
+ for (const ParserExceptionTestCase& test : tests) {
+ try {
+ Load(test.input);
+ FAIL() << "Expected exception " << test.expected_exception << " for "
+ << test.name << ", input: " << test.input;
+ } catch (const ParserException& e) {
+ EXPECT_EQ(test.expected_exception, e.msg);
+ }
+ }
+}
+
+struct SingleNodeTestCase {
+ std::string input;
+ NodeType::value nodeType;
+ int nodeSize;
+ std::string expected_content;
+};
+
+TEST(NodeTest, SpecialFlow) {
+ std::vector<SingleNodeTestCase> tests = {
+ {"[:]", NodeType::Sequence, 1, "[{~: ~}]"},
+ {"[a:]", NodeType::Sequence, 1, "[{a: ~}]"},
+ {"[:a]", NodeType::Sequence, 1, "[:a]"},
+ {"[,]", NodeType::Sequence, 1, "[~]"},
+ {"[a:,]", NodeType::Sequence, 1, "[{a: ~}]"},
+ {"{:}", NodeType::Map, 1, "{~: ~}"},
+ {"{a:}", NodeType::Map, 1, "{a: ~}"},
+ {"{:a}", NodeType::Map, 1, "{:a: ~}"},
+ {"{,}", NodeType::Map, 1, "{~: ~}"},
+ {"{a:,}", NodeType::Map, 1, "{a: ~}"},
+ //testcase for the trailing TAB of scalar
+ {"key\t: value\t", NodeType::Map, 1, "key: value"},
+ {"key\t: value\t #comment", NodeType::Map, 1, "key: value"},
+ {"{key\t: value\t}", NodeType::Map, 1, "{key: value}"},
+ {"{key\t: value\t #comment\n}", NodeType::Map, 1, "{key: value}"},
+ };
+ for (const SingleNodeTestCase& test : tests) {
+ Node node = Load(test.input);
+ Emitter emitter;
+ emitter << node;
+ EXPECT_EQ(test.nodeType, node.Type());
+ EXPECT_EQ(test.nodeSize, node.size());
+ EXPECT_EQ(test.expected_content, std::string(emitter.c_str()));
+ }
+}
+
+TEST(NodeTest, IncorrectFlow) {
+ std::vector<ParserExceptionTestCase> tests = {
+ {"Incorrect yaml: \"{:]\"", "{:]", ErrorMsg::FLOW_END},
+ {"Incorrect yaml: \"[:}\"", "[:}", ErrorMsg::FLOW_END},
+ };
for (const ParserExceptionTestCase test : tests) {
try {
Load(test.input);
@@ -258,12 +319,30 @@ TEST(NodeTest, IncompleteJson) {
TEST(NodeTest, LoadTildeAsNull) {
Node node = Load("~");
ASSERT_TRUE(node.IsNull());
+ EXPECT_EQ(node.as<std::string>(), "null");
+ EXPECT_EQ(node.as<std::string>("~"), "null");
+}
+
+TEST(NodeTest, LoadNullWithStrTag) {
+ Node node = Load("!!str null");
+ EXPECT_EQ(node.Tag(), "tag:yaml.org,2002:str");
+ EXPECT_EQ(node.as<std::string>(), "null");
+}
+
+TEST(NodeTest, LoadQuotedNull) {
+ Node node = Load("\"null\"");
+ EXPECT_EQ(node.as<std::string>(), "null");
}
TEST(NodeTest, LoadTagWithParenthesis) {
- Node node = Load("!Complex(Tag) foo");
- EXPECT_EQ(node.Tag(), "!Complex(Tag)");
- EXPECT_EQ(node.as<std::string>(), "foo");
+ Node node = Load("!Complex(Tag) foo");
+ EXPECT_EQ(node.Tag(), "!Complex(Tag)");
+ EXPECT_EQ(node.as<std::string>(), "foo");
+}
+
+TEST(NodeTest, LoadTagWithNullScalar) {
+ Node node = Load("!2");
+ EXPECT_TRUE(node.IsNull());
}
} // namespace
diff --git a/lib/yamlcpp/test/integration/node_spec_test.cpp b/lib/yamlcpp/test/integration/node_spec_test.cpp
index aedf38b2b..bfc8578a6 100644
--- a/lib/yamlcpp/test/integration/node_spec_test.cpp
+++ b/lib/yamlcpp/test/integration/node_spec_test.cpp
@@ -1127,5 +1127,10 @@ TEST(NodeSpecTest, Ex8_22_BlockCollectionNodes) {
EXPECT_EQ(1, doc["mapping"].size());
EXPECT_EQ("bar", doc["mapping"]["foo"].as<std::string>());
}
+
+TEST(NodeSpecTest, FlowMapNotClosed) {
+ EXPECT_THROW_PARSER_EXCEPTION(Load("{x:"), ErrorMsg::UNKNOWN_TOKEN);
+}
+
}
}
diff --git a/lib/yamlcpp/test/mock_event_handler.h b/lib/yamlcpp/test/mock_event_handler.h
index 2c1d15a4b..0b7e7da8e 100644
--- a/lib/yamlcpp/test/mock_event_handler.h
+++ b/lib/yamlcpp/test/mock_event_handler.h
@@ -1,8 +1,11 @@
#include "yaml-cpp/emitterstyle.h"
#include "yaml-cpp/eventhandler.h"
+#include "yaml-cpp/mark.h"
#include "gmock/gmock.h"
+#include <string>
+
namespace YAML {
class MockEventHandler : public EventHandler {
diff --git a/lib/yamlcpp/test/node/node_test.cpp b/lib/yamlcpp/test/node/node_test.cpp
index 18234dbde..4f577c846 100644
--- a/lib/yamlcpp/test/node/node_test.cpp
+++ b/lib/yamlcpp/test/node/node_test.cpp
@@ -9,6 +9,40 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
+#include <sstream>
+
+namespace {
+
+// malloc/free based allocator just for testing custom allocators on stl containers
+template <class T>
+class CustomAllocator : public std::allocator<T> {
+ public:
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef T value_type;
+ template<class U> struct rebind { typedef CustomAllocator<U> other; };
+ CustomAllocator() : std::allocator<T>() {}
+ CustomAllocator(const CustomAllocator& other) : std::allocator<T>(other) {}
+ template<class U> CustomAllocator(const CustomAllocator<U>& other) : std::allocator<T>(other) {}
+ ~CustomAllocator() {}
+ size_type max_size() const { return (std::numeric_limits<std::ptrdiff_t>::max)()/sizeof(T); }
+ pointer allocate(size_type num, const void* /*hint*/ = 0) {
+ if (num > std::size_t(-1) / sizeof(T)) throw std::bad_alloc();
+ return static_cast<pointer>(malloc(num * sizeof(T)));
+ }
+ void deallocate(pointer p, size_type /*num*/) { free(p); }
+};
+
+template <class T> using CustomVector = std::vector<T,CustomAllocator<T>>;
+template <class T> using CustomList = std::list<T,CustomAllocator<T>>;
+template <class K, class V, class C=std::less<K>> using CustomMap = std::map<K,V,C,CustomAllocator<std::pair<const K,V>>>;
+
+} // anonymous namespace
+
using ::testing::AnyOf;
using ::testing::Eq;
@@ -59,6 +93,44 @@ TEST(NodeTest, SequenceElementRemoval) {
EXPECT_EQ("c", node[1].as<std::string>());
}
+TEST(NodeTest, SequenceElementRemovalSizeCheck) {
+ Node node;
+ node[0] = "a";
+ node[1] = "b";
+ node[2] = "c";
+ EXPECT_EQ(3, node.size());
+ node.remove(1);
+ EXPECT_TRUE(node.IsSequence());
+ EXPECT_EQ(2, node.size());
+ EXPECT_EQ("a", node[0].as<std::string>());
+ EXPECT_EQ("c", node[1].as<std::string>());
+}
+
+TEST(NodeTest, SequenceFirstElementRemoval) {
+ Node node;
+ node[0] = "a";
+ node[1] = "b";
+ node[2] = "c";
+ node.remove(0);
+ EXPECT_TRUE(node.IsSequence());
+ EXPECT_EQ(2, node.size());
+ EXPECT_EQ("b", node[0].as<std::string>());
+ EXPECT_EQ("c", node[1].as<std::string>());
+}
+
+TEST(NodeTest, SequenceFirstElementRemovalSizeCheck) {
+ Node node;
+ node[0] = "a";
+ node[1] = "b";
+ node[2] = "c";
+ EXPECT_EQ(3, node.size());
+ node.remove(0);
+ EXPECT_TRUE(node.IsSequence());
+ EXPECT_EQ(2, node.size());
+ EXPECT_EQ("b", node[0].as<std::string>());
+ EXPECT_EQ("c", node[1].as<std::string>());
+}
+
TEST(NodeTest, SequenceLastElementRemoval) {
Node node;
node[0] = "a";
@@ -71,6 +143,46 @@ TEST(NodeTest, SequenceLastElementRemoval) {
EXPECT_EQ("b", node[1].as<std::string>());
}
+TEST(NodeTest, SequenceLastElementRemovalSizeCheck) {
+ Node node;
+ node[0] = "a";
+ node[1] = "b";
+ node[2] = "c";
+ EXPECT_EQ(3, node.size());
+ node.remove(2);
+ EXPECT_TRUE(node.IsSequence());
+ EXPECT_EQ(2, node.size());
+ EXPECT_EQ("a", node[0].as<std::string>());
+ EXPECT_EQ("b", node[1].as<std::string>());
+}
+
+TEST(NodeTest, NodeAssignment) {
+ Node node1;
+ Node node2;
+ node1[1] = 1;
+ node1[2] = 2;
+ node1[3] = 3;
+ node2 = node1;
+ EXPECT_EQ(node1, node2);
+ EXPECT_EQ(node1[1], node2[1]);
+ EXPECT_EQ(node1[2], node2[2]);
+ EXPECT_EQ(node1[3], node2[3]);
+}
+
+TEST(NodeTest, EqualRepresentationAfterMoveAssignment) {
+ Node node1;
+ Node node2;
+ std::ostringstream ss1, ss2;
+ node1["foo"] = "bar";
+ ss1 << node1;
+ node2["hello"] = "world";
+ node2 = std::move(node1);
+ ss2 << node2;
+ EXPECT_FALSE(node2["hello"]);
+ EXPECT_EQ("bar", node2["foo"].as<std::string>());
+ EXPECT_EQ(ss1.str(), ss2.str());
+}
+
TEST(NodeTest, MapElementRemoval) {
Node node;
node["foo"] = "bar";
@@ -253,6 +365,20 @@ TEST(NodeTest, StdVector) {
EXPECT_EQ(primes, node["primes"].as<std::vector<int>>());
}
+TEST(NodeTest, StdVectorWithCustomAllocator) {
+ CustomVector<int> primes;
+ primes.push_back(2);
+ primes.push_back(3);
+ primes.push_back(5);
+ primes.push_back(7);
+ primes.push_back(11);
+ primes.push_back(13);
+
+ Node node;
+ node["primes"] = primes;
+ EXPECT_EQ(primes, node["primes"].as<CustomVector<int>>());
+}
+
TEST(NodeTest, StdList) {
std::list<int> primes;
primes.push_back(2);
@@ -267,6 +393,20 @@ TEST(NodeTest, StdList) {
EXPECT_EQ(primes, node["primes"].as<std::list<int>>());
}
+TEST(NodeTest, StdListWithCustomAllocator) {
+ CustomList<int> primes;
+ primes.push_back(2);
+ primes.push_back(3);
+ primes.push_back(5);
+ primes.push_back(7);
+ primes.push_back(11);
+ primes.push_back(13);
+
+ Node node;
+ node["primes"] = primes;
+ EXPECT_EQ(primes, node["primes"].as<CustomList<int>>());
+}
+
TEST(NodeTest, StdMap) {
std::map<int, int> squares;
squares[0] = 0;
@@ -281,6 +421,20 @@ TEST(NodeTest, StdMap) {
EXPECT_EQ(squares, actualSquares);
}
+TEST(NodeTest, StdMapWithCustomAllocator) {
+ CustomMap<int,int> squares;
+ squares[0] = 0;
+ squares[1] = 1;
+ squares[2] = 4;
+ squares[3] = 9;
+ squares[4] = 16;
+
+ Node node;
+ node["squares"] = squares;
+ CustomMap<int,int> actualSquares = node["squares"].as<CustomMap<int,int>>();
+ EXPECT_EQ(squares, actualSquares);
+}
+
TEST(NodeTest, StdPair) {
std::pair<int, std::string> p;
p.first = 5;
@@ -397,12 +551,66 @@ TEST(NodeTest, FloatingPrecisionFloat) {
EXPECT_EQ(x, node.as<float>());
}
+TEST(NodeTest, FloatingPrecisionPositiveInfinityFloat) {
+ if (!std::numeric_limits<float>::has_infinity) {
+ return;
+ }
+ const float x = std::numeric_limits<float>::infinity();
+ Node node = Node(x);
+ EXPECT_EQ(x, node.as<float>());
+}
+
+TEST(NodeTest, FloatingPrecisionNegativeInfinityFloat) {
+ if (!std::numeric_limits<float>::has_infinity) {
+ return;
+ }
+ const float x = -std::numeric_limits<float>::infinity();
+ Node node = Node(x);
+ EXPECT_EQ(x, node.as<float>());
+}
+
+TEST(NodeTest, FloatingPrecisionNanFloat) {
+ if (!std::numeric_limits<float>::has_quiet_NaN) {
+ return;
+ }
+ const float x = std::numeric_limits<float>::quiet_NaN();
+ Node node = Node(x);
+ EXPECT_TRUE(std::isnan(node.as<float>()));
+}
+
TEST(NodeTest, FloatingPrecisionDouble) {
const double x = 0.123456789;
Node node = Node(x);
EXPECT_EQ(x, node.as<double>());
}
+TEST(NodeTest, FloatingPrecisionPositiveInfinityDouble) {
+ if (!std::numeric_limits<double>::has_infinity) {
+ return;
+ }
+ const double x = std::numeric_limits<double>::infinity();
+ Node node = Node(x);
+ EXPECT_EQ(x, node.as<float>());
+}
+
+TEST(NodeTest, FloatingPrecisionNegativeInfinityDouble) {
+ if (!std::numeric_limits<double>::has_infinity) {
+ return;
+ }
+ const double x = -std::numeric_limits<double>::infinity();
+ Node node = Node(x);
+ EXPECT_EQ(x, node.as<double>());
+}
+
+TEST(NodeTest, FloatingPrecisionNanDouble) {
+ if (!std::numeric_limits<double>::has_quiet_NaN) {
+ return;
+ }
+ const double x = std::numeric_limits<double>::quiet_NaN();
+ Node node = Node(x);
+ EXPECT_TRUE(std::isnan(node.as<double>()));
+}
+
TEST(NodeTest, SpaceChar) {
Node node = Node(' ');
EXPECT_EQ(' ', node.as<char>());
diff --git a/lib/yamlcpp/test/ostream_wrapper_test.cpp b/lib/yamlcpp/test/ostream_wrapper_test.cpp
index cdc1f0508..ff4f635a5 100644
--- a/lib/yamlcpp/test/ostream_wrapper_test.cpp
+++ b/lib/yamlcpp/test/ostream_wrapper_test.cpp
@@ -1,5 +1,5 @@
-#include <stddef.h>
#include <sstream>
+#include <cstddef>
#include "gtest/gtest.h"
#include "yaml-cpp/ostream_wrapper.h"
diff --git a/lib/yamlcpp/test/parser_test.cpp b/lib/yamlcpp/test/parser_test.cpp
new file mode 100644
index 000000000..e5002a4fb
--- /dev/null
+++ b/lib/yamlcpp/test/parser_test.cpp
@@ -0,0 +1,64 @@
+#include <yaml-cpp/depthguard.h>
+#include "yaml-cpp/parser.h"
+#include "yaml-cpp/exceptions.h"
+#include "mock_event_handler.h"
+#include "gtest/gtest.h"
+
+using YAML::Parser;
+using YAML::MockEventHandler;
+using ::testing::NiceMock;
+using ::testing::StrictMock;
+
+TEST(ParserTest, Empty) {
+ Parser parser;
+
+ EXPECT_FALSE(parser);
+
+ StrictMock<MockEventHandler> handler;
+ EXPECT_FALSE(parser.HandleNextDocument(handler));
+}
+
+TEST(ParserTest, CVE_2017_5950) {
+ std::string excessive_recursion;
+ for (auto i = 0; i != 16384; ++i)
+ excessive_recursion.push_back('[');
+ std::istringstream input{excessive_recursion};
+ Parser parser{input};
+
+ NiceMock<MockEventHandler> handler;
+ EXPECT_THROW(parser.HandleNextDocument(handler), YAML::DeepRecursion);
+}
+
+TEST(ParserTest, CVE_2018_20573) {
+ std::string excessive_recursion;
+ for (auto i = 0; i != 20535; ++i)
+ excessive_recursion.push_back('{');
+ std::istringstream input{excessive_recursion};
+ Parser parser{input};
+
+ NiceMock<MockEventHandler> handler;
+ EXPECT_THROW(parser.HandleNextDocument(handler), YAML::DeepRecursion);
+}
+
+TEST(ParserTest, CVE_2018_20574) {
+ std::string excessive_recursion;
+ for (auto i = 0; i != 21989; ++i)
+ excessive_recursion.push_back('{');
+ std::istringstream input{excessive_recursion};
+ Parser parser{input};
+
+ NiceMock<MockEventHandler> handler;
+ EXPECT_THROW(parser.HandleNextDocument(handler), YAML::DeepRecursion);
+}
+
+TEST(ParserTest, CVE_2019_6285) {
+ std::string excessive_recursion;
+ for (auto i = 0; i != 23100; ++i)
+ excessive_recursion.push_back('[');
+ excessive_recursion.push_back('f');
+ std::istringstream input{excessive_recursion};
+ Parser parser{input};
+
+ NiceMock<MockEventHandler> handler;
+ EXPECT_THROW(parser.HandleNextDocument(handler), YAML::DeepRecursion);
+}
diff --git a/lib/yamlcpp/test/specexamples.h b/lib/yamlcpp/test/specexamples.h
index 3c81c7779..46e2c4c7d 100644
--- a/lib/yamlcpp/test/specexamples.h
+++ b/lib/yamlcpp/test/specexamples.h
@@ -154,7 +154,29 @@ const char *ex2_18 =
"quoted: \"So does this\n"
" quoted scalar.\\n\"";
-// TODO: 2.19 - 2.22 schema tags
+const char *ex2_19 =
+ "canonical: 12345\n"
+ "decimal: +12345\n"
+ "octal: 0o14\n"
+ "hexadecimal: 0xC\n";
+
+const char *ex2_20 =
+ "canonical: 1.23015e+3\n"
+ "exponential: 12.3015e+02\n"
+ "fixed: 1230.15\n"
+ "negative infinity: -.inf\n"
+ "not a number: .NaN\n";
+
+const char *ex2_21 =
+ "null:\n"
+ "booleans: [ true, false ]\n"
+ "string: '012345'\n";
+
+const char *ex2_22 =
+ "canonical: 2001-12-15T02:59:43.1Z\n"
+ "iso8601: 2001-12-14t21:59:43.10-05:00\n"
+ "spaced: 2001-12-14 21:59:43.10 -5\n"
+ "date: 2002-12-14\n";
const char *ex2_23 =
"---\n"
diff --git a/lib/yamlcpp/util/CMakeLists.txt b/lib/yamlcpp/util/CMakeLists.txt
index 09dafa24c..87ea4f91e 100644
--- a/lib/yamlcpp/util/CMakeLists.txt
+++ b/lib/yamlcpp/util/CMakeLists.txt
@@ -1,26 +1,32 @@
-cmake_minimum_required(VERSION 3.5)
+add_executable(yaml-cpp-sandbox sandbox.cpp)
+add_executable(yaml-cpp-parse parse.cpp)
+add_executable(yaml-cpp-read read.cpp)
-add_sources(parse.cpp)
-add_executable(parse parse.cpp)
-set_target_properties(parse PROPERTIES
- CXX_STANDARD 11
+target_link_libraries(yaml-cpp-sandbox PRIVATE yaml-cpp)
+target_link_libraries(yaml-cpp-parse PRIVATE yaml-cpp)
+target_link_libraries(yaml-cpp-read PRIVATE yaml-cpp)
+
+set_property(TARGET yaml-cpp-sandbox PROPERTY OUTPUT_NAME sandbox)
+set_property(TARGET yaml-cpp-parse PROPERTY OUTPUT_NAME parse)
+set_property(TARGET yaml-cpp-read PROPERTY OUTPUT_NAME read)
+
+set_target_properties(yaml-cpp-sandbox
+ PROPERTIES
CXX_STANDARD_REQUIRED ON
-)
-target_link_libraries(parse yaml-cpp)
+ OUTPUT_NAME sandbox)
-add_sources(sandbox.cpp)
-add_executable(sandbox sandbox.cpp)
-set_target_properties(sandbox PROPERTIES
- CXX_STANDARD 11
+set_target_properties(yaml-cpp-parse
+ PROPERTIES
CXX_STANDARD_REQUIRED ON
-)
-target_link_libraries(sandbox yaml-cpp)
+ OUTPUT_NAME parse)
-add_sources(read.cpp)
-add_executable(read read.cpp)
-set_target_properties(read PROPERTIES
- CXX_STANDARD 11
+set_target_properties(yaml-cpp-read
+ PROPERTIES
CXX_STANDARD_REQUIRED ON
-)
-target_link_libraries(read yaml-cpp)
+ OUTPUT_NAME read)
+if (NOT DEFINED CMAKE_CXX_STANDARD)
+ set_target_properties(yaml-cpp-sandbox yaml-cpp-parse yaml-cpp-read
+ PROPERTIES
+ CXX_STANDARD 11)
+endif()
diff --git a/lib/yamlcpp/util/read.cpp b/lib/yamlcpp/util/read.cpp
index fc88f1f9b..3455ea3cf 100644
--- a/lib/yamlcpp/util/read.cpp
+++ b/lib/yamlcpp/util/read.cpp
@@ -8,23 +8,23 @@
class NullEventHandler : public YAML::EventHandler {
public:
- typedef YAML::Mark Mark;
- typedef YAML::anchor_t anchor_t;
+ using Mark = YAML::Mark;
+ using anchor_t = YAML::anchor_t;
- NullEventHandler() {}
+ NullEventHandler() = default;
- virtual void OnDocumentStart(const Mark&) {}
- virtual void OnDocumentEnd() {}
- virtual void OnNull(const Mark&, anchor_t) {}
- virtual void OnAlias(const Mark&, anchor_t) {}
- virtual void OnScalar(const Mark&, const std::string&, anchor_t,
- const std::string&) {}
- virtual void OnSequenceStart(const Mark&, const std::string&, anchor_t,
- YAML::EmitterStyle::value style) {}
- virtual void OnSequenceEnd() {}
- virtual void OnMapStart(const Mark&, const std::string&, anchor_t,
- YAML::EmitterStyle::value style) {}
- virtual void OnMapEnd() {}
+ void OnDocumentStart(const Mark&) override {}
+ void OnDocumentEnd() override {}
+ void OnNull(const Mark&, anchor_t) override {}
+ void OnAlias(const Mark&, anchor_t) override {}
+ void OnScalar(const Mark&, const std::string&, anchor_t,
+ const std::string&) override {}
+ void OnSequenceStart(const Mark&, const std::string&, anchor_t,
+ YAML::EmitterStyle::value style) override {}
+ void OnSequenceEnd() override {}
+ void OnMapStart(const Mark&, const std::string&, anchor_t,
+ YAML::EmitterStyle::value style) override {}
+ void OnMapEnd() override {}
};
void run(std::istream& in) {
@@ -68,14 +68,14 @@ int main(int argc, char** argv) {
}
}
- if (N > 1 && !cache && filename == "") {
+ if (N > 1 && !cache && filename.empty()) {
usage();
return -1;
}
if (cache) {
std::string input;
- if (filename != "") {
+ if (!filename.empty()) {
std::ifstream in(filename);
input = read_stream(in);
} else {
@@ -87,7 +87,7 @@ int main(int argc, char** argv) {
run(in);
}
} else {
- if (filename != "") {
+ if (!filename.empty()) {
std::ifstream in(filename);
for (int i = 0; i < N; i++) {
in.seekg(std::ios_base::beg);
diff --git a/lib/yamlcpp/util/sandbox.cpp b/lib/yamlcpp/util/sandbox.cpp
index 1df25bb24..f21490e7a 100644
--- a/lib/yamlcpp/util/sandbox.cpp
+++ b/lib/yamlcpp/util/sandbox.cpp
@@ -6,23 +6,23 @@
class NullEventHandler : public YAML::EventHandler {
public:
- typedef YAML::Mark Mark;
- typedef YAML::anchor_t anchor_t;
+ using Mark = YAML::Mark;
+ using anchor_t = YAML::anchor_t;
- NullEventHandler() {}
+ NullEventHandler() = default;
- virtual void OnDocumentStart(const Mark&) {}
- virtual void OnDocumentEnd() {}
- virtual void OnNull(const Mark&, anchor_t) {}
- virtual void OnAlias(const Mark&, anchor_t) {}
- virtual void OnScalar(const Mark&, const std::string&, anchor_t,
- const std::string&) {}
- virtual void OnSequenceStart(const Mark&, const std::string&, anchor_t,
- YAML::EmitterStyle::value style) {}
- virtual void OnSequenceEnd() {}
- virtual void OnMapStart(const Mark&, const std::string&, anchor_t,
- YAML::EmitterStyle::value style) {}
- virtual void OnMapEnd() {}
+ void OnDocumentStart(const Mark&) override {}
+ void OnDocumentEnd() override {}
+ void OnNull(const Mark&, anchor_t) override {}
+ void OnAlias(const Mark&, anchor_t) override {}
+ void OnScalar(const Mark&, const std::string&, anchor_t,
+ const std::string&) override {}
+ void OnSequenceStart(const Mark&, const std::string&, anchor_t,
+ YAML::EmitterStyle::value style) override {}
+ void OnSequenceEnd() override {}
+ void OnMapStart(const Mark&, const std::string&, anchor_t,
+ YAML::EmitterStyle::value style) override {}
+ void OnMapEnd() override {}
};
int main() {
diff --git a/lib/yamlcpp/yaml-cpp-config-version.cmake.in b/lib/yamlcpp/yaml-cpp-config-version.cmake.in
deleted file mode 100644
index 80b9c79ad..000000000
--- a/lib/yamlcpp/yaml-cpp-config-version.cmake.in
+++ /dev/null
@@ -1,11 +0,0 @@
-set(PACKAGE_VERSION "@YAML_CPP_VERSION@")
-
-# Check whether the requested PACKAGE_FIND_VERSION is compatible
-if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
- set(PACKAGE_VERSION_COMPATIBLE FALSE)
-else()
- set(PACKAGE_VERSION_COMPATIBLE TRUE)
- if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
- set(PACKAGE_VERSION_EXACT TRUE)
- endif()
-endif()
diff --git a/lib/yamlcpp/yaml-cpp.pc.cmake b/lib/yamlcpp/yaml-cpp.pc.in
similarity index 68%
rename from lib/yamlcpp/yaml-cpp.pc.cmake
rename to lib/yamlcpp/yaml-cpp.pc.in
index 3db7962ea..f713de636 100644
--- a/lib/yamlcpp/yaml-cpp.pc.cmake
+++ b/lib/yamlcpp/yaml-cpp.pc.in
@@ -1,7 +1,7 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
-includedir=${prefix}/@INCLUDE_INSTALL_ROOT_DIR@
-libdir=${exec_prefix}/@LIB_INSTALL_DIR@
+includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
Name: Yaml-cpp
Description: A YAML parser and emitter for C++