diff --git a/external_imported/Catch2/.bazelrc b/external_imported/Catch2/.bazelrc index c01cb39f1..9cb0aa1b8 100644 --- a/external_imported/Catch2/.bazelrc +++ b/external_imported/Catch2/.bazelrc @@ -8,3 +8,4 @@ build:vs2022 --cxxopt=/std:c++17 build:windows --config=vs2022 build:linux --config=gcc11 +build:macos --cxxopt=-std=c++2b diff --git a/external_imported/Catch2/.github/workflows/linux-bazel-builds.yml b/external_imported/Catch2/.github/workflows/linux-bazel-builds.yml index 9006652e2..dc826ac0d 100644 --- a/external_imported/Catch2/.github/workflows/linux-bazel-builds.yml +++ b/external_imported/Catch2/.github/workflows/linux-bazel-builds.yml @@ -11,7 +11,7 @@ jobs: compilation_mode: [fastbuild, dbg, opt] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Mount bazel cache uses: actions/cache@v3 diff --git a/external_imported/Catch2/.github/workflows/linux-meson-builds.yml b/external_imported/Catch2/.github/workflows/linux-meson-builds.yml index dec701b61..4ffa0243a 100644 --- a/external_imported/Catch2/.github/workflows/linux-meson-builds.yml +++ b/external_imported/Catch2/.github/workflows/linux-meson-builds.yml @@ -18,10 +18,12 @@ jobs: other_pkgs: clang-11 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Prepare environment - run: sudo apt-get install -y meson ninja-build ${{matrix.other_pkgs}} + run: | + sudo apt-get update + sudo apt-get install -y meson ninja-build ${{matrix.other_pkgs}} - name: Configure build env: diff --git a/external_imported/Catch2/.github/workflows/linux-other-builds.yml b/external_imported/Catch2/.github/workflows/linux-other-builds.yml index cf4e2c06b..4a7f5ecc6 100644 --- a/external_imported/Catch2/.github/workflows/linux-other-builds.yml +++ b/external_imported/Catch2/.github/workflows/linux-other-builds.yml @@ -29,13 +29,13 @@ jobs: build_type: Debug std: 14 other_pkgs: g++-7 - cmake_configurations: -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_BUILD_EXAMPLES=ON + cmake_configurations: -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_BUILD_EXAMPLES=ON -DCATCH_ENABLE_CMAKE_HELPER_TESTS=ON - cxx: g++-7 build_description: Extras + Examples build_type: Release std: 14 other_pkgs: g++-7 - cmake_configurations: -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_BUILD_EXAMPLES=ON + cmake_configurations: -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_BUILD_EXAMPLES=ON -DCATCH_ENABLE_CMAKE_HELPER_TESTS=ON # Extras and examples with Clang-10 - cxx: clang++-10 @@ -43,13 +43,13 @@ jobs: build_type: Debug std: 17 other_pkgs: clang-10 - cmake_configurations: -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_BUILD_EXAMPLES=ON + cmake_configurations: -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_BUILD_EXAMPLES=ON -DCATCH_ENABLE_CMAKE_HELPER_TESTS=ON - cxx: clang++-10 build_description: Extras + Examples build_type: Release std: 17 other_pkgs: clang-10 - cmake_configurations: -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_BUILD_EXAMPLES=ON + cmake_configurations: -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_BUILD_EXAMPLES=ON -DCATCH_ENABLE_CMAKE_HELPER_TESTS=ON # Configure tests with Clang-10 - cxx: clang++-10 @@ -70,10 +70,12 @@ jobs: steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Prepare environment - run: sudo apt-get install -y ninja-build ${{matrix.other_pkgs}} + run: | + sudo apt-get update + sudo apt-get install -y ninja-build ${{matrix.other_pkgs}} - name: Configure build working-directory: ${{runner.workspace}} diff --git a/external_imported/Catch2/.github/workflows/linux-simple-builds.yml b/external_imported/Catch2/.github/workflows/linux-simple-builds.yml index 989c4942e..a32eb597e 100644 --- a/external_imported/Catch2/.github/workflows/linux-simple-builds.yml +++ b/external_imported/Catch2/.github/workflows/linux-simple-builds.yml @@ -83,7 +83,7 @@ jobs: other_pkgs: g++-10 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Add repositories for older GCC run: | @@ -92,7 +92,9 @@ jobs: if: ${{ matrix.cxx == 'g++-5' || matrix.cxx == 'g++-6' }} - name: Prepare environment - run: sudo apt-get install -y ninja-build ${{matrix.other_pkgs}} + run: | + sudo apt-get update + sudo apt-get install -y ninja-build ${{matrix.other_pkgs}} - name: Configure build working-directory: ${{runner.workspace}} diff --git a/external_imported/Catch2/.github/workflows/mac-builds.yml b/external_imported/Catch2/.github/workflows/mac-builds.yml index 955b81fcc..259d8b367 100644 --- a/external_imported/Catch2/.github/workflows/mac-builds.yml +++ b/external_imported/Catch2/.github/workflows/mac-builds.yml @@ -22,7 +22,7 @@ jobs: extra_tests: ON steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Configure build working-directory: ${{runner.workspace}} @@ -42,11 +42,10 @@ jobs: - name: Build tests + lib working-directory: ${{runner.workspace}}/build - run: make -j 2 + run: make -j `sysctl -n hw.ncpu` - name: Run tests env: CTEST_OUTPUT_ON_FAILURE: 1 working-directory: ${{runner.workspace}}/build - # Hardcode 2 cores we know are there - run: ctest -C ${{matrix.build_type}} -j 2 + run: ctest -C ${{matrix.build_type}} -j `sysctl -n hw.ncpu` diff --git a/external_imported/Catch2/.github/workflows/validate-header-guards.yml b/external_imported/Catch2/.github/workflows/validate-header-guards.yml index c02b5d49e..fa9d1574b 100644 --- a/external_imported/Catch2/.github/workflows/validate-header-guards.yml +++ b/external_imported/Catch2/.github/workflows/validate-header-guards.yml @@ -9,7 +9,7 @@ jobs: steps: - name: Checkout source code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup Dependencies uses: actions/setup-python@v2 diff --git a/external_imported/Catch2/.github/workflows/windows-simple-builds.yml b/external_imported/Catch2/.github/workflows/windows-simple-builds.yml index 197fa219e..5fb7b8fe7 100644 --- a/external_imported/Catch2/.github/workflows/windows-simple-builds.yml +++ b/external_imported/Catch2/.github/workflows/windows-simple-builds.yml @@ -13,7 +13,7 @@ jobs: build_type: [Debug, Release] std: [14, 17] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Configure build working-directory: ${{runner.workspace}} diff --git a/external_imported/Catch2/BUILD.bazel b/external_imported/Catch2/BUILD.bazel index 3125e7c54..c51bf57e7 100644 --- a/external_imported/Catch2/BUILD.bazel +++ b/external_imported/Catch2/BUILD.bazel @@ -43,12 +43,15 @@ expand_template( "#cmakedefine CATCH_CONFIG_NO_GLOBAL_NEXTAFTER": "", "#cmakedefine CATCH_CONFIG_NO_POSIX_SIGNALS": "", "#cmakedefine CATCH_CONFIG_NO_USE_ASYNC": "", + "#cmakedefine CATCH_CONFIG_NO_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT": "", "#cmakedefine CATCH_CONFIG_NO_WCHAR": "", "#cmakedefine CATCH_CONFIG_NO_WINDOWS_SEH": "", "#cmakedefine CATCH_CONFIG_NOSTDOUT": "", "#cmakedefine CATCH_CONFIG_POSIX_SIGNALS": "", "#cmakedefine CATCH_CONFIG_PREFIX_ALL": "", + "#cmakedefine CATCH_CONFIG_PREFIX_MESSAGES": "", "#cmakedefine CATCH_CONFIG_SHARED_LIBRARY": "", + "#cmakedefine CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT": "", "#cmakedefine CATCH_CONFIG_USE_ASYNC": "", "#cmakedefine CATCH_CONFIG_WCHAR": "", "#cmakedefine CATCH_CONFIG_WINDOWS_CRTDBG": "", diff --git a/external_imported/Catch2/CMake/CatchConfigOptions.cmake b/external_imported/Catch2/CMake/CatchConfigOptions.cmake index 733ec65e2..6eae220df 100644 --- a/external_imported/Catch2/CMake/CatchConfigOptions.cmake +++ b/external_imported/Catch2/CMake/CatchConfigOptions.cmake @@ -18,10 +18,12 @@ macro(AddOverridableConfigOption OptionBaseName) option(CATCH_CONFIG_${OptionBaseName} "Read docs/configuration.md for details" OFF) option(CATCH_CONFIG_NO_${OptionBaseName} "Read docs/configuration.md for details" OFF) + mark_as_advanced(CATCH_CONFIG_${OptionBaseName} CATCH_CONFIG_NO_${OptionBaseName}) endmacro() macro(AddConfigOption OptionBaseName) option(CATCH_CONFIG_${OptionBaseName} "Read docs/configuration.md for details" OFF) + mark_as_advanced(CATCH_CONFIG_${OptionBaseName}) endmacro() set(_OverridableOptions @@ -41,6 +43,7 @@ set(_OverridableOptions "WCHAR" "WINDOWS_SEH" "GETENV" + "EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT" ) foreach(OptionName ${_OverridableOptions}) @@ -61,6 +64,7 @@ set(_OtherConfigOptions "FAST_COMPILE" "NOSTDOUT" "PREFIX_ALL" + "PREFIX_MESSAGES" "WINDOWS_CRTDBG" ) @@ -68,11 +72,17 @@ set(_OtherConfigOptions foreach(OptionName ${_OtherConfigOptions}) AddConfigOption(${OptionName}) endforeach() -set(CATCH_CONFIG_SHARED_LIBRARY ${BUILD_SHARED_LIBS}) +if(DEFINED BUILD_SHARED_LIBS) + set(CATCH_CONFIG_SHARED_LIBRARY ${BUILD_SHARED_LIBS}) +else() + set(CATCH_CONFIG_SHARED_LIBRARY "") +endif() set(CATCH_CONFIG_DEFAULT_REPORTER "console" CACHE STRING "Read docs/configuration.md for details. The name of the reporter should be without quotes.") set(CATCH_CONFIG_CONSOLE_WIDTH "80" CACHE STRING "Read docs/configuration.md for details. Must form a valid integer literal.") +mark_as_advanced(CATCH_CONFIG_SHARED_LIBRARY CATCH_CONFIG_DEFAULT_REPORTER CATCH_CONFIG_CONSOLE_WIDTH) + # There is no good way to both turn this into a CMake cache variable, # and keep reasonable default semantics inside the project. Thus we do # not define it and users have to provide it as an outside variable. diff --git a/external_imported/Catch2/CMake/CatchMiscFunctions.cmake b/external_imported/Catch2/CMake/CatchMiscFunctions.cmake index 3758d9568..84bd7cc79 100644 --- a/external_imported/Catch2/CMake/CatchMiscFunctions.cmake +++ b/external_imported/Catch2/CMake/CatchMiscFunctions.cmake @@ -46,7 +46,6 @@ function(add_warnings_to_targets targets) set(CHECKED_WARNING_FLAGS "-Wabsolute-value" "-Wall" - "-Wc++20-compat" "-Wcall-to-pure-virtual-from-ctor-dtor" "-Wcast-align" "-Wcatch-value" @@ -74,16 +73,18 @@ function(add_warnings_to_targets targets) "-Woverloaded-virtual" "-Wparentheses" "-Wpedantic" + "-Wredundant-decls" "-Wreorder" "-Wreturn-std-move" "-Wshadow" "-Wstrict-aliasing" + "-Wsubobject-linkage" "-Wsuggest-destructor-override" "-Wsuggest-override" "-Wundef" "-Wuninitialized" "-Wunneeded-internal-declaration" - "-Wunreachable-code" + "-Wunreachable-code-aggressive" "-Wunused" "-Wunused-function" "-Wunused-parameter" diff --git a/external_imported/Catch2/CMakeLists.txt b/external_imported/Catch2/CMakeLists.txt index 6d381d8de..78ac4c8ad 100644 --- a/external_imported/Catch2/CMakeLists.txt +++ b/external_imported/Catch2/CMakeLists.txt @@ -11,6 +11,7 @@ endif() option(CATCH_INSTALL_DOCS "Install documentation alongside library" ON) option(CATCH_INSTALL_EXTRAS "Install extras (CMake scripts, debugger helpers) alongside library" ON) option(CATCH_DEVELOPMENT_BUILD "Build tests, enable warnings, enable Werror, etc" OFF) +option(CATCH_ENABLE_REPRODUCIBLE_BUILD "Add compiler flags for improving build reproducibility" ON) include(CMakeDependentOption) cmake_dependent_option(CATCH_BUILD_TESTING "Build the SelfTest project" ON "CATCH_DEVELOPMENT_BUILD" OFF) @@ -21,6 +22,7 @@ cmake_dependent_option(CATCH_ENABLE_COVERAGE "Generate coverage for codecov.io" cmake_dependent_option(CATCH_ENABLE_WERROR "Enables Werror during build" ON "CATCH_DEVELOPMENT_BUILD" OFF) cmake_dependent_option(CATCH_BUILD_SURROGATES "Enable generating and building surrogate TUs for the main headers" OFF "CATCH_DEVELOPMENT_BUILD" OFF) cmake_dependent_option(CATCH_ENABLE_CONFIGURE_TESTS "Enable CMake configuration tests. WARNING: VERY EXPENSIVE" OFF "CATCH_DEVELOPMENT_BUILD" OFF) +cmake_dependent_option(CATCH_ENABLE_CMAKE_HELPER_TESTS "Enable CMake helper tests. WARNING: VERY EXPENSIVE" OFF "CATCH_DEVELOPMENT_BUILD" OFF) # Catch2's build breaks if done in-tree. You probably should not build @@ -31,7 +33,7 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) endif() project(Catch2 - VERSION 3.3.2 # CML version placeholder, don't delete + VERSION 3.5.2 # CML version placeholder, don't delete LANGUAGES CXX # HOMEPAGE_URL is not supported until CMake version 3.12, which # we do not target yet. @@ -148,6 +150,8 @@ if (NOT_SUBPROJECT) "extras/ParseAndAddCatchTests.cmake" "extras/Catch.cmake" "extras/CatchAddTests.cmake" + "extras/CatchShardTests.cmake" + "extras/CatchShardTestsImpl.cmake" DESTINATION ${CATCH_CMAKE_CONFIG_DESTINATION} ) diff --git a/external_imported/Catch2/CMakePresets.json b/external_imported/Catch2/CMakePresets.json index 00f3a6d3a..885412850 100644 --- a/external_imported/Catch2/CMakePresets.json +++ b/external_imported/Catch2/CMakePresets.json @@ -18,7 +18,8 @@ "CATCH_BUILD_EXAMPLES": "ON", "CATCH_BUILD_EXTRA_TESTS": "ON", "CATCH_BUILD_SURROGATES": "ON", - "CATCH_ENABLE_CONFIGURE_TESTS": "ON" + "CATCH_ENABLE_CONFIGURE_TESTS": "ON", + "CATCH_ENABLE_CMAKE_HELPER_TESTS": "ON" } } ] diff --git a/external_imported/Catch2/Doxyfile b/external_imported/Catch2/Doxyfile index 07b385ec1..914e59848 100644 --- a/external_imported/Catch2/Doxyfile +++ b/external_imported/Catch2/Doxyfile @@ -1,4 +1,4 @@ -# Doxyfile 1.8.16 +# Doxyfile 1.9.1 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = "Catch2" +PROJECT_NAME = Catch2 # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version @@ -51,6 +51,7 @@ PROJECT_BRIEF = "Popular C++ unit testing framework" # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy # the logo to the output directory. +PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is @@ -216,6 +217,14 @@ QT_AUTOBRIEF = YES MULTILINE_CPP_IS_BRIEF = NO +# By default Python docstrings are displayed as preformatted text and doxygen's +# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the +# doxygen's special commands can be used and the contents of the docstring +# documentation blocks is shown as doxygen documentation. +# The default value is: YES. + +PYTHON_DOCSTRING = YES + # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the # documentation from any documented member that it re-implements. # The default value is: YES. @@ -251,13 +260,7 @@ TAB_SIZE = 4 # a double escape (\\{ and \\}) ALIASES = "complexity=@par Complexity:" \ - "noexcept=**Noexcept**" - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding "class=itcl::class" -# will allow you to use the command class in the itcl::class meaning. - -TCL_SUBST = + noexcept=**Noexcept** # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For @@ -299,19 +302,22 @@ OPTIMIZE_OUTPUT_SLICE = NO # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, and -# language is one of the parsers supported by doxygen: IDL, Java, Javascript, -# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, +# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, +# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, VHDL, # Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: # FortranFree, unknown formatted Fortran: Fortran. In the later case the parser # tries to guess whether the code is fixed or free formatted code, this is the -# default for Fortran type files), VHDL, tcl. For instance to make doxygen treat -# .inc files as Fortran files (default is PHP), and .f files as C (default is -# Fortran), use: inc=Fortran f=C. +# default for Fortran type files). For instance to make doxygen treat .inc files +# as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. # # Note: For files without extension you can use no_extension as a placeholder. # # Note that for custom extensions you also need to set FILE_PATTERNS otherwise -# the files are not read by doxygen. +# the files are not read by doxygen. When specifying no_extension you should add +# * to the FILE_PATTERNS. +# +# Note see also the list of default file extension mappings. EXTENSION_MAPPING = @@ -445,6 +451,19 @@ TYPEDEF_HIDES_STRUCT = NO LOOKUP_CACHE_SIZE = 0 +# The NUM_PROC_THREADS specifies the number threads doxygen is allowed to use +# during processing. When set to 0 doxygen will based this on the number of +# cores available in the system. You can set it explicitly to a value larger +# than 0 to get more control over the balance between CPU load and processing +# speed. At this moment only the input processing can be done using multiple +# threads. Since this is still an experimental feature the default is set to 1, +# which efficively disables parallel processing. Please report any issues you +# encounter. Generating dot graphs in parallel is controlled by the +# DOT_NUM_THREADS setting. +# Minimum value: 0, maximum value: 32, default value: 1. + +NUM_PROC_THREADS = 1 + #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- @@ -508,6 +527,13 @@ EXTRACT_LOCAL_METHODS = NO EXTRACT_ANON_NSPACES = NO +# If this flag is set to YES, the name of an unnamed parameter in a declaration +# will be determined by the corresponding definition. By default unnamed +# parameters remain unnamed in the output. +# The default value is: YES. + +RESOLVE_UNNAMED_PARAMS = YES + # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all # undocumented members inside documented classes or files. If set to NO these # members will be included in the various overviews, but no documentation @@ -525,8 +551,8 @@ HIDE_UNDOC_MEMBERS = NO HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend -# (class|struct|union) declarations. If set to NO, these declarations will be -# included in the documentation. +# declarations. If set to NO, these declarations will be included in the +# documentation. # The default value is: NO. HIDE_FRIEND_COMPOUNDS = NO @@ -545,11 +571,18 @@ HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file -# names in lower-case letters. If set to YES, upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# (including Cygwin) ands Mac users are advised to set this option to NO. +# With the correct setting of option CASE_SENSE_NAMES doxygen will better be +# able to match the capabilities of the underlying filesystem. In case the +# filesystem is case sensitive (i.e. it supports files in the same directory +# whose names only differ in casing), the option must be set to YES to properly +# deal with such files in case they appear in the input. For filesystems that +# are not case sensitive the option should be be set to NO to properly deal with +# output files written for symbols that only differ in casing, such as for two +# classes, one named CLASS and the other named Class, and to also support +# references to files without having to specify the exact matching casing. On +# Windows (including Cygwin) and MacOS, users should typically set this option +# to NO, whereas on Linux or other Unix flavors it should typically be set to +# YES. # The default value is: system dependent. CASE_SENSE_NAMES = NO @@ -788,7 +821,10 @@ WARN_IF_DOC_ERROR = YES WARN_NO_PARAMDOC = YES # If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when -# a warning is encountered. +# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS +# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but +# at the end of the doxygen process doxygen will return with a non-zero status. +# Possible values are: NO, YES and FAIL_ON_WARNINGS. # The default value is: NO. WARN_AS_ERROR = NO @@ -819,13 +855,13 @@ WARN_LOGFILE = doxygen.errors # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = "src/catch2" +INPUT = src/catch2 # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: https://www.gnu.org/software/libiconv/) for the list of -# possible encodings. +# documentation (see: +# https://www.gnu.org/software/libiconv/) for the list of possible encodings. # The default value is: UTF-8. INPUT_ENCODING = UTF-8 @@ -838,13 +874,61 @@ INPUT_ENCODING = UTF-8 # need to set EXTENSION_MAPPING for the extension otherwise the files are not # read by doxygen. # +# Note the list of default checked file patterns might differ from the list of +# default file extension mappings. +# # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, # *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, -# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, -# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, *.qsf and *.ice. - -# FILE_PATTERNS = +# *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment), +# *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, *.vhdl, +# *.ucf, *.qsf and *.ice. + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.idl \ + *.ddl \ + *.odl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.cs \ + *.d \ + *.php \ + *.php4 \ + *.php5 \ + *.phtml \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.pyw \ + *.f90 \ + *.f95 \ + *.f03 \ + *.f08 \ + *.f18 \ + *.f \ + *.for \ + *.vhd \ + *.vhdl \ + *.ucf \ + *.qsf \ + *.ice # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. @@ -968,6 +1052,7 @@ FILTER_SOURCE_PATTERNS = # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. +USE_MDFILE_AS_MAINPAGE = #--------------------------------------------------------------------------- # Configuration options related to source browsing @@ -1055,6 +1140,44 @@ USE_HTAGS = NO VERBATIM_HEADERS = YES +# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the +# clang parser (see: +# http://clang.llvm.org/) for more accurate parsing at the cost of reduced +# performance. This can be particularly helpful with template rich C++ code for +# which doxygen's built-in parser lacks the necessary type information. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. +# The default value is: NO. + +CLANG_ASSISTED_PARSING = NO + +# If clang assisted parsing is enabled and the CLANG_ADD_INC_PATHS tag is set to +# YES then doxygen will add the directory of each input to the include path. +# The default value is: YES. + +CLANG_ADD_INC_PATHS = YES + +# If clang assisted parsing is enabled you can provide the compiler with command +# line options that you would normally use when invoking the compiler. Note that +# the include paths will already be set by doxygen for the files and directories +# specified with INPUT and INCLUDE_PATH. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_OPTIONS = + +# If clang assisted parsing is enabled you can provide the clang parser with the +# path to the directory containing a file called compile_commands.json. This +# file is the compilation database (see: +# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) containing the +# options used when the source files were built. This is equivalent to +# specifying the -p option to a clang tool, such as clang-check. These options +# will then be passed to the parser. Any options specified with CLANG_OPTIONS +# will be added as well. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. + +CLANG_DATABASE_PATH = + #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- @@ -1066,13 +1189,6 @@ VERBATIM_HEADERS = YES ALPHABETICAL_INDEX = YES -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -COLS_IN_ALPHA_INDEX = 5 - # In case all classes in a project start with a common prefix, all classes will # be put under the same header in the alphabetical index. The IGNORE_PREFIX tag # can be used to specify a prefix (or a list of prefixes) that should be ignored @@ -1211,9 +1327,9 @@ HTML_TIMESTAMP = NO # If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML # documentation will contain a main index with vertical navigation menus that -# are dynamically created via Javascript. If disabled, the navigation index will +# are dynamically created via JavaScript. If disabled, the navigation index will # consists of multiple levels of tabs that are statically embedded in every HTML -# page. Disable this option to support browsers that do not have Javascript, +# page. Disable this option to support browsers that do not have JavaScript, # like the Qt help browser. # The default value is: YES. # This tag requires that the tag GENERATE_HTML is set to YES. @@ -1243,10 +1359,11 @@ HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: https://developer.apple.com/xcode/), introduced with OSX -# 10.5 (Leopard). To create a documentation set, doxygen will generate a -# Makefile in the HTML output directory. Running make will produce the docset in -# that directory and running make install will install the docset in +# environment (see: +# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To +# create a documentation set, doxygen will generate a Makefile in the HTML +# output directory. Running make will produce the docset in that directory and +# running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at # startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy # genXcode/_index.html for more information. @@ -1288,8 +1405,8 @@ DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: https://www.microsoft.com/en-us/download/details.aspx?id=21138) on -# Windows. +# (see: +# https://www.microsoft.com/en-us/download/details.aspx?id=21138) on Windows. # # The HTML Help Workshop contains a compiler that can convert all HTML output # generated by doxygen into a single compiled HTML file (.chm). Compiled HTML @@ -1364,7 +1481,8 @@ QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace -# (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). +# (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1372,8 +1490,8 @@ QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual- -# folders). +# Folders (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders). # The default value is: doc. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1381,16 +1499,16 @@ QHP_VIRTUAL_FOLDER = doc # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # filter to add. For more information please see Qt Help Project / Custom -# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- -# filters). +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- -# filters). +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_ATTRS = @@ -1402,9 +1520,9 @@ QHP_CUST_FILTER_ATTRS = QHP_SECT_FILTER_ATTRS = -# The QHG_LOCATION tag can be used to specify the location of Qt's -# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the -# generated .qhp file. +# The QHG_LOCATION tag can be used to specify the location (absolute path +# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to +# run qhelpgenerator on the generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. QHG_LOCATION = @@ -1481,6 +1599,17 @@ TREEVIEW_WIDTH = 250 EXT_LINKS_IN_WINDOW = NO +# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg +# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see +# https://inkscape.org) to generate formulas as SVG images instead of PNGs for +# the HTML output. These images will generally look nicer at scaled resolutions. +# Possible values are: png (the default) and svg (looks nicer but requires the +# pdf2svg or inkscape tool). +# The default value is: png. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FORMULA_FORMAT = png + # Use this tag to change the font size of LaTeX formulas included as images in # the HTML documentation. When you change the font size after a successful # doxygen run you need to manually remove any form_*.png images from the HTML @@ -1501,8 +1630,14 @@ FORMULA_FONTSIZE = 10 FORMULA_TRANSPARENT = YES +# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands +# to create new LaTeX commands to be used in formulas as building blocks. See +# the section "Including formulas" for details. + +FORMULA_MACROFILE = + # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# https://www.mathjax.org) which uses client side Javascript for the rendering +# https://www.mathjax.org) which uses client side JavaScript for the rendering # instead of using pre-rendered bitmaps. Use this if you do not have LaTeX # installed or if you want to formulas look prettier in the HTML output. When # enabled you may also need to install MathJax separately and configure the path @@ -1514,7 +1649,7 @@ USE_MATHJAX = YES # When MathJax is enabled you can set the default output format to be used for # the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. # Possible values are: HTML-CSS (which is slower, but has the best # compatibility), NativeMML (i.e. MathML) and SVG. # The default value is: HTML-CSS. @@ -1530,7 +1665,7 @@ MATHJAX_FORMAT = HTML-CSS # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of # MathJax from https://www.mathjax.org before deployment. -# The default value is: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/. +# The default value is: https://cdn.jsdelivr.net/npm/mathjax@2. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest @@ -1545,7 +1680,8 @@ MATHJAX_EXTENSIONS = TeX/AMSmath \ # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. @@ -1573,7 +1709,7 @@ MATHJAX_CODEFILE = SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a web server instead of a web client using Javascript. There +# implemented using a web server instead of a web client using JavaScript. There # are two flavors of web server based searching depending on the EXTERNAL_SEARCH # setting. When disabled, doxygen will generate a PHP script for searching and # an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing @@ -1592,7 +1728,8 @@ SERVER_BASED_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: https://xapian.org/). +# Xapian (see: +# https://xapian.org/). # # See the section "External Indexing and Searching" for details. # The default value is: NO. @@ -1605,8 +1742,9 @@ EXTERNAL_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: https://xapian.org/). See the section "External Indexing and -# Searching" for details. +# Xapian (see: +# https://xapian.org/). See the section "External Indexing and Searching" for +# details. # This tag requires that the tag SEARCHENGINE is set to YES. SEARCHENGINE_URL = @@ -1770,9 +1908,11 @@ LATEX_EXTRA_FILES = PDF_HYPERLINKS = YES -# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate -# the PDF file directly from the LaTeX files. Set this option to YES, to get a -# higher quality PDF documentation. +# If the USE_PDFLATEX tag is set to YES, doxygen will use the engine as +# specified with LATEX_CMD_NAME to generate the PDF file directly from the LaTeX +# files. Set this option to YES, to get a higher quality PDF documentation. +# +# See also section LATEX_CMD_NAME for selecting the engine. # The default value is: YES. # This tag requires that the tag GENERATE_LATEX is set to YES. @@ -2204,7 +2344,7 @@ HIDE_UNDOC_RELATIONS = YES # http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent # Bell Labs. The other options in this section have no effect if this option is # set to NO -# The default value is: NO. +# The default value is: YES. HAVE_DOT = YES @@ -2283,10 +2423,32 @@ UML_LOOK = NO # but if the number exceeds 15, the total amount of fields shown is limited to # 10. # Minimum value: 0, maximum value: 100, default value: 10. -# This tag requires that the tag HAVE_DOT is set to YES. +# This tag requires that the tag UML_LOOK is set to YES. UML_LIMIT_NUM_FIELDS = 10 +# If the DOT_UML_DETAILS tag is set to NO, doxygen will show attributes and +# methods without types and arguments in the UML graphs. If the DOT_UML_DETAILS +# tag is set to YES, doxygen will add type and arguments for attributes and +# methods in the UML graphs. If the DOT_UML_DETAILS tag is set to NONE, doxygen +# will not generate fields with class member information in the UML graphs. The +# class diagrams will look similar to the default class diagrams but using UML +# notation for the relationships. +# Possible values are: NO, YES and NONE. +# The default value is: NO. +# This tag requires that the tag UML_LOOK is set to YES. + +DOT_UML_DETAILS = NO + +# The DOT_WRAP_THRESHOLD tag can be used to set the maximum number of characters +# to display on a single line. If the actual line length exceeds this threshold +# significantly it will wrapped across multiple lines. Some heuristics are apply +# to avoid ugly line breaks. +# Minimum value: 0, maximum value: 1000, default value: 17. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_WRAP_THRESHOLD = 17 + # If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and # collaboration graphs will show the relations between templates and their # instances. @@ -2360,7 +2522,9 @@ DIRECTORY_GRAPH = NO # Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order # to make the SVG files visible in IE 9+ (other browsers do not have this # requirement). -# Possible values are: png, jpg, gif, svg, png:gd, png:gd:gd, png:cairo, +# Possible values are: png, png:cairo, png:cairo:cairo, png:cairo:gd, png:gd, +# png:gd:gd, jpg, jpg:cairo, jpg:cairo:gd, jpg:gd, jpg:gd:gd, gif, gif:cairo, +# gif:cairo:gd, gif:gd, gif:gd:gd, svg, png:gd, png:gd:gd, png:cairo, # png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and # png:gdiplus:gdiplus. # The default value is: png. @@ -2476,9 +2640,11 @@ DOT_MULTI_TARGETS = YES GENERATE_LEGEND = YES -# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot +# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate # files that are used to generate the various graphs. +# +# Note: This setting is not only used for dot files but also for msc and +# plantuml temporary files. # The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. DOT_CLEANUP = YES diff --git a/external_imported/Catch2/MODULE.bazel b/external_imported/Catch2/MODULE.bazel new file mode 100644 index 000000000..a7846cd60 --- /dev/null +++ b/external_imported/Catch2/MODULE.bazel @@ -0,0 +1,3 @@ +module(name = "catch2") + +bazel_dep(name = "bazel_skylib", version = "1.5.0") diff --git a/external_imported/Catch2/WORKSPACE.bazel b/external_imported/Catch2/WORKSPACE.bazel index 6fd2ffa5d..357e6f944 100644 --- a/external_imported/Catch2/WORKSPACE.bazel +++ b/external_imported/Catch2/WORKSPACE.bazel @@ -4,12 +4,13 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "bazel_skylib", + sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz", ], - sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506", ) load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") + bazel_skylib_workspace() diff --git a/external_imported/Catch2/appveyor.yml b/external_imported/Catch2/appveyor.yml index 3b6580d8b..7a0ad83ff 100644 --- a/external_imported/Catch2/appveyor.yml +++ b/external_imported/Catch2/appveyor.yml @@ -70,14 +70,3 @@ environment: additional_flags: "/permissive- /std:c++latest" platform: x64 configuration: Debug - - - FLAVOR: VS 2017 x64 Debug - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - platform: x64 - configuration: Debug - - - FLAVOR: VS 2017 x64 Release Coverage - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - coverage: 1 - platform: x64 - configuration: Debug \ No newline at end of file diff --git a/external_imported/Catch2/docs/benchmarks.md b/external_imported/Catch2/docs/benchmarks.md index 548913c76..9edbb93c7 100644 --- a/external_imported/Catch2/docs/benchmarks.md +++ b/external_imported/Catch2/docs/benchmarks.md @@ -93,7 +93,7 @@ Fibonacci ------------------------------------------------------------------------------- C:\path\to\Catch2\Benchmark.tests.cpp(10) ............................................................................... -benchmark name samples iterations estimated +benchmark name samples iterations est run time mean low mean high mean std dev low std dev high std dev ------------------------------------------------------------------------------- diff --git a/external_imported/Catch2/docs/ci-and-misc.md b/external_imported/Catch2/docs/ci-and-misc.md index c07da29f0..49bbd9891 100644 --- a/external_imported/Catch2/docs/ci-and-misc.md +++ b/external_imported/Catch2/docs/ci-and-misc.md @@ -82,7 +82,7 @@ variable set to "1". ### CodeCoverage module (GCOV, LCOV...) -If you are using GCOV tool to get testing coverage of your code, and are not sure how to integrate it with CMake and Catch, there should be an external example over at https://github.com/fkromer/catch_cmake_coverage +If you are using GCOV tool to get testing coverage of your code, and are not sure how to integrate it with CMake and Catch, there should be an external example over at https://github.com/claremacrae/catch_cmake_coverage ### pkg-config diff --git a/external_imported/Catch2/docs/cmake-integration.md b/external_imported/Catch2/docs/cmake-integration.md index 0720a95b0..86666efe2 100644 --- a/external_imported/Catch2/docs/cmake-integration.md +++ b/external_imported/Catch2/docs/cmake-integration.md @@ -51,7 +51,7 @@ Include(FetchContent) FetchContent_Declare( Catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_TAG v3.0.1 # or a later release + GIT_TAG v3.4.0 # or a later release ) FetchContent_MakeAvailable(Catch2) @@ -126,6 +126,7 @@ catch_discover_tests(target [OUTPUT_DIR dir] [OUTPUT_PREFIX prefix] [OUTPUT_SUFFIX suffix] + [DISCOVERY_MODE ] ) ``` @@ -198,6 +199,16 @@ If specified, `suffix` is added to each output file name, like so `--out dir/suffix`. This can be used to add a file extension to the output file name e.g. ".xml". +* `DISCOVERY_MODE mode` + +If specified allows control over when test discovery is performed. +For a value of `POST_BUILD` (default) test discovery is performed at build time. +For a value of `PRE_TEST` test discovery is delayed until just prior to test +execution (useful e.g. in cross-compilation environments). +``DISCOVERY_MODE`` defaults to the value of the +``CMAKE_CATCH_DISCOVER_TESTS_DISCOVERY_MODE`` variable if it is not passed when +calling ``catch_discover_tests``. This provides a mechanism for globally +selecting a preferred test discovery behavior. ### `ParseAndAddCatchTests.cmake` diff --git a/external_imported/Catch2/docs/command-line.md b/external_imported/Catch2/docs/command-line.md index a15a21314..bb483959d 100644 --- a/external_imported/Catch2/docs/command-line.md +++ b/external_imported/Catch2/docs/command-line.md @@ -85,43 +85,102 @@ Click one of the following links to take you straight to that option - or scroll
<test-spec> ...
-Test cases, wildcarded test cases, tags and tag expressions are all passed directly as arguments. Tags are distinguished by being enclosed in square brackets. +By providing a test spec, you filter which tests will be run. If you call +Catch2 without any test spec, then it will run all non-hidden test +cases. A test case is hidden if it has the `[!benchmark]` tag, any tag +with a dot at the start, e.g. `[.]` or `[.foo]`. -If no test specs are supplied then all test cases, except "hidden" tests, are run. -A test is hidden by giving it any tag starting with (or just) a period (```.```) - or, in the deprecated case, tagged ```[hide]``` or given name starting with `'./'`. To specify hidden tests from the command line ```[.]``` or ```[hide]``` can be used *regardless of how they were declared*. +There are three basic test specs that can then be combined into more +complex specs: -Specs must be enclosed in quotes if they contain spaces. If they do not contain spaces the quotes are optional. + * Full test name, e.g. `"Test 1"`. -Wildcards consist of the `*` character at the beginning and/or end of test case names and can substitute for any number of any characters (including none). + This allows only test cases whose name is "Test 1". -Test specs are case insensitive. + * Wildcarded test name, e.g. `"*Test"`, or `"Test*"`, or `"*Test*"`. -If a spec is prefixed with `exclude:` or the `~` character then the pattern matches an exclusion. This means that tests matching the pattern are excluded from the set - even if a prior inclusion spec included them. Subsequent inclusion specs will take precedence, however. -Inclusions and exclusions are evaluated in left-to-right order. + This allows any test case whose name ends with, starts with, or contains + in the middle the string "Test". Note that the wildcard can only be at + the start or end. -Test case examples: + * Tag name, e.g. `[some-tag]`. + This allows any test case tagged with "[some-tag]". Remember that some + tags are special, e.g. those that start with "." or with "!". + + +You can also combine the basic test specs to create more complex test +specs. You can: + + * Concatenate specs to apply all of them, e.g. `[some-tag][other-tag]`. + + This allows test cases that are tagged with **both** "[some-tag]" **and** + "[other-tag]". A test case with just "[some-tag]" will not pass the filter, + nor will test case with just "[other-tag]". + + * Comma-join specs to apply any of them, e.g. `[some-tag],[other-tag]`. + + This allows test cases that are tagged with **either** "[some-tag]" **or** + "[other-tag]". A test case with both will obviously also pass the filter. + + Note that commas take precendence over simple concatenation. This means + that `[a][b],[c]` accepts tests that are tagged with either both "[a]" and + "[b]", or tests that are tagged with just "[c]". + + * Negate the spec by prepending it with `~`, e.g. `~[some-tag]`. + + This rejects any test case that is tagged with "[some-tag]". Note that + rejection takes precedence over other filters. + + Note that negations always binds to the following _basic_ test spec. + This means that `~[foo][bar]` negates only the "[foo]" tag and not the + "[bar]" tag. + +Note that when Catch2 is deciding whether to include a test, first it +checks whether the test matches any negative filters. If it does, +the test is rejected. After that, the behaviour depends on whether there +are positive filters as well. If there are no positive filters, all +remaining non-hidden tests are included. If there are positive filters, +only tests that match the positive filters are included. + +You can also match test names with special characters by escaping them +with a backslash (`"\"`), e.g. a test named `"Do A, then B"` is matched +by "Do A\, then B" test spec. Backslash also escapes itself. + + +### Examples + +Given these TEST_CASEs, ``` -thisTestOnly Matches the test case called, 'thisTestOnly' -"this test only" Matches the test case called, 'this test only' -these* Matches all cases starting with 'these' -exclude:notThis Matches all tests except, 'notThis' -~notThis Matches all tests except, 'notThis' -~*private* Matches all tests except those that contain 'private' -a* ~ab* abc Matches all tests that start with 'a', except those that - start with 'ab', except 'abc', which is included -~[tag1] Matches all tests except those tagged with '[tag1]' --# [#somefile] Matches all tests from the file 'somefile.cpp' +TEST_CASE("Test 1") {} + +TEST_CASE("Test 2", "[.foo]") {} + +TEST_CASE("Test 3", "[.bar]") {} + +TEST_CASE("Test 4", "[.][foo][bar]") {} ``` -Names within square brackets are interpreted as tags. -A series of tags form an AND expression whereas a comma-separated sequence forms an OR expression. e.g.: +this is the result of these filters +``` +./tests # Selects only the first test, others are hidden +./tests "Test 1" # Selects only the first test, other do not match +./tests ~"Test 1" # Selects no tests. Test 1 is rejected, other tests are hidden +./tests "Test *" # Selects all tests. +./tests [bar] # Selects tests 3 and 4. Other tests are not tagged [bar] +./tests ~[foo] # Selects test 1, because it is the only non-hidden test without [foo] tag +./tests [foo][bar] # Selects test 4. +./tests [foo],[bar] # Selects tests 2, 3, 4. +./tests ~[foo][bar] # Selects test 3. 2 and 4 are rejected due to having [foo] tag +./tests ~"Test 2"[foo] # Selects test 4, because test 2 is explicitly rejected +./tests [foo][bar],"Test 1" # Selects tests 1 and 4. +./tests "Test 1*" # Selects test 1, wildcard can match zero characters +``` -
[one][two],[three]
-This matches all tests tagged `[one]` and `[two]`, as well as all tests tagged `[three]` +_Note: Using plain asterisk on a command line can cause issues with shell +expansion. Make sure that the asterisk is passed to Catch2 and is not +interpreted by the shell._ -Test names containing special characters, such as `,` or `[` can specify them on the command line using `\`. -`\` also escapes itself. ## Choosing a reporter to use diff --git a/external_imported/Catch2/docs/configuration.md b/external_imported/Catch2/docs/configuration.md index d4421f3c0..8a3ddfab5 100644 --- a/external_imported/Catch2/docs/configuration.md +++ b/external_imported/Catch2/docs/configuration.md @@ -15,6 +15,7 @@ [Enabling stringification](#enabling-stringification)
[Disabling exceptions](#disabling-exceptions)
[Overriding Catch's debug break (`-b`)](#overriding-catchs-debug-break--b)
+[Static analysis support](#static-analysis-support)
Catch2 is designed to "just work" as much as possible, and most of the configuration options below are changed automatically during compilation, @@ -25,7 +26,8 @@ with the same name. ## Prefixing Catch macros - CATCH_CONFIG_PREFIX_ALL + CATCH_CONFIG_PREFIX_ALL // Prefix all macros with CATCH_ + CATCH_CONFIG_PREFIX_MESSAGES // Prefix only INFO, UNSCOPED_INFO, WARN and CAPTURE To keep test code clean and uncluttered Catch uses short macro names (e.g. ```TEST_CASE``` and ```REQUIRE```). Occasionally these may conflict with identifiers from platform headers or the system under test. In this case the above identifier can be defined. This will cause all the Catch user macros to be prefixed with ```CATCH_``` (e.g. ```CATCH_TEST_CASE``` and ```CATCH_REQUIRE```). @@ -264,6 +266,31 @@ The macro will be used as is, that is, `CATCH_BREAK_INTO_DEBUGGER();` must compile and must break into debugger. +## Static analysis support + +> Introduced in Catch2 3.4.0. + +Some parts of Catch2, e.g. `SECTION`s, can be hard for static analysis +tools to reason about. Catch2 can change its internals to help static +analysis tools reason about the tests. + +Catch2 automatically detects some static analysis tools (initial +implementation checks for clang-tidy and Coverity), but you can override +its detection (in either direction) via + +``` +CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT // force enables static analysis help +CATCH_CONFIG_NO_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT // force disables static analysis help +``` + +_As the name suggests, this is currently experimental, and thus we provide +no backwards compatibility guarantees._ + +**DO NOT ENABLE THIS FOR BUILDS YOU INTEND TO RUN.** The changed internals +are not meant to be runnable, only "scannable". + + + --- [Home](Readme.md#top) diff --git a/external_imported/Catch2/docs/faq.md b/external_imported/Catch2/docs/faq.md index 0f303ee50..80923d26e 100644 --- a/external_imported/Catch2/docs/faq.md +++ b/external_imported/Catch2/docs/faq.md @@ -10,6 +10,7 @@ [Does Catch2 support running tests in parallel?](#does-catch2-support-running-tests-in-parallel)
[Can I compile Catch2 into a dynamic library?](#can-i-compile-catch2-into-a-dynamic-library)
[What repeatability guarantees does Catch2 provide?](#what-repeatability-guarantees-does-catch2-provide)
+[My build cannot find `catch2/catch_user_config.hpp`, how can I fix it?](#my-build-cannot-find-catch2catch_user_confighpp-how-can-i-fix-it)
## How do I run global setup/teardown only if tests will be run? @@ -28,7 +29,7 @@ depending on how often the cleanup needs to happen. ## Why cannot I derive from the built-in reporters? They are not made to be overridden, in that we do not attempt to maintain -a consistent internal state if a member function is overriden, and by +a consistent internal state if a member function is overridden, and by forbidding users from using them as a base class, we can refactor them as needed later. @@ -83,12 +84,30 @@ and it is also generally repeatable across versions, but we might break it from time to time. E.g. we broke repeatability with previous versions in v2.13.4 so that test cases with similar names are shuffled better. -Random generators currently rely on platform's stdlib, specifically -the distributions from ``. We thus provide no extra guarantee -above what your platform does. **Important: ``'s distributions +Since Catch2 3.5.0 the random generators use custom distributions, +that should be repeatable across different platforms, with few caveats. +For details see the section on random generators in the [Generator +documentation](generators.md#random-number-generators-details). + +Before this version, random generators relied on distributions from +platform's stdlib. We thus can provide no extra guarantee on top of the +ones given by your platform. **Important: ``'s distributions are not specified to be repeatable across different platforms.** +## My build cannot find `catch2/catch_user_config.hpp`, how can I fix it? + +`catch2/catch_user_config.hpp` is a generated header that contains user +compile time configuration. It is generated by CMake/Meson/Bazel during +build. If you are not using either of these, your three options are to + +1) Build Catch2 separately using build tool that will generate the header +2) Use the amalgamated files to build Catch2 +3) Use CMake to configure a build. This will generate the header and you + can copy it into your own checkout of Catch2. + + + --- [Home](Readme.md#top) diff --git a/external_imported/Catch2/docs/generators.md b/external_imported/Catch2/docs/generators.md index 69d1a02d1..8bca54c75 100644 --- a/external_imported/Catch2/docs/generators.md +++ b/external_imported/Catch2/docs/generators.md @@ -134,7 +134,7 @@ type, making their usage much nicer. These are * `map(func, GeneratorWrapper&&)` for `MapGenerator` (map `U` to `T`) * `chunk(chunk-size, GeneratorWrapper&&)` for `ChunkGenerator` * `random(IntegerOrFloat a, IntegerOrFloat b)` for `RandomIntegerGenerator` or `RandomFloatGenerator` -* `range(Arithemtic start, Arithmetic end)` for `RangeGenerator` with a step size of `1` +* `range(Arithmetic start, Arithmetic end)` for `RangeGenerator` with a step size of `1` * `range(Arithmetic start, Arithmetic end, Arithmetic step)` for `RangeGenerator` with a custom step size * `from_range(InputIterator from, InputIterator to)` for `IteratorGenerator` * `from_range(Container const&)` for `IteratorGenerator` @@ -189,6 +189,31 @@ TEST_CASE("type conversion", "[generators]") { } ``` + +### Random number generators: details + +> This section applies from Catch2 3.5.0. Before that, random generators +> were a thin wrapper around distributions from ``. + +All of the `random(a, b)` generators in Catch2 currently generate uniformly +distributed number in closed interval \[a; b\]. This is different from +`std::uniform_real_distribution`, which should return numbers in interval +\[a; b) (but due to rounding can end up returning b anyway), but the +difference is intentional, so that `random(a, a)` makes sense. If there is +enough interest from users, we can provide API to pick any of CC, CO, OC, +or OO ranges. + +Unlike `std::uniform_int_distribution`, Catch2's generators also support +various single-byte integral types, such as `char` or `bool`. + +Given the same seed, the output from the integral generators is +reproducible across different platforms. For floating point generators, +we only promise reproducibility on platforms that obey the IEEE 754 +standard, and where `float` is 4 bytes and `double` is 8 bytes. We provide +no guarantees for `long double`, as the internals of `long double` can +vary wildly across different platforms. + + ## Generator interface You can also implement your own generators, by deriving from the @@ -221,3 +246,21 @@ For full example of implementing your own generator, look into Catch2's examples, specifically [Generators: Create your own generator](../examples/300-Gen-OwnGenerator.cpp). + +### Handling empty generators + +The generator interface assumes that a generator always has at least one +element. This is not always true, e.g. if the generator depends on an external +datafile, the file might be missing. + +There are two ways to handle this, depending on whether you want this +to be an error or not. + + * If empty generator **is** an error, throw an exception in constructor. + * If empty generator **is not** an error, use the [`SKIP`](skipping-passing-failing.md#skipping-test-cases-at-runtime) in constructor. + + + +--- + +[Home](Readme.md#top) diff --git a/external_imported/Catch2/docs/limitations.md b/external_imported/Catch2/docs/limitations.md index cc0ed05d1..099dd82a5 100644 --- a/external_imported/Catch2/docs/limitations.md +++ b/external_imported/Catch2/docs/limitations.md @@ -173,13 +173,3 @@ TEST_CASE("b") { If you are seeing a problem like this, i.e. weird test paths that trigger only under Clang with `libc++`, or only under very specific version of `libstdc++`, it is very likely you are seeing this. The only known workaround is to use a fixed version of your standard library. - -### libstdc++, `_GLIBCXX_DEBUG` macro and random ordering of tests - -Running a Catch2 binary compiled against libstdc++ with `_GLIBCXX_DEBUG` -macro defined with `--order rand` will cause a debug check to trigger and -abort the run due to self-assignment. -[This is a known bug inside libstdc++](https://stackoverflow.com/questions/22915325/avoiding-self-assignment-in-stdshuffle/23691322) - -Workaround: Don't use `--order rand` when compiling against debug-enabled -libstdc++. diff --git a/external_imported/Catch2/docs/matchers.md b/external_imported/Catch2/docs/matchers.md index 14c158982..d5be1f5a3 100644 --- a/external_imported/Catch2/docs/matchers.md +++ b/external_imported/Catch2/docs/matchers.md @@ -50,25 +50,43 @@ Both of the string matchers used in the examples above live in the `catch_matchers_string.hpp` header, so to compile the code above also requires `#include `. +### Combining operators and lifetimes + **IMPORTANT**: The combining operators do not take ownership of the -matcher objects being combined. This means that if you store combined -matcher object, you have to ensure that the matchers being combined -outlive its last use. What this means is that the following code leads -to a use-after-free (UAF): +matcher objects being combined. + +This means that if you store combined matcher object, you have to ensure +that the individual matchers being combined outlive the combined matcher. +Note that the negation matcher from `!` also counts as combining matcher +for this. +Explained on an example, this is fine ```cpp -#include -#include +CHECK_THAT(value, WithinAbs(0, 2e-2) && !WithinULP(0., 1)); +``` -TEST_CASE("Bugs, bugs, bugs", "[Bug]"){ - std::string str = "Bugs as a service"; +and so is this +```cpp +auto is_close_to_zero = WithinAbs(0, 2e-2); +auto is_zero = WithinULP(0., 1); - auto match_expression = Catch::Matchers::EndsWith( "as a service" ) || - (Catch::Matchers::StartsWith( "Big data" ) && !Catch::Matchers::ContainsSubstring( "web scale" ) ); - REQUIRE_THAT(str, match_expression); -} +CHECK_THAT(value, is_close_to_zero && !is_zero); ``` +but this is not +```cpp +auto is_close_to_zero = WithinAbs(0, 2e-2); +auto is_zero = WithinULP(0., 1); +auto is_close_to_but_not_zero = is_close_to_zero && !is_zero; + +CHECK_THAT(a_value, is_close_to_but_not_zero); // UAF +``` + +because `!is_zero` creates a temporary instance of Negation matcher, +which the `is_close_to_but_not_zero` refers to. After the line ends, +the temporary is destroyed and the combined `is_close_to_but_not_zero` +matcher now refers to non-existent object, so using it causes use-after-free. + ## Built-in matchers @@ -286,7 +304,7 @@ comparable. (e.g. you may compare `std::vector` to `std::array`). `UnorderedRangeEquals` is similar to `RangeEquals`, but the order does not matter. For example "1, 2, 3" would match "3, 2, 1", but not "1, 1, 2, 3" As with `RangeEquals`, `UnorderedRangeEquals` compares -the individual elements using using `operator==` by default. +the individual elements using `operator==` by default. Both `RangeEquals` and `UnorderedRangeEquals` optionally accept a predicate which can be used to compare the containers element-wise. diff --git a/external_imported/Catch2/docs/opensource-users.md b/external_imported/Catch2/docs/opensource-users.md index 12b4551c5..a02d0b98e 100644 --- a/external_imported/Catch2/docs/opensource-users.md +++ b/external_imported/Catch2/docs/opensource-users.md @@ -95,6 +95,9 @@ A C++ client library for Consul. Consul is a distributed tool for discovering an ### [Reactive-Extensions/ RxCpp](https://github.com/Reactive-Extensions/RxCpp) A library of algorithms for values-distributed-in-time. +### [SFML](https://github.com/SFML/SFML) +Simple and Fast Multimedia Library. + ### [SOCI](https://github.com/SOCI/soci) The C++ Database Access Library. @@ -110,6 +113,12 @@ A header-only TOML parser and serializer for modern C++. ### [Trompeloeil](https://github.com/rollbear/trompeloeil) A thread-safe header-only mocking framework for C++14. +### [wxWidgets](https://www.wxwidgets.org/) +Cross-Platform C++ GUI Library. + +### [xmlwrapp](https://github.com/vslavik/xmlwrapp) +C++ XML parsing library using libxml2. + ## Applications & Tools ### [App Mesh](https://github.com/laoshanxi/app-mesh) @@ -137,7 +146,7 @@ Newsbeuter is an open-source RSS/Atom feed reader for text terminals. A 2D, Zombie, RPG game which is being made on our own engine. ### [raspigcd](https://github.com/pantadeusz/raspigcd) -Low level CLI app and library for execution of GCODE on Raspberry Pi without any additional microcontrolers (just RPi + Stepsticks). +Low level CLI app and library for execution of GCODE on Raspberry Pi without any additional microcontrollers (just RPi + Stepsticks). ### [SpECTRE](https://github.com/sxs-collaboration/spectre) SpECTRE is a code for multi-scale, multi-physics problems in astrophysics and gravitational physics. diff --git a/external_imported/Catch2/docs/release-notes.md b/external_imported/Catch2/docs/release-notes.md index 1fa37da43..ca7f4ddee 100644 --- a/external_imported/Catch2/docs/release-notes.md +++ b/external_imported/Catch2/docs/release-notes.md @@ -2,6 +2,10 @@ # Release notes **Contents**
+[3.5.2](#352)
+[3.5.1](#351)
+[3.5.0](#350)
+[3.4.0](#340)
[3.3.2](#332)
[3.3.1](#331)
[3.3.0](#330)
@@ -56,6 +60,87 @@ [Even Older versions](#even-older-versions)
+## 3.5.1 + +### Fixes +* Fixed `-Wsubobject-linkage` in the Console reporter (#2794) +* Fixed adding new CLI Options to lvalue parser using `|` (#2787) + + +## 3.5.1 + +### Improvements +* Significantly improved performance of the CLI parsing. + * This includes the cost of preparing the CLI parser, so Catch2's binaries start much faster. + +### Miscellaneous +* Added support for Bazel modules (#2781) +* Added CMake option to disable the build reproducibility settings (#2785) +* Added `log` library linking to the Meson build (#2784) + + +## 3.5.0 + +### Improvements +* Introduced `CATCH_CONFIG_PREFIX_MESSAGES` to prefix only logging macros (#2544) + * This means `INFO`, `UNSCOPED_INFO`, `WARN` and `CAPTURE`. +* Section hints in static analysis mode are now `const` + * This prevents Clang-Tidy from complaining about `misc-const-correctness`. +* `from_range` generator supports C arrays and ranges that require ADL (#2737) +* Stringification support for `std::optional` now also includes `std::nullopt` (#2740) +* The Console reporter flushes output after writing benchmark runtime estimate. + * This means that you can immediately see for how long the benchmark is expected to run. +* Added workaround to enable compilation with ICC 19.1 (#2551, #2766) +* Compiling Catch2 for XBox should work out of the box (#2772) + * Catch2 should automatically disable getenv when compiled for XBox. +* Compiling Catch2 with exceptions disabled no longer triggers `Wunused-function` (#2726) +* **`random` Generators for integral types are now reproducible across different platforms** + * Unlike ``, Catch2's generators also support 1 byte integral types (`char`, `bool`, ...) +* **`random` Generators for `float` and `double` are now reproducible across different platforms** + * `long double` varies across different platforms too much to be reproducible + * This guarantee applies only to platforms with IEEE 754 floats. + +### Fixes +* UDL declaration inside Catch2 are now strictly conforming to the standard + * `operator "" _a` is UB, `operator ""_a` is fine. Seriously. +* Fixed `CAPTURE` tests failing to compile in C++23 mode (#2744) +* Fixed missing include in `catch_message.hpp` (#2758) +* Fixed `CHECK_ELSE` suppressing failure from uncaught exceptions(#2723) + +### Miscellaneous +* The documentation for specifying which tests to run through commandline has been completely rewritten (#2738) +* Fixed installation when building Catch2 with meson (#2722, #2742) +* Fixed `catch_discover_tests` when using custom reporter and `PRE_TEST` discovery mode (#2747) +* `catch_discover_tests` supports multi-config CMake generator in `PRE_TEST` discovery mode (#2739, #2746) + + +## 3.4.0 + +### Improvements +* `VectorEquals` supports elements that provide only `==` and not `!=` (#2648) +* Catch2 supports compiling with IAR compiler (#2651) +* Various small internal performance improvements +* Various small internal compilation time improvements +* XMLReporter now reports location info for INFO and WARN (#1251) + * This bumps up the xml format version to 3 +* Documented that `SKIP` in generator constructor can be used to handle empty generator (#1593) +* Added experimental static analysis support to `TEST_CASE` and `SECTION` macros (#2681) + * The two macros are redefined in a way that helps the SA tools reason about the possible paths through a test case with sections. + * The support is controlled by the `CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT` option and autodetects clang-tidy and Coverity. +* `*_THROWS`, `*_THROWS_AS`, etc now suppress warning coming from `__attribute__((warn_unused_result))` on GCC (#2691) + * Unlike plain `[[nodiscard]]`, this warning is not silenced by void cast. WTF GCC? + +### Fixes +* Fixed `assertionStarting` events being sent after the expr is evaluated (#2678) +* Errors in `TEST_CASE` tags are now reported nicely (#2650) + +### Miscellaneous +* Bunch of improvements to `catch_discover_tests` + * Added DISCOVERY_MODE option, so the discovery can happen either post build or pre-run. + * Fixed handling of semicolons and backslashes in test names (#2674, #2676) +* meson build can disable building tests (#2693) +* meson build properly sets meson version 0.54.1 as the minimal supported version (#2688) + ## 3.3.2 @@ -149,7 +234,7 @@ ### Fixes * Cleaned out some warnings and static analysis issues - * Suppressed `-Wcomma` warning rarely occuring in templated test cases (#2543) + * Suppressed `-Wcomma` warning rarely occurring in templated test cases (#2543) * Constified implementation details in `INFO` (#2564) * Made `MatcherGenericBase` copy constructor const (#2566) * Fixed serialization of test filters so the output roundtrips @@ -352,7 +437,7 @@ v3 releases. * Added `STATIC_CHECK` macro, similar to `STATIC_REQUIRE` (#2318) * When deferred tu runtime, it behaves like `CHECK`, and not like `REQUIRE`. * You can have multiple tests with the same name, as long as other parts of the test identity differ (#1915, #1999, #2175) - * Test identity includes test's name, test's tags and and test's class name if applicable. + * Test identity includes test's name, test's tags and test's class name if applicable. * Added new warning, `UnmatchedTestSpec`, to error on test specs with no matching tests * The `-w`, `--warn` warning flags can now be provided multiple times to enable multiple warnings * The case-insensitive handling of tags is now more reliable and takes up less memory @@ -517,7 +602,7 @@ v3 releases. * The `SECTION`(s) before the `GENERATE` will not be run multiple times, the following ones will. * Added `-D`/`--min-duration` command line flag (#1910) * If a test takes longer to finish than the provided value, its name and duration will be printed. - * This flag is overriden by setting `-d`/`--duration`. + * This flag is overridden by setting `-d`/`--duration`. ### Fixes * `TAPReporter` no longer skips successful assertions (#1983) @@ -585,7 +670,7 @@ v3 releases. ### Fixes * Fixed computation of benchmarking column widths in ConsoleReporter (#1885, #1886) * Suppressed clang-tidy's `cppcoreguidelines-pro-type-vararg` in assertions (#1901) - * It was a false positive trigered by the new warning support workaround + * It was a false positive triggered by the new warning support workaround * Fixed bug in test specification parser handling of OR'd patterns using escaping (#1905) ### Miscellaneous @@ -922,7 +1007,7 @@ v3 releases. ### Contrib * `ParseAndAddCatchTests` has learned how to use `DISABLED` CTest property (#1452) -* `ParseAndAddCatchTests` now works when there is a whitspace before the test name (#1493) +* `ParseAndAddCatchTests` now works when there is a whitespace before the test name (#1493) ### Miscellaneous diff --git a/external_imported/Catch2/docs/reporter-events.md b/external_imported/Catch2/docs/reporter-events.md index 32a0ae507..015f67be4 100644 --- a/external_imported/Catch2/docs/reporter-events.md +++ b/external_imported/Catch2/docs/reporter-events.md @@ -96,12 +96,12 @@ void assertionStarting( AssertionInfo const& assertionInfo ); void assertionEnded( AssertionStats const& assertionStats ); ``` -`assertionStarting` is called after the expression is captured, but before -the assertion expression is evaluated. This might seem like a minor -distinction, but what it means is that if you have assertion like -`REQUIRE( a + b == c + d )`, then what happens is that `a + b` and `c + d` -are evaluated before `assertionStarting` is emitted, while the `==` is -evaluated after the event. +The `assertionStarting` event is emitted before the expression in the +assertion is captured or evaluated and `assertionEnded` is emitted +afterwards. This means that given assertion like `REQUIRE(a + b == c + d)`, +Catch2 first emits `assertionStarting` event, then `a + b` and `c + d` +are evaluated, then their results are captured, the comparison is evaluated, +and then `assertionEnded` event is emitted. ## Benchmarking events diff --git a/external_imported/Catch2/docs/reporters.md b/external_imported/Catch2/docs/reporters.md index 496c61a92..e2abfe34d 100644 --- a/external_imported/Catch2/docs/reporters.md +++ b/external_imported/Catch2/docs/reporters.md @@ -52,7 +52,7 @@ its machine-readable XML output to file `result-junit.xml`, and the uses ANSI colour codes for colouring the output. Using multiple reporters (or one reporter and one-or-more [event -listeners](event-listener.md#top)) can have surprisingly complex semantics +listeners](event-listeners.md#top)) can have surprisingly complex semantics when using customization points provided to reporters by Catch2, namely capturing stdout/stderr from test cases. diff --git a/external_imported/Catch2/docs/skipping-passing-failing.md b/external_imported/Catch2/docs/skipping-passing-failing.md index 4300d9d32..52bb18f76 100644 --- a/external_imported/Catch2/docs/skipping-passing-failing.md +++ b/external_imported/Catch2/docs/skipping-passing-failing.md @@ -9,7 +9,7 @@ In some situations it may not be possible to meaningfully execute a test case, for example when the system under test is missing certain hardware capabilities. If the required conditions can only be determined at runtime, it often doesn't make sense to consider such a test case as either passed or failed, -because it simply can not run at all. +because it simply cannot run at all. To properly express such scenarios, Catch2 provides a way to explicitly _skip_ test cases, using the `SKIP` macro: @@ -84,6 +84,12 @@ exit code, same as it does if no test cases have run. This behaviour can be overridden using the [--allow-running-no-tests](command-line.md#no-tests-override) flag. +### `SKIP` inside generators + +You can also use the `SKIP` macro inside generator's constructor to handle +cases where the generator is empty, but you do not want to fail the test +case. + ## Passing and failing test cases diff --git a/external_imported/Catch2/docs/test-cases-and-sections.md b/external_imported/Catch2/docs/test-cases-and-sections.md index acebcc51d..01c898bb6 100644 --- a/external_imported/Catch2/docs/test-cases-and-sections.md +++ b/external_imported/Catch2/docs/test-cases-and-sections.md @@ -231,7 +231,7 @@ TEMPLATE_TEST_CASE( "vectors can be sized and resized", "[vector][template]", in > [Introduced](https://github.com/catchorg/Catch2/issues/1468) in Catch2 2.6.0. -_template-type1_ through _template-typen_ is list of template template +_template-type1_ through _template-typen_ is list of template types which should be combined with each of _template-arg1_ through _template-argm_, resulting in _n * m_ test cases. Inside the test case, the resulting type is available under the name of `TestType`. diff --git a/external_imported/Catch2/docs/tostring.md b/external_imported/Catch2/docs/tostring.md index adce3cc76..b99b67426 100644 --- a/external_imported/Catch2/docs/tostring.md +++ b/external_imported/Catch2/docs/tostring.md @@ -75,7 +75,7 @@ CATCH_TRANSLATE_EXCEPTION( MyType const& ex ) { Enums that already have a `<<` overload for `std::ostream` will convert to strings as expected. If you only need to convert enums to strings for test reporting purposes you can provide a `StringMaker` specialisations as any other type. -However, as a convenience, Catch provides the `REGISTER_ENUM` helper macro that will generate the `StringMaker` specialiation for you with minimal code. +However, as a convenience, Catch provides the `REGISTER_ENUM` helper macro that will generate the `StringMaker` specialisation for you with minimal code. Simply provide it the (qualified) enum name, followed by all the enum values, and you're done! E.g. diff --git a/external_imported/Catch2/docs/tutorial.md b/external_imported/Catch2/docs/tutorial.md index 342c73818..dfccac888 100644 --- a/external_imported/Catch2/docs/tutorial.md +++ b/external_imported/Catch2/docs/tutorial.md @@ -119,7 +119,7 @@ This is best explained through an example ([code](../examples/100-Fix-Section.cp ```c++ TEST_CASE( "vectors can be sized and resized", "[vector]" ) { - + // This setup will be done 4 times in total, once for each section std::vector v( 5 ); REQUIRE( v.size() == 5 ); @@ -152,11 +152,12 @@ TEST_CASE( "vectors can be sized and resized", "[vector]" ) { } ``` -For each `SECTION` the `TEST_CASE` is executed from the start. This means +For each `SECTION` the `TEST_CASE` is **executed from the start**. This means that each section is entered with a freshly constructed vector `v`, that we know has size 5 and capacity at least 5, because the two assertions -are also checked before the section is entered. Each run through a test -case will execute one, and only one, leaf section. +are also checked before the section is entered. This behaviour may not be +ideal for tests where setup is expensive. Each run through a test case will +execute one, and only one, leaf section. Section can also be nested, in which case the parent section can be entered multiple times, once for each leaf section. Nested sections are diff --git a/external_imported/Catch2/docs/why-catch.md b/external_imported/Catch2/docs/why-catch.md index 2c0178ca5..b7367496b 100644 --- a/external_imported/Catch2/docs/why-catch.md +++ b/external_imported/Catch2/docs/why-catch.md @@ -30,7 +30,7 @@ So what does Catch2 bring to the party that differentiates it from these? Apart * Output is through modular reporter objects. Basic textual and XML reporters are included. Custom reporters can easily be added. * JUnit xml output is supported for integration with third-party tools, such as CI servers. * A default main() function is provided, but you can supply your own for complete control (e.g. integration into your own test runner GUI). -* A command line parser is provided and can still be used if you choose to provided your own main() function. +* A command line parser is provided and can still be used if you choose to provide your own main() function. * Alternative assertion macro(s) report failures but don't abort the test case * Good set of facilities for floating point comparisons (`Catch::Approx` and full set of matchers) * Internal and friendly macros are isolated so name clashes can be managed @@ -41,8 +41,8 @@ So what does Catch2 bring to the party that differentiates it from these? Apart ## Who else is using Catch2? -A whole lot of people. According to the 2021 JetBrains C++ ecosystem survey, -about 11% of C++ programmers use Catch2 for unit testing, making it the +A whole lot of people. According to [the 2022 JetBrains C++ ecosystem survey](https://www.jetbrains.com/lp/devecosystem-2022/cpp/#Which-unit-testing-frameworks-do-you-regularly-use), +about 12% of C++ programmers use Catch2 for unit testing, making it the second most popular unit testing framework. You can also take a look at the (incomplete) list of [open source projects](opensource-users.md#top) diff --git a/external_imported/Catch2/examples/010-TestCase.cpp b/external_imported/Catch2/examples/010-TestCase.cpp index 7ec208d5f..9e5cd8cd3 100644 --- a/external_imported/Catch2/examples/010-TestCase.cpp +++ b/external_imported/Catch2/examples/010-TestCase.cpp @@ -1,3 +1,11 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + // 010-TestCase.cpp // And write tests in the same file: #include diff --git a/external_imported/Catch2/examples/020-TestCase-1.cpp b/external_imported/Catch2/examples/020-TestCase-1.cpp index cec55799a..a9d87dbcb 100644 --- a/external_imported/Catch2/examples/020-TestCase-1.cpp +++ b/external_imported/Catch2/examples/020-TestCase-1.cpp @@ -1,3 +1,11 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + // 020-TestCase-1.cpp #include diff --git a/external_imported/Catch2/examples/020-TestCase-2.cpp b/external_imported/Catch2/examples/020-TestCase-2.cpp index 3f5767b34..72dd0ffb6 100644 --- a/external_imported/Catch2/examples/020-TestCase-2.cpp +++ b/external_imported/Catch2/examples/020-TestCase-2.cpp @@ -1,3 +1,11 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + // 020-TestCase-2.cpp // main() provided by Catch in file 020-TestCase-1.cpp. diff --git a/external_imported/Catch2/examples/030-Asn-Require-Check.cpp b/external_imported/Catch2/examples/030-Asn-Require-Check.cpp index 0d027ca93..62cd3cfc4 100644 --- a/external_imported/Catch2/examples/030-Asn-Require-Check.cpp +++ b/external_imported/Catch2/examples/030-Asn-Require-Check.cpp @@ -1,3 +1,11 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + // 030-Asn-Require-Check.cpp // Catch has two natural expression assertion macro's: diff --git a/external_imported/Catch2/examples/100-Fix-Section.cpp b/external_imported/Catch2/examples/100-Fix-Section.cpp index cfbfa79f9..7c8d8aa86 100644 --- a/external_imported/Catch2/examples/100-Fix-Section.cpp +++ b/external_imported/Catch2/examples/100-Fix-Section.cpp @@ -1,3 +1,11 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + // 100-Fix-Section.cpp // Catch has two ways to express fixtures: diff --git a/external_imported/Catch2/examples/110-Fix-ClassFixture.cpp b/external_imported/Catch2/examples/110-Fix-ClassFixture.cpp index 75c10da62..614c37979 100644 --- a/external_imported/Catch2/examples/110-Fix-ClassFixture.cpp +++ b/external_imported/Catch2/examples/110-Fix-ClassFixture.cpp @@ -1,3 +1,11 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + // 110-Fix-ClassFixture.cpp // Catch has two ways to express fixtures: diff --git a/external_imported/Catch2/examples/120-Bdd-ScenarioGivenWhenThen.cpp b/external_imported/Catch2/examples/120-Bdd-ScenarioGivenWhenThen.cpp index 99cdf9ab9..345d53c38 100644 --- a/external_imported/Catch2/examples/120-Bdd-ScenarioGivenWhenThen.cpp +++ b/external_imported/Catch2/examples/120-Bdd-ScenarioGivenWhenThen.cpp @@ -1,3 +1,11 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + // 120-Bdd-ScenarioGivenWhenThen.cpp // main() provided by linkage with Catch2WithMain diff --git a/external_imported/Catch2/examples/210-Evt-EventListeners.cpp b/external_imported/Catch2/examples/210-Evt-EventListeners.cpp index 6cedb885c..56b050d41 100644 --- a/external_imported/Catch2/examples/210-Evt-EventListeners.cpp +++ b/external_imported/Catch2/examples/210-Evt-EventListeners.cpp @@ -1,3 +1,11 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + // 210-Evt-EventListeners.cpp // Contents: diff --git a/external_imported/Catch2/examples/231-Cfg-OutputStreams.cpp b/external_imported/Catch2/examples/231-Cfg-OutputStreams.cpp index b77c12735..da1713cf8 100644 --- a/external_imported/Catch2/examples/231-Cfg-OutputStreams.cpp +++ b/external_imported/Catch2/examples/231-Cfg-OutputStreams.cpp @@ -1,3 +1,11 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + // 231-Cfg-OutputStreams.cpp // Show how to replace the streams with a simple custom made streambuf. diff --git a/external_imported/Catch2/examples/232-Cfg-CustomMain.cpp b/external_imported/Catch2/examples/232-Cfg-CustomMain.cpp new file mode 100644 index 000000000..69fba7f16 --- /dev/null +++ b/external_imported/Catch2/examples/232-Cfg-CustomMain.cpp @@ -0,0 +1,41 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +// 232-Cfg-CustomMain.cpp +// Show how to use custom main and add a custom option to the CLI parser + +#include + +#include + +int main(int argc, char** argv) { + Catch::Session session; // There must be exactly one instance + + int height = 0; // Some user variable you want to be able to set + + // Build a new parser on top of Catch2's + using namespace Catch::Clara; + auto cli + = session.cli() // Get Catch2's command line parser + | Opt( height, "height" ) // bind variable to a new option, with a hint string + ["--height"] // the option names it will respond to + ("how high?"); // description string for the help output + + // Now pass the new composite back to Catch2 so it uses that + session.cli( cli ); + + // Let Catch2 (using Clara) parse the command line + int returnCode = session.applyCommandLine( argc, argv ); + if( returnCode != 0 ) // Indicates a command line error + return returnCode; + + // if set on the command line then 'height' is now set at this point + std::cout << "height: " << height << std::endl; + + return session.run(); +} diff --git a/external_imported/Catch2/examples/300-Gen-OwnGenerator.cpp b/external_imported/Catch2/examples/300-Gen-OwnGenerator.cpp index 09643d6f7..b5d951ac4 100644 --- a/external_imported/Catch2/examples/300-Gen-OwnGenerator.cpp +++ b/external_imported/Catch2/examples/300-Gen-OwnGenerator.cpp @@ -1,3 +1,11 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + // 300-Gen-OwnGenerator.cpp // Shows how to define a custom generator. diff --git a/external_imported/Catch2/examples/301-Gen-MapTypeConversion.cpp b/external_imported/Catch2/examples/301-Gen-MapTypeConversion.cpp index ba55f65f1..a065d87ae 100644 --- a/external_imported/Catch2/examples/301-Gen-MapTypeConversion.cpp +++ b/external_imported/Catch2/examples/301-Gen-MapTypeConversion.cpp @@ -1,3 +1,11 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + // 301-Gen-MapTypeConversion.cpp // Shows how to use map to modify generator's return type. diff --git a/external_imported/Catch2/examples/302-Gen-Table.cpp b/external_imported/Catch2/examples/302-Gen-Table.cpp index 743195183..3cdb14301 100644 --- a/external_imported/Catch2/examples/302-Gen-Table.cpp +++ b/external_imported/Catch2/examples/302-Gen-Table.cpp @@ -1,3 +1,11 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + // 302-Gen-Table.cpp // Shows how to use table to run a test many times with different inputs. Lifted from examples on // issue #850. @@ -44,11 +52,11 @@ TEST_CASE("Table allows pre-computed test inputs and outputs", "[example][genera /* Possible simplifications where less legacy toolchain support is needed: * - * - With libstdc++6 or newer, the make_tuple() calls can be ommitted + * - With libstdc++6 or newer, the make_tuple() calls can be omitted * (technically C++17 but does not require -std in GCC/Clang). See * https://stackoverflow.com/questions/12436586/tuple-vector-and-initializer-list * - * - In C++17 mode std::tie() and the preceding variable delcarations can be + * - In C++17 mode std::tie() and the preceding variable declarations can be * replaced by structured bindings: auto [test_input, expected] = GENERATE( * table({ ... */ diff --git a/external_imported/Catch2/examples/310-Gen-VariablesInGenerators.cpp b/external_imported/Catch2/examples/310-Gen-VariablesInGenerators.cpp index 0339c5f18..5d24d45a1 100644 --- a/external_imported/Catch2/examples/310-Gen-VariablesInGenerators.cpp +++ b/external_imported/Catch2/examples/310-Gen-VariablesInGenerators.cpp @@ -1,3 +1,11 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + // 310-Gen-VariablesInGenerator.cpp // Shows how to use variables when creating generators. diff --git a/external_imported/Catch2/examples/311-Gen-CustomCapture.cpp b/external_imported/Catch2/examples/311-Gen-CustomCapture.cpp index d12ee7090..ee3103835 100644 --- a/external_imported/Catch2/examples/311-Gen-CustomCapture.cpp +++ b/external_imported/Catch2/examples/311-Gen-CustomCapture.cpp @@ -1,3 +1,11 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + // 311-Gen-CustomCapture.cpp // Shows how to provide custom capture list to the generator expression diff --git a/external_imported/Catch2/examples/CMakeLists.txt b/external_imported/Catch2/examples/CMakeLists.txt index f99333418..82734adab 100644 --- a/external_imported/Catch2/examples/CMakeLists.txt +++ b/external_imported/Catch2/examples/CMakeLists.txt @@ -30,6 +30,7 @@ set( SOURCES_IDIOMATIC_EXAMPLES 110-Fix-ClassFixture.cpp 120-Bdd-ScenarioGivenWhenThen.cpp 210-Evt-EventListeners.cpp + 232-Cfg-CustomMain.cpp 300-Gen-OwnGenerator.cpp 301-Gen-MapTypeConversion.cpp 302-Gen-Table.cpp @@ -53,7 +54,7 @@ set(ALL_EXAMPLE_TARGETS ) foreach( name ${ALL_EXAMPLE_TARGETS} ) - target_link_libraries( ${name} Catch2 Catch2WithMain ) + target_link_libraries( ${name} Catch2WithMain ) endforeach() diff --git a/external_imported/Catch2/extras/Catch.cmake b/external_imported/Catch2/extras/Catch.cmake index bc553591b..8f30688c5 100644 --- a/external_imported/Catch2/extras/Catch.cmake +++ b/external_imported/Catch2/extras/Catch.cmake @@ -35,8 +35,9 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``. [TEST_LIST var] [REPORTER reporter] [OUTPUT_DIR dir] - [OUTPUT_PREFIX prefix} + [OUTPUT_PREFIX prefix] [OUTPUT_SUFFIX suffix] + [DISCOVERY_MODE ] ) ``catch_discover_tests`` sets up a post-build command on the test executable @@ -123,14 +124,28 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``. test executable and when the tests are executed themselves. This requires cmake/ctest >= 3.22. + `DISCOVERY_MODE mode`` + Provides control over when ``catch_discover_tests`` performs test discovery. + By default, ``POST_BUILD`` sets up a post-build command to perform test discovery + at build time. In certain scenarios, like cross-compiling, this ``POST_BUILD`` + behavior is not desirable. By contrast, ``PRE_TEST`` delays test discovery until + just prior to test execution. This way test discovery occurs in the target environment + where the test has a better chance at finding appropriate runtime dependencies. + + ``DISCOVERY_MODE`` defaults to the value of the + ``CMAKE_CATCH_DISCOVER_TESTS_DISCOVERY_MODE`` variable if it is not passed when + calling ``catch_discover_tests``. This provides a mechanism for globally selecting + a preferred test discovery behavior without having to modify each call site. + #]=======================================================================] #------------------------------------------------------------------------------ function(catch_discover_tests TARGET) + cmake_parse_arguments( "" "" - "TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST;REPORTER;OUTPUT_DIR;OUTPUT_PREFIX;OUTPUT_SUFFIX" + "TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST;REPORTER;OUTPUT_DIR;OUTPUT_PREFIX;OUTPUT_SUFFIX;DISCOVERY_MODE" "TEST_SPEC;EXTRA_ARGS;PROPERTIES;DL_PATHS" ${ARGN} ) @@ -141,57 +156,128 @@ function(catch_discover_tests TARGET) if(NOT _TEST_LIST) set(_TEST_LIST ${TARGET}_TESTS) endif() - if (_DL_PATHS) if(${CMAKE_VERSION} VERSION_LESS "3.22.0") message(FATAL_ERROR "The DL_PATHS option requires at least cmake 3.22") endif() endif() + if(NOT _DISCOVERY_MODE) + if(NOT CMAKE_CATCH_DISCOVER_TESTS_DISCOVERY_MODE) + set(CMAKE_CATCH_DISCOVER_TESTS_DISCOVERY_MODE "POST_BUILD") + endif() + set(_DISCOVERY_MODE ${CMAKE_CATCH_DISCOVER_TESTS_DISCOVERY_MODE}) + endif() + if (NOT _DISCOVERY_MODE MATCHES "^(POST_BUILD|PRE_TEST)$") + message(FATAL_ERROR "Unknown DISCOVERY_MODE: ${_DISCOVERY_MODE}") + endif() ## Generate a unique name based on the extra arguments string(SHA1 args_hash "${_TEST_SPEC} ${_EXTRA_ARGS} ${_REPORTER} ${_OUTPUT_DIR} ${_OUTPUT_PREFIX} ${_OUTPUT_SUFFIX}") string(SUBSTRING ${args_hash} 0 7 args_hash) # Define rule to generate test list for aforementioned test executable - set(ctest_include_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_include-${args_hash}.cmake") - set(ctest_tests_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_tests-${args_hash}.cmake") + set(ctest_file_base "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}-${args_hash}") + set(ctest_include_file "${ctest_file_base}_include.cmake") + set(ctest_tests_file "${ctest_file_base}_tests.cmake") + get_property(crosscompiling_emulator TARGET ${TARGET} PROPERTY CROSSCOMPILING_EMULATOR ) - add_custom_command( - TARGET ${TARGET} POST_BUILD - BYPRODUCTS "${ctest_tests_file}" - COMMAND "${CMAKE_COMMAND}" - -D "TEST_TARGET=${TARGET}" - -D "TEST_EXECUTABLE=$" - -D "TEST_EXECUTOR=${crosscompiling_emulator}" - -D "TEST_WORKING_DIR=${_WORKING_DIRECTORY}" - -D "TEST_SPEC=${_TEST_SPEC}" - -D "TEST_EXTRA_ARGS=${_EXTRA_ARGS}" - -D "TEST_PROPERTIES=${_PROPERTIES}" - -D "TEST_PREFIX=${_TEST_PREFIX}" - -D "TEST_SUFFIX=${_TEST_SUFFIX}" - -D "TEST_LIST=${_TEST_LIST}" - -D "TEST_REPORTER=${_REPORTER}" - -D "TEST_OUTPUT_DIR=${_OUTPUT_DIR}" - -D "TEST_OUTPUT_PREFIX=${_OUTPUT_PREFIX}" - -D "TEST_OUTPUT_SUFFIX=${_OUTPUT_SUFFIX}" - -D "TEST_DL_PATHS=${_DL_PATHS}" - -D "CTEST_FILE=${ctest_tests_file}" - -P "${_CATCH_DISCOVER_TESTS_SCRIPT}" - VERBATIM - ) - file(WRITE "${ctest_include_file}" - "if(EXISTS \"${ctest_tests_file}\")\n" - " include(\"${ctest_tests_file}\")\n" - "else()\n" - " add_test(${TARGET}_NOT_BUILT-${args_hash} ${TARGET}_NOT_BUILT-${args_hash})\n" - "endif()\n" - ) + if(_DISCOVERY_MODE STREQUAL "POST_BUILD") + add_custom_command( + TARGET ${TARGET} POST_BUILD + BYPRODUCTS "${ctest_tests_file}" + COMMAND "${CMAKE_COMMAND}" + -D "TEST_TARGET=${TARGET}" + -D "TEST_EXECUTABLE=$" + -D "TEST_EXECUTOR=${crosscompiling_emulator}" + -D "TEST_WORKING_DIR=${_WORKING_DIRECTORY}" + -D "TEST_SPEC=${_TEST_SPEC}" + -D "TEST_EXTRA_ARGS=${_EXTRA_ARGS}" + -D "TEST_PROPERTIES=${_PROPERTIES}" + -D "TEST_PREFIX=${_TEST_PREFIX}" + -D "TEST_SUFFIX=${_TEST_SUFFIX}" + -D "TEST_LIST=${_TEST_LIST}" + -D "TEST_REPORTER=${_REPORTER}" + -D "TEST_OUTPUT_DIR=${_OUTPUT_DIR}" + -D "TEST_OUTPUT_PREFIX=${_OUTPUT_PREFIX}" + -D "TEST_OUTPUT_SUFFIX=${_OUTPUT_SUFFIX}" + -D "TEST_DL_PATHS=${_DL_PATHS}" + -D "CTEST_FILE=${ctest_tests_file}" + -P "${_CATCH_DISCOVER_TESTS_SCRIPT}" + VERBATIM + ) + + file(WRITE "${ctest_include_file}" + "if(EXISTS \"${ctest_tests_file}\")\n" + " include(\"${ctest_tests_file}\")\n" + "else()\n" + " add_test(${TARGET}_NOT_BUILT-${args_hash} ${TARGET}_NOT_BUILT-${args_hash})\n" + "endif()\n" + ) - if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0") + elseif(_DISCOVERY_MODE STREQUAL "PRE_TEST") + + get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL + PROPERTY GENERATOR_IS_MULTI_CONFIG + ) + + if(GENERATOR_IS_MULTI_CONFIG) + set(ctest_tests_file "${ctest_file_base}_tests-$.cmake") + endif() + + string(CONCAT ctest_include_content + "if(EXISTS \"$\")" "\n" + " if(NOT EXISTS \"${ctest_tests_file}\" OR" "\n" + " NOT \"${ctest_tests_file}\" IS_NEWER_THAN \"$\" OR\n" + " NOT \"${ctest_tests_file}\" IS_NEWER_THAN \"\${CMAKE_CURRENT_LIST_FILE}\")\n" + " include(\"${_CATCH_DISCOVER_TESTS_SCRIPT}\")" "\n" + " catch_discover_tests_impl(" "\n" + " TEST_EXECUTABLE" " [==[" "$" "]==]" "\n" + " TEST_EXECUTOR" " [==[" "${crosscompiling_emulator}" "]==]" "\n" + " TEST_WORKING_DIR" " [==[" "${_WORKING_DIRECTORY}" "]==]" "\n" + " TEST_SPEC" " [==[" "${_TEST_SPEC}" "]==]" "\n" + " TEST_EXTRA_ARGS" " [==[" "${_EXTRA_ARGS}" "]==]" "\n" + " TEST_PROPERTIES" " [==[" "${_PROPERTIES}" "]==]" "\n" + " TEST_PREFIX" " [==[" "${_TEST_PREFIX}" "]==]" "\n" + " TEST_SUFFIX" " [==[" "${_TEST_SUFFIX}" "]==]" "\n" + " TEST_LIST" " [==[" "${_TEST_LIST}" "]==]" "\n" + " TEST_REPORTER" " [==[" "${_REPORTER}" "]==]" "\n" + " TEST_OUTPUT_DIR" " [==[" "${_OUTPUT_DIR}" "]==]" "\n" + " TEST_OUTPUT_PREFIX" " [==[" "${_OUTPUT_PREFIX}" "]==]" "\n" + " TEST_OUTPUT_SUFFIX" " [==[" "${_OUTPUT_SUFFIX}" "]==]" "\n" + " CTEST_FILE" " [==[" "${ctest_tests_file}" "]==]" "\n" + " TEST_DL_PATHS" " [==[" "${_DL_PATHS}" "]==]" "\n" + " CTEST_FILE" " [==[" "${CTEST_FILE}" "]==]" "\n" + " )" "\n" + " endif()" "\n" + " include(\"${ctest_tests_file}\")" "\n" + "else()" "\n" + " add_test(${TARGET}_NOT_BUILT ${TARGET}_NOT_BUILT)" "\n" + "endif()" "\n" + ) + + if(GENERATOR_IS_MULTI_CONFIG) + foreach(_config ${CMAKE_CONFIGURATION_TYPES}) + file(GENERATE OUTPUT "${ctest_file_base}_include-${_config}.cmake" CONTENT "${ctest_include_content}" CONDITION $) + endforeach() + string(CONCAT ctest_include_multi_content + "if(NOT CTEST_CONFIGURATION_TYPE)" "\n" + " message(\"No configuration for testing specified, use '-C '.\")" "\n" + "else()" "\n" + " include(\"${ctest_file_base}_include-\${CTEST_CONFIGURATION_TYPE}.cmake\")" "\n" + "endif()" "\n" + ) + file(GENERATE OUTPUT "${ctest_include_file}" CONTENT "${ctest_include_multi_content}") + else() + file(GENERATE OUTPUT "${ctest_file_base}_include.cmake" CONTENT "${ctest_include_content}") + file(WRITE "${ctest_include_file}" "include(\"${ctest_file_base}_include.cmake\")") + endif() + endif() + + if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0") # Add discovered tests to directory TEST_INCLUDE_FILES set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES "${ctest_include_file}" @@ -204,9 +290,7 @@ function(catch_discover_tests TARGET) PROPERTY TEST_INCLUDE_FILE "${ctest_include_file}" ) else() - message(FATAL_ERROR - "Cannot set more than one TEST_INCLUDE_FILE" - ) + message(FATAL_ERROR "Cannot set more than one TEST_INCLUDE_FILE") endif() endif() diff --git a/external_imported/Catch2/extras/CatchAddTests.cmake b/external_imported/Catch2/extras/CatchAddTests.cmake index beec3aede..692e34056 100644 --- a/external_imported/Catch2/extras/CatchAddTests.cmake +++ b/external_imported/Catch2/extras/CatchAddTests.cmake @@ -1,28 +1,6 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -set(prefix "${TEST_PREFIX}") -set(suffix "${TEST_SUFFIX}") -set(spec ${TEST_SPEC}) -set(extra_args ${TEST_EXTRA_ARGS}) -set(properties ${TEST_PROPERTIES}) -set(reporter ${TEST_REPORTER}) -set(output_dir ${TEST_OUTPUT_DIR}) -set(output_prefix ${TEST_OUTPUT_PREFIX}) -set(output_suffix ${TEST_OUTPUT_SUFFIX}) -set(dl_paths ${TEST_DL_PATHS}) -set(script) -set(suite) -set(tests) - -if(WIN32) - set(dl_paths_variable_name PATH) -elseif(APPLE) - set(dl_paths_variable_name DYLD_LIBRARY_PATH) -else() - set(dl_paths_variable_name LD_LIBRARY_PATH) -endif() - function(add_command NAME) set(_args "") # use ARGV* instead of ARGN, because ARGN splits arrays into multiple arguments @@ -38,119 +16,177 @@ function(add_command NAME) set(script "${script}${NAME}(${_args})\n" PARENT_SCOPE) endfunction() -# Run test executable to get list of available tests -if(NOT EXISTS "${TEST_EXECUTABLE}") - message(FATAL_ERROR - "Specified test executable '${TEST_EXECUTABLE}' does not exist" +function(catch_discover_tests_impl) + + cmake_parse_arguments( + "" + "" + "TEST_EXECUTABLE;TEST_WORKING_DIR;TEST_DL_PATHS;TEST_OUTPUT_DIR;TEST_OUTPUT_PREFIX;TEST_OUTPUT_SUFFIX;TEST_PREFIX;TEST_REPORTER;TEST_SPEC;TEST_SUFFIX;TEST_LIST;CTEST_FILE" + "TEST_EXTRA_ARGS;TEST_PROPERTIES;TEST_EXECUTOR" + ${ARGN} ) -endif() -if(dl_paths) - cmake_path(CONVERT "${dl_paths}" TO_NATIVE_PATH_LIST paths) - set(ENV{${dl_paths_variable_name}} "${paths}") -endif() + set(prefix "${_TEST_PREFIX}") + set(suffix "${_TEST_SUFFIX}") + set(spec ${_TEST_SPEC}) + set(extra_args ${_TEST_EXTRA_ARGS}) + set(properties ${_TEST_PROPERTIES}) + set(reporter ${_TEST_REPORTER}) + set(output_dir ${_TEST_OUTPUT_DIR}) + set(output_prefix ${_TEST_OUTPUT_PREFIX}) + set(output_suffix ${_TEST_OUTPUT_SUFFIX}) + set(dl_paths ${_TEST_DL_PATHS}) + set(script) + set(suite) + set(tests) + + if(WIN32) + set(dl_paths_variable_name PATH) + elseif(APPLE) + set(dl_paths_variable_name DYLD_LIBRARY_PATH) + else() + set(dl_paths_variable_name LD_LIBRARY_PATH) + endif() -execute_process( - COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-tests --verbosity quiet - OUTPUT_VARIABLE output - RESULT_VARIABLE result - WORKING_DIRECTORY "${TEST_WORKING_DIR}" -) -if(NOT ${result} EQUAL 0) - message(FATAL_ERROR - "Error running test executable '${TEST_EXECUTABLE}':\n" - " Result: ${result}\n" - " Output: ${output}\n" - ) -endif() + # Run test executable to get list of available tests + if(NOT EXISTS "${_TEST_EXECUTABLE}") + message(FATAL_ERROR + "Specified test executable '${_TEST_EXECUTABLE}' does not exist" + ) + endif() -string(REPLACE "\n" ";" output "${output}") - -# Run test executable to get list of available reporters -execute_process( - COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-reporters - OUTPUT_VARIABLE reporters_output - RESULT_VARIABLE reporters_result - WORKING_DIRECTORY "${TEST_WORKING_DIR}" -) -if(NOT ${reporters_result} EQUAL 0) - message(FATAL_ERROR - "Error running test executable '${TEST_EXECUTABLE}':\n" - " Result: ${reporters_result}\n" - " Output: ${reporters_output}\n" - ) -endif() -string(FIND "${reporters_output}" "${reporter}" reporter_is_valid) -if(reporter AND ${reporter_is_valid} EQUAL -1) - message(FATAL_ERROR - "\"${reporter}\" is not a valid reporter!\n" - ) -endif() + if(dl_paths) + cmake_path(CONVERT "${dl_paths}" TO_NATIVE_PATH_LIST paths) + set(ENV{${dl_paths_variable_name}} "${paths}") + endif() -# Prepare reporter -if(reporter) - set(reporter_arg "--reporter ${reporter}") -endif() + execute_process( + COMMAND ${_TEST_EXECUTOR} "${_TEST_EXECUTABLE}" ${spec} --list-tests --verbosity quiet + OUTPUT_VARIABLE output + RESULT_VARIABLE result + WORKING_DIRECTORY "${_TEST_WORKING_DIR}" + ) + if(NOT ${result} EQUAL 0) + message(FATAL_ERROR + "Error running test executable '${_TEST_EXECUTABLE}':\n" + " Result: ${result}\n" + " Output: ${output}\n" + ) + endif() -# Prepare output dir -if(output_dir AND NOT IS_ABSOLUTE ${output_dir}) - set(output_dir "${TEST_WORKING_DIR}/${output_dir}") - if(NOT EXISTS ${output_dir}) - file(MAKE_DIRECTORY ${output_dir}) + # Make sure to escape ; (semicolons) in test names first, because + # that'd break the foreach loop for "Parse output" later and create + # wrongly splitted and thus failing test cases (false positives) + string(REPLACE ";" "\;" output "${output}") + string(REPLACE "\n" ";" output "${output}") + + # Prepare reporter + if(reporter) + set(reporter_arg "--reporter ${reporter}") + + # Run test executable to check whether reporter is available + # note that the use of --list-reporters is not the important part, + # we only want to check whether the execution succeeds with ${reporter_arg} + execute_process( + COMMAND ${_TEST_EXECUTOR} "${_TEST_EXECUTABLE}" ${spec} ${reporter_arg} --list-reporters + OUTPUT_VARIABLE reporter_check_output + RESULT_VARIABLE reporter_check_result + WORKING_DIRECTORY "${_TEST_WORKING_DIR}" + ) + if(${reporter_check_result} EQUAL 255) + message(FATAL_ERROR + "\"${reporter}\" is not a valid reporter!\n" + ) + elseif(NOT ${reporter_check_result} EQUAL 0) + message(FATAL_ERROR + "Error running test executable '${_TEST_EXECUTABLE}':\n" + " Result: ${reporter_check_result}\n" + " Output: ${reporter_check_output}\n" + ) + endif() endif() -endif() -if(dl_paths) - foreach(path ${dl_paths}) - cmake_path(NATIVE_PATH path native_path) - list(APPEND environment_modifications "${dl_paths_variable_name}=path_list_prepend:${native_path}") - endforeach() -endif() + # Prepare output dir + if(output_dir AND NOT IS_ABSOLUTE ${output_dir}) + set(output_dir "${_TEST_WORKING_DIR}/${output_dir}") + if(NOT EXISTS ${output_dir}) + file(MAKE_DIRECTORY ${output_dir}) + endif() + endif() -# Parse output -foreach(line ${output}) - set(test ${line}) - # Escape characters in test case names that would be parsed by Catch2 - set(test_name ${test}) - foreach(char , [ ]) - string(REPLACE ${char} "\\${char}" test_name ${test_name}) - endforeach(char) - # ...add output dir - if(output_dir) - string(REGEX REPLACE "[^A-Za-z0-9_]" "_" test_name_clean ${test_name}) - set(output_dir_arg "--out ${output_dir}/${output_prefix}${test_name_clean}${output_suffix}") + if(dl_paths) + foreach(path ${dl_paths}) + cmake_path(NATIVE_PATH path native_path) + list(APPEND environment_modifications "${dl_paths_variable_name}=path_list_prepend:${native_path}") + endforeach() endif() - - # ...and add to script - add_command(add_test - "${prefix}${test}${suffix}" - ${TEST_EXECUTOR} - "${TEST_EXECUTABLE}" - "${test_name}" - ${extra_args} - "${reporter_arg}" - "${output_dir_arg}" - ) - add_command(set_tests_properties - "${prefix}${test}${suffix}" - PROPERTIES - WORKING_DIRECTORY "${TEST_WORKING_DIR}" - ${properties} - ) - if(environment_modifications) - add_command(set_tests_properties - "${prefix}${test}${suffix}" - PROPERTIES - ENVIRONMENT_MODIFICATION "${environment_modifications}") - endif() + # Parse output + foreach(line ${output}) + set(test "${line}") + # Escape characters in test case names that would be parsed by Catch2 + # Note that the \ escaping must happen FIRST! Do not change the order. + set(test_name "${test}") + foreach(char \\ , [ ]) + string(REPLACE ${char} "\\${char}" test_name "${test_name}") + endforeach(char) + # ...add output dir + if(output_dir) + string(REGEX REPLACE "[^A-Za-z0-9_]" "_" test_name_clean "${test_name}") + set(output_dir_arg "--out ${output_dir}/${output_prefix}${test_name_clean}${output_suffix}") + endif() + + # ...and add to script + add_command(add_test + "${prefix}${test}${suffix}" + ${_TEST_EXECUTOR} + "${_TEST_EXECUTABLE}" + "${test_name}" + ${extra_args} + "${reporter_arg}" + "${output_dir_arg}" + ) + add_command(set_tests_properties + "${prefix}${test}${suffix}" + PROPERTIES + WORKING_DIRECTORY "${_TEST_WORKING_DIR}" + ${properties} + ) + + if(environment_modifications) + add_command(set_tests_properties + "${prefix}${test}${suffix}" + PROPERTIES + ENVIRONMENT_MODIFICATION "${environment_modifications}") + endif() + + list(APPEND tests "${prefix}${test}${suffix}") + endforeach() - list(APPEND tests "${prefix}${test}${suffix}") -endforeach() + # Create a list of all discovered tests, which users may use to e.g. set + # properties on the tests + add_command(set ${_TEST_LIST} ${tests}) -# Create a list of all discovered tests, which users may use to e.g. set -# properties on the tests -add_command(set ${TEST_LIST} ${tests}) + # Write CTest script + file(WRITE "${_CTEST_FILE}" "${script}") +endfunction() -# Write CTest script -file(WRITE "${CTEST_FILE}" "${script}") +if(CMAKE_SCRIPT_MODE_FILE) + catch_discover_tests_impl( + TEST_EXECUTABLE ${TEST_EXECUTABLE} + TEST_EXECUTOR ${TEST_EXECUTOR} + TEST_WORKING_DIR ${TEST_WORKING_DIR} + TEST_SPEC ${TEST_SPEC} + TEST_EXTRA_ARGS ${TEST_EXTRA_ARGS} + TEST_PROPERTIES ${TEST_PROPERTIES} + TEST_PREFIX ${TEST_PREFIX} + TEST_SUFFIX ${TEST_SUFFIX} + TEST_LIST ${TEST_LIST} + TEST_REPORTER ${TEST_REPORTER} + TEST_OUTPUT_DIR ${TEST_OUTPUT_DIR} + TEST_OUTPUT_PREFIX ${TEST_OUTPUT_PREFIX} + TEST_OUTPUT_SUFFIX ${TEST_OUTPUT_SUFFIX} + TEST_DL_PATHS ${TEST_DL_PATHS} + CTEST_FILE ${CTEST_FILE} + ) +endif() diff --git a/external_imported/Catch2/extras/CatchShardTests.cmake b/external_imported/Catch2/extras/CatchShardTests.cmake index 5e043cf06..68228f5a6 100644 --- a/external_imported/Catch2/extras/CatchShardTests.cmake +++ b/external_imported/Catch2/extras/CatchShardTests.cmake @@ -46,7 +46,7 @@ function(catch_add_sharded_tests TARGET) APPEND PROPERTY TEST_INCLUDE_FILES "${ctest_include_file}" ) - set(shard_impl_script_file "${CMAKE_CURRENT_LIST_DIR}/CatchShardTestsImpl.cmake") + set(shard_impl_script_file "${_CATCH_DISCOVER_SHARD_TESTS_IMPL_SCRIPT}") add_custom_command( TARGET ${TARGET} POST_BUILD @@ -64,3 +64,11 @@ function(catch_add_sharded_tests TARGET) endfunction() + + +############################################################################### + +set(_CATCH_DISCOVER_SHARD_TESTS_IMPL_SCRIPT + ${CMAKE_CURRENT_LIST_DIR}/CatchShardTestsImpl.cmake + CACHE INTERNAL "Catch2 full path to CatchShardTestsImpl.cmake helper file" +) diff --git a/external_imported/Catch2/extras/catch_amalgamated.cpp b/external_imported/Catch2/extras/catch_amalgamated.cpp index a81b1b6ae..f68c9005b 100644 --- a/external_imported/Catch2/extras/catch_amalgamated.cpp +++ b/external_imported/Catch2/extras/catch_amalgamated.cpp @@ -1,3 +1,4 @@ + // Copyright Catch2 Authors // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.txt or copy at @@ -5,8 +6,8 @@ // SPDX-License-Identifier: BSL-1.0 -// Catch v3.3.2 -// Generated: 2023-02-26 10:28:48.270752 +// Catch v3.5.2 +// Generated: 2024-01-15 14:06:36.675713 // ---------------------------------------------------------- // This file is an amalgamation of multiple different files. // You probably shouldn't edit it directly. @@ -48,6 +49,80 @@ namespace Catch { } // namespace Catch +// Adapted from donated nonius code. + + +#include + +namespace Catch { + namespace Benchmark { + namespace Detail { + SampleAnalysis analyse(const IConfig &cfg, FDuration* first, FDuration* last) { + if (!cfg.benchmarkNoAnalysis()) { + std::vector samples; + samples.reserve(static_cast(last - first)); + for (auto current = first; current != last; ++current) { + samples.push_back( current->count() ); + } + + auto analysis = Catch::Benchmark::Detail::analyse_samples( + cfg.benchmarkConfidenceInterval(), + cfg.benchmarkResamples(), + samples.data(), + samples.data() + samples.size() ); + auto outliers = Catch::Benchmark::Detail::classify_outliers( + samples.data(), samples.data() + samples.size() ); + + auto wrap_estimate = [](Estimate e) { + return Estimate { + FDuration(e.point), + FDuration(e.lower_bound), + FDuration(e.upper_bound), + e.confidence_interval, + }; + }; + std::vector samples2; + samples2.reserve(samples.size()); + for (auto s : samples) { + samples2.push_back( FDuration( s ) ); + } + + return { + CATCH_MOVE(samples2), + wrap_estimate(analysis.mean), + wrap_estimate(analysis.standard_deviation), + outliers, + analysis.outlier_variance, + }; + } else { + std::vector samples; + samples.reserve(static_cast(last - first)); + + FDuration mean = FDuration(0); + int i = 0; + for (auto it = first; it < last; ++it, ++i) { + samples.push_back(FDuration(*it)); + mean += FDuration(*it); + } + mean /= i; + + return SampleAnalysis{ + CATCH_MOVE(samples), + Estimate{ mean, mean, mean, 0.0 }, + Estimate{ FDuration( 0 ), + FDuration( 0 ), + FDuration( 0 ), + 0.0 }, + OutlierClassification{}, + 0.0 + }; + } + } + } // namespace Detail + } // namespace Benchmark +} // namespace Catch + + namespace Catch { @@ -60,6 +135,7 @@ namespace Catch { + #include namespace Catch { @@ -86,9 +162,11 @@ namespace Catch { +#include #include +#include #include -#include +#include #include @@ -96,139 +174,199 @@ namespace Catch { #include #endif -namespace { +namespace Catch { + namespace Benchmark { + namespace Detail { + namespace { + + template + static sample + resample( URng& rng, + unsigned int resamples, + double const* first, + double const* last, + Estimator& estimator ) { + auto n = static_cast( last - first ); + std::uniform_int_distribution dist( 0, n - 1 ); + + sample out; + out.reserve( resamples ); + std::vector resampled; + resampled.reserve( n ); + for ( size_t i = 0; i < resamples; ++i ) { + resampled.clear(); + for ( size_t s = 0; s < n; ++s ) { + resampled.push_back( first[dist( rng )] ); + } + const auto estimate = + estimator( resampled.data(), resampled.data() + resampled.size() ); + out.push_back( estimate ); + } + std::sort( out.begin(), out.end() ); + return out; + } -using Catch::Benchmark::Detail::sample; - - template - sample resample(URng& rng, unsigned int resamples, std::vector::iterator first, std::vector::iterator last, Estimator& estimator) { - auto n = static_cast(last - first); - std::uniform_int_distribution dist(0, n - 1); - - sample out; - out.reserve(resamples); - std::generate_n(std::back_inserter(out), resamples, [n, first, &estimator, &dist, &rng] { - std::vector resampled; - resampled.reserve(n); - std::generate_n(std::back_inserter(resampled), n, [first, &dist, &rng] { return first[static_cast(dist(rng))]; }); - return estimator(resampled.begin(), resampled.end()); - }); - std::sort(out.begin(), out.end()); - return out; - } - - - double erf_inv(double x) { - // Code accompanying the article "Approximating the erfinv function" in GPU Computing Gems, Volume 2 - double w, p; - - w = -log((1.0 - x) * (1.0 + x)); - - if (w < 6.250000) { - w = w - 3.125000; - p = -3.6444120640178196996e-21; - p = -1.685059138182016589e-19 + p * w; - p = 1.2858480715256400167e-18 + p * w; - p = 1.115787767802518096e-17 + p * w; - p = -1.333171662854620906e-16 + p * w; - p = 2.0972767875968561637e-17 + p * w; - p = 6.6376381343583238325e-15 + p * w; - p = -4.0545662729752068639e-14 + p * w; - p = -8.1519341976054721522e-14 + p * w; - p = 2.6335093153082322977e-12 + p * w; - p = -1.2975133253453532498e-11 + p * w; - p = -5.4154120542946279317e-11 + p * w; - p = 1.051212273321532285e-09 + p * w; - p = -4.1126339803469836976e-09 + p * w; - p = -2.9070369957882005086e-08 + p * w; - p = 4.2347877827932403518e-07 + p * w; - p = -1.3654692000834678645e-06 + p * w; - p = -1.3882523362786468719e-05 + p * w; - p = 0.0001867342080340571352 + p * w; - p = -0.00074070253416626697512 + p * w; - p = -0.0060336708714301490533 + p * w; - p = 0.24015818242558961693 + p * w; - p = 1.6536545626831027356 + p * w; - } else if (w < 16.000000) { - w = sqrt(w) - 3.250000; - p = 2.2137376921775787049e-09; - p = 9.0756561938885390979e-08 + p * w; - p = -2.7517406297064545428e-07 + p * w; - p = 1.8239629214389227755e-08 + p * w; - p = 1.5027403968909827627e-06 + p * w; - p = -4.013867526981545969e-06 + p * w; - p = 2.9234449089955446044e-06 + p * w; - p = 1.2475304481671778723e-05 + p * w; - p = -4.7318229009055733981e-05 + p * w; - p = 6.8284851459573175448e-05 + p * w; - p = 2.4031110387097893999e-05 + p * w; - p = -0.0003550375203628474796 + p * w; - p = 0.00095328937973738049703 + p * w; - p = -0.0016882755560235047313 + p * w; - p = 0.0024914420961078508066 + p * w; - p = -0.0037512085075692412107 + p * w; - p = 0.005370914553590063617 + p * w; - p = 1.0052589676941592334 + p * w; - p = 3.0838856104922207635 + p * w; - } else { - w = sqrt(w) - 5.000000; - p = -2.7109920616438573243e-11; - p = -2.5556418169965252055e-10 + p * w; - p = 1.5076572693500548083e-09 + p * w; - p = -3.7894654401267369937e-09 + p * w; - p = 7.6157012080783393804e-09 + p * w; - p = -1.4960026627149240478e-08 + p * w; - p = 2.9147953450901080826e-08 + p * w; - p = -6.7711997758452339498e-08 + p * w; - p = 2.2900482228026654717e-07 + p * w; - p = -9.9298272942317002539e-07 + p * w; - p = 4.5260625972231537039e-06 + p * w; - p = -1.9681778105531670567e-05 + p * w; - p = 7.5995277030017761139e-05 + p * w; - p = -0.00021503011930044477347 + p * w; - p = -0.00013871931833623122026 + p * w; - p = 1.0103004648645343977 + p * w; - p = 4.8499064014085844221 + p * w; - } - return p * x; - } - - double standard_deviation(std::vector::iterator first, std::vector::iterator last) { - auto m = Catch::Benchmark::Detail::mean(first, last); - double variance = std::accumulate( first, - last, - 0., - [m]( double a, double b ) { - double diff = b - m; - return a + diff * diff; - } ) / - ( last - first ); - return std::sqrt( variance ); - } + static double outlier_variance( Estimate mean, + Estimate stddev, + int n ) { + double sb = stddev.point; + double mn = mean.point / n; + double mg_min = mn / 2.; + double sg = (std::min)( mg_min / 4., sb / std::sqrt( n ) ); + double sg2 = sg * sg; + double sb2 = sb * sb; + + auto c_max = [n, mn, sb2, sg2]( double x ) -> double { + double k = mn - x; + double d = k * k; + double nd = n * d; + double k0 = -n * nd; + double k1 = sb2 - n * sg2 + nd; + double det = k1 * k1 - 4 * sg2 * k0; + return static_cast( -2. * k0 / + ( k1 + std::sqrt( det ) ) ); + }; + + auto var_out = [n, sb2, sg2]( double c ) { + double nc = n - c; + return ( nc / n ) * ( sb2 - nc * sg2 ); + }; + + return (std::min)( var_out( 1 ), + var_out( + (std::min)( c_max( 0. ), + c_max( mg_min ) ) ) ) / + sb2; + } -} + static double erf_inv( double x ) { + // Code accompanying the article "Approximating the erfinv + // function" in GPU Computing Gems, Volume 2 + double w, p; + + w = -log( ( 1.0 - x ) * ( 1.0 + x ) ); + + if ( w < 6.250000 ) { + w = w - 3.125000; + p = -3.6444120640178196996e-21; + p = -1.685059138182016589e-19 + p * w; + p = 1.2858480715256400167e-18 + p * w; + p = 1.115787767802518096e-17 + p * w; + p = -1.333171662854620906e-16 + p * w; + p = 2.0972767875968561637e-17 + p * w; + p = 6.6376381343583238325e-15 + p * w; + p = -4.0545662729752068639e-14 + p * w; + p = -8.1519341976054721522e-14 + p * w; + p = 2.6335093153082322977e-12 + p * w; + p = -1.2975133253453532498e-11 + p * w; + p = -5.4154120542946279317e-11 + p * w; + p = 1.051212273321532285e-09 + p * w; + p = -4.1126339803469836976e-09 + p * w; + p = -2.9070369957882005086e-08 + p * w; + p = 4.2347877827932403518e-07 + p * w; + p = -1.3654692000834678645e-06 + p * w; + p = -1.3882523362786468719e-05 + p * w; + p = 0.0001867342080340571352 + p * w; + p = -0.00074070253416626697512 + p * w; + p = -0.0060336708714301490533 + p * w; + p = 0.24015818242558961693 + p * w; + p = 1.6536545626831027356 + p * w; + } else if ( w < 16.000000 ) { + w = sqrt( w ) - 3.250000; + p = 2.2137376921775787049e-09; + p = 9.0756561938885390979e-08 + p * w; + p = -2.7517406297064545428e-07 + p * w; + p = 1.8239629214389227755e-08 + p * w; + p = 1.5027403968909827627e-06 + p * w; + p = -4.013867526981545969e-06 + p * w; + p = 2.9234449089955446044e-06 + p * w; + p = 1.2475304481671778723e-05 + p * w; + p = -4.7318229009055733981e-05 + p * w; + p = 6.8284851459573175448e-05 + p * w; + p = 2.4031110387097893999e-05 + p * w; + p = -0.0003550375203628474796 + p * w; + p = 0.00095328937973738049703 + p * w; + p = -0.0016882755560235047313 + p * w; + p = 0.0024914420961078508066 + p * w; + p = -0.0037512085075692412107 + p * w; + p = 0.005370914553590063617 + p * w; + p = 1.0052589676941592334 + p * w; + p = 3.0838856104922207635 + p * w; + } else { + w = sqrt( w ) - 5.000000; + p = -2.7109920616438573243e-11; + p = -2.5556418169965252055e-10 + p * w; + p = 1.5076572693500548083e-09 + p * w; + p = -3.7894654401267369937e-09 + p * w; + p = 7.6157012080783393804e-09 + p * w; + p = -1.4960026627149240478e-08 + p * w; + p = 2.9147953450901080826e-08 + p * w; + p = -6.7711997758452339498e-08 + p * w; + p = 2.2900482228026654717e-07 + p * w; + p = -9.9298272942317002539e-07 + p * w; + p = 4.5260625972231537039e-06 + p * w; + p = -1.9681778105531670567e-05 + p * w; + p = 7.5995277030017761139e-05 + p * w; + p = -0.00021503011930044477347 + p * w; + p = -0.00013871931833623122026 + p * w; + p = 1.0103004648645343977 + p * w; + p = 4.8499064014085844221 + p * w; + } + return p * x; + } + + static double + standard_deviation( double const* first, double const* last ) { + auto m = Catch::Benchmark::Detail::mean( first, last ); + double variance = + std::accumulate( first, + last, + 0., + [m]( double a, double b ) { + double diff = b - m; + return a + diff * diff; + } ) / + ( last - first ); + return std::sqrt( variance ); + } + + static sample jackknife( double ( *estimator )( double const*, + double const* ), + double* first, + double* last ) { + const auto second = first + 1; + sample results; + results.reserve( static_cast( last - first ) ); + + for ( auto it = first; it != last; ++it ) { + std::iter_swap( it, first ); + results.push_back( estimator( second, last ) ); + } + + return results; + } + + + } // namespace + } // namespace Detail + } // namespace Benchmark +} // namespace Catch namespace Catch { namespace Benchmark { namespace Detail { -#if defined( __GNUC__ ) || defined( __clang__ ) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wfloat-equal" -#endif - bool directCompare( double lhs, double rhs ) { return lhs == rhs; } -#if defined( __GNUC__ ) || defined( __clang__ ) -# pragma GCC diagnostic pop -#endif - - double weighted_average_quantile(int k, int q, std::vector::iterator first, std::vector::iterator last) { + double weighted_average_quantile( int k, + int q, + double* first, + double* last ) { auto count = last - first; double idx = (count - 1) * k / static_cast(q); int j = static_cast(idx); double g = idx - j; std::nth_element(first, first + j, last); auto xj = first[j]; - if ( directCompare( g, 0 ) ) { + if ( Catch::Detail::directCompare( g, 0 ) ) { return xj; } @@ -236,6 +374,48 @@ namespace Catch { return xj + g * (xj1 - xj); } + OutlierClassification + classify_outliers( double const* first, double const* last ) { + std::vector copy( first, last ); + + auto q1 = weighted_average_quantile( 1, 4, copy.data(), copy.data() + copy.size() ); + auto q3 = weighted_average_quantile( 3, 4, copy.data(), copy.data() + copy.size() ); + auto iqr = q3 - q1; + auto los = q1 - ( iqr * 3. ); + auto lom = q1 - ( iqr * 1.5 ); + auto him = q3 + ( iqr * 1.5 ); + auto his = q3 + ( iqr * 3. ); + + OutlierClassification o; + for ( ; first != last; ++first ) { + const double t = *first; + if ( t < los ) { + ++o.low_severe; + } else if ( t < lom ) { + ++o.low_mild; + } else if ( t > his ) { + ++o.high_severe; + } else if ( t > him ) { + ++o.high_mild; + } + ++o.samples_seen; + } + return o; + } + + double mean( double const* first, double const* last ) { + auto count = last - first; + double sum = 0.; + while (first != last) { + sum += *first; + ++first; + } + return sum / static_cast(count); + } + + double normal_cdf( double x ) { + return std::erfc( -x / std::sqrt( 2.0 ) ) / 2.0; + } double erfc_inv(double x) { return erf_inv(1.0 - x); @@ -257,50 +437,77 @@ namespace Catch { return result; } + Estimate + bootstrap( double confidence_level, + double* first, + double* last, + sample const& resample, + double ( *estimator )( double const*, double const* ) ) { + auto n_samples = last - first; + + double point = estimator( first, last ); + // Degenerate case with a single sample + if ( n_samples == 1 ) + return { point, point, point, confidence_level }; + + sample jack = jackknife( estimator, first, last ); + double jack_mean = + mean( jack.data(), jack.data() + jack.size() ); + double sum_squares = 0, sum_cubes = 0; + for ( double x : jack ) { + auto difference = jack_mean - x; + auto square = difference * difference; + auto cube = square * difference; + sum_squares += square; + sum_cubes += cube; + } - double outlier_variance(Estimate mean, Estimate stddev, int n) { - double sb = stddev.point; - double mn = mean.point / n; - double mg_min = mn / 2.; - double sg = (std::min)(mg_min / 4., sb / std::sqrt(n)); - double sg2 = sg * sg; - double sb2 = sb * sb; + double accel = sum_cubes / ( 6 * std::pow( sum_squares, 1.5 ) ); + long n = static_cast( resample.size() ); + double prob_n = + std::count_if( resample.begin(), + resample.end(), + [point]( double x ) { return x < point; } ) / + static_cast( n ); + // degenerate case with uniform samples + if ( Catch::Detail::directCompare( prob_n, 0. ) ) { + return { point, point, point, confidence_level }; + } - auto c_max = [n, mn, sb2, sg2](double x) -> double { - double k = mn - x; - double d = k * k; - double nd = n * d; - double k0 = -n * nd; - double k1 = sb2 - n * sg2 + nd; - double det = k1 * k1 - 4 * sg2 * k0; - return static_cast(-2. * k0 / (k1 + std::sqrt(det))); - }; + double bias = normal_quantile( prob_n ); + double z1 = normal_quantile( ( 1. - confidence_level ) / 2. ); - auto var_out = [n, sb2, sg2](double c) { - double nc = n - c; - return (nc / n) * (sb2 - nc * sg2); + auto cumn = [n]( double x ) -> long { + return std::lround( normal_cdf( x ) * + static_cast( n ) ); }; - - return (std::min)(var_out(1), var_out((std::min)(c_max(0.), c_max(mg_min)))) / sb2; - } - - - bootstrap_analysis analyse_samples(double confidence_level, unsigned int n_resamples, std::vector::iterator first, std::vector::iterator last) { - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION - CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS - static std::random_device entropy; - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION - - auto n = static_cast(last - first); // seriously, one can't use integral types without hell in C++ - - auto mean = &Detail::mean::iterator>; + auto a = [bias, accel]( double b ) { + return bias + b / ( 1. - accel * b ); + }; + double b1 = bias + z1; + double b2 = bias - z1; + double a1 = a( b1 ); + double a2 = a( b2 ); + auto lo = static_cast( (std::max)( cumn( a1 ), 0l ) ); + auto hi = + static_cast( (std::min)( cumn( a2 ), n - 1 ) ); + + return { point, resample[lo], resample[hi], confidence_level }; + } + + bootstrap_analysis analyse_samples(double confidence_level, + unsigned int n_resamples, + double* first, + double* last) { + auto mean = &Detail::mean; auto stddev = &standard_deviation; #if defined(CATCH_CONFIG_USE_ASYNC) - auto Estimate = [=](double(*f)(std::vector::iterator, std::vector::iterator)) { - auto seed = entropy(); + auto Estimate = [=](double(*f)(double const*, double const*)) { + std::random_device rd; + auto seed = rd(); return std::async(std::launch::async, [=] { - std::mt19937 rng(seed); + SimplePcg32 rng( seed ); auto resampled = resample(rng, n_resamples, first, last, f); return bootstrap(confidence_level, first, last, resampled, f); }); @@ -312,9 +519,10 @@ namespace Catch { auto mean_estimate = mean_future.get(); auto stddev_estimate = stddev_future.get(); #else - auto Estimate = [=](double(*f)(std::vector::iterator, std::vector::iterator)) { - auto seed = entropy(); - std::mt19937 rng(seed); + auto Estimate = [=](double(*f)(double const* , double const*)) { + std::random_device rd; + auto seed = rd(); + SimplePcg32 rng( seed ); auto resampled = resample(rng, n_resamples, first, last, f); return bootstrap(confidence_level, first, last, resampled, f); }; @@ -323,6 +531,7 @@ namespace Catch { auto stddev_estimate = Estimate(stddev); #endif // CATCH_USE_ASYNC + auto n = static_cast(last - first); // seriously, one can't use integral types without hell in C++ double outlier_variance = Detail::outlier_variance(mean_estimate, stddev_estimate, n); return { mean_estimate, stddev_estimate, outlier_variance }; @@ -394,10 +603,10 @@ namespace Catch { } namespace literals { - Approx operator "" _a(long double val) { + Approx operator ""_a(long double val) { return Approx(val); } - Approx operator "" _a(unsigned long long val) { + Approx operator ""_a(unsigned long long val) { return Approx(val); } } // end namespace literals @@ -596,7 +805,7 @@ namespace Catch { elem = trim(elem); } - // Insert the default reporter if user hasn't asked for a specfic one + // Insert the default reporter if user hasn't asked for a specific one if ( m_data.reporterSpecifications.empty() ) { m_data.reporterSpecifications.push_back( { #if defined( CATCH_CONFIG_DEFAULT_REPORTER ) @@ -775,7 +984,11 @@ namespace Catch { } - Capturer::Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ) { + Capturer::Capturer( StringRef macroName, + SourceLineInfo const& lineInfo, + ResultWas::OfType resultType, + StringRef names ): + m_resultCapture( getResultCapture() ) { auto trimmed = [&] (size_t start, size_t end) { while (names[start] == ',' || isspace(static_cast(names[start]))) { ++start; @@ -852,6 +1065,8 @@ namespace Catch { +#include + namespace Catch { namespace { @@ -862,7 +1077,7 @@ namespace Catch { public: // IRegistryHub RegistryHub() = default; - IReporterRegistry const& getReporterRegistry() const override { + ReporterRegistry const& getReporterRegistry() const override { return m_reporterRegistry; } ITestCaseRegistry const& getTestCaseRegistry() const override { @@ -938,6 +1153,7 @@ namespace Catch { #include #include +#include #include #include @@ -1420,12 +1636,20 @@ namespace Catch { for (size_t idx = 0; idx < originalTags.size(); ++idx) { auto c = originalTags[idx]; if (c == '[') { - assert(!inTag); + CATCH_ENFORCE( + !inTag, + "Found '[' inside a tag while registering test case '" + << _nameAndTags.name << "' at " << _lineInfo ); + inTag = true; tagStart = idx; } if (c == ']') { - assert(inTag); + CATCH_ENFORCE( + inTag, + "Found unmatched ']' while registering test case '" + << _nameAndTags.name << "' at " << _lineInfo ); + inTag = false; tagEnd = idx; assert(tagStart < tagEnd); @@ -1434,7 +1658,11 @@ namespace Catch { // it over to backing storage and actually reference the // backing storage in the saved tags StringRef tagStr = originalTags.substr(tagStart+1, tagEnd - tagStart - 1); - CATCH_ENFORCE(!tagStr.empty(), "Empty tags are not allowed"); + CATCH_ENFORCE( !tagStr.empty(), + "Found an empty tag while registering test case '" + << _nameAndTags.name << "' at " + << _lineInfo ); + enforceNotReservedTag(tagStr, lineInfo); properties |= parseSpecialTag(tagStr); // When copying a tag to the backing storage, we need to @@ -1448,8 +1676,12 @@ namespace Catch { // the tags. internalAppendTag(tagStr); } - (void)inTag; // Silence "set-but-unused" warning in release mode. } + CATCH_ENFORCE( !inTag, + "Found an unclosed tag while registering test case '" + << _nameAndTags.name << "' at " << _lineInfo ); + + // Add [.] if relevant if (isHidden()) { internalAppendTag("."_sr); @@ -1625,16 +1857,18 @@ namespace Catch { return std::any_of( m_filters.begin(), m_filters.end(), [&]( Filter const& f ){ return f.matches( testCase ); } ); } - TestSpec::Matches TestSpec::matchesByFilter( std::vector const& testCases, IConfig const& config ) const - { - Matches matches( m_filters.size() ); - std::transform( m_filters.begin(), m_filters.end(), matches.begin(), [&]( Filter const& filter ){ + TestSpec::Matches TestSpec::matchesByFilter( std::vector const& testCases, IConfig const& config ) const { + Matches matches; + matches.reserve( m_filters.size() ); + for ( auto const& filter : m_filters ) { std::vector currentMatches; - for( auto const& test : testCases ) - if( isThrowSafe( test, config ) && filter.matches( test.getTestCaseInfo() ) ) + for ( auto const& test : testCases ) + if ( isThrowSafe( test, config ) && + filter.matches( test.getTestCaseInfo() ) ) currentMatches.emplace_back( &test ); - return FilterMatch{ extractFilterName(filter), currentMatches }; - } ); + matches.push_back( + FilterMatch{ extractFilterName( filter ), currentMatches } ); + } return matches; } @@ -1991,6 +2225,19 @@ namespace Catch { } + + +namespace Catch { + namespace Detail { + void registerTranslatorImpl( + Detail::unique_ptr&& translator ) { + getMutableRegistryHub().registerTranslator( + CATCH_MOVE( translator ) ); + } + } // namespace Detail +} // namespace Catch + + #include namespace Catch { @@ -2021,7 +2268,7 @@ namespace Catch { } Version const& libraryVersion() { - static Version version( 3, 3, 2, "", 0 ); + static Version version( 3, 5, 2, "", 0 ); return version; } @@ -2074,8 +2321,36 @@ namespace Detail { +#include -std::uint32_t Catch::Generators::Detail::getSeed() { return sharedRng()(); } +namespace Catch { + namespace Generators { + namespace Detail { + std::uint32_t getSeed() { return sharedRng()(); } + } // namespace Detail + + struct RandomFloatingGenerator::PImpl { + PImpl( long double a, long double b, uint32_t seed ): + rng( seed ), dist( a, b ) {} + + Catch::SimplePcg32 rng; + std::uniform_real_distribution dist; + }; + + RandomFloatingGenerator::RandomFloatingGenerator( + long double a, long double b, std::uint32_t seed) : + m_pimpl(Catch::Detail::make_unique(a, b, seed)) { + static_cast( next() ); + } + + RandomFloatingGenerator::~RandomFloatingGenerator() = + default; + bool RandomFloatingGenerator::next() { + m_current_number = m_pimpl->dist( m_pimpl->rng ); + return true; + } + } // namespace Generators +} // namespace Catch @@ -2135,9 +2410,7 @@ namespace Catch { -#include #include -#include namespace Catch { @@ -2172,8 +2445,6 @@ namespace Catch { infoMessages( _infoMessages ), totals( _totals ) { - assertionResult.m_resultData.lazyExpression.m_transientExpression = _assertionResult.m_resultData.lazyExpression.m_transientExpression; - if( assertionResult.hasMessage() ) { // Copy message into messages list. // !TBD This should have been done earlier, somewhere @@ -2232,14 +2503,6 @@ namespace Catch { namespace Catch { - IReporterRegistry::~IReporterRegistry() = default; -} - - - - -namespace Catch { - ITestInvoker::~ITestInvoker() = default; ITestCaseRegistry::~ITestCaseRegistry() = default; } @@ -2254,7 +2517,9 @@ namespace Catch { ResultDisposition::Flags resultDisposition ) : m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition }, m_resultCapture( getResultCapture() ) - {} + { + m_resultCapture.notifyAssertionStarted( m_assertionInfo ); + } void AssertionHandler::handleExpr( ITransientExpression const& expr ) { m_resultCapture.handleExpr( m_assertionInfo, expr, m_reaction ); @@ -2268,7 +2533,7 @@ namespace Catch { } void AssertionHandler::complete() { - setCompleted(); + m_completed = true; if( m_reaction.shouldDebugBreak ) { // If you find your debugger stopping you here then go one level up on the @@ -2281,16 +2546,9 @@ namespace Catch { throw_test_failure_exception(); } if ( m_reaction.shouldSkip ) { -#if !defined( CATCH_CONFIG_DISABLE_EXCEPTIONS ) - throw Catch::TestSkipException(); -#else - CATCH_ERROR( "Explicitly skipping tests during runtime requires exceptions" ); -#endif + throw_test_skip_exception(); } } - void AssertionHandler::setCompleted() { - m_completed = true; - } void AssertionHandler::handleUnexpectedInflightException() { m_resultCapture.handleUnexpectedInflightException( m_assertionInfo, Catch::translateActiveException(), m_reaction ); @@ -2362,13 +2620,29 @@ namespace { ; } - std::string normaliseOpt( std::string const& optName ) { -#ifdef CATCH_PLATFORM_WINDOWS - if ( optName[0] == '/' ) - return "-" + optName.substr( 1 ); - else + Catch::StringRef normaliseOpt( Catch::StringRef optName ) { + if ( optName[0] == '-' +#if defined(CATCH_PLATFORM_WINDOWS) + || optName[0] == '/' #endif - return optName; + ) { + return optName.substr( 1, optName.size() ); + } + + return optName; + } + + static size_t find_first_separator(Catch::StringRef sr) { + auto is_separator = []( char c ) { + return c == ' ' || c == ':' || c == '='; + }; + size_t pos = 0; + while (pos < sr.size()) { + if (is_separator(sr[pos])) { return pos; } + ++pos; + } + + return Catch::StringRef::npos; } } // namespace @@ -2386,23 +2660,23 @@ namespace Catch { } if ( it != itEnd ) { - auto const& next = *it; + StringRef next = *it; if ( isOptPrefix( next[0] ) ) { - auto delimiterPos = next.find_first_of( " :=" ); - if ( delimiterPos != std::string::npos ) { + auto delimiterPos = find_first_separator(next); + if ( delimiterPos != StringRef::npos ) { m_tokenBuffer.push_back( { TokenType::Option, next.substr( 0, delimiterPos ) } ); m_tokenBuffer.push_back( { TokenType::Argument, - next.substr( delimiterPos + 1 ) } ); + next.substr( delimiterPos + 1, next.size() ) } ); } else { if ( next[1] != '-' && next.size() > 2 ) { - std::string opt = "- "; + // Combined short args, e.g. "-ab" for "-a -b" for ( size_t i = 1; i < next.size(); ++i ) { - opt[1] = next[i]; m_tokenBuffer.push_back( - { TokenType::Option, opt } ); + { TokenType::Option, + next.substr( i, 1 ) } ); } } else { m_tokenBuffer.push_back( @@ -2462,12 +2736,12 @@ namespace Catch { size_t ParserBase::cardinality() const { return 1; } InternalParseResult ParserBase::parse( Args const& args ) const { - return parse( args.exeName(), TokenStream( args ) ); + return parse( static_cast(args.exeName()), TokenStream( args ) ); } ParseState::ParseState( ParseResultType type, - TokenStream const& remainingTokens ): - m_type( type ), m_remainingTokens( remainingTokens ) {} + TokenStream remainingTokens ): + m_type( type ), m_remainingTokens( CATCH_MOVE(remainingTokens) ) {} ParserResult BoundFlagRef::setFlag( bool flag ) { m_ref = flag; @@ -2485,34 +2759,34 @@ namespace Catch { } // namespace Detail Detail::InternalParseResult Arg::parse(std::string const&, - Detail::TokenStream const& tokens) const { + Detail::TokenStream tokens) const { auto validationResult = validate(); if (!validationResult) return Detail::InternalParseResult(validationResult); - auto remainingTokens = tokens; - auto const& token = *remainingTokens; + auto token = *tokens; if (token.type != Detail::TokenType::Argument) return Detail::InternalParseResult::ok(Detail::ParseState( - ParseResultType::NoMatch, remainingTokens)); + ParseResultType::NoMatch, CATCH_MOVE(tokens))); assert(!m_ref->isFlag()); auto valueRef = static_cast(m_ref.get()); - auto result = valueRef->setValue(remainingTokens->token); - if (!result) - return Detail::InternalParseResult(result); + auto result = valueRef->setValue(static_cast(token.token)); + if ( !result ) + return Detail::InternalParseResult( result ); else - return Detail::InternalParseResult::ok(Detail::ParseState( - ParseResultType::Matched, ++remainingTokens)); + return Detail::InternalParseResult::ok( + Detail::ParseState( ParseResultType::Matched, + CATCH_MOVE( ++tokens ) ) ); } Opt::Opt(bool& ref) : ParserRefImpl(std::make_shared(ref)) {} - std::vector Opt::getHelpColumns() const { - std::ostringstream oss; + Detail::HelpColumns Opt::getHelpColumns() const { + ReusableStringStream oss; bool first = true; for (auto const& opt : m_optNames) { if (first) @@ -2523,10 +2797,10 @@ namespace Catch { } if (!m_hint.empty()) oss << " <" << m_hint << '>'; - return { { oss.str(), m_description } }; + return { oss.str(), m_description }; } - bool Opt::isMatch(std::string const& optToken) const { + bool Opt::isMatch(StringRef optToken) const { auto normalisedToken = normaliseOpt(optToken); for (auto const& name : m_optNames) { if (normaliseOpt(name) == normalisedToken) @@ -2536,15 +2810,14 @@ namespace Catch { } Detail::InternalParseResult Opt::parse(std::string const&, - Detail::TokenStream const& tokens) const { + Detail::TokenStream tokens) const { auto validationResult = validate(); if (!validationResult) return Detail::InternalParseResult(validationResult); - auto remainingTokens = tokens; - if (remainingTokens && - remainingTokens->type == Detail::TokenType::Option) { - auto const& token = *remainingTokens; + if (tokens && + tokens->type == Detail::TokenType::Option) { + auto const& token = *tokens; if (isMatch(token.token)) { if (m_ref->isFlag()) { auto flagRef = @@ -2556,35 +2829,35 @@ namespace Catch { if (result.value() == ParseResultType::ShortCircuitAll) return Detail::InternalParseResult::ok(Detail::ParseState( - result.value(), remainingTokens)); + result.value(), CATCH_MOVE(tokens))); } else { auto valueRef = static_cast( m_ref.get()); - ++remainingTokens; - if (!remainingTokens) + ++tokens; + if (!tokens) return Detail::InternalParseResult::runtimeError( "Expected argument following " + token.token); - auto const& argToken = *remainingTokens; + auto const& argToken = *tokens; if (argToken.type != Detail::TokenType::Argument) return Detail::InternalParseResult::runtimeError( "Expected argument following " + token.token); - const auto result = valueRef->setValue(argToken.token); + const auto result = valueRef->setValue(static_cast(argToken.token)); if (!result) return Detail::InternalParseResult(result); if (result.value() == ParseResultType::ShortCircuitAll) return Detail::InternalParseResult::ok(Detail::ParseState( - result.value(), remainingTokens)); + result.value(), CATCH_MOVE(tokens))); } return Detail::InternalParseResult::ok(Detail::ParseState( - ParseResultType::Matched, ++remainingTokens)); + ParseResultType::Matched, CATCH_MOVE(++tokens))); } } return Detail::InternalParseResult::ok( - Detail::ParseState(ParseResultType::NoMatch, remainingTokens)); + Detail::ParseState(ParseResultType::NoMatch, CATCH_MOVE(tokens))); } Detail::Result Opt::validate() const { @@ -2616,9 +2889,9 @@ namespace Catch { Detail::InternalParseResult ExeName::parse(std::string const&, - Detail::TokenStream const& tokens) const { + Detail::TokenStream tokens) const { return Detail::InternalParseResult::ok( - Detail::ParseState(ParseResultType::NoMatch, tokens)); + Detail::ParseState(ParseResultType::NoMatch, CATCH_MOVE(tokens))); } ParserResult ExeName::set(std::string const& newName) { @@ -2648,9 +2921,9 @@ namespace Catch { std::vector Parser::getHelpColumns() const { std::vector cols; + cols.reserve( m_options.size() ); for ( auto const& o : m_options ) { - auto childCols = o.getHelpColumns(); - cols.insert( cols.end(), childCols.begin(), childCols.end() ); + cols.push_back(o.getHelpColumns()); } return cols; } @@ -2688,12 +2961,12 @@ namespace Catch { optWidth = ( std::min )( optWidth, consoleWidth / 2 ); - for ( auto const& cols : rows ) { - auto row = TextFlow::Column( cols.left ) + for ( auto& cols : rows ) { + auto row = TextFlow::Column( CATCH_MOVE(cols.left) ) .width( optWidth ) .indent( 2 ) + TextFlow::Spacer( 4 ) + - TextFlow::Column( cols.right ) + TextFlow::Column( static_cast(cols.descriptions) ) .width( consoleWidth - 7 - optWidth ); os << row << '\n'; } @@ -2715,7 +2988,7 @@ namespace Catch { Detail::InternalParseResult Parser::parse( std::string const& exeName, - Detail::TokenStream const& tokens ) const { + Detail::TokenStream tokens ) const { struct ParserInfo { ParserBase const* parser = nullptr; @@ -2733,7 +3006,7 @@ namespace Catch { m_exeName.set( exeName ); auto result = Detail::InternalParseResult::ok( - Detail::ParseState( ParseResultType::NoMatch, tokens ) ); + Detail::ParseState( ParseResultType::NoMatch, CATCH_MOVE(tokens) ) ); while ( result.value().remainingTokens() ) { bool tokenParsed = false; @@ -2741,7 +3014,7 @@ namespace Catch { if ( parseInfo.parser->cardinality() == 0 || parseInfo.count < parseInfo.parser->cardinality() ) { result = parseInfo.parser->parse( - exeName, result.value().remainingTokens() ); + exeName, CATCH_MOVE(result).value().remainingTokens() ); if ( !result ) return result; if ( result.value().type() != @@ -2767,7 +3040,7 @@ namespace Catch { Args::Args(int argc, char const* const* argv) : m_exeName(argv[0]), m_args(argv + 1, argv + argc) {} - Args::Args(std::initializer_list args) : + Args::Args(std::initializer_list args) : m_exeName(*args.begin()), m_args(args.begin() + 1, args.end()) {} @@ -2917,7 +3190,7 @@ namespace Catch { auto const& reporterSpec = *parsed; - IReporterRegistry::FactoryMap const& factories = + auto const& factories = getRegistryHub().getReporterRegistry().getFactories(); auto result = factories.find( reporterSpec.name() ); @@ -3073,8 +3346,8 @@ namespace Catch { ( "split the tests to execute into this many groups" ) | Opt( setShardIndex, "shard index" ) ["--shard-index"] - ( "index of the group of tests to execute (see --shard-count)" ) | - Opt( config.allowZeroTests ) + ( "index of the group of tests to execute (see --shard-count)" ) + | Opt( config.allowZeroTests ) ["--allow-running-no-tests"] ( "Treat 'No tests run' as a success" ) | Arg( config.testsOrTags, "test name|pattern|tags" ) @@ -3155,7 +3428,7 @@ namespace Catch { namespace { //! A do-nothing implementation of colour, used as fallback for unknown //! platforms, and when the user asks to deactivate all colours. - class NoColourImpl : public ColourImpl { + class NoColourImpl final : public ColourImpl { public: NoColourImpl( IStream* stream ): ColourImpl( stream ) {} @@ -3173,7 +3446,7 @@ namespace Catch { namespace Catch { namespace { - class Win32ColourImpl : public ColourImpl { + class Win32ColourImpl final : public ColourImpl { public: Win32ColourImpl(IStream* stream): ColourImpl(stream) { @@ -3239,7 +3512,7 @@ namespace { namespace Catch { namespace { - class ANSIColourImpl : public ColourImpl { + class ANSIColourImpl final : public ColourImpl { public: ANSIColourImpl( IStream* stream ): ColourImpl( stream ) {} @@ -3355,49 +3628,27 @@ namespace Catch { namespace Catch { - class Context : public IMutableContext, private Detail::NonCopyable { - - public: // IContext - IResultCapture* getResultCapture() override { - return m_resultCapture; - } - - IConfig const* getConfig() const override { - return m_config; - } - - ~Context() override; - - public: // IMutableContext - void setResultCapture( IResultCapture* resultCapture ) override { - m_resultCapture = resultCapture; - } - void setConfig( IConfig const* config ) override { - m_config = config; - } + Context* Context::currentContext = nullptr; - friend IMutableContext& getCurrentMutableContext(); - - private: - IConfig const* m_config = nullptr; - IResultCapture* m_resultCapture = nullptr; - }; - - IMutableContext *IMutableContext::currentContext = nullptr; - - void IMutableContext::createContext() - { + void cleanUpContext() { + delete Context::currentContext; + Context::currentContext = nullptr; + } + void Context::createContext() { currentContext = new Context(); } - void cleanUpContext() { - delete IMutableContext::currentContext; - IMutableContext::currentContext = nullptr; + Context& getCurrentMutableContext() { + if ( !Context::currentContext ) { Context::createContext(); } + // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn) + return *Context::currentContext; } - IContext::~IContext() = default; - IMutableContext::~IMutableContext() = default; - Context::~Context() = default; + void Context::setResultCapture( IResultCapture* resultCapture ) { + m_resultCapture = resultCapture; + } + + void Context::setConfig( IConfig const* config ) { m_config = config; } SimplePcg32& sharedRng() { static SimplePcg32 s_rng; @@ -3635,7 +3886,7 @@ namespace Catch { return parsed; } - EnumInfo::~EnumInfo() {} + EnumInfo::~EnumInfo() = default; StringRef EnumInfo::lookup( int value ) const { for( auto const& valueToName : m_values ) { @@ -3680,10 +3931,27 @@ namespace Catch { +#include + namespace Catch { - ExceptionTranslatorRegistry::~ExceptionTranslatorRegistry() { +#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + namespace { + static std::string tryTranslators( + std::vector< + Detail::unique_ptr> const& translators ) { + if ( translators.empty() ) { + std::rethrow_exception( std::current_exception() ); + } else { + return translators[0]->translate( translators.begin() + 1, + translators.end() ); + } + } + } +#endif //!defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + + ExceptionTranslatorRegistry::~ExceptionTranslatorRegistry() = default; void ExceptionTranslatorRegistry::registerTranslator( Detail::unique_ptr&& translator ) { m_translators.push_back( CATCH_MOVE( translator ) ); @@ -3706,7 +3974,7 @@ namespace Catch { // First we try user-registered translators. If none of them can // handle the exception, it will be rethrown handled by our defaults. try { - return tryTranslators(); + return tryTranslators(m_translators); } // To avoid having to handle TFE explicitly everywhere, we just // rethrow it so that it goes back up the caller. @@ -3730,25 +3998,12 @@ namespace Catch { } } - std::string ExceptionTranslatorRegistry::tryTranslators() const { - if (m_translators.empty()) { - std::rethrow_exception(std::current_exception()); - } else { - return m_translators[0]->translate(m_translators.begin() + 1, m_translators.end()); - } - } - #else // ^^ Exceptions are enabled // Exceptions are disabled vv std::string ExceptionTranslatorRegistry::translateActiveException() const { CATCH_INTERNAL_ERROR("Attempted to translate active exception under CATCH_CONFIG_DISABLE_EXCEPTIONS!"); } - - std::string ExceptionTranslatorRegistry::tryTranslators() const { - CATCH_INTERNAL_ERROR("Attempted to use exception translators under CATCH_CONFIG_DISABLE_EXCEPTIONS!"); - } #endif - } @@ -4005,6 +4260,17 @@ namespace Catch { return i; } +#if defined( __GNUC__ ) || defined( __clang__ ) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wfloat-equal" +#endif + bool directCompare( float lhs, float rhs ) { return lhs == rhs; } + bool directCompare( double lhs, double rhs ) { return lhs == rhs; } +#if defined( __GNUC__ ) || defined( __clang__ ) +# pragma GCC diagnostic pop +#endif + + } // end namespace Detail } // end namespace Catch @@ -4053,7 +4319,7 @@ namespace Catch { namespace Detail { namespace { template - class StreamBufImpl : public std::streambuf { + class StreamBufImpl final : public std::streambuf { char data[bufferSize]; WriterF m_writer; @@ -4101,7 +4367,7 @@ namespace Detail { /////////////////////////////////////////////////////////////////////////// - class FileStream : public IStream { + class FileStream final : public IStream { std::ofstream m_ofs; public: FileStream( std::string const& filename ) { @@ -4109,7 +4375,6 @@ namespace Detail { CATCH_ENFORCE( !m_ofs.fail(), "Unable to open file: '" << filename << '\'' ); m_ofs << std::unitbuf; } - ~FileStream() override = default; public: // IStream std::ostream& stream() override { return m_ofs; @@ -4118,13 +4383,12 @@ namespace Detail { /////////////////////////////////////////////////////////////////////////// - class CoutStream : public IStream { + class CoutStream final : public IStream { std::ostream m_os; public: // Store the streambuf from cout up-front because // cout may get redirected when running tests CoutStream() : m_os( Catch::cout().rdbuf() ) {} - ~CoutStream() override = default; public: // IStream std::ostream& stream() override { return m_os; } @@ -4138,7 +4402,6 @@ namespace Detail { // Store the streambuf from cerr up-front because // cout may get redirected when running tests CerrStream(): m_os( Catch::cerr().rdbuf() ) {} - ~CerrStream() override = default; public: // IStream std::ostream& stream() override { return m_os; } @@ -4147,7 +4410,7 @@ namespace Detail { /////////////////////////////////////////////////////////////////////////// - class DebugOutStream : public IStream { + class DebugOutStream final : public IStream { Detail::unique_ptr> m_streamBuf; std::ostream m_os; public: @@ -4156,8 +4419,6 @@ namespace Detail { m_os( m_streamBuf.get() ) {} - ~DebugOutStream() override = default; - public: // IStream std::ostream& stream() override { return m_os; } }; @@ -4189,6 +4450,147 @@ namespace Detail { +namespace Catch { + void JsonUtils::indent( std::ostream& os, std::uint64_t level ) { + for ( std::uint64_t i = 0; i < level; ++i ) { + os << " "; + } + } + void JsonUtils::appendCommaNewline( std::ostream& os, + bool& should_comma, + std::uint64_t level ) { + if ( should_comma ) { os << ','; } + should_comma = true; + os << '\n'; + indent( os, level ); + } + + JsonObjectWriter::JsonObjectWriter( std::ostream& os ): + JsonObjectWriter{ os, 0 } {} + + JsonObjectWriter::JsonObjectWriter( std::ostream& os, + std::uint64_t indent_level ): + m_os{ os }, m_indent_level{ indent_level } { + m_os << '{'; + } + JsonObjectWriter::JsonObjectWriter( JsonObjectWriter&& source ): + m_os{ source.m_os }, + m_indent_level{ source.m_indent_level }, + m_should_comma{ source.m_should_comma }, + m_active{ source.m_active } { + source.m_active = false; + } + + JsonObjectWriter::~JsonObjectWriter() { + if ( !m_active ) { return; } + + m_os << '\n'; + JsonUtils::indent( m_os, m_indent_level ); + m_os << '}'; + } + + JsonValueWriter JsonObjectWriter::write( StringRef key ) { + JsonUtils::appendCommaNewline( + m_os, m_should_comma, m_indent_level + 1 ); + + m_os << '"' << key << "\": "; + return JsonValueWriter{ m_os, m_indent_level + 1 }; + } + + JsonArrayWriter::JsonArrayWriter( std::ostream& os ): + JsonArrayWriter{ os, 0 } {} + JsonArrayWriter::JsonArrayWriter( std::ostream& os, + std::uint64_t indent_level ): + m_os{ os }, m_indent_level{ indent_level } { + m_os << '['; + } + JsonArrayWriter::JsonArrayWriter( JsonArrayWriter&& source ): + m_os{ source.m_os }, + m_indent_level{ source.m_indent_level }, + m_should_comma{ source.m_should_comma }, + m_active{ source.m_active } { + source.m_active = false; + } + JsonArrayWriter::~JsonArrayWriter() { + if ( !m_active ) { return; } + + m_os << '\n'; + JsonUtils::indent( m_os, m_indent_level ); + m_os << ']'; + } + + JsonObjectWriter JsonArrayWriter::writeObject() { + JsonUtils::appendCommaNewline( + m_os, m_should_comma, m_indent_level + 1 ); + return JsonObjectWriter{ m_os, m_indent_level + 1 }; + } + + JsonArrayWriter JsonArrayWriter::writeArray() { + JsonUtils::appendCommaNewline( + m_os, m_should_comma, m_indent_level + 1 ); + return JsonArrayWriter{ m_os, m_indent_level + 1 }; + } + + JsonArrayWriter& JsonArrayWriter::write( bool value ) { + return writeImpl( value ); + } + + JsonValueWriter::JsonValueWriter( std::ostream& os ): + JsonValueWriter{ os, 0 } {} + + JsonValueWriter::JsonValueWriter( std::ostream& os, + std::uint64_t indent_level ): + m_os{ os }, m_indent_level{ indent_level } {} + + JsonObjectWriter JsonValueWriter::writeObject() && { + return JsonObjectWriter{ m_os, m_indent_level }; + } + + JsonArrayWriter JsonValueWriter::writeArray() && { + return JsonArrayWriter{ m_os, m_indent_level }; + } + + void JsonValueWriter::write( Catch::StringRef value ) && { + writeImpl( value, true ); + } + + void JsonValueWriter::write( bool value ) && { + writeImpl( value ? "true"_sr : "false"_sr, false ); + } + + void JsonValueWriter::writeImpl( Catch::StringRef value, bool quote ) { + if ( quote ) { m_os << '"'; } + for (char c : value) { + // Escape list taken from https://www.json.org/json-en.html, + // string definition. + // Note that while forward slash _can_ be escaped, it does + // not have to be, if JSON is not further embedded somewhere + // where forward slash is meaningful. + if ( c == '"' ) { + m_os << "\\\""; + } else if ( c == '\\' ) { + m_os << "\\\\"; + } else if ( c == '\b' ) { + m_os << "\\b"; + } else if ( c == '\f' ) { + m_os << "\\f"; + } else if ( c == '\n' ) { + m_os << "\\n"; + } else if ( c == '\r' ) { + m_os << "\\r"; + } else if ( c == '\t' ) { + m_os << "\\t"; + } else { + m_os << c; + } + } + if ( quote ) { m_os << '"'; } + } + +} // namespace Catch + + + namespace Catch { @@ -4231,7 +4633,7 @@ namespace Catch { #else // ^^ Windows crt debug heap enabled // Windows crt debug heap disabled vv - Catch::LeakDetector::LeakDetector() {} + Catch::LeakDetector::LeakDetector() = default; #endif // CATCH_CONFIG_WINDOWS_CRTDBG @@ -4242,7 +4644,6 @@ Catch::LeakDetector::~LeakDetector() { - namespace Catch { namespace { @@ -4277,7 +4678,7 @@ namespace Catch { void listReporters(IEventListener& reporter) { std::vector descriptions; - IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories(); + auto const& factories = getRegistryHub().getReporterRegistry().getFactories(); descriptions.reserve(factories.size()); for (auto const& fac : factories) { descriptions.push_back({ fac.first, fac.second->getDescription() }); @@ -4599,6 +5000,14 @@ namespace Catch { } #endif +#if !defined( CATCH_CONFIG_GLOBAL_NEXTAFTER ) + float nextafter( float x, float y ) { return std::nextafter( x, y ); } + double nextafter( double x, double y ) { return std::nextafter( x, y ); } +#else + float nextafter( float x, float y ) { return ::nextafterf( x, y ); } + double nextafter( double x, double y ) { return ::nextafter( x, y ); } +#endif + } // end namespace Catch @@ -4680,10 +5089,10 @@ namespace Catch { return static_cast( std::time( nullptr ) ); case GenerateFrom::Default: - case GenerateFrom::RandomDevice: - // In theory, a platform could have random_device that returns just - // 16 bits. That is still some randomness, so we don't care too much - return static_cast( std::random_device{}() ); + case GenerateFrom::RandomDevice: { + std::random_device rd; + return Detail::fillBitsFrom( rd ); + } default: CATCH_ERROR("Unknown generation method"); @@ -4696,49 +5105,73 @@ namespace Catch { namespace Catch { + struct ReporterRegistry::ReporterRegistryImpl { + std::vector> listeners; + std::map + factories; + }; - ReporterRegistry::ReporterRegistry() { + ReporterRegistry::ReporterRegistry(): + m_impl( Detail::make_unique() ) { // Because it is impossible to move out of initializer list, // we have to add the elements manually - m_factories["Automake"] = Detail::make_unique>(); - m_factories["compact"] = Detail::make_unique>(); - m_factories["console"] = Detail::make_unique>(); - m_factories["JUnit"] = Detail::make_unique>(); - m_factories["SonarQube"] = Detail::make_unique>(); - m_factories["TAP"] = Detail::make_unique>(); - m_factories["TeamCity"] = Detail::make_unique>(); - m_factories["XML"] = Detail::make_unique>(); + m_impl->factories["Automake"] = + Detail::make_unique>(); + m_impl->factories["compact"] = + Detail::make_unique>(); + m_impl->factories["console"] = + Detail::make_unique>(); + m_impl->factories["JUnit"] = + Detail::make_unique>(); + m_impl->factories["SonarQube"] = + Detail::make_unique>(); + m_impl->factories["TAP"] = + Detail::make_unique>(); + m_impl->factories["TeamCity"] = + Detail::make_unique>(); + m_impl->factories["XML"] = + Detail::make_unique>(); + m_impl->factories["JSON"] = + Detail::make_unique>(); } ReporterRegistry::~ReporterRegistry() = default; - - IEventListenerPtr ReporterRegistry::create( std::string const& name, ReporterConfig&& config ) const { - auto it = m_factories.find( name ); - if( it == m_factories.end() ) - return nullptr; - return it->second->create( CATCH_MOVE(config) ); + IEventListenerPtr + ReporterRegistry::create( std::string const& name, + ReporterConfig&& config ) const { + auto it = m_impl->factories.find( name ); + if ( it == m_impl->factories.end() ) return nullptr; + return it->second->create( CATCH_MOVE( config ) ); } - void ReporterRegistry::registerReporter( std::string const& name, IReporterFactoryPtr factory ) { + void ReporterRegistry::registerReporter( std::string const& name, + IReporterFactoryPtr factory ) { CATCH_ENFORCE( name.find( "::" ) == name.npos, - "'::' is not allowed in reporter name: '" + name + '\'' ); - auto ret = m_factories.emplace(name, CATCH_MOVE(factory)); - CATCH_ENFORCE( ret.second, "reporter using '" + name + "' as name was already registered" ); + "'::' is not allowed in reporter name: '" + name + + '\'' ); + auto ret = m_impl->factories.emplace( name, CATCH_MOVE( factory ) ); + CATCH_ENFORCE( ret.second, + "reporter using '" + name + + "' as name was already registered" ); } void ReporterRegistry::registerListener( Detail::unique_ptr factory ) { - m_listeners.push_back( CATCH_MOVE(factory) ); + m_impl->listeners.push_back( CATCH_MOVE( factory ) ); } - IReporterRegistry::FactoryMap const& ReporterRegistry::getFactories() const { - return m_factories; - } - IReporterRegistry::Listeners const& ReporterRegistry::getListeners() const { - return m_listeners; + std::map const& + ReporterRegistry::getFactories() const { + return m_impl->factories; } -} + std::vector> const& + ReporterRegistry::getListeners() const { + return m_impl->listeners; + } +} // namespace Catch @@ -4754,9 +5187,9 @@ namespace Catch { }; kvPair splitKVPair(StringRef kvString) { - auto splitPos = static_cast( std::distance( - kvString.begin(), - std::find( kvString.begin(), kvString.end(), '=' ) ) ); + auto splitPos = static_cast( + std::find( kvString.begin(), kvString.end(), '=' ) - + kvString.begin() ); return { kvString.substr( 0, splitPos ), kvString.substr( splitPos + 1, kvString.size() ) }; @@ -4988,146 +5421,151 @@ namespace Catch { namespace Catch { namespace Generators { - struct GeneratorTracker : TestCaseTracking::TrackerBase, IGeneratorTracker { - GeneratorBasePtr m_generator; + namespace { + struct GeneratorTracker final : TestCaseTracking::TrackerBase, + IGeneratorTracker { + GeneratorBasePtr m_generator; + + GeneratorTracker( + TestCaseTracking::NameAndLocation&& nameAndLocation, + TrackerContext& ctx, + ITracker* parent ): + TrackerBase( CATCH_MOVE( nameAndLocation ), ctx, parent ) {} + + static GeneratorTracker* + acquire( TrackerContext& ctx, + TestCaseTracking::NameAndLocationRef const& + nameAndLocation ) { + GeneratorTracker* tracker; + + ITracker& currentTracker = ctx.currentTracker(); + // Under specific circumstances, the generator we want + // to acquire is also the current tracker. If this is + // the case, we have to avoid looking through current + // tracker's children, and instead return the current + // tracker. + // A case where this check is important is e.g. + // for (int i = 0; i < 5; ++i) { + // int n = GENERATE(1, 2); + // } + // + // without it, the code above creates 5 nested generators. + if ( currentTracker.nameAndLocation() == nameAndLocation ) { + auto thisTracker = currentTracker.parent()->findChild( + nameAndLocation ); + assert( thisTracker ); + assert( thisTracker->isGeneratorTracker() ); + tracker = static_cast( thisTracker ); + } else if ( ITracker* childTracker = + currentTracker.findChild( + nameAndLocation ) ) { + assert( childTracker ); + assert( childTracker->isGeneratorTracker() ); + tracker = + static_cast( childTracker ); + } else { + return nullptr; + } - GeneratorTracker( TestCaseTracking::NameAndLocation&& nameAndLocation, TrackerContext& ctx, ITracker* parent ) - : TrackerBase( CATCH_MOVE(nameAndLocation), ctx, parent ) - {} - ~GeneratorTracker() override; - - static GeneratorTracker* acquire( TrackerContext& ctx, TestCaseTracking::NameAndLocationRef const& nameAndLocation ) { - GeneratorTracker* tracker; - - ITracker& currentTracker = ctx.currentTracker(); - // Under specific circumstances, the generator we want - // to acquire is also the current tracker. If this is - // the case, we have to avoid looking through current - // tracker's children, and instead return the current - // tracker. - // A case where this check is important is e.g. - // for (int i = 0; i < 5; ++i) { - // int n = GENERATE(1, 2); - // } - // - // without it, the code above creates 5 nested generators. - if ( currentTracker.nameAndLocation() == nameAndLocation ) { - auto thisTracker = - currentTracker.parent()->findChild( nameAndLocation ); - assert( thisTracker ); - assert( thisTracker->isGeneratorTracker() ); - tracker = static_cast( thisTracker ); - } else if ( ITracker* childTracker = - currentTracker.findChild( nameAndLocation ) ) { - assert( childTracker ); - assert( childTracker->isGeneratorTracker() ); - tracker = static_cast( childTracker ); - } else { - return nullptr; - } + if ( !tracker->isComplete() ) { tracker->open(); } - if( !tracker->isComplete() ) { - tracker->open(); + return tracker; } - return tracker; - } - - // TrackerBase interface - bool isGeneratorTracker() const override { return true; } - auto hasGenerator() const -> bool override { - return !!m_generator; - } - void close() override { - TrackerBase::close(); - // If a generator has a child (it is followed by a section) - // and none of its children have started, then we must wait - // until later to start consuming its values. - // This catches cases where `GENERATE` is placed between two - // `SECTION`s. - // **The check for m_children.empty cannot be removed**. - // doing so would break `GENERATE` _not_ followed by `SECTION`s. - const bool should_wait_for_child = [&]() { - // No children -> nobody to wait for - if ( m_children.empty() ) { - return false; - } - // If at least one child started executing, don't wait - if ( std::find_if( - m_children.begin(), - m_children.end(), - []( TestCaseTracking::ITrackerPtr const& tracker ) { - return tracker->hasStarted(); - } ) != m_children.end() ) { - return false; - } - - // No children have started. We need to check if they _can_ - // start, and thus we should wait for them, or they cannot - // start (due to filters), and we shouldn't wait for them - ITracker* parent = m_parent; - // This is safe: there is always at least one section - // tracker in a test case tracking tree - while ( !parent->isSectionTracker() ) { - parent = parent->parent(); - } - assert( parent && - "Missing root (test case) level section" ); - - auto const& parentSection = - static_cast( *parent ); - auto const& filters = parentSection.getFilters(); - // No filters -> no restrictions on running sections - if ( filters.empty() ) { - return true; - } + // TrackerBase interface + bool isGeneratorTracker() const override { return true; } + auto hasGenerator() const -> bool override { + return !!m_generator; + } + void close() override { + TrackerBase::close(); + // If a generator has a child (it is followed by a section) + // and none of its children have started, then we must wait + // until later to start consuming its values. + // This catches cases where `GENERATE` is placed between two + // `SECTION`s. + // **The check for m_children.empty cannot be removed**. + // doing so would break `GENERATE` _not_ followed by + // `SECTION`s. + const bool should_wait_for_child = [&]() { + // No children -> nobody to wait for + if ( m_children.empty() ) { return false; } + // If at least one child started executing, don't wait + if ( std::find_if( + m_children.begin(), + m_children.end(), + []( TestCaseTracking::ITrackerPtr const& + tracker ) { + return tracker->hasStarted(); + } ) != m_children.end() ) { + return false; + } - for ( auto const& child : m_children ) { - if ( child->isSectionTracker() && - std::find( - filters.begin(), - filters.end(), - static_cast( *child ) - .trimmedName() ) != filters.end() ) { - return true; + // No children have started. We need to check if they + // _can_ start, and thus we should wait for them, or + // they cannot start (due to filters), and we shouldn't + // wait for them + ITracker* parent = m_parent; + // This is safe: there is always at least one section + // tracker in a test case tracking tree + while ( !parent->isSectionTracker() ) { + parent = parent->parent(); } + assert( parent && + "Missing root (test case) level section" ); + + auto const& parentSection = + static_cast( *parent ); + auto const& filters = parentSection.getFilters(); + // No filters -> no restrictions on running sections + if ( filters.empty() ) { return true; } + + for ( auto const& child : m_children ) { + if ( child->isSectionTracker() && + std::find( filters.begin(), + filters.end(), + static_cast( + *child ) + .trimmedName() ) != + filters.end() ) { + return true; + } + } + return false; + }(); + + // This check is a bit tricky, because m_generator->next() + // has a side-effect, where it consumes generator's current + // value, but we do not want to invoke the side-effect if + // this generator is still waiting for any child to start. + assert( m_generator && "Tracker without generator" ); + if ( should_wait_for_child || + ( m_runState == CompletedSuccessfully && + m_generator->countedNext() ) ) { + m_children.clear(); + m_runState = Executing; } - return false; - }(); - - // This check is a bit tricky, because m_generator->next() - // has a side-effect, where it consumes generator's current - // value, but we do not want to invoke the side-effect if - // this generator is still waiting for any child to start. - assert( m_generator && "Tracker without generator" ); - if ( should_wait_for_child || - ( m_runState == CompletedSuccessfully && - m_generator->countedNext() ) ) { - m_children.clear(); - m_runState = Executing; } - } - // IGeneratorTracker interface - auto getGenerator() const -> GeneratorBasePtr const& override { - return m_generator; - } - void setGenerator( GeneratorBasePtr&& generator ) override { - m_generator = CATCH_MOVE( generator ); - } - }; - GeneratorTracker::~GeneratorTracker() = default; + // IGeneratorTracker interface + auto getGenerator() const -> GeneratorBasePtr const& override { + return m_generator; + } + void setGenerator( GeneratorBasePtr&& generator ) override { + m_generator = CATCH_MOVE( generator ); + } + }; + } // namespace } RunContext::RunContext(IConfig const* _config, IEventListenerPtr&& reporter) : m_runInfo(_config->name()), - m_context(getCurrentMutableContext()), m_config(_config), m_reporter(CATCH_MOVE(reporter)), m_lastAssertionInfo{ StringRef(), SourceLineInfo("",0), StringRef(), ResultDisposition::Normal }, m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions ) { - m_context.setResultCapture(this); + getCurrentMutableContext().setResultCapture( this ); m_reporter->testRunStarting(m_runInfo); } @@ -5222,7 +5660,7 @@ namespace Catch { } - void RunContext::assertionEnded(AssertionResult const & result) { + void RunContext::assertionEnded(AssertionResult&& result) { if (result.getResultType() == ResultWas::Ok) { m_totals.assertions.passed++; m_lastAssertionPassed = true; @@ -5244,19 +5682,27 @@ namespace Catch { m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals)); - if (result.getResultType() != ResultWas::Warning) + if ( result.getResultType() != ResultWas::Warning ) { m_messageScopes.clear(); + } - // Reset working state - resetAssertionInfo(); - m_lastResult = result; + // Reset working state. assertion info will be reset after + // populateReaction is run if it is needed + m_lastResult = CATCH_MOVE( result ); } void RunContext::resetAssertionInfo() { m_lastAssertionInfo.macroName = StringRef(); m_lastAssertionInfo.capturedExpression = "{Unknown expression after the reported line}"_sr; + m_lastAssertionInfo.resultDisposition = ResultDisposition::Normal; + } + + void RunContext::notifyAssertionStarted( AssertionInfo const& info ) { + m_reporter->assertionStarting( info ); } - bool RunContext::sectionStarted(StringRef sectionName, SourceLineInfo const& sectionLineInfo, Counts & assertions) { + bool RunContext::sectionStarted( StringRef sectionName, + SourceLineInfo const& sectionLineInfo, + Counts& assertions ) { ITracker& sectionTracker = SectionTracker::acquire( m_trackerContext, TestCaseTracking::NameAndLocationRef( @@ -5394,7 +5840,8 @@ namespace Catch { tempResult.message = static_cast(message); AssertionResult result(m_lastAssertionInfo, CATCH_MOVE(tempResult)); - assertionEnded(result); + assertionEnded(CATCH_MOVE(result) ); + resetAssertionInfo(); handleUnfinishedSections(); @@ -5516,8 +5963,6 @@ namespace Catch { ITransientExpression const& expr, AssertionReaction& reaction ) { - m_reporter->assertionStarting( info ); - bool negated = isFalseTest( info.resultDisposition ); bool result = expr.getResult() != negated; @@ -5533,6 +5978,7 @@ namespace Catch { reportExpr(info, ResultWas::ExpressionFailed, &expr, negated ); populateReaction( reaction ); } + resetAssertionInfo(); } void RunContext::reportExpr( AssertionInfo const &info, @@ -5546,7 +5992,7 @@ namespace Catch { AssertionResult assertionResult{ info, CATCH_MOVE( data ) }; assertionResult.m_resultData.lazyExpression.m_transientExpression = expr; - assertionEnded( assertionResult ); + assertionEnded( CATCH_MOVE(assertionResult) ); } void RunContext::handleMessage( @@ -5555,22 +6001,23 @@ namespace Catch { StringRef message, AssertionReaction& reaction ) { - m_reporter->assertionStarting( info ); - m_lastAssertionInfo = info; AssertionResultData data( resultType, LazyExpression( false ) ); data.message = static_cast(message); AssertionResult assertionResult{ m_lastAssertionInfo, CATCH_MOVE( data ) }; - assertionEnded( assertionResult ); - if ( !assertionResult.isOk() ) { + + const auto isOk = assertionResult.isOk(); + assertionEnded( CATCH_MOVE(assertionResult) ); + if ( !isOk ) { populateReaction( reaction ); } else if ( resultType == ResultWas::ExplicitSkip ) { // TODO: Need to handle this explicitly, as ExplicitSkip is // considered "OK" reaction.shouldSkip = true; } + resetAssertionInfo(); } void RunContext::handleUnexpectedExceptionNotThrown( AssertionInfo const& info, @@ -5581,16 +6028,17 @@ namespace Catch { void RunContext::handleUnexpectedInflightException( AssertionInfo const& info, - std::string const& message, + std::string&& message, AssertionReaction& reaction ) { m_lastAssertionInfo = info; AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) ); - data.message = message; + data.message = CATCH_MOVE(message); AssertionResult assertionResult{ info, CATCH_MOVE(data) }; - assertionEnded( assertionResult ); + assertionEnded( CATCH_MOVE(assertionResult) ); populateReaction( reaction ); + resetAssertionInfo(); } void RunContext::populateReaction( AssertionReaction& reaction ) { @@ -5607,7 +6055,8 @@ namespace Catch { AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) ); data.message = "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE"s; AssertionResult assertionResult{ info, CATCH_MOVE( data ) }; - assertionEnded( assertionResult ); + assertionEnded( CATCH_MOVE(assertionResult) ); + resetAssertionInfo(); } void RunContext::handleNonExpr( AssertionInfo const &info, @@ -5618,10 +6067,11 @@ namespace Catch { AssertionResultData data( resultType, LazyExpression( false ) ); AssertionResult assertionResult{ info, CATCH_MOVE( data ) }; - assertionEnded( assertionResult ); - if( !assertionResult.isOk() ) - populateReaction( reaction ); + const auto isOk = assertionResult.isOk(); + assertionEnded( CATCH_MOVE(assertionResult) ); + if ( !isOk ) { populateReaction( reaction ); } + resetAssertionInfo(); } @@ -5790,7 +6240,6 @@ namespace Catch { -#include #include #include #include @@ -5814,9 +6263,9 @@ namespace Catch { return s.find( infix ) != std::string::npos; } void toLowerInPlace( std::string& s ) { - std::transform( s.begin(), s.end(), s.begin(), []( char c ) { - return toLower( c ); - } ); + for ( char& c : s ) { + c = toLower( c ); + } } std::string toLower( std::string const& s ) { std::string lc = s; @@ -5949,7 +6398,7 @@ namespace Catch { namespace Catch { - TagAliasRegistry::~TagAliasRegistry() {} + TagAliasRegistry::~TagAliasRegistry() = default; TagAlias const* TagAliasRegistry::find( std::string const& alias ) const { auto it = m_registry.find( alias ); @@ -6030,6 +6479,38 @@ namespace Catch { namespace Catch { + namespace { + static void enforceNoDuplicateTestCases( + std::vector const& tests ) { + auto testInfoCmp = []( TestCaseInfo const* lhs, + TestCaseInfo const* rhs ) { + return *lhs < *rhs; + }; + std::set seenTests( + testInfoCmp ); + for ( auto const& test : tests ) { + const auto infoPtr = &test.getTestCaseInfo(); + const auto prev = seenTests.insert( infoPtr ); + CATCH_ENFORCE( prev.second, + "error: test case \"" + << infoPtr->name << "\", with tags \"" + << infoPtr->tagsAsString() + << "\" already defined.\n" + << "\tFirst seen at " + << ( *prev.first )->lineInfo << "\n" + << "\tRedefined at " << infoPtr->lineInfo ); + } + } + + static bool matchTest( TestCaseHandle const& testCase, + TestSpec const& testSpec, + IConfig const& config ) { + return testSpec.matches( testCase.getTestCaseInfo() ) && + isThrowSafe( testCase, config ); + } + + } // end unnamed namespace + std::vector sortTests( IConfig const& config, std::vector const& unsortedTestCases ) { switch (config.runOrder()) { case TestRunOrder::Declared: @@ -6047,7 +6528,6 @@ namespace Catch { return sorted; } case TestRunOrder::Randomized: { - seedRng(config); using TestWithHash = std::pair; TestCaseInfoHasher h{ config.rngSeed() }; @@ -6086,29 +6566,6 @@ namespace Catch { return !testCase.getTestCaseInfo().throws() || config.allowThrows(); } - bool matchTest( TestCaseHandle const& testCase, TestSpec const& testSpec, IConfig const& config ) { - return testSpec.matches( testCase.getTestCaseInfo() ) && isThrowSafe( testCase, config ); - } - - void - enforceNoDuplicateTestCases( std::vector const& tests ) { - auto testInfoCmp = []( TestCaseInfo const* lhs, - TestCaseInfo const* rhs ) { - return *lhs < *rhs; - }; - std::set seenTests(testInfoCmp); - for ( auto const& test : tests ) { - const auto infoPtr = &test.getTestCaseInfo(); - const auto prev = seenTests.insert( infoPtr ); - CATCH_ENFORCE( - prev.second, - "error: test case \"" << infoPtr->name << "\", with tags \"" - << infoPtr->tagsAsString() << "\" already defined.\n" - << "\tFirst seen at " << ( *prev.first )->lineInfo << "\n" - << "\tRedefined at " << infoPtr->lineInfo ); - } - } - std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ) { std::vector filtered; filtered.reserve( testCases.size() ); @@ -6149,13 +6606,6 @@ namespace Catch { return m_sortedFunctions; } - - - /////////////////////////////////////////////////////////////////////////// - void TestInvokerAsFunction::invoke() const { - m_testAsFunction(); - } - } // end namespace Catch @@ -6401,6 +6851,14 @@ namespace Catch { #endif } + void throw_test_skip_exception() { +#if !defined( CATCH_CONFIG_DISABLE_EXCEPTIONS ) + throw Catch::TestSkipException(); +#else + CATCH_ERROR( "Explicitly skipping tests during runtime requires exceptions" ); +#endif + } + } // namespace Catch @@ -6409,9 +6867,10 @@ namespace Catch { #include namespace Catch { + ITestInvoker::~ITestInvoker() = default; namespace { - StringRef extractClassName( StringRef classOrMethodName ) { + static StringRef extractClassName( StringRef classOrMethodName ) { if ( !startsWith( classOrMethodName, '&' ) ) { return classOrMethodName; } @@ -6438,6 +6897,18 @@ namespace Catch { static_cast( startIdx ), static_cast( classNameSize ) ); } + + class TestInvokerAsFunction final : public ITestInvoker { + using TestType = void ( * )(); + TestType m_testAsFunction; + + public: + TestInvokerAsFunction( TestType testAsFunction ) noexcept: + m_testAsFunction( testAsFunction ) {} + + void invoke() const override { m_testAsFunction(); } + }; + } // namespace Detail::unique_ptr makeTestInvoker( void(*testAsFunction)() ) { @@ -6919,23 +7390,36 @@ namespace Catch { return os; } - Columns Column::operator+( Column const& other ) { + Columns operator+(Column const& lhs, Column const& rhs) { Columns cols; - cols += *this; - cols += other; + cols += lhs; + cols += rhs; return cols; } - - Columns& Columns::operator+=( Column const& col ) { - m_columns.push_back( col ); - return *this; + Columns operator+(Column&& lhs, Column&& rhs) { + Columns cols; + cols += CATCH_MOVE( lhs ); + cols += CATCH_MOVE( rhs ); + return cols; } - Columns Columns::operator+( Column const& col ) { - Columns combined = *this; - combined += col; + Columns& operator+=(Columns& lhs, Column const& rhs) { + lhs.m_columns.push_back( rhs ); + return lhs; + } + Columns& operator+=(Columns& lhs, Column&& rhs) { + lhs.m_columns.push_back( CATCH_MOVE(rhs) ); + return lhs; + } + Columns operator+( Columns const& lhs, Column const& rhs ) { + auto combined( lhs ); + combined += rhs; return combined; } + Columns operator+( Columns&& lhs, Column&& rhs ) { + lhs += CATCH_MOVE( rhs ); + return CATCH_MOVE( lhs ); + } } // namespace TextFlow } // namespace Catch @@ -7431,26 +7915,11 @@ namespace { return ulpDist <= maxUlpDiff; } -#if defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) - - float nextafter(float x, float y) { - return ::nextafterf(x, y); - } - - double nextafter(double x, double y) { - return ::nextafter(x, y); - } - -#endif // ^^^ CATCH_CONFIG_GLOBAL_NEXTAFTER ^^^ template FP step(FP start, FP direction, uint64_t steps) { for (uint64_t i = 0; i < steps; ++i) { -#if defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) start = Catch::nextafter(start, direction); -#else - start = std::nextafter(start, direction); -#endif } return start; } @@ -7824,7 +8293,7 @@ namespace Catch { namespace Catch { - AutomakeReporter::~AutomakeReporter() {} + AutomakeReporter::~AutomakeReporter() = default; void AutomakeReporter::testCaseEnded(TestCaseStats const& _testCaseStats) { // Possible values to emit are PASS, XFAIL, SKIP, FAIL, XPASS and ERROR. @@ -8046,7 +8515,7 @@ class AssertionPrinter { return; const auto itEnd = messages.cend(); - const auto N = static_cast(std::distance(itMessage, itEnd)); + const auto N = static_cast(itEnd - itMessage); stream << colourImpl->guardColour( colour ) << " with " << pluralise( N, "message"_sr ) << ':'; @@ -8124,7 +8593,7 @@ class AssertionPrinter { StreamingReporterBase::testRunEnded( _testRunStats ); } - CompactReporter::~CompactReporter() {} + CompactReporter::~CompactReporter() = default; } // end namespace Catch @@ -8319,15 +8788,9 @@ findMax( std::size_t& i, std::size_t& j, std::size_t& k, std::size_t& l ) { return l; } -enum class Justification { Left, Right }; - -struct ColumnInfo { - std::string name; - std::size_t width; - Justification justification; -}; struct ColumnBreak {}; struct RowBreak {}; +struct OutputFlush {}; class Duration { enum class Unit { @@ -8402,6 +8865,14 @@ class Duration { }; } // end anon namespace +enum class Justification { Left, Right }; + +struct ColumnInfo { + std::string name; + std::size_t width; + Justification justification; +}; + class TablePrinter { std::ostream& m_os; std::vector m_columnInfos; @@ -8424,11 +8895,10 @@ class TablePrinter { *this << RowBreak(); TextFlow::Columns headerCols; - auto spacer = TextFlow::Spacer(2); for (auto const& info : m_columnInfos) { assert(info.width > 2); headerCols += TextFlow::Column(info.name).width(info.width - 2); - headerCols += spacer; + headerCols += TextFlow::Spacer( 2 ); } m_os << headerCols << '\n'; @@ -8444,12 +8914,12 @@ class TablePrinter { } template - friend TablePrinter& operator << (TablePrinter& tp, T const& value) { + friend TablePrinter& operator<< (TablePrinter& tp, T const& value) { tp.m_oss << value; return tp; } - friend TablePrinter& operator << (TablePrinter& tp, ColumnBreak) { + friend TablePrinter& operator<< (TablePrinter& tp, ColumnBreak) { auto colStr = tp.m_oss.str(); const auto strSize = colStr.size(); tp.m_oss.str(""); @@ -8471,13 +8941,18 @@ class TablePrinter { return tp; } - friend TablePrinter& operator << (TablePrinter& tp, RowBreak) { + friend TablePrinter& operator<< (TablePrinter& tp, RowBreak) { if (tp.m_currentColumn > 0) { tp.m_os << '\n'; tp.m_currentColumn = -1; } return tp; } + + friend TablePrinter& operator<<(TablePrinter& tp, OutputFlush) { + tp.m_os << std::flush; + return tp; + } }; ConsoleReporter::ConsoleReporter(ReporterConfig&& config): @@ -8499,7 +8974,7 @@ ConsoleReporter::ConsoleReporter(ReporterConfig&& config): { "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 43, Justification::Left }, { "samples mean std dev", 14, Justification::Right }, { "iterations low mean low std dev", 14, Justification::Right }, - { "estimated high mean high std dev", 14, Justification::Right } + { "est run time high mean high std dev", 14, Justification::Right } }; } }())) {} @@ -8583,8 +9058,11 @@ void ConsoleReporter::benchmarkPreparing( StringRef name ) { void ConsoleReporter::benchmarkStarting(BenchmarkInfo const& info) { (*m_tablePrinter) << info.samples << ColumnBreak() << info.iterations << ColumnBreak(); - if (!m_config->benchmarkNoAnalysis()) - (*m_tablePrinter) << Duration(info.estimatedDuration) << ColumnBreak(); + if ( !m_config->benchmarkNoAnalysis() ) { + ( *m_tablePrinter ) + << Duration( info.estimatedDuration ) << ColumnBreak(); + } + ( *m_tablePrinter ) << OutputFlush{}; } void ConsoleReporter::benchmarkEnded(BenchmarkStats<> const& stats) { if (m_config->benchmarkNoAnalysis()) @@ -9280,6 +9758,366 @@ namespace Catch { } // namespace Catch +// + +namespace Catch { + namespace { + void writeSourceInfo( JsonObjectWriter& writer, + SourceLineInfo const& sourceInfo ) { + auto source_location_writer = + writer.write( "source-location"_sr ).writeObject(); + source_location_writer.write( "filename"_sr ) + .write( sourceInfo.file ); + source_location_writer.write( "line"_sr ).write( sourceInfo.line ); + } + + void writeTags( JsonArrayWriter writer, std::vector const& tags ) { + for ( auto const& tag : tags ) { + writer.write( tag.original ); + } + } + + void writeProperties( JsonArrayWriter writer, + TestCaseInfo const& info ) { + if ( info.isHidden() ) { writer.write( "is-hidden"_sr ); } + if ( info.okToFail() ) { writer.write( "ok-to-fail"_sr ); } + if ( info.expectedToFail() ) { + writer.write( "expected-to-fail"_sr ); + } + if ( info.throws() ) { writer.write( "throws"_sr ); } + } + + } // namespace + + JsonReporter::JsonReporter( ReporterConfig&& config ): + StreamingReporterBase{ CATCH_MOVE( config ) } { + + m_preferences.shouldRedirectStdOut = true; + // TBD: Do we want to report all assertions? XML reporter does + // not, but for machine-parseable reporters I think the answer + // should be yes. + m_preferences.shouldReportAllAssertions = true; + + m_objectWriters.emplace( m_stream ); + m_writers.emplace( Writer::Object ); + auto& writer = m_objectWriters.top(); + + writer.write( "version"_sr ).write( 1 ); + + { + auto metadata_writer = writer.write( "metadata"_sr ).writeObject(); + metadata_writer.write( "name"_sr ).write( m_config->name() ); + metadata_writer.write( "rng-seed"_sr ).write( m_config->rngSeed() ); + metadata_writer.write( "catch2-version"_sr ) + .write( libraryVersion() ); + if ( m_config->testSpec().hasFilters() ) { + metadata_writer.write( "filters"_sr ) + .write( m_config->testSpec() ); + } + } + } + + JsonReporter::~JsonReporter() { + endListing(); + // TODO: Ensure this closes the top level object, add asserts + assert( m_writers.size() == 1 && "Only the top level object should be open" ); + assert( m_writers.top() == Writer::Object ); + endObject(); + m_stream << '\n' << std::flush; + assert( m_writers.empty() ); + } + + JsonArrayWriter& JsonReporter::startArray() { + m_arrayWriters.emplace( m_arrayWriters.top().writeArray() ); + m_writers.emplace( Writer::Array ); + return m_arrayWriters.top(); + } + JsonArrayWriter& JsonReporter::startArray( StringRef key ) { + m_arrayWriters.emplace( + m_objectWriters.top().write( key ).writeArray() ); + m_writers.emplace( Writer::Array ); + return m_arrayWriters.top(); + } + + JsonObjectWriter& JsonReporter::startObject() { + m_objectWriters.emplace( m_arrayWriters.top().writeObject() ); + m_writers.emplace( Writer::Object ); + return m_objectWriters.top(); + } + JsonObjectWriter& JsonReporter::startObject( StringRef key ) { + m_objectWriters.emplace( + m_objectWriters.top().write( key ).writeObject() ); + m_writers.emplace( Writer::Object ); + return m_objectWriters.top(); + } + + void JsonReporter::endObject() { + assert( isInside( Writer::Object ) ); + m_objectWriters.pop(); + m_writers.pop(); + } + void JsonReporter::endArray() { + assert( isInside( Writer::Array ) ); + m_arrayWriters.pop(); + m_writers.pop(); + } + + bool JsonReporter::isInside( Writer writer ) { + return !m_writers.empty() && m_writers.top() == writer; + } + + void JsonReporter::startListing() { + if ( !m_startedListing ) { startObject( "listings"_sr ); } + m_startedListing = true; + } + void JsonReporter::endListing() { + if ( m_startedListing ) { endObject(); } + m_startedListing = false; + } + + std::string JsonReporter::getDescription() { + return "Outputs listings as JSON. Test listing is Work-in-Progress!"; + } + + void JsonReporter::testRunStarting( TestRunInfo const& testInfo ) { + StreamingReporterBase::testRunStarting( testInfo ); + endListing(); + + assert( isInside( Writer::Object ) ); + startObject( "test-run"_sr ); + startArray( "test-cases"_sr ); + } + + static void writeCounts( JsonObjectWriter&& writer, Counts const& counts ) { + writer.write( "passed"_sr ).write( counts.passed ); + writer.write( "failed"_sr ).write( counts.failed ); + writer.write( "fail-but-ok"_sr ).write( counts.failedButOk ); + writer.write( "skipped"_sr ).write( counts.skipped ); + } + + void JsonReporter::testRunEnded(TestRunStats const& runStats) { + assert( isInside( Writer::Array ) ); + // End "test-cases" + endArray(); + + { + auto totals = + m_objectWriters.top().write( "totals"_sr ).writeObject(); + writeCounts( totals.write( "assertions"_sr ).writeObject(), + runStats.totals.assertions ); + writeCounts( totals.write( "test-cases"_sr ).writeObject(), + runStats.totals.testCases ); + } + + // End the "test-run" object + endObject(); + } + + void JsonReporter::testCaseStarting( TestCaseInfo const& tcInfo ) { + StreamingReporterBase::testCaseStarting( tcInfo ); + + assert( isInside( Writer::Array ) && + "We should be in the 'test-cases' array" ); + startObject(); + // "test-info" prelude + { + auto testInfo = + m_objectWriters.top().write( "test-info"_sr ).writeObject(); + // TODO: handle testName vs className!! + testInfo.write( "name"_sr ).write( tcInfo.name ); + writeSourceInfo(testInfo, tcInfo.lineInfo); + writeTags( testInfo.write( "tags"_sr ).writeArray(), tcInfo.tags ); + writeProperties( testInfo.write( "properties"_sr ).writeArray(), + tcInfo ); + } + + + // Start the array for individual test runs (testCasePartial pairs) + startArray( "runs"_sr ); + } + + void JsonReporter::testCaseEnded( TestCaseStats const& tcStats ) { + StreamingReporterBase::testCaseEnded( tcStats ); + + // We need to close the 'runs' array before finishing the test case + assert( isInside( Writer::Array ) ); + endArray(); + + { + auto totals = + m_objectWriters.top().write( "totals"_sr ).writeObject(); + writeCounts( totals.write( "assertions"_sr ).writeObject(), + tcStats.totals.assertions ); + // We do not write the test case totals, because there will always be just one test case here. + // TODO: overall "result" -> success, skip, fail here? Or in partial result? + } + // We do not write out stderr/stdout, because we instead wrote those out in partial runs + + // TODO: aborting? + + // And we also close this test case's object + assert( isInside( Writer::Object ) ); + endObject(); + } + + void JsonReporter::testCasePartialStarting( TestCaseInfo const& /*tcInfo*/, + uint64_t index ) { + startObject(); + m_objectWriters.top().write( "run-idx"_sr ).write( index ); + startArray( "path"_sr ); + // TODO: we want to delay most of the printing to the 'root' section + // TODO: childSection key name? + } + + void JsonReporter::testCasePartialEnded( TestCaseStats const& tcStats, + uint64_t /*index*/ ) { + // Fixme: the top level section handles this. + //// path object + endArray(); + if ( !tcStats.stdOut.empty() ) { + m_objectWriters.top() + .write( "captured-stdout"_sr ) + .write( tcStats.stdOut ); + } + if ( !tcStats.stdErr.empty() ) { + m_objectWriters.top() + .write( "captured-stderr"_sr ) + .write( tcStats.stdErr ); + } + { + auto totals = + m_objectWriters.top().write( "totals"_sr ).writeObject(); + writeCounts( totals.write( "assertions"_sr ).writeObject(), + tcStats.totals.assertions ); + // We do not write the test case totals, because there will + // always be just one test case here. + // TODO: overall "result" -> success, skip, fail here? Or in + // partial result? + } + // TODO: aborting? + // run object + endObject(); + } + + void JsonReporter::sectionStarting( SectionInfo const& sectionInfo ) { + assert( isInside( Writer::Array ) && + "Section should always start inside an object" ); + // We want to nest top level sections, even though it shares name + // and source loc with the TEST_CASE + auto& sectionObject = startObject(); + sectionObject.write( "kind"_sr ).write( "section"_sr ); + sectionObject.write( "name"_sr ).write( sectionInfo.name ); + writeSourceInfo( m_objectWriters.top(), sectionInfo.lineInfo ); + + + // TBD: Do we want to create this event lazily? It would become + // rather complex, but we could do it, and it would look + // better for empty sections. OTOH, empty sections should + // be rare. + startArray( "path"_sr ); + } + void JsonReporter::sectionEnded( SectionStats const& /*sectionStats */) { + // End the subpath array + endArray(); + // TODO: metadata + // TODO: what info do we have here? + + // End the section object + endObject(); + } + + void JsonReporter::assertionStarting( AssertionInfo const& /*assertionInfo*/ ) {} + void JsonReporter::assertionEnded( AssertionStats const& assertionStats ) { + // TODO: There is lot of different things to handle here, but + // we can fill it in later, after we show that the basic + // outline and streaming reporter impl works well enough. + //if ( !m_config->includeSuccessfulResults() + // && assertionStats.assertionResult.isOk() ) { + // return; + //} + assert( isInside( Writer::Array ) ); + auto assertionObject = m_arrayWriters.top().writeObject(); + + assertionObject.write( "kind"_sr ).write( "assertion"_sr ); + writeSourceInfo( assertionObject, + assertionStats.assertionResult.getSourceInfo() ); + assertionObject.write( "status"_sr ) + .write( assertionStats.assertionResult.isOk() ); + // TODO: handling of result. + // TODO: messages + // TODO: totals? + } + + + void JsonReporter::benchmarkPreparing( StringRef name ) { (void)name; } + void JsonReporter::benchmarkStarting( BenchmarkInfo const& ) {} + void JsonReporter::benchmarkEnded( BenchmarkStats<> const& ) {} + void JsonReporter::benchmarkFailed( StringRef error ) { (void)error; } + + void JsonReporter::listReporters( + std::vector const& descriptions ) { + startListing(); + + auto writer = + m_objectWriters.top().write( "reporters"_sr ).writeArray(); + for ( auto const& desc : descriptions ) { + auto desc_writer = writer.writeObject(); + desc_writer.write( "name"_sr ).write( desc.name ); + desc_writer.write( "description"_sr ).write( desc.description ); + } + } + void JsonReporter::listListeners( + std::vector const& descriptions ) { + startListing(); + + auto writer = + m_objectWriters.top().write( "listeners"_sr ).writeArray(); + + for ( auto const& desc : descriptions ) { + auto desc_writer = writer.writeObject(); + desc_writer.write( "name"_sr ).write( desc.name ); + desc_writer.write( "description"_sr ).write( desc.description ); + } + } + void JsonReporter::listTests( std::vector const& tests ) { + startListing(); + + auto writer = m_objectWriters.top().write( "tests"_sr ).writeArray(); + + for ( auto const& test : tests ) { + auto desc_writer = writer.writeObject(); + auto const& info = test.getTestCaseInfo(); + + desc_writer.write( "name"_sr ).write( info.name ); + desc_writer.write( "class-name"_sr ).write( info.className ); + { + auto tag_writer = desc_writer.write( "tags"_sr ).writeArray(); + for ( auto const& tag : info.tags ) { + tag_writer.write( tag.original ); + } + } + writeSourceInfo( desc_writer, info.lineInfo ); + } + } + void JsonReporter::listTags( std::vector const& tags ) { + startListing(); + + auto writer = m_objectWriters.top().write( "tags"_sr ).writeArray(); + for ( auto const& tag : tags ) { + auto tag_writer = writer.writeObject(); + { + auto aliases_writer = + tag_writer.write( "aliases"_sr ).writeArray(); + for ( auto alias : tag.spellings ) { + aliases_writer.write( alias ); + } + } + tag_writer.write( "count"_sr ).write( tag.count ); + } + } +} // namespace Catch + + #include @@ -9299,6 +10137,8 @@ namespace Catch { gmtime_s(&timeInfo, &rawtime); #elif defined (CATCH_PLATFORM_PLAYSTATION) gmtime_s(&rawtime, &timeInfo); +#elif defined (__IAR_SYSTEMS_ICC__) + timeInfo = *std::gmtime(&rawtime); #else gmtime_r(&rawtime, &timeInfo); #endif @@ -9559,7 +10399,7 @@ namespace Catch { } } - if( !result.getMessage().empty() ) + if( result.hasMessage() ) rss << result.getMessage() << '\n'; for( auto const& msg : stats.infoMessages ) if( msg.type == ResultWas::Info ) @@ -9678,7 +10518,6 @@ namespace Catch { } } - // The return value indicates if the messages buffer should be cleared: void MultiReporter::assertionEnded( AssertionStats const& assertionStats ) { const bool reportByDefault = assertionStats.assertionResult.getResultType() != ResultWas::Ok || @@ -9781,6 +10620,11 @@ namespace Catch { } } + void registerListenerImpl( Detail::unique_ptr listenerFactory ) { + getMutableRegistryHub().registerListener( CATCH_MOVE(listenerFactory) ); + } + + } // namespace Detail } // namespace Catch @@ -9920,7 +10764,7 @@ namespace Catch { } } - if (!result.getMessage().empty()) + if (result.hasMessage()) textRss << result.getMessage() << '\n'; for (auto const& msg : stats.infoMessages) @@ -9954,7 +10798,6 @@ namespace Catch { #include -#include #include namespace Catch { @@ -10105,7 +10948,7 @@ namespace Catch { // using messages.end() directly (or auto) yields compilation error: std::vector::const_iterator itEnd = messages.end(); - const std::size_t N = static_cast(std::distance(itMessage, itEnd)); + const std::size_t N = static_cast(itEnd - itMessage); stream << colourImpl->guardColour( colour ) << " with " << pluralise( N, "message"_sr ) << ':'; @@ -10203,7 +11046,7 @@ namespace Catch { } // end anonymous namespace - TeamCityReporter::~TeamCityReporter() {} + TeamCityReporter::~TeamCityReporter() = default; void TeamCityReporter::testRunStarting( TestRunInfo const& runInfo ) { m_stream << "##teamcity[testSuiteStarted name='" << escape( runInfo.name ) @@ -10377,7 +11220,7 @@ namespace Catch { m_xml.startElement("Catch2TestRun") .writeAttribute("name"_sr, m_config->name()) .writeAttribute("rng-seed"_sr, m_config->rngSeed()) - .writeAttribute("xml-format-version"_sr, 2) + .writeAttribute("xml-format-version"_sr, 3) .writeAttribute("catch2-version"_sr, libraryVersion()); if ( m_config->testSpec().hasFilters() ) { m_xml.writeAttribute( "filters"_sr, m_config->testSpec() ); @@ -10419,11 +11262,13 @@ namespace Catch { // Print any info messages in tags. for( auto const& msg : assertionStats.infoMessages ) { if( msg.type == ResultWas::Info && includeResults ) { - m_xml.scopedElement( "Info" ) - .writeText( msg.message ); + auto t = m_xml.scopedElement( "Info" ); + writeSourceInfo( msg.lineInfo ); + t.writeText( msg.message ); } else if ( msg.type == ResultWas::Warning ) { - m_xml.scopedElement( "Warning" ) - .writeText( msg.message ); + auto t = m_xml.scopedElement( "Warning" ); + writeSourceInfo( msg.lineInfo ); + t.writeText( msg.message ); } } } @@ -10553,26 +11398,23 @@ namespace Catch { } void XmlReporter::benchmarkEnded(BenchmarkStats<> const& benchmarkStats) { - m_xml.startElement("mean") + m_xml.scopedElement("mean") .writeAttribute("value"_sr, benchmarkStats.mean.point.count()) .writeAttribute("lowerBound"_sr, benchmarkStats.mean.lower_bound.count()) .writeAttribute("upperBound"_sr, benchmarkStats.mean.upper_bound.count()) .writeAttribute("ci"_sr, benchmarkStats.mean.confidence_interval); - m_xml.endElement(); - m_xml.startElement("standardDeviation") + m_xml.scopedElement("standardDeviation") .writeAttribute("value"_sr, benchmarkStats.standardDeviation.point.count()) .writeAttribute("lowerBound"_sr, benchmarkStats.standardDeviation.lower_bound.count()) .writeAttribute("upperBound"_sr, benchmarkStats.standardDeviation.upper_bound.count()) .writeAttribute("ci"_sr, benchmarkStats.standardDeviation.confidence_interval); - m_xml.endElement(); - m_xml.startElement("outliers") + m_xml.scopedElement("outliers") .writeAttribute("variance"_sr, benchmarkStats.outlierVariance) .writeAttribute("lowMild"_sr, benchmarkStats.outliers.low_mild) .writeAttribute("lowSevere"_sr, benchmarkStats.outliers.low_severe) .writeAttribute("highMild"_sr, benchmarkStats.outliers.high_mild) .writeAttribute("highSevere"_sr, benchmarkStats.outliers.high_severe); m_xml.endElement(); - m_xml.endElement(); } void XmlReporter::benchmarkFailed(StringRef error) { diff --git a/external_imported/Catch2/extras/catch_amalgamated.hpp b/external_imported/Catch2/extras/catch_amalgamated.hpp index 321cec5da..fdba759a7 100644 --- a/external_imported/Catch2/extras/catch_amalgamated.hpp +++ b/external_imported/Catch2/extras/catch_amalgamated.hpp @@ -1,3 +1,4 @@ + // Copyright Catch2 Authors // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.txt or copy at @@ -5,8 +6,8 @@ // SPDX-License-Identifier: BSL-1.0 -// Catch v3.3.2 -// Generated: 2023-02-26 10:28:46.785908 +// Catch v3.5.2 +// Generated: 2024-01-15 14:06:34.036475 // ---------------------------------------------------------- // This file is an amalgamation of multiple different files. // You probably shouldn't edit it directly. @@ -59,238 +60,6 @@ -#ifndef CATCH_INTERFACES_CONFIG_HPP_INCLUDED -#define CATCH_INTERFACES_CONFIG_HPP_INCLUDED - - - -#ifndef CATCH_NONCOPYABLE_HPP_INCLUDED -#define CATCH_NONCOPYABLE_HPP_INCLUDED - -namespace Catch { - namespace Detail { - - //! Deriving classes become noncopyable and nonmovable - class NonCopyable { - NonCopyable( NonCopyable const& ) = delete; - NonCopyable( NonCopyable&& ) = delete; - NonCopyable& operator=( NonCopyable const& ) = delete; - NonCopyable& operator=( NonCopyable&& ) = delete; - - protected: - NonCopyable() noexcept = default; - }; - - } // namespace Detail -} // namespace Catch - -#endif // CATCH_NONCOPYABLE_HPP_INCLUDED - - -#ifndef CATCH_STRINGREF_HPP_INCLUDED -#define CATCH_STRINGREF_HPP_INCLUDED - -#include -#include -#include -#include - -#include - -namespace Catch { - - /// A non-owning string class (similar to the forthcoming std::string_view) - /// Note that, because a StringRef may be a substring of another string, - /// it may not be null terminated. - class StringRef { - public: - using size_type = std::size_t; - using const_iterator = const char*; - - private: - static constexpr char const* const s_empty = ""; - - char const* m_start = s_empty; - size_type m_size = 0; - - public: // construction - constexpr StringRef() noexcept = default; - - StringRef( char const* rawChars ) noexcept; - - constexpr StringRef( char const* rawChars, size_type size ) noexcept - : m_start( rawChars ), - m_size( size ) - {} - - StringRef( std::string const& stdString ) noexcept - : m_start( stdString.c_str() ), - m_size( stdString.size() ) - {} - - explicit operator std::string() const { - return std::string(m_start, m_size); - } - - public: // operators - auto operator == ( StringRef other ) const noexcept -> bool { - return m_size == other.m_size - && (std::memcmp( m_start, other.m_start, m_size ) == 0); - } - auto operator != (StringRef other) const noexcept -> bool { - return !(*this == other); - } - - constexpr auto operator[] ( size_type index ) const noexcept -> char { - assert(index < m_size); - return m_start[index]; - } - - bool operator<(StringRef rhs) const noexcept; - - public: // named queries - constexpr auto empty() const noexcept -> bool { - return m_size == 0; - } - constexpr auto size() const noexcept -> size_type { - return m_size; - } - - // Returns a substring of [start, start + length). - // If start + length > size(), then the substring is [start, start + size()). - // If start > size(), then the substring is empty. - constexpr StringRef substr(size_type start, size_type length) const noexcept { - if (start < m_size) { - const auto shortened_size = m_size - start; - return StringRef(m_start + start, (shortened_size < length) ? shortened_size : length); - } else { - return StringRef(); - } - } - - // Returns the current start pointer. May not be null-terminated. - constexpr char const* data() const noexcept { - return m_start; - } - - constexpr const_iterator begin() const { return m_start; } - constexpr const_iterator end() const { return m_start + m_size; } - - - friend std::string& operator += (std::string& lhs, StringRef sr); - friend std::ostream& operator << (std::ostream& os, StringRef sr); - friend std::string operator+(StringRef lhs, StringRef rhs); - - /** - * Provides a three-way comparison with rhs - * - * Returns negative number if lhs < rhs, 0 if lhs == rhs, and a positive - * number if lhs > rhs - */ - int compare( StringRef rhs ) const; - }; - - - constexpr auto operator ""_sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { - return StringRef( rawChars, size ); - } -} // namespace Catch - -constexpr auto operator ""_catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef { - return Catch::StringRef( rawChars, size ); -} - -#endif // CATCH_STRINGREF_HPP_INCLUDED - -#include -#include -#include -#include - -namespace Catch { - - enum class Verbosity { - Quiet = 0, - Normal, - High - }; - - struct WarnAbout { enum What { - Nothing = 0x00, - //! A test case or leaf section did not run any assertions - NoAssertions = 0x01, - //! A command line test spec matched no test cases - UnmatchedTestSpec = 0x02, - }; }; - - enum class ShowDurations { - DefaultForReporter, - Always, - Never - }; - enum class TestRunOrder { - Declared, - LexicographicallySorted, - Randomized - }; - enum class ColourMode : std::uint8_t { - //! Let Catch2 pick implementation based on platform detection - PlatformDefault, - //! Use ANSI colour code escapes - ANSI, - //! Use Win32 console colour API - Win32, - //! Don't use any colour - None - }; - struct WaitForKeypress { enum When { - Never, - BeforeStart = 1, - BeforeExit = 2, - BeforeStartAndExit = BeforeStart | BeforeExit - }; }; - - class TestSpec; - class IStream; - - class IConfig : public Detail::NonCopyable { - public: - virtual ~IConfig(); - - virtual bool allowThrows() const = 0; - virtual StringRef name() const = 0; - virtual bool includeSuccessfulResults() const = 0; - virtual bool shouldDebugBreak() const = 0; - virtual bool warnAboutMissingAssertions() const = 0; - virtual bool warnAboutUnmatchedTestSpecs() const = 0; - virtual bool zeroTestsCountAsSuccess() const = 0; - virtual int abortAfter() const = 0; - virtual bool showInvisibles() const = 0; - virtual ShowDurations showDurations() const = 0; - virtual double minDuration() const = 0; - virtual TestSpec const& testSpec() const = 0; - virtual bool hasTestFilters() const = 0; - virtual std::vector const& getTestsOrTags() const = 0; - virtual TestRunOrder runOrder() const = 0; - virtual uint32_t rngSeed() const = 0; - virtual unsigned int shardCount() const = 0; - virtual unsigned int shardIndex() const = 0; - virtual ColourMode defaultColourMode() const = 0; - virtual std::vector const& getSectionsToRun() const = 0; - virtual Verbosity verbosity() const = 0; - - virtual bool skipBenchmarks() const = 0; - virtual bool benchmarkNoAnalysis() const = 0; - virtual unsigned int benchmarkSamples() const = 0; - virtual double benchmarkConfidenceInterval() const = 0; - virtual unsigned int benchmarkResamples() const = 0; - virtual std::chrono::milliseconds benchmarkWarmupTime() const = 0; - }; -} - -#endif // CATCH_INTERFACES_CONFIG_HPP_INCLUDED - - #ifndef CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED #define CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED @@ -366,12 +135,18 @@ namespace Catch { # define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ _Pragma( "GCC diagnostic ignored \"-Wparentheses\"" ) +# define CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT \ + _Pragma( "GCC diagnostic ignored \"-Wunused-result\"" ) + # define CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ _Pragma( "GCC diagnostic ignored \"-Wunused-variable\"" ) # define CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \ _Pragma( "GCC diagnostic ignored \"-Wuseless-cast\"" ) +# define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ + _Pragma( "GCC diagnostic ignored \"-Wshadow\"" ) + # define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) #endif @@ -444,6 +219,9 @@ namespace Catch { # define CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS \ _Pragma( "clang diagnostic ignored \"-Wcomma\"" ) +# define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wshadow\"" ) + #endif // __clang__ @@ -463,7 +241,9 @@ namespace Catch { //////////////////////////////////////////////////////////////////////////////// // Assume that some platforms do not support getenv. -#if defined(CATCH_PLATFORM_WINDOWS_UWP) || defined(CATCH_PLATFORM_PLAYSTATION) +#if defined( CATCH_PLATFORM_WINDOWS_UWP ) || \ + defined( CATCH_PLATFORM_PLAYSTATION ) || \ + defined( _GAMING_XBOX ) # define CATCH_INTERNAL_CONFIG_NO_GETENV #else # define CATCH_INTERNAL_CONFIG_GETENV @@ -681,6 +461,9 @@ namespace Catch { #if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) # define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS #endif +#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT) +# define CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT +#endif #if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS) # define CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS #endif @@ -690,6 +473,16 @@ namespace Catch { #if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS) # define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS #endif +#if !defined( CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS ) +# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS +#endif +#if !defined( CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS ) +# define CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS +#endif +#if !defined( CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS ) +# define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS +#endif + // The goal of this macro is to avoid evaluation of the arguments, but // still have the compiler warn on problems inside... @@ -703,13 +496,6 @@ namespace Catch { # undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS #endif -#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#endif - -#if !defined(CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS -#endif #if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) #define CATCH_TRY if ((true)) @@ -755,38 +541,31 @@ namespace Catch { class IResultCapture; class IConfig; - class IContext { - public: - virtual ~IContext(); // = default + class Context { + IConfig const* m_config = nullptr; + IResultCapture* m_resultCapture = nullptr; - virtual IResultCapture* getResultCapture() = 0; - virtual IConfig const* getConfig() const = 0; - }; + CATCH_EXPORT static Context* currentContext; + friend Context& getCurrentMutableContext(); + friend Context const& getCurrentContext(); + static void createContext(); + friend void cleanUpContext(); - class IMutableContext : public IContext { public: - ~IMutableContext() override; // = default - virtual void setResultCapture( IResultCapture* resultCapture ) = 0; - virtual void setConfig( IConfig const* config ) = 0; - - private: - CATCH_EXPORT static IMutableContext* currentContext; - friend IMutableContext& getCurrentMutableContext(); - friend void cleanUpContext(); - static void createContext(); + IResultCapture* getResultCapture() const { return m_resultCapture; } + IConfig const* getConfig() const { return m_config; } + void setResultCapture( IResultCapture* resultCapture ); + void setConfig( IConfig const* config ); }; - inline IMutableContext& getCurrentMutableContext() - { - if( !IMutableContext::currentContext ) - IMutableContext::createContext(); + Context& getCurrentMutableContext(); + + inline Context const& getCurrentContext() { + // We duplicate the logic from `getCurrentMutableContext` here, + // to avoid paying the call overhead in debug mode. + if ( !Context::currentContext ) { Context::createContext(); } // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn) - return *IMutableContext::currentContext; - } - - inline IContext& getCurrentContext() - { - return getCurrentMutableContext(); + return *Context::currentContext; } void cleanUpContext(); @@ -798,16 +577,6 @@ namespace Catch { #endif // CATCH_CONTEXT_HPP_INCLUDED -#ifndef CATCH_INTERFACES_REPORTER_HPP_INCLUDED -#define CATCH_INTERFACES_REPORTER_HPP_INCLUDED - - - -#ifndef CATCH_SECTION_INFO_HPP_INCLUDED -#define CATCH_SECTION_INFO_HPP_INCLUDED - - - #ifndef CATCH_MOVE_AND_FORWARD_HPP_INCLUDED #define CATCH_MOVE_AND_FORWARD_HPP_INCLUDED @@ -822,110 +591,201 @@ namespace Catch { #endif // CATCH_MOVE_AND_FORWARD_HPP_INCLUDED -#ifndef CATCH_SOURCE_LINE_INFO_HPP_INCLUDED -#define CATCH_SOURCE_LINE_INFO_HPP_INCLUDED - -#include -#include +#ifndef CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED +#define CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED namespace Catch { - struct SourceLineInfo { + //! Used to signal that an assertion macro failed + struct TestFailureException{}; + //! Used to signal that the remainder of a test should be skipped + struct TestSkipException {}; - SourceLineInfo() = delete; - constexpr SourceLineInfo( char const* _file, std::size_t _line ) noexcept: - file( _file ), - line( _line ) - {} + /** + * Outlines throwing of `TestFailureException` into a single TU + * + * Also handles `CATCH_CONFIG_DISABLE_EXCEPTIONS` for callers. + */ + [[noreturn]] void throw_test_failure_exception(); - bool operator == ( SourceLineInfo const& other ) const noexcept; - bool operator < ( SourceLineInfo const& other ) const noexcept; + /** + * Outlines throwing of `TestSkipException` into a single TU + * + * Also handles `CATCH_CONFIG_DISABLE_EXCEPTIONS` for callers. + */ + [[noreturn]] void throw_test_skip_exception(); - char const* file; - std::size_t line; +} // namespace Catch - friend std::ostream& operator << (std::ostream& os, SourceLineInfo const& info); - }; -} +#endif // CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED -#define CATCH_INTERNAL_LINEINFO \ - ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) -#endif // CATCH_SOURCE_LINE_INFO_HPP_INCLUDED +#ifndef CATCH_UNIQUE_NAME_HPP_INCLUDED +#define CATCH_UNIQUE_NAME_HPP_INCLUDED -#ifndef CATCH_TOTALS_HPP_INCLUDED -#define CATCH_TOTALS_HPP_INCLUDED -#include -namespace Catch { +/** \file + * Wrapper for the CONFIG configuration option + * + * When generating internal unique names, there are two options. Either + * we mix in the current line number, or mix in an incrementing number. + * We prefer the latter, using `__COUNTER__`, but users might want to + * use the former. + */ - struct Counts { - Counts operator - ( Counts const& other ) const; - Counts& operator += ( Counts const& other ); +#ifndef CATCH_CONFIG_COUNTER_HPP_INCLUDED +#define CATCH_CONFIG_COUNTER_HPP_INCLUDED - std::uint64_t total() const; - bool allPassed() const; - bool allOk() const; - std::uint64_t passed = 0; - std::uint64_t failed = 0; - std::uint64_t failedButOk = 0; - std::uint64_t skipped = 0; - }; +#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) + #define CATCH_INTERNAL_CONFIG_COUNTER +#endif - struct Totals { +#if defined( CATCH_INTERNAL_CONFIG_COUNTER ) && \ + !defined( CATCH_CONFIG_NO_COUNTER ) && \ + !defined( CATCH_CONFIG_COUNTER ) +# define CATCH_CONFIG_COUNTER +#endif - Totals operator - ( Totals const& other ) const; - Totals& operator += ( Totals const& other ); - Totals delta( Totals const& prevTotals ) const; +#endif // CATCH_CONFIG_COUNTER_HPP_INCLUDED +#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line +#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) +#ifdef CATCH_CONFIG_COUNTER +# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) +#else +# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) +#endif - Counts assertions; - Counts testCases; - }; -} +#endif // CATCH_UNIQUE_NAME_HPP_INCLUDED -#endif // CATCH_TOTALS_HPP_INCLUDED +#ifndef CATCH_INTERFACES_CAPTURE_HPP_INCLUDED +#define CATCH_INTERFACES_CAPTURE_HPP_INCLUDED + +#include +#include + + + +#ifndef CATCH_STRINGREF_HPP_INCLUDED +#define CATCH_STRINGREF_HPP_INCLUDED + +#include #include +#include +#include + +#include namespace Catch { - struct SectionInfo { - // The last argument is ignored, so that people can write - // SECTION("ShortName", "Proper description that is long") and - // still use the `-c` flag comfortably. - SectionInfo( SourceLineInfo const& _lineInfo, std::string _name, - const char* const = nullptr ): - name(CATCH_MOVE(_name)), - lineInfo(_lineInfo) - {} + /// A non-owning string class (similar to the forthcoming std::string_view) + /// Note that, because a StringRef may be a substring of another string, + /// it may not be null terminated. + class StringRef { + public: + using size_type = std::size_t; + using const_iterator = const char*; - std::string name; - SourceLineInfo lineInfo; - }; + static constexpr size_type npos{ static_cast( -1 ) }; - struct SectionEndInfo { - SectionInfo sectionInfo; - Counts prevAssertions; - double durationInSeconds; - }; + private: + static constexpr char const* const s_empty = ""; -} // end namespace Catch + char const* m_start = s_empty; + size_type m_size = 0; -#endif // CATCH_SECTION_INFO_HPP_INCLUDED + public: // construction + constexpr StringRef() noexcept = default; + StringRef( char const* rawChars ) noexcept; -#ifndef CATCH_ASSERTION_RESULT_HPP_INCLUDED -#define CATCH_ASSERTION_RESULT_HPP_INCLUDED + constexpr StringRef( char const* rawChars, size_type size ) noexcept + : m_start( rawChars ), + m_size( size ) + {} + + StringRef( std::string const& stdString ) noexcept + : m_start( stdString.c_str() ), + m_size( stdString.size() ) + {} + explicit operator std::string() const { + return std::string(m_start, m_size); + } + public: // operators + auto operator == ( StringRef other ) const noexcept -> bool { + return m_size == other.m_size + && (std::memcmp( m_start, other.m_start, m_size ) == 0); + } + auto operator != (StringRef other) const noexcept -> bool { + return !(*this == other); + } -#ifndef CATCH_ASSERTION_INFO_HPP_INCLUDED -#define CATCH_ASSERTION_INFO_HPP_INCLUDED + constexpr auto operator[] ( size_type index ) const noexcept -> char { + assert(index < m_size); + return m_start[index]; + } + + bool operator<(StringRef rhs) const noexcept; + + public: // named queries + constexpr auto empty() const noexcept -> bool { + return m_size == 0; + } + constexpr auto size() const noexcept -> size_type { + return m_size; + } + + // Returns a substring of [start, start + length). + // If start + length > size(), then the substring is [start, size()). + // If start > size(), then the substring is empty. + constexpr StringRef substr(size_type start, size_type length) const noexcept { + if (start < m_size) { + const auto shortened_size = m_size - start; + return StringRef(m_start + start, (shortened_size < length) ? shortened_size : length); + } else { + return StringRef(); + } + } + + // Returns the current start pointer. May not be null-terminated. + constexpr char const* data() const noexcept { + return m_start; + } + + constexpr const_iterator begin() const { return m_start; } + constexpr const_iterator end() const { return m_start + m_size; } + + + friend std::string& operator += (std::string& lhs, StringRef sr); + friend std::ostream& operator << (std::ostream& os, StringRef sr); + friend std::string operator+(StringRef lhs, StringRef rhs); + + /** + * Provides a three-way comparison with rhs + * + * Returns negative number if lhs < rhs, 0 if lhs == rhs, and a positive + * number if lhs > rhs + */ + int compare( StringRef rhs ) const; + }; + + + constexpr auto operator ""_sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { + return StringRef( rawChars, size ); + } +} // namespace Catch + +constexpr auto operator ""_catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef { + return Catch::StringRef( rawChars, size ); +} +#endif // CATCH_STRINGREF_HPP_INCLUDED #ifndef CATCH_RESULT_TYPE_HPP_INCLUDED @@ -979,120 +839,12 @@ namespace Catch { #endif // CATCH_RESULT_TYPE_HPP_INCLUDED -namespace Catch { - - struct AssertionInfo { - // AssertionInfo() = delete; - - StringRef macroName; - SourceLineInfo lineInfo; - StringRef capturedExpression; - ResultDisposition::Flags resultDisposition; - }; - -} // end namespace Catch - -#endif // CATCH_ASSERTION_INFO_HPP_INCLUDED +#ifndef CATCH_UNIQUE_PTR_HPP_INCLUDED +#define CATCH_UNIQUE_PTR_HPP_INCLUDED -#ifndef CATCH_LAZY_EXPR_HPP_INCLUDED -#define CATCH_LAZY_EXPR_HPP_INCLUDED - -#include - -namespace Catch { - - class ITransientExpression; - - class LazyExpression { - friend class AssertionHandler; - friend struct AssertionStats; - friend class RunContext; - - ITransientExpression const* m_transientExpression = nullptr; - bool m_isNegated; - public: - LazyExpression( bool isNegated ): - m_isNegated(isNegated) - {} - LazyExpression(LazyExpression const& other) = default; - LazyExpression& operator = ( LazyExpression const& ) = delete; - - explicit operator bool() const { - return m_transientExpression != nullptr; - } - - friend auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream&; - }; - -} // namespace Catch - -#endif // CATCH_LAZY_EXPR_HPP_INCLUDED - -#include - -namespace Catch { - - struct AssertionResultData - { - AssertionResultData() = delete; - - AssertionResultData( ResultWas::OfType _resultType, LazyExpression const& _lazyExpression ); - - std::string message; - mutable std::string reconstructedExpression; - LazyExpression lazyExpression; - ResultWas::OfType resultType; - - std::string reconstructExpression() const; - }; - - class AssertionResult { - public: - AssertionResult() = delete; - AssertionResult( AssertionInfo const& info, AssertionResultData&& data ); - - bool isOk() const; - bool succeeded() const; - ResultWas::OfType getResultType() const; - bool hasExpression() const; - bool hasMessage() const; - std::string getExpression() const; - std::string getExpressionInMacro() const; - bool hasExpandedExpression() const; - std::string getExpandedExpression() const; - StringRef getMessage() const; - SourceLineInfo getSourceInfo() const; - StringRef getTestMacroName() const; - - //protected: - AssertionInfo m_info; - AssertionResultData m_resultData; - }; - -} // end namespace Catch - -#endif // CATCH_ASSERTION_RESULT_HPP_INCLUDED - - -#ifndef CATCH_MESSAGE_INFO_HPP_INCLUDED -#define CATCH_MESSAGE_INFO_HPP_INCLUDED - - - -#ifndef CATCH_INTERFACES_CAPTURE_HPP_INCLUDED -#define CATCH_INTERFACES_CAPTURE_HPP_INCLUDED - -#include -#include - - - -#ifndef CATCH_UNIQUE_PTR_HPP_INCLUDED -#define CATCH_UNIQUE_PTR_HPP_INCLUDED - -#include -#include +#include +#include namespace Catch { @@ -1199,6 +951,45 @@ namespace Detail { #endif // CATCH_UNIQUE_PTR_HPP_INCLUDED + +#ifndef CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED +#define CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED + + + +// Adapted from donated nonius code. + +#ifndef CATCH_CLOCK_HPP_INCLUDED +#define CATCH_CLOCK_HPP_INCLUDED + +#include + +namespace Catch { + namespace Benchmark { + using IDuration = std::chrono::nanoseconds; + using FDuration = std::chrono::duration; + + template + using TimePoint = typename Clock::time_point; + + using default_clock = std::chrono::steady_clock; + } // namespace Benchmark +} // namespace Catch + +#endif // CATCH_CLOCK_HPP_INCLUDED + +namespace Catch { + + // We cannot forward declare the type with default template argument + // multiple times, so it is split out into a separate header so that + // we can prevent multiple declarations in dependees + template + struct BenchmarkStats; + +} // end namespace Catch + +#endif // CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED + namespace Catch { class AssertionResult; @@ -1215,8 +1006,6 @@ namespace Catch { class IGeneratorTracker; struct BenchmarkInfo; - template > - struct BenchmarkStats; namespace Generators { class GeneratorUntypedBase; @@ -1228,6 +1017,7 @@ namespace Catch { public: virtual ~IResultCapture(); + virtual void notifyAssertionStarted( AssertionInfo const& info ) = 0; virtual bool sectionStarted( StringRef sectionName, SourceLineInfo const& sectionLineInfo, Counts& assertions ) = 0; @@ -1268,7 +1058,7 @@ namespace Catch { AssertionReaction& reaction ) = 0; virtual void handleUnexpectedInflightException ( AssertionInfo const& info, - std::string const& message, + std::string&& message, AssertionReaction& reaction ) = 0; virtual void handleIncomplete ( AssertionInfo const& info ) = 0; @@ -1293,415 +1083,308 @@ namespace Catch { #endif // CATCH_INTERFACES_CAPTURE_HPP_INCLUDED -#include - -namespace Catch { - - struct MessageInfo { - MessageInfo( StringRef _macroName, - SourceLineInfo const& _lineInfo, - ResultWas::OfType _type ); - - StringRef macroName; - std::string message; - SourceLineInfo lineInfo; - ResultWas::OfType type; - unsigned int sequence; - - bool operator == (MessageInfo const& other) const { - return sequence == other.sequence; - } - bool operator < (MessageInfo const& other) const { - return sequence < other.sequence; - } - private: - static unsigned int globalCount; - }; -} // end namespace Catch - -#endif // CATCH_MESSAGE_INFO_HPP_INCLUDED +#ifndef CATCH_INTERFACES_CONFIG_HPP_INCLUDED +#define CATCH_INTERFACES_CONFIG_HPP_INCLUDED -// Adapted from donated nonius code. -#ifndef CATCH_ESTIMATE_HPP_INCLUDED -#define CATCH_ESTIMATE_HPP_INCLUDED +#ifndef CATCH_NONCOPYABLE_HPP_INCLUDED +#define CATCH_NONCOPYABLE_HPP_INCLUDED namespace Catch { - namespace Benchmark { - template - struct Estimate { - Duration point; - Duration lower_bound; - Duration upper_bound; - double confidence_interval; - - template - operator Estimate() const { - return { point, lower_bound, upper_bound, confidence_interval }; - } - }; - } // namespace Benchmark -} // namespace Catch - -#endif // CATCH_ESTIMATE_HPP_INCLUDED - - -// Adapted from donated nonius code. - -#ifndef CATCH_OUTLIER_CLASSIFICATION_HPP_INCLUDED -#define CATCH_OUTLIER_CLASSIFICATION_HPP_INCLUDED + namespace Detail { -namespace Catch { - namespace Benchmark { - struct OutlierClassification { - int samples_seen = 0; - int low_severe = 0; // more than 3 times IQR below Q1 - int low_mild = 0; // 1.5 to 3 times IQR below Q1 - int high_mild = 0; // 1.5 to 3 times IQR above Q3 - int high_severe = 0; // more than 3 times IQR above Q3 + //! Deriving classes become noncopyable and nonmovable + class NonCopyable { + NonCopyable( NonCopyable const& ) = delete; + NonCopyable( NonCopyable&& ) = delete; + NonCopyable& operator=( NonCopyable const& ) = delete; + NonCopyable& operator=( NonCopyable&& ) = delete; - int total() const { - return low_severe + low_mild + high_mild + high_severe; - } + protected: + NonCopyable() noexcept = default; }; - } // namespace Benchmark -} // namespace Catch -#endif // CATCH_OUTLIERS_CLASSIFICATION_HPP_INCLUDED + } // namespace Detail +} // namespace Catch +#endif // CATCH_NONCOPYABLE_HPP_INCLUDED -#include +#include +#include #include #include -#include namespace Catch { - struct ReporterDescription; - struct ListenerDescription; - struct TagInfo; - struct TestCaseInfo; - class TestCaseHandle; - class IConfig; - class IStream; - enum class ColourMode : std::uint8_t; - - struct ReporterConfig { - ReporterConfig( IConfig const* _fullConfig, - Detail::unique_ptr _stream, - ColourMode colourMode, - std::map customOptions ); - - ReporterConfig( ReporterConfig&& ) = default; - ReporterConfig& operator=( ReporterConfig&& ) = default; - ~ReporterConfig(); // = default + enum class Verbosity { + Quiet = 0, + Normal, + High + }; - Detail::unique_ptr takeStream() &&; - IConfig const* fullConfig() const; - ColourMode colourMode() const; - std::map const& customOptions() const; + struct WarnAbout { enum What { + Nothing = 0x00, + //! A test case or leaf section did not run any assertions + NoAssertions = 0x01, + //! A command line test spec matched no test cases + UnmatchedTestSpec = 0x02, + }; }; - private: - Detail::unique_ptr m_stream; - IConfig const* m_fullConfig; - ColourMode m_colourMode; - std::map m_customOptions; + enum class ShowDurations { + DefaultForReporter, + Always, + Never }; - - struct TestRunInfo { - constexpr TestRunInfo(StringRef _name) : name(_name) {} - StringRef name; + enum class TestRunOrder { + Declared, + LexicographicallySorted, + Randomized }; - - struct AssertionStats { - AssertionStats( AssertionResult const& _assertionResult, - std::vector const& _infoMessages, - Totals const& _totals ); - - AssertionStats( AssertionStats const& ) = default; - AssertionStats( AssertionStats && ) = default; - AssertionStats& operator = ( AssertionStats const& ) = delete; - AssertionStats& operator = ( AssertionStats && ) = delete; - - AssertionResult assertionResult; - std::vector infoMessages; - Totals totals; + enum class ColourMode : std::uint8_t { + //! Let Catch2 pick implementation based on platform detection + PlatformDefault, + //! Use ANSI colour code escapes + ANSI, + //! Use Win32 console colour API + Win32, + //! Don't use any colour + None }; + struct WaitForKeypress { enum When { + Never, + BeforeStart = 1, + BeforeExit = 2, + BeforeStartAndExit = BeforeStart | BeforeExit + }; }; - struct SectionStats { - SectionStats( SectionInfo&& _sectionInfo, - Counts const& _assertions, - double _durationInSeconds, - bool _missingAssertions ); + class TestSpec; + class IStream; - SectionInfo sectionInfo; - Counts assertions; - double durationInSeconds; - bool missingAssertions; - }; + class IConfig : public Detail::NonCopyable { + public: + virtual ~IConfig(); - struct TestCaseStats { - TestCaseStats( TestCaseInfo const& _testInfo, - Totals const& _totals, - std::string&& _stdOut, - std::string&& _stdErr, - bool _aborting ); + virtual bool allowThrows() const = 0; + virtual StringRef name() const = 0; + virtual bool includeSuccessfulResults() const = 0; + virtual bool shouldDebugBreak() const = 0; + virtual bool warnAboutMissingAssertions() const = 0; + virtual bool warnAboutUnmatchedTestSpecs() const = 0; + virtual bool zeroTestsCountAsSuccess() const = 0; + virtual int abortAfter() const = 0; + virtual bool showInvisibles() const = 0; + virtual ShowDurations showDurations() const = 0; + virtual double minDuration() const = 0; + virtual TestSpec const& testSpec() const = 0; + virtual bool hasTestFilters() const = 0; + virtual std::vector const& getTestsOrTags() const = 0; + virtual TestRunOrder runOrder() const = 0; + virtual uint32_t rngSeed() const = 0; + virtual unsigned int shardCount() const = 0; + virtual unsigned int shardIndex() const = 0; + virtual ColourMode defaultColourMode() const = 0; + virtual std::vector const& getSectionsToRun() const = 0; + virtual Verbosity verbosity() const = 0; - TestCaseInfo const * testInfo; - Totals totals; - std::string stdOut; - std::string stdErr; - bool aborting; + virtual bool skipBenchmarks() const = 0; + virtual bool benchmarkNoAnalysis() const = 0; + virtual unsigned int benchmarkSamples() const = 0; + virtual double benchmarkConfidenceInterval() const = 0; + virtual unsigned int benchmarkResamples() const = 0; + virtual std::chrono::milliseconds benchmarkWarmupTime() const = 0; }; +} - struct TestRunStats { - TestRunStats( TestRunInfo const& _runInfo, - Totals const& _totals, - bool _aborting ); +#endif // CATCH_INTERFACES_CONFIG_HPP_INCLUDED - TestRunInfo runInfo; - Totals totals; - bool aborting; - }; +#ifndef CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED +#define CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED - struct BenchmarkInfo { - std::string name; - double estimatedDuration; - int iterations; - unsigned int samples; - unsigned int resamples; - double clockResolution; - double clockCost; - }; - template - struct BenchmarkStats { - BenchmarkInfo info; +#include - std::vector samples; - Benchmark::Estimate mean; - Benchmark::Estimate standardDeviation; - Benchmark::OutlierClassification outliers; - double outlierVariance; +namespace Catch { - template - operator BenchmarkStats() const { - std::vector samples2; - samples2.reserve(samples.size()); - for (auto const& sample : samples) { - samples2.push_back(Duration2(sample)); - } - return { - info, - CATCH_MOVE(samples2), - mean, - standardDeviation, - outliers, - outlierVariance, - }; - } - }; + class TestCaseHandle; + struct TestCaseInfo; + class ITestCaseRegistry; + class IExceptionTranslatorRegistry; + class IExceptionTranslator; + class ReporterRegistry; + class IReporterFactory; + class ITagAliasRegistry; + class ITestInvoker; + class IMutableEnumValuesRegistry; + struct SourceLineInfo; - //! By setting up its preferences, a reporter can modify Catch2's behaviour - //! in some regards, e.g. it can request Catch2 to capture writes to - //! stdout/stderr during test execution, and pass them to the reporter. - struct ReporterPreferences { - //! Catch2 should redirect writes to stdout and pass them to the - //! reporter - bool shouldRedirectStdOut = false; - //! Catch2 should call `Reporter::assertionEnded` even for passing - //! assertions - bool shouldReportAllAssertions = false; - }; + class StartupExceptionRegistry; + class EventListenerFactory; - /** - * The common base for all reporters and event listeners - * - * Implementing classes must also implement: - * - * //! User-friendly description of the reporter/listener type - * static std::string getDescription() - * - * Generally shouldn't be derived from by users of Catch2 directly, - * instead they should derive from one of the utility bases that - * derive from this class. - */ - class IEventListener { - protected: - //! Derived classes can set up their preferences here - ReporterPreferences m_preferences; - //! The test run's config as filled in from CLI and defaults - IConfig const* m_config; + using IReporterFactoryPtr = Detail::unique_ptr; + class IRegistryHub { public: - IEventListener( IConfig const* config ): m_config( config ) {} + virtual ~IRegistryHub(); // = default - virtual ~IEventListener(); // = default; + virtual ReporterRegistry const& getReporterRegistry() const = 0; + virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0; + virtual ITagAliasRegistry const& getTagAliasRegistry() const = 0; + virtual IExceptionTranslatorRegistry const& getExceptionTranslatorRegistry() const = 0; - // Implementing class must also provide the following static methods: - // static std::string getDescription(); - ReporterPreferences const& getPreferences() const { - return m_preferences; - } + virtual StartupExceptionRegistry const& getStartupExceptionRegistry() const = 0; + }; - //! Called when no test cases match provided test spec - virtual void noMatchingTestCases( StringRef unmatchedSpec ) = 0; - //! Called for all invalid test specs from the cli - virtual void reportInvalidTestSpec( StringRef invalidArgument ) = 0; + class IMutableRegistryHub { + public: + virtual ~IMutableRegistryHub(); // = default + virtual void registerReporter( std::string const& name, IReporterFactoryPtr factory ) = 0; + virtual void registerListener( Detail::unique_ptr factory ) = 0; + virtual void registerTest(Detail::unique_ptr&& testInfo, Detail::unique_ptr&& invoker) = 0; + virtual void registerTranslator( Detail::unique_ptr&& translator ) = 0; + virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0; + virtual void registerStartupException() noexcept = 0; + virtual IMutableEnumValuesRegistry& getMutableEnumValuesRegistry() = 0; + }; - /** - * Called once in a testing run before tests are started - * - * Not called if tests won't be run (e.g. only listing will happen) - */ - virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; + IRegistryHub const& getRegistryHub(); + IMutableRegistryHub& getMutableRegistryHub(); + void cleanUp(); + std::string translateActiveException(); - //! Called _once_ for each TEST_CASE, no matter how many times it is entered - virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0; - //! Called _every time_ a TEST_CASE is entered, including repeats (due to sections) - virtual void testCasePartialStarting( TestCaseInfo const& testInfo, uint64_t partNumber ) = 0; - //! Called when a `SECTION` is being entered. Not called for skipped sections - virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0; +} - //! Called when user-code is being probed before the actual benchmark runs - virtual void benchmarkPreparing( StringRef benchmarkName ) = 0; - //! Called after probe but before the user-code is being benchmarked - virtual void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) = 0; - //! Called with the benchmark results if benchmark successfully finishes - virtual void benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) = 0; - //! Called if running the benchmarks fails for any reason - virtual void benchmarkFailed( StringRef benchmarkName ) = 0; +#endif // CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED - //! Called before assertion success/failure is evaluated - virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0; - //! Called after assertion was fully evaluated - virtual void assertionEnded( AssertionStats const& assertionStats ) = 0; +#ifndef CATCH_BENCHMARK_STATS_HPP_INCLUDED +#define CATCH_BENCHMARK_STATS_HPP_INCLUDED - //! Called after a `SECTION` has finished running - virtual void sectionEnded( SectionStats const& sectionStats ) = 0; - //! Called _every time_ a TEST_CASE is entered, including repeats (due to sections) - virtual void testCasePartialEnded(TestCaseStats const& testCaseStats, uint64_t partNumber ) = 0; - //! Called _once_ for each TEST_CASE, no matter how many times it is entered - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0; - /** - * Called once after all tests in a testing run are finished - * - * Not called if tests weren't run (e.g. only listings happened) - */ - virtual void testRunEnded( TestRunStats const& testRunStats ) = 0; - /** - * Called with test cases that are skipped due to the test run aborting. - * NOT called for test cases that are explicitly skipped using the `SKIP` macro. - * - * Deprecated - will be removed in the next major release. - */ - virtual void skipTest( TestCaseInfo const& testInfo ) = 0; - //! Called if a fatal error (signal/structured exception) occured - virtual void fatalErrorEncountered( StringRef error ) = 0; +// Adapted from donated nonius code. - //! Writes out information about provided reporters using reporter-specific format - virtual void listReporters(std::vector const& descriptions) = 0; - //! Writes out the provided listeners descriptions using reporter-specific format - virtual void listListeners(std::vector const& descriptions) = 0; - //! Writes out information about provided tests using reporter-specific format - virtual void listTests(std::vector const& tests) = 0; - //! Writes out information about the provided tags using reporter-specific format - virtual void listTags(std::vector const& tags) = 0; - }; - using IEventListenerPtr = Detail::unique_ptr; +#ifndef CATCH_ESTIMATE_HPP_INCLUDED +#define CATCH_ESTIMATE_HPP_INCLUDED -} // end namespace Catch +namespace Catch { + namespace Benchmark { + template + struct Estimate { + Type point; + Type lower_bound; + Type upper_bound; + double confidence_interval; + }; + } // namespace Benchmark +} // namespace Catch -#endif // CATCH_INTERFACES_REPORTER_HPP_INCLUDED +#endif // CATCH_ESTIMATE_HPP_INCLUDED -#ifndef CATCH_UNIQUE_NAME_HPP_INCLUDED -#define CATCH_UNIQUE_NAME_HPP_INCLUDED +// Adapted from donated nonius code. +#ifndef CATCH_OUTLIER_CLASSIFICATION_HPP_INCLUDED +#define CATCH_OUTLIER_CLASSIFICATION_HPP_INCLUDED +namespace Catch { + namespace Benchmark { + struct OutlierClassification { + int samples_seen = 0; + int low_severe = 0; // more than 3 times IQR below Q1 + int low_mild = 0; // 1.5 to 3 times IQR below Q1 + int high_mild = 0; // 1.5 to 3 times IQR above Q3 + int high_severe = 0; // more than 3 times IQR above Q3 + int total() const { + return low_severe + low_mild + high_mild + high_severe; + } + }; + } // namespace Benchmark +} // namespace Catch -/** \file - * Wrapper for the CONFIG configuration option - * - * When generating internal unique names, there are two options. Either - * we mix in the current line number, or mix in an incrementing number. - * We prefer the latter, using `__COUNTER__`, but users might want to - * use the former. - */ +#endif // CATCH_OUTLIERS_CLASSIFICATION_HPP_INCLUDED +// The fwd decl & default specialization needs to be seen by VS2017 before +// BenchmarkStats itself, or VS2017 will report compilation error. -#ifndef CATCH_CONFIG_COUNTER_HPP_INCLUDED -#define CATCH_CONFIG_COUNTER_HPP_INCLUDED +#include +#include -#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) - #define CATCH_INTERNAL_CONFIG_COUNTER -#endif +namespace Catch { -#if defined( CATCH_INTERNAL_CONFIG_COUNTER ) && \ - !defined( CATCH_CONFIG_NO_COUNTER ) && \ - !defined( CATCH_CONFIG_COUNTER ) -# define CATCH_CONFIG_COUNTER -#endif + struct BenchmarkInfo { + std::string name; + double estimatedDuration; + int iterations; + unsigned int samples; + unsigned int resamples; + double clockResolution; + double clockCost; + }; + // We need to keep template parameter for backwards compatibility, + // but we also do not want to use the template paraneter. + template + struct BenchmarkStats { + BenchmarkInfo info; -#endif // CATCH_CONFIG_COUNTER_HPP_INCLUDED -#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line -#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) -#ifdef CATCH_CONFIG_COUNTER -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) -#else -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) -#endif + std::vector samples; + Benchmark::Estimate mean; + Benchmark::Estimate standardDeviation; + Benchmark::OutlierClassification outliers; + double outlierVariance; + }; -#endif // CATCH_UNIQUE_NAME_HPP_INCLUDED + +} // end namespace Catch + +#endif // CATCH_BENCHMARK_STATS_HPP_INCLUDED // Adapted from donated nonius code. -#ifndef CATCH_CHRONOMETER_HPP_INCLUDED -#define CATCH_CHRONOMETER_HPP_INCLUDED +#ifndef CATCH_ENVIRONMENT_HPP_INCLUDED +#define CATCH_ENVIRONMENT_HPP_INCLUDED +namespace Catch { + namespace Benchmark { + struct EnvironmentEstimate { + FDuration mean; + OutlierClassification outliers; + }; + struct Environment { + EnvironmentEstimate clock_resolution; + EnvironmentEstimate clock_cost; + }; + } // namespace Benchmark +} // namespace Catch + +#endif // CATCH_ENVIRONMENT_HPP_INCLUDED + // Adapted from donated nonius code. -#ifndef CATCH_CLOCK_HPP_INCLUDED -#define CATCH_CLOCK_HPP_INCLUDED +#ifndef CATCH_EXECUTION_PLAN_HPP_INCLUDED +#define CATCH_EXECUTION_PLAN_HPP_INCLUDED -#include -#include -namespace Catch { - namespace Benchmark { - template - using ClockDuration = typename Clock::duration; - template - using FloatDuration = std::chrono::duration; - template - using TimePoint = typename Clock::time_point; +// Adapted from donated nonius code. - using default_clock = std::chrono::steady_clock; +#ifndef CATCH_BENCHMARK_FUNCTION_HPP_INCLUDED +#define CATCH_BENCHMARK_FUNCTION_HPP_INCLUDED - template - struct now { - TimePoint operator()() const { - return Clock::now(); - } - }; - using fp_seconds = std::chrono::duration>; - } // namespace Benchmark -} // namespace Catch -#endif // CATCH_CLOCK_HPP_INCLUDED +// Adapted from donated nonius code. + +#ifndef CATCH_CHRONOMETER_HPP_INCLUDED +#define CATCH_CHRONOMETER_HPP_INCLUDED + // Adapted from donated nonius code. @@ -1709,7 +1392,7 @@ namespace Catch { #ifndef CATCH_OPTIMIZER_HPP_INCLUDED #define CATCH_OPTIMIZER_HPP_INCLUDED -#if defined(_MSC_VER) +#if defined(_MSC_VER) || defined(__IAR_SYSTEMS_ICC__) # include // atomic_thread_fence #endif @@ -1730,16 +1413,23 @@ namespace Catch { namespace Detail { inline void optimizer_barrier() { keep_memory(); } } // namespace Detail -#elif defined(_MSC_VER) +#elif defined(_MSC_VER) || defined(__IAR_SYSTEMS_ICC__) +#if defined(_MSVC_VER) #pragma optimize("", off) +#elif defined(__IAR_SYSTEMS_ICC__) +// For IAR the pragma only affects the following function +#pragma optimize=disable +#endif template inline void keep_memory(T* p) { // thanks @milleniumbug *reinterpret_cast(p) = *reinterpret_cast(p); } // TODO equivalent keep_memory() +#if defined(_MSVC_VER) #pragma optimize("", on) +#endif namespace Detail { inline void optimizer_barrier() { @@ -1751,52 +1441,22 @@ namespace Catch { template inline void deoptimize_value(T&& x) { - keep_memory(&x); - } - - template - inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> std::enable_if_t::value> { - deoptimize_value(CATCH_FORWARD(fn) (CATCH_FORWARD(args)...)); - } - - template - inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> std::enable_if_t::value> { - CATCH_FORWARD(fn) (CATCH_FORWARD(args)...); - } - } // namespace Benchmark -} // namespace Catch - -#endif // CATCH_OPTIMIZER_HPP_INCLUDED - - -// Adapted from donated nonius code. - -#ifndef CATCH_COMPLETE_INVOKE_HPP_INCLUDED -#define CATCH_COMPLETE_INVOKE_HPP_INCLUDED - - - -#ifndef CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED -#define CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED - -namespace Catch { - - //! Used to signal that an assertion macro failed - struct TestFailureException{}; - - /** - * Outlines throwing of `TestFailureException` into a single TU - * - * Also handles `CATCH_CONFIG_DISABLE_EXCEPTIONS` for callers. - */ - [[noreturn]] void throw_test_failure_exception(); + keep_memory(&x); + } - //! Used to signal that the remainder of a test should be skipped - struct TestSkipException{}; + template + inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> std::enable_if_t::value> { + deoptimize_value(CATCH_FORWARD(fn) (CATCH_FORWARD(args)...)); + } + template + inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> std::enable_if_t::value> { + CATCH_FORWARD((fn)) (CATCH_FORWARD(args)...); + } + } // namespace Benchmark } // namespace Catch -#endif // CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED +#endif // CATCH_OPTIMIZER_HPP_INCLUDED #ifndef CATCH_META_HPP_INCLUDED @@ -1840,112 +1500,6 @@ namespace mpl_{ #endif // CATCH_META_HPP_INCLUDED - -#ifndef CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED -#define CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED - - -#include - -namespace Catch { - - class TestCaseHandle; - struct TestCaseInfo; - class ITestCaseRegistry; - class IExceptionTranslatorRegistry; - class IExceptionTranslator; - class IReporterRegistry; - class IReporterFactory; - class ITagAliasRegistry; - class ITestInvoker; - class IMutableEnumValuesRegistry; - struct SourceLineInfo; - - class StartupExceptionRegistry; - class EventListenerFactory; - - using IReporterFactoryPtr = Detail::unique_ptr; - - class IRegistryHub { - public: - virtual ~IRegistryHub(); // = default - - virtual IReporterRegistry const& getReporterRegistry() const = 0; - virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0; - virtual ITagAliasRegistry const& getTagAliasRegistry() const = 0; - virtual IExceptionTranslatorRegistry const& getExceptionTranslatorRegistry() const = 0; - - - virtual StartupExceptionRegistry const& getStartupExceptionRegistry() const = 0; - }; - - class IMutableRegistryHub { - public: - virtual ~IMutableRegistryHub(); // = default - virtual void registerReporter( std::string const& name, IReporterFactoryPtr factory ) = 0; - virtual void registerListener( Detail::unique_ptr factory ) = 0; - virtual void registerTest(Detail::unique_ptr&& testInfo, Detail::unique_ptr&& invoker) = 0; - virtual void registerTranslator( Detail::unique_ptr&& translator ) = 0; - virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0; - virtual void registerStartupException() noexcept = 0; - virtual IMutableEnumValuesRegistry& getMutableEnumValuesRegistry() = 0; - }; - - IRegistryHub const& getRegistryHub(); - IMutableRegistryHub& getMutableRegistryHub(); - void cleanUp(); - std::string translateActiveException(); - -} - -#endif // CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED - -#include - -namespace Catch { - namespace Benchmark { - namespace Detail { - template - struct CompleteType { using type = T; }; - template <> - struct CompleteType { struct type {}; }; - - template - using CompleteType_t = typename CompleteType::type; - - template - struct CompleteInvoker { - template - static Result invoke(Fun&& fun, Args&&... args) { - return CATCH_FORWARD(fun)(CATCH_FORWARD(args)...); - } - }; - template <> - struct CompleteInvoker { - template - static CompleteType_t invoke(Fun&& fun, Args&&... args) { - CATCH_FORWARD(fun)(CATCH_FORWARD(args)...); - return {}; - } - }; - - // invoke and not return void :( - template - CompleteType_t> complete_invoke(Fun&& fun, Args&&... args) { - return CompleteInvoker>::invoke(CATCH_FORWARD(fun), CATCH_FORWARD(args)...); - } - - } // namespace Detail - - template - Detail::CompleteType_t> user_code(Fun&& fun) { - return Detail::complete_invoke(CATCH_FORWARD(fun)); - } - } // namespace Benchmark -} // namespace Catch - -#endif // CATCH_COMPLETE_INVOKE_HPP_INCLUDED - namespace Catch { namespace Benchmark { namespace Detail { @@ -1963,7 +1517,10 @@ namespace Catch { void start() override { started = Clock::now(); } void finish() override { finished = Clock::now(); } - ClockDuration elapsed() const { return finished - started; } + IDuration elapsed() const { + return std::chrono::duration_cast( + finished - started ); + } TimePoint started; TimePoint finished; @@ -2004,50 +1561,6 @@ namespace Catch { #endif // CATCH_CHRONOMETER_HPP_INCLUDED - -// Adapted from donated nonius code. - -#ifndef CATCH_ENVIRONMENT_HPP_INCLUDED -#define CATCH_ENVIRONMENT_HPP_INCLUDED - - -namespace Catch { - namespace Benchmark { - template - struct EnvironmentEstimate { - Duration mean; - OutlierClassification outliers; - - template - operator EnvironmentEstimate() const { - return { mean, outliers }; - } - }; - template - struct Environment { - using clock_type = Clock; - EnvironmentEstimate> clock_resolution; - EnvironmentEstimate> clock_cost; - }; - } // namespace Benchmark -} // namespace Catch - -#endif // CATCH_ENVIRONMENT_HPP_INCLUDED - - -// Adapted from donated nonius code. - -#ifndef CATCH_EXECUTION_PLAN_HPP_INCLUDED -#define CATCH_EXECUTION_PLAN_HPP_INCLUDED - - - -// Adapted from donated nonius code. - -#ifndef CATCH_BENCHMARK_FUNCTION_HPP_INCLUDED -#define CATCH_BENCHMARK_FUNCTION_HPP_INCLUDED - - #include namespace Catch { @@ -2184,6 +1697,57 @@ namespace Catch { +// Adapted from donated nonius code. + +#ifndef CATCH_COMPLETE_INVOKE_HPP_INCLUDED +#define CATCH_COMPLETE_INVOKE_HPP_INCLUDED + + +namespace Catch { + namespace Benchmark { + namespace Detail { + template + struct CompleteType { using type = T; }; + template <> + struct CompleteType { struct type {}; }; + + template + using CompleteType_t = typename CompleteType::type; + + template + struct CompleteInvoker { + template + static Result invoke(Fun&& fun, Args&&... args) { + return CATCH_FORWARD(fun)(CATCH_FORWARD(args)...); + } + }; + template <> + struct CompleteInvoker { + template + static CompleteType_t invoke(Fun&& fun, Args&&... args) { + CATCH_FORWARD(fun)(CATCH_FORWARD(args)...); + return {}; + } + }; + + // invoke and not return void :( + template + CompleteType_t> complete_invoke(Fun&& fun, Args&&... args) { + return CompleteInvoker>::invoke(CATCH_FORWARD(fun), CATCH_FORWARD(args)...); + } + + } // namespace Detail + + template + Detail::CompleteType_t> user_code(Fun&& fun) { + return Detail::complete_invoke(CATCH_FORWARD(fun)); + } + } // namespace Benchmark +} // namespace Catch + +#endif // CATCH_COMPLETE_INVOKE_HPP_INCLUDED + + // Adapted from donated nonius code. #ifndef CATCH_TIMING_HPP_INCLUDED @@ -2194,14 +1758,14 @@ namespace Catch { namespace Catch { namespace Benchmark { - template + template struct Timing { - Duration elapsed; + IDuration elapsed; Result result; int iterations; }; - template - using TimingOf = Timing, Detail::CompleteType_t>>; + template + using TimingOf = Timing>>; } // namespace Benchmark } // namespace Catch @@ -2211,7 +1775,7 @@ namespace Catch { namespace Benchmark { namespace Detail { template - TimingOf measure(Fun&& fun, Args&&... args) { + TimingOf measure(Fun&& fun, Args&&... args) { auto start = Clock::now(); auto&& r = Detail::complete_invoke(fun, CATCH_FORWARD(args)...); auto end = Clock::now(); @@ -2230,11 +1794,11 @@ namespace Catch { namespace Benchmark { namespace Detail { template - TimingOf measure_one(Fun&& fun, int iters, std::false_type) { + TimingOf measure_one(Fun&& fun, int iters, std::false_type) { return Detail::measure(fun, iters); } template - TimingOf measure_one(Fun&& fun, int iters, std::true_type) { + TimingOf measure_one(Fun&& fun, int iters, std::true_type) { Detail::ChronometerModel meter; auto&& result = Detail::complete_invoke(fun, Chronometer(meter, iters)); @@ -2249,8 +1813,8 @@ namespace Catch { void throw_optimized_away_error(); template - TimingOf> - run_for_at_least(ClockDuration how_long, + TimingOf> + run_for_at_least(IDuration how_long, const int initial_iterations, Fun&& fun) { auto iters = initial_iterations; @@ -2270,38 +1834,38 @@ namespace Catch { #endif // CATCH_RUN_FOR_AT_LEAST_HPP_INCLUDED -#include -#include +#include namespace Catch { namespace Benchmark { - template struct ExecutionPlan { int iterations_per_sample; - Duration estimated_duration; + FDuration estimated_duration; Detail::BenchmarkFunction benchmark; - Duration warmup_time; + FDuration warmup_time; int warmup_iterations; - template - operator ExecutionPlan() const { - return { iterations_per_sample, estimated_duration, benchmark, warmup_time, warmup_iterations }; - } - template - std::vector> run(const IConfig &cfg, Environment> env) const { + std::vector run(const IConfig &cfg, Environment env) const { // warmup a bit - Detail::run_for_at_least(std::chrono::duration_cast>(warmup_time), warmup_iterations, Detail::repeat(now{})); + Detail::run_for_at_least( + std::chrono::duration_cast( warmup_time ), + warmup_iterations, + Detail::repeat( []() { return Clock::now(); } ) + ); - std::vector> times; - times.reserve(cfg.benchmarkSamples()); - std::generate_n(std::back_inserter(times), cfg.benchmarkSamples(), [this, env] { + std::vector times; + const auto num_samples = cfg.benchmarkSamples(); + times.reserve( num_samples ); + for ( size_t i = 0; i < num_samples; ++i ) { Detail::ChronometerModel model; - this->benchmark(Chronometer(model, iterations_per_sample)); + this->benchmark( Chronometer( model, iterations_per_sample ) ); auto sample_time = model.elapsed() - env.clock_cost.mean; - if (sample_time < FloatDuration::zero()) sample_time = FloatDuration::zero(); - return sample_time / iterations_per_sample; - }); + if ( sample_time < FDuration::zero() ) { + sample_time = FDuration::zero(); + } + times.push_back(sample_time / iterations_per_sample); + } return times; } }; @@ -2324,122 +1888,35 @@ namespace Catch { #define CATCH_STATS_HPP_INCLUDED -#include #include -#include -#include -#include namespace Catch { namespace Benchmark { namespace Detail { using sample = std::vector; - // Used when we know we want == comparison of two doubles - // to centralize warning suppression - bool directCompare( double lhs, double rhs ); - - double weighted_average_quantile(int k, int q, std::vector::iterator first, std::vector::iterator last); - - template - OutlierClassification classify_outliers(Iterator first, Iterator last) { - std::vector copy(first, last); - - auto q1 = weighted_average_quantile(1, 4, copy.begin(), copy.end()); - auto q3 = weighted_average_quantile(3, 4, copy.begin(), copy.end()); - auto iqr = q3 - q1; - auto los = q1 - (iqr * 3.); - auto lom = q1 - (iqr * 1.5); - auto him = q3 + (iqr * 1.5); - auto his = q3 + (iqr * 3.); - - OutlierClassification o; - for (; first != last; ++first) { - auto&& t = *first; - if (t < los) ++o.low_severe; - else if (t < lom) ++o.low_mild; - else if (t > his) ++o.high_severe; - else if (t > him) ++o.high_mild; - ++o.samples_seen; - } - return o; - } - - template - double mean(Iterator first, Iterator last) { - auto count = last - first; - double sum = std::accumulate(first, last, 0.); - return sum / static_cast(count); - } + double weighted_average_quantile( int k, + int q, + double* first, + double* last ); - template - sample jackknife(Estimator&& estimator, Iterator first, Iterator last) { - auto n = static_cast(last - first); - auto second = first; - ++second; - sample results; - results.reserve(n); + OutlierClassification + classify_outliers( double const* first, double const* last ); - for (auto it = first; it != last; ++it) { - std::iter_swap(it, first); - results.push_back(estimator(second, last)); - } - - return results; - } + double mean( double const* first, double const* last ); - inline double normal_cdf(double x) { - return std::erfc(-x / std::sqrt(2.0)) / 2.0; - } + double normal_cdf( double x ); double erfc_inv(double x); double normal_quantile(double p); - template - Estimate bootstrap(double confidence_level, Iterator first, Iterator last, sample const& resample, Estimator&& estimator) { - auto n_samples = last - first; - - double point = estimator(first, last); - // Degenerate case with a single sample - if (n_samples == 1) return { point, point, point, confidence_level }; - - sample jack = jackknife(estimator, first, last); - double jack_mean = mean(jack.begin(), jack.end()); - double sum_squares, sum_cubes; - std::tie(sum_squares, sum_cubes) = std::accumulate(jack.begin(), jack.end(), std::make_pair(0., 0.), [jack_mean](std::pair sqcb, double x) -> std::pair { - auto d = jack_mean - x; - auto d2 = d * d; - auto d3 = d2 * d; - return { sqcb.first + d2, sqcb.second + d3 }; - }); - - double accel = sum_cubes / (6 * std::pow(sum_squares, 1.5)); - long n = static_cast(resample.size()); - double prob_n = std::count_if(resample.begin(), resample.end(), [point](double x) { return x < point; }) / static_cast(n); - // degenerate case with uniform samples - if ( directCompare( prob_n, 0. ) ) { - return { point, point, point, confidence_level }; - } - - double bias = normal_quantile(prob_n); - double z1 = normal_quantile((1. - confidence_level) / 2.); - - auto cumn = [n]( double x ) -> long { - return std::lround( normal_cdf( x ) * static_cast(n) ); - }; - auto a = [bias, accel](double b) { return bias + b / (1. - accel * b); }; - double b1 = bias + z1; - double b2 = bias - z1; - double a1 = a(b1); - double a2 = a(b2); - auto lo = static_cast((std::max)(cumn(a1), 0l)); - auto hi = static_cast((std::min)(cumn(a2), n - 1)); - - return { point, resample[lo], resample[hi], confidence_level }; - } - - double outlier_variance(Estimate mean, Estimate stddev, int n); + Estimate + bootstrap( double confidence_level, + double* first, + double* last, + sample const& resample, + double ( *estimator )( double const*, double const* ) ); struct bootstrap_analysis { Estimate mean; @@ -2447,7 +1924,10 @@ namespace Catch { double outlier_variance; }; - bootstrap_analysis analyse_samples(double confidence_level, unsigned int n_resamples, std::vector::iterator first, std::vector::iterator last); + bootstrap_analysis analyse_samples(double confidence_level, + unsigned int n_resamples, + double* first, + double* last); } // namespace Detail } // namespace Benchmark } // namespace Catch @@ -2455,7 +1935,6 @@ namespace Catch { #endif // CATCH_STATS_HPP_INCLUDED #include -#include #include #include @@ -2466,46 +1945,49 @@ namespace Catch { std::vector resolution(int k) { std::vector> times; times.reserve(static_cast(k + 1)); - std::generate_n(std::back_inserter(times), k + 1, now{}); + for ( int i = 0; i < k + 1; ++i ) { + times.push_back( Clock::now() ); + } std::vector deltas; deltas.reserve(static_cast(k)); - std::transform(std::next(times.begin()), times.end(), times.begin(), - std::back_inserter(deltas), - [](TimePoint a, TimePoint b) { return static_cast((a - b).count()); }); + for ( size_t idx = 1; idx < times.size(); ++idx ) { + deltas.push_back( static_cast( + ( times[idx] - times[idx - 1] ).count() ) ); + } return deltas; } - const auto warmup_iterations = 10000; - const auto warmup_time = std::chrono::milliseconds(100); - const auto minimum_ticks = 1000; - const auto warmup_seed = 10000; - const auto clock_resolution_estimation_time = std::chrono::milliseconds(500); - const auto clock_cost_estimation_time_limit = std::chrono::seconds(1); - const auto clock_cost_estimation_tick_limit = 100000; - const auto clock_cost_estimation_time = std::chrono::milliseconds(10); - const auto clock_cost_estimation_iterations = 10000; + constexpr auto warmup_iterations = 10000; + constexpr auto warmup_time = std::chrono::milliseconds(100); + constexpr auto minimum_ticks = 1000; + constexpr auto warmup_seed = 10000; + constexpr auto clock_resolution_estimation_time = std::chrono::milliseconds(500); + constexpr auto clock_cost_estimation_time_limit = std::chrono::seconds(1); + constexpr auto clock_cost_estimation_tick_limit = 100000; + constexpr auto clock_cost_estimation_time = std::chrono::milliseconds(10); + constexpr auto clock_cost_estimation_iterations = 10000; template int warmup() { - return run_for_at_least(std::chrono::duration_cast>(warmup_time), warmup_seed, &resolution) + return run_for_at_least(warmup_time, warmup_seed, &resolution) .iterations; } template - EnvironmentEstimate> estimate_clock_resolution(int iterations) { - auto r = run_for_at_least(std::chrono::duration_cast>(clock_resolution_estimation_time), iterations, &resolution) + EnvironmentEstimate estimate_clock_resolution(int iterations) { + auto r = run_for_at_least(clock_resolution_estimation_time, iterations, &resolution) .result; return { - FloatDuration(mean(r.begin(), r.end())), - classify_outliers(r.begin(), r.end()), + FDuration(mean(r.data(), r.data() + r.size())), + classify_outliers(r.data(), r.data() + r.size()), }; } template - EnvironmentEstimate> estimate_clock_cost(FloatDuration resolution) { + EnvironmentEstimate estimate_clock_cost(FDuration resolution) { auto time_limit = (std::min)( resolution * clock_cost_estimation_tick_limit, - FloatDuration(clock_cost_estimation_time_limit)); + FDuration(clock_cost_estimation_time_limit)); auto time_clock = [](int k) { return Detail::measure([k] { for (int i = 0; i < k; ++i) { @@ -2516,26 +1998,28 @@ namespace Catch { }; time_clock(1); int iters = clock_cost_estimation_iterations; - auto&& r = run_for_at_least(std::chrono::duration_cast>(clock_cost_estimation_time), iters, time_clock); + auto&& r = run_for_at_least(clock_cost_estimation_time, iters, time_clock); std::vector times; int nsamples = static_cast(std::ceil(time_limit / r.elapsed)); times.reserve(static_cast(nsamples)); - std::generate_n(std::back_inserter(times), nsamples, [time_clock, &r] { - return static_cast((time_clock(r.iterations) / r.iterations).count()); - }); + for ( int s = 0; s < nsamples; ++s ) { + times.push_back( static_cast( + ( time_clock( r.iterations ) / r.iterations ) + .count() ) ); + } return { - FloatDuration(mean(times.begin(), times.end())), - classify_outliers(times.begin(), times.end()), + FDuration(mean(times.data(), times.data() + times.size())), + classify_outliers(times.data(), times.data() + times.size()), }; } template - Environment> measure_environment() { + Environment measure_environment() { #if defined(__clang__) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wexit-time-destructors" #endif - static Catch::Detail::unique_ptr>> env; + static Catch::Detail::unique_ptr env; #if defined(__clang__) # pragma clang diagnostic pop #endif @@ -2547,7 +2031,7 @@ namespace Catch { auto resolution = Detail::estimate_clock_resolution(iters); auto cost = Detail::estimate_clock_cost(resolution.mean); - env = Catch::Detail::make_unique>>( Environment>{resolution, cost} ); + env = Catch::Detail::make_unique( Environment{resolution, cost} ); return *env; } } // namespace Detail @@ -2570,95 +2054,29 @@ namespace Catch { #define CATCH_SAMPLE_ANALYSIS_HPP_INCLUDED -#include #include -#include namespace Catch { namespace Benchmark { - template struct SampleAnalysis { - std::vector samples; - Estimate mean; - Estimate standard_deviation; + std::vector samples; + Estimate mean; + Estimate standard_deviation; OutlierClassification outliers; double outlier_variance; - - template - operator SampleAnalysis() const { - std::vector samples2; - samples2.reserve(samples.size()); - std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](Duration d) { return Duration2(d); }); - return { - CATCH_MOVE(samples2), - mean, - standard_deviation, - outliers, - outlier_variance, - }; - } }; } // namespace Benchmark } // namespace Catch #endif // CATCH_SAMPLE_ANALYSIS_HPP_INCLUDED -#include -#include -#include namespace Catch { + class IConfig; + namespace Benchmark { namespace Detail { - template - SampleAnalysis analyse(const IConfig &cfg, Environment, Iterator first, Iterator last) { - if (!cfg.benchmarkNoAnalysis()) { - std::vector samples; - samples.reserve(static_cast(last - first)); - std::transform(first, last, std::back_inserter(samples), [](Duration d) { return d.count(); }); - - auto analysis = Catch::Benchmark::Detail::analyse_samples(cfg.benchmarkConfidenceInterval(), cfg.benchmarkResamples(), samples.begin(), samples.end()); - auto outliers = Catch::Benchmark::Detail::classify_outliers(samples.begin(), samples.end()); - - auto wrap_estimate = [](Estimate e) { - return Estimate { - Duration(e.point), - Duration(e.lower_bound), - Duration(e.upper_bound), - e.confidence_interval, - }; - }; - std::vector samples2; - samples2.reserve(samples.size()); - std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](double d) { return Duration(d); }); - return { - CATCH_MOVE(samples2), - wrap_estimate(analysis.mean), - wrap_estimate(analysis.standard_deviation), - outliers, - analysis.outlier_variance, - }; - } else { - std::vector samples; - samples.reserve(static_cast(last - first)); - - Duration mean = Duration(0); - int i = 0; - for (auto it = first; it < last; ++it, ++i) { - samples.push_back(Duration(*it)); - mean += Duration(*it); - } - mean /= i; - - return { - CATCH_MOVE(samples), - Estimate{mean, mean, mean, 0.0}, - Estimate{Duration(0), Duration(0), Duration(0), 0.0}, - OutlierClassification{}, - 0.0 - }; - } - } + SampleAnalysis analyse(const IConfig &cfg, FDuration* first, FDuration* last); } // namespace Detail } // namespace Benchmark } // namespace Catch @@ -2666,9 +2084,9 @@ namespace Catch { #endif // CATCH_ANALYSE_HPP_INCLUDED #include -#include +#include +#include #include -#include #include namespace Catch { @@ -2682,16 +2100,18 @@ namespace Catch { : fun(CATCH_MOVE(func)), name(CATCH_MOVE(benchmarkName)) {} template - ExecutionPlan> prepare(const IConfig &cfg, Environment> env) const { + ExecutionPlan prepare(const IConfig &cfg, Environment env) const { auto min_time = env.clock_resolution.mean * Detail::minimum_ticks; auto run_time = std::max(min_time, std::chrono::duration_cast(cfg.benchmarkWarmupTime())); - auto&& test = Detail::run_for_at_least(std::chrono::duration_cast>(run_time), 1, fun); + auto&& test = Detail::run_for_at_least(std::chrono::duration_cast(run_time), 1, fun); int new_iters = static_cast(std::ceil(min_time * test.iterations / test.elapsed)); - return { new_iters, test.elapsed / test.iterations * new_iters * cfg.benchmarkSamples(), fun, std::chrono::duration_cast>(cfg.benchmarkWarmupTime()), Detail::warmup_iterations }; + return { new_iters, test.elapsed / test.iterations * new_iters * cfg.benchmarkSamples(), fun, std::chrono::duration_cast(cfg.benchmarkWarmupTime()), Detail::warmup_iterations }; } template void run() { + static_assert( Clock::is_steady, + "Benchmarking clock should be steady" ); auto const* cfg = getCurrentContext().getConfig(); auto env = Detail::measure_environment(); @@ -2718,10 +2138,10 @@ namespace Catch { return plan.template run(*cfg, env); }); - auto analysis = Detail::analyse(*cfg, env, samples.begin(), samples.end()); - BenchmarkStats> stats{ CATCH_MOVE(info), CATCH_MOVE(analysis.samples), analysis.mean, analysis.standard_deviation, analysis.outliers, analysis.outlier_variance }; + auto analysis = Detail::analyse(*cfg, samples.data(), samples.data() + samples.size()); + BenchmarkStats<> stats{ CATCH_MOVE(info), CATCH_MOVE(analysis.samples), analysis.mean, analysis.standard_deviation, analysis.outliers, analysis.outlier_variance }; getResultCapture().benchmarkEnded(stats); - } CATCH_CATCH_ANON (TestFailureException) { + } CATCH_CATCH_ANON (TestFailureException const&) { getResultCapture().benchmarkFailed("Benchmark failed due to failed assertion"_sr); } CATCH_CATCH_ALL{ getResultCapture().benchmarkFailed(translateActiveException()); @@ -2889,6 +2309,7 @@ namespace Catch { #ifndef CATCH_CONFIG_WCHAR_HPP_INCLUDED #define CATCH_CONFIG_WCHAR_HPP_INCLUDED + // We assume that WCHAR should be enabled by default, and only disabled // for a shortlist (so far only DJGPP) of compilers. @@ -3112,7 +2533,6 @@ namespace Catch { } // namespace Detail - // If we decide for C++14, change these to enable_if_ts template struct StringMaker { template @@ -3395,6 +2815,12 @@ namespace Catch { } } }; + template <> + struct StringMaker { + static std::string convert(const std::nullopt_t&) { + return "{ }"; + } + }; } #endif // CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER @@ -3781,6 +3207,143 @@ struct StringMaker { #endif // CATCH_APPROX_HPP_INCLUDED +#ifndef CATCH_ASSERTION_INFO_HPP_INCLUDED +#define CATCH_ASSERTION_INFO_HPP_INCLUDED + + + +#ifndef CATCH_SOURCE_LINE_INFO_HPP_INCLUDED +#define CATCH_SOURCE_LINE_INFO_HPP_INCLUDED + +#include +#include + +namespace Catch { + + struct SourceLineInfo { + + SourceLineInfo() = delete; + constexpr SourceLineInfo( char const* _file, std::size_t _line ) noexcept: + file( _file ), + line( _line ) + {} + + bool operator == ( SourceLineInfo const& other ) const noexcept; + bool operator < ( SourceLineInfo const& other ) const noexcept; + + char const* file; + std::size_t line; + + friend std::ostream& operator << (std::ostream& os, SourceLineInfo const& info); + }; +} + +#define CATCH_INTERNAL_LINEINFO \ + ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) + +#endif // CATCH_SOURCE_LINE_INFO_HPP_INCLUDED + +namespace Catch { + + struct AssertionInfo { + // AssertionInfo() = delete; + + StringRef macroName; + SourceLineInfo lineInfo; + StringRef capturedExpression; + ResultDisposition::Flags resultDisposition; + }; + +} // end namespace Catch + +#endif // CATCH_ASSERTION_INFO_HPP_INCLUDED + + +#ifndef CATCH_ASSERTION_RESULT_HPP_INCLUDED +#define CATCH_ASSERTION_RESULT_HPP_INCLUDED + + + +#ifndef CATCH_LAZY_EXPR_HPP_INCLUDED +#define CATCH_LAZY_EXPR_HPP_INCLUDED + +#include + +namespace Catch { + + class ITransientExpression; + + class LazyExpression { + friend class AssertionHandler; + friend struct AssertionStats; + friend class RunContext; + + ITransientExpression const* m_transientExpression = nullptr; + bool m_isNegated; + public: + LazyExpression( bool isNegated ): + m_isNegated(isNegated) + {} + LazyExpression(LazyExpression const& other) = default; + LazyExpression& operator = ( LazyExpression const& ) = delete; + + explicit operator bool() const { + return m_transientExpression != nullptr; + } + + friend auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream&; + }; + +} // namespace Catch + +#endif // CATCH_LAZY_EXPR_HPP_INCLUDED + +#include + +namespace Catch { + + struct AssertionResultData + { + AssertionResultData() = delete; + + AssertionResultData( ResultWas::OfType _resultType, LazyExpression const& _lazyExpression ); + + std::string message; + mutable std::string reconstructedExpression; + LazyExpression lazyExpression; + ResultWas::OfType resultType; + + std::string reconstructExpression() const; + }; + + class AssertionResult { + public: + AssertionResult() = delete; + AssertionResult( AssertionInfo const& info, AssertionResultData&& data ); + + bool isOk() const; + bool succeeded() const; + ResultWas::OfType getResultType() const; + bool hasExpression() const; + bool hasMessage() const; + std::string getExpression() const; + std::string getExpressionInMacro() const; + bool hasExpandedExpression() const; + std::string getExpandedExpression() const; + StringRef getMessage() const; + SourceLineInfo getSourceInfo() const; + StringRef getTestMacroName() const; + + //protected: + AssertionInfo m_info; + AssertionResultData m_resultData; + }; + +} // end namespace Catch + +#endif // CATCH_ASSERTION_RESULT_HPP_INCLUDED + + #ifndef CATCH_CONFIG_HPP_INCLUDED #define CATCH_CONFIG_HPP_INCLUDED @@ -3945,6 +3508,7 @@ namespace Catch { #ifndef CATCH_OPTIONAL_HPP_INCLUDED #define CATCH_OPTIONAL_HPP_INCLUDED + #include namespace Catch { @@ -3953,35 +3517,50 @@ namespace Catch { template class Optional { public: - Optional() : nullableValue( nullptr ) {} - Optional( T const& _value ) - : nullableValue( new( storage ) T( _value ) ) - {} - Optional( Optional const& _other ) - : nullableValue( _other ? new( storage ) T( *_other ) : nullptr ) - {} + Optional(): nullableValue( nullptr ) {} + ~Optional() { reset(); } + + Optional( T const& _value ): + nullableValue( new ( storage ) T( _value ) ) {} + Optional( T&& _value ): + nullableValue( new ( storage ) T( CATCH_MOVE( _value ) ) ) {} - ~Optional() { + Optional& operator=( T const& _value ) { + reset(); + nullableValue = new ( storage ) T( _value ); + return *this; + } + Optional& operator=( T&& _value ) { reset(); + nullableValue = new ( storage ) T( CATCH_MOVE( _value ) ); + return *this; } - Optional& operator= ( Optional const& _other ) { - if( &_other != this ) { + Optional( Optional const& _other ): + nullableValue( _other ? new ( storage ) T( *_other ) : nullptr ) {} + Optional( Optional&& _other ): + nullableValue( _other ? new ( storage ) T( CATCH_MOVE( *_other ) ) + : nullptr ) {} + + Optional& operator=( Optional const& _other ) { + if ( &_other != this ) { reset(); - if( _other ) - nullableValue = new( storage ) T( *_other ); + if ( _other ) { nullableValue = new ( storage ) T( *_other ); } } return *this; } - Optional& operator = ( T const& _value ) { - reset(); - nullableValue = new( storage ) T( _value ); + Optional& operator=( Optional&& _other ) { + if ( &_other != this ) { + reset(); + if ( _other ) { + nullableValue = new ( storage ) T( CATCH_MOVE( *_other ) ); + } + } return *this; } void reset() { - if( nullableValue ) - nullableValue->~T(); + if ( nullableValue ) { nullableValue->~T(); } nullableValue = nullptr; } @@ -4025,177 +3604,42 @@ namespace Catch { } friend bool operator!=(Optional const& a, Optional const& b) { return !( a == b ); - } - - private: - T *nullableValue; - alignas(alignof(T)) char storage[sizeof(T)]; - }; - -} // end namespace Catch - -#endif // CATCH_OPTIONAL_HPP_INCLUDED - - -#ifndef CATCH_RANDOM_SEED_GENERATION_HPP_INCLUDED -#define CATCH_RANDOM_SEED_GENERATION_HPP_INCLUDED - -#include - -namespace Catch { - - enum class GenerateFrom { - Time, - RandomDevice, - //! Currently equivalent to RandomDevice, but can change at any point - Default - }; - - std::uint32_t generateRandomSeed(GenerateFrom from); - -} // end namespace Catch - -#endif // CATCH_RANDOM_SEED_GENERATION_HPP_INCLUDED - - -#ifndef CATCH_REPORTER_SPEC_PARSER_HPP_INCLUDED -#define CATCH_REPORTER_SPEC_PARSER_HPP_INCLUDED - - - -#ifndef CATCH_CONSOLE_COLOUR_HPP_INCLUDED -#define CATCH_CONSOLE_COLOUR_HPP_INCLUDED - - -#include -#include - -namespace Catch { - - enum class ColourMode : std::uint8_t; - class IStream; - - struct Colour { - enum Code { - None = 0, - - White, - Red, - Green, - Blue, - Cyan, - Yellow, - Grey, - - Bright = 0x10, - - BrightRed = Bright | Red, - BrightGreen = Bright | Green, - LightGrey = Bright | Grey, - BrightWhite = Bright | White, - BrightYellow = Bright | Yellow, - - // By intention - FileName = LightGrey, - Warning = BrightYellow, - ResultError = BrightRed, - ResultSuccess = BrightGreen, - ResultExpectedFailure = Warning, - - Error = BrightRed, - Success = Green, - Skip = LightGrey, - - OriginalExpression = Cyan, - ReconstructedExpression = BrightYellow, - - SecondaryText = LightGrey, - Headers = White - }; - }; - - class ColourImpl { - protected: - //! The associated stream of this ColourImpl instance - IStream* m_stream; - public: - ColourImpl( IStream* stream ): m_stream( stream ) {} - - //! RAII wrapper around writing specific colour of text using specific - //! colour impl into a stream. - class ColourGuard { - ColourImpl const* m_colourImpl; - Colour::Code m_code; - bool m_engaged = false; + } - public: - //! Does **not** engage the guard/start the colour - ColourGuard( Colour::Code code, - ColourImpl const* colour ); + private: + T* nullableValue; + alignas(alignof(T)) char storage[sizeof(T)]; + }; - ColourGuard( ColourGuard const& rhs ) = delete; - ColourGuard& operator=( ColourGuard const& rhs ) = delete; +} // end namespace Catch - ColourGuard( ColourGuard&& rhs ) noexcept; - ColourGuard& operator=( ColourGuard&& rhs ) noexcept; +#endif // CATCH_OPTIONAL_HPP_INCLUDED - //! Removes colour _if_ the guard was engaged - ~ColourGuard(); - /** - * Explicitly engages colour for given stream. - * - * The API based on operator<< should be preferred. - */ - ColourGuard& engage( std::ostream& stream ) &; - /** - * Explicitly engages colour for given stream. - * - * The API based on operator<< should be preferred. - */ - ColourGuard&& engage( std::ostream& stream ) &&; +#ifndef CATCH_RANDOM_SEED_GENERATION_HPP_INCLUDED +#define CATCH_RANDOM_SEED_GENERATION_HPP_INCLUDED - private: - //! Engages the guard and starts using colour - friend std::ostream& operator<<( std::ostream& lhs, - ColourGuard& guard ) { - guard.engageImpl( lhs ); - return lhs; - } - //! Engages the guard and starts using colour - friend std::ostream& operator<<( std::ostream& lhs, - ColourGuard&& guard) { - guard.engageImpl( lhs ); - return lhs; - } +#include - void engageImpl( std::ostream& stream ); +namespace Catch { - }; + enum class GenerateFrom { + Time, + RandomDevice, + //! Currently equivalent to RandomDevice, but can change at any point + Default + }; - virtual ~ColourImpl(); // = default - /** - * Creates a guard object for given colour and this colour impl - * - * **Important:** - * the guard starts disengaged, and has to be engaged explicitly. - */ - ColourGuard guardColour( Colour::Code colourCode ); + std::uint32_t generateRandomSeed(GenerateFrom from); - private: - virtual void use( Colour::Code colourCode ) const = 0; - }; +} // end namespace Catch - //! Provides ColourImpl based on global config and target compilation platform - Detail::unique_ptr makeColourImpl( ColourMode colourSelection, - IStream* stream ); +#endif // CATCH_RANDOM_SEED_GENERATION_HPP_INCLUDED - //! Checks if specific colour impl has been compiled into the binary - bool isColourImplAvailable( ColourMode colourSelection ); -} // end namespace Catch +#ifndef CATCH_REPORTER_SPEC_PARSER_HPP_INCLUDED +#define CATCH_REPORTER_SPEC_PARSER_HPP_INCLUDED -#endif // CATCH_CONSOLE_COLOUR_HPP_INCLUDED #include #include @@ -4322,7 +3766,7 @@ namespace Catch { bool benchmarkNoAnalysis = false; unsigned int benchmarkSamples = 100; double benchmarkConfidenceInterval = 0.95; - unsigned int benchmarkResamples = 100000; + unsigned int benchmarkResamples = 100'000; std::chrono::milliseconds::rep benchmarkWarmupTime = 100; Verbosity verbosity = Verbosity::Normal; @@ -4424,6 +3868,29 @@ namespace Catch { + +/** \file + * Wrapper for the CATCH_CONFIG_PREFIX_MESSAGES configuration option + * + * CATCH_CONFIG_PREFIX_ALL can be used to avoid clashes with other macros + * by prepending CATCH_. This may not be desirable if the only clashes are with + * logger macros such as INFO and WARN. In this cases + * CATCH_CONFIG_PREFIX_MESSAGES can be used to only prefix a small subset + * of relevant macros. + * + */ + +#ifndef CATCH_CONFIG_PREFIX_MESSAGES_HPP_INCLUDED +#define CATCH_CONFIG_PREFIX_MESSAGES_HPP_INCLUDED + + +#if defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_PREFIX_MESSAGES) + #define CATCH_CONFIG_PREFIX_MESSAGES +#endif + +#endif // CATCH_CONFIG_PREFIX_MESSAGES_HPP_INCLUDED + + #ifndef CATCH_STREAM_END_STOP_HPP_INCLUDED #define CATCH_STREAM_END_STOP_HPP_INCLUDED @@ -4435,10 +3902,10 @@ namespace Catch { // as well as // << stuff +StreamEndStop struct StreamEndStop { - StringRef operator+() const { return StringRef(); } + constexpr StringRef operator+() const { return StringRef(); } template - friend T const& operator+( T const& value, StreamEndStop ) { + constexpr friend T const& operator+( T const& value, StreamEndStop ) { return value; } }; @@ -4447,12 +3914,47 @@ namespace Catch { #endif // CATCH_STREAM_END_STOP_HPP_INCLUDED + +#ifndef CATCH_MESSAGE_INFO_HPP_INCLUDED +#define CATCH_MESSAGE_INFO_HPP_INCLUDED + + +#include + +namespace Catch { + + struct MessageInfo { + MessageInfo( StringRef _macroName, + SourceLineInfo const& _lineInfo, + ResultWas::OfType _type ); + + StringRef macroName; + std::string message; + SourceLineInfo lineInfo; + ResultWas::OfType type; + unsigned int sequence; + + bool operator == (MessageInfo const& other) const { + return sequence == other.sequence; + } + bool operator < (MessageInfo const& other) const { + return sequence < other.sequence; + } + private: + static unsigned int globalCount; + }; + +} // end namespace Catch + +#endif // CATCH_MESSAGE_INFO_HPP_INCLUDED + #include #include namespace Catch { struct SourceLineInfo; + class IResultCapture; struct MessageStream { @@ -4493,7 +3995,7 @@ namespace Catch { class Capturer { std::vector m_messages; - IResultCapture& m_resultCapture = getResultCapture(); + IResultCapture& m_resultCapture; size_t m_captured = 0; public: Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ); @@ -4544,28 +4046,28 @@ namespace Catch { Catch::getResultCapture().emplaceUnscopedMessage( Catch::MessageBuilder( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log ) -#if defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_DISABLE) +#if defined(CATCH_CONFIG_PREFIX_MESSAGES) && !defined(CATCH_CONFIG_DISABLE) #define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( "CATCH_INFO", msg ) #define CATCH_UNSCOPED_INFO( msg ) INTERNAL_CATCH_UNSCOPED_INFO( "CATCH_UNSCOPED_INFO", msg ) #define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( "CATCH_WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg ) #define CATCH_CAPTURE( ... ) INTERNAL_CATCH_CAPTURE( INTERNAL_CATCH_UNIQUE_NAME(capturer), "CATCH_CAPTURE", __VA_ARGS__ ) -#elif defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CONFIG_DISABLE) +#elif defined(CATCH_CONFIG_PREFIX_MESSAGES) && defined(CATCH_CONFIG_DISABLE) #define CATCH_INFO( msg ) (void)(0) #define CATCH_UNSCOPED_INFO( msg ) (void)(0) #define CATCH_WARN( msg ) (void)(0) #define CATCH_CAPTURE( ... ) (void)(0) -#elif !defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_DISABLE) +#elif !defined(CATCH_CONFIG_PREFIX_MESSAGES) && !defined(CATCH_CONFIG_DISABLE) #define INFO( msg ) INTERNAL_CATCH_INFO( "INFO", msg ) #define UNSCOPED_INFO( msg ) INTERNAL_CATCH_UNSCOPED_INFO( "UNSCOPED_INFO", msg ) #define WARN( msg ) INTERNAL_CATCH_MSG( "WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg ) #define CAPTURE( ... ) INTERNAL_CATCH_CAPTURE( INTERNAL_CATCH_UNIQUE_NAME(capturer), "CAPTURE", __VA_ARGS__ ) -#elif !defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CONFIG_DISABLE) +#elif !defined(CATCH_CONFIG_PREFIX_MESSAGES) && defined(CATCH_CONFIG_DISABLE) #define INFO( msg ) (void)(0) #define UNSCOPED_INFO( msg ) (void)(0) @@ -4580,6 +4082,75 @@ namespace Catch { #endif // CATCH_MESSAGE_HPP_INCLUDED +#ifndef CATCH_SECTION_INFO_HPP_INCLUDED +#define CATCH_SECTION_INFO_HPP_INCLUDED + + + +#ifndef CATCH_TOTALS_HPP_INCLUDED +#define CATCH_TOTALS_HPP_INCLUDED + +#include + +namespace Catch { + + struct Counts { + Counts operator - ( Counts const& other ) const; + Counts& operator += ( Counts const& other ); + + std::uint64_t total() const; + bool allPassed() const; + bool allOk() const; + + std::uint64_t passed = 0; + std::uint64_t failed = 0; + std::uint64_t failedButOk = 0; + std::uint64_t skipped = 0; + }; + + struct Totals { + + Totals operator - ( Totals const& other ) const; + Totals& operator += ( Totals const& other ); + + Totals delta( Totals const& prevTotals ) const; + + Counts assertions; + Counts testCases; + }; +} + +#endif // CATCH_TOTALS_HPP_INCLUDED + +#include + +namespace Catch { + + struct SectionInfo { + // The last argument is ignored, so that people can write + // SECTION("ShortName", "Proper description that is long") and + // still use the `-c` flag comfortably. + SectionInfo( SourceLineInfo const& _lineInfo, std::string _name, + const char* const = nullptr ): + name(CATCH_MOVE(_name)), + lineInfo(_lineInfo) + {} + + std::string name; + SourceLineInfo lineInfo; + }; + + struct SectionEndInfo { + SectionInfo sectionInfo; + Counts prevAssertions; + double durationInSeconds; + }; + +} // end namespace Catch + +#endif // CATCH_SECTION_INFO_HPP_INCLUDED + + #ifndef CATCH_SESSION_HPP_INCLUDED #define CATCH_SESSION_HPP_INCLUDED @@ -4683,17 +4254,16 @@ namespace Catch { enum class TokenType { Option, Argument }; struct Token { TokenType type; - std::string token; + StringRef token; }; // Abstracts iterators into args as a stream of tokens, with option // arguments uniformly handled class TokenStream { - using Iterator = std::vector::const_iterator; + using Iterator = std::vector::const_iterator; Iterator it; Iterator itEnd; std::vector m_tokenBuffer; - void loadBuffer(); public: @@ -4745,12 +4315,17 @@ namespace Catch { ResultType m_type; }; - template class ResultValueBase : public ResultBase { + template + class ResultValueBase : public ResultBase { public: - auto value() const -> T const& { + T const& value() const& { enforceOk(); return m_value; } + T&& value() && { + enforceOk(); + return CATCH_MOVE( m_value ); + } protected: ResultValueBase( ResultType type ): ResultBase( type ) {} @@ -4760,13 +4335,23 @@ namespace Catch { if ( m_type == ResultType::Ok ) new ( &m_value ) T( other.m_value ); } + ResultValueBase( ResultValueBase&& other ): + ResultBase( other ) { + if ( m_type == ResultType::Ok ) + new ( &m_value ) T( CATCH_MOVE(other.m_value) ); + } - ResultValueBase( ResultType, T const& value ): ResultBase( ResultType::Ok ) { + + ResultValueBase( ResultType, T const& value ): + ResultBase( ResultType::Ok ) { new ( &m_value ) T( value ); } + ResultValueBase( ResultType, T&& value ): + ResultBase( ResultType::Ok ) { + new ( &m_value ) T( CATCH_MOVE(value) ); + } - auto operator=( ResultValueBase const& other ) - -> ResultValueBase& { + ResultValueBase& operator=( ResultValueBase const& other ) { if ( m_type == ResultType::Ok ) m_value.~T(); ResultBase::operator=( other ); @@ -4774,6 +4359,14 @@ namespace Catch { new ( &m_value ) T( other.m_value ); return *this; } + ResultValueBase& operator=( ResultValueBase&& other ) { + if ( m_type == ResultType::Ok ) m_value.~T(); + ResultBase::operator=( other ); + if ( m_type == ResultType::Ok ) + new ( &m_value ) T( CATCH_MOVE(other.m_value) ); + return *this; + } + ~ResultValueBase() override { if ( m_type == ResultType::Ok ) @@ -4801,8 +4394,8 @@ namespace Catch { } template - static auto ok( U const& value ) -> BasicResult { - return { ResultType::Ok, value }; + static auto ok( U&& value ) -> BasicResult { + return { ResultType::Ok, CATCH_FORWARD(value) }; } static auto ok() -> BasicResult { return { ResultType::Ok }; } static auto logicError( std::string&& message ) @@ -4849,12 +4442,15 @@ namespace Catch { class ParseState { public: ParseState( ParseResultType type, - TokenStream const& remainingTokens ); + TokenStream remainingTokens ); ParseResultType type() const { return m_type; } - TokenStream const& remainingTokens() const { + TokenStream const& remainingTokens() const& { return m_remainingTokens; } + TokenStream&& remainingTokens() && { + return CATCH_MOVE( m_remainingTokens ); + } private: ParseResultType m_type; @@ -4867,7 +4463,7 @@ namespace Catch { struct HelpColumns { std::string left; - std::string right; + StringRef descriptions; }; template @@ -5027,7 +4623,7 @@ namespace Catch { virtual ~ParserBase() = default; virtual auto validate() const -> Result { return Result::ok(); } virtual auto parse( std::string const& exeName, - TokenStream const& tokens ) const + TokenStream tokens ) const -> InternalParseResult = 0; virtual size_t cardinality() const; @@ -5047,8 +4643,8 @@ namespace Catch { protected: Optionality m_optionality = Optionality::Optional; std::shared_ptr m_ref; - std::string m_hint; - std::string m_description; + StringRef m_hint; + StringRef m_description; explicit ParserRefImpl( std::shared_ptr const& ref ): m_ref( ref ) {} @@ -5057,28 +4653,32 @@ namespace Catch { template ParserRefImpl( accept_many_t, LambdaT const& ref, - std::string const& hint ): + StringRef hint ): m_ref( std::make_shared>( ref ) ), m_hint( hint ) {} template ::value>> - ParserRefImpl( T& ref, std::string const& hint ): + ParserRefImpl( T& ref, StringRef hint ): m_ref( std::make_shared>( ref ) ), m_hint( hint ) {} template ::value>> - ParserRefImpl( LambdaT const& ref, std::string const& hint ): + ParserRefImpl( LambdaT const& ref, StringRef hint ): m_ref( std::make_shared>( ref ) ), m_hint( hint ) {} - auto operator()( std::string const& description ) -> DerivedT& { + DerivedT& operator()( StringRef description ) & { m_description = description; return static_cast( *this ); } + DerivedT&& operator()( StringRef description ) && { + m_description = description; + return static_cast( *this ); + } auto optional() -> DerivedT& { m_optionality = Optionality::Optional; @@ -5101,7 +4701,7 @@ namespace Catch { return 1; } - std::string const& hint() const { return m_hint; } + StringRef hint() const { return m_hint; } }; } // namespace detail @@ -5115,13 +4715,13 @@ namespace Catch { Detail::InternalParseResult parse(std::string const&, - Detail::TokenStream const& tokens) const override; + Detail::TokenStream tokens) const override; }; // A parser for options class Opt : public Detail::ParserRefImpl { protected: - std::vector m_optNames; + std::vector m_optNames; public: template @@ -5134,33 +4734,37 @@ namespace Catch { template ::value>> - Opt( LambdaT const& ref, std::string const& hint ): + Opt( LambdaT const& ref, StringRef hint ): ParserRefImpl( ref, hint ) {} template - Opt( accept_many_t, LambdaT const& ref, std::string const& hint ): + Opt( accept_many_t, LambdaT const& ref, StringRef hint ): ParserRefImpl( accept_many, ref, hint ) {} template ::value>> - Opt( T& ref, std::string const& hint ): + Opt( T& ref, StringRef hint ): ParserRefImpl( ref, hint ) {} - auto operator[](std::string const& optName) -> Opt& { + Opt& operator[]( StringRef optName ) & { m_optNames.push_back(optName); return *this; } + Opt&& operator[]( StringRef optName ) && { + m_optNames.push_back( optName ); + return CATCH_MOVE(*this); + } - std::vector getHelpColumns() const; + Detail::HelpColumns getHelpColumns() const; - bool isMatch(std::string const& optToken) const; + bool isMatch(StringRef optToken) const; using ParserBase::parse; Detail::InternalParseResult parse(std::string const&, - Detail::TokenStream const& tokens) const override; + Detail::TokenStream tokens) const override; Detail::Result validate() const override; }; @@ -5183,7 +4787,7 @@ namespace Catch { // handled specially Detail::InternalParseResult parse(std::string const&, - Detail::TokenStream const& tokens) const override; + Detail::TokenStream tokens) const override; std::string const& name() const { return *m_name; } Detail::ParserResult set(std::string const& newName); @@ -5208,16 +4812,28 @@ namespace Catch { return *this; } - auto operator|=(Opt const& opt) -> Parser& { - m_options.push_back(opt); - return *this; + friend Parser& operator|=( Parser& p, Opt const& opt ) { + p.m_options.push_back( opt ); + return p; + } + friend Parser& operator|=( Parser& p, Opt&& opt ) { + p.m_options.push_back( CATCH_MOVE(opt) ); + return p; } Parser& operator|=(Parser const& other); template - auto operator|(T const& other) const -> Parser { - return Parser(*this) |= other; + friend Parser operator|( Parser const& p, T&& rhs ) { + Parser temp( p ); + temp |= rhs; + return temp; + } + + template + friend Parser operator|( Parser&& p, T&& rhs ) { + p |= CATCH_FORWARD(rhs); + return CATCH_MOVE(p); } std::vector getHelpColumns() const; @@ -5235,21 +4851,23 @@ namespace Catch { using ParserBase::parse; Detail::InternalParseResult parse(std::string const& exeName, - Detail::TokenStream const& tokens) const override; + Detail::TokenStream tokens) const override; }; - // Transport for raw args (copied from main args, or supplied via - // init list for testing) + /** + * Wrapper over argc + argv, assumes that the inputs outlive it + */ class Args { friend Detail::TokenStream; - std::string m_exeName; - std::vector m_args; + StringRef m_exeName; + std::vector m_args; public: Args(int argc, char const* const* argv); - Args(std::initializer_list args); + // Helper constructor for testing + Args(std::initializer_list args); - std::string const& exeName() const { return m_exeName; } + StringRef exeName() const { return m_exeName; } }; @@ -5855,8 +5473,6 @@ namespace Catch { namespace Catch { - class IResultCapture; - struct AssertionReaction { bool shouldDebugBreak = false; bool shouldThrow = false; @@ -5897,7 +5513,6 @@ namespace Catch { void handleUnexpectedInflightException(); void complete(); - void setCompleted(); // query auto allowThrows() const -> bool; @@ -5909,13 +5524,10 @@ namespace Catch { #endif // CATCH_ASSERTION_HANDLER_HPP_INCLUDED -// We need this suppression to leak, because it took until GCC 10 -// for the front end to handle local suppression via _Pragma properly -#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && __GNUC__ <= 9 - #pragma GCC diagnostic ignored "-Wparentheses" -#endif -#if !defined(CATCH_CONFIG_DISABLE) +#ifndef CATCH_PREPROCESSOR_INTERNAL_STRINGIFY_HPP_INCLUDED +#define CATCH_PREPROCESSOR_INTERNAL_STRINGIFY_HPP_INCLUDED + #if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION) #define CATCH_INTERNAL_STRINGIFY(...) #__VA_ARGS__##_catch_sr @@ -5923,6 +5535,16 @@ namespace Catch { #define CATCH_INTERNAL_STRINGIFY(...) "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION"_catch_sr #endif +#endif // CATCH_PREPROCESSOR_INTERNAL_STRINGIFY_HPP_INCLUDED + +// We need this suppression to leak, because it took until GCC 10 +// for the front end to handle local suppression via _Pragma properly +#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && __GNUC__ <= 9 + #pragma GCC diagnostic ignored "-Wparentheses" +#endif + +#if !defined(CATCH_CONFIG_DISABLE) + #if defined(CATCH_CONFIG_FAST_COMPILE) || defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) /////////////////////////////////////////////////////////////////////////////// @@ -5934,7 +5556,7 @@ namespace Catch { #else // CATCH_CONFIG_FAST_COMPILE #define INTERNAL_CATCH_TRY try -#define INTERNAL_CATCH_CATCH( handler ) catch(...) { handler.handleUnexpectedInflightException(); } +#define INTERNAL_CATCH_CATCH( handler ) catch(...) { (handler).handleUnexpectedInflightException(); } #endif @@ -5990,6 +5612,7 @@ namespace Catch { if( catchAssertionHandler.allowThrows() ) \ try { \ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT \ CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \ static_cast(__VA_ARGS__); \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ @@ -6010,6 +5633,7 @@ namespace Catch { if( catchAssertionHandler.allowThrows() ) \ try { \ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT \ CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \ static_cast(expr); \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ @@ -6036,6 +5660,7 @@ namespace Catch { if( catchAssertionHandler.allowThrows() ) \ try { \ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT \ CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \ static_cast(__VA_ARGS__); \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ @@ -6051,12 +5676,40 @@ namespace Catch { #endif // CATCH_CONFIG_DISABLE -#endif // CATCH_TEST_MACRO_IMPL_HPP_INCLUDED +#endif // CATCH_TEST_MACRO_IMPL_HPP_INCLUDED + + +#ifndef CATCH_SECTION_HPP_INCLUDED +#define CATCH_SECTION_HPP_INCLUDED + + + + +/** \file + * Wrapper for the STATIC_ANALYSIS_SUPPORT configuration option + * + * Some of Catch2's macros can be defined differently to work better with + * static analysis tools, like clang-tidy or coverity. + * Currently the main use case is to show that `SECTION`s are executed + * exclusively, and not all in one run of a `TEST_CASE`. + */ + +#ifndef CATCH_CONFIG_STATIC_ANALYSIS_SUPPORT_HPP_INCLUDED +#define CATCH_CONFIG_STATIC_ANALYSIS_SUPPORT_HPP_INCLUDED + + +#if defined(__clang_analyzer__) || defined(__COVERITY__) + #define CATCH_INTERNAL_CONFIG_STATIC_ANALYSIS_SUPPORT +#endif +#if defined( CATCH_INTERNAL_CONFIG_STATIC_ANALYSIS_SUPPORT ) && \ + !defined( CATCH_CONFIG_NO_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT ) && \ + !defined( CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT ) +# define CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT +#endif -#ifndef CATCH_SECTION_HPP_INCLUDED -#define CATCH_SECTION_HPP_INCLUDED +#endif // CATCH_CONFIG_STATIC_ANALYSIS_SUPPORT_HPP_INCLUDED #ifndef CATCH_TIMER_HPP_INCLUDED @@ -6103,17 +5756,63 @@ namespace Catch { } // end namespace Catch -#define INTERNAL_CATCH_SECTION( ... ) \ - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ - CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ - if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::Section( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) \ - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION +#if !defined(CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT) +# define INTERNAL_CATCH_SECTION( ... ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ + if ( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( \ + catch_internal_Section ) = \ + Catch::Section( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + +# define INTERNAL_CATCH_DYNAMIC_SECTION( ... ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ + if ( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( \ + catch_internal_Section ) = \ + Catch::SectionInfo( \ + CATCH_INTERNAL_LINEINFO, \ + ( Catch::ReusableStringStream() << __VA_ARGS__ ) \ + .str() ) ) \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + +#else + +// These section definitions imply that at most one section at one level +// will be intered (because only one section's __LINE__ can be equal to +// the dummy `catchInternalSectionHint` variable from `TEST_CASE`). + +namespace Catch { + namespace Detail { + // Intentionally without linkage, as it should only be used as a dummy + // symbol for static analysis. + int GetNewSectionHint(); + } // namespace Detail +} // namespace Catch + + +# define INTERNAL_CATCH_SECTION( ... ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ + if ( [[maybe_unused]] const int catchInternalPreviousSectionHint = \ + catchInternalSectionHint, \ + catchInternalSectionHint = Catch::Detail::GetNewSectionHint(); \ + catchInternalPreviousSectionHint == __LINE__ ) \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + +# define INTERNAL_CATCH_DYNAMIC_SECTION( ... ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ + if ( [[maybe_unused]] const int catchInternalPreviousSectionHint = \ + catchInternalSectionHint, \ + catchInternalSectionHint = Catch::Detail::GetNewSectionHint(); \ + catchInternalPreviousSectionHint == __LINE__ ) \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + +#endif -#define INTERNAL_CATCH_DYNAMIC_SECTION( ... ) \ - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ - CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ - if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, (Catch::ReusableStringStream() << __VA_ARGS__).str() ) ) \ - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION #endif // CATCH_SECTION_HPP_INCLUDED @@ -6123,42 +5822,20 @@ namespace Catch { -#ifndef CATCH_INTERFACES_TESTCASE_HPP_INCLUDED -#define CATCH_INTERFACES_TESTCASE_HPP_INCLUDED - -#include +#ifndef CATCH_INTERFACES_TEST_INVOKER_HPP_INCLUDED +#define CATCH_INTERFACES_TEST_INVOKER_HPP_INCLUDED namespace Catch { - class TestSpec; - struct TestCaseInfo; - class ITestInvoker { public: - virtual void invoke () const = 0; + virtual void invoke() const = 0; virtual ~ITestInvoker(); // = default }; - class TestCaseHandle; - class IConfig; - - class ITestCaseRegistry { - public: - virtual ~ITestCaseRegistry(); // = default - // TODO: this exists only for adding filenames to test cases -- let's expose this in a saner way later - virtual std::vector const& getAllInfos() const = 0; - virtual std::vector const& getAllTests() const = 0; - virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0; - }; - - bool isThrowSafe( TestCaseHandle const& testCase, IConfig const& config ); - bool matchTest( TestCaseHandle const& testCase, TestSpec const& testSpec, IConfig const& config ); - std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); - std::vector const& getAllTestCasesSorted( IConfig const& config ); - -} +} // namespace Catch -#endif // CATCH_INTERFACES_TESTCASE_HPP_INCLUDED +#endif // CATCH_INTERFACES_TEST_INVOKER_HPP_INCLUDED #ifndef CATCH_PREPROCESSOR_REMOVE_PARENS_HPP_INCLUDED @@ -6230,6 +5907,9 @@ struct AutoReg : Detail::NonCopyable { void TestName::test() #endif + +#if !defined(CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT) + /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \ static void TestName(); \ @@ -6242,19 +5922,40 @@ struct AutoReg : Detail::NonCopyable { #define INTERNAL_CATCH_TESTCASE( ... ) \ INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), __VA_ARGS__ ) - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \ - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ - CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ - namespace { \ - const Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( \ - Catch::makeTestInvoker( &QualifiedMethod ), \ - CATCH_INTERNAL_LINEINFO, \ - "&" #QualifiedMethod##_catch_sr, \ - Catch::NameAndTags{ __VA_ARGS__ } ); \ - } /* NOLINT */ \ - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION +#else // ^^ !CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT | vv CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT + + +// Dummy registrator for the dumy test case macros +namespace Catch { + namespace Detail { + struct DummyUse { + DummyUse( void ( * )( int ) ); + }; + } // namespace Detail +} // namespace Catch + +// Note that both the presence of the argument and its exact name are +// necessary for the section support. + +// We provide a shadowed variable so that a `SECTION` inside non-`TEST_CASE` +// tests can compile. The redefined `TEST_CASE` shadows this with param. +static int catchInternalSectionHint = 0; + +# define INTERNAL_CATCH_TESTCASE2( fname ) \ + static void fname( int ); \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ + static const Catch::Detail::DummyUse INTERNAL_CATCH_UNIQUE_NAME( \ + dummyUser )( &(fname) ); \ + CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ + static void fname( [[maybe_unused]] int catchInternalSectionHint ) \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION +# define INTERNAL_CATCH_TESTCASE( ... ) \ + INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( dummyFunction ) ) + + +#endif // CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\ @@ -6276,6 +5977,22 @@ struct AutoReg : Detail::NonCopyable { #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \ INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), ClassName, __VA_ARGS__ ) + + /////////////////////////////////////////////////////////////////////////////// + #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ + namespace { \ + const Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( \ + Catch::makeTestInvoker( &QualifiedMethod ), \ + CATCH_INTERNAL_LINEINFO, \ + "&" #QualifiedMethod##_catch_sr, \ + Catch::NameAndTags{ __VA_ARGS__ } ); \ + } /* NOLINT */ \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + + /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \ do { \ @@ -7194,6 +6911,7 @@ namespace Catch { }; class ITestInvoker; + struct NameAndTags; enum class TestCaseProperties : uint8_t { None = 0, @@ -7318,6 +7036,10 @@ namespace Catch { #include namespace Catch { + namespace Detail { + void registerTranslatorImpl( + Detail::unique_ptr&& translator ); + } class ExceptionTranslatorRegistrar { template @@ -7351,9 +7073,9 @@ namespace Catch { public: template ExceptionTranslatorRegistrar( std::string(*translateFunction)( T const& ) ) { - getMutableRegistryHub().registerTranslator( - Detail::make_unique>(translateFunction) - ); + Detail::registerTranslatorImpl( + Detail::make_unique>( + translateFunction ) ); } }; @@ -7425,7 +7147,7 @@ namespace Catch { #define CATCH_VERSION_MACROS_HPP_INCLUDED #define CATCH_VERSION_MAJOR 3 -#define CATCH_VERSION_MINOR 3 +#define CATCH_VERSION_MINOR 5 #define CATCH_VERSION_PATCH 2 #endif // CATCH_VERSION_MACROS_HPP_INCLUDED @@ -7584,12 +7306,6 @@ namespace Detail { } public: - ~IGenerator() override = default; - IGenerator() = default; - IGenerator(IGenerator const&) = default; - IGenerator& operator=(IGenerator const&) = default; - - // Returns the current element of the generator // // \Precondition The generator is either freshly constructed, @@ -8058,37 +7774,578 @@ namespace Catch { return static_cast(-1); } - // Provide some default initial state for the default constructor - SimplePcg32():SimplePcg32(0xed743cc4U) {} + // Provide some default initial state for the default constructor + SimplePcg32():SimplePcg32(0xed743cc4U) {} + + explicit SimplePcg32(result_type seed_); + + void seed(result_type seed_); + void discard(uint64_t skip); + + result_type operator()(); + + private: + friend bool operator==(SimplePcg32 const& lhs, SimplePcg32 const& rhs); + friend bool operator!=(SimplePcg32 const& lhs, SimplePcg32 const& rhs); + + // In theory we also need operator<< and operator>> + // In practice we do not use them, so we will skip them for now + + + std::uint64_t m_state; + // This part of the state determines which "stream" of the numbers + // is chosen -- we take it as a constant for Catch2, so we only + // need to deal with seeding the main state. + // Picked by reading 8 bytes from `/dev/random` :-) + static const std::uint64_t s_inc = (0x13ed0cc53f939476ULL << 1ULL) | 1ULL; + }; + +} // end namespace Catch + +#endif // CATCH_RANDOM_NUMBER_GENERATOR_HPP_INCLUDED + + + +#ifndef CATCH_UNIFORM_INTEGER_DISTRIBUTION_HPP_INCLUDED +#define CATCH_UNIFORM_INTEGER_DISTRIBUTION_HPP_INCLUDED + + + + +#ifndef CATCH_RANDOM_INTEGER_HELPERS_HPP_INCLUDED +#define CATCH_RANDOM_INTEGER_HELPERS_HPP_INCLUDED + +#include +#include +#include +#include + +namespace Catch { + namespace Detail { + + template + struct SizedUnsignedType; +#define SizedUnsignedTypeHelper( TYPE ) \ + template <> \ + struct SizedUnsignedType { \ + using type = TYPE; \ + } + + SizedUnsignedTypeHelper( std::uint8_t ); + SizedUnsignedTypeHelper( std::uint16_t ); + SizedUnsignedTypeHelper( std::uint32_t ); + SizedUnsignedTypeHelper( std::uint64_t ); +#undef SizedUnsignedTypeHelper + + template + using SizedUnsignedType_t = typename SizedUnsignedType::type; + + template + using DoubleWidthUnsignedType_t = SizedUnsignedType_t<2 * sizeof( T )>; + + template + struct ExtendedMultResult { + T upper; + T lower; + friend bool operator==( ExtendedMultResult const& lhs, + ExtendedMultResult const& rhs ) { + return lhs.upper == rhs.upper && lhs.lower == rhs.lower; + } + }; + + // Returns 128 bit result of multiplying lhs and rhs + constexpr ExtendedMultResult + extendedMult( std::uint64_t lhs, std::uint64_t rhs ) { + // We use the simple long multiplication approach for + // correctness, we can use platform specific builtins + // for performance later. + + // Split the lhs and rhs into two 32bit "digits", so that we can + // do 64 bit arithmetic to handle carry bits. + // 32b 32b 32b 32b + // lhs L1 L2 + // * rhs R1 R2 + // ------------------------ + // | R2 * L2 | + // | R2 * L1 | + // | R1 * L2 | + // | R1 * L1 | + // ------------------------- + // | a | b | c | d | + +#define CarryBits( x ) ( x >> 32 ) +#define Digits( x ) ( x & 0xFF'FF'FF'FF ) + + auto r2l2 = Digits( rhs ) * Digits( lhs ); + auto r2l1 = Digits( rhs ) * CarryBits( lhs ); + auto r1l2 = CarryBits( rhs ) * Digits( lhs ); + auto r1l1 = CarryBits( rhs ) * CarryBits( lhs ); + + // Sum to columns first + auto d = Digits( r2l2 ); + auto c = CarryBits( r2l2 ) + Digits( r2l1 ) + Digits( r1l2 ); + auto b = CarryBits( r2l1 ) + CarryBits( r1l2 ) + Digits( r1l1 ); + auto a = CarryBits( r1l1 ); + + // Propagate carries between columns + c += CarryBits( d ); + b += CarryBits( c ); + a += CarryBits( b ); + + // Remove the used carries + c = Digits( c ); + b = Digits( b ); + a = Digits( a ); + +#undef CarryBits +#undef Digits + + return { + a << 32 | b, // upper 64 bits + c << 32 | d // lower 64 bits + }; + } + + template + constexpr ExtendedMultResult extendedMult( UInt lhs, UInt rhs ) { + static_assert( std::is_unsigned::value, + "extendedMult can only handle unsigned integers" ); + static_assert( sizeof( UInt ) < sizeof( std::uint64_t ), + "Generic extendedMult can only handle types smaller " + "than uint64_t" ); + using WideType = DoubleWidthUnsignedType_t; + + auto result = WideType( lhs ) * WideType( rhs ); + return { + static_cast( result >> ( CHAR_BIT * sizeof( UInt ) ) ), + static_cast( result & UInt( -1 ) ) }; + } + + + template + std::enable_if_t= sizeof(TargetType), + TargetType> fillBitsFrom(Generator& gen) { + using gresult_type = typename Generator::result_type; + static_assert( std::is_unsigned::value, "Only unsigned integers are supported" ); + static_assert( Generator::min() == 0 && + Generator::max() == static_cast( -1 ), + "Generator must be able to output all numbers in its result type (effectively it must be a random bit generator)" ); + + // We want to return the top bits from a generator, as they are + // usually considered higher quality. + constexpr auto generated_bits = sizeof( gresult_type ) * CHAR_BIT; + constexpr auto return_bits = sizeof( TargetType ) * CHAR_BIT; + + return static_cast( gen() >> + ( generated_bits - return_bits) ); + } + + template + std::enable_if_t fillBitsFrom(Generator& gen) { + using gresult_type = typename Generator::result_type; + static_assert( std::is_unsigned::value, + "Only unsigned integers are supported" ); + static_assert( Generator::min() == 0 && + Generator::max() == static_cast( -1 ), + "Generator must be able to output all numbers in its result type (effectively it must be a random bit generator)" ); + + constexpr auto generated_bits = sizeof( gresult_type ) * CHAR_BIT; + constexpr auto return_bits = sizeof( TargetType ) * CHAR_BIT; + std::size_t filled_bits = 0; + TargetType ret = 0; + do { + ret <<= generated_bits; + ret |= gen(); + filled_bits += generated_bits; + } while ( filled_bits < return_bits ); + + return ret; + } + + /* + * Transposes numbers into unsigned type while keeping their ordering + * + * This means that signed types are changed so that the ordering is + * [INT_MIN, ..., -1, 0, ..., INT_MAX], rather than order we would + * get by simple casting ([0, ..., INT_MAX, INT_MIN, ..., -1]) + */ + template + std::enable_if_t::value, UnsignedType> + transposeToNaturalOrder( UnsignedType in ) { + static_assert( + sizeof( OriginalType ) == sizeof( UnsignedType ), + "reordering requires the same sized types on both sides" ); + static_assert( std::is_unsigned::value, + "Input type must be unsigned" ); + // Assuming 2s complement (standardized in current C++), the + // positive and negative numbers are already internally ordered, + // and their difference is in the top bit. Swapping it orders + // them the desired way. + constexpr auto highest_bit = + UnsignedType( 1 ) << ( sizeof( UnsignedType ) * CHAR_BIT - 1 ); + return static_cast( in ^ highest_bit ); + } + + + + template + std::enable_if_t::value, UnsignedType> + transposeToNaturalOrder(UnsignedType in) { + static_assert( + sizeof( OriginalType ) == sizeof( UnsignedType ), + "reordering requires the same sized types on both sides" ); + static_assert( std::is_unsigned::value, "Input type must be unsigned" ); + // No reordering is needed for unsigned -> unsigned + return in; + } + } // namespace Detail +} // namespace Catch + +#endif // CATCH_RANDOM_INTEGER_HELPERS_HPP_INCLUDED + +namespace Catch { + + namespace Detail { + // Indirection to enable make_unsigned behaviour. + template + struct make_unsigned { + using type = std::make_unsigned_t; + }; + + template <> + struct make_unsigned { + using type = uint8_t; + }; + + template + using make_unsigned_t = typename make_unsigned::type; + } + +/** + * Implementation of uniform distribution on integers. + * + * Unlike `std::uniform_int_distribution`, this implementation supports + * various 1 byte integral types, including bool (but you should not + * actually use it for bools). + * + * The underlying algorithm is based on the one described in "Fast Random + * Integer Generation in an Interval" by Daniel Lemire, but has been + * optimized under the assumption of reuse of the same distribution object. + */ +template +class uniform_integer_distribution { + static_assert(std::is_integral::value, "..."); + + using UnsignedIntegerType = Detail::make_unsigned_t; + + // Only the left bound is stored, and we store it converted to its + // unsigned image. This avoids having to do the conversions inside + // the operator(), at the cost of having to do the conversion in + // the a() getter. The right bound is only needed in the b() getter, + // so we recompute it there from other stored data. + UnsignedIntegerType m_a; + + // How many different values are there in [a, b]. a == b => 1, can be 0 for distribution over all values in the type. + UnsignedIntegerType m_ab_distance; + + // We hoisted this out of the main generation function. Technically, + // this means that using this distribution will be slower than Lemire's + // algorithm if this distribution instance will be used only few times, + // but it will be faster if it is used many times. Since Catch2 uses + // distributions only to implement random generators, we assume that each + // distribution will be reused many times and this is an optimization. + UnsignedIntegerType m_rejection_threshold = 0; + + UnsignedIntegerType computeDistance(IntegerType a, IntegerType b) const { + // This overflows and returns 0 if a == 0 and b == TYPE_MAX. + // We handle that later when generating the number. + return transposeTo(b) - transposeTo(a) + 1; + } + + static UnsignedIntegerType computeRejectionThreshold(UnsignedIntegerType ab_distance) { + // distance == 0 means that we will return all possible values from + // the type's range, and that we shouldn't reject anything. + if ( ab_distance == 0 ) { return 0; } + return ( ~ab_distance + 1 ) % ab_distance; + } + + static UnsignedIntegerType transposeTo(IntegerType in) { + return Detail::transposeToNaturalOrder( + static_cast( in ) ); + } + static IntegerType transposeBack(UnsignedIntegerType in) { + return static_cast( + Detail::transposeToNaturalOrder(in) ); + } + +public: + using result_type = IntegerType; + + uniform_integer_distribution( IntegerType a, IntegerType b ): + m_a( transposeTo(a) ), + m_ab_distance( computeDistance(a, b) ), + m_rejection_threshold( computeRejectionThreshold(m_ab_distance) ) { + assert( a <= b ); + } + + template + result_type operator()( Generator& g ) { + // All possible values of result_type are valid. + if ( m_ab_distance == 0 ) { + return transposeBack( Detail::fillBitsFrom( g ) ); + } + + auto random_number = Detail::fillBitsFrom( g ); + auto emul = Detail::extendedMult( random_number, m_ab_distance ); + // Unlike Lemire's algorithm we skip the ab_distance check, since + // we precomputed the rejection threshold, which is always tighter. + while (emul.lower < m_rejection_threshold) { + random_number = Detail::fillBitsFrom( g ); + emul = Detail::extendedMult( random_number, m_ab_distance ); + } + + return transposeBack(m_a + emul.upper); + } + + result_type a() const { return transposeBack(m_a); } + result_type b() const { return transposeBack(m_ab_distance + m_a - 1); } +}; + +} // end namespace Catch + +#endif // CATCH_UNIFORM_INTEGER_DISTRIBUTION_HPP_INCLUDED + + + +#ifndef CATCH_UNIFORM_FLOATING_POINT_DISTRIBUTION_HPP_INCLUDED +#define CATCH_UNIFORM_FLOATING_POINT_DISTRIBUTION_HPP_INCLUDED + + + + +#ifndef CATCH_RANDOM_FLOATING_POINT_HELPERS_HPP_INCLUDED +#define CATCH_RANDOM_FLOATING_POINT_HELPERS_HPP_INCLUDED + + + +#ifndef CATCH_POLYFILLS_HPP_INCLUDED +#define CATCH_POLYFILLS_HPP_INCLUDED + +namespace Catch { + + bool isnan(float f); + bool isnan(double d); + + float nextafter(float x, float y); + double nextafter(double x, double y); + +} + +#endif // CATCH_POLYFILLS_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace Catch { + + namespace Detail { + /** + * Returns the largest magnitude of 1-ULP distance inside the [a, b] range. + * + * Assumes `a < b`. + */ + template + FloatType gamma(FloatType a, FloatType b) { + static_assert( std::is_floating_point::value, + "gamma returns the largest ULP magnitude within " + "floating point range [a, b]. This only makes sense " + "for floating point types" ); + assert( a <= b ); + + const auto gamma_up = Catch::nextafter( a, std::numeric_limits::infinity() ) - a; + const auto gamma_down = b - Catch::nextafter( b, -std::numeric_limits::infinity() ); + + return gamma_up < gamma_down ? gamma_down : gamma_up; + } + + template + struct DistanceTypePicker; + template <> + struct DistanceTypePicker { + using type = std::uint32_t; + }; + template <> + struct DistanceTypePicker { + using type = std::uint64_t; + }; + + template + using DistanceType = typename DistanceTypePicker::type; + +#if defined( __GNUC__ ) || defined( __clang__ ) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wfloat-equal" +#endif + /** + * Computes the number of equi-distant floats in [a, b] + * + * Since not every range can be split into equidistant floats + * exactly, we actually compute ceil(b/distance - a/distance), + * because in those cases we want to overcount. + * + * Uses modified Dekker's FastTwoSum algorithm to handle rounding. + */ + template + DistanceType + count_equidistant_floats( FloatType a, FloatType b, FloatType distance ) { + assert( a <= b ); + // We get distance as gamma for our uniform float distribution, + // so this will round perfectly. + const auto ag = a / distance; + const auto bg = b / distance; + + const auto s = bg - ag; + const auto err = ( std::fabs( a ) <= std::fabs( b ) ) + ? -ag - ( s - bg ) + : bg - ( s + ag ); + const auto ceil_s = static_cast>( std::ceil( s ) ); + + return ( ceil_s != s ) ? ceil_s : ceil_s + ( err > 0 ); + } +#if defined( __GNUC__ ) || defined( __clang__ ) +# pragma GCC diagnostic pop +#endif + + } - explicit SimplePcg32(result_type seed_); +} // end namespace Catch - void seed(result_type seed_); - void discard(uint64_t skip); +#endif // CATCH_RANDOM_FLOATING_POINT_HELPERS_HPP_INCLUDED - result_type operator()(); +#include +#include - private: - friend bool operator==(SimplePcg32 const& lhs, SimplePcg32 const& rhs); - friend bool operator!=(SimplePcg32 const& lhs, SimplePcg32 const& rhs); +namespace Catch { - // In theory we also need operator<< and operator>> - // In practice we do not use them, so we will skip them for now + namespace Detail { +#if defined( __GNUC__ ) || defined( __clang__ ) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wfloat-equal" +#endif + // The issue with overflow only happens with maximal ULP and HUGE + // distance, e.g. when generating numbers in [-inf, inf] for given + // type. So we only check for the largest possible ULP in the + // type, and return something that does not overflow to inf in 1 mult. + constexpr std::uint64_t calculate_max_steps_in_one_go(double gamma) { + if ( gamma == 1.99584030953472e+292 ) { return 9007199254740991; } + return static_cast( -1 ); + } + constexpr std::uint32_t calculate_max_steps_in_one_go(float gamma) { + if ( gamma == 2.028241e+31f ) { return 16777215; } + return static_cast( -1 ); + } +#if defined( __GNUC__ ) || defined( __clang__ ) +# pragma GCC diagnostic pop +#endif + } +/** + * Implementation of uniform distribution on floating point numbers. + * + * Note that we support only `float` and `double` types, because these + * usually mean the same thing across different platform. `long double` + * varies wildly by platform and thus we cannot provide reproducible + * implementation. Also note that we don't implement all parts of + * distribution per standard: this distribution is not serializable, nor + * can the range be arbitrarily reset. + * + * The implementation also uses different approach than the one taken by + * `std::uniform_real_distribution`, where instead of generating a number + * between [0, 1) and then multiplying the range bounds with it, we first + * split the [a, b] range into a set of equidistributed floating point + * numbers, and then use uniform int distribution to pick which one to + * return. + * + * This has the advantage of guaranteeing uniformity (the multiplication + * method loses uniformity due to rounding when multiplying floats), except + * for small non-uniformity at one side of the interval, where we have + * to deal with the fact that not every interval is splittable into + * equidistributed floats. + * + * Based on "Drawing random floating-point numbers from an interval" by + * Frederic Goualard. + */ +template +class uniform_floating_point_distribution { + static_assert(std::is_floating_point::value, "..."); + static_assert(!std::is_same::value, + "We do not support long double due to inconsistent behaviour between platforms"); + + using WidthType = Detail::DistanceType; + + FloatType m_a, m_b; + FloatType m_ulp_magnitude; + WidthType m_floats_in_range; + uniform_integer_distribution m_int_dist; + + // In specific cases, we can overflow into `inf` when computing the + // `steps * g` offset. To avoid this, we don't offset by more than this + // in one multiply + addition. + WidthType m_max_steps_in_one_go; + // We don't want to do the magnitude check every call to `operator()` + bool m_a_has_leq_magnitude; - std::uint64_t m_state; - // This part of the state determines which "stream" of the numbers - // is chosen -- we take it as a constant for Catch2, so we only - // need to deal with seeding the main state. - // Picked by reading 8 bytes from `/dev/random` :-) - static const std::uint64_t s_inc = (0x13ed0cc53f939476ULL << 1ULL) | 1ULL; - }; +public: + using result_type = FloatType; + + uniform_floating_point_distribution( FloatType a, FloatType b ): + m_a( a ), + m_b( b ), + m_ulp_magnitude( Detail::gamma( m_a, m_b ) ), + m_floats_in_range( Detail::count_equidistant_floats( m_a, m_b, m_ulp_magnitude ) ), + m_int_dist(0, m_floats_in_range), + m_max_steps_in_one_go( Detail::calculate_max_steps_in_one_go(m_ulp_magnitude)), + m_a_has_leq_magnitude(std::fabs(m_a) <= std::fabs(m_b)) + { + assert( a <= b ); + } -} // end namespace Catch + template + result_type operator()( Generator& g ) { + WidthType steps = m_int_dist( g ); + if ( m_a_has_leq_magnitude ) { + if ( steps == m_floats_in_range ) { return m_a; } + auto b = m_b; + while (steps > m_max_steps_in_one_go) { + b -= m_max_steps_in_one_go * m_ulp_magnitude; + steps -= m_max_steps_in_one_go; + } + return b - steps * m_ulp_magnitude; + } else { + if ( steps == m_floats_in_range ) { return m_b; } + auto a = m_a; + while (steps > m_max_steps_in_one_go) { + a += m_max_steps_in_one_go * m_ulp_magnitude; + steps -= m_max_steps_in_one_go; + } + return a + steps * m_ulp_magnitude; + } + } -#endif // CATCH_RANDOM_NUMBER_GENERATOR_HPP_INCLUDED + result_type a() const { return m_a; } + result_type b() const { return m_b; } +}; + +} // end namespace Catch -#include +#endif // CATCH_UNIFORM_FLOATING_POINT_DISTRIBUTION_HPP_INCLUDED namespace Catch { namespace Generators { @@ -8102,7 +8359,7 @@ namespace Detail { template class RandomFloatingGenerator final : public IGenerator { Catch::SimplePcg32 m_rng; - std::uniform_real_distribution m_dist; + Catch::uniform_floating_point_distribution m_dist; Float m_current_number; public: RandomFloatingGenerator( Float a, Float b, std::uint32_t seed ): @@ -8120,10 +8377,27 @@ class RandomFloatingGenerator final : public IGenerator { } }; +template <> +class RandomFloatingGenerator final : public IGenerator { + // We still rely on for this specialization, but we don't + // want to drag it into the header. + struct PImpl; + Catch::Detail::unique_ptr m_pimpl; + long double m_current_number; + +public: + RandomFloatingGenerator( long double a, long double b, std::uint32_t seed ); + + long double const& get() const override { return m_current_number; } + bool next() override; + + ~RandomFloatingGenerator() override; // = default +}; + template class RandomIntegerGenerator final : public IGenerator { Catch::SimplePcg32 m_rng; - std::uniform_int_distribution m_dist; + Catch::uniform_integer_distribution m_dist; Integer m_current_number; public: RandomIntegerGenerator( Integer a, Integer b, std::uint32_t seed ): @@ -8144,14 +8418,6 @@ class RandomIntegerGenerator final : public IGenerator { template std::enable_if_t::value, GeneratorWrapper> random(T a, T b) { - static_assert( - !std::is_same::value && - !std::is_same::value && - !std::is_same::value && - !std::is_same::value && - !std::is_same::value && - !std::is_same::value, - "The requested type is not supported by the underlying random distributions from std" ); return GeneratorWrapper( Catch::Detail::make_unique>(a, b, Detail::getSeed()) ); @@ -8264,39 +8530,266 @@ GeneratorWrapper from_range(InputIterator from, InputSentinel to) { return GeneratorWrapper(Catch::Detail::make_unique>(from, to)); } -template -GeneratorWrapper from_range(Container const& cnt) { - return GeneratorWrapper(Catch::Detail::make_unique>(cnt.begin(), cnt.end())); +template +auto from_range(Container const& cnt) { + using std::begin; + using std::end; + return from_range( begin( cnt ), end( cnt ) ); } -} // namespace Generators -} // namespace Catch +} // namespace Generators +} // namespace Catch + + +#endif // CATCH_GENERATORS_RANGE_HPP_INCLUDED + +#endif // CATCH_GENERATORS_ALL_HPP_INCLUDED + + +/** \file + * This is a convenience header for Catch2's interfaces. It includes + * **all** of Catch2 headers related to interfaces. + * + * Generally the Catch2 users should use specific includes they need, + * but this header can be used instead for ease-of-experimentation, or + * just plain convenience, at the cost of somewhat increased compilation + * times. + * + * When a new header is added to either the `interfaces` folder, or to + * the corresponding internal subfolder, it should be added here. + */ + + +#ifndef CATCH_INTERFACES_ALL_HPP_INCLUDED +#define CATCH_INTERFACES_ALL_HPP_INCLUDED + + + +#ifndef CATCH_INTERFACES_REPORTER_HPP_INCLUDED +#define CATCH_INTERFACES_REPORTER_HPP_INCLUDED + + + +#ifndef CATCH_TEST_RUN_INFO_HPP_INCLUDED +#define CATCH_TEST_RUN_INFO_HPP_INCLUDED + + +namespace Catch { + + struct TestRunInfo { + constexpr TestRunInfo(StringRef _name) : name(_name) {} + StringRef name; + }; + +} // end namespace Catch + +#endif // CATCH_TEST_RUN_INFO_HPP_INCLUDED + +#include +#include +#include +#include + +namespace Catch { + + struct ReporterDescription; + struct ListenerDescription; + struct TagInfo; + struct TestCaseInfo; + class TestCaseHandle; + class IConfig; + class IStream; + enum class ColourMode : std::uint8_t; + + struct ReporterConfig { + ReporterConfig( IConfig const* _fullConfig, + Detail::unique_ptr _stream, + ColourMode colourMode, + std::map customOptions ); + + ReporterConfig( ReporterConfig&& ) = default; + ReporterConfig& operator=( ReporterConfig&& ) = default; + ~ReporterConfig(); // = default + + Detail::unique_ptr takeStream() &&; + IConfig const* fullConfig() const; + ColourMode colourMode() const; + std::map const& customOptions() const; + + private: + Detail::unique_ptr m_stream; + IConfig const* m_fullConfig; + ColourMode m_colourMode; + std::map m_customOptions; + }; + + struct AssertionStats { + AssertionStats( AssertionResult const& _assertionResult, + std::vector const& _infoMessages, + Totals const& _totals ); + + AssertionStats( AssertionStats const& ) = default; + AssertionStats( AssertionStats && ) = default; + AssertionStats& operator = ( AssertionStats const& ) = delete; + AssertionStats& operator = ( AssertionStats && ) = delete; + + AssertionResult assertionResult; + std::vector infoMessages; + Totals totals; + }; + + struct SectionStats { + SectionStats( SectionInfo&& _sectionInfo, + Counts const& _assertions, + double _durationInSeconds, + bool _missingAssertions ); + + SectionInfo sectionInfo; + Counts assertions; + double durationInSeconds; + bool missingAssertions; + }; + + struct TestCaseStats { + TestCaseStats( TestCaseInfo const& _testInfo, + Totals const& _totals, + std::string&& _stdOut, + std::string&& _stdErr, + bool _aborting ); + + TestCaseInfo const * testInfo; + Totals totals; + std::string stdOut; + std::string stdErr; + bool aborting; + }; + + struct TestRunStats { + TestRunStats( TestRunInfo const& _runInfo, + Totals const& _totals, + bool _aborting ); + + TestRunInfo runInfo; + Totals totals; + bool aborting; + }; + + //! By setting up its preferences, a reporter can modify Catch2's behaviour + //! in some regards, e.g. it can request Catch2 to capture writes to + //! stdout/stderr during test execution, and pass them to the reporter. + struct ReporterPreferences { + //! Catch2 should redirect writes to stdout and pass them to the + //! reporter + bool shouldRedirectStdOut = false; + //! Catch2 should call `Reporter::assertionEnded` even for passing + //! assertions + bool shouldReportAllAssertions = false; + }; + + /** + * The common base for all reporters and event listeners + * + * Implementing classes must also implement: + * + * //! User-friendly description of the reporter/listener type + * static std::string getDescription() + * + * Generally shouldn't be derived from by users of Catch2 directly, + * instead they should derive from one of the utility bases that + * derive from this class. + */ + class IEventListener { + protected: + //! Derived classes can set up their preferences here + ReporterPreferences m_preferences; + //! The test run's config as filled in from CLI and defaults + IConfig const* m_config; + + public: + IEventListener( IConfig const* config ): m_config( config ) {} + + virtual ~IEventListener(); // = default; + + // Implementing class must also provide the following static methods: + // static std::string getDescription(); + + ReporterPreferences const& getPreferences() const { + return m_preferences; + } + + //! Called when no test cases match provided test spec + virtual void noMatchingTestCases( StringRef unmatchedSpec ) = 0; + //! Called for all invalid test specs from the cli + virtual void reportInvalidTestSpec( StringRef invalidArgument ) = 0; + + /** + * Called once in a testing run before tests are started + * + * Not called if tests won't be run (e.g. only listing will happen) + */ + virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; + + //! Called _once_ for each TEST_CASE, no matter how many times it is entered + virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0; + //! Called _every time_ a TEST_CASE is entered, including repeats (due to sections) + virtual void testCasePartialStarting( TestCaseInfo const& testInfo, uint64_t partNumber ) = 0; + //! Called when a `SECTION` is being entered. Not called for skipped sections + virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0; + + //! Called when user-code is being probed before the actual benchmark runs + virtual void benchmarkPreparing( StringRef benchmarkName ) = 0; + //! Called after probe but before the user-code is being benchmarked + virtual void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) = 0; + //! Called with the benchmark results if benchmark successfully finishes + virtual void benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) = 0; + //! Called if running the benchmarks fails for any reason + virtual void benchmarkFailed( StringRef benchmarkName ) = 0; + //! Called before assertion success/failure is evaluated + virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0; -#endif // CATCH_GENERATORS_RANGE_HPP_INCLUDED + //! Called after assertion was fully evaluated + virtual void assertionEnded( AssertionStats const& assertionStats ) = 0; -#endif // CATCH_GENERATORS_ALL_HPP_INCLUDED + //! Called after a `SECTION` has finished running + virtual void sectionEnded( SectionStats const& sectionStats ) = 0; + //! Called _every time_ a TEST_CASE is entered, including repeats (due to sections) + virtual void testCasePartialEnded(TestCaseStats const& testCaseStats, uint64_t partNumber ) = 0; + //! Called _once_ for each TEST_CASE, no matter how many times it is entered + virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0; + /** + * Called once after all tests in a testing run are finished + * + * Not called if tests weren't run (e.g. only listings happened) + */ + virtual void testRunEnded( TestRunStats const& testRunStats ) = 0; + /** + * Called with test cases that are skipped due to the test run aborting. + * NOT called for test cases that are explicitly skipped using the `SKIP` macro. + * + * Deprecated - will be removed in the next major release. + */ + virtual void skipTest( TestCaseInfo const& testInfo ) = 0; -/** \file - * This is a convenience header for Catch2's interfaces. It includes - * **all** of Catch2 headers related to interfaces. - * - * Generally the Catch2 users should use specific includes they need, - * but this header can be used instead for ease-of-experimentation, or - * just plain convenience, at the cost of somewhat increased compilation - * times. - * - * When a new header is added to either the `interfaces` folder, or to - * the corresponding internal subfolder, it should be added here. - */ + //! Called if a fatal error (signal/structured exception) occurred + virtual void fatalErrorEncountered( StringRef error ) = 0; + //! Writes out information about provided reporters using reporter-specific format + virtual void listReporters(std::vector const& descriptions) = 0; + //! Writes out the provided listeners descriptions using reporter-specific format + virtual void listListeners(std::vector const& descriptions) = 0; + //! Writes out information about provided tests using reporter-specific format + virtual void listTests(std::vector const& tests) = 0; + //! Writes out information about the provided tags using reporter-specific format + virtual void listTags(std::vector const& tags) = 0; + }; + using IEventListenerPtr = Detail::unique_ptr; -#ifndef CATCH_INTERFACES_ALL_HPP_INCLUDED -#define CATCH_INTERFACES_ALL_HPP_INCLUDED +} // end namespace Catch +#endif // CATCH_INTERFACES_REPORTER_HPP_INCLUDED #ifndef CATCH_INTERFACES_REPORTER_FACTORY_HPP_INCLUDED @@ -8337,89 +8830,79 @@ namespace Catch { #endif // CATCH_INTERFACES_REPORTER_FACTORY_HPP_INCLUDED -#ifndef CATCH_INTERFACES_REPORTER_REGISTRY_HPP_INCLUDED -#define CATCH_INTERFACES_REPORTER_REGISTRY_HPP_INCLUDED +#ifndef CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED +#define CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED +#include +namespace Catch { -#ifndef CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED -#define CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED + struct TagAlias; + class ITagAliasRegistry { + public: + virtual ~ITagAliasRegistry(); // = default + // Nullptr if not present + virtual TagAlias const* find( std::string const& alias ) const = 0; + virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const = 0; -namespace Catch { - namespace Detail { - //! Provides case-insensitive `op<` semantics when called - struct CaseInsensitiveLess { - bool operator()( StringRef lhs, - StringRef rhs ) const; - }; + static ITagAliasRegistry const& get(); + }; - //! Provides case-insensitive `op==` semantics when called - struct CaseInsensitiveEqualTo { - bool operator()( StringRef lhs, - StringRef rhs ) const; - }; +} // end namespace Catch - } // namespace Detail -} // namespace Catch +#endif // CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED -#endif // CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED -#include +#ifndef CATCH_INTERFACES_TESTCASE_HPP_INCLUDED +#define CATCH_INTERFACES_TESTCASE_HPP_INCLUDED + #include -#include namespace Catch { + struct TestCaseInfo; + class TestCaseHandle; class IConfig; - class IEventListener; - using IEventListenerPtr = Detail::unique_ptr; - class IReporterFactory; - using IReporterFactoryPtr = Detail::unique_ptr; - struct ReporterConfig; - class EventListenerFactory; - - class IReporterRegistry { + class ITestCaseRegistry { public: - using FactoryMap = std::map; - using Listeners = std::vector>; - - virtual ~IReporterRegistry(); // = default - virtual IEventListenerPtr create( std::string const& name, ReporterConfig&& config ) const = 0; - virtual FactoryMap const& getFactories() const = 0; - virtual Listeners const& getListeners() const = 0; + virtual ~ITestCaseRegistry(); // = default + // TODO: this exists only for adding filenames to test cases -- let's expose this in a saner way later + virtual std::vector const& getAllInfos() const = 0; + virtual std::vector const& getAllTests() const = 0; + virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0; }; -} // end namespace Catch - -#endif // CATCH_INTERFACES_REPORTER_REGISTRY_HPP_INCLUDED - +} -#ifndef CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED -#define CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED +#endif // CATCH_INTERFACES_TESTCASE_HPP_INCLUDED -#include +#endif // CATCH_INTERFACES_ALL_HPP_INCLUDED -namespace Catch { - struct TagAlias; +#ifndef CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED +#define CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED - class ITagAliasRegistry { - public: - virtual ~ITagAliasRegistry(); // = default - // Nullptr if not present - virtual TagAlias const* find( std::string const& alias ) const = 0; - virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const = 0; - static ITagAliasRegistry const& get(); - }; +namespace Catch { + namespace Detail { + //! Provides case-insensitive `op<` semantics when called + struct CaseInsensitiveLess { + bool operator()( StringRef lhs, + StringRef rhs ) const; + }; -} // end namespace Catch + //! Provides case-insensitive `op==` semantics when called + struct CaseInsensitiveEqualTo { + bool operator()( StringRef lhs, + StringRef rhs ) const; + }; -#endif // CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED + } // namespace Detail +} // namespace Catch -#endif // CATCH_INTERFACES_ALL_HPP_INCLUDED +#endif // CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED @@ -8446,46 +8929,182 @@ namespace Catch { # define CATCH_CONFIG_ANDROID_LOGWRITE #endif -#endif // CATCH_CONFIG_ANDROID_LOGWRITE_HPP_INCLUDED +#endif // CATCH_CONFIG_ANDROID_LOGWRITE_HPP_INCLUDED + + + +/** \file + * Wrapper for UNCAUGHT_EXCEPTIONS configuration option + * + * For some functionality, Catch2 requires to know whether there is + * an active exception. Because `std::uncaught_exception` is deprecated + * in C++17, we want to use `std::uncaught_exceptions` if possible. + */ + +#ifndef CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED +#define CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED + + +#if defined(_MSC_VER) +# if _MSC_VER >= 1900 // Visual Studio 2015 or newer +# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS +# endif +#endif + + +#include + +#if defined(__cpp_lib_uncaught_exceptions) \ + && !defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) + +# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS +#endif // __cpp_lib_uncaught_exceptions + + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) \ + && !defined(CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) \ + && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) + +# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS +#endif + + +#endif // CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED + + +#ifndef CATCH_CONSOLE_COLOUR_HPP_INCLUDED +#define CATCH_CONSOLE_COLOUR_HPP_INCLUDED + + +#include +#include + +namespace Catch { + + enum class ColourMode : std::uint8_t; + class IStream; + + struct Colour { + enum Code { + None = 0, + + White, + Red, + Green, + Blue, + Cyan, + Yellow, + Grey, + + Bright = 0x10, + + BrightRed = Bright | Red, + BrightGreen = Bright | Green, + LightGrey = Bright | Grey, + BrightWhite = Bright | White, + BrightYellow = Bright | Yellow, + + // By intention + FileName = LightGrey, + Warning = BrightYellow, + ResultError = BrightRed, + ResultSuccess = BrightGreen, + ResultExpectedFailure = Warning, + + Error = BrightRed, + Success = Green, + Skip = LightGrey, + + OriginalExpression = Cyan, + ReconstructedExpression = BrightYellow, + + SecondaryText = LightGrey, + Headers = White + }; + }; + + class ColourImpl { + protected: + //! The associated stream of this ColourImpl instance + IStream* m_stream; + public: + ColourImpl( IStream* stream ): m_stream( stream ) {} + + //! RAII wrapper around writing specific colour of text using specific + //! colour impl into a stream. + class ColourGuard { + ColourImpl const* m_colourImpl; + Colour::Code m_code; + bool m_engaged = false; + public: + //! Does **not** engage the guard/start the colour + ColourGuard( Colour::Code code, + ColourImpl const* colour ); + ColourGuard( ColourGuard const& rhs ) = delete; + ColourGuard& operator=( ColourGuard const& rhs ) = delete; -/** \file - * Wrapper for UNCAUGHT_EXCEPTIONS configuration option - * - * For some functionality, Catch2 requires to know whether there is - * an active exception. Because `std::uncaught_exception` is deprecated - * in C++17, we want to use `std::uncaught_exceptions` if possible. - */ + ColourGuard( ColourGuard&& rhs ) noexcept; + ColourGuard& operator=( ColourGuard&& rhs ) noexcept; -#ifndef CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED -#define CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED + //! Removes colour _if_ the guard was engaged + ~ColourGuard(); -#if defined(_MSC_VER) -# if _MSC_VER >= 1900 // Visual Studio 2015 or newer -# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS -# endif -#endif + /** + * Explicitly engages colour for given stream. + * + * The API based on operator<< should be preferred. + */ + ColourGuard& engage( std::ostream& stream ) &; + /** + * Explicitly engages colour for given stream. + * + * The API based on operator<< should be preferred. + */ + ColourGuard&& engage( std::ostream& stream ) &&; + private: + //! Engages the guard and starts using colour + friend std::ostream& operator<<( std::ostream& lhs, + ColourGuard& guard ) { + guard.engageImpl( lhs ); + return lhs; + } + //! Engages the guard and starts using colour + friend std::ostream& operator<<( std::ostream& lhs, + ColourGuard&& guard) { + guard.engageImpl( lhs ); + return lhs; + } -#include + void engageImpl( std::ostream& stream ); -#if defined(__cpp_lib_uncaught_exceptions) \ - && !defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) + }; -# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS -#endif // __cpp_lib_uncaught_exceptions + virtual ~ColourImpl(); // = default + /** + * Creates a guard object for given colour and this colour impl + * + * **Important:** + * the guard starts disengaged, and has to be engaged explicitly. + */ + ColourGuard guardColour( Colour::Code colourCode ); + private: + virtual void use( Colour::Code colourCode ) const = 0; + }; -#if defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) \ - && !defined(CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) \ - && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) + //! Provides ColourImpl based on global config and target compilation platform + Detail::unique_ptr makeColourImpl( ColourMode colourSelection, + IStream* stream ); -# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS -#endif + //! Checks if specific colour impl has been compiled into the binary + bool isColourImplAvailable( ColourMode colourSelection ); +} // end namespace Catch -#endif // CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED +#endif // CATCH_CONSOLE_COLOUR_HPP_INCLUDED #ifndef CATCH_CONSOLE_WIDTH_HPP_INCLUDED @@ -8751,7 +9370,6 @@ namespace Catch { ~ExceptionTranslatorRegistry() override; void registerTranslator( Detail::unique_ptr&& translator ); std::string translateActiveException() const override; - std::string tryTranslators() const; private: ExceptionTranslators m_translators; @@ -8764,7 +9382,6 @@ namespace Catch { #ifndef CATCH_FATAL_CONDITION_HANDLER_HPP_INCLUDED #define CATCH_FATAL_CONDITION_HANDLER_HPP_INCLUDED - #include namespace Catch { @@ -8827,17 +9444,6 @@ namespace Catch { #define CATCH_FLOATING_POINT_HELPERS_HPP_INCLUDED - -#ifndef CATCH_POLYFILLS_HPP_INCLUDED -#define CATCH_POLYFILLS_HPP_INCLUDED - -namespace Catch { - bool isnan(float f); - bool isnan(double d); -} - -#endif // CATCH_POLYFILLS_HPP_INCLUDED - #include #include #include @@ -8850,6 +9456,11 @@ namespace Catch { uint32_t convertToBits(float f); uint64_t convertToBits(double d); + // Used when we know we want == comparison of two doubles + // to centralize warning suppression + bool directCompare( float lhs, float rhs ); + bool directCompare( double lhs, double rhs ); + } // end namespace Detail @@ -9126,6 +9737,119 @@ namespace Catch { #endif // CATCH_STREAM_HPP_INCLUDED +#ifndef CATCH_JSONWRITER_HPP_INCLUDED +#define CATCH_JSONWRITER_HPP_INCLUDED + + +#include +#include + +namespace Catch { + class JsonObjectWriter; + class JsonArrayWriter; + + struct JsonUtils { + static void indent( std::ostream& os, std::uint64_t level ); + static void appendCommaNewline( std::ostream& os, + bool& should_comma, + std::uint64_t level ); + }; + + class JsonValueWriter { + public: + JsonValueWriter( std::ostream& os ); + JsonValueWriter( std::ostream& os, std::uint64_t indent_level ); + + JsonObjectWriter writeObject() &&; + JsonArrayWriter writeArray() &&; + + template + void write( T const& value ) && { + writeImpl( value, !std::is_arithmetic::value ); + } + void write( StringRef value ) &&; + void write( bool value ) &&; + + private: + void writeImpl( StringRef value, bool quote ); + + // Without this SFINAE, this overload is a better match + // for `std::string`, `char const*`, `char const[N]` args. + // While it would still work, it would cause code bloat + // and multiple iteration over the strings + template ::value>> + void writeImpl( T const& value, bool quote_value ) { + m_sstream << value; + writeImpl( m_sstream.str(), quote_value ); + } + + std::ostream& m_os; + std::stringstream m_sstream; + std::uint64_t m_indent_level; + }; + + class JsonObjectWriter { + public: + JsonObjectWriter( std::ostream& os ); + JsonObjectWriter( std::ostream& os, std::uint64_t indent_level ); + + JsonObjectWriter( JsonObjectWriter&& source ); + JsonObjectWriter& operator=( JsonObjectWriter&& source ) = delete; + + ~JsonObjectWriter(); + + JsonValueWriter write( StringRef key ); + + private: + std::ostream& m_os; + std::uint64_t m_indent_level; + bool m_should_comma = false; + bool m_active = true; + }; + + class JsonArrayWriter { + public: + JsonArrayWriter( std::ostream& os ); + JsonArrayWriter( std::ostream& os, std::uint64_t indent_level ); + + JsonArrayWriter( JsonArrayWriter&& source ); + JsonArrayWriter& operator=( JsonArrayWriter&& source ) = delete; + + ~JsonArrayWriter(); + + JsonObjectWriter writeObject(); + JsonArrayWriter writeArray(); + + template + JsonArrayWriter& write( T const& value ) { + return writeImpl( value ); + } + + JsonArrayWriter& write( bool value ); + + private: + template + JsonArrayWriter& writeImpl( T const& value ) { + JsonUtils::appendCommaNewline( + m_os, m_should_comma, m_indent_level + 1 ); + JsonValueWriter{ m_os }.write( value ); + + return *this; + } + + std::ostream& m_os; + std::uint64_t m_indent_level; + bool m_should_comma = false; + bool m_active = true; + }; + +} // namespace Catch + +#endif // CATCH_JSONWRITER_HPP_INCLUDED + + #ifndef CATCH_LEAK_DETECTOR_HPP_INCLUDED #define CATCH_LEAK_DETECTOR_HPP_INCLUDED @@ -9312,28 +10036,45 @@ namespace Catch { #include +#include +#include namespace Catch { - class ReporterRegistry : public IReporterRegistry { - public: + class IEventListener; + using IEventListenerPtr = Detail::unique_ptr; + class IReporterFactory; + using IReporterFactoryPtr = Detail::unique_ptr; + struct ReporterConfig; + class EventListenerFactory; + + class ReporterRegistry { + struct ReporterRegistryImpl; + Detail::unique_ptr m_impl; + public: ReporterRegistry(); - ~ReporterRegistry() override; // = default, out of line to allow fwd decl + ~ReporterRegistry(); // = default; - IEventListenerPtr create( std::string const& name, ReporterConfig&& config ) const override; + IEventListenerPtr create( std::string const& name, + ReporterConfig&& config ) const; - void registerReporter( std::string const& name, IReporterFactoryPtr factory ); - void registerListener( Detail::unique_ptr factory ); + void registerReporter( std::string const& name, + IReporterFactoryPtr factory ); - FactoryMap const& getFactories() const override; - Listeners const& getListeners() const override; + void + registerListener( Detail::unique_ptr factory ); - private: - FactoryMap m_factories; - Listeners m_listeners; + std::map const& + getFactories() const; + + std::vector> const& + getListeners() const; }; -} + +} // end namespace Catch #endif // CATCH_REPORTER_REGISTRY_HPP_INCLUDED @@ -9448,7 +10189,7 @@ namespace TestCaseTracking { //! Returns true if tracker run to completion (successfully or not) virtual bool isComplete() const = 0; - //! Returns true if tracker run to completion succesfully + //! Returns true if tracker run to completion successfully bool isSuccessfullyCompleted() const { return m_runState == CompletedSuccessfully; } @@ -9582,13 +10323,14 @@ using TestCaseTracking::SectionTracker; namespace Catch { - class IMutableContext; class IGeneratorTracker; class IConfig; + class IEventListener; + using IEventListenerPtr = Detail::unique_ptr; /////////////////////////////////////////////////////////////////////////// - class RunContext : public IResultCapture { + class RunContext final : public IResultCapture { public: RunContext( RunContext const& ) = delete; @@ -9617,7 +10359,7 @@ namespace Catch { AssertionReaction& reaction ) override; void handleUnexpectedInflightException ( AssertionInfo const& info, - std::string const& message, + std::string&& message, AssertionReaction& reaction ) override; void handleIncomplete ( AssertionInfo const& info ) override; @@ -9626,6 +10368,7 @@ namespace Catch { ResultWas::OfType resultType, AssertionReaction &reaction ) override; + void notifyAssertionStarted( AssertionInfo const& info ) override; bool sectionStarted( StringRef sectionName, SourceLineInfo const& sectionLineInfo, Counts& assertions ) override; @@ -9676,7 +10419,7 @@ namespace Catch { void resetAssertionInfo(); bool testForMissingAssertions( Counts& assertions ); - void assertionEnded( AssertionResult const& result ); + void assertionEnded( AssertionResult&& result ); void reportExpr ( AssertionInfo const &info, ResultWas::OfType resultType, @@ -9690,7 +10433,6 @@ namespace Catch { void handleUnfinishedSections(); TestRunInfo m_runInfo; - IMutableContext& m_context; TestCaseHandle const* m_activeTestCase = nullptr; ITracker* m_testCaseTracker = nullptr; Optional m_lastResult; @@ -9720,7 +10462,7 @@ namespace Catch { #ifndef CATCH_SHARDING_HPP_INCLUDED #define CATCH_SHARDING_HPP_INCLUDED - +#include #include #include @@ -9947,24 +10689,20 @@ namespace Catch { namespace Catch { - class TestCaseHandle; class IConfig; + class ITestInvoker; + class TestCaseHandle; class TestSpec; std::vector sortTests( IConfig const& config, std::vector const& unsortedTestCases ); bool isThrowSafe( TestCaseHandle const& testCase, IConfig const& config ); - bool matchTest( TestCaseHandle const& testCase, TestSpec const& testSpec, IConfig const& config ); - - void enforceNoDuplicateTestCases( std::vector const& functions ); std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); std::vector const& getAllTestCasesSorted( IConfig const& config ); class TestRegistry : public ITestCaseRegistry { public: - ~TestRegistry() override = default; - void registerTest( Detail::unique_ptr testInfo, Detail::unique_ptr testInvoker ); std::vector const& getAllInfos() const override; @@ -9985,18 +10723,6 @@ namespace Catch { /////////////////////////////////////////////////////////////////////////// - class TestInvokerAsFunction final : public ITestInvoker { - using TestType = void(*)(); - TestType m_testAsFunction; - public: - TestInvokerAsFunction(TestType testAsFunction) noexcept: - m_testAsFunction(testAsFunction) {} - - void invoke() const override; - }; - - /////////////////////////////////////////////////////////////////////////// - } // end namespace Catch @@ -10082,6 +10808,7 @@ namespace Catch { #ifndef CATCH_TEXTFLOW_HPP_INCLUDED #define CATCH_TEXTFLOW_HPP_INCLUDED + #include #include #include @@ -10110,7 +10837,7 @@ namespace Catch { public: /** - * Iterates "lines" in `Column` and return sthem + * Iterates "lines" in `Column` and returns them */ class const_iterator { friend Column; @@ -10132,7 +10859,7 @@ namespace Catch { // Calculates the length of the current line void calcLength(); - // Returns current indention width + // Returns current indentation width size_t indentSize() const; // Creates an indented and (optionally) suffixed string from @@ -10164,20 +10891,35 @@ namespace Catch { using iterator = const_iterator; explicit Column( std::string const& text ): m_string( text ) {} + explicit Column( std::string&& text ): + m_string( CATCH_MOVE(text)) {} - Column& width( size_t newWidth ) { + Column& width( size_t newWidth ) & { assert( newWidth > 0 ); m_width = newWidth; return *this; } - Column& indent( size_t newIndent ) { + Column&& width( size_t newWidth ) && { + assert( newWidth > 0 ); + m_width = newWidth; + return CATCH_MOVE( *this ); + } + Column& indent( size_t newIndent ) & { m_indent = newIndent; return *this; } - Column& initialIndent( size_t newIndent ) { + Column&& indent( size_t newIndent ) && { + m_indent = newIndent; + return CATCH_MOVE( *this ); + } + Column& initialIndent( size_t newIndent ) & { m_initialIndent = newIndent; return *this; } + Column&& initialIndent( size_t newIndent ) && { + m_initialIndent = newIndent; + return CATCH_MOVE( *this ); + } size_t width() const { return m_width; } const_iterator begin() const { return const_iterator( *this ); } @@ -10186,7 +10928,8 @@ namespace Catch { friend std::ostream& operator<<( std::ostream& os, Column const& col ); - Columns operator+( Column const& other ); + friend Columns operator+( Column const& lhs, Column const& rhs ); + friend Columns operator+( Column&& lhs, Column&& rhs ); }; //! Creates a column that serves as an empty space of specific width @@ -10230,8 +10973,10 @@ namespace Catch { iterator begin() const { return iterator( *this ); } iterator end() const { return { *this, iterator::EndTag() }; } - Columns& operator+=( Column const& col ); - Columns operator+( Column const& col ); + friend Columns& operator+=( Columns& lhs, Column const& rhs ); + friend Columns& operator+=( Columns& lhs, Column&& rhs ); + friend Columns operator+( Columns const& lhs, Column const& rhs ); + friend Columns operator+( Columns&& lhs, Column&& rhs ); friend std::ostream& operator<<( std::ostream& os, Columns const& cols ); @@ -10445,6 +11190,8 @@ namespace Catch { #define CATCH_MATCHERS_IMPL_HPP_INCLUDED +#include + namespace Catch { template @@ -11680,7 +12427,7 @@ namespace Catch { /** * Creates a matcher that checks if all elements in a range are equal - * to all elements in another range, in some permuation. + * to all elements in another range, in some permutation. * * Uses to provided predicate `predicate` to do the comparisons */ @@ -11850,11 +12597,10 @@ namespace Matchers { // - a more general approach would be via a compare template that defaults // to using !=. but could be specialised for, e.g. std::vector etc // - then just call that directly - if (m_comparator.size() != v.size()) - return false; - for (std::size_t i = 0; i < v.size(); ++i) - if (m_comparator[i] != v[i]) - return false; + if ( m_comparator.size() != v.size() ) { return false; } + for ( std::size_t i = 0; i < v.size(); ++i ) { + if ( !( m_comparator[i] == v[i] ) ) { return false; } + } return true; } std::string describe() const override { @@ -12358,7 +13104,7 @@ namespace Catch { void skipTest(TestCaseInfo const&) override {} protected: - //! Should the cumulative base store the assertion expansion for succesful assertions? + //! Should the cumulative base store the assertion expansion for successful assertions? bool m_shouldStoreSuccesfulAssertions = true; //! Should the cumulative base store the assertion expansion for failed assertions? bool m_shouldStoreFailedAssertions = true; @@ -12526,6 +13272,93 @@ namespace Catch { #endif // CATCH_REPORTER_HELPERS_HPP_INCLUDED + +#ifndef CATCH_REPORTER_JSON_HPP_INCLUDED +#define CATCH_REPORTER_JSON_HPP_INCLUDED + + +#include + +namespace Catch { + class JsonReporter : public StreamingReporterBase { + public: + JsonReporter( ReporterConfig&& config ); + + ~JsonReporter() override; + + static std::string getDescription(); + + public: // StreamingReporterBase + void testRunStarting( TestRunInfo const& runInfo ) override; + void testRunEnded( TestRunStats const& runStats ) override; + + void testCaseStarting( TestCaseInfo const& tcInfo ) override; + void testCaseEnded( TestCaseStats const& tcStats ) override; + + void testCasePartialStarting( TestCaseInfo const& tcInfo, + uint64_t index ) override; + void testCasePartialEnded( TestCaseStats const& tcStats, + uint64_t index ) override; + + void sectionStarting( SectionInfo const& sectionInfo ) override; + void sectionEnded( SectionStats const& sectionStats ) override; + + void assertionStarting( AssertionInfo const& assertionInfo ) override; + void assertionEnded( AssertionStats const& assertionStats ) override; + + //void testRunEndedCumulative() override; + + void benchmarkPreparing( StringRef name ) override; + void benchmarkStarting( BenchmarkInfo const& ) override; + void benchmarkEnded( BenchmarkStats<> const& ) override; + void benchmarkFailed( StringRef error ) override; + + void listReporters( + std::vector const& descriptions ) override; + void listListeners( + std::vector const& descriptions ) override; + void listTests( std::vector const& tests ) override; + void listTags( std::vector const& tags ) override; + + private: + Timer m_testCaseTimer; + enum class Writer { + Object, + Array + }; + + JsonArrayWriter& startArray(); + JsonArrayWriter& startArray( StringRef key ); + + JsonObjectWriter& startObject(); + JsonObjectWriter& startObject( StringRef key ); + + void endObject(); + void endArray(); + + bool isInside( Writer writer ); + + void startListing(); + void endListing(); + + // Invariant: + // When m_writers is not empty and its top element is + // - Writer::Object, then m_objectWriters is not be empty + // - Writer::Array, then m_arrayWriters shall not be empty + std::stack m_objectWriters{}; + std::stack m_arrayWriters{}; + std::stack m_writers{}; + + bool m_startedListing = false; + + // std::size_t m_sectionDepth = 0; + // std::size_t m_sectionStarted = 0; + }; +} // namespace Catch + +#endif // CATCH_REPORTER_JSON_HPP_INCLUDED + + #ifndef CATCH_REPORTER_JUNIT_HPP_INCLUDED #define CATCH_REPORTER_JUNIT_HPP_INCLUDED @@ -12537,8 +13370,6 @@ namespace Catch { public: JunitReporter(ReporterConfig&& _config); - ~JunitReporter() override = default; - static std::string getDescription(); void testRunStarting(TestRunInfo const& runInfo) override; @@ -12665,7 +13496,8 @@ namespace Catch { //! independent on the reporter's concrete type void registerReporterImpl( std::string const& name, IReporterFactoryPtr reporterPtr ); - + //! Actually registers the factory, independent on listener's concrete type + void registerListenerImpl( Detail::unique_ptr listenerFactory ); } // namespace Detail class IEventListener; @@ -12726,7 +13558,7 @@ namespace Catch { public: ListenerRegistrar(StringRef listenerName) { - getMutableRegistryHub().registerListener( Detail::make_unique(listenerName) ); + registerListenerImpl( Detail::make_unique(listenerName) ); } }; } @@ -12778,8 +13610,6 @@ namespace Catch { m_shouldStoreSuccesfulAssertions = false; } - ~SonarQubeReporter() override = default; - static std::string getDescription() { using namespace std::string_literals; return "Reports test results in the Generic Test Data SonarQube XML format"s; @@ -12826,7 +13656,6 @@ namespace Catch { StreamingReporterBase( CATCH_MOVE(config) ) { m_preferences.shouldReportAllAssertions = true; } - ~TAPReporter() override = default; static std::string getDescription() { using namespace std::string_literals; diff --git a/external_imported/Catch2/fuzzing/NullOStream.cpp b/external_imported/Catch2/fuzzing/NullOStream.cpp index 53e0893dc..e3a181e80 100644 --- a/external_imported/Catch2/fuzzing/NullOStream.cpp +++ b/external_imported/Catch2/fuzzing/NullOStream.cpp @@ -1,3 +1,11 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + #include "NullOStream.h" void NullOStream::avoidOutOfLineVirtualCompilerWarning() diff --git a/external_imported/Catch2/fuzzing/NullOStream.h b/external_imported/Catch2/fuzzing/NullOStream.h index e1fe15b08..abbec09c8 100644 --- a/external_imported/Catch2/fuzzing/NullOStream.h +++ b/external_imported/Catch2/fuzzing/NullOStream.h @@ -1,3 +1,11 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + #pragma once #include diff --git a/external_imported/Catch2/fuzzing/fuzz_TestSpecParser.cpp b/external_imported/Catch2/fuzzing/fuzz_TestSpecParser.cpp index af4de4062..3aba8c840 100644 --- a/external_imported/Catch2/fuzzing/fuzz_TestSpecParser.cpp +++ b/external_imported/Catch2/fuzzing/fuzz_TestSpecParser.cpp @@ -1,4 +1,10 @@ -//License: Boost 1.0 + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 //By Paul Dreik 2020 #include diff --git a/external_imported/Catch2/fuzzing/fuzz_XmlWriter.cpp b/external_imported/Catch2/fuzzing/fuzz_XmlWriter.cpp index f8e5a0d9a..70c4ed803 100644 --- a/external_imported/Catch2/fuzzing/fuzz_XmlWriter.cpp +++ b/external_imported/Catch2/fuzzing/fuzz_XmlWriter.cpp @@ -1,4 +1,10 @@ -//License: Boost 1.0 + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 //By Paul Dreik 2020 #include diff --git a/external_imported/Catch2/fuzzing/fuzz_textflow.cpp b/external_imported/Catch2/fuzzing/fuzz_textflow.cpp index eafe79feb..7000f420f 100644 --- a/external_imported/Catch2/fuzzing/fuzz_textflow.cpp +++ b/external_imported/Catch2/fuzzing/fuzz_textflow.cpp @@ -1,4 +1,10 @@ -//License: Boost 1.0 + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 //By Paul Dreik 2020 #include diff --git a/external_imported/Catch2/meson.build b/external_imported/Catch2/meson.build index 1faca35f7..0a897520d 100644 --- a/external_imported/Catch2/meson.build +++ b/external_imported/Catch2/meson.build @@ -8,10 +8,12 @@ project( 'catch2', 'cpp', - version: '3.3.2', # CML version placeholder, don't delete + version: '3.5.2', # CML version placeholder, don't delete license: 'BSL-1.0', - meson_version: '>=0.50.0', + meson_version: '>=0.54.1', ) subdir('src/catch2') -subdir('tests') +if get_option('tests') + subdir('tests') +endif diff --git a/external_imported/Catch2/meson_options.txt b/external_imported/Catch2/meson_options.txt new file mode 100644 index 000000000..769048735 --- /dev/null +++ b/external_imported/Catch2/meson_options.txt @@ -0,0 +1 @@ +option('tests', type: 'boolean', value: true, description: 'Build the unit tests') diff --git a/external_imported/Catch2/src/CMakeLists.txt b/external_imported/Catch2/src/CMakeLists.txt index fd05dbdde..eb805ddd0 100644 --- a/external_imported/Catch2/src/CMakeLists.txt +++ b/external_imported/Catch2/src/CMakeLists.txt @@ -21,6 +21,8 @@ set(BENCHMARK_HEADERS ${SOURCES_DIR}/benchmark/catch_sample_analysis.hpp ${SOURCES_DIR}/benchmark/detail/catch_analyse.hpp ${SOURCES_DIR}/benchmark/detail/catch_benchmark_function.hpp + ${SOURCES_DIR}/benchmark/detail/catch_benchmark_stats.hpp + ${SOURCES_DIR}/benchmark/detail/catch_benchmark_stats_fwd.hpp ${SOURCES_DIR}/benchmark/detail/catch_complete_invoke.hpp ${SOURCES_DIR}/benchmark/detail/catch_estimate_clock.hpp ${SOURCES_DIR}/benchmark/detail/catch_measure.hpp @@ -31,6 +33,7 @@ set(BENCHMARK_HEADERS ) set(BENCHMARK_SOURCES ${SOURCES_DIR}/benchmark/catch_chronometer.cpp + ${SOURCES_DIR}/benchmark/detail/catch_analyse.cpp ${SOURCES_DIR}/benchmark/detail/catch_benchmark_function.cpp ${SOURCES_DIR}/benchmark/detail/catch_run_for_at_least.cpp ${SOURCES_DIR}/benchmark/detail/catch_stats.cpp @@ -71,6 +74,7 @@ set(IMPL_HEADERS ${SOURCES_DIR}/internal/catch_compiler_capabilities.hpp ${SOURCES_DIR}/internal/catch_config_android_logwrite.hpp ${SOURCES_DIR}/internal/catch_config_counter.hpp + ${SOURCES_DIR}/internal/catch_config_static_analysis_support.hpp ${SOURCES_DIR}/internal/catch_config_uncaught_exceptions.hpp ${SOURCES_DIR}/internal/catch_config_wchar.hpp ${SOURCES_DIR}/internal/catch_console_colour.hpp @@ -89,6 +93,7 @@ set(IMPL_HEADERS ${SOURCES_DIR}/internal/catch_getenv.hpp ${SOURCES_DIR}/internal/catch_istream.hpp ${SOURCES_DIR}/internal/catch_is_permutation.hpp + ${SOURCES_DIR}/internal/catch_jsonwriter.hpp ${SOURCES_DIR}/internal/catch_lazy_expr.hpp ${SOURCES_DIR}/internal/catch_leak_detector.hpp ${SOURCES_DIR}/internal/catch_list.hpp @@ -104,6 +109,8 @@ set(IMPL_HEADERS ${SOURCES_DIR}/internal/catch_polyfills.hpp ${SOURCES_DIR}/internal/catch_preprocessor.hpp ${SOURCES_DIR}/internal/catch_preprocessor_remove_parens.hpp + ${SOURCES_DIR}/internal/catch_random_floating_point_helpers.hpp + ${SOURCES_DIR}/internal/catch_random_integer_helpers.hpp ${SOURCES_DIR}/internal/catch_random_number_generator.hpp ${SOURCES_DIR}/internal/catch_random_seed_generation.hpp ${SOURCES_DIR}/internal/catch_reporter_registry.hpp @@ -128,10 +135,13 @@ set(IMPL_HEADERS ${SOURCES_DIR}/internal/catch_test_failure_exception.hpp ${SOURCES_DIR}/internal/catch_test_macro_impl.hpp ${SOURCES_DIR}/internal/catch_test_registry.hpp + ${SOURCES_DIR}/internal/catch_test_run_info.hpp ${SOURCES_DIR}/internal/catch_test_spec_parser.hpp ${SOURCES_DIR}/internal/catch_textflow.hpp ${SOURCES_DIR}/internal/catch_to_string.hpp ${SOURCES_DIR}/internal/catch_uncaught_exceptions.hpp + ${SOURCES_DIR}/internal/catch_uniform_floating_point_distribution.hpp + ${SOURCES_DIR}/internal/catch_uniform_integer_distribution.hpp ${SOURCES_DIR}/internal/catch_unique_name.hpp ${SOURCES_DIR}/internal/catch_unique_ptr.hpp ${SOURCES_DIR}/internal/catch_void_type.hpp @@ -153,6 +163,7 @@ set(IMPL_SOURCES ${SOURCES_DIR}/catch_timer.cpp ${SOURCES_DIR}/catch_tostring.cpp ${SOURCES_DIR}/catch_totals.cpp + ${SOURCES_DIR}/catch_translate_exception.cpp ${SOURCES_DIR}/catch_version.cpp ${SOURCES_DIR}/internal/catch_assertion_handler.cpp ${SOURCES_DIR}/internal/catch_case_insensitive_comparisons.cpp @@ -171,6 +182,7 @@ set(IMPL_SOURCES ${SOURCES_DIR}/internal/catch_floating_point_helpers.cpp ${SOURCES_DIR}/internal/catch_getenv.cpp ${SOURCES_DIR}/internal/catch_istream.cpp + ${SOURCES_DIR}/internal/catch_jsonwriter.cpp ${SOURCES_DIR}/internal/catch_lazy_expr.cpp ${SOURCES_DIR}/internal/catch_leak_detector.cpp ${SOURCES_DIR}/internal/catch_list.cpp @@ -216,8 +228,8 @@ set(INTERFACE_HEADERS ${SOURCES_DIR}/interfaces/catch_interfaces_registry_hub.hpp ${SOURCES_DIR}/interfaces/catch_interfaces_reporter.hpp ${SOURCES_DIR}/interfaces/catch_interfaces_reporter_factory.hpp - ${SOURCES_DIR}/interfaces/catch_interfaces_reporter_registry.hpp ${SOURCES_DIR}/interfaces/catch_interfaces_tag_alias_registry.hpp + ${SOURCES_DIR}/interfaces/catch_interfaces_test_invoker.hpp ${SOURCES_DIR}/interfaces/catch_interfaces_testcase.hpp ) set(INTERFACE_SOURCES @@ -228,7 +240,6 @@ set(INTERFACE_SOURCES ${SOURCES_DIR}/interfaces/catch_interfaces_registry_hub.cpp ${SOURCES_DIR}/interfaces/catch_interfaces_reporter.cpp ${SOURCES_DIR}/interfaces/catch_interfaces_reporter_factory.cpp - ${SOURCES_DIR}/interfaces/catch_interfaces_reporter_registry.cpp ${SOURCES_DIR}/interfaces/catch_interfaces_testcase.cpp ) set(INTERFACE_FILES ${INTERFACE_HEADERS} ${INTERFACE_SOURCES}) @@ -284,6 +295,7 @@ set(REPORTER_HEADERS ${SOURCES_DIR}/reporters/catch_reporter_cumulative_base.hpp ${SOURCES_DIR}/reporters/catch_reporter_event_listener.hpp ${SOURCES_DIR}/reporters/catch_reporter_helpers.hpp + ${SOURCES_DIR}/reporters/catch_reporter_json.hpp ${SOURCES_DIR}/reporters/catch_reporter_junit.hpp ${SOURCES_DIR}/reporters/catch_reporter_multi.hpp ${SOURCES_DIR}/reporters/catch_reporter_registrars.hpp @@ -302,6 +314,7 @@ set(REPORTER_SOURCES ${SOURCES_DIR}/reporters/catch_reporter_cumulative_base.cpp ${SOURCES_DIR}/reporters/catch_reporter_event_listener.cpp ${SOURCES_DIR}/reporters/catch_reporter_helpers.cpp + ${SOURCES_DIR}/reporters/catch_reporter_json.cpp ${SOURCES_DIR}/reporters/catch_reporter_junit.cpp ${SOURCES_DIR}/reporters/catch_reporter_multi.cpp ${SOURCES_DIR}/reporters/catch_reporter_registrars.cpp @@ -335,7 +348,9 @@ source_group("generated headers" ) add_library(Catch2 ${ALL_FILES}) -add_build_reproducibility_settings(Catch2) +if (CATCH_ENABLE_REPRODUCIBLE_BUILD) + add_build_reproducibility_settings(Catch2) +endif() add_library(Catch2::Catch2 ALIAS Catch2) if (ANDROID) @@ -388,7 +403,9 @@ target_include_directories(Catch2 add_library(Catch2WithMain ${SOURCES_DIR}/internal/catch_main.cpp ) -add_build_reproducibility_settings(Catch2WithMain) +if (CATCH_ENABLE_REPRODUCIBLE_BUILD) + add_build_reproducibility_settings(Catch2WithMain) +endif() add_library(Catch2::Catch2WithMain ALIAS Catch2WithMain) target_link_libraries(Catch2WithMain PUBLIC Catch2) set_target_properties(Catch2WithMain diff --git a/external_imported/Catch2/src/catch2/benchmark/catch_benchmark.hpp b/external_imported/Catch2/src/catch2/benchmark/catch_benchmark.hpp index 1cf10be66..3db40bb04 100644 --- a/external_imported/Catch2/src/catch2/benchmark/catch_benchmark.hpp +++ b/external_imported/Catch2/src/catch2/benchmark/catch_benchmark.hpp @@ -10,26 +10,28 @@ #ifndef CATCH_BENCHMARK_HPP_INCLUDED #define CATCH_BENCHMARK_HPP_INCLUDED -#include +#include #include #include -#include -#include #include -#include +#include +#include +#include +#include +#include +#include #include #include #include #include -#include #include #include #include #include -#include +#include +#include #include -#include #include namespace Catch { @@ -43,16 +45,18 @@ namespace Catch { : fun(CATCH_MOVE(func)), name(CATCH_MOVE(benchmarkName)) {} template - ExecutionPlan> prepare(const IConfig &cfg, Environment> env) const { + ExecutionPlan prepare(const IConfig &cfg, Environment env) const { auto min_time = env.clock_resolution.mean * Detail::minimum_ticks; auto run_time = std::max(min_time, std::chrono::duration_cast(cfg.benchmarkWarmupTime())); - auto&& test = Detail::run_for_at_least(std::chrono::duration_cast>(run_time), 1, fun); + auto&& test = Detail::run_for_at_least(std::chrono::duration_cast(run_time), 1, fun); int new_iters = static_cast(std::ceil(min_time * test.iterations / test.elapsed)); - return { new_iters, test.elapsed / test.iterations * new_iters * cfg.benchmarkSamples(), fun, std::chrono::duration_cast>(cfg.benchmarkWarmupTime()), Detail::warmup_iterations }; + return { new_iters, test.elapsed / test.iterations * new_iters * cfg.benchmarkSamples(), fun, std::chrono::duration_cast(cfg.benchmarkWarmupTime()), Detail::warmup_iterations }; } template void run() { + static_assert( Clock::is_steady, + "Benchmarking clock should be steady" ); auto const* cfg = getCurrentContext().getConfig(); auto env = Detail::measure_environment(); @@ -79,10 +83,10 @@ namespace Catch { return plan.template run(*cfg, env); }); - auto analysis = Detail::analyse(*cfg, env, samples.begin(), samples.end()); - BenchmarkStats> stats{ CATCH_MOVE(info), CATCH_MOVE(analysis.samples), analysis.mean, analysis.standard_deviation, analysis.outliers, analysis.outlier_variance }; + auto analysis = Detail::analyse(*cfg, samples.data(), samples.data() + samples.size()); + BenchmarkStats<> stats{ CATCH_MOVE(info), CATCH_MOVE(analysis.samples), analysis.mean, analysis.standard_deviation, analysis.outliers, analysis.outlier_variance }; getResultCapture().benchmarkEnded(stats); - } CATCH_CATCH_ANON (TestFailureException) { + } CATCH_CATCH_ANON (TestFailureException const&) { getResultCapture().benchmarkFailed("Benchmark failed due to failed assertion"_sr); } CATCH_CATCH_ALL{ getResultCapture().benchmarkFailed(translateActiveException()); diff --git a/external_imported/Catch2/src/catch2/benchmark/catch_benchmark_all.hpp b/external_imported/Catch2/src/catch2/benchmark/catch_benchmark_all.hpp index eb81f2386..56fc7c74c 100644 --- a/external_imported/Catch2/src/catch2/benchmark/catch_benchmark_all.hpp +++ b/external_imported/Catch2/src/catch2/benchmark/catch_benchmark_all.hpp @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/external_imported/Catch2/src/catch2/benchmark/catch_chronometer.hpp b/external_imported/Catch2/src/catch2/benchmark/catch_chronometer.hpp index bce2406b8..95498e6be 100644 --- a/external_imported/Catch2/src/catch2/benchmark/catch_chronometer.hpp +++ b/external_imported/Catch2/src/catch2/benchmark/catch_chronometer.hpp @@ -12,7 +12,6 @@ #include #include -#include #include #include @@ -33,7 +32,10 @@ namespace Catch { void start() override { started = Clock::now(); } void finish() override { finished = Clock::now(); } - ClockDuration elapsed() const { return finished - started; } + IDuration elapsed() const { + return std::chrono::duration_cast( + finished - started ); + } TimePoint started; TimePoint finished; diff --git a/external_imported/Catch2/src/catch2/benchmark/catch_clock.hpp b/external_imported/Catch2/src/catch2/benchmark/catch_clock.hpp index cee46097d..4068c4d29 100644 --- a/external_imported/Catch2/src/catch2/benchmark/catch_clock.hpp +++ b/external_imported/Catch2/src/catch2/benchmark/catch_clock.hpp @@ -11,28 +11,16 @@ #define CATCH_CLOCK_HPP_INCLUDED #include -#include namespace Catch { namespace Benchmark { - template - using ClockDuration = typename Clock::duration; - template - using FloatDuration = std::chrono::duration; + using IDuration = std::chrono::nanoseconds; + using FDuration = std::chrono::duration; template using TimePoint = typename Clock::time_point; using default_clock = std::chrono::steady_clock; - - template - struct now { - TimePoint operator()() const { - return Clock::now(); - } - }; - - using fp_seconds = std::chrono::duration>; } // namespace Benchmark } // namespace Catch diff --git a/external_imported/Catch2/src/catch2/benchmark/catch_environment.hpp b/external_imported/Catch2/src/catch2/benchmark/catch_environment.hpp index de4d77df4..da3f2fa95 100644 --- a/external_imported/Catch2/src/catch2/benchmark/catch_environment.hpp +++ b/external_imported/Catch2/src/catch2/benchmark/catch_environment.hpp @@ -15,21 +15,13 @@ namespace Catch { namespace Benchmark { - template struct EnvironmentEstimate { - Duration mean; + FDuration mean; OutlierClassification outliers; - - template - operator EnvironmentEstimate() const { - return { mean, outliers }; - } }; - template struct Environment { - using clock_type = Clock; - EnvironmentEstimate> clock_resolution; - EnvironmentEstimate> clock_cost; + EnvironmentEstimate clock_resolution; + EnvironmentEstimate clock_cost; }; } // namespace Benchmark } // namespace Catch diff --git a/external_imported/Catch2/src/catch2/benchmark/catch_estimate.hpp b/external_imported/Catch2/src/catch2/benchmark/catch_estimate.hpp index be594a189..64383a2e5 100644 --- a/external_imported/Catch2/src/catch2/benchmark/catch_estimate.hpp +++ b/external_imported/Catch2/src/catch2/benchmark/catch_estimate.hpp @@ -12,17 +12,12 @@ namespace Catch { namespace Benchmark { - template + template struct Estimate { - Duration point; - Duration lower_bound; - Duration upper_bound; + Type point; + Type lower_bound; + Type upper_bound; double confidence_interval; - - template - operator Estimate() const { - return { point, lower_bound, upper_bound, confidence_interval }; - } }; } // namespace Benchmark } // namespace Catch diff --git a/external_imported/Catch2/src/catch2/benchmark/catch_execution_plan.hpp b/external_imported/Catch2/src/catch2/benchmark/catch_execution_plan.hpp index 039de7ee5..17ca589f5 100644 --- a/external_imported/Catch2/src/catch2/benchmark/catch_execution_plan.hpp +++ b/external_imported/Catch2/src/catch2/benchmark/catch_execution_plan.hpp @@ -17,38 +17,38 @@ #include #include -#include -#include +#include namespace Catch { namespace Benchmark { - template struct ExecutionPlan { int iterations_per_sample; - Duration estimated_duration; + FDuration estimated_duration; Detail::BenchmarkFunction benchmark; - Duration warmup_time; + FDuration warmup_time; int warmup_iterations; - template - operator ExecutionPlan() const { - return { iterations_per_sample, estimated_duration, benchmark, warmup_time, warmup_iterations }; - } - template - std::vector> run(const IConfig &cfg, Environment> env) const { + std::vector run(const IConfig &cfg, Environment env) const { // warmup a bit - Detail::run_for_at_least(std::chrono::duration_cast>(warmup_time), warmup_iterations, Detail::repeat(now{})); - - std::vector> times; - times.reserve(cfg.benchmarkSamples()); - std::generate_n(std::back_inserter(times), cfg.benchmarkSamples(), [this, env] { + Detail::run_for_at_least( + std::chrono::duration_cast( warmup_time ), + warmup_iterations, + Detail::repeat( []() { return Clock::now(); } ) + ); + + std::vector times; + const auto num_samples = cfg.benchmarkSamples(); + times.reserve( num_samples ); + for ( size_t i = 0; i < num_samples; ++i ) { Detail::ChronometerModel model; - this->benchmark(Chronometer(model, iterations_per_sample)); + this->benchmark( Chronometer( model, iterations_per_sample ) ); auto sample_time = model.elapsed() - env.clock_cost.mean; - if (sample_time < FloatDuration::zero()) sample_time = FloatDuration::zero(); - return sample_time / iterations_per_sample; - }); + if ( sample_time < FDuration::zero() ) { + sample_time = FDuration::zero(); + } + times.push_back(sample_time / iterations_per_sample); + } return times; } }; diff --git a/external_imported/Catch2/src/catch2/benchmark/catch_optimizer.hpp b/external_imported/Catch2/src/catch2/benchmark/catch_optimizer.hpp index 0dbfc1450..61e6571f6 100644 --- a/external_imported/Catch2/src/catch2/benchmark/catch_optimizer.hpp +++ b/external_imported/Catch2/src/catch2/benchmark/catch_optimizer.hpp @@ -10,7 +10,7 @@ #ifndef CATCH_OPTIMIZER_HPP_INCLUDED #define CATCH_OPTIMIZER_HPP_INCLUDED -#if defined(_MSC_VER) +#if defined(_MSC_VER) || defined(__IAR_SYSTEMS_ICC__) # include // atomic_thread_fence #endif @@ -32,16 +32,23 @@ namespace Catch { namespace Detail { inline void optimizer_barrier() { keep_memory(); } } // namespace Detail -#elif defined(_MSC_VER) +#elif defined(_MSC_VER) || defined(__IAR_SYSTEMS_ICC__) +#if defined(_MSVC_VER) #pragma optimize("", off) +#elif defined(__IAR_SYSTEMS_ICC__) +// For IAR the pragma only affects the following function +#pragma optimize=disable +#endif template inline void keep_memory(T* p) { // thanks @milleniumbug *reinterpret_cast(p) = *reinterpret_cast(p); } // TODO equivalent keep_memory() +#if defined(_MSVC_VER) #pragma optimize("", on) +#endif namespace Detail { inline void optimizer_barrier() { @@ -63,7 +70,7 @@ namespace Catch { template inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> std::enable_if_t::value> { - CATCH_FORWARD(fn) (CATCH_FORWARD(args)...); + CATCH_FORWARD((fn)) (CATCH_FORWARD(args)...); } } // namespace Benchmark } // namespace Catch diff --git a/external_imported/Catch2/src/catch2/benchmark/catch_sample_analysis.hpp b/external_imported/Catch2/src/catch2/benchmark/catch_sample_analysis.hpp index d849d2464..aeb87d05a 100644 --- a/external_imported/Catch2/src/catch2/benchmark/catch_sample_analysis.hpp +++ b/external_imported/Catch2/src/catch2/benchmark/catch_sample_analysis.hpp @@ -10,38 +10,20 @@ #ifndef CATCH_SAMPLE_ANALYSIS_HPP_INCLUDED #define CATCH_SAMPLE_ANALYSIS_HPP_INCLUDED -#include #include #include -#include +#include -#include #include -#include namespace Catch { namespace Benchmark { - template struct SampleAnalysis { - std::vector samples; - Estimate mean; - Estimate standard_deviation; + std::vector samples; + Estimate mean; + Estimate standard_deviation; OutlierClassification outliers; double outlier_variance; - - template - operator SampleAnalysis() const { - std::vector samples2; - samples2.reserve(samples.size()); - std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](Duration d) { return Duration2(d); }); - return { - CATCH_MOVE(samples2), - mean, - standard_deviation, - outliers, - outlier_variance, - }; - } }; } // namespace Benchmark } // namespace Catch diff --git a/external_imported/Catch2/src/catch2/benchmark/detail/catch_analyse.cpp b/external_imported/Catch2/src/catch2/benchmark/detail/catch_analyse.cpp new file mode 100644 index 000000000..7d27daf19 --- /dev/null +++ b/external_imported/Catch2/src/catch2/benchmark/detail/catch_analyse.cpp @@ -0,0 +1,85 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 +// Adapted from donated nonius code. + +#include +#include +#include +#include +#include +#include + +#include + +namespace Catch { + namespace Benchmark { + namespace Detail { + SampleAnalysis analyse(const IConfig &cfg, FDuration* first, FDuration* last) { + if (!cfg.benchmarkNoAnalysis()) { + std::vector samples; + samples.reserve(static_cast(last - first)); + for (auto current = first; current != last; ++current) { + samples.push_back( current->count() ); + } + + auto analysis = Catch::Benchmark::Detail::analyse_samples( + cfg.benchmarkConfidenceInterval(), + cfg.benchmarkResamples(), + samples.data(), + samples.data() + samples.size() ); + auto outliers = Catch::Benchmark::Detail::classify_outliers( + samples.data(), samples.data() + samples.size() ); + + auto wrap_estimate = [](Estimate e) { + return Estimate { + FDuration(e.point), + FDuration(e.lower_bound), + FDuration(e.upper_bound), + e.confidence_interval, + }; + }; + std::vector samples2; + samples2.reserve(samples.size()); + for (auto s : samples) { + samples2.push_back( FDuration( s ) ); + } + + return { + CATCH_MOVE(samples2), + wrap_estimate(analysis.mean), + wrap_estimate(analysis.standard_deviation), + outliers, + analysis.outlier_variance, + }; + } else { + std::vector samples; + samples.reserve(static_cast(last - first)); + + FDuration mean = FDuration(0); + int i = 0; + for (auto it = first; it < last; ++it, ++i) { + samples.push_back(FDuration(*it)); + mean += FDuration(*it); + } + mean /= i; + + return SampleAnalysis{ + CATCH_MOVE(samples), + Estimate{ mean, mean, mean, 0.0 }, + Estimate{ FDuration( 0 ), + FDuration( 0 ), + FDuration( 0 ), + 0.0 }, + OutlierClassification{}, + 0.0 + }; + } + } + } // namespace Detail + } // namespace Benchmark +} // namespace Catch diff --git a/external_imported/Catch2/src/catch2/benchmark/detail/catch_analyse.hpp b/external_imported/Catch2/src/catch2/benchmark/detail/catch_analyse.hpp index 77b0a9d38..5e3f7b0f5 100644 --- a/external_imported/Catch2/src/catch2/benchmark/detail/catch_analyse.hpp +++ b/external_imported/Catch2/src/catch2/benchmark/detail/catch_analyse.hpp @@ -11,68 +11,15 @@ #define CATCH_ANALYSE_HPP_INCLUDED #include -#include #include -#include -#include -#include -#include -#include -#include namespace Catch { + class IConfig; + namespace Benchmark { namespace Detail { - template - SampleAnalysis analyse(const IConfig &cfg, Environment, Iterator first, Iterator last) { - if (!cfg.benchmarkNoAnalysis()) { - std::vector samples; - samples.reserve(static_cast(last - first)); - std::transform(first, last, std::back_inserter(samples), [](Duration d) { return d.count(); }); - - auto analysis = Catch::Benchmark::Detail::analyse_samples(cfg.benchmarkConfidenceInterval(), cfg.benchmarkResamples(), samples.begin(), samples.end()); - auto outliers = Catch::Benchmark::Detail::classify_outliers(samples.begin(), samples.end()); - - auto wrap_estimate = [](Estimate e) { - return Estimate { - Duration(e.point), - Duration(e.lower_bound), - Duration(e.upper_bound), - e.confidence_interval, - }; - }; - std::vector samples2; - samples2.reserve(samples.size()); - std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](double d) { return Duration(d); }); - return { - CATCH_MOVE(samples2), - wrap_estimate(analysis.mean), - wrap_estimate(analysis.standard_deviation), - outliers, - analysis.outlier_variance, - }; - } else { - std::vector samples; - samples.reserve(static_cast(last - first)); - - Duration mean = Duration(0); - int i = 0; - for (auto it = first; it < last; ++it, ++i) { - samples.push_back(Duration(*it)); - mean += Duration(*it); - } - mean /= i; - - return { - CATCH_MOVE(samples), - Estimate{mean, mean, mean, 0.0}, - Estimate{Duration(0), Duration(0), Duration(0), 0.0}, - OutlierClassification{}, - 0.0 - }; - } - } + SampleAnalysis analyse(const IConfig &cfg, FDuration* first, FDuration* last); } // namespace Detail } // namespace Benchmark } // namespace Catch diff --git a/external_imported/Catch2/src/catch2/benchmark/detail/catch_benchmark_function.hpp b/external_imported/Catch2/src/catch2/benchmark/detail/catch_benchmark_function.hpp index 152982587..144e4b6e4 100644 --- a/external_imported/Catch2/src/catch2/benchmark/detail/catch_benchmark_function.hpp +++ b/external_imported/Catch2/src/catch2/benchmark/detail/catch_benchmark_function.hpp @@ -11,7 +11,6 @@ #define CATCH_BENCHMARK_FUNCTION_HPP_INCLUDED #include -#include #include #include #include diff --git a/external_imported/Catch2/src/catch2/benchmark/detail/catch_benchmark_stats.hpp b/external_imported/Catch2/src/catch2/benchmark/detail/catch_benchmark_stats.hpp new file mode 100644 index 000000000..3633bc9f9 --- /dev/null +++ b/external_imported/Catch2/src/catch2/benchmark/detail/catch_benchmark_stats.hpp @@ -0,0 +1,48 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 +#ifndef CATCH_BENCHMARK_STATS_HPP_INCLUDED +#define CATCH_BENCHMARK_STATS_HPP_INCLUDED + +#include +#include +// The fwd decl & default specialization needs to be seen by VS2017 before +// BenchmarkStats itself, or VS2017 will report compilation error. +#include + +#include +#include + +namespace Catch { + + struct BenchmarkInfo { + std::string name; + double estimatedDuration; + int iterations; + unsigned int samples; + unsigned int resamples; + double clockResolution; + double clockCost; + }; + + // We need to keep template parameter for backwards compatibility, + // but we also do not want to use the template paraneter. + template + struct BenchmarkStats { + BenchmarkInfo info; + + std::vector samples; + Benchmark::Estimate mean; + Benchmark::Estimate standardDeviation; + Benchmark::OutlierClassification outliers; + double outlierVariance; + }; + + +} // end namespace Catch + +#endif // CATCH_BENCHMARK_STATS_HPP_INCLUDED diff --git a/external_imported/Catch2/src/catch2/benchmark/detail/catch_benchmark_stats_fwd.hpp b/external_imported/Catch2/src/catch2/benchmark/detail/catch_benchmark_stats_fwd.hpp new file mode 100644 index 000000000..2ccc25d58 --- /dev/null +++ b/external_imported/Catch2/src/catch2/benchmark/detail/catch_benchmark_stats_fwd.hpp @@ -0,0 +1,23 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 +#ifndef CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED +#define CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED + +#include + +namespace Catch { + + // We cannot forward declare the type with default template argument + // multiple times, so it is split out into a separate header so that + // we can prevent multiple declarations in dependees + template + struct BenchmarkStats; + +} // end namespace Catch + +#endif // CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED diff --git a/external_imported/Catch2/src/catch2/benchmark/detail/catch_complete_invoke.hpp b/external_imported/Catch2/src/catch2/benchmark/detail/catch_complete_invoke.hpp index 49db413ec..4dff4b7eb 100644 --- a/external_imported/Catch2/src/catch2/benchmark/detail/catch_complete_invoke.hpp +++ b/external_imported/Catch2/src/catch2/benchmark/detail/catch_complete_invoke.hpp @@ -10,14 +10,9 @@ #ifndef CATCH_COMPLETE_INVOKE_HPP_INCLUDED #define CATCH_COMPLETE_INVOKE_HPP_INCLUDED -#include #include -#include -#include #include -#include - namespace Catch { namespace Benchmark { namespace Detail { diff --git a/external_imported/Catch2/src/catch2/benchmark/detail/catch_estimate_clock.hpp b/external_imported/Catch2/src/catch2/benchmark/detail/catch_estimate_clock.hpp index 907773f24..8e3552796 100644 --- a/external_imported/Catch2/src/catch2/benchmark/detail/catch_estimate_clock.hpp +++ b/external_imported/Catch2/src/catch2/benchmark/detail/catch_estimate_clock.hpp @@ -19,7 +19,6 @@ #include #include -#include #include #include @@ -30,46 +29,49 @@ namespace Catch { std::vector resolution(int k) { std::vector> times; times.reserve(static_cast(k + 1)); - std::generate_n(std::back_inserter(times), k + 1, now{}); + for ( int i = 0; i < k + 1; ++i ) { + times.push_back( Clock::now() ); + } std::vector deltas; deltas.reserve(static_cast(k)); - std::transform(std::next(times.begin()), times.end(), times.begin(), - std::back_inserter(deltas), - [](TimePoint a, TimePoint b) { return static_cast((a - b).count()); }); + for ( size_t idx = 1; idx < times.size(); ++idx ) { + deltas.push_back( static_cast( + ( times[idx] - times[idx - 1] ).count() ) ); + } return deltas; } - const auto warmup_iterations = 10000; - const auto warmup_time = std::chrono::milliseconds(100); - const auto minimum_ticks = 1000; - const auto warmup_seed = 10000; - const auto clock_resolution_estimation_time = std::chrono::milliseconds(500); - const auto clock_cost_estimation_time_limit = std::chrono::seconds(1); - const auto clock_cost_estimation_tick_limit = 100000; - const auto clock_cost_estimation_time = std::chrono::milliseconds(10); - const auto clock_cost_estimation_iterations = 10000; + constexpr auto warmup_iterations = 10000; + constexpr auto warmup_time = std::chrono::milliseconds(100); + constexpr auto minimum_ticks = 1000; + constexpr auto warmup_seed = 10000; + constexpr auto clock_resolution_estimation_time = std::chrono::milliseconds(500); + constexpr auto clock_cost_estimation_time_limit = std::chrono::seconds(1); + constexpr auto clock_cost_estimation_tick_limit = 100000; + constexpr auto clock_cost_estimation_time = std::chrono::milliseconds(10); + constexpr auto clock_cost_estimation_iterations = 10000; template int warmup() { - return run_for_at_least(std::chrono::duration_cast>(warmup_time), warmup_seed, &resolution) + return run_for_at_least(warmup_time, warmup_seed, &resolution) .iterations; } template - EnvironmentEstimate> estimate_clock_resolution(int iterations) { - auto r = run_for_at_least(std::chrono::duration_cast>(clock_resolution_estimation_time), iterations, &resolution) + EnvironmentEstimate estimate_clock_resolution(int iterations) { + auto r = run_for_at_least(clock_resolution_estimation_time, iterations, &resolution) .result; return { - FloatDuration(mean(r.begin(), r.end())), - classify_outliers(r.begin(), r.end()), + FDuration(mean(r.data(), r.data() + r.size())), + classify_outliers(r.data(), r.data() + r.size()), }; } template - EnvironmentEstimate> estimate_clock_cost(FloatDuration resolution) { + EnvironmentEstimate estimate_clock_cost(FDuration resolution) { auto time_limit = (std::min)( resolution * clock_cost_estimation_tick_limit, - FloatDuration(clock_cost_estimation_time_limit)); + FDuration(clock_cost_estimation_time_limit)); auto time_clock = [](int k) { return Detail::measure([k] { for (int i = 0; i < k; ++i) { @@ -80,26 +82,28 @@ namespace Catch { }; time_clock(1); int iters = clock_cost_estimation_iterations; - auto&& r = run_for_at_least(std::chrono::duration_cast>(clock_cost_estimation_time), iters, time_clock); + auto&& r = run_for_at_least(clock_cost_estimation_time, iters, time_clock); std::vector times; int nsamples = static_cast(std::ceil(time_limit / r.elapsed)); times.reserve(static_cast(nsamples)); - std::generate_n(std::back_inserter(times), nsamples, [time_clock, &r] { - return static_cast((time_clock(r.iterations) / r.iterations).count()); - }); + for ( int s = 0; s < nsamples; ++s ) { + times.push_back( static_cast( + ( time_clock( r.iterations ) / r.iterations ) + .count() ) ); + } return { - FloatDuration(mean(times.begin(), times.end())), - classify_outliers(times.begin(), times.end()), + FDuration(mean(times.data(), times.data() + times.size())), + classify_outliers(times.data(), times.data() + times.size()), }; } template - Environment> measure_environment() { + Environment measure_environment() { #if defined(__clang__) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wexit-time-destructors" #endif - static Catch::Detail::unique_ptr>> env; + static Catch::Detail::unique_ptr env; #if defined(__clang__) # pragma clang diagnostic pop #endif @@ -111,7 +115,7 @@ namespace Catch { auto resolution = Detail::estimate_clock_resolution(iters); auto cost = Detail::estimate_clock_cost(resolution.mean); - env = Catch::Detail::make_unique>>( Environment>{resolution, cost} ); + env = Catch::Detail::make_unique( Environment{resolution, cost} ); return *env; } } // namespace Detail diff --git a/external_imported/Catch2/src/catch2/benchmark/detail/catch_measure.hpp b/external_imported/Catch2/src/catch2/benchmark/detail/catch_measure.hpp index 388814c1c..37494a68f 100644 --- a/external_imported/Catch2/src/catch2/benchmark/detail/catch_measure.hpp +++ b/external_imported/Catch2/src/catch2/benchmark/detail/catch_measure.hpp @@ -10,7 +10,6 @@ #ifndef CATCH_MEASURE_HPP_INCLUDED #define CATCH_MEASURE_HPP_INCLUDED -#include #include #include #include @@ -19,7 +18,7 @@ namespace Catch { namespace Benchmark { namespace Detail { template - TimingOf measure(Fun&& fun, Args&&... args) { + TimingOf measure(Fun&& fun, Args&&... args) { auto start = Clock::now(); auto&& r = Detail::complete_invoke(fun, CATCH_FORWARD(args)...); auto end = Clock::now(); diff --git a/external_imported/Catch2/src/catch2/benchmark/detail/catch_run_for_at_least.cpp b/external_imported/Catch2/src/catch2/benchmark/detail/catch_run_for_at_least.cpp index 35778b27f..3ebdcc05a 100644 --- a/external_imported/Catch2/src/catch2/benchmark/detail/catch_run_for_at_least.cpp +++ b/external_imported/Catch2/src/catch2/benchmark/detail/catch_run_for_at_least.cpp @@ -7,9 +7,10 @@ // SPDX-License-Identifier: BSL-1.0 #include -#include #include +#include + namespace Catch { namespace Benchmark { namespace Detail { diff --git a/external_imported/Catch2/src/catch2/benchmark/detail/catch_run_for_at_least.hpp b/external_imported/Catch2/src/catch2/benchmark/detail/catch_run_for_at_least.hpp index 976a4b243..4dfa8bbbb 100644 --- a/external_imported/Catch2/src/catch2/benchmark/detail/catch_run_for_at_least.hpp +++ b/external_imported/Catch2/src/catch2/benchmark/detail/catch_run_for_at_least.hpp @@ -24,11 +24,11 @@ namespace Catch { namespace Benchmark { namespace Detail { template - TimingOf measure_one(Fun&& fun, int iters, std::false_type) { + TimingOf measure_one(Fun&& fun, int iters, std::false_type) { return Detail::measure(fun, iters); } template - TimingOf measure_one(Fun&& fun, int iters, std::true_type) { + TimingOf measure_one(Fun&& fun, int iters, std::true_type) { Detail::ChronometerModel meter; auto&& result = Detail::complete_invoke(fun, Chronometer(meter, iters)); @@ -43,8 +43,8 @@ namespace Catch { void throw_optimized_away_error(); template - TimingOf> - run_for_at_least(ClockDuration how_long, + TimingOf> + run_for_at_least(IDuration how_long, const int initial_iterations, Fun&& fun) { auto iters = initial_iterations; diff --git a/external_imported/Catch2/src/catch2/benchmark/detail/catch_stats.cpp b/external_imported/Catch2/src/catch2/benchmark/detail/catch_stats.cpp index 514ed1f73..52cee4eea 100644 --- a/external_imported/Catch2/src/catch2/benchmark/detail/catch_stats.cpp +++ b/external_imported/Catch2/src/catch2/benchmark/detail/catch_stats.cpp @@ -10,10 +10,14 @@ #include #include +#include +#include +#include #include +#include #include -#include +#include #include @@ -21,139 +25,199 @@ #include #endif -namespace { - -using Catch::Benchmark::Detail::sample; - - template - sample resample(URng& rng, unsigned int resamples, std::vector::iterator first, std::vector::iterator last, Estimator& estimator) { - auto n = static_cast(last - first); - std::uniform_int_distribution dist(0, n - 1); - - sample out; - out.reserve(resamples); - std::generate_n(std::back_inserter(out), resamples, [n, first, &estimator, &dist, &rng] { - std::vector resampled; - resampled.reserve(n); - std::generate_n(std::back_inserter(resampled), n, [first, &dist, &rng] { return first[static_cast(dist(rng))]; }); - return estimator(resampled.begin(), resampled.end()); - }); - std::sort(out.begin(), out.end()); - return out; - } - - - double erf_inv(double x) { - // Code accompanying the article "Approximating the erfinv function" in GPU Computing Gems, Volume 2 - double w, p; - - w = -log((1.0 - x) * (1.0 + x)); - - if (w < 6.250000) { - w = w - 3.125000; - p = -3.6444120640178196996e-21; - p = -1.685059138182016589e-19 + p * w; - p = 1.2858480715256400167e-18 + p * w; - p = 1.115787767802518096e-17 + p * w; - p = -1.333171662854620906e-16 + p * w; - p = 2.0972767875968561637e-17 + p * w; - p = 6.6376381343583238325e-15 + p * w; - p = -4.0545662729752068639e-14 + p * w; - p = -8.1519341976054721522e-14 + p * w; - p = 2.6335093153082322977e-12 + p * w; - p = -1.2975133253453532498e-11 + p * w; - p = -5.4154120542946279317e-11 + p * w; - p = 1.051212273321532285e-09 + p * w; - p = -4.1126339803469836976e-09 + p * w; - p = -2.9070369957882005086e-08 + p * w; - p = 4.2347877827932403518e-07 + p * w; - p = -1.3654692000834678645e-06 + p * w; - p = -1.3882523362786468719e-05 + p * w; - p = 0.0001867342080340571352 + p * w; - p = -0.00074070253416626697512 + p * w; - p = -0.0060336708714301490533 + p * w; - p = 0.24015818242558961693 + p * w; - p = 1.6536545626831027356 + p * w; - } else if (w < 16.000000) { - w = sqrt(w) - 3.250000; - p = 2.2137376921775787049e-09; - p = 9.0756561938885390979e-08 + p * w; - p = -2.7517406297064545428e-07 + p * w; - p = 1.8239629214389227755e-08 + p * w; - p = 1.5027403968909827627e-06 + p * w; - p = -4.013867526981545969e-06 + p * w; - p = 2.9234449089955446044e-06 + p * w; - p = 1.2475304481671778723e-05 + p * w; - p = -4.7318229009055733981e-05 + p * w; - p = 6.8284851459573175448e-05 + p * w; - p = 2.4031110387097893999e-05 + p * w; - p = -0.0003550375203628474796 + p * w; - p = 0.00095328937973738049703 + p * w; - p = -0.0016882755560235047313 + p * w; - p = 0.0024914420961078508066 + p * w; - p = -0.0037512085075692412107 + p * w; - p = 0.005370914553590063617 + p * w; - p = 1.0052589676941592334 + p * w; - p = 3.0838856104922207635 + p * w; - } else { - w = sqrt(w) - 5.000000; - p = -2.7109920616438573243e-11; - p = -2.5556418169965252055e-10 + p * w; - p = 1.5076572693500548083e-09 + p * w; - p = -3.7894654401267369937e-09 + p * w; - p = 7.6157012080783393804e-09 + p * w; - p = -1.4960026627149240478e-08 + p * w; - p = 2.9147953450901080826e-08 + p * w; - p = -6.7711997758452339498e-08 + p * w; - p = 2.2900482228026654717e-07 + p * w; - p = -9.9298272942317002539e-07 + p * w; - p = 4.5260625972231537039e-06 + p * w; - p = -1.9681778105531670567e-05 + p * w; - p = 7.5995277030017761139e-05 + p * w; - p = -0.00021503011930044477347 + p * w; - p = -0.00013871931833623122026 + p * w; - p = 1.0103004648645343977 + p * w; - p = 4.8499064014085844221 + p * w; - } - return p * x; - } - - double standard_deviation(std::vector::iterator first, std::vector::iterator last) { - auto m = Catch::Benchmark::Detail::mean(first, last); - double variance = std::accumulate( first, - last, - 0., - [m]( double a, double b ) { - double diff = b - m; - return a + diff * diff; - } ) / - ( last - first ); - return std::sqrt( variance ); - } - -} - namespace Catch { namespace Benchmark { namespace Detail { + namespace { + + template + static sample + resample( URng& rng, + unsigned int resamples, + double const* first, + double const* last, + Estimator& estimator ) { + auto n = static_cast( last - first ); + std::uniform_int_distribution dist( 0, n - 1 ); + + sample out; + out.reserve( resamples ); + std::vector resampled; + resampled.reserve( n ); + for ( size_t i = 0; i < resamples; ++i ) { + resampled.clear(); + for ( size_t s = 0; s < n; ++s ) { + resampled.push_back( first[dist( rng )] ); + } + const auto estimate = + estimator( resampled.data(), resampled.data() + resampled.size() ); + out.push_back( estimate ); + } + std::sort( out.begin(), out.end() ); + return out; + } -#if defined( __GNUC__ ) || defined( __clang__ ) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wfloat-equal" -#endif - bool directCompare( double lhs, double rhs ) { return lhs == rhs; } -#if defined( __GNUC__ ) || defined( __clang__ ) -# pragma GCC diagnostic pop -#endif + static double outlier_variance( Estimate mean, + Estimate stddev, + int n ) { + double sb = stddev.point; + double mn = mean.point / n; + double mg_min = mn / 2.; + double sg = (std::min)( mg_min / 4., sb / std::sqrt( n ) ); + double sg2 = sg * sg; + double sb2 = sb * sb; + + auto c_max = [n, mn, sb2, sg2]( double x ) -> double { + double k = mn - x; + double d = k * k; + double nd = n * d; + double k0 = -n * nd; + double k1 = sb2 - n * sg2 + nd; + double det = k1 * k1 - 4 * sg2 * k0; + return static_cast( -2. * k0 / + ( k1 + std::sqrt( det ) ) ); + }; + + auto var_out = [n, sb2, sg2]( double c ) { + double nc = n - c; + return ( nc / n ) * ( sb2 - nc * sg2 ); + }; + + return (std::min)( var_out( 1 ), + var_out( + (std::min)( c_max( 0. ), + c_max( mg_min ) ) ) ) / + sb2; + } + + static double erf_inv( double x ) { + // Code accompanying the article "Approximating the erfinv + // function" in GPU Computing Gems, Volume 2 + double w, p; + + w = -log( ( 1.0 - x ) * ( 1.0 + x ) ); + + if ( w < 6.250000 ) { + w = w - 3.125000; + p = -3.6444120640178196996e-21; + p = -1.685059138182016589e-19 + p * w; + p = 1.2858480715256400167e-18 + p * w; + p = 1.115787767802518096e-17 + p * w; + p = -1.333171662854620906e-16 + p * w; + p = 2.0972767875968561637e-17 + p * w; + p = 6.6376381343583238325e-15 + p * w; + p = -4.0545662729752068639e-14 + p * w; + p = -8.1519341976054721522e-14 + p * w; + p = 2.6335093153082322977e-12 + p * w; + p = -1.2975133253453532498e-11 + p * w; + p = -5.4154120542946279317e-11 + p * w; + p = 1.051212273321532285e-09 + p * w; + p = -4.1126339803469836976e-09 + p * w; + p = -2.9070369957882005086e-08 + p * w; + p = 4.2347877827932403518e-07 + p * w; + p = -1.3654692000834678645e-06 + p * w; + p = -1.3882523362786468719e-05 + p * w; + p = 0.0001867342080340571352 + p * w; + p = -0.00074070253416626697512 + p * w; + p = -0.0060336708714301490533 + p * w; + p = 0.24015818242558961693 + p * w; + p = 1.6536545626831027356 + p * w; + } else if ( w < 16.000000 ) { + w = sqrt( w ) - 3.250000; + p = 2.2137376921775787049e-09; + p = 9.0756561938885390979e-08 + p * w; + p = -2.7517406297064545428e-07 + p * w; + p = 1.8239629214389227755e-08 + p * w; + p = 1.5027403968909827627e-06 + p * w; + p = -4.013867526981545969e-06 + p * w; + p = 2.9234449089955446044e-06 + p * w; + p = 1.2475304481671778723e-05 + p * w; + p = -4.7318229009055733981e-05 + p * w; + p = 6.8284851459573175448e-05 + p * w; + p = 2.4031110387097893999e-05 + p * w; + p = -0.0003550375203628474796 + p * w; + p = 0.00095328937973738049703 + p * w; + p = -0.0016882755560235047313 + p * w; + p = 0.0024914420961078508066 + p * w; + p = -0.0037512085075692412107 + p * w; + p = 0.005370914553590063617 + p * w; + p = 1.0052589676941592334 + p * w; + p = 3.0838856104922207635 + p * w; + } else { + w = sqrt( w ) - 5.000000; + p = -2.7109920616438573243e-11; + p = -2.5556418169965252055e-10 + p * w; + p = 1.5076572693500548083e-09 + p * w; + p = -3.7894654401267369937e-09 + p * w; + p = 7.6157012080783393804e-09 + p * w; + p = -1.4960026627149240478e-08 + p * w; + p = 2.9147953450901080826e-08 + p * w; + p = -6.7711997758452339498e-08 + p * w; + p = 2.2900482228026654717e-07 + p * w; + p = -9.9298272942317002539e-07 + p * w; + p = 4.5260625972231537039e-06 + p * w; + p = -1.9681778105531670567e-05 + p * w; + p = 7.5995277030017761139e-05 + p * w; + p = -0.00021503011930044477347 + p * w; + p = -0.00013871931833623122026 + p * w; + p = 1.0103004648645343977 + p * w; + p = 4.8499064014085844221 + p * w; + } + return p * x; + } + + static double + standard_deviation( double const* first, double const* last ) { + auto m = Catch::Benchmark::Detail::mean( first, last ); + double variance = + std::accumulate( first, + last, + 0., + [m]( double a, double b ) { + double diff = b - m; + return a + diff * diff; + } ) / + ( last - first ); + return std::sqrt( variance ); + } + + static sample jackknife( double ( *estimator )( double const*, + double const* ), + double* first, + double* last ) { + const auto second = first + 1; + sample results; + results.reserve( static_cast( last - first ) ); + + for ( auto it = first; it != last; ++it ) { + std::iter_swap( it, first ); + results.push_back( estimator( second, last ) ); + } + + return results; + } + + + } // namespace + } // namespace Detail + } // namespace Benchmark +} // namespace Catch + +namespace Catch { + namespace Benchmark { + namespace Detail { - double weighted_average_quantile(int k, int q, std::vector::iterator first, std::vector::iterator last) { + double weighted_average_quantile( int k, + int q, + double* first, + double* last ) { auto count = last - first; double idx = (count - 1) * k / static_cast(q); int j = static_cast(idx); double g = idx - j; std::nth_element(first, first + j, last); auto xj = first[j]; - if ( directCompare( g, 0 ) ) { + if ( Catch::Detail::directCompare( g, 0 ) ) { return xj; } @@ -161,6 +225,48 @@ namespace Catch { return xj + g * (xj1 - xj); } + OutlierClassification + classify_outliers( double const* first, double const* last ) { + std::vector copy( first, last ); + + auto q1 = weighted_average_quantile( 1, 4, copy.data(), copy.data() + copy.size() ); + auto q3 = weighted_average_quantile( 3, 4, copy.data(), copy.data() + copy.size() ); + auto iqr = q3 - q1; + auto los = q1 - ( iqr * 3. ); + auto lom = q1 - ( iqr * 1.5 ); + auto him = q3 + ( iqr * 1.5 ); + auto his = q3 + ( iqr * 3. ); + + OutlierClassification o; + for ( ; first != last; ++first ) { + const double t = *first; + if ( t < los ) { + ++o.low_severe; + } else if ( t < lom ) { + ++o.low_mild; + } else if ( t > his ) { + ++o.high_severe; + } else if ( t > him ) { + ++o.high_mild; + } + ++o.samples_seen; + } + return o; + } + + double mean( double const* first, double const* last ) { + auto count = last - first; + double sum = 0.; + while (first != last) { + sum += *first; + ++first; + } + return sum / static_cast(count); + } + + double normal_cdf( double x ) { + return std::erfc( -x / std::sqrt( 2.0 ) ) / 2.0; + } double erfc_inv(double x) { return erf_inv(1.0 - x); @@ -182,50 +288,77 @@ namespace Catch { return result; } + Estimate + bootstrap( double confidence_level, + double* first, + double* last, + sample const& resample, + double ( *estimator )( double const*, double const* ) ) { + auto n_samples = last - first; + + double point = estimator( first, last ); + // Degenerate case with a single sample + if ( n_samples == 1 ) + return { point, point, point, confidence_level }; + + sample jack = jackknife( estimator, first, last ); + double jack_mean = + mean( jack.data(), jack.data() + jack.size() ); + double sum_squares = 0, sum_cubes = 0; + for ( double x : jack ) { + auto difference = jack_mean - x; + auto square = difference * difference; + auto cube = square * difference; + sum_squares += square; + sum_cubes += cube; + } - double outlier_variance(Estimate mean, Estimate stddev, int n) { - double sb = stddev.point; - double mn = mean.point / n; - double mg_min = mn / 2.; - double sg = (std::min)(mg_min / 4., sb / std::sqrt(n)); - double sg2 = sg * sg; - double sb2 = sb * sb; - - auto c_max = [n, mn, sb2, sg2](double x) -> double { - double k = mn - x; - double d = k * k; - double nd = n * d; - double k0 = -n * nd; - double k1 = sb2 - n * sg2 + nd; - double det = k1 * k1 - 4 * sg2 * k0; - return static_cast(-2. * k0 / (k1 + std::sqrt(det))); - }; + double accel = sum_cubes / ( 6 * std::pow( sum_squares, 1.5 ) ); + long n = static_cast( resample.size() ); + double prob_n = + std::count_if( resample.begin(), + resample.end(), + [point]( double x ) { return x < point; } ) / + static_cast( n ); + // degenerate case with uniform samples + if ( Catch::Detail::directCompare( prob_n, 0. ) ) { + return { point, point, point, confidence_level }; + } - auto var_out = [n, sb2, sg2](double c) { - double nc = n - c; - return (nc / n) * (sb2 - nc * sg2); - }; + double bias = normal_quantile( prob_n ); + double z1 = normal_quantile( ( 1. - confidence_level ) / 2. ); - return (std::min)(var_out(1), var_out((std::min)(c_max(0.), c_max(mg_min)))) / sb2; + auto cumn = [n]( double x ) -> long { + return std::lround( normal_cdf( x ) * + static_cast( n ) ); + }; + auto a = [bias, accel]( double b ) { + return bias + b / ( 1. - accel * b ); + }; + double b1 = bias + z1; + double b2 = bias - z1; + double a1 = a( b1 ); + double a2 = a( b2 ); + auto lo = static_cast( (std::max)( cumn( a1 ), 0l ) ); + auto hi = + static_cast( (std::min)( cumn( a2 ), n - 1 ) ); + + return { point, resample[lo], resample[hi], confidence_level }; } - - bootstrap_analysis analyse_samples(double confidence_level, unsigned int n_resamples, std::vector::iterator first, std::vector::iterator last) { - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION - CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS - static std::random_device entropy; - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION - - auto n = static_cast(last - first); // seriously, one can't use integral types without hell in C++ - - auto mean = &Detail::mean::iterator>; + bootstrap_analysis analyse_samples(double confidence_level, + unsigned int n_resamples, + double* first, + double* last) { + auto mean = &Detail::mean; auto stddev = &standard_deviation; #if defined(CATCH_CONFIG_USE_ASYNC) - auto Estimate = [=](double(*f)(std::vector::iterator, std::vector::iterator)) { - auto seed = entropy(); + auto Estimate = [=](double(*f)(double const*, double const*)) { + std::random_device rd; + auto seed = rd(); return std::async(std::launch::async, [=] { - std::mt19937 rng(seed); + SimplePcg32 rng( seed ); auto resampled = resample(rng, n_resamples, first, last, f); return bootstrap(confidence_level, first, last, resampled, f); }); @@ -237,9 +370,10 @@ namespace Catch { auto mean_estimate = mean_future.get(); auto stddev_estimate = stddev_future.get(); #else - auto Estimate = [=](double(*f)(std::vector::iterator, std::vector::iterator)) { - auto seed = entropy(); - std::mt19937 rng(seed); + auto Estimate = [=](double(*f)(double const* , double const*)) { + std::random_device rd; + auto seed = rd(); + SimplePcg32 rng( seed ); auto resampled = resample(rng, n_resamples, first, last, f); return bootstrap(confidence_level, first, last, resampled, f); }; @@ -248,6 +382,7 @@ namespace Catch { auto stddev_estimate = Estimate(stddev); #endif // CATCH_USE_ASYNC + auto n = static_cast(last - first); // seriously, one can't use integral types without hell in C++ double outlier_variance = Detail::outlier_variance(mean_estimate, stddev_estimate, n); return { mean_estimate, stddev_estimate, outlier_variance }; diff --git a/external_imported/Catch2/src/catch2/benchmark/detail/catch_stats.hpp b/external_imported/Catch2/src/catch2/benchmark/detail/catch_stats.hpp index 4c54ec52e..3bea612f9 100644 --- a/external_imported/Catch2/src/catch2/benchmark/detail/catch_stats.hpp +++ b/external_imported/Catch2/src/catch2/benchmark/detail/catch_stats.hpp @@ -13,122 +13,35 @@ #include #include -#include #include -#include -#include -#include namespace Catch { namespace Benchmark { namespace Detail { using sample = std::vector; - // Used when we know we want == comparison of two doubles - // to centralize warning suppression - bool directCompare( double lhs, double rhs ); - - double weighted_average_quantile(int k, int q, std::vector::iterator first, std::vector::iterator last); - - template - OutlierClassification classify_outliers(Iterator first, Iterator last) { - std::vector copy(first, last); - - auto q1 = weighted_average_quantile(1, 4, copy.begin(), copy.end()); - auto q3 = weighted_average_quantile(3, 4, copy.begin(), copy.end()); - auto iqr = q3 - q1; - auto los = q1 - (iqr * 3.); - auto lom = q1 - (iqr * 1.5); - auto him = q3 + (iqr * 1.5); - auto his = q3 + (iqr * 3.); - - OutlierClassification o; - for (; first != last; ++first) { - auto&& t = *first; - if (t < los) ++o.low_severe; - else if (t < lom) ++o.low_mild; - else if (t > his) ++o.high_severe; - else if (t > him) ++o.high_mild; - ++o.samples_seen; - } - return o; - } - - template - double mean(Iterator first, Iterator last) { - auto count = last - first; - double sum = std::accumulate(first, last, 0.); - return sum / static_cast(count); - } - - template - sample jackknife(Estimator&& estimator, Iterator first, Iterator last) { - auto n = static_cast(last - first); - auto second = first; - ++second; - sample results; - results.reserve(n); - - for (auto it = first; it != last; ++it) { - std::iter_swap(it, first); - results.push_back(estimator(second, last)); - } - - return results; - } - - inline double normal_cdf(double x) { - return std::erfc(-x / std::sqrt(2.0)) / 2.0; - } + double weighted_average_quantile( int k, + int q, + double* first, + double* last ); + + OutlierClassification + classify_outliers( double const* first, double const* last ); + + double mean( double const* first, double const* last ); + + double normal_cdf( double x ); double erfc_inv(double x); double normal_quantile(double p); - template - Estimate bootstrap(double confidence_level, Iterator first, Iterator last, sample const& resample, Estimator&& estimator) { - auto n_samples = last - first; - - double point = estimator(first, last); - // Degenerate case with a single sample - if (n_samples == 1) return { point, point, point, confidence_level }; - - sample jack = jackknife(estimator, first, last); - double jack_mean = mean(jack.begin(), jack.end()); - double sum_squares, sum_cubes; - std::tie(sum_squares, sum_cubes) = std::accumulate(jack.begin(), jack.end(), std::make_pair(0., 0.), [jack_mean](std::pair sqcb, double x) -> std::pair { - auto d = jack_mean - x; - auto d2 = d * d; - auto d3 = d2 * d; - return { sqcb.first + d2, sqcb.second + d3 }; - }); - - double accel = sum_cubes / (6 * std::pow(sum_squares, 1.5)); - long n = static_cast(resample.size()); - double prob_n = std::count_if(resample.begin(), resample.end(), [point](double x) { return x < point; }) / static_cast(n); - // degenerate case with uniform samples - if ( directCompare( prob_n, 0. ) ) { - return { point, point, point, confidence_level }; - } - - double bias = normal_quantile(prob_n); - double z1 = normal_quantile((1. - confidence_level) / 2.); - - auto cumn = [n]( double x ) -> long { - return std::lround( normal_cdf( x ) * static_cast(n) ); - }; - auto a = [bias, accel](double b) { return bias + b / (1. - accel * b); }; - double b1 = bias + z1; - double b2 = bias - z1; - double a1 = a(b1); - double a2 = a(b2); - auto lo = static_cast((std::max)(cumn(a1), 0l)); - auto hi = static_cast((std::min)(cumn(a2), n - 1)); - - return { point, resample[lo], resample[hi], confidence_level }; - } - - double outlier_variance(Estimate mean, Estimate stddev, int n); + Estimate + bootstrap( double confidence_level, + double* first, + double* last, + sample const& resample, + double ( *estimator )( double const*, double const* ) ); struct bootstrap_analysis { Estimate mean; @@ -136,7 +49,10 @@ namespace Catch { double outlier_variance; }; - bootstrap_analysis analyse_samples(double confidence_level, unsigned int n_resamples, std::vector::iterator first, std::vector::iterator last); + bootstrap_analysis analyse_samples(double confidence_level, + unsigned int n_resamples, + double* first, + double* last); } // namespace Detail } // namespace Benchmark } // namespace Catch diff --git a/external_imported/Catch2/src/catch2/benchmark/detail/catch_timing.hpp b/external_imported/Catch2/src/catch2/benchmark/detail/catch_timing.hpp index f5c25571c..da5671908 100644 --- a/external_imported/Catch2/src/catch2/benchmark/detail/catch_timing.hpp +++ b/external_imported/Catch2/src/catch2/benchmark/detail/catch_timing.hpp @@ -17,14 +17,14 @@ namespace Catch { namespace Benchmark { - template + template struct Timing { - Duration elapsed; + IDuration elapsed; Result result; int iterations; }; - template - using TimingOf = Timing, Detail::CompleteType_t>>; + template + using TimingOf = Timing>>; } // namespace Benchmark } // namespace Catch diff --git a/external_imported/Catch2/src/catch2/catch_all.hpp b/external_imported/Catch2/src/catch2/catch_all.hpp index be146421e..f2cc85365 100644 --- a/external_imported/Catch2/src/catch2/catch_all.hpp +++ b/external_imported/Catch2/src/catch2/catch_all.hpp @@ -54,6 +54,8 @@ #include #include #include +#include +#include #include #include #include @@ -72,6 +74,7 @@ #include #include #include +#include #include #include #include @@ -86,7 +89,10 @@ #include #include #include +#include #include +#include +#include #include #include #include @@ -111,10 +117,13 @@ #include #include #include +#include #include #include #include #include +#include +#include #include #include #include diff --git a/external_imported/Catch2/src/catch2/catch_approx.cpp b/external_imported/Catch2/src/catch2/catch_approx.cpp index 407586d1d..9ad4ce3ee 100644 --- a/external_imported/Catch2/src/catch2/catch_approx.cpp +++ b/external_imported/Catch2/src/catch2/catch_approx.cpp @@ -70,10 +70,10 @@ namespace Catch { } namespace literals { - Approx operator "" _a(long double val) { + Approx operator ""_a(long double val) { return Approx(val); } - Approx operator "" _a(unsigned long long val) { + Approx operator ""_a(unsigned long long val) { return Approx(val); } } // end namespace literals diff --git a/external_imported/Catch2/src/catch2/catch_config.cpp b/external_imported/Catch2/src/catch2/catch_config.cpp index eb4f5ad36..34f50f175 100644 --- a/external_imported/Catch2/src/catch2/catch_config.cpp +++ b/external_imported/Catch2/src/catch2/catch_config.cpp @@ -105,7 +105,7 @@ namespace Catch { elem = trim(elem); } - // Insert the default reporter if user hasn't asked for a specfic one + // Insert the default reporter if user hasn't asked for a specific one if ( m_data.reporterSpecifications.empty() ) { m_data.reporterSpecifications.push_back( { #if defined( CATCH_CONFIG_DEFAULT_REPORTER ) diff --git a/external_imported/Catch2/src/catch2/catch_config.hpp b/external_imported/Catch2/src/catch2/catch_config.hpp index 784de4aa5..17e983e5c 100644 --- a/external_imported/Catch2/src/catch2/catch_config.hpp +++ b/external_imported/Catch2/src/catch2/catch_config.hpp @@ -69,7 +69,7 @@ namespace Catch { bool benchmarkNoAnalysis = false; unsigned int benchmarkSamples = 100; double benchmarkConfidenceInterval = 0.95; - unsigned int benchmarkResamples = 100000; + unsigned int benchmarkResamples = 100'000; std::chrono::milliseconds::rep benchmarkWarmupTime = 100; Verbosity verbosity = Verbosity::Normal; diff --git a/external_imported/Catch2/src/catch2/catch_message.cpp b/external_imported/Catch2/src/catch2/catch_message.cpp index d4723e949..384f180e5 100644 --- a/external_imported/Catch2/src/catch2/catch_message.cpp +++ b/external_imported/Catch2/src/catch2/catch_message.cpp @@ -37,7 +37,11 @@ namespace Catch { } - Capturer::Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ) { + Capturer::Capturer( StringRef macroName, + SourceLineInfo const& lineInfo, + ResultWas::OfType resultType, + StringRef names ): + m_resultCapture( getResultCapture() ) { auto trimmed = [&] (size_t start, size_t end) { while (names[start] == ',' || isspace(static_cast(names[start]))) { ++start; diff --git a/external_imported/Catch2/src/catch2/catch_message.hpp b/external_imported/Catch2/src/catch2/catch_message.hpp index e6bc1b5dc..05325ee8f 100644 --- a/external_imported/Catch2/src/catch2/catch_message.hpp +++ b/external_imported/Catch2/src/catch2/catch_message.hpp @@ -8,12 +8,13 @@ #ifndef CATCH_MESSAGE_HPP_INCLUDED #define CATCH_MESSAGE_HPP_INCLUDED +#include #include #include #include #include -#include #include +#include #include #include @@ -21,6 +22,7 @@ namespace Catch { struct SourceLineInfo; + class IResultCapture; struct MessageStream { @@ -61,7 +63,7 @@ namespace Catch { class Capturer { std::vector m_messages; - IResultCapture& m_resultCapture = getResultCapture(); + IResultCapture& m_resultCapture; size_t m_captured = 0; public: Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ); @@ -112,28 +114,28 @@ namespace Catch { Catch::getResultCapture().emplaceUnscopedMessage( Catch::MessageBuilder( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log ) -#if defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_DISABLE) +#if defined(CATCH_CONFIG_PREFIX_MESSAGES) && !defined(CATCH_CONFIG_DISABLE) #define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( "CATCH_INFO", msg ) #define CATCH_UNSCOPED_INFO( msg ) INTERNAL_CATCH_UNSCOPED_INFO( "CATCH_UNSCOPED_INFO", msg ) #define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( "CATCH_WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg ) #define CATCH_CAPTURE( ... ) INTERNAL_CATCH_CAPTURE( INTERNAL_CATCH_UNIQUE_NAME(capturer), "CATCH_CAPTURE", __VA_ARGS__ ) -#elif defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CONFIG_DISABLE) +#elif defined(CATCH_CONFIG_PREFIX_MESSAGES) && defined(CATCH_CONFIG_DISABLE) #define CATCH_INFO( msg ) (void)(0) #define CATCH_UNSCOPED_INFO( msg ) (void)(0) #define CATCH_WARN( msg ) (void)(0) #define CATCH_CAPTURE( ... ) (void)(0) -#elif !defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_DISABLE) +#elif !defined(CATCH_CONFIG_PREFIX_MESSAGES) && !defined(CATCH_CONFIG_DISABLE) #define INFO( msg ) INTERNAL_CATCH_INFO( "INFO", msg ) #define UNSCOPED_INFO( msg ) INTERNAL_CATCH_UNSCOPED_INFO( "UNSCOPED_INFO", msg ) #define WARN( msg ) INTERNAL_CATCH_MSG( "WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg ) #define CAPTURE( ... ) INTERNAL_CATCH_CAPTURE( INTERNAL_CATCH_UNIQUE_NAME(capturer), "CAPTURE", __VA_ARGS__ ) -#elif !defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CONFIG_DISABLE) +#elif !defined(CATCH_CONFIG_PREFIX_MESSAGES) && defined(CATCH_CONFIG_DISABLE) #define INFO( msg ) (void)(0) #define UNSCOPED_INFO( msg ) (void)(0) diff --git a/external_imported/Catch2/src/catch2/catch_registry_hub.cpp b/external_imported/Catch2/src/catch2/catch_registry_hub.cpp index 243dd2b0c..8716db3a7 100644 --- a/external_imported/Catch2/src/catch2/catch_registry_hub.cpp +++ b/external_imported/Catch2/src/catch2/catch_registry_hub.cpp @@ -20,6 +20,9 @@ #include #include #include +#include + +#include namespace Catch { @@ -31,7 +34,7 @@ namespace Catch { public: // IRegistryHub RegistryHub() = default; - IReporterRegistry const& getReporterRegistry() const override { + ReporterRegistry const& getReporterRegistry() const override { return m_reporterRegistry; } ITestCaseRegistry const& getTestCaseRegistry() const override { diff --git a/external_imported/Catch2/src/catch2/catch_session.cpp b/external_imported/Catch2/src/catch2/catch_session.cpp index 43465f0c4..f1ed5f9cc 100644 --- a/external_imported/Catch2/src/catch2/catch_session.cpp +++ b/external_imported/Catch2/src/catch2/catch_session.cpp @@ -13,13 +13,13 @@ #include #include #include -#include #include #include +#include #include #include #include -#include +#include #include #include #include @@ -27,6 +27,7 @@ #include #include +#include #include #include diff --git a/external_imported/Catch2/src/catch2/catch_test_case_info.cpp b/external_imported/Catch2/src/catch2/catch_test_case_info.cpp index a6adce0ae..c38ee55ac 100644 --- a/external_imported/Catch2/src/catch2/catch_test_case_info.cpp +++ b/external_imported/Catch2/src/catch2/catch_test_case_info.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -139,12 +140,20 @@ namespace Catch { for (size_t idx = 0; idx < originalTags.size(); ++idx) { auto c = originalTags[idx]; if (c == '[') { - assert(!inTag); + CATCH_ENFORCE( + !inTag, + "Found '[' inside a tag while registering test case '" + << _nameAndTags.name << "' at " << _lineInfo ); + inTag = true; tagStart = idx; } if (c == ']') { - assert(inTag); + CATCH_ENFORCE( + inTag, + "Found unmatched ']' while registering test case '" + << _nameAndTags.name << "' at " << _lineInfo ); + inTag = false; tagEnd = idx; assert(tagStart < tagEnd); @@ -153,7 +162,11 @@ namespace Catch { // it over to backing storage and actually reference the // backing storage in the saved tags StringRef tagStr = originalTags.substr(tagStart+1, tagEnd - tagStart - 1); - CATCH_ENFORCE(!tagStr.empty(), "Empty tags are not allowed"); + CATCH_ENFORCE( !tagStr.empty(), + "Found an empty tag while registering test case '" + << _nameAndTags.name << "' at " + << _lineInfo ); + enforceNotReservedTag(tagStr, lineInfo); properties |= parseSpecialTag(tagStr); // When copying a tag to the backing storage, we need to @@ -167,8 +180,12 @@ namespace Catch { // the tags. internalAppendTag(tagStr); } - (void)inTag; // Silence "set-but-unused" warning in release mode. } + CATCH_ENFORCE( !inTag, + "Found an unclosed tag while registering test case '" + << _nameAndTags.name << "' at " << _lineInfo ); + + // Add [.] if relevant if (isHidden()) { internalAppendTag("."_sr); diff --git a/external_imported/Catch2/src/catch2/catch_test_case_info.hpp b/external_imported/Catch2/src/catch2/catch_test_case_info.hpp index 5ff3e3e72..a2f4b43ec 100644 --- a/external_imported/Catch2/src/catch2/catch_test_case_info.hpp +++ b/external_imported/Catch2/src/catch2/catch_test_case_info.hpp @@ -8,10 +8,10 @@ #ifndef CATCH_TEST_CASE_INFO_HPP_INCLUDED #define CATCH_TEST_CASE_INFO_HPP_INCLUDED +#include #include #include #include -#include #include @@ -44,6 +44,7 @@ namespace Catch { }; class ITestInvoker; + struct NameAndTags; enum class TestCaseProperties : uint8_t { None = 0, diff --git a/external_imported/Catch2/src/catch2/catch_test_spec.cpp b/external_imported/Catch2/src/catch2/catch_test_spec.cpp index f27ce99c3..f32f9864c 100644 --- a/external_imported/Catch2/src/catch2/catch_test_spec.cpp +++ b/external_imported/Catch2/src/catch2/catch_test_spec.cpp @@ -6,6 +6,8 @@ // SPDX-License-Identifier: BSL-1.0 #include +#include +#include #include #include #include @@ -106,16 +108,18 @@ namespace Catch { return std::any_of( m_filters.begin(), m_filters.end(), [&]( Filter const& f ){ return f.matches( testCase ); } ); } - TestSpec::Matches TestSpec::matchesByFilter( std::vector const& testCases, IConfig const& config ) const - { - Matches matches( m_filters.size() ); - std::transform( m_filters.begin(), m_filters.end(), matches.begin(), [&]( Filter const& filter ){ + TestSpec::Matches TestSpec::matchesByFilter( std::vector const& testCases, IConfig const& config ) const { + Matches matches; + matches.reserve( m_filters.size() ); + for ( auto const& filter : m_filters ) { std::vector currentMatches; - for( auto const& test : testCases ) - if( isThrowSafe( test, config ) && filter.matches( test.getTestCaseInfo() ) ) + for ( auto const& test : testCases ) + if ( isThrowSafe( test, config ) && + filter.matches( test.getTestCaseInfo() ) ) currentMatches.emplace_back( &test ); - return FilterMatch{ extractFilterName(filter), currentMatches }; - } ); + matches.push_back( + FilterMatch{ extractFilterName( filter ), currentMatches } ); + } return matches; } diff --git a/external_imported/Catch2/src/catch2/catch_tostring.hpp b/external_imported/Catch2/src/catch2/catch_tostring.hpp index 904caa7e7..f3fb0beb7 100644 --- a/external_imported/Catch2/src/catch2/catch_tostring.hpp +++ b/external_imported/Catch2/src/catch2/catch_tostring.hpp @@ -116,7 +116,6 @@ namespace Catch { } // namespace Detail - // If we decide for C++14, change these to enable_if_ts template struct StringMaker { template @@ -399,6 +398,12 @@ namespace Catch { } } }; + template <> + struct StringMaker { + static std::string convert(const std::nullopt_t&) { + return "{ }"; + } + }; } #endif // CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER diff --git a/external_imported/Catch2/src/catch2/catch_translate_exception.cpp b/external_imported/Catch2/src/catch2/catch_translate_exception.cpp new file mode 100644 index 000000000..c4b289449 --- /dev/null +++ b/external_imported/Catch2/src/catch2/catch_translate_exception.cpp @@ -0,0 +1,20 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include +#include + +namespace Catch { + namespace Detail { + void registerTranslatorImpl( + Detail::unique_ptr&& translator ) { + getMutableRegistryHub().registerTranslator( + CATCH_MOVE( translator ) ); + } + } // namespace Detail +} // namespace Catch diff --git a/external_imported/Catch2/src/catch2/catch_translate_exception.hpp b/external_imported/Catch2/src/catch2/catch_translate_exception.hpp index 2dbeb17e8..5a4dc5e37 100644 --- a/external_imported/Catch2/src/catch2/catch_translate_exception.hpp +++ b/external_imported/Catch2/src/catch2/catch_translate_exception.hpp @@ -15,6 +15,10 @@ #include namespace Catch { + namespace Detail { + void registerTranslatorImpl( + Detail::unique_ptr&& translator ); + } class ExceptionTranslatorRegistrar { template @@ -48,9 +52,9 @@ namespace Catch { public: template ExceptionTranslatorRegistrar( std::string(*translateFunction)( T const& ) ) { - getMutableRegistryHub().registerTranslator( - Detail::make_unique>(translateFunction) - ); + Detail::registerTranslatorImpl( + Detail::make_unique>( + translateFunction ) ); } }; diff --git a/external_imported/Catch2/src/catch2/catch_user_config.hpp.in b/external_imported/Catch2/src/catch2/catch_user_config.hpp.in index 3f6b10e89..10d61937f 100644 --- a/external_imported/Catch2/src/catch2/catch_user_config.hpp.in +++ b/external_imported/Catch2/src/catch2/catch_user_config.hpp.in @@ -169,9 +169,18 @@ #endif +#cmakedefine CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT +#cmakedefine CATCH_CONFIG_NO_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT + +#if defined( CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT ) && \ + defined( CATCH_CONFIG_NO_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT ) +# error Cannot force STATIC_ANALYSIS_SUPPORT to both ON and OFF +#endif + + // ------ // Simple toggle defines -// their value is never used and they cannot be overriden +// their value is never used and they cannot be overridden // ------ @@ -189,6 +198,7 @@ #cmakedefine CATCH_CONFIG_FAST_COMPILE #cmakedefine CATCH_CONFIG_NOSTDOUT #cmakedefine CATCH_CONFIG_PREFIX_ALL +#cmakedefine CATCH_CONFIG_PREFIX_MESSAGES #cmakedefine CATCH_CONFIG_WINDOWS_CRTDBG #cmakedefine CATCH_CONFIG_SHARED_LIBRARY diff --git a/external_imported/Catch2/src/catch2/catch_version.cpp b/external_imported/Catch2/src/catch2/catch_version.cpp index 19cab91b3..4e67d968c 100644 --- a/external_imported/Catch2/src/catch2/catch_version.cpp +++ b/external_imported/Catch2/src/catch2/catch_version.cpp @@ -36,7 +36,7 @@ namespace Catch { } Version const& libraryVersion() { - static Version version( 3, 3, 2, "", 0 ); + static Version version( 3, 5, 2, "", 0 ); return version; } diff --git a/external_imported/Catch2/src/catch2/catch_version_macros.hpp b/external_imported/Catch2/src/catch2/catch_version_macros.hpp index 9ece85051..be2a04d2f 100644 --- a/external_imported/Catch2/src/catch2/catch_version_macros.hpp +++ b/external_imported/Catch2/src/catch2/catch_version_macros.hpp @@ -9,7 +9,7 @@ #define CATCH_VERSION_MACROS_HPP_INCLUDED #define CATCH_VERSION_MAJOR 3 -#define CATCH_VERSION_MINOR 3 +#define CATCH_VERSION_MINOR 5 #define CATCH_VERSION_PATCH 2 #endif // CATCH_VERSION_MACROS_HPP_INCLUDED diff --git a/external_imported/Catch2/src/catch2/generators/catch_generators.hpp b/external_imported/Catch2/src/catch2/generators/catch_generators.hpp index 117f19019..0f35a9968 100644 --- a/external_imported/Catch2/src/catch2/generators/catch_generators.hpp +++ b/external_imported/Catch2/src/catch2/generators/catch_generators.hpp @@ -37,12 +37,6 @@ namespace Detail { } public: - ~IGenerator() override = default; - IGenerator() = default; - IGenerator(IGenerator const&) = default; - IGenerator& operator=(IGenerator const&) = default; - - // Returns the current element of the generator // // \Precondition The generator is either freshly constructed, diff --git a/external_imported/Catch2/src/catch2/generators/catch_generators_random.cpp b/external_imported/Catch2/src/catch2/generators/catch_generators_random.cpp index 2e3390fdf..00a8e634f 100644 --- a/external_imported/Catch2/src/catch2/generators/catch_generators_random.cpp +++ b/external_imported/Catch2/src/catch2/generators/catch_generators_random.cpp @@ -7,7 +7,35 @@ // SPDX-License-Identifier: BSL-1.0 #include - #include -std::uint32_t Catch::Generators::Detail::getSeed() { return sharedRng()(); } +#include + +namespace Catch { + namespace Generators { + namespace Detail { + std::uint32_t getSeed() { return sharedRng()(); } + } // namespace Detail + + struct RandomFloatingGenerator::PImpl { + PImpl( long double a, long double b, uint32_t seed ): + rng( seed ), dist( a, b ) {} + + Catch::SimplePcg32 rng; + std::uniform_real_distribution dist; + }; + + RandomFloatingGenerator::RandomFloatingGenerator( + long double a, long double b, std::uint32_t seed) : + m_pimpl(Catch::Detail::make_unique(a, b, seed)) { + static_cast( next() ); + } + + RandomFloatingGenerator::~RandomFloatingGenerator() = + default; + bool RandomFloatingGenerator::next() { + m_current_number = m_pimpl->dist( m_pimpl->rng ); + return true; + } + } // namespace Generators +} // namespace Catch diff --git a/external_imported/Catch2/src/catch2/generators/catch_generators_random.hpp b/external_imported/Catch2/src/catch2/generators/catch_generators_random.hpp index bcd4888dc..712835619 100644 --- a/external_imported/Catch2/src/catch2/generators/catch_generators_random.hpp +++ b/external_imported/Catch2/src/catch2/generators/catch_generators_random.hpp @@ -8,11 +8,11 @@ #ifndef CATCH_GENERATORS_RANDOM_HPP_INCLUDED #define CATCH_GENERATORS_RANDOM_HPP_INCLUDED -#include #include #include - -#include +#include +#include +#include namespace Catch { namespace Generators { @@ -26,7 +26,7 @@ namespace Detail { template class RandomFloatingGenerator final : public IGenerator { Catch::SimplePcg32 m_rng; - std::uniform_real_distribution m_dist; + Catch::uniform_floating_point_distribution m_dist; Float m_current_number; public: RandomFloatingGenerator( Float a, Float b, std::uint32_t seed ): @@ -44,10 +44,27 @@ class RandomFloatingGenerator final : public IGenerator { } }; +template <> +class RandomFloatingGenerator final : public IGenerator { + // We still rely on for this specialization, but we don't + // want to drag it into the header. + struct PImpl; + Catch::Detail::unique_ptr m_pimpl; + long double m_current_number; + +public: + RandomFloatingGenerator( long double a, long double b, std::uint32_t seed ); + + long double const& get() const override { return m_current_number; } + bool next() override; + + ~RandomFloatingGenerator() override; // = default +}; + template class RandomIntegerGenerator final : public IGenerator { Catch::SimplePcg32 m_rng; - std::uniform_int_distribution m_dist; + Catch::uniform_integer_distribution m_dist; Integer m_current_number; public: RandomIntegerGenerator( Integer a, Integer b, std::uint32_t seed ): @@ -68,14 +85,6 @@ class RandomIntegerGenerator final : public IGenerator { template std::enable_if_t::value, GeneratorWrapper> random(T a, T b) { - static_assert( - !std::is_same::value && - !std::is_same::value && - !std::is_same::value && - !std::is_same::value && - !std::is_same::value && - !std::is_same::value, - "The requested type is not supported by the underlying random distributions from std" ); return GeneratorWrapper( Catch::Detail::make_unique>(a, b, Detail::getSeed()) ); diff --git a/external_imported/Catch2/src/catch2/generators/catch_generators_range.hpp b/external_imported/Catch2/src/catch2/generators/catch_generators_range.hpp index 495acb950..b67c1590e 100644 --- a/external_imported/Catch2/src/catch2/generators/catch_generators_range.hpp +++ b/external_imported/Catch2/src/catch2/generators/catch_generators_range.hpp @@ -96,10 +96,11 @@ GeneratorWrapper from_range(InputIterator from, InputSentinel to) { return GeneratorWrapper(Catch::Detail::make_unique>(from, to)); } -template -GeneratorWrapper from_range(Container const& cnt) { - return GeneratorWrapper(Catch::Detail::make_unique>(cnt.begin(), cnt.end())); +template +auto from_range(Container const& cnt) { + using std::begin; + using std::end; + return from_range( begin( cnt ), end( cnt ) ); } diff --git a/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_all.hpp b/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_all.hpp index 87b746d8c..a99fdcdc9 100644 --- a/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_all.hpp +++ b/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_all.hpp @@ -30,8 +30,8 @@ #include #include #include -#include #include +#include #include #endif // CATCH_INTERFACES_ALL_HPP_INCLUDED diff --git a/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_capture.hpp b/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_capture.hpp index 2a469c12b..a1876a4ca 100644 --- a/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_capture.hpp +++ b/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_capture.hpp @@ -14,6 +14,7 @@ #include #include #include +#include namespace Catch { @@ -31,8 +32,6 @@ namespace Catch { class IGeneratorTracker; struct BenchmarkInfo; - template > - struct BenchmarkStats; namespace Generators { class GeneratorUntypedBase; @@ -44,6 +43,7 @@ namespace Catch { public: virtual ~IResultCapture(); + virtual void notifyAssertionStarted( AssertionInfo const& info ) = 0; virtual bool sectionStarted( StringRef sectionName, SourceLineInfo const& sectionLineInfo, Counts& assertions ) = 0; @@ -84,7 +84,7 @@ namespace Catch { AssertionReaction& reaction ) = 0; virtual void handleUnexpectedInflightException ( AssertionInfo const& info, - std::string const& message, + std::string&& message, AssertionReaction& reaction ) = 0; virtual void handleIncomplete ( AssertionInfo const& info ) = 0; diff --git a/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_exception.hpp b/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_exception.hpp index 9177666ae..fcc2a8f9c 100644 --- a/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_exception.hpp +++ b/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_exception.hpp @@ -8,7 +8,6 @@ #ifndef CATCH_INTERFACES_EXCEPTION_HPP_INCLUDED #define CATCH_INTERFACES_EXCEPTION_HPP_INCLUDED -#include #include #include diff --git a/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_registry_hub.hpp b/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_registry_hub.hpp index 8813b538d..113f223e8 100644 --- a/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_registry_hub.hpp +++ b/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_registry_hub.hpp @@ -19,7 +19,7 @@ namespace Catch { class ITestCaseRegistry; class IExceptionTranslatorRegistry; class IExceptionTranslator; - class IReporterRegistry; + class ReporterRegistry; class IReporterFactory; class ITagAliasRegistry; class ITestInvoker; @@ -35,7 +35,7 @@ namespace Catch { public: virtual ~IRegistryHub(); // = default - virtual IReporterRegistry const& getReporterRegistry() const = 0; + virtual ReporterRegistry const& getReporterRegistry() const = 0; virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0; virtual ITagAliasRegistry const& getTagAliasRegistry() const = 0; virtual IExceptionTranslatorRegistry const& getExceptionTranslatorRegistry() const = 0; diff --git a/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_reporter.cpp b/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_reporter.cpp index 67c5c80ed..90536bb36 100644 --- a/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_reporter.cpp +++ b/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_reporter.cpp @@ -7,19 +7,11 @@ // SPDX-License-Identifier: BSL-1.0 #include #include -#include -#include #include -#include -#include -#include -#include #include #include -#include #include -#include namespace Catch { @@ -54,8 +46,6 @@ namespace Catch { infoMessages( _infoMessages ), totals( _totals ) { - assertionResult.m_resultData.lazyExpression.m_transientExpression = _assertionResult.m_resultData.lazyExpression.m_transientExpression; - if( assertionResult.hasMessage() ) { // Copy message into messages list. // !TBD This should have been done earlier, somewhere diff --git a/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_reporter.hpp b/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_reporter.hpp index cf414f10e..a052c5db1 100644 --- a/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_reporter.hpp +++ b/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_reporter.hpp @@ -13,11 +13,9 @@ #include #include #include +#include #include -#include -#include -#include - +#include #include #include @@ -57,11 +55,6 @@ namespace Catch { std::map m_customOptions; }; - struct TestRunInfo { - constexpr TestRunInfo(StringRef _name) : name(_name) {} - StringRef name; - }; - struct AssertionStats { AssertionStats( AssertionResult const& _assertionResult, std::vector const& _infoMessages, @@ -113,45 +106,6 @@ namespace Catch { bool aborting; }; - - struct BenchmarkInfo { - std::string name; - double estimatedDuration; - int iterations; - unsigned int samples; - unsigned int resamples; - double clockResolution; - double clockCost; - }; - - template - struct BenchmarkStats { - BenchmarkInfo info; - - std::vector samples; - Benchmark::Estimate mean; - Benchmark::Estimate standardDeviation; - Benchmark::OutlierClassification outliers; - double outlierVariance; - - template - operator BenchmarkStats() const { - std::vector samples2; - samples2.reserve(samples.size()); - for (auto const& sample : samples) { - samples2.push_back(Duration2(sample)); - } - return { - info, - CATCH_MOVE(samples2), - mean, - standardDeviation, - outliers, - outlierVariance, - }; - } - }; - //! By setting up its preferences, a reporter can modify Catch2's behaviour //! in some regards, e.g. it can request Catch2 to capture writes to //! stdout/stderr during test execution, and pass them to the reporter. @@ -250,7 +204,7 @@ namespace Catch { */ virtual void skipTest( TestCaseInfo const& testInfo ) = 0; - //! Called if a fatal error (signal/structured exception) occured + //! Called if a fatal error (signal/structured exception) occurred virtual void fatalErrorEncountered( StringRef error ) = 0; //! Writes out information about provided reporters using reporter-specific format diff --git a/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_reporter_registry.cpp b/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_reporter_registry.cpp deleted file mode 100644 index f620cbc8d..000000000 --- a/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_reporter_registry.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// Copyright Catch2 Authors -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.txt or copy at -// https://www.boost.org/LICENSE_1_0.txt) - -// SPDX-License-Identifier: BSL-1.0 - -#include - -namespace Catch { - IReporterRegistry::~IReporterRegistry() = default; -} diff --git a/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_reporter_registry.hpp b/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_reporter_registry.hpp deleted file mode 100644 index 277d1761b..000000000 --- a/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_reporter_registry.hpp +++ /dev/null @@ -1,42 +0,0 @@ - -// Copyright Catch2 Authors -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.txt or copy at -// https://www.boost.org/LICENSE_1_0.txt) - -// SPDX-License-Identifier: BSL-1.0 -#ifndef CATCH_INTERFACES_REPORTER_REGISTRY_HPP_INCLUDED -#define CATCH_INTERFACES_REPORTER_REGISTRY_HPP_INCLUDED - -#include -#include - -#include -#include -#include - -namespace Catch { - - class IConfig; - - class IEventListener; - using IEventListenerPtr = Detail::unique_ptr; - class IReporterFactory; - using IReporterFactoryPtr = Detail::unique_ptr; - struct ReporterConfig; - class EventListenerFactory; - - class IReporterRegistry { - public: - using FactoryMap = std::map; - using Listeners = std::vector>; - - virtual ~IReporterRegistry(); // = default - virtual IEventListenerPtr create( std::string const& name, ReporterConfig&& config ) const = 0; - virtual FactoryMap const& getFactories() const = 0; - virtual Listeners const& getListeners() const = 0; - }; - -} // end namespace Catch - -#endif // CATCH_INTERFACES_REPORTER_REGISTRY_HPP_INCLUDED diff --git a/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_test_invoker.hpp b/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_test_invoker.hpp new file mode 100644 index 000000000..3caeff9a3 --- /dev/null +++ b/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_test_invoker.hpp @@ -0,0 +1,21 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 +#ifndef CATCH_INTERFACES_TEST_INVOKER_HPP_INCLUDED +#define CATCH_INTERFACES_TEST_INVOKER_HPP_INCLUDED + +namespace Catch { + + class ITestInvoker { + public: + virtual void invoke() const = 0; + virtual ~ITestInvoker(); // = default + }; + +} // namespace Catch + +#endif // CATCH_INTERFACES_TEST_INVOKER_HPP_INCLUDED diff --git a/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_testcase.cpp b/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_testcase.cpp index 5e632ba89..a543116c3 100644 --- a/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_testcase.cpp +++ b/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_testcase.cpp @@ -9,6 +9,5 @@ #include namespace Catch { - ITestInvoker::~ITestInvoker() = default; ITestCaseRegistry::~ITestCaseRegistry() = default; } diff --git a/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_testcase.hpp b/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_testcase.hpp index 78ee20216..daee84829 100644 --- a/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_testcase.hpp +++ b/external_imported/Catch2/src/catch2/interfaces/catch_interfaces_testcase.hpp @@ -12,15 +12,7 @@ namespace Catch { - class TestSpec; struct TestCaseInfo; - - class ITestInvoker { - public: - virtual void invoke () const = 0; - virtual ~ITestInvoker(); // = default - }; - class TestCaseHandle; class IConfig; @@ -33,11 +25,6 @@ namespace Catch { virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0; }; - bool isThrowSafe( TestCaseHandle const& testCase, IConfig const& config ); - bool matchTest( TestCaseHandle const& testCase, TestSpec const& testSpec, IConfig const& config ); - std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); - std::vector const& getAllTestCasesSorted( IConfig const& config ); - } #endif // CATCH_INTERFACES_TESTCASE_HPP_INCLUDED diff --git a/external_imported/Catch2/src/catch2/internal/catch_assertion_handler.cpp b/external_imported/Catch2/src/catch2/internal/catch_assertion_handler.cpp index 0b14e0bba..f650a7073 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_assertion_handler.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_assertion_handler.cpp @@ -8,11 +8,8 @@ #include #include #include -#include #include #include -#include -#include #include namespace Catch { @@ -24,7 +21,9 @@ namespace Catch { ResultDisposition::Flags resultDisposition ) : m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition }, m_resultCapture( getResultCapture() ) - {} + { + m_resultCapture.notifyAssertionStarted( m_assertionInfo ); + } void AssertionHandler::handleExpr( ITransientExpression const& expr ) { m_resultCapture.handleExpr( m_assertionInfo, expr, m_reaction ); @@ -38,7 +37,7 @@ namespace Catch { } void AssertionHandler::complete() { - setCompleted(); + m_completed = true; if( m_reaction.shouldDebugBreak ) { // If you find your debugger stopping you here then go one level up on the @@ -51,16 +50,9 @@ namespace Catch { throw_test_failure_exception(); } if ( m_reaction.shouldSkip ) { -#if !defined( CATCH_CONFIG_DISABLE_EXCEPTIONS ) - throw Catch::TestSkipException(); -#else - CATCH_ERROR( "Explicitly skipping tests during runtime requires exceptions" ); -#endif + throw_test_skip_exception(); } } - void AssertionHandler::setCompleted() { - m_completed = true; - } void AssertionHandler::handleUnexpectedInflightException() { m_resultCapture.handleUnexpectedInflightException( m_assertionInfo, Catch::translateActiveException(), m_reaction ); diff --git a/external_imported/Catch2/src/catch2/internal/catch_assertion_handler.hpp b/external_imported/Catch2/src/catch2/internal/catch_assertion_handler.hpp index ae7776d8b..01dd7801d 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_assertion_handler.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_assertion_handler.hpp @@ -11,14 +11,11 @@ #include #include #include -#include #include namespace Catch { - class IResultCapture; - struct AssertionReaction { bool shouldDebugBreak = false; bool shouldThrow = false; @@ -59,7 +56,6 @@ namespace Catch { void handleUnexpectedInflightException(); void complete(); - void setCompleted(); // query auto allowThrows() const -> bool; diff --git a/external_imported/Catch2/src/catch2/internal/catch_clara.cpp b/external_imported/Catch2/src/catch2/internal/catch_clara.cpp index c9bc76959..c76089eea 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_clara.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_clara.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -24,13 +25,29 @@ namespace { ; } - std::string normaliseOpt( std::string const& optName ) { -#ifdef CATCH_PLATFORM_WINDOWS - if ( optName[0] == '/' ) - return "-" + optName.substr( 1 ); - else + Catch::StringRef normaliseOpt( Catch::StringRef optName ) { + if ( optName[0] == '-' +#if defined(CATCH_PLATFORM_WINDOWS) + || optName[0] == '/' #endif - return optName; + ) { + return optName.substr( 1, optName.size() ); + } + + return optName; + } + + static size_t find_first_separator(Catch::StringRef sr) { + auto is_separator = []( char c ) { + return c == ' ' || c == ':' || c == '='; + }; + size_t pos = 0; + while (pos < sr.size()) { + if (is_separator(sr[pos])) { return pos; } + ++pos; + } + + return Catch::StringRef::npos; } } // namespace @@ -48,23 +65,23 @@ namespace Catch { } if ( it != itEnd ) { - auto const& next = *it; + StringRef next = *it; if ( isOptPrefix( next[0] ) ) { - auto delimiterPos = next.find_first_of( " :=" ); - if ( delimiterPos != std::string::npos ) { + auto delimiterPos = find_first_separator(next); + if ( delimiterPos != StringRef::npos ) { m_tokenBuffer.push_back( { TokenType::Option, next.substr( 0, delimiterPos ) } ); m_tokenBuffer.push_back( { TokenType::Argument, - next.substr( delimiterPos + 1 ) } ); + next.substr( delimiterPos + 1, next.size() ) } ); } else { if ( next[1] != '-' && next.size() > 2 ) { - std::string opt = "- "; + // Combined short args, e.g. "-ab" for "-a -b" for ( size_t i = 1; i < next.size(); ++i ) { - opt[1] = next[i]; m_tokenBuffer.push_back( - { TokenType::Option, opt } ); + { TokenType::Option, + next.substr( i, 1 ) } ); } } else { m_tokenBuffer.push_back( @@ -124,12 +141,12 @@ namespace Catch { size_t ParserBase::cardinality() const { return 1; } InternalParseResult ParserBase::parse( Args const& args ) const { - return parse( args.exeName(), TokenStream( args ) ); + return parse( static_cast(args.exeName()), TokenStream( args ) ); } ParseState::ParseState( ParseResultType type, - TokenStream const& remainingTokens ): - m_type( type ), m_remainingTokens( remainingTokens ) {} + TokenStream remainingTokens ): + m_type( type ), m_remainingTokens( CATCH_MOVE(remainingTokens) ) {} ParserResult BoundFlagRef::setFlag( bool flag ) { m_ref = flag; @@ -147,34 +164,34 @@ namespace Catch { } // namespace Detail Detail::InternalParseResult Arg::parse(std::string const&, - Detail::TokenStream const& tokens) const { + Detail::TokenStream tokens) const { auto validationResult = validate(); if (!validationResult) return Detail::InternalParseResult(validationResult); - auto remainingTokens = tokens; - auto const& token = *remainingTokens; + auto token = *tokens; if (token.type != Detail::TokenType::Argument) return Detail::InternalParseResult::ok(Detail::ParseState( - ParseResultType::NoMatch, remainingTokens)); + ParseResultType::NoMatch, CATCH_MOVE(tokens))); assert(!m_ref->isFlag()); auto valueRef = static_cast(m_ref.get()); - auto result = valueRef->setValue(remainingTokens->token); - if (!result) - return Detail::InternalParseResult(result); + auto result = valueRef->setValue(static_cast(token.token)); + if ( !result ) + return Detail::InternalParseResult( result ); else - return Detail::InternalParseResult::ok(Detail::ParseState( - ParseResultType::Matched, ++remainingTokens)); + return Detail::InternalParseResult::ok( + Detail::ParseState( ParseResultType::Matched, + CATCH_MOVE( ++tokens ) ) ); } Opt::Opt(bool& ref) : ParserRefImpl(std::make_shared(ref)) {} - std::vector Opt::getHelpColumns() const { - std::ostringstream oss; + Detail::HelpColumns Opt::getHelpColumns() const { + ReusableStringStream oss; bool first = true; for (auto const& opt : m_optNames) { if (first) @@ -185,10 +202,10 @@ namespace Catch { } if (!m_hint.empty()) oss << " <" << m_hint << '>'; - return { { oss.str(), m_description } }; + return { oss.str(), m_description }; } - bool Opt::isMatch(std::string const& optToken) const { + bool Opt::isMatch(StringRef optToken) const { auto normalisedToken = normaliseOpt(optToken); for (auto const& name : m_optNames) { if (normaliseOpt(name) == normalisedToken) @@ -198,15 +215,14 @@ namespace Catch { } Detail::InternalParseResult Opt::parse(std::string const&, - Detail::TokenStream const& tokens) const { + Detail::TokenStream tokens) const { auto validationResult = validate(); if (!validationResult) return Detail::InternalParseResult(validationResult); - auto remainingTokens = tokens; - if (remainingTokens && - remainingTokens->type == Detail::TokenType::Option) { - auto const& token = *remainingTokens; + if (tokens && + tokens->type == Detail::TokenType::Option) { + auto const& token = *tokens; if (isMatch(token.token)) { if (m_ref->isFlag()) { auto flagRef = @@ -218,35 +234,35 @@ namespace Catch { if (result.value() == ParseResultType::ShortCircuitAll) return Detail::InternalParseResult::ok(Detail::ParseState( - result.value(), remainingTokens)); + result.value(), CATCH_MOVE(tokens))); } else { auto valueRef = static_cast( m_ref.get()); - ++remainingTokens; - if (!remainingTokens) + ++tokens; + if (!tokens) return Detail::InternalParseResult::runtimeError( "Expected argument following " + token.token); - auto const& argToken = *remainingTokens; + auto const& argToken = *tokens; if (argToken.type != Detail::TokenType::Argument) return Detail::InternalParseResult::runtimeError( "Expected argument following " + token.token); - const auto result = valueRef->setValue(argToken.token); + const auto result = valueRef->setValue(static_cast(argToken.token)); if (!result) return Detail::InternalParseResult(result); if (result.value() == ParseResultType::ShortCircuitAll) return Detail::InternalParseResult::ok(Detail::ParseState( - result.value(), remainingTokens)); + result.value(), CATCH_MOVE(tokens))); } return Detail::InternalParseResult::ok(Detail::ParseState( - ParseResultType::Matched, ++remainingTokens)); + ParseResultType::Matched, CATCH_MOVE(++tokens))); } } return Detail::InternalParseResult::ok( - Detail::ParseState(ParseResultType::NoMatch, remainingTokens)); + Detail::ParseState(ParseResultType::NoMatch, CATCH_MOVE(tokens))); } Detail::Result Opt::validate() const { @@ -278,9 +294,9 @@ namespace Catch { Detail::InternalParseResult ExeName::parse(std::string const&, - Detail::TokenStream const& tokens) const { + Detail::TokenStream tokens) const { return Detail::InternalParseResult::ok( - Detail::ParseState(ParseResultType::NoMatch, tokens)); + Detail::ParseState(ParseResultType::NoMatch, CATCH_MOVE(tokens))); } ParserResult ExeName::set(std::string const& newName) { @@ -310,9 +326,9 @@ namespace Catch { std::vector Parser::getHelpColumns() const { std::vector cols; + cols.reserve( m_options.size() ); for ( auto const& o : m_options ) { - auto childCols = o.getHelpColumns(); - cols.insert( cols.end(), childCols.begin(), childCols.end() ); + cols.push_back(o.getHelpColumns()); } return cols; } @@ -350,12 +366,12 @@ namespace Catch { optWidth = ( std::min )( optWidth, consoleWidth / 2 ); - for ( auto const& cols : rows ) { - auto row = TextFlow::Column( cols.left ) + for ( auto& cols : rows ) { + auto row = TextFlow::Column( CATCH_MOVE(cols.left) ) .width( optWidth ) .indent( 2 ) + TextFlow::Spacer( 4 ) + - TextFlow::Column( cols.right ) + TextFlow::Column( static_cast(cols.descriptions) ) .width( consoleWidth - 7 - optWidth ); os << row << '\n'; } @@ -377,7 +393,7 @@ namespace Catch { Detail::InternalParseResult Parser::parse( std::string const& exeName, - Detail::TokenStream const& tokens ) const { + Detail::TokenStream tokens ) const { struct ParserInfo { ParserBase const* parser = nullptr; @@ -395,7 +411,7 @@ namespace Catch { m_exeName.set( exeName ); auto result = Detail::InternalParseResult::ok( - Detail::ParseState( ParseResultType::NoMatch, tokens ) ); + Detail::ParseState( ParseResultType::NoMatch, CATCH_MOVE(tokens) ) ); while ( result.value().remainingTokens() ) { bool tokenParsed = false; @@ -403,7 +419,7 @@ namespace Catch { if ( parseInfo.parser->cardinality() == 0 || parseInfo.count < parseInfo.parser->cardinality() ) { result = parseInfo.parser->parse( - exeName, result.value().remainingTokens() ); + exeName, CATCH_MOVE(result).value().remainingTokens() ); if ( !result ) return result; if ( result.value().type() != @@ -429,7 +445,7 @@ namespace Catch { Args::Args(int argc, char const* const* argv) : m_exeName(argv[0]), m_args(argv + 1, argv + argc) {} - Args::Args(std::initializer_list args) : + Args::Args(std::initializer_list args) : m_exeName(*args.begin()), m_args(args.begin() + 1, args.end()) {} diff --git a/external_imported/Catch2/src/catch2/internal/catch_clara.hpp b/external_imported/Catch2/src/catch2/internal/catch_clara.hpp index 9117b65e8..d869593bf 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_clara.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_clara.hpp @@ -29,6 +29,7 @@ # endif #endif +#include #include #include #include @@ -101,17 +102,16 @@ namespace Catch { enum class TokenType { Option, Argument }; struct Token { TokenType type; - std::string token; + StringRef token; }; // Abstracts iterators into args as a stream of tokens, with option // arguments uniformly handled class TokenStream { - using Iterator = std::vector::const_iterator; + using Iterator = std::vector::const_iterator; Iterator it; Iterator itEnd; std::vector m_tokenBuffer; - void loadBuffer(); public: @@ -163,12 +163,17 @@ namespace Catch { ResultType m_type; }; - template class ResultValueBase : public ResultBase { + template + class ResultValueBase : public ResultBase { public: - auto value() const -> T const& { + T const& value() const& { enforceOk(); return m_value; } + T&& value() && { + enforceOk(); + return CATCH_MOVE( m_value ); + } protected: ResultValueBase( ResultType type ): ResultBase( type ) {} @@ -178,13 +183,23 @@ namespace Catch { if ( m_type == ResultType::Ok ) new ( &m_value ) T( other.m_value ); } + ResultValueBase( ResultValueBase&& other ): + ResultBase( other ) { + if ( m_type == ResultType::Ok ) + new ( &m_value ) T( CATCH_MOVE(other.m_value) ); + } + - ResultValueBase( ResultType, T const& value ): ResultBase( ResultType::Ok ) { + ResultValueBase( ResultType, T const& value ): + ResultBase( ResultType::Ok ) { new ( &m_value ) T( value ); } + ResultValueBase( ResultType, T&& value ): + ResultBase( ResultType::Ok ) { + new ( &m_value ) T( CATCH_MOVE(value) ); + } - auto operator=( ResultValueBase const& other ) - -> ResultValueBase& { + ResultValueBase& operator=( ResultValueBase const& other ) { if ( m_type == ResultType::Ok ) m_value.~T(); ResultBase::operator=( other ); @@ -192,6 +207,14 @@ namespace Catch { new ( &m_value ) T( other.m_value ); return *this; } + ResultValueBase& operator=( ResultValueBase&& other ) { + if ( m_type == ResultType::Ok ) m_value.~T(); + ResultBase::operator=( other ); + if ( m_type == ResultType::Ok ) + new ( &m_value ) T( CATCH_MOVE(other.m_value) ); + return *this; + } + ~ResultValueBase() override { if ( m_type == ResultType::Ok ) @@ -219,8 +242,8 @@ namespace Catch { } template - static auto ok( U const& value ) -> BasicResult { - return { ResultType::Ok, value }; + static auto ok( U&& value ) -> BasicResult { + return { ResultType::Ok, CATCH_FORWARD(value) }; } static auto ok() -> BasicResult { return { ResultType::Ok }; } static auto logicError( std::string&& message ) @@ -267,12 +290,15 @@ namespace Catch { class ParseState { public: ParseState( ParseResultType type, - TokenStream const& remainingTokens ); + TokenStream remainingTokens ); ParseResultType type() const { return m_type; } - TokenStream const& remainingTokens() const { + TokenStream const& remainingTokens() const& { return m_remainingTokens; } + TokenStream&& remainingTokens() && { + return CATCH_MOVE( m_remainingTokens ); + } private: ParseResultType m_type; @@ -285,7 +311,7 @@ namespace Catch { struct HelpColumns { std::string left; - std::string right; + StringRef descriptions; }; template @@ -445,7 +471,7 @@ namespace Catch { virtual ~ParserBase() = default; virtual auto validate() const -> Result { return Result::ok(); } virtual auto parse( std::string const& exeName, - TokenStream const& tokens ) const + TokenStream tokens ) const -> InternalParseResult = 0; virtual size_t cardinality() const; @@ -465,8 +491,8 @@ namespace Catch { protected: Optionality m_optionality = Optionality::Optional; std::shared_ptr m_ref; - std::string m_hint; - std::string m_description; + StringRef m_hint; + StringRef m_description; explicit ParserRefImpl( std::shared_ptr const& ref ): m_ref( ref ) {} @@ -475,28 +501,32 @@ namespace Catch { template ParserRefImpl( accept_many_t, LambdaT const& ref, - std::string const& hint ): + StringRef hint ): m_ref( std::make_shared>( ref ) ), m_hint( hint ) {} template ::value>> - ParserRefImpl( T& ref, std::string const& hint ): + ParserRefImpl( T& ref, StringRef hint ): m_ref( std::make_shared>( ref ) ), m_hint( hint ) {} template ::value>> - ParserRefImpl( LambdaT const& ref, std::string const& hint ): + ParserRefImpl( LambdaT const& ref, StringRef hint ): m_ref( std::make_shared>( ref ) ), m_hint( hint ) {} - auto operator()( std::string const& description ) -> DerivedT& { + DerivedT& operator()( StringRef description ) & { m_description = description; return static_cast( *this ); } + DerivedT&& operator()( StringRef description ) && { + m_description = description; + return static_cast( *this ); + } auto optional() -> DerivedT& { m_optionality = Optionality::Optional; @@ -519,7 +549,7 @@ namespace Catch { return 1; } - std::string const& hint() const { return m_hint; } + StringRef hint() const { return m_hint; } }; } // namespace detail @@ -533,13 +563,13 @@ namespace Catch { Detail::InternalParseResult parse(std::string const&, - Detail::TokenStream const& tokens) const override; + Detail::TokenStream tokens) const override; }; // A parser for options class Opt : public Detail::ParserRefImpl { protected: - std::vector m_optNames; + std::vector m_optNames; public: template @@ -552,33 +582,37 @@ namespace Catch { template ::value>> - Opt( LambdaT const& ref, std::string const& hint ): + Opt( LambdaT const& ref, StringRef hint ): ParserRefImpl( ref, hint ) {} template - Opt( accept_many_t, LambdaT const& ref, std::string const& hint ): + Opt( accept_many_t, LambdaT const& ref, StringRef hint ): ParserRefImpl( accept_many, ref, hint ) {} template ::value>> - Opt( T& ref, std::string const& hint ): + Opt( T& ref, StringRef hint ): ParserRefImpl( ref, hint ) {} - auto operator[](std::string const& optName) -> Opt& { + Opt& operator[]( StringRef optName ) & { m_optNames.push_back(optName); return *this; } + Opt&& operator[]( StringRef optName ) && { + m_optNames.push_back( optName ); + return CATCH_MOVE(*this); + } - std::vector getHelpColumns() const; + Detail::HelpColumns getHelpColumns() const; - bool isMatch(std::string const& optToken) const; + bool isMatch(StringRef optToken) const; using ParserBase::parse; Detail::InternalParseResult parse(std::string const&, - Detail::TokenStream const& tokens) const override; + Detail::TokenStream tokens) const override; Detail::Result validate() const override; }; @@ -601,7 +635,7 @@ namespace Catch { // handled specially Detail::InternalParseResult parse(std::string const&, - Detail::TokenStream const& tokens) const override; + Detail::TokenStream tokens) const override; std::string const& name() const { return *m_name; } Detail::ParserResult set(std::string const& newName); @@ -626,16 +660,28 @@ namespace Catch { return *this; } - auto operator|=(Opt const& opt) -> Parser& { - m_options.push_back(opt); - return *this; + friend Parser& operator|=( Parser& p, Opt const& opt ) { + p.m_options.push_back( opt ); + return p; + } + friend Parser& operator|=( Parser& p, Opt&& opt ) { + p.m_options.push_back( CATCH_MOVE(opt) ); + return p; } Parser& operator|=(Parser const& other); template - auto operator|(T const& other) const -> Parser { - return Parser(*this) |= other; + friend Parser operator|( Parser const& p, T&& rhs ) { + Parser temp( p ); + temp |= rhs; + return temp; + } + + template + friend Parser operator|( Parser&& p, T&& rhs ) { + p |= CATCH_FORWARD(rhs); + return CATCH_MOVE(p); } std::vector getHelpColumns() const; @@ -653,21 +699,23 @@ namespace Catch { using ParserBase::parse; Detail::InternalParseResult parse(std::string const& exeName, - Detail::TokenStream const& tokens) const override; + Detail::TokenStream tokens) const override; }; - // Transport for raw args (copied from main args, or supplied via - // init list for testing) + /** + * Wrapper over argc + argv, assumes that the inputs outlive it + */ class Args { friend Detail::TokenStream; - std::string m_exeName; - std::vector m_args; + StringRef m_exeName; + std::vector m_args; public: Args(int argc, char const* const* argv); - Args(std::initializer_list args); + // Helper constructor for testing + Args(std::initializer_list args); - std::string const& exeName() const { return m_exeName; } + StringRef exeName() const { return m_exeName; } }; diff --git a/external_imported/Catch2/src/catch2/internal/catch_commandline.cpp b/external_imported/Catch2/src/catch2/internal/catch_commandline.cpp index 81aa073c8..c29a801d3 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_commandline.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_commandline.cpp @@ -9,8 +9,9 @@ #include #include +#include #include -#include +#include #include #include #include @@ -144,7 +145,7 @@ namespace Catch { auto const& reporterSpec = *parsed; - IReporterRegistry::FactoryMap const& factories = + auto const& factories = getRegistryHub().getReporterRegistry().getFactories(); auto result = factories.find( reporterSpec.name() ); @@ -300,8 +301,8 @@ namespace Catch { ( "split the tests to execute into this many groups" ) | Opt( setShardIndex, "shard index" ) ["--shard-index"] - ( "index of the group of tests to execute (see --shard-count)" ) | - Opt( config.allowZeroTests ) + ( "index of the group of tests to execute (see --shard-count)" ) + | Opt( config.allowZeroTests ) ["--allow-running-no-tests"] ( "Treat 'No tests run' as a success" ) | Arg( config.testsOrTags, "test name|pattern|tags" ) diff --git a/external_imported/Catch2/src/catch2/internal/catch_compiler_capabilities.hpp b/external_imported/Catch2/src/catch2/internal/catch_compiler_capabilities.hpp index 42631a5f1..dacae01b7 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_compiler_capabilities.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_compiler_capabilities.hpp @@ -50,12 +50,18 @@ # define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ _Pragma( "GCC diagnostic ignored \"-Wparentheses\"" ) +# define CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT \ + _Pragma( "GCC diagnostic ignored \"-Wunused-result\"" ) + # define CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ _Pragma( "GCC diagnostic ignored \"-Wunused-variable\"" ) # define CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \ _Pragma( "GCC diagnostic ignored \"-Wuseless-cast\"" ) +# define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ + _Pragma( "GCC diagnostic ignored \"-Wshadow\"" ) + # define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) #endif @@ -128,6 +134,9 @@ # define CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS \ _Pragma( "clang diagnostic ignored \"-Wcomma\"" ) +# define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wshadow\"" ) + #endif // __clang__ @@ -147,7 +156,9 @@ //////////////////////////////////////////////////////////////////////////////// // Assume that some platforms do not support getenv. -#if defined(CATCH_PLATFORM_WINDOWS_UWP) || defined(CATCH_PLATFORM_PLAYSTATION) +#if defined( CATCH_PLATFORM_WINDOWS_UWP ) || \ + defined( CATCH_PLATFORM_PLAYSTATION ) || \ + defined( _GAMING_XBOX ) # define CATCH_INTERNAL_CONFIG_NO_GETENV #else # define CATCH_INTERNAL_CONFIG_GETENV @@ -365,6 +376,9 @@ #if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) # define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS #endif +#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT) +# define CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT +#endif #if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS) # define CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS #endif @@ -374,6 +388,16 @@ #if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS) # define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS #endif +#if !defined( CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS ) +# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS +#endif +#if !defined( CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS ) +# define CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS +#endif +#if !defined( CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS ) +# define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS +#endif + // The goal of this macro is to avoid evaluation of the arguments, but // still have the compiler warn on problems inside... @@ -387,13 +411,6 @@ # undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS #endif -#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#endif - -#if !defined(CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS -#endif #if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) #define CATCH_TRY if ((true)) diff --git a/external_imported/Catch2/src/catch2/internal/catch_config_counter.hpp b/external_imported/Catch2/src/catch2/internal/catch_config_counter.hpp index 23b223245..a482ce346 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_config_counter.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_config_counter.hpp @@ -18,6 +18,8 @@ #ifndef CATCH_CONFIG_COUNTER_HPP_INCLUDED #define CATCH_CONFIG_COUNTER_HPP_INCLUDED +#include + #if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) #define CATCH_INTERNAL_CONFIG_COUNTER #endif diff --git a/external_imported/Catch2/src/catch2/internal/catch_config_prefix_messages.hpp b/external_imported/Catch2/src/catch2/internal/catch_config_prefix_messages.hpp new file mode 100644 index 000000000..be1e9a963 --- /dev/null +++ b/external_imported/Catch2/src/catch2/internal/catch_config_prefix_messages.hpp @@ -0,0 +1,29 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +/** \file + * Wrapper for the CATCH_CONFIG_PREFIX_MESSAGES configuration option + * + * CATCH_CONFIG_PREFIX_ALL can be used to avoid clashes with other macros + * by prepending CATCH_. This may not be desirable if the only clashes are with + * logger macros such as INFO and WARN. In this cases + * CATCH_CONFIG_PREFIX_MESSAGES can be used to only prefix a small subset + * of relevant macros. + * + */ + +#ifndef CATCH_CONFIG_PREFIX_MESSAGES_HPP_INCLUDED +#define CATCH_CONFIG_PREFIX_MESSAGES_HPP_INCLUDED + +#include + +#if defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_PREFIX_MESSAGES) + #define CATCH_CONFIG_PREFIX_MESSAGES +#endif + +#endif // CATCH_CONFIG_PREFIX_MESSAGES_HPP_INCLUDED diff --git a/external_imported/Catch2/src/catch2/internal/catch_config_static_analysis_support.hpp b/external_imported/Catch2/src/catch2/internal/catch_config_static_analysis_support.hpp new file mode 100644 index 000000000..81bdf39f4 --- /dev/null +++ b/external_imported/Catch2/src/catch2/internal/catch_config_static_analysis_support.hpp @@ -0,0 +1,34 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +/** \file + * Wrapper for the STATIC_ANALYSIS_SUPPORT configuration option + * + * Some of Catch2's macros can be defined differently to work better with + * static analysis tools, like clang-tidy or coverity. + * Currently the main use case is to show that `SECTION`s are executed + * exclusively, and not all in one run of a `TEST_CASE`. + */ + +#ifndef CATCH_CONFIG_STATIC_ANALYSIS_SUPPORT_HPP_INCLUDED +#define CATCH_CONFIG_STATIC_ANALYSIS_SUPPORT_HPP_INCLUDED + +#include + +#if defined(__clang_analyzer__) || defined(__COVERITY__) + #define CATCH_INTERNAL_CONFIG_STATIC_ANALYSIS_SUPPORT +#endif + +#if defined( CATCH_INTERNAL_CONFIG_STATIC_ANALYSIS_SUPPORT ) && \ + !defined( CATCH_CONFIG_NO_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT ) && \ + !defined( CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT ) +# define CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT +#endif + + +#endif // CATCH_CONFIG_STATIC_ANALYSIS_SUPPORT_HPP_INCLUDED diff --git a/external_imported/Catch2/src/catch2/internal/catch_config_uncaught_exceptions.hpp b/external_imported/Catch2/src/catch2/internal/catch_config_uncaught_exceptions.hpp index 5c4cb9301..20b1dfca4 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_config_uncaught_exceptions.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_config_uncaught_exceptions.hpp @@ -17,6 +17,8 @@ #ifndef CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED #define CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED +#include + #if defined(_MSC_VER) # if _MSC_VER >= 1900 // Visual Studio 2015 or newer # define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS diff --git a/external_imported/Catch2/src/catch2/internal/catch_config_wchar.hpp b/external_imported/Catch2/src/catch2/internal/catch_config_wchar.hpp index 8c758ec43..90d85d055 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_config_wchar.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_config_wchar.hpp @@ -17,6 +17,8 @@ #ifndef CATCH_CONFIG_WCHAR_HPP_INCLUDED #define CATCH_CONFIG_WCHAR_HPP_INCLUDED +#include + // We assume that WCHAR should be enabled by default, and only disabled // for a shortlist (so far only DJGPP) of compilers. diff --git a/external_imported/Catch2/src/catch2/internal/catch_console_colour.cpp b/external_imported/Catch2/src/catch2/internal/catch_console_colour.cpp index 099a6c59b..e1238816a 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_console_colour.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_console_colour.cpp @@ -85,7 +85,7 @@ namespace Catch { namespace { //! A do-nothing implementation of colour, used as fallback for unknown //! platforms, and when the user asks to deactivate all colours. - class NoColourImpl : public ColourImpl { + class NoColourImpl final : public ColourImpl { public: NoColourImpl( IStream* stream ): ColourImpl( stream ) {} @@ -103,7 +103,7 @@ namespace Catch { namespace Catch { namespace { - class Win32ColourImpl : public ColourImpl { + class Win32ColourImpl final : public ColourImpl { public: Win32ColourImpl(IStream* stream): ColourImpl(stream) { @@ -169,7 +169,7 @@ namespace { namespace Catch { namespace { - class ANSIColourImpl : public ColourImpl { + class ANSIColourImpl final : public ColourImpl { public: ANSIColourImpl( IStream* stream ): ColourImpl( stream ) {} diff --git a/external_imported/Catch2/src/catch2/internal/catch_context.cpp b/external_imported/Catch2/src/catch2/internal/catch_context.cpp index 17f285097..3b1cc2774 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_context.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_context.cpp @@ -11,49 +11,27 @@ namespace Catch { - class Context : public IMutableContext, private Detail::NonCopyable { + Context* Context::currentContext = nullptr; - public: // IContext - IResultCapture* getResultCapture() override { - return m_resultCapture; - } - - IConfig const* getConfig() const override { - return m_config; - } - - ~Context() override; - - public: // IMutableContext - void setResultCapture( IResultCapture* resultCapture ) override { - m_resultCapture = resultCapture; - } - void setConfig( IConfig const* config ) override { - m_config = config; - } - - friend IMutableContext& getCurrentMutableContext(); - - private: - IConfig const* m_config = nullptr; - IResultCapture* m_resultCapture = nullptr; - }; - - IMutableContext *IMutableContext::currentContext = nullptr; - - void IMutableContext::createContext() - { + void cleanUpContext() { + delete Context::currentContext; + Context::currentContext = nullptr; + } + void Context::createContext() { currentContext = new Context(); } - void cleanUpContext() { - delete IMutableContext::currentContext; - IMutableContext::currentContext = nullptr; + Context& getCurrentMutableContext() { + if ( !Context::currentContext ) { Context::createContext(); } + // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn) + return *Context::currentContext; + } + + void Context::setResultCapture( IResultCapture* resultCapture ) { + m_resultCapture = resultCapture; } - IContext::~IContext() = default; - IMutableContext::~IMutableContext() = default; - Context::~Context() = default; + void Context::setConfig( IConfig const* config ) { m_config = config; } SimplePcg32& sharedRng() { static SimplePcg32 s_rng; diff --git a/external_imported/Catch2/src/catch2/internal/catch_context.hpp b/external_imported/Catch2/src/catch2/internal/catch_context.hpp index a9d1b3941..6ccb3b318 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_context.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_context.hpp @@ -15,38 +15,31 @@ namespace Catch { class IResultCapture; class IConfig; - class IContext { - public: - virtual ~IContext(); // = default + class Context { + IConfig const* m_config = nullptr; + IResultCapture* m_resultCapture = nullptr; - virtual IResultCapture* getResultCapture() = 0; - virtual IConfig const* getConfig() const = 0; - }; + CATCH_EXPORT static Context* currentContext; + friend Context& getCurrentMutableContext(); + friend Context const& getCurrentContext(); + static void createContext(); + friend void cleanUpContext(); - class IMutableContext : public IContext { public: - ~IMutableContext() override; // = default - virtual void setResultCapture( IResultCapture* resultCapture ) = 0; - virtual void setConfig( IConfig const* config ) = 0; - - private: - CATCH_EXPORT static IMutableContext* currentContext; - friend IMutableContext& getCurrentMutableContext(); - friend void cleanUpContext(); - static void createContext(); + IResultCapture* getResultCapture() const { return m_resultCapture; } + IConfig const* getConfig() const { return m_config; } + void setResultCapture( IResultCapture* resultCapture ); + void setConfig( IConfig const* config ); }; - inline IMutableContext& getCurrentMutableContext() - { - if( !IMutableContext::currentContext ) - IMutableContext::createContext(); - // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn) - return *IMutableContext::currentContext; - } + Context& getCurrentMutableContext(); - inline IContext& getCurrentContext() - { - return getCurrentMutableContext(); + inline Context const& getCurrentContext() { + // We duplicate the logic from `getCurrentMutableContext` here, + // to avoid paying the call overhead in debug mode. + if ( !Context::currentContext ) { Context::createContext(); } + // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn) + return *Context::currentContext; } void cleanUpContext(); diff --git a/external_imported/Catch2/src/catch2/internal/catch_enum_values_registry.cpp b/external_imported/Catch2/src/catch2/internal/catch_enum_values_registry.cpp index 7e8bf5e5e..a94b60881 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_enum_values_registry.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_enum_values_registry.cpp @@ -39,7 +39,7 @@ namespace Catch { return parsed; } - EnumInfo::~EnumInfo() {} + EnumInfo::~EnumInfo() = default; StringRef EnumInfo::lookup( int value ) const { for( auto const& valueToName : m_values ) { diff --git a/external_imported/Catch2/src/catch2/internal/catch_exception_translator_registry.cpp b/external_imported/Catch2/src/catch2/internal/catch_exception_translator_registry.cpp index 0645c6ce0..1eb611473 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_exception_translator_registry.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_exception_translator_registry.cpp @@ -11,10 +11,27 @@ #include #include +#include + namespace Catch { - ExceptionTranslatorRegistry::~ExceptionTranslatorRegistry() { +#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + namespace { + static std::string tryTranslators( + std::vector< + Detail::unique_ptr> const& translators ) { + if ( translators.empty() ) { + std::rethrow_exception( std::current_exception() ); + } else { + return translators[0]->translate( translators.begin() + 1, + translators.end() ); + } + } + } +#endif //!defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + + ExceptionTranslatorRegistry::~ExceptionTranslatorRegistry() = default; void ExceptionTranslatorRegistry::registerTranslator( Detail::unique_ptr&& translator ) { m_translators.push_back( CATCH_MOVE( translator ) ); @@ -37,7 +54,7 @@ namespace Catch { // First we try user-registered translators. If none of them can // handle the exception, it will be rethrown handled by our defaults. try { - return tryTranslators(); + return tryTranslators(m_translators); } // To avoid having to handle TFE explicitly everywhere, we just // rethrow it so that it goes back up the caller. @@ -61,23 +78,10 @@ namespace Catch { } } - std::string ExceptionTranslatorRegistry::tryTranslators() const { - if (m_translators.empty()) { - std::rethrow_exception(std::current_exception()); - } else { - return m_translators[0]->translate(m_translators.begin() + 1, m_translators.end()); - } - } - #else // ^^ Exceptions are enabled // Exceptions are disabled vv std::string ExceptionTranslatorRegistry::translateActiveException() const { CATCH_INTERNAL_ERROR("Attempted to translate active exception under CATCH_CONFIG_DISABLE_EXCEPTIONS!"); } - - std::string ExceptionTranslatorRegistry::tryTranslators() const { - CATCH_INTERNAL_ERROR("Attempted to use exception translators under CATCH_CONFIG_DISABLE_EXCEPTIONS!"); - } #endif - } diff --git a/external_imported/Catch2/src/catch2/internal/catch_exception_translator_registry.hpp b/external_imported/Catch2/src/catch2/internal/catch_exception_translator_registry.hpp index 2aafa684f..3123e93d7 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_exception_translator_registry.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_exception_translator_registry.hpp @@ -21,7 +21,6 @@ namespace Catch { ~ExceptionTranslatorRegistry() override; void registerTranslator( Detail::unique_ptr&& translator ); std::string translateActiveException() const override; - std::string tryTranslators() const; private: ExceptionTranslators m_translators; diff --git a/external_imported/Catch2/src/catch2/internal/catch_fatal_condition_handler.cpp b/external_imported/Catch2/src/catch2/internal/catch_fatal_condition_handler.cpp index f9702b184..9ef5b2179 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_fatal_condition_handler.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_fatal_condition_handler.cpp @@ -26,6 +26,7 @@ #include +#include #include #include #include diff --git a/external_imported/Catch2/src/catch2/internal/catch_fatal_condition_handler.hpp b/external_imported/Catch2/src/catch2/internal/catch_fatal_condition_handler.hpp index ce07f9b6a..81728b563 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_fatal_condition_handler.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_fatal_condition_handler.hpp @@ -8,9 +8,6 @@ #ifndef CATCH_FATAL_CONDITION_HANDLER_HPP_INCLUDED #define CATCH_FATAL_CONDITION_HANDLER_HPP_INCLUDED -#include -#include - #include namespace Catch { diff --git a/external_imported/Catch2/src/catch2/internal/catch_floating_point_helpers.cpp b/external_imported/Catch2/src/catch2/internal/catch_floating_point_helpers.cpp index e30ee4342..9631ed6d2 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_floating_point_helpers.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_floating_point_helpers.cpp @@ -27,6 +27,17 @@ namespace Catch { return i; } +#if defined( __GNUC__ ) || defined( __clang__ ) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wfloat-equal" +#endif + bool directCompare( float lhs, float rhs ) { return lhs == rhs; } + bool directCompare( double lhs, double rhs ) { return lhs == rhs; } +#if defined( __GNUC__ ) || defined( __clang__ ) +# pragma GCC diagnostic pop +#endif + + } // end namespace Detail } // end namespace Catch diff --git a/external_imported/Catch2/src/catch2/internal/catch_floating_point_helpers.hpp b/external_imported/Catch2/src/catch2/internal/catch_floating_point_helpers.hpp index ca883c613..b2143726d 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_floating_point_helpers.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_floating_point_helpers.hpp @@ -22,6 +22,11 @@ namespace Catch { uint32_t convertToBits(float f); uint64_t convertToBits(double d); + // Used when we know we want == comparison of two doubles + // to centralize warning suppression + bool directCompare( float lhs, float rhs ); + bool directCompare( double lhs, double rhs ); + } // end namespace Detail diff --git a/external_imported/Catch2/src/catch2/internal/catch_istream.cpp b/external_imported/Catch2/src/catch2/internal/catch_istream.cpp index 489396ec7..2867ce747 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_istream.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_istream.cpp @@ -24,7 +24,7 @@ namespace Catch { namespace Detail { namespace { template - class StreamBufImpl : public std::streambuf { + class StreamBufImpl final : public std::streambuf { char data[bufferSize]; WriterF m_writer; @@ -72,7 +72,7 @@ namespace Detail { /////////////////////////////////////////////////////////////////////////// - class FileStream : public IStream { + class FileStream final : public IStream { std::ofstream m_ofs; public: FileStream( std::string const& filename ) { @@ -80,7 +80,6 @@ namespace Detail { CATCH_ENFORCE( !m_ofs.fail(), "Unable to open file: '" << filename << '\'' ); m_ofs << std::unitbuf; } - ~FileStream() override = default; public: // IStream std::ostream& stream() override { return m_ofs; @@ -89,13 +88,12 @@ namespace Detail { /////////////////////////////////////////////////////////////////////////// - class CoutStream : public IStream { + class CoutStream final : public IStream { std::ostream m_os; public: // Store the streambuf from cout up-front because // cout may get redirected when running tests CoutStream() : m_os( Catch::cout().rdbuf() ) {} - ~CoutStream() override = default; public: // IStream std::ostream& stream() override { return m_os; } @@ -109,7 +107,6 @@ namespace Detail { // Store the streambuf from cerr up-front because // cout may get redirected when running tests CerrStream(): m_os( Catch::cerr().rdbuf() ) {} - ~CerrStream() override = default; public: // IStream std::ostream& stream() override { return m_os; } @@ -118,7 +115,7 @@ namespace Detail { /////////////////////////////////////////////////////////////////////////// - class DebugOutStream : public IStream { + class DebugOutStream final : public IStream { Detail::unique_ptr> m_streamBuf; std::ostream m_os; public: @@ -127,8 +124,6 @@ namespace Detail { m_os( m_streamBuf.get() ) {} - ~DebugOutStream() override = default; - public: // IStream std::ostream& stream() override { return m_os; } }; diff --git a/external_imported/Catch2/src/catch2/internal/catch_jsonwriter.cpp b/external_imported/Catch2/src/catch2/internal/catch_jsonwriter.cpp new file mode 100644 index 000000000..ff65a9d34 --- /dev/null +++ b/external_imported/Catch2/src/catch2/internal/catch_jsonwriter.cpp @@ -0,0 +1,148 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 +#include +#include + +namespace Catch { + void JsonUtils::indent( std::ostream& os, std::uint64_t level ) { + for ( std::uint64_t i = 0; i < level; ++i ) { + os << " "; + } + } + void JsonUtils::appendCommaNewline( std::ostream& os, + bool& should_comma, + std::uint64_t level ) { + if ( should_comma ) { os << ','; } + should_comma = true; + os << '\n'; + indent( os, level ); + } + + JsonObjectWriter::JsonObjectWriter( std::ostream& os ): + JsonObjectWriter{ os, 0 } {} + + JsonObjectWriter::JsonObjectWriter( std::ostream& os, + std::uint64_t indent_level ): + m_os{ os }, m_indent_level{ indent_level } { + m_os << '{'; + } + JsonObjectWriter::JsonObjectWriter( JsonObjectWriter&& source ): + m_os{ source.m_os }, + m_indent_level{ source.m_indent_level }, + m_should_comma{ source.m_should_comma }, + m_active{ source.m_active } { + source.m_active = false; + } + + JsonObjectWriter::~JsonObjectWriter() { + if ( !m_active ) { return; } + + m_os << '\n'; + JsonUtils::indent( m_os, m_indent_level ); + m_os << '}'; + } + + JsonValueWriter JsonObjectWriter::write( StringRef key ) { + JsonUtils::appendCommaNewline( + m_os, m_should_comma, m_indent_level + 1 ); + + m_os << '"' << key << "\": "; + return JsonValueWriter{ m_os, m_indent_level + 1 }; + } + + JsonArrayWriter::JsonArrayWriter( std::ostream& os ): + JsonArrayWriter{ os, 0 } {} + JsonArrayWriter::JsonArrayWriter( std::ostream& os, + std::uint64_t indent_level ): + m_os{ os }, m_indent_level{ indent_level } { + m_os << '['; + } + JsonArrayWriter::JsonArrayWriter( JsonArrayWriter&& source ): + m_os{ source.m_os }, + m_indent_level{ source.m_indent_level }, + m_should_comma{ source.m_should_comma }, + m_active{ source.m_active } { + source.m_active = false; + } + JsonArrayWriter::~JsonArrayWriter() { + if ( !m_active ) { return; } + + m_os << '\n'; + JsonUtils::indent( m_os, m_indent_level ); + m_os << ']'; + } + + JsonObjectWriter JsonArrayWriter::writeObject() { + JsonUtils::appendCommaNewline( + m_os, m_should_comma, m_indent_level + 1 ); + return JsonObjectWriter{ m_os, m_indent_level + 1 }; + } + + JsonArrayWriter JsonArrayWriter::writeArray() { + JsonUtils::appendCommaNewline( + m_os, m_should_comma, m_indent_level + 1 ); + return JsonArrayWriter{ m_os, m_indent_level + 1 }; + } + + JsonArrayWriter& JsonArrayWriter::write( bool value ) { + return writeImpl( value ); + } + + JsonValueWriter::JsonValueWriter( std::ostream& os ): + JsonValueWriter{ os, 0 } {} + + JsonValueWriter::JsonValueWriter( std::ostream& os, + std::uint64_t indent_level ): + m_os{ os }, m_indent_level{ indent_level } {} + + JsonObjectWriter JsonValueWriter::writeObject() && { + return JsonObjectWriter{ m_os, m_indent_level }; + } + + JsonArrayWriter JsonValueWriter::writeArray() && { + return JsonArrayWriter{ m_os, m_indent_level }; + } + + void JsonValueWriter::write( Catch::StringRef value ) && { + writeImpl( value, true ); + } + + void JsonValueWriter::write( bool value ) && { + writeImpl( value ? "true"_sr : "false"_sr, false ); + } + + void JsonValueWriter::writeImpl( Catch::StringRef value, bool quote ) { + if ( quote ) { m_os << '"'; } + for (char c : value) { + // Escape list taken from https://www.json.org/json-en.html, + // string definition. + // Note that while forward slash _can_ be escaped, it does + // not have to be, if JSON is not further embedded somewhere + // where forward slash is meaningful. + if ( c == '"' ) { + m_os << "\\\""; + } else if ( c == '\\' ) { + m_os << "\\\\"; + } else if ( c == '\b' ) { + m_os << "\\b"; + } else if ( c == '\f' ) { + m_os << "\\f"; + } else if ( c == '\n' ) { + m_os << "\\n"; + } else if ( c == '\r' ) { + m_os << "\\r"; + } else if ( c == '\t' ) { + m_os << "\\t"; + } else { + m_os << c; + } + } + if ( quote ) { m_os << '"'; } + } + +} // namespace Catch diff --git a/external_imported/Catch2/src/catch2/internal/catch_jsonwriter.hpp b/external_imported/Catch2/src/catch2/internal/catch_jsonwriter.hpp new file mode 100644 index 000000000..59c044e45 --- /dev/null +++ b/external_imported/Catch2/src/catch2/internal/catch_jsonwriter.hpp @@ -0,0 +1,120 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 +#ifndef CATCH_JSONWRITER_HPP_INCLUDED +#define CATCH_JSONWRITER_HPP_INCLUDED + +#include +#include + +#include +#include + +namespace Catch { + class JsonObjectWriter; + class JsonArrayWriter; + + struct JsonUtils { + static void indent( std::ostream& os, std::uint64_t level ); + static void appendCommaNewline( std::ostream& os, + bool& should_comma, + std::uint64_t level ); + }; + + class JsonValueWriter { + public: + JsonValueWriter( std::ostream& os ); + JsonValueWriter( std::ostream& os, std::uint64_t indent_level ); + + JsonObjectWriter writeObject() &&; + JsonArrayWriter writeArray() &&; + + template + void write( T const& value ) && { + writeImpl( value, !std::is_arithmetic::value ); + } + void write( StringRef value ) &&; + void write( bool value ) &&; + + private: + void writeImpl( StringRef value, bool quote ); + + // Without this SFINAE, this overload is a better match + // for `std::string`, `char const*`, `char const[N]` args. + // While it would still work, it would cause code bloat + // and multiple iteration over the strings + template ::value>> + void writeImpl( T const& value, bool quote_value ) { + m_sstream << value; + writeImpl( m_sstream.str(), quote_value ); + } + + std::ostream& m_os; + std::stringstream m_sstream; + std::uint64_t m_indent_level; + }; + + class JsonObjectWriter { + public: + JsonObjectWriter( std::ostream& os ); + JsonObjectWriter( std::ostream& os, std::uint64_t indent_level ); + + JsonObjectWriter( JsonObjectWriter&& source ); + JsonObjectWriter& operator=( JsonObjectWriter&& source ) = delete; + + ~JsonObjectWriter(); + + JsonValueWriter write( StringRef key ); + + private: + std::ostream& m_os; + std::uint64_t m_indent_level; + bool m_should_comma = false; + bool m_active = true; + }; + + class JsonArrayWriter { + public: + JsonArrayWriter( std::ostream& os ); + JsonArrayWriter( std::ostream& os, std::uint64_t indent_level ); + + JsonArrayWriter( JsonArrayWriter&& source ); + JsonArrayWriter& operator=( JsonArrayWriter&& source ) = delete; + + ~JsonArrayWriter(); + + JsonObjectWriter writeObject(); + JsonArrayWriter writeArray(); + + template + JsonArrayWriter& write( T const& value ) { + return writeImpl( value ); + } + + JsonArrayWriter& write( bool value ); + + private: + template + JsonArrayWriter& writeImpl( T const& value ) { + JsonUtils::appendCommaNewline( + m_os, m_should_comma, m_indent_level + 1 ); + JsonValueWriter{ m_os }.write( value ); + + return *this; + } + + std::ostream& m_os; + std::uint64_t m_indent_level; + bool m_should_comma = false; + bool m_active = true; + }; + +} // namespace Catch + +#endif // CATCH_JSONWRITER_HPP_INCLUDED diff --git a/external_imported/Catch2/src/catch2/internal/catch_leak_detector.cpp b/external_imported/Catch2/src/catch2/internal/catch_leak_detector.cpp index 7389eaf77..691bc772e 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_leak_detector.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_leak_detector.cpp @@ -29,7 +29,7 @@ namespace Catch { #else // ^^ Windows crt debug heap enabled // Windows crt debug heap disabled vv - Catch::LeakDetector::LeakDetector() {} + Catch::LeakDetector::LeakDetector() = default; #endif // CATCH_CONFIG_WINDOWS_CRTDBG diff --git a/external_imported/Catch2/src/catch2/internal/catch_list.cpp b/external_imported/Catch2/src/catch2/internal/catch_list.cpp index 263781d60..5bd06a2ae 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_list.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_list.cpp @@ -9,15 +9,12 @@ #include #include -#include -#include #include +#include +#include #include #include - -#include #include -#include #include namespace Catch { @@ -54,7 +51,7 @@ namespace Catch { void listReporters(IEventListener& reporter) { std::vector descriptions; - IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories(); + auto const& factories = getRegistryHub().getReporterRegistry().getFactories(); descriptions.reserve(factories.size()); for (auto const& fac : factories) { descriptions.push_back({ fac.first, fac.second->getDescription() }); diff --git a/external_imported/Catch2/src/catch2/internal/catch_message_info.hpp b/external_imported/Catch2/src/catch2/internal/catch_message_info.hpp index d2658429e..1ef43fdaf 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_message_info.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_message_info.hpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include diff --git a/external_imported/Catch2/src/catch2/internal/catch_optional.hpp b/external_imported/Catch2/src/catch2/internal/catch_optional.hpp index ac3714ee8..d1e953ad9 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_optional.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_optional.hpp @@ -8,6 +8,8 @@ #ifndef CATCH_OPTIONAL_HPP_INCLUDED #define CATCH_OPTIONAL_HPP_INCLUDED +#include + #include namespace Catch { @@ -16,35 +18,50 @@ namespace Catch { template class Optional { public: - Optional() : nullableValue( nullptr ) {} - Optional( T const& _value ) - : nullableValue( new( storage ) T( _value ) ) - {} - Optional( Optional const& _other ) - : nullableValue( _other ? new( storage ) T( *_other ) : nullptr ) - {} - - ~Optional() { + Optional(): nullableValue( nullptr ) {} + ~Optional() { reset(); } + + Optional( T const& _value ): + nullableValue( new ( storage ) T( _value ) ) {} + Optional( T&& _value ): + nullableValue( new ( storage ) T( CATCH_MOVE( _value ) ) ) {} + + Optional& operator=( T const& _value ) { reset(); + nullableValue = new ( storage ) T( _value ); + return *this; } + Optional& operator=( T&& _value ) { + reset(); + nullableValue = new ( storage ) T( CATCH_MOVE( _value ) ); + return *this; + } + + Optional( Optional const& _other ): + nullableValue( _other ? new ( storage ) T( *_other ) : nullptr ) {} + Optional( Optional&& _other ): + nullableValue( _other ? new ( storage ) T( CATCH_MOVE( *_other ) ) + : nullptr ) {} - Optional& operator= ( Optional const& _other ) { - if( &_other != this ) { + Optional& operator=( Optional const& _other ) { + if ( &_other != this ) { reset(); - if( _other ) - nullableValue = new( storage ) T( *_other ); + if ( _other ) { nullableValue = new ( storage ) T( *_other ); } } return *this; } - Optional& operator = ( T const& _value ) { - reset(); - nullableValue = new( storage ) T( _value ); + Optional& operator=( Optional&& _other ) { + if ( &_other != this ) { + reset(); + if ( _other ) { + nullableValue = new ( storage ) T( CATCH_MOVE( *_other ) ); + } + } return *this; } void reset() { - if( nullableValue ) - nullableValue->~T(); + if ( nullableValue ) { nullableValue->~T(); } nullableValue = nullptr; } @@ -91,7 +108,7 @@ namespace Catch { } private: - T *nullableValue; + T* nullableValue; alignas(alignof(T)) char storage[sizeof(T)]; }; diff --git a/external_imported/Catch2/src/catch2/internal/catch_polyfills.cpp b/external_imported/Catch2/src/catch2/internal/catch_polyfills.cpp index 96efad5dd..776c22439 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_polyfills.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_polyfills.cpp @@ -31,4 +31,12 @@ namespace Catch { } #endif +#if !defined( CATCH_CONFIG_GLOBAL_NEXTAFTER ) + float nextafter( float x, float y ) { return std::nextafter( x, y ); } + double nextafter( double x, double y ) { return std::nextafter( x, y ); } +#else + float nextafter( float x, float y ) { return ::nextafterf( x, y ); } + double nextafter( double x, double y ) { return ::nextafter( x, y ); } +#endif + } // end namespace Catch diff --git a/external_imported/Catch2/src/catch2/internal/catch_polyfills.hpp b/external_imported/Catch2/src/catch2/internal/catch_polyfills.hpp index 23a9332bc..4503f8f2a 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_polyfills.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_polyfills.hpp @@ -9,8 +9,13 @@ #define CATCH_POLYFILLS_HPP_INCLUDED namespace Catch { + bool isnan(float f); bool isnan(double d); + + float nextafter(float x, float y); + double nextafter(double x, double y); + } #endif // CATCH_POLYFILLS_HPP_INCLUDED diff --git a/external_imported/Catch2/src/catch2/internal/catch_preprocessor_internal_stringify.hpp b/external_imported/Catch2/src/catch2/internal/catch_preprocessor_internal_stringify.hpp new file mode 100644 index 000000000..2fd64e1c6 --- /dev/null +++ b/external_imported/Catch2/src/catch2/internal/catch_preprocessor_internal_stringify.hpp @@ -0,0 +1,19 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 +#ifndef CATCH_PREPROCESSOR_INTERNAL_STRINGIFY_HPP_INCLUDED +#define CATCH_PREPROCESSOR_INTERNAL_STRINGIFY_HPP_INCLUDED + +#include + +#if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION) + #define CATCH_INTERNAL_STRINGIFY(...) #__VA_ARGS__##_catch_sr +#else + #define CATCH_INTERNAL_STRINGIFY(...) "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION"_catch_sr +#endif + +#endif // CATCH_PREPROCESSOR_INTERNAL_STRINGIFY_HPP_INCLUDED diff --git a/external_imported/Catch2/src/catch2/internal/catch_random_floating_point_helpers.hpp b/external_imported/Catch2/src/catch2/internal/catch_random_floating_point_helpers.hpp new file mode 100644 index 000000000..c59c05391 --- /dev/null +++ b/external_imported/Catch2/src/catch2/internal/catch_random_floating_point_helpers.hpp @@ -0,0 +1,94 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#ifndef CATCH_RANDOM_FLOATING_POINT_HELPERS_HPP_INCLUDED +#define CATCH_RANDOM_FLOATING_POINT_HELPERS_HPP_INCLUDED + +#include + +#include +#include +#include +#include +#include + +namespace Catch { + + namespace Detail { + /** + * Returns the largest magnitude of 1-ULP distance inside the [a, b] range. + * + * Assumes `a < b`. + */ + template + FloatType gamma(FloatType a, FloatType b) { + static_assert( std::is_floating_point::value, + "gamma returns the largest ULP magnitude within " + "floating point range [a, b]. This only makes sense " + "for floating point types" ); + assert( a <= b ); + + const auto gamma_up = Catch::nextafter( a, std::numeric_limits::infinity() ) - a; + const auto gamma_down = b - Catch::nextafter( b, -std::numeric_limits::infinity() ); + + return gamma_up < gamma_down ? gamma_down : gamma_up; + } + + template + struct DistanceTypePicker; + template <> + struct DistanceTypePicker { + using type = std::uint32_t; + }; + template <> + struct DistanceTypePicker { + using type = std::uint64_t; + }; + + template + using DistanceType = typename DistanceTypePicker::type; + +#if defined( __GNUC__ ) || defined( __clang__ ) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wfloat-equal" +#endif + /** + * Computes the number of equi-distant floats in [a, b] + * + * Since not every range can be split into equidistant floats + * exactly, we actually compute ceil(b/distance - a/distance), + * because in those cases we want to overcount. + * + * Uses modified Dekker's FastTwoSum algorithm to handle rounding. + */ + template + DistanceType + count_equidistant_floats( FloatType a, FloatType b, FloatType distance ) { + assert( a <= b ); + // We get distance as gamma for our uniform float distribution, + // so this will round perfectly. + const auto ag = a / distance; + const auto bg = b / distance; + + const auto s = bg - ag; + const auto err = ( std::fabs( a ) <= std::fabs( b ) ) + ? -ag - ( s - bg ) + : bg - ( s + ag ); + const auto ceil_s = static_cast>( std::ceil( s ) ); + + return ( ceil_s != s ) ? ceil_s : ceil_s + ( err > 0 ); + } +#if defined( __GNUC__ ) || defined( __clang__ ) +# pragma GCC diagnostic pop +#endif + + } + +} // end namespace Catch + +#endif // CATCH_RANDOM_FLOATING_POINT_HELPERS_HPP_INCLUDED diff --git a/external_imported/Catch2/src/catch2/internal/catch_random_integer_helpers.hpp b/external_imported/Catch2/src/catch2/internal/catch_random_integer_helpers.hpp new file mode 100644 index 000000000..1c450f05c --- /dev/null +++ b/external_imported/Catch2/src/catch2/internal/catch_random_integer_helpers.hpp @@ -0,0 +1,202 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#ifndef CATCH_RANDOM_INTEGER_HELPERS_HPP_INCLUDED +#define CATCH_RANDOM_INTEGER_HELPERS_HPP_INCLUDED + +#include +#include +#include +#include + +namespace Catch { + namespace Detail { + + template + struct SizedUnsignedType; +#define SizedUnsignedTypeHelper( TYPE ) \ + template <> \ + struct SizedUnsignedType { \ + using type = TYPE; \ + } + + SizedUnsignedTypeHelper( std::uint8_t ); + SizedUnsignedTypeHelper( std::uint16_t ); + SizedUnsignedTypeHelper( std::uint32_t ); + SizedUnsignedTypeHelper( std::uint64_t ); +#undef SizedUnsignedTypeHelper + + template + using SizedUnsignedType_t = typename SizedUnsignedType::type; + + template + using DoubleWidthUnsignedType_t = SizedUnsignedType_t<2 * sizeof( T )>; + + template + struct ExtendedMultResult { + T upper; + T lower; + friend bool operator==( ExtendedMultResult const& lhs, + ExtendedMultResult const& rhs ) { + return lhs.upper == rhs.upper && lhs.lower == rhs.lower; + } + }; + + // Returns 128 bit result of multiplying lhs and rhs + constexpr ExtendedMultResult + extendedMult( std::uint64_t lhs, std::uint64_t rhs ) { + // We use the simple long multiplication approach for + // correctness, we can use platform specific builtins + // for performance later. + + // Split the lhs and rhs into two 32bit "digits", so that we can + // do 64 bit arithmetic to handle carry bits. + // 32b 32b 32b 32b + // lhs L1 L2 + // * rhs R1 R2 + // ------------------------ + // | R2 * L2 | + // | R2 * L1 | + // | R1 * L2 | + // | R1 * L1 | + // ------------------------- + // | a | b | c | d | + +#define CarryBits( x ) ( x >> 32 ) +#define Digits( x ) ( x & 0xFF'FF'FF'FF ) + + auto r2l2 = Digits( rhs ) * Digits( lhs ); + auto r2l1 = Digits( rhs ) * CarryBits( lhs ); + auto r1l2 = CarryBits( rhs ) * Digits( lhs ); + auto r1l1 = CarryBits( rhs ) * CarryBits( lhs ); + + // Sum to columns first + auto d = Digits( r2l2 ); + auto c = CarryBits( r2l2 ) + Digits( r2l1 ) + Digits( r1l2 ); + auto b = CarryBits( r2l1 ) + CarryBits( r1l2 ) + Digits( r1l1 ); + auto a = CarryBits( r1l1 ); + + // Propagate carries between columns + c += CarryBits( d ); + b += CarryBits( c ); + a += CarryBits( b ); + + // Remove the used carries + c = Digits( c ); + b = Digits( b ); + a = Digits( a ); + +#undef CarryBits +#undef Digits + + return { + a << 32 | b, // upper 64 bits + c << 32 | d // lower 64 bits + }; + } + + template + constexpr ExtendedMultResult extendedMult( UInt lhs, UInt rhs ) { + static_assert( std::is_unsigned::value, + "extendedMult can only handle unsigned integers" ); + static_assert( sizeof( UInt ) < sizeof( std::uint64_t ), + "Generic extendedMult can only handle types smaller " + "than uint64_t" ); + using WideType = DoubleWidthUnsignedType_t; + + auto result = WideType( lhs ) * WideType( rhs ); + return { + static_cast( result >> ( CHAR_BIT * sizeof( UInt ) ) ), + static_cast( result & UInt( -1 ) ) }; + } + + + template + std::enable_if_t= sizeof(TargetType), + TargetType> fillBitsFrom(Generator& gen) { + using gresult_type = typename Generator::result_type; + static_assert( std::is_unsigned::value, "Only unsigned integers are supported" ); + static_assert( Generator::min() == 0 && + Generator::max() == static_cast( -1 ), + "Generator must be able to output all numbers in its result type (effectively it must be a random bit generator)" ); + + // We want to return the top bits from a generator, as they are + // usually considered higher quality. + constexpr auto generated_bits = sizeof( gresult_type ) * CHAR_BIT; + constexpr auto return_bits = sizeof( TargetType ) * CHAR_BIT; + + return static_cast( gen() >> + ( generated_bits - return_bits) ); + } + + template + std::enable_if_t fillBitsFrom(Generator& gen) { + using gresult_type = typename Generator::result_type; + static_assert( std::is_unsigned::value, + "Only unsigned integers are supported" ); + static_assert( Generator::min() == 0 && + Generator::max() == static_cast( -1 ), + "Generator must be able to output all numbers in its result type (effectively it must be a random bit generator)" ); + + constexpr auto generated_bits = sizeof( gresult_type ) * CHAR_BIT; + constexpr auto return_bits = sizeof( TargetType ) * CHAR_BIT; + std::size_t filled_bits = 0; + TargetType ret = 0; + do { + ret <<= generated_bits; + ret |= gen(); + filled_bits += generated_bits; + } while ( filled_bits < return_bits ); + + return ret; + } + + /* + * Transposes numbers into unsigned type while keeping their ordering + * + * This means that signed types are changed so that the ordering is + * [INT_MIN, ..., -1, 0, ..., INT_MAX], rather than order we would + * get by simple casting ([0, ..., INT_MAX, INT_MIN, ..., -1]) + */ + template + std::enable_if_t::value, UnsignedType> + transposeToNaturalOrder( UnsignedType in ) { + static_assert( + sizeof( OriginalType ) == sizeof( UnsignedType ), + "reordering requires the same sized types on both sides" ); + static_assert( std::is_unsigned::value, + "Input type must be unsigned" ); + // Assuming 2s complement (standardized in current C++), the + // positive and negative numbers are already internally ordered, + // and their difference is in the top bit. Swapping it orders + // them the desired way. + constexpr auto highest_bit = + UnsignedType( 1 ) << ( sizeof( UnsignedType ) * CHAR_BIT - 1 ); + return static_cast( in ^ highest_bit ); + } + + + + template + std::enable_if_t::value, UnsignedType> + transposeToNaturalOrder(UnsignedType in) { + static_assert( + sizeof( OriginalType ) == sizeof( UnsignedType ), + "reordering requires the same sized types on both sides" ); + static_assert( std::is_unsigned::value, "Input type must be unsigned" ); + // No reordering is needed for unsigned -> unsigned + return in; + } + } // namespace Detail +} // namespace Catch + +#endif // CATCH_RANDOM_INTEGER_HELPERS_HPP_INCLUDED diff --git a/external_imported/Catch2/src/catch2/internal/catch_random_seed_generation.cpp b/external_imported/Catch2/src/catch2/internal/catch_random_seed_generation.cpp index 40c468cb4..fdc3fa19e 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_random_seed_generation.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_random_seed_generation.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -21,10 +22,10 @@ namespace Catch { return static_cast( std::time( nullptr ) ); case GenerateFrom::Default: - case GenerateFrom::RandomDevice: - // In theory, a platform could have random_device that returns just - // 16 bits. That is still some randomness, so we don't care too much - return static_cast( std::random_device{}() ); + case GenerateFrom::RandomDevice: { + std::random_device rd; + return Detail::fillBitsFrom( rd ); + } default: CATCH_ERROR("Unknown generation method"); diff --git a/external_imported/Catch2/src/catch2/internal/catch_reporter_registry.cpp b/external_imported/Catch2/src/catch2/internal/catch_reporter_registry.cpp index 4c0c44f42..cea8c4dc9 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_reporter_registry.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_reporter_registry.cpp @@ -5,61 +5,87 @@ // https://www.boost.org/LICENSE_1_0.txt) // SPDX-License-Identifier: BSL-1.0 -#include -#include +#include +#include +#include +#include #include #include #include +#include #include +#include #include #include #include #include -#include -#include namespace Catch { + struct ReporterRegistry::ReporterRegistryImpl { + std::vector> listeners; + std::map + factories; + }; - ReporterRegistry::ReporterRegistry() { + ReporterRegistry::ReporterRegistry(): + m_impl( Detail::make_unique() ) { // Because it is impossible to move out of initializer list, // we have to add the elements manually - m_factories["Automake"] = Detail::make_unique>(); - m_factories["compact"] = Detail::make_unique>(); - m_factories["console"] = Detail::make_unique>(); - m_factories["JUnit"] = Detail::make_unique>(); - m_factories["SonarQube"] = Detail::make_unique>(); - m_factories["TAP"] = Detail::make_unique>(); - m_factories["TeamCity"] = Detail::make_unique>(); - m_factories["XML"] = Detail::make_unique>(); + m_impl->factories["Automake"] = + Detail::make_unique>(); + m_impl->factories["compact"] = + Detail::make_unique>(); + m_impl->factories["console"] = + Detail::make_unique>(); + m_impl->factories["JUnit"] = + Detail::make_unique>(); + m_impl->factories["SonarQube"] = + Detail::make_unique>(); + m_impl->factories["TAP"] = + Detail::make_unique>(); + m_impl->factories["TeamCity"] = + Detail::make_unique>(); + m_impl->factories["XML"] = + Detail::make_unique>(); + m_impl->factories["JSON"] = + Detail::make_unique>(); } ReporterRegistry::~ReporterRegistry() = default; - - IEventListenerPtr ReporterRegistry::create( std::string const& name, ReporterConfig&& config ) const { - auto it = m_factories.find( name ); - if( it == m_factories.end() ) - return nullptr; - return it->second->create( CATCH_MOVE(config) ); + IEventListenerPtr + ReporterRegistry::create( std::string const& name, + ReporterConfig&& config ) const { + auto it = m_impl->factories.find( name ); + if ( it == m_impl->factories.end() ) return nullptr; + return it->second->create( CATCH_MOVE( config ) ); } - void ReporterRegistry::registerReporter( std::string const& name, IReporterFactoryPtr factory ) { + void ReporterRegistry::registerReporter( std::string const& name, + IReporterFactoryPtr factory ) { CATCH_ENFORCE( name.find( "::" ) == name.npos, - "'::' is not allowed in reporter name: '" + name + '\'' ); - auto ret = m_factories.emplace(name, CATCH_MOVE(factory)); - CATCH_ENFORCE( ret.second, "reporter using '" + name + "' as name was already registered" ); + "'::' is not allowed in reporter name: '" + name + + '\'' ); + auto ret = m_impl->factories.emplace( name, CATCH_MOVE( factory ) ); + CATCH_ENFORCE( ret.second, + "reporter using '" + name + + "' as name was already registered" ); } void ReporterRegistry::registerListener( Detail::unique_ptr factory ) { - m_listeners.push_back( CATCH_MOVE(factory) ); + m_impl->listeners.push_back( CATCH_MOVE( factory ) ); } - IReporterRegistry::FactoryMap const& ReporterRegistry::getFactories() const { - return m_factories; - } - IReporterRegistry::Listeners const& ReporterRegistry::getListeners() const { - return m_listeners; + std::map const& + ReporterRegistry::getFactories() const { + return m_impl->factories; } -} + std::vector> const& + ReporterRegistry::getListeners() const { + return m_impl->listeners; + } +} // namespace Catch diff --git a/external_imported/Catch2/src/catch2/internal/catch_reporter_registry.hpp b/external_imported/Catch2/src/catch2/internal/catch_reporter_registry.hpp index 5577b9ef6..92a889279 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_reporter_registry.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_reporter_registry.hpp @@ -8,31 +8,48 @@ #ifndef CATCH_REPORTER_REGISTRY_HPP_INCLUDED #define CATCH_REPORTER_REGISTRY_HPP_INCLUDED -#include -#include +#include +#include #include +#include +#include namespace Catch { - class ReporterRegistry : public IReporterRegistry { - public: + class IEventListener; + using IEventListenerPtr = Detail::unique_ptr; + class IReporterFactory; + using IReporterFactoryPtr = Detail::unique_ptr; + struct ReporterConfig; + class EventListenerFactory; + + class ReporterRegistry { + struct ReporterRegistryImpl; + Detail::unique_ptr m_impl; + public: ReporterRegistry(); - ~ReporterRegistry() override; // = default, out of line to allow fwd decl + ~ReporterRegistry(); // = default; - IEventListenerPtr create( std::string const& name, ReporterConfig&& config ) const override; + IEventListenerPtr create( std::string const& name, + ReporterConfig&& config ) const; - void registerReporter( std::string const& name, IReporterFactoryPtr factory ); - void registerListener( Detail::unique_ptr factory ); + void registerReporter( std::string const& name, + IReporterFactoryPtr factory ); - FactoryMap const& getFactories() const override; - Listeners const& getListeners() const override; + void + registerListener( Detail::unique_ptr factory ); - private: - FactoryMap m_factories; - Listeners m_listeners; + std::map const& + getFactories() const; + + std::vector> const& + getListeners() const; }; -} + +} // end namespace Catch #endif // CATCH_REPORTER_REGISTRY_HPP_INCLUDED diff --git a/external_imported/Catch2/src/catch2/internal/catch_reporter_spec_parser.cpp b/external_imported/Catch2/src/catch2/internal/catch_reporter_spec_parser.cpp index f6591d9ac..8b88b170a 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_reporter_spec_parser.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_reporter_spec_parser.cpp @@ -21,9 +21,9 @@ namespace Catch { }; kvPair splitKVPair(StringRef kvString) { - auto splitPos = static_cast( std::distance( - kvString.begin(), - std::find( kvString.begin(), kvString.end(), '=' ) ) ); + auto splitPos = static_cast( + std::find( kvString.begin(), kvString.end(), '=' ) - + kvString.begin() ); return { kvString.substr( 0, splitPos ), kvString.substr( splitPos + 1, kvString.size() ) }; diff --git a/external_imported/Catch2/src/catch2/internal/catch_reporter_spec_parser.hpp b/external_imported/Catch2/src/catch2/internal/catch_reporter_spec_parser.hpp index d446ce98b..9f447ee2f 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_reporter_spec_parser.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_reporter_spec_parser.hpp @@ -8,7 +8,7 @@ #ifndef CATCH_REPORTER_SPEC_PARSER_HPP_INCLUDED #define CATCH_REPORTER_SPEC_PARSER_HPP_INCLUDED -#include +#include #include #include diff --git a/external_imported/Catch2/src/catch2/internal/catch_run_context.cpp b/external_imported/Catch2/src/catch2/internal/catch_run_context.cpp index 08086b28e..77b476d82 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_run_context.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_run_context.cpp @@ -8,8 +8,9 @@ #include #include -#include #include +#include +#include #include #include #include @@ -19,6 +20,7 @@ #include #include #include +#include #include #include @@ -26,146 +28,151 @@ namespace Catch { namespace Generators { - struct GeneratorTracker : TestCaseTracking::TrackerBase, IGeneratorTracker { - GeneratorBasePtr m_generator; - - GeneratorTracker( TestCaseTracking::NameAndLocation&& nameAndLocation, TrackerContext& ctx, ITracker* parent ) - : TrackerBase( CATCH_MOVE(nameAndLocation), ctx, parent ) - {} - ~GeneratorTracker() override; - - static GeneratorTracker* acquire( TrackerContext& ctx, TestCaseTracking::NameAndLocationRef const& nameAndLocation ) { - GeneratorTracker* tracker; - - ITracker& currentTracker = ctx.currentTracker(); - // Under specific circumstances, the generator we want - // to acquire is also the current tracker. If this is - // the case, we have to avoid looking through current - // tracker's children, and instead return the current - // tracker. - // A case where this check is important is e.g. - // for (int i = 0; i < 5; ++i) { - // int n = GENERATE(1, 2); - // } - // - // without it, the code above creates 5 nested generators. - if ( currentTracker.nameAndLocation() == nameAndLocation ) { - auto thisTracker = - currentTracker.parent()->findChild( nameAndLocation ); - assert( thisTracker ); - assert( thisTracker->isGeneratorTracker() ); - tracker = static_cast( thisTracker ); - } else if ( ITracker* childTracker = - currentTracker.findChild( nameAndLocation ) ) { - assert( childTracker ); - assert( childTracker->isGeneratorTracker() ); - tracker = static_cast( childTracker ); - } else { - return nullptr; - } + namespace { + struct GeneratorTracker final : TestCaseTracking::TrackerBase, + IGeneratorTracker { + GeneratorBasePtr m_generator; + + GeneratorTracker( + TestCaseTracking::NameAndLocation&& nameAndLocation, + TrackerContext& ctx, + ITracker* parent ): + TrackerBase( CATCH_MOVE( nameAndLocation ), ctx, parent ) {} + + static GeneratorTracker* + acquire( TrackerContext& ctx, + TestCaseTracking::NameAndLocationRef const& + nameAndLocation ) { + GeneratorTracker* tracker; + + ITracker& currentTracker = ctx.currentTracker(); + // Under specific circumstances, the generator we want + // to acquire is also the current tracker. If this is + // the case, we have to avoid looking through current + // tracker's children, and instead return the current + // tracker. + // A case where this check is important is e.g. + // for (int i = 0; i < 5; ++i) { + // int n = GENERATE(1, 2); + // } + // + // without it, the code above creates 5 nested generators. + if ( currentTracker.nameAndLocation() == nameAndLocation ) { + auto thisTracker = currentTracker.parent()->findChild( + nameAndLocation ); + assert( thisTracker ); + assert( thisTracker->isGeneratorTracker() ); + tracker = static_cast( thisTracker ); + } else if ( ITracker* childTracker = + currentTracker.findChild( + nameAndLocation ) ) { + assert( childTracker ); + assert( childTracker->isGeneratorTracker() ); + tracker = + static_cast( childTracker ); + } else { + return nullptr; + } - if( !tracker->isComplete() ) { - tracker->open(); - } + if ( !tracker->isComplete() ) { tracker->open(); } - return tracker; - } - - // TrackerBase interface - bool isGeneratorTracker() const override { return true; } - auto hasGenerator() const -> bool override { - return !!m_generator; - } - void close() override { - TrackerBase::close(); - // If a generator has a child (it is followed by a section) - // and none of its children have started, then we must wait - // until later to start consuming its values. - // This catches cases where `GENERATE` is placed between two - // `SECTION`s. - // **The check for m_children.empty cannot be removed**. - // doing so would break `GENERATE` _not_ followed by `SECTION`s. - const bool should_wait_for_child = [&]() { - // No children -> nobody to wait for - if ( m_children.empty() ) { - return false; - } - // If at least one child started executing, don't wait - if ( std::find_if( - m_children.begin(), - m_children.end(), - []( TestCaseTracking::ITrackerPtr const& tracker ) { - return tracker->hasStarted(); - } ) != m_children.end() ) { - return false; - } + return tracker; + } - // No children have started. We need to check if they _can_ - // start, and thus we should wait for them, or they cannot - // start (due to filters), and we shouldn't wait for them - ITracker* parent = m_parent; - // This is safe: there is always at least one section - // tracker in a test case tracking tree - while ( !parent->isSectionTracker() ) { - parent = parent->parent(); - } - assert( parent && - "Missing root (test case) level section" ); - - auto const& parentSection = - static_cast( *parent ); - auto const& filters = parentSection.getFilters(); - // No filters -> no restrictions on running sections - if ( filters.empty() ) { - return true; - } + // TrackerBase interface + bool isGeneratorTracker() const override { return true; } + auto hasGenerator() const -> bool override { + return !!m_generator; + } + void close() override { + TrackerBase::close(); + // If a generator has a child (it is followed by a section) + // and none of its children have started, then we must wait + // until later to start consuming its values. + // This catches cases where `GENERATE` is placed between two + // `SECTION`s. + // **The check for m_children.empty cannot be removed**. + // doing so would break `GENERATE` _not_ followed by + // `SECTION`s. + const bool should_wait_for_child = [&]() { + // No children -> nobody to wait for + if ( m_children.empty() ) { return false; } + // If at least one child started executing, don't wait + if ( std::find_if( + m_children.begin(), + m_children.end(), + []( TestCaseTracking::ITrackerPtr const& + tracker ) { + return tracker->hasStarted(); + } ) != m_children.end() ) { + return false; + } - for ( auto const& child : m_children ) { - if ( child->isSectionTracker() && - std::find( - filters.begin(), - filters.end(), - static_cast( *child ) - .trimmedName() ) != filters.end() ) { - return true; + // No children have started. We need to check if they + // _can_ start, and thus we should wait for them, or + // they cannot start (due to filters), and we shouldn't + // wait for them + ITracker* parent = m_parent; + // This is safe: there is always at least one section + // tracker in a test case tracking tree + while ( !parent->isSectionTracker() ) { + parent = parent->parent(); + } + assert( parent && + "Missing root (test case) level section" ); + + auto const& parentSection = + static_cast( *parent ); + auto const& filters = parentSection.getFilters(); + // No filters -> no restrictions on running sections + if ( filters.empty() ) { return true; } + + for ( auto const& child : m_children ) { + if ( child->isSectionTracker() && + std::find( filters.begin(), + filters.end(), + static_cast( + *child ) + .trimmedName() ) != + filters.end() ) { + return true; + } } + return false; + }(); + + // This check is a bit tricky, because m_generator->next() + // has a side-effect, where it consumes generator's current + // value, but we do not want to invoke the side-effect if + // this generator is still waiting for any child to start. + assert( m_generator && "Tracker without generator" ); + if ( should_wait_for_child || + ( m_runState == CompletedSuccessfully && + m_generator->countedNext() ) ) { + m_children.clear(); + m_runState = Executing; } - return false; - }(); - - // This check is a bit tricky, because m_generator->next() - // has a side-effect, where it consumes generator's current - // value, but we do not want to invoke the side-effect if - // this generator is still waiting for any child to start. - assert( m_generator && "Tracker without generator" ); - if ( should_wait_for_child || - ( m_runState == CompletedSuccessfully && - m_generator->countedNext() ) ) { - m_children.clear(); - m_runState = Executing; } - } - // IGeneratorTracker interface - auto getGenerator() const -> GeneratorBasePtr const& override { - return m_generator; - } - void setGenerator( GeneratorBasePtr&& generator ) override { - m_generator = CATCH_MOVE( generator ); - } - }; - GeneratorTracker::~GeneratorTracker() = default; + // IGeneratorTracker interface + auto getGenerator() const -> GeneratorBasePtr const& override { + return m_generator; + } + void setGenerator( GeneratorBasePtr&& generator ) override { + m_generator = CATCH_MOVE( generator ); + } + }; + } // namespace } RunContext::RunContext(IConfig const* _config, IEventListenerPtr&& reporter) : m_runInfo(_config->name()), - m_context(getCurrentMutableContext()), m_config(_config), m_reporter(CATCH_MOVE(reporter)), m_lastAssertionInfo{ StringRef(), SourceLineInfo("",0), StringRef(), ResultDisposition::Normal }, m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions ) { - m_context.setResultCapture(this); + getCurrentMutableContext().setResultCapture( this ); m_reporter->testRunStarting(m_runInfo); } @@ -260,7 +267,7 @@ namespace Catch { } - void RunContext::assertionEnded(AssertionResult const & result) { + void RunContext::assertionEnded(AssertionResult&& result) { if (result.getResultType() == ResultWas::Ok) { m_totals.assertions.passed++; m_lastAssertionPassed = true; @@ -282,19 +289,27 @@ namespace Catch { m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals)); - if (result.getResultType() != ResultWas::Warning) + if ( result.getResultType() != ResultWas::Warning ) { m_messageScopes.clear(); + } - // Reset working state - resetAssertionInfo(); - m_lastResult = result; + // Reset working state. assertion info will be reset after + // populateReaction is run if it is needed + m_lastResult = CATCH_MOVE( result ); } void RunContext::resetAssertionInfo() { m_lastAssertionInfo.macroName = StringRef(); m_lastAssertionInfo.capturedExpression = "{Unknown expression after the reported line}"_sr; + m_lastAssertionInfo.resultDisposition = ResultDisposition::Normal; } - bool RunContext::sectionStarted(StringRef sectionName, SourceLineInfo const& sectionLineInfo, Counts & assertions) { + void RunContext::notifyAssertionStarted( AssertionInfo const& info ) { + m_reporter->assertionStarting( info ); + } + + bool RunContext::sectionStarted( StringRef sectionName, + SourceLineInfo const& sectionLineInfo, + Counts& assertions ) { ITracker& sectionTracker = SectionTracker::acquire( m_trackerContext, TestCaseTracking::NameAndLocationRef( @@ -432,7 +447,8 @@ namespace Catch { tempResult.message = static_cast(message); AssertionResult result(m_lastAssertionInfo, CATCH_MOVE(tempResult)); - assertionEnded(result); + assertionEnded(CATCH_MOVE(result) ); + resetAssertionInfo(); handleUnfinishedSections(); @@ -554,8 +570,6 @@ namespace Catch { ITransientExpression const& expr, AssertionReaction& reaction ) { - m_reporter->assertionStarting( info ); - bool negated = isFalseTest( info.resultDisposition ); bool result = expr.getResult() != negated; @@ -571,6 +585,7 @@ namespace Catch { reportExpr(info, ResultWas::ExpressionFailed, &expr, negated ); populateReaction( reaction ); } + resetAssertionInfo(); } void RunContext::reportExpr( AssertionInfo const &info, @@ -584,7 +599,7 @@ namespace Catch { AssertionResult assertionResult{ info, CATCH_MOVE( data ) }; assertionResult.m_resultData.lazyExpression.m_transientExpression = expr; - assertionEnded( assertionResult ); + assertionEnded( CATCH_MOVE(assertionResult) ); } void RunContext::handleMessage( @@ -593,22 +608,23 @@ namespace Catch { StringRef message, AssertionReaction& reaction ) { - m_reporter->assertionStarting( info ); - m_lastAssertionInfo = info; AssertionResultData data( resultType, LazyExpression( false ) ); data.message = static_cast(message); AssertionResult assertionResult{ m_lastAssertionInfo, CATCH_MOVE( data ) }; - assertionEnded( assertionResult ); - if ( !assertionResult.isOk() ) { + + const auto isOk = assertionResult.isOk(); + assertionEnded( CATCH_MOVE(assertionResult) ); + if ( !isOk ) { populateReaction( reaction ); } else if ( resultType == ResultWas::ExplicitSkip ) { // TODO: Need to handle this explicitly, as ExplicitSkip is // considered "OK" reaction.shouldSkip = true; } + resetAssertionInfo(); } void RunContext::handleUnexpectedExceptionNotThrown( AssertionInfo const& info, @@ -619,16 +635,17 @@ namespace Catch { void RunContext::handleUnexpectedInflightException( AssertionInfo const& info, - std::string const& message, + std::string&& message, AssertionReaction& reaction ) { m_lastAssertionInfo = info; AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) ); - data.message = message; + data.message = CATCH_MOVE(message); AssertionResult assertionResult{ info, CATCH_MOVE(data) }; - assertionEnded( assertionResult ); + assertionEnded( CATCH_MOVE(assertionResult) ); populateReaction( reaction ); + resetAssertionInfo(); } void RunContext::populateReaction( AssertionReaction& reaction ) { @@ -645,7 +662,8 @@ namespace Catch { AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) ); data.message = "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE"s; AssertionResult assertionResult{ info, CATCH_MOVE( data ) }; - assertionEnded( assertionResult ); + assertionEnded( CATCH_MOVE(assertionResult) ); + resetAssertionInfo(); } void RunContext::handleNonExpr( AssertionInfo const &info, @@ -656,10 +674,11 @@ namespace Catch { AssertionResultData data( resultType, LazyExpression( false ) ); AssertionResult assertionResult{ info, CATCH_MOVE( data ) }; - assertionEnded( assertionResult ); - if( !assertionResult.isOk() ) - populateReaction( reaction ); + const auto isOk = assertionResult.isOk(); + assertionEnded( CATCH_MOVE(assertionResult) ); + if ( !isOk ) { populateReaction( reaction ); } + resetAssertionInfo(); } diff --git a/external_imported/Catch2/src/catch2/internal/catch_run_context.hpp b/external_imported/Catch2/src/catch2/internal/catch_run_context.hpp index 3928180e2..c749304d3 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_run_context.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_run_context.hpp @@ -8,8 +8,9 @@ #ifndef CATCH_RUN_CONTEXT_HPP_INCLUDED #define CATCH_RUN_CONTEXT_HPP_INCLUDED -#include +#include #include +#include #include #include #include @@ -24,13 +25,14 @@ namespace Catch { - class IMutableContext; class IGeneratorTracker; class IConfig; + class IEventListener; + using IEventListenerPtr = Detail::unique_ptr; /////////////////////////////////////////////////////////////////////////// - class RunContext : public IResultCapture { + class RunContext final : public IResultCapture { public: RunContext( RunContext const& ) = delete; @@ -59,7 +61,7 @@ namespace Catch { AssertionReaction& reaction ) override; void handleUnexpectedInflightException ( AssertionInfo const& info, - std::string const& message, + std::string&& message, AssertionReaction& reaction ) override; void handleIncomplete ( AssertionInfo const& info ) override; @@ -68,6 +70,7 @@ namespace Catch { ResultWas::OfType resultType, AssertionReaction &reaction ) override; + void notifyAssertionStarted( AssertionInfo const& info ) override; bool sectionStarted( StringRef sectionName, SourceLineInfo const& sectionLineInfo, Counts& assertions ) override; @@ -118,7 +121,7 @@ namespace Catch { void resetAssertionInfo(); bool testForMissingAssertions( Counts& assertions ); - void assertionEnded( AssertionResult const& result ); + void assertionEnded( AssertionResult&& result ); void reportExpr ( AssertionInfo const &info, ResultWas::OfType resultType, @@ -132,7 +135,6 @@ namespace Catch { void handleUnfinishedSections(); TestRunInfo m_runInfo; - IMutableContext& m_context; TestCaseHandle const* m_activeTestCase = nullptr; ITracker* m_testCaseTracker = nullptr; Optional m_lastResult; diff --git a/external_imported/Catch2/src/catch2/internal/catch_section.cpp b/external_imported/Catch2/src/catch2/internal/catch_section.cpp index 061732b1d..677c2164c 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_section.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_section.cpp @@ -6,7 +6,7 @@ // SPDX-License-Identifier: BSL-1.0 #include -#include +#include #include #include diff --git a/external_imported/Catch2/src/catch2/internal/catch_section.hpp b/external_imported/Catch2/src/catch2/internal/catch_section.hpp index 8c1a882bb..8c894eeb8 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_section.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_section.hpp @@ -9,6 +9,7 @@ #define CATCH_SECTION_HPP_INCLUDED #include +#include #include #include #include @@ -38,16 +39,62 @@ namespace Catch { } // end namespace Catch -#define INTERNAL_CATCH_SECTION( ... ) \ - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ - CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ - if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::Section( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) \ - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION - -#define INTERNAL_CATCH_DYNAMIC_SECTION( ... ) \ - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ - CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ - if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, (Catch::ReusableStringStream() << __VA_ARGS__).str() ) ) \ - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION +#if !defined(CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT) +# define INTERNAL_CATCH_SECTION( ... ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ + if ( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( \ + catch_internal_Section ) = \ + Catch::Section( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + +# define INTERNAL_CATCH_DYNAMIC_SECTION( ... ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ + if ( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( \ + catch_internal_Section ) = \ + Catch::SectionInfo( \ + CATCH_INTERNAL_LINEINFO, \ + ( Catch::ReusableStringStream() << __VA_ARGS__ ) \ + .str() ) ) \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + +#else + +// These section definitions imply that at most one section at one level +// will be intered (because only one section's __LINE__ can be equal to +// the dummy `catchInternalSectionHint` variable from `TEST_CASE`). + +namespace Catch { + namespace Detail { + // Intentionally without linkage, as it should only be used as a dummy + // symbol for static analysis. + int GetNewSectionHint(); + } // namespace Detail +} // namespace Catch + + +# define INTERNAL_CATCH_SECTION( ... ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ + if ( [[maybe_unused]] const int catchInternalPreviousSectionHint = \ + catchInternalSectionHint, \ + catchInternalSectionHint = Catch::Detail::GetNewSectionHint(); \ + catchInternalPreviousSectionHint == __LINE__ ) \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + +# define INTERNAL_CATCH_DYNAMIC_SECTION( ... ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ + if ( [[maybe_unused]] const int catchInternalPreviousSectionHint = \ + catchInternalSectionHint, \ + catchInternalSectionHint = Catch::Detail::GetNewSectionHint(); \ + catchInternalPreviousSectionHint == __LINE__ ) \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + +#endif + #endif // CATCH_SECTION_HPP_INCLUDED diff --git a/external_imported/Catch2/src/catch2/internal/catch_sharding.hpp b/external_imported/Catch2/src/catch2/internal/catch_sharding.hpp index d0e4cfa13..22561f4bf 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_sharding.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_sharding.hpp @@ -8,8 +8,7 @@ #ifndef CATCH_SHARDING_HPP_INCLUDED #define CATCH_SHARDING_HPP_INCLUDED -#include - +#include #include #include diff --git a/external_imported/Catch2/src/catch2/internal/catch_stream_end_stop.hpp b/external_imported/Catch2/src/catch2/internal/catch_stream_end_stop.hpp index 61379f20d..66d678cf8 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_stream_end_stop.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_stream_end_stop.hpp @@ -17,10 +17,10 @@ namespace Catch { // as well as // << stuff +StreamEndStop struct StreamEndStop { - StringRef operator+() const { return StringRef(); } + constexpr StringRef operator+() const { return StringRef(); } template - friend T const& operator+( T const& value, StreamEndStop ) { + constexpr friend T const& operator+( T const& value, StreamEndStop ) { return value; } }; diff --git a/external_imported/Catch2/src/catch2/internal/catch_string_manip.cpp b/external_imported/Catch2/src/catch2/internal/catch_string_manip.cpp index cb96dd4fb..0c889ca18 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_string_manip.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_string_manip.cpp @@ -8,7 +8,6 @@ #include #include -#include #include #include #include @@ -32,9 +31,9 @@ namespace Catch { return s.find( infix ) != std::string::npos; } void toLowerInPlace( std::string& s ) { - std::transform( s.begin(), s.end(), s.begin(), []( char c ) { - return toLower( c ); - } ); + for ( char& c : s ) { + c = toLower( c ); + } } std::string toLower( std::string const& s ) { std::string lc = s; diff --git a/external_imported/Catch2/src/catch2/internal/catch_stringref.hpp b/external_imported/Catch2/src/catch2/internal/catch_stringref.hpp index 99bb9a986..4b9212bfa 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_stringref.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_stringref.hpp @@ -25,6 +25,8 @@ namespace Catch { using size_type = std::size_t; using const_iterator = const char*; + static constexpr size_type npos{ static_cast( -1 ) }; + private: static constexpr char const* const s_empty = ""; @@ -75,7 +77,7 @@ namespace Catch { } // Returns a substring of [start, start + length). - // If start + length > size(), then the substring is [start, start + size()). + // If start + length > size(), then the substring is [start, size()). // If start > size(), then the substring is empty. constexpr StringRef substr(size_type start, size_type length) const noexcept { if (start < m_size) { diff --git a/external_imported/Catch2/src/catch2/internal/catch_tag_alias_registry.cpp b/external_imported/Catch2/src/catch2/internal/catch_tag_alias_registry.cpp index b7c6b9ec7..510df167f 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_tag_alias_registry.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_tag_alias_registry.cpp @@ -6,14 +6,13 @@ // SPDX-License-Identifier: BSL-1.0 #include -#include #include #include #include namespace Catch { - TagAliasRegistry::~TagAliasRegistry() {} + TagAliasRegistry::~TagAliasRegistry() = default; TagAlias const* TagAliasRegistry::find( std::string const& alias ) const { auto it = m_registry.find( alias ); diff --git a/external_imported/Catch2/src/catch2/internal/catch_test_case_registry_impl.cpp b/external_imported/Catch2/src/catch2/internal/catch_test_case_registry_impl.cpp index 4b3d2e471..c2b052daf 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_test_case_registry_impl.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_test_case_registry_impl.cpp @@ -7,11 +7,9 @@ // SPDX-License-Identifier: BSL-1.0 #include -#include #include +#include #include -#include -#include #include #include #include @@ -23,6 +21,38 @@ namespace Catch { + namespace { + static void enforceNoDuplicateTestCases( + std::vector const& tests ) { + auto testInfoCmp = []( TestCaseInfo const* lhs, + TestCaseInfo const* rhs ) { + return *lhs < *rhs; + }; + std::set seenTests( + testInfoCmp ); + for ( auto const& test : tests ) { + const auto infoPtr = &test.getTestCaseInfo(); + const auto prev = seenTests.insert( infoPtr ); + CATCH_ENFORCE( prev.second, + "error: test case \"" + << infoPtr->name << "\", with tags \"" + << infoPtr->tagsAsString() + << "\" already defined.\n" + << "\tFirst seen at " + << ( *prev.first )->lineInfo << "\n" + << "\tRedefined at " << infoPtr->lineInfo ); + } + } + + static bool matchTest( TestCaseHandle const& testCase, + TestSpec const& testSpec, + IConfig const& config ) { + return testSpec.matches( testCase.getTestCaseInfo() ) && + isThrowSafe( testCase, config ); + } + + } // end unnamed namespace + std::vector sortTests( IConfig const& config, std::vector const& unsortedTestCases ) { switch (config.runOrder()) { case TestRunOrder::Declared: @@ -40,7 +70,6 @@ namespace Catch { return sorted; } case TestRunOrder::Randomized: { - seedRng(config); using TestWithHash = std::pair; TestCaseInfoHasher h{ config.rngSeed() }; @@ -79,29 +108,6 @@ namespace Catch { return !testCase.getTestCaseInfo().throws() || config.allowThrows(); } - bool matchTest( TestCaseHandle const& testCase, TestSpec const& testSpec, IConfig const& config ) { - return testSpec.matches( testCase.getTestCaseInfo() ) && isThrowSafe( testCase, config ); - } - - void - enforceNoDuplicateTestCases( std::vector const& tests ) { - auto testInfoCmp = []( TestCaseInfo const* lhs, - TestCaseInfo const* rhs ) { - return *lhs < *rhs; - }; - std::set seenTests(testInfoCmp); - for ( auto const& test : tests ) { - const auto infoPtr = &test.getTestCaseInfo(); - const auto prev = seenTests.insert( infoPtr ); - CATCH_ENFORCE( - prev.second, - "error: test case \"" << infoPtr->name << "\", with tags \"" - << infoPtr->tagsAsString() << "\" already defined.\n" - << "\tFirst seen at " << ( *prev.first )->lineInfo << "\n" - << "\tRedefined at " << infoPtr->lineInfo ); - } - } - std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ) { std::vector filtered; filtered.reserve( testCases.size() ); @@ -142,11 +148,4 @@ namespace Catch { return m_sortedFunctions; } - - - /////////////////////////////////////////////////////////////////////////// - void TestInvokerAsFunction::invoke() const { - m_testAsFunction(); - } - } // end namespace Catch diff --git a/external_imported/Catch2/src/catch2/internal/catch_test_case_registry_impl.hpp b/external_imported/Catch2/src/catch2/internal/catch_test_case_registry_impl.hpp index 228dbb799..99a38498f 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_test_case_registry_impl.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_test_case_registry_impl.hpp @@ -8,31 +8,28 @@ #ifndef CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED #define CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED -#include +#include #include +#include #include namespace Catch { - class TestCaseHandle; class IConfig; + class ITestInvoker; + class TestCaseHandle; class TestSpec; std::vector sortTests( IConfig const& config, std::vector const& unsortedTestCases ); bool isThrowSafe( TestCaseHandle const& testCase, IConfig const& config ); - bool matchTest( TestCaseHandle const& testCase, TestSpec const& testSpec, IConfig const& config ); - - void enforceNoDuplicateTestCases( std::vector const& functions ); std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); std::vector const& getAllTestCasesSorted( IConfig const& config ); class TestRegistry : public ITestCaseRegistry { public: - ~TestRegistry() override = default; - void registerTest( Detail::unique_ptr testInfo, Detail::unique_ptr testInvoker ); std::vector const& getAllInfos() const override; @@ -53,18 +50,6 @@ namespace Catch { /////////////////////////////////////////////////////////////////////////// - class TestInvokerAsFunction final : public ITestInvoker { - using TestType = void(*)(); - TestType m_testAsFunction; - public: - TestInvokerAsFunction(TestType testAsFunction) noexcept: - m_testAsFunction(testAsFunction) {} - - void invoke() const override; - }; - - /////////////////////////////////////////////////////////////////////////// - } // end namespace Catch diff --git a/external_imported/Catch2/src/catch2/internal/catch_test_case_tracker.hpp b/external_imported/Catch2/src/catch2/internal/catch_test_case_tracker.hpp index beff8d6d9..50278c910 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_test_case_tracker.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_test_case_tracker.hpp @@ -113,7 +113,7 @@ namespace TestCaseTracking { //! Returns true if tracker run to completion (successfully or not) virtual bool isComplete() const = 0; - //! Returns true if tracker run to completion succesfully + //! Returns true if tracker run to completion successfully bool isSuccessfullyCompleted() const { return m_runState == CompletedSuccessfully; } diff --git a/external_imported/Catch2/src/catch2/internal/catch_test_failure_exception.cpp b/external_imported/Catch2/src/catch2/internal/catch_test_failure_exception.cpp index c1edff3cc..8ea313131 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_test_failure_exception.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_test_failure_exception.cpp @@ -20,4 +20,12 @@ namespace Catch { #endif } + void throw_test_skip_exception() { +#if !defined( CATCH_CONFIG_DISABLE_EXCEPTIONS ) + throw Catch::TestSkipException(); +#else + CATCH_ERROR( "Explicitly skipping tests during runtime requires exceptions" ); +#endif + } + } // namespace Catch diff --git a/external_imported/Catch2/src/catch2/internal/catch_test_failure_exception.hpp b/external_imported/Catch2/src/catch2/internal/catch_test_failure_exception.hpp index 13c5fc082..1ef883648 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_test_failure_exception.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_test_failure_exception.hpp @@ -12,6 +12,8 @@ namespace Catch { //! Used to signal that an assertion macro failed struct TestFailureException{}; + //! Used to signal that the remainder of a test should be skipped + struct TestSkipException {}; /** * Outlines throwing of `TestFailureException` into a single TU @@ -20,8 +22,12 @@ namespace Catch { */ [[noreturn]] void throw_test_failure_exception(); - //! Used to signal that the remainder of a test should be skipped - struct TestSkipException{}; + /** + * Outlines throwing of `TestSkipException` into a single TU + * + * Also handles `CATCH_CONFIG_DISABLE_EXCEPTIONS` for callers. + */ + [[noreturn]] void throw_test_skip_exception(); } // namespace Catch diff --git a/external_imported/Catch2/src/catch2/internal/catch_test_macro_impl.hpp b/external_imported/Catch2/src/catch2/internal/catch_test_macro_impl.hpp index e569680bb..59c851e8f 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_test_macro_impl.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_test_macro_impl.hpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -22,12 +23,6 @@ #if !defined(CATCH_CONFIG_DISABLE) -#if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION) - #define CATCH_INTERNAL_STRINGIFY(...) #__VA_ARGS__##_catch_sr -#else - #define CATCH_INTERNAL_STRINGIFY(...) "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION"_catch_sr -#endif - #if defined(CATCH_CONFIG_FAST_COMPILE) || defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) /////////////////////////////////////////////////////////////////////////////// @@ -39,7 +34,7 @@ #else // CATCH_CONFIG_FAST_COMPILE #define INTERNAL_CATCH_TRY try -#define INTERNAL_CATCH_CATCH( handler ) catch(...) { handler.handleUnexpectedInflightException(); } +#define INTERNAL_CATCH_CATCH( handler ) catch(...) { (handler).handleUnexpectedInflightException(); } #endif @@ -95,6 +90,7 @@ if( catchAssertionHandler.allowThrows() ) \ try { \ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT \ CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \ static_cast(__VA_ARGS__); \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ @@ -115,6 +111,7 @@ if( catchAssertionHandler.allowThrows() ) \ try { \ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT \ CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \ static_cast(expr); \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ @@ -141,6 +138,7 @@ if( catchAssertionHandler.allowThrows() ) \ try { \ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT \ CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \ static_cast(__VA_ARGS__); \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ diff --git a/external_imported/Catch2/src/catch2/internal/catch_test_registry.cpp b/external_imported/Catch2/src/catch2/internal/catch_test_registry.cpp index 9769ed032..e9c999fec 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_test_registry.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_test_registry.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -17,9 +16,10 @@ #include namespace Catch { + ITestInvoker::~ITestInvoker() = default; namespace { - StringRef extractClassName( StringRef classOrMethodName ) { + static StringRef extractClassName( StringRef classOrMethodName ) { if ( !startsWith( classOrMethodName, '&' ) ) { return classOrMethodName; } @@ -46,6 +46,18 @@ namespace Catch { static_cast( startIdx ), static_cast( classNameSize ) ); } + + class TestInvokerAsFunction final : public ITestInvoker { + using TestType = void ( * )(); + TestType m_testAsFunction; + + public: + TestInvokerAsFunction( TestType testAsFunction ) noexcept: + m_testAsFunction( testAsFunction ) {} + + void invoke() const override { m_testAsFunction(); } + }; + } // namespace Detail::unique_ptr makeTestInvoker( void(*testAsFunction)() ) { diff --git a/external_imported/Catch2/src/catch2/internal/catch_test_registry.hpp b/external_imported/Catch2/src/catch2/internal/catch_test_registry.hpp index f53b93c8b..7766fe111 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_test_registry.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_test_registry.hpp @@ -8,9 +8,10 @@ #ifndef CATCH_TEST_REGISTRY_HPP_INCLUDED #define CATCH_TEST_REGISTRY_HPP_INCLUDED +#include #include #include -#include +#include #include #include #include @@ -72,6 +73,9 @@ struct AutoReg : Detail::NonCopyable { void TestName::test() #endif + +#if !defined(CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT) + /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \ static void TestName(); \ @@ -84,19 +88,40 @@ struct AutoReg : Detail::NonCopyable { #define INTERNAL_CATCH_TESTCASE( ... ) \ INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), __VA_ARGS__ ) - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \ - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ - CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ - namespace { \ - const Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( \ - Catch::makeTestInvoker( &QualifiedMethod ), \ - CATCH_INTERNAL_LINEINFO, \ - "&" #QualifiedMethod##_catch_sr, \ - Catch::NameAndTags{ __VA_ARGS__ } ); \ - } /* NOLINT */ \ - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION +#else // ^^ !CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT | vv CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT + + +// Dummy registrator for the dumy test case macros +namespace Catch { + namespace Detail { + struct DummyUse { + DummyUse( void ( * )( int ) ); + }; + } // namespace Detail +} // namespace Catch + +// Note that both the presence of the argument and its exact name are +// necessary for the section support. + +// We provide a shadowed variable so that a `SECTION` inside non-`TEST_CASE` +// tests can compile. The redefined `TEST_CASE` shadows this with param. +static int catchInternalSectionHint = 0; + +# define INTERNAL_CATCH_TESTCASE2( fname ) \ + static void fname( int ); \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ + static const Catch::Detail::DummyUse INTERNAL_CATCH_UNIQUE_NAME( \ + dummyUser )( &(fname) ); \ + CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ + static void fname( [[maybe_unused]] int catchInternalSectionHint ) \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION +# define INTERNAL_CATCH_TESTCASE( ... ) \ + INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( dummyFunction ) ) + + +#endif // CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\ @@ -118,6 +143,22 @@ struct AutoReg : Detail::NonCopyable { #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \ INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), ClassName, __VA_ARGS__ ) + + /////////////////////////////////////////////////////////////////////////////// + #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ + namespace { \ + const Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( \ + Catch::makeTestInvoker( &QualifiedMethod ), \ + CATCH_INTERNAL_LINEINFO, \ + "&" #QualifiedMethod##_catch_sr, \ + Catch::NameAndTags{ __VA_ARGS__ } ); \ + } /* NOLINT */ \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + + /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \ do { \ diff --git a/external_imported/Catch2/src/catch2/internal/catch_test_run_info.hpp b/external_imported/Catch2/src/catch2/internal/catch_test_run_info.hpp new file mode 100644 index 000000000..90357b0af --- /dev/null +++ b/external_imported/Catch2/src/catch2/internal/catch_test_run_info.hpp @@ -0,0 +1,22 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 +#ifndef CATCH_TEST_RUN_INFO_HPP_INCLUDED +#define CATCH_TEST_RUN_INFO_HPP_INCLUDED + +#include + +namespace Catch { + + struct TestRunInfo { + constexpr TestRunInfo(StringRef _name) : name(_name) {} + StringRef name; + }; + +} // end namespace Catch + +#endif // CATCH_TEST_RUN_INFO_HPP_INCLUDED diff --git a/external_imported/Catch2/src/catch2/internal/catch_textflow.cpp b/external_imported/Catch2/src/catch2/internal/catch_textflow.cpp index 7eac97325..857fd2b9f 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_textflow.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_textflow.cpp @@ -233,23 +233,36 @@ namespace Catch { return os; } - Columns Column::operator+( Column const& other ) { + Columns operator+(Column const& lhs, Column const& rhs) { Columns cols; - cols += *this; - cols += other; + cols += lhs; + cols += rhs; return cols; } - - Columns& Columns::operator+=( Column const& col ) { - m_columns.push_back( col ); - return *this; + Columns operator+(Column&& lhs, Column&& rhs) { + Columns cols; + cols += CATCH_MOVE( lhs ); + cols += CATCH_MOVE( rhs ); + return cols; } - Columns Columns::operator+( Column const& col ) { - Columns combined = *this; - combined += col; + Columns& operator+=(Columns& lhs, Column const& rhs) { + lhs.m_columns.push_back( rhs ); + return lhs; + } + Columns& operator+=(Columns& lhs, Column&& rhs) { + lhs.m_columns.push_back( CATCH_MOVE(rhs) ); + return lhs; + } + Columns operator+( Columns const& lhs, Column const& rhs ) { + auto combined( lhs ); + combined += rhs; return combined; } + Columns operator+( Columns&& lhs, Column&& rhs ) { + lhs += CATCH_MOVE( rhs ); + return CATCH_MOVE( lhs ); + } } // namespace TextFlow } // namespace Catch diff --git a/external_imported/Catch2/src/catch2/internal/catch_textflow.hpp b/external_imported/Catch2/src/catch2/internal/catch_textflow.hpp index ceac675d5..a78451d55 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_textflow.hpp +++ b/external_imported/Catch2/src/catch2/internal/catch_textflow.hpp @@ -8,8 +8,10 @@ #ifndef CATCH_TEXTFLOW_HPP_INCLUDED #define CATCH_TEXTFLOW_HPP_INCLUDED -#include #include +#include + +#include #include #include @@ -37,7 +39,7 @@ namespace Catch { public: /** - * Iterates "lines" in `Column` and return sthem + * Iterates "lines" in `Column` and returns them */ class const_iterator { friend Column; @@ -59,7 +61,7 @@ namespace Catch { // Calculates the length of the current line void calcLength(); - // Returns current indention width + // Returns current indentation width size_t indentSize() const; // Creates an indented and (optionally) suffixed string from @@ -91,20 +93,35 @@ namespace Catch { using iterator = const_iterator; explicit Column( std::string const& text ): m_string( text ) {} + explicit Column( std::string&& text ): + m_string( CATCH_MOVE(text)) {} - Column& width( size_t newWidth ) { + Column& width( size_t newWidth ) & { assert( newWidth > 0 ); m_width = newWidth; return *this; } - Column& indent( size_t newIndent ) { + Column&& width( size_t newWidth ) && { + assert( newWidth > 0 ); + m_width = newWidth; + return CATCH_MOVE( *this ); + } + Column& indent( size_t newIndent ) & { m_indent = newIndent; return *this; } - Column& initialIndent( size_t newIndent ) { + Column&& indent( size_t newIndent ) && { + m_indent = newIndent; + return CATCH_MOVE( *this ); + } + Column& initialIndent( size_t newIndent ) & { m_initialIndent = newIndent; return *this; } + Column&& initialIndent( size_t newIndent ) && { + m_initialIndent = newIndent; + return CATCH_MOVE( *this ); + } size_t width() const { return m_width; } const_iterator begin() const { return const_iterator( *this ); } @@ -113,7 +130,8 @@ namespace Catch { friend std::ostream& operator<<( std::ostream& os, Column const& col ); - Columns operator+( Column const& other ); + friend Columns operator+( Column const& lhs, Column const& rhs ); + friend Columns operator+( Column&& lhs, Column&& rhs ); }; //! Creates a column that serves as an empty space of specific width @@ -157,8 +175,10 @@ namespace Catch { iterator begin() const { return iterator( *this ); } iterator end() const { return { *this, iterator::EndTag() }; } - Columns& operator+=( Column const& col ); - Columns operator+( Column const& col ); + friend Columns& operator+=( Columns& lhs, Column const& rhs ); + friend Columns& operator+=( Columns& lhs, Column&& rhs ); + friend Columns operator+( Columns const& lhs, Column const& rhs ); + friend Columns operator+( Columns&& lhs, Column&& rhs ); friend std::ostream& operator<<( std::ostream& os, Columns const& cols ); diff --git a/external_imported/Catch2/src/catch2/internal/catch_uncaught_exceptions.cpp b/external_imported/Catch2/src/catch2/internal/catch_uncaught_exceptions.cpp index 704d6e1ca..8cfabc0f8 100644 --- a/external_imported/Catch2/src/catch2/internal/catch_uncaught_exceptions.cpp +++ b/external_imported/Catch2/src/catch2/internal/catch_uncaught_exceptions.cpp @@ -7,7 +7,6 @@ // SPDX-License-Identifier: BSL-1.0 #include -#include #include #include diff --git a/external_imported/Catch2/src/catch2/internal/catch_uniform_floating_point_distribution.hpp b/external_imported/Catch2/src/catch2/internal/catch_uniform_floating_point_distribution.hpp new file mode 100644 index 000000000..23d03b43c --- /dev/null +++ b/external_imported/Catch2/src/catch2/internal/catch_uniform_floating_point_distribution.hpp @@ -0,0 +1,131 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#ifndef CATCH_UNIFORM_FLOATING_POINT_DISTRIBUTION_HPP_INCLUDED +#define CATCH_UNIFORM_FLOATING_POINT_DISTRIBUTION_HPP_INCLUDED + +#include +#include + +#include +#include + +namespace Catch { + + namespace Detail { +#if defined( __GNUC__ ) || defined( __clang__ ) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wfloat-equal" +#endif + // The issue with overflow only happens with maximal ULP and HUGE + // distance, e.g. when generating numbers in [-inf, inf] for given + // type. So we only check for the largest possible ULP in the + // type, and return something that does not overflow to inf in 1 mult. + constexpr std::uint64_t calculate_max_steps_in_one_go(double gamma) { + if ( gamma == 1.99584030953472e+292 ) { return 9007199254740991; } + return static_cast( -1 ); + } + constexpr std::uint32_t calculate_max_steps_in_one_go(float gamma) { + if ( gamma == 2.028241e+31f ) { return 16777215; } + return static_cast( -1 ); + } +#if defined( __GNUC__ ) || defined( __clang__ ) +# pragma GCC diagnostic pop +#endif + } + +/** + * Implementation of uniform distribution on floating point numbers. + * + * Note that we support only `float` and `double` types, because these + * usually mean the same thing across different platform. `long double` + * varies wildly by platform and thus we cannot provide reproducible + * implementation. Also note that we don't implement all parts of + * distribution per standard: this distribution is not serializable, nor + * can the range be arbitrarily reset. + * + * The implementation also uses different approach than the one taken by + * `std::uniform_real_distribution`, where instead of generating a number + * between [0, 1) and then multiplying the range bounds with it, we first + * split the [a, b] range into a set of equidistributed floating point + * numbers, and then use uniform int distribution to pick which one to + * return. + * + * This has the advantage of guaranteeing uniformity (the multiplication + * method loses uniformity due to rounding when multiplying floats), except + * for small non-uniformity at one side of the interval, where we have + * to deal with the fact that not every interval is splittable into + * equidistributed floats. + * + * Based on "Drawing random floating-point numbers from an interval" by + * Frederic Goualard. + */ +template +class uniform_floating_point_distribution { + static_assert(std::is_floating_point::value, "..."); + static_assert(!std::is_same::value, + "We do not support long double due to inconsistent behaviour between platforms"); + + using WidthType = Detail::DistanceType; + + FloatType m_a, m_b; + FloatType m_ulp_magnitude; + WidthType m_floats_in_range; + uniform_integer_distribution m_int_dist; + + // In specific cases, we can overflow into `inf` when computing the + // `steps * g` offset. To avoid this, we don't offset by more than this + // in one multiply + addition. + WidthType m_max_steps_in_one_go; + // We don't want to do the magnitude check every call to `operator()` + bool m_a_has_leq_magnitude; + +public: + using result_type = FloatType; + + uniform_floating_point_distribution( FloatType a, FloatType b ): + m_a( a ), + m_b( b ), + m_ulp_magnitude( Detail::gamma( m_a, m_b ) ), + m_floats_in_range( Detail::count_equidistant_floats( m_a, m_b, m_ulp_magnitude ) ), + m_int_dist(0, m_floats_in_range), + m_max_steps_in_one_go( Detail::calculate_max_steps_in_one_go(m_ulp_magnitude)), + m_a_has_leq_magnitude(std::fabs(m_a) <= std::fabs(m_b)) + { + assert( a <= b ); + } + + template + result_type operator()( Generator& g ) { + WidthType steps = m_int_dist( g ); + if ( m_a_has_leq_magnitude ) { + if ( steps == m_floats_in_range ) { return m_a; } + auto b = m_b; + while (steps > m_max_steps_in_one_go) { + b -= m_max_steps_in_one_go * m_ulp_magnitude; + steps -= m_max_steps_in_one_go; + } + return b - steps * m_ulp_magnitude; + } else { + if ( steps == m_floats_in_range ) { return m_b; } + auto a = m_a; + while (steps > m_max_steps_in_one_go) { + a += m_max_steps_in_one_go * m_ulp_magnitude; + steps -= m_max_steps_in_one_go; + } + return a + steps * m_ulp_magnitude; + } + } + + result_type a() const { return m_a; } + result_type b() const { return m_b; } +}; + +} // end namespace Catch + +#endif // CATCH_UNIFORM_FLOATING_POINT_DISTRIBUTION_HPP_INCLUDED diff --git a/external_imported/Catch2/src/catch2/internal/catch_uniform_integer_distribution.hpp b/external_imported/Catch2/src/catch2/internal/catch_uniform_integer_distribution.hpp new file mode 100644 index 000000000..afa2015d9 --- /dev/null +++ b/external_imported/Catch2/src/catch2/internal/catch_uniform_integer_distribution.hpp @@ -0,0 +1,124 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#ifndef CATCH_UNIFORM_INTEGER_DISTRIBUTION_HPP_INCLUDED +#define CATCH_UNIFORM_INTEGER_DISTRIBUTION_HPP_INCLUDED + +#include + +namespace Catch { + + namespace Detail { + // Indirection to enable make_unsigned behaviour. + template + struct make_unsigned { + using type = std::make_unsigned_t; + }; + + template <> + struct make_unsigned { + using type = uint8_t; + }; + + template + using make_unsigned_t = typename make_unsigned::type; + } + +/** + * Implementation of uniform distribution on integers. + * + * Unlike `std::uniform_int_distribution`, this implementation supports + * various 1 byte integral types, including bool (but you should not + * actually use it for bools). + * + * The underlying algorithm is based on the one described in "Fast Random + * Integer Generation in an Interval" by Daniel Lemire, but has been + * optimized under the assumption of reuse of the same distribution object. + */ +template +class uniform_integer_distribution { + static_assert(std::is_integral::value, "..."); + + using UnsignedIntegerType = Detail::make_unsigned_t; + + // Only the left bound is stored, and we store it converted to its + // unsigned image. This avoids having to do the conversions inside + // the operator(), at the cost of having to do the conversion in + // the a() getter. The right bound is only needed in the b() getter, + // so we recompute it there from other stored data. + UnsignedIntegerType m_a; + + // How many different values are there in [a, b]. a == b => 1, can be 0 for distribution over all values in the type. + UnsignedIntegerType m_ab_distance; + + // We hoisted this out of the main generation function. Technically, + // this means that using this distribution will be slower than Lemire's + // algorithm if this distribution instance will be used only few times, + // but it will be faster if it is used many times. Since Catch2 uses + // distributions only to implement random generators, we assume that each + // distribution will be reused many times and this is an optimization. + UnsignedIntegerType m_rejection_threshold = 0; + + UnsignedIntegerType computeDistance(IntegerType a, IntegerType b) const { + // This overflows and returns 0 if a == 0 and b == TYPE_MAX. + // We handle that later when generating the number. + return transposeTo(b) - transposeTo(a) + 1; + } + + static UnsignedIntegerType computeRejectionThreshold(UnsignedIntegerType ab_distance) { + // distance == 0 means that we will return all possible values from + // the type's range, and that we shouldn't reject anything. + if ( ab_distance == 0 ) { return 0; } + return ( ~ab_distance + 1 ) % ab_distance; + } + + static UnsignedIntegerType transposeTo(IntegerType in) { + return Detail::transposeToNaturalOrder( + static_cast( in ) ); + } + static IntegerType transposeBack(UnsignedIntegerType in) { + return static_cast( + Detail::transposeToNaturalOrder(in) ); + } + +public: + using result_type = IntegerType; + + uniform_integer_distribution( IntegerType a, IntegerType b ): + m_a( transposeTo(a) ), + m_ab_distance( computeDistance(a, b) ), + m_rejection_threshold( computeRejectionThreshold(m_ab_distance) ) { + assert( a <= b ); + } + + template + result_type operator()( Generator& g ) { + // All possible values of result_type are valid. + if ( m_ab_distance == 0 ) { + return transposeBack( Detail::fillBitsFrom( g ) ); + } + + auto random_number = Detail::fillBitsFrom( g ); + auto emul = Detail::extendedMult( random_number, m_ab_distance ); + // Unlike Lemire's algorithm we skip the ab_distance check, since + // we precomputed the rejection threshold, which is always tighter. + while (emul.lower < m_rejection_threshold) { + random_number = Detail::fillBitsFrom( g ); + emul = Detail::extendedMult( random_number, m_ab_distance ); + } + + return transposeBack(m_a + emul.upper); + } + + result_type a() const { return transposeBack(m_a); } + result_type b() const { return transposeBack(m_ab_distance + m_a - 1); } +}; + +} // end namespace Catch + +#endif // CATCH_UNIFORM_INTEGER_DISTRIBUTION_HPP_INCLUDED diff --git a/external_imported/Catch2/src/catch2/matchers/catch_matchers_floating_point.cpp b/external_imported/Catch2/src/catch2/matchers/catch_matchers_floating_point.cpp index 6e596466e..206332ef7 100644 --- a/external_imported/Catch2/src/catch2/matchers/catch_matchers_floating_point.cpp +++ b/external_imported/Catch2/src/catch2/matchers/catch_matchers_floating_point.cpp @@ -38,26 +38,11 @@ namespace { return ulpDist <= maxUlpDiff; } -#if defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) - - float nextafter(float x, float y) { - return ::nextafterf(x, y); - } - - double nextafter(double x, double y) { - return ::nextafter(x, y); - } - -#endif // ^^^ CATCH_CONFIG_GLOBAL_NEXTAFTER ^^^ template FP step(FP start, FP direction, uint64_t steps) { for (uint64_t i = 0; i < steps; ++i) { -#if defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) start = Catch::nextafter(start, direction); -#else - start = std::nextafter(start, direction); -#endif } return start; } diff --git a/external_imported/Catch2/src/catch2/matchers/catch_matchers_range_equals.hpp b/external_imported/Catch2/src/catch2/matchers/catch_matchers_range_equals.hpp index ce66bed9b..95b781a43 100644 --- a/external_imported/Catch2/src/catch2/matchers/catch_matchers_range_equals.hpp +++ b/external_imported/Catch2/src/catch2/matchers/catch_matchers_range_equals.hpp @@ -129,7 +129,7 @@ namespace Catch { /** * Creates a matcher that checks if all elements in a range are equal - * to all elements in another range, in some permuation. + * to all elements in another range, in some permutation. * * Uses to provided predicate `predicate` to do the comparisons */ diff --git a/external_imported/Catch2/src/catch2/matchers/catch_matchers_vector.hpp b/external_imported/Catch2/src/catch2/matchers/catch_matchers_vector.hpp index 9a4b024f6..fffbfdf63 100644 --- a/external_imported/Catch2/src/catch2/matchers/catch_matchers_vector.hpp +++ b/external_imported/Catch2/src/catch2/matchers/catch_matchers_vector.hpp @@ -85,11 +85,10 @@ namespace Matchers { // - a more general approach would be via a compare template that defaults // to using !=. but could be specialised for, e.g. std::vector etc // - then just call that directly - if (m_comparator.size() != v.size()) - return false; - for (std::size_t i = 0; i < v.size(); ++i) - if (m_comparator[i] != v[i]) - return false; + if ( m_comparator.size() != v.size() ) { return false; } + for ( std::size_t i = 0; i < v.size(); ++i ) { + if ( !( m_comparator[i] == v[i] ) ) { return false; } + } return true; } std::string describe() const override { diff --git a/external_imported/Catch2/src/catch2/matchers/internal/catch_matchers_impl.hpp b/external_imported/Catch2/src/catch2/matchers/internal/catch_matchers_impl.hpp index 12455bfe7..2ee9f0c09 100644 --- a/external_imported/Catch2/src/catch2/matchers/internal/catch_matchers_impl.hpp +++ b/external_imported/Catch2/src/catch2/matchers/internal/catch_matchers_impl.hpp @@ -8,9 +8,14 @@ #ifndef CATCH_MATCHERS_IMPL_HPP_INCLUDED #define CATCH_MATCHERS_IMPL_HPP_INCLUDED -#include +#include +#include +#include +#include #include +#include + namespace Catch { template diff --git a/external_imported/Catch2/src/catch2/meson.build b/external_imported/Catch2/src/catch2/meson.build index 0e114065b..cc45e6419 100644 --- a/external_imported/Catch2/src/catch2/meson.build +++ b/external_imported/Catch2/src/catch2/meson.build @@ -18,6 +18,8 @@ configure_file( configuration: conf_data, ) +fs = import('fs') + benchmark_headers = [ 'benchmark/catch_benchmark.hpp', 'benchmark/catch_benchmark_all.hpp', @@ -32,6 +34,8 @@ benchmark_headers = [ 'benchmark/catch_sample_analysis.hpp', 'benchmark/detail/catch_analyse.hpp', 'benchmark/detail/catch_benchmark_function.hpp', + 'benchmark/detail/catch_benchmark_stats.hpp', + 'benchmark/detail/catch_benchmark_stats_fwd.hpp', 'benchmark/detail/catch_complete_invoke.hpp', 'benchmark/detail/catch_estimate_clock.hpp', 'benchmark/detail/catch_measure.hpp', @@ -43,6 +47,7 @@ benchmark_headers = [ benchmark_sources = files( 'benchmark/catch_chronometer.cpp', + 'benchmark/detail/catch_analyse.cpp', 'benchmark/detail/catch_benchmark_function.cpp', 'benchmark/detail/catch_run_for_at_least.cpp', 'benchmark/detail/catch_stats.cpp', @@ -64,8 +69,8 @@ internal_headers = [ 'interfaces/catch_interfaces_registry_hub.hpp', 'interfaces/catch_interfaces_reporter.hpp', 'interfaces/catch_interfaces_reporter_factory.hpp', - 'interfaces/catch_interfaces_reporter_registry.hpp', 'interfaces/catch_interfaces_tag_alias_registry.hpp', + 'interfaces/catch_interfaces_test_invoker.hpp', 'interfaces/catch_interfaces_testcase.hpp', 'internal/catch_assertion_handler.hpp', 'internal/catch_case_insensitive_comparisons.hpp', @@ -76,6 +81,7 @@ internal_headers = [ 'internal/catch_compiler_capabilities.hpp', 'internal/catch_config_android_logwrite.hpp', 'internal/catch_config_counter.hpp', + 'internal/catch_config_static_analysis_support.hpp', 'internal/catch_config_uncaught_exceptions.hpp', 'internal/catch_config_wchar.hpp', 'internal/catch_console_colour.hpp', @@ -94,6 +100,7 @@ internal_headers = [ 'internal/catch_getenv.hpp', 'internal/catch_istream.hpp', 'internal/catch_is_permutation.hpp', + 'internal/catch_jsonwriter.hpp', 'internal/catch_lazy_expr.hpp', 'internal/catch_leak_detector.hpp', 'internal/catch_list.hpp', @@ -108,7 +115,10 @@ internal_headers = [ 'internal/catch_platform.hpp', 'internal/catch_polyfills.hpp', 'internal/catch_preprocessor.hpp', + 'internal/catch_preprocessor_internal_stringify.hpp', 'internal/catch_preprocessor_remove_parens.hpp', + 'internal/catch_random_floating_point_helpers.hpp', + 'internal/catch_random_integer_helpers.hpp', 'internal/catch_random_number_generator.hpp', 'internal/catch_random_seed_generation.hpp', 'internal/catch_reporter_registry.hpp', @@ -133,10 +143,13 @@ internal_headers = [ 'internal/catch_test_failure_exception.hpp', 'internal/catch_test_macro_impl.hpp', 'internal/catch_test_registry.hpp', + 'internal/catch_test_run_info.hpp', 'internal/catch_test_spec_parser.hpp', 'internal/catch_textflow.hpp', 'internal/catch_to_string.hpp', 'internal/catch_uncaught_exceptions.hpp', + 'internal/catch_uniform_floating_point_distribution.hpp', + 'internal/catch_uniform_integer_distribution.hpp', 'internal/catch_unique_name.hpp', 'internal/catch_unique_ptr.hpp', 'internal/catch_void_type.hpp', @@ -151,6 +164,7 @@ internal_headers = [ 'matchers/catch_matchers_floating_point.hpp', 'matchers/catch_matchers_predicate.hpp', 'matchers/catch_matchers_quantifiers.hpp', + 'matchers/catch_matchers_range_equals.hpp', 'matchers/catch_matchers_string.hpp', 'matchers/catch_matchers_templated.hpp', 'matchers/catch_matchers_vector.hpp', @@ -189,7 +203,6 @@ internal_sources = files( 'interfaces/catch_interfaces_registry_hub.cpp', 'interfaces/catch_interfaces_reporter.cpp', 'interfaces/catch_interfaces_reporter_factory.cpp', - 'interfaces/catch_interfaces_reporter_registry.cpp', 'interfaces/catch_interfaces_testcase.cpp', 'internal/catch_assertion_handler.cpp', 'internal/catch_case_insensitive_comparisons.cpp', @@ -208,6 +221,7 @@ internal_sources = files( 'internal/catch_floating_point_helpers.cpp', 'internal/catch_getenv.cpp', 'internal/catch_istream.cpp', + 'internal/catch_jsonwriter.cpp', 'internal/catch_lazy_expr.cpp', 'internal/catch_leak_detector.cpp', 'internal/catch_list.cpp', @@ -262,6 +276,7 @@ internal_sources = files( 'catch_timer.cpp', 'catch_tostring.cpp', 'catch_totals.cpp', + 'catch_translate_exception.cpp', 'catch_version.cpp', ) @@ -273,6 +288,7 @@ reporter_headers = [ 'reporters/catch_reporter_cumulative_base.hpp', 'reporters/catch_reporter_event_listener.hpp', 'reporters/catch_reporter_helpers.hpp', + 'reporters/catch_reporter_json.hpp', 'reporters/catch_reporter_junit.hpp', 'reporters/catch_reporter_multi.hpp', 'reporters/catch_reporter_registrars.hpp', @@ -292,6 +308,7 @@ reporter_sources = files( 'reporters/catch_reporter_cumulative_base.cpp', 'reporters/catch_reporter_event_listener.cpp', 'reporters/catch_reporter_helpers.cpp', + 'reporters/catch_reporter_json.cpp', 'reporters/catch_reporter_junit.cpp', 'reporters/catch_reporter_multi.cpp', 'reporters/catch_reporter_registrars.cpp', @@ -325,9 +342,19 @@ foreach file : headers install_headers(file, subdir: join_paths(include_subdir, folder)) endforeach +catch2_dependencies = [] +# Check if this is an Android NDK build. +if ((host_machine.system() == 'android') or + # Check if this is an Android Termux build. + (host_machine.system() == 'linux' and fs.is_dir('/data/data/com.termux'))) + log_dep = meson.get_compiler('cpp').find_library('log') + catch2_dependencies += log_dep +endif + catch2 = static_library( 'Catch2', sources, + dependencies: catch2_dependencies, include_directories: '..', install: true, ) diff --git a/external_imported/Catch2/src/catch2/reporters/catch_reporter_automake.cpp b/external_imported/Catch2/src/catch2/reporters/catch_reporter_automake.cpp index 993b594b8..5e506a6bc 100644 --- a/external_imported/Catch2/src/catch2/reporters/catch_reporter_automake.cpp +++ b/external_imported/Catch2/src/catch2/reporters/catch_reporter_automake.cpp @@ -12,7 +12,7 @@ namespace Catch { - AutomakeReporter::~AutomakeReporter() {} + AutomakeReporter::~AutomakeReporter() = default; void AutomakeReporter::testCaseEnded(TestCaseStats const& _testCaseStats) { // Possible values to emit are PASS, XFAIL, SKIP, FAIL, XPASS and ERROR. diff --git a/external_imported/Catch2/src/catch2/reporters/catch_reporter_automake.hpp b/external_imported/Catch2/src/catch2/reporters/catch_reporter_automake.hpp index 3475a1fd4..a639428c3 100644 --- a/external_imported/Catch2/src/catch2/reporters/catch_reporter_automake.hpp +++ b/external_imported/Catch2/src/catch2/reporters/catch_reporter_automake.hpp @@ -8,7 +8,6 @@ #ifndef CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED #define CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED -#include #include #include diff --git a/external_imported/Catch2/src/catch2/reporters/catch_reporter_compact.cpp b/external_imported/Catch2/src/catch2/reporters/catch_reporter_compact.cpp index 3a9b870c4..0f855944e 100644 --- a/external_imported/Catch2/src/catch2/reporters/catch_reporter_compact.cpp +++ b/external_imported/Catch2/src/catch2/reporters/catch_reporter_compact.cpp @@ -171,7 +171,7 @@ class AssertionPrinter { return; const auto itEnd = messages.cend(); - const auto N = static_cast(std::distance(itMessage, itEnd)); + const auto N = static_cast(itEnd - itMessage); stream << colourImpl->guardColour( colour ) << " with " << pluralise( N, "message"_sr ) << ':'; @@ -249,6 +249,6 @@ class AssertionPrinter { StreamingReporterBase::testRunEnded( _testRunStats ); } - CompactReporter::~CompactReporter() {} + CompactReporter::~CompactReporter() = default; } // end namespace Catch diff --git a/external_imported/Catch2/src/catch2/reporters/catch_reporter_console.cpp b/external_imported/Catch2/src/catch2/reporters/catch_reporter_console.cpp index a46b22cf0..f3b8b5b14 100644 --- a/external_imported/Catch2/src/catch2/reporters/catch_reporter_console.cpp +++ b/external_imported/Catch2/src/catch2/reporters/catch_reporter_console.cpp @@ -209,15 +209,9 @@ findMax( std::size_t& i, std::size_t& j, std::size_t& k, std::size_t& l ) { return l; } -enum class Justification { Left, Right }; - -struct ColumnInfo { - std::string name; - std::size_t width; - Justification justification; -}; struct ColumnBreak {}; struct RowBreak {}; +struct OutputFlush {}; class Duration { enum class Unit { @@ -292,6 +286,14 @@ class Duration { }; } // end anon namespace +enum class Justification { Left, Right }; + +struct ColumnInfo { + std::string name; + std::size_t width; + Justification justification; +}; + class TablePrinter { std::ostream& m_os; std::vector m_columnInfos; @@ -314,11 +316,10 @@ class TablePrinter { *this << RowBreak(); TextFlow::Columns headerCols; - auto spacer = TextFlow::Spacer(2); for (auto const& info : m_columnInfos) { assert(info.width > 2); headerCols += TextFlow::Column(info.name).width(info.width - 2); - headerCols += spacer; + headerCols += TextFlow::Spacer( 2 ); } m_os << headerCols << '\n'; @@ -334,12 +335,12 @@ class TablePrinter { } template - friend TablePrinter& operator << (TablePrinter& tp, T const& value) { + friend TablePrinter& operator<< (TablePrinter& tp, T const& value) { tp.m_oss << value; return tp; } - friend TablePrinter& operator << (TablePrinter& tp, ColumnBreak) { + friend TablePrinter& operator<< (TablePrinter& tp, ColumnBreak) { auto colStr = tp.m_oss.str(); const auto strSize = colStr.size(); tp.m_oss.str(""); @@ -361,13 +362,18 @@ class TablePrinter { return tp; } - friend TablePrinter& operator << (TablePrinter& tp, RowBreak) { + friend TablePrinter& operator<< (TablePrinter& tp, RowBreak) { if (tp.m_currentColumn > 0) { tp.m_os << '\n'; tp.m_currentColumn = -1; } return tp; } + + friend TablePrinter& operator<<(TablePrinter& tp, OutputFlush) { + tp.m_os << std::flush; + return tp; + } }; ConsoleReporter::ConsoleReporter(ReporterConfig&& config): @@ -389,7 +395,7 @@ ConsoleReporter::ConsoleReporter(ReporterConfig&& config): { "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 43, Justification::Left }, { "samples mean std dev", 14, Justification::Right }, { "iterations low mean low std dev", 14, Justification::Right }, - { "estimated high mean high std dev", 14, Justification::Right } + { "est run time high mean high std dev", 14, Justification::Right } }; } }())) {} @@ -473,8 +479,11 @@ void ConsoleReporter::benchmarkPreparing( StringRef name ) { void ConsoleReporter::benchmarkStarting(BenchmarkInfo const& info) { (*m_tablePrinter) << info.samples << ColumnBreak() << info.iterations << ColumnBreak(); - if (!m_config->benchmarkNoAnalysis()) - (*m_tablePrinter) << Duration(info.estimatedDuration) << ColumnBreak(); + if ( !m_config->benchmarkNoAnalysis() ) { + ( *m_tablePrinter ) + << Duration( info.estimatedDuration ) << ColumnBreak(); + } + ( *m_tablePrinter ) << OutputFlush{}; } void ConsoleReporter::benchmarkEnded(BenchmarkStats<> const& stats) { if (m_config->benchmarkNoAnalysis()) diff --git a/external_imported/Catch2/src/catch2/reporters/catch_reporter_cumulative_base.hpp b/external_imported/Catch2/src/catch2/reporters/catch_reporter_cumulative_base.hpp index cdff99913..267b39fdb 100644 --- a/external_imported/Catch2/src/catch2/reporters/catch_reporter_cumulative_base.hpp +++ b/external_imported/Catch2/src/catch2/reporters/catch_reporter_cumulative_base.hpp @@ -8,7 +8,6 @@ #ifndef CATCH_REPORTER_CUMULATIVE_BASE_HPP_INCLUDED #define CATCH_REPORTER_CUMULATIVE_BASE_HPP_INCLUDED -#include #include #include #include @@ -125,7 +124,7 @@ namespace Catch { void skipTest(TestCaseInfo const&) override {} protected: - //! Should the cumulative base store the assertion expansion for succesful assertions? + //! Should the cumulative base store the assertion expansion for successful assertions? bool m_shouldStoreSuccesfulAssertions = true; //! Should the cumulative base store the assertion expansion for failed assertions? bool m_shouldStoreFailedAssertions = true; diff --git a/external_imported/Catch2/src/catch2/reporters/catch_reporter_json.cpp b/external_imported/Catch2/src/catch2/reporters/catch_reporter_json.cpp new file mode 100644 index 000000000..1f0db8b0d --- /dev/null +++ b/external_imported/Catch2/src/catch2/reporters/catch_reporter_json.cpp @@ -0,0 +1,372 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 +// +#include +#include +#include +#include +#include +#include +#include + +namespace Catch { + namespace { + void writeSourceInfo( JsonObjectWriter& writer, + SourceLineInfo const& sourceInfo ) { + auto source_location_writer = + writer.write( "source-location"_sr ).writeObject(); + source_location_writer.write( "filename"_sr ) + .write( sourceInfo.file ); + source_location_writer.write( "line"_sr ).write( sourceInfo.line ); + } + + void writeTags( JsonArrayWriter writer, std::vector const& tags ) { + for ( auto const& tag : tags ) { + writer.write( tag.original ); + } + } + + void writeProperties( JsonArrayWriter writer, + TestCaseInfo const& info ) { + if ( info.isHidden() ) { writer.write( "is-hidden"_sr ); } + if ( info.okToFail() ) { writer.write( "ok-to-fail"_sr ); } + if ( info.expectedToFail() ) { + writer.write( "expected-to-fail"_sr ); + } + if ( info.throws() ) { writer.write( "throws"_sr ); } + } + + } // namespace + + JsonReporter::JsonReporter( ReporterConfig&& config ): + StreamingReporterBase{ CATCH_MOVE( config ) } { + + m_preferences.shouldRedirectStdOut = true; + // TBD: Do we want to report all assertions? XML reporter does + // not, but for machine-parseable reporters I think the answer + // should be yes. + m_preferences.shouldReportAllAssertions = true; + + m_objectWriters.emplace( m_stream ); + m_writers.emplace( Writer::Object ); + auto& writer = m_objectWriters.top(); + + writer.write( "version"_sr ).write( 1 ); + + { + auto metadata_writer = writer.write( "metadata"_sr ).writeObject(); + metadata_writer.write( "name"_sr ).write( m_config->name() ); + metadata_writer.write( "rng-seed"_sr ).write( m_config->rngSeed() ); + metadata_writer.write( "catch2-version"_sr ) + .write( libraryVersion() ); + if ( m_config->testSpec().hasFilters() ) { + metadata_writer.write( "filters"_sr ) + .write( m_config->testSpec() ); + } + } + } + + JsonReporter::~JsonReporter() { + endListing(); + // TODO: Ensure this closes the top level object, add asserts + assert( m_writers.size() == 1 && "Only the top level object should be open" ); + assert( m_writers.top() == Writer::Object ); + endObject(); + m_stream << '\n' << std::flush; + assert( m_writers.empty() ); + } + + JsonArrayWriter& JsonReporter::startArray() { + m_arrayWriters.emplace( m_arrayWriters.top().writeArray() ); + m_writers.emplace( Writer::Array ); + return m_arrayWriters.top(); + } + JsonArrayWriter& JsonReporter::startArray( StringRef key ) { + m_arrayWriters.emplace( + m_objectWriters.top().write( key ).writeArray() ); + m_writers.emplace( Writer::Array ); + return m_arrayWriters.top(); + } + + JsonObjectWriter& JsonReporter::startObject() { + m_objectWriters.emplace( m_arrayWriters.top().writeObject() ); + m_writers.emplace( Writer::Object ); + return m_objectWriters.top(); + } + JsonObjectWriter& JsonReporter::startObject( StringRef key ) { + m_objectWriters.emplace( + m_objectWriters.top().write( key ).writeObject() ); + m_writers.emplace( Writer::Object ); + return m_objectWriters.top(); + } + + void JsonReporter::endObject() { + assert( isInside( Writer::Object ) ); + m_objectWriters.pop(); + m_writers.pop(); + } + void JsonReporter::endArray() { + assert( isInside( Writer::Array ) ); + m_arrayWriters.pop(); + m_writers.pop(); + } + + bool JsonReporter::isInside( Writer writer ) { + return !m_writers.empty() && m_writers.top() == writer; + } + + void JsonReporter::startListing() { + if ( !m_startedListing ) { startObject( "listings"_sr ); } + m_startedListing = true; + } + void JsonReporter::endListing() { + if ( m_startedListing ) { endObject(); } + m_startedListing = false; + } + + std::string JsonReporter::getDescription() { + return "Outputs listings as JSON. Test listing is Work-in-Progress!"; + } + + void JsonReporter::testRunStarting( TestRunInfo const& testInfo ) { + StreamingReporterBase::testRunStarting( testInfo ); + endListing(); + + assert( isInside( Writer::Object ) ); + startObject( "test-run"_sr ); + startArray( "test-cases"_sr ); + } + + static void writeCounts( JsonObjectWriter&& writer, Counts const& counts ) { + writer.write( "passed"_sr ).write( counts.passed ); + writer.write( "failed"_sr ).write( counts.failed ); + writer.write( "fail-but-ok"_sr ).write( counts.failedButOk ); + writer.write( "skipped"_sr ).write( counts.skipped ); + } + + void JsonReporter::testRunEnded(TestRunStats const& runStats) { + assert( isInside( Writer::Array ) ); + // End "test-cases" + endArray(); + + { + auto totals = + m_objectWriters.top().write( "totals"_sr ).writeObject(); + writeCounts( totals.write( "assertions"_sr ).writeObject(), + runStats.totals.assertions ); + writeCounts( totals.write( "test-cases"_sr ).writeObject(), + runStats.totals.testCases ); + } + + // End the "test-run" object + endObject(); + } + + void JsonReporter::testCaseStarting( TestCaseInfo const& tcInfo ) { + StreamingReporterBase::testCaseStarting( tcInfo ); + + assert( isInside( Writer::Array ) && + "We should be in the 'test-cases' array" ); + startObject(); + // "test-info" prelude + { + auto testInfo = + m_objectWriters.top().write( "test-info"_sr ).writeObject(); + // TODO: handle testName vs className!! + testInfo.write( "name"_sr ).write( tcInfo.name ); + writeSourceInfo(testInfo, tcInfo.lineInfo); + writeTags( testInfo.write( "tags"_sr ).writeArray(), tcInfo.tags ); + writeProperties( testInfo.write( "properties"_sr ).writeArray(), + tcInfo ); + } + + + // Start the array for individual test runs (testCasePartial pairs) + startArray( "runs"_sr ); + } + + void JsonReporter::testCaseEnded( TestCaseStats const& tcStats ) { + StreamingReporterBase::testCaseEnded( tcStats ); + + // We need to close the 'runs' array before finishing the test case + assert( isInside( Writer::Array ) ); + endArray(); + + { + auto totals = + m_objectWriters.top().write( "totals"_sr ).writeObject(); + writeCounts( totals.write( "assertions"_sr ).writeObject(), + tcStats.totals.assertions ); + // We do not write the test case totals, because there will always be just one test case here. + // TODO: overall "result" -> success, skip, fail here? Or in partial result? + } + // We do not write out stderr/stdout, because we instead wrote those out in partial runs + + // TODO: aborting? + + // And we also close this test case's object + assert( isInside( Writer::Object ) ); + endObject(); + } + + void JsonReporter::testCasePartialStarting( TestCaseInfo const& /*tcInfo*/, + uint64_t index ) { + startObject(); + m_objectWriters.top().write( "run-idx"_sr ).write( index ); + startArray( "path"_sr ); + // TODO: we want to delay most of the printing to the 'root' section + // TODO: childSection key name? + } + + void JsonReporter::testCasePartialEnded( TestCaseStats const& tcStats, + uint64_t /*index*/ ) { + // Fixme: the top level section handles this. + //// path object + endArray(); + if ( !tcStats.stdOut.empty() ) { + m_objectWriters.top() + .write( "captured-stdout"_sr ) + .write( tcStats.stdOut ); + } + if ( !tcStats.stdErr.empty() ) { + m_objectWriters.top() + .write( "captured-stderr"_sr ) + .write( tcStats.stdErr ); + } + { + auto totals = + m_objectWriters.top().write( "totals"_sr ).writeObject(); + writeCounts( totals.write( "assertions"_sr ).writeObject(), + tcStats.totals.assertions ); + // We do not write the test case totals, because there will + // always be just one test case here. + // TODO: overall "result" -> success, skip, fail here? Or in + // partial result? + } + // TODO: aborting? + // run object + endObject(); + } + + void JsonReporter::sectionStarting( SectionInfo const& sectionInfo ) { + assert( isInside( Writer::Array ) && + "Section should always start inside an object" ); + // We want to nest top level sections, even though it shares name + // and source loc with the TEST_CASE + auto& sectionObject = startObject(); + sectionObject.write( "kind"_sr ).write( "section"_sr ); + sectionObject.write( "name"_sr ).write( sectionInfo.name ); + writeSourceInfo( m_objectWriters.top(), sectionInfo.lineInfo ); + + + // TBD: Do we want to create this event lazily? It would become + // rather complex, but we could do it, and it would look + // better for empty sections. OTOH, empty sections should + // be rare. + startArray( "path"_sr ); + } + void JsonReporter::sectionEnded( SectionStats const& /*sectionStats */) { + // End the subpath array + endArray(); + // TODO: metadata + // TODO: what info do we have here? + + // End the section object + endObject(); + } + + void JsonReporter::assertionStarting( AssertionInfo const& /*assertionInfo*/ ) {} + void JsonReporter::assertionEnded( AssertionStats const& assertionStats ) { + // TODO: There is lot of different things to handle here, but + // we can fill it in later, after we show that the basic + // outline and streaming reporter impl works well enough. + //if ( !m_config->includeSuccessfulResults() + // && assertionStats.assertionResult.isOk() ) { + // return; + //} + assert( isInside( Writer::Array ) ); + auto assertionObject = m_arrayWriters.top().writeObject(); + + assertionObject.write( "kind"_sr ).write( "assertion"_sr ); + writeSourceInfo( assertionObject, + assertionStats.assertionResult.getSourceInfo() ); + assertionObject.write( "status"_sr ) + .write( assertionStats.assertionResult.isOk() ); + // TODO: handling of result. + // TODO: messages + // TODO: totals? + } + + + void JsonReporter::benchmarkPreparing( StringRef name ) { (void)name; } + void JsonReporter::benchmarkStarting( BenchmarkInfo const& ) {} + void JsonReporter::benchmarkEnded( BenchmarkStats<> const& ) {} + void JsonReporter::benchmarkFailed( StringRef error ) { (void)error; } + + void JsonReporter::listReporters( + std::vector const& descriptions ) { + startListing(); + + auto writer = + m_objectWriters.top().write( "reporters"_sr ).writeArray(); + for ( auto const& desc : descriptions ) { + auto desc_writer = writer.writeObject(); + desc_writer.write( "name"_sr ).write( desc.name ); + desc_writer.write( "description"_sr ).write( desc.description ); + } + } + void JsonReporter::listListeners( + std::vector const& descriptions ) { + startListing(); + + auto writer = + m_objectWriters.top().write( "listeners"_sr ).writeArray(); + + for ( auto const& desc : descriptions ) { + auto desc_writer = writer.writeObject(); + desc_writer.write( "name"_sr ).write( desc.name ); + desc_writer.write( "description"_sr ).write( desc.description ); + } + } + void JsonReporter::listTests( std::vector const& tests ) { + startListing(); + + auto writer = m_objectWriters.top().write( "tests"_sr ).writeArray(); + + for ( auto const& test : tests ) { + auto desc_writer = writer.writeObject(); + auto const& info = test.getTestCaseInfo(); + + desc_writer.write( "name"_sr ).write( info.name ); + desc_writer.write( "class-name"_sr ).write( info.className ); + { + auto tag_writer = desc_writer.write( "tags"_sr ).writeArray(); + for ( auto const& tag : info.tags ) { + tag_writer.write( tag.original ); + } + } + writeSourceInfo( desc_writer, info.lineInfo ); + } + } + void JsonReporter::listTags( std::vector const& tags ) { + startListing(); + + auto writer = m_objectWriters.top().write( "tags"_sr ).writeArray(); + for ( auto const& tag : tags ) { + auto tag_writer = writer.writeObject(); + { + auto aliases_writer = + tag_writer.write( "aliases"_sr ).writeArray(); + for ( auto alias : tag.spellings ) { + aliases_writer.write( alias ); + } + } + tag_writer.write( "count"_sr ).write( tag.count ); + } + } +} // namespace Catch diff --git a/external_imported/Catch2/src/catch2/reporters/catch_reporter_json.hpp b/external_imported/Catch2/src/catch2/reporters/catch_reporter_json.hpp new file mode 100644 index 000000000..c938ca394 --- /dev/null +++ b/external_imported/Catch2/src/catch2/reporters/catch_reporter_json.hpp @@ -0,0 +1,95 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#ifndef CATCH_REPORTER_JSON_HPP_INCLUDED +#define CATCH_REPORTER_JSON_HPP_INCLUDED + +#include +#include +#include + +#include + +namespace Catch { + class JsonReporter : public StreamingReporterBase { + public: + JsonReporter( ReporterConfig&& config ); + + ~JsonReporter() override; + + static std::string getDescription(); + + public: // StreamingReporterBase + void testRunStarting( TestRunInfo const& runInfo ) override; + void testRunEnded( TestRunStats const& runStats ) override; + + void testCaseStarting( TestCaseInfo const& tcInfo ) override; + void testCaseEnded( TestCaseStats const& tcStats ) override; + + void testCasePartialStarting( TestCaseInfo const& tcInfo, + uint64_t index ) override; + void testCasePartialEnded( TestCaseStats const& tcStats, + uint64_t index ) override; + + void sectionStarting( SectionInfo const& sectionInfo ) override; + void sectionEnded( SectionStats const& sectionStats ) override; + + void assertionStarting( AssertionInfo const& assertionInfo ) override; + void assertionEnded( AssertionStats const& assertionStats ) override; + + //void testRunEndedCumulative() override; + + void benchmarkPreparing( StringRef name ) override; + void benchmarkStarting( BenchmarkInfo const& ) override; + void benchmarkEnded( BenchmarkStats<> const& ) override; + void benchmarkFailed( StringRef error ) override; + + void listReporters( + std::vector const& descriptions ) override; + void listListeners( + std::vector const& descriptions ) override; + void listTests( std::vector const& tests ) override; + void listTags( std::vector const& tags ) override; + + private: + Timer m_testCaseTimer; + enum class Writer { + Object, + Array + }; + + JsonArrayWriter& startArray(); + JsonArrayWriter& startArray( StringRef key ); + + JsonObjectWriter& startObject(); + JsonObjectWriter& startObject( StringRef key ); + + void endObject(); + void endArray(); + + bool isInside( Writer writer ); + + void startListing(); + void endListing(); + + // Invariant: + // When m_writers is not empty and its top element is + // - Writer::Object, then m_objectWriters is not be empty + // - Writer::Array, then m_arrayWriters shall not be empty + std::stack m_objectWriters{}; + std::stack m_arrayWriters{}; + std::stack m_writers{}; + + bool m_startedListing = false; + + // std::size_t m_sectionDepth = 0; + // std::size_t m_sectionStarted = 0; + }; +} // namespace Catch + +#endif // CATCH_REPORTER_JSON_HPP_INCLUDED diff --git a/external_imported/Catch2/src/catch2/reporters/catch_reporter_junit.cpp b/external_imported/Catch2/src/catch2/reporters/catch_reporter_junit.cpp index 22d6526fa..fc5cae34a 100644 --- a/external_imported/Catch2/src/catch2/reporters/catch_reporter_junit.cpp +++ b/external_imported/Catch2/src/catch2/reporters/catch_reporter_junit.cpp @@ -33,6 +33,8 @@ namespace Catch { gmtime_s(&timeInfo, &rawtime); #elif defined (CATCH_PLATFORM_PLAYSTATION) gmtime_s(&rawtime, &timeInfo); +#elif defined (__IAR_SYSTEMS_ICC__) + timeInfo = *std::gmtime(&rawtime); #else gmtime_r(&rawtime, &timeInfo); #endif @@ -293,7 +295,7 @@ namespace Catch { } } - if( !result.getMessage().empty() ) + if( result.hasMessage() ) rss << result.getMessage() << '\n'; for( auto const& msg : stats.infoMessages ) if( msg.type == ResultWas::Info ) diff --git a/external_imported/Catch2/src/catch2/reporters/catch_reporter_junit.hpp b/external_imported/Catch2/src/catch2/reporters/catch_reporter_junit.hpp index 87c7c5679..7cb53c25b 100644 --- a/external_imported/Catch2/src/catch2/reporters/catch_reporter_junit.hpp +++ b/external_imported/Catch2/src/catch2/reporters/catch_reporter_junit.hpp @@ -19,8 +19,6 @@ namespace Catch { public: JunitReporter(ReporterConfig&& _config); - ~JunitReporter() override = default; - static std::string getDescription(); void testRunStarting(TestRunInfo const& runInfo) override; diff --git a/external_imported/Catch2/src/catch2/reporters/catch_reporter_multi.cpp b/external_imported/Catch2/src/catch2/reporters/catch_reporter_multi.cpp index ebf28b64f..531902bea 100644 --- a/external_imported/Catch2/src/catch2/reporters/catch_reporter_multi.cpp +++ b/external_imported/Catch2/src/catch2/reporters/catch_reporter_multi.cpp @@ -114,7 +114,6 @@ namespace Catch { } } - // The return value indicates if the messages buffer should be cleared: void MultiReporter::assertionEnded( AssertionStats const& assertionStats ) { const bool reportByDefault = assertionStats.assertionResult.getResultType() != ResultWas::Ok || diff --git a/external_imported/Catch2/src/catch2/reporters/catch_reporter_registrars.cpp b/external_imported/Catch2/src/catch2/reporters/catch_reporter_registrars.cpp index a9787ce58..2a3ac9579 100644 --- a/external_imported/Catch2/src/catch2/reporters/catch_reporter_registrars.cpp +++ b/external_imported/Catch2/src/catch2/reporters/catch_reporter_registrars.cpp @@ -8,6 +8,7 @@ #include +#include #include namespace Catch { @@ -26,5 +27,10 @@ namespace Catch { } } + void registerListenerImpl( Detail::unique_ptr listenerFactory ) { + getMutableRegistryHub().registerListener( CATCH_MOVE(listenerFactory) ); + } + + } // namespace Detail } // namespace Catch diff --git a/external_imported/Catch2/src/catch2/reporters/catch_reporter_registrars.hpp b/external_imported/Catch2/src/catch2/reporters/catch_reporter_registrars.hpp index db5688f25..a93963f06 100644 --- a/external_imported/Catch2/src/catch2/reporters/catch_reporter_registrars.hpp +++ b/external_imported/Catch2/src/catch2/reporters/catch_reporter_registrars.hpp @@ -8,8 +8,6 @@ #ifndef CATCH_REPORTER_REGISTRARS_HPP_INCLUDED #define CATCH_REPORTER_REGISTRARS_HPP_INCLUDED -#include -#include #include #include #include @@ -36,7 +34,8 @@ namespace Catch { //! independent on the reporter's concrete type void registerReporterImpl( std::string const& name, IReporterFactoryPtr reporterPtr ); - + //! Actually registers the factory, independent on listener's concrete type + void registerListenerImpl( Detail::unique_ptr listenerFactory ); } // namespace Detail class IEventListener; @@ -97,7 +96,7 @@ namespace Catch { public: ListenerRegistrar(StringRef listenerName) { - getMutableRegistryHub().registerListener( Detail::make_unique(listenerName) ); + registerListenerImpl( Detail::make_unique(listenerName) ); } }; } diff --git a/external_imported/Catch2/src/catch2/reporters/catch_reporter_sonarqube.cpp b/external_imported/Catch2/src/catch2/reporters/catch_reporter_sonarqube.cpp index dd002b611..9c391b1f4 100644 --- a/external_imported/Catch2/src/catch2/reporters/catch_reporter_sonarqube.cpp +++ b/external_imported/Catch2/src/catch2/reporters/catch_reporter_sonarqube.cpp @@ -147,7 +147,7 @@ namespace Catch { } } - if (!result.getMessage().empty()) + if (result.hasMessage()) textRss << result.getMessage() << '\n'; for (auto const& msg : stats.infoMessages) diff --git a/external_imported/Catch2/src/catch2/reporters/catch_reporter_sonarqube.hpp b/external_imported/Catch2/src/catch2/reporters/catch_reporter_sonarqube.hpp index cad6deec8..d26af62e8 100644 --- a/external_imported/Catch2/src/catch2/reporters/catch_reporter_sonarqube.hpp +++ b/external_imported/Catch2/src/catch2/reporters/catch_reporter_sonarqube.hpp @@ -25,8 +25,6 @@ namespace Catch { m_shouldStoreSuccesfulAssertions = false; } - ~SonarQubeReporter() override = default; - static std::string getDescription() { using namespace std::string_literals; return "Reports test results in the Generic Test Data SonarQube XML format"s; diff --git a/external_imported/Catch2/src/catch2/reporters/catch_reporter_streaming_base.hpp b/external_imported/Catch2/src/catch2/reporters/catch_reporter_streaming_base.hpp index 13672a285..5448000c7 100644 --- a/external_imported/Catch2/src/catch2/reporters/catch_reporter_streaming_base.hpp +++ b/external_imported/Catch2/src/catch2/reporters/catch_reporter_streaming_base.hpp @@ -8,7 +8,6 @@ #ifndef CATCH_REPORTER_STREAMING_BASE_HPP_INCLUDED #define CATCH_REPORTER_STREAMING_BASE_HPP_INCLUDED -#include #include #include diff --git a/external_imported/Catch2/src/catch2/reporters/catch_reporter_tap.cpp b/external_imported/Catch2/src/catch2/reporters/catch_reporter_tap.cpp index 563d6fb1b..67d406fb8 100644 --- a/external_imported/Catch2/src/catch2/reporters/catch_reporter_tap.cpp +++ b/external_imported/Catch2/src/catch2/reporters/catch_reporter_tap.cpp @@ -14,7 +14,6 @@ #include #include -#include #include namespace Catch { @@ -165,7 +164,7 @@ namespace Catch { // using messages.end() directly (or auto) yields compilation error: std::vector::const_iterator itEnd = messages.end(); - const std::size_t N = static_cast(std::distance(itMessage, itEnd)); + const std::size_t N = static_cast(itEnd - itMessage); stream << colourImpl->guardColour( colour ) << " with " << pluralise( N, "message"_sr ) << ':'; diff --git a/external_imported/Catch2/src/catch2/reporters/catch_reporter_tap.hpp b/external_imported/Catch2/src/catch2/reporters/catch_reporter_tap.hpp index fe45df63e..e6889bb11 100644 --- a/external_imported/Catch2/src/catch2/reporters/catch_reporter_tap.hpp +++ b/external_imported/Catch2/src/catch2/reporters/catch_reporter_tap.hpp @@ -19,7 +19,6 @@ namespace Catch { StreamingReporterBase( CATCH_MOVE(config) ) { m_preferences.shouldReportAllAssertions = true; } - ~TAPReporter() override = default; static std::string getDescription() { using namespace std::string_literals; diff --git a/external_imported/Catch2/src/catch2/reporters/catch_reporter_teamcity.cpp b/external_imported/Catch2/src/catch2/reporters/catch_reporter_teamcity.cpp index 320728007..38aa55a65 100644 --- a/external_imported/Catch2/src/catch2/reporters/catch_reporter_teamcity.cpp +++ b/external_imported/Catch2/src/catch2/reporters/catch_reporter_teamcity.cpp @@ -45,7 +45,7 @@ namespace Catch { } // end anonymous namespace - TeamCityReporter::~TeamCityReporter() {} + TeamCityReporter::~TeamCityReporter() = default; void TeamCityReporter::testRunStarting( TestRunInfo const& runInfo ) { m_stream << "##teamcity[testSuiteStarted name='" << escape( runInfo.name ) diff --git a/external_imported/Catch2/src/catch2/reporters/catch_reporter_xml.cpp b/external_imported/Catch2/src/catch2/reporters/catch_reporter_xml.cpp index 13812b927..35a3028ee 100644 --- a/external_imported/Catch2/src/catch2/reporters/catch_reporter_xml.cpp +++ b/external_imported/Catch2/src/catch2/reporters/catch_reporter_xml.cpp @@ -56,7 +56,7 @@ namespace Catch { m_xml.startElement("Catch2TestRun") .writeAttribute("name"_sr, m_config->name()) .writeAttribute("rng-seed"_sr, m_config->rngSeed()) - .writeAttribute("xml-format-version"_sr, 2) + .writeAttribute("xml-format-version"_sr, 3) .writeAttribute("catch2-version"_sr, libraryVersion()); if ( m_config->testSpec().hasFilters() ) { m_xml.writeAttribute( "filters"_sr, m_config->testSpec() ); @@ -98,11 +98,13 @@ namespace Catch { // Print any info messages in tags. for( auto const& msg : assertionStats.infoMessages ) { if( msg.type == ResultWas::Info && includeResults ) { - m_xml.scopedElement( "Info" ) - .writeText( msg.message ); + auto t = m_xml.scopedElement( "Info" ); + writeSourceInfo( msg.lineInfo ); + t.writeText( msg.message ); } else if ( msg.type == ResultWas::Warning ) { - m_xml.scopedElement( "Warning" ) - .writeText( msg.message ); + auto t = m_xml.scopedElement( "Warning" ); + writeSourceInfo( msg.lineInfo ); + t.writeText( msg.message ); } } } @@ -232,26 +234,23 @@ namespace Catch { } void XmlReporter::benchmarkEnded(BenchmarkStats<> const& benchmarkStats) { - m_xml.startElement("mean") + m_xml.scopedElement("mean") .writeAttribute("value"_sr, benchmarkStats.mean.point.count()) .writeAttribute("lowerBound"_sr, benchmarkStats.mean.lower_bound.count()) .writeAttribute("upperBound"_sr, benchmarkStats.mean.upper_bound.count()) .writeAttribute("ci"_sr, benchmarkStats.mean.confidence_interval); - m_xml.endElement(); - m_xml.startElement("standardDeviation") + m_xml.scopedElement("standardDeviation") .writeAttribute("value"_sr, benchmarkStats.standardDeviation.point.count()) .writeAttribute("lowerBound"_sr, benchmarkStats.standardDeviation.lower_bound.count()) .writeAttribute("upperBound"_sr, benchmarkStats.standardDeviation.upper_bound.count()) .writeAttribute("ci"_sr, benchmarkStats.standardDeviation.confidence_interval); - m_xml.endElement(); - m_xml.startElement("outliers") + m_xml.scopedElement("outliers") .writeAttribute("variance"_sr, benchmarkStats.outlierVariance) .writeAttribute("lowMild"_sr, benchmarkStats.outliers.low_mild) .writeAttribute("lowSevere"_sr, benchmarkStats.outliers.low_severe) .writeAttribute("highMild"_sr, benchmarkStats.outliers.high_mild) .writeAttribute("highSevere"_sr, benchmarkStats.outliers.high_severe); m_xml.endElement(); - m_xml.endElement(); } void XmlReporter::benchmarkFailed(StringRef error) { diff --git a/external_imported/Catch2/src/catch2/reporters/catch_reporters_all.hpp b/external_imported/Catch2/src/catch2/reporters/catch_reporters_all.hpp index 16f7bd70c..5c713fe14 100644 --- a/external_imported/Catch2/src/catch2/reporters/catch_reporters_all.hpp +++ b/external_imported/Catch2/src/catch2/reporters/catch_reporters_all.hpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/external_imported/Catch2/tests/CMakeLists.txt b/external_imported/Catch2/tests/CMakeLists.txt index 7be57abec..d3ab14a7f 100644 --- a/external_imported/Catch2/tests/CMakeLists.txt +++ b/external_imported/Catch2/tests/CMakeLists.txt @@ -78,6 +78,7 @@ endif(MSVC) #Temporary workaround set(TEST_SOURCES ${SELF_TEST_DIR}/TestRegistrations.cpp ${SELF_TEST_DIR}/IntrospectiveTests/Algorithms.tests.cpp + ${SELF_TEST_DIR}/IntrospectiveTests/AssertionHandler.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/Clara.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/CmdLine.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/CmdLineHelpers.tests.cpp @@ -85,7 +86,9 @@ set(TEST_SOURCES ${SELF_TEST_DIR}/IntrospectiveTests/Details.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/FloatingPoint.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/GeneratorsImpl.tests.cpp + ${SELF_TEST_DIR}/IntrospectiveTests/Integer.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/InternalBenchmark.tests.cpp + ${SELF_TEST_DIR}/IntrospectiveTests/Json.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/Parse.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/PartTracker.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/RandomNumberGeneration.tests.cpp @@ -622,6 +625,18 @@ if (CATCH_ENABLE_CONFIGURE_TESTS) endforeach() endif() +if (CATCH_ENABLE_CMAKE_HELPER_TESTS) + add_test(NAME "CMakeHelper::DiscoverTests" + COMMAND + "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_LIST_DIR}/TestScripts/DiscoverTests/VerifyRegistration.py" "${CATCH_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" + ) + set_tests_properties("CMakeHelper::DiscoverTests" + PROPERTIES + COST 240 + LABELS "uses-python" + ) +endif() + foreach (reporterName # "Automake" - the simple .trs format does not support any kind of comments/metadata "compact" "console" @@ -629,7 +644,8 @@ foreach (reporterName # "Automake" - the simple .trs format does not support any "SonarQube" "TAP" # "TeamCity" - does not seem to support test suite-level metadata/comments - "XML") + "XML" + "JSON") add_test(NAME "Reporters:Filters:${reporterName}" COMMAND @@ -639,6 +655,8 @@ foreach (reporterName # "Automake" - the simple .trs format does not support any # Different regex for these two reporters, because the commas end up xml-escaped if (reporterName MATCHES "JUnit|XML") set(testCaseNameFormat ""CaseInsensitiveLess is case insensitive"") + elseif(reporterName MATCHES "JSON") + set(testCaseNameFormat "\\\\\"CaseInsensitiveLess is case insensitive\\\\\"") else() set(testCaseNameFormat "\"CaseInsensitiveLess is case insensitive\"") endif() diff --git a/external_imported/Catch2/tests/ExtraTests/CMakeLists.txt b/external_imported/Catch2/tests/ExtraTests/CMakeLists.txt index 4172d7a03..2a810e258 100644 --- a/external_imported/Catch2/tests/ExtraTests/CMakeLists.txt +++ b/external_imported/Catch2/tests/ExtraTests/CMakeLists.txt @@ -468,6 +468,17 @@ set_tests_properties( ) +add_executable(AssertionStartingEventGoesBeforeAssertionIsEvaluated + X20-AssertionStartingEventGoesBeforeAssertionIsEvaluated.cpp +) +target_link_libraries(AssertionStartingEventGoesBeforeAssertionIsEvaluated + PRIVATE Catch2::Catch2WithMain +) +add_test( + NAME ReporterEvents::AssertionStartingHappensBeforeAssertionIsEvaluated + COMMAND $ +) + #add_executable(DebugBreakMacros ${TESTS_DIR}/X12-CustomDebugBreakMacro.cpp) #target_link_libraries(DebugBreakMacros Catch2) #add_test(NAME DebugBreakMacros COMMAND DebugBreakMacros --break) diff --git a/external_imported/Catch2/tests/ExtraTests/X20-AssertionStartingEventGoesBeforeAssertionIsEvaluated.cpp b/external_imported/Catch2/tests/ExtraTests/X20-AssertionStartingEventGoesBeforeAssertionIsEvaluated.cpp new file mode 100644 index 000000000..6f44bf691 --- /dev/null +++ b/external_imported/Catch2/tests/ExtraTests/X20-AssertionStartingEventGoesBeforeAssertionIsEvaluated.cpp @@ -0,0 +1,77 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +/**\file + * Registers an event listener to increments counter of assertionStarting events. + * + * Different assertion macros then check that the counter is at expected + * value when they are evaluated. + */ + +#include +#include +#include +#include + +namespace { + + static size_t assertion_starting_events_seen = 0; + + class AssertionStartingListener : public Catch::EventListenerBase { + public: + AssertionStartingListener( Catch::IConfig const* config ): + EventListenerBase( config ) {} + + void assertionStarting( Catch::AssertionInfo const& ) override { + ++assertion_starting_events_seen; + } + }; + + static bool f1() { + return assertion_starting_events_seen == 1; + } + + static void f2() { + if ( assertion_starting_events_seen != 2 ) { throw 1; } + } + + static void f3() { + if ( assertion_starting_events_seen == 3 ) { throw 1; } + } + + static bool f4() { return assertion_starting_events_seen == 4; } + + static void f5() { throw assertion_starting_events_seen; } + +} // anonymous namespace + +CATCH_REGISTER_LISTENER( AssertionStartingListener ) + +TEST_CASE() { + // **IMPORTANT** + // The order of assertions below matters. + REQUIRE( f1() ); + REQUIRE_NOTHROW( f2() ); + REQUIRE_THROWS( f3() ); + REQUIRE_THAT( f4(), + Catch::Matchers::Predicate( []( bool b ) { return b; } ) ); + REQUIRE_THROWS_MATCHES( + f5(), size_t, Catch::Matchers::Predicate( []( size_t i ) { + return i == 5; + } ) ); + + CAPTURE( assertion_starting_events_seen ); // **not** an assertion + INFO( "some info msg" ); // **not** an assertion + WARN( "warning! warning!" ); // assertion-like message + SUCCEED(); // assertion-like message + + // We skip FAIL/SKIP and so on, which fail the test. + + // This require will also increment the count once + REQUIRE( assertion_starting_events_seen == 8 ); +} diff --git a/external_imported/Catch2/tests/SelfTest/Baselines/automake.sw.approved.txt b/external_imported/Catch2/tests/SelfTest/Baselines/automake.sw.approved.txt index d33effddf..88c23e173 100644 --- a/external_imported/Catch2/tests/SelfTest/Baselines/automake.sw.approved.txt +++ b/external_imported/Catch2/tests/SelfTest/Baselines/automake.sw.approved.txt @@ -130,8 +130,8 @@ Nor would this :test-result: FAIL Custom std-exceptions can be custom translated :test-result: PASS Default scale is invisible to comparison :test-result: PASS Directly creating an EnumInfo +:test-result: SKIP Empty generators can SKIP in constructor :test-result: PASS Empty stream name opens cout stream -:test-result: PASS Empty tag is not allowed :test-result: FAIL EndsWith string matcher :test-result: PASS Enums can quickly have stringification enabled using REGISTER_ENUM :test-result: PASS Enums in namespaces can quickly have stringification enabled using REGISTER_ENUM @@ -154,6 +154,7 @@ Nor would this :test-result: PASS Filter generator throws exception for empty generator :test-result: PASS Floating point matchers: double :test-result: PASS Floating point matchers: float +:test-result: PASS GENERATE can combine literals and generators :test-result: PASS Generators -- adapters :test-result: PASS Generators -- simple :test-result: PASS Generators internals @@ -162,12 +163,16 @@ Nor would this :test-result: PASS Hashers with same seed produce same hash :test-result: PASS Hashing different test cases produces different result :test-result: PASS Hashing test case produces same hash across multiple calls +:test-result: FAIL INFO and UNSCOPED_INFO can stream multiple arguments :test-result: FAIL INFO and WARN do not abort tests :test-result: FAIL INFO gets logged on failure :test-result: FAIL INFO gets logged on failure, even if captured before successful assertions :test-result: FAIL INFO is reset for each loop +:test-result: XFAIL Incomplete AssertionHandler :test-result: XFAIL Inequality checks that should fail :test-result: PASS Inequality checks that should succeed +:test-result: PASS JsonWriter +:test-result: PASS JsonWriter escapes charaters in strings properly :test-result: PASS Lambdas in assertions :test-result: PASS Less-than inequalities with different epsilons :test-result: PASS ManuallyRegistered @@ -265,6 +270,8 @@ Message from section two :test-result: PASS Testing checked-if :test-result: XFAIL Testing checked-if 2 :test-result: XFAIL Testing checked-if 3 +:test-result: XFAIL Testing checked-if 4 +:test-result: XFAIL Testing checked-if 5 :test-result: FAIL The NO_FAIL macro reports a failure but does not fail the test :test-result: PASS The default listing implementation write to provided stream :test-result: FAIL This test 'should' fail but doesn't @@ -408,6 +415,7 @@ b1! :test-result: PASS tuple :test-result: PASS tuple,tuple<>,float> :test-result: PASS uniform samples +:test-result: PASS uniform_integer_distribution can return the bounds :test-result: PASS unique_ptr reimplementation: basic functionality :test-result: PASS vec> -> toString :test-result: PASS vector -> toString diff --git a/external_imported/Catch2/tests/SelfTest/Baselines/automake.sw.multi.approved.txt b/external_imported/Catch2/tests/SelfTest/Baselines/automake.sw.multi.approved.txt index f698f0c57..a37b1a2b5 100644 --- a/external_imported/Catch2/tests/SelfTest/Baselines/automake.sw.multi.approved.txt +++ b/external_imported/Catch2/tests/SelfTest/Baselines/automake.sw.multi.approved.txt @@ -128,8 +128,8 @@ :test-result: FAIL Custom std-exceptions can be custom translated :test-result: PASS Default scale is invisible to comparison :test-result: PASS Directly creating an EnumInfo +:test-result: SKIP Empty generators can SKIP in constructor :test-result: PASS Empty stream name opens cout stream -:test-result: PASS Empty tag is not allowed :test-result: FAIL EndsWith string matcher :test-result: PASS Enums can quickly have stringification enabled using REGISTER_ENUM :test-result: PASS Enums in namespaces can quickly have stringification enabled using REGISTER_ENUM @@ -152,6 +152,7 @@ :test-result: PASS Filter generator throws exception for empty generator :test-result: PASS Floating point matchers: double :test-result: PASS Floating point matchers: float +:test-result: PASS GENERATE can combine literals and generators :test-result: PASS Generators -- adapters :test-result: PASS Generators -- simple :test-result: PASS Generators internals @@ -160,12 +161,16 @@ :test-result: PASS Hashers with same seed produce same hash :test-result: PASS Hashing different test cases produces different result :test-result: PASS Hashing test case produces same hash across multiple calls +:test-result: FAIL INFO and UNSCOPED_INFO can stream multiple arguments :test-result: FAIL INFO and WARN do not abort tests :test-result: FAIL INFO gets logged on failure :test-result: FAIL INFO gets logged on failure, even if captured before successful assertions :test-result: FAIL INFO is reset for each loop +:test-result: XFAIL Incomplete AssertionHandler :test-result: XFAIL Inequality checks that should fail :test-result: PASS Inequality checks that should succeed +:test-result: PASS JsonWriter +:test-result: PASS JsonWriter escapes charaters in strings properly :test-result: PASS Lambdas in assertions :test-result: PASS Less-than inequalities with different epsilons :test-result: PASS ManuallyRegistered @@ -258,6 +263,8 @@ :test-result: PASS Testing checked-if :test-result: XFAIL Testing checked-if 2 :test-result: XFAIL Testing checked-if 3 +:test-result: XFAIL Testing checked-if 4 +:test-result: XFAIL Testing checked-if 5 :test-result: FAIL The NO_FAIL macro reports a failure but does not fail the test :test-result: PASS The default listing implementation write to provided stream :test-result: FAIL This test 'should' fail but doesn't @@ -397,6 +404,7 @@ :test-result: PASS tuple :test-result: PASS tuple,tuple<>,float> :test-result: PASS uniform samples +:test-result: PASS uniform_integer_distribution can return the bounds :test-result: PASS unique_ptr reimplementation: basic functionality :test-result: PASS vec> -> toString :test-result: PASS vector -> toString diff --git a/external_imported/Catch2/tests/SelfTest/Baselines/compact.sw.approved.txt b/external_imported/Catch2/tests/SelfTest/Baselines/compact.sw.approved.txt index 541770ccc..0669fdbbb 100644 --- a/external_imported/Catch2/tests/SelfTest/Baselines/compact.sw.approved.txt +++ b/external_imported/Catch2/tests/SelfTest/Baselines/compact.sw.approved.txt @@ -331,7 +331,7 @@ MatchersRanges.tests.cpp:: passed: inner_lists_are_empty.front(), I MatchersRanges.tests.cpp:: passed: has_empty{}, !IsEmpty() for: {?} not is empty MatchersRanges.tests.cpp:: passed: unrelated::ADL_empty{}, IsEmpty() for: {?} is empty Message.tests.cpp:: passed: with 7 messages: 'a := 1' and 'b := 2' and 'c := 3' and 'a + b := 3' and 'a+b := 3' and 'c > b := true' and 'a == 1 := true' -Message.tests.cpp:: passed: with 7 messages: 'std::vector{1, 2, 3}[0, 1, 2] := 3' and 'std::vector{1, 2, 3}[(0, 1)] := 2' and 'std::vector{1, 2, 3}[0] := 1' and '(helper_1436{12, -12}) := { 12, -12 }' and '(helper_1436(-12, 12)) := { -12, 12 }' and '(1, 2) := 2' and '(2, 3) := 3' +Message.tests.cpp:: passed: with 7 messages: 'custom_index_op{1, 2, 3}[0, 1, 2] := 0' and 'custom_index_op{1, 2, 3}[(0, 1)] := 0' and 'custom_index_op{1, 2, 3}[0] := 0' and '(helper_1436{12, -12}) := { 12, -12 }' and '(helper_1436(-12, 12)) := { -12, 12 }' and '(1, 2) := 2' and '(2, 3) := 3' Message.tests.cpp:: passed: with 11 messages: '("comma, in string", "escaped, \", ") := "escaped, ", "' and '"single quote in string,'," := "single quote in string,',"' and '"some escapes, \\,\\\\" := "some escapes, \,\\"' and '"some, ), unmatched, } prenheses {[<" := "some, ), unmatched, } prenheses {[<"' and ''"' := '"'' and ''\'' := '''' and '',' := ','' and ''}' := '}'' and '')' := ')'' and ''(' := '('' and ''{' := '{'' ToStringGeneral.tests.cpp:: passed: true with 1 message: 'i := 2' ToStringGeneral.tests.cpp:: passed: true with 1 message: '3' @@ -520,8 +520,8 @@ ToString.tests.cpp:: passed: enumInfo->lookup(1) == "Value2" for: V ToString.tests.cpp:: passed: enumInfo->lookup(3) == "{** unexpected enum value **}" for: {** unexpected enum value **} == "{** unexpected enum value **}" +Skip.tests.cpp:: skipped: 'This generator is empty' Stream.tests.cpp:: passed: Catch::makeStream( "" )->isConsole() for: true -Tag.tests.cpp:: passed: Catch::TestCaseInfo( "", { "fake test name", "[]" }, dummySourceLineInfo ) Matchers.tests.cpp:: failed: testStringForMatching(), EndsWith( "Substring" ) for: "this string contains 'abc' as a substring" ends with: "Substring" Matchers.tests.cpp:: failed: testStringForMatching(), EndsWith( "this", Catch::CaseSensitive::No ) for: "this string contains 'abc' as a substring" ends with: "this" (case insensitive) EnumToString.tests.cpp:: passed: stringify( EnumClass3::Value1 ) == "Value1" for: "Value1" == "Value1" @@ -666,6 +666,10 @@ Matchers.tests.cpp:: passed: 1., !IsNaN() for: 1.0 not is NaN Generators.tests.cpp:: passed: i % 2 == 0 for: 0 == 0 Generators.tests.cpp:: passed: i % 2 == 0 for: 0 == 0 Generators.tests.cpp:: passed: i % 2 == 0 for: 0 == 0 +Generators.tests.cpp:: passed: i % 2 == 0 for: 0 == 0 +Generators.tests.cpp:: passed: i % 2 == 0 for: 0 == 0 +Generators.tests.cpp:: passed: i % 2 == 0 for: 0 == 0 +Generators.tests.cpp:: passed: i % 2 == 0 for: 0 == 0 Generators.tests.cpp:: passed: filter([] (int) {return false; }, value(1)), Catch::GeneratorException Generators.tests.cpp:: passed: i < 4 for: 1 < 4 Generators.tests.cpp:: passed: i < 4 for: 2 < 4 @@ -944,6 +948,7 @@ TestCaseInfoHasher.tests.cpp:: passed: h( dummy1 ) != h( dummy2 ) f TestCaseInfoHasher.tests.cpp:: passed: h( dummy ) == h( dummy ) for: 3422778688 (0x) == 3422778688 (0x) +Message.tests.cpp:: failed: explicitly with 3 messages: 'This info has multiple parts.' and 'This unscoped info has multiple parts.' and 'Show infos!' Message.tests.cpp:: warning: 'this is a message' with 1 message: 'this is a warning' Message.tests.cpp:: failed: a == 1 for: 2 == 1 with 2 messages: 'this message should be logged' and 'so should this' Message.tests.cpp:: passed: a == 2 for: 2 == 2 with 1 message: 'this message may be logged later' @@ -961,6 +966,7 @@ Message.tests.cpp:: passed: i < 10 for: 7 < 10 with 2 messages: 'cu Message.tests.cpp:: passed: i < 10 for: 8 < 10 with 2 messages: 'current counter 8' and 'i := 8' Message.tests.cpp:: passed: i < 10 for: 9 < 10 with 2 messages: 'current counter 9' and 'i := 9' Message.tests.cpp:: failed: i < 10 for: 10 < 10 with 2 messages: 'current counter 10' and 'i := 10' +AssertionHandler.tests.cpp:: failed: unexpected exception with message: 'Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE'; expression was: Dummy Condition.tests.cpp:: failed: data.int_seven != 7 for: 7 != 7 Condition.tests.cpp:: failed: data.float_nine_point_one != Approx( 9.1f ) for: 9.1f != Approx( 9.1000003815 ) Condition.tests.cpp:: failed: data.double_pi != Approx( 3.1415926535 ) for: 3.1415926535 != Approx( 3.1415926535 ) @@ -977,6 +983,91 @@ Condition.tests.cpp:: passed: data.str_hello != "goodbye" for: "hel Condition.tests.cpp:: passed: data.str_hello != "hell" for: "hello" != "hell" Condition.tests.cpp:: passed: data.str_hello != "hello1" for: "hello" != "hello1" Condition.tests.cpp:: passed: data.str_hello.size() != 6 for: 5 != 6 +Json.tests.cpp:: passed: stream.str() == "" for: "" == "" +Json.tests.cpp:: passed: stream.str() == "{\n}" for: "{ +}" +== +"{ +}" +Json.tests.cpp:: passed: stream.str(), ContainsSubstring( "\"int\": 1," ) && ContainsSubstring( "\"double\": 1.5," ) && ContainsSubstring( "\"true\": true," ) && ContainsSubstring( "\"false\": false," ) && ContainsSubstring( "\"string\": \"this is a string\"," ) && ContainsSubstring( "\"array\": [\n 1,\n 2\n ]\n}" ) for: "{ + "int": 1, + "double": 1.5, + "true": true, + "false": false, + "string": "this is a string", + "array": [ + 1, + 2 + ] +}" ( contains: ""int": 1," and contains: ""double": 1.5," and contains: ""true": true," and contains: ""false": false," and contains: ""string": "this is a string"," and contains: ""array": [ + 1, + 2 + ] +}" ) +Json.tests.cpp:: passed: stream.str(), ContainsSubstring( "\"empty_object\": {\n }," ) && ContainsSubstring( "\"fully_object\": {\n \"key\": 1\n }" ) for: "{ + "empty_object": { + }, + "fully_object": { + "key": 1 + } +}" ( contains: ""empty_object": { + }," and contains: ""fully_object": { + "key": 1 + }" ) +Json.tests.cpp:: passed: stream.str() == "[\n]" for: "[ +]" +== +"[ +]" +Json.tests.cpp:: passed: stream.str() == "[\n 1,\n 1.5,\n true,\n false,\n \"this is a string\",\n {\n \"object\": 42\n },\n [\n \"array\",\n 42.5\n ]\n]" for: "[ + 1, + 1.5, + true, + false, + "this is a string", + { + "object": 42 + }, + [ + "array", + 42.5 + ] +]" +== +"[ + 1, + 1.5, + true, + false, + "this is a string", + { + "object": 42 + }, + [ + "array", + 42.5 + ] +]" +Json.tests.cpp:: passed: stream.str() == "{\n}" for: "{ +}" +== +"{ +}" +Json.tests.cpp:: passed: stream.str() == "[\n]" for: "[ +]" +== +"[ +]" +Json.tests.cpp:: passed: stream.str() == "\"custom\"" for: ""custom"" == ""custom"" +Json.tests.cpp:: passed: sstream.str() == "\"\\\"\"" for: ""\""" == ""\""" +Json.tests.cpp:: passed: sstream.str() == "\"\\\\\"" for: ""\\"" == ""\\"" +Json.tests.cpp:: passed: sstream.str() == "\"/\"" for: ""/"" == ""/"" +Json.tests.cpp:: passed: sstream.str() == "\"\\b\"" for: ""\b"" == ""\b"" +Json.tests.cpp:: passed: sstream.str() == "\"\\f\"" for: ""\f"" == ""\f"" +Json.tests.cpp:: passed: sstream.str() == "\"\\n\"" for: ""\n"" == ""\n"" +Json.tests.cpp:: passed: sstream.str() == "\"\\r\"" for: ""\r"" == ""\r"" +Json.tests.cpp:: passed: sstream.str() == "\"\\t\"" for: ""\t"" == ""\t"" +Json.tests.cpp:: passed: sstream.str() == "\"\\\\/\\t\\r\\n\"" for: ""\\/\t\r\n"" == ""\\/\t\r\n"" Compilation.tests.cpp:: passed: []() { return true; }() for: true Approx.tests.cpp:: passed: d <= Approx( 1.24 ) for: 1.23 <= Approx( 1.24 ) Approx.tests.cpp:: passed: d <= Approx( 1.23 ) for: 1.23 <= Approx( 1.23 ) @@ -1341,6 +1432,60 @@ Reporters.tests.cpp:: passed: listingString, ContainsSubstring( "fa " ( contains: "fake test name" and contains: "fakeTestTag" ) with 1 message: 'Tested reporter: console' Reporters.tests.cpp:: passed: !(factories.empty()) for: !false +Reporters.tests.cpp:: passed: listingString, ContainsSubstring("fakeTag"s) for: "{ + "version": 1, + "metadata": { + "name": "", + "rng-seed": 1234, + "catch2-version": "" + }, + "listings": { + "tags": [ + { + "aliases": [ + "fakeTag" + ], + "count": 1 + } + ]" contains: "fakeTag" with 1 message: 'Tested reporter: JSON' +Reporters.tests.cpp:: passed: !(factories.empty()) for: !false +Reporters.tests.cpp:: passed: listingString, ContainsSubstring("fake reporter"s) for: "{ + "version": 1, + "metadata": { + "name": "", + "rng-seed": 1234, + "catch2-version": "" + }, + "listings": { + "reporters": [ + { + "name": "fake reporter", + "description": "fake description" + } + ]" contains: "fake reporter" with 1 message: 'Tested reporter: JSON' +Reporters.tests.cpp:: passed: !(factories.empty()) for: !false +Reporters.tests.cpp:: passed: listingString, ContainsSubstring( "fake test name"s ) && ContainsSubstring( "fakeTestTag"s ) for: "{ + "version": 1, + "metadata": { + "name": "", + "rng-seed": 1234, + "catch2-version": "" + }, + "listings": { + "tests": [ + { + "name": "fake test name", + "class-name": "", + "tags": [ + "fakeTestTag" + ], + "source-location": { + "filename": "fake-file.cpp", + "line": 123456789 + } + } + ]" ( contains: "fake test name" and contains: "fakeTestTag" ) with 1 message: 'Tested reporter: JSON' +Reporters.tests.cpp:: passed: !(factories.empty()) for: !false Reporters.tests.cpp:: passed: listingString, ContainsSubstring("fakeTag"s) for: " All available tags: 1 [fakeTag] @@ -1750,6 +1895,10 @@ Misc.tests.cpp:: passed: true Misc.tests.cpp:: failed: explicitly Misc.tests.cpp:: failed - but was ok: false Misc.tests.cpp:: failed: explicitly +Misc.tests.cpp:: passed: true +Misc.tests.cpp:: failed: unexpected exception with message: 'Uncaught exception should fail!'; expression was: {Unknown expression after the reported line} +Misc.tests.cpp:: failed - but was ok: false +Misc.tests.cpp:: failed: unexpected exception with message: 'Uncaught exception should fail!'; expression was: {Unknown expression after the reported line} Message.tests.cpp:: failed - but was ok: 1 == 2 Reporters.tests.cpp:: passed: listingString, ContainsSubstring("[fakeTag]"s) for: "All available tags: 1 [fakeTag] @@ -2473,6 +2622,8 @@ InternalBenchmark.tests.cpp:: passed: e.point == 23 for: 23.0 == 23 InternalBenchmark.tests.cpp:: passed: e.upper_bound == 23 for: 23.0 == 23 InternalBenchmark.tests.cpp:: passed: e.lower_bound == 23 for: 23.0 == 23 InternalBenchmark.tests.cpp:: passed: e.confidence_interval == 0.95 for: 0.95 == 0.95 +RandomNumberGeneration.tests.cpp:: passed: dist.a() == -10 for: -10 == -10 +RandomNumberGeneration.tests.cpp:: passed: dist.b() == 10 for: 10 == 10 UniquePtr.tests.cpp:: passed: !(ptr) for: !{?} UniquePtr.tests.cpp:: passed: ptr.get() == 0 for: 0 == 0 UniquePtr.tests.cpp:: passed: ptr for: {?} @@ -2538,7 +2689,7 @@ InternalBenchmark.tests.cpp:: passed: med == 18. for: 18.0 == 18.0 InternalBenchmark.tests.cpp:: passed: q3 == 23. for: 23.0 == 23.0 Misc.tests.cpp:: passed: Misc.tests.cpp:: passed: -test cases: 409 | 309 passed | 84 failed | 5 skipped | 11 failed as expected -assertions: 2226 | 2049 passed | 145 failed | 32 failed as expected +test cases: 417 | 312 passed | 85 failed | 6 skipped | 14 failed as expected +assertions: 2260 | 2079 passed | 146 failed | 35 failed as expected diff --git a/external_imported/Catch2/tests/SelfTest/Baselines/compact.sw.multi.approved.txt b/external_imported/Catch2/tests/SelfTest/Baselines/compact.sw.multi.approved.txt index 5b292da12..214fef74b 100644 --- a/external_imported/Catch2/tests/SelfTest/Baselines/compact.sw.multi.approved.txt +++ b/external_imported/Catch2/tests/SelfTest/Baselines/compact.sw.multi.approved.txt @@ -329,7 +329,7 @@ MatchersRanges.tests.cpp:: passed: inner_lists_are_empty.front(), I MatchersRanges.tests.cpp:: passed: has_empty{}, !IsEmpty() for: {?} not is empty MatchersRanges.tests.cpp:: passed: unrelated::ADL_empty{}, IsEmpty() for: {?} is empty Message.tests.cpp:: passed: with 7 messages: 'a := 1' and 'b := 2' and 'c := 3' and 'a + b := 3' and 'a+b := 3' and 'c > b := true' and 'a == 1 := true' -Message.tests.cpp:: passed: with 7 messages: 'std::vector{1, 2, 3}[0, 1, 2] := 3' and 'std::vector{1, 2, 3}[(0, 1)] := 2' and 'std::vector{1, 2, 3}[0] := 1' and '(helper_1436{12, -12}) := { 12, -12 }' and '(helper_1436(-12, 12)) := { -12, 12 }' and '(1, 2) := 2' and '(2, 3) := 3' +Message.tests.cpp:: passed: with 7 messages: 'custom_index_op{1, 2, 3}[0, 1, 2] := 0' and 'custom_index_op{1, 2, 3}[(0, 1)] := 0' and 'custom_index_op{1, 2, 3}[0] := 0' and '(helper_1436{12, -12}) := { 12, -12 }' and '(helper_1436(-12, 12)) := { -12, 12 }' and '(1, 2) := 2' and '(2, 3) := 3' Message.tests.cpp:: passed: with 11 messages: '("comma, in string", "escaped, \", ") := "escaped, ", "' and '"single quote in string,'," := "single quote in string,',"' and '"some escapes, \\,\\\\" := "some escapes, \,\\"' and '"some, ), unmatched, } prenheses {[<" := "some, ), unmatched, } prenheses {[<"' and ''"' := '"'' and ''\'' := '''' and '',' := ','' and ''}' := '}'' and '')' := ')'' and ''(' := '('' and ''{' := '{'' ToStringGeneral.tests.cpp:: passed: true with 1 message: 'i := 2' ToStringGeneral.tests.cpp:: passed: true with 1 message: '3' @@ -518,8 +518,8 @@ ToString.tests.cpp:: passed: enumInfo->lookup(1) == "Value2" for: V ToString.tests.cpp:: passed: enumInfo->lookup(3) == "{** unexpected enum value **}" for: {** unexpected enum value **} == "{** unexpected enum value **}" +Skip.tests.cpp:: skipped: 'This generator is empty' Stream.tests.cpp:: passed: Catch::makeStream( "" )->isConsole() for: true -Tag.tests.cpp:: passed: Catch::TestCaseInfo( "", { "fake test name", "[]" }, dummySourceLineInfo ) Matchers.tests.cpp:: failed: testStringForMatching(), EndsWith( "Substring" ) for: "this string contains 'abc' as a substring" ends with: "Substring" Matchers.tests.cpp:: failed: testStringForMatching(), EndsWith( "this", Catch::CaseSensitive::No ) for: "this string contains 'abc' as a substring" ends with: "this" (case insensitive) EnumToString.tests.cpp:: passed: stringify( EnumClass3::Value1 ) == "Value1" for: "Value1" == "Value1" @@ -664,6 +664,10 @@ Matchers.tests.cpp:: passed: 1., !IsNaN() for: 1.0 not is NaN Generators.tests.cpp:: passed: i % 2 == 0 for: 0 == 0 Generators.tests.cpp:: passed: i % 2 == 0 for: 0 == 0 Generators.tests.cpp:: passed: i % 2 == 0 for: 0 == 0 +Generators.tests.cpp:: passed: i % 2 == 0 for: 0 == 0 +Generators.tests.cpp:: passed: i % 2 == 0 for: 0 == 0 +Generators.tests.cpp:: passed: i % 2 == 0 for: 0 == 0 +Generators.tests.cpp:: passed: i % 2 == 0 for: 0 == 0 Generators.tests.cpp:: passed: filter([] (int) {return false; }, value(1)), Catch::GeneratorException Generators.tests.cpp:: passed: i < 4 for: 1 < 4 Generators.tests.cpp:: passed: i < 4 for: 2 < 4 @@ -942,6 +946,7 @@ TestCaseInfoHasher.tests.cpp:: passed: h( dummy1 ) != h( dummy2 ) f TestCaseInfoHasher.tests.cpp:: passed: h( dummy ) == h( dummy ) for: 3422778688 (0x) == 3422778688 (0x) +Message.tests.cpp:: failed: explicitly with 3 messages: 'This info has multiple parts.' and 'This unscoped info has multiple parts.' and 'Show infos!' Message.tests.cpp:: warning: 'this is a message' with 1 message: 'this is a warning' Message.tests.cpp:: failed: a == 1 for: 2 == 1 with 2 messages: 'this message should be logged' and 'so should this' Message.tests.cpp:: passed: a == 2 for: 2 == 2 with 1 message: 'this message may be logged later' @@ -959,6 +964,7 @@ Message.tests.cpp:: passed: i < 10 for: 7 < 10 with 2 messages: 'cu Message.tests.cpp:: passed: i < 10 for: 8 < 10 with 2 messages: 'current counter 8' and 'i := 8' Message.tests.cpp:: passed: i < 10 for: 9 < 10 with 2 messages: 'current counter 9' and 'i := 9' Message.tests.cpp:: failed: i < 10 for: 10 < 10 with 2 messages: 'current counter 10' and 'i := 10' +AssertionHandler.tests.cpp:: failed: unexpected exception with message: 'Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE'; expression was: Dummy Condition.tests.cpp:: failed: data.int_seven != 7 for: 7 != 7 Condition.tests.cpp:: failed: data.float_nine_point_one != Approx( 9.1f ) for: 9.1f != Approx( 9.1000003815 ) Condition.tests.cpp:: failed: data.double_pi != Approx( 3.1415926535 ) for: 3.1415926535 != Approx( 3.1415926535 ) @@ -975,6 +981,91 @@ Condition.tests.cpp:: passed: data.str_hello != "goodbye" for: "hel Condition.tests.cpp:: passed: data.str_hello != "hell" for: "hello" != "hell" Condition.tests.cpp:: passed: data.str_hello != "hello1" for: "hello" != "hello1" Condition.tests.cpp:: passed: data.str_hello.size() != 6 for: 5 != 6 +Json.tests.cpp:: passed: stream.str() == "" for: "" == "" +Json.tests.cpp:: passed: stream.str() == "{\n}" for: "{ +}" +== +"{ +}" +Json.tests.cpp:: passed: stream.str(), ContainsSubstring( "\"int\": 1," ) && ContainsSubstring( "\"double\": 1.5," ) && ContainsSubstring( "\"true\": true," ) && ContainsSubstring( "\"false\": false," ) && ContainsSubstring( "\"string\": \"this is a string\"," ) && ContainsSubstring( "\"array\": [\n 1,\n 2\n ]\n}" ) for: "{ + "int": 1, + "double": 1.5, + "true": true, + "false": false, + "string": "this is a string", + "array": [ + 1, + 2 + ] +}" ( contains: ""int": 1," and contains: ""double": 1.5," and contains: ""true": true," and contains: ""false": false," and contains: ""string": "this is a string"," and contains: ""array": [ + 1, + 2 + ] +}" ) +Json.tests.cpp:: passed: stream.str(), ContainsSubstring( "\"empty_object\": {\n }," ) && ContainsSubstring( "\"fully_object\": {\n \"key\": 1\n }" ) for: "{ + "empty_object": { + }, + "fully_object": { + "key": 1 + } +}" ( contains: ""empty_object": { + }," and contains: ""fully_object": { + "key": 1 + }" ) +Json.tests.cpp:: passed: stream.str() == "[\n]" for: "[ +]" +== +"[ +]" +Json.tests.cpp:: passed: stream.str() == "[\n 1,\n 1.5,\n true,\n false,\n \"this is a string\",\n {\n \"object\": 42\n },\n [\n \"array\",\n 42.5\n ]\n]" for: "[ + 1, + 1.5, + true, + false, + "this is a string", + { + "object": 42 + }, + [ + "array", + 42.5 + ] +]" +== +"[ + 1, + 1.5, + true, + false, + "this is a string", + { + "object": 42 + }, + [ + "array", + 42.5 + ] +]" +Json.tests.cpp:: passed: stream.str() == "{\n}" for: "{ +}" +== +"{ +}" +Json.tests.cpp:: passed: stream.str() == "[\n]" for: "[ +]" +== +"[ +]" +Json.tests.cpp:: passed: stream.str() == "\"custom\"" for: ""custom"" == ""custom"" +Json.tests.cpp:: passed: sstream.str() == "\"\\\"\"" for: ""\""" == ""\""" +Json.tests.cpp:: passed: sstream.str() == "\"\\\\\"" for: ""\\"" == ""\\"" +Json.tests.cpp:: passed: sstream.str() == "\"/\"" for: ""/"" == ""/"" +Json.tests.cpp:: passed: sstream.str() == "\"\\b\"" for: ""\b"" == ""\b"" +Json.tests.cpp:: passed: sstream.str() == "\"\\f\"" for: ""\f"" == ""\f"" +Json.tests.cpp:: passed: sstream.str() == "\"\\n\"" for: ""\n"" == ""\n"" +Json.tests.cpp:: passed: sstream.str() == "\"\\r\"" for: ""\r"" == ""\r"" +Json.tests.cpp:: passed: sstream.str() == "\"\\t\"" for: ""\t"" == ""\t"" +Json.tests.cpp:: passed: sstream.str() == "\"\\\\/\\t\\r\\n\"" for: ""\\/\t\r\n"" == ""\\/\t\r\n"" Compilation.tests.cpp:: passed: []() { return true; }() for: true Approx.tests.cpp:: passed: d <= Approx( 1.24 ) for: 1.23 <= Approx( 1.24 ) Approx.tests.cpp:: passed: d <= Approx( 1.23 ) for: 1.23 <= Approx( 1.23 ) @@ -1339,6 +1430,60 @@ Reporters.tests.cpp:: passed: listingString, ContainsSubstring( "fa " ( contains: "fake test name" and contains: "fakeTestTag" ) with 1 message: 'Tested reporter: console' Reporters.tests.cpp:: passed: !(factories.empty()) for: !false +Reporters.tests.cpp:: passed: listingString, ContainsSubstring("fakeTag"s) for: "{ + "version": 1, + "metadata": { + "name": "", + "rng-seed": 1234, + "catch2-version": "" + }, + "listings": { + "tags": [ + { + "aliases": [ + "fakeTag" + ], + "count": 1 + } + ]" contains: "fakeTag" with 1 message: 'Tested reporter: JSON' +Reporters.tests.cpp:: passed: !(factories.empty()) for: !false +Reporters.tests.cpp:: passed: listingString, ContainsSubstring("fake reporter"s) for: "{ + "version": 1, + "metadata": { + "name": "", + "rng-seed": 1234, + "catch2-version": "" + }, + "listings": { + "reporters": [ + { + "name": "fake reporter", + "description": "fake description" + } + ]" contains: "fake reporter" with 1 message: 'Tested reporter: JSON' +Reporters.tests.cpp:: passed: !(factories.empty()) for: !false +Reporters.tests.cpp:: passed: listingString, ContainsSubstring( "fake test name"s ) && ContainsSubstring( "fakeTestTag"s ) for: "{ + "version": 1, + "metadata": { + "name": "", + "rng-seed": 1234, + "catch2-version": "" + }, + "listings": { + "tests": [ + { + "name": "fake test name", + "class-name": "", + "tags": [ + "fakeTestTag" + ], + "source-location": { + "filename": "fake-file.cpp", + "line": 123456789 + } + } + ]" ( contains: "fake test name" and contains: "fakeTestTag" ) with 1 message: 'Tested reporter: JSON' +Reporters.tests.cpp:: passed: !(factories.empty()) for: !false Reporters.tests.cpp:: passed: listingString, ContainsSubstring("fakeTag"s) for: " All available tags: 1 [fakeTag] @@ -1743,6 +1888,10 @@ Misc.tests.cpp:: passed: true Misc.tests.cpp:: failed: explicitly Misc.tests.cpp:: failed - but was ok: false Misc.tests.cpp:: failed: explicitly +Misc.tests.cpp:: passed: true +Misc.tests.cpp:: failed: unexpected exception with message: 'Uncaught exception should fail!'; expression was: {Unknown expression after the reported line} +Misc.tests.cpp:: failed - but was ok: false +Misc.tests.cpp:: failed: unexpected exception with message: 'Uncaught exception should fail!'; expression was: {Unknown expression after the reported line} Message.tests.cpp:: failed - but was ok: 1 == 2 Reporters.tests.cpp:: passed: listingString, ContainsSubstring("[fakeTag]"s) for: "All available tags: 1 [fakeTag] @@ -2462,6 +2611,8 @@ InternalBenchmark.tests.cpp:: passed: e.point == 23 for: 23.0 == 23 InternalBenchmark.tests.cpp:: passed: e.upper_bound == 23 for: 23.0 == 23 InternalBenchmark.tests.cpp:: passed: e.lower_bound == 23 for: 23.0 == 23 InternalBenchmark.tests.cpp:: passed: e.confidence_interval == 0.95 for: 0.95 == 0.95 +RandomNumberGeneration.tests.cpp:: passed: dist.a() == -10 for: -10 == -10 +RandomNumberGeneration.tests.cpp:: passed: dist.b() == 10 for: 10 == 10 UniquePtr.tests.cpp:: passed: !(ptr) for: !{?} UniquePtr.tests.cpp:: passed: ptr.get() == 0 for: 0 == 0 UniquePtr.tests.cpp:: passed: ptr for: {?} @@ -2527,7 +2678,7 @@ InternalBenchmark.tests.cpp:: passed: med == 18. for: 18.0 == 18.0 InternalBenchmark.tests.cpp:: passed: q3 == 23. for: 23.0 == 23.0 Misc.tests.cpp:: passed: Misc.tests.cpp:: passed: -test cases: 409 | 309 passed | 84 failed | 5 skipped | 11 failed as expected -assertions: 2226 | 2049 passed | 145 failed | 32 failed as expected +test cases: 417 | 312 passed | 85 failed | 6 skipped | 14 failed as expected +assertions: 2260 | 2079 passed | 146 failed | 35 failed as expected diff --git a/external_imported/Catch2/tests/SelfTest/Baselines/console.std.approved.txt b/external_imported/Catch2/tests/SelfTest/Baselines/console.std.approved.txt index 15d8b024f..254262565 100644 --- a/external_imported/Catch2/tests/SelfTest/Baselines/console.std.approved.txt +++ b/external_imported/Catch2/tests/SelfTest/Baselines/console.std.approved.txt @@ -383,6 +383,16 @@ Exception.tests.cpp:: FAILED: due to unexpected exception with message: custom std exception +------------------------------------------------------------------------------- +Empty generators can SKIP in constructor +------------------------------------------------------------------------------- +Skip.tests.cpp: +............................................................................... + +Skip.tests.cpp:: SKIPPED: +explicitly with message: + This generator is empty + ------------------------------------------------------------------------------- EndsWith string matcher ------------------------------------------------------------------------------- @@ -589,6 +599,18 @@ explicitly with message: Message.tests.cpp:: warning: This message appears in the output +------------------------------------------------------------------------------- +INFO and UNSCOPED_INFO can stream multiple arguments +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: +explicitly with messages: + This info has multiple parts. + This unscoped info has multiple parts. + Show infos! + ------------------------------------------------------------------------------- INFO and WARN do not abort tests ------------------------------------------------------------------------------- @@ -649,6 +671,17 @@ with messages: current counter 10 i := 10 +------------------------------------------------------------------------------- +Incomplete AssertionHandler +------------------------------------------------------------------------------- +AssertionHandler.tests.cpp: +............................................................................... + +AssertionHandler.tests.cpp:: FAILED: + REQUIRE( Dummy ) +due to unexpected exception with message: + Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE + ------------------------------------------------------------------------------- Inequality checks that should fail ------------------------------------------------------------------------------- @@ -987,6 +1020,28 @@ Misc.tests.cpp: Misc.tests.cpp:: FAILED: +------------------------------------------------------------------------------- +Testing checked-if 4 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: + {Unknown expression after the reported line} +due to unexpected exception with message: + Uncaught exception should fail! + +------------------------------------------------------------------------------- +Testing checked-if 5 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: + {Unknown expression after the reported line} +due to unexpected exception with message: + Uncaught exception should fail! + ------------------------------------------------------------------------------- Thrown string literals are translated ------------------------------------------------------------------------------- @@ -1533,6 +1588,6 @@ due to unexpected exception with message: Why would you throw a std::string? =============================================================================== -test cases: 409 | 323 passed | 69 failed | 6 skipped | 11 failed as expected -assertions: 2209 | 2049 passed | 128 failed | 32 failed as expected +test cases: 417 | 326 passed | 70 failed | 7 skipped | 14 failed as expected +assertions: 2243 | 2079 passed | 129 failed | 35 failed as expected diff --git a/external_imported/Catch2/tests/SelfTest/Baselines/console.sw.approved.txt b/external_imported/Catch2/tests/SelfTest/Baselines/console.sw.approved.txt index 26d5e8f35..077b7bf75 100644 --- a/external_imported/Catch2/tests/SelfTest/Baselines/console.sw.approved.txt +++ b/external_imported/Catch2/tests/SelfTest/Baselines/console.sw.approved.txt @@ -2740,9 +2740,9 @@ Message.tests.cpp: Message.tests.cpp:: PASSED: with messages: - std::vector{1, 2, 3}[0, 1, 2] := 3 - std::vector{1, 2, 3}[(0, 1)] := 2 - std::vector{1, 2, 3}[0] := 1 + custom_index_op{1, 2, 3}[0, 1, 2] := 0 + custom_index_op{1, 2, 3}[(0, 1)] := 0 + custom_index_op{1, 2, 3}[0] := 0 (helper_1436{12, -12}) := { 12, -12 } (helper_1436(-12, 12)) := { -12, 12 } (1, 2) := 2 @@ -3956,6 +3956,16 @@ with expansion: == "{** unexpected enum value **}" +------------------------------------------------------------------------------- +Empty generators can SKIP in constructor +------------------------------------------------------------------------------- +Skip.tests.cpp: +............................................................................... + +Skip.tests.cpp:: SKIPPED: +explicitly with message: + This generator is empty + ------------------------------------------------------------------------------- Empty stream name opens cout stream ------------------------------------------------------------------------------- @@ -3967,15 +3977,6 @@ Stream.tests.cpp:: PASSED: with expansion: true -------------------------------------------------------------------------------- -Empty tag is not allowed -------------------------------------------------------------------------------- -Tag.tests.cpp: -............................................................................... - -Tag.tests.cpp:: PASSED: - REQUIRE_THROWS( Catch::TestCaseInfo( "", { "fake test name", "[]" }, dummySourceLineInfo ) ) - ------------------------------------------------------------------------------- EndsWith string matcher ------------------------------------------------------------------------------- @@ -4888,6 +4889,50 @@ Matchers.tests.cpp:: PASSED: with expansion: 1.0 not is NaN +------------------------------------------------------------------------------- +GENERATE can combine literals and generators +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( i % 2 == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +GENERATE can combine literals and generators +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( i % 2 == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +GENERATE can combine literals and generators +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( i % 2 == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +GENERATE can combine literals and generators +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( i % 2 == 0 ) +with expansion: + 0 == 0 + ------------------------------------------------------------------------------- Generators -- adapters Filtering by predicate @@ -6981,6 +7026,18 @@ with expansion: == 3422778688 (0x) +------------------------------------------------------------------------------- +INFO and UNSCOPED_INFO can stream multiple arguments +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: +explicitly with messages: + This info has multiple parts. + This unscoped info has multiple parts. + Show infos! + ------------------------------------------------------------------------------- INFO and WARN do not abort tests ------------------------------------------------------------------------------- @@ -7142,6 +7199,17 @@ with messages: current counter 10 i := 10 +------------------------------------------------------------------------------- +Incomplete AssertionHandler +------------------------------------------------------------------------------- +AssertionHandler.tests.cpp: +............................................................................... + +AssertionHandler.tests.cpp:: FAILED: + REQUIRE( Dummy ) +due to unexpected exception with message: + Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE + ------------------------------------------------------------------------------- Inequality checks that should fail ------------------------------------------------------------------------------- @@ -7234,6 +7302,291 @@ Condition.tests.cpp:: PASSED: with expansion: 5 != 6 +------------------------------------------------------------------------------- +JsonWriter + Newly constructed JsonWriter does nothing +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( stream.str() == "" ) +with expansion: + "" == "" + +------------------------------------------------------------------------------- +JsonWriter + Calling writeObject will create an empty pair of braces +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( stream.str() == "{\n}" ) +with expansion: + "{ + }" + == + "{ + }" + +------------------------------------------------------------------------------- +JsonWriter + Calling writeObject with key will create an object to write the value +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE_THAT( stream.str(), ContainsSubstring( "\"int\": 1," ) && ContainsSubstring( "\"double\": 1.5," ) && ContainsSubstring( "\"true\": true," ) && ContainsSubstring( "\"false\": false," ) && ContainsSubstring( "\"string\": \"this is a string\"," ) && ContainsSubstring( "\"array\": [\n 1,\n 2\n ]\n}" ) ) +with expansion: + "{ + "int": 1, + "double": 1.5, + "true": true, + "false": false, + "string": "this is a string", + "array": [ + 1, + 2 + ] + }" ( contains: ""int": 1," and contains: ""double": 1.5," and contains: + ""true": true," and contains: ""false": false," and contains: ""string": + "this is a string"," and contains: ""array": [ + 1, + 2 + ] + }" ) + +------------------------------------------------------------------------------- +JsonWriter + nesting objects +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE_THAT( stream.str(), ContainsSubstring( "\"empty_object\": {\n }," ) && ContainsSubstring( "\"fully_object\": {\n \"key\": 1\n }" ) ) +with expansion: + "{ + "empty_object": { + }, + "fully_object": { + "key": 1 + } + }" ( contains: ""empty_object": { + }," and contains: ""fully_object": { + "key": 1 + }" ) + +------------------------------------------------------------------------------- +JsonWriter + Calling writeArray will create an empty pair of braces +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( stream.str() == "[\n]" ) +with expansion: + "[ + ]" + == + "[ + ]" + +------------------------------------------------------------------------------- +JsonWriter + Calling writeArray creates array to write the values to +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( stream.str() == "[\n 1,\n 1.5,\n true,\n false,\n \"this is a string\",\n {\n \"object\": 42\n },\n [\n \"array\",\n 42.5\n ]\n]" ) +with expansion: + "[ + 1, + 1.5, + true, + false, + "this is a string", + { + "object": 42 + }, + [ + "array", + 42.5 + ] + ]" + == + "[ + 1, + 1.5, + true, + false, + "this is a string", + { + "object": 42 + }, + [ + "array", + 42.5 + ] + ]" + +------------------------------------------------------------------------------- +JsonWriter + Moved from JsonObjectWriter shall not insert superfluous brace +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( stream.str() == "{\n}" ) +with expansion: + "{ + }" + == + "{ + }" + +------------------------------------------------------------------------------- +JsonWriter + Moved from JsonArrayWriter shall not insert superfluous bracket +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( stream.str() == "[\n]" ) +with expansion: + "[ + ]" + == + "[ + ]" + +------------------------------------------------------------------------------- +JsonWriter + Custom class shall be quoted +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( stream.str() == "\"custom\"" ) +with expansion: + ""custom"" == ""custom"" + +------------------------------------------------------------------------------- +JsonWriter escapes charaters in strings properly + Quote in a string is escaped +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( sstream.str() == "\"\\\"\"" ) +with expansion: + ""\""" == ""\""" + +------------------------------------------------------------------------------- +JsonWriter escapes charaters in strings properly + Backslash in a string is escaped +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( sstream.str() == "\"\\\\\"" ) +with expansion: + ""\\"" == ""\\"" + +------------------------------------------------------------------------------- +JsonWriter escapes charaters in strings properly + Forward slash in a string is **not** escaped +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( sstream.str() == "\"/\"" ) +with expansion: + ""/"" == ""/"" + +------------------------------------------------------------------------------- +JsonWriter escapes charaters in strings properly + Backspace in a string is escaped +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( sstream.str() == "\"\\b\"" ) +with expansion: + ""\b"" == ""\b"" + +------------------------------------------------------------------------------- +JsonWriter escapes charaters in strings properly + Formfeed in a string is escaped +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( sstream.str() == "\"\\f\"" ) +with expansion: + ""\f"" == ""\f"" + +------------------------------------------------------------------------------- +JsonWriter escapes charaters in strings properly + linefeed in a string is escaped +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( sstream.str() == "\"\\n\"" ) +with expansion: + ""\n"" == ""\n"" + +------------------------------------------------------------------------------- +JsonWriter escapes charaters in strings properly + carriage return in a string is escaped +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( sstream.str() == "\"\\r\"" ) +with expansion: + ""\r"" == ""\r"" + +------------------------------------------------------------------------------- +JsonWriter escapes charaters in strings properly + tab in a string is escaped +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( sstream.str() == "\"\\t\"" ) +with expansion: + ""\t"" == ""\t"" + +------------------------------------------------------------------------------- +JsonWriter escapes charaters in strings properly + combination of characters is escaped +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( sstream.str() == "\"\\\\/\\t\\r\\n\"" ) +with expansion: + ""\\/\t\r\n"" == ""\\/\t\r\n"" + ------------------------------------------------------------------------------- Lambdas in assertions ------------------------------------------------------------------------------- @@ -9732,6 +10085,129 @@ Reporter's write listings to provided stream Reporters.tests.cpp: ............................................................................... +Reporters.tests.cpp:: PASSED: + REQUIRE_FALSE( factories.empty() ) +with expansion: + !false + +------------------------------------------------------------------------------- +Reporter's write listings to provided stream + JSON reporter lists tags +------------------------------------------------------------------------------- +Reporters.tests.cpp: +............................................................................... + +Reporters.tests.cpp:: PASSED: + REQUIRE_THAT( listingString, ContainsSubstring("fakeTag"s) ) +with expansion: + "{ + "version": 1, + "metadata": { + "name": "", + "rng-seed": 1234, + "catch2-version": "" + }, + "listings": { + "tags": [ + { + "aliases": [ + "fakeTag" + ], + "count": 1 + } + ]" contains: "fakeTag" +with message: + Tested reporter: JSON + +------------------------------------------------------------------------------- +Reporter's write listings to provided stream +------------------------------------------------------------------------------- +Reporters.tests.cpp: +............................................................................... + +Reporters.tests.cpp:: PASSED: + REQUIRE_FALSE( factories.empty() ) +with expansion: + !false + +------------------------------------------------------------------------------- +Reporter's write listings to provided stream + JSON reporter lists reporters +------------------------------------------------------------------------------- +Reporters.tests.cpp: +............................................................................... + +Reporters.tests.cpp:: PASSED: + REQUIRE_THAT( listingString, ContainsSubstring("fake reporter"s) ) +with expansion: + "{ + "version": 1, + "metadata": { + "name": "", + "rng-seed": 1234, + "catch2-version": "" + }, + "listings": { + "reporters": [ + { + "name": "fake reporter", + "description": "fake description" + } + ]" contains: "fake reporter" +with message: + Tested reporter: JSON + +------------------------------------------------------------------------------- +Reporter's write listings to provided stream +------------------------------------------------------------------------------- +Reporters.tests.cpp: +............................................................................... + +Reporters.tests.cpp:: PASSED: + REQUIRE_FALSE( factories.empty() ) +with expansion: + !false + +------------------------------------------------------------------------------- +Reporter's write listings to provided stream + JSON reporter lists tests +------------------------------------------------------------------------------- +Reporters.tests.cpp: +............................................................................... + +Reporters.tests.cpp:: PASSED: + REQUIRE_THAT( listingString, ContainsSubstring( "fake test name"s ) && ContainsSubstring( "fakeTestTag"s ) ) +with expansion: + "{ + "version": 1, + "metadata": { + "name": "", + "rng-seed": 1234, + "catch2-version": "" + }, + "listings": { + "tests": [ + { + "name": "fake test name", + "class-name": "", + "tags": [ + "fakeTestTag" + ], + "source-location": { + "filename": "fake-file.cpp", + "line": 123456789 + } + } + ]" ( contains: "fake test name" and contains: "fakeTestTag" ) +with message: + Tested reporter: JSON + +------------------------------------------------------------------------------- +Reporter's write listings to provided stream +------------------------------------------------------------------------------- +Reporters.tests.cpp: +............................................................................... + Reporters.tests.cpp:: PASSED: REQUIRE_FALSE( factories.empty() ) with expansion: @@ -12521,6 +12997,34 @@ Misc.tests.cpp:: FAILED - but was ok: Misc.tests.cpp:: FAILED: +------------------------------------------------------------------------------- +Testing checked-if 4 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: PASSED: + CHECKED_ELSE( true ) + +Misc.tests.cpp:: FAILED: + {Unknown expression after the reported line} +due to unexpected exception with message: + Uncaught exception should fail! + +------------------------------------------------------------------------------- +Testing checked-if 5 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED - but was ok: + CHECKED_ELSE( false ) + +Misc.tests.cpp:: FAILED: + {Unknown expression after the reported line} +due to unexpected exception with message: + Uncaught exception should fail! + ------------------------------------------------------------------------------- The NO_FAIL macro reports a failure but does not fail the test ------------------------------------------------------------------------------- @@ -13460,7 +13964,7 @@ with expansion: ------------------------------------------------------------------------------- Usage of AllTrue range matcher Basic usage - One false evalutes to false + One false evaluates to false ------------------------------------------------------------------------------- MatchersRanges.tests.cpp: ............................................................................... @@ -13499,7 +14003,7 @@ with expansion: ------------------------------------------------------------------------------- Usage of AllTrue range matcher Contained type is convertible to bool - One false evalutes to false + One false evaluates to false ------------------------------------------------------------------------------- MatchersRanges.tests.cpp: ............................................................................... @@ -13735,7 +14239,7 @@ with expansion: ------------------------------------------------------------------------------- Usage of AnyTrue range matcher Basic usage - One true evalutes to true + One true evaluates to true ------------------------------------------------------------------------------- MatchersRanges.tests.cpp: ............................................................................... @@ -13774,7 +14278,7 @@ with expansion: ------------------------------------------------------------------------------- Usage of AnyTrue range matcher Contained type is convertible to bool - One true evalutes to true + One true evaluates to true ------------------------------------------------------------------------------- MatchersRanges.tests.cpp: ............................................................................... @@ -14010,7 +14514,7 @@ with expansion: ------------------------------------------------------------------------------- Usage of NoneTrue range matcher Basic usage - One true evalutes to false + One true evaluates to false ------------------------------------------------------------------------------- MatchersRanges.tests.cpp: ............................................................................... @@ -14049,7 +14553,7 @@ with expansion: ------------------------------------------------------------------------------- Usage of NoneTrue range matcher Contained type is convertible to bool - One true evalutes to false + One true evaluates to false ------------------------------------------------------------------------------- MatchersRanges.tests.cpp: ............................................................................... @@ -17744,6 +18248,22 @@ InternalBenchmark.tests.cpp:: PASSED: with expansion: 0.95 == 0.95 +------------------------------------------------------------------------------- +uniform_integer_distribution can return the bounds +------------------------------------------------------------------------------- +RandomNumberGeneration.tests.cpp: +............................................................................... + +RandomNumberGeneration.tests.cpp:: PASSED: + REQUIRE( dist.a() == -10 ) +with expansion: + -10 == -10 + +RandomNumberGeneration.tests.cpp:: PASSED: + REQUIRE( dist.b() == 10 ) +with expansion: + 10 == 10 + ------------------------------------------------------------------------------- unique_ptr reimplementation: basic functionality Default constructed unique_ptr is empty @@ -18231,6 +18751,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 409 | 309 passed | 84 failed | 5 skipped | 11 failed as expected -assertions: 2226 | 2049 passed | 145 failed | 32 failed as expected +test cases: 417 | 312 passed | 85 failed | 6 skipped | 14 failed as expected +assertions: 2260 | 2079 passed | 146 failed | 35 failed as expected diff --git a/external_imported/Catch2/tests/SelfTest/Baselines/console.sw.multi.approved.txt b/external_imported/Catch2/tests/SelfTest/Baselines/console.sw.multi.approved.txt index 80b63ab84..5d204990c 100644 --- a/external_imported/Catch2/tests/SelfTest/Baselines/console.sw.multi.approved.txt +++ b/external_imported/Catch2/tests/SelfTest/Baselines/console.sw.multi.approved.txt @@ -2738,9 +2738,9 @@ Message.tests.cpp: Message.tests.cpp:: PASSED: with messages: - std::vector{1, 2, 3}[0, 1, 2] := 3 - std::vector{1, 2, 3}[(0, 1)] := 2 - std::vector{1, 2, 3}[0] := 1 + custom_index_op{1, 2, 3}[0, 1, 2] := 0 + custom_index_op{1, 2, 3}[(0, 1)] := 0 + custom_index_op{1, 2, 3}[0] := 0 (helper_1436{12, -12}) := { 12, -12 } (helper_1436(-12, 12)) := { -12, 12 } (1, 2) := 2 @@ -3954,6 +3954,16 @@ with expansion: == "{** unexpected enum value **}" +------------------------------------------------------------------------------- +Empty generators can SKIP in constructor +------------------------------------------------------------------------------- +Skip.tests.cpp: +............................................................................... + +Skip.tests.cpp:: SKIPPED: +explicitly with message: + This generator is empty + ------------------------------------------------------------------------------- Empty stream name opens cout stream ------------------------------------------------------------------------------- @@ -3965,15 +3975,6 @@ Stream.tests.cpp:: PASSED: with expansion: true -------------------------------------------------------------------------------- -Empty tag is not allowed -------------------------------------------------------------------------------- -Tag.tests.cpp: -............................................................................... - -Tag.tests.cpp:: PASSED: - REQUIRE_THROWS( Catch::TestCaseInfo( "", { "fake test name", "[]" }, dummySourceLineInfo ) ) - ------------------------------------------------------------------------------- EndsWith string matcher ------------------------------------------------------------------------------- @@ -4886,6 +4887,50 @@ Matchers.tests.cpp:: PASSED: with expansion: 1.0 not is NaN +------------------------------------------------------------------------------- +GENERATE can combine literals and generators +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( i % 2 == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +GENERATE can combine literals and generators +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( i % 2 == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +GENERATE can combine literals and generators +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( i % 2 == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +GENERATE can combine literals and generators +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( i % 2 == 0 ) +with expansion: + 0 == 0 + ------------------------------------------------------------------------------- Generators -- adapters Filtering by predicate @@ -6979,6 +7024,18 @@ with expansion: == 3422778688 (0x) +------------------------------------------------------------------------------- +INFO and UNSCOPED_INFO can stream multiple arguments +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: +explicitly with messages: + This info has multiple parts. + This unscoped info has multiple parts. + Show infos! + ------------------------------------------------------------------------------- INFO and WARN do not abort tests ------------------------------------------------------------------------------- @@ -7140,6 +7197,17 @@ with messages: current counter 10 i := 10 +------------------------------------------------------------------------------- +Incomplete AssertionHandler +------------------------------------------------------------------------------- +AssertionHandler.tests.cpp: +............................................................................... + +AssertionHandler.tests.cpp:: FAILED: + REQUIRE( Dummy ) +due to unexpected exception with message: + Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE + ------------------------------------------------------------------------------- Inequality checks that should fail ------------------------------------------------------------------------------- @@ -7232,6 +7300,291 @@ Condition.tests.cpp:: PASSED: with expansion: 5 != 6 +------------------------------------------------------------------------------- +JsonWriter + Newly constructed JsonWriter does nothing +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( stream.str() == "" ) +with expansion: + "" == "" + +------------------------------------------------------------------------------- +JsonWriter + Calling writeObject will create an empty pair of braces +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( stream.str() == "{\n}" ) +with expansion: + "{ + }" + == + "{ + }" + +------------------------------------------------------------------------------- +JsonWriter + Calling writeObject with key will create an object to write the value +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE_THAT( stream.str(), ContainsSubstring( "\"int\": 1," ) && ContainsSubstring( "\"double\": 1.5," ) && ContainsSubstring( "\"true\": true," ) && ContainsSubstring( "\"false\": false," ) && ContainsSubstring( "\"string\": \"this is a string\"," ) && ContainsSubstring( "\"array\": [\n 1,\n 2\n ]\n}" ) ) +with expansion: + "{ + "int": 1, + "double": 1.5, + "true": true, + "false": false, + "string": "this is a string", + "array": [ + 1, + 2 + ] + }" ( contains: ""int": 1," and contains: ""double": 1.5," and contains: + ""true": true," and contains: ""false": false," and contains: ""string": + "this is a string"," and contains: ""array": [ + 1, + 2 + ] + }" ) + +------------------------------------------------------------------------------- +JsonWriter + nesting objects +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE_THAT( stream.str(), ContainsSubstring( "\"empty_object\": {\n }," ) && ContainsSubstring( "\"fully_object\": {\n \"key\": 1\n }" ) ) +with expansion: + "{ + "empty_object": { + }, + "fully_object": { + "key": 1 + } + }" ( contains: ""empty_object": { + }," and contains: ""fully_object": { + "key": 1 + }" ) + +------------------------------------------------------------------------------- +JsonWriter + Calling writeArray will create an empty pair of braces +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( stream.str() == "[\n]" ) +with expansion: + "[ + ]" + == + "[ + ]" + +------------------------------------------------------------------------------- +JsonWriter + Calling writeArray creates array to write the values to +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( stream.str() == "[\n 1,\n 1.5,\n true,\n false,\n \"this is a string\",\n {\n \"object\": 42\n },\n [\n \"array\",\n 42.5\n ]\n]" ) +with expansion: + "[ + 1, + 1.5, + true, + false, + "this is a string", + { + "object": 42 + }, + [ + "array", + 42.5 + ] + ]" + == + "[ + 1, + 1.5, + true, + false, + "this is a string", + { + "object": 42 + }, + [ + "array", + 42.5 + ] + ]" + +------------------------------------------------------------------------------- +JsonWriter + Moved from JsonObjectWriter shall not insert superfluous brace +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( stream.str() == "{\n}" ) +with expansion: + "{ + }" + == + "{ + }" + +------------------------------------------------------------------------------- +JsonWriter + Moved from JsonArrayWriter shall not insert superfluous bracket +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( stream.str() == "[\n]" ) +with expansion: + "[ + ]" + == + "[ + ]" + +------------------------------------------------------------------------------- +JsonWriter + Custom class shall be quoted +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( stream.str() == "\"custom\"" ) +with expansion: + ""custom"" == ""custom"" + +------------------------------------------------------------------------------- +JsonWriter escapes charaters in strings properly + Quote in a string is escaped +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( sstream.str() == "\"\\\"\"" ) +with expansion: + ""\""" == ""\""" + +------------------------------------------------------------------------------- +JsonWriter escapes charaters in strings properly + Backslash in a string is escaped +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( sstream.str() == "\"\\\\\"" ) +with expansion: + ""\\"" == ""\\"" + +------------------------------------------------------------------------------- +JsonWriter escapes charaters in strings properly + Forward slash in a string is **not** escaped +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( sstream.str() == "\"/\"" ) +with expansion: + ""/"" == ""/"" + +------------------------------------------------------------------------------- +JsonWriter escapes charaters in strings properly + Backspace in a string is escaped +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( sstream.str() == "\"\\b\"" ) +with expansion: + ""\b"" == ""\b"" + +------------------------------------------------------------------------------- +JsonWriter escapes charaters in strings properly + Formfeed in a string is escaped +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( sstream.str() == "\"\\f\"" ) +with expansion: + ""\f"" == ""\f"" + +------------------------------------------------------------------------------- +JsonWriter escapes charaters in strings properly + linefeed in a string is escaped +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( sstream.str() == "\"\\n\"" ) +with expansion: + ""\n"" == ""\n"" + +------------------------------------------------------------------------------- +JsonWriter escapes charaters in strings properly + carriage return in a string is escaped +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( sstream.str() == "\"\\r\"" ) +with expansion: + ""\r"" == ""\r"" + +------------------------------------------------------------------------------- +JsonWriter escapes charaters in strings properly + tab in a string is escaped +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( sstream.str() == "\"\\t\"" ) +with expansion: + ""\t"" == ""\t"" + +------------------------------------------------------------------------------- +JsonWriter escapes charaters in strings properly + combination of characters is escaped +------------------------------------------------------------------------------- +Json.tests.cpp: +............................................................................... + +Json.tests.cpp:: PASSED: + REQUIRE( sstream.str() == "\"\\\\/\\t\\r\\n\"" ) +with expansion: + ""\\/\t\r\n"" == ""\\/\t\r\n"" + ------------------------------------------------------------------------------- Lambdas in assertions ------------------------------------------------------------------------------- @@ -9730,6 +10083,129 @@ Reporter's write listings to provided stream Reporters.tests.cpp: ............................................................................... +Reporters.tests.cpp:: PASSED: + REQUIRE_FALSE( factories.empty() ) +with expansion: + !false + +------------------------------------------------------------------------------- +Reporter's write listings to provided stream + JSON reporter lists tags +------------------------------------------------------------------------------- +Reporters.tests.cpp: +............................................................................... + +Reporters.tests.cpp:: PASSED: + REQUIRE_THAT( listingString, ContainsSubstring("fakeTag"s) ) +with expansion: + "{ + "version": 1, + "metadata": { + "name": "", + "rng-seed": 1234, + "catch2-version": "" + }, + "listings": { + "tags": [ + { + "aliases": [ + "fakeTag" + ], + "count": 1 + } + ]" contains: "fakeTag" +with message: + Tested reporter: JSON + +------------------------------------------------------------------------------- +Reporter's write listings to provided stream +------------------------------------------------------------------------------- +Reporters.tests.cpp: +............................................................................... + +Reporters.tests.cpp:: PASSED: + REQUIRE_FALSE( factories.empty() ) +with expansion: + !false + +------------------------------------------------------------------------------- +Reporter's write listings to provided stream + JSON reporter lists reporters +------------------------------------------------------------------------------- +Reporters.tests.cpp: +............................................................................... + +Reporters.tests.cpp:: PASSED: + REQUIRE_THAT( listingString, ContainsSubstring("fake reporter"s) ) +with expansion: + "{ + "version": 1, + "metadata": { + "name": "", + "rng-seed": 1234, + "catch2-version": "" + }, + "listings": { + "reporters": [ + { + "name": "fake reporter", + "description": "fake description" + } + ]" contains: "fake reporter" +with message: + Tested reporter: JSON + +------------------------------------------------------------------------------- +Reporter's write listings to provided stream +------------------------------------------------------------------------------- +Reporters.tests.cpp: +............................................................................... + +Reporters.tests.cpp:: PASSED: + REQUIRE_FALSE( factories.empty() ) +with expansion: + !false + +------------------------------------------------------------------------------- +Reporter's write listings to provided stream + JSON reporter lists tests +------------------------------------------------------------------------------- +Reporters.tests.cpp: +............................................................................... + +Reporters.tests.cpp:: PASSED: + REQUIRE_THAT( listingString, ContainsSubstring( "fake test name"s ) && ContainsSubstring( "fakeTestTag"s ) ) +with expansion: + "{ + "version": 1, + "metadata": { + "name": "", + "rng-seed": 1234, + "catch2-version": "" + }, + "listings": { + "tests": [ + { + "name": "fake test name", + "class-name": "", + "tags": [ + "fakeTestTag" + ], + "source-location": { + "filename": "fake-file.cpp", + "line": 123456789 + } + } + ]" ( contains: "fake test name" and contains: "fakeTestTag" ) +with message: + Tested reporter: JSON + +------------------------------------------------------------------------------- +Reporter's write listings to provided stream +------------------------------------------------------------------------------- +Reporters.tests.cpp: +............................................................................... + Reporters.tests.cpp:: PASSED: REQUIRE_FALSE( factories.empty() ) with expansion: @@ -12514,6 +12990,34 @@ Misc.tests.cpp:: FAILED - but was ok: Misc.tests.cpp:: FAILED: +------------------------------------------------------------------------------- +Testing checked-if 4 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: PASSED: + CHECKED_ELSE( true ) + +Misc.tests.cpp:: FAILED: + {Unknown expression after the reported line} +due to unexpected exception with message: + Uncaught exception should fail! + +------------------------------------------------------------------------------- +Testing checked-if 5 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED - but was ok: + CHECKED_ELSE( false ) + +Misc.tests.cpp:: FAILED: + {Unknown expression after the reported line} +due to unexpected exception with message: + Uncaught exception should fail! + ------------------------------------------------------------------------------- The NO_FAIL macro reports a failure but does not fail the test ------------------------------------------------------------------------------- @@ -13453,7 +13957,7 @@ with expansion: ------------------------------------------------------------------------------- Usage of AllTrue range matcher Basic usage - One false evalutes to false + One false evaluates to false ------------------------------------------------------------------------------- MatchersRanges.tests.cpp: ............................................................................... @@ -13492,7 +13996,7 @@ with expansion: ------------------------------------------------------------------------------- Usage of AllTrue range matcher Contained type is convertible to bool - One false evalutes to false + One false evaluates to false ------------------------------------------------------------------------------- MatchersRanges.tests.cpp: ............................................................................... @@ -13728,7 +14232,7 @@ with expansion: ------------------------------------------------------------------------------- Usage of AnyTrue range matcher Basic usage - One true evalutes to true + One true evaluates to true ------------------------------------------------------------------------------- MatchersRanges.tests.cpp: ............................................................................... @@ -13767,7 +14271,7 @@ with expansion: ------------------------------------------------------------------------------- Usage of AnyTrue range matcher Contained type is convertible to bool - One true evalutes to true + One true evaluates to true ------------------------------------------------------------------------------- MatchersRanges.tests.cpp: ............................................................................... @@ -14003,7 +14507,7 @@ with expansion: ------------------------------------------------------------------------------- Usage of NoneTrue range matcher Basic usage - One true evalutes to false + One true evaluates to false ------------------------------------------------------------------------------- MatchersRanges.tests.cpp: ............................................................................... @@ -14042,7 +14546,7 @@ with expansion: ------------------------------------------------------------------------------- Usage of NoneTrue range matcher Contained type is convertible to bool - One true evalutes to false + One true evaluates to false ------------------------------------------------------------------------------- MatchersRanges.tests.cpp: ............................................................................... @@ -17733,6 +18237,22 @@ InternalBenchmark.tests.cpp:: PASSED: with expansion: 0.95 == 0.95 +------------------------------------------------------------------------------- +uniform_integer_distribution can return the bounds +------------------------------------------------------------------------------- +RandomNumberGeneration.tests.cpp: +............................................................................... + +RandomNumberGeneration.tests.cpp:: PASSED: + REQUIRE( dist.a() == -10 ) +with expansion: + -10 == -10 + +RandomNumberGeneration.tests.cpp:: PASSED: + REQUIRE( dist.b() == 10 ) +with expansion: + 10 == 10 + ------------------------------------------------------------------------------- unique_ptr reimplementation: basic functionality Default constructed unique_ptr is empty @@ -18220,6 +18740,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 409 | 309 passed | 84 failed | 5 skipped | 11 failed as expected -assertions: 2226 | 2049 passed | 145 failed | 32 failed as expected +test cases: 417 | 312 passed | 85 failed | 6 skipped | 14 failed as expected +assertions: 2260 | 2079 passed | 146 failed | 35 failed as expected diff --git a/external_imported/Catch2/tests/SelfTest/Baselines/junit.sw.approved.txt b/external_imported/Catch2/tests/SelfTest/Baselines/junit.sw.approved.txt index 25129349c..48eccfc3d 100644 --- a/external_imported/Catch2/tests/SelfTest/Baselines/junit.sw.approved.txt +++ b/external_imported/Catch2/tests/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ - + @@ -462,8 +462,14 @@ at Exception.tests.cpp: + + +SKIPPED +This generator is empty +at Skip.tests.cpp: + + - FAILED: @@ -702,6 +708,7 @@ at Message.tests.cpp: + @@ -746,6 +753,15 @@ at Message.tests.cpp: + + +FAILED: +Show infos! +This info has multiple parts. +This unscoped info has multiple parts. +at Message.tests.cpp: + + @@ -790,6 +806,15 @@ i := 10 at Message.tests.cpp: + + + +FAILED: + REQUIRE( Dummy ) +Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE +at AssertionHandler.tests.cpp: + + @@ -829,6 +854,24 @@ at Condition.tests.cpp: + + + + + + + + + + + + + + + + + + @@ -1166,6 +1209,9 @@ at Matchers.tests.cpp: + + + @@ -1354,6 +1400,24 @@ FAILED: at Misc.tests.cpp: + + + +FAILED: + {Unknown expression after the reported line} +Uncaught exception should fail! +at Misc.tests.cpp: + + + + + +FAILED: + {Unknown expression after the reported line} +Uncaught exception should fail! +at Misc.tests.cpp: + + @@ -1401,10 +1465,10 @@ at Exception.tests.cpp: - + - + @@ -1414,10 +1478,10 @@ at Exception.tests.cpp: - + - + @@ -1427,10 +1491,10 @@ at Exception.tests.cpp: - + - + @@ -2011,6 +2075,7 @@ at Exception.tests.cpp: + diff --git a/external_imported/Catch2/tests/SelfTest/Baselines/junit.sw.multi.approved.txt b/external_imported/Catch2/tests/SelfTest/Baselines/junit.sw.multi.approved.txt index 6220d8e23..d270c88fb 100644 --- a/external_imported/Catch2/tests/SelfTest/Baselines/junit.sw.multi.approved.txt +++ b/external_imported/Catch2/tests/SelfTest/Baselines/junit.sw.multi.approved.txt @@ -1,6 +1,6 @@ - + @@ -461,8 +461,14 @@ at Exception.tests.cpp: + + +SKIPPED +This generator is empty +at Skip.tests.cpp: + + - FAILED: @@ -701,6 +707,7 @@ at Message.tests.cpp: + @@ -745,6 +752,15 @@ at Message.tests.cpp: + + +FAILED: +Show infos! +This info has multiple parts. +This unscoped info has multiple parts. +at Message.tests.cpp: + + @@ -789,6 +805,15 @@ i := 10 at Message.tests.cpp: + + + +FAILED: + REQUIRE( Dummy ) +Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE +at AssertionHandler.tests.cpp: + + @@ -828,6 +853,24 @@ at Condition.tests.cpp: + + + + + + + + + + + + + + + + + + @@ -1165,6 +1208,9 @@ at Matchers.tests.cpp: + + + @@ -1353,6 +1399,24 @@ FAILED: at Misc.tests.cpp: + + + +FAILED: + {Unknown expression after the reported line} +Uncaught exception should fail! +at Misc.tests.cpp: + + + + + +FAILED: + {Unknown expression after the reported line} +Uncaught exception should fail! +at Misc.tests.cpp: + + @@ -1400,10 +1464,10 @@ at Exception.tests.cpp: - + - + @@ -1413,10 +1477,10 @@ at Exception.tests.cpp: - + - + @@ -1426,10 +1490,10 @@ at Exception.tests.cpp: - + - + @@ -2010,6 +2074,7 @@ at Exception.tests.cpp: + diff --git a/external_imported/Catch2/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/external_imported/Catch2/tests/SelfTest/Baselines/sonarqube.sw.approved.txt index a4e08bd26..36b05e54d 100644 --- a/external_imported/Catch2/tests/SelfTest/Baselines/sonarqube.sw.approved.txt +++ b/external_imported/Catch2/tests/SelfTest/Baselines/sonarqube.sw.approved.txt @@ -2,6 +2,16 @@ + + + +FAILED: + REQUIRE( Dummy ) +Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE +at AssertionHandler.tests.cpp: + + + @@ -120,6 +130,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -151,6 +181,7 @@ + @@ -168,6 +199,9 @@ + + + @@ -233,7 +267,6 @@ - @@ -1039,6 +1072,7 @@ at Generators.tests.cpp: + @@ -1389,10 +1423,10 @@ at Matchers.tests.cpp: - + - + @@ -1402,10 +1436,10 @@ at Matchers.tests.cpp: - + - + @@ -1415,10 +1449,10 @@ at Matchers.tests.cpp: - + - + @@ -1468,6 +1502,15 @@ at Message.tests.cpp: FAILED: This is a failure +at Message.tests.cpp: + + + + +FAILED: +Show infos! +This info has multiple parts. +This unscoped info has multiple parts. at Message.tests.cpp: @@ -1728,6 +1771,22 @@ at Misc.tests.cpp: FAILED: +at Misc.tests.cpp: + + + + +FAILED: + {Unknown expression after the reported line} +Uncaught exception should fail! +at Misc.tests.cpp: + + + + +FAILED: + {Unknown expression after the reported line} +Uncaught exception should fail! at Misc.tests.cpp: @@ -1871,6 +1930,13 @@ at Misc.tests.cpp: + + +SKIPPED +This generator is empty +at Skip.tests.cpp: + + SKIPPED diff --git a/external_imported/Catch2/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt b/external_imported/Catch2/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt index c00defae7..c9d3d205b 100644 --- a/external_imported/Catch2/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt +++ b/external_imported/Catch2/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt @@ -1,6 +1,16 @@ + + + +FAILED: + REQUIRE( Dummy ) +Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE +at AssertionHandler.tests.cpp: + + + @@ -119,6 +129,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -150,6 +180,7 @@ + @@ -167,6 +198,9 @@ + + + @@ -232,7 +266,6 @@ - @@ -1038,6 +1071,7 @@ at Generators.tests.cpp: + @@ -1388,10 +1422,10 @@ at Matchers.tests.cpp: - + - + @@ -1401,10 +1435,10 @@ at Matchers.tests.cpp: - + - + @@ -1414,10 +1448,10 @@ at Matchers.tests.cpp: - + - + @@ -1467,6 +1501,15 @@ at Message.tests.cpp: FAILED: This is a failure +at Message.tests.cpp: + + + + +FAILED: +Show infos! +This info has multiple parts. +This unscoped info has multiple parts. at Message.tests.cpp: @@ -1727,6 +1770,22 @@ at Misc.tests.cpp: FAILED: +at Misc.tests.cpp: + + + + +FAILED: + {Unknown expression after the reported line} +Uncaught exception should fail! +at Misc.tests.cpp: + + + + +FAILED: + {Unknown expression after the reported line} +Uncaught exception should fail! at Misc.tests.cpp: @@ -1870,6 +1929,13 @@ at Misc.tests.cpp: + + +SKIPPED +This generator is empty +at Skip.tests.cpp: + + SKIPPED diff --git a/external_imported/Catch2/tests/SelfTest/Baselines/tap.sw.approved.txt b/external_imported/Catch2/tests/SelfTest/Baselines/tap.sw.approved.txt index 920c95fd7..a02dbd954 100644 --- a/external_imported/Catch2/tests/SelfTest/Baselines/tap.sw.approved.txt +++ b/external_imported/Catch2/tests/SelfTest/Baselines/tap.sw.approved.txt @@ -659,7 +659,7 @@ ok {test-number} - unrelated::ADL_empty{}, IsEmpty() for: {?} is empty # CAPTURE can deal with complex expressions ok {test-number} - with 7 messages: 'a := 1' and 'b := 2' and 'c := 3' and 'a + b := 3' and 'a+b := 3' and 'c > b := true' and 'a == 1 := true' # CAPTURE can deal with complex expressions involving commas -ok {test-number} - with 7 messages: 'std::vector{1, 2, 3}[0, 1, 2] := 3' and 'std::vector{1, 2, 3}[(0, 1)] := 2' and 'std::vector{1, 2, 3}[0] := 1' and '(helper_1436{12, -12}) := { 12, -12 }' and '(helper_1436(-12, 12)) := { -12, 12 }' and '(1, 2) := 2' and '(2, 3) := 3' +ok {test-number} - with 7 messages: 'custom_index_op{1, 2, 3}[0, 1, 2] := 0' and 'custom_index_op{1, 2, 3}[(0, 1)] := 0' and 'custom_index_op{1, 2, 3}[0] := 0' and '(helper_1436{12, -12}) := { 12, -12 }' and '(helper_1436(-12, 12)) := { -12, 12 }' and '(1, 2) := 2' and '(2, 3) := 3' # CAPTURE parses string and character constants ok {test-number} - with 11 messages: '("comma, in string", "escaped, \", ") := "escaped, ", "' and '"single quote in string,'," := "single quote in string,',"' and '"some escapes, \\,\\\\" := "some escapes, \,\\"' and '"some, ), unmatched, } prenheses {[<" := "some, ), unmatched, } prenheses {[<"' and ''"' := '"'' and ''\'' := '''' and '',' := ','' and ''}' := '}'' and '')' := ')'' and ''(' := '('' and ''{' := '{'' # Capture and info messages @@ -984,10 +984,10 @@ ok {test-number} - enumInfo->lookup(0) == "Value1" for: Value1 == "Value1" ok {test-number} - enumInfo->lookup(1) == "Value2" for: Value2 == "Value2" # Directly creating an EnumInfo ok {test-number} - enumInfo->lookup(3) == "{** unexpected enum value **}" for: {** unexpected enum value **} == "{** unexpected enum value **}" +# Empty generators can SKIP in constructor +ok {test-number} - # SKIP 'This generator is empty' # Empty stream name opens cout stream ok {test-number} - Catch::makeStream( "" )->isConsole() for: true -# Empty tag is not allowed -ok {test-number} - Catch::TestCaseInfo( "", { "fake test name", "[]" }, dummySourceLineInfo ) # EndsWith string matcher not ok {test-number} - testStringForMatching(), EndsWith( "Substring" ) for: "this string contains 'abc' as a substring" ends with: "Substring" # EndsWith string matcher @@ -1258,6 +1258,14 @@ ok {test-number} - WithinRel( 1.f, -0.2f ), std::domain_error ok {test-number} - WithinRel( 1.f, 1.f ), std::domain_error # Floating point matchers: float ok {test-number} - 1., !IsNaN() for: 1.0 not is NaN +# GENERATE can combine literals and generators +ok {test-number} - i % 2 == 0 for: 0 == 0 +# GENERATE can combine literals and generators +ok {test-number} - i % 2 == 0 for: 0 == 0 +# GENERATE can combine literals and generators +ok {test-number} - i % 2 == 0 for: 0 == 0 +# GENERATE can combine literals and generators +ok {test-number} - i % 2 == 0 for: 0 == 0 # Generators -- adapters ok {test-number} - i % 2 == 0 for: 0 == 0 # Generators -- adapters @@ -1796,6 +1804,8 @@ ok {test-number} - h( dummy1 ) != h( dummy2 ) for: 2673152918 (0x) ! ok {test-number} - h( dummy1 ) != h( dummy2 ) for: 2074929312 (0x) != 3429949824 (0x) # Hashing test case produces same hash across multiple calls ok {test-number} - h( dummy ) == h( dummy ) for: 3422778688 (0x) == 3422778688 (0x) +# INFO and UNSCOPED_INFO can stream multiple arguments +not ok {test-number} - explicitly with 3 messages: 'This info has multiple parts.' and 'This unscoped info has multiple parts.' and 'Show infos!' # INFO and WARN do not abort tests warning {test-number} - 'this is a message' with 1 message: 'this is a warning' # INFO gets logged on failure @@ -1830,6 +1840,8 @@ ok {test-number} - i < 10 for: 8 < 10 with 2 messages: 'current counter 8' and ' ok {test-number} - i < 10 for: 9 < 10 with 2 messages: 'current counter 9' and 'i := 9' # INFO is reset for each loop not ok {test-number} - i < 10 for: 10 < 10 with 2 messages: 'current counter 10' and 'i := 10' +# Incomplete AssertionHandler +not ok {test-number} - unexpected exception with message: 'Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE'; expression was: Dummy # Inequality checks that should fail not ok {test-number} - data.int_seven != 7 for: 7 != 7 # Inequality checks that should fail @@ -1862,6 +1874,42 @@ ok {test-number} - data.str_hello != "hell" for: "hello" != "hell" ok {test-number} - data.str_hello != "hello1" for: "hello" != "hello1" # Inequality checks that should succeed ok {test-number} - data.str_hello.size() != 6 for: 5 != 6 +# JsonWriter +ok {test-number} - stream.str() == "" for: "" == "" +# JsonWriter +ok {test-number} - stream.str() == "{\n}" for: "{ }" == "{ }" +# JsonWriter +ok {test-number} - stream.str(), ContainsSubstring( "\"int\": 1," ) && ContainsSubstring( "\"double\": 1.5," ) && ContainsSubstring( "\"true\": true," ) && ContainsSubstring( "\"false\": false," ) && ContainsSubstring( "\"string\": \"this is a string\"," ) && ContainsSubstring( "\"array\": [\n 1,\n 2\n ]\n}" ) for: "{ "int": 1, "double": 1.5, "true": true, "false": false, "string": "this is a string", "array": [ 1, 2 ] }" ( contains: ""int": 1," and contains: ""double": 1.5," and contains: ""true": true," and contains: ""false": false," and contains: ""string": "this is a string"," and contains: ""array": [ 1, 2 ] }" ) +# JsonWriter +ok {test-number} - stream.str(), ContainsSubstring( "\"empty_object\": {\n }," ) && ContainsSubstring( "\"fully_object\": {\n \"key\": 1\n }" ) for: "{ "empty_object": { }, "fully_object": { "key": 1 } }" ( contains: ""empty_object": { }," and contains: ""fully_object": { "key": 1 }" ) +# JsonWriter +ok {test-number} - stream.str() == "[\n]" for: "[ ]" == "[ ]" +# JsonWriter +ok {test-number} - stream.str() == "[\n 1,\n 1.5,\n true,\n false,\n \"this is a string\",\n {\n \"object\": 42\n },\n [\n \"array\",\n 42.5\n ]\n]" for: "[ 1, 1.5, true, false, "this is a string", { "object": 42 }, [ "array", 42.5 ] ]" == "[ 1, 1.5, true, false, "this is a string", { "object": 42 }, [ "array", 42.5 ] ]" +# JsonWriter +ok {test-number} - stream.str() == "{\n}" for: "{ }" == "{ }" +# JsonWriter +ok {test-number} - stream.str() == "[\n]" for: "[ ]" == "[ ]" +# JsonWriter +ok {test-number} - stream.str() == "\"custom\"" for: ""custom"" == ""custom"" +# JsonWriter escapes charaters in strings properly +ok {test-number} - sstream.str() == "\"\\\"\"" for: ""\""" == ""\""" +# JsonWriter escapes charaters in strings properly +ok {test-number} - sstream.str() == "\"\\\\\"" for: ""\\"" == ""\\"" +# JsonWriter escapes charaters in strings properly +ok {test-number} - sstream.str() == "\"/\"" for: ""/"" == ""/"" +# JsonWriter escapes charaters in strings properly +ok {test-number} - sstream.str() == "\"\\b\"" for: ""\b"" == ""\b"" +# JsonWriter escapes charaters in strings properly +ok {test-number} - sstream.str() == "\"\\f\"" for: ""\f"" == ""\f"" +# JsonWriter escapes charaters in strings properly +ok {test-number} - sstream.str() == "\"\\n\"" for: ""\n"" == ""\n"" +# JsonWriter escapes charaters in strings properly +ok {test-number} - sstream.str() == "\"\\r\"" for: ""\r"" == ""\r"" +# JsonWriter escapes charaters in strings properly +ok {test-number} - sstream.str() == "\"\\t\"" for: ""\t"" == ""\t"" +# JsonWriter escapes charaters in strings properly +ok {test-number} - sstream.str() == "\"\\\\/\\t\\r\\n\"" for: ""\\/\t\r\n"" == ""\\/\t\r\n"" # Lambdas in assertions ok {test-number} - []() { return true; }() for: true # Less-than inequalities with different epsilons @@ -2455,6 +2503,18 @@ ok {test-number} - listingString, ContainsSubstring( "fake test name"s ) && Cont # Reporter's write listings to provided stream ok {test-number} - !(factories.empty()) for: !false # Reporter's write listings to provided stream +ok {test-number} - listingString, ContainsSubstring("fakeTag"s) for: "{ "version": 1, "metadata": { "name": "", "rng-seed": 1234, "catch2-version": "" }, "listings": { "tags": [ { "aliases": [ "fakeTag" ], "count": 1 } ]" contains: "fakeTag" with 1 message: 'Tested reporter: JSON' +# Reporter's write listings to provided stream +ok {test-number} - !(factories.empty()) for: !false +# Reporter's write listings to provided stream +ok {test-number} - listingString, ContainsSubstring("fake reporter"s) for: "{ "version": 1, "metadata": { "name": "", "rng-seed": 1234, "catch2-version": "" }, "listings": { "reporters": [ { "name": "fake reporter", "description": "fake description" } ]" contains: "fake reporter" with 1 message: 'Tested reporter: JSON' +# Reporter's write listings to provided stream +ok {test-number} - !(factories.empty()) for: !false +# Reporter's write listings to provided stream +ok {test-number} - listingString, ContainsSubstring( "fake test name"s ) && ContainsSubstring( "fakeTestTag"s ) for: "{ "version": 1, "metadata": { "name": "", "rng-seed": 1234, "catch2-version": "" }, "listings": { "tests": [ { "name": "fake test name", "class-name": "", "tags": [ "fakeTestTag" ], "source-location": { "filename": "fake-file.cpp", "line": 123456789 } } ]" ( contains: "fake test name" and contains: "fakeTestTag" ) with 1 message: 'Tested reporter: JSON' +# Reporter's write listings to provided stream +ok {test-number} - !(factories.empty()) for: !false +# Reporter's write listings to provided stream ok {test-number} - listingString, ContainsSubstring("fakeTag"s) for: " All available tags: 1 [fakeTag] 1 tag " contains: "fakeTag" with 1 message: 'Tested reporter: JUnit' # Reporter's write listings to provided stream ok {test-number} - !(factories.empty()) for: !false @@ -3067,6 +3127,14 @@ not ok {test-number} - explicitly ok {test-number} - false # TODO # Testing checked-if 3 not ok {test-number} - explicitly +# Testing checked-if 4 +ok {test-number} - true +# Testing checked-if 4 +not ok {test-number} - unexpected exception with message: 'Uncaught exception should fail!'; expression was: {Unknown expression after the reported line} +# Testing checked-if 5 +ok {test-number} - false # TODO +# Testing checked-if 5 +not ok {test-number} - unexpected exception with message: 'Uncaught exception should fail!'; expression was: {Unknown expression after the reported line} # The NO_FAIL macro reports a failure but does not fail the test ok {test-number} - 1 == 2 # TODO # The default listing implementation write to provided stream @@ -4355,6 +4423,10 @@ ok {test-number} - e.upper_bound == 23 for: 23.0 == 23 ok {test-number} - e.lower_bound == 23 for: 23.0 == 23 # uniform samples ok {test-number} - e.confidence_interval == 0.95 for: 0.95 == 0.95 +# uniform_integer_distribution can return the bounds +ok {test-number} - dist.a() == -10 for: -10 == -10 +# uniform_integer_distribution can return the bounds +ok {test-number} - dist.b() == 10 for: 10 == 10 # unique_ptr reimplementation: basic functionality ok {test-number} - !(ptr) for: !{?} # unique_ptr reimplementation: basic functionality @@ -4477,5 +4549,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2237 +1..2272 diff --git a/external_imported/Catch2/tests/SelfTest/Baselines/tap.sw.multi.approved.txt b/external_imported/Catch2/tests/SelfTest/Baselines/tap.sw.multi.approved.txt index c0e0c4dbe..13449bd40 100644 --- a/external_imported/Catch2/tests/SelfTest/Baselines/tap.sw.multi.approved.txt +++ b/external_imported/Catch2/tests/SelfTest/Baselines/tap.sw.multi.approved.txt @@ -657,7 +657,7 @@ ok {test-number} - unrelated::ADL_empty{}, IsEmpty() for: {?} is empty # CAPTURE can deal with complex expressions ok {test-number} - with 7 messages: 'a := 1' and 'b := 2' and 'c := 3' and 'a + b := 3' and 'a+b := 3' and 'c > b := true' and 'a == 1 := true' # CAPTURE can deal with complex expressions involving commas -ok {test-number} - with 7 messages: 'std::vector{1, 2, 3}[0, 1, 2] := 3' and 'std::vector{1, 2, 3}[(0, 1)] := 2' and 'std::vector{1, 2, 3}[0] := 1' and '(helper_1436{12, -12}) := { 12, -12 }' and '(helper_1436(-12, 12)) := { -12, 12 }' and '(1, 2) := 2' and '(2, 3) := 3' +ok {test-number} - with 7 messages: 'custom_index_op{1, 2, 3}[0, 1, 2] := 0' and 'custom_index_op{1, 2, 3}[(0, 1)] := 0' and 'custom_index_op{1, 2, 3}[0] := 0' and '(helper_1436{12, -12}) := { 12, -12 }' and '(helper_1436(-12, 12)) := { -12, 12 }' and '(1, 2) := 2' and '(2, 3) := 3' # CAPTURE parses string and character constants ok {test-number} - with 11 messages: '("comma, in string", "escaped, \", ") := "escaped, ", "' and '"single quote in string,'," := "single quote in string,',"' and '"some escapes, \\,\\\\" := "some escapes, \,\\"' and '"some, ), unmatched, } prenheses {[<" := "some, ), unmatched, } prenheses {[<"' and ''"' := '"'' and ''\'' := '''' and '',' := ','' and ''}' := '}'' and '')' := ')'' and ''(' := '('' and ''{' := '{'' # Capture and info messages @@ -982,10 +982,10 @@ ok {test-number} - enumInfo->lookup(0) == "Value1" for: Value1 == "Value1" ok {test-number} - enumInfo->lookup(1) == "Value2" for: Value2 == "Value2" # Directly creating an EnumInfo ok {test-number} - enumInfo->lookup(3) == "{** unexpected enum value **}" for: {** unexpected enum value **} == "{** unexpected enum value **}" +# Empty generators can SKIP in constructor +ok {test-number} - # SKIP 'This generator is empty' # Empty stream name opens cout stream ok {test-number} - Catch::makeStream( "" )->isConsole() for: true -# Empty tag is not allowed -ok {test-number} - Catch::TestCaseInfo( "", { "fake test name", "[]" }, dummySourceLineInfo ) # EndsWith string matcher not ok {test-number} - testStringForMatching(), EndsWith( "Substring" ) for: "this string contains 'abc' as a substring" ends with: "Substring" # EndsWith string matcher @@ -1256,6 +1256,14 @@ ok {test-number} - WithinRel( 1.f, -0.2f ), std::domain_error ok {test-number} - WithinRel( 1.f, 1.f ), std::domain_error # Floating point matchers: float ok {test-number} - 1., !IsNaN() for: 1.0 not is NaN +# GENERATE can combine literals and generators +ok {test-number} - i % 2 == 0 for: 0 == 0 +# GENERATE can combine literals and generators +ok {test-number} - i % 2 == 0 for: 0 == 0 +# GENERATE can combine literals and generators +ok {test-number} - i % 2 == 0 for: 0 == 0 +# GENERATE can combine literals and generators +ok {test-number} - i % 2 == 0 for: 0 == 0 # Generators -- adapters ok {test-number} - i % 2 == 0 for: 0 == 0 # Generators -- adapters @@ -1794,6 +1802,8 @@ ok {test-number} - h( dummy1 ) != h( dummy2 ) for: 2673152918 (0x) ! ok {test-number} - h( dummy1 ) != h( dummy2 ) for: 2074929312 (0x) != 3429949824 (0x) # Hashing test case produces same hash across multiple calls ok {test-number} - h( dummy ) == h( dummy ) for: 3422778688 (0x) == 3422778688 (0x) +# INFO and UNSCOPED_INFO can stream multiple arguments +not ok {test-number} - explicitly with 3 messages: 'This info has multiple parts.' and 'This unscoped info has multiple parts.' and 'Show infos!' # INFO and WARN do not abort tests warning {test-number} - 'this is a message' with 1 message: 'this is a warning' # INFO gets logged on failure @@ -1828,6 +1838,8 @@ ok {test-number} - i < 10 for: 8 < 10 with 2 messages: 'current counter 8' and ' ok {test-number} - i < 10 for: 9 < 10 with 2 messages: 'current counter 9' and 'i := 9' # INFO is reset for each loop not ok {test-number} - i < 10 for: 10 < 10 with 2 messages: 'current counter 10' and 'i := 10' +# Incomplete AssertionHandler +not ok {test-number} - unexpected exception with message: 'Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE'; expression was: Dummy # Inequality checks that should fail not ok {test-number} - data.int_seven != 7 for: 7 != 7 # Inequality checks that should fail @@ -1860,6 +1872,42 @@ ok {test-number} - data.str_hello != "hell" for: "hello" != "hell" ok {test-number} - data.str_hello != "hello1" for: "hello" != "hello1" # Inequality checks that should succeed ok {test-number} - data.str_hello.size() != 6 for: 5 != 6 +# JsonWriter +ok {test-number} - stream.str() == "" for: "" == "" +# JsonWriter +ok {test-number} - stream.str() == "{\n}" for: "{ }" == "{ }" +# JsonWriter +ok {test-number} - stream.str(), ContainsSubstring( "\"int\": 1," ) && ContainsSubstring( "\"double\": 1.5," ) && ContainsSubstring( "\"true\": true," ) && ContainsSubstring( "\"false\": false," ) && ContainsSubstring( "\"string\": \"this is a string\"," ) && ContainsSubstring( "\"array\": [\n 1,\n 2\n ]\n}" ) for: "{ "int": 1, "double": 1.5, "true": true, "false": false, "string": "this is a string", "array": [ 1, 2 ] }" ( contains: ""int": 1," and contains: ""double": 1.5," and contains: ""true": true," and contains: ""false": false," and contains: ""string": "this is a string"," and contains: ""array": [ 1, 2 ] }" ) +# JsonWriter +ok {test-number} - stream.str(), ContainsSubstring( "\"empty_object\": {\n }," ) && ContainsSubstring( "\"fully_object\": {\n \"key\": 1\n }" ) for: "{ "empty_object": { }, "fully_object": { "key": 1 } }" ( contains: ""empty_object": { }," and contains: ""fully_object": { "key": 1 }" ) +# JsonWriter +ok {test-number} - stream.str() == "[\n]" for: "[ ]" == "[ ]" +# JsonWriter +ok {test-number} - stream.str() == "[\n 1,\n 1.5,\n true,\n false,\n \"this is a string\",\n {\n \"object\": 42\n },\n [\n \"array\",\n 42.5\n ]\n]" for: "[ 1, 1.5, true, false, "this is a string", { "object": 42 }, [ "array", 42.5 ] ]" == "[ 1, 1.5, true, false, "this is a string", { "object": 42 }, [ "array", 42.5 ] ]" +# JsonWriter +ok {test-number} - stream.str() == "{\n}" for: "{ }" == "{ }" +# JsonWriter +ok {test-number} - stream.str() == "[\n]" for: "[ ]" == "[ ]" +# JsonWriter +ok {test-number} - stream.str() == "\"custom\"" for: ""custom"" == ""custom"" +# JsonWriter escapes charaters in strings properly +ok {test-number} - sstream.str() == "\"\\\"\"" for: ""\""" == ""\""" +# JsonWriter escapes charaters in strings properly +ok {test-number} - sstream.str() == "\"\\\\\"" for: ""\\"" == ""\\"" +# JsonWriter escapes charaters in strings properly +ok {test-number} - sstream.str() == "\"/\"" for: ""/"" == ""/"" +# JsonWriter escapes charaters in strings properly +ok {test-number} - sstream.str() == "\"\\b\"" for: ""\b"" == ""\b"" +# JsonWriter escapes charaters in strings properly +ok {test-number} - sstream.str() == "\"\\f\"" for: ""\f"" == ""\f"" +# JsonWriter escapes charaters in strings properly +ok {test-number} - sstream.str() == "\"\\n\"" for: ""\n"" == ""\n"" +# JsonWriter escapes charaters in strings properly +ok {test-number} - sstream.str() == "\"\\r\"" for: ""\r"" == ""\r"" +# JsonWriter escapes charaters in strings properly +ok {test-number} - sstream.str() == "\"\\t\"" for: ""\t"" == ""\t"" +# JsonWriter escapes charaters in strings properly +ok {test-number} - sstream.str() == "\"\\\\/\\t\\r\\n\"" for: ""\\/\t\r\n"" == ""\\/\t\r\n"" # Lambdas in assertions ok {test-number} - []() { return true; }() for: true # Less-than inequalities with different epsilons @@ -2453,6 +2501,18 @@ ok {test-number} - listingString, ContainsSubstring( "fake test name"s ) && Cont # Reporter's write listings to provided stream ok {test-number} - !(factories.empty()) for: !false # Reporter's write listings to provided stream +ok {test-number} - listingString, ContainsSubstring("fakeTag"s) for: "{ "version": 1, "metadata": { "name": "", "rng-seed": 1234, "catch2-version": "" }, "listings": { "tags": [ { "aliases": [ "fakeTag" ], "count": 1 } ]" contains: "fakeTag" with 1 message: 'Tested reporter: JSON' +# Reporter's write listings to provided stream +ok {test-number} - !(factories.empty()) for: !false +# Reporter's write listings to provided stream +ok {test-number} - listingString, ContainsSubstring("fake reporter"s) for: "{ "version": 1, "metadata": { "name": "", "rng-seed": 1234, "catch2-version": "" }, "listings": { "reporters": [ { "name": "fake reporter", "description": "fake description" } ]" contains: "fake reporter" with 1 message: 'Tested reporter: JSON' +# Reporter's write listings to provided stream +ok {test-number} - !(factories.empty()) for: !false +# Reporter's write listings to provided stream +ok {test-number} - listingString, ContainsSubstring( "fake test name"s ) && ContainsSubstring( "fakeTestTag"s ) for: "{ "version": 1, "metadata": { "name": "", "rng-seed": 1234, "catch2-version": "" }, "listings": { "tests": [ { "name": "fake test name", "class-name": "", "tags": [ "fakeTestTag" ], "source-location": { "filename": "fake-file.cpp", "line": 123456789 } } ]" ( contains: "fake test name" and contains: "fakeTestTag" ) with 1 message: 'Tested reporter: JSON' +# Reporter's write listings to provided stream +ok {test-number} - !(factories.empty()) for: !false +# Reporter's write listings to provided stream ok {test-number} - listingString, ContainsSubstring("fakeTag"s) for: " All available tags: 1 [fakeTag] 1 tag " contains: "fakeTag" with 1 message: 'Tested reporter: JUnit' # Reporter's write listings to provided stream ok {test-number} - !(factories.empty()) for: !false @@ -3060,6 +3120,14 @@ not ok {test-number} - explicitly ok {test-number} - false # TODO # Testing checked-if 3 not ok {test-number} - explicitly +# Testing checked-if 4 +ok {test-number} - true +# Testing checked-if 4 +not ok {test-number} - unexpected exception with message: 'Uncaught exception should fail!'; expression was: {Unknown expression after the reported line} +# Testing checked-if 5 +ok {test-number} - false # TODO +# Testing checked-if 5 +not ok {test-number} - unexpected exception with message: 'Uncaught exception should fail!'; expression was: {Unknown expression after the reported line} # The NO_FAIL macro reports a failure but does not fail the test ok {test-number} - 1 == 2 # TODO # The default listing implementation write to provided stream @@ -4344,6 +4412,10 @@ ok {test-number} - e.upper_bound == 23 for: 23.0 == 23 ok {test-number} - e.lower_bound == 23 for: 23.0 == 23 # uniform samples ok {test-number} - e.confidence_interval == 0.95 for: 0.95 == 0.95 +# uniform_integer_distribution can return the bounds +ok {test-number} - dist.a() == -10 for: -10 == -10 +# uniform_integer_distribution can return the bounds +ok {test-number} - dist.b() == 10 for: 10 == 10 # unique_ptr reimplementation: basic functionality ok {test-number} - !(ptr) for: !{?} # unique_ptr reimplementation: basic functionality @@ -4466,5 +4538,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2237 +1..2272 diff --git a/external_imported/Catch2/tests/SelfTest/Baselines/teamcity.sw.approved.txt b/external_imported/Catch2/tests/SelfTest/Baselines/teamcity.sw.approved.txt index 8a8b55e2b..2a2c40cfc 100644 --- a/external_imported/Catch2/tests/SelfTest/Baselines/teamcity.sw.approved.txt +++ b/external_imported/Catch2/tests/SelfTest/Baselines/teamcity.sw.approved.txt @@ -299,10 +299,11 @@ ##teamcity[testFinished name='Default scale is invisible to comparison' duration="{duration}"] ##teamcity[testStarted name='Directly creating an EnumInfo'] ##teamcity[testFinished name='Directly creating an EnumInfo' duration="{duration}"] +##teamcity[testStarted name='Empty generators can SKIP in constructor'] +##teamcity[testIgnored name='Empty generators can SKIP in constructor' message='Skip.tests.cpp:|n...............................................................................|n|nSkip.tests.cpp:|nexplicit skip with message:|n "This generator is empty"'] +##teamcity[testFinished name='Empty generators can SKIP in constructor' duration="{duration}"] ##teamcity[testStarted name='Empty stream name opens cout stream'] ##teamcity[testFinished name='Empty stream name opens cout stream' duration="{duration}"] -##teamcity[testStarted name='Empty tag is not allowed'] -##teamcity[testFinished name='Empty tag is not allowed' duration="{duration}"] ##teamcity[testStarted name='EndsWith string matcher'] ##teamcity[testFailed name='EndsWith string matcher' message='Matchers.tests.cpp:|n...............................................................................|n|nMatchers.tests.cpp:|nexpression failed|n CHECK_THAT( testStringForMatching(), EndsWith( "Substring" ) )|nwith expansion:|n "this string contains |'abc|' as a substring" ends with: "Substring"|n'] ##teamcity[testFailed name='EndsWith string matcher' message='Matchers.tests.cpp:|nexpression failed|n CHECK_THAT( testStringForMatching(), EndsWith( "this", Catch::CaseSensitive::No ) )|nwith expansion:|n "this string contains |'abc|' as a substring" ends with: "this" (case insensitive)|n'] @@ -376,6 +377,8 @@ ##teamcity[testFinished name='Floating point matchers: double' duration="{duration}"] ##teamcity[testStarted name='Floating point matchers: float'] ##teamcity[testFinished name='Floating point matchers: float' duration="{duration}"] +##teamcity[testStarted name='GENERATE can combine literals and generators'] +##teamcity[testFinished name='GENERATE can combine literals and generators' duration="{duration}"] ##teamcity[testStarted name='Generators -- adapters'] ##teamcity[testFinished name='Generators -- adapters' duration="{duration}"] ##teamcity[testStarted name='Generators -- simple'] @@ -392,6 +395,9 @@ ##teamcity[testFinished name='Hashing different test cases produces different result' duration="{duration}"] ##teamcity[testStarted name='Hashing test case produces same hash across multiple calls'] ##teamcity[testFinished name='Hashing test case produces same hash across multiple calls' duration="{duration}"] +##teamcity[testStarted name='INFO and UNSCOPED_INFO can stream multiple arguments'] +##teamcity[testFailed name='INFO and UNSCOPED_INFO can stream multiple arguments' message='Message.tests.cpp:|n...............................................................................|n|nMessage.tests.cpp:|nexplicit failure with messages:|n "This info has multiple parts."|n "This unscoped info has multiple parts."|n "Show infos!"'] +##teamcity[testFinished name='INFO and UNSCOPED_INFO can stream multiple arguments' duration="{duration}"] ##teamcity[testStarted name='INFO and WARN do not abort tests'] ##teamcity[testFinished name='INFO and WARN do not abort tests' duration="{duration}"] ##teamcity[testStarted name='INFO gets logged on failure'] @@ -404,6 +410,9 @@ ##teamcity[testStarted name='INFO is reset for each loop'] ##teamcity[testFailed name='INFO is reset for each loop' message='Message.tests.cpp:|n...............................................................................|n|nMessage.tests.cpp:|nexpression failed with messages:|n "current counter 10"|n "i := 10"|n REQUIRE( i < 10 )|nwith expansion:|n 10 < 10|n'] ##teamcity[testFinished name='INFO is reset for each loop' duration="{duration}"] +##teamcity[testStarted name='Incomplete AssertionHandler'] +##teamcity[testIgnored name='Incomplete AssertionHandler' message='AssertionHandler.tests.cpp:|n...............................................................................|n|nAssertionHandler.tests.cpp:|nunexpected exception with message:|n "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE"|n REQUIRE( Dummy )|nwith expansion:|n Dummy|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testFinished name='Incomplete AssertionHandler' duration="{duration}"] ##teamcity[testStarted name='Inequality checks that should fail'] ##teamcity[testIgnored name='Inequality checks that should fail' message='Condition.tests.cpp:|n...............................................................................|n|nCondition.tests.cpp:|nexpression failed|n CHECK( data.int_seven != 7 )|nwith expansion:|n 7 != 7|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testIgnored name='Inequality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one != Approx( 9.1f ) )|nwith expansion:|n 9.1f != Approx( 9.1000003815 )|n- failure ignore as test marked as |'ok to fail|'|n'] @@ -413,6 +422,10 @@ ##teamcity[testFinished name='Inequality checks that should fail' duration="{duration}"] ##teamcity[testStarted name='Inequality checks that should succeed'] ##teamcity[testFinished name='Inequality checks that should succeed' duration="{duration}"] +##teamcity[testStarted name='JsonWriter'] +##teamcity[testFinished name='JsonWriter' duration="{duration}"] +##teamcity[testStarted name='JsonWriter escapes charaters in strings properly'] +##teamcity[testFinished name='JsonWriter escapes charaters in strings properly' duration="{duration}"] ##teamcity[testStarted name='Lambdas in assertions'] ##teamcity[testFinished name='Lambdas in assertions' duration="{duration}"] ##teamcity[testStarted name='Less-than inequalities with different epsilons'] @@ -638,6 +651,12 @@ ##teamcity[testStarted name='Testing checked-if 3'] ##teamcity[testIgnored name='Testing checked-if 3' message='Misc.tests.cpp:|n...............................................................................|n|nMisc.tests.cpp:|nexplicit failure- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testFinished name='Testing checked-if 3' duration="{duration}"] +##teamcity[testStarted name='Testing checked-if 4'] +##teamcity[testIgnored name='Testing checked-if 4' message='Misc.tests.cpp:|n...............................................................................|n|nMisc.tests.cpp:|nunexpected exception with message:|n "Uncaught exception should fail!"|n {Unknown expression after the reported line}|nwith expansion:|n {Unknown expression after the reported line}|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testFinished name='Testing checked-if 4' duration="{duration}"] +##teamcity[testStarted name='Testing checked-if 5'] +##teamcity[testIgnored name='Testing checked-if 5' message='Misc.tests.cpp:|n...............................................................................|n|nMisc.tests.cpp:|nunexpected exception with message:|n "Uncaught exception should fail!"|n {Unknown expression after the reported line}|nwith expansion:|n {Unknown expression after the reported line}|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testFinished name='Testing checked-if 5' duration="{duration}"] ##teamcity[testStarted name='The NO_FAIL macro reports a failure but does not fail the test'] ##teamcity[testFinished name='The NO_FAIL macro reports a failure but does not fail the test' duration="{duration}"] ##teamcity[testStarted name='The default listing implementation write to provided stream'] @@ -975,6 +994,8 @@ loose text artifact ##teamcity[testFinished name='tuple,tuple<>,float>' duration="{duration}"] ##teamcity[testStarted name='uniform samples'] ##teamcity[testFinished name='uniform samples' duration="{duration}"] +##teamcity[testStarted name='uniform_integer_distribution can return the bounds'] +##teamcity[testFinished name='uniform_integer_distribution can return the bounds' duration="{duration}"] ##teamcity[testStarted name='unique_ptr reimplementation: basic functionality'] ##teamcity[testFinished name='unique_ptr reimplementation: basic functionality' duration="{duration}"] ##teamcity[testStarted name='vec> -> toString'] diff --git a/external_imported/Catch2/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt b/external_imported/Catch2/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt index 77f70a630..24ed5d988 100644 --- a/external_imported/Catch2/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt +++ b/external_imported/Catch2/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt @@ -299,10 +299,11 @@ ##teamcity[testFinished name='Default scale is invisible to comparison' duration="{duration}"] ##teamcity[testStarted name='Directly creating an EnumInfo'] ##teamcity[testFinished name='Directly creating an EnumInfo' duration="{duration}"] +##teamcity[testStarted name='Empty generators can SKIP in constructor'] +##teamcity[testIgnored name='Empty generators can SKIP in constructor' message='Skip.tests.cpp:|n...............................................................................|n|nSkip.tests.cpp:|nexplicit skip with message:|n "This generator is empty"'] +##teamcity[testFinished name='Empty generators can SKIP in constructor' duration="{duration}"] ##teamcity[testStarted name='Empty stream name opens cout stream'] ##teamcity[testFinished name='Empty stream name opens cout stream' duration="{duration}"] -##teamcity[testStarted name='Empty tag is not allowed'] -##teamcity[testFinished name='Empty tag is not allowed' duration="{duration}"] ##teamcity[testStarted name='EndsWith string matcher'] ##teamcity[testFailed name='EndsWith string matcher' message='Matchers.tests.cpp:|n...............................................................................|n|nMatchers.tests.cpp:|nexpression failed|n CHECK_THAT( testStringForMatching(), EndsWith( "Substring" ) )|nwith expansion:|n "this string contains |'abc|' as a substring" ends with: "Substring"|n'] ##teamcity[testFailed name='EndsWith string matcher' message='Matchers.tests.cpp:|nexpression failed|n CHECK_THAT( testStringForMatching(), EndsWith( "this", Catch::CaseSensitive::No ) )|nwith expansion:|n "this string contains |'abc|' as a substring" ends with: "this" (case insensitive)|n'] @@ -376,6 +377,8 @@ ##teamcity[testFinished name='Floating point matchers: double' duration="{duration}"] ##teamcity[testStarted name='Floating point matchers: float'] ##teamcity[testFinished name='Floating point matchers: float' duration="{duration}"] +##teamcity[testStarted name='GENERATE can combine literals and generators'] +##teamcity[testFinished name='GENERATE can combine literals and generators' duration="{duration}"] ##teamcity[testStarted name='Generators -- adapters'] ##teamcity[testFinished name='Generators -- adapters' duration="{duration}"] ##teamcity[testStarted name='Generators -- simple'] @@ -392,6 +395,9 @@ ##teamcity[testFinished name='Hashing different test cases produces different result' duration="{duration}"] ##teamcity[testStarted name='Hashing test case produces same hash across multiple calls'] ##teamcity[testFinished name='Hashing test case produces same hash across multiple calls' duration="{duration}"] +##teamcity[testStarted name='INFO and UNSCOPED_INFO can stream multiple arguments'] +##teamcity[testFailed name='INFO and UNSCOPED_INFO can stream multiple arguments' message='Message.tests.cpp:|n...............................................................................|n|nMessage.tests.cpp:|nexplicit failure with messages:|n "This info has multiple parts."|n "This unscoped info has multiple parts."|n "Show infos!"'] +##teamcity[testFinished name='INFO and UNSCOPED_INFO can stream multiple arguments' duration="{duration}"] ##teamcity[testStarted name='INFO and WARN do not abort tests'] ##teamcity[testFinished name='INFO and WARN do not abort tests' duration="{duration}"] ##teamcity[testStarted name='INFO gets logged on failure'] @@ -404,6 +410,9 @@ ##teamcity[testStarted name='INFO is reset for each loop'] ##teamcity[testFailed name='INFO is reset for each loop' message='Message.tests.cpp:|n...............................................................................|n|nMessage.tests.cpp:|nexpression failed with messages:|n "current counter 10"|n "i := 10"|n REQUIRE( i < 10 )|nwith expansion:|n 10 < 10|n'] ##teamcity[testFinished name='INFO is reset for each loop' duration="{duration}"] +##teamcity[testStarted name='Incomplete AssertionHandler'] +##teamcity[testIgnored name='Incomplete AssertionHandler' message='AssertionHandler.tests.cpp:|n...............................................................................|n|nAssertionHandler.tests.cpp:|nunexpected exception with message:|n "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE"|n REQUIRE( Dummy )|nwith expansion:|n Dummy|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testFinished name='Incomplete AssertionHandler' duration="{duration}"] ##teamcity[testStarted name='Inequality checks that should fail'] ##teamcity[testIgnored name='Inequality checks that should fail' message='Condition.tests.cpp:|n...............................................................................|n|nCondition.tests.cpp:|nexpression failed|n CHECK( data.int_seven != 7 )|nwith expansion:|n 7 != 7|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testIgnored name='Inequality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one != Approx( 9.1f ) )|nwith expansion:|n 9.1f != Approx( 9.1000003815 )|n- failure ignore as test marked as |'ok to fail|'|n'] @@ -413,6 +422,10 @@ ##teamcity[testFinished name='Inequality checks that should fail' duration="{duration}"] ##teamcity[testStarted name='Inequality checks that should succeed'] ##teamcity[testFinished name='Inequality checks that should succeed' duration="{duration}"] +##teamcity[testStarted name='JsonWriter'] +##teamcity[testFinished name='JsonWriter' duration="{duration}"] +##teamcity[testStarted name='JsonWriter escapes charaters in strings properly'] +##teamcity[testFinished name='JsonWriter escapes charaters in strings properly' duration="{duration}"] ##teamcity[testStarted name='Lambdas in assertions'] ##teamcity[testFinished name='Lambdas in assertions' duration="{duration}"] ##teamcity[testStarted name='Less-than inequalities with different epsilons'] @@ -638,6 +651,12 @@ ##teamcity[testStarted name='Testing checked-if 3'] ##teamcity[testIgnored name='Testing checked-if 3' message='Misc.tests.cpp:|n...............................................................................|n|nMisc.tests.cpp:|nexplicit failure- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testFinished name='Testing checked-if 3' duration="{duration}"] +##teamcity[testStarted name='Testing checked-if 4'] +##teamcity[testIgnored name='Testing checked-if 4' message='Misc.tests.cpp:|n...............................................................................|n|nMisc.tests.cpp:|nunexpected exception with message:|n "Uncaught exception should fail!"|n {Unknown expression after the reported line}|nwith expansion:|n {Unknown expression after the reported line}|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testFinished name='Testing checked-if 4' duration="{duration}"] +##teamcity[testStarted name='Testing checked-if 5'] +##teamcity[testIgnored name='Testing checked-if 5' message='Misc.tests.cpp:|n...............................................................................|n|nMisc.tests.cpp:|nunexpected exception with message:|n "Uncaught exception should fail!"|n {Unknown expression after the reported line}|nwith expansion:|n {Unknown expression after the reported line}|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testFinished name='Testing checked-if 5' duration="{duration}"] ##teamcity[testStarted name='The NO_FAIL macro reports a failure but does not fail the test'] ##teamcity[testFinished name='The NO_FAIL macro reports a failure but does not fail the test' duration="{duration}"] ##teamcity[testStarted name='The default listing implementation write to provided stream'] @@ -974,6 +993,8 @@ ##teamcity[testFinished name='tuple,tuple<>,float>' duration="{duration}"] ##teamcity[testStarted name='uniform samples'] ##teamcity[testFinished name='uniform samples' duration="{duration}"] +##teamcity[testStarted name='uniform_integer_distribution can return the bounds'] +##teamcity[testFinished name='uniform_integer_distribution can return the bounds' duration="{duration}"] ##teamcity[testStarted name='unique_ptr reimplementation: basic functionality'] ##teamcity[testFinished name='unique_ptr reimplementation: basic functionality' duration="{duration}"] ##teamcity[testStarted name='vec> -> toString'] diff --git a/external_imported/Catch2/tests/SelfTest/Baselines/xml.sw.approved.txt b/external_imported/Catch2/tests/SelfTest/Baselines/xml.sw.approved.txt index 6a0d1587c..be57798bf 100644 --- a/external_imported/Catch2/tests/SelfTest/Baselines/xml.sw.approved.txt +++ b/external_imported/Catch2/tests/SelfTest/Baselines/xml.sw.approved.txt @@ -1,5 +1,5 @@ - + @@ -77,10 +77,10 @@ - + uarr := "123" - + sarr := "456" @@ -91,10 +91,10 @@ 0 == 0 - + uarr := "123" - + sarr := "456" @@ -128,11 +128,11 @@ - + This info message starts with a linebreak - + This warning message starts with a linebreak @@ -384,91 +384,91 @@ Nor would this
- + i := 1 - + j := 3 - + k := 5
- + i := 1 - + j := 3 - + k := 6
- + i := 1 - + j := 4 - + k := 5 - + i := 1 - + j := 4 - + k := 6
- + i := 2 - + j := 3 - + k := 5
- + i := 2 - + j := 3 - + k := 6
- + i := 2 - + j := 4 - + k := 5 - + i := 2 - + j := 4 - + k := 6 @@ -667,7 +667,7 @@ Nor would this
- + failure to init @@ -675,7 +675,7 @@ Nor would this
- + answer := 42 @@ -684,7 +684,7 @@ Nor would this
- + answer := 42 @@ -701,7 +701,7 @@ Nor would this
- + answer := 42 @@ -806,7 +806,7 @@ Nor would this - + dummy := 0 @@ -2886,92 +2886,92 @@ Nor would this - + a := 1 - + b := 2 - + c := 3 - + a + b := 3 - + a+b := 3 - + c > b := true - + a == 1 := true - - std::vector<int>{1, 2, 3}[0, 1, 2] := 3 + + custom_index_op<int>{1, 2, 3}[0, 1, 2] := 0 - - std::vector<int>{1, 2, 3}[(0, 1)] := 2 + + custom_index_op<int>{1, 2, 3}[(0, 1)] := 0 - - std::vector<int>{1, 2, 3}[0] := 1 + + custom_index_op<int>{1, 2, 3}[0] := 0 - + (helper_1436<int, int>{12, -12}) := { 12, -12 } - + (helper_1436<int, int>(-12, 12)) := { -12, 12 } - + (1, 2) := 2 - + (2, 3) := 3 - + ("comma, in string", "escaped, \", ") := "escaped, ", " - + "single quote in string,'," := "single quote in string,'," - + "some escapes, \\,\\\\" := "some escapes, \,\\" - + "some, ), unmatched, } prenheses {[<" := "some, ), unmatched, } prenheses {[<" - + '"' := '"' - + '\'' := ''' - + ',' := ',' - + '}' := '}' - + ')' := ')' - + '(' := '(' - + '{' := '{'
- + i := 2 @@ -2985,7 +2985,7 @@ Nor would this
- + 3 @@ -4364,6 +4364,12 @@ C + + + This generator is empty + + + @@ -4375,17 +4381,6 @@ C - - - - Catch::TestCaseInfo( "", { "fake test name", "[]" }, dummySourceLineInfo ) - - - Catch::TestCaseInfo( "", { "fake test name", "[]" }, dummySourceLineInfo ) - - - - @@ -4977,7 +4972,7 @@ C This is a failure - + This message appears in the output @@ -5588,6 +5583,41 @@ C
+ + + + i % 2 == 0 + + + 0 == 0 + + + + + i % 2 == 0 + + + 0 == 0 + + + + + i % 2 == 0 + + + 0 == 0 + + + + + i % 2 == 0 + + + 0 == 0 + + + +
@@ -7246,7 +7276,7 @@ C
- + Current expected value is -1 @@ -7257,7 +7287,7 @@ C -1.0 == Approx( -1.0 ) - + Current expected value is -1 @@ -7268,7 +7298,7 @@ C true - + Current expected value is -0.9 @@ -7279,7 +7309,7 @@ C -0.9 == Approx( -0.9 ) - + Current expected value is -0.9 @@ -7290,7 +7320,7 @@ C true - + Current expected value is -0.8 @@ -7301,7 +7331,7 @@ C -0.8 == Approx( -0.8 ) - + Current expected value is -0.8 @@ -7312,7 +7342,7 @@ C true - + Current expected value is -0.7 @@ -7323,7 +7353,7 @@ C -0.7 == Approx( -0.7 ) - + Current expected value is -0.7 @@ -7334,7 +7364,7 @@ C true - + Current expected value is -0.6 @@ -7345,7 +7375,7 @@ C -0.6 == Approx( -0.6 ) - + Current expected value is -0.6 @@ -7356,7 +7386,7 @@ C true - + Current expected value is -0.5 @@ -7367,7 +7397,7 @@ C -0.5 == Approx( -0.5 ) - + Current expected value is -0.5 @@ -7378,7 +7408,7 @@ C true - + Current expected value is -0.4 @@ -7389,7 +7419,7 @@ C -0.4 == Approx( -0.4 ) - + Current expected value is -0.4 @@ -7400,7 +7430,7 @@ C true - + Current expected value is -0.3 @@ -7411,7 +7441,7 @@ C -0.3 == Approx( -0.3 ) - + Current expected value is -0.3 @@ -7422,7 +7452,7 @@ C true - + Current expected value is -0.2 @@ -7433,7 +7463,7 @@ C -0.2 == Approx( -0.2 ) - + Current expected value is -0.2 @@ -7444,7 +7474,7 @@ C true - + Current expected value is -0.1 @@ -7455,7 +7485,7 @@ C -0.1 == Approx( -0.1 ) - + Current expected value is -0.1 @@ -7466,7 +7496,7 @@ C true - + Current expected value is -1.38778e-16 @@ -7477,7 +7507,7 @@ C -0.0 == Approx( -0.0 ) - + Current expected value is -1.38778e-16 @@ -7488,7 +7518,7 @@ C true - + Current expected value is 0.1 @@ -7499,7 +7529,7 @@ C 0.1 == Approx( 0.1 ) - + Current expected value is 0.1 @@ -7510,7 +7540,7 @@ C true - + Current expected value is 0.2 @@ -7521,7 +7551,7 @@ C 0.2 == Approx( 0.2 ) - + Current expected value is 0.2 @@ -7532,7 +7562,7 @@ C true - + Current expected value is 0.3 @@ -7543,7 +7573,7 @@ C 0.3 == Approx( 0.3 ) - + Current expected value is 0.3 @@ -7554,7 +7584,7 @@ C true - + Current expected value is 0.4 @@ -7565,7 +7595,7 @@ C 0.4 == Approx( 0.4 ) - + Current expected value is 0.4 @@ -7576,7 +7606,7 @@ C true - + Current expected value is 0.5 @@ -7587,7 +7617,7 @@ C 0.5 == Approx( 0.5 ) - + Current expected value is 0.5 @@ -7598,7 +7628,7 @@ C true - + Current expected value is 0.6 @@ -7609,7 +7639,7 @@ C 0.6 == Approx( 0.6 ) - + Current expected value is 0.6 @@ -7620,7 +7650,7 @@ C true - + Current expected value is 0.7 @@ -7631,7 +7661,7 @@ C 0.7 == Approx( 0.7 ) - + Current expected value is 0.7 @@ -7642,7 +7672,7 @@ C true - + Current expected value is 0.8 @@ -7653,7 +7683,7 @@ C 0.8 == Approx( 0.8 ) - + Current expected value is 0.8 @@ -7664,7 +7694,7 @@ C true - + Current expected value is 0.9 @@ -7675,7 +7705,7 @@ C 0.9 == Approx( 0.9 ) - + Current expected value is 0.9 @@ -7714,7 +7744,7 @@ C
- + Current expected value is -1 @@ -7725,7 +7755,7 @@ C -1.0 == Approx( -1.0 ) - + Current expected value is -1 @@ -7736,7 +7766,7 @@ C true - + Current expected value is -0.7 @@ -7747,7 +7777,7 @@ C -0.7 == Approx( -0.7 ) - + Current expected value is -0.7 @@ -7758,7 +7788,7 @@ C true - + Current expected value is -0.4 @@ -7769,7 +7799,7 @@ C -0.4 == Approx( -0.4 ) - + Current expected value is -0.4 @@ -7780,7 +7810,7 @@ C true - + Current expected value is -0.1 @@ -7791,7 +7821,7 @@ C -0.1 == Approx( -0.1 ) - + Current expected value is -0.1 @@ -7802,7 +7832,7 @@ C true - + Current expected value is 0.2 @@ -7813,7 +7843,7 @@ C 0.2 == Approx( 0.2 ) - + Current expected value is 0.2 @@ -7824,7 +7854,7 @@ C true - + Current expected value is 0.5 @@ -7835,7 +7865,7 @@ C 0.5 == Approx( 0.5 ) - + Current expected value is 0.5 @@ -7866,7 +7896,7 @@ C
- + Current expected value is -1 @@ -7877,7 +7907,7 @@ C -1.0 == Approx( -1.0 ) - + Current expected value is -1 @@ -7888,7 +7918,7 @@ C true - + Current expected value is -0.7 @@ -7899,7 +7929,7 @@ C -0.7 == Approx( -0.7 ) - + Current expected value is -0.7 @@ -7910,7 +7940,7 @@ C true - + Current expected value is -0.4 @@ -7921,7 +7951,7 @@ C -0.4 == Approx( -0.4 ) - + Current expected value is -0.4 @@ -7932,7 +7962,7 @@ C true - + Current expected value is -0.1 @@ -7943,7 +7973,7 @@ C -0.1 == Approx( -0.1 ) - + Current expected value is -0.1 @@ -7954,7 +7984,7 @@ C true - + Current expected value is 0.2 @@ -7965,7 +7995,7 @@ C 0.2 == Approx( 0.2 ) - + Current expected value is 0.2 @@ -7976,7 +8006,7 @@ C true - + Current expected value is 0.5 @@ -7987,7 +8017,7 @@ C 0.5 == Approx( 0.5 ) - + Current expected value is 0.5 @@ -8376,20 +8406,32 @@ C + + + This info has multiple parts. + + + This unscoped info has multiple parts. + + + Show infos! + + + - + this is a message - + this is a warning - + this message should be logged - + so should this @@ -8403,7 +8445,7 @@ C - + this message may be logged later @@ -8414,10 +8456,10 @@ C 2 == 2 - + this message may be logged later - + this message should be logged @@ -8428,13 +8470,13 @@ C 2 == 1 - + this message may be logged later - + this message should be logged - + and this, but later @@ -8445,16 +8487,16 @@ C 2 == 0 - + this message may be logged later - + this message should be logged - + and this, but later - + but not this @@ -8468,10 +8510,10 @@ C - + current counter 0 - + i := 0 @@ -8482,10 +8524,10 @@ C 0 < 10 - + current counter 1 - + i := 1 @@ -8496,10 +8538,10 @@ C 1 < 10 - + current counter 2 - + i := 2 @@ -8510,10 +8552,10 @@ C 2 < 10 - + current counter 3 - + i := 3 @@ -8524,10 +8566,10 @@ C 3 < 10 - + current counter 4 - + i := 4 @@ -8538,10 +8580,10 @@ C 4 < 10 - + current counter 5 - + i := 5 @@ -8552,10 +8594,10 @@ C 5 < 10 - + current counter 6 - + i := 6 @@ -8566,10 +8608,10 @@ C 6 < 10 - + current counter 7 - + i := 7 @@ -8580,10 +8622,10 @@ C 7 < 10 - + current counter 8 - + i := 8 @@ -8594,10 +8636,10 @@ C 8 < 10 - + current counter 9 - + i := 9 @@ -8608,10 +8650,10 @@ C 9 < 10 - + current counter 10 - + i := 10 @@ -8624,6 +8666,20 @@ C + + + + Dummy + + + Dummy + + + Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE + + + + @@ -8758,6 +8814,277 @@ C + +
+ + + stream.str() == "" + + + "" == "" + + + +
+
+ + + stream.str() == "{\n}" + + + "{ +}" +== +"{ +}" + + + +
+
+ + + stream.str(), ContainsSubstring( "\"int\": 1," ) && ContainsSubstring( "\"double\": 1.5," ) && ContainsSubstring( "\"true\": true," ) && ContainsSubstring( "\"false\": false," ) && ContainsSubstring( "\"string\": \"this is a string\"," ) && ContainsSubstring( "\"array\": [\n 1,\n 2\n ]\n}" ) + + + "{ + "int": 1, + "double": 1.5, + "true": true, + "false": false, + "string": "this is a string", + "array": [ + 1, + 2 + ] +}" ( contains: ""int": 1," and contains: ""double": 1.5," and contains: ""true": true," and contains: ""false": false," and contains: ""string": "this is a string"," and contains: ""array": [ + 1, + 2 + ] +}" ) + + + +
+
+ + + stream.str(), ContainsSubstring( "\"empty_object\": {\n }," ) && ContainsSubstring( "\"fully_object\": {\n \"key\": 1\n }" ) + + + "{ + "empty_object": { + }, + "fully_object": { + "key": 1 + } +}" ( contains: ""empty_object": { + }," and contains: ""fully_object": { + "key": 1 + }" ) + + + +
+
+ + + stream.str() == "[\n]" + + + "[ +]" +== +"[ +]" + + + +
+
+ + + stream.str() == "[\n 1,\n 1.5,\n true,\n false,\n \"this is a string\",\n {\n \"object\": 42\n },\n [\n \"array\",\n 42.5\n ]\n]" + + + "[ + 1, + 1.5, + true, + false, + "this is a string", + { + "object": 42 + }, + [ + "array", + 42.5 + ] +]" +== +"[ + 1, + 1.5, + true, + false, + "this is a string", + { + "object": 42 + }, + [ + "array", + 42.5 + ] +]" + + + +
+
+ + + stream.str() == "{\n}" + + + "{ +}" +== +"{ +}" + + + +
+
+ + + stream.str() == "[\n]" + + + "[ +]" +== +"[ +]" + + + +
+
+ + + stream.str() == "\"custom\"" + + + ""custom"" == ""custom"" + + + +
+ +
+ +
+ + + sstream.str() == "\"\\\"\"" + + + ""\""" == ""\""" + + + +
+
+ + + sstream.str() == "\"\\\\\"" + + + ""\\"" == ""\\"" + + + +
+
+ + + sstream.str() == "\"/\"" + + + ""/"" == ""/"" + + + +
+
+ + + sstream.str() == "\"\\b\"" + + + ""\b"" == ""\b"" + + + +
+
+ + + sstream.str() == "\"\\f\"" + + + ""\f"" == ""\f"" + + + +
+
+ + + sstream.str() == "\"\\n\"" + + + ""\n"" == ""\n"" + + + +
+
+ + + sstream.str() == "\"\\r\"" + + + ""\r"" == ""\r"" + + + +
+
+ + + sstream.str() == "\"\\t\"" + + + ""\t"" == ""\t"" + + + +
+
+ + + sstream.str() == "\"\\\\/\\t\\r\\n\"" + + + ""\\/\t\r\n"" == ""\\/\t\r\n"" + + + +
+ +
@@ -9219,7 +9546,7 @@ C - + This one ran @@ -10005,7 +10332,7 @@ C - + tagString := "[tag with spaces]" @@ -10016,7 +10343,7 @@ C true - + tagString := "[tag with spaces]" @@ -10027,7 +10354,7 @@ C true - + tagString := "[tag with spaces]" @@ -10038,7 +10365,7 @@ C true - + tagString := "[I said "good day" sir!]" @@ -10049,7 +10376,7 @@ C true - + tagString := "[I said "good day" sir!]" @@ -10060,7 +10387,7 @@ C true - + tagString := "[I said "good day" sir!]" @@ -10471,7 +10798,7 @@ C
- + result.errorMessage() := "" @@ -10482,7 +10809,7 @@ C {?} - + result.errorMessage() := "" @@ -10499,7 +10826,7 @@ C
- + result.errorMessage() := "" @@ -10510,7 +10837,7 @@ C {?} - + result.errorMessage() := "" @@ -10527,7 +10854,7 @@ C
- + result.errorMessage() := "" @@ -10538,7 +10865,7 @@ C {?} - + result.errorMessage() := "" @@ -10577,7 +10904,7 @@ C
- + result.errorMessage() := "" @@ -10588,7 +10915,7 @@ C {?} - + result.errorMessage() := "" @@ -10605,7 +10932,7 @@ C
- + result.errorMessage() := "" @@ -10616,7 +10943,7 @@ C {?} - + result.errorMessage() := "" @@ -11441,7 +11768,7 @@ C
- + Tested reporter: Automake @@ -11467,7 +11794,7 @@ C
- + Tested reporter: Automake @@ -11492,7 +11819,7 @@ C
- + Tested reporter: Automake @@ -11519,7 +11846,7 @@ C
- + Tested reporter: compact @@ -11545,7 +11872,7 @@ C
- + Tested reporter: compact @@ -11570,7 +11897,7 @@ C
- + Tested reporter: compact @@ -11597,7 +11924,7 @@ C
- + Tested reporter: console @@ -11623,7 +11950,7 @@ C
- + Tested reporter: console @@ -11648,7 +11975,7 @@ C
- + Tested reporter: console @@ -11674,8 +12001,122 @@ C !false +
+ + Tested reporter: JSON + + + + listingString, ContainsSubstring("fakeTag"s) + + + "{ + "version": 1, + "metadata": { + "name": "", + "rng-seed": 1234, + "catch2-version": "" + }, + "listings": { + "tags": [ + { + "aliases": [ + "fakeTag" + ], + "count": 1 + } + ]" contains: "fakeTag" + + + +
+ + + !(factories.empty()) + + + !false + + +
+ + Tested reporter: JSON + + + + listingString, ContainsSubstring("fake reporter"s) + + + "{ + "version": 1, + "metadata": { + "name": "", + "rng-seed": 1234, + "catch2-version": "" + }, + "listings": { + "reporters": [ + { + "name": "fake reporter", + "description": "fake description" + } + ]" contains: "fake reporter" + + + +
+ + + !(factories.empty()) + + + !false + + +
+ + Tested reporter: JSON + + + + listingString, ContainsSubstring( "fake test name"s ) && ContainsSubstring( "fakeTestTag"s ) + + + "{ + "version": 1, + "metadata": { + "name": "", + "rng-seed": 1234, + "catch2-version": "" + }, + "listings": { + "tests": [ + { + "name": "fake test name", + "class-name": "", + "tags": [ + "fakeTestTag" + ], + "source-location": { + "filename": "fake-file.cpp", + "line": 123456789 + } + } + ]" ( contains: "fake test name" and contains: "fakeTestTag" ) + + + +
+ + + !(factories.empty()) + + + !false + +
- + Tested reporter: JUnit @@ -11702,7 +12143,7 @@ All available tags:
- + Tested reporter: JUnit @@ -11728,7 +12169,7 @@ Available reporters:
- + Tested reporter: JUnit @@ -11756,7 +12197,7 @@ All available test cases:
- + Tested reporter: SonarQube @@ -11783,7 +12224,7 @@ All available tags:
- + Tested reporter: SonarQube @@ -11809,7 +12250,7 @@ Available reporters:
- + Tested reporter: SonarQube @@ -11837,7 +12278,7 @@ All available test cases:
- + Tested reporter: TAP @@ -11863,7 +12304,7 @@ All available test cases:
- + Tested reporter: TAP @@ -11888,7 +12329,7 @@ All available test cases:
- + Tested reporter: TAP @@ -11915,7 +12356,7 @@ All available test cases:
- + Tested reporter: TeamCity @@ -11941,7 +12382,7 @@ All available test cases:
- + Tested reporter: TeamCity @@ -11966,7 +12407,7 @@ All available test cases:
- + Tested reporter: TeamCity @@ -11993,7 +12434,7 @@ All available test cases:
- + Tested reporter: XML @@ -12023,7 +12464,7 @@ All available test cases:
- + Tested reporter: XML @@ -12051,7 +12492,7 @@ All available test cases:
- + Tested reporter: XML @@ -14552,6 +14993,50 @@ Message from section two + + + + true + + + true + + + + + {Unknown expression after the reported line} + + + {Unknown expression after the reported line} + + + Uncaught exception should fail! + + + + + + + + false + + + false + + + + + {Unknown expression after the reported line} + + + {Unknown expression after the reported line} + + + Uncaught exception should fail! + + + + @@ -15670,7 +16155,7 @@ There is no extra whitespace here
-
+
data, !AllTrue() @@ -15712,7 +16197,7 @@ There is no extra whitespace here
-
+
data, !AllTrue() @@ -16020,7 +16505,7 @@ There is no extra whitespace here
-
+
data, AnyTrue() @@ -16062,7 +16547,7 @@ There is no extra whitespace here
-
+
data, AnyTrue() @@ -16370,7 +16855,7 @@ There is no extra whitespace here
-
+
data, !NoneTrue() @@ -16412,7 +16897,7 @@ There is no extra whitespace here
-
+
data, !NoneTrue() @@ -18766,7 +19251,7 @@ loose text artifact - + Testing if fib[0] (1) is even @@ -18777,7 +19262,7 @@ loose text artifact 1 == 0 - + Testing if fib[1] (1) is even @@ -18788,7 +19273,7 @@ loose text artifact 1 == 0 - + Testing if fib[2] (2) is even @@ -18799,7 +19284,7 @@ loose text artifact 0 == 0 - + Testing if fib[3] (3) is even @@ -18810,7 +19295,7 @@ loose text artifact 1 == 0 - + Testing if fib[4] (5) is even @@ -18821,7 +19306,7 @@ loose text artifact 1 == 0 - + Testing if fib[5] (8) is even @@ -18832,7 +19317,7 @@ loose text artifact 0 == 0 - + Testing if fib[6] (13) is even @@ -18843,7 +19328,7 @@ loose text artifact 1 == 0 - + Testing if fib[7] (21) is even @@ -18982,22 +19467,22 @@ loose text artifact - + info - + unscoped info - + and warn may mix - + info - + unscoped info - + they are not cleared after warnings @@ -19204,7 +19689,7 @@ b1! - + this MAY be seen only for the FIRST assertion IF info is printed for passing assertions @@ -19215,7 +19700,7 @@ b1! true - + this MAY be seen only for the SECOND assertion IF info is printed for passing assertions @@ -19226,7 +19711,7 @@ b1! true - + this SHOULD be seen @@ -19362,7 +19847,7 @@ b1! - + this MAY be seen IF info is printed for passing assertions @@ -19376,10 +19861,10 @@ b1! - + this SHOULD be seen - + this SHOULD also be seen @@ -19393,7 +19878,7 @@ b1! - + this SHOULD be seen only ONCE @@ -19412,7 +19897,7 @@ b1! true - + this MAY also be seen only ONCE IF info is printed for passing assertions @@ -19895,7 +20380,7 @@ b1! - + 3 @@ -19909,10 +20394,10 @@ b1! - + hi - + i := 7 @@ -19970,16 +20455,16 @@ b1! - + Count 1 to 3... - + 1 - + 2 - + 3 @@ -19990,16 +20475,16 @@ b1! false - + Count 4 to 6... - + 4 - + 5 - + 6 @@ -20649,6 +21134,25 @@ b1! + + + + dist.a() == -10 + + + -10 == -10 + + + + + dist.b() == 10 + + + 10 == 10 + + + +
@@ -21203,6 +21707,6 @@ b1!
- - + + diff --git a/external_imported/Catch2/tests/SelfTest/Baselines/xml.sw.multi.approved.txt b/external_imported/Catch2/tests/SelfTest/Baselines/xml.sw.multi.approved.txt index c6ddfc808..08ff6c437 100644 --- a/external_imported/Catch2/tests/SelfTest/Baselines/xml.sw.multi.approved.txt +++ b/external_imported/Catch2/tests/SelfTest/Baselines/xml.sw.multi.approved.txt @@ -1,5 +1,5 @@ - + @@ -77,10 +77,10 @@ - + uarr := "123" - + sarr := "456" @@ -91,10 +91,10 @@ 0 == 0 - + uarr := "123" - + sarr := "456" @@ -128,11 +128,11 @@ - + This info message starts with a linebreak - + This warning message starts with a linebreak @@ -384,91 +384,91 @@ Nor would this
- + i := 1 - + j := 3 - + k := 5
- + i := 1 - + j := 3 - + k := 6
- + i := 1 - + j := 4 - + k := 5 - + i := 1 - + j := 4 - + k := 6
- + i := 2 - + j := 3 - + k := 5
- + i := 2 - + j := 3 - + k := 6
- + i := 2 - + j := 4 - + k := 5 - + i := 2 - + j := 4 - + k := 6 @@ -667,7 +667,7 @@ Nor would this
- + failure to init @@ -675,7 +675,7 @@ Nor would this
- + answer := 42 @@ -684,7 +684,7 @@ Nor would this
- + answer := 42 @@ -701,7 +701,7 @@ Nor would this
- + answer := 42 @@ -806,7 +806,7 @@ Nor would this - + dummy := 0 @@ -2886,92 +2886,92 @@ Nor would this - + a := 1 - + b := 2 - + c := 3 - + a + b := 3 - + a+b := 3 - + c > b := true - + a == 1 := true - - std::vector<int>{1, 2, 3}[0, 1, 2] := 3 + + custom_index_op<int>{1, 2, 3}[0, 1, 2] := 0 - - std::vector<int>{1, 2, 3}[(0, 1)] := 2 + + custom_index_op<int>{1, 2, 3}[(0, 1)] := 0 - - std::vector<int>{1, 2, 3}[0] := 1 + + custom_index_op<int>{1, 2, 3}[0] := 0 - + (helper_1436<int, int>{12, -12}) := { 12, -12 } - + (helper_1436<int, int>(-12, 12)) := { -12, 12 } - + (1, 2) := 2 - + (2, 3) := 3 - + ("comma, in string", "escaped, \", ") := "escaped, ", " - + "single quote in string,'," := "single quote in string,'," - + "some escapes, \\,\\\\" := "some escapes, \,\\" - + "some, ), unmatched, } prenheses {[<" := "some, ), unmatched, } prenheses {[<" - + '"' := '"' - + '\'' := ''' - + ',' := ',' - + '}' := '}' - + ')' := ')' - + '(' := '(' - + '{' := '{'
- + i := 2 @@ -2985,7 +2985,7 @@ Nor would this
- + 3 @@ -4364,6 +4364,12 @@ C + + + This generator is empty + + + @@ -4375,17 +4381,6 @@ C - - - - Catch::TestCaseInfo( "", { "fake test name", "[]" }, dummySourceLineInfo ) - - - Catch::TestCaseInfo( "", { "fake test name", "[]" }, dummySourceLineInfo ) - - - - @@ -4977,7 +4972,7 @@ C This is a failure - + This message appears in the output @@ -5588,6 +5583,41 @@ C
+ + + + i % 2 == 0 + + + 0 == 0 + + + + + i % 2 == 0 + + + 0 == 0 + + + + + i % 2 == 0 + + + 0 == 0 + + + + + i % 2 == 0 + + + 0 == 0 + + + +
@@ -7246,7 +7276,7 @@ C
- + Current expected value is -1 @@ -7257,7 +7287,7 @@ C -1.0 == Approx( -1.0 ) - + Current expected value is -1 @@ -7268,7 +7298,7 @@ C true - + Current expected value is -0.9 @@ -7279,7 +7309,7 @@ C -0.9 == Approx( -0.9 ) - + Current expected value is -0.9 @@ -7290,7 +7320,7 @@ C true - + Current expected value is -0.8 @@ -7301,7 +7331,7 @@ C -0.8 == Approx( -0.8 ) - + Current expected value is -0.8 @@ -7312,7 +7342,7 @@ C true - + Current expected value is -0.7 @@ -7323,7 +7353,7 @@ C -0.7 == Approx( -0.7 ) - + Current expected value is -0.7 @@ -7334,7 +7364,7 @@ C true - + Current expected value is -0.6 @@ -7345,7 +7375,7 @@ C -0.6 == Approx( -0.6 ) - + Current expected value is -0.6 @@ -7356,7 +7386,7 @@ C true - + Current expected value is -0.5 @@ -7367,7 +7397,7 @@ C -0.5 == Approx( -0.5 ) - + Current expected value is -0.5 @@ -7378,7 +7408,7 @@ C true - + Current expected value is -0.4 @@ -7389,7 +7419,7 @@ C -0.4 == Approx( -0.4 ) - + Current expected value is -0.4 @@ -7400,7 +7430,7 @@ C true - + Current expected value is -0.3 @@ -7411,7 +7441,7 @@ C -0.3 == Approx( -0.3 ) - + Current expected value is -0.3 @@ -7422,7 +7452,7 @@ C true - + Current expected value is -0.2 @@ -7433,7 +7463,7 @@ C -0.2 == Approx( -0.2 ) - + Current expected value is -0.2 @@ -7444,7 +7474,7 @@ C true - + Current expected value is -0.1 @@ -7455,7 +7485,7 @@ C -0.1 == Approx( -0.1 ) - + Current expected value is -0.1 @@ -7466,7 +7496,7 @@ C true - + Current expected value is -1.38778e-16 @@ -7477,7 +7507,7 @@ C -0.0 == Approx( -0.0 ) - + Current expected value is -1.38778e-16 @@ -7488,7 +7518,7 @@ C true - + Current expected value is 0.1 @@ -7499,7 +7529,7 @@ C 0.1 == Approx( 0.1 ) - + Current expected value is 0.1 @@ -7510,7 +7540,7 @@ C true - + Current expected value is 0.2 @@ -7521,7 +7551,7 @@ C 0.2 == Approx( 0.2 ) - + Current expected value is 0.2 @@ -7532,7 +7562,7 @@ C true - + Current expected value is 0.3 @@ -7543,7 +7573,7 @@ C 0.3 == Approx( 0.3 ) - + Current expected value is 0.3 @@ -7554,7 +7584,7 @@ C true - + Current expected value is 0.4 @@ -7565,7 +7595,7 @@ C 0.4 == Approx( 0.4 ) - + Current expected value is 0.4 @@ -7576,7 +7606,7 @@ C true - + Current expected value is 0.5 @@ -7587,7 +7617,7 @@ C 0.5 == Approx( 0.5 ) - + Current expected value is 0.5 @@ -7598,7 +7628,7 @@ C true - + Current expected value is 0.6 @@ -7609,7 +7639,7 @@ C 0.6 == Approx( 0.6 ) - + Current expected value is 0.6 @@ -7620,7 +7650,7 @@ C true - + Current expected value is 0.7 @@ -7631,7 +7661,7 @@ C 0.7 == Approx( 0.7 ) - + Current expected value is 0.7 @@ -7642,7 +7672,7 @@ C true - + Current expected value is 0.8 @@ -7653,7 +7683,7 @@ C 0.8 == Approx( 0.8 ) - + Current expected value is 0.8 @@ -7664,7 +7694,7 @@ C true - + Current expected value is 0.9 @@ -7675,7 +7705,7 @@ C 0.9 == Approx( 0.9 ) - + Current expected value is 0.9 @@ -7714,7 +7744,7 @@ C
- + Current expected value is -1 @@ -7725,7 +7755,7 @@ C -1.0 == Approx( -1.0 ) - + Current expected value is -1 @@ -7736,7 +7766,7 @@ C true - + Current expected value is -0.7 @@ -7747,7 +7777,7 @@ C -0.7 == Approx( -0.7 ) - + Current expected value is -0.7 @@ -7758,7 +7788,7 @@ C true - + Current expected value is -0.4 @@ -7769,7 +7799,7 @@ C -0.4 == Approx( -0.4 ) - + Current expected value is -0.4 @@ -7780,7 +7810,7 @@ C true - + Current expected value is -0.1 @@ -7791,7 +7821,7 @@ C -0.1 == Approx( -0.1 ) - + Current expected value is -0.1 @@ -7802,7 +7832,7 @@ C true - + Current expected value is 0.2 @@ -7813,7 +7843,7 @@ C 0.2 == Approx( 0.2 ) - + Current expected value is 0.2 @@ -7824,7 +7854,7 @@ C true - + Current expected value is 0.5 @@ -7835,7 +7865,7 @@ C 0.5 == Approx( 0.5 ) - + Current expected value is 0.5 @@ -7866,7 +7896,7 @@ C
- + Current expected value is -1 @@ -7877,7 +7907,7 @@ C -1.0 == Approx( -1.0 ) - + Current expected value is -1 @@ -7888,7 +7918,7 @@ C true - + Current expected value is -0.7 @@ -7899,7 +7929,7 @@ C -0.7 == Approx( -0.7 ) - + Current expected value is -0.7 @@ -7910,7 +7940,7 @@ C true - + Current expected value is -0.4 @@ -7921,7 +7951,7 @@ C -0.4 == Approx( -0.4 ) - + Current expected value is -0.4 @@ -7932,7 +7962,7 @@ C true - + Current expected value is -0.1 @@ -7943,7 +7973,7 @@ C -0.1 == Approx( -0.1 ) - + Current expected value is -0.1 @@ -7954,7 +7984,7 @@ C true - + Current expected value is 0.2 @@ -7965,7 +7995,7 @@ C 0.2 == Approx( 0.2 ) - + Current expected value is 0.2 @@ -7976,7 +8006,7 @@ C true - + Current expected value is 0.5 @@ -7987,7 +8017,7 @@ C 0.5 == Approx( 0.5 ) - + Current expected value is 0.5 @@ -8376,20 +8406,32 @@ C + + + This info has multiple parts. + + + This unscoped info has multiple parts. + + + Show infos! + + + - + this is a message - + this is a warning - + this message should be logged - + so should this @@ -8403,7 +8445,7 @@ C - + this message may be logged later @@ -8414,10 +8456,10 @@ C 2 == 2 - + this message may be logged later - + this message should be logged @@ -8428,13 +8470,13 @@ C 2 == 1 - + this message may be logged later - + this message should be logged - + and this, but later @@ -8445,16 +8487,16 @@ C 2 == 0 - + this message may be logged later - + this message should be logged - + and this, but later - + but not this @@ -8468,10 +8510,10 @@ C - + current counter 0 - + i := 0 @@ -8482,10 +8524,10 @@ C 0 < 10 - + current counter 1 - + i := 1 @@ -8496,10 +8538,10 @@ C 1 < 10 - + current counter 2 - + i := 2 @@ -8510,10 +8552,10 @@ C 2 < 10 - + current counter 3 - + i := 3 @@ -8524,10 +8566,10 @@ C 3 < 10 - + current counter 4 - + i := 4 @@ -8538,10 +8580,10 @@ C 4 < 10 - + current counter 5 - + i := 5 @@ -8552,10 +8594,10 @@ C 5 < 10 - + current counter 6 - + i := 6 @@ -8566,10 +8608,10 @@ C 6 < 10 - + current counter 7 - + i := 7 @@ -8580,10 +8622,10 @@ C 7 < 10 - + current counter 8 - + i := 8 @@ -8594,10 +8636,10 @@ C 8 < 10 - + current counter 9 - + i := 9 @@ -8608,10 +8650,10 @@ C 9 < 10 - + current counter 10 - + i := 10 @@ -8624,6 +8666,20 @@ C + + + + Dummy + + + Dummy + + + Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE + + + + @@ -8758,6 +8814,277 @@ C + +
+ + + stream.str() == "" + + + "" == "" + + + +
+
+ + + stream.str() == "{\n}" + + + "{ +}" +== +"{ +}" + + + +
+
+ + + stream.str(), ContainsSubstring( "\"int\": 1," ) && ContainsSubstring( "\"double\": 1.5," ) && ContainsSubstring( "\"true\": true," ) && ContainsSubstring( "\"false\": false," ) && ContainsSubstring( "\"string\": \"this is a string\"," ) && ContainsSubstring( "\"array\": [\n 1,\n 2\n ]\n}" ) + + + "{ + "int": 1, + "double": 1.5, + "true": true, + "false": false, + "string": "this is a string", + "array": [ + 1, + 2 + ] +}" ( contains: ""int": 1," and contains: ""double": 1.5," and contains: ""true": true," and contains: ""false": false," and contains: ""string": "this is a string"," and contains: ""array": [ + 1, + 2 + ] +}" ) + + + +
+
+ + + stream.str(), ContainsSubstring( "\"empty_object\": {\n }," ) && ContainsSubstring( "\"fully_object\": {\n \"key\": 1\n }" ) + + + "{ + "empty_object": { + }, + "fully_object": { + "key": 1 + } +}" ( contains: ""empty_object": { + }," and contains: ""fully_object": { + "key": 1 + }" ) + + + +
+
+ + + stream.str() == "[\n]" + + + "[ +]" +== +"[ +]" + + + +
+
+ + + stream.str() == "[\n 1,\n 1.5,\n true,\n false,\n \"this is a string\",\n {\n \"object\": 42\n },\n [\n \"array\",\n 42.5\n ]\n]" + + + "[ + 1, + 1.5, + true, + false, + "this is a string", + { + "object": 42 + }, + [ + "array", + 42.5 + ] +]" +== +"[ + 1, + 1.5, + true, + false, + "this is a string", + { + "object": 42 + }, + [ + "array", + 42.5 + ] +]" + + + +
+
+ + + stream.str() == "{\n}" + + + "{ +}" +== +"{ +}" + + + +
+
+ + + stream.str() == "[\n]" + + + "[ +]" +== +"[ +]" + + + +
+
+ + + stream.str() == "\"custom\"" + + + ""custom"" == ""custom"" + + + +
+ +
+ +
+ + + sstream.str() == "\"\\\"\"" + + + ""\""" == ""\""" + + + +
+
+ + + sstream.str() == "\"\\\\\"" + + + ""\\"" == ""\\"" + + + +
+
+ + + sstream.str() == "\"/\"" + + + ""/"" == ""/"" + + + +
+
+ + + sstream.str() == "\"\\b\"" + + + ""\b"" == ""\b"" + + + +
+
+ + + sstream.str() == "\"\\f\"" + + + ""\f"" == ""\f"" + + + +
+
+ + + sstream.str() == "\"\\n\"" + + + ""\n"" == ""\n"" + + + +
+
+ + + sstream.str() == "\"\\r\"" + + + ""\r"" == ""\r"" + + + +
+
+ + + sstream.str() == "\"\\t\"" + + + ""\t"" == ""\t"" + + + +
+
+ + + sstream.str() == "\"\\\\/\\t\\r\\n\"" + + + ""\\/\t\r\n"" == ""\\/\t\r\n"" + + + +
+ +
@@ -9219,7 +9546,7 @@ C - + This one ran @@ -10005,7 +10332,7 @@ C - + tagString := "[tag with spaces]" @@ -10016,7 +10343,7 @@ C true - + tagString := "[tag with spaces]" @@ -10027,7 +10354,7 @@ C true - + tagString := "[tag with spaces]" @@ -10038,7 +10365,7 @@ C true - + tagString := "[I said "good day" sir!]" @@ -10049,7 +10376,7 @@ C true - + tagString := "[I said "good day" sir!]" @@ -10060,7 +10387,7 @@ C true - + tagString := "[I said "good day" sir!]" @@ -10471,7 +10798,7 @@ C
- + result.errorMessage() := "" @@ -10482,7 +10809,7 @@ C {?} - + result.errorMessage() := "" @@ -10499,7 +10826,7 @@ C
- + result.errorMessage() := "" @@ -10510,7 +10837,7 @@ C {?} - + result.errorMessage() := "" @@ -10527,7 +10854,7 @@ C
- + result.errorMessage() := "" @@ -10538,7 +10865,7 @@ C {?} - + result.errorMessage() := "" @@ -10577,7 +10904,7 @@ C
- + result.errorMessage() := "" @@ -10588,7 +10915,7 @@ C {?} - + result.errorMessage() := "" @@ -10605,7 +10932,7 @@ C
- + result.errorMessage() := "" @@ -10616,7 +10943,7 @@ C {?} - + result.errorMessage() := "" @@ -11441,7 +11768,7 @@ C
- + Tested reporter: Automake @@ -11467,7 +11794,7 @@ C
- + Tested reporter: Automake @@ -11492,7 +11819,7 @@ C
- + Tested reporter: Automake @@ -11519,7 +11846,7 @@ C
- + Tested reporter: compact @@ -11545,7 +11872,7 @@ C
- + Tested reporter: compact @@ -11570,7 +11897,7 @@ C
- + Tested reporter: compact @@ -11597,7 +11924,7 @@ C
- + Tested reporter: console @@ -11623,7 +11950,7 @@ C
- + Tested reporter: console @@ -11648,7 +11975,7 @@ C
- + Tested reporter: console @@ -11674,8 +12001,122 @@ C !false +
+ + Tested reporter: JSON + + + + listingString, ContainsSubstring("fakeTag"s) + + + "{ + "version": 1, + "metadata": { + "name": "", + "rng-seed": 1234, + "catch2-version": "" + }, + "listings": { + "tags": [ + { + "aliases": [ + "fakeTag" + ], + "count": 1 + } + ]" contains: "fakeTag" + + + +
+ + + !(factories.empty()) + + + !false + + +
+ + Tested reporter: JSON + + + + listingString, ContainsSubstring("fake reporter"s) + + + "{ + "version": 1, + "metadata": { + "name": "", + "rng-seed": 1234, + "catch2-version": "" + }, + "listings": { + "reporters": [ + { + "name": "fake reporter", + "description": "fake description" + } + ]" contains: "fake reporter" + + + +
+ + + !(factories.empty()) + + + !false + + +
+ + Tested reporter: JSON + + + + listingString, ContainsSubstring( "fake test name"s ) && ContainsSubstring( "fakeTestTag"s ) + + + "{ + "version": 1, + "metadata": { + "name": "", + "rng-seed": 1234, + "catch2-version": "" + }, + "listings": { + "tests": [ + { + "name": "fake test name", + "class-name": "", + "tags": [ + "fakeTestTag" + ], + "source-location": { + "filename": "fake-file.cpp", + "line": 123456789 + } + } + ]" ( contains: "fake test name" and contains: "fakeTestTag" ) + + + +
+ + + !(factories.empty()) + + + !false + +
- + Tested reporter: JUnit @@ -11702,7 +12143,7 @@ All available tags:
- + Tested reporter: JUnit @@ -11728,7 +12169,7 @@ Available reporters:
- + Tested reporter: JUnit @@ -11756,7 +12197,7 @@ All available test cases:
- + Tested reporter: SonarQube @@ -11783,7 +12224,7 @@ All available tags:
- + Tested reporter: SonarQube @@ -11809,7 +12250,7 @@ Available reporters:
- + Tested reporter: SonarQube @@ -11837,7 +12278,7 @@ All available test cases:
- + Tested reporter: TAP @@ -11863,7 +12304,7 @@ All available test cases:
- + Tested reporter: TAP @@ -11888,7 +12329,7 @@ All available test cases:
- + Tested reporter: TAP @@ -11915,7 +12356,7 @@ All available test cases:
- + Tested reporter: TeamCity @@ -11941,7 +12382,7 @@ All available test cases:
- + Tested reporter: TeamCity @@ -11966,7 +12407,7 @@ All available test cases:
- + Tested reporter: TeamCity @@ -11993,7 +12434,7 @@ All available test cases:
- + Tested reporter: XML @@ -12023,7 +12464,7 @@ All available test cases:
- + Tested reporter: XML @@ -12051,7 +12492,7 @@ All available test cases:
- + Tested reporter: XML @@ -14552,6 +14993,50 @@ Message from section two + + + + true + + + true + + + + + {Unknown expression after the reported line} + + + {Unknown expression after the reported line} + + + Uncaught exception should fail! + + + + + + + + false + + + false + + + + + {Unknown expression after the reported line} + + + {Unknown expression after the reported line} + + + Uncaught exception should fail! + + + + @@ -15670,7 +16155,7 @@ There is no extra whitespace here
-
+
data, !AllTrue() @@ -15712,7 +16197,7 @@ There is no extra whitespace here
-
+
data, !AllTrue() @@ -16020,7 +16505,7 @@ There is no extra whitespace here
-
+
data, AnyTrue() @@ -16062,7 +16547,7 @@ There is no extra whitespace here
-
+
data, AnyTrue() @@ -16370,7 +16855,7 @@ There is no extra whitespace here
-
+
data, !NoneTrue() @@ -16412,7 +16897,7 @@ There is no extra whitespace here
-
+
data, !NoneTrue() @@ -18765,7 +19250,7 @@ There is no extra whitespace here - + Testing if fib[0] (1) is even @@ -18776,7 +19261,7 @@ There is no extra whitespace here 1 == 0 - + Testing if fib[1] (1) is even @@ -18787,7 +19272,7 @@ There is no extra whitespace here 1 == 0 - + Testing if fib[2] (2) is even @@ -18798,7 +19283,7 @@ There is no extra whitespace here 0 == 0 - + Testing if fib[3] (3) is even @@ -18809,7 +19294,7 @@ There is no extra whitespace here 1 == 0 - + Testing if fib[4] (5) is even @@ -18820,7 +19305,7 @@ There is no extra whitespace here 1 == 0 - + Testing if fib[5] (8) is even @@ -18831,7 +19316,7 @@ There is no extra whitespace here 0 == 0 - + Testing if fib[6] (13) is even @@ -18842,7 +19327,7 @@ There is no extra whitespace here 1 == 0 - + Testing if fib[7] (21) is even @@ -18981,22 +19466,22 @@ There is no extra whitespace here - + info - + unscoped info - + and warn may mix - + info - + unscoped info - + they are not cleared after warnings @@ -19203,7 +19688,7 @@ b1! - + this MAY be seen only for the FIRST assertion IF info is printed for passing assertions @@ -19214,7 +19699,7 @@ b1! true - + this MAY be seen only for the SECOND assertion IF info is printed for passing assertions @@ -19225,7 +19710,7 @@ b1! true - + this SHOULD be seen @@ -19361,7 +19846,7 @@ b1! - + this MAY be seen IF info is printed for passing assertions @@ -19375,10 +19860,10 @@ b1! - + this SHOULD be seen - + this SHOULD also be seen @@ -19392,7 +19877,7 @@ b1! - + this SHOULD be seen only ONCE @@ -19411,7 +19896,7 @@ b1! true - + this MAY also be seen only ONCE IF info is printed for passing assertions @@ -19894,7 +20379,7 @@ b1! - + 3 @@ -19908,10 +20393,10 @@ b1! - + hi - + i := 7 @@ -19969,16 +20454,16 @@ b1! - + Count 1 to 3... - + 1 - + 2 - + 3 @@ -19989,16 +20474,16 @@ b1! false - + Count 4 to 6... - + 4 - + 5 - + 6 @@ -20648,6 +21133,25 @@ b1! + + + + dist.a() == -10 + + + -10 == -10 + + + + + dist.b() == 10 + + + 10 == 10 + + + +
@@ -21202,6 +21706,6 @@ b1!
- - + + diff --git a/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/AssertionHandler.tests.cpp b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/AssertionHandler.tests.cpp new file mode 100644 index 000000000..ab0960745 --- /dev/null +++ b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/AssertionHandler.tests.cpp @@ -0,0 +1,17 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include + +TEST_CASE( "Incomplete AssertionHandler", "[assertion-handler][!shouldfail]" ) { + Catch::AssertionHandler catchAssertionHandler( + "REQUIRE"_catch_sr, + CATCH_INTERNAL_LINEINFO, + "Dummy", + Catch::ResultDisposition::Normal ); +} diff --git a/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/Details.tests.cpp b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/Details.tests.cpp index a5a43926c..d7175756b 100644 --- a/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/Details.tests.cpp +++ b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/Details.tests.cpp @@ -89,6 +89,47 @@ TEST_CASE("Optional comparison ops", "[optional][approvals]") { } } +namespace { + struct MoveChecker { + bool has_moved = false; + MoveChecker() = default; + MoveChecker( MoveChecker const& rhs ) = default; + MoveChecker& operator=( MoveChecker const& rhs ) = default; + MoveChecker( MoveChecker&& rhs ) noexcept { rhs.has_moved = true; } + MoveChecker& operator=( MoveChecker&& rhs ) noexcept { + rhs.has_moved = true; + return *this; + } + }; +} + +TEST_CASE( "Optional supports move ops", "[optional][approvals]" ) { + using Catch::Optional; + MoveChecker a; + Optional opt_A( a ); + REQUIRE_FALSE( a.has_moved ); + REQUIRE_FALSE( opt_A->has_moved ); + + SECTION( "Move construction from element" ) { + Optional opt_B( CATCH_MOVE( a ) ); + REQUIRE( a.has_moved ); + } + SECTION( "Move assignment from element" ) { + opt_A = CATCH_MOVE( a ); + REQUIRE( a.has_moved ); + } + SECTION( "Move construction from optional" ) { + Optional opt_B( CATCH_MOVE( opt_A ) ); + REQUIRE( opt_A->has_moved ); + } + SECTION( "Move assignment from optional" ) { + Optional opt_B( opt_A ); + REQUIRE_FALSE( opt_A->has_moved ); + opt_B = CATCH_MOVE( opt_A ); + REQUIRE( opt_A->has_moved ); + } +} + TEST_CASE( "Decomposer checks that the argument is 0 when handling " "only-0-comparable types", "[decomposition][approvals]" ) { diff --git a/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/FloatingPoint.tests.cpp b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/FloatingPoint.tests.cpp index 08a579c9d..d2181702d 100644 --- a/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/FloatingPoint.tests.cpp +++ b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/FloatingPoint.tests.cpp @@ -9,7 +9,9 @@ #include #include #include +#include +#include TEST_CASE("convertToBits", "[floating-point][conversion]") { using Catch::Detail::convertToBits; @@ -72,3 +74,66 @@ TEST_CASE("UlpDistance", "[floating-point][ulp][approvals]") { CHECK( ulpDistance( 1.f, 2.f ) == 0x80'00'00 ); CHECK( ulpDistance( -2.f, 2.f ) == 0x80'00'00'00 ); } + + + +TEMPLATE_TEST_CASE("gamma", "[approvals][floating-point][ulp][gamma]", float, double) { + using Catch::Detail::gamma; + using Catch::Detail::directCompare; + + // We need to butcher the equal tests with the directCompare helper, + // because the Wfloat-equal triggers in decomposer rather than here, + // so we cannot locally disable it. Goddamn GCC. + CHECK( directCompare( gamma( TestType( -1. ), TestType( 1. ) ), + gamma( TestType( 0.2332 ), TestType( 1.0 ) ) ) ); + CHECK( directCompare( gamma( TestType( -2. ), TestType( 0 ) ), + gamma( TestType( 1. ), TestType( 1.5 ) ) ) ); + CHECK( gamma( TestType( 0. ), TestType( 1.0 ) ) < + gamma( TestType( 1.0 ), TestType( 1.5 ) ) ); + CHECK( gamma( TestType( 0 ), TestType( 1. ) ) < + std::numeric_limits::epsilon() ); + CHECK( gamma( TestType( -1. ), TestType( -0. ) ) < + std::numeric_limits::epsilon() ); + CHECK( directCompare( gamma( TestType( 1. ), TestType( 2. ) ), + std::numeric_limits::epsilon() ) ); + CHECK( directCompare( gamma( TestType( -2. ), TestType( -1. ) ), + std::numeric_limits::epsilon() ) ); +} + +TEMPLATE_TEST_CASE("count_equidistant_floats", + "[approvals][floating-point][distance]", + float, + double) { + using Catch::Detail::count_equidistant_floats; + auto count_steps = []( TestType a, TestType b ) { + return count_equidistant_floats( a, b, Catch::Detail::gamma( a, b ) ); + }; + + CHECK( count_steps( TestType( -1. ), TestType( 1. ) ) == + 2 * count_steps( TestType( 0. ), TestType( 1. ) ) ); +} + +TEST_CASE( "count_equidistant_floats", + "[approvals][floating-point][distance]" ) { + using Catch::Detail::count_equidistant_floats; + auto count_floats_with_scaled_ulp = []( auto a, auto b ) { + return count_equidistant_floats( a, b, Catch::Detail::gamma( a, b ) ); + }; + + CHECK( count_floats_with_scaled_ulp( 1., 1.5 ) == 1ull << 51 ); + CHECK( count_floats_with_scaled_ulp( 1.25, 1.5 ) == 1ull << 50 ); + CHECK( count_floats_with_scaled_ulp( 1.f, 1.5f ) == 1 << 22 ); + CHECK( count_floats_with_scaled_ulp( -std::numeric_limits::max(), + std::numeric_limits::max() ) == + 33554430 ); // (1 << 25) - 2 due to not including infinities + CHECK( count_floats_with_scaled_ulp( -std::numeric_limits::max(), + std::numeric_limits::max() ) == + 18014398509481982 ); // (1 << 54) - 2 due to not including infinities + + STATIC_REQUIRE( std::is_same::value ); + STATIC_REQUIRE( std::is_same::value ); +} diff --git a/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp index 64e943f84..acfeebed0 100644 --- a/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp +++ b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp @@ -10,6 +10,8 @@ # pragma GCC diagnostic ignored "-Wfloat-equal" #endif +#include + #include #include #include @@ -412,6 +414,7 @@ TEST_CASE("GENERATE handles function (pointers)", "[generators][compilation][app TEST_CASE("GENERATE decays arrays", "[generators][compilation][approvals]") { auto str = GENERATE("abc", "def", "gh"); + (void)str; STATIC_REQUIRE(std::is_same::value); } @@ -544,3 +547,30 @@ TEST_CASE("Filter generator throws exception for empty generator", filter( []( int ) { return false; }, value( 3 ) ), Catch::GeneratorException ); } + +TEST_CASE("from_range(container) supports ADL begin/end and arrays", "[generators][from-range][approvals]") { + using namespace Catch::Generators; + + SECTION("C array") { + int arr[3]{ 5, 6, 7 }; + auto gen = from_range( arr ); + REQUIRE( gen.get() == 5 ); + REQUIRE( gen.next() ); + REQUIRE( gen.get() == 6 ); + REQUIRE( gen.next() ); + REQUIRE( gen.get() == 7 ); + REQUIRE_FALSE( gen.next() ); + } + + SECTION( "ADL range" ) { + unrelated::needs_ADL_begin range{ 1, 2, 3 }; + auto gen = from_range( range ); + REQUIRE( gen.get() == 1 ); + REQUIRE( gen.next() ); + REQUIRE( gen.get() == 2 ); + REQUIRE( gen.next() ); + REQUIRE( gen.get() == 3 ); + REQUIRE_FALSE( gen.next() ); + } + +} diff --git a/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/Integer.tests.cpp b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/Integer.tests.cpp new file mode 100644 index 000000000..fd620ebbf --- /dev/null +++ b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/Integer.tests.cpp @@ -0,0 +1,150 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include +#include + +namespace { + template + static void + CommutativeMultCheck( Int a, Int b, Int upper_result, Int lower_result ) { + using Catch::Detail::extendedMult; + using Catch::Detail::ExtendedMultResult; + CHECK( extendedMult( a, b ) == + ExtendedMultResult{ upper_result, lower_result } ); + CHECK( extendedMult( b, a ) == + ExtendedMultResult{ upper_result, lower_result } ); + } +} // namespace + +TEST_CASE( "extendedMult 64x64", "[Integer][approvals]" ) { + // a x 0 == 0 + CommutativeMultCheck( 0x1234'5678'9ABC'DEFF, 0, 0, 0 ); + + // bit carried from low half to upper half + CommutativeMultCheck( uint64_t( 1 ) << 63, 2, 1, 0 ); + + // bits in upper half on one side, bits in lower half on other side + CommutativeMultCheck( 0xcdcd'dcdc'0000'0000, + 0x0000'0000'aeae'aeae, + 0x0000'0000'8c6e'5a77, + 0x7391'a588'0000'0000 ); + + // Some input numbers without interesting patterns + CommutativeMultCheck( 0xaaaa'aaaa'aaaa'aaaa, + 0xbbbb'bbbb'bbbb'bbbb, + 0x7d27'd27d'27d2'7d26, + 0xd82d'82d8'2d82'd82e ); + + CommutativeMultCheck( 0x7d27'd27d'27d2'7d26, + 0xd82d'82d8'2d82'd82e, + 0x69af'd991'8256'b953, + 0x8724'8909'fcb6'8cd4 ); + + CommutativeMultCheck( 0xdead'beef'dead'beef, + 0xfeed'feed'feed'feef, + 0xddbf'680b'2b0c'b558, + 0x7a36'b06f'2ce9'6321 ); + + CommutativeMultCheck( 0xddbf'680b'2b0c'b558, + 0x7a36'b06f'2ce9'6321, + 0x69dc'96c9'294b'fc7f, + 0xd038'39fa'a3dc'6858 ); + + CommutativeMultCheck( 0x61c8'8646'80b5'83eb, + 0x61c8'8646'80b5'83eb, + 0x2559'92d3'8220'8bbe, + 0xdf44'2d22'ce48'59b9 ); +} + +TEST_CASE( "SizedUnsignedType helpers", "[integer][approvals]" ) { + using Catch::Detail::SizedUnsignedType_t; + using Catch::Detail::DoubleWidthUnsignedType_t; + + STATIC_REQUIRE( sizeof( SizedUnsignedType_t<1> ) == 1 ); + STATIC_REQUIRE( sizeof( SizedUnsignedType_t<2> ) == 2 ); + STATIC_REQUIRE( sizeof( SizedUnsignedType_t<4> ) == 4 ); + STATIC_REQUIRE( sizeof( SizedUnsignedType_t<8> ) == 8 ); + + STATIC_REQUIRE( sizeof( DoubleWidthUnsignedType_t ) == 2 ); + STATIC_REQUIRE( std::is_unsigned>::value ); + STATIC_REQUIRE( sizeof( DoubleWidthUnsignedType_t ) == 4 ); + STATIC_REQUIRE( std::is_unsigned>::value ); + STATIC_REQUIRE( sizeof( DoubleWidthUnsignedType_t ) == 8 ); + STATIC_REQUIRE( std::is_unsigned>::value ); +} + +TEST_CASE( "extendedMult 32x32", "[integer][approvals]" ) { + // a x 0 == 0 + CommutativeMultCheck( 0x1234'5678, 0, 0, 0 ); + + // bit carried from low half to upper half + CommutativeMultCheck( uint32_t(1) << 31, 2, 1, 0 ); + + // bits in upper half on one side, bits in lower half on other side + CommutativeMultCheck( 0xdcdc'0000, 0x0000'aabb, 0x0000'934b, 0x6cb4'0000 ); + + // Some input numbers without interesting patterns + CommutativeMultCheck( + 0xaaaa'aaaa, 0xbbbb'bbbb, 0x7d27'd27c, 0x2d82'd82e ); + + CommutativeMultCheck( + 0x7d27'd27c, 0x2d82'd82e, 0x163f'f7e8, 0xc5b8'7248 ); + + CommutativeMultCheck( + 0xdead'beef, 0xfeed'feed, 0xddbf'6809, 0x6f8d'e543 ); + + CommutativeMultCheck( + 0xddbf'6809, 0x6f8d'e543, 0x60a0'e71e, 0x751d'475b ); +} + +TEST_CASE( "extendedMult 8x8", "[integer][approvals]" ) { + // a x 0 == 0 + CommutativeMultCheck( 0xcd, 0, 0, 0 ); + + // bit carried from low half to upper half + CommutativeMultCheck( uint8_t( 1 ) << 7, 2, 1, 0 ); + + // bits in upper half on one side, bits in lower half on other side + CommutativeMultCheck( 0x80, 0x03, 0x01, 0x80 ); + + // Some input numbers without interesting patterns + CommutativeMultCheck( 0xaa, 0xbb, 0x7c, 0x2e ); + CommutativeMultCheck( 0x7c, 0x2e, 0x16, 0x48 ); + CommutativeMultCheck( 0xdc, 0xcd, 0xb0, 0x2c ); + CommutativeMultCheck( 0xb0, 0x2c, 0x1e, 0x40 ); +} + + +TEST_CASE( "negative and positive signed integers keep their order after transposeToNaturalOrder", + "[integer][approvals]") { + using Catch::Detail::transposeToNaturalOrder; + int32_t negative( -1 ); + int32_t positive( 1 ); + uint32_t adjusted_negative = + transposeToNaturalOrder( static_cast( negative ) ); + uint32_t adjusted_positive = + transposeToNaturalOrder( static_cast( positive ) ); + REQUIRE( adjusted_negative < adjusted_positive ); + REQUIRE( adjusted_positive - adjusted_negative == 2 ); + + // Conversion has to be reversible + REQUIRE( negative == static_cast( transposeToNaturalOrder( + adjusted_negative ) ) ); + REQUIRE( positive == static_cast( transposeToNaturalOrder( + adjusted_positive ) ) ); +} + +TEST_CASE( "unsigned integers are unchanged by transposeToNaturalOrder", + "[integer][approvals]") { + using Catch::Detail::transposeToNaturalOrder; + uint32_t max = std::numeric_limits::max(); + uint32_t zero = 0; + REQUIRE( max == transposeToNaturalOrder( max ) ); + REQUIRE( zero == transposeToNaturalOrder( zero ) ); +} diff --git a/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/InternalBenchmark.tests.cpp b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/InternalBenchmark.tests.cpp index 96c0977b7..bc8d715b4 100644 --- a/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/InternalBenchmark.tests.cpp +++ b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/InternalBenchmark.tests.cpp @@ -22,6 +22,8 @@ #include #include +#include + namespace { struct manual_clock { public: @@ -154,8 +156,12 @@ TEST_CASE("uniform samples", "[benchmark]") { std::vector samples(100); std::fill(samples.begin(), samples.end(), 23); - using it = std::vector::iterator; - auto e = Catch::Benchmark::Detail::bootstrap(0.95, samples.begin(), samples.end(), samples, [](it a, it b) { + auto e = Catch::Benchmark::Detail::bootstrap( + 0.95, + samples.data(), + samples.data() + samples.size(), + samples, + []( double const* a, double const* b ) { auto sum = std::accumulate(a, b, 0.); return sum / (b - a); }); @@ -196,7 +202,7 @@ TEST_CASE("normal_quantile", "[benchmark]") { TEST_CASE("mean", "[benchmark]") { std::vector x{ 10., 20., 14., 16., 30., 24. }; - auto m = Catch::Benchmark::Detail::mean(x.begin(), x.end()); + auto m = Catch::Benchmark::Detail::mean(x.data(), x.data() + x.size()); REQUIRE(m == 19.); } @@ -204,9 +210,9 @@ TEST_CASE("mean", "[benchmark]") { TEST_CASE("weighted_average_quantile", "[benchmark]") { std::vector x{ 10., 20., 14., 16., 30., 24. }; - auto q1 = Catch::Benchmark::Detail::weighted_average_quantile(1, 4, x.begin(), x.end()); - auto med = Catch::Benchmark::Detail::weighted_average_quantile(1, 2, x.begin(), x.end()); - auto q3 = Catch::Benchmark::Detail::weighted_average_quantile(3, 4, x.begin(), x.end()); + auto q1 = Catch::Benchmark::Detail::weighted_average_quantile(1, 4, x.data(), x.data() + x.size()); + auto med = Catch::Benchmark::Detail::weighted_average_quantile(1, 2, x.data(), x.data() + x.size()); + auto q3 = Catch::Benchmark::Detail::weighted_average_quantile(3, 4, x.data(), x.data() + x.size()); REQUIRE(q1 == 14.5); REQUIRE(med == 18.); @@ -225,7 +231,8 @@ TEST_CASE("classify_outliers", "[benchmark]") { SECTION("none") { std::vector x{ 10., 20., 14., 16., 30., 24. }; - auto o = Catch::Benchmark::Detail::classify_outliers(x.begin(), x.end()); + auto o = Catch::Benchmark::Detail::classify_outliers( + x.data(), x.data() + x.size() ); REQUIRE(o.samples_seen == static_cast(x.size())); require_outliers(o, 0, 0, 0, 0); @@ -233,7 +240,8 @@ TEST_CASE("classify_outliers", "[benchmark]") { SECTION("low severe") { std::vector x{ -12., 20., 14., 16., 30., 24. }; - auto o = Catch::Benchmark::Detail::classify_outliers(x.begin(), x.end()); + auto o = Catch::Benchmark::Detail::classify_outliers( + x.data(), x.data() + x.size() ); REQUIRE(o.samples_seen == static_cast(x.size())); require_outliers(o, 1, 0, 0, 0); @@ -241,7 +249,8 @@ TEST_CASE("classify_outliers", "[benchmark]") { SECTION("low mild") { std::vector x{ 1., 20., 14., 16., 30., 24. }; - auto o = Catch::Benchmark::Detail::classify_outliers(x.begin(), x.end()); + auto o = Catch::Benchmark::Detail::classify_outliers( + x.data(), x.data() + x.size() ); REQUIRE(o.samples_seen == static_cast(x.size())); require_outliers(o, 0, 1, 0, 0); @@ -249,7 +258,8 @@ TEST_CASE("classify_outliers", "[benchmark]") { SECTION("high mild") { std::vector x{ 10., 20., 14., 16., 36., 24. }; - auto o = Catch::Benchmark::Detail::classify_outliers(x.begin(), x.end()); + auto o = Catch::Benchmark::Detail::classify_outliers( + x.data(), x.data() + x.size() ); REQUIRE(o.samples_seen == static_cast(x.size())); require_outliers(o, 0, 0, 1, 0); @@ -257,7 +267,8 @@ TEST_CASE("classify_outliers", "[benchmark]") { SECTION("high severe") { std::vector x{ 10., 20., 14., 16., 49., 24. }; - auto o = Catch::Benchmark::Detail::classify_outliers(x.begin(), x.end()); + auto o = Catch::Benchmark::Detail::classify_outliers( + x.data(), x.data() + x.size() ); REQUIRE(o.samples_seen == static_cast(x.size())); require_outliers(o, 0, 0, 0, 1); @@ -265,7 +276,8 @@ TEST_CASE("classify_outliers", "[benchmark]") { SECTION("mixed") { std::vector x{ -20., 20., 14., 16., 39., 24. }; - auto o = Catch::Benchmark::Detail::classify_outliers(x.begin(), x.end()); + auto o = Catch::Benchmark::Detail::classify_outliers( + x.data(), x.data() + x.size() ); REQUIRE(o.samples_seen == static_cast(x.size())); require_outliers(o, 1, 0, 1, 0); @@ -280,15 +292,13 @@ TEST_CASE("analyse", "[approvals][benchmark]") { data.benchmarkSamples = 99; Catch::Config config{data}; - using Duration = Catch::Benchmark::FloatDuration; - - Catch::Benchmark::Environment env; - std::vector samples(99); + using FDuration = Catch::Benchmark::FDuration; + std::vector samples(99); for (size_t i = 0; i < samples.size(); ++i) { - samples[i] = Duration(23 + (i % 3 - 1)); + samples[i] = FDuration(23 + (i % 3 - 1)); } - auto analysis = Catch::Benchmark::Detail::analyse(config, env, samples.begin(), samples.end()); + auto analysis = Catch::Benchmark::Detail::analyse(config, samples.data(), samples.data() + samples.size()); CHECK( analysis.mean.point.count() == 23 ); CHECK( analysis.mean.lower_bound.count() < 23 ); CHECK(analysis.mean.lower_bound.count() > 22); @@ -321,15 +331,13 @@ TEST_CASE("analyse no analysis", "[benchmark]") { data.benchmarkSamples = 99; Catch::Config config{ data }; - using Duration = Catch::Benchmark::FloatDuration; - - Catch::Benchmark::Environment env; - std::vector samples(99); + using FDuration = Catch::Benchmark::FDuration; + std::vector samples(99); for (size_t i = 0; i < samples.size(); ++i) { - samples[i] = Duration(23 + (i % 3 - 1)); + samples[i] = FDuration(23 + (i % 3 - 1)); } - auto analysis = Catch::Benchmark::Detail::analyse(config, env, samples.begin(), samples.end()); + auto analysis = Catch::Benchmark::Detail::analyse(config, samples.data(), samples.data() + samples.size()); CHECK(analysis.mean.point.count() == 23); CHECK(analysis.mean.lower_bound.count() == 23); CHECK(analysis.mean.upper_bound.count() == 23); @@ -442,6 +450,6 @@ TEST_CASE("Failing benchmarks", "[!benchmark][.approvals]") { } TEST_CASE( "Failing benchmark respects should-fail", - "[!shouldfail][!benchmark][.approvals]" ) { + "[!shouldfail][!benchmark][approvals]" ) { BENCHMARK( "Asserting benchmark" ) { REQUIRE( 1 == 2 ); }; } diff --git a/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/Json.tests.cpp b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/Json.tests.cpp new file mode 100644 index 000000000..8204e3c4b --- /dev/null +++ b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/Json.tests.cpp @@ -0,0 +1,152 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include +#include +#include + +#include + +namespace { + struct Custom {}; + static std::ostream& operator<<( std::ostream& os, Custom const& ) { + return os << "custom"; + } +} // namespace + +TEST_CASE( "JsonWriter", "[JSON][JsonWriter]" ) { + + std::stringstream stream; + SECTION( "Newly constructed JsonWriter does nothing" ) { + Catch::JsonValueWriter writer{ stream }; + REQUIRE( stream.str() == "" ); + } + + SECTION( "Calling writeObject will create an empty pair of braces" ) { + { auto writer = Catch::JsonValueWriter{ stream }.writeObject(); } + REQUIRE( stream.str() == "{\n}" ); + } + + SECTION( "Calling writeObject with key will create an object to write the " + "value" ) { + using Catch::Matchers::ContainsSubstring; + { + auto writer = Catch::JsonValueWriter{ stream }.writeObject(); + writer.write( "int" ).write( 1 ); + writer.write( "double" ).write( 1.5 ); + writer.write( "true" ).write( true ); + writer.write( "false" ).write( false ); + writer.write( "string" ).write( "this is a string" ); + writer.write( "array" ).writeArray().write( 1 ).write( 2 ); + } + REQUIRE_THAT( + stream.str(), + ContainsSubstring( "\"int\": 1," ) && + ContainsSubstring( "\"double\": 1.5," ) && + ContainsSubstring( "\"true\": true," ) && + ContainsSubstring( "\"false\": false," ) && + ContainsSubstring( "\"string\": \"this is a string\"," ) && + ContainsSubstring( "\"array\": [\n 1,\n 2\n ]\n}" ) ); + } + + SECTION( "nesting objects" ) { + using Catch::Matchers::ContainsSubstring; + { + auto writer = Catch::JsonValueWriter{ stream }.writeObject(); + writer.write( "empty_object" ).writeObject(); + writer.write( "fully_object" ) + .writeObject() + .write( "key" ) + .write( 1 ); + } + REQUIRE_THAT( stream.str(), + ContainsSubstring( "\"empty_object\": {\n }," ) && + ContainsSubstring( + "\"fully_object\": {\n \"key\": 1\n }" ) ); + } + + SECTION( "Calling writeArray will create an empty pair of braces" ) { + { auto writer = Catch::JsonValueWriter{ stream }.writeArray(); } + REQUIRE( stream.str() == "[\n]" ); + } + + SECTION( "Calling writeArray creates array to write the values to" ) { + { + auto writer = Catch::JsonValueWriter{ stream }.writeArray(); + writer.write( 1 ); + writer.write( 1.5 ); + writer.write( true ); + writer.write( false ); + writer.write( "this is a string" ); + writer.writeObject().write( "object" ).write( 42 ); + writer.writeArray().write( "array" ).write( 42.5 ); + } + REQUIRE( stream.str() == "[\n 1,\n 1.5,\n true,\n false,\n \"this is a string\",\n {\n \"object\": 42\n },\n [\n \"array\",\n 42.5\n ]\n]" ); + } + + SECTION( + "Moved from JsonObjectWriter shall not insert superfluous brace" ) { + { + auto writer = Catch::JsonObjectWriter{ stream }; + auto another_writer = std::move( writer ); + } + REQUIRE( stream.str() == "{\n}" ); + } + SECTION( + "Moved from JsonArrayWriter shall not insert superfluous bracket" ) { + { + auto writer = Catch::JsonArrayWriter{ stream }; + auto another_writer = std::move( writer ); + } + REQUIRE( stream.str() == "[\n]" ); + } + SECTION( "Custom class shall be quoted" ) { + Catch::JsonValueWriter{ stream }.write( Custom{} ); + REQUIRE( stream.str() == "\"custom\"" ); + } +} + +TEST_CASE( "JsonWriter escapes charaters in strings properly", "[JsonWriter]" ) { + std::stringstream sstream; + SECTION( "Quote in a string is escaped" ) { + Catch::JsonValueWriter{ sstream }.write( "\"" ); + REQUIRE( sstream.str() == "\"\\\"\"" ); + } + SECTION("Backslash in a string is escaped") { + Catch::JsonValueWriter{ sstream }.write( "\\" ); + REQUIRE( sstream.str() == "\"\\\\\"" ); + } + SECTION( "Forward slash in a string is **not** escaped" ) { + Catch::JsonValueWriter{ sstream }.write( "/" ); + REQUIRE( sstream.str() == "\"/\"" ); + } + SECTION( "Backspace in a string is escaped" ) { + Catch::JsonValueWriter{ sstream }.write( "\b" ); + REQUIRE( sstream.str() == "\"\\b\"" ); + } + SECTION( "Formfeed in a string is escaped" ) { + Catch::JsonValueWriter{ sstream }.write( "\f" ); + REQUIRE( sstream.str() == "\"\\f\"" ); + } + SECTION( "linefeed in a string is escaped" ) { + Catch::JsonValueWriter{ sstream }.write( "\n" ); + REQUIRE( sstream.str() == "\"\\n\"" ); + } + SECTION( "carriage return in a string is escaped" ) { + Catch::JsonValueWriter{ sstream }.write( "\r" ); + REQUIRE( sstream.str() == "\"\\r\"" ); + } + SECTION( "tab in a string is escaped" ) { + Catch::JsonValueWriter{ sstream }.write( "\t" ); + REQUIRE( sstream.str() == "\"\\t\"" ); + } + SECTION( "combination of characters is escaped" ) { + Catch::JsonValueWriter{ sstream }.write( "\\/\t\r\n" ); + REQUIRE( sstream.str() == "\"\\\\/\\t\\r\\n\"" ); + } +} diff --git a/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/RandomNumberGeneration.tests.cpp b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/RandomNumberGeneration.tests.cpp index 8018b7eb0..03be6c9ca 100644 --- a/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/RandomNumberGeneration.tests.cpp +++ b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/RandomNumberGeneration.tests.cpp @@ -7,9 +7,17 @@ // SPDX-License-Identifier: BSL-1.0 #include +#include +#include +#include #include #include +#include +#include #include +#include + +#include TEST_CASE("Our PCG implementation provides expected results for known seeds", "[rng]") { Catch::SimplePcg32 rng; @@ -60,3 +68,523 @@ TEST_CASE("Random seed generation accepts known methods", "[rng][seed]") { REQUIRE_NOTHROW(Catch::generateRandomSeed(method)); } + +TEMPLATE_TEST_CASE("uniform_floating_point_distribution never returns infs from finite range", + "[rng][distribution][floating-point][approvals]", float, double) { + std::random_device rd{}; + Catch::SimplePcg32 pcg( rd() ); + Catch::uniform_floating_point_distribution dist( + -std::numeric_limits::max(), + std::numeric_limits::max() ); + + for (size_t i = 0; i < 10'000; ++i) { + auto ret = dist( pcg ); + REQUIRE_FALSE( std::isinf( ret ) ); + REQUIRE_FALSE( std::isnan( ret ) ); + } +} + +TEST_CASE( "fillBitsFrom - shortening and stretching", "[rng][approvals]" ) { + using Catch::Detail::fillBitsFrom; + + // The seed is not important, but the numbers below have to be repeatable. + // They should also exhibit the same general pattern of being prefixes + Catch::SimplePcg32 pcg( 0xaabb'ccdd ); + + SECTION( "Shorten to 8 bits" ) { + // We cast the result to avoid dealing with char-like type in uint8_t + auto shortened = static_cast( fillBitsFrom( pcg ) ); + REQUIRE( shortened == 0xcc ); + } + SECTION( "Shorten to 16 bits" ) { + auto shortened = fillBitsFrom( pcg ); + REQUIRE( shortened == 0xccbe ); + } + SECTION( "Keep at 32 bits" ) { + auto n = fillBitsFrom( pcg ); + REQUIRE( n == 0xccbe'5f04 ); + } + SECTION( "Stretch to 64 bits" ) { + auto stretched = fillBitsFrom( pcg ); + REQUIRE( stretched == 0xccbe'5f04'a424'a486 ); + } +} + +TEST_CASE("uniform_integer_distribution can return the bounds", "[rng][distribution]") { + Catch::uniform_integer_distribution dist( -10, 10 ); + REQUIRE( dist.a() == -10 ); + REQUIRE( dist.b() == 10 ); +} + +namespace { + template + static void CheckReturnValue(Catch::uniform_integer_distribution& dist, + Catch::SimplePcg32& rng, + T target) { + REQUIRE( dist.a() == dist.b() ); + for (int i = 0; i < 1'000; ++i) { + REQUIRE( dist( rng ) == target ); + } + } +} + +TEMPLATE_TEST_CASE( "uniform_integer_distribution can handle unit ranges", + "[rng][distribution][approvals]", + unsigned char, + signed char, + char, + uint8_t, + int8_t, + uint16_t, + int16_t, + uint32_t, + int32_t, + uint64_t, + int64_t ) { + // We want random seed to sample different parts of the rng state, + // the output is predetermined anyway + std::random_device rd; + auto seed = rd(); + CAPTURE( seed ); + Catch::SimplePcg32 pcg( seed ); + + // We check unitary ranges of 3 different values, min for type, max for type, + // some value inbetween just to make sure + SECTION("lowest value") { + constexpr auto lowest = std::numeric_limits::min(); + Catch::uniform_integer_distribution dist( lowest, lowest ); + CheckReturnValue( dist, pcg, lowest ); + } + SECTION( "highest value" ) { + constexpr auto highest = std::numeric_limits::max(); + Catch::uniform_integer_distribution dist( highest, highest ); + CheckReturnValue( dist, pcg, highest ); + } + SECTION( "some value" ) { + constexpr auto some = TestType( 42 ); + Catch::uniform_integer_distribution dist( some, some ); + CheckReturnValue( dist, pcg, some ); + } +} + +// Bool needs its own test because it doesn't have a valid "third" value +TEST_CASE( "uniform_integer_distribution can handle boolean unit ranges", + "[rng][distribution][approvals]" ) { + // We want random seed to sample different parts of the rng state, + // the output is predetermined anyway + std::random_device rd; + auto seed = rd(); + CAPTURE( seed ); + Catch::SimplePcg32 pcg( seed ); + + // We check unitary ranges of 3 different values, min for type, max for + // type, some value inbetween just to make sure + SECTION( "lowest value" ) { + Catch::uniform_integer_distribution dist( false, false ); + CheckReturnValue( dist, pcg, false ); + } + SECTION( "highest value" ) { + Catch::uniform_integer_distribution dist( true, true ); + CheckReturnValue( dist, pcg, true ); + } +} + +TEMPLATE_TEST_CASE( "uniform_integer_distribution can handle full width ranges", + "[rng][distribution][approvals]", + unsigned char, + signed char, + char, + uint8_t, + int8_t, + uint16_t, + int16_t, + uint32_t, + int32_t, + uint64_t, + int64_t ) { + // We want random seed to sample different parts of the rng state, + // the output is predetermined anyway + std::random_device rd; + auto seed = rd(); + CAPTURE( seed ); + Catch::SimplePcg32 pcg( seed ); + + constexpr auto lowest = std::numeric_limits::min(); + constexpr auto highest = std::numeric_limits::max(); + Catch::uniform_integer_distribution dist( lowest, highest ); + STATIC_REQUIRE( std::is_same::value ); + + // We need to do bit operations on the results, so we will have to + // cast them to unsigned type. + using BitType = std::make_unsigned_t; + BitType ORs = 0; + BitType ANDs = BitType(-1); + for (int i = 0; i < 100; ++i) { + auto bits = static_cast( dist( pcg ) ); + ORs |= bits; + ANDs &= bits; + } + // Assuming both our RNG and distribution are unbiased, asking for + // the full range should essentially give us random bit generator. + // Over long run, OR of all the generated values should have all + // bits set to 1, while AND should have all bits set to 0. + // The chance of this test failing for unbiased pipeline is + // 1 / 2**iters, which for 100 iterations is astronomical. + REQUIRE( ORs == BitType( -1 ) ); + REQUIRE( ANDs == 0 ); +} + +namespace { + template + struct uniform_integer_test_params; + + template <> + struct uniform_integer_test_params { + static constexpr bool lowest = false; + static constexpr bool highest = true; + // This seems weird, but it is an artifact of the specific seed + static constexpr bool expected[] = { true, + true, + true, + true, + true, + true, + false, + true, + true, + true, + true, + true, + false, + true, + true }; + }; + + template <> + struct uniform_integer_test_params { + static constexpr char lowest = 32; + static constexpr char highest = 126; + static constexpr char expected[] = { 'k', + '\\', + 'Z', + 'X', + '`', + 'Q', + ';', + 'o', + ']', + 'T', + 'v', + 'p', + ':', + 'S', + 't' }; + }; + + template <> + struct uniform_integer_test_params { + static constexpr uint8_t lowest = 3; + static constexpr uint8_t highest = 123; + static constexpr uint8_t expected[] = { 'c', + 'P', + 'M', + 'J', + 'U', + 'A', + '%', + 'h', + 'Q', + 'F', + 'q', + 'i', + '$', + 'E', + 'o' }; + }; + + template <> + struct uniform_integer_test_params { + static constexpr int8_t lowest = -27; + static constexpr int8_t highest = 73; + static constexpr int8_t expected[] = { '5', + '%', + '#', + ' ', + '*', + 25, + 2, + '9', + '&', + 29, + 'A', + ':', + 1, + 28, + '?' }; + }; + + template <> + struct uniform_integer_test_params { + static constexpr uint16_t lowest = 123; + static constexpr uint16_t highest = 33333; + static constexpr uint16_t expected[] = { 26684, + 21417, + 20658, + 19791, + 22896, + 17433, + 9806, + 27948, + 21767, + 18588, + 30556, + 28244, + 9439, + 18293, + 29949 }; + }; + + template <> + struct uniform_integer_test_params { + static constexpr int16_t lowest = -17222; + static constexpr int16_t highest = 17222; + static constexpr int16_t expected[] = { 10326, + 4863, + 4076, + 3177, + 6397, + 731, + -7179, + 11637, + 5226, + 1929, + 14342, + 11944, + -7560, + 1623, + 13712 }; + }; + + template <> + struct uniform_integer_test_params { + static constexpr uint32_t lowest = 17222; + static constexpr uint32_t highest = 234234; + static constexpr uint32_t expected[] = { 190784, + 156367, + 151409, + 145743, + 166032, + 130337, + 80501, + 199046, + 158654, + 137883, + 216091, + 200981, + 78099, + 135954, + 212120 }; + }; + + template <> + struct uniform_integer_test_params { + static constexpr int32_t lowest = -237272; + static constexpr int32_t highest = 234234; + static constexpr int32_t expected[] = { 139829, + 65050, + 54278, + 41969, + 86051, + 8494, + -99785, + 157781, + 70021, + 24890, + 194815, + 161985, + -105004, + 20699, + 186186 }; + }; + + template <> + struct uniform_integer_test_params { + static constexpr uint64_t lowest = 1234; + static constexpr uint64_t highest = 1234567890; + static constexpr uint64_t expected[] = { 987382749, + 763380386, + 846572137, + 359990258, + 804599765, + 1131353566, + 346324913, + 1108760730, + 1141693933, + 856999148, + 879390623, + 1149485521, + 900556586, + 952385958, + 807916408 }; + }; + + template <> + struct uniform_integer_test_params { + static constexpr int64_t lowest = -1234567890; + static constexpr int64_t highest = 1234567890; + static constexpr int64_t expected[] = { 740197113, + 292191940, + 458575608, + -514589122, + 374630781, + 1028139036, + -541919840, + 982953318, + 1048819790, + 479429651, + 524212647, + 1064402981, + 566544615, + 670203462, + 381264073 }; + }; + + // We need these definitions for C++14 and earlier, but + // GCC will complain about them in newer C++ standards +#if __cplusplus <= 201402L + constexpr bool uniform_integer_test_params::expected[]; + constexpr char uniform_integer_test_params::expected[]; + constexpr uint8_t uniform_integer_test_params::expected[]; + constexpr int8_t uniform_integer_test_params::expected[]; + constexpr uint16_t uniform_integer_test_params::expected[]; + constexpr int16_t uniform_integer_test_params::expected[]; + constexpr uint32_t uniform_integer_test_params::expected[]; + constexpr int32_t uniform_integer_test_params::expected[]; + constexpr uint64_t uniform_integer_test_params::expected[]; + constexpr int64_t uniform_integer_test_params::expected[]; +#endif + +} + +TEMPLATE_TEST_CASE( "uniform_integer_distribution is reproducible", + "[rng][distribution][approvals]", + bool, + char, + uint8_t, + int8_t, + uint16_t, + int16_t, + uint32_t, + int32_t, + uint64_t, + int64_t) { + Catch::SimplePcg32 pcg( 0xaabb'ccdd ); + + constexpr auto lowest = uniform_integer_test_params::lowest; + constexpr auto highest = uniform_integer_test_params::highest; + Catch::uniform_integer_distribution dist(lowest, highest); + + constexpr auto iters = 15; + std::array generated; + for (int i = 0; i < iters; ++i) { + generated[i] = dist( pcg ); + } + + REQUIRE_THAT(generated, Catch::Matchers::RangeEquals(uniform_integer_test_params::expected)); +} + + +namespace { + template + struct uniform_fp_test_params; + + template<> + struct uniform_fp_test_params { + // These are exactly representable + static constexpr float lowest = -256.125f; + static constexpr float highest = 385.125f; + // These are just round-trip formatted + static constexpr float expected[] = { 92.56961f, + -23.170044f, + 310.81833f, + -53.023132f, + 105.03287f, + 198.77591f, + -172.72931f, + 51.805176f, + -241.10156f, + 64.66101f, + 212.12509f, + -49.24292f, + -177.1399f, + 245.23679f, + 173.22421f }; + }; + template <> + struct uniform_fp_test_params { + // These are exactly representable + static constexpr double lowest = -234582.9921875; + static constexpr double highest = 261238.015625; + // These are just round-trip formatted + static constexpr double expected[] = { 35031.207052832615, + 203783.3401838024, + 44667.940405848756, + -170100.5877224467, + -222966.7418051684, + 127472.72630072923, + -173510.88209096913, + 97394.16172239158, + 119123.6921592663, + 22595.741022785165, + 8988.68409120926, + 136906.86520606978, + 33369.19104222473, + 60912.7615841752, + -149060.05936760217 }; + }; + +// We need these definitions for C++14 and earlier, but +// GCC will complain about them in newer C++ standards +#if __cplusplus <= 201402L + constexpr float uniform_fp_test_params::expected[]; + constexpr double uniform_fp_test_params::expected[]; +#endif +} // namespace + +TEMPLATE_TEST_CASE( "uniform_floating_point_distribution is reproducible", + "[rng][distribution][floating-point][approvals]", + float, + double ) { + Catch::SimplePcg32 pcg( 0xaabb'aabb ); + + const auto lowest = uniform_fp_test_params::lowest; + const auto highest = uniform_fp_test_params::highest; + Catch::uniform_floating_point_distribution dist( lowest, highest ); + + constexpr auto iters = 15; + std::array generated; + for ( int i = 0; i < iters; ++i ) { + generated[i] = dist( pcg ); + } + + REQUIRE_THAT( generated, Catch::Matchers::RangeEquals( uniform_fp_test_params::expected ) ); +} + +TEMPLATE_TEST_CASE( "uniform_floating_point_distribution can handle unitary ranges", + "[rng][distribution][floating-point][approvals]", + float, + double ) { + std::random_device rd; + auto seed = rd(); + CAPTURE( seed ); + Catch::SimplePcg32 pcg( seed ); + + const auto highest = uniform_fp_test_params::highest; + Catch::uniform_floating_point_distribution dist( highest, + highest ); + + constexpr auto iters = 20; + for (int i = 0; i < iters; ++i) { + REQUIRE( Catch::Detail::directCompare( dist( pcg ), highest ) ); + } +} diff --git a/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp index 54c26a7a2..e5a65bda5 100644 --- a/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp +++ b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -110,7 +109,9 @@ TEST_CASE( "Reporter's write listings to provided stream", "[reporters]" ) { auto sstream = Catch::Detail::make_unique(); auto& sstreamRef = *sstream.get(); - Catch::Config config( Catch::ConfigData{} ); + Catch::ConfigData cfg_data; + cfg_data.rngSeed = 1234; + Catch::Config config( cfg_data ); auto reporter = factory.second->create( Catch::ReporterConfig{ &config, CATCH_MOVE( sstream ), Catch::ColourMode::None, {} } ); @@ -164,7 +165,7 @@ namespace { std::vector& recorder, Catch::IConfig const* config ): EventListenerBase( config ), - m_witness( witness ), + m_witness( CATCH_MOVE(witness) ), m_recorder( recorder ) {} @@ -182,7 +183,7 @@ namespace { std::vector& recorder, Catch::ReporterConfig&& config ): StreamingReporterBase( CATCH_MOVE(config) ), - m_witness( witness ), + m_witness( CATCH_MOVE(witness) ), m_recorder( recorder ) {} diff --git a/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/String.tests.cpp b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/String.tests.cpp index 7a0b3b4ab..43c58b49b 100644 --- a/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/String.tests.cpp +++ b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/String.tests.cpp @@ -177,7 +177,7 @@ TEST_CASE("StringRef at compilation time", "[Strings][StringRef][constexpr]") { STATIC_REQUIRE_FALSE(sr1.empty()); STATIC_REQUIRE(sr1.size() == 3); - using Catch::operator"" _sr; + using Catch::operator""_sr; constexpr auto sr2 = ""_sr; STATIC_REQUIRE(sr2.empty()); STATIC_REQUIRE(sr2.size() == 0); diff --git a/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/Tag.tests.cpp b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/Tag.tests.cpp index ef321b274..43723758d 100644 --- a/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/Tag.tests.cpp +++ b/external_imported/Catch2/tests/SelfTest/IntrospectiveTests/Tag.tests.cpp @@ -98,7 +98,20 @@ TEST_CASE( "Test case with identical tags keeps just one", "[tags]" ) { REQUIRE( testCase.tags[0] == Tag( "tag1" ) ); } -TEST_CASE( "Empty tag is not allowed" ) { - REQUIRE_THROWS( Catch::TestCaseInfo( - "", { "fake test name", "[]" }, dummySourceLineInfo ) ); +TEST_CASE("Mismatched square brackets in tags are caught and reported", + "[tags][approvals]") { + using Catch::TestCaseInfo; + using Catch::Matchers::ContainsSubstring; + REQUIRE_THROWS_WITH( TestCaseInfo( "", + { "test with unclosed tag", "[abc" }, + dummySourceLineInfo ), + ContainsSubstring("registering test case 'test with unclosed tag'") ); + REQUIRE_THROWS_WITH( TestCaseInfo( "", + { "test with nested tags", "[abc[def]]" }, + dummySourceLineInfo ), + ContainsSubstring("registering test case 'test with nested tags'") ); + REQUIRE_THROWS_WITH( TestCaseInfo( "", + { "test with superfluous close tags", "[abc][def]]" }, + dummySourceLineInfo ), + ContainsSubstring("registering test case 'test with superfluous close tags'") ); } diff --git a/external_imported/Catch2/tests/SelfTest/UsageTests/Exception.tests.cpp b/external_imported/Catch2/tests/SelfTest/UsageTests/Exception.tests.cpp index f917932f1..4f91a30c4 100644 --- a/external_imported/Catch2/tests/SelfTest/UsageTests/Exception.tests.cpp +++ b/external_imported/Catch2/tests/SelfTest/UsageTests/Exception.tests.cpp @@ -20,7 +20,7 @@ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wweak-vtables" #pragma clang diagnostic ignored "-Wmissing-noreturn" -#pragma clang diagnostic ignored "-Wunreachable-code" +#pragma clang diagnostic ignored "-Wunreachable-code-return" #endif namespace { diff --git a/external_imported/Catch2/tests/SelfTest/UsageTests/Generators.tests.cpp b/external_imported/Catch2/tests/SelfTest/UsageTests/Generators.tests.cpp index 274c63b8f..f04cf4f09 100644 --- a/external_imported/Catch2/tests/SelfTest/UsageTests/Generators.tests.cpp +++ b/external_imported/Catch2/tests/SelfTest/UsageTests/Generators.tests.cpp @@ -261,6 +261,10 @@ TEST_CASE("Copy and then generate a range", "[generators]") { } } +#if defined( __clang__ ) +# pragma clang diagnostic pop +#endif + TEST_CASE("#1913 - GENERATE inside a for loop should not keep recreating the generator", "[regression][generators]") { static int counter = 0; for (int i = 0; i < 3; ++i) { @@ -301,13 +305,19 @@ namespace { } // namespace -TEST_CASE( "#2615 - Throwing in constructor generator fails test case but does not abort", "[!shouldfail]" ) { +TEST_CASE( "#2615 - Throwing in constructor generator fails test case but does not abort", + "[!shouldfail][regression][generators]" ) { // this should fail the test case, but not abort the application auto sample = GENERATE( make_test_generator() ); // this assertion shouldn't trigger - REQUIRE( sample == 0U ); + REQUIRE( sample == 0 ); } -#if defined( __clang__ ) -# pragma clang diagnostic pop -#endif +TEST_CASE( "GENERATE can combine literals and generators", "[generators]" ) { + auto i = GENERATE( 2, + 4, + take( 2, + filter( []( int val ) { return val % 2 == 0; }, + random( -100, 100 ) ) ) ); + REQUIRE( i % 2 == 0 ); +} diff --git a/external_imported/Catch2/tests/SelfTest/UsageTests/Matchers.tests.cpp b/external_imported/Catch2/tests/SelfTest/UsageTests/Matchers.tests.cpp index 49e25232f..74bedf5ea 100644 --- a/external_imported/Catch2/tests/SelfTest/UsageTests/Matchers.tests.cpp +++ b/external_imported/Catch2/tests/SelfTest/UsageTests/Matchers.tests.cpp @@ -406,6 +406,25 @@ TEST_CASE( "Vector matchers that fail", "[matchers][vector][.][failing]" ) { } } +namespace { + struct SomeType { + int i; + friend bool operator==( SomeType lhs, SomeType rhs ) { + return lhs.i == rhs.i; + } + }; +} // end anonymous namespace + +TEST_CASE( "Vector matcher with elements without !=", "[matchers][vector][approvals]" ) { + std::vector lhs, rhs; + lhs.push_back( { 1 } ); + lhs.push_back( { 2 } ); + rhs.push_back( { 1 } ); + rhs.push_back( { 1 } ); + + REQUIRE_THAT( lhs, !Equals(rhs) ); +} + TEST_CASE( "Exception matchers that succeed", "[matchers][exceptions][!throws]" ) { CHECK_THROWS_MATCHES( @@ -871,7 +890,7 @@ struct MatcherA : Catch::Matchers::MatcherGenericBase { return "equals: (int) 1 or (string) \"1\""; } bool match( int i ) const { return i == 1; } - bool match( std::string s ) const { return s == "1"; } + bool match( std::string const& s ) const { return s == "1"; } }; struct MatcherB : Catch::Matchers::MatcherGenericBase { diff --git a/external_imported/Catch2/tests/SelfTest/UsageTests/MatchersRanges.tests.cpp b/external_imported/Catch2/tests/SelfTest/UsageTests/MatchersRanges.tests.cpp index 05e11b0c3..cc8c54f8b 100644 --- a/external_imported/Catch2/tests/SelfTest/UsageTests/MatchersRanges.tests.cpp +++ b/external_imported/Catch2/tests/SelfTest/UsageTests/MatchersRanges.tests.cpp @@ -381,7 +381,7 @@ TEST_CASE("Usage of AllTrue range matcher", "[matchers][templated][quantifiers]" std::array const data{}; REQUIRE_THAT( data, AllTrue() ); } - SECTION( "One false evalutes to false" ) { + SECTION( "One false evaluates to false" ) { std::array const data{ { true, true, false, true, true } }; REQUIRE_THAT( data, !AllTrue() ); } @@ -398,7 +398,7 @@ TEST_CASE("Usage of AllTrue range matcher", "[matchers][templated][quantifiers]" { { true }, { true }, { true }, { true }, { true } } }; REQUIRE_THAT( data, AllTrue() ); } - SECTION( "One false evalutes to false" ) { + SECTION( "One false evaluates to false" ) { std::array const data{ { { true }, { true }, { false }, { true }, { true } } }; REQUIRE_THAT( data, !AllTrue() ); @@ -446,7 +446,7 @@ TEST_CASE( "Usage of NoneTrue range matcher", "[matchers][templated][quantifiers std::array const data{}; REQUIRE_THAT( data, NoneTrue() ); } - SECTION( "One true evalutes to false" ) { + SECTION( "One true evaluates to false" ) { std::array const data{ { false, false, true, false, false } }; REQUIRE_THAT( data, !NoneTrue() ); @@ -464,7 +464,7 @@ TEST_CASE( "Usage of NoneTrue range matcher", "[matchers][templated][quantifiers { { true }, { true }, { true }, { true }, { true } } }; REQUIRE_THAT( data, !NoneTrue() ); } - SECTION( "One true evalutes to false" ) { + SECTION( "One true evaluates to false" ) { std::array const data{ { { false }, { false }, { true }, { false }, { false } } }; REQUIRE_THAT( data, !NoneTrue() ); @@ -512,7 +512,7 @@ TEST_CASE( "Usage of AnyTrue range matcher", "[matchers][templated][quantifiers] std::array const data{}; REQUIRE_THAT( data, !AnyTrue() ); } - SECTION( "One true evalutes to true" ) { + SECTION( "One true evaluates to true" ) { std::array const data{ { false, false, true, false, false } }; REQUIRE_THAT( data, AnyTrue() ); @@ -530,7 +530,7 @@ TEST_CASE( "Usage of AnyTrue range matcher", "[matchers][templated][quantifiers] { { true }, { true }, { true }, { true }, { true } } }; REQUIRE_THAT( data, AnyTrue() ); } - SECTION( "One true evalutes to true" ) { + SECTION( "One true evaluates to true" ) { std::array const data{ { { false }, { false }, { true }, { false }, { false } } }; REQUIRE_THAT( data, AnyTrue() ); diff --git a/external_imported/Catch2/tests/SelfTest/UsageTests/Message.tests.cpp b/external_imported/Catch2/tests/SelfTest/UsageTests/Message.tests.cpp index a5e695825..6367bf591 100644 --- a/external_imported/Catch2/tests/SelfTest/UsageTests/Message.tests.cpp +++ b/external_imported/Catch2/tests/SelfTest/UsageTests/Message.tests.cpp @@ -255,10 +255,24 @@ std::ostream& operator<<(std::ostream& out, helper_1436 const& helper) { #pragma clang diagnostic ignored "-Wunused-value" #endif +namespace { + template + struct custom_index_op { + constexpr custom_index_op( std::initializer_list ) {} + constexpr T operator[]( size_t ) { return T{}; } +#if defined( __cpp_multidimensional_subscript ) && \ + __cpp_multidimensional_subscript >= 202110L + constexpr T operator[]( size_t, size_t, size_t ) const noexcept { + return T{}; + } +#endif + }; +} + TEST_CASE("CAPTURE can deal with complex expressions involving commas", "[messages][capture]") { - CAPTURE(std::vector{1, 2, 3}[0, 1, 2], - std::vector{1, 2, 3}[(0, 1)], - std::vector{1, 2, 3}[0]); + CAPTURE(custom_index_op{1, 2, 3}[0, 1, 2], + custom_index_op{1, 2, 3}[(0, 1)], + custom_index_op{1, 2, 3}[0]); CAPTURE((helper_1436{12, -12}), (helper_1436(-12, 12))); CAPTURE( (1, 2), (2, 3) ); @@ -285,3 +299,14 @@ TEST_CASE("CAPTURE parses string and character constants", "[messages][capture]" #ifdef _MSC_VER #pragma warning(pop) #endif + +TEST_CASE( "INFO and UNSCOPED_INFO can stream multiple arguments", + "[messages][info][.failing]" ) { + INFO( "This info" + << " has multiple" + << " parts." ); + UNSCOPED_INFO( "This unscoped info" + << " has multiple" + << " parts." ); + FAIL( "Show infos!" ); +} diff --git a/external_imported/Catch2/tests/SelfTest/UsageTests/Misc.tests.cpp b/external_imported/Catch2/tests/SelfTest/UsageTests/Misc.tests.cpp index 6c1fd68f4..7f06704b4 100644 --- a/external_imported/Catch2/tests/SelfTest/UsageTests/Misc.tests.cpp +++ b/external_imported/Catch2/tests/SelfTest/UsageTests/Misc.tests.cpp @@ -217,6 +217,18 @@ TEST_CASE("Testing checked-if 3", "[checked-if][!shouldfail]") { SUCCEED(); } +[[noreturn]] +TEST_CASE("Testing checked-if 4", "[checked-if][!shouldfail]") { + CHECKED_ELSE(true) {} + throw std::runtime_error("Uncaught exception should fail!"); +} + +[[noreturn]] +TEST_CASE("Testing checked-if 5", "[checked-if][!shouldfail]") { + CHECKED_ELSE(false) {} + throw std::runtime_error("Uncaught exception should fail!"); +} + TEST_CASE( "xmlentitycheck" ) { SECTION( "embedded xml: it should be possible to embed xml characters, such as <, \" or &, or even whole documents within an attribute" ) { SUCCEED(); // We need this here to stop it failing due to no tests diff --git a/external_imported/Catch2/tests/SelfTest/UsageTests/Skip.tests.cpp b/external_imported/Catch2/tests/SelfTest/UsageTests/Skip.tests.cpp index 6bd4189b4..661795e11 100644 --- a/external_imported/Catch2/tests/SelfTest/UsageTests/Skip.tests.cpp +++ b/external_imported/Catch2/tests/SelfTest/UsageTests/Skip.tests.cpp @@ -71,3 +71,30 @@ TEST_CASE( "failing for some generator values causes entire test case to fail", FAIL(); } } + +namespace { + class test_skip_generator : public Catch::Generators::IGenerator { + public: + explicit test_skip_generator() { SKIP( "This generator is empty" ); } + + auto get() const -> int const& override { + static constexpr int value = 1; + return value; + } + + auto next() -> bool override { return false; } + }; + + static auto make_test_skip_generator() + -> Catch::Generators::GeneratorWrapper { + return { new test_skip_generator() }; + } + +} // namespace + +TEST_CASE( "Empty generators can SKIP in constructor", "[skipping]" ) { + // The generator signals emptiness with `SKIP` + auto sample = GENERATE( make_test_skip_generator() ); + // This assertion would fail, but shouldn't trigger + REQUIRE( sample == 0 ); +} diff --git a/external_imported/Catch2/tests/SelfTest/UsageTests/ToStringOptional.tests.cpp b/external_imported/Catch2/tests/SelfTest/UsageTests/ToStringOptional.tests.cpp index 9fd9d6b45..3671771a7 100644 --- a/external_imported/Catch2/tests/SelfTest/UsageTests/ToStringOptional.tests.cpp +++ b/external_imported/Catch2/tests/SelfTest/UsageTests/ToStringOptional.tests.cpp @@ -28,4 +28,8 @@ TEST_CASE( "std::vector > -> toString", "[toString][optional] REQUIRE( "{ 0, { }, 2 }" == ::Catch::Detail::stringify( type{ 0, {}, 2 } ) ); } +TEST_CASE( "std::nullopt -> toString", "[toString][optional][approvals]" ) { + REQUIRE( "{ }" == ::Catch::Detail::stringify( std::nullopt ) ); +} + #endif // CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL diff --git a/external_imported/Catch2/tests/TestScripts/DiscoverTests/CMakeLists.txt b/external_imported/Catch2/tests/TestScripts/DiscoverTests/CMakeLists.txt new file mode 100644 index 000000000..d19f2f889 --- /dev/null +++ b/external_imported/Catch2/tests/TestScripts/DiscoverTests/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.10) + +project(discover-tests-test + LANGUAGES CXX +) + +add_executable(tests + register-tests.cpp +) + +add_subdirectory(${CATCH2_PATH} catch2-build) +target_link_libraries(tests PRIVATE Catch2::Catch2WithMain) + +include(CTest) +include(Catch) +catch_discover_tests(tests) diff --git a/external_imported/Catch2/tests/TestScripts/DiscoverTests/VerifyRegistration.py b/external_imported/Catch2/tests/TestScripts/DiscoverTests/VerifyRegistration.py new file mode 100644 index 000000000..9ec42f24c --- /dev/null +++ b/external_imported/Catch2/tests/TestScripts/DiscoverTests/VerifyRegistration.py @@ -0,0 +1,123 @@ +#!/usr/bin/env python3 + +# Copyright Catch2 Authors +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +# SPDX-License-Identifier: BSL-1.0 + +import os +import subprocess +import sys + + +def build_project(sources_dir, output_base_path, catch2_path): + build_dir = os.path.join(output_base_path, 'ctest-registration-test') + config_cmd = ['cmake', + '-B', build_dir, + '-S', sources_dir, + f'-DCATCH2_PATH={catch2_path}', + '-DCMAKE_BUILD_TYPE=Debug'] + + build_cmd = ['cmake', + '--build', build_dir, + '--config', 'Debug'] + + try: + subprocess.run(config_cmd, + capture_output = True, + check = True, + text = True) + subprocess.run(build_cmd, + capture_output = True, + check = True, + text = True) + except subprocess.CalledProcessError as err: + print('Error when building the test project') + print(f'cmd: {err.cmd}') + print(f'stderr: {err.stderr}') + print(f'stdout: {err.stdout}') + exit(3) + + return build_dir + + + +def get_test_names(build_path): + # For now we assume that Windows builds are done using MSBuild under + # Debug configuration. This means that we need to add "Debug" folder + # to the path when constructing it. On Linux, we don't add anything. + config_path = "Debug" if os.name == 'nt' else "" + full_path = os.path.join(build_path, config_path, 'tests') + + + cmd = [full_path, '--reporter', 'xml', '--list-tests'] + result = subprocess.run(cmd, + capture_output = True, + check = True, + text = True) + + import xml.etree.ElementTree as ET + root = ET.fromstring(result.stdout) + return [tc.text for tc in root.findall('TestCase/Name')] + + +def list_ctest_tests(build_path): + old_path = os.getcwd() + os.chdir(build_path) + + cmd = ['ctest', '-C', 'debug', '--show-only=json-v1'] + result = subprocess.run(cmd, + capture_output = True, + check = True, + text = True) + os.chdir(old_path) + + import json + + ctest_response = json.loads(result.stdout) + tests = ctest_response['tests'] + test_names = [] + for test in tests: + test_command = test['command'] + # First part of the command is the binary, second is the filter. + # If there are less, registration has failed. If there are more, + # registration has changed and the script needs updating. + assert len(test_command) == 2 + test_names.append(test_command[1]) + test_name = test_command[1] + + return test_names + +def escape_catch2_test_name(name): + for char in ('\\', ',', '[', ']'): + name = name.replace(char, f"\\{char}") + return name + +if __name__ == '__main__': + if len(sys.argv) != 3: + print(f'Usage: {sys.argv[0]} path-to-catch2-cml output-path') + exit(2) + catch2_path = sys.argv[1] + output_base_path = sys.argv[2] + sources_dir = os.path.dirname(os.path.abspath(sys.argv[0])) + + build_path = build_project(sources_dir, output_base_path, catch2_path) + + catch_test_names = [escape_catch2_test_name(name) for name in get_test_names(build_path)] + ctest_test_names = list_ctest_tests(build_path) + + mismatched = 0 + for catch_test in catch_test_names: + if catch_test not in ctest_test_names: + print(f"Catch2 test '{catch_test}' not found in CTest") + mismatched += 1 + for ctest_test in ctest_test_names: + if ctest_test not in catch_test_names: + print(f"CTest test '{ctest_test}' not found in Catch2") + mismatched += 1 + + if mismatched: + print(f"Found {mismatched} mismatched tests catch test names and ctest test commands!") + exit(1) diff --git a/external_imported/Catch2/tests/TestScripts/DiscoverTests/register-tests.cpp b/external_imported/Catch2/tests/TestScripts/DiscoverTests/register-tests.cpp new file mode 100644 index 000000000..aa603df1a --- /dev/null +++ b/external_imported/Catch2/tests/TestScripts/DiscoverTests/register-tests.cpp @@ -0,0 +1,16 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include + +TEST_CASE("@Script[C:\\EPM1A]=x;\"SCALA_ZERO:\"", "[script regressions]"){} +TEST_CASE("Some test") {} +TEST_CASE( "Let's have a test case with a long name. Longer. No, even longer. " + "Really looooooooooooong. Even longer than that. Multiple lines " + "worth of test name. Yep, like this." ) {} +TEST_CASE( "And now a test case with weird tags.", "[tl;dr][tl;dw][foo,bar]" ) {} diff --git a/external_imported/Catch2/tests/meson.build b/external_imported/Catch2/tests/meson.build index f525f0412..58302b7aa 100644 --- a/external_imported/Catch2/tests/meson.build +++ b/external_imported/Catch2/tests/meson.build @@ -17,6 +17,7 @@ self_test_sources = files( 'SelfTest/IntrospectiveTests/Details.tests.cpp', 'SelfTest/IntrospectiveTests/FloatingPoint.tests.cpp', 'SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp', + 'SelfTest/IntrospectiveTests/Integer.tests.cpp', 'SelfTest/IntrospectiveTests/InternalBenchmark.tests.cpp', 'SelfTest/IntrospectiveTests/Parse.tests.cpp', 'SelfTest/IntrospectiveTests/PartTracker.tests.cpp', diff --git a/external_imported/Catch2/tools/scripts/checkLicense.py b/external_imported/Catch2/tools/scripts/checkLicense.py index 9a9497692..7078d3ec2 100755 --- a/external_imported/Catch2/tools/scripts/checkLicense.py +++ b/external_imported/Catch2/tools/scripts/checkLicense.py @@ -33,7 +33,8 @@ def check_licences_in_path(path: str) -> int: def check_licences(): failed = 0 - roots = ['src/catch2', 'tests'] + # Add 'extras' after the amalgamted files are regenerated with the new script (past 3.4.0) + roots = ['src/catch2', 'tests', 'examples', 'fuzzing'] for root in roots: failed += check_licences_in_path(root) diff --git a/external_imported/Catch2/tools/scripts/generateAmalgamatedFiles.py b/external_imported/Catch2/tools/scripts/generateAmalgamatedFiles.py index 99fc446bf..e3e86aab9 100755 --- a/external_imported/Catch2/tools/scripts/generateAmalgamatedFiles.py +++ b/external_imported/Catch2/tools/scripts/generateAmalgamatedFiles.py @@ -1,4 +1,9 @@ #!/usr/bin/env python3 +# Copyright Catch2 Authors +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) +# SPDX-License-Identifier: BSL-1.0 import os import re @@ -12,6 +17,8 @@ output_header = os.path.join(catchPath, 'extras', 'catch_amalgamated.hpp') output_cpp = os.path.join(catchPath, 'extras', 'catch_amalgamated.cpp') +# REUSE-IgnoreStart + # These are the copyright comments in each file, we want to ignore them copyright_lines = [ '// Copyright Catch2 Authors\n', @@ -24,6 +31,7 @@ # The header of the amalgamated file: copyright information + explanation # what this file is. file_header = '''\ + // Copyright Catch2 Authors // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.txt or copy at @@ -39,6 +47,8 @@ // ---------------------------------------------------------- ''' +# REUSE-IgnoreEnd + # Returns file header with proper version string and generation time def formatted_file_header(version): return file_header.format(version_string=version.getVersionString(), diff --git a/external_imported/Catch2/tools/scripts/releaseCommon.py b/external_imported/Catch2/tools/scripts/releaseCommon.py index 0d995eaf7..1ff4af291 100644 --- a/external_imported/Catch2/tools/scripts/releaseCommon.py +++ b/external_imported/Catch2/tools/scripts/releaseCommon.py @@ -114,8 +114,8 @@ def updateVersionDefine(version): def updateVersionPlaceholder(filename, version): with open(filename, 'rb') as file: lines = file.readlines() - placeholderRegex = re.compile(b'in Catch[0-9]? X.Y.Z') - replacement = 'in Catch2 {}.{}.{}'.format(version.majorVersion, version.minorVersion, version.patchNumber).encode('ascii') + placeholderRegex = re.compile(b'Catch[0-9]? X.Y.Z') + replacement = 'Catch2 {}.{}.{}'.format(version.majorVersion, version.minorVersion, version.patchNumber).encode('ascii') with open(filename, 'wb') as file: for line in lines: file.write(placeholderRegex.sub(replacement, line)) diff --git a/external_imported/Catch2/tools/scripts/updateDocumentToC.py b/external_imported/Catch2/tools/scripts/updateDocumentToC.py index 7b56cfc7a..1840cecc6 100755 --- a/external_imported/Catch2/tools/scripts/updateDocumentToC.py +++ b/external_imported/Catch2/tools/scripts/updateDocumentToC.py @@ -287,7 +287,7 @@ def markdownToclify( Path to the markdown output file. min_toc_len: int (default: 2) - Miniumum number of entries to create a table of contents for. + Minimum number of entries to create a table of contents for. github: bool (default: False) Uses GitHub TOC syntax if True. diff --git a/external_imported/PlatformFolders/.github/workflows/build.yml b/external_imported/PlatformFolders/.github/workflows/build.yml new file mode 100644 index 000000000..12a111e76 --- /dev/null +++ b/external_imported/PlatformFolders/.github/workflows/build.yml @@ -0,0 +1,16 @@ +on: [push] + +jobs: + ci_job: + runs-on: ubuntu-latest + name: Test that the code compiles + steps: + - name: Check Out Repo + uses: actions/checkout@v2 + - name: Test Linux build + run: | + sudo apt-get install -y build-essential cmake + mkdir -p build && cd build + cmake -DPLATFORMFOLDERS_BUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release .. -B . + sudo cmake --build . --target install + ctest diff --git a/external_imported/PlatformFolders/.travis.yml b/external_imported/PlatformFolders/.travis.yml deleted file mode 100644 index cad7ff48b..000000000 --- a/external_imported/PlatformFolders/.travis.yml +++ /dev/null @@ -1,38 +0,0 @@ -language: cpp -matrix: - include: - - os: linux - env: BUILD_TYPE=Debug - compiler: gcc - - os: linux - env: BUILD_TYPE=Debug - compiler: clang - - os: linux - env: BUILD_TYPE=Release - compiler: gcc - - os: linux - env: BUILD_TYPE=Release - compiler: clang - - os: osx - env: BUILD_TYPE=Debug - compiler: gcc - - os: osx - env: BUILD_TYPE=Debug - compiler: clang - - os: osx - env: BUILD_TYPE=Release - compiler: gcc - - os: osx - env: BUILD_TYPE=Release - compiler: clang -before_script: - - mkdir -p build && cd build -script: - # Run cmake, then compile and run tests with make - - cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE .. && make -j$(nproc) && make test -after_failure: - # Dumps any logs so you can read the stderr - - if [[ -e 'Testing/Temporary/LastTest.log' ]]; then cat 'Testing/Temporary/LastTest.log'; fi - - if [[ -e 'CMakeFiles/CMakeError.log' ]]; then cat 'CMakeFiles/CMakeError.log'; fi -notifications: - email: false diff --git a/external_imported/PlatformFolders/CHANGELOG.md b/external_imported/PlatformFolders/CHANGELOG.md new file mode 100644 index 000000000..5da7fab36 --- /dev/null +++ b/external_imported/PlatformFolders/CHANGELOG.md @@ -0,0 +1,91 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). + +## [4.2.0] 2022-02-06 + +### Added + - Support for "state" dir aka Local Machine + +### Changed + - PlatformFolders specific CMake variables are now prefixed with "PLATFORMFOLDERS_" (Thanks @OlivierLDff) + +## [4.1.0] 2021-08-08 + +### Added + - CHANGELOG.md + - Support for CMAKE_DEBUG_POSTFIX. Makes it possible to add a postfix to debug builds + +### Changed + - README.md is now included in the Doxygen documentation + - Should now be thread safe + - Minor internal changes + +## [4.0.0] 2018-06-24 + +### Added + - Support for "Public" folder + - Support for "Saved Games 2". This will be "Saved Games" in Vista and newer + - Unit tests + + +### Changed + - The correct "Download" folder is now returned on Windows + - Now requires a C++11 compatible compiler (was C++98) + - Minimum Windows version raised from Windows XP to Windows 7. + - The Mac version no longer depends on CoreServices + - The XDG implementation are slightly more resilient to unrelated environments in user-dirs.dirs + - Improved CMake system + +### Removed + - C++98 compatibility + - Windows XP compatibility + - No longer needs CoreServices on Mac OS X + +## [3.2.0] 2018-05-28 + +### Added + - Stand-alone functions. Method calls are no longer needed or recommended. + +### Changed + - Fixed a bug in the xdg cache function that caused sago::getCacheDir() to return the wrong folder if XDG_CONFIG_HOME and/or XDG_CACHE_HOME were set + +## [3.1] 2018-04-21 + +### Added + - Now uses CMake for testing (Thanks @sum01) + - It is now possible to compile as a (static) library. (Thanks @sum01) + - Appveyor CI integration (Thanks @sum01) + +### Changed + - Optimised use of iterator. + - No longer keeps empty data structure on Mac and Windows platforms. + +## [3.0] 2016-10-08 + +### Changed + - On Windows the library now returns UTF-8 encoded paths as default. + +## [2.2] 2016-09-06 + +### Fixed + - Fixed a buffer overflow introduced in 2.1 (originally created to ensure C++03 compatibility) + - The example file no longer abuses namespaces. + + +## [2.1] 2016-02-22 + +### Changed + - Updated documentation URL + - No longer uses a variable length array internally + + +## [2.0] 2015-10-26 + +### Added +- Mac OS X support using Core Framework + +## [1.0] 2015-09-21 +Designed to work with Linux and Windows XP+ diff --git a/external_imported/PlatformFolders/CMakeLists.txt b/external_imported/PlatformFolders/CMakeLists.txt index d82991ecc..5ae2017ca 100644 --- a/external_imported/PlatformFolders/CMakeLists.txt +++ b/external_imported/PlatformFolders/CMakeLists.txt @@ -1,14 +1,33 @@ # For target_compile_features cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) -project(platform_folders VERSION 4.0.0 LANGUAGES CXX) -# Since it's off, the library will be static by default -option(BUILD_SHARED_LIBS "Build shared instead of static." OFF) +set(PLATFORMFOLDERS_MAIN_PROJECT OFF) +if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) + set(PLATFORMFOLDERS_MAIN_PROJECT ON) +endif() + +project(platform_folders VERSION 4.2.0 LANGUAGES CXX) -add_library(platform_folders +# BUILD_SHARED_LIBS is off by default, the library will be static by default +option(PLATFORMFOLDERS_BUILD_SHARED_LIBS "Build platform_folders shared library" ${BUILD_SHARED_LIBS}) +option(PLATFORMFOLDERS_BUILD_TESTING "Build platform_folders tests" ${PLATFORMFOLDERS_MAIN_PROJECT}) +option(PLATFORMFOLDERS_ENABLE_INSTALL "Enable platform_folders INSTALL target" ${PLATFORMFOLDERS_MAIN_PROJECT}) + +set(PLATFORMFOLDERS_TYPE STATIC) +if(PLATFORMFOLDERS_BUILD_SHARED_LIBS) + set(PLATFORMFOLDERS_TYPE SHARED) +endif() + +add_library(platform_folders ${PLATFORMFOLDERS_TYPE} sago/platform_folders.cpp ) +set_target_properties(platform_folders PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}") + +# Creates an alias so that people building in-tree (instead of using find_package)... +# can still link against the same target +add_library(sago::platform_folders ALIAS platform_folders) + # Defines standardized defaults for install paths include(GNUInstallDirs) # Where to search for the header while building @@ -57,52 +76,52 @@ else() set(_PROJECT_INSTALL_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/platform_folders") endif() -# Gives "Make install" esque operations a location to install to... -# and creates a .cmake file to be exported -install(TARGETS platform_folders - EXPORT "platform_foldersConfig" - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" - # Tells it where to put the header files - PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sago" -) +if(PLATFORMFOLDERS_ENABLE_INSTALL) + # Gives "Make install" esque operations a location to install to... + # and creates a .cmake file to be exported + install(TARGETS platform_folders + EXPORT "platform_foldersConfig" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + # Tells it where to put the header files + PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sago" + ) -# "The install(TARGETS) and install(EXPORT) commands work together to install a target and a file to help import it" -# Installs a cmake file which external projects can import. -install(EXPORT "platform_foldersConfig" - NAMESPACE sago:: - DESTINATION "${_PROJECT_INSTALL_CMAKE_DIR}" -) + # "The install(TARGETS) and install(EXPORT) commands work together to install a target and a file to help import it" + # Installs a cmake file which external projects can import. + install(EXPORT "platform_foldersConfig" + NAMESPACE sago:: + DESTINATION "${_PROJECT_INSTALL_CMAKE_DIR}" + ) -# "The export command is used to generate a file exporting targets from a project build tree" -# Creates an import file for external projects which are aware of the build tree. -# May be useful for cross-compiling -export(TARGETS platform_folders - FILE "platform_folders-exports.cmake" -) + # "The export command is used to generate a file exporting targets from a project build tree" + # Creates an import file for external projects which are aware of the build tree. + # May be useful for cross-compiling + export(TARGETS platform_folders + FILE "platform_folders-exports.cmake" + ) -# For the config and configversion macros -include(CMakePackageConfigHelpers) + # For the config and configversion macros + include(CMakePackageConfigHelpers) -# Creates the project's ConfigVersion.cmake file -# This allows for find_package() to use a version in the call -write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/platform_foldersConfigVersion.cmake" - # This'll require versioning in the project() call - VERSION ${CMAKE_PROJECT_VERSION} - # Just assuming Semver is followed - COMPATIBILITY SameMajorVersion -) + # Creates the project's ConfigVersion.cmake file + # This allows for find_package() to use a version in the call + write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/platform_foldersConfigVersion.cmake" + # This'll require versioning in the project() call + VERSION ${CMAKE_PROJECT_VERSION} + # Just assuming Semver is followed + COMPATIBILITY SameMajorVersion + ) -# Install the ConfigVersion file, which is located in the build dir -install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/platform_foldersConfigVersion.cmake" - DESTINATION "${_PROJECT_INSTALL_CMAKE_DIR}" -) + # Install the ConfigVersion file, which is located in the build dir + install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/platform_foldersConfigVersion.cmake" + DESTINATION "${_PROJECT_INSTALL_CMAKE_DIR}" + ) +endif() -# A module for testing the library -include(CTest) -# BUILD_TESTING is defined (default ON) in CTest -if(BUILD_TESTING) +if(PLATFORMFOLDERS_BUILD_TESTING) + enable_testing() add_subdirectory(test) add_executable(platform_folders_sample platform_folders.cpp) target_link_libraries(platform_folders_sample PRIVATE platform_folders) diff --git a/external_imported/PlatformFolders/README.md b/external_imported/PlatformFolders/README.md index 4978a0f28..e988ad539 100644 --- a/external_imported/PlatformFolders/README.md +++ b/external_imported/PlatformFolders/README.md @@ -2,7 +2,7 @@ A C++ library to look for directories like `My Documents`, `~/.config`, `%APPDATA%`, etc. so that you do not need to write platform-specific code -[Source code](https://github.com/sago007/PlatformFolders) • [Latest release](https://github.com/sago007/PlatformFolders/releases/latest) • [Doxygen documentation](http://sago007.github.io/PlatformFolders/html/doxygen/) +[Source code](https://github.com/sago007/PlatformFolders) • [Latest release](https://github.com/sago007/PlatformFolders/releases/latest) • [Doxygen documentation](https://sago007.github.io/PlatformFolders/html/doxygen/) ## Rationale @@ -11,11 +11,11 @@ There are a lot of platform abstraction libraries available. You can get graphic But folder abstraction seems to be more difficult. My problem was that the code that found the place to save data was platform dependent. This cluttered my code and often I would not discover that it did not compile until moving it to the different platforms. -[I have written a bit more about it here.](http://sago007.blogspot.dk/2015/10/abstraction-for-special-folders.html) +[I have written a bit more about it here.](https://sago007.blogspot.dk/2015/10/abstraction-for-special-folders.html) There are some alternatives that you might consider instead: -* [QStandardPaths](http://doc.qt.io/qt-5/qstandardpaths.html) +* [QStandardPaths](https://doc.qt.io/qt-5/qstandardpaths.html) * [glib](https://developer.gnome.org/glib/stable/glib-Miscellaneous-Utility-Functions.html) Both are properly more mature than this library. However they are both parts of large frameworks and using them with libraries outside the framework may not be that simple. @@ -45,9 +45,9 @@ This project should be compatible with things like [Cmake's ExternalProject_Add] You can also follow the [build step](#building) below to install at a system level, and use [Cmake's find_package](https://cmake.org/cmake/help/latest/command/find_package.html). ```cmake -# Specifying a version is optional -- note it follows by Semver +# Specifying a version is optional -- note it follows Semver find_package(platform_folders 3.1.0 REQUIRED) -# Which creates the IMPORTED lib "sago::platform_folders" +# Which imports the linkable library "sago::platform_folders" # Use it like so... target_link_libraries(EXEORLIBNAME PRIVATE sago::platform_folders) ``` @@ -55,6 +55,8 @@ target_link_libraries(EXEORLIBNAME PRIVATE sago::platform_folders) Alternatively, you can just copy the [sago](https://github.com/sago007/PlatformFolders/tree/master/sago) folder into your program and manually link everything. If you use the last option and are using a library version from before 4.0.0: Remember to link to the CoreServices lib when compiling on Mac. This typically means passing "-framework CoreServices" during the linking phase. +Note that if you build in-tree, you can link against the Cmake alias `sago::platform_folders` just like if you had used find_package. + ### Building **Notes:** @@ -91,6 +93,7 @@ int main() { std::cout << "Config: " << sago::getConfigHome() << "\n"; std::cout << "Data: " << sago::getDataHome() << "\n"; + std::cout << "State: " << sago::getStateDir() << "\n"; std::cout << "Cache: " << sago::getCacheDir() << "\n"; std::cout << "Documents: " << sago::getDocumentsFolder() << "\n"; std::cout << "Desktop: " << sago::getDesktopFolder() << "\n"; @@ -111,6 +114,7 @@ int main() ``` Config: /home/poul/.config Data: /home/poul/.local/share +State: /home/poul/.local/state Cache: /home/poul/.cache Documents: /home/poul/Dokumenter Desktop: /home/poul/Skrivebord @@ -127,6 +131,7 @@ Save Games 2: /home/poul/.local/share ``` Config: C:\users\poul\Application Data Data: C:\users\poul\Application Data +State: C:\users\poul\Local Settings\Application Data Cache: C:\users\poul\Local Settings\Application Data Documents: C:\users\poul\Mine dokumenter Desktop: C:\users\poul\Skrivebord @@ -143,6 +148,7 @@ Save Games 2: C:\users\poul\Saved Games ``` Config: /Users/poul/Library/Application Support Data: /Users/poul/Library/Application Support +State: /Users/poul/Library/Application Support Cache: /Users/poul/Library/Caches Documents: /Users/poul/Documents Desktop: /Users/poul/Desktop diff --git a/external_imported/PlatformFolders/doxygen.conf b/external_imported/PlatformFolders/doxygen.conf index cea077bc8..66b6a4314 100644 --- a/external_imported/PlatformFolders/doxygen.conf +++ b/external_imported/PlatformFolders/doxygen.conf @@ -38,7 +38,7 @@ PROJECT_NAME = "Platform folders" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "4.0.0" +PROJECT_NUMBER = "4.2.0" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a @@ -894,7 +894,8 @@ FILTER_SOURCE_PATTERNS = # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. -USE_MDFILE_AS_MAINPAGE = +INPUT += README.md +USE_MDFILE_AS_MAINPAGE = README.md #--------------------------------------------------------------------------- # Configuration options related to source browsing diff --git a/external_imported/PlatformFolders/platform_folders.cpp b/external_imported/PlatformFolders/platform_folders.cpp index 08a23dfc6..0c796b6cd 100644 --- a/external_imported/PlatformFolders/platform_folders.cpp +++ b/external_imported/PlatformFolders/platform_folders.cpp @@ -30,6 +30,7 @@ int main() { std::cout << "Config: " << sago::getConfigHome() << "\n"; std::cout << "Data: " << sago::getDataHome() << "\n"; + std::cout << "State: " << sago::getStateDir() << "\n"; std::cout << "Cache: " << sago::getCacheDir() << "\n"; std::cout << "Documents: " << sago::getDocumentsFolder() << "\n"; std::cout << "Desktop: " << sago::getDesktopFolder() << "\n"; diff --git a/external_imported/PlatformFolders/sago/platform_folders.cpp b/external_imported/PlatformFolders/sago/platform_folders.cpp index f4e699e09..b1a08745d 100644 --- a/external_imported/PlatformFolders/sago/platform_folders.cpp +++ b/external_imported/PlatformFolders/sago/platform_folders.cpp @@ -52,8 +52,16 @@ static std::string getHome() { res = homeEnv; return res; } - struct passwd* pw = getpwuid(uid); - if (!pw) { + struct passwd* pw = nullptr; + struct passwd pwd; + long bufsize = sysconf(_SC_GETPW_R_SIZE_MAX); + if (bufsize < 0) { + bufsize = 16384; + } + std::vector buffer; + buffer.resize(bufsize); + int error_code = getpwuid_r(uid, &pwd, buffer.data(), buffer.size(), &pw); + if (error_code) { throw std::runtime_error("Unable to get passwd struct."); } const char* tempRes = pw->pw_dir; @@ -64,7 +72,7 @@ static std::string getHome() { return res; } -#endif +#endif #ifdef _WIN32 // Make sure we don't bring in all the extra junk with windows.h @@ -80,24 +88,29 @@ static std::string getHome() { // For SHGetFolderPathW and various CSIDL "magic numbers" #include -static std::string win32_utf16_to_utf8(const wchar_t* wstr) { +namespace sago { +namespace internal { + +std::string win32_utf16_to_utf8(const wchar_t* wstr) { std::string res; // If the 6th parameter is 0 then WideCharToMultiByte returns the number of bytes needed to store the result. int actualSize = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, nullptr, 0, nullptr, nullptr); if (actualSize > 0) { //If the converted UTF-8 string could not be in the initial buffer. Allocate one that can hold it. std::vector buffer(actualSize); - actualSize = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, &buffer[0], buffer.size(), nullptr, nullptr); + actualSize = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, &buffer[0], static_cast(buffer.size()), nullptr, nullptr); res = buffer.data(); } if (actualSize == 0) { // WideCharToMultiByte return 0 for errors. - const std::string errorMsg = "UTF16 to UTF8 failed with error code: " + GetLastError(); - throw std::runtime_error(errorMsg.c_str()); + throw std::runtime_error("UTF16 to UTF8 failed with error code: " + std::to_string(GetLastError())); } return res; } +} // namesapce internal +} // namespace sago + class FreeCoTaskMemory { LPWSTR pointer = NULL; public: @@ -116,7 +129,7 @@ static std::string GetKnownWindowsFolder(REFKNOWNFOLDERID folderId, const char* if (!SUCCEEDED(hr)) { throw std::runtime_error(errorMsg); } - return win32_utf16_to_utf8(wszPath); + return sago::internal::win32_utf16_to_utf8(wszPath); } static std::string GetAppData() { @@ -137,6 +150,7 @@ static std::string GetAppDataLocal() { #include // For strlen and strtok #include +#include //Typically Linux. For easy reading the comments will just say Linux but should work with most *nixes static void throwOnRelative(const char* envName, const char* envValue) { @@ -161,28 +175,12 @@ static std::string getLinuxFolderDefault(const char* envName, const char* defaul return res; } -static void appendExtraFoldersTokenizer(const char* envName, const char* envValue, std::vector& folders) { - std::vector buffer(envValue, envValue + std::strlen(envValue) + 1); - char* p = std::strtok ( &buffer[0], ":"); - while (p != nullptr) { - if (p[0] == '/') { - folders.push_back(p); - } - else { - //Unless the system is wrongly configured this should never happen... But of course some systems will be incorectly configured. - //The XDG documentation indicates that the folder should be ignored but that the program should continue. - std::cerr << "Skipping path \"" << p << "\" in \"" << envName << "\" because it does not start with a \"/\"\n"; - } - p = std::strtok (nullptr, ":"); - } -} - static void appendExtraFolders(const char* envName, const char* defaultValue, std::vector& folders) { const char* envValue = std::getenv(envName); if (!envValue) { envValue = defaultValue; } - appendExtraFoldersTokenizer(envName, envValue, folders); + sago::internal::appendExtraFoldersTokenizer(envName, envValue, folders); } #endif @@ -190,6 +188,25 @@ static void appendExtraFolders(const char* envName, const char* defaultValue, st namespace sago { +#if !defined(_WIN32) && !defined(__APPLE__) +namespace internal { +void appendExtraFoldersTokenizer(const char* envName, const char* envValue, std::vector& folders) { + std::stringstream ss(envValue); + std::string value; + while (std::getline(ss, value, ':')) { + if (value[0] == '/') { + folders.push_back(value); + } + else { + //Unless the system is wrongly configured this should never happen... But of course some systems will be incorectly configured. + //The XDG documentation indicates that the folder should be ignored but that the program should continue. + std::cerr << "Skipping path \"" << value << "\" in \"" << envName << "\" because it does not start with a \"/\"\n"; + } + } +} +} +#endif + std::string getDataHome() { #ifdef _WIN32 return GetAppData(); @@ -220,6 +237,16 @@ std::string getCacheDir() { #endif } +std::string getStateDir() { +#ifdef _WIN32 + return GetAppDataLocal(); +#elif defined(__APPLE__) + return getHome()+"/Library/Application Support"; +#else + return getLinuxFolderDefault("XDG_STATE_HOME", ".local/state"); +#endif +} + void appendAdditionalDataDirectories(std::vector& homes) { #ifdef _WIN32 homes.push_back(GetAppDataCommon()); @@ -255,7 +282,8 @@ static void PlatformFoldersAddFromFile(const std::string& filename, std::map& folders); +#endif +#ifdef _WIN32 +std::string win32_utf16_to_utf8(const wchar_t* wstr); +#endif +} +#endif //DOXYGEN_SHOULD_SKIP_THIS + /** * Retrives the base folder for storing data files. * You must add the program name yourself like this: @@ -44,7 +55,7 @@ namespace sago { * string data_home = getDataHome()+"/My Program Name/"; * @endcode * On Windows this defaults to %APPDATA% (Roaming profile) - * On Linux this defaults to ~/.local/share but can be configured + * On Linux this defaults to ~/.local/share but can be configured by the user * @return The base folder for storing program data. */ std::string getDataHome(); @@ -56,7 +67,7 @@ std::string getDataHome(); * string data_home = getConfigHome()+"/My Program Name/"; * @endcode * On Windows this defaults to %APPDATA% (Roaming profile) - * On Linux this defaults to ~/.config but can be configured + * On Linux this defaults to ~/.config but can be configured by the user * @return The base folder for storing config data. */ std::string getConfigHome(); @@ -65,14 +76,28 @@ std::string getConfigHome(); * Retrives the base folder for storing cache files. * You must add the program name yourself like this: * @code{.cpp} - * string data_home = getCacheDir()+"/My Program Name/"; + * string data_home = getCacheDir()+"/My Program Name/cache/"; * @endcode * On Windows this defaults to %APPDATALOCAL% - * On Linux this defaults to ~/.cache but can be configured - * @return The base folder for storing data that do not need to be backed up. + * On Linux this defaults to ~/.cache but can be configured by the user + * Note that it is recommended to append "cache" after the program name to prevent conflicting with "StateDir" under Windows + * @return The base folder for storing data that do not need to be backed up and might be deleted. */ std::string getCacheDir(); +/** + * Retrives the base folder used for state files. + * You must add the program name yourself like this: + * @code{.cpp} + * string data_home = getStateDir()+"/My Program Name/"; + * @endcode + * On Windows this defaults to %APPDATALOCAL% + * On Linux this defaults to ~/.local/state but can be configured by the user + * On OS X this is the same as getDataHome() + * @return The base folder for storing data that do not need to be backed up but should not be reguarly deleted either. + */ +std::string getStateDir(); + /** * This will append extra folders that your program should be looking for data files in. * This does not normally include the path returned by GetDataHome(). @@ -214,7 +239,7 @@ class PlatformFolders { */ std::string getPicturesFolder() const; /** - * Use sago::getPublicFolder() instead! + * Use sago::getPublicFolder() instead! */ std::string getPublicFolder() const; /** diff --git a/external_imported/PlatformFolders/test/CMakeLists.txt b/external_imported/PlatformFolders/test/CMakeLists.txt index a5568831a..c11103e5b 100644 --- a/external_imported/PlatformFolders/test/CMakeLists.txt +++ b/external_imported/PlatformFolders/test/CMakeLists.txt @@ -47,5 +47,7 @@ _def_test("getMusicFolder") _def_test("getPicturesFolder") _def_test("getPublicFolder") _def_test("getSaveGamesFolder1") +_def_test("getStateDir") _def_test("getVideoFolder") _def_test("integration") +_def_test("internalTest") \ No newline at end of file diff --git a/external_imported/PlatformFolders/test/appendAdditionalDataDirectories.cpp b/external_imported/PlatformFolders/test/appendAdditionalDataDirectories.cpp index ab83d22db..75d874c1c 100644 --- a/external_imported/PlatformFolders/test/appendAdditionalDataDirectories.cpp +++ b/external_imported/PlatformFolders/test/appendAdditionalDataDirectories.cpp @@ -2,6 +2,7 @@ #include "../sago/platform_folders.h" #include #include +#include int main() { std::vector extraData; diff --git a/external_imported/PlatformFolders/test/getStateDir.cpp b/external_imported/PlatformFolders/test/getStateDir.cpp new file mode 100644 index 000000000..294a00c7f --- /dev/null +++ b/external_imported/PlatformFolders/test/getStateDir.cpp @@ -0,0 +1,7 @@ +#include "tester.hpp" +#include "../sago/platform_folders.h" + +int main() { + run_test(sago::getStateDir()); + return 0; +} diff --git a/external_imported/PlatformFolders/test/internalTest.cpp b/external_imported/PlatformFolders/test/internalTest.cpp new file mode 100644 index 000000000..faae2c1dc --- /dev/null +++ b/external_imported/PlatformFolders/test/internalTest.cpp @@ -0,0 +1,22 @@ +#include "tester.hpp" +#include "../sago/platform_folders.h" +#include +#include +#include + +int main() { + std::vector extraData; + #if !defined(_WIN32) && !defined(__APPLE__) + extraData.clear(); + sago::internal::appendExtraFoldersTokenizer("", "/hello:two:/three", extraData); + if (extraData.at(0) != "/hello") { + std::cerr << "sago::internal::appendExtraFoldersTokenizer did not return \"/hello\"\n"; + std::exit(EXIT_FAILURE); + } + if (extraData.at(1) != "/three") { + std::cerr << "sago::internal::appendExtraFoldersTokenizer did not return \"/three\"\n"; + std::exit(EXIT_FAILURE); + } + #endif + return 0; +} diff --git a/external_imported/cpp-httplib/.github/workflows/test.yaml b/external_imported/cpp-httplib/.github/workflows/test.yaml index 2bf0c3dfd..173daa8c8 100644 --- a/external_imported/cpp-httplib/.github/workflows/test.yaml +++ b/external_imported/cpp-httplib/.github/workflows/test.yaml @@ -17,7 +17,7 @@ jobs: git config --global core.autocrlf false git config --global core.eol lf - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: install brotli library on ubuntu if: matrix.os == 'ubuntu-latest' run: sudo apt update && sudo apt-get install -y libbrotli-dev @@ -32,7 +32,7 @@ jobs: run: cd test && make fuzz_test - name: setup msbuild on windows if: matrix.os == 'windows-latest' - uses: microsoft/setup-msbuild@v1.0.2 + uses: microsoft/setup-msbuild@v1.1 - name: make-windows if: matrix.os == 'windows-latest' run: | diff --git a/external_imported/cpp-httplib/CMakeLists.txt b/external_imported/cpp-httplib/CMakeLists.txt index e8781c1ff..73de51189 100644 --- a/external_imported/cpp-httplib/CMakeLists.txt +++ b/external_imported/cpp-httplib/CMakeLists.txt @@ -3,18 +3,21 @@ * BUILD_SHARED_LIBS (default off) builds as a shared library (if HTTPLIB_COMPILE is ON) * HTTPLIB_USE_OPENSSL_IF_AVAILABLE (default on) * HTTPLIB_USE_ZLIB_IF_AVAILABLE (default on) + * HTTPLIB_USE_BROTLI_IF_AVAILABLE (default on) * HTTPLIB_REQUIRE_OPENSSL (default off) * HTTPLIB_REQUIRE_ZLIB (default off) - * HTTPLIB_USE_BROTLI_IF_AVAILABLE (default on) * HTTPLIB_REQUIRE_BROTLI (default off) + * HTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN (default on) * HTTPLIB_COMPILE (default off) + * HTTPLIB_INSTALL (default on) + * HTTPLIB_TEST (default off) * BROTLI_USE_STATIC_LIBS - tells Cmake to use the static Brotli libs (only works if you have them installed). * OPENSSL_USE_STATIC_LIBS - tells Cmake to use the static OpenSSL libs (only works if you have them installed). ------------------------------------------------------------------------------- - After installation with Cmake, a find_package(httplib) is available. - This creates a httplib::httplib target (if found). + After installation with Cmake, a find_package(httplib COMPONENTS OpenSSL ZLIB Brotli) is available. + This creates a httplib::httplib target (if found and if listed components are supported). It can be linked like so: target_link_libraries(your_exe httplib::httplib) @@ -42,6 +45,7 @@ * HTTPLIB_IS_USING_OPENSSL - a bool for if OpenSSL support is enabled. * HTTPLIB_IS_USING_ZLIB - a bool for if ZLIB support is enabled. * HTTPLIB_IS_USING_BROTLI - a bool for if Brotli support is enabled. + * HTTPLIB_IS_USING_CERTS_FROM_MACOSX_KEYCHAIN - a bool for if support of loading system certs from the Apple Keychain is enabled. * HTTPLIB_IS_COMPILED - a bool for if the library is compiled, or otherwise header-only. * HTTPLIB_INCLUDE_DIR - the root path to httplib's header (e.g. /usr/include). * HTTPLIB_LIBRARY - the full path to the library if compiled (e.g. /usr/lib/libhttplib.so). @@ -55,7 +59,6 @@ ------------------------------------------------------------------------------- - FindPython3 requires Cmake v3.12 ARCH_INDEPENDENT option of write_basic_package_version_file() requires Cmake v3.14 ]] cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR) @@ -65,32 +68,34 @@ cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR) # This is so the maintainer doesn't actually need to update this manually. file(STRINGS httplib.h _raw_version_string REGEX "CPPHTTPLIB_VERSION \"([0-9]+\\.[0-9]+\\.[0-9]+)\"") -# Needed since git tags have "v" prefixing them. -# Also used if the fallback to user agent string is being used. +# Extracts just the version string itself from the whole string contained in _raw_version_string +# since _raw_version_string would contain the entire line of code where it found the version string string(REGEX MATCH "([0-9]+\\.?)+" _httplib_version "${_raw_version_string}") project(httplib VERSION ${_httplib_version} LANGUAGES CXX) # Change as needed to set an OpenSSL minimum version. # This is used in the installed Cmake config file. -set(_HTTPLIB_OPENSSL_MIN_VER "1.1.1") +set(_HTTPLIB_OPENSSL_MIN_VER "3.0.0") +# Lets you disable C++ exception during CMake configure time. +# The value is used in the install CMake config file. +option(HTTPLIB_NO_EXCEPTIONS "Disable the use of C++ exceptions" OFF) # Allow for a build to require OpenSSL to pass, instead of just being optional option(HTTPLIB_REQUIRE_OPENSSL "Requires OpenSSL to be found & linked, or fails build." OFF) option(HTTPLIB_REQUIRE_ZLIB "Requires ZLIB to be found & linked, or fails build." OFF) -# Allow for a build to casually enable OpenSSL/ZLIB support, but silenty continue if not found. +# Allow for a build to casually enable OpenSSL/ZLIB support, but silently continue if not found. # Make these options so their automatic use can be specifically disabled (as needed) option(HTTPLIB_USE_OPENSSL_IF_AVAILABLE "Uses OpenSSL (if available) to enable HTTPS support." ON) option(HTTPLIB_USE_ZLIB_IF_AVAILABLE "Uses ZLIB (if available) to enable Zlib compression support." ON) # Lets you compile the program as a regular library instead of header-only option(HTTPLIB_COMPILE "If ON, uses a Python script to split the header into a compilable header & source file (requires Python v3)." OFF) -# Just setting this variable here for people building in-tree -if(HTTPLIB_COMPILE) - set(HTTPLIB_IS_COMPILED TRUE) -endif() - +# Lets you disable the installation (useful when fetched from another CMake project) +option(HTTPLIB_INSTALL "Enables the installation target" ON) +option(HTTPLIB_TEST "Enables testing and builds tests" OFF) option(HTTPLIB_REQUIRE_BROTLI "Requires Brotli to be found & linked, or fails build." OFF) option(HTTPLIB_USE_BROTLI_IF_AVAILABLE "Uses Brotli (if available) to enable Brotli decompression support." ON) +option(HTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN "Enable feature to load system certs from the Apple Keychain." ON) # Defaults to static library option(BUILD_SHARED_LIBS "Build the library as a shared library instead of static. Has no effect if using header-only." OFF) if (BUILD_SHARED_LIBS AND WIN32 AND HTTPLIB_COMPILE) @@ -99,40 +104,48 @@ if (BUILD_SHARED_LIBS AND WIN32 AND HTTPLIB_COMPILE) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) endif() +# Set some variables that are used in-tree and while building based on our options +set(HTTPLIB_IS_COMPILED ${HTTPLIB_COMPILE}) +set(HTTPLIB_IS_USING_CERTS_FROM_MACOSX_KEYCHAIN ${HTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN}) + # Threads needed for on some systems, and for on Linux +set(THREADS_PREFER_PTHREAD_FLAG TRUE) find_package(Threads REQUIRED) # Since Cmake v3.11, Crypto & SSL became optional when not specified as COMPONENTS. if(HTTPLIB_REQUIRE_OPENSSL) find_package(OpenSSL ${_HTTPLIB_OPENSSL_MIN_VER} COMPONENTS Crypto SSL REQUIRED) + set(HTTPLIB_IS_USING_OPENSSL TRUE) elseif(HTTPLIB_USE_OPENSSL_IF_AVAILABLE) find_package(OpenSSL ${_HTTPLIB_OPENSSL_MIN_VER} COMPONENTS Crypto SSL QUIET) -endif() -# Just setting this variable here for people building in-tree -if(OPENSSL_FOUND) - set(HTTPLIB_IS_USING_OPENSSL TRUE) + # Avoid a rare circumstance of not finding all components but the end-user did their + # own call for OpenSSL, which might trick us into thinking we'd otherwise have what we wanted + if (TARGET OpenSSL::SSL AND TARGET OpenSSL::Crypto) + set(HTTPLIB_IS_USING_OPENSSL ${OPENSSL_FOUND}) + else() + set(HTTPLIB_IS_USING_OPENSSL FALSE) + endif() endif() if(HTTPLIB_REQUIRE_ZLIB) find_package(ZLIB REQUIRED) + set(HTTPLIB_IS_USING_ZLIB TRUE) elseif(HTTPLIB_USE_ZLIB_IF_AVAILABLE) find_package(ZLIB QUIET) -endif() -# Just setting this variable here for people building in-tree -# FindZLIB doesn't have a ZLIB_FOUND variable, so check the target. -if(TARGET ZLIB::ZLIB) - set(HTTPLIB_IS_USING_ZLIB TRUE) + # FindZLIB doesn't have a ZLIB_FOUND variable, so check the target. + if(TARGET ZLIB::ZLIB) + set(HTTPLIB_IS_USING_ZLIB TRUE) + endif() endif() # Adds our cmake folder to the search path for find_package +# This is so we can use our custom FindBrotli.cmake list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") if(HTTPLIB_REQUIRE_BROTLI) find_package(Brotli COMPONENTS encoder decoder common REQUIRED) + set(HTTPLIB_IS_USING_BROTLI TRUE) elseif(HTTPLIB_USE_BROTLI_IF_AVAILABLE) find_package(Brotli COMPONENTS encoder decoder common QUIET) -endif() -# Just setting this variable here for people building in-tree -if(Brotli_FOUND) - set(HTTPLIB_IS_USING_BROTLI TRUE) + set(HTTPLIB_IS_USING_BROTLI ${Brotli_FOUND}) endif() # Used for default, common dirs that the end-user can change (if needed) @@ -160,7 +173,7 @@ if(HTTPLIB_COMPILE) ERROR_VARIABLE _httplib_split_error ) if(_httplib_split_error) - message(FATAL_ERROR "Failed when trying to split Cpp-httplib with the Python script.\n${_httplib_split_error}") + message(FATAL_ERROR "Failed when trying to split cpp-httplib with the Python script.\n${_httplib_split_error}") endif() # split.py puts output in "out" @@ -175,7 +188,7 @@ if(HTTPLIB_COMPILE) set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${${PROJECT_NAME}_VERSION} - SOVERSION ${${PROJECT_NAME}_VERSION_MAJOR} + SOVERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}" ) else() # This is for header-only. @@ -187,22 +200,10 @@ endif() # Only useful if building in-tree, versus using it from an installation. add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) -# Might be missing some, but this list is somewhat comprehensive -target_compile_features(${PROJECT_NAME} ${_INTERFACE_OR_PUBLIC} - cxx_std_11 - cxx_nullptr - cxx_lambdas - cxx_override - cxx_defaulted_functions - cxx_attribute_deprecated - cxx_auto_type - cxx_decltype - cxx_deleted_functions - cxx_range_for - cxx_sizeof_member -) +# Require C++11 +target_compile_features(${PROJECT_NAME} ${_INTERFACE_OR_PUBLIC} cxx_std_11) -target_include_directories(${PROJECT_NAME} ${_INTERFACE_OR_PUBLIC} +target_include_directories(${PROJECT_NAME} SYSTEM ${_INTERFACE_OR_PUBLIC} $ $ ) @@ -213,7 +214,8 @@ target_link_libraries(${PROJECT_NAME} ${_INTERFACE_OR_PUBLIC} # Needed for Windows libs on Mingw, as the pragma comment(lib, "xyz") aren't triggered. $<$:ws2_32> $<$:crypt32> - $<$:cryptui> + # Needed for API from MacOS Security framework + "$<$,$,$>:-framework CoreFoundation -framework Security>" # Can't put multiple targets in a single generator expression or it bugs out. $<$:Brotli::common> $<$:Brotli::encoder> @@ -225,20 +227,15 @@ target_link_libraries(${PROJECT_NAME} ${_INTERFACE_OR_PUBLIC} # Set the definitions to enable optional features target_compile_definitions(${PROJECT_NAME} ${_INTERFACE_OR_PUBLIC} + $<$:CPPHTTPLIB_NO_EXCEPTIONS> $<$:CPPHTTPLIB_BROTLI_SUPPORT> $<$:CPPHTTPLIB_ZLIB_SUPPORT> $<$:CPPHTTPLIB_OPENSSL_SUPPORT> + $<$,$,$>:CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN> ) -# Cmake's find_package search path is different based on the system -# See https://cmake.org/cmake/help/latest/command/find_package.html for the list -if(CMAKE_SYSTEM_NAME STREQUAL "Windows") - set(_TARGET_INSTALL_CMAKEDIR "${CMAKE_INSTALL_PREFIX}/cmake/${PROJECT_NAME}") -else() - # On Non-Windows, it should be /usr/lib/cmake//Config.cmake - # NOTE: This may or may not work for macOS... - set(_TARGET_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") -endif() +# CMake configuration files installation directory +set(_TARGET_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") include(CMakePackageConfigHelpers) @@ -248,51 +245,52 @@ configure_package_config_file("${PROJECT_NAME}Config.cmake.in" INSTALL_DESTINATION "${_TARGET_INSTALL_CMAKEDIR}" # Passes the includedir install path PATH_VARS CMAKE_INSTALL_FULL_INCLUDEDIR - # There aren't any components, so don't use the macro - NO_CHECK_REQUIRED_COMPONENTS_MACRO ) if(HTTPLIB_COMPILE) write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake" # Example: if you find_package(httplib 0.5.4) - # then anything >= 0.5 and <= 1.0 is accepted - COMPATIBILITY SameMajorVersion + # then anything >= 0.5.4 and < 0.6 is accepted + COMPATIBILITY SameMinorVersion ) else() write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake" # Example: if you find_package(httplib 0.5.4) - # then anything >= 0.5 and <= 1.0 is accepted - COMPATIBILITY SameMajorVersion + # then anything >= 0.5.4 and < 0.6 is accepted + COMPATIBILITY SameMinorVersion # Tells Cmake that it's a header-only lib # Mildly useful for end-users :) ARCH_INDEPENDENT ) endif() -# Creates the export httplibTargets.cmake -# This is strictly what holds compilation requirements -# and linkage information (doesn't find deps though). -install(TARGETS ${PROJECT_NAME} - EXPORT httplibTargets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} -) +if(HTTPLIB_INSTALL) + # Creates the export httplibTargets.cmake + # This is strictly what holds compilation requirements + # and linkage information (doesn't find deps though). + install(TARGETS ${PROJECT_NAME} EXPORT httplibTargets) -install(FILES "${_httplib_build_includedir}/httplib.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + install(FILES "${_httplib_build_includedir}/httplib.h" TYPE INCLUDE) -install(FILES + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" # Install it so it can be used later by the httplibConfig.cmake file. # Put it in the same dir as our config file instead of a global path so we don't potentially stomp on other packages. "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindBrotli.cmake" - DESTINATION ${_TARGET_INSTALL_CMAKEDIR} -) + DESTINATION ${_TARGET_INSTALL_CMAKEDIR} + ) -# NOTE: This path changes depending on if it's on Windows or Linux -install(EXPORT httplibTargets - # Puts the targets into the httplib namespace - # So this makes httplib::httplib linkable after doing find_package(httplib) - NAMESPACE ${PROJECT_NAME}:: - DESTINATION ${_TARGET_INSTALL_CMAKEDIR} -) + # NOTE: This path changes depending on if it's on Windows or Linux + install(EXPORT httplibTargets + # Puts the targets into the httplib namespace + # So this makes httplib::httplib linkable after doing find_package(httplib) + NAMESPACE ${PROJECT_NAME}:: + DESTINATION ${_TARGET_INSTALL_CMAKEDIR} + ) +endif() + +if(HTTPLIB_TEST) + include(CTest) + add_subdirectory(test) +endif() diff --git a/external_imported/cpp-httplib/README.md b/external_imported/cpp-httplib/README.md index cb4d80289..ebde68aaf 100644 --- a/external_imported/cpp-httplib/README.md +++ b/external_imported/cpp-httplib/README.md @@ -7,12 +7,12 @@ A C++11 single-file header-only cross platform HTTP/HTTPS library. It's extremely easy to setup. Just include the **httplib.h** file in your code! -NOTE: This is a multi-threaded 'blocking' HTTP library. If you are looking for a 'non-blocking' library, this is not the one that you want. +NOTE: This library uses 'blocking' socket I/O. If you are looking for a library with 'non-blocking' socket I/O, this is not the one that you want. Simple examples --------------- -#### Server +#### Server (Multi-threaded) ```c++ #define CPPHTTPLIB_OPENSSL_SUPPORT @@ -53,7 +53,9 @@ SSL Support SSL support is available with `CPPHTTPLIB_OPENSSL_SUPPORT`. `libssl` and `libcrypto` should be linked. -NOTE: cpp-httplib currently supports only version 1.1.1 and 3.0. +NOTE: cpp-httplib currently supports only version 3.0 or later. Please see [this page](https://www.openssl.org/policies/releasestrat.html) to get more information. + +NOTE for macOS: cpp-httplib now can use system certs with `CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN`. `CoreFoundation` and `Security` should be linked with `-framework`. ```c++ #define CPPHTTPLIB_OPENSSL_SUPPORT @@ -65,6 +67,7 @@ httplib::SSLServer svr("./cert.pem", "./key.pem"); // Client httplib::Client cli("https://localhost:1234"); // scheme + host httplib::SSLClient cli("localhost:1234"); // host +httplib::SSLClient cli("localhost", 1234); // host, port // Use your CA bundle cli.set_ca_cert_path("./ca-bundle.crt"); @@ -73,7 +76,7 @@ cli.set_ca_cert_path("./ca-bundle.crt"); cli.enable_server_certificate_verification(false); ``` -Note: When using SSL, it seems impossible to avoid SIGPIPE in all cases, since on some operating systems, SIGPIPE can only be suppressed on a per-message basis, but there is no way to make the OpenSSL library do so for its internal communications. If your program needs to avoid being terminated on SIGPIPE, the only fully general way might be to set up a signal handler for SIGPIPE to handle or ignore it yourself. +NOTE: When using SSL, it seems impossible to avoid SIGPIPE in all cases, since on some operating systems, SIGPIPE can only be suppressed on a per-message basis, but there is no way to make the OpenSSL library do so for its internal communications. If your program needs to avoid being terminated on SIGPIPE, the only fully general way might be to set up a signal handler for SIGPIPE to handle or ignore it yourself. Server ------ @@ -91,11 +94,20 @@ int main(void) res.set_content("Hello World!", "text/plain"); }); + // Match the request path against a regular expression + // and extract its captures svr.Get(R"(/numbers/(\d+))", [&](const Request& req, Response& res) { auto numbers = req.matches[1]; res.set_content(numbers, "text/plain"); }); + // Capture the second segment of the request path as "id" path param + svr.Get("/users/:id", [&](const Request& req, Response& res) { + auto user_id = req.path_params.at("id"); + res.set_content(user_id, "text/plain"); + }); + + // Extract values from HTTP headers and URL query params svr.Get("/body-header-param", [](const Request& req, Response& res) { if (req.has_header("Content-Length")) { auto val = req.get_header_value("Content-Length"); @@ -178,6 +190,8 @@ The followings are built-in mappings: | webm | video/webm | zip | application/zip | | mp3 | audio/mp3 | wasm | application/wasm | +NOTE: These static file server methods are not thread-safe. + ### File request handler ```cpp @@ -187,8 +201,6 @@ svr.set_file_request_handler([](const Request &req, Response &res) { }); ``` -NOTE: These static file server methods are not thread-safe. - ### Logging ```cpp @@ -212,15 +224,23 @@ svr.set_error_handler([](const auto& req, auto& res) { The exception handler gets called if a user routing handler throws an error. ```cpp -svr.set_exception_handler([](const auto& req, auto& res, std::exception &e) { - res.status = 500; +svr.set_exception_handler([](const auto& req, auto& res, std::exception_ptr ep) { auto fmt = "

Error 500

%s

"; char buf[BUFSIZ]; - snprintf(buf, sizeof(buf), fmt, e.what()); + try { + std::rethrow_exception(ep); + } catch (std::exception &e) { + snprintf(buf, sizeof(buf), fmt, e.what()); + } catch (...) { // See the following NOTE + snprintf(buf, sizeof(buf), fmt, "Unknown Exception"); + } res.set_content(buf, "text/html"); + res.status = StatusCode::InternalServerError_500; }); ``` +NOTE: if you don't provide the `catch (...)` block for a rethrown exception pointer, an uncaught exception will end up causing the server crash. Be careful! + ### Pre routing handler ```cpp @@ -292,7 +312,7 @@ svr.Get("/stream", [&](const Request &req, Response &res) { res.set_content_provider( data->size(), // Content length "text/plain", // Content type - [data](size_t offset, size_t length, DataSink &sink) { + [&, data](size_t offset, size_t length, DataSink &sink) { const auto &d = *data; sink.write(&d[offset], std::min(length, DATA_CHUNK_SIZE)); return true; // return 'false' if you want to cancel the process. @@ -337,6 +357,27 @@ svr.Get("/chunked", [&](const Request& req, Response& res) { }); ``` +With trailer: + +```cpp +svr.Get("/chunked", [&](const Request& req, Response& res) { + res.set_header("Trailer", "Dummy1, Dummy2"); + res.set_chunked_content_provider( + "text/plain", + [](size_t offset, DataSink &sink) { + sink.write("123", 3); + sink.write("345", 3); + sink.write("789", 3); + sink.done_with_trailer({ + {"Dummy1", "DummyVal1"}, + {"Dummy2", "DummyVal2"} + }); + return true; + } + ); +}); +``` + ### 'Expect: 100-continue' handler By default, the server sends a `100 Continue` response for an `Expect: 100-continue` header. @@ -344,14 +385,14 @@ By default, the server sends a `100 Continue` response for an `Expect: 100-conti ```cpp // Send a '417 Expectation Failed' response. svr.set_expect_100_continue_handler([](const Request &req, Response &res) { - return 417; + return StatusCode::ExpectationFailed_417; }); ``` ```cpp // Send a final status without reading the message body. svr.set_expect_100_continue_handler([](const Request &req, Response &res) { - return res.status = 401; + return res.status = StatusCode::Unauthorized_401; }); ``` @@ -376,6 +417,8 @@ svr.set_idle_interval(0, 100000); // 100 milliseconds svr.set_payload_max_length(1024 * 1024 * 512); // 512MB ``` +NOTE: When the request body content type is 'www-form-urlencoded', the actual payload length shouldn't exceed `CPPHTTPLIB_FORM_URL_ENCODED_PAYLOAD_MAX_LENGTH`. + ### Server-Sent Events Please see [Server example](https://github.com/yhirose/cpp-httplib/blob/master/example/ssesvr.cc) and [Client example](https://github.com/yhirose/cpp-httplib/blob/master/example/ssecli.cc). @@ -390,6 +433,17 @@ If you want to set the thread count at runtime, there is no convenient way... Bu svr.new_task_queue = [] { return new ThreadPool(12); }; ``` +You can also provide an optional parameter to limit the maximum number +of pending requests, i.e. requests `accept()`ed by the listener but +still waiting to be serviced by worker threads. + +```cpp +svr.new_task_queue = [] { return new ThreadPool(/*num_threads=*/12, /*max_queued_requests=*/18); }; +``` + +Default limit is 0 (unlimited). Once the limit is reached, the listener +will shutdown the client connection. + ### Override the default thread pool with yours You can supply your own thread pool implementation according to your need. @@ -401,8 +455,10 @@ public: pool_.start_with_thread_count(n); } - virtual void enqueue(std::function fn) override { - pool_.enqueue(fn); + virtual bool enqueue(std::function fn) override { + /* Return true if the task was actually enqueued, or false + * if the caller must drop the corresponding connection. */ + return pool_.enqueue(fn); } virtual void shutdown() override { @@ -430,12 +486,12 @@ int main(void) httplib::Client cli("localhost", 1234); if (auto res = cli.Get("/hi")) { - if (res->status == 200) { + if (res->status == StatusCode::OK_200) { std::cout << res->body << std::endl; } } else { auto err = res.error(); - ... + std::cout << "HTTP error: " << httplib::to_string(err) << std::endl; } } ``` @@ -468,7 +524,9 @@ enum Error { SSLConnection, SSLLoadingCerts, SSLServerVerification, - UnsupportedMultipartBoundaryChars + UnsupportedMultipartBoundaryChars, + Compression, + ConnectionTimeout, }; ``` @@ -482,6 +540,10 @@ auto res = cli.Get("/hi", headers); ``` or ```c++ +auto res = cli.Get("/hi", {{"Accept-Encoding", "gzip, deflate"}}); +``` +or +```c++ cli.set_default_headers({ { "Accept-Encoding", "gzip, deflate" } }); @@ -574,7 +636,7 @@ std::string body; auto res = cli.Get( "/stream", Headers(), [&](const Response &response) { - EXPECT_EQ(200, response.status); + EXPECT_EQ(StatusCode::OK_200, response.status); return true; // return 'false' if you want to cancel the request. }, [&](const char *data, size_t data_length) { @@ -615,7 +677,7 @@ auto res = cli.Post( ### With Progress Callback ```cpp -httplib::Client client(url, port); +httplib::Client cli(url, port); // prints: 0 / 000 bytes => 50% complete auto res = cli.Get("/", [](uint64_t len, uint64_t total) { @@ -797,14 +859,14 @@ Include `httplib.h` before `Windows.h` or include `Windows.h` by defining `WIN32 #include ``` -Note: cpp-httplib officially supports only the latest Visual Studio. It might work with former versions of Visual Studio, but I can no longer verify it. Pull requests are always welcome for the older versions of Visual Studio unless they break the C++11 conformance. +NOTE: cpp-httplib officially supports only the latest Visual Studio. It might work with former versions of Visual Studio, but I can no longer verify it. Pull requests are always welcome for the older versions of Visual Studio unless they break the C++11 conformance. -Note: Windows 8 or lower and Cygwin on Windows are not supported. +NOTE: Windows 8 or lower, Visual Studio 2013 or lower, and Cygwin and MSYS2 including MinGW are neither supported nor tested. License ------- -MIT license (© 2021 Yuji Hirose) +MIT license (© 2024 Yuji Hirose) Special Thanks To ----------------- diff --git a/external_imported/cpp-httplib/example/Makefile b/external_imported/cpp-httplib/example/Makefile index f37cc2464..64a35885f 100644 --- a/external_imported/cpp-httplib/example/Makefile +++ b/external_imported/cpp-httplib/example/Makefile @@ -4,16 +4,22 @@ CXXFLAGS = -O2 -std=c++11 -I.. -Wall -Wextra -pthread PREFIX = /usr/local #PREFIX = $(shell brew --prefix) -OPENSSL_DIR = $(PREFIX)/opt/openssl@1.1 -#OPENSSL_DIR = $(PREFIX)/opt/openssl@3 +OPENSSL_DIR = $(PREFIX)/opt/openssl@3 OPENSSL_SUPPORT = -DCPPHTTPLIB_OPENSSL_SUPPORT -I$(OPENSSL_DIR)/include -L$(OPENSSL_DIR)/lib -lssl -lcrypto +ifneq ($(OS), Windows_NT) + UNAME_S := $(shell uname -s) + ifeq ($(UNAME_S), Darwin) + OPENSSL_SUPPORT += -framework CoreFoundation -framework Security + endif +endif + ZLIB_SUPPORT = -DCPPHTTPLIB_ZLIB_SUPPORT -lz BROTLI_DIR = $(PREFIX)/opt/brotli BROTLI_SUPPORT = -DCPPHTTPLIB_BROTLI_SUPPORT -I$(BROTLI_DIR)/include -L$(BROTLI_DIR)/lib -lbrotlicommon -lbrotlienc -lbrotlidec -all: server client hello simplecli simplesvr upload redirect ssesvr ssecli benchmark +all: server client hello simplecli simplesvr upload redirect ssesvr ssecli benchmark issue server : server.cc ../httplib.h Makefile $(CXX) -o server $(CXXFLAGS) server.cc $(OPENSSL_SUPPORT) $(ZLIB_SUPPORT) $(BROTLI_SUPPORT) diff --git a/external_imported/cpp-httplib/example/benchmark.cc b/external_imported/cpp-httplib/example/benchmark.cc index 8e300b9e6..433cc675c 100644 --- a/external_imported/cpp-httplib/example/benchmark.cc +++ b/external_imported/cpp-httplib/example/benchmark.cc @@ -26,7 +26,7 @@ int main(void) { for (int i = 0; i < 3; i++) { StopWatch sw(to_string(i).c_str()); auto res = cli.Post("/post", body, "application/octet-stream"); - assert(res->status == 200); + assert(res->status == httplib::StatusCode::OK_200); } return 0; diff --git a/external_imported/cpp-httplib/example/ssesvr.cc b/external_imported/cpp-httplib/example/ssesvr.cc index d18aed355..5b0e0b93b 100644 --- a/external_imported/cpp-httplib/example/ssesvr.cc +++ b/external_imported/cpp-httplib/example/ssesvr.cc @@ -19,7 +19,7 @@ class EventDispatcher { unique_lock lk(m_); int id = id_; cv_.wait(lk, [&] { return cid_ == id; }); - if (sink->is_writable()) { sink->write(message_.data(), message_.size()); } + sink->write(message_.data(), message_.size()); } void send_event(const string &message) { diff --git a/external_imported/cpp-httplib/example/uploader.sh b/external_imported/cpp-httplib/example/uploader.sh index 0e992f459..4382ae621 100755 --- a/external_imported/cpp-httplib/example/uploader.sh +++ b/external_imported/cpp-httplib/example/uploader.sh @@ -1,5 +1,5 @@ #/usr/bin/env bash -for i in {1..10000} +for i in {1..1000000} do echo "#### $i ####" curl -X POST -F image_file=@$1 http://localhost:1234/post > /dev/null diff --git a/external_imported/cpp-httplib/httplib.h b/external_imported/cpp-httplib/httplib.h index 04a552f0a..dfdd260ab 100644 --- a/external_imported/cpp-httplib/httplib.h +++ b/external_imported/cpp-httplib/httplib.h @@ -1,14 +1,14 @@ // // httplib.h // -// Copyright (c) 2022 Yuji Hirose. All rights reserved. +// Copyright (c) 2024 Yuji Hirose. All rights reserved. // MIT License // #ifndef CPPHTTPLIB_HTTPLIB_H #define CPPHTTPLIB_HTTPLIB_H -#define CPPHTTPLIB_VERSION "0.10.7" +#define CPPHTTPLIB_VERSION "0.15.3" /* * Configuration @@ -70,10 +70,22 @@ #define CPPHTTPLIB_REDIRECT_MAX_COUNT 20 #endif +#ifndef CPPHTTPLIB_MULTIPART_FORM_DATA_FILE_MAX_COUNT +#define CPPHTTPLIB_MULTIPART_FORM_DATA_FILE_MAX_COUNT 1024 +#endif + #ifndef CPPHTTPLIB_PAYLOAD_MAX_LENGTH #define CPPHTTPLIB_PAYLOAD_MAX_LENGTH ((std::numeric_limits::max)()) #endif +#ifndef CPPHTTPLIB_FORM_URL_ENCODED_PAYLOAD_MAX_LENGTH +#define CPPHTTPLIB_FORM_URL_ENCODED_PAYLOAD_MAX_LENGTH 8192 +#endif + +#ifndef CPPHTTPLIB_RANGE_MAX_COUNT +#define CPPHTTPLIB_RANGE_MAX_COUNT 1024 +#endif + #ifndef CPPHTTPLIB_TCP_NODELAY #define CPPHTTPLIB_TCP_NODELAY false #endif @@ -119,23 +131,25 @@ #endif //_CRT_NONSTDC_NO_DEPRECATE #if defined(_MSC_VER) +#if _MSC_VER < 1900 +#error Sorry, Visual Studio versions prior to 2015 are not supported +#endif + +#pragma comment(lib, "ws2_32.lib") + #ifdef _WIN64 using ssize_t = __int64; #else -using ssize_t = int; -#endif - -#if _MSC_VER < 1900 -#define snprintf _snprintf_s +using ssize_t = long; #endif #endif // _MSC_VER #ifndef S_ISREG -#define S_ISREG(m) (((m)&S_IFREG) == S_IFREG) +#define S_ISREG(m) (((m) & S_IFREG) == S_IFREG) #endif // S_ISREG #ifndef S_ISDIR -#define S_ISDIR(m) (((m)&S_IFDIR) == S_IFDIR) +#define S_ISDIR(m) (((m) & S_IFDIR) == S_IFDIR) #endif // S_ISDIR #ifndef NOMINMAX @@ -150,14 +164,6 @@ using ssize_t = int; #define WSA_FLAG_NO_HANDLE_INHERIT 0x80 #endif -#ifdef _MSC_VER -#pragma comment(lib, "ws2_32.lib") -#endif - -#ifndef strcasecmp -#define strcasecmp _stricmp -#endif // strcasecmp - using socket_t = SOCKET; #ifdef CPPHTTPLIB_USE_POLL #define poll(fds, nfds, timeout) WSAPoll(fds, nfds, timeout) @@ -166,8 +172,15 @@ using socket_t = SOCKET; #else // not _WIN32 #include -#include +#if !defined(_AIX) && !defined(__MVS__) #include +#endif +#ifdef __MVS__ +#include +#ifndef NI_MAXHOST +#define NI_MAXHOST 1025 +#endif +#endif #include #include #include @@ -180,8 +193,10 @@ using socket_t = SOCKET; #endif #include #include +#include #include #include +#include #include using socket_t = int; @@ -197,7 +212,9 @@ using socket_t = int; #include #include #include +#include #include +#include #include #include #include @@ -214,6 +231,9 @@ using socket_t = int; #include #include #include +#include +#include +#include #ifdef CPPHTTPLIB_OPENSSL_SUPPORT #ifdef _WIN32 @@ -228,9 +248,14 @@ using socket_t = int; #ifdef _MSC_VER #pragma comment(lib, "crypt32.lib") -#pragma comment(lib, "cryptui.lib") #endif -#endif //_WIN32 +#elif defined(CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN) && defined(__APPLE__) +#include +#if TARGET_OS_OSX +#include +#include +#endif // TARGET_OS_OSX +#endif // _WIN32 #include #include @@ -244,16 +269,10 @@ using socket_t = int; #include #include -#if OPENSSL_VERSION_NUMBER < 0x1010100fL -#error Sorry, OpenSSL versions prior to 1.1.1 are not supported +#if OPENSSL_VERSION_NUMBER < 0x30000000L +#error Sorry, OpenSSL versions prior to 3.0.0 are not supported #endif -#if OPENSSL_VERSION_NUMBER < 0x10100000L -#include -inline const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *asn1) { - return M_ASN1_STRING_data(asn1); -} -#endif #endif #ifdef CPPHTTPLIB_ZLIB_SUPPORT @@ -303,8 +322,111 @@ struct ci { } }; +// This is based on +// "http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4189". + +struct scope_exit { + explicit scope_exit(std::function &&f) + : exit_function(std::move(f)), execute_on_destruction{true} {} + + scope_exit(scope_exit &&rhs) noexcept + : exit_function(std::move(rhs.exit_function)), + execute_on_destruction{rhs.execute_on_destruction} { + rhs.release(); + } + + ~scope_exit() { + if (execute_on_destruction) { this->exit_function(); } + } + + void release() { this->execute_on_destruction = false; } + +private: + scope_exit(const scope_exit &) = delete; + void operator=(const scope_exit &) = delete; + scope_exit &operator=(scope_exit &&) = delete; + + std::function exit_function; + bool execute_on_destruction; +}; + } // namespace detail +enum StatusCode { + // Information responses + Continue_100 = 100, + SwitchingProtocol_101 = 101, + Processing_102 = 102, + EarlyHints_103 = 103, + + // Successful responses + OK_200 = 200, + Created_201 = 201, + Accepted_202 = 202, + NonAuthoritativeInformation_203 = 203, + NoContent_204 = 204, + ResetContent_205 = 205, + PartialContent_206 = 206, + MultiStatus_207 = 207, + AlreadyReported_208 = 208, + IMUsed_226 = 226, + + // Redirection messages + MultipleChoices_300 = 300, + MovedPermanently_301 = 301, + Found_302 = 302, + SeeOther_303 = 303, + NotModified_304 = 304, + UseProxy_305 = 305, + unused_306 = 306, + TemporaryRedirect_307 = 307, + PermanentRedirect_308 = 308, + + // Client error responses + BadRequest_400 = 400, + Unauthorized_401 = 401, + PaymentRequired_402 = 402, + Forbidden_403 = 403, + NotFound_404 = 404, + MethodNotAllowed_405 = 405, + NotAcceptable_406 = 406, + ProxyAuthenticationRequired_407 = 407, + RequestTimeout_408 = 408, + Conflict_409 = 409, + Gone_410 = 410, + LengthRequired_411 = 411, + PreconditionFailed_412 = 412, + PayloadTooLarge_413 = 413, + UriTooLong_414 = 414, + UnsupportedMediaType_415 = 415, + RangeNotSatisfiable_416 = 416, + ExpectationFailed_417 = 417, + ImATeapot_418 = 418, + MisdirectedRequest_421 = 421, + UnprocessableContent_422 = 422, + Locked_423 = 423, + FailedDependency_424 = 424, + TooEarly_425 = 425, + UpgradeRequired_426 = 426, + PreconditionRequired_428 = 428, + TooManyRequests_429 = 429, + RequestHeaderFieldsTooLarge_431 = 431, + UnavailableForLegalReasons_451 = 451, + + // Server error responses + InternalServerError_500 = 500, + NotImplemented_501 = 501, + BadGateway_502 = 502, + ServiceUnavailable_503 = 503, + GatewayTimeout_504 = 504, + HttpVersionNotSupported_505 = 505, + VariantAlsoNegotiates_506 = 506, + InsufficientStorage_507 = 507, + LoopDetected_508 = 508, + NotExtended_510 = 510, + NetworkAuthenticationRequired_511 = 511, +}; + using Headers = std::multimap; using Params = std::multimap; @@ -334,8 +456,9 @@ class DataSink { DataSink &operator=(DataSink &&) = delete; std::function write; - std::function done; std::function is_writable; + std::function done; + std::function done_with_trailer; std::ostream os; private: @@ -344,7 +467,7 @@ class DataSink { explicit data_sink_streambuf(DataSink &sink) : sink_(sink) {} protected: - std::streamsize xsputn(const char *s, std::streamsize n) { + std::streamsize xsputn(const char *s, std::streamsize n) override { sink_.write(s, static_cast(n)); return n; } @@ -364,6 +487,14 @@ using ContentProviderWithoutLength = using ContentProviderResourceReleaser = std::function; +struct MultipartFormDataProvider { + std::string name; + ContentProviderWithoutLength provider; + std::string filename; + std::string content_type; +}; +using MultipartFormDataProviderItems = std::vector; + using ContentReceiverWithProgress = std::function; @@ -408,6 +539,8 @@ struct Request { std::string remote_addr; int remote_port = -1; + std::string local_addr; + int local_port = -1; // for server std::string version; @@ -416,6 +549,7 @@ struct Request { MultipartFormDataMap files; Ranges ranges; Match matches; + std::unordered_map path_params; // for client ResponseHandler response_handler; @@ -425,22 +559,21 @@ struct Request { const SSL *ssl = nullptr; #endif - bool has_header(const char *key) const; - std::string get_header_value(const char *key, size_t id = 0) const; - template - T get_header_value(const char *key, size_t id = 0) const; - size_t get_header_value_count(const char *key) const; - void set_header(const char *key, const char *val); - void set_header(const char *key, const std::string &val); + bool has_header(const std::string &key) const; + std::string get_header_value(const std::string &key, size_t id = 0) const; + uint64_t get_header_value_u64(const std::string &key, size_t id = 0) const; + size_t get_header_value_count(const std::string &key) const; + void set_header(const std::string &key, const std::string &val); - bool has_param(const char *key) const; - std::string get_param_value(const char *key, size_t id = 0) const; - size_t get_param_value_count(const char *key) const; + bool has_param(const std::string &key) const; + std::string get_param_value(const std::string &key, size_t id = 0) const; + size_t get_param_value_count(const std::string &key) const; bool is_multipart_form_data() const; - bool has_file(const char *key) const; - MultipartFormData get_file_value(const char *key) const; + bool has_file(const std::string &key) const; + MultipartFormData get_file_value(const std::string &key) const; + std::vector get_file_values(const std::string &key) const; // private members... size_t redirect_count_ = CPPHTTPLIB_REDIRECT_MAX_COUNT; @@ -458,29 +591,27 @@ struct Response { std::string body; std::string location; // Redirect location - bool has_header(const char *key) const; - std::string get_header_value(const char *key, size_t id = 0) const; - template - T get_header_value(const char *key, size_t id = 0) const; - size_t get_header_value_count(const char *key) const; - void set_header(const char *key, const char *val); - void set_header(const char *key, const std::string &val); + bool has_header(const std::string &key) const; + std::string get_header_value(const std::string &key, size_t id = 0) const; + uint64_t get_header_value_u64(const std::string &key, size_t id = 0) const; + size_t get_header_value_count(const std::string &key) const; + void set_header(const std::string &key, const std::string &val); - void set_redirect(const char *url, int status = 302); - void set_redirect(const std::string &url, int status = 302); - void set_content(const char *s, size_t n, const char *content_type); - void set_content(const std::string &s, const char *content_type); + void set_redirect(const std::string &url, int status = StatusCode::Found_302); + void set_content(const char *s, size_t n, const std::string &content_type); + void set_content(const std::string &s, const std::string &content_type); + void set_content(std::string &&s, const std::string &content_type); void set_content_provider( - size_t length, const char *content_type, ContentProvider provider, + size_t length, const std::string &content_type, ContentProvider provider, ContentProviderResourceReleaser resource_releaser = nullptr); void set_content_provider( - const char *content_type, ContentProviderWithoutLength provider, + const std::string &content_type, ContentProviderWithoutLength provider, ContentProviderResourceReleaser resource_releaser = nullptr); void set_chunked_content_provider( - const char *content_type, ContentProviderWithoutLength provider, + const std::string &content_type, ContentProviderWithoutLength provider, ContentProviderResourceReleaser resource_releaser = nullptr); Response() = default; @@ -512,6 +643,7 @@ class Stream { virtual ssize_t read(char *ptr, size_t size) = 0; virtual ssize_t write(const char *ptr, size_t size) = 0; virtual void get_remote_ip_and_port(std::string &ip, int &port) const = 0; + virtual void get_local_ip_and_port(std::string &ip, int &port) const = 0; virtual socket_t socket() const = 0; template @@ -525,7 +657,7 @@ class TaskQueue { TaskQueue() = default; virtual ~TaskQueue() = default; - virtual void enqueue(std::function fn) = 0; + virtual bool enqueue(std::function fn) = 0; virtual void shutdown() = 0; virtual void on_idle() {} @@ -533,7 +665,8 @@ class TaskQueue { class ThreadPool : public TaskQueue { public: - explicit ThreadPool(size_t n) : shutdown_(false) { + explicit ThreadPool(size_t n, size_t mqr = 0) + : shutdown_(false), max_queued_requests_(mqr) { while (n) { threads_.emplace_back(worker(*this)); n--; @@ -543,10 +676,17 @@ class ThreadPool : public TaskQueue { ThreadPool(const ThreadPool &) = delete; ~ThreadPool() override = default; - void enqueue(std::function fn) override { - std::unique_lock lock(mutex_); - jobs_.push_back(std::move(fn)); + bool enqueue(std::function fn) override { + { + std::unique_lock lock(mutex_); + if (max_queued_requests_ > 0 && jobs_.size() >= max_queued_requests_) { + return false; + } + jobs_.push_back(std::move(fn)); + } + cond_.notify_one(); + return true; } void shutdown() override { @@ -579,7 +719,7 @@ class ThreadPool : public TaskQueue { if (pool_.shutdown_ && pool_.jobs_.empty()) { break; } - fn = pool_.jobs_.front(); + fn = std::move(pool_.jobs_.front()); pool_.jobs_.pop_front(); } @@ -596,6 +736,7 @@ class ThreadPool : public TaskQueue { std::list> jobs_; bool shutdown_; + size_t max_queued_requests_ = 0; std::condition_variable cond_; std::mutex mutex_; @@ -607,12 +748,88 @@ using SocketOptions = std::function; void default_socket_options(socket_t sock); +const char *status_message(int status); + +std::string get_bearer_token_auth(const Request &req); + +namespace detail { + +class MatcherBase { +public: + virtual ~MatcherBase() = default; + + // Match request path and populate its matches and + virtual bool match(Request &request) const = 0; +}; + +/** + * Captures parameters in request path and stores them in Request::path_params + * + * Capture name is a substring of a pattern from : to /. + * The rest of the pattern is matched agains the request path directly + * Parameters are captured starting from the next character after + * the end of the last matched static pattern fragment until the next /. + * + * Example pattern: + * "/path/fragments/:capture/more/fragments/:second_capture" + * Static fragments: + * "/path/fragments/", "more/fragments/" + * + * Given the following request path: + * "/path/fragments/:1/more/fragments/:2" + * the resulting capture will be + * {{"capture", "1"}, {"second_capture", "2"}} + */ +class PathParamsMatcher : public MatcherBase { +public: + PathParamsMatcher(const std::string &pattern); + + bool match(Request &request) const override; + +private: + static constexpr char marker = ':'; + // Treat segment separators as the end of path parameter capture + // Does not need to handle query parameters as they are parsed before path + // matching + static constexpr char separator = '/'; + + // Contains static path fragments to match against, excluding the '/' after + // path params + // Fragments are separated by path params + std::vector static_fragments_; + // Stores the names of the path parameters to be used as keys in the + // Request::path_params map + std::vector param_names_; +}; + +/** + * Performs std::regex_match on request path + * and stores the result in Request::matches + * + * Note that regex match is performed directly on the whole request. + * This means that wildcard patterns may match multiple path segments with /: + * "/begin/(.*)/end" will match both "/begin/middle/end" and "/begin/1/2/end". + */ +class RegexMatcher : public MatcherBase { +public: + RegexMatcher(const std::string &pattern) : regex_(pattern) {} + + bool match(Request &request) const override; + +private: + std::regex regex_; +}; + +ssize_t write_headers(Stream &strm, const Headers &headers); + +} // namespace detail + class Server { public: using Handler = std::function; using ExceptionHandler = - std::function; + std::function; enum class HandlerResponse { Handled, @@ -649,8 +866,9 @@ class Server { bool set_mount_point(const std::string &mount_point, const std::string &dir, Headers headers = Headers()); bool remove_mount_point(const std::string &mount_point); - Server &set_file_extension_and_mimetype_mapping(const char *ext, - const char *mime); + Server &set_file_extension_and_mimetype_mapping(const std::string &ext, + const std::string &mime); + Server &set_default_file_mimetype(const std::string &mime); Server &set_file_request_handler(Handler handler); Server &set_error_handler(HandlerWithResponse handler); @@ -667,6 +885,8 @@ class Server { Server &set_socket_options(SocketOptions socket_options); Server &set_default_headers(Headers headers); + Server & + set_header_writer(std::function const &writer); Server &set_keep_alive_max_count(size_t count); Server &set_keep_alive_timeout(time_t sec); @@ -685,13 +905,14 @@ class Server { Server &set_payload_max_length(size_t length); - bool bind_to_port(const char *host, int port, int socket_flags = 0); - int bind_to_any_port(const char *host, int socket_flags = 0); + bool bind_to_port(const std::string &host, int port, int socket_flags = 0); + int bind_to_any_port(const std::string &host, int socket_flags = 0); bool listen_after_bind(); - bool listen(const char *host, int port, int socket_flags = 0); + bool listen(const std::string &host, int port, int socket_flags = 0); bool is_running() const; + void wait_until_ready() const; void stop(); std::function new_task_queue; @@ -701,7 +922,7 @@ class Server { bool &connection_closed, const std::function &setup_request); - std::atomic svr_sock_; + std::atomic svr_sock_{INVALID_SOCKET}; size_t keep_alive_max_count_ = CPPHTTPLIB_KEEPALIVE_MAX_COUNT; time_t keep_alive_timeout_sec_ = CPPHTTPLIB_KEEPALIVE_TIMEOUT_SECOND; time_t read_timeout_sec_ = CPPHTTPLIB_READ_TIMEOUT_SECOND; @@ -713,28 +934,34 @@ class Server { size_t payload_max_length_ = CPPHTTPLIB_PAYLOAD_MAX_LENGTH; private: - using Handlers = std::vector>; + using Handlers = + std::vector, Handler>>; using HandlersForContentReader = - std::vector>; + std::vector, + HandlerWithContentReader>>; + + static std::unique_ptr + make_matcher(const std::string &pattern); - socket_t create_server_socket(const char *host, int port, int socket_flags, + socket_t create_server_socket(const std::string &host, int port, + int socket_flags, SocketOptions socket_options) const; - int bind_internal(const char *host, int port, int socket_flags); + int bind_internal(const std::string &host, int port, int socket_flags); bool listen_internal(); bool routing(Request &req, Response &res, Stream &strm); bool handle_file_request(const Request &req, Response &res, bool head = false); - bool dispatch_request(Request &req, Response &res, const Handlers &handlers); - bool - dispatch_request_for_content_reader(Request &req, Response &res, - ContentReader content_reader, - const HandlersForContentReader &handlers); + bool dispatch_request(Request &req, Response &res, + const Handlers &handlers) const; + bool dispatch_request_for_content_reader( + Request &req, Response &res, ContentReader content_reader, + const HandlersForContentReader &handlers) const; - bool parse_request_line(const char *s, Request &req); + bool parse_request_line(const char *s, Request &req) const; void apply_ranges(const Request &req, Response &res, - std::string &content_type, std::string &boundary); - bool write_response(Stream &strm, bool close_connection, const Request &req, + std::string &content_type, std::string &boundary) const; + bool write_response(Stream &strm, bool close_connection, Request &req, Response &res); bool write_response_with_content(Stream &strm, bool close_connection, const Request &req, Response &res); @@ -752,21 +979,24 @@ class Server { ContentReceiver multipart_receiver); bool read_content_core(Stream &strm, Request &req, Response &res, ContentReceiver receiver, - MultipartContentHeader mulitpart_header, - ContentReceiver multipart_receiver); + MultipartContentHeader multipart_header, + ContentReceiver multipart_receiver) const; virtual bool process_and_close_socket(socket_t sock); + std::atomic is_running_{false}; + std::atomic done_{false}; + struct MountPointEntry { std::string mount_point; std::string base_dir; Headers headers; }; std::vector base_dirs_; - - std::atomic is_running_; std::map file_extension_and_mimetype_map_; + std::string default_file_mimetype_ = "application/octet-stream"; Handler file_request_handler_; + Handlers get_handlers_; Handlers post_handlers_; HandlersForContentReader post_handlers_for_content_reader_; @@ -777,18 +1007,22 @@ class Server { Handlers delete_handlers_; HandlersForContentReader delete_handlers_for_content_reader_; Handlers options_handlers_; + HandlerWithResponse error_handler_; ExceptionHandler exception_handler_; HandlerWithResponse pre_routing_handler_; Handler post_routing_handler_; - Logger logger_; Expect100ContinueHandler expect_100_continue_handler_; + Logger logger_; + int address_family_ = AF_UNSPEC; bool tcp_nodelay_ = CPPHTTPLIB_TCP_NODELAY; SocketOptions socket_options_ = default_socket_options; Headers default_headers_; + std::function header_writer_ = + detail::write_headers; }; enum class Error { @@ -806,14 +1040,19 @@ enum class Error { UnsupportedMultipartBoundaryChars, Compression, ConnectionTimeout, + ProxyConnection, + + // For internal use only + SSLPeerCouldBeClosed_, }; -std::string to_string(const Error error); +std::string to_string(Error error); std::ostream &operator<<(std::ostream &os, const Error &obj); class Result { public: + Result() = default; Result(std::unique_ptr &&res, Error err, Headers &&request_headers = Headers{}) : res_(std::move(res)), err_(err), @@ -833,15 +1072,16 @@ class Result { Error error() const { return err_; } // Request Headers - bool has_request_header(const char *key) const; - std::string get_request_header_value(const char *key, size_t id = 0) const; - template - T get_request_header_value(const char *key, size_t id = 0) const; - size_t get_request_header_value_count(const char *key) const; + bool has_request_header(const std::string &key) const; + std::string get_request_header_value(const std::string &key, + size_t id = 0) const; + uint64_t get_request_header_value_u64(const std::string &key, + size_t id = 0) const; + size_t get_request_header_value_count(const std::string &key) const; private: std::unique_ptr res_; - Error err_; + Error err_ = Error::Unknown; Headers request_headers_; }; @@ -859,130 +1099,163 @@ class ClientImpl { virtual bool is_valid() const; - Result Get(const char *path); - Result Get(const char *path, const Headers &headers); - Result Get(const char *path, Progress progress); - Result Get(const char *path, const Headers &headers, Progress progress); - Result Get(const char *path, ContentReceiver content_receiver); - Result Get(const char *path, const Headers &headers, + Result Get(const std::string &path); + Result Get(const std::string &path, const Headers &headers); + Result Get(const std::string &path, Progress progress); + Result Get(const std::string &path, const Headers &headers, + Progress progress); + Result Get(const std::string &path, ContentReceiver content_receiver); + Result Get(const std::string &path, const Headers &headers, ContentReceiver content_receiver); - Result Get(const char *path, ContentReceiver content_receiver, + Result Get(const std::string &path, ContentReceiver content_receiver, Progress progress); - Result Get(const char *path, const Headers &headers, + Result Get(const std::string &path, const Headers &headers, ContentReceiver content_receiver, Progress progress); - Result Get(const char *path, ResponseHandler response_handler, + Result Get(const std::string &path, ResponseHandler response_handler, ContentReceiver content_receiver); - Result Get(const char *path, const Headers &headers, + Result Get(const std::string &path, const Headers &headers, ResponseHandler response_handler, ContentReceiver content_receiver); - Result Get(const char *path, ResponseHandler response_handler, + Result Get(const std::string &path, ResponseHandler response_handler, ContentReceiver content_receiver, Progress progress); - Result Get(const char *path, const Headers &headers, + Result Get(const std::string &path, const Headers &headers, ResponseHandler response_handler, ContentReceiver content_receiver, Progress progress); - Result Get(const char *path, const Params ¶ms, const Headers &headers, + Result Get(const std::string &path, const Params ¶ms, + const Headers &headers, Progress progress = nullptr); + Result Get(const std::string &path, const Params ¶ms, + const Headers &headers, ContentReceiver content_receiver, Progress progress = nullptr); - Result Get(const char *path, const Params ¶ms, const Headers &headers, + Result Get(const std::string &path, const Params ¶ms, + const Headers &headers, ResponseHandler response_handler, ContentReceiver content_receiver, Progress progress = nullptr); - Result Get(const char *path, const Params ¶ms, const Headers &headers, - ResponseHandler response_handler, ContentReceiver content_receiver, - Progress progress = nullptr); - Result Head(const char *path); - Result Head(const char *path, const Headers &headers); - - Result Post(const char *path); - Result Post(const char *path, const char *body, size_t content_length, - const char *content_type); - Result Post(const char *path, const Headers &headers, const char *body, - size_t content_length, const char *content_type); - Result Post(const char *path, const std::string &body, - const char *content_type); - Result Post(const char *path, const Headers &headers, const std::string &body, - const char *content_type); - Result Post(const char *path, size_t content_length, - ContentProvider content_provider, const char *content_type); - Result Post(const char *path, ContentProviderWithoutLength content_provider, - const char *content_type); - Result Post(const char *path, const Headers &headers, size_t content_length, - ContentProvider content_provider, const char *content_type); - Result Post(const char *path, const Headers &headers, + Result Head(const std::string &path); + Result Head(const std::string &path, const Headers &headers); + + Result Post(const std::string &path); + Result Post(const std::string &path, const Headers &headers); + Result Post(const std::string &path, const char *body, size_t content_length, + const std::string &content_type); + Result Post(const std::string &path, const Headers &headers, const char *body, + size_t content_length, const std::string &content_type); + Result Post(const std::string &path, const std::string &body, + const std::string &content_type); + Result Post(const std::string &path, const Headers &headers, + const std::string &body, const std::string &content_type); + Result Post(const std::string &path, size_t content_length, + ContentProvider content_provider, + const std::string &content_type); + Result Post(const std::string &path, ContentProviderWithoutLength content_provider, - const char *content_type); - Result Post(const char *path, const Params ¶ms); - Result Post(const char *path, const Headers &headers, const Params ¶ms); - Result Post(const char *path, const MultipartFormDataItems &items); - Result Post(const char *path, const Headers &headers, + const std::string &content_type); + Result Post(const std::string &path, const Headers &headers, + size_t content_length, ContentProvider content_provider, + const std::string &content_type); + Result Post(const std::string &path, const Headers &headers, + ContentProviderWithoutLength content_provider, + const std::string &content_type); + Result Post(const std::string &path, const Params ¶ms); + Result Post(const std::string &path, const Headers &headers, + const Params ¶ms); + Result Post(const std::string &path, const MultipartFormDataItems &items); + Result Post(const std::string &path, const Headers &headers, const MultipartFormDataItems &items); - Result Post(const char *path, const Headers &headers, + Result Post(const std::string &path, const Headers &headers, const MultipartFormDataItems &items, const std::string &boundary); - - Result Put(const char *path); - Result Put(const char *path, const char *body, size_t content_length, - const char *content_type); - Result Put(const char *path, const Headers &headers, const char *body, - size_t content_length, const char *content_type); - Result Put(const char *path, const std::string &body, - const char *content_type); - Result Put(const char *path, const Headers &headers, const std::string &body, - const char *content_type); - Result Put(const char *path, size_t content_length, - ContentProvider content_provider, const char *content_type); - Result Put(const char *path, ContentProviderWithoutLength content_provider, - const char *content_type); - Result Put(const char *path, const Headers &headers, size_t content_length, - ContentProvider content_provider, const char *content_type); - Result Put(const char *path, const Headers &headers, + Result Post(const std::string &path, const Headers &headers, + const MultipartFormDataItems &items, + const MultipartFormDataProviderItems &provider_items); + + Result Put(const std::string &path); + Result Put(const std::string &path, const char *body, size_t content_length, + const std::string &content_type); + Result Put(const std::string &path, const Headers &headers, const char *body, + size_t content_length, const std::string &content_type); + Result Put(const std::string &path, const std::string &body, + const std::string &content_type); + Result Put(const std::string &path, const Headers &headers, + const std::string &body, const std::string &content_type); + Result Put(const std::string &path, size_t content_length, + ContentProvider content_provider, const std::string &content_type); + Result Put(const std::string &path, ContentProviderWithoutLength content_provider, - const char *content_type); - Result Put(const char *path, const Params ¶ms); - Result Put(const char *path, const Headers &headers, const Params ¶ms); - - Result Patch(const char *path); - Result Patch(const char *path, const char *body, size_t content_length, - const char *content_type); - Result Patch(const char *path, const Headers &headers, const char *body, - size_t content_length, const char *content_type); - Result Patch(const char *path, const std::string &body, - const char *content_type); - Result Patch(const char *path, const Headers &headers, - const std::string &body, const char *content_type); - Result Patch(const char *path, size_t content_length, - ContentProvider content_provider, const char *content_type); - Result Patch(const char *path, ContentProviderWithoutLength content_provider, - const char *content_type); - Result Patch(const char *path, const Headers &headers, size_t content_length, - ContentProvider content_provider, const char *content_type); - Result Patch(const char *path, const Headers &headers, + const std::string &content_type); + Result Put(const std::string &path, const Headers &headers, + size_t content_length, ContentProvider content_provider, + const std::string &content_type); + Result Put(const std::string &path, const Headers &headers, + ContentProviderWithoutLength content_provider, + const std::string &content_type); + Result Put(const std::string &path, const Params ¶ms); + Result Put(const std::string &path, const Headers &headers, + const Params ¶ms); + Result Put(const std::string &path, const MultipartFormDataItems &items); + Result Put(const std::string &path, const Headers &headers, + const MultipartFormDataItems &items); + Result Put(const std::string &path, const Headers &headers, + const MultipartFormDataItems &items, const std::string &boundary); + Result Put(const std::string &path, const Headers &headers, + const MultipartFormDataItems &items, + const MultipartFormDataProviderItems &provider_items); + + Result Patch(const std::string &path); + Result Patch(const std::string &path, const char *body, size_t content_length, + const std::string &content_type); + Result Patch(const std::string &path, const Headers &headers, + const char *body, size_t content_length, + const std::string &content_type); + Result Patch(const std::string &path, const std::string &body, + const std::string &content_type); + Result Patch(const std::string &path, const Headers &headers, + const std::string &body, const std::string &content_type); + Result Patch(const std::string &path, size_t content_length, + ContentProvider content_provider, + const std::string &content_type); + Result Patch(const std::string &path, + ContentProviderWithoutLength content_provider, + const std::string &content_type); + Result Patch(const std::string &path, const Headers &headers, + size_t content_length, ContentProvider content_provider, + const std::string &content_type); + Result Patch(const std::string &path, const Headers &headers, ContentProviderWithoutLength content_provider, - const char *content_type); - - Result Delete(const char *path); - Result Delete(const char *path, const Headers &headers); - Result Delete(const char *path, const char *body, size_t content_length, - const char *content_type); - Result Delete(const char *path, const Headers &headers, const char *body, - size_t content_length, const char *content_type); - Result Delete(const char *path, const std::string &body, - const char *content_type); - Result Delete(const char *path, const Headers &headers, - const std::string &body, const char *content_type); - - Result Options(const char *path); - Result Options(const char *path, const Headers &headers); + const std::string &content_type); + + Result Delete(const std::string &path); + Result Delete(const std::string &path, const Headers &headers); + Result Delete(const std::string &path, const char *body, + size_t content_length, const std::string &content_type); + Result Delete(const std::string &path, const Headers &headers, + const char *body, size_t content_length, + const std::string &content_type); + Result Delete(const std::string &path, const std::string &body, + const std::string &content_type); + Result Delete(const std::string &path, const Headers &headers, + const std::string &body, const std::string &content_type); + + Result Options(const std::string &path); + Result Options(const std::string &path, const Headers &headers); bool send(Request &req, Response &res, Error &error); Result send(const Request &req); - size_t is_socket_open() const; - void stop(); + std::string host() const; + int port() const; + + size_t is_socket_open() const; + socket_t socket() const; + void set_hostname_addr_map(std::map addr_map); void set_default_headers(Headers headers); + void + set_header_writer(std::function const &writer); + void set_address_family(int family); void set_tcp_nodelay(bool on); void set_socket_options(SocketOptions socket_options); @@ -1000,10 +1273,11 @@ class ClientImpl { template void set_write_timeout(const std::chrono::duration &duration); - void set_basic_auth(const char *username, const char *password); - void set_bearer_token_auth(const char *token); + void set_basic_auth(const std::string &username, const std::string &password); + void set_bearer_token_auth(const std::string &token); #ifdef CPPHTTPLIB_OPENSSL_SUPPORT - void set_digest_auth(const char *username, const char *password); + void set_digest_auth(const std::string &username, + const std::string &password); #endif void set_keep_alive(bool on); @@ -1015,19 +1289,22 @@ class ClientImpl { void set_decompress(bool on); - void set_interface(const char *intf); + void set_interface(const std::string &intf); - void set_proxy(const char *host, int port); - void set_proxy_basic_auth(const char *username, const char *password); - void set_proxy_bearer_token_auth(const char *token); + void set_proxy(const std::string &host, int port); + void set_proxy_basic_auth(const std::string &username, + const std::string &password); + void set_proxy_bearer_token_auth(const std::string &token); #ifdef CPPHTTPLIB_OPENSSL_SUPPORT - void set_proxy_digest_auth(const char *username, const char *password); + void set_proxy_digest_auth(const std::string &username, + const std::string &password); #endif #ifdef CPPHTTPLIB_OPENSSL_SUPPORT - void set_ca_cert_path(const char *ca_cert_file_path, - const char *ca_cert_dir_path = nullptr); + void set_ca_cert_path(const std::string &ca_cert_file_path, + const std::string &ca_cert_dir_path = std::string()); void set_ca_cert_store(X509_STORE *ca_cert_store); + X509_STORE *create_ca_cert_store(const char *ca_cert, std::size_t size) const; #endif #ifdef CPPHTTPLIB_OPENSSL_SUPPORT @@ -1046,8 +1323,6 @@ class ClientImpl { bool is_open() const { return sock != INVALID_SOCKET; } }; - Result send_(Request &&req); - virtual bool create_and_connect_socket(Socket &socket, Error &error); // All of: @@ -1058,18 +1333,18 @@ class ClientImpl { // Also, shutdown_ssl and close_socket should also NOT be called concurrently // with a DIFFERENT thread sending requests using that socket. virtual void shutdown_ssl(Socket &socket, bool shutdown_gracefully); - void shutdown_socket(Socket &socket); + void shutdown_socket(Socket &socket) const; void close_socket(Socket &socket); bool process_request(Stream &strm, Request &req, Response &res, bool close_connection, Error &error); bool write_content_with_provider(Stream &strm, const Request &req, - Error &error); + Error &error) const; void copy_settings(const ClientImpl &rhs); - // Socket endoint information + // Socket endpoint information const std::string host_; const int port_; const std::string host_and_port_; @@ -1090,6 +1365,10 @@ class ClientImpl { // Default headers Headers default_headers_; + // Header writer + std::function header_writer_ = + detail::write_headers; + // Settings std::string client_cert_path_; std::string client_key_path_; @@ -1148,24 +1427,31 @@ class ClientImpl { Logger logger_; private: + bool send_(Request &req, Response &res, Error &error); + Result send_(Request &&req); + socket_t create_client_socket(Error &error) const; - bool read_response_line(Stream &strm, const Request &req, Response &res); + bool read_response_line(Stream &strm, const Request &req, + Response &res) const; bool write_request(Stream &strm, Request &req, bool close_connection, Error &error); bool redirect(Request &req, Response &res, Error &error); bool handle_request(Stream &strm, Request &req, Response &res, bool close_connection, Error &error); std::unique_ptr send_with_content_provider( - Request &req, - // const char *method, const char *path, const Headers &headers, - const char *body, size_t content_length, ContentProvider content_provider, + Request &req, const char *body, size_t content_length, + ContentProvider content_provider, ContentProviderWithoutLength content_provider_without_length, - const char *content_type, Error &error); + const std::string &content_type, Error &error); Result send_with_content_provider( - const char *method, const char *path, const Headers &headers, - const char *body, size_t content_length, ContentProvider content_provider, + const std::string &method, const std::string &path, + const Headers &headers, const char *body, size_t content_length, + ContentProvider content_provider, ContentProviderWithoutLength content_provider_without_length, - const char *content_type); + const std::string &content_type); + ContentProviderWithoutLength get_multipart_content_provider( + const std::string &boundary, const MultipartFormDataItems &items, + const MultipartFormDataProviderItems &provider_items) const; std::string adjust_host_string(const std::string &host) const; @@ -1196,128 +1482,163 @@ class Client { bool is_valid() const; - Result Get(const char *path); - Result Get(const char *path, const Headers &headers); - Result Get(const char *path, Progress progress); - Result Get(const char *path, const Headers &headers, Progress progress); - Result Get(const char *path, ContentReceiver content_receiver); - Result Get(const char *path, const Headers &headers, + Result Get(const std::string &path); + Result Get(const std::string &path, const Headers &headers); + Result Get(const std::string &path, Progress progress); + Result Get(const std::string &path, const Headers &headers, + Progress progress); + Result Get(const std::string &path, ContentReceiver content_receiver); + Result Get(const std::string &path, const Headers &headers, ContentReceiver content_receiver); - Result Get(const char *path, ContentReceiver content_receiver, + Result Get(const std::string &path, ContentReceiver content_receiver, Progress progress); - Result Get(const char *path, const Headers &headers, + Result Get(const std::string &path, const Headers &headers, ContentReceiver content_receiver, Progress progress); - Result Get(const char *path, ResponseHandler response_handler, + Result Get(const std::string &path, ResponseHandler response_handler, ContentReceiver content_receiver); - Result Get(const char *path, const Headers &headers, + Result Get(const std::string &path, const Headers &headers, ResponseHandler response_handler, ContentReceiver content_receiver); - Result Get(const char *path, const Headers &headers, + Result Get(const std::string &path, const Headers &headers, ResponseHandler response_handler, ContentReceiver content_receiver, Progress progress); - Result Get(const char *path, ResponseHandler response_handler, + Result Get(const std::string &path, ResponseHandler response_handler, ContentReceiver content_receiver, Progress progress); - Result Get(const char *path, const Params ¶ms, const Headers &headers, + Result Get(const std::string &path, const Params ¶ms, + const Headers &headers, Progress progress = nullptr); + Result Get(const std::string &path, const Params ¶ms, + const Headers &headers, ContentReceiver content_receiver, Progress progress = nullptr); - Result Get(const char *path, const Params ¶ms, const Headers &headers, + Result Get(const std::string &path, const Params ¶ms, + const Headers &headers, ResponseHandler response_handler, ContentReceiver content_receiver, Progress progress = nullptr); - Result Get(const char *path, const Params ¶ms, const Headers &headers, - ResponseHandler response_handler, ContentReceiver content_receiver, - Progress progress = nullptr); - Result Head(const char *path); - Result Head(const char *path, const Headers &headers); - - Result Post(const char *path); - Result Post(const char *path, const char *body, size_t content_length, - const char *content_type); - Result Post(const char *path, const Headers &headers, const char *body, - size_t content_length, const char *content_type); - Result Post(const char *path, const std::string &body, - const char *content_type); - Result Post(const char *path, const Headers &headers, const std::string &body, - const char *content_type); - Result Post(const char *path, size_t content_length, - ContentProvider content_provider, const char *content_type); - Result Post(const char *path, ContentProviderWithoutLength content_provider, - const char *content_type); - Result Post(const char *path, const Headers &headers, size_t content_length, - ContentProvider content_provider, const char *content_type); - Result Post(const char *path, const Headers &headers, + Result Head(const std::string &path); + Result Head(const std::string &path, const Headers &headers); + + Result Post(const std::string &path); + Result Post(const std::string &path, const Headers &headers); + Result Post(const std::string &path, const char *body, size_t content_length, + const std::string &content_type); + Result Post(const std::string &path, const Headers &headers, const char *body, + size_t content_length, const std::string &content_type); + Result Post(const std::string &path, const std::string &body, + const std::string &content_type); + Result Post(const std::string &path, const Headers &headers, + const std::string &body, const std::string &content_type); + Result Post(const std::string &path, size_t content_length, + ContentProvider content_provider, + const std::string &content_type); + Result Post(const std::string &path, + ContentProviderWithoutLength content_provider, + const std::string &content_type); + Result Post(const std::string &path, const Headers &headers, + size_t content_length, ContentProvider content_provider, + const std::string &content_type); + Result Post(const std::string &path, const Headers &headers, ContentProviderWithoutLength content_provider, - const char *content_type); - Result Post(const char *path, const Params ¶ms); - Result Post(const char *path, const Headers &headers, const Params ¶ms); - Result Post(const char *path, const MultipartFormDataItems &items); - Result Post(const char *path, const Headers &headers, + const std::string &content_type); + Result Post(const std::string &path, const Params ¶ms); + Result Post(const std::string &path, const Headers &headers, + const Params ¶ms); + Result Post(const std::string &path, const MultipartFormDataItems &items); + Result Post(const std::string &path, const Headers &headers, const MultipartFormDataItems &items); - Result Post(const char *path, const Headers &headers, + Result Post(const std::string &path, const Headers &headers, const MultipartFormDataItems &items, const std::string &boundary); - Result Put(const char *path); - Result Put(const char *path, const char *body, size_t content_length, - const char *content_type); - Result Put(const char *path, const Headers &headers, const char *body, - size_t content_length, const char *content_type); - Result Put(const char *path, const std::string &body, - const char *content_type); - Result Put(const char *path, const Headers &headers, const std::string &body, - const char *content_type); - Result Put(const char *path, size_t content_length, - ContentProvider content_provider, const char *content_type); - Result Put(const char *path, ContentProviderWithoutLength content_provider, - const char *content_type); - Result Put(const char *path, const Headers &headers, size_t content_length, - ContentProvider content_provider, const char *content_type); - Result Put(const char *path, const Headers &headers, + Result Post(const std::string &path, const Headers &headers, + const MultipartFormDataItems &items, + const MultipartFormDataProviderItems &provider_items); + + Result Put(const std::string &path); + Result Put(const std::string &path, const char *body, size_t content_length, + const std::string &content_type); + Result Put(const std::string &path, const Headers &headers, const char *body, + size_t content_length, const std::string &content_type); + Result Put(const std::string &path, const std::string &body, + const std::string &content_type); + Result Put(const std::string &path, const Headers &headers, + const std::string &body, const std::string &content_type); + Result Put(const std::string &path, size_t content_length, + ContentProvider content_provider, const std::string &content_type); + Result Put(const std::string &path, ContentProviderWithoutLength content_provider, - const char *content_type); - Result Put(const char *path, const Params ¶ms); - Result Put(const char *path, const Headers &headers, const Params ¶ms); - Result Patch(const char *path); - Result Patch(const char *path, const char *body, size_t content_length, - const char *content_type); - Result Patch(const char *path, const Headers &headers, const char *body, - size_t content_length, const char *content_type); - Result Patch(const char *path, const std::string &body, - const char *content_type); - Result Patch(const char *path, const Headers &headers, - const std::string &body, const char *content_type); - Result Patch(const char *path, size_t content_length, - ContentProvider content_provider, const char *content_type); - Result Patch(const char *path, ContentProviderWithoutLength content_provider, - const char *content_type); - Result Patch(const char *path, const Headers &headers, size_t content_length, - ContentProvider content_provider, const char *content_type); - Result Patch(const char *path, const Headers &headers, + const std::string &content_type); + Result Put(const std::string &path, const Headers &headers, + size_t content_length, ContentProvider content_provider, + const std::string &content_type); + Result Put(const std::string &path, const Headers &headers, + ContentProviderWithoutLength content_provider, + const std::string &content_type); + Result Put(const std::string &path, const Params ¶ms); + Result Put(const std::string &path, const Headers &headers, + const Params ¶ms); + Result Put(const std::string &path, const MultipartFormDataItems &items); + Result Put(const std::string &path, const Headers &headers, + const MultipartFormDataItems &items); + Result Put(const std::string &path, const Headers &headers, + const MultipartFormDataItems &items, const std::string &boundary); + Result Put(const std::string &path, const Headers &headers, + const MultipartFormDataItems &items, + const MultipartFormDataProviderItems &provider_items); + + Result Patch(const std::string &path); + Result Patch(const std::string &path, const char *body, size_t content_length, + const std::string &content_type); + Result Patch(const std::string &path, const Headers &headers, + const char *body, size_t content_length, + const std::string &content_type); + Result Patch(const std::string &path, const std::string &body, + const std::string &content_type); + Result Patch(const std::string &path, const Headers &headers, + const std::string &body, const std::string &content_type); + Result Patch(const std::string &path, size_t content_length, + ContentProvider content_provider, + const std::string &content_type); + Result Patch(const std::string &path, + ContentProviderWithoutLength content_provider, + const std::string &content_type); + Result Patch(const std::string &path, const Headers &headers, + size_t content_length, ContentProvider content_provider, + const std::string &content_type); + Result Patch(const std::string &path, const Headers &headers, ContentProviderWithoutLength content_provider, - const char *content_type); - - Result Delete(const char *path); - Result Delete(const char *path, const Headers &headers); - Result Delete(const char *path, const char *body, size_t content_length, - const char *content_type); - Result Delete(const char *path, const Headers &headers, const char *body, - size_t content_length, const char *content_type); - Result Delete(const char *path, const std::string &body, - const char *content_type); - Result Delete(const char *path, const Headers &headers, - const std::string &body, const char *content_type); - - Result Options(const char *path); - Result Options(const char *path, const Headers &headers); + const std::string &content_type); + + Result Delete(const std::string &path); + Result Delete(const std::string &path, const Headers &headers); + Result Delete(const std::string &path, const char *body, + size_t content_length, const std::string &content_type); + Result Delete(const std::string &path, const Headers &headers, + const char *body, size_t content_length, + const std::string &content_type); + Result Delete(const std::string &path, const std::string &body, + const std::string &content_type); + Result Delete(const std::string &path, const Headers &headers, + const std::string &body, const std::string &content_type); + + Result Options(const std::string &path); + Result Options(const std::string &path, const Headers &headers); bool send(Request &req, Response &res, Error &error); Result send(const Request &req); - size_t is_socket_open() const; - void stop(); + std::string host() const; + int port() const; + + size_t is_socket_open() const; + socket_t socket() const; + void set_hostname_addr_map(std::map addr_map); void set_default_headers(Headers headers); + void + set_header_writer(std::function const &writer); + void set_address_family(int family); void set_tcp_nodelay(bool on); void set_socket_options(SocketOptions socket_options); @@ -1335,10 +1656,11 @@ class Client { template void set_write_timeout(const std::chrono::duration &duration); - void set_basic_auth(const char *username, const char *password); - void set_bearer_token_auth(const char *token); + void set_basic_auth(const std::string &username, const std::string &password); + void set_bearer_token_auth(const std::string &token); #ifdef CPPHTTPLIB_OPENSSL_SUPPORT - void set_digest_auth(const char *username, const char *password); + void set_digest_auth(const std::string &username, + const std::string &password); #endif void set_keep_alive(bool on); @@ -1350,13 +1672,15 @@ class Client { void set_decompress(bool on); - void set_interface(const char *intf); + void set_interface(const std::string &intf); - void set_proxy(const char *host, int port); - void set_proxy_basic_auth(const char *username, const char *password); - void set_proxy_bearer_token_auth(const char *token); + void set_proxy(const std::string &host, int port); + void set_proxy_basic_auth(const std::string &username, + const std::string &password); + void set_proxy_bearer_token_auth(const std::string &token); #ifdef CPPHTTPLIB_OPENSSL_SUPPORT - void set_proxy_digest_auth(const char *username, const char *password); + void set_proxy_digest_auth(const std::string &username, + const std::string &password); #endif #ifdef CPPHTTPLIB_OPENSSL_SUPPORT @@ -1367,10 +1691,11 @@ class Client { // SSL #ifdef CPPHTTPLIB_OPENSSL_SUPPORT - void set_ca_cert_path(const char *ca_cert_file_path, - const char *ca_cert_dir_path = nullptr); + void set_ca_cert_path(const std::string &ca_cert_file_path, + const std::string &ca_cert_dir_path = std::string()); void set_ca_cert_store(X509_STORE *ca_cert_store); + void load_ca_cert_store(const char *ca_cert, std::size_t size); long get_openssl_verify_result() const; @@ -1430,6 +1755,7 @@ class SSLClient : public ClientImpl { bool is_valid() const override; void set_ca_cert_store(X509_STORE *ca_cert_store); + void load_ca_cert_store(const char *ca_cert, std::size_t size); long get_openssl_verify_result() const; @@ -1438,7 +1764,7 @@ class SSLClient : public ClientImpl { private: bool create_and_connect_socket(Socket &socket, Error &error) override; void shutdown_ssl(Socket &socket, bool shutdown_gracefully) override; - void shutdown_ssl_impl(Socket &socket, bool shutdown_socket); + void shutdown_ssl_impl(Socket &socket, bool shutdown_gracefully); bool process_socket(const Socket &socket, std::function callback) override; @@ -1479,17 +1805,12 @@ inline void duration_to_sec_and_usec(const T &duration, U callback) { auto usec = std::chrono::duration_cast( duration - std::chrono::seconds(sec)) .count(); - callback(sec, usec); + callback(static_cast(sec), static_cast(usec)); } -template -inline T get_header_value(const Headers & /*headers*/, const char * /*key*/, - size_t /*id*/ = 0, uint64_t /*def*/ = 0) {} - -template <> -inline uint64_t get_header_value(const Headers &headers, - const char *key, size_t id, - uint64_t def) { +inline uint64_t get_header_value_u64(const Headers &headers, + const std::string &key, size_t id, + uint64_t def) { auto rng = headers.equal_range(key); auto it = rng.first; std::advance(it, static_cast(id)); @@ -1501,14 +1822,14 @@ inline uint64_t get_header_value(const Headers &headers, } // namespace detail -template -inline T Request::get_header_value(const char *key, size_t id) const { - return detail::get_header_value(headers, key, id, 0); +inline uint64_t Request::get_header_value_u64(const std::string &key, + size_t id) const { + return detail::get_header_value_u64(headers, key, id, 0); } -template -inline T Response::get_header_value(const char *key, size_t id) const { - return detail::get_header_value(headers, key, id, 0); +inline uint64_t Response::get_header_value_u64(const std::string &key, + size_t id) const { + return detail::get_header_value_u64(headers, key, id, 0); } template @@ -1516,11 +1837,7 @@ inline ssize_t Stream::write_format(const char *fmt, const Args &...args) { const auto bufsiz = 2048; std::array buf{}; -#if defined(_MSC_VER) && _MSC_VER < 1900 - auto sn = _snprintf_s(buf.data(), bufsiz, _TRUNCATE, fmt, args...); -#else auto sn = snprintf(buf.data(), buf.size() - 1, fmt, args...); -#endif if (sn <= 0) { return sn; } auto n = static_cast(sn); @@ -1530,14 +1847,8 @@ inline ssize_t Stream::write_format(const char *fmt, const Args &...args) { while (n >= glowable_buf.size() - 1) { glowable_buf.resize(glowable_buf.size() * 2); -#if defined(_MSC_VER) && _MSC_VER < 1900 - n = static_cast(_snprintf_s(&glowable_buf[0], glowable_buf.size(), - glowable_buf.size() - 1, fmt, - args...)); -#else n = static_cast( snprintf(&glowable_buf[0], glowable_buf.size() - 1, fmt, args...)); -#endif } return write(&glowable_buf[0], n); } else { @@ -1548,21 +1859,106 @@ inline ssize_t Stream::write_format(const char *fmt, const Args &...args) { inline void default_socket_options(socket_t sock) { int yes = 1; #ifdef _WIN32 - setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast(&yes), - sizeof(yes)); + setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, + reinterpret_cast(&yes), sizeof(yes)); setsockopt(sock, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, - reinterpret_cast(&yes), sizeof(yes)); + reinterpret_cast(&yes), sizeof(yes)); #else #ifdef SO_REUSEPORT - setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, reinterpret_cast(&yes), - sizeof(yes)); + setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, + reinterpret_cast(&yes), sizeof(yes)); #else - setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast(&yes), - sizeof(yes)); + setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, + reinterpret_cast(&yes), sizeof(yes)); #endif #endif } +inline const char *status_message(int status) { + switch (status) { + case StatusCode::Continue_100: return "Continue"; + case StatusCode::SwitchingProtocol_101: return "Switching Protocol"; + case StatusCode::Processing_102: return "Processing"; + case StatusCode::EarlyHints_103: return "Early Hints"; + case StatusCode::OK_200: return "OK"; + case StatusCode::Created_201: return "Created"; + case StatusCode::Accepted_202: return "Accepted"; + case StatusCode::NonAuthoritativeInformation_203: + return "Non-Authoritative Information"; + case StatusCode::NoContent_204: return "No Content"; + case StatusCode::ResetContent_205: return "Reset Content"; + case StatusCode::PartialContent_206: return "Partial Content"; + case StatusCode::MultiStatus_207: return "Multi-Status"; + case StatusCode::AlreadyReported_208: return "Already Reported"; + case StatusCode::IMUsed_226: return "IM Used"; + case StatusCode::MultipleChoices_300: return "Multiple Choices"; + case StatusCode::MovedPermanently_301: return "Moved Permanently"; + case StatusCode::Found_302: return "Found"; + case StatusCode::SeeOther_303: return "See Other"; + case StatusCode::NotModified_304: return "Not Modified"; + case StatusCode::UseProxy_305: return "Use Proxy"; + case StatusCode::unused_306: return "unused"; + case StatusCode::TemporaryRedirect_307: return "Temporary Redirect"; + case StatusCode::PermanentRedirect_308: return "Permanent Redirect"; + case StatusCode::BadRequest_400: return "Bad Request"; + case StatusCode::Unauthorized_401: return "Unauthorized"; + case StatusCode::PaymentRequired_402: return "Payment Required"; + case StatusCode::Forbidden_403: return "Forbidden"; + case StatusCode::NotFound_404: return "Not Found"; + case StatusCode::MethodNotAllowed_405: return "Method Not Allowed"; + case StatusCode::NotAcceptable_406: return "Not Acceptable"; + case StatusCode::ProxyAuthenticationRequired_407: + return "Proxy Authentication Required"; + case StatusCode::RequestTimeout_408: return "Request Timeout"; + case StatusCode::Conflict_409: return "Conflict"; + case StatusCode::Gone_410: return "Gone"; + case StatusCode::LengthRequired_411: return "Length Required"; + case StatusCode::PreconditionFailed_412: return "Precondition Failed"; + case StatusCode::PayloadTooLarge_413: return "Payload Too Large"; + case StatusCode::UriTooLong_414: return "URI Too Long"; + case StatusCode::UnsupportedMediaType_415: return "Unsupported Media Type"; + case StatusCode::RangeNotSatisfiable_416: return "Range Not Satisfiable"; + case StatusCode::ExpectationFailed_417: return "Expectation Failed"; + case StatusCode::ImATeapot_418: return "I'm a teapot"; + case StatusCode::MisdirectedRequest_421: return "Misdirected Request"; + case StatusCode::UnprocessableContent_422: return "Unprocessable Content"; + case StatusCode::Locked_423: return "Locked"; + case StatusCode::FailedDependency_424: return "Failed Dependency"; + case StatusCode::TooEarly_425: return "Too Early"; + case StatusCode::UpgradeRequired_426: return "Upgrade Required"; + case StatusCode::PreconditionRequired_428: return "Precondition Required"; + case StatusCode::TooManyRequests_429: return "Too Many Requests"; + case StatusCode::RequestHeaderFieldsTooLarge_431: + return "Request Header Fields Too Large"; + case StatusCode::UnavailableForLegalReasons_451: + return "Unavailable For Legal Reasons"; + case StatusCode::NotImplemented_501: return "Not Implemented"; + case StatusCode::BadGateway_502: return "Bad Gateway"; + case StatusCode::ServiceUnavailable_503: return "Service Unavailable"; + case StatusCode::GatewayTimeout_504: return "Gateway Timeout"; + case StatusCode::HttpVersionNotSupported_505: + return "HTTP Version Not Supported"; + case StatusCode::VariantAlsoNegotiates_506: return "Variant Also Negotiates"; + case StatusCode::InsufficientStorage_507: return "Insufficient Storage"; + case StatusCode::LoopDetected_508: return "Loop Detected"; + case StatusCode::NotExtended_510: return "Not Extended"; + case StatusCode::NetworkAuthenticationRequired_511: + return "Network Authentication Required"; + + default: + case StatusCode::InternalServerError_500: return "Internal Server Error"; + } +} + +inline std::string get_bearer_token_auth(const Request &req) { + if (req.has_header("Authorization")) { + static std::string BearerHeaderPrefix = "Bearer "; + return req.get_header_value("Authorization") + .substr(BearerHeaderPrefix.length()); + } + return ""; +} + template inline Server & Server::set_read_timeout(const std::chrono::duration &duration) { @@ -1589,20 +1985,21 @@ Server::set_idle_interval(const std::chrono::duration &duration) { inline std::string to_string(const Error error) { switch (error) { - case Error::Success: return "Success"; - case Error::Connection: return "Connection"; - case Error::BindIPAddress: return "BindIPAddress"; - case Error::Read: return "Read"; - case Error::Write: return "Write"; - case Error::ExceedRedirectCount: return "ExceedRedirectCount"; - case Error::Canceled: return "Canceled"; - case Error::SSLConnection: return "SSLConnection"; - case Error::SSLLoadingCerts: return "SSLLoadingCerts"; - case Error::SSLServerVerification: return "SSLServerVerification"; + case Error::Success: return "Success (no error)"; + case Error::Connection: return "Could not establish connection"; + case Error::BindIPAddress: return "Failed to bind IP address"; + case Error::Read: return "Failed to read connection"; + case Error::Write: return "Failed to write connection"; + case Error::ExceedRedirectCount: return "Maximum redirect count exceeded"; + case Error::Canceled: return "Connection handling canceled"; + case Error::SSLConnection: return "SSL connection failed"; + case Error::SSLLoadingCerts: return "SSL certificate loading failed"; + case Error::SSLServerVerification: return "SSL server verification failed"; case Error::UnsupportedMultipartBoundaryChars: - return "UnsupportedMultipartBoundaryChars"; - case Error::Compression: return "Compression"; - case Error::ConnectionTimeout: return "ConnectionTimeout"; + return "Unsupported HTTP multipart boundary characters"; + case Error::Compression: return "Compression failed"; + case Error::ConnectionTimeout: return "Connection timed out"; + case Error::ProxyConnection: return "Proxy connection failed"; case Error::Unknown: return "Unknown"; default: break; } @@ -1616,9 +2013,9 @@ inline std::ostream &operator<<(std::ostream &os, const Error &obj) { return os; } -template -inline T Result::get_request_header_value(const char *key, size_t id) const { - return detail::get_header_value(request_headers_, key, id, 0); +inline uint64_t Result::get_request_header_value_u64(const std::string &key, + size_t id) const { + return detail::get_header_value_u64(request_headers_, key, id, 0); } template @@ -1666,13 +2063,13 @@ Client::set_write_timeout(const std::chrono::duration &duration) { * .h + .cc. */ -std::string hosted_at(const char *hostname); +std::string hosted_at(const std::string &hostname); -void hosted_at(const char *hostname, std::vector &addrs); +void hosted_at(const std::string &hostname, std::vector &addrs); -std::string append_query_params(const char *path, const Params ¶ms); +std::string append_query_params(const std::string &path, const Params ¶ms); -std::pair make_range_header(Ranges ranges); +std::pair make_range_header(const Ranges &ranges); std::pair make_basic_authentication_header(const std::string &username, @@ -1692,25 +2089,31 @@ std::string trim_copy(const std::string &s); void split(const char *b, const char *e, char d, std::function fn); +void split(const char *b, const char *e, char d, size_t m, + std::function fn); + bool process_client_socket(socket_t sock, time_t read_timeout_sec, time_t read_timeout_usec, time_t write_timeout_sec, time_t write_timeout_usec, std::function callback); socket_t create_client_socket( - const char *host, const char *ip, int port, int address_family, - bool tcp_nodelay, SocketOptions socket_options, + const std::string &host, const std::string &ip, int port, + int address_family, bool tcp_nodelay, SocketOptions socket_options, time_t connection_timeout_sec, time_t connection_timeout_usec, time_t read_timeout_sec, time_t read_timeout_usec, time_t write_timeout_sec, time_t write_timeout_usec, const std::string &intf, Error &error); -const char *get_header_value(const Headers &headers, const char *key, +const char *get_header_value(const Headers &headers, const std::string &key, size_t id = 0, const char *def = nullptr); std::string params_to_query_str(const Params ¶ms); void parse_query_text(const std::string &s, Params ¶ms); +bool parse_multipart_boundary(const std::string &content_type, + std::string &boundary); + bool parse_range_header(const std::string &s, Ranges &ranges); int close_socket(socket_t sock); @@ -1733,6 +2136,7 @@ class BufferStream : public Stream { ssize_t read(char *ptr, size_t size) override; ssize_t write(const char *ptr, size_t size) override; void get_remote_ip_and_port(std::string &ip, int &port) const override; + void get_local_ip_and_port(std::string &ip, int &port) const override; socket_t socket() const override; const std::string &get_buffer() const; @@ -1764,7 +2168,7 @@ class decompressor { class nocompressor : public compressor { public: - virtual ~nocompressor() = default; + ~nocompressor() override = default; bool compress(const char *data, size_t data_length, bool /*last*/, Callback callback) override; @@ -1774,7 +2178,7 @@ class nocompressor : public compressor { class gzip_compressor : public compressor { public: gzip_compressor(); - ~gzip_compressor(); + ~gzip_compressor() override; bool compress(const char *data, size_t data_length, bool last, Callback callback) override; @@ -1787,7 +2191,7 @@ class gzip_compressor : public compressor { class gzip_decompressor : public decompressor { public: gzip_decompressor(); - ~gzip_decompressor(); + ~gzip_decompressor() override; bool is_valid() const override; @@ -1850,6 +2254,29 @@ class stream_line_reader { std::string glowable_buffer_; }; +class mmap { +public: + mmap(const char *path); + ~mmap(); + + bool open(const char *path); + void close(); + + bool is_open() const; + size_t size() const; + const char *data() const; + +private: +#if defined(_WIN32) + HANDLE hFile_; + HANDLE hMapping_; +#else + int fd_; +#endif + size_t size_; + void *addr_; +}; + } // namespace detail // ---------------------------------------------------------------------------- @@ -1881,7 +2308,7 @@ inline bool from_hex_to_i(const std::string &s, size_t i, size_t cnt, val = 0; for (; cnt; i++, cnt--) { if (!s[i]) { return false; } - int v = 0; + auto v = 0; if (is_hex(s[i], v)) { val = val * 16 + v; } else { @@ -1892,7 +2319,7 @@ inline bool from_hex_to_i(const std::string &s, size_t i, size_t cnt, } inline std::string from_i_to_hex(size_t n) { - const char *charset = "0123456789abcdef"; + static const auto charset = "0123456789abcdef"; std::string ret; do { ret = charset[n & 15] + ret; @@ -1903,7 +2330,7 @@ inline std::string from_i_to_hex(size_t n) { inline size_t to_utf8(int code, char *buff) { if (code < 0x0080) { - buff[0] = (code & 0x7F); + buff[0] = static_cast(code & 0x7F); return 1; } else if (code < 0x0800) { buff[0] = static_cast(0xC0 | ((code >> 6) & 0x1F)); @@ -1942,8 +2369,8 @@ inline std::string base64_encode(const std::string &in) { std::string out; out.reserve(in.size()); - int val = 0; - int valb = -6; + auto val = 0; + auto valb = -6; for (auto c : in) { val = (val << 8) + static_cast(c); @@ -1990,6 +2417,11 @@ inline bool is_valid_path(const std::string &path) { // Read component auto beg = i; while (i < path.size() && path[i] != '/') { + if (path[i] == '\0') { + return false; + } else if (path[i] == '\\') { + return false; + } i++; } @@ -2074,7 +2506,7 @@ inline std::string decode_url(const std::string &s, for (size_t i = 0; i < s.size(); i++) { if (s[i] == '%' && i + 1 < s.size()) { if (s[i + 1] == 'u') { - int val = 0; + auto val = 0; if (from_hex_to_i(s, i + 2, 4, val)) { // 4 digits Unicode codes char buff[4]; @@ -2085,7 +2517,7 @@ inline std::string decode_url(const std::string &s, result += s[i]; } } else { - int val = 0; + auto val = 0; if (from_hex_to_i(s, i + 1, 2, val)) { // 2 digits hex codes result += static_cast(val); @@ -2138,16 +2570,30 @@ inline std::string trim_copy(const std::string &s) { return s.substr(r.first, r.second - r.first); } +inline std::string trim_double_quotes_copy(const std::string &s) { + if (s.length() >= 2 && s.front() == '"' && s.back() == '"') { + return s.substr(1, s.size() - 2); + } + return s; +} + inline void split(const char *b, const char *e, char d, std::function fn) { + return split(b, e, d, (std::numeric_limits::max)(), std::move(fn)); +} + +inline void split(const char *b, const char *e, char d, size_t m, + std::function fn) { size_t i = 0; size_t beg = 0; + size_t count = 1; while (e ? (b + i < e) : (b[i] != '\0')) { - if (b[i] == d) { + if (b[i] == d && count < m) { auto r = trim(b, e, beg, i); if (r.first < r.second) { fn(&b[r.first], &b[r.second]); } beg = i + 1; + count++; } i++; } @@ -2223,6 +2669,97 @@ inline void stream_line_reader::append(char c) { } } +inline mmap::mmap(const char *path) +#if defined(_WIN32) + : hFile_(NULL), hMapping_(NULL) +#else + : fd_(-1) +#endif + , + size_(0), addr_(nullptr) { + open(path); +} + +inline mmap::~mmap() { close(); } + +inline bool mmap::open(const char *path) { + close(); + +#if defined(_WIN32) + hFile_ = ::CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + + if (hFile_ == INVALID_HANDLE_VALUE) { return false; } + + size_ = ::GetFileSize(hFile_, NULL); + + hMapping_ = ::CreateFileMapping(hFile_, NULL, PAGE_READONLY, 0, 0, NULL); + + if (hMapping_ == NULL) { + close(); + return false; + } + + addr_ = ::MapViewOfFile(hMapping_, FILE_MAP_READ, 0, 0, 0); +#else + fd_ = ::open(path, O_RDONLY); + if (fd_ == -1) { return false; } + + struct stat sb; + if (fstat(fd_, &sb) == -1) { + close(); + return false; + } + size_ = static_cast(sb.st_size); + + addr_ = ::mmap(NULL, size_, PROT_READ, MAP_PRIVATE, fd_, 0); +#endif + + if (addr_ == nullptr) { + close(); + return false; + } + + return true; +} + +inline bool mmap::is_open() const { return addr_ != nullptr; } + +inline size_t mmap::size() const { return size_; } + +inline const char *mmap::data() const { + return static_cast(addr_); +} + +inline void mmap::close() { +#if defined(_WIN32) + if (addr_) { + ::UnmapViewOfFile(addr_); + addr_ = nullptr; + } + + if (hMapping_) { + ::CloseHandle(hMapping_); + hMapping_ = NULL; + } + + if (hFile_ != INVALID_HANDLE_VALUE) { + ::CloseHandle(hFile_); + hFile_ = INVALID_HANDLE_VALUE; + } +#else + if (addr_ != nullptr) { + munmap(addr_, size_); + addr_ = nullptr; + } + + if (fd_ != -1) { + ::close(fd_); + fd_ = -1; + } +#endif + size_ = 0; +} inline int close_socket(socket_t sock) { #ifdef _WIN32 return closesocket(sock); @@ -2232,7 +2769,7 @@ inline int close_socket(socket_t sock) { } template inline ssize_t handle_EINTR(T fn) { - ssize_t res = false; + ssize_t res = 0; while (true) { res = fn(); if (res < 0 && errno == EINTR) { continue; } @@ -2277,7 +2814,7 @@ inline ssize_t select_read(socket_t sock, time_t sec, time_t usec) { return handle_EINTR([&]() { return poll(&pfd_read, 1, timeout); }); #else #ifndef _WIN32 - if (sock >= FD_SETSIZE) { return 1; } + if (sock >= FD_SETSIZE) { return -1; } #endif fd_set fds; @@ -2305,7 +2842,7 @@ inline ssize_t select_write(socket_t sock, time_t sec, time_t usec) { return handle_EINTR([&]() { return poll(&pfd_read, 1, timeout); }); #else #ifndef _WIN32 - if (sock >= FD_SETSIZE) { return 1; } + if (sock >= FD_SETSIZE) { return -1; } #endif fd_set fds; @@ -2336,7 +2873,7 @@ inline Error wait_until_socket_is_ready(socket_t sock, time_t sec, if (poll_res == 0) { return Error::ConnectionTimeout; } if (poll_res > 0 && pfd_read.revents & (POLLIN | POLLOUT)) { - int error = 0; + auto error = 0; socklen_t len = sizeof(error); auto res = getsockopt(sock, SOL_SOCKET, SO_ERROR, reinterpret_cast(&error), &len); @@ -2368,7 +2905,7 @@ inline Error wait_until_socket_is_ready(socket_t sock, time_t sec, if (ret == 0) { return Error::ConnectionTimeout; } if (ret > 0 && (FD_ISSET(sock, &fdsr) || FD_ISSET(sock, &fdsw))) { - int error = 0; + auto error = 0; socklen_t len = sizeof(error); auto res = getsockopt(sock, SOL_SOCKET, SO_ERROR, reinterpret_cast(&error), &len); @@ -2401,6 +2938,7 @@ class SocketStream : public Stream { ssize_t read(char *ptr, size_t size) override; ssize_t write(const char *ptr, size_t size) override; void get_remote_ip_and_port(std::string &ip, int &port) const override; + void get_local_ip_and_port(std::string &ip, int &port) const override; socket_t socket() const override; private: @@ -2414,7 +2952,7 @@ class SocketStream : public Stream { size_t read_buff_off_ = 0; size_t read_buff_content_size_ = 0; - static const size_t read_buff_size_ = 1024 * 4; + static const size_t read_buff_size_ = 1024l * 4; }; #ifdef CPPHTTPLIB_OPENSSL_SUPPORT @@ -2430,6 +2968,7 @@ class SSLSocketStream : public Stream { ssize_t read(char *ptr, size_t size) override; ssize_t write(const char *ptr, size_t size) override; void get_remote_ip_and_port(std::string &ip, int &port) const override; + void get_local_ip_and_port(std::string &ip, int &port) const override; socket_t socket() const override; private: @@ -2515,7 +3054,7 @@ inline int shutdown_socket(socket_t sock) { } template -socket_t create_socket(const char *host, const char *ip, int port, +socket_t create_socket(const std::string &host, const std::string &ip, int port, int address_family, int socket_flags, bool tcp_nodelay, SocketOptions socket_options, BindOrConnect bind_or_connect) { @@ -2528,17 +3067,44 @@ socket_t create_socket(const char *host, const char *ip, int port, hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = 0; - if (ip[0] != '\0') { - node = ip; + if (!ip.empty()) { + node = ip.c_str(); // Ask getaddrinfo to convert IP in c-string to address hints.ai_family = AF_UNSPEC; hints.ai_flags = AI_NUMERICHOST; } else { - node = host; + if (!host.empty()) { node = host.c_str(); } hints.ai_family = address_family; hints.ai_flags = socket_flags; } +#ifndef _WIN32 + if (hints.ai_family == AF_UNIX) { + const auto addrlen = host.length(); + if (addrlen > sizeof(sockaddr_un::sun_path)) { return INVALID_SOCKET; } + + auto sock = socket(hints.ai_family, hints.ai_socktype, hints.ai_protocol); + if (sock != INVALID_SOCKET) { + sockaddr_un addr{}; + addr.sun_family = AF_UNIX; + std::copy(host.begin(), host.end(), addr.sun_path); + + hints.ai_addr = reinterpret_cast(&addr); + hints.ai_addrlen = static_cast( + sizeof(addr) - sizeof(addr.sun_path) + addrlen); + + fcntl(sock, F_SETFD, FD_CLOEXEC); + if (socket_options) { socket_options(sock); } + + if (!bind_or_connect(sock, hints)) { + close_socket(sock); + sock = INVALID_SOCKET; + } + } + return sock; + } +#endif + auto service = std::to_string(port); if (getaddrinfo(node, service.c_str(), &hints, &result)) { @@ -2577,21 +3143,34 @@ socket_t create_socket(const char *host, const char *ip, int port, if (sock == INVALID_SOCKET) { continue; } #ifndef _WIN32 - if (fcntl(sock, F_SETFD, FD_CLOEXEC) == -1) { continue; } + if (fcntl(sock, F_SETFD, FD_CLOEXEC) == -1) { + close_socket(sock); + continue; + } #endif if (tcp_nodelay) { - int yes = 1; - setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast(&yes), - sizeof(yes)); + auto yes = 1; +#ifdef _WIN32 + setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, + reinterpret_cast(&yes), sizeof(yes)); +#else + setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, + reinterpret_cast(&yes), sizeof(yes)); +#endif } if (socket_options) { socket_options(sock); } if (rp->ai_family == AF_INET6) { - int no = 0; - setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast(&no), - sizeof(no)); + auto no = 0; +#ifdef _WIN32 + setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, + reinterpret_cast(&no), sizeof(no)); +#else + setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, + reinterpret_cast(&no), sizeof(no)); +#endif } // bind or connect @@ -2626,7 +3205,7 @@ inline bool is_connection_error() { #endif } -inline bool bind_ip_address(socket_t sock, const char *host) { +inline bool bind_ip_address(socket_t sock, const std::string &host) { struct addrinfo hints; struct addrinfo *result; @@ -2635,7 +3214,7 @@ inline bool bind_ip_address(socket_t sock, const char *host) { hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = 0; - if (getaddrinfo(host, "0", &hints, &result)) { return false; } + if (getaddrinfo(host.c_str(), "0", &hints, &result)) { return false; } auto ret = false; for (auto rp = result; rp; rp = rp->ai_next) { @@ -2650,7 +3229,7 @@ inline bool bind_ip_address(socket_t sock, const char *host) { return ret; } -#if !defined _WIN32 && !defined ANDROID +#if !defined _WIN32 && !defined ANDROID && !defined _AIX && !defined __MVS__ #define USE_IF2IP #endif @@ -2694,8 +3273,8 @@ inline std::string if2ip(int address_family, const std::string &ifn) { #endif inline socket_t create_client_socket( - const char *host, const char *ip, int port, int address_family, - bool tcp_nodelay, SocketOptions socket_options, + const std::string &host, const std::string &ip, int port, + int address_family, bool tcp_nodelay, SocketOptions socket_options, time_t connection_timeout_sec, time_t connection_timeout_usec, time_t read_timeout_sec, time_t read_timeout_usec, time_t write_timeout_sec, time_t write_timeout_usec, const std::string &intf, Error &error) { @@ -2704,9 +3283,9 @@ inline socket_t create_client_socket( [&](socket_t sock2, struct addrinfo &ai) -> bool { if (!intf.empty()) { #ifdef USE_IF2IP - auto ip = if2ip(address_family, intf); - if (ip.empty()) { ip = intf; } - if (!bind_ip_address(sock2, ip.c_str())) { + auto ip_from_if = if2ip(address_family, intf); + if (ip_from_if.empty()) { ip_from_if = intf; } + if (!bind_ip_address(sock2, ip_from_if)) { error = Error::BindIPAddress; return false; } @@ -2734,13 +3313,14 @@ inline socket_t create_client_socket( #ifdef _WIN32 auto timeout = static_cast(read_timeout_sec * 1000 + read_timeout_usec / 1000); - setsockopt(sock2, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, - sizeof(timeout)); + setsockopt(sock2, SOL_SOCKET, SO_RCVTIMEO, + reinterpret_cast(&timeout), sizeof(timeout)); #else timeval tv; tv.tv_sec = static_cast(read_timeout_sec); tv.tv_usec = static_cast(read_timeout_usec); - setsockopt(sock2, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)); + setsockopt(sock2, SOL_SOCKET, SO_RCVTIMEO, + reinterpret_cast(&tv), sizeof(tv)); #endif } { @@ -2748,13 +3328,14 @@ inline socket_t create_client_socket( #ifdef _WIN32 auto timeout = static_cast(write_timeout_sec * 1000 + write_timeout_usec / 1000); - setsockopt(sock2, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, - sizeof(timeout)); + setsockopt(sock2, SOL_SOCKET, SO_SNDTIMEO, + reinterpret_cast(&timeout), sizeof(timeout)); #else timeval tv; tv.tv_sec = static_cast(write_timeout_sec); tv.tv_usec = static_cast(write_timeout_usec); - setsockopt(sock2, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(tv)); + setsockopt(sock2, SOL_SOCKET, SO_SNDTIMEO, + reinterpret_cast(&tv), sizeof(tv)); #endif } @@ -2771,9 +3352,8 @@ inline socket_t create_client_socket( return sock; } -inline bool get_remote_ip_and_port(const struct sockaddr_storage &addr, - socklen_t addr_len, std::string &ip, - int &port) { +inline bool get_ip_and_port(const struct sockaddr_storage &addr, + socklen_t addr_len, std::string &ip, int &port) { if (addr.ss_family == AF_INET) { port = ntohs(reinterpret_cast(&addr)->sin_port); } else if (addr.ss_family == AF_INET6) { @@ -2794,21 +3374,53 @@ inline bool get_remote_ip_and_port(const struct sockaddr_storage &addr, return true; } +inline void get_local_ip_and_port(socket_t sock, std::string &ip, int &port) { + struct sockaddr_storage addr; + socklen_t addr_len = sizeof(addr); + if (!getsockname(sock, reinterpret_cast(&addr), + &addr_len)) { + get_ip_and_port(addr, addr_len, ip, port); + } +} + inline void get_remote_ip_and_port(socket_t sock, std::string &ip, int &port) { struct sockaddr_storage addr; socklen_t addr_len = sizeof(addr); if (!getpeername(sock, reinterpret_cast(&addr), &addr_len)) { - get_remote_ip_and_port(addr, addr_len, ip, port); +#ifndef _WIN32 + if (addr.ss_family == AF_UNIX) { +#if defined(__linux__) + struct ucred ucred; + socklen_t len = sizeof(ucred); + if (getsockopt(sock, SOL_SOCKET, SO_PEERCRED, &ucred, &len) == 0) { + port = ucred.pid; + } +#elif defined(SOL_LOCAL) && defined(SO_PEERPID) // __APPLE__ + pid_t pid; + socklen_t len = sizeof(pid); + if (getsockopt(sock, SOL_LOCAL, SO_PEERPID, &pid, &len) == 0) { + port = pid; + } +#endif + return; + } +#endif + get_ip_and_port(addr, addr_len, ip, port); } } inline constexpr unsigned int str2tag_core(const char *s, size_t l, unsigned int h) { - return (l == 0) ? h - : str2tag_core(s + 1, l - 1, - (h * 33) ^ static_cast(*s)); + return (l == 0) + ? h + : str2tag_core( + s + 1, l - 1, + // Unsets the 6 high bits of h, therefore no overflow happens + (((std::numeric_limits::max)() >> 6) & + h * 33) ^ + static_cast(*s)); } inline unsigned int str2tag(const std::string &s) { @@ -2823,18 +3435,20 @@ inline constexpr unsigned int operator"" _t(const char *s, size_t l) { } // namespace udl -inline const char * +inline std::string find_content_type(const std::string &path, - const std::map &user_data) { + const std::map &user_data, + const std::string &default_content_type) { auto ext = file_extension(path); auto it = user_data.find(ext); - if (it != user_data.end()) { return it->second.c_str(); } + if (it != user_data.end()) { return it->second; } using udl::operator""_t; switch (str2tag(ext)) { - default: return nullptr; + default: return default_content_type; + case "css"_t: return "text/css"; case "csv"_t: return "text/csv"; case "htm"_t: @@ -2887,76 +3501,6 @@ find_content_type(const std::string &path, } } -inline const char *status_message(int status) { - switch (status) { - case 100: return "Continue"; - case 101: return "Switching Protocol"; - case 102: return "Processing"; - case 103: return "Early Hints"; - case 200: return "OK"; - case 201: return "Created"; - case 202: return "Accepted"; - case 203: return "Non-Authoritative Information"; - case 204: return "No Content"; - case 205: return "Reset Content"; - case 206: return "Partial Content"; - case 207: return "Multi-Status"; - case 208: return "Already Reported"; - case 226: return "IM Used"; - case 300: return "Multiple Choice"; - case 301: return "Moved Permanently"; - case 302: return "Found"; - case 303: return "See Other"; - case 304: return "Not Modified"; - case 305: return "Use Proxy"; - case 306: return "unused"; - case 307: return "Temporary Redirect"; - case 308: return "Permanent Redirect"; - case 400: return "Bad Request"; - case 401: return "Unauthorized"; - case 402: return "Payment Required"; - case 403: return "Forbidden"; - case 404: return "Not Found"; - case 405: return "Method Not Allowed"; - case 406: return "Not Acceptable"; - case 407: return "Proxy Authentication Required"; - case 408: return "Request Timeout"; - case 409: return "Conflict"; - case 410: return "Gone"; - case 411: return "Length Required"; - case 412: return "Precondition Failed"; - case 413: return "Payload Too Large"; - case 414: return "URI Too Long"; - case 415: return "Unsupported Media Type"; - case 416: return "Range Not Satisfiable"; - case 417: return "Expectation Failed"; - case 418: return "I'm a teapot"; - case 421: return "Misdirected Request"; - case 422: return "Unprocessable Entity"; - case 423: return "Locked"; - case 424: return "Failed Dependency"; - case 425: return "Too Early"; - case 426: return "Upgrade Required"; - case 428: return "Precondition Required"; - case 429: return "Too Many Requests"; - case 431: return "Request Header Fields Too Large"; - case 451: return "Unavailable For Legal Reasons"; - case 501: return "Not Implemented"; - case 502: return "Bad Gateway"; - case 503: return "Service Unavailable"; - case 504: return "Gateway Timeout"; - case 505: return "HTTP Version Not Supported"; - case 506: return "Variant Also Negotiates"; - case 507: return "Insufficient Storage"; - case 508: return "Loop Detected"; - case 510: return "Not Extended"; - case 511: return "Network Authentication Required"; - - default: - case 500: return "Internal Server Error"; - } -} - inline bool can_compress_content_type(const std::string &content_type) { using udl::operator""_t; @@ -3033,7 +3577,7 @@ inline bool gzip_compressor::compress(const char *data, size_t data_length, data += strm_.avail_in; auto flush = (last && data_length == 0) ? Z_FINISH : Z_NO_FLUSH; - int ret = Z_OK; + auto ret = Z_OK; std::array buff{}; do { @@ -3077,7 +3621,7 @@ inline bool gzip_decompressor::decompress(const char *data, size_t data_length, Callback callback) { assert(is_valid_); - int ret = Z_OK; + auto ret = Z_OK; do { constexpr size_t max_avail_in = @@ -3091,16 +3635,12 @@ inline bool gzip_decompressor::decompress(const char *data, size_t data_length, data += strm_.avail_in; std::array buff{}; - while (strm_.avail_in > 0) { + while (strm_.avail_in > 0 && ret == Z_OK) { strm_.avail_out = static_cast(buff.size()); strm_.next_out = reinterpret_cast(buff.data()); - auto prev_avail_in = strm_.avail_in; - ret = inflate(&strm_, Z_NO_FLUSH); - if (prev_avail_in - strm_.avail_in == 0) { return false; } - assert(ret != Z_STREAM_ERROR); switch (ret) { case Z_NEED_DICT: @@ -3113,7 +3653,7 @@ inline bool gzip_decompressor::decompress(const char *data, size_t data_length, } } - if (ret != Z_OK && ret != Z_STREAM_END) return false; + if (ret != Z_OK && ret != Z_STREAM_END) { return false; } } while (data_length > 0); @@ -3182,7 +3722,7 @@ inline bool brotli_decompressor::decompress(const char *data, return 0; } - const uint8_t *next_in = (const uint8_t *)data; + auto next_in = reinterpret_cast(data); size_t avail_in = data_length; size_t total_out; @@ -3207,12 +3747,13 @@ inline bool brotli_decompressor::decompress(const char *data, } #endif -inline bool has_header(const Headers &headers, const char *key) { +inline bool has_header(const Headers &headers, const std::string &key) { return headers.find(key) != headers.end(); } -inline const char *get_header_value(const Headers &headers, const char *key, - size_t id, const char *def) { +inline const char *get_header_value(const Headers &headers, + const std::string &key, size_t id, + const char *def) { auto rng = headers.equal_range(key); auto it = rng.first; std::advance(it, static_cast(id)); @@ -3220,6 +3761,14 @@ inline const char *get_header_value(const Headers &headers, const char *key, return def; } +inline bool compare_case_ignore(const std::string &a, const std::string &b) { + if (a.size() != b.size()) { return false; } + for (size_t i = 0; i < b.size(); i++) { + if (::tolower(a[i]) != ::tolower(b[i])) { return false; } + } + return true; +} + template inline bool parse_header(const char *beg, const char *end, T fn) { // Skip trailing spaces and tabs. @@ -3243,7 +3792,14 @@ inline bool parse_header(const char *beg, const char *end, T fn) { } if (p < end) { - fn(std::string(beg, key_end), decode_url(std::string(p, end), false)); + auto key_len = key_end - beg; + if (!key_len) { return false; } + + auto key = std::string(beg, key_end); + auto val = compare_case_ignore(key, "Location") + ? std::string(p, end) + : decode_url(std::string(p, end), false); + fn(std::move(key), std::move(val)); return true; } @@ -3328,11 +3884,7 @@ inline bool read_content_without_length(Stream &strm, uint64_t r = 0; for (;;) { auto n = strm.read(buf, CPPHTTPLIB_RECV_BUFSIZ); - if (n < 0) { - return false; - } else if (n == 0) { - return true; - } + if (n <= 0) { return true; } if (!out(buf, static_cast(n), r, 0)) { return false; } r += static_cast(n); @@ -3341,7 +3893,8 @@ inline bool read_content_without_length(Stream &strm, return true; } -inline bool read_content_chunked(Stream &strm, +template +inline bool read_content_chunked(Stream &strm, T &x, ContentReceiverWithProgress out) { const auto bufsiz = 16; char buf[bufsiz]; @@ -3367,23 +3920,37 @@ inline bool read_content_chunked(Stream &strm, if (!line_reader.getline()) { return false; } - if (strcmp(line_reader.ptr(), "\r\n")) { break; } + if (strcmp(line_reader.ptr(), "\r\n") != 0) { return false; } if (!line_reader.getline()) { return false; } } - if (chunk_len == 0) { - // Reader terminator after chunks - if (!line_reader.getline() || strcmp(line_reader.ptr(), "\r\n")) - return false; + assert(chunk_len == 0); + + // Trailer + if (!line_reader.getline()) { return false; } + + while (strcmp(line_reader.ptr(), "\r\n") != 0) { + if (line_reader.size() > CPPHTTPLIB_HEADER_MAX_LENGTH) { return false; } + + // Exclude line terminator + constexpr auto line_terminator_len = 2; + auto end = line_reader.ptr() + line_reader.size() - line_terminator_len; + + parse_header(line_reader.ptr(), end, + [&](std::string &&key, std::string &&val) { + x.headers.emplace(std::move(key), std::move(val)); + }); + + if (!line_reader.getline()) { return false; } } return true; } inline bool is_chunked_transfer_encoding(const Headers &headers) { - return !strcasecmp(get_header_value(headers, "Transfer-Encoding", 0, ""), - "chunked"); + return compare_case_ignore( + get_header_value(headers, "Transfer-Encoding", 0, ""), "chunked"); } template @@ -3398,14 +3965,14 @@ bool prepare_content_receiver(T &x, int &status, #ifdef CPPHTTPLIB_ZLIB_SUPPORT decompressor = detail::make_unique(); #else - status = 415; + status = StatusCode::UnsupportedMediaType_415; return false; #endif } else if (encoding.find("br") != std::string::npos) { #ifdef CPPHTTPLIB_BROTLI_SUPPORT decompressor = detail::make_unique(); #else - status = 415; + status = StatusCode::UnsupportedMediaType_415; return false; #endif } @@ -3421,7 +3988,7 @@ bool prepare_content_receiver(T &x, int &status, }; return callback(std::move(out)); } else { - status = 500; + status = StatusCode::InternalServerError_500; return false; } } @@ -3445,11 +4012,11 @@ bool read_content(Stream &strm, T &x, size_t payload_max_length, int &status, auto exceed_payload_max_length = false; if (is_chunked_transfer_encoding(x.headers)) { - ret = read_content_chunked(strm, out); + ret = read_content_chunked(strm, x, out); } else if (!has_header(x.headers, "Content-Length")) { ret = read_content_without_length(strm, out); } else { - auto len = get_header_value(x.headers, "Content-Length"); + auto len = get_header_value_u64(x.headers, "Content-Length", 0, 0); if (len > payload_max_length) { exceed_payload_max_length = true; skip_content_with_length(strm, len); @@ -3459,7 +4026,10 @@ bool read_content(Stream &strm, T &x, size_t payload_max_length, int &status, } } - if (!ret) { status = exceed_payload_max_length ? 413 : 400; } + if (!ret) { + status = exceed_payload_max_length ? StatusCode::PayloadTooLarge_413 + : StatusCode::BadRequest_400; + } return ret; }); } // namespace detail @@ -3498,7 +4068,7 @@ inline bool write_content(Stream &strm, const ContentProvider &content_provider, data_sink.write = [&](const char *d, size_t l) -> bool { if (ok) { - if (write_data(strm, d, l)) { + if (strm.is_writable() && write_data(strm, d, l)) { offset += l; } else { ok = false; @@ -3507,14 +4077,16 @@ inline bool write_content(Stream &strm, const ContentProvider &content_provider, return ok; }; - data_sink.is_writable = [&](void) { return ok && strm.is_writable(); }; + data_sink.is_writable = [&]() -> bool { return strm.is_writable(); }; while (offset < end_offset && !is_shutting_down()) { - if (!content_provider(offset, end_offset - offset, data_sink)) { + if (!strm.is_writable()) { + error = Error::Write; + return false; + } else if (!content_provider(offset, end_offset - offset, data_sink)) { error = Error::Canceled; return false; - } - if (!ok) { + } else if (!ok) { error = Error::Write; return false; } @@ -3546,18 +4118,23 @@ write_content_without_length(Stream &strm, data_sink.write = [&](const char *d, size_t l) -> bool { if (ok) { offset += l; - if (!write_data(strm, d, l)) { ok = false; } + if (!strm.is_writable() || !write_data(strm, d, l)) { ok = false; } } return ok; }; - data_sink.done = [&](void) { data_available = false; }; + data_sink.is_writable = [&]() -> bool { return strm.is_writable(); }; - data_sink.is_writable = [&](void) { return ok && strm.is_writable(); }; + data_sink.done = [&](void) { data_available = false; }; while (data_available && !is_shutting_down()) { - if (!content_provider(offset, 0, data_sink)) { return false; } - if (!ok) { return false; } + if (!strm.is_writable()) { + return false; + } else if (!content_provider(offset, 0, data_sink)) { + return false; + } else if (!ok) { + return false; + } } return true; } @@ -3586,7 +4163,10 @@ write_content_chunked(Stream &strm, const ContentProvider &content_provider, // Emit chunked response header and footer for each chunk auto chunk = from_i_to_hex(payload.size()) + "\r\n" + payload + "\r\n"; - if (!write_data(strm, chunk.data(), chunk.size())) { ok = false; } + if (!strm.is_writable() || + !write_data(strm, chunk.data(), chunk.size())) { + ok = false; + } } } else { ok = false; @@ -3595,7 +4175,9 @@ write_content_chunked(Stream &strm, const ContentProvider &content_provider, return ok; }; - data_sink.done = [&](void) { + data_sink.is_writable = [&]() -> bool { return strm.is_writable(); }; + + auto done_with_trailer = [&](const Headers *trailer) { if (!ok) { return; } data_available = false; @@ -3613,26 +4195,46 @@ write_content_chunked(Stream &strm, const ContentProvider &content_provider, if (!payload.empty()) { // Emit chunked response header and footer for each chunk auto chunk = from_i_to_hex(payload.size()) + "\r\n" + payload + "\r\n"; - if (!write_data(strm, chunk.data(), chunk.size())) { + if (!strm.is_writable() || + !write_data(strm, chunk.data(), chunk.size())) { ok = false; return; } } - static const std::string done_marker("0\r\n\r\n"); + static const std::string done_marker("0\r\n"); if (!write_data(strm, done_marker.data(), done_marker.size())) { ok = false; } + + // Trailer + if (trailer) { + for (const auto &kv : *trailer) { + std::string field_line = kv.first + ": " + kv.second + "\r\n"; + if (!write_data(strm, field_line.data(), field_line.size())) { + ok = false; + } + } + } + + static const std::string crlf("\r\n"); + if (!write_data(strm, crlf.data(), crlf.size())) { ok = false; } }; - data_sink.is_writable = [&](void) { return ok && strm.is_writable(); }; + data_sink.done = [&](void) { done_with_trailer(nullptr); }; + + data_sink.done_with_trailer = [&](const Headers &trailer) { + done_with_trailer(&trailer); + }; while (data_available && !is_shutting_down()) { - if (!content_provider(offset, 0, data_sink)) { + if (!strm.is_writable()) { + error = Error::Write; + return false; + } else if (!content_provider(offset, 0, data_sink)) { error = Error::Canceled; return false; - } - if (!ok) { + } else if (!ok) { error = Error::Write; return false; } @@ -3659,7 +4261,8 @@ inline bool redirect(T &cli, Request &req, Response &res, new_req.path = path; new_req.redirect_count_ -= 1; - if (res.status == 303 && (req.method != "GET" && req.method != "HEAD")) { + if (res.status == StatusCode::SeeOther_303 && + (req.method != "GET" && req.method != "HEAD")) { new_req.method = "GET"; new_req.body.clear(); new_req.headers.clear(); @@ -3671,7 +4274,8 @@ inline bool redirect(T &cli, Request &req, Response &res, if (ret) { req = new_req; res = new_res; - res.location = location; + + if (res.location.empty()) { res.location = location; } } return ret; } @@ -3713,16 +4317,39 @@ inline void parse_query_text(const std::string &s, Params ¶ms) { inline bool parse_multipart_boundary(const std::string &content_type, std::string &boundary) { - auto pos = content_type.find("boundary="); + auto boundary_keyword = "boundary="; + auto pos = content_type.find(boundary_keyword); if (pos == std::string::npos) { return false; } - boundary = content_type.substr(pos + 9); - if (boundary.length() >= 2 && boundary.front() == '"' && - boundary.back() == '"') { - boundary = boundary.substr(1, boundary.size() - 2); - } + auto end = content_type.find(';', pos); + auto beg = pos + strlen(boundary_keyword); + boundary = trim_double_quotes_copy(content_type.substr(beg, end - beg)); return !boundary.empty(); } +inline void parse_disposition_params(const std::string &s, Params ¶ms) { + std::set cache; + split(s.data(), s.data() + s.size(), ';', [&](const char *b, const char *e) { + std::string kv(b, e); + if (cache.find(kv) != cache.end()) { return; } + cache.insert(kv); + + std::string key; + std::string val; + split(b, e, '=', [&](const char *b2, const char *e2) { + if (key.empty()) { + key.assign(b2, e2); + } else { + val.assign(b2, e2); + } + }); + + if (!key.empty()) { + params.emplace(trim_double_quotes_copy((key)), + trim_double_quotes_copy((val))); + } + }); +} + #ifdef CPPHTTPLIB_NO_EXCEPTIONS inline bool parse_range_header(const std::string &s, Ranges &ranges) { #else @@ -3733,9 +4360,9 @@ inline bool parse_range_header(const std::string &s, Ranges &ranges) try { if (std::regex_match(s, m, re_first_range)) { auto pos = static_cast(m.position(1)); auto len = static_cast(m.length(1)); - bool all_valid_ranges = true; + auto all_valid_ranges = true; split(&s[pos], &s[pos + len], ',', [&](const char *b, const char *e) { - if (!all_valid_ranges) return; + if (!all_valid_ranges) { return; } static auto re_another_range = std::regex(R"(\s*(\d*)-(\d*))"); std::cmatch cm; if (std::regex_match(b, e, cm, re_another_range)) { @@ -3769,30 +4396,26 @@ class MultipartFormDataParser { public: MultipartFormDataParser() = default; - void set_boundary(std::string &&boundary) { boundary_ = boundary; } + void set_boundary(std::string &&boundary) { + boundary_ = boundary; + dash_boundary_crlf_ = dash_ + boundary_ + crlf_; + crlf_dash_boundary_ = crlf_ + dash_ + boundary_; + } bool is_valid() const { return is_valid_; } bool parse(const char *buf, size_t n, const ContentReceiver &content_callback, const MultipartContentHeader &header_callback) { - // TODO: support 'filename*' - static const std::regex re_content_disposition( - R"~(^Content-Disposition:\s*form-data;\s*name="(.*?)"(?:;\s*filename="(.*?)")?(?:;\s*filename\*=\S+)?\s*$)~", - std::regex_constants::icase); - - static const std::string dash_ = "--"; - static const std::string crlf_ = "\r\n"; - buf_append(buf, n); while (buf_size() > 0) { switch (state_) { case 0: { // Initial boundary - auto pattern = dash_ + boundary_ + crlf_; - if (pattern.size() > buf_size()) { return true; } - if (!buf_start_with(pattern)) { return false; } - buf_erase(pattern.size()); + buf_erase(buf_find(dash_boundary_crlf_)); + if (dash_boundary_crlf_.size() > buf_size()) { return true; } + if (!buf_start_with(dash_boundary_crlf_)) { return false; } + buf_erase(dash_boundary_crlf_.size()); state_ = 1; break; } @@ -3816,18 +4439,56 @@ class MultipartFormDataParser { break; } - static const std::string header_name = "content-type:"; const auto header = buf_head(pos); - if (start_with_case_ignore(header, header_name)) { - file_.content_type = trim_copy(header.substr(header_name.size())); + + if (!parse_header(header.data(), header.data() + header.size(), + [&](std::string &&, std::string &&) {})) { + is_valid_ = false; + return false; + } + + static const std::string header_content_type = "Content-Type:"; + + if (start_with_case_ignore(header, header_content_type)) { + file_.content_type = + trim_copy(header.substr(header_content_type.size())); } else { + static const std::regex re_content_disposition( + R"~(^Content-Disposition:\s*form-data;\s*(.*)$)~", + std::regex_constants::icase); + std::smatch m; if (std::regex_match(header, m, re_content_disposition)) { - file_.name = m[1]; - file_.filename = m[2]; + Params params; + parse_disposition_params(m[1], params); + + auto it = params.find("name"); + if (it != params.end()) { + file_.name = it->second; + } else { + is_valid_ = false; + return false; + } + + it = params.find("filename"); + if (it != params.end()) { file_.filename = it->second; } + + it = params.find("filename*"); + if (it != params.end()) { + // Only allow UTF-8 enconnding... + static const std::regex re_rfc5987_encoding( + R"~(^UTF-8''(.+?)$)~", std::regex_constants::icase); + + std::smatch m2; + if (std::regex_match(it->second, m2, re_rfc5987_encoding)) { + file_.filename = decode_url(m2[1], false); // override... + } else { + is_valid_ = false; + return false; + } + } } } - buf_erase(pos + crlf_.size()); pos = buf_find(crlf_); } @@ -3835,40 +4496,25 @@ class MultipartFormDataParser { break; } case 3: { // Body - { - auto pattern = crlf_ + dash_; - if (pattern.size() > buf_size()) { return true; } - - auto pos = buf_find(pattern); - + if (crlf_dash_boundary_.size() > buf_size()) { return true; } + auto pos = buf_find(crlf_dash_boundary_); + if (pos < buf_size()) { if (!content_callback(buf_data(), pos)) { is_valid_ = false; return false; } - - buf_erase(pos); - } - { - auto pattern = crlf_ + dash_ + boundary_; - if (pattern.size() > buf_size()) { return true; } - - auto pos = buf_find(pattern); - if (pos < buf_size()) { - if (!content_callback(buf_data(), pos)) { - is_valid_ = false; - return false; - } - - buf_erase(pos + pattern.size()); - state_ = 4; - } else { - if (!content_callback(buf_data(), pattern.size())) { + buf_erase(pos + crlf_dash_boundary_.size()); + state_ = 4; + } else { + auto len = buf_size() - crlf_dash_boundary_.size(); + if (len > 0) { + if (!content_callback(buf_data(), len)) { is_valid_ = false; return false; } - - buf_erase(pattern.size()); + buf_erase(len); } + return true; } break; } @@ -3878,22 +4524,17 @@ class MultipartFormDataParser { buf_erase(crlf_.size()); state_ = 1; } else { - auto pattern = dash_ + crlf_; - if (pattern.size() > buf_size()) { return true; } - if (buf_start_with(pattern)) { - buf_erase(pattern.size()); + if (dash_.size() > buf_size()) { return true; } + if (buf_start_with(dash_)) { + buf_erase(dash_.size()); is_valid_ = true; - state_ = 5; + buf_erase(buf_size()); // Remove epilogue } else { return true; } } break; } - case 5: { // Done - is_valid_ = false; - return false; - } } } @@ -3916,7 +4557,11 @@ class MultipartFormDataParser { return true; } + const std::string dash_ = "--"; + const std::string crlf_ = "\r\n"; std::string boundary_; + std::string dash_boundary_crlf_; + std::string crlf_dash_boundary_; size_t state_ = 0; bool is_valid_ = false; @@ -4000,65 +4645,174 @@ inline std::string to_lower(const char *beg, const char *end) { return out; } -inline std::string make_multipart_data_boundary() { +inline std::string random_string(size_t length) { static const char data[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; // std::random_device might actually be deterministic on some // platforms, but due to lack of support in the c++ standard library, // doing better requires either some ugly hacks or breaking portability. - std::random_device seed_gen; + static std::random_device seed_gen; // Request 128 bits of entropy for initialization - std::seed_seq seed_sequence{seed_gen(), seed_gen(), seed_gen(), seed_gen()}; - std::mt19937 engine(seed_sequence); + static std::seed_seq seed_sequence{seed_gen(), seed_gen(), seed_gen(), + seed_gen()}; - std::string result = "--cpp-httplib-multipart-data-"; + static std::mt19937 engine(seed_sequence); - for (auto i = 0; i < 16; i++) { + std::string result; + for (size_t i = 0; i < length; i++) { result += data[engine() % (sizeof(data) - 1)]; } - return result; } -inline std::pair -get_range_offset_and_length(const Request &req, size_t content_length, - size_t index) { - auto r = req.ranges[index]; +inline std::string make_multipart_data_boundary() { + return "--cpp-httplib-multipart-data-" + detail::random_string(16); +} + +inline bool is_multipart_boundary_chars_valid(const std::string &boundary) { + auto valid = true; + for (size_t i = 0; i < boundary.size(); i++) { + auto c = boundary[i]; + if (!std::isalnum(c) && c != '-' && c != '_') { + valid = false; + break; + } + } + return valid; +} + +template +inline std::string +serialize_multipart_formdata_item_begin(const T &item, + const std::string &boundary) { + std::string body = "--" + boundary + "\r\n"; + body += "Content-Disposition: form-data; name=\"" + item.name + "\""; + if (!item.filename.empty()) { + body += "; filename=\"" + item.filename + "\""; + } + body += "\r\n"; + if (!item.content_type.empty()) { + body += "Content-Type: " + item.content_type + "\r\n"; + } + body += "\r\n"; + + return body; +} + +inline std::string serialize_multipart_formdata_item_end() { return "\r\n"; } + +inline std::string +serialize_multipart_formdata_finish(const std::string &boundary) { + return "--" + boundary + "--\r\n"; +} + +inline std::string +serialize_multipart_formdata_get_content_type(const std::string &boundary) { + return "multipart/form-data; boundary=" + boundary; +} + +inline std::string +serialize_multipart_formdata(const MultipartFormDataItems &items, + const std::string &boundary, bool finish = true) { + std::string body; - if (r.first == -1 && r.second == -1) { - return std::make_pair(0, content_length); + for (const auto &item : items) { + body += serialize_multipart_formdata_item_begin(item, boundary); + body += item.content + serialize_multipart_formdata_item_end(); } - auto slen = static_cast(content_length); + if (finish) { body += serialize_multipart_formdata_finish(boundary); } + + return body; +} + +inline bool range_error(Request &req, Response &res) { + if (!req.ranges.empty() && 200 <= res.status && res.status < 300) { + ssize_t contant_len = static_cast( + res.content_length_ ? res.content_length_ : res.body.size()); + + ssize_t prev_first_pos = -1; + ssize_t prev_last_pos = -1; + size_t overwrapping_count = 0; + + // NOTE: The following Range check is based on '14.2. Range' in RFC 9110 + // 'HTTP Semantics' to avoid potential denial-of-service attacks. + // https://www.rfc-editor.org/rfc/rfc9110#section-14.2 + + // Too many ranges + if (req.ranges.size() > CPPHTTPLIB_RANGE_MAX_COUNT) { return true; } + + for (auto &r : req.ranges) { + auto &first_pos = r.first; + auto &last_pos = r.second; + + if (first_pos == -1 && last_pos == -1) { + first_pos = 0; + last_pos = contant_len; + } + + if (first_pos == -1) { + first_pos = contant_len - last_pos; + last_pos = contant_len - 1; + } + + if (last_pos == -1) { last_pos = contant_len - 1; } + + // Range must be within content length + if (!(0 <= first_pos && first_pos <= last_pos && + last_pos <= contant_len - 1)) { + return true; + } + + // Ranges must be in ascending order + if (first_pos <= prev_first_pos) { return true; } + + // Request must not have more than two overlapping ranges + if (first_pos <= prev_last_pos) { + overwrapping_count++; + if (overwrapping_count > 2) { return true; } + } - if (r.first == -1) { - r.first = (std::max)(static_cast(0), slen - r.second); - r.second = slen - 1; + prev_first_pos = (std::max)(prev_first_pos, first_pos); + prev_last_pos = (std::max)(prev_last_pos, last_pos); + } } - if (r.second == -1) { r.second = slen - 1; } + return false; +} + +inline std::pair +get_range_offset_and_length(Range r, size_t content_length) { + assert(r.first != -1 && r.second != -1); + assert(0 <= r.first && r.first < static_cast(content_length)); + assert(r.first <= r.second && + r.second < static_cast(content_length)); + return std::make_pair(r.first, static_cast(r.second - r.first) + 1); } -inline std::string make_content_range_header_field(size_t offset, size_t length, - size_t content_length) { +inline std::string make_content_range_header_field( + const std::pair &offset_and_length, size_t content_length) { + auto st = offset_and_length.first; + auto ed = st + offset_and_length.second - 1; + std::string field = "bytes "; - field += std::to_string(offset); + field += std::to_string(st); field += "-"; - field += std::to_string(offset + length - 1); + field += std::to_string(ed); field += "/"; field += std::to_string(content_length); return field; } template -bool process_multipart_ranges_data(const Request &req, Response &res, +bool process_multipart_ranges_data(const Request &req, const std::string &boundary, const std::string &content_type, - SToken stoken, CToken ctoken, - Content content) { + size_t content_length, SToken stoken, + CToken ctoken, Content content) { for (size_t i = 0; i < req.ranges.size(); i++) { ctoken("--"); stoken(boundary); @@ -4069,52 +4823,53 @@ bool process_multipart_ranges_data(const Request &req, Response &res, ctoken("\r\n"); } - auto offsets = get_range_offset_and_length(req, res.body.size(), i); - auto offset = offsets.first; - auto length = offsets.second; + auto offset_and_length = + get_range_offset_and_length(req.ranges[i], content_length); ctoken("Content-Range: "); - stoken(make_content_range_header_field(offset, length, res.body.size())); + stoken(make_content_range_header_field(offset_and_length, content_length)); ctoken("\r\n"); ctoken("\r\n"); - if (!content(offset, length)) { return false; } + + if (!content(offset_and_length.first, offset_and_length.second)) { + return false; + } ctoken("\r\n"); } ctoken("--"); stoken(boundary); - ctoken("--\r\n"); + ctoken("--"); return true; } -inline bool make_multipart_ranges_data(const Request &req, Response &res, +inline void make_multipart_ranges_data(const Request &req, Response &res, const std::string &boundary, const std::string &content_type, + size_t content_length, std::string &data) { - return process_multipart_ranges_data( - req, res, boundary, content_type, + process_multipart_ranges_data( + req, boundary, content_type, content_length, + [&](const std::string &token) { data += token; }, [&](const std::string &token) { data += token; }, - [&](const char *token) { data += token; }, [&](size_t offset, size_t length) { - if (offset < res.body.size()) { - data += res.body.substr(offset, length); - return true; - } - return false; + assert(offset + length <= content_length); + data += res.body.substr(offset, length); + return true; }); } -inline size_t -get_multipart_ranges_data_length(const Request &req, Response &res, - const std::string &boundary, - const std::string &content_type) { +inline size_t get_multipart_ranges_data_length(const Request &req, + const std::string &boundary, + const std::string &content_type, + size_t content_length) { size_t data_length = 0; process_multipart_ranges_data( - req, res, boundary, content_type, + req, boundary, content_type, content_length, + [&](const std::string &token) { data_length += token.size(); }, [&](const std::string &token) { data_length += token.size(); }, - [&](const char *token) { data_length += strlen(token); }, [&](size_t /*offset*/, size_t length) { data_length += length; return true; @@ -4124,33 +4879,21 @@ get_multipart_ranges_data_length(const Request &req, Response &res, } template -inline bool write_multipart_ranges_data(Stream &strm, const Request &req, - Response &res, - const std::string &boundary, - const std::string &content_type, - const T &is_shutting_down) { +inline bool +write_multipart_ranges_data(Stream &strm, const Request &req, Response &res, + const std::string &boundary, + const std::string &content_type, + size_t content_length, const T &is_shutting_down) { return process_multipart_ranges_data( - req, res, boundary, content_type, + req, boundary, content_type, content_length, + [&](const std::string &token) { strm.write(token); }, [&](const std::string &token) { strm.write(token); }, - [&](const char *token) { strm.write(token); }, [&](size_t offset, size_t length) { return write_content(strm, res.content_provider_, offset, length, is_shutting_down); }); } -inline std::pair -get_range_offset_and_length(const Request &req, const Response &res, - size_t index) { - auto r = req.ranges[index]; - - if (r.second == -1) { - r.second = static_cast(res.content_length_) - 1; - } - - return std::make_pair(r.first, r.second - r.first + 1); -} - inline bool expect_content(const Request &req) { if (req.method == "POST" || req.method == "PUT" || req.method == "PATCH" || req.method == "PRI" || req.method == "DELETE") { @@ -4160,8 +4903,8 @@ inline bool expect_content(const Request &req) { return false; } -inline bool has_crlf(const char *s) { - auto p = s; +inline bool has_crlf(const std::string &s) { + auto p = s.c_str(); while (*p) { if (*p == '\r' || *p == '\n') { return true; } p++; @@ -4184,7 +4927,7 @@ inline std::string message_digest(const std::string &s, const EVP_MD *algo) { std::stringstream ss; for (auto i = 0u; i < hash_length; ++i) { ss << std::hex << std::setw(2) << std::setfill('0') - << (unsigned int)hash[i]; + << static_cast(hash[i]); } return ss.str(); @@ -4203,15 +4946,15 @@ inline std::string SHA_512(const std::string &s) { } #endif -#ifdef _WIN32 #ifdef CPPHTTPLIB_OPENSSL_SUPPORT +#ifdef _WIN32 // NOTE: This code came up with the following stackoverflow post: // https://stackoverflow.com/questions/9507184/can-openssl-on-windows-use-the-system-certificate-store inline bool load_system_certs_on_windows(X509_STORE *store) { auto hStore = CertOpenSystemStoreW((HCRYPTPROV_LEGACY)NULL, L"ROOT"); - if (!hStore) { return false; } + auto result = false; PCCERT_CONTEXT pContext = NULL; while ((pContext = CertEnumCertificatesInStore(hStore, pContext)) != nullptr) { @@ -4222,16 +4965,109 @@ inline bool load_system_certs_on_windows(X509_STORE *store) { if (x509) { X509_STORE_add_cert(store, x509); X509_free(x509); + result = true; } } CertFreeCertificateContext(pContext); CertCloseStore(hStore, 0); + return result; +} +#elif defined(CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN) && defined(__APPLE__) +#if TARGET_OS_OSX +template +using CFObjectPtr = + std::unique_ptr::type, void (*)(CFTypeRef)>; + +inline void cf_object_ptr_deleter(CFTypeRef obj) { + if (obj) { CFRelease(obj); } +} + +inline bool retrieve_certs_from_keychain(CFObjectPtr &certs) { + CFStringRef keys[] = {kSecClass, kSecMatchLimit, kSecReturnRef}; + CFTypeRef values[] = {kSecClassCertificate, kSecMatchLimitAll, + kCFBooleanTrue}; + + CFObjectPtr query( + CFDictionaryCreate(nullptr, reinterpret_cast(keys), values, + sizeof(keys) / sizeof(keys[0]), + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks), + cf_object_ptr_deleter); + + if (!query) { return false; } + + CFTypeRef security_items = nullptr; + if (SecItemCopyMatching(query.get(), &security_items) != errSecSuccess || + CFArrayGetTypeID() != CFGetTypeID(security_items)) { + return false; + } + + certs.reset(reinterpret_cast(security_items)); return true; } -#endif +inline bool retrieve_root_certs_from_keychain(CFObjectPtr &certs) { + CFArrayRef root_security_items = nullptr; + if (SecTrustCopyAnchorCertificates(&root_security_items) != errSecSuccess) { + return false; + } + + certs.reset(root_security_items); + return true; +} + +inline bool add_certs_to_x509_store(CFArrayRef certs, X509_STORE *store) { + auto result = false; + for (auto i = 0; i < CFArrayGetCount(certs); ++i) { + const auto cert = reinterpret_cast( + CFArrayGetValueAtIndex(certs, i)); + + if (SecCertificateGetTypeID() != CFGetTypeID(cert)) { continue; } + + CFDataRef cert_data = nullptr; + if (SecItemExport(cert, kSecFormatX509Cert, 0, nullptr, &cert_data) != + errSecSuccess) { + continue; + } + + CFObjectPtr cert_data_ptr(cert_data, cf_object_ptr_deleter); + + auto encoded_cert = static_cast( + CFDataGetBytePtr(cert_data_ptr.get())); + + auto x509 = + d2i_X509(NULL, &encoded_cert, CFDataGetLength(cert_data_ptr.get())); + + if (x509) { + X509_STORE_add_cert(store, x509); + X509_free(x509); + result = true; + } + } + + return result; +} + +inline bool load_system_certs_on_macos(X509_STORE *store) { + auto result = false; + CFObjectPtr certs(nullptr, cf_object_ptr_deleter); + if (retrieve_certs_from_keychain(certs) && certs) { + result = add_certs_to_x509_store(certs.get(), store); + } + + if (retrieve_root_certs_from_keychain(certs) && certs) { + result = add_certs_to_x509_store(certs.get(), store) || result; + } + + return result; +} +#endif // TARGET_OS_OSX +#endif // _WIN32 +#endif // CPPHTTPLIB_OPENSSL_SUPPORT + +#ifdef _WIN32 class WSInit { public: WSInit() { @@ -4327,7 +5163,7 @@ inline bool parse_www_authenticate(const Response &res, s = s.substr(pos + 1); auto beg = std::sregex_iterator(s.begin(), s.end(), re); for (auto i = beg; i != std::sregex_iterator(); ++i) { - auto m = *i; + const auto &m = *i; auto key = s.substr(static_cast(m.position(1)), static_cast(m.length(1))); auto val = m.length(2) > 0 @@ -4344,20 +5180,6 @@ inline bool parse_www_authenticate(const Response &res, return false; } -// https://stackoverflow.com/questions/440133/how-do-i-create-a-random-alpha-numeric-string-in-c/440240#answer-440240 -inline std::string random_string(size_t length) { - auto randchar = []() -> char { - const char charset[] = "0123456789" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz"; - const size_t max_index = (sizeof(charset) - 1); - return charset[static_cast(std::rand()) % max_index]; - }; - std::string str(length, 0); - std::generate_n(str.begin(), length, randchar); - return str; -} - class ContentProviderAdapter { public: explicit ContentProviderAdapter( @@ -4374,14 +5196,15 @@ class ContentProviderAdapter { } // namespace detail -inline std::string hosted_at(const char *hostname) { +inline std::string hosted_at(const std::string &hostname) { std::vector addrs; hosted_at(hostname, addrs); if (addrs.empty()) { return std::string(); } return addrs[0]; } -inline void hosted_at(const char *hostname, std::vector &addrs) { +inline void hosted_at(const std::string &hostname, + std::vector &addrs) { struct addrinfo hints; struct addrinfo *result; @@ -4390,7 +5213,7 @@ inline void hosted_at(const char *hostname, std::vector &addrs) { hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = 0; - if (getaddrinfo(hostname, nullptr, &hints, &result)) { + if (getaddrinfo(hostname.c_str(), nullptr, &hints, &result)) { #if defined __linux__ && !defined __ANDROID__ res_init(); #endif @@ -4401,15 +5224,18 @@ inline void hosted_at(const char *hostname, std::vector &addrs) { const auto &addr = *reinterpret_cast(rp->ai_addr); std::string ip; - int dummy = -1; - if (detail::get_remote_ip_and_port(addr, sizeof(struct sockaddr_storage), - ip, dummy)) { + auto dummy = -1; + if (detail::get_ip_and_port(addr, sizeof(struct sockaddr_storage), ip, + dummy)) { addrs.push_back(ip); } } + + freeaddrinfo(result); } -inline std::string append_query_params(const char *path, const Params ¶ms) { +inline std::string append_query_params(const std::string &path, + const Params ¶ms) { std::string path_with_query = path; const static std::regex re("[^?]+\\?.*"); auto delm = std::regex_match(path, re) ? '&' : '?'; @@ -4418,10 +5244,11 @@ inline std::string append_query_params(const char *path, const Params ¶ms) { } // Header utilities -inline std::pair make_range_header(Ranges ranges) { +inline std::pair +make_range_header(const Ranges &ranges) { std::string field = "bytes="; auto i = 0; - for (auto r : ranges) { + for (const auto &r : ranges) { if (i != 0) { field += ", "; } if (r.first != -1) { field += std::to_string(r.first); } field += '-'; @@ -4448,36 +5275,33 @@ make_bearer_token_authentication_header(const std::string &token, } // Request implementation -inline bool Request::has_header(const char *key) const { +inline bool Request::has_header(const std::string &key) const { return detail::has_header(headers, key); } -inline std::string Request::get_header_value(const char *key, size_t id) const { +inline std::string Request::get_header_value(const std::string &key, + size_t id) const { return detail::get_header_value(headers, key, id, ""); } -inline size_t Request::get_header_value_count(const char *key) const { +inline size_t Request::get_header_value_count(const std::string &key) const { auto r = headers.equal_range(key); return static_cast(std::distance(r.first, r.second)); } -inline void Request::set_header(const char *key, const char *val) { +inline void Request::set_header(const std::string &key, + const std::string &val) { if (!detail::has_crlf(key) && !detail::has_crlf(val)) { headers.emplace(key, val); } } -inline void Request::set_header(const char *key, const std::string &val) { - if (!detail::has_crlf(key) && !detail::has_crlf(val.c_str())) { - headers.emplace(key, val); - } -} - -inline bool Request::has_param(const char *key) const { +inline bool Request::has_param(const std::string &key) const { return params.find(key) != params.end(); } -inline std::string Request::get_param_value(const char *key, size_t id) const { +inline std::string Request::get_param_value(const std::string &key, + size_t id) const { auto rng = params.equal_range(key); auto it = rng.first; std::advance(it, static_cast(id)); @@ -4485,7 +5309,7 @@ inline std::string Request::get_param_value(const char *key, size_t id) const { return std::string(); } -inline size_t Request::get_param_value_count(const char *key) const { +inline size_t Request::get_param_value_count(const std::string &key) const { auto r = params.equal_range(key); return static_cast(std::distance(r.first, r.second)); } @@ -4495,60 +5319,61 @@ inline bool Request::is_multipart_form_data() const { return !content_type.rfind("multipart/form-data", 0); } -inline bool Request::has_file(const char *key) const { +inline bool Request::has_file(const std::string &key) const { return files.find(key) != files.end(); } -inline MultipartFormData Request::get_file_value(const char *key) const { +inline MultipartFormData Request::get_file_value(const std::string &key) const { auto it = files.find(key); if (it != files.end()) { return it->second; } return MultipartFormData(); } +inline std::vector +Request::get_file_values(const std::string &key) const { + std::vector values; + auto rng = files.equal_range(key); + for (auto it = rng.first; it != rng.second; it++) { + values.push_back(it->second); + } + return values; +} + // Response implementation -inline bool Response::has_header(const char *key) const { +inline bool Response::has_header(const std::string &key) const { return headers.find(key) != headers.end(); } -inline std::string Response::get_header_value(const char *key, +inline std::string Response::get_header_value(const std::string &key, size_t id) const { return detail::get_header_value(headers, key, id, ""); } -inline size_t Response::get_header_value_count(const char *key) const { +inline size_t Response::get_header_value_count(const std::string &key) const { auto r = headers.equal_range(key); return static_cast(std::distance(r.first, r.second)); } -inline void Response::set_header(const char *key, const char *val) { +inline void Response::set_header(const std::string &key, + const std::string &val) { if (!detail::has_crlf(key) && !detail::has_crlf(val)) { headers.emplace(key, val); } } -inline void Response::set_header(const char *key, const std::string &val) { - if (!detail::has_crlf(key) && !detail::has_crlf(val.c_str())) { - headers.emplace(key, val); - } -} - -inline void Response::set_redirect(const char *url, int stat) { +inline void Response::set_redirect(const std::string &url, int stat) { if (!detail::has_crlf(url)) { set_header("Location", url); if (300 <= stat && stat < 400) { this->status = stat; } else { - this->status = 302; + this->status = StatusCode::Found_302; } } } -inline void Response::set_redirect(const std::string &url, int stat) { - set_redirect(url.c_str(), stat); -} - inline void Response::set_content(const char *s, size_t n, - const char *content_type) { + const std::string &content_type) { body.assign(s, n); auto rng = headers.equal_range("Content-Type"); @@ -4557,52 +5382,61 @@ inline void Response::set_content(const char *s, size_t n, } inline void Response::set_content(const std::string &s, - const char *content_type) { + const std::string &content_type) { set_content(s.data(), s.size(), content_type); } +inline void Response::set_content(std::string &&s, + const std::string &content_type) { + body = std::move(s); + + auto rng = headers.equal_range("Content-Type"); + headers.erase(rng.first, rng.second); + set_header("Content-Type", content_type); +} + inline void Response::set_content_provider( - size_t in_length, const char *content_type, ContentProvider provider, + size_t in_length, const std::string &content_type, ContentProvider provider, ContentProviderResourceReleaser resource_releaser) { - assert(in_length > 0); set_header("Content-Type", content_type); content_length_ = in_length; - content_provider_ = std::move(provider); - content_provider_resource_releaser_ = resource_releaser; + if (in_length > 0) { content_provider_ = std::move(provider); } + content_provider_resource_releaser_ = std::move(resource_releaser); is_chunked_content_provider_ = false; } inline void Response::set_content_provider( - const char *content_type, ContentProviderWithoutLength provider, + const std::string &content_type, ContentProviderWithoutLength provider, ContentProviderResourceReleaser resource_releaser) { set_header("Content-Type", content_type); content_length_ = 0; content_provider_ = detail::ContentProviderAdapter(std::move(provider)); - content_provider_resource_releaser_ = resource_releaser; + content_provider_resource_releaser_ = std::move(resource_releaser); is_chunked_content_provider_ = false; } inline void Response::set_chunked_content_provider( - const char *content_type, ContentProviderWithoutLength provider, + const std::string &content_type, ContentProviderWithoutLength provider, ContentProviderResourceReleaser resource_releaser) { set_header("Content-Type", content_type); content_length_ = 0; content_provider_ = detail::ContentProviderAdapter(std::move(provider)); - content_provider_resource_releaser_ = resource_releaser; + content_provider_resource_releaser_ = std::move(resource_releaser); is_chunked_content_provider_ = true; } // Result implementation -inline bool Result::has_request_header(const char *key) const { +inline bool Result::has_request_header(const std::string &key) const { return request_headers_.find(key) != request_headers_.end(); } -inline std::string Result::get_request_header_value(const char *key, +inline std::string Result::get_request_header_value(const std::string &key, size_t id) const { return detail::get_header_value(request_headers_, key, id, ""); } -inline size_t Result::get_request_header_value_count(const char *key) const { +inline size_t +Result::get_request_header_value_count(const std::string &key) const { auto r = request_headers_.equal_range(key); return static_cast(std::distance(r.first, r.second)); } @@ -4628,14 +5462,15 @@ inline SocketStream::SocketStream(socket_t sock, time_t read_timeout_sec, write_timeout_sec_(write_timeout_sec), write_timeout_usec_(write_timeout_usec), read_buff_(read_buff_size_, 0) {} -inline SocketStream::~SocketStream() {} +inline SocketStream::~SocketStream() = default; inline bool SocketStream::is_readable() const { return select_read(sock_, read_timeout_sec_, read_timeout_usec_) > 0; } inline bool SocketStream::is_writable() const { - return select_write(sock_, write_timeout_sec_, write_timeout_usec_) > 0; + return select_write(sock_, write_timeout_sec_, write_timeout_usec_) > 0 && + is_socket_alive(sock_); } inline ssize_t SocketStream::read(char *ptr, size_t size) { @@ -4687,7 +5522,7 @@ inline ssize_t SocketStream::read(char *ptr, size_t size) { inline ssize_t SocketStream::write(const char *ptr, size_t size) { if (!is_writable()) { return -1; } -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_WIN64) size = (std::min)(size, static_cast((std::numeric_limits::max)())); #endif @@ -4700,6 +5535,11 @@ inline void SocketStream::get_remote_ip_and_port(std::string &ip, return detail::get_remote_ip_and_port(sock_, ip, port); } +inline void SocketStream::get_local_ip_and_port(std::string &ip, + int &port) const { + return detail::get_local_ip_and_port(sock_, ip, port); +} + inline socket_t SocketStream::socket() const { return sock_; } // Buffer stream implementation @@ -4708,7 +5548,7 @@ inline bool BufferStream::is_readable() const { return true; } inline bool BufferStream::is_writable() const { return true; } inline ssize_t BufferStream::read(char *ptr, size_t size) { -#if defined(_MSC_VER) && _MSC_VER <= 1900 +#if defined(_MSC_VER) && _MSC_VER < 1910 auto len_read = buffer._Copy_s(ptr, size, size, position); #else auto len_read = buffer.copy(ptr, size, position); @@ -4725,85 +5565,183 @@ inline ssize_t BufferStream::write(const char *ptr, size_t size) { inline void BufferStream::get_remote_ip_and_port(std::string & /*ip*/, int & /*port*/) const {} +inline void BufferStream::get_local_ip_and_port(std::string & /*ip*/, + int & /*port*/) const {} + inline socket_t BufferStream::socket() const { return 0; } inline const std::string &BufferStream::get_buffer() const { return buffer; } +inline PathParamsMatcher::PathParamsMatcher(const std::string &pattern) { + // One past the last ending position of a path param substring + std::size_t last_param_end = 0; + +#ifndef CPPHTTPLIB_NO_EXCEPTIONS + // Needed to ensure that parameter names are unique during matcher + // construction + // If exceptions are disabled, only last duplicate path + // parameter will be set + std::unordered_set param_name_set; +#endif + + while (true) { + const auto marker_pos = pattern.find(marker, last_param_end); + if (marker_pos == std::string::npos) { break; } + + static_fragments_.push_back( + pattern.substr(last_param_end, marker_pos - last_param_end)); + + const auto param_name_start = marker_pos + 1; + + auto sep_pos = pattern.find(separator, param_name_start); + if (sep_pos == std::string::npos) { sep_pos = pattern.length(); } + + auto param_name = + pattern.substr(param_name_start, sep_pos - param_name_start); + +#ifndef CPPHTTPLIB_NO_EXCEPTIONS + if (param_name_set.find(param_name) != param_name_set.cend()) { + std::string msg = "Encountered path parameter '" + param_name + + "' multiple times in route pattern '" + pattern + "'."; + throw std::invalid_argument(msg); + } +#endif + + param_names_.push_back(std::move(param_name)); + + last_param_end = sep_pos + 1; + } + + if (last_param_end < pattern.length()) { + static_fragments_.push_back(pattern.substr(last_param_end)); + } +} + +inline bool PathParamsMatcher::match(Request &request) const { + request.matches = std::smatch(); + request.path_params.clear(); + request.path_params.reserve(param_names_.size()); + + // One past the position at which the path matched the pattern last time + std::size_t starting_pos = 0; + for (size_t i = 0; i < static_fragments_.size(); ++i) { + const auto &fragment = static_fragments_[i]; + + if (starting_pos + fragment.length() > request.path.length()) { + return false; + } + + // Avoid unnecessary allocation by using strncmp instead of substr + + // comparison + if (std::strncmp(request.path.c_str() + starting_pos, fragment.c_str(), + fragment.length()) != 0) { + return false; + } + + starting_pos += fragment.length(); + + // Should only happen when we have a static fragment after a param + // Example: '/users/:id/subscriptions' + // The 'subscriptions' fragment here does not have a corresponding param + if (i >= param_names_.size()) { continue; } + + auto sep_pos = request.path.find(separator, starting_pos); + if (sep_pos == std::string::npos) { sep_pos = request.path.length(); } + + const auto ¶m_name = param_names_[i]; + + request.path_params.emplace( + param_name, request.path.substr(starting_pos, sep_pos - starting_pos)); + + // Mark everythin up to '/' as matched + starting_pos = sep_pos + 1; + } + // Returns false if the path is longer than the pattern + return starting_pos >= request.path.length(); +} + +inline bool RegexMatcher::match(Request &request) const { + request.path_params.clear(); + return std::regex_match(request.path, request.matches, regex_); +} + } // namespace detail // HTTP server implementation inline Server::Server() : new_task_queue( - [] { return new ThreadPool(CPPHTTPLIB_THREAD_POOL_COUNT); }), - svr_sock_(INVALID_SOCKET), is_running_(false) { + [] { return new ThreadPool(CPPHTTPLIB_THREAD_POOL_COUNT); }) { #ifndef _WIN32 signal(SIGPIPE, SIG_IGN); #endif } -inline Server::~Server() {} +inline Server::~Server() = default; + +inline std::unique_ptr +Server::make_matcher(const std::string &pattern) { + if (pattern.find("/:") != std::string::npos) { + return detail::make_unique(pattern); + } else { + return detail::make_unique(pattern); + } +} inline Server &Server::Get(const std::string &pattern, Handler handler) { - get_handlers_.push_back( - std::make_pair(std::regex(pattern), std::move(handler))); + get_handlers_.emplace_back(make_matcher(pattern), std::move(handler)); return *this; } inline Server &Server::Post(const std::string &pattern, Handler handler) { - post_handlers_.push_back( - std::make_pair(std::regex(pattern), std::move(handler))); + post_handlers_.emplace_back(make_matcher(pattern), std::move(handler)); return *this; } inline Server &Server::Post(const std::string &pattern, HandlerWithContentReader handler) { - post_handlers_for_content_reader_.push_back( - std::make_pair(std::regex(pattern), std::move(handler))); + post_handlers_for_content_reader_.emplace_back(make_matcher(pattern), + std::move(handler)); return *this; } inline Server &Server::Put(const std::string &pattern, Handler handler) { - put_handlers_.push_back( - std::make_pair(std::regex(pattern), std::move(handler))); + put_handlers_.emplace_back(make_matcher(pattern), std::move(handler)); return *this; } inline Server &Server::Put(const std::string &pattern, HandlerWithContentReader handler) { - put_handlers_for_content_reader_.push_back( - std::make_pair(std::regex(pattern), std::move(handler))); + put_handlers_for_content_reader_.emplace_back(make_matcher(pattern), + std::move(handler)); return *this; } inline Server &Server::Patch(const std::string &pattern, Handler handler) { - patch_handlers_.push_back( - std::make_pair(std::regex(pattern), std::move(handler))); + patch_handlers_.emplace_back(make_matcher(pattern), std::move(handler)); return *this; } inline Server &Server::Patch(const std::string &pattern, HandlerWithContentReader handler) { - patch_handlers_for_content_reader_.push_back( - std::make_pair(std::regex(pattern), std::move(handler))); + patch_handlers_for_content_reader_.emplace_back(make_matcher(pattern), + std::move(handler)); return *this; } inline Server &Server::Delete(const std::string &pattern, Handler handler) { - delete_handlers_.push_back( - std::make_pair(std::regex(pattern), std::move(handler))); + delete_handlers_.emplace_back(make_matcher(pattern), std::move(handler)); return *this; } inline Server &Server::Delete(const std::string &pattern, HandlerWithContentReader handler) { - delete_handlers_for_content_reader_.push_back( - std::make_pair(std::regex(pattern), std::move(handler))); + delete_handlers_for_content_reader_.emplace_back(make_matcher(pattern), + std::move(handler)); return *this; } inline Server &Server::Options(const std::string &pattern, Handler handler) { - options_handlers_.push_back( - std::make_pair(std::regex(pattern), std::move(handler))); + options_handlers_.emplace_back(make_matcher(pattern), std::move(handler)); return *this; } @@ -4835,12 +5773,17 @@ inline bool Server::remove_mount_point(const std::string &mount_point) { } inline Server & -Server::set_file_extension_and_mimetype_mapping(const char *ext, - const char *mime) { +Server::set_file_extension_and_mimetype_mapping(const std::string &ext, + const std::string &mime) { file_extension_and_mimetype_map_[ext] = mime; return *this; } +inline Server &Server::set_default_file_mimetype(const std::string &mime) { + default_file_mimetype_ = mime; + return *this; +} + inline Server &Server::set_file_request_handler(Handler handler) { file_request_handler_ = std::move(handler); return *this; @@ -4882,7 +5825,6 @@ inline Server &Server::set_logger(Logger logger) { inline Server & Server::set_expect_100_continue_handler(Expect100ContinueHandler handler) { expect_100_continue_handler_ = std::move(handler); - return *this; } @@ -4906,6 +5848,12 @@ inline Server &Server::set_default_headers(Headers headers) { return *this; } +inline Server &Server::set_header_writer( + std::function const &writer) { + header_writer_ = writer; + return *this; +} + inline Server &Server::set_keep_alive_max_count(size_t count) { keep_alive_max_count_ = count; return *this; @@ -4939,22 +5887,33 @@ inline Server &Server::set_payload_max_length(size_t length) { return *this; } -inline bool Server::bind_to_port(const char *host, int port, int socket_flags) { - if (bind_internal(host, port, socket_flags) < 0) return false; - return true; +inline bool Server::bind_to_port(const std::string &host, int port, + int socket_flags) { + return bind_internal(host, port, socket_flags) >= 0; } -inline int Server::bind_to_any_port(const char *host, int socket_flags) { +inline int Server::bind_to_any_port(const std::string &host, int socket_flags) { return bind_internal(host, 0, socket_flags); } -inline bool Server::listen_after_bind() { return listen_internal(); } +inline bool Server::listen_after_bind() { + auto se = detail::scope_exit([&]() { done_ = true; }); + return listen_internal(); +} -inline bool Server::listen(const char *host, int port, int socket_flags) { +inline bool Server::listen(const std::string &host, int port, + int socket_flags) { + auto se = detail::scope_exit([&]() { done_ = true; }); return bind_to_port(host, port, socket_flags) && listen_internal(); } inline bool Server::is_running() const { return is_running_; } +inline void Server::wait_until_ready() const { + while (!is_running() && !done_) { + std::this_thread::sleep_for(std::chrono::milliseconds{1}); + } +} + inline void Server::stop() { if (is_running_) { assert(svr_sock_ != INVALID_SOCKET); @@ -4964,7 +5923,7 @@ inline void Server::stop() { } } -inline bool Server::parse_request_line(const char *s, Request &req) { +inline bool Server::parse_request_line(const char *s, Request &req) const { auto len = strlen(s); if (len < 2 || s[len - 2] != '\r' || s[len - 1] != '\n') { return false; } len -= 2; @@ -5005,7 +5964,7 @@ inline bool Server::parse_request_line(const char *s, Request &req) { size_t count = 0; detail::split(req.target.data(), req.target.data() + req.target.size(), '?', - [&](const char *b, const char *e) { + 2, [&](const char *b, const char *e) { switch (count) { case 0: req.path = detail::decode_url(std::string(b, e), false); @@ -5028,7 +5987,10 @@ inline bool Server::parse_request_line(const char *s, Request &req) { } inline bool Server::write_response(Stream &strm, bool close_connection, - const Request &req, Response &res) { + Request &req, Response &res) { + // NOTE: `req.ranges` should be empty, otherwise it will be applied + // incorrectly to the error content. + req.ranges.clear(); return write_response_core(strm, close_connection, req, res, false); } @@ -5084,27 +6046,28 @@ inline bool Server::write_response_core(Stream &strm, bool close_connection, detail::BufferStream bstrm; if (!bstrm.write_format("HTTP/1.1 %d %s\r\n", res.status, - detail::status_message(res.status))) { + status_message(res.status))) { return false; } - if (!detail::write_headers(bstrm, res.headers)) { return false; } + if (!header_writer_(bstrm, res.headers)) { return false; } // Flush buffer auto &data = bstrm.get_buffer(); - strm.write(data.data(), data.size()); + detail::write_data(strm, data.data(), data.size()); } // Body auto ret = true; if (req.method != "HEAD") { if (!res.body.empty()) { - if (!strm.write(res.body)) { ret = false; } + if (!detail::write_data(strm, res.body.data(), res.body.size())) { + ret = false; + } } else if (res.content_provider_) { if (write_content_with_provider(strm, req, res, boundary, content_type)) { res.content_provider_success_ = true; } else { - res.content_provider_success_ = false; ret = false; } } @@ -5129,15 +6092,16 @@ Server::write_content_with_provider(Stream &strm, const Request &req, return detail::write_content(strm, res.content_provider_, 0, res.content_length_, is_shutting_down); } else if (req.ranges.size() == 1) { - auto offsets = - detail::get_range_offset_and_length(req, res.content_length_, 0); - auto offset = offsets.first; - auto length = offsets.second; - return detail::write_content(strm, res.content_provider_, offset, length, - is_shutting_down); + auto offset_and_length = detail::get_range_offset_and_length( + req.ranges[0], res.content_length_); + + return detail::write_content(strm, res.content_provider_, + offset_and_length.first, + offset_and_length.second, is_shutting_down); } else { return detail::write_multipart_ranges_data( - strm, req, res, boundary, content_type, is_shutting_down); + strm, req, res, boundary, content_type, res.content_length_, + is_shutting_down); } } else { if (res.is_chunked_content_provider_) { @@ -5168,6 +6132,7 @@ Server::write_content_with_provider(Stream &strm, const Request &req, inline bool Server::read_content(Stream &strm, Request &req, Response &res) { MultipartFormDataMap::iterator cur; + auto file_count = 0; if (read_content_core( strm, req, res, // Regular @@ -5178,6 +6143,9 @@ inline bool Server::read_content(Stream &strm, Request &req, Response &res) { }, // Multipart [&](const MultipartFormData &file) { + if (file_count++ == CPPHTTPLIB_MULTIPART_FORM_DATA_FILE_MAX_COUNT) { + return false; + } cur = req.files.emplace(file.name, file); return true; }, @@ -5189,8 +6157,8 @@ inline bool Server::read_content(Stream &strm, Request &req, Response &res) { })) { const auto &content_type = req.get_header_value("Content-Type"); if (!content_type.find("application/x-www-form-urlencoded")) { - if (req.body.size() > CPPHTTPLIB_REQUEST_URI_MAX_LENGTH) { - res.status = 413; // NOTE: should be 414? + if (req.body.size() > CPPHTTPLIB_FORM_URL_ENCODED_PAYLOAD_MAX_LENGTH) { + res.status = StatusCode::PayloadTooLarge_413; // NOTE: should be 414? return false; } detail::parse_query_text(req.body, req.params); @@ -5209,10 +6177,11 @@ inline bool Server::read_content_with_content_receiver( std::move(multipart_receiver)); } -inline bool Server::read_content_core(Stream &strm, Request &req, Response &res, - ContentReceiver receiver, - MultipartContentHeader mulitpart_header, - ContentReceiver multipart_receiver) { +inline bool +Server::read_content_core(Stream &strm, Request &req, Response &res, + ContentReceiver receiver, + MultipartContentHeader multipart_header, + ContentReceiver multipart_receiver) const { detail::MultipartFormDataParser multipart_form_data_parser; ContentReceiverWithProgress out; @@ -5220,7 +6189,7 @@ inline bool Server::read_content_core(Stream &strm, Request &req, Response &res, const auto &content_type = req.get_header_value("Content-Type"); std::string boundary; if (!detail::parse_multipart_boundary(content_type, boundary)) { - res.status = 400; + res.status = StatusCode::BadRequest_400; return false; } @@ -5231,14 +6200,14 @@ inline bool Server::read_content_core(Stream &strm, Request &req, Response &res, while (pos < n) { auto read_size = (std::min)(1, n - pos); auto ret = multipart_form_data_parser.parse( - buf + pos, read_size, multipart_receiver, mulitpart_header); + buf + pos, read_size, multipart_receiver, multipart_header); if (!ret) { return false; } pos += read_size; } return true; */ return multipart_form_data_parser.parse(buf, n, multipart_receiver, - mulitpart_header); + multipart_header); }; } else { out = [receiver](const char *buf, size_t n, uint64_t /*off*/, @@ -5256,7 +6225,7 @@ inline bool Server::read_content_core(Stream &strm, Request &req, Response &res, if (req.is_multipart_form_data()) { if (!multipart_form_data_parser.is_valid()) { - res.status = 400; + res.status = StatusCode::BadRequest_400; return false; } } @@ -5275,17 +6244,26 @@ inline bool Server::handle_file_request(const Request &req, Response &res, if (path.back() == '/') { path += "index.html"; } if (detail::is_file(path)) { - detail::read_file(path, res.body); - auto type = - detail::find_content_type(path, file_extension_and_mimetype_map_); - if (type) { res.set_header("Content-Type", type); } for (const auto &kv : entry.headers) { - res.set_header(kv.first.c_str(), kv.second); + res.set_header(kv.first, kv.second); } - res.status = req.has_header("Range") ? 206 : 200; + + auto mm = std::make_shared(path.c_str()); + if (!mm->is_open()) { return false; } + + res.set_content_provider( + mm->size(), + detail::find_content_type(path, file_extension_and_mimetype_map_, + default_file_mimetype_), + [mm](size_t offset, size_t length, DataSink &sink) -> bool { + sink.write(mm->data() + offset, length); + return true; + }); + if (!head && file_request_handler_) { file_request_handler_(req, res); } + return true; } } @@ -5295,10 +6273,11 @@ inline bool Server::handle_file_request(const Request &req, Response &res, } inline socket_t -Server::create_server_socket(const char *host, int port, int socket_flags, +Server::create_server_socket(const std::string &host, int port, + int socket_flags, SocketOptions socket_options) const { return detail::create_socket( - host, "", port, address_family_, socket_flags, tcp_nodelay_, + host, std::string(), port, address_family_, socket_flags, tcp_nodelay_, std::move(socket_options), [](socket_t sock, struct addrinfo &ai) -> bool { if (::bind(sock, ai.ai_addr, static_cast(ai.ai_addrlen))) { @@ -5309,7 +6288,8 @@ Server::create_server_socket(const char *host, int port, int socket_flags, }); } -inline int Server::bind_internal(const char *host, int port, int socket_flags) { +inline int Server::bind_internal(const std::string &host, int port, + int socket_flags) { if (!is_valid()) { return -1; } svr_sock_ = create_server_socket(host, port, socket_flags, socket_options_); @@ -5337,6 +6317,7 @@ inline int Server::bind_internal(const char *host, int port, int socket_flags) { inline bool Server::listen_internal() { auto ret = true; is_running_ = true; + auto se = detail::scope_exit([&]() { is_running_ = false; }); { std::unique_ptr task_queue(new_task_queue()); @@ -5362,6 +6343,8 @@ inline bool Server::listen_internal() { // Try to accept new connections after a short sleep. std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; + } else if (errno == EINTR || errno == EAGAIN) { + continue; } if (svr_sock_ != INVALID_SOCKET) { detail::close_socket(svr_sock_); @@ -5376,13 +6359,14 @@ inline bool Server::listen_internal() { #ifdef _WIN32 auto timeout = static_cast(read_timeout_sec_ * 1000 + read_timeout_usec_ / 1000); - setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, - sizeof(timeout)); + setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, + reinterpret_cast(&timeout), sizeof(timeout)); #else timeval tv; tv.tv_sec = static_cast(read_timeout_sec_); tv.tv_usec = static_cast(read_timeout_usec_); - setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)); + setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, + reinterpret_cast(&tv), sizeof(tv)); #endif } { @@ -5390,27 +6374,27 @@ inline bool Server::listen_internal() { #ifdef _WIN32 auto timeout = static_cast(write_timeout_sec_ * 1000 + write_timeout_usec_ / 1000); - setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, - sizeof(timeout)); + setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, + reinterpret_cast(&timeout), sizeof(timeout)); #else timeval tv; tv.tv_sec = static_cast(write_timeout_sec_); tv.tv_usec = static_cast(write_timeout_usec_); - setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(tv)); + setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, + reinterpret_cast(&tv), sizeof(tv)); #endif } -#if __cplusplus > 201703L - task_queue->enqueue([=, this]() { process_and_close_socket(sock); }); -#else - task_queue->enqueue([=]() { process_and_close_socket(sock); }); -#endif + if (!task_queue->enqueue( + [this, sock]() { process_and_close_socket(sock); })) { + detail::shutdown_socket(sock); + detail::close_socket(sock); + } } task_queue->shutdown(); } - is_running_ = false; return ret; } @@ -5421,7 +6405,7 @@ inline bool Server::routing(Request &req, Response &res, Stream &strm) { } // File handler - bool is_head_request = req.method == "HEAD"; + auto is_head_request = req.method == "HEAD"; if ((req.method == "GET" || is_head_request) && handle_file_request(req, res, is_head_request)) { return true; @@ -5487,17 +6471,17 @@ inline bool Server::routing(Request &req, Response &res, Stream &strm) { return dispatch_request(req, res, patch_handlers_); } - res.status = 400; + res.status = StatusCode::BadRequest_400; return false; } inline bool Server::dispatch_request(Request &req, Response &res, - const Handlers &handlers) { + const Handlers &handlers) const { for (const auto &x : handlers) { - const auto &pattern = x.first; + const auto &matcher = x.first; const auto &handler = x.second; - if (std::regex_match(req.path, req.matches, pattern)) { + if (matcher->match(req)) { handler(req, res); return true; } @@ -5507,18 +6491,18 @@ inline bool Server::dispatch_request(Request &req, Response &res, inline void Server::apply_ranges(const Request &req, Response &res, std::string &content_type, - std::string &boundary) { + std::string &boundary) const { if (req.ranges.size() > 1) { - boundary = detail::make_multipart_data_boundary(); - auto it = res.headers.find("Content-Type"); if (it != res.headers.end()) { content_type = it->second; res.headers.erase(it); } - res.headers.emplace("Content-Type", - "multipart/byteranges; boundary=" + boundary); + boundary = detail::make_multipart_data_boundary(); + + res.set_header("Content-Type", + "multipart/byteranges; boundary=" + boundary); } auto type = detail::encoding_type(req, res); @@ -5529,16 +6513,17 @@ inline void Server::apply_ranges(const Request &req, Response &res, if (req.ranges.empty()) { length = res.content_length_; } else if (req.ranges.size() == 1) { - auto offsets = - detail::get_range_offset_and_length(req, res.content_length_, 0); - auto offset = offsets.first; - length = offsets.second; + auto offset_and_length = detail::get_range_offset_and_length( + req.ranges[0], res.content_length_); + + length = offset_and_length.second; + auto content_range = detail::make_content_range_header_field( - offset, length, res.content_length_); + offset_and_length, res.content_length_); res.set_header("Content-Range", content_range); } else { - length = detail::get_multipart_ranges_data_length(req, res, boundary, - content_type); + length = detail::get_multipart_ranges_data_length( + req, boundary, content_type, res.content_length_); } res.set_header("Content-Length", std::to_string(length)); } else { @@ -5557,28 +6542,22 @@ inline void Server::apply_ranges(const Request &req, Response &res, if (req.ranges.empty()) { ; } else if (req.ranges.size() == 1) { - auto offsets = - detail::get_range_offset_and_length(req, res.body.size(), 0); - auto offset = offsets.first; - auto length = offsets.second; + auto offset_and_length = + detail::get_range_offset_and_length(req.ranges[0], res.body.size()); + auto offset = offset_and_length.first; + auto length = offset_and_length.second; + auto content_range = detail::make_content_range_header_field( - offset, length, res.body.size()); + offset_and_length, res.body.size()); res.set_header("Content-Range", content_range); - if (offset < res.body.size()) { - res.body = res.body.substr(offset, length); - } else { - res.body.clear(); - res.status = 416; - } + + assert(offset + length <= res.body.size()); + res.body = res.body.substr(offset, length); } else { std::string data; - if (detail::make_multipart_ranges_data(req, res, boundary, content_type, - data)) { - res.body.swap(data); - } else { - res.body.clear(); - res.status = 416; - } + detail::make_multipart_ranges_data(req, res, boundary, content_type, + res.body.size(), data); + res.body.swap(data); } if (type != detail::EncodingType::None) { @@ -5617,12 +6596,12 @@ inline void Server::apply_ranges(const Request &req, Response &res, inline bool Server::dispatch_request_for_content_reader( Request &req, Response &res, ContentReader content_reader, - const HandlersForContentReader &handlers) { + const HandlersForContentReader &handlers) const { for (const auto &x : handlers) { - const auto &pattern = x.first; + const auto &matcher = x.first; const auto &handler = x.second; - if (std::regex_match(req.path, req.matches, pattern)) { + if (matcher->match(req)) { handler(req, res, content_reader); return true; } @@ -5642,15 +6621,10 @@ Server::process_request(Stream &strm, bool close_connection, if (!line_reader.getline()) { return false; } Request req; - Response res; + Response res; res.version = "HTTP/1.1"; - - for (const auto &header : default_headers_) { - if (res.headers.find(header.first) == res.headers.end()) { - res.headers.insert(header); - } - } + res.headers = default_headers_; #ifdef _WIN32 // TODO: Increase FD_SETSIZE statically (libzmq), dynamically (MySQL). @@ -5660,7 +6634,7 @@ Server::process_request(Stream &strm, bool close_connection, if (strm.socket() >= FD_SETSIZE) { Headers dummy; detail::read_headers(strm, dummy); - res.status = 500; + res.status = StatusCode::InternalServerError_500; return write_response(strm, close_connection, req, res); } #endif @@ -5670,14 +6644,14 @@ Server::process_request(Stream &strm, bool close_connection, if (line_reader.size() > CPPHTTPLIB_REQUEST_URI_MAX_LENGTH) { Headers dummy; detail::read_headers(strm, dummy); - res.status = 414; + res.status = StatusCode::UriTooLong_414; return write_response(strm, close_connection, req, res); } // Request line and headers if (!parse_request_line(line_reader.ptr(), req) || !detail::read_headers(strm, req.headers)) { - res.status = 400; + res.status = StatusCode::BadRequest_400; return write_response(strm, close_connection, req, res); } @@ -5694,10 +6668,14 @@ Server::process_request(Stream &strm, bool close_connection, req.set_header("REMOTE_ADDR", req.remote_addr); req.set_header("REMOTE_PORT", std::to_string(req.remote_port)); + strm.get_local_ip_and_port(req.local_addr, req.local_port); + req.set_header("LOCAL_ADDR", req.local_addr); + req.set_header("LOCAL_PORT", std::to_string(req.local_port)); + if (req.has_header("Range")) { const auto &range_header_value = req.get_header_value("Range"); if (!detail::parse_range_header(range_header_value, req.ranges)) { - res.status = 416; + res.status = StatusCode::RangeNotSatisfiable_416; return write_response(strm, close_connection, req, res); } } @@ -5705,22 +6683,22 @@ Server::process_request(Stream &strm, bool close_connection, if (setup_request) { setup_request(req); } if (req.get_header_value("Expect") == "100-continue") { - auto status = 100; + int status = StatusCode::Continue_100; if (expect_100_continue_handler_) { status = expect_100_continue_handler_(req, res); } switch (status) { - case 100: - case 417: + case StatusCode::Continue_100: + case StatusCode::ExpectationFailed_417: strm.write_format("HTTP/1.1 %d %s\r\n\r\n", status, - detail::status_message(status)); + status_message(status)); break; default: return write_response(strm, close_connection, req, res); } } - // Rounting - bool routed = false; + // Routing + auto routed = false; #ifdef CPPHTTPLIB_NO_EXCEPTIONS routed = routing(req, res, strm); #else @@ -5728,23 +6706,51 @@ Server::process_request(Stream &strm, bool close_connection, routed = routing(req, res, strm); } catch (std::exception &e) { if (exception_handler_) { - exception_handler_(req, res, e); + auto ep = std::current_exception(); + exception_handler_(req, res, ep); routed = true; } else { - res.status = 500; - res.set_header("EXCEPTION_WHAT", e.what()); + res.status = StatusCode::InternalServerError_500; + std::string val; + auto s = e.what(); + for (size_t i = 0; s[i]; i++) { + switch (s[i]) { + case '\r': val += "\\r"; break; + case '\n': val += "\\n"; break; + default: val += s[i]; break; + } + } + res.set_header("EXCEPTION_WHAT", val); } } catch (...) { - res.status = 500; - res.set_header("EXCEPTION_WHAT", "UNKNOWN"); + if (exception_handler_) { + auto ep = std::current_exception(); + exception_handler_(req, res, ep); + routed = true; + } else { + res.status = StatusCode::InternalServerError_500; + res.set_header("EXCEPTION_WHAT", "UNKNOWN"); + } } #endif - if (routed) { - if (res.status == -1) { res.status = req.ranges.empty() ? 200 : 206; } + if (res.status == -1) { + res.status = req.ranges.empty() ? StatusCode::OK_200 + : StatusCode::PartialContent_206; + } + + if (detail::range_error(req, res)) { + res.body.clear(); + res.content_length_ = 0; + res.content_provider_ = nullptr; + res.status = StatusCode::RangeNotSatisfiable_416; + return write_response(strm, close_connection, req, res); + } + return write_response_with_content(strm, close_connection, req, res); } else { - if (res.status == -1) { res.status = 404; } + if (res.status == -1) { res.status = StatusCode::NotFound_404; } + return write_response(strm, close_connection, req, res); } } @@ -5835,7 +6841,7 @@ inline void ClientImpl::copy_settings(const ClientImpl &rhs) { inline socket_t ClientImpl::create_client_socket(Error &error) const { if (!proxy_host_.empty() && proxy_port_ != -1) { return detail::create_client_socket( - proxy_host_.c_str(), "", proxy_port_, address_family_, tcp_nodelay_, + proxy_host_, std::string(), proxy_port_, address_family_, tcp_nodelay_, socket_options_, connection_timeout_sec_, connection_timeout_usec_, read_timeout_sec_, read_timeout_usec_, write_timeout_sec_, write_timeout_usec_, interface_, error); @@ -5844,13 +6850,13 @@ inline socket_t ClientImpl::create_client_socket(Error &error) const { // Check is custom IP specified for host_ std::string ip; auto it = addr_map_.find(host_); - if (it != addr_map_.end()) ip = it->second; + if (it != addr_map_.end()) { ip = it->second; } return detail::create_client_socket( - host_.c_str(), ip.c_str(), port_, address_family_, tcp_nodelay_, - socket_options_, connection_timeout_sec_, connection_timeout_usec_, - read_timeout_sec_, read_timeout_usec_, write_timeout_sec_, - write_timeout_usec_, interface_, error); + host_, ip, port_, address_family_, tcp_nodelay_, socket_options_, + connection_timeout_sec_, connection_timeout_usec_, read_timeout_sec_, + read_timeout_usec_, write_timeout_sec_, write_timeout_usec_, interface_, + error); } inline bool ClientImpl::create_and_connect_socket(Socket &socket, @@ -5869,7 +6875,7 @@ inline void ClientImpl::shutdown_ssl(Socket & /*socket*/, socket_requests_are_from_thread_ == std::this_thread::get_id()); } -inline void ClientImpl::shutdown_socket(Socket &socket) { +inline void ClientImpl::shutdown_socket(Socket &socket) const { if (socket.sock == INVALID_SOCKET) { return; } detail::shutdown_socket(socket.sock); } @@ -5894,7 +6900,7 @@ inline void ClientImpl::close_socket(Socket &socket) { } inline bool ClientImpl::read_response_line(Stream &strm, const Request &req, - Response &res) { + Response &res) const { std::array buf{}; detail::stream_line_reader line_reader(strm, buf.data(), buf.size()); @@ -5902,9 +6908,9 @@ inline bool ClientImpl::read_response_line(Stream &strm, const Request &req, if (!line_reader.getline()) { return false; } #ifdef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR - const static std::regex re("(HTTP/1\\.[01]) (\\d{3})(?: (.*?))?\r\n"); -#else const static std::regex re("(HTTP/1\\.[01]) (\\d{3})(?: (.*?))?\r?\n"); +#else + const static std::regex re("(HTTP/1\\.[01]) (\\d{3})(?: (.*?))?\r\n"); #endif std::cmatch m; @@ -5916,7 +6922,7 @@ inline bool ClientImpl::read_response_line(Stream &strm, const Request &req, res.reason = std::string(m[3]); // Ignore '100 Continue' - while (res.status == 100) { + while (res.status == StatusCode::Continue_100) { if (!line_reader.getline()) { return false; } // CRLF if (!line_reader.getline()) { return false; } // next response line @@ -5931,7 +6937,15 @@ inline bool ClientImpl::read_response_line(Stream &strm, const Request &req, inline bool ClientImpl::send(Request &req, Response &res, Error &error) { std::lock_guard request_mutex_guard(request_mutex_); + auto ret = send_(req, res, error); + if (error == Error::SSLPeerCouldBeClosed_) { + assert(!ret); + ret = send_(req, res, error); + } + return ret; +} +inline bool ClientImpl::send_(Request &req, Response &res, Error &error) { { std::lock_guard guard(socket_mutex_); @@ -5962,7 +6976,7 @@ inline bool ClientImpl::send(Request &req, Response &res, Error &error) { if (is_ssl()) { auto &scli = static_cast(*this); if (!proxy_host_.empty() && proxy_port_ != -1) { - bool success = false; + auto success = false; if (!scli.connect_with_proxy(socket_, res, success, error)) { return success; } @@ -5989,13 +7003,11 @@ inline bool ClientImpl::send(Request &req, Response &res, Error &error) { } } + auto ret = false; auto close_connection = !keep_alive_; - auto ret = process_socket(socket_, [&](Stream &strm) { - return handle_request(strm, req, res, close_connection, error); - }); - // Briefly lock mutex in order to mark that a request is no longer ongoing - { + auto se = detail::scope_exit([&]() { + // Briefly lock mutex in order to mark that a request is no longer ongoing std::lock_guard guard(socket_mutex_); socket_requests_in_flight_ -= 1; if (socket_requests_in_flight_ <= 0) { @@ -6009,7 +7021,11 @@ inline bool ClientImpl::send(Request &req, Response &res, Error &error) { shutdown_socket(socket_); close_socket(socket_); } - } + }); + + ret = process_socket(socket_, [&](Stream &strm) { + return handle_request(strm, req, res, close_connection, error); + }); if (!ret) { if (error == Error::Success) { error = Error::Unknown; } @@ -6054,15 +7070,31 @@ inline bool ClientImpl::handle_request(Stream &strm, Request &req, if (!ret) { return false; } + if (res.get_header_value("Connection") == "close" || + (res.version == "HTTP/1.0" && res.reason != "Connection established")) { + // TODO this requires a not-entirely-obvious chain of calls to be correct + // for this to be safe. + + // This is safe to call because handle_request is only called by send_ + // which locks the request mutex during the process. It would be a bug + // to call it from a different thread since it's a thread-safety issue + // to do these things to the socket if another thread is using the socket. + std::lock_guard guard(socket_mutex_); + shutdown_ssl(socket_, true); + shutdown_socket(socket_); + close_socket(socket_); + } + if (300 < res.status && res.status < 400 && follow_location_) { req = req_save; ret = redirect(req, res, error); } #ifdef CPPHTTPLIB_OPENSSL_SUPPORT - if ((res.status == 401 || res.status == 407) && + if ((res.status == StatusCode::Unauthorized_401 || + res.status == StatusCode::ProxyAuthenticationRequired_407) && req.authorization_count_ < 5) { - auto is_proxy = res.status == 407; + auto is_proxy = res.status == StatusCode::ProxyAuthenticationRequired_407; const auto &username = is_proxy ? proxy_digest_auth_username_ : digest_auth_username_; const auto &password = @@ -6097,11 +7129,11 @@ inline bool ClientImpl::redirect(Request &req, Response &res, Error &error) { return false; } - auto location = detail::decode_url(res.get_header_value("location"), true); + auto location = res.get_header_value("location"); if (location.empty()) { return false; } const static std::regex re( - R"((?:(https?):)?(?://(?:\[([\d:]+)\]|([^:/?#]+))(?::(\d+))?)?([^?#]*(?:\?[^#]*)?)(?:#.*)?)"); + R"((?:(https?):)?(?://(?:\[([\d:]+)\]|([^:/?#]+))(?::(\d+))?)?([^?#]*)(\?[^#]*)?(?:#.*)?)"); std::smatch m; if (!std::regex_match(location, m, re)) { return false; } @@ -6113,6 +7145,7 @@ inline bool ClientImpl::redirect(Request &req, Response &res, Error &error) { if (next_host.empty()) { next_host = m[3].str(); } auto port_str = m[4].str(); auto next_path = m[5].str(); + auto next_query = m[6].str(); auto next_port = port_; if (!port_str.empty()) { @@ -6125,33 +7158,35 @@ inline bool ClientImpl::redirect(Request &req, Response &res, Error &error) { if (next_host.empty()) { next_host = host_; } if (next_path.empty()) { next_path = "/"; } + auto path = detail::decode_url(next_path, true) + next_query; + if (next_scheme == scheme && next_host == host_ && next_port == port_) { - return detail::redirect(*this, req, res, next_path, location, error); + return detail::redirect(*this, req, res, path, location, error); } else { if (next_scheme == "https") { #ifdef CPPHTTPLIB_OPENSSL_SUPPORT - SSLClient cli(next_host.c_str(), next_port); + SSLClient cli(next_host, next_port); cli.copy_settings(*this); if (ca_cert_store_) { cli.set_ca_cert_store(ca_cert_store_); } - return detail::redirect(cli, req, res, next_path, location, error); + return detail::redirect(cli, req, res, path, location, error); #else return false; #endif } else { - ClientImpl cli(next_host.c_str(), next_port); + ClientImpl cli(next_host, next_port); cli.copy_settings(*this); - return detail::redirect(cli, req, res, next_path, location, error); + return detail::redirect(cli, req, res, path, location, error); } } } inline bool ClientImpl::write_content_with_provider(Stream &strm, const Request &req, - Error &error) { + Error &error) const { auto is_shutting_down = []() { return false; }; if (req.is_chunked_content_provider_) { - // TODO: Brotli suport + // TODO: Brotli support std::unique_ptr compressor; #ifdef CPPHTTPLIB_ZLIB_SUPPORT if (compress_) { @@ -6168,39 +7203,39 @@ inline bool ClientImpl::write_content_with_provider(Stream &strm, return detail::write_content(strm, req.content_provider_, 0, req.content_length_, is_shutting_down, error); } -} // namespace httplib +} inline bool ClientImpl::write_request(Stream &strm, Request &req, bool close_connection, Error &error) { // Prepare additional headers if (close_connection) { if (!req.has_header("Connection")) { - req.headers.emplace("Connection", "close"); + req.set_header("Connection", "close"); } } if (!req.has_header("Host")) { if (is_ssl()) { if (port_ == 443) { - req.headers.emplace("Host", host_); + req.set_header("Host", host_); } else { - req.headers.emplace("Host", host_and_port_); + req.set_header("Host", host_and_port_); } } else { if (port_ == 80) { - req.headers.emplace("Host", host_); + req.set_header("Host", host_); } else { - req.headers.emplace("Host", host_and_port_); + req.set_header("Host", host_and_port_); } } } - if (!req.has_header("Accept")) { req.headers.emplace("Accept", "*/*"); } + if (!req.has_header("Accept")) { req.set_header("Accept", "*/*"); } #ifndef CPPHTTPLIB_NO_DEFAULT_USER_AGENT if (!req.has_header("User-Agent")) { auto agent = std::string("cpp-httplib/") + CPPHTTPLIB_VERSION; - req.headers.emplace("User-Agent", agent); + req.set_header("User-Agent", agent); } #endif @@ -6209,23 +7244,23 @@ inline bool ClientImpl::write_request(Stream &strm, Request &req, if (!req.is_chunked_content_provider_) { if (!req.has_header("Content-Length")) { auto length = std::to_string(req.content_length_); - req.headers.emplace("Content-Length", length); + req.set_header("Content-Length", length); } } } else { if (req.method == "POST" || req.method == "PUT" || req.method == "PATCH") { - req.headers.emplace("Content-Length", "0"); + req.set_header("Content-Length", "0"); } } } else { if (!req.has_header("Content-Type")) { - req.headers.emplace("Content-Type", "text/plain"); + req.set_header("Content-Type", "text/plain"); } if (!req.has_header("Content-Length")) { auto length = std::to_string(req.body.size()); - req.headers.emplace("Content-Length", length); + req.set_header("Content-Length", length); } } @@ -6265,7 +7300,7 @@ inline bool ClientImpl::write_request(Stream &strm, Request &req, const auto &path = url_encode_ ? detail::encode_url(req.path) : req.path; bstrm.write_format("%s %s HTTP/1.1\r\n", req.method.c_str(), path.c_str()); - detail::write_headers(bstrm, req.headers); + header_writer_(bstrm, req.headers); // Flush buffer auto &data = bstrm.get_buffer(); @@ -6289,16 +7324,14 @@ inline bool ClientImpl::write_request(Stream &strm, Request &req, } inline std::unique_ptr ClientImpl::send_with_content_provider( - Request &req, - // const char *method, const char *path, const Headers &headers, - const char *body, size_t content_length, ContentProvider content_provider, + Request &req, const char *body, size_t content_length, + ContentProvider content_provider, ContentProviderWithoutLength content_provider_without_length, - const char *content_type, Error &error) { - - if (content_type) { req.headers.emplace("Content-Type", content_type); } + const std::string &content_type, Error &error) { + if (!content_type.empty()) { req.set_header("Content-Type", content_type); } #ifdef CPPHTTPLIB_ZLIB_SUPPORT - if (compress_) { req.headers.emplace("Content-Encoding", "gzip"); } + if (compress_) { req.set_header("Content-Encoding", "gzip"); } #endif #ifdef CPPHTTPLIB_ZLIB_SUPPORT @@ -6316,8 +7349,9 @@ inline std::unique_ptr ClientImpl::send_with_content_provider( auto last = offset + data_len == content_length; auto ret = compressor.compress( - data, data_len, last, [&](const char *data, size_t data_len) { - req.body.append(data, data_len); + data, data_len, last, + [&](const char *compressed_data, size_t compressed_data_len) { + req.body.append(compressed_data, compressed_data_len); return true; }); @@ -6330,8 +7364,6 @@ inline std::unique_ptr ClientImpl::send_with_content_provider( return ok; }; - data_sink.is_writable = [&](void) { return ok && true; }; - while (ok && offset < content_length) { if (!content_provider(offset, content_length - offset, data_sink)) { error = Error::Canceled; @@ -6360,10 +7392,9 @@ inline std::unique_ptr ClientImpl::send_with_content_provider( req.content_provider_ = detail::ContentProviderAdapter( std::move(content_provider_without_length)); req.is_chunked_content_provider_ = true; - req.headers.emplace("Transfer-Encoding", "chunked"); + req.set_header("Transfer-Encoding", "chunked"); } else { req.body.assign(body, content_length); - ; } } @@ -6372,10 +7403,10 @@ inline std::unique_ptr ClientImpl::send_with_content_provider( } inline Result ClientImpl::send_with_content_provider( - const char *method, const char *path, const Headers &headers, + const std::string &method, const std::string &path, const Headers &headers, const char *body, size_t content_length, ContentProvider content_provider, ContentProviderWithoutLength content_provider_without_length, - const char *content_type) { + const std::string &content_type) { Request req; req.method = method; req.headers = headers; @@ -6384,9 +7415,7 @@ inline Result ClientImpl::send_with_content_provider( auto error = Error::Success; auto res = send_with_content_provider( - req, - // method, path, headers, - body, content_length, std::move(content_provider), + req, body, content_length, std::move(content_provider), std::move(content_provider_without_length), content_type, error); return Result{std::move(res), error, std::move(req.headers)}; @@ -6404,6 +7433,20 @@ inline bool ClientImpl::process_request(Stream &strm, Request &req, // Send request if (!write_request(strm, req, close_connection, error)) { return false; } +#ifdef CPPHTTPLIB_OPENSSL_SUPPORT + if (is_ssl()) { + auto is_proxy_enabled = !proxy_host_.empty() && proxy_port_ != -1; + if (!is_proxy_enabled) { + char buf[1]; + if (SSL_peek(socket_.ssl, buf, 1) == 0 && + SSL_get_error(socket_.ssl, 0) == SSL_ERROR_ZERO_RETURN) { + error = Error::SSLPeerCouldBeClosed_; + return false; + } + } + } +#endif + // Receive response and headers if (!read_response_line(strm, req, res) || !detail::read_headers(strm, res.headers)) { @@ -6412,7 +7455,8 @@ inline bool ClientImpl::process_request(Stream &strm, Request &req, } // Body - if ((res.status != 204) && req.method != "HEAD" && req.method != "CONNECT") { + if ((res.status != StatusCode::NoContent_204) && req.method != "HEAD" && + req.method != "CONNECT") { auto redirect = 300 < res.status && res.status < 400 && follow_location_; if (req.response_handler && !redirect) { @@ -6457,30 +7501,56 @@ inline bool ClientImpl::process_request(Stream &strm, Request &req, } } - if (res.get_header_value("Connection") == "close" || - (res.version == "HTTP/1.0" && res.reason != "Connection established")) { - // TODO this requires a not-entirely-obvious chain of calls to be correct - // for this to be safe. Maybe a code refactor (such as moving this out to - // the send function and getting rid of the recursiveness of the mutex) - // could make this more obvious. - - // This is safe to call because process_request is only called by - // handle_request which is only called by send, which locks the request - // mutex during the process. It would be a bug to call it from a different - // thread since it's a thread-safety issue to do these things to the socket - // if another thread is using the socket. - std::lock_guard guard(socket_mutex_); - shutdown_ssl(socket_, true); - shutdown_socket(socket_); - close_socket(socket_); - } - // Log if (logger_) { logger_(req, res); } return true; } +inline ContentProviderWithoutLength ClientImpl::get_multipart_content_provider( + const std::string &boundary, const MultipartFormDataItems &items, + const MultipartFormDataProviderItems &provider_items) const { + size_t cur_item = 0; + size_t cur_start = 0; + // cur_item and cur_start are copied to within the std::function and maintain + // state between successive calls + return [&, cur_item, cur_start](size_t offset, + DataSink &sink) mutable -> bool { + if (!offset && !items.empty()) { + sink.os << detail::serialize_multipart_formdata(items, boundary, false); + return true; + } else if (cur_item < provider_items.size()) { + if (!cur_start) { + const auto &begin = detail::serialize_multipart_formdata_item_begin( + provider_items[cur_item], boundary); + offset += begin.size(); + cur_start = offset; + sink.os << begin; + } + + DataSink cur_sink; + auto has_data = true; + cur_sink.write = sink.write; + cur_sink.done = [&]() { has_data = false; }; + + if (!provider_items[cur_item].provider(offset - cur_start, cur_sink)) { + return false; + } + + if (!has_data) { + sink.os << detail::serialize_multipart_formdata_item_end(); + cur_item++; + cur_start = 0; + } + return true; + } else { + sink.os << detail::serialize_multipart_formdata_finish(boundary); + sink.done(); + return true; + } + }; +} + inline bool ClientImpl::process_socket(const Socket &socket, std::function callback) { @@ -6491,19 +7561,19 @@ ClientImpl::process_socket(const Socket &socket, inline bool ClientImpl::is_ssl() const { return false; } -inline Result ClientImpl::Get(const char *path) { +inline Result ClientImpl::Get(const std::string &path) { return Get(path, Headers(), Progress()); } -inline Result ClientImpl::Get(const char *path, Progress progress) { +inline Result ClientImpl::Get(const std::string &path, Progress progress) { return Get(path, Headers(), std::move(progress)); } -inline Result ClientImpl::Get(const char *path, const Headers &headers) { +inline Result ClientImpl::Get(const std::string &path, const Headers &headers) { return Get(path, headers, Progress()); } -inline Result ClientImpl::Get(const char *path, const Headers &headers, +inline Result ClientImpl::Get(const std::string &path, const Headers &headers, Progress progress) { Request req; req.method = "GET"; @@ -6514,45 +7584,45 @@ inline Result ClientImpl::Get(const char *path, const Headers &headers, return send_(std::move(req)); } -inline Result ClientImpl::Get(const char *path, +inline Result ClientImpl::Get(const std::string &path, ContentReceiver content_receiver) { return Get(path, Headers(), nullptr, std::move(content_receiver), nullptr); } -inline Result ClientImpl::Get(const char *path, +inline Result ClientImpl::Get(const std::string &path, ContentReceiver content_receiver, Progress progress) { return Get(path, Headers(), nullptr, std::move(content_receiver), std::move(progress)); } -inline Result ClientImpl::Get(const char *path, const Headers &headers, +inline Result ClientImpl::Get(const std::string &path, const Headers &headers, ContentReceiver content_receiver) { return Get(path, headers, nullptr, std::move(content_receiver), nullptr); } -inline Result ClientImpl::Get(const char *path, const Headers &headers, +inline Result ClientImpl::Get(const std::string &path, const Headers &headers, ContentReceiver content_receiver, Progress progress) { return Get(path, headers, nullptr, std::move(content_receiver), std::move(progress)); } -inline Result ClientImpl::Get(const char *path, +inline Result ClientImpl::Get(const std::string &path, ResponseHandler response_handler, ContentReceiver content_receiver) { return Get(path, Headers(), std::move(response_handler), std::move(content_receiver), nullptr); } -inline Result ClientImpl::Get(const char *path, const Headers &headers, +inline Result ClientImpl::Get(const std::string &path, const Headers &headers, ResponseHandler response_handler, ContentReceiver content_receiver) { return Get(path, headers, std::move(response_handler), std::move(content_receiver), nullptr); } -inline Result ClientImpl::Get(const char *path, +inline Result ClientImpl::Get(const std::string &path, ResponseHandler response_handler, ContentReceiver content_receiver, Progress progress) { @@ -6560,7 +7630,7 @@ inline Result ClientImpl::Get(const char *path, std::move(content_receiver), std::move(progress)); } -inline Result ClientImpl::Get(const char *path, const Headers &headers, +inline Result ClientImpl::Get(const std::string &path, const Headers &headers, ResponseHandler response_handler, ContentReceiver content_receiver, Progress progress) { @@ -6579,40 +7649,43 @@ inline Result ClientImpl::Get(const char *path, const Headers &headers, return send_(std::move(req)); } -inline Result ClientImpl::Get(const char *path, const Params ¶ms, +inline Result ClientImpl::Get(const std::string &path, const Params ¶ms, const Headers &headers, Progress progress) { if (params.empty()) { return Get(path, headers); } std::string path_with_query = append_query_params(path, params); - return Get(path_with_query.c_str(), headers, progress); + return Get(path_with_query, headers, std::move(progress)); } -inline Result ClientImpl::Get(const char *path, const Params ¶ms, +inline Result ClientImpl::Get(const std::string &path, const Params ¶ms, const Headers &headers, ContentReceiver content_receiver, Progress progress) { - return Get(path, params, headers, nullptr, content_receiver, progress); + return Get(path, params, headers, nullptr, std::move(content_receiver), + std::move(progress)); } -inline Result ClientImpl::Get(const char *path, const Params ¶ms, +inline Result ClientImpl::Get(const std::string &path, const Params ¶ms, const Headers &headers, ResponseHandler response_handler, ContentReceiver content_receiver, Progress progress) { if (params.empty()) { - return Get(path, headers, response_handler, content_receiver, progress); + return Get(path, headers, std::move(response_handler), + std::move(content_receiver), std::move(progress)); } std::string path_with_query = append_query_params(path, params); - return Get(path_with_query.c_str(), headers, response_handler, - content_receiver, progress); + return Get(path_with_query, headers, std::move(response_handler), + std::move(content_receiver), std::move(progress)); } -inline Result ClientImpl::Head(const char *path) { +inline Result ClientImpl::Head(const std::string &path) { return Head(path, Headers()); } -inline Result ClientImpl::Head(const char *path, const Headers &headers) { +inline Result ClientImpl::Head(const std::string &path, + const Headers &headers) { Request req; req.method = "HEAD"; req.headers = headers; @@ -6621,288 +7694,338 @@ inline Result ClientImpl::Head(const char *path, const Headers &headers) { return send_(std::move(req)); } -inline Result ClientImpl::Post(const char *path) { - return Post(path, std::string(), nullptr); +inline Result ClientImpl::Post(const std::string &path) { + return Post(path, std::string(), std::string()); +} + +inline Result ClientImpl::Post(const std::string &path, + const Headers &headers) { + return Post(path, headers, nullptr, 0, std::string()); } -inline Result ClientImpl::Post(const char *path, const char *body, +inline Result ClientImpl::Post(const std::string &path, const char *body, size_t content_length, - const char *content_type) { + const std::string &content_type) { return Post(path, Headers(), body, content_length, content_type); } -inline Result ClientImpl::Post(const char *path, const Headers &headers, +inline Result ClientImpl::Post(const std::string &path, const Headers &headers, const char *body, size_t content_length, - const char *content_type) { + const std::string &content_type) { return send_with_content_provider("POST", path, headers, body, content_length, nullptr, nullptr, content_type); } -inline Result ClientImpl::Post(const char *path, const std::string &body, - const char *content_type) { +inline Result ClientImpl::Post(const std::string &path, const std::string &body, + const std::string &content_type) { return Post(path, Headers(), body, content_type); } -inline Result ClientImpl::Post(const char *path, const Headers &headers, +inline Result ClientImpl::Post(const std::string &path, const Headers &headers, const std::string &body, - const char *content_type) { + const std::string &content_type) { return send_with_content_provider("POST", path, headers, body.data(), body.size(), nullptr, nullptr, content_type); } -inline Result ClientImpl::Post(const char *path, const Params ¶ms) { +inline Result ClientImpl::Post(const std::string &path, const Params ¶ms) { return Post(path, Headers(), params); } -inline Result ClientImpl::Post(const char *path, size_t content_length, +inline Result ClientImpl::Post(const std::string &path, size_t content_length, ContentProvider content_provider, - const char *content_type) { + const std::string &content_type) { return Post(path, Headers(), content_length, std::move(content_provider), content_type); } -inline Result ClientImpl::Post(const char *path, +inline Result ClientImpl::Post(const std::string &path, ContentProviderWithoutLength content_provider, - const char *content_type) { + const std::string &content_type) { return Post(path, Headers(), std::move(content_provider), content_type); } -inline Result ClientImpl::Post(const char *path, const Headers &headers, +inline Result ClientImpl::Post(const std::string &path, const Headers &headers, size_t content_length, ContentProvider content_provider, - const char *content_type) { + const std::string &content_type) { return send_with_content_provider("POST", path, headers, nullptr, content_length, std::move(content_provider), nullptr, content_type); } -inline Result ClientImpl::Post(const char *path, const Headers &headers, +inline Result ClientImpl::Post(const std::string &path, const Headers &headers, ContentProviderWithoutLength content_provider, - const char *content_type) { + const std::string &content_type) { return send_with_content_provider("POST", path, headers, nullptr, 0, nullptr, std::move(content_provider), content_type); } -inline Result ClientImpl::Post(const char *path, const Headers &headers, +inline Result ClientImpl::Post(const std::string &path, const Headers &headers, const Params ¶ms) { auto query = detail::params_to_query_str(params); return Post(path, headers, query, "application/x-www-form-urlencoded"); } -inline Result ClientImpl::Post(const char *path, +inline Result ClientImpl::Post(const std::string &path, const MultipartFormDataItems &items) { return Post(path, Headers(), items); } -inline Result ClientImpl::Post(const char *path, const Headers &headers, +inline Result ClientImpl::Post(const std::string &path, const Headers &headers, const MultipartFormDataItems &items) { - return Post(path, headers, items, detail::make_multipart_data_boundary()); + const auto &boundary = detail::make_multipart_data_boundary(); + const auto &content_type = + detail::serialize_multipart_formdata_get_content_type(boundary); + const auto &body = detail::serialize_multipart_formdata(items, boundary); + return Post(path, headers, body, content_type); } -inline Result ClientImpl::Post(const char *path, const Headers &headers, + +inline Result ClientImpl::Post(const std::string &path, const Headers &headers, const MultipartFormDataItems &items, const std::string &boundary) { - for (size_t i = 0; i < boundary.size(); i++) { - char c = boundary[i]; - if (!std::isalnum(c) && c != '-' && c != '_') { - return Result{nullptr, Error::UnsupportedMultipartBoundaryChars}; - } + if (!detail::is_multipart_boundary_chars_valid(boundary)) { + return Result{nullptr, Error::UnsupportedMultipartBoundaryChars}; } - std::string body; - - for (const auto &item : items) { - body += "--" + boundary + "\r\n"; - body += "Content-Disposition: form-data; name=\"" + item.name + "\""; - if (!item.filename.empty()) { - body += "; filename=\"" + item.filename + "\""; - } - body += "\r\n"; - if (!item.content_type.empty()) { - body += "Content-Type: " + item.content_type + "\r\n"; - } - body += "\r\n"; - body += item.content + "\r\n"; - } - - body += "--" + boundary + "--\r\n"; + const auto &content_type = + detail::serialize_multipart_formdata_get_content_type(boundary); + const auto &body = detail::serialize_multipart_formdata(items, boundary); + return Post(path, headers, body, content_type); +} - std::string content_type = "multipart/form-data; boundary=" + boundary; - return Post(path, headers, body, content_type.c_str()); +inline Result +ClientImpl::Post(const std::string &path, const Headers &headers, + const MultipartFormDataItems &items, + const MultipartFormDataProviderItems &provider_items) { + const auto &boundary = detail::make_multipart_data_boundary(); + const auto &content_type = + detail::serialize_multipart_formdata_get_content_type(boundary); + return send_with_content_provider( + "POST", path, headers, nullptr, 0, nullptr, + get_multipart_content_provider(boundary, items, provider_items), + content_type); } -inline Result ClientImpl::Put(const char *path) { - return Put(path, std::string(), nullptr); +inline Result ClientImpl::Put(const std::string &path) { + return Put(path, std::string(), std::string()); } -inline Result ClientImpl::Put(const char *path, const char *body, - size_t content_length, const char *content_type) { +inline Result ClientImpl::Put(const std::string &path, const char *body, + size_t content_length, + const std::string &content_type) { return Put(path, Headers(), body, content_length, content_type); } -inline Result ClientImpl::Put(const char *path, const Headers &headers, +inline Result ClientImpl::Put(const std::string &path, const Headers &headers, const char *body, size_t content_length, - const char *content_type) { + const std::string &content_type) { return send_with_content_provider("PUT", path, headers, body, content_length, nullptr, nullptr, content_type); } -inline Result ClientImpl::Put(const char *path, const std::string &body, - const char *content_type) { +inline Result ClientImpl::Put(const std::string &path, const std::string &body, + const std::string &content_type) { return Put(path, Headers(), body, content_type); } -inline Result ClientImpl::Put(const char *path, const Headers &headers, +inline Result ClientImpl::Put(const std::string &path, const Headers &headers, const std::string &body, - const char *content_type) { + const std::string &content_type) { return send_with_content_provider("PUT", path, headers, body.data(), body.size(), nullptr, nullptr, content_type); } -inline Result ClientImpl::Put(const char *path, size_t content_length, +inline Result ClientImpl::Put(const std::string &path, size_t content_length, ContentProvider content_provider, - const char *content_type) { + const std::string &content_type) { return Put(path, Headers(), content_length, std::move(content_provider), content_type); } -inline Result ClientImpl::Put(const char *path, +inline Result ClientImpl::Put(const std::string &path, ContentProviderWithoutLength content_provider, - const char *content_type) { + const std::string &content_type) { return Put(path, Headers(), std::move(content_provider), content_type); } -inline Result ClientImpl::Put(const char *path, const Headers &headers, +inline Result ClientImpl::Put(const std::string &path, const Headers &headers, size_t content_length, ContentProvider content_provider, - const char *content_type) { + const std::string &content_type) { return send_with_content_provider("PUT", path, headers, nullptr, content_length, std::move(content_provider), nullptr, content_type); } -inline Result ClientImpl::Put(const char *path, const Headers &headers, +inline Result ClientImpl::Put(const std::string &path, const Headers &headers, ContentProviderWithoutLength content_provider, - const char *content_type) { + const std::string &content_type) { return send_with_content_provider("PUT", path, headers, nullptr, 0, nullptr, std::move(content_provider), content_type); } -inline Result ClientImpl::Put(const char *path, const Params ¶ms) { +inline Result ClientImpl::Put(const std::string &path, const Params ¶ms) { return Put(path, Headers(), params); } -inline Result ClientImpl::Put(const char *path, const Headers &headers, +inline Result ClientImpl::Put(const std::string &path, const Headers &headers, const Params ¶ms) { auto query = detail::params_to_query_str(params); return Put(path, headers, query, "application/x-www-form-urlencoded"); } -inline Result ClientImpl::Patch(const char *path) { - return Patch(path, std::string(), nullptr); +inline Result ClientImpl::Put(const std::string &path, + const MultipartFormDataItems &items) { + return Put(path, Headers(), items); +} + +inline Result ClientImpl::Put(const std::string &path, const Headers &headers, + const MultipartFormDataItems &items) { + const auto &boundary = detail::make_multipart_data_boundary(); + const auto &content_type = + detail::serialize_multipart_formdata_get_content_type(boundary); + const auto &body = detail::serialize_multipart_formdata(items, boundary); + return Put(path, headers, body, content_type); +} + +inline Result ClientImpl::Put(const std::string &path, const Headers &headers, + const MultipartFormDataItems &items, + const std::string &boundary) { + if (!detail::is_multipart_boundary_chars_valid(boundary)) { + return Result{nullptr, Error::UnsupportedMultipartBoundaryChars}; + } + + const auto &content_type = + detail::serialize_multipart_formdata_get_content_type(boundary); + const auto &body = detail::serialize_multipart_formdata(items, boundary); + return Put(path, headers, body, content_type); +} + +inline Result +ClientImpl::Put(const std::string &path, const Headers &headers, + const MultipartFormDataItems &items, + const MultipartFormDataProviderItems &provider_items) { + const auto &boundary = detail::make_multipart_data_boundary(); + const auto &content_type = + detail::serialize_multipart_formdata_get_content_type(boundary); + return send_with_content_provider( + "PUT", path, headers, nullptr, 0, nullptr, + get_multipart_content_provider(boundary, items, provider_items), + content_type); +} +inline Result ClientImpl::Patch(const std::string &path) { + return Patch(path, std::string(), std::string()); } -inline Result ClientImpl::Patch(const char *path, const char *body, +inline Result ClientImpl::Patch(const std::string &path, const char *body, size_t content_length, - const char *content_type) { + const std::string &content_type) { return Patch(path, Headers(), body, content_length, content_type); } -inline Result ClientImpl::Patch(const char *path, const Headers &headers, +inline Result ClientImpl::Patch(const std::string &path, const Headers &headers, const char *body, size_t content_length, - const char *content_type) { + const std::string &content_type) { return send_with_content_provider("PATCH", path, headers, body, content_length, nullptr, nullptr, content_type); } -inline Result ClientImpl::Patch(const char *path, const std::string &body, - const char *content_type) { +inline Result ClientImpl::Patch(const std::string &path, + const std::string &body, + const std::string &content_type) { return Patch(path, Headers(), body, content_type); } -inline Result ClientImpl::Patch(const char *path, const Headers &headers, +inline Result ClientImpl::Patch(const std::string &path, const Headers &headers, const std::string &body, - const char *content_type) { + const std::string &content_type) { return send_with_content_provider("PATCH", path, headers, body.data(), body.size(), nullptr, nullptr, content_type); } -inline Result ClientImpl::Patch(const char *path, size_t content_length, +inline Result ClientImpl::Patch(const std::string &path, size_t content_length, ContentProvider content_provider, - const char *content_type) { + const std::string &content_type) { return Patch(path, Headers(), content_length, std::move(content_provider), content_type); } -inline Result ClientImpl::Patch(const char *path, +inline Result ClientImpl::Patch(const std::string &path, ContentProviderWithoutLength content_provider, - const char *content_type) { + const std::string &content_type) { return Patch(path, Headers(), std::move(content_provider), content_type); } -inline Result ClientImpl::Patch(const char *path, const Headers &headers, +inline Result ClientImpl::Patch(const std::string &path, const Headers &headers, size_t content_length, ContentProvider content_provider, - const char *content_type) { + const std::string &content_type) { return send_with_content_provider("PATCH", path, headers, nullptr, content_length, std::move(content_provider), nullptr, content_type); } -inline Result ClientImpl::Patch(const char *path, const Headers &headers, +inline Result ClientImpl::Patch(const std::string &path, const Headers &headers, ContentProviderWithoutLength content_provider, - const char *content_type) { + const std::string &content_type) { return send_with_content_provider("PATCH", path, headers, nullptr, 0, nullptr, std::move(content_provider), content_type); } -inline Result ClientImpl::Delete(const char *path) { - return Delete(path, Headers(), std::string(), nullptr); +inline Result ClientImpl::Delete(const std::string &path) { + return Delete(path, Headers(), std::string(), std::string()); } -inline Result ClientImpl::Delete(const char *path, const Headers &headers) { - return Delete(path, headers, std::string(), nullptr); +inline Result ClientImpl::Delete(const std::string &path, + const Headers &headers) { + return Delete(path, headers, std::string(), std::string()); } -inline Result ClientImpl::Delete(const char *path, const char *body, +inline Result ClientImpl::Delete(const std::string &path, const char *body, size_t content_length, - const char *content_type) { + const std::string &content_type) { return Delete(path, Headers(), body, content_length, content_type); } -inline Result ClientImpl::Delete(const char *path, const Headers &headers, - const char *body, size_t content_length, - const char *content_type) { +inline Result ClientImpl::Delete(const std::string &path, + const Headers &headers, const char *body, + size_t content_length, + const std::string &content_type) { Request req; req.method = "DELETE"; req.headers = headers; req.path = path; - if (content_type) { req.headers.emplace("Content-Type", content_type); } + if (!content_type.empty()) { req.set_header("Content-Type", content_type); } req.body.assign(body, content_length); return send_(std::move(req)); } -inline Result ClientImpl::Delete(const char *path, const std::string &body, - const char *content_type) { +inline Result ClientImpl::Delete(const std::string &path, + const std::string &body, + const std::string &content_type) { return Delete(path, Headers(), body.data(), body.size(), content_type); } -inline Result ClientImpl::Delete(const char *path, const Headers &headers, +inline Result ClientImpl::Delete(const std::string &path, + const Headers &headers, const std::string &body, - const char *content_type) { + const std::string &content_type) { return Delete(path, headers, body.data(), body.size(), content_type); } -inline Result ClientImpl::Options(const char *path) { +inline Result ClientImpl::Options(const std::string &path) { return Options(path, Headers()); } -inline Result ClientImpl::Options(const char *path, const Headers &headers) { +inline Result ClientImpl::Options(const std::string &path, + const Headers &headers) { Request req; req.method = "OPTIONS"; req.headers = headers; @@ -6911,11 +8034,6 @@ inline Result ClientImpl::Options(const char *path, const Headers &headers) { return send_(std::move(req)); } -inline size_t ClientImpl::is_socket_open() const { - std::lock_guard guard(socket_mutex_); - return socket_.is_open(); -} - inline void ClientImpl::stop() { std::lock_guard guard(socket_mutex_); @@ -6933,12 +8051,23 @@ inline void ClientImpl::stop() { return; } - // Otherwise, sitll holding the mutex, we can shut everything down ourselves + // Otherwise, still holding the mutex, we can shut everything down ourselves shutdown_ssl(socket_, true); shutdown_socket(socket_); close_socket(socket_); } +inline std::string ClientImpl::host() const { return host_; } + +inline int ClientImpl::port() const { return port_; } + +inline size_t ClientImpl::is_socket_open() const { + std::lock_guard guard(socket_mutex_); + return socket_.is_open(); +} + +inline socket_t ClientImpl::socket() const { return socket_.sock; } + inline void ClientImpl::set_connection_timeout(time_t sec, time_t usec) { connection_timeout_sec_ = sec; connection_timeout_usec_ = usec; @@ -6954,19 +8083,19 @@ inline void ClientImpl::set_write_timeout(time_t sec, time_t usec) { write_timeout_usec_ = usec; } -inline void ClientImpl::set_basic_auth(const char *username, - const char *password) { +inline void ClientImpl::set_basic_auth(const std::string &username, + const std::string &password) { basic_auth_username_ = username; basic_auth_password_ = password; } -inline void ClientImpl::set_bearer_token_auth(const char *token) { +inline void ClientImpl::set_bearer_token_auth(const std::string &token) { bearer_token_auth_token_ = token; } #ifdef CPPHTTPLIB_OPENSSL_SUPPORT -inline void ClientImpl::set_digest_auth(const char *username, - const char *password) { +inline void ClientImpl::set_digest_auth(const std::string &username, + const std::string &password) { digest_auth_username_ = username; digest_auth_password_ = password; } @@ -6987,6 +8116,11 @@ inline void ClientImpl::set_default_headers(Headers headers) { default_headers_ = std::move(headers); } +inline void ClientImpl::set_header_writer( + std::function const &writer) { + header_writer_ = writer; +} + inline void ClientImpl::set_address_family(int family) { address_family_ = family; } @@ -7001,36 +8135,36 @@ inline void ClientImpl::set_compress(bool on) { compress_ = on; } inline void ClientImpl::set_decompress(bool on) { decompress_ = on; } -inline void ClientImpl::set_interface(const char *intf) { interface_ = intf; } +inline void ClientImpl::set_interface(const std::string &intf) { + interface_ = intf; +} -inline void ClientImpl::set_proxy(const char *host, int port) { +inline void ClientImpl::set_proxy(const std::string &host, int port) { proxy_host_ = host; proxy_port_ = port; } -inline void ClientImpl::set_proxy_basic_auth(const char *username, - const char *password) { +inline void ClientImpl::set_proxy_basic_auth(const std::string &username, + const std::string &password) { proxy_basic_auth_username_ = username; proxy_basic_auth_password_ = password; } -inline void ClientImpl::set_proxy_bearer_token_auth(const char *token) { +inline void ClientImpl::set_proxy_bearer_token_auth(const std::string &token) { proxy_bearer_token_auth_token_ = token; } #ifdef CPPHTTPLIB_OPENSSL_SUPPORT -inline void ClientImpl::set_proxy_digest_auth(const char *username, - const char *password) { +inline void ClientImpl::set_proxy_digest_auth(const std::string &username, + const std::string &password) { proxy_digest_auth_username_ = username; proxy_digest_auth_password_ = password; } -#endif -#ifdef CPPHTTPLIB_OPENSSL_SUPPORT -inline void ClientImpl::set_ca_cert_path(const char *ca_cert_file_path, - const char *ca_cert_dir_path) { - if (ca_cert_file_path) { ca_cert_file_path_ = ca_cert_file_path; } - if (ca_cert_dir_path) { ca_cert_dir_path_ = ca_cert_dir_path; } +inline void ClientImpl::set_ca_cert_path(const std::string &ca_cert_file_path, + const std::string &ca_cert_dir_path) { + ca_cert_file_path_ = ca_cert_file_path; + ca_cert_dir_path_ = ca_cert_dir_path; } inline void ClientImpl::set_ca_cert_store(X509_STORE *ca_cert_store) { @@ -7038,9 +8172,34 @@ inline void ClientImpl::set_ca_cert_store(X509_STORE *ca_cert_store) { ca_cert_store_ = ca_cert_store; } } -#endif -#ifdef CPPHTTPLIB_OPENSSL_SUPPORT +inline X509_STORE *ClientImpl::create_ca_cert_store(const char *ca_cert, + std::size_t size) const { + auto mem = BIO_new_mem_buf(ca_cert, static_cast(size)); + if (!mem) { return nullptr; } + + auto inf = PEM_X509_INFO_read_bio(mem, nullptr, nullptr, nullptr); + if (!inf) { + BIO_free_all(mem); + return nullptr; + } + + auto cts = X509_STORE_new(); + if (cts) { + for (auto i = 0; i < static_cast(sk_X509_INFO_num(inf)); i++) { + auto itmp = sk_X509_INFO_value(inf, i); + if (!itmp) { continue; } + + if (itmp->x509) { X509_STORE_add_cert(cts, itmp->x509); } + if (itmp->crl) { X509_STORE_add_crl(cts, itmp->crl); } + } + } + + sk_X509_INFO_pop_free(inf, X509_INFO_free); + BIO_free_all(mem); + return cts; +} + inline void ClientImpl::enable_server_certificate_verification(bool enabled) { server_certificate_verification_ = enabled; } @@ -7104,7 +8263,7 @@ bool ssl_connect_or_accept_nonblocking(socket_t sock, SSL *ssl, U ssl_connect_or_accept, time_t timeout_sec, time_t timeout_usec) { - int res = 0; + auto res = 0; while ((res = ssl_connect_or_accept(ssl)) != 1) { auto err = SSL_get_error(ssl, res); switch (err) { @@ -7146,55 +8305,12 @@ process_client_socket_ssl(SSL *ssl, socket_t sock, time_t read_timeout_sec, return callback(strm); } -#if OPENSSL_VERSION_NUMBER < 0x10100000L -static std::shared_ptr> openSSL_locks_; - -class SSLThreadLocks { -public: - SSLThreadLocks() { - openSSL_locks_ = - std::make_shared>(CRYPTO_num_locks()); - CRYPTO_set_locking_callback(locking_callback); - } - - ~SSLThreadLocks() { CRYPTO_set_locking_callback(nullptr); } - -private: - static void locking_callback(int mode, int type, const char * /*file*/, - int /*line*/) { - auto &lk = (*openSSL_locks_)[static_cast(type)]; - if (mode & CRYPTO_LOCK) { - lk.lock(); - } else { - lk.unlock(); - } - } -}; - -#endif - class SSLInit { public: SSLInit() { -#if OPENSSL_VERSION_NUMBER < 0x1010001fL - SSL_load_error_strings(); - SSL_library_init(); -#else OPENSSL_init_ssl( OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL); -#endif - } - - ~SSLInit() { -#if OPENSSL_VERSION_NUMBER < 0x1010001fL - ERR_free_strings(); -#endif } - -private: -#if OPENSSL_VERSION_NUMBER < 0x10100000L - SSLThreadLocks thread_init_; -#endif }; // SSL socket stream implementation @@ -7210,75 +8326,77 @@ inline SSLSocketStream::SSLSocketStream(socket_t sock, SSL *ssl, SSL_clear_mode(ssl, SSL_MODE_AUTO_RETRY); } -inline SSLSocketStream::~SSLSocketStream() {} +inline SSLSocketStream::~SSLSocketStream() = default; inline bool SSLSocketStream::is_readable() const { return detail::select_read(sock_, read_timeout_sec_, read_timeout_usec_) > 0; } inline bool SSLSocketStream::is_writable() const { - return detail::select_write(sock_, write_timeout_sec_, write_timeout_usec_) > - 0; + return select_write(sock_, write_timeout_sec_, write_timeout_usec_) > 0 && + is_socket_alive(sock_); } inline ssize_t SSLSocketStream::read(char *ptr, size_t size) { - size_t readbytes = 0; if (SSL_pending(ssl_) > 0) { - auto ret = SSL_read_ex(ssl_, ptr, size, &readbytes); - if (ret == 1) { return static_cast(readbytes); } - if (SSL_get_error(ssl_, ret) == SSL_ERROR_ZERO_RETURN) { return 0; } - return -1; - } - if (!is_readable()) { return -1; } - - auto ret = SSL_read_ex(ssl_, ptr, size, &readbytes); - if (ret == 1) { return static_cast(readbytes); } - auto err = SSL_get_error(ssl_, ret); - int n = 1000; + return SSL_read(ssl_, ptr, static_cast(size)); + } else if (is_readable()) { + auto ret = SSL_read(ssl_, ptr, static_cast(size)); + if (ret < 0) { + auto err = SSL_get_error(ssl_, ret); + auto n = 1000; #ifdef _WIN32 - while (--n >= 0 && - (err == SSL_ERROR_WANT_READ || - (err == SSL_ERROR_SYSCALL && WSAGetLastError() == WSAETIMEDOUT))) { + while (--n >= 0 && (err == SSL_ERROR_WANT_READ || + (err == SSL_ERROR_SYSCALL && + WSAGetLastError() == WSAETIMEDOUT))) { #else - while (--n >= 0 && err == SSL_ERROR_WANT_READ) { + while (--n >= 0 && err == SSL_ERROR_WANT_READ) { #endif - if (SSL_pending(ssl_) > 0) { - ret = SSL_read_ex(ssl_, ptr, size, &readbytes); - if (ret == 1) { return static_cast(readbytes); } - if (SSL_get_error(ssl_, ret) == SSL_ERROR_ZERO_RETURN) { return 0; } - return -1; + if (SSL_pending(ssl_) > 0) { + return SSL_read(ssl_, ptr, static_cast(size)); + } else if (is_readable()) { + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + ret = SSL_read(ssl_, ptr, static_cast(size)); + if (ret >= 0) { return ret; } + err = SSL_get_error(ssl_, ret); + } else { + return -1; + } + } } - if (!is_readable()) { return -1; } - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - ret = SSL_read_ex(ssl_, ptr, size, &readbytes); - if (ret == 1) { return static_cast(readbytes); } - err = SSL_get_error(ssl_, ret); + return ret; } - if (err == SSL_ERROR_ZERO_RETURN) { return 0; } return -1; } inline ssize_t SSLSocketStream::write(const char *ptr, size_t size) { - if (!is_writable()) { return -1; } - size_t written = 0; - auto ret = SSL_write_ex(ssl_, ptr, size, &written); - if (ret == 1) { return static_cast(written); } - auto err = SSL_get_error(ssl_, ret); - int n = 1000; + if (is_writable()) { + auto handle_size = static_cast( + std::min(size, (std::numeric_limits::max)())); + + auto ret = SSL_write(ssl_, ptr, static_cast(handle_size)); + if (ret < 0) { + auto err = SSL_get_error(ssl_, ret); + auto n = 1000; #ifdef _WIN32 - while (--n >= 0 && - (err == SSL_ERROR_WANT_WRITE || - (err == SSL_ERROR_SYSCALL && WSAGetLastError() == WSAETIMEDOUT))) { + while (--n >= 0 && (err == SSL_ERROR_WANT_WRITE || + (err == SSL_ERROR_SYSCALL && + WSAGetLastError() == WSAETIMEDOUT))) { #else - while (--n >= 0 && err == SSL_ERROR_WANT_WRITE) { + while (--n >= 0 && err == SSL_ERROR_WANT_WRITE) { #endif - if (!is_writable()) { return -1; } - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - ret = SSL_write_ex(ssl_, ptr, size, &written); - if (ret == 1) { return static_cast(written); } - err = SSL_get_error(ssl_, ret); + if (is_writable()) { + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + ret = SSL_write(ssl_, ptr, static_cast(handle_size)); + if (ret >= 0) { return ret; } + err = SSL_get_error(ssl_, ret); + } else { + return -1; + } + } + } + return ret; } - if (err == SSL_ERROR_ZERO_RETURN) { return 0; } return -1; } @@ -7287,6 +8405,11 @@ inline void SSLSocketStream::get_remote_ip_and_port(std::string &ip, detail::get_remote_ip_and_port(sock_, ip, port); } +inline void SSLSocketStream::get_local_ip_and_port(std::string &ip, + int &port) const { + detail::get_local_ip_and_port(sock_, ip, port); +} + inline socket_t SSLSocketStream::socket() const { return sock_; } static SSLInit sslinit_; @@ -7309,8 +8432,9 @@ inline SSLServer::SSLServer(const char *cert_path, const char *private_key_path, // add default password callback before opening encrypted private key if (private_key_password != nullptr && (private_key_password[0] != '\0')) { - SSL_CTX_set_default_passwd_cb_userdata(ctx_, - (char *)private_key_password); + SSL_CTX_set_default_passwd_cb_userdata( + ctx_, + reinterpret_cast(const_cast(private_key_password))); } if (SSL_CTX_use_certificate_chain_file(ctx_, cert_path) != 1 || @@ -7374,13 +8498,13 @@ inline SSL_CTX *SSLServer::ssl_context() const { return ctx_; } inline bool SSLServer::process_and_close_socket(socket_t sock) { auto ssl = detail::ssl_new( sock, ctx_, ctx_mutex_, - [&](SSL *ssl) { + [&](SSL *ssl2) { return detail::ssl_connect_or_accept_nonblocking( - sock, ssl, SSL_accept, read_timeout_sec_, read_timeout_usec_); + sock, ssl2, SSL_accept, read_timeout_sec_, read_timeout_usec_); }, - [](SSL * /*ssl*/) { return true; }); + [](SSL * /*ssl2*/) { return true; }); - bool ret = false; + auto ret = false; if (ssl) { ret = detail::process_server_socket_ssl( svr_sock_, ssl, sock, keep_alive_max_count_, keep_alive_timeout_sec_, @@ -7418,7 +8542,7 @@ inline SSLClient::SSLClient(const std::string &host, int port, detail::split(&host_[0], &host_[host_.size()], '.', [&](const char *b, const char *e) { - host_components_.emplace_back(std::string(b, e)); + host_components_.emplace_back(b, e); }); if (!client_cert_path.empty() && !client_key_path.empty()) { @@ -7439,7 +8563,7 @@ inline SSLClient::SSLClient(const std::string &host, int port, detail::split(&host_[0], &host_[host_.size()], '.', [&](const char *b, const char *e) { - host_components_.emplace_back(std::string(b, e)); + host_components_.emplace_back(b, e); }); if (client_cert != nullptr && client_key != nullptr) { @@ -7474,6 +8598,11 @@ inline void SSLClient::set_ca_cert_store(X509_STORE *ca_cert_store) { } } +inline void SSLClient::load_ca_cert_store(const char *ca_cert, + std::size_t size) { + set_ca_cert_store(ClientImpl::create_ca_cert_store(ca_cert, size)); +} + inline long SSLClient::get_openssl_verify_result() const { return verify_result_; } @@ -7488,14 +8617,14 @@ inline bool SSLClient::create_and_connect_socket(Socket &socket, Error &error) { inline bool SSLClient::connect_with_proxy(Socket &socket, Response &res, bool &success, Error &error) { success = true; - Response res2; + Response proxy_res; if (!detail::process_client_socket( socket.sock, read_timeout_sec_, read_timeout_usec_, write_timeout_sec_, write_timeout_usec_, [&](Stream &strm) { Request req2; req2.method = "CONNECT"; req2.path = host_and_port_; - return process_request(strm, req2, res2, false, error); + return process_request(strm, req2, proxy_res, false, error); })) { // Thread-safe to close everything because we are assuming there are no // requests in flight @@ -7506,12 +8635,12 @@ inline bool SSLClient::connect_with_proxy(Socket &socket, Response &res, return false; } - if (res2.status == 407) { + if (proxy_res.status == StatusCode::ProxyAuthenticationRequired_407) { if (!proxy_digest_auth_username_.empty() && !proxy_digest_auth_password_.empty()) { std::map auth; - if (detail::parse_www_authenticate(res2, auth, true)) { - Response res3; + if (detail::parse_www_authenticate(proxy_res, auth, true)) { + proxy_res = Response(); if (!detail::process_client_socket( socket.sock, read_timeout_sec_, read_timeout_usec_, write_timeout_sec_, write_timeout_usec_, [&](Stream &strm) { @@ -7522,7 +8651,7 @@ inline bool SSLClient::connect_with_proxy(Socket &socket, Response &res, req3, auth, 1, detail::random_string(10), proxy_digest_auth_username_, proxy_digest_auth_password_, true)); - return process_request(strm, req3, res3, false, error); + return process_request(strm, req3, proxy_res, false, error); })) { // Thread-safe to close everything because we are assuming there are // no requests in flight @@ -7533,17 +8662,28 @@ inline bool SSLClient::connect_with_proxy(Socket &socket, Response &res, return false; } } - } else { - res = res2; - return false; } } + // If status code is not 200, proxy request is failed. + // Set error to ProxyConnection and return proxy response + // as the response of the request + if (proxy_res.status != StatusCode::OK_200) { + error = Error::ProxyConnection; + res = std::move(proxy_res); + // Thread-safe to close everything because we are assuming there are + // no requests in flight + shutdown_ssl(socket, true); + shutdown_socket(socket); + close_socket(socket); + return false; + } + return true; } inline bool SSLClient::load_certs() { - bool ret = true; + auto ret = true; std::call_once(initialize_cert_, [&]() { std::lock_guard guard(ctx_mutex_); @@ -7558,11 +8698,16 @@ inline bool SSLClient::load_certs() { ret = false; } } else { + auto loaded = false; #ifdef _WIN32 - detail::load_system_certs_on_windows(SSL_CTX_get_cert_store(ctx_)); -#else - SSL_CTX_set_default_verify_paths(ctx_); -#endif + loaded = + detail::load_system_certs_on_windows(SSL_CTX_get_cert_store(ctx_)); +#elif defined(CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN) && defined(__APPLE__) +#if TARGET_OS_OSX + loaded = detail::load_system_certs_on_macos(SSL_CTX_get_cert_store(ctx_)); +#endif // TARGET_OS_OSX +#endif // _WIN32 + if (!loaded) { SSL_CTX_set_default_verify_paths(ctx_); } } }); @@ -7572,31 +8717,31 @@ inline bool SSLClient::load_certs() { inline bool SSLClient::initialize_ssl(Socket &socket, Error &error) { auto ssl = detail::ssl_new( socket.sock, ctx_, ctx_mutex_, - [&](SSL *ssl) { + [&](SSL *ssl2) { if (server_certificate_verification_) { if (!load_certs()) { error = Error::SSLLoadingCerts; return false; } - SSL_set_verify(ssl, SSL_VERIFY_NONE, nullptr); + SSL_set_verify(ssl2, SSL_VERIFY_NONE, nullptr); } if (!detail::ssl_connect_or_accept_nonblocking( - socket.sock, ssl, SSL_connect, connection_timeout_sec_, + socket.sock, ssl2, SSL_connect, connection_timeout_sec_, connection_timeout_usec_)) { error = Error::SSLConnection; return false; } if (server_certificate_verification_) { - verify_result_ = SSL_get_verify_result(ssl); + verify_result_ = SSL_get_verify_result(ssl2); if (verify_result_ != X509_V_OK) { error = Error::SSLServerVerification; return false; } - auto server_cert = SSL_get_peer_certificate(ssl); + auto server_cert = SSL_get1_peer_certificate(ssl2); if (server_cert == nullptr) { error = Error::SSLServerVerification; @@ -7613,8 +8758,12 @@ inline bool SSLClient::initialize_ssl(Socket &socket, Error &error) { return true; }, - [&](SSL *ssl) { - SSL_set_tlsext_host_name(ssl, host_.c_str()); + [&](SSL *ssl2) { + // NOTE: Direct call instead of using the OpenSSL macro to suppress + // -Wold-style-cast warning + // SSL_set_tlsext_host_name(ssl2, host_.c_str()); + SSL_ctrl(ssl2, SSL_CTRL_SET_TLSEXT_HOSTNAME, TLSEXT_NAMETYPE_host_name, + static_cast(const_cast(host_.c_str()))); return true; }); @@ -7688,8 +8837,8 @@ SSLClient::verify_host_with_subject_alt_name(X509 *server_cert) const { auto type = GEN_DNS; - struct in6_addr addr6; - struct in_addr addr; + struct in6_addr addr6 {}; + struct in_addr addr {}; size_t addr_len = 0; #ifndef __MINGW32__ @@ -7707,15 +8856,16 @@ SSLClient::verify_host_with_subject_alt_name(X509 *server_cert) const { if (alt_names) { auto dsn_matched = false; - auto ip_mached = false; + auto ip_matched = false; auto count = sk_GENERAL_NAME_num(alt_names); for (decltype(count) i = 0; i < count && !dsn_matched; i++) { auto val = sk_GENERAL_NAME_value(alt_names, i); if (val->type == type) { - auto name = (const char *)ASN1_STRING_get0_data(val->d.ia5); - auto name_len = (size_t)ASN1_STRING_length(val->d.ia5); + auto name = + reinterpret_cast(ASN1_STRING_get0_data(val->d.ia5)); + auto name_len = static_cast(ASN1_STRING_length(val->d.ia5)); switch (type) { case GEN_DNS: dsn_matched = check_host_name(name, name_len); break; @@ -7723,17 +8873,18 @@ SSLClient::verify_host_with_subject_alt_name(X509 *server_cert) const { case GEN_IPADD: if (!memcmp(&addr6, name, addr_len) || !memcmp(&addr, name, addr_len)) { - ip_mached = true; + ip_matched = true; } break; } } } - if (dsn_matched || ip_mached) { ret = true; } + if (dsn_matched || ip_matched) { ret = true; } } - GENERAL_NAMES_free((STACK_OF(GENERAL_NAME) *)alt_names); + GENERAL_NAMES_free(const_cast( + reinterpret_cast(alt_names))); return ret; } @@ -7762,7 +8913,7 @@ inline bool SSLClient::check_host_name(const char *pattern, std::vector pattern_components; detail::split(&pattern[0], &pattern[pattern_len], '.', [&](const char *b, const char *e) { - pattern_components.emplace_back(std::string(b, e)); + pattern_components.emplace_back(b, e); }); if (host_components_.size() != pattern_components.size()) { return false; } @@ -7818,13 +8969,13 @@ inline Client::Client(const std::string &scheme_host_port, if (is_ssl) { #ifdef CPPHTTPLIB_OPENSSL_SUPPORT - cli_ = detail::make_unique(host.c_str(), port, - client_cert_path, client_key_path); + cli_ = detail::make_unique(host, port, client_cert_path, + client_key_path); is_ssl_ = is_ssl; #endif } else { - cli_ = detail::make_unique(host.c_str(), port, - client_cert_path, client_key_path); + cli_ = detail::make_unique(host, port, client_cert_path, + client_key_path); } } else { cli_ = detail::make_unique(scheme_host_port, 80, @@ -7841,257 +8992,302 @@ inline Client::Client(const std::string &host, int port, : cli_(detail::make_unique(host, port, client_cert_path, client_key_path)) {} -inline Client::~Client() {} +inline Client::~Client() = default; inline bool Client::is_valid() const { return cli_ != nullptr && cli_->is_valid(); } -inline Result Client::Get(const char *path) { return cli_->Get(path); } -inline Result Client::Get(const char *path, const Headers &headers) { +inline Result Client::Get(const std::string &path) { return cli_->Get(path); } +inline Result Client::Get(const std::string &path, const Headers &headers) { return cli_->Get(path, headers); } -inline Result Client::Get(const char *path, Progress progress) { +inline Result Client::Get(const std::string &path, Progress progress) { return cli_->Get(path, std::move(progress)); } -inline Result Client::Get(const char *path, const Headers &headers, +inline Result Client::Get(const std::string &path, const Headers &headers, Progress progress) { return cli_->Get(path, headers, std::move(progress)); } -inline Result Client::Get(const char *path, ContentReceiver content_receiver) { +inline Result Client::Get(const std::string &path, + ContentReceiver content_receiver) { return cli_->Get(path, std::move(content_receiver)); } -inline Result Client::Get(const char *path, const Headers &headers, +inline Result Client::Get(const std::string &path, const Headers &headers, ContentReceiver content_receiver) { return cli_->Get(path, headers, std::move(content_receiver)); } -inline Result Client::Get(const char *path, ContentReceiver content_receiver, - Progress progress) { +inline Result Client::Get(const std::string &path, + ContentReceiver content_receiver, Progress progress) { return cli_->Get(path, std::move(content_receiver), std::move(progress)); } -inline Result Client::Get(const char *path, const Headers &headers, +inline Result Client::Get(const std::string &path, const Headers &headers, ContentReceiver content_receiver, Progress progress) { return cli_->Get(path, headers, std::move(content_receiver), std::move(progress)); } -inline Result Client::Get(const char *path, ResponseHandler response_handler, +inline Result Client::Get(const std::string &path, + ResponseHandler response_handler, ContentReceiver content_receiver) { return cli_->Get(path, std::move(response_handler), std::move(content_receiver)); } -inline Result Client::Get(const char *path, const Headers &headers, +inline Result Client::Get(const std::string &path, const Headers &headers, ResponseHandler response_handler, ContentReceiver content_receiver) { return cli_->Get(path, headers, std::move(response_handler), std::move(content_receiver)); } -inline Result Client::Get(const char *path, ResponseHandler response_handler, +inline Result Client::Get(const std::string &path, + ResponseHandler response_handler, ContentReceiver content_receiver, Progress progress) { return cli_->Get(path, std::move(response_handler), std::move(content_receiver), std::move(progress)); } -inline Result Client::Get(const char *path, const Headers &headers, +inline Result Client::Get(const std::string &path, const Headers &headers, ResponseHandler response_handler, ContentReceiver content_receiver, Progress progress) { return cli_->Get(path, headers, std::move(response_handler), std::move(content_receiver), std::move(progress)); } -inline Result Client::Get(const char *path, const Params ¶ms, +inline Result Client::Get(const std::string &path, const Params ¶ms, const Headers &headers, Progress progress) { - return cli_->Get(path, params, headers, progress); + return cli_->Get(path, params, headers, std::move(progress)); } -inline Result Client::Get(const char *path, const Params ¶ms, +inline Result Client::Get(const std::string &path, const Params ¶ms, const Headers &headers, ContentReceiver content_receiver, Progress progress) { - return cli_->Get(path, params, headers, content_receiver, progress); + return cli_->Get(path, params, headers, std::move(content_receiver), + std::move(progress)); } -inline Result Client::Get(const char *path, const Params ¶ms, +inline Result Client::Get(const std::string &path, const Params ¶ms, const Headers &headers, ResponseHandler response_handler, ContentReceiver content_receiver, Progress progress) { - return cli_->Get(path, params, headers, response_handler, content_receiver, - progress); + return cli_->Get(path, params, headers, std::move(response_handler), + std::move(content_receiver), std::move(progress)); } -inline Result Client::Head(const char *path) { return cli_->Head(path); } -inline Result Client::Head(const char *path, const Headers &headers) { +inline Result Client::Head(const std::string &path) { return cli_->Head(path); } +inline Result Client::Head(const std::string &path, const Headers &headers) { return cli_->Head(path, headers); } -inline Result Client::Post(const char *path) { return cli_->Post(path); } -inline Result Client::Post(const char *path, const char *body, - size_t content_length, const char *content_type) { +inline Result Client::Post(const std::string &path) { return cli_->Post(path); } +inline Result Client::Post(const std::string &path, const Headers &headers) { + return cli_->Post(path, headers); +} +inline Result Client::Post(const std::string &path, const char *body, + size_t content_length, + const std::string &content_type) { return cli_->Post(path, body, content_length, content_type); } -inline Result Client::Post(const char *path, const Headers &headers, +inline Result Client::Post(const std::string &path, const Headers &headers, const char *body, size_t content_length, - const char *content_type) { + const std::string &content_type) { return cli_->Post(path, headers, body, content_length, content_type); } -inline Result Client::Post(const char *path, const std::string &body, - const char *content_type) { +inline Result Client::Post(const std::string &path, const std::string &body, + const std::string &content_type) { return cli_->Post(path, body, content_type); } -inline Result Client::Post(const char *path, const Headers &headers, - const std::string &body, const char *content_type) { +inline Result Client::Post(const std::string &path, const Headers &headers, + const std::string &body, + const std::string &content_type) { return cli_->Post(path, headers, body, content_type); } -inline Result Client::Post(const char *path, size_t content_length, +inline Result Client::Post(const std::string &path, size_t content_length, ContentProvider content_provider, - const char *content_type) { + const std::string &content_type) { return cli_->Post(path, content_length, std::move(content_provider), content_type); } -inline Result Client::Post(const char *path, +inline Result Client::Post(const std::string &path, ContentProviderWithoutLength content_provider, - const char *content_type) { + const std::string &content_type) { return cli_->Post(path, std::move(content_provider), content_type); } -inline Result Client::Post(const char *path, const Headers &headers, +inline Result Client::Post(const std::string &path, const Headers &headers, size_t content_length, ContentProvider content_provider, - const char *content_type) { + const std::string &content_type) { return cli_->Post(path, headers, content_length, std::move(content_provider), content_type); } -inline Result Client::Post(const char *path, const Headers &headers, +inline Result Client::Post(const std::string &path, const Headers &headers, ContentProviderWithoutLength content_provider, - const char *content_type) { + const std::string &content_type) { return cli_->Post(path, headers, std::move(content_provider), content_type); } -inline Result Client::Post(const char *path, const Params ¶ms) { +inline Result Client::Post(const std::string &path, const Params ¶ms) { return cli_->Post(path, params); } -inline Result Client::Post(const char *path, const Headers &headers, +inline Result Client::Post(const std::string &path, const Headers &headers, const Params ¶ms) { return cli_->Post(path, headers, params); } -inline Result Client::Post(const char *path, +inline Result Client::Post(const std::string &path, const MultipartFormDataItems &items) { return cli_->Post(path, items); } -inline Result Client::Post(const char *path, const Headers &headers, +inline Result Client::Post(const std::string &path, const Headers &headers, const MultipartFormDataItems &items) { return cli_->Post(path, headers, items); } -inline Result Client::Post(const char *path, const Headers &headers, +inline Result Client::Post(const std::string &path, const Headers &headers, const MultipartFormDataItems &items, const std::string &boundary) { return cli_->Post(path, headers, items, boundary); } -inline Result Client::Put(const char *path) { return cli_->Put(path); } -inline Result Client::Put(const char *path, const char *body, - size_t content_length, const char *content_type) { +inline Result +Client::Post(const std::string &path, const Headers &headers, + const MultipartFormDataItems &items, + const MultipartFormDataProviderItems &provider_items) { + return cli_->Post(path, headers, items, provider_items); +} +inline Result Client::Put(const std::string &path) { return cli_->Put(path); } +inline Result Client::Put(const std::string &path, const char *body, + size_t content_length, + const std::string &content_type) { return cli_->Put(path, body, content_length, content_type); } -inline Result Client::Put(const char *path, const Headers &headers, +inline Result Client::Put(const std::string &path, const Headers &headers, const char *body, size_t content_length, - const char *content_type) { + const std::string &content_type) { return cli_->Put(path, headers, body, content_length, content_type); } -inline Result Client::Put(const char *path, const std::string &body, - const char *content_type) { +inline Result Client::Put(const std::string &path, const std::string &body, + const std::string &content_type) { return cli_->Put(path, body, content_type); } -inline Result Client::Put(const char *path, const Headers &headers, - const std::string &body, const char *content_type) { +inline Result Client::Put(const std::string &path, const Headers &headers, + const std::string &body, + const std::string &content_type) { return cli_->Put(path, headers, body, content_type); } -inline Result Client::Put(const char *path, size_t content_length, +inline Result Client::Put(const std::string &path, size_t content_length, ContentProvider content_provider, - const char *content_type) { + const std::string &content_type) { return cli_->Put(path, content_length, std::move(content_provider), content_type); } -inline Result Client::Put(const char *path, +inline Result Client::Put(const std::string &path, ContentProviderWithoutLength content_provider, - const char *content_type) { + const std::string &content_type) { return cli_->Put(path, std::move(content_provider), content_type); } -inline Result Client::Put(const char *path, const Headers &headers, +inline Result Client::Put(const std::string &path, const Headers &headers, size_t content_length, ContentProvider content_provider, - const char *content_type) { + const std::string &content_type) { return cli_->Put(path, headers, content_length, std::move(content_provider), content_type); } -inline Result Client::Put(const char *path, const Headers &headers, +inline Result Client::Put(const std::string &path, const Headers &headers, ContentProviderWithoutLength content_provider, - const char *content_type) { + const std::string &content_type) { return cli_->Put(path, headers, std::move(content_provider), content_type); } -inline Result Client::Put(const char *path, const Params ¶ms) { +inline Result Client::Put(const std::string &path, const Params ¶ms) { return cli_->Put(path, params); } -inline Result Client::Put(const char *path, const Headers &headers, +inline Result Client::Put(const std::string &path, const Headers &headers, const Params ¶ms) { return cli_->Put(path, headers, params); } -inline Result Client::Patch(const char *path) { return cli_->Patch(path); } -inline Result Client::Patch(const char *path, const char *body, - size_t content_length, const char *content_type) { +inline Result Client::Put(const std::string &path, + const MultipartFormDataItems &items) { + return cli_->Put(path, items); +} +inline Result Client::Put(const std::string &path, const Headers &headers, + const MultipartFormDataItems &items) { + return cli_->Put(path, headers, items); +} +inline Result Client::Put(const std::string &path, const Headers &headers, + const MultipartFormDataItems &items, + const std::string &boundary) { + return cli_->Put(path, headers, items, boundary); +} +inline Result +Client::Put(const std::string &path, const Headers &headers, + const MultipartFormDataItems &items, + const MultipartFormDataProviderItems &provider_items) { + return cli_->Put(path, headers, items, provider_items); +} +inline Result Client::Patch(const std::string &path) { + return cli_->Patch(path); +} +inline Result Client::Patch(const std::string &path, const char *body, + size_t content_length, + const std::string &content_type) { return cli_->Patch(path, body, content_length, content_type); } -inline Result Client::Patch(const char *path, const Headers &headers, +inline Result Client::Patch(const std::string &path, const Headers &headers, const char *body, size_t content_length, - const char *content_type) { + const std::string &content_type) { return cli_->Patch(path, headers, body, content_length, content_type); } -inline Result Client::Patch(const char *path, const std::string &body, - const char *content_type) { +inline Result Client::Patch(const std::string &path, const std::string &body, + const std::string &content_type) { return cli_->Patch(path, body, content_type); } -inline Result Client::Patch(const char *path, const Headers &headers, - const std::string &body, const char *content_type) { +inline Result Client::Patch(const std::string &path, const Headers &headers, + const std::string &body, + const std::string &content_type) { return cli_->Patch(path, headers, body, content_type); } -inline Result Client::Patch(const char *path, size_t content_length, +inline Result Client::Patch(const std::string &path, size_t content_length, ContentProvider content_provider, - const char *content_type) { + const std::string &content_type) { return cli_->Patch(path, content_length, std::move(content_provider), content_type); } -inline Result Client::Patch(const char *path, +inline Result Client::Patch(const std::string &path, ContentProviderWithoutLength content_provider, - const char *content_type) { + const std::string &content_type) { return cli_->Patch(path, std::move(content_provider), content_type); } -inline Result Client::Patch(const char *path, const Headers &headers, +inline Result Client::Patch(const std::string &path, const Headers &headers, size_t content_length, ContentProvider content_provider, - const char *content_type) { + const std::string &content_type) { return cli_->Patch(path, headers, content_length, std::move(content_provider), content_type); } -inline Result Client::Patch(const char *path, const Headers &headers, +inline Result Client::Patch(const std::string &path, const Headers &headers, ContentProviderWithoutLength content_provider, - const char *content_type) { + const std::string &content_type) { return cli_->Patch(path, headers, std::move(content_provider), content_type); } -inline Result Client::Delete(const char *path) { return cli_->Delete(path); } -inline Result Client::Delete(const char *path, const Headers &headers) { +inline Result Client::Delete(const std::string &path) { + return cli_->Delete(path); +} +inline Result Client::Delete(const std::string &path, const Headers &headers) { return cli_->Delete(path, headers); } -inline Result Client::Delete(const char *path, const char *body, - size_t content_length, const char *content_type) { +inline Result Client::Delete(const std::string &path, const char *body, + size_t content_length, + const std::string &content_type) { return cli_->Delete(path, body, content_length, content_type); } -inline Result Client::Delete(const char *path, const Headers &headers, +inline Result Client::Delete(const std::string &path, const Headers &headers, const char *body, size_t content_length, - const char *content_type) { + const std::string &content_type) { return cli_->Delete(path, headers, body, content_length, content_type); } -inline Result Client::Delete(const char *path, const std::string &body, - const char *content_type) { +inline Result Client::Delete(const std::string &path, const std::string &body, + const std::string &content_type) { return cli_->Delete(path, body, content_type); } -inline Result Client::Delete(const char *path, const Headers &headers, +inline Result Client::Delete(const std::string &path, const Headers &headers, const std::string &body, - const char *content_type) { + const std::string &content_type) { return cli_->Delete(path, headers, body, content_type); } -inline Result Client::Options(const char *path) { return cli_->Options(path); } -inline Result Client::Options(const char *path, const Headers &headers) { +inline Result Client::Options(const std::string &path) { + return cli_->Options(path); +} +inline Result Client::Options(const std::string &path, const Headers &headers) { return cli_->Options(path, headers); } @@ -8101,9 +9297,15 @@ inline bool Client::send(Request &req, Response &res, Error &error) { inline Result Client::send(const Request &req) { return cli_->send(req); } +inline void Client::stop() { cli_->stop(); } + +inline std::string Client::host() const { return cli_->host(); } + +inline int Client::port() const { return cli_->port(); } + inline size_t Client::is_socket_open() const { return cli_->is_socket_open(); } -inline void Client::stop() { cli_->stop(); } +inline socket_t Client::socket() const { return cli_->socket(); } inline void Client::set_hostname_addr_map(std::map addr_map) { @@ -8114,6 +9316,11 @@ inline void Client::set_default_headers(Headers headers) { cli_->set_default_headers(std::move(headers)); } +inline void Client::set_header_writer( + std::function const &writer) { + cli_->set_header_writer(writer); +} + inline void Client::set_address_family(int family) { cli_->set_address_family(family); } @@ -8136,15 +9343,16 @@ inline void Client::set_write_timeout(time_t sec, time_t usec) { cli_->set_write_timeout(sec, usec); } -inline void Client::set_basic_auth(const char *username, const char *password) { +inline void Client::set_basic_auth(const std::string &username, + const std::string &password) { cli_->set_basic_auth(username, password); } -inline void Client::set_bearer_token_auth(const char *token) { +inline void Client::set_bearer_token_auth(const std::string &token) { cli_->set_bearer_token_auth(token); } #ifdef CPPHTTPLIB_OPENSSL_SUPPORT -inline void Client::set_digest_auth(const char *username, - const char *password) { +inline void Client::set_digest_auth(const std::string &username, + const std::string &password) { cli_->set_digest_auth(username, password); } #endif @@ -8160,23 +9368,23 @@ inline void Client::set_compress(bool on) { cli_->set_compress(on); } inline void Client::set_decompress(bool on) { cli_->set_decompress(on); } -inline void Client::set_interface(const char *intf) { +inline void Client::set_interface(const std::string &intf) { cli_->set_interface(intf); } -inline void Client::set_proxy(const char *host, int port) { +inline void Client::set_proxy(const std::string &host, int port) { cli_->set_proxy(host, port); } -inline void Client::set_proxy_basic_auth(const char *username, - const char *password) { +inline void Client::set_proxy_basic_auth(const std::string &username, + const std::string &password) { cli_->set_proxy_basic_auth(username, password); } -inline void Client::set_proxy_bearer_token_auth(const char *token) { +inline void Client::set_proxy_bearer_token_auth(const std::string &token) { cli_->set_proxy_bearer_token_auth(token); } #ifdef CPPHTTPLIB_OPENSSL_SUPPORT -inline void Client::set_proxy_digest_auth(const char *username, - const char *password) { +inline void Client::set_proxy_digest_auth(const std::string &username, + const std::string &password) { cli_->set_proxy_digest_auth(username, password); } #endif @@ -8187,11 +9395,13 @@ inline void Client::enable_server_certificate_verification(bool enabled) { } #endif -inline void Client::set_logger(Logger logger) { cli_->set_logger(logger); } +inline void Client::set_logger(Logger logger) { + cli_->set_logger(std::move(logger)); +} #ifdef CPPHTTPLIB_OPENSSL_SUPPORT -inline void Client::set_ca_cert_path(const char *ca_cert_file_path, - const char *ca_cert_dir_path) { +inline void Client::set_ca_cert_path(const std::string &ca_cert_file_path, + const std::string &ca_cert_dir_path) { cli_->set_ca_cert_path(ca_cert_file_path, ca_cert_dir_path); } @@ -8203,6 +9413,10 @@ inline void Client::set_ca_cert_store(X509_STORE *ca_cert_store) { } } +inline void Client::load_ca_cert_store(const char *ca_cert, std::size_t size) { + set_ca_cert_store(cli_->create_ca_cert_store(ca_cert, size)); +} + inline long Client::get_openssl_verify_result() const { if (is_ssl_) { return static_cast(*cli_).get_openssl_verify_result(); @@ -8220,4 +9434,8 @@ inline SSL_CTX *Client::ssl_context() const { } // namespace httplib +#if defined(_WIN32) && defined(CPPHTTPLIB_USE_POLL) +#undef poll +#endif + #endif // CPPHTTPLIB_HTTPLIB_H diff --git a/external_imported/cpp-httplib/httplibConfig.cmake.in b/external_imported/cpp-httplib/httplibConfig.cmake.in index 4cd5ebf72..93dff323d 100644 --- a/external_imported/cpp-httplib/httplibConfig.cmake.in +++ b/external_imported/cpp-httplib/httplibConfig.cmake.in @@ -12,19 +12,19 @@ set(HTTPLIB_VERSION @PROJECT_VERSION@) include(CMakeFindDependencyMacro) # We add find_dependency calls here to not make the end-user have to call them. -find_dependency(Threads REQUIRED) +find_dependency(Threads) if(@HTTPLIB_IS_USING_OPENSSL@) # OpenSSL COMPONENTS were added in Cmake v3.11 if(CMAKE_VERSION VERSION_LESS "3.11") - find_dependency(OpenSSL @_HTTPLIB_OPENSSL_MIN_VER@ REQUIRED) + find_dependency(OpenSSL @_HTTPLIB_OPENSSL_MIN_VER@) else() # Once the COMPONENTS were added, they were made optional when not specified. # Since we use both, we need to search for both. - find_dependency(OpenSSL @_HTTPLIB_OPENSSL_MIN_VER@ COMPONENTS Crypto SSL REQUIRED) + find_dependency(OpenSSL @_HTTPLIB_OPENSSL_MIN_VER@ COMPONENTS Crypto SSL) endif() endif() if(@HTTPLIB_IS_USING_ZLIB@) - find_dependency(ZLIB REQUIRED) + find_dependency(ZLIB) endif() if(@HTTPLIB_IS_USING_BROTLI@) @@ -32,7 +32,7 @@ if(@HTTPLIB_IS_USING_BROTLI@) # Note that the FindBrotli.cmake file is installed in the same dir as this file. list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") set(BROTLI_USE_STATIC_LIBS @BROTLI_USE_STATIC_LIBS@) - find_dependency(Brotli COMPONENTS common encoder decoder REQUIRED) + find_dependency(Brotli COMPONENTS common encoder decoder) endif() # Mildly useful for end-users @@ -42,10 +42,19 @@ set_and_check(HTTPLIB_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@") # This is helpful if you're using Cmake's pre-compiled header feature set_and_check(HTTPLIB_HEADER_PATH "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@/httplib.h") -# Brings in the target library -include("${CMAKE_CURRENT_LIST_DIR}/httplibTargets.cmake") +# Consider each library support as a "component" +set(httplib_OpenSSL_FOUND @HTTPLIB_IS_USING_OPENSSL@) +set(httplib_ZLIB_FOUND @HTTPLIB_IS_USING_ZLIB@) +set(httplib_Brotli_FOUND @HTTPLIB_IS_USING_BROTLI@) -# Ouputs a "found httplib /usr/include/httplib.h" message when using find_package(httplib) +check_required_components(httplib) + +# Brings in the target library, but only if all required components are found +if(NOT DEFINED httplib_FOUND OR httplib_FOUND) + include("${CMAKE_CURRENT_LIST_DIR}/httplibTargets.cmake") +endif() + +# Outputs a "found httplib /usr/include/httplib.h" message when using find_package(httplib) include(FindPackageMessage) if(TARGET httplib::httplib) set(HTTPLIB_FOUND TRUE) diff --git a/external_imported/cpp-httplib/meson.build b/external_imported/cpp-httplib/meson.build index 961777e63..e82ae8451 100644 --- a/external_imported/cpp-httplib/meson.build +++ b/external_imported/cpp-httplib/meson.build @@ -19,7 +19,6 @@ project( # Check just in case downstream decides to edit the source # and add a project version version = meson.project_version() -python3 = find_program('python3') if version == 'undefined' cxx = meson.get_compiler('cpp') version = cxx.get_define('CPPHTTPLIB_VERSION', @@ -28,15 +27,20 @@ if version == 'undefined' assert(version != '', 'failed to get version from httplib.h') endif -message('cpp-httplib version ' + version) - deps = [dependency('threads')] args = [] -openssl_dep = dependency('openssl', version: '>=1.1.1', required: get_option('cpp-httplib_openssl')) +openssl_dep = dependency('openssl', version: '>=3.0.0', required: get_option('cpp-httplib_openssl')) if openssl_dep.found() deps += openssl_dep args += '-DCPPHTTPLIB_OPENSSL_SUPPORT' + if host_machine.system() == 'darwin' + macosx_keychain_dep = dependency('appleframeworks', modules: ['CoreFoundation', 'Security'], required: get_option('cpp-httplib_macosx_keychain')) + if macosx_keychain_dep.found() + deps += macosx_keychain_dep + args += '-DCPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN' + endif + endif endif zlib_dep = dependency('zlib', required: get_option('cpp-httplib_zlib')) @@ -64,6 +68,8 @@ endif cpp_httplib_dep = dependency('', required: false) if get_option('cpp-httplib_compile') + python3 = find_program('python3') + httplib_ch = custom_target( 'split', input: 'httplib.h', @@ -78,6 +84,7 @@ if get_option('cpp-httplib_compile') dependencies: deps, cpp_args: args, version: version, + soversion: version.split('.')[0] + '.' + version.split('.')[1], install: true ) cpp_httplib_dep = declare_dependency(compile_args: args, dependencies: deps, link_with: lib, sources: httplib_ch[1]) diff --git a/external_imported/cpp-httplib/meson_options.txt b/external_imported/cpp-httplib/meson_options.txt index 6f6d9240f..e15847d42 100644 --- a/external_imported/cpp-httplib/meson_options.txt +++ b/external_imported/cpp-httplib/meson_options.txt @@ -5,5 +5,6 @@ option('cpp-httplib_openssl', type: 'feature', value: 'auto', description: 'Enable OpenSSL support') option('cpp-httplib_zlib', type: 'feature', value: 'auto', description: 'Enable zlib support') option('cpp-httplib_brotli', type: 'feature', value: 'auto', description: 'Enable Brotli support') -option('cpp-httplib_compile', type: 'boolean', value: false, description: 'Split the header into a compilable header & source file') +option('cpp-httplib_macosx_keychain', type: 'feature', value: 'auto', description: 'Enable loading certs from the Keychain on Apple devices') +option('cpp-httplib_compile', type: 'boolean', value: false, description: 'Split the header into a compilable header & source file (requires python3)') option('cpp-httplib_test', type: 'boolean', value: false, description: 'Build tests') diff --git a/external_imported/cpp-httplib/test/CMakeLists.txt b/external_imported/cpp-httplib/test/CMakeLists.txt new file mode 100644 index 000000000..3cf2c24d8 --- /dev/null +++ b/external_imported/cpp-httplib/test/CMakeLists.txt @@ -0,0 +1,106 @@ +find_package(GTest) + +if(GTest_FOUND) + if(NOT TARGET GTest::gtest_main AND TARGET GTest::Main) + # CMake <3.20 + add_library(GTest::gtest_main INTERFACE IMPORTED) + target_link_libraries(GTest::gtest_main INTERFACE GTest::Main) + endif() +else() + if(POLICY CMP0135) + cmake_policy(SET CMP0135 NEW) + endif() + + include(FetchContent) + + set(BUILD_GMOCK OFF) + set(INSTALL_GTEST OFF) + set(gtest_force_shared_crt ON) + + FetchContent_Declare( + gtest + URL https://github.com/google/googletest/archive/main.tar.gz + ) + FetchContent_MakeAvailable(gtest) +endif() + +add_executable(httplib-test test.cc) +target_compile_options(httplib-test PRIVATE "$<$:/utf-8;/bigobj>") +target_link_libraries(httplib-test PRIVATE httplib GTest::gtest_main) +gtest_discover_tests(httplib-test) + +execute_process( + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_LIST_DIR}/www www + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_LIST_DIR}/www2 www2 + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_LIST_DIR}/www3 www3 + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_LIST_DIR}/ca-bundle.crt ca-bundle.crt + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_LIST_DIR}/image.jpg image.jpg + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND_ERROR_IS_FATAL ANY +) + +if(HTTPLIB_IS_USING_OPENSSL) + find_program(OPENSSL_COMMAND + NAMES openssl + PATHS ${OPENSSL_INCLUDE_DIR}/../bin + REQUIRED + ) + execute_process( + COMMAND ${OPENSSL_COMMAND} genrsa 2048 + OUTPUT_FILE key.pem + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND_ERROR_IS_FATAL ANY + ) + execute_process( + COMMAND ${OPENSSL_COMMAND} req -new -batch -config ${CMAKE_CURRENT_LIST_DIR}/test.conf -key key.pem + COMMAND ${OPENSSL_COMMAND} x509 -days 3650 -req -signkey key.pem + OUTPUT_FILE cert.pem + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND_ERROR_IS_FATAL ANY + ) + execute_process( + COMMAND ${OPENSSL_COMMAND} req -x509 -new -config ${CMAKE_CURRENT_LIST_DIR}/test.conf -key key.pem -sha256 -days 3650 -nodes -out cert2.pem -extensions SAN + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND_ERROR_IS_FATAL ANY + ) + execute_process( + COMMAND ${OPENSSL_COMMAND} genrsa 2048 + OUTPUT_FILE rootCA.key.pem + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND_ERROR_IS_FATAL ANY + ) + execute_process( + COMMAND ${OPENSSL_COMMAND} req -x509 -new -batch -config ${CMAKE_CURRENT_LIST_DIR}/test.rootCA.conf -key rootCA.key.pem -days 1024 + OUTPUT_FILE rootCA.cert.pem + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND_ERROR_IS_FATAL ANY + ) + execute_process( + COMMAND ${OPENSSL_COMMAND} genrsa 2048 + OUTPUT_FILE client.key.pem + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND_ERROR_IS_FATAL ANY + ) + execute_process( + COMMAND ${OPENSSL_COMMAND} req -new -batch -config ${CMAKE_CURRENT_LIST_DIR}/test.conf -key client.key.pem + COMMAND ${OPENSSL_COMMAND} x509 -days 370 -req -CA rootCA.cert.pem -CAkey rootCA.key.pem -CAcreateserial + OUTPUT_FILE client.cert.pem + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND_ERROR_IS_FATAL ANY + ) + execute_process( + COMMAND ${OPENSSL_COMMAND} genrsa -passout pass:test123! 2048 + OUTPUT_FILE key_encrypted.pem + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND_ERROR_IS_FATAL ANY + ) + execute_process( + COMMAND ${OPENSSL_COMMAND} req -new -batch -config ${CMAKE_CURRENT_LIST_DIR}/test.conf -key key_encrypted.pem + COMMAND ${OPENSSL_COMMAND} x509 -days 3650 -req -signkey key_encrypted.pem + OUTPUT_FILE cert_encrypted.pem + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND_ERROR_IS_FATAL ANY + ) +endif() + +add_subdirectory(fuzzing) diff --git a/external_imported/cpp-httplib/test/Makefile b/external_imported/cpp-httplib/test/Makefile index e75ab5b63..3b72d209f 100644 --- a/external_imported/cpp-httplib/test/Makefile +++ b/external_imported/cpp-httplib/test/Makefile @@ -1,13 +1,19 @@ CXX = clang++ -CXXFLAGS = -g -std=c++11 -I. -Wall -Wextra -Wtype-limits -Wconversion # -fno-exceptions -DCPPHTTPLIB_NO_EXCEPTIONS -fsanitize=address +CXXFLAGS = -g -std=c++11 -I. -Wall -Wextra -Wtype-limits -Wconversion -Wshadow # -fno-exceptions -DCPPHTTPLIB_NO_EXCEPTIONS -fsanitize=address PREFIX = /usr/local #PREFIX = $(shell brew --prefix) -OPENSSL_DIR = $(PREFIX)/opt/openssl@1.1 -#OPENSSL_DIR = $(PREFIX)/opt/openssl@3 +OPENSSL_DIR = $(PREFIX)/opt/openssl@3 OPENSSL_SUPPORT = -DCPPHTTPLIB_OPENSSL_SUPPORT -I$(OPENSSL_DIR)/include -L$(OPENSSL_DIR)/lib -lssl -lcrypto +ifneq ($(OS), Windows_NT) + UNAME_S := $(shell uname -s) + ifeq ($(UNAME_S), Darwin) + OPENSSL_SUPPORT += -DCPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN -framework CoreFoundation -framework Security + endif +endif + ZLIB_SUPPORT = -DCPPHTTPLIB_ZLIB_SUPPORT -lz BROTLI_DIR = $(PREFIX)/opt/brotli diff --git a/external_imported/cpp-httplib/test/fuzzing/CMakeLists.txt b/external_imported/cpp-httplib/test/fuzzing/CMakeLists.txt new file mode 100644 index 000000000..7e416c7eb --- /dev/null +++ b/external_imported/cpp-httplib/test/fuzzing/CMakeLists.txt @@ -0,0 +1,10 @@ +file(GLOB HTTPLIB_CORPUS corpus/*) +add_executable(httplib-test-fuzz + server_fuzzer.cc + standalone_fuzz_target_runner.cpp +) +target_link_libraries(httplib-test-fuzz PRIVATE httplib) +add_test( + NAME httplib-test-fuzz + COMMAND httplib-test-fuzz ${HTTPLIB_CORPUS} +) diff --git a/external_imported/cpp-httplib/test/fuzzing/corpus/clusterfuzz-testcase-minimized-server_fuzzer-5042094968537088 b/external_imported/cpp-httplib/test/fuzzing/corpus/clusterfuzz-testcase-minimized-server_fuzzer-5042094968537088 new file mode 100644 index 000000000..032572903 Binary files /dev/null and b/external_imported/cpp-httplib/test/fuzzing/corpus/clusterfuzz-testcase-minimized-server_fuzzer-5042094968537088 differ diff --git a/external_imported/cpp-httplib/test/fuzzing/corpus/clusterfuzz-testcase-minimized-server_fuzzer-5886572146327552 b/external_imported/cpp-httplib/test/fuzzing/corpus/clusterfuzz-testcase-minimized-server_fuzzer-5886572146327552 new file mode 100644 index 000000000..797165c50 Binary files /dev/null and b/external_imported/cpp-httplib/test/fuzzing/corpus/clusterfuzz-testcase-minimized-server_fuzzer-5886572146327552 differ diff --git a/external_imported/cpp-httplib/test/fuzzing/corpus/clusterfuzz-testcase-minimized-server_fuzzer-6007379124158464 b/external_imported/cpp-httplib/test/fuzzing/corpus/clusterfuzz-testcase-minimized-server_fuzzer-6007379124158464 new file mode 100644 index 000000000..4c4c57e81 Binary files /dev/null and b/external_imported/cpp-httplib/test/fuzzing/corpus/clusterfuzz-testcase-minimized-server_fuzzer-6007379124158464 differ diff --git a/external_imported/cpp-httplib/test/fuzzing/corpus/issue1264 b/external_imported/cpp-httplib/test/fuzzing/corpus/issue1264 new file mode 100644 index 000000000..fd53db5c9 --- /dev/null +++ b/external_imported/cpp-httplib/test/fuzzing/corpus/issue1264 @@ -0,0 +1,19 @@ +POST /fform%u008anoÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔãm%u08ag HTTP/1.0 +DondntGnt-Encodin€z-daExpi%20-Enëv2PUT@ËHTkP/ +Rcnðÿÿÿÿÿÿ ,Cotent-Security-Pz-tes=T“peont.eµ-Typ ènt-Ty@n/***ww-form-urlenc…Tÿû?aLO%KSi@FrÇTTP/1.0 +Cofffffffffffffffffffffffntemt + + + + + +Content-Length:dent:applica;tion/x-wsw-form%`00368aogrlencod368angrlencoded +JJ` +o + +8ÿõContent-EncodxNg:deflatePtipfo + +8 +9Ö2H2  ncod368anPOST # HTTP/1.0 Content-Encoding:defPOST / HTTP/1.0 +Content-Encoding:PUT { HTTP/1.0 +Content-Type:Range:bytes=- multipart/ \ No newline at end of file diff --git a/external_imported/cpp-httplib/test/fuzzing/server_fuzzer.cc b/external_imported/cpp-httplib/test/fuzzing/server_fuzzer.cc index 9fb4d4b61..3c0e94802 100644 --- a/external_imported/cpp-httplib/test/fuzzing/server_fuzzer.cc +++ b/external_imported/cpp-httplib/test/fuzzing/server_fuzzer.cc @@ -1,5 +1,6 @@ +#include + #include -#include class FuzzedStream : public httplib::Stream { public: @@ -22,8 +23,6 @@ class FuzzedStream : public httplib::Stream { ssize_t write(const std::string &s) { return write(s.data(), s.size()); } - std::string get_remote_addr() const { return ""; } - bool is_readable() const override { return true; } bool is_writable() const override { return true; } @@ -33,6 +32,11 @@ class FuzzedStream : public httplib::Stream { port = 8080; } + void get_local_ip_and_port(std::string &ip, int &port) const override { + ip = "127.0.0.1"; + port = 8080; + } + socket_t socket() const override { return 0; } private: diff --git a/external_imported/cpp-httplib/test/fuzzing/standalone_fuzz_target_runner.cpp b/external_imported/cpp-httplib/test/fuzzing/standalone_fuzz_target_runner.cpp index 733737bcf..e8bd5ed6e 100644 --- a/external_imported/cpp-httplib/test/fuzzing/standalone_fuzz_target_runner.cpp +++ b/external_imported/cpp-httplib/test/fuzzing/standalone_fuzz_target_runner.cpp @@ -5,13 +5,13 @@ // on the test corpus or on a single file, // e.g. the one that comes from a bug report. -#include -#include +#include #include +#include #include // Forward declare the "fuzz target" interface. -// We deliberately keep this inteface simple and header-free. +// We deliberately keep this interface simple and header-free. extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); // It reads all files passed as parameters and feeds their contents @@ -21,7 +21,7 @@ int main(int argc, char **argv) { std::ifstream in(argv[i]); in.seekg(0, in.end); size_t length = static_cast(in.tellg()); - in.seekg (0, in.beg); + in.seekg(0, in.beg); std::cout << "Reading " << length << " bytes from " << argv[i] << std::endl; // Allocate exactly length bytes so that we reliably catch buffer overflows. std::vector bytes(length); diff --git a/external_imported/cpp-httplib/test/gtest/gtest-all.cc b/external_imported/cpp-httplib/test/gtest/gtest-all.cc index eb8fa17c8..24e669e1e 100644 --- a/external_imported/cpp-httplib/test/gtest/gtest-all.cc +++ b/external_imported/cpp-httplib/test/gtest/gtest-all.cc @@ -1912,7 +1912,7 @@ void AssertHelper::operator=(const Message& message) const { namespace { // When TEST_P is found without a matching INSTANTIATE_TEST_SUITE_P -// to creates test cases for it, a syntetic test case is +// to creates test cases for it, a synthetic test case is // inserted to report ether an error or a log message. // // This configuration bit will likely be removed at some point. diff --git a/external_imported/cpp-httplib/test/meson.build b/external_imported/cpp-httplib/test/meson.build index 293ba0563..a83360d5c 100644 --- a/external_imported/cpp-httplib/test/meson.build +++ b/external_imported/cpp-httplib/test/meson.build @@ -86,6 +86,12 @@ subdir(join_paths('www', 'dir')) subdir(join_paths('www2', 'dir')) subdir(join_paths('www3', 'dir')) +# GoogleTest 1.13.0 requires C++14 +test_options = [] +if gtest_dep.version().version_compare('>=1.13.0') + test_options += 'cpp_std=c++14' +endif + test( 'main', executable( @@ -94,7 +100,8 @@ test( dependencies: [ cpp_httplib_dep, gtest_dep - ] + ], + override_options: test_options ), depends: [ key_pem, diff --git a/external_imported/cpp-httplib/test/test.cc b/external_imported/cpp-httplib/test/test.cc index d7257ee7a..64fc8f289 100644 --- a/external_imported/cpp-httplib/test/test.cc +++ b/external_imported/cpp-httplib/test/test.cc @@ -1,10 +1,12 @@ #include +#include #include #include #include #include +#include #include #include #include @@ -44,7 +46,7 @@ MultipartFormData &get_file_value(MultipartFormDataItems &files, return *it; #else if (it != files.end()) { return *it; } - throw std::runtime_error("invalid mulitpart form data name error"); + throw std::runtime_error("invalid multipart form data name error"); #endif } @@ -69,6 +71,15 @@ TEST(DecodeURLTest, PercentCharacter) { R"(descrip=Gastos áéíóúñÑ 6)"); } +TEST(DecodeURLTest, PercentCharacterNUL) { + string expected; + expected.push_back('x'); + expected.push_back('\0'); + expected.push_back('x'); + + EXPECT_EQ(detail::decode_url("x%00x", false), expected); +} + TEST(EncodeQueryParamTest, ParseUnescapedChararactersTest) { string unescapedCharacters = "-_.!~*'()"; @@ -109,11 +120,11 @@ TEST(SplitTest, ParseQueryString) { detail::split(s.c_str(), s.c_str() + s.size(), '&', [&](const char *b, const char *e) { string key, val; - detail::split(b, e, '=', [&](const char *b, const char *e) { + detail::split(b, e, '=', [&](const char *b2, const char *e2) { if (key.empty()) { - key.assign(b, e); + key.assign(b2, e2); } else { - val.assign(b, e); + val.assign(b2, e2); } }); dic.emplace(key, val); @@ -167,6 +178,40 @@ TEST(ParamsToQueryTest, ConvertParamsToQuery) { EXPECT_EQ(detail::params_to_query_str(dic), "key1=val1&key2=val2&key3=val3"); } +TEST(ParseMultipartBoundaryTest, DefaultValue) { + string content_type = "multipart/form-data; boundary=something"; + string boundary; + auto ret = detail::parse_multipart_boundary(content_type, boundary); + EXPECT_TRUE(ret); + EXPECT_EQ(boundary, "something"); +} + +TEST(ParseMultipartBoundaryTest, ValueWithQuote) { + string content_type = "multipart/form-data; boundary=\"gc0pJq0M:08jU534c0p\""; + string boundary; + auto ret = detail::parse_multipart_boundary(content_type, boundary); + EXPECT_TRUE(ret); + EXPECT_EQ(boundary, "gc0pJq0M:08jU534c0p"); +} + +TEST(ParseMultipartBoundaryTest, ValueWithCharset) { + string content_type = + "multipart/mixed; boundary=THIS_STRING_SEPARATES;charset=UTF-8"; + string boundary; + auto ret = detail::parse_multipart_boundary(content_type, boundary); + EXPECT_TRUE(ret); + EXPECT_EQ(boundary, "THIS_STRING_SEPARATES"); +} + +TEST(ParseMultipartBoundaryTest, ValueWithQuotesAndCharset) { + string content_type = + "multipart/mixed; boundary=\"cpp-httplib-multipart-data\"; charset=UTF-8"; + string boundary; + auto ret = detail::parse_multipart_boundary(content_type, boundary); + EXPECT_TRUE(ret); + EXPECT_EQ(boundary, "cpp-httplib-multipart-data"); +} + TEST(GetHeaderValueTest, DefaultValue) { Headers headers = {{"Dummy", "Dummy"}}; auto val = detail::get_header_value(headers, "Content-Type", 0, "text/plain"); @@ -175,8 +220,7 @@ TEST(GetHeaderValueTest, DefaultValue) { TEST(GetHeaderValueTest, DefaultValueInt) { Headers headers = {{"Dummy", "Dummy"}}; - auto val = - detail::get_header_value(headers, "Content-Length", 0, 100); + auto val = detail::get_header_value_u64(headers, "Content-Length", 0, 100); EXPECT_EQ(100ull, val); } @@ -205,8 +249,7 @@ TEST(GetHeaderValueTest, SetContent) { TEST(GetHeaderValueTest, RegularValueInt) { Headers headers = {{"Content-Length", "100"}, {"Dummy", "Dummy"}}; - auto val = - detail::get_header_value(headers, "Content-Length", 0, 0); + auto val = detail::get_header_value_u64(headers, "Content-Length", 0, 0); EXPECT_EQ(100ull, val); } @@ -400,7 +443,7 @@ TEST(ChunkedEncodingTest, FromHTTPWatch_Online) { std::string out; detail::read_file("./image.jpg", out); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ(out, res->body); } @@ -408,7 +451,7 @@ TEST(HostnameToIPConversionTest, HTTPWatch_Online) { auto host = "www.httpwatch.com"; auto ip = hosted_at(host); - EXPECT_EQ("191.236.16.12", ip); + EXPECT_EQ("23.96.13.243", ip); std::vector addrs; hosted_at(host, addrs); @@ -453,7 +496,7 @@ TEST(ChunkedEncodingTest, WithContentReceiver_Online) { std::string out; detail::read_file("./image.jpg", out); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ(out, body); } @@ -473,7 +516,7 @@ TEST(ChunkedEncodingTest, WithResponseHandlerAndContentReceiver_Online) { auto res = cli.Get( "/httpgallery/chunked/chunkedimage.aspx?0.4153841143030137", [&](const Response &response) { - EXPECT_EQ(200, response.status); + EXPECT_EQ(StatusCode::OK_200, response.status); return true; }, [&](const char *data, size_t data_length) { @@ -485,12 +528,18 @@ TEST(ChunkedEncodingTest, WithResponseHandlerAndContentReceiver_Online) { std::string out; detail::read_file("./image.jpg", out); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ(out, body); } TEST(RangeTest, FromHTTPBin_Online) { +#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN auto host = "httpbin.org"; + auto path = std::string{"/range/32"}; +#else + auto host = "nghttp2.org"; + auto path = std::string{"/httpbin/range/32"}; +#endif #ifdef CPPHTTPLIB_OPENSSL_SUPPORT auto port = 443; @@ -502,49 +551,49 @@ TEST(RangeTest, FromHTTPBin_Online) { cli.set_connection_timeout(5); { - auto res = cli.Get("/range/32"); + auto res = cli.Get(path); ASSERT_TRUE(res); EXPECT_EQ("abcdefghijklmnopqrstuvwxyzabcdef", res->body); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } { Headers headers = {make_range_header({{1, -1}})}; - auto res = cli.Get("/range/32", headers); + auto res = cli.Get(path, headers); ASSERT_TRUE(res); EXPECT_EQ("bcdefghijklmnopqrstuvwxyzabcdef", res->body); - EXPECT_EQ(206, res->status); + EXPECT_EQ(StatusCode::PartialContent_206, res->status); } { Headers headers = {make_range_header({{1, 10}})}; - auto res = cli.Get("/range/32", headers); + auto res = cli.Get(path, headers); ASSERT_TRUE(res); EXPECT_EQ("bcdefghijk", res->body); - EXPECT_EQ(206, res->status); + EXPECT_EQ(StatusCode::PartialContent_206, res->status); } { Headers headers = {make_range_header({{0, 31}})}; - auto res = cli.Get("/range/32", headers); + auto res = cli.Get(path, headers); ASSERT_TRUE(res); EXPECT_EQ("abcdefghijklmnopqrstuvwxyzabcdef", res->body); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } { Headers headers = {make_range_header({{0, -1}})}; - auto res = cli.Get("/range/32", headers); + auto res = cli.Get(path, headers); ASSERT_TRUE(res); EXPECT_EQ("abcdefghijklmnopqrstuvwxyzabcdef", res->body); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } { Headers headers = {make_range_header({{0, 32}})}; - auto res = cli.Get("/range/32", headers); + auto res = cli.Get(path, headers); ASSERT_TRUE(res); - EXPECT_EQ(416, res->status); + EXPECT_EQ(StatusCode::RangeNotSatisfiable_416, res->status); } } @@ -594,7 +643,7 @@ TEST(ConnectionErrorTest, InvalidHostCheckResultErrorToString) { ASSERT_TRUE(!res); stringstream s; s << "error code: " << res.error(); - EXPECT_EQ("error code: Connection (2)", s.str()); + EXPECT_EQ("error code: Could not establish connection (2)", s.str()); } TEST(ConnectionErrorTest, InvalidPort) { @@ -637,7 +686,13 @@ TEST(ConnectionErrorTest, Timeout_Online) { } TEST(CancelTest, NoCancel_Online) { +#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN auto host = "httpbin.org"; + auto path = std::string{"/range/32"}; +#else + auto host = "nghttp2.org"; + auto path = std::string{"/httpbin/range/32"}; +#endif #ifdef CPPHTTPLIB_OPENSSL_SUPPORT auto port = 443; @@ -648,14 +703,20 @@ TEST(CancelTest, NoCancel_Online) { #endif cli.set_connection_timeout(std::chrono::seconds(5)); - auto res = cli.Get("/range/32", [](uint64_t, uint64_t) { return true; }); + auto res = cli.Get(path, [](uint64_t, uint64_t) { return true; }); ASSERT_TRUE(res); EXPECT_EQ("abcdefghijklmnopqrstuvwxyzabcdef", res->body); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST(CancelTest, WithCancelSmallPayload_Online) { +#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN auto host = "httpbin.org"; + auto path = std::string{"/range/32"}; +#else + auto host = "nghttp2.org"; + auto path = std::string{"/httpbin/range/32"}; +#endif #ifdef CPPHTTPLIB_OPENSSL_SUPPORT auto port = 443; @@ -665,14 +726,20 @@ TEST(CancelTest, WithCancelSmallPayload_Online) { Client cli(host, port); #endif - auto res = cli.Get("/range/32", [](uint64_t, uint64_t) { return false; }); + auto res = cli.Get(path, [](uint64_t, uint64_t) { return false; }); cli.set_connection_timeout(std::chrono::seconds(5)); ASSERT_TRUE(!res); EXPECT_EQ(Error::Canceled, res.error()); } TEST(CancelTest, WithCancelLargePayload_Online) { +#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN auto host = "httpbin.org"; + auto path = std::string{"/range/65536"}; +#else + auto host = "nghttp2.org"; + auto path = std::string{"/httpbin/range/65536"}; +#endif #ifdef CPPHTTPLIB_OPENSSL_SUPPORT auto port = 443; @@ -684,14 +751,20 @@ TEST(CancelTest, WithCancelLargePayload_Online) { cli.set_connection_timeout(std::chrono::seconds(5)); uint32_t count = 0; - auto res = cli.Get("/range/65536", - [&count](uint64_t, uint64_t) { return (count++ == 0); }); + auto res = + cli.Get(path, [&count](uint64_t, uint64_t) { return (count++ == 0); }); ASSERT_TRUE(!res); EXPECT_EQ(Error::Canceled, res.error()); } TEST(BaseAuthTest, FromHTTPWatch_Online) { +#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN auto host = "httpbin.org"; + auto path = std::string{"/basic-auth/hello/world"}; +#else + auto host = "nghttp2.org"; + auto path = std::string{"/httpbin/basic-auth/hello/world"}; +#endif #ifdef CPPHTTPLIB_OPENSSL_SUPPORT auto port = 443; @@ -702,87 +775,100 @@ TEST(BaseAuthTest, FromHTTPWatch_Online) { #endif { - auto res = cli.Get("/basic-auth/hello/world"); + auto res = cli.Get(path); ASSERT_TRUE(res); - EXPECT_EQ(401, res->status); + EXPECT_EQ(StatusCode::Unauthorized_401, res->status); } { - auto res = cli.Get("/basic-auth/hello/world", - {make_basic_authentication_header("hello", "world")}); + auto res = + cli.Get(path, {make_basic_authentication_header("hello", "world")}); ASSERT_TRUE(res); EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n", res->body); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } { cli.set_basic_auth("hello", "world"); - auto res = cli.Get("/basic-auth/hello/world"); + auto res = cli.Get(path); ASSERT_TRUE(res); EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n", res->body); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } { cli.set_basic_auth("hello", "bad"); - auto res = cli.Get("/basic-auth/hello/world"); + auto res = cli.Get(path); ASSERT_TRUE(res); - EXPECT_EQ(401, res->status); + EXPECT_EQ(StatusCode::Unauthorized_401, res->status); } { cli.set_basic_auth("bad", "world"); - auto res = cli.Get("/basic-auth/hello/world"); + auto res = cli.Get(path); ASSERT_TRUE(res); - EXPECT_EQ(401, res->status); + EXPECT_EQ(StatusCode::Unauthorized_401, res->status); } } #ifdef CPPHTTPLIB_OPENSSL_SUPPORT TEST(DigestAuthTest, FromHTTPWatch_Online) { +#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN auto host = "httpbin.org"; + auto unauth_path = std::string{"/digest-auth/auth/hello/world"}; + auto paths = std::vector{ + "/digest-auth/auth/hello/world/MD5", + "/digest-auth/auth/hello/world/SHA-256", + "/digest-auth/auth/hello/world/SHA-512", + "/digest-auth/auth-int/hello/world/MD5", + }; +#else + auto host = "nghttp2.org"; + auto unauth_path = std::string{"/httpbin/digest-auth/auth/hello/world"}; + auto paths = std::vector{ + "/httpbin/digest-auth/auth/hello/world/MD5", + "/httpbin/digest-auth/auth/hello/world/SHA-256", + "/httpbin/digest-auth/auth/hello/world/SHA-512", + "/httpbin/digest-auth/auth-int/hello/world/MD5", + }; +#endif + auto port = 443; SSLClient cli(host, port); { - auto res = cli.Get("/digest-auth/auth/hello/world"); + auto res = cli.Get(unauth_path); ASSERT_TRUE(res); - EXPECT_EQ(401, res->status); + EXPECT_EQ(StatusCode::Unauthorized_401, res->status); } { - std::vector paths = { - "/digest-auth/auth/hello/world/MD5", - "/digest-auth/auth/hello/world/SHA-256", - "/digest-auth/auth/hello/world/SHA-512", - "/digest-auth/auth-int/hello/world/MD5", - }; cli.set_digest_auth("hello", "world"); - for (auto path : paths) { + for (const auto &path : paths) { auto res = cli.Get(path.c_str()); ASSERT_TRUE(res); EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n", res->body); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } cli.set_digest_auth("hello", "bad"); - for (auto path : paths) { + for (const auto &path : paths) { auto res = cli.Get(path.c_str()); ASSERT_TRUE(res); - EXPECT_EQ(401, res->status); + EXPECT_EQ(StatusCode::Unauthorized_401, res->status); } // NOTE: Until httpbin.org fixes issue #46, the following test is commented - // out. Plese see https://httpbin.org/digest-auth/auth/hello/world + // out. Please see https://httpbin.org/digest-auth/auth/hello/world // cli.set_digest_auth("bad", "world"); - // for (auto path : paths) { + // for (const auto& path : paths) { // auto res = cli.Get(path.c_str()); // ASSERT_TRUE(res); - // EXPECT_EQ(400, res->status); + // EXPECT_EQ(StatusCode::BadRequest_400, res->status); // } } } @@ -802,7 +888,7 @@ TEST(SpecifyServerIPAddressTest, AnotherHostname_Online) { cli.set_hostname_addr_map({{another_host, wrong_ip}}); auto res = cli.Get("/"); ASSERT_TRUE(res); - ASSERT_EQ(301, res->status); + ASSERT_EQ(StatusCode::MovedPermanently_301, res->status); } TEST(SpecifyServerIPAddressTest, RealHostname_Online) { @@ -833,7 +919,7 @@ TEST(AbsoluteRedirectTest, Redirect_Online) { cli.set_follow_location(true); auto res = cli.Get("/httpbin/absolute-redirect/3"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST(RedirectTest, Redirect_Online) { @@ -848,7 +934,7 @@ TEST(RedirectTest, Redirect_Online) { cli.set_follow_location(true); auto res = cli.Get("/httpbin/redirect/3"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST(RelativeRedirectTest, Redirect_Online) { @@ -863,7 +949,7 @@ TEST(RelativeRedirectTest, Redirect_Online) { cli.set_follow_location(true); auto res = cli.Get("/httpbin/relative-redirect/3"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST(TooManyRedirectTest, Redirect_Online) { @@ -887,13 +973,13 @@ TEST(YahooRedirectTest, Redirect_Online) { auto res = cli.Get("/"); ASSERT_TRUE(res); - EXPECT_EQ(301, res->status); + EXPECT_EQ(StatusCode::MovedPermanently_301, res->status); cli.set_follow_location(true); res = cli.Get("/"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); - EXPECT_EQ("https://yahoo.com/", res->location); + EXPECT_EQ(StatusCode::OK_200, res->status); + EXPECT_EQ("https://www.yahoo.com/", res->location); } TEST(HttpsToHttpRedirectTest, Redirect_Online) { @@ -902,7 +988,7 @@ TEST(HttpsToHttpRedirectTest, Redirect_Online) { auto res = cli.Get( "/httpbin/redirect-to?url=http%3A%2F%2Fwww.google.com&status_code=302"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST(HttpsToHttpRedirectTest2, Redirect_Online) { @@ -915,7 +1001,7 @@ TEST(HttpsToHttpRedirectTest2, Redirect_Online) { auto res = cli.Get("/httpbin/redirect-to", params, Headers{}); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST(HttpsToHttpRedirectTest3, Redirect_Online) { @@ -927,7 +1013,7 @@ TEST(HttpsToHttpRedirectTest3, Redirect_Online) { auto res = cli.Get("/httpbin/redirect-to?status_code=302", params, Headers{}); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST(UrlWithSpace, Redirect_Online) { @@ -936,12 +1022,50 @@ TEST(UrlWithSpace, Redirect_Online) { auto res = cli.Get("/files/2595/310/Neat 1.4-17.jar"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); - EXPECT_EQ(18527U, res->get_header_value("Content-Length")); + EXPECT_EQ(StatusCode::OK_200, res->status); + EXPECT_EQ(18527U, res->get_header_value_u64("Content-Length")); } #endif +#if !defined(_WIN32) && !defined(_WIN64) +TEST(ReceiveSignals, Signal) { + auto setupSignalHandlers = []() { + struct sigaction act; + + sigemptyset(&act.sa_mask); + act.sa_flags = SA_SIGINFO; + act.sa_sigaction = [](int sig, siginfo_t *, void *) { + switch (sig) { + case SIGINT: + default: break; + } + }; + ::sigaction(SIGINT, &act, nullptr); + }; + + Server svr; + int port = 0; + auto thread = std::thread([&]() { + setupSignalHandlers(); + port = svr.bind_to_any_port("localhost"); + svr.listen_after_bind(); + }); + auto se = detail::scope_exit([&] { + svr.stop(); + thread.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); + + ASSERT_TRUE(svr.is_running()); + pthread_kill(thread.native_handle(), SIGINT); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + ASSERT_TRUE(svr.is_running()); +} +#endif + TEST(RedirectToDifferentPort, Redirect) { Server svr1; svr1.Get("/1", [&](const Request & /*req*/, Response &res) { @@ -964,28 +1088,25 @@ TEST(RedirectToDifferentPort, Redirect) { svr2_port = svr2.bind_to_any_port("localhost"); svr2.listen_after_bind(); }); + auto se = detail::scope_exit([&] { + svr2.stop(); + thread2.join(); + svr1.stop(); + thread1.join(); + ASSERT_FALSE(svr2.is_running()); + ASSERT_FALSE(svr1.is_running()); + }); - while (!svr1.is_running() || !svr2.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } - - // Give GET time to get a few messages. - std::this_thread::sleep_for(std::chrono::seconds(1)); + svr1.wait_until_ready(); + svr2.wait_until_ready(); Client cli("localhost", svr2_port); cli.set_follow_location(true); auto res = cli.Get("/2"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("Hello World!", res->body); - - svr1.stop(); - svr2.stop(); - thread1.join(); - thread2.join(); - ASSERT_FALSE(svr1.is_running()); - ASSERT_FALSE(svr2.is_running()); } TEST(RedirectFromPageWithContent, Redirect) { @@ -1001,13 +1122,13 @@ TEST(RedirectFromPageWithContent, Redirect) { }); auto th = std::thread([&]() { svr.listen("localhost", PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + th.join(); + ASSERT_FALSE(svr.is_running()); + }); - while (!svr.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } - - // Give GET time to get a few messages. - std::this_thread::sleep_for(std::chrono::seconds(1)); + svr.wait_until_ready(); { Client cli("localhost", PORT); @@ -1020,7 +1141,7 @@ TEST(RedirectFromPageWithContent, Redirect) { }); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("Hello World!", body); } @@ -1034,13 +1155,9 @@ TEST(RedirectFromPageWithContent, Redirect) { }); ASSERT_TRUE(res); - EXPECT_EQ(302, res->status); + EXPECT_EQ(StatusCode::Found_302, res->status); EXPECT_EQ("___", body); } - - svr.stop(); - th.join(); - ASSERT_FALSE(svr.is_running()); } TEST(RedirectFromPageWithContentIP6, Redirect) { @@ -1061,6 +1178,11 @@ TEST(RedirectFromPageWithContentIP6, Redirect) { }); auto th = std::thread([&]() { svr.listen("::1", 1234); }); + auto se = detail::scope_exit([&] { + svr.stop(); + th.join(); + ASSERT_FALSE(svr.is_running()); + }); // When IPV6 support isn't available svr.listen("::1", 1234) never // actually starts anything, so the condition !svr.is_running() will @@ -1073,9 +1195,6 @@ TEST(RedirectFromPageWithContentIP6, Redirect) { ASSERT_LT(milliseconds, 5000U); } - // Give GET time to get a few messages. - std::this_thread::sleep_for(std::chrono::seconds(1)); - { Client cli("http://[::1]:1234"); cli.set_follow_location(true); @@ -1087,7 +1206,7 @@ TEST(RedirectFromPageWithContentIP6, Redirect) { }); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("Hello World!", body); } @@ -1101,13 +1220,9 @@ TEST(RedirectFromPageWithContentIP6, Redirect) { }); ASSERT_TRUE(res); - EXPECT_EQ(302, res->status); + EXPECT_EQ(StatusCode::Found_302, res->status); EXPECT_EQ("___", body); } - - svr.stop(); - th.join(); - ASSERT_FALSE(svr.is_running()); } TEST(PathUrlEncodeTest, PathUrlEncode) { @@ -1117,16 +1232,20 @@ TEST(PathUrlEncodeTest, PathUrlEncode) { auto a = req.params.find("a"); if (a != req.params.end()) { res.set_content((*a).second, "text/plain"); - res.status = 200; + res.status = StatusCode::OK_200; } else { - res.status = 400; + res.status = StatusCode::BadRequest_400; } }); auto thread = std::thread([&]() { svr.listen(HOST, PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + thread.join(); + ASSERT_FALSE(svr.is_running()); + }); - // Give GET time to get a few messages. - std::this_thread::sleep_for(std::chrono::seconds(1)); + svr.wait_until_ready(); { Client cli(HOST, PORT); @@ -1134,19 +1253,15 @@ TEST(PathUrlEncodeTest, PathUrlEncode) { auto res = cli.Get("/foo?a=explicitly+encoded"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); // This expects it back with a space, as the `+` won't have been // url-encoded, and server-side the params get decoded turning `+` // into spaces. EXPECT_EQ("explicitly encoded", res->body); } - - svr.stop(); - thread.join(); - ASSERT_FALSE(svr.is_running()); } -TEST(BindServerTest, BindDualStack) { +TEST(BindServerTest, DISABLED_BindDualStack) { Server svr; svr.Get("/1", [&](const Request & /*req*/, Response &res) { @@ -1154,16 +1269,20 @@ TEST(BindServerTest, BindDualStack) { }); auto thread = std::thread([&]() { svr.listen("::", PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + thread.join(); + ASSERT_FALSE(svr.is_running()); + }); - // Give GET time to get a few messages. - std::this_thread::sleep_for(std::chrono::seconds(1)); + svr.wait_until_ready(); { Client cli("127.0.0.1", PORT); auto res = cli.Get("/1"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("Hello World!", res->body); } { @@ -1171,12 +1290,9 @@ TEST(BindServerTest, BindDualStack) { auto res = cli.Get("/1"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("Hello World!", res->body); } - svr.stop(); - thread.join(); - ASSERT_FALSE(svr.is_running()); } TEST(BindServerTest, BindAndListenSeparately) { @@ -1213,7 +1329,7 @@ TEST(ErrorHandlerTest, ContentLength) { Server svr; svr.set_error_handler([](const Request & /*req*/, Response &res) { - res.status = 200; + res.status = StatusCode::OK_200; res.set_content("abcdefghijklmnopqrstuvwxyz", "text/html"); // <= Content-Length still 13 }); @@ -1224,24 +1340,24 @@ TEST(ErrorHandlerTest, ContentLength) { }); auto thread = std::thread([&]() { svr.listen(HOST, PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + thread.join(); + ASSERT_FALSE(svr.is_running()); + }); - // Give GET time to get a few messages. - std::this_thread::sleep_for(std::chrono::seconds(1)); + svr.wait_until_ready(); { Client cli(HOST, PORT); auto res = cli.Get("/hi"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("text/html", res->get_header_value("Content-Type")); EXPECT_EQ("26", res->get_header_value("Content-Length")); EXPECT_EQ("abcdefghijklmnopqrstuvwxyz", res->body); } - - svr.stop(); - thread.join(); - ASSERT_FALSE(svr.is_running()); } #ifndef CPPHTTPLIB_NO_EXCEPTIONS @@ -1249,9 +1365,12 @@ TEST(ExceptionHandlerTest, ContentLength) { Server svr; svr.set_exception_handler([](const Request & /*req*/, Response &res, - std::exception &e) { - EXPECT_EQ("abc", std::string(e.what())); - res.status = 500; + std::exception_ptr ep) { + EXPECT_FALSE(ep == nullptr); + try { + std::rethrow_exception(ep); + } catch (std::exception &e) { EXPECT_EQ("abc", std::string(e.what())); } + res.status = StatusCode::InternalServerError_500; res.set_content("abcdefghijklmnopqrstuvwxyz", "text/html"); // <= Content-Length still 13 at this point }); @@ -1262,9 +1381,13 @@ TEST(ExceptionHandlerTest, ContentLength) { }); auto thread = std::thread([&]() { svr.listen(HOST, PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + thread.join(); + ASSERT_FALSE(svr.is_running()); + }); - // Give GET time to get a few messages. - std::this_thread::sleep_for(std::chrono::seconds(1)); + svr.wait_until_ready(); for (size_t i = 0; i < 10; i++) { Client cli(HOST, PORT); @@ -1272,7 +1395,7 @@ TEST(ExceptionHandlerTest, ContentLength) { for (size_t j = 0; j < 100; j++) { auto res = cli.Get("/hi"); ASSERT_TRUE(res); - EXPECT_EQ(500, res->status); + EXPECT_EQ(StatusCode::InternalServerError_500, res->status); EXPECT_EQ("text/html", res->get_header_value("Content-Type")); EXPECT_EQ("26", res->get_header_value("Content-Length")); EXPECT_EQ("abcdefghijklmnopqrstuvwxyz", res->body); @@ -1283,45 +1406,47 @@ TEST(ExceptionHandlerTest, ContentLength) { for (size_t j = 0; j < 100; j++) { auto res = cli.Get("/hi"); ASSERT_TRUE(res); - EXPECT_EQ(500, res->status); + EXPECT_EQ(StatusCode::InternalServerError_500, res->status); EXPECT_EQ("text/html", res->get_header_value("Content-Type")); EXPECT_EQ("26", res->get_header_value("Content-Length")); EXPECT_EQ("abcdefghijklmnopqrstuvwxyz", res->body); } } - - svr.stop(); - thread.join(); - ASSERT_FALSE(svr.is_running()); } #endif TEST(NoContentTest, ContentLength) { Server svr; - svr.Get("/hi", - [](const Request & /*req*/, Response &res) { res.status = 204; }); + svr.Get("/hi", [](const Request & /*req*/, Response &res) { + res.status = StatusCode::NoContent_204; + }); auto thread = std::thread([&]() { svr.listen(HOST, PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + thread.join(); + ASSERT_FALSE(svr.is_running()); + }); - // Give GET time to get a few messages. - std::this_thread::sleep_for(std::chrono::seconds(1)); + svr.wait_until_ready(); { Client cli(HOST, PORT); auto res = cli.Get("/hi"); ASSERT_TRUE(res); - EXPECT_EQ(204, res->status); + EXPECT_EQ(StatusCode::NoContent_204, res->status); EXPECT_EQ("0", res->get_header_value("Content-Length")); } - - svr.stop(); - thread.join(); - ASSERT_FALSE(svr.is_running()); } TEST(RoutingHandlerTest, PreRoutingHandler) { +#ifdef CPPHTTPLIB_OPENSSL_SUPPORT + SSLServer svr(SERVER_CERT_FILE, SERVER_PRIVATE_KEY_FILE); + ASSERT_TRUE(svr.is_valid()); +#else Server svr; +#endif svr.set_pre_routing_handler([](const Request &req, Response &res) { if (req.path == "/routing_handler") { @@ -1347,16 +1472,25 @@ TEST(RoutingHandlerTest, PreRoutingHandler) { }); auto thread = std::thread([&]() { svr.listen(HOST, PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + thread.join(); + ASSERT_FALSE(svr.is_running()); + }); - // Give GET time to get a few messages. - std::this_thread::sleep_for(std::chrono::seconds(1)); + svr.wait_until_ready(); { +#ifdef CPPHTTPLIB_OPENSSL_SUPPORT + SSLClient cli(HOST, PORT); + cli.enable_server_certificate_verification(false); +#else Client cli(HOST, PORT); +#endif auto res = cli.Get("/routing_handler"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("Routing Handler", res->body); EXPECT_EQ(1U, res->get_header_value_count("PRE_ROUTING")); EXPECT_EQ("on", res->get_header_value("PRE_ROUTING")); @@ -1365,30 +1499,36 @@ TEST(RoutingHandlerTest, PreRoutingHandler) { } { +#ifdef CPPHTTPLIB_OPENSSL_SUPPORT + SSLClient cli(HOST, PORT); + cli.enable_server_certificate_verification(false); +#else Client cli(HOST, PORT); +#endif auto res = cli.Get("/hi"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("Hello World!\n", res->body); EXPECT_EQ(0U, res->get_header_value_count("PRE_ROUTING")); EXPECT_EQ(0U, res->get_header_value_count("POST_ROUTING")); } { +#ifdef CPPHTTPLIB_OPENSSL_SUPPORT + SSLClient cli(HOST, PORT); + cli.enable_server_certificate_verification(false); +#else Client cli(HOST, PORT); +#endif auto res = cli.Get("/aaa"); ASSERT_TRUE(res); - EXPECT_EQ(404, res->status); + EXPECT_EQ(StatusCode::NotFound_404, res->status); EXPECT_EQ("Error", res->body); EXPECT_EQ(0U, res->get_header_value_count("PRE_ROUTING")); EXPECT_EQ(0U, res->get_header_value_count("POST_ROUTING")); } - - svr.stop(); - thread.join(); - ASSERT_FALSE(svr.is_running()); } TEST(InvalidFormatTest, StatusCode) { @@ -1400,9 +1540,13 @@ TEST(InvalidFormatTest, StatusCode) { }); auto thread = std::thread([&]() { svr.listen(HOST, PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + thread.join(); + ASSERT_FALSE(svr.is_running()); + }); - // Give GET time to get a few messages. - std::this_thread::sleep_for(std::chrono::seconds(1)); + svr.wait_until_ready(); { Client cli(HOST, PORT); @@ -1410,10 +1554,6 @@ TEST(InvalidFormatTest, StatusCode) { auto res = cli.Get("/hi"); ASSERT_FALSE(res); } - - svr.stop(); - thread.join(); - ASSERT_FALSE(svr.is_running()); } TEST(URLFragmentTest, WithFragment) { @@ -1424,24 +1564,65 @@ TEST(URLFragmentTest, WithFragment) { }); auto thread = std::thread([&]() { svr.listen(HOST, PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + thread.join(); + ASSERT_FALSE(svr.is_running()); + }); - std::this_thread::sleep_for(std::chrono::seconds(1)); + svr.wait_until_ready(); { Client cli(HOST, PORT); auto res = cli.Get("/hi#key1=val1=key2=val2"); EXPECT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); res = cli.Get("/hi%23key1=val1=key2=val2"); EXPECT_TRUE(res); - EXPECT_EQ(404, res->status); + EXPECT_EQ(StatusCode::NotFound_404, res->status); } +} - svr.stop(); - thread.join(); - ASSERT_FALSE(svr.is_running()); +TEST(HeaderWriter, SetHeaderWriter) { + Server svr; + + svr.set_header_writer([](Stream &strm, Headers &hdrs) { + hdrs.emplace("CustomServerHeader", "CustomServerValue"); + return detail::write_headers(strm, hdrs); + }); + svr.Get("/hi", [](const Request &req, Response &res) { + auto it = req.headers.find("CustomClientHeader"); + EXPECT_TRUE(it != req.headers.end()); + EXPECT_EQ(it->second, "CustomClientValue"); + res.set_content("Hello World!\n", "text/plain"); + }); + + auto thread = std::thread([&]() { svr.listen(HOST, PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + thread.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); + + { + Client cli(HOST, PORT); + cli.set_header_writer([](Stream &strm, Headers &hdrs) { + hdrs.emplace("CustomClientHeader", "CustomClientValue"); + return detail::write_headers(strm, hdrs); + }); + + auto res = cli.Get("/hi"); + EXPECT_TRUE(res); + EXPECT_EQ(StatusCode::OK_200, res->status); + + auto it = res->headers.find("CustomServerHeader"); + EXPECT_TRUE(it != res->headers.end()); + EXPECT_EQ(it->second, "CustomServerValue"); + } } class ServerTest : public ::testing::Test { @@ -1518,6 +1699,17 @@ class ServerTest : public ::testing::Test { std::stoi(req.get_header_value("REMOTE_PORT"))); res.set_content(remote_addr.c_str(), "text/plain"); }) + .Get("/local_addr", + [&](const Request &req, Response &res) { + EXPECT_TRUE(req.has_header("LOCAL_PORT")); + EXPECT_TRUE(req.has_header("LOCAL_ADDR")); + auto local_addr = req.get_header_value("LOCAL_ADDR"); + auto local_port = req.get_header_value("LOCAL_PORT"); + EXPECT_EQ(req.local_addr, local_addr); + EXPECT_EQ(req.local_port, std::stoi(local_port)); + res.set_content(local_addr.append(":").append(local_port), + "text/plain"); + }) .Get("/endwith%", [&](const Request & /*req*/, Response &res) { res.set_content("Hello World!", "text/plain"); @@ -1530,12 +1722,14 @@ class ServerTest : public ::testing::Test { }) .Get("/", [&](const Request & /*req*/, Response &res) { res.set_redirect("/hi"); }) - .Post("/1", [](const Request & /*req*/, - Response &res) { res.set_redirect("/2", 303); }) + .Post("/1", + [](const Request & /*req*/, Response &res) { + res.set_redirect("/2", StatusCode::SeeOther_303); + }) .Get("/2", [](const Request & /*req*/, Response &res) { res.set_content("redirected.", "text/plain"); - res.status = 200; + res.status = StatusCode::OK_200; }) .Post("/person", [&](const Request &req, Response &res) { @@ -1543,7 +1737,7 @@ class ServerTest : public ::testing::Test { persons_[req.get_param_value("name")] = req.get_param_value("note"); } else { - res.status = 400; + res.status = StatusCode::BadRequest_400; } }) .Put("/person", @@ -1552,7 +1746,7 @@ class ServerTest : public ::testing::Test { persons_[req.get_param_value("name")] = req.get_param_value("note"); } else { - res.status = 400; + res.status = StatusCode::BadRequest_400; } }) .Get("/person/(.*)", @@ -1562,7 +1756,7 @@ class ServerTest : public ::testing::Test { auto note = persons_[name]; res.set_content(note, "text/plain"); } else { - res.status = 404; + res.status = StatusCode::NotFound_404; } }) .Post("/x-www-form-urlencoded-json", @@ -1570,13 +1764,12 @@ class ServerTest : public ::testing::Test { auto json = req.get_param_value("json"); ASSERT_EQ(JSON_DATA, json); res.set_content(json, "appliation/json"); - res.status = 200; + res.status = StatusCode::OK_200; }) .Get("/streamed-chunked", [&](const Request & /*req*/, Response &res) { res.set_chunked_content_provider( "text/plain", [](size_t /*offset*/, DataSink &sink) { - EXPECT_TRUE(sink.is_writable()); sink.os << "123"; sink.os << "456"; sink.os << "789"; @@ -1590,7 +1783,6 @@ class ServerTest : public ::testing::Test { res.set_chunked_content_provider( "text/plain", [i](size_t /*offset*/, DataSink &sink) { - EXPECT_TRUE(sink.is_writable()); switch (*i) { case 0: sink.os << "123"; break; case 1: sink.os << "456"; break; @@ -1605,6 +1797,30 @@ class ServerTest : public ::testing::Test { delete i; }); }) + .Get("/streamed-chunked-with-trailer", + [&](const Request & /*req*/, Response &res) { + auto i = new int(0); + res.set_header("Trailer", "Dummy1, Dummy2"); + res.set_chunked_content_provider( + "text/plain", + [i](size_t /*offset*/, DataSink &sink) { + switch (*i) { + case 0: sink.os << "123"; break; + case 1: sink.os << "456"; break; + case 2: sink.os << "789"; break; + case 3: { + sink.done_with_trailer( + {{"Dummy1", "DummyVal1"}, {"Dummy2", "DummyVal2"}}); + } break; + } + (*i)++; + return true; + }, + [i](bool success) { + EXPECT_TRUE(success); + delete i; + }); + }) .Get("/streamed", [&](const Request & /*req*/, Response &res) { res.set_content_provider( @@ -1615,12 +1831,11 @@ class ServerTest : public ::testing::Test { }); }) .Get("/streamed-with-range", - [&](const Request & /*req*/, Response &res) { + [&](const Request &req, Response &res) { auto data = new std::string("abcdefg"); res.set_content_provider( data->size(), "text/plain", [data](size_t offset, size_t length, DataSink &sink) { - EXPECT_TRUE(sink.is_writable()); size_t DATA_CHUNK_SIZE = 4; const auto &d = *data; auto out_len = @@ -1630,8 +1845,8 @@ class ServerTest : public ::testing::Test { EXPECT_TRUE(ret); return true; }, - [data](bool success) { - EXPECT_TRUE(success); + [data, &req](bool success) { + EXPECT_EQ(success, !req.has_param("error")); delete data; }); }) @@ -1640,11 +1855,15 @@ class ServerTest : public ::testing::Test { res.set_content_provider( size_t(-1), "text/plain", [](size_t /*offset*/, size_t /*length*/, DataSink &sink) { - EXPECT_TRUE(sink.is_writable()); sink.os << "data_chunk"; return true; }); }) + .Get("/regex-with-delimiter", + [&](const Request &req, Response & /*res*/) { + ASSERT_TRUE(req.has_param("key")); + EXPECT_EQ("^(?.*(value))", req.get_param_value("key")); + }) .Get("/with-range", [&](const Request & /*req*/, Response &res) { res.set_content("abcdefg", "text/plain"); @@ -1697,6 +1916,40 @@ class ServerTest : public ::testing::Test { EXPECT_EQ("application/json tmp-string", file.content_type); } }) + .Post("/multipart/multi_file_values", + [&](const Request &req, Response & /*res*/) { + EXPECT_EQ(5u, req.files.size()); + ASSERT_TRUE(!req.has_file("???")); + ASSERT_TRUE(req.body.empty()); + + { + const auto &text_value = req.get_file_values("text"); + EXPECT_EQ(1u, text_value.size()); + auto &text = text_value[0]; + EXPECT_TRUE(text.filename.empty()); + EXPECT_EQ("default text", text.content); + } + { + const auto &text1_values = req.get_file_values("multi_text1"); + EXPECT_EQ(2u, text1_values.size()); + EXPECT_EQ("aaaaa", text1_values[0].content); + EXPECT_EQ("bbbbb", text1_values[1].content); + } + + { + const auto &file1_values = req.get_file_values("multi_file1"); + EXPECT_EQ(2u, file1_values.size()); + auto file1 = file1_values[0]; + EXPECT_EQ(file1.filename, "hello.txt"); + EXPECT_EQ(file1.content_type, "text/plain"); + EXPECT_EQ("h\ne\n\nl\nl\no\n", file1.content); + + auto file2 = file1_values[1]; + EXPECT_EQ(file2.filename, "world.json"); + EXPECT_EQ(file2.content_type, "application/json"); + EXPECT_EQ("{\n \"world\", true\n}\n", file2.content); + } + }) .Post("/empty", [&](const Request &req, Response &res) { EXPECT_EQ(req.body, ""); @@ -1711,6 +1964,22 @@ class ServerTest : public ::testing::Test { EXPECT_EQ("0", req.get_header_value("Content-Length")); res.set_content("empty-no-content-type", "text/plain"); }) + .Post("/path-only", + [&](const Request &req, Response &res) { + EXPECT_EQ(req.body, ""); + EXPECT_EQ("", req.get_header_value("Content-Type")); + EXPECT_EQ("0", req.get_header_value("Content-Length")); + res.set_content("path-only", "text/plain"); + }) + .Post("/path-headers-only", + [&](const Request &req, Response &res) { + EXPECT_EQ(req.body, ""); + EXPECT_EQ("", req.get_header_value("Content-Type")); + EXPECT_EQ("0", req.get_header_value("Content-Length")); + EXPECT_EQ("world", req.get_header_value("hello")); + EXPECT_EQ("world2", req.get_header_value("hello2")); + res.set_content("path-headers-only", "text/plain"); + }) .Post("/post-large", [&](const Request &req, Response &res) { EXPECT_EQ(req.body, LARGE_DATA); @@ -1897,6 +2166,11 @@ class ServerTest : public ::testing::Test { EXPECT_EQ("4", req.get_header_value("Content-Length")); res.set_content(req.body, "application/octet-stream"); }) + .Get("/issue1772", + [&](const Request & /*req*/, Response &res) { + res.status = 401; + res.set_header("WWW-Authenticate", "Basic realm=123456"); + }) #if defined(CPPHTTPLIB_ZLIB_SUPPORT) || defined(CPPHTTPLIB_BROTLI_SUPPORT) .Get("/compress", [&](const Request & /*req*/, Response &res) { @@ -1936,9 +2210,7 @@ class ServerTest : public ::testing::Test { t_ = thread([&]() { ASSERT_TRUE(svr_.listen(HOST, PORT)); }); - while (!svr_.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } + svr_.wait_until_ready(); } virtual void TearDown() { @@ -1968,7 +2240,7 @@ TEST_F(ServerTest, GetMethod200) { auto res = cli_.Get("/hi"); ASSERT_TRUE(res); EXPECT_EQ("HTTP/1.1", res->version); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("OK", res->reason); EXPECT_EQ("text/plain", res->get_header_value("Content-Type")); EXPECT_EQ(1U, res->get_header_value_count("Content-Type")); @@ -1979,7 +2251,7 @@ TEST_F(ServerTest, GetMethod200withPercentEncoding) { auto res = cli_.Get("/%68%69"); // auto res = cli_.Get("/hi"); ASSERT_TRUE(res); EXPECT_EQ("HTTP/1.1", res->version); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("text/plain", res->get_header_value("Content-Type")); EXPECT_EQ(1U, res->get_header_value_count("Content-Type")); EXPECT_EQ("Hello World!", res->body); @@ -1988,7 +2260,7 @@ TEST_F(ServerTest, GetMethod200withPercentEncoding) { TEST_F(ServerTest, GetMethod302) { auto res = cli_.Get("/"); ASSERT_TRUE(res); - EXPECT_EQ(302, res->status); + EXPECT_EQ(StatusCode::Found_302, res->status); EXPECT_EQ("/hi", res->get_header_value("Location")); } @@ -1996,7 +2268,7 @@ TEST_F(ServerTest, GetMethod302Redirect) { cli_.set_follow_location(true); auto res = cli_.Get("/"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("Hello World!", res->body); EXPECT_EQ("/hi", res->location); } @@ -2004,13 +2276,13 @@ TEST_F(ServerTest, GetMethod302Redirect) { TEST_F(ServerTest, GetMethod404) { auto res = cli_.Get("/invalid"); ASSERT_TRUE(res); - EXPECT_EQ(404, res->status); + EXPECT_EQ(StatusCode::NotFound_404, res->status); } TEST_F(ServerTest, HeadMethod200) { auto res = cli_.Head("/hi"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("text/plain", res->get_header_value("Content-Type")); EXPECT_TRUE(res->body.empty()); } @@ -2018,7 +2290,7 @@ TEST_F(ServerTest, HeadMethod200) { TEST_F(ServerTest, HeadMethod200Static) { auto res = cli_.Head("/mount/dir/index.html"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("text/html", res->get_header_value("Content-Type")); EXPECT_EQ(104, std::stoi(res->get_header_value("Content-Length"))); EXPECT_TRUE(res->body.empty()); @@ -2027,14 +2299,14 @@ TEST_F(ServerTest, HeadMethod200Static) { TEST_F(ServerTest, HeadMethod404) { auto res = cli_.Head("/invalid"); ASSERT_TRUE(res); - EXPECT_EQ(404, res->status); + EXPECT_EQ(StatusCode::NotFound_404, res->status); EXPECT_TRUE(res->body.empty()); } TEST_F(ServerTest, GetMethodPersonJohn) { auto res = cli_.Get("/person/john"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("text/plain", res->get_header_value("Content-Type")); EXPECT_EQ("programmer", res->body); } @@ -2042,16 +2314,16 @@ TEST_F(ServerTest, GetMethodPersonJohn) { TEST_F(ServerTest, PostMethod1) { auto res = cli_.Get("/person/john1"); ASSERT_TRUE(res); - ASSERT_EQ(404, res->status); + ASSERT_EQ(StatusCode::NotFound_404, res->status); res = cli_.Post("/person", "name=john1¬e=coder", "application/x-www-form-urlencoded"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); res = cli_.Get("/person/john1"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); ASSERT_EQ("text/plain", res->get_header_value("Content-Type")); ASSERT_EQ("coder", res->body); } @@ -2059,7 +2331,7 @@ TEST_F(ServerTest, PostMethod1) { TEST_F(ServerTest, PostMethod2) { auto res = cli_.Get("/person/john2"); ASSERT_TRUE(res); - ASSERT_EQ(404, res->status); + ASSERT_EQ(StatusCode::NotFound_404, res->status); Params params; params.emplace("name", "john2"); @@ -2067,11 +2339,11 @@ TEST_F(ServerTest, PostMethod2) { res = cli_.Post("/person", params); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); res = cli_.Get("/person/john2"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); ASSERT_EQ("text/plain", res->get_header_value("Content-Type")); ASSERT_EQ("coder", res->body); } @@ -2079,7 +2351,7 @@ TEST_F(ServerTest, PostMethod2) { TEST_F(ServerTest, PutMethod3) { auto res = cli_.Get("/person/john3"); ASSERT_TRUE(res); - ASSERT_EQ(404, res->status); + ASSERT_EQ(StatusCode::NotFound_404, res->status); Params params; params.emplace("name", "john3"); @@ -2087,11 +2359,11 @@ TEST_F(ServerTest, PutMethod3) { res = cli_.Put("/person", params); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); res = cli_.Get("/person/john3"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); ASSERT_EQ("text/plain", res->get_header_value("Content-Type")); ASSERT_EQ("coder", res->body); } @@ -2103,42 +2375,57 @@ TEST_F(ServerTest, PostWwwFormUrlEncodedJson) { auto res = cli_.Post("/x-www-form-urlencoded-json", params); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); ASSERT_EQ(JSON_DATA, res->body); } TEST_F(ServerTest, PostEmptyContent) { auto res = cli_.Post("/empty", "", "text/plain"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); ASSERT_EQ("empty", res->body); } TEST_F(ServerTest, PostEmptyContentWithNoContentType) { auto res = cli_.Post("/empty-no-content-type"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); ASSERT_EQ("empty-no-content-type", res->body); } +TEST_F(ServerTest, PostPathOnly) { + auto res = cli_.Post("/path-only"); + ASSERT_TRUE(res); + ASSERT_EQ(StatusCode::OK_200, res->status); + ASSERT_EQ("path-only", res->body); +} + +TEST_F(ServerTest, PostPathAndHeadersOnly) { + auto res = cli_.Post("/path-headers-only", + Headers({{"hello", "world"}, {"hello2", "world2"}})); + ASSERT_TRUE(res); + ASSERT_EQ(StatusCode::OK_200, res->status); + ASSERT_EQ("path-headers-only", res->body); +} + TEST_F(ServerTest, PostLarge) { auto res = cli_.Post("/post-large", LARGE_DATA, "text/plain"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ(LARGE_DATA, res->body); } TEST_F(ServerTest, PutEmptyContentWithNoContentType) { auto res = cli_.Put("/empty-no-content-type"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); ASSERT_EQ("empty-no-content-type", res->body); } TEST_F(ServerTest, GetMethodDir) { auto res = cli_.Get("/dir/"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("text/html", res->get_header_value("Content-Type")); auto body = R"( @@ -2156,7 +2443,7 @@ TEST_F(ServerTest, GetMethodDir) { TEST_F(ServerTest, GetMethodDirTest) { auto res = cli_.Get("/dir/test.html"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("text/html", res->get_header_value("Content-Type")); EXPECT_EQ("test.html", res->body); } @@ -2164,7 +2451,7 @@ TEST_F(ServerTest, GetMethodDirTest) { TEST_F(ServerTest, GetMethodDirTestWithDoubleDots) { auto res = cli_.Get("/dir/../dir/test.html"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("text/html", res->get_header_value("Content-Type")); EXPECT_EQ("test.html", res->body); } @@ -2172,25 +2459,25 @@ TEST_F(ServerTest, GetMethodDirTestWithDoubleDots) { TEST_F(ServerTest, GetMethodInvalidPath) { auto res = cli_.Get("/dir/../test.html"); ASSERT_TRUE(res); - EXPECT_EQ(404, res->status); + EXPECT_EQ(StatusCode::NotFound_404, res->status); } TEST_F(ServerTest, GetMethodOutOfBaseDir) { auto res = cli_.Get("/../www/dir/test.html"); ASSERT_TRUE(res); - EXPECT_EQ(404, res->status); + EXPECT_EQ(StatusCode::NotFound_404, res->status); } TEST_F(ServerTest, GetMethodOutOfBaseDir2) { auto res = cli_.Get("/dir/../../www/dir/test.html"); ASSERT_TRUE(res); - EXPECT_EQ(404, res->status); + EXPECT_EQ(StatusCode::NotFound_404, res->status); } TEST_F(ServerTest, GetMethodDirMountTest) { auto res = cli_.Get("/mount/dir/test.html"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("text/html", res->get_header_value("Content-Type")); EXPECT_EQ("test.html", res->body); } @@ -2198,7 +2485,7 @@ TEST_F(ServerTest, GetMethodDirMountTest) { TEST_F(ServerTest, GetMethodDirMountTestWithDoubleDots) { auto res = cli_.Get("/mount/dir/../dir/test.html"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("text/html", res->get_header_value("Content-Type")); EXPECT_EQ("test.html", res->body); } @@ -2206,25 +2493,37 @@ TEST_F(ServerTest, GetMethodDirMountTestWithDoubleDots) { TEST_F(ServerTest, GetMethodInvalidMountPath) { auto res = cli_.Get("/mount/dir/../test.html"); ASSERT_TRUE(res); - EXPECT_EQ(404, res->status); + EXPECT_EQ(StatusCode::NotFound_404, res->status); +} + +TEST_F(ServerTest, GetMethodEmbeddedNUL) { + auto res = cli_.Get("/mount/dir/test.html%00.js"); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::NotFound_404, res->status); } TEST_F(ServerTest, GetMethodOutOfBaseDirMount) { auto res = cli_.Get("/mount/../www2/dir/test.html"); ASSERT_TRUE(res); - EXPECT_EQ(404, res->status); + EXPECT_EQ(StatusCode::NotFound_404, res->status); } TEST_F(ServerTest, GetMethodOutOfBaseDirMount2) { auto res = cli_.Get("/mount/dir/../../www2/dir/test.html"); ASSERT_TRUE(res); - EXPECT_EQ(404, res->status); + EXPECT_EQ(StatusCode::NotFound_404, res->status); +} + +TEST_F(ServerTest, GetMethodOutOfBaseDirMountWithBackslash) { + auto res = cli_.Get("/mount/%2e%2e%5c/www2/dir/test.html"); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::NotFound_404, res->status); } TEST_F(ServerTest, PostMethod303) { auto res = cli_.Post("/1", "body", "text/plain"); ASSERT_TRUE(res); - EXPECT_EQ(303, res->status); + EXPECT_EQ(StatusCode::SeeOther_303, res->status); EXPECT_EQ("/2", res->get_header_value("Location")); } @@ -2232,7 +2531,7 @@ TEST_F(ServerTest, PostMethod303Redirect) { cli_.set_follow_location(true); auto res = cli_.Post("/1", "body", "text/plain"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("redirected.", res->body); EXPECT_EQ("/2", res->location); } @@ -2240,7 +2539,7 @@ TEST_F(ServerTest, PostMethod303Redirect) { TEST_F(ServerTest, UserDefinedMIMETypeMapping) { auto res = cli_.Get("/dir/test.abcde"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("text/abcde", res->get_header_value("Content-Type")); EXPECT_EQ("abcde", res->body); } @@ -2248,13 +2547,67 @@ TEST_F(ServerTest, UserDefinedMIMETypeMapping) { TEST_F(ServerTest, StaticFileRange) { auto res = cli_.Get("/dir/test.abcde", {{make_range_header({{2, 3}})}}); ASSERT_TRUE(res); - EXPECT_EQ(206, res->status); + EXPECT_EQ(StatusCode::PartialContent_206, res->status); EXPECT_EQ("text/abcde", res->get_header_value("Content-Type")); EXPECT_EQ("2", res->get_header_value("Content-Length")); EXPECT_EQ(true, res->has_header("Content-Range")); + EXPECT_EQ("bytes 2-3/5", res->get_header_value("Content-Range")); EXPECT_EQ(std::string("cd"), res->body); } +TEST_F(ServerTest, StaticFileRanges) { + auto res = + cli_.Get("/dir/test.abcde", {{make_range_header({{1, 2}, {4, -1}})}}); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::PartialContent_206, res->status); + EXPECT_TRUE( + res->get_header_value("Content-Type") + .find( + "multipart/byteranges; boundary=--cpp-httplib-multipart-data-") == + 0); + EXPECT_EQ("266", res->get_header_value("Content-Length")); +} + +TEST_F(ServerTest, StaticFileRangeHead) { + auto res = cli_.Head("/dir/test.abcde", {{make_range_header({{2, 3}})}}); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::PartialContent_206, res->status); + EXPECT_EQ("text/abcde", res->get_header_value("Content-Type")); + EXPECT_EQ("2", res->get_header_value("Content-Length")); + EXPECT_EQ(true, res->has_header("Content-Range")); + EXPECT_EQ("bytes 2-3/5", res->get_header_value("Content-Range")); +} + +TEST_F(ServerTest, StaticFileRangeBigFile) { + auto res = cli_.Get("/dir/1MB.txt", {{make_range_header({{-1, 5}})}}); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::PartialContent_206, res->status); + EXPECT_EQ("text/plain", res->get_header_value("Content-Type")); + EXPECT_EQ("5", res->get_header_value("Content-Length")); + EXPECT_EQ(true, res->has_header("Content-Range")); + EXPECT_EQ("bytes 1048571-1048575/1048576", + res->get_header_value("Content-Range")); + EXPECT_EQ("LAST\n", res->body); +} + +TEST_F(ServerTest, StaticFileRangeBigFile2) { + auto res = cli_.Get("/dir/1MB.txt", {{make_range_header({{1, 4097}})}}); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::PartialContent_206, res->status); + EXPECT_EQ("text/plain", res->get_header_value("Content-Type")); + EXPECT_EQ("4097", res->get_header_value("Content-Length")); + EXPECT_EQ(true, res->has_header("Content-Range")); + EXPECT_EQ("bytes 1-4097/1048576", res->get_header_value("Content-Range")); +} + +TEST_F(ServerTest, StaticFileBigFile) { + auto res = cli_.Get("/dir/1MB.txt"); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::OK_200, res->status); + EXPECT_EQ("text/plain", res->get_header_value("Content-Type")); + EXPECT_EQ("1048576", res->get_header_value("Content-Length")); +} + TEST_F(ServerTest, InvalidBaseDirMount) { EXPECT_EQ(false, svr_.set_mount_point("invalid_mount_point", "./www3")); } @@ -2265,25 +2618,25 @@ TEST_F(ServerTest, Binary) { auto res = cli_.Post("/binary", binary.data(), binary.size(), "application/octet-stream"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); ASSERT_EQ(4U, res->body.size()); res = cli_.Put("/binary", binary.data(), binary.size(), "application/octet-stream"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); ASSERT_EQ(4U, res->body.size()); res = cli_.Patch("/binary", binary.data(), binary.size(), "application/octet-stream"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); ASSERT_EQ(4U, res->body.size()); res = cli_.Delete("/binary", binary.data(), binary.size(), "application/octet-stream"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); ASSERT_EQ(4U, res->body.size()); } @@ -2292,22 +2645,22 @@ TEST_F(ServerTest, BinaryString) { auto res = cli_.Post("/binary", binary, "application/octet-stream"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); ASSERT_EQ(4U, res->body.size()); res = cli_.Put("/binary", binary, "application/octet-stream"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); ASSERT_EQ(4U, res->body.size()); res = cli_.Patch("/binary", binary, "application/octet-stream"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); ASSERT_EQ(4U, res->body.size()); res = cli_.Delete("/binary", binary, "application/octet-stream"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); ASSERT_EQ(4U, res->body.size()); } @@ -2327,7 +2680,7 @@ TEST_F(ServerTest, LongRequest) { auto res = cli_.Get(request.c_str()); ASSERT_TRUE(res); - EXPECT_EQ(404, res->status); + EXPECT_EQ(StatusCode::NotFound_404, res->status); } TEST_F(ServerTest, TooLongRequest) { @@ -2340,7 +2693,7 @@ TEST_F(ServerTest, TooLongRequest) { auto res = cli_.Get(request.c_str()); ASSERT_TRUE(res); - EXPECT_EQ(414, res->status); + EXPECT_EQ(StatusCode::UriTooLong_414, res->status); } TEST_F(ServerTest, LongHeader) { @@ -2394,14 +2747,14 @@ TEST_F(ServerTest, LongHeader) { auto ret = cli_.send(req, *res, error); ASSERT_TRUE(ret); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST_F(ServerTest, LongQueryValue) { auto res = cli_.Get(LONG_QUERY_URL.c_str()); ASSERT_TRUE(res); - EXPECT_EQ(414, res->status); + EXPECT_EQ(StatusCode::UriTooLong_414, res->status); } TEST_F(ServerTest, TooLongHeader) { @@ -2455,43 +2808,43 @@ TEST_F(ServerTest, TooLongHeader) { auto ret = cli_.send(req, *res, error); ASSERT_TRUE(ret); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST_F(ServerTest, PercentEncoding) { auto res = cli_.Get("/e%6edwith%"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST_F(ServerTest, PercentEncodingUnicode) { auto res = cli_.Get("/e%u006edwith%"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST_F(ServerTest, InvalidPercentEncoding) { auto res = cli_.Get("/%endwith%"); ASSERT_TRUE(res); - EXPECT_EQ(404, res->status); + EXPECT_EQ(StatusCode::NotFound_404, res->status); } TEST_F(ServerTest, InvalidPercentEncodingUnicode) { auto res = cli_.Get("/%uendwith%"); ASSERT_TRUE(res); - EXPECT_EQ(404, res->status); + EXPECT_EQ(StatusCode::NotFound_404, res->status); } TEST_F(ServerTest, EndWithPercentCharacterInQuery) { auto res = cli_.Get("/hello?aaa=bbb%"); ASSERT_TRUE(res); - EXPECT_EQ(404, res->status); + EXPECT_EQ(StatusCode::NotFound_404, res->status); } TEST_F(ServerTest, PlusSignEncoding) { auto res = cli_.Get("/a+%2Bb?a %2bb=a %2Bb"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("a +b", res->body); } @@ -2507,18 +2860,36 @@ TEST_F(ServerTest, MultipartFormData) { auto res = cli_.Post("/multipart", items); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } -TEST_F(ServerTest, CaseInsensitiveHeaderName) { - auto res = cli_.Get("/hi"); - ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); - EXPECT_EQ("text/plain", res->get_header_value("content-type")); - EXPECT_EQ("Hello World!", res->body); -} +TEST_F(ServerTest, MultipartFormDataMultiFileValues) { + MultipartFormDataItems items = { + {"text", "default text", "", ""}, -TEST_F(ServerTest, CaseInsensitiveTransferEncoding) { + {"multi_text1", "aaaaa", "", ""}, + {"multi_text1", "bbbbb", "", ""}, + + {"multi_file1", "h\ne\n\nl\nl\no\n", "hello.txt", "text/plain"}, + {"multi_file1", "{\n \"world\", true\n}\n", "world.json", + "application/json"}, + }; + + auto res = cli_.Post("/multipart/multi_file_values", items); + + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::OK_200, res->status); +} + +TEST_F(ServerTest, CaseInsensitiveHeaderName) { + auto res = cli_.Get("/hi"); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::OK_200, res->status); + EXPECT_EQ("text/plain", res->get_header_value("content-type")); + EXPECT_EQ("Hello World!", res->body); +} + +TEST_F(ServerTest, CaseInsensitiveTransferEncoding) { Request req; req.method = "POST"; req.path = "/chunked"; @@ -2545,21 +2916,23 @@ TEST_F(ServerTest, CaseInsensitiveTransferEncoding) { auto ret = cli_.send(req, *res, error); ASSERT_TRUE(ret); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST_F(ServerTest, GetStreamed2) { auto res = cli_.Get("/streamed", {{make_range_header({{2, 3}})}}); ASSERT_TRUE(res); - EXPECT_EQ(206, res->status); + EXPECT_EQ(StatusCode::PartialContent_206, res->status); EXPECT_EQ("2", res->get_header_value("Content-Length")); + EXPECT_EQ(true, res->has_header("Content-Range")); + EXPECT_EQ("bytes 2-3/6", res->get_header_value("Content-Range")); EXPECT_EQ(std::string("ab"), res->body); } TEST_F(ServerTest, GetStreamed) { auto res = cli_.Get("/streamed"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("6", res->get_header_value("Content-Length")); EXPECT_EQ(std::string("aaabbb"), res->body); } @@ -2567,37 +2940,40 @@ TEST_F(ServerTest, GetStreamed) { TEST_F(ServerTest, GetStreamedWithRange1) { auto res = cli_.Get("/streamed-with-range", {{make_range_header({{3, 5}})}}); ASSERT_TRUE(res); - EXPECT_EQ(206, res->status); + EXPECT_EQ(StatusCode::PartialContent_206, res->status); EXPECT_EQ("3", res->get_header_value("Content-Length")); EXPECT_EQ(true, res->has_header("Content-Range")); + EXPECT_EQ("bytes 3-5/7", res->get_header_value("Content-Range")); EXPECT_EQ(std::string("def"), res->body); } TEST_F(ServerTest, GetStreamedWithRange2) { auto res = cli_.Get("/streamed-with-range", {{make_range_header({{1, -1}})}}); ASSERT_TRUE(res); - EXPECT_EQ(206, res->status); + EXPECT_EQ(StatusCode::PartialContent_206, res->status); EXPECT_EQ("6", res->get_header_value("Content-Length")); EXPECT_EQ(true, res->has_header("Content-Range")); + EXPECT_EQ("bytes 1-6/7", res->get_header_value("Content-Range")); EXPECT_EQ(std::string("bcdefg"), res->body); } TEST_F(ServerTest, GetStreamedWithRangeSuffix1) { auto res = cli_.Get("/streamed-with-range", {{"Range", "bytes=-3"}}); ASSERT_TRUE(res); - EXPECT_EQ(206, res->status); + EXPECT_EQ(StatusCode::PartialContent_206, res->status); EXPECT_EQ("3", res->get_header_value("Content-Length")); EXPECT_EQ(true, res->has_header("Content-Range")); + EXPECT_EQ("bytes 4-6/7", res->get_header_value("Content-Range")); EXPECT_EQ(std::string("efg"), res->body); } TEST_F(ServerTest, GetStreamedWithRangeSuffix2) { - auto res = cli_.Get("/streamed-with-range", {{"Range", "bytes=-9999"}}); + auto res = cli_.Get("/streamed-with-range?error", {{"Range", "bytes=-9999"}}); ASSERT_TRUE(res); - EXPECT_EQ(206, res->status); - EXPECT_EQ("7", res->get_header_value("Content-Length")); - EXPECT_EQ(true, res->has_header("Content-Range")); - EXPECT_EQ(std::string("abcdefg"), res->body); + EXPECT_EQ(StatusCode::RangeNotSatisfiable_416, res->status); + EXPECT_EQ("0", res->get_header_value("Content-Length")); + EXPECT_EQ(false, res->has_header("Content-Range")); + EXPECT_EQ(0U, res->body.size()); } TEST_F(ServerTest, GetStreamedWithRangeError) { @@ -2605,26 +2981,64 @@ TEST_F(ServerTest, GetStreamedWithRangeError) { {{"Range", "bytes=92233720368547758079223372036854775806-" "92233720368547758079223372036854775807"}}); ASSERT_TRUE(res); - EXPECT_EQ(416, res->status); + EXPECT_EQ(StatusCode::RangeNotSatisfiable_416, res->status); + EXPECT_EQ("0", res->get_header_value("Content-Length")); + EXPECT_EQ(false, res->has_header("Content-Range")); + EXPECT_EQ(0U, res->body.size()); } TEST_F(ServerTest, GetRangeWithMaxLongLength) { auto res = cli_.Get("/with-range", {{"Range", "bytes=0-9223372036854775807"}}); - EXPECT_EQ(206, res->status); - EXPECT_EQ("7", res->get_header_value("Content-Length")); - EXPECT_EQ(true, res->has_header("Content-Range")); - EXPECT_EQ(std::string("abcdefg"), res->body); + EXPECT_EQ(StatusCode::RangeNotSatisfiable_416, res->status); + EXPECT_EQ("0", res->get_header_value("Content-Length")); + EXPECT_EQ(false, res->has_header("Content-Range")); + EXPECT_EQ(0U, res->body.size()); } TEST_F(ServerTest, GetStreamedWithRangeMultipart) { auto res = cli_.Get("/streamed-with-range", {{make_range_header({{1, 2}, {4, 5}})}}); ASSERT_TRUE(res); - EXPECT_EQ(206, res->status); - EXPECT_EQ("269", res->get_header_value("Content-Length")); + EXPECT_EQ(StatusCode::PartialContent_206, res->status); + EXPECT_EQ("267", res->get_header_value("Content-Length")); + EXPECT_EQ(false, res->has_header("Content-Range")); + EXPECT_EQ(267U, res->body.size()); +} + +TEST_F(ServerTest, GetStreamedWithTooManyRanges) { + Ranges ranges; + for (size_t i = 0; i < CPPHTTPLIB_RANGE_MAX_COUNT + 1; i++) { + ranges.emplace_back(0, -1); + } + + auto res = + cli_.Get("/streamed-with-range?error", {{make_range_header(ranges)}}); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::RangeNotSatisfiable_416, res->status); + EXPECT_EQ("0", res->get_header_value("Content-Length")); + EXPECT_EQ(false, res->has_header("Content-Range")); + EXPECT_EQ(0U, res->body.size()); +} + +TEST_F(ServerTest, GetStreamedWithNonAscendingRanges) { + auto res = cli_.Get("/streamed-with-range?error", + {{make_range_header({{0, -1}, {0, -1}})}}); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::RangeNotSatisfiable_416, res->status); + EXPECT_EQ("0", res->get_header_value("Content-Length")); EXPECT_EQ(false, res->has_header("Content-Range")); - EXPECT_EQ(269U, res->body.size()); + EXPECT_EQ(0U, res->body.size()); +} + +TEST_F(ServerTest, GetStreamedWithRangesMoreThanTwoOverwrapping) { + auto res = cli_.Get("/streamed-with-range?error", + {{make_range_header({{0, 1}, {1, 2}, {2, 3}, {3, 4}})}}); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::RangeNotSatisfiable_416, res->status); + EXPECT_EQ("0", res->get_header_value("Content-Length")); + EXPECT_EQ(false, res->has_header("Content-Range")); + EXPECT_EQ(0U, res->body.size()); } TEST_F(ServerTest, GetStreamedEndless) { @@ -2642,19 +3056,24 @@ TEST_F(ServerTest, GetStreamedEndless) { } TEST_F(ServerTest, ClientStop) { + std::atomic_size_t count{4}; std::vector threads; - for (auto i = 0; i < 3; i++) { - threads.emplace_back(thread([&]() { + + for (auto i = count.load(); i != 0; --i) { + threads.emplace_back([&]() { auto res = cli_.Get("/streamed-cancel", [&](const char *, uint64_t) { return true; }); + + --count; + ASSERT_TRUE(!res); EXPECT_TRUE(res.error() == Error::Canceled || res.error() == Error::Read || res.error() == Error::Write); - })); + }); } std::this_thread::sleep_for(std::chrono::seconds(2)); - while (cli_.is_socket_open()) { + while (count != 0) { cli_.stop(); std::this_thread::sleep_for(std::chrono::milliseconds(10)); } @@ -2666,73 +3085,92 @@ TEST_F(ServerTest, ClientStop) { TEST_F(ServerTest, GetWithRange1) { auto res = cli_.Get("/with-range", {{make_range_header({{3, 5}})}}); ASSERT_TRUE(res); - EXPECT_EQ(206, res->status); + EXPECT_EQ(StatusCode::PartialContent_206, res->status); EXPECT_EQ("3", res->get_header_value("Content-Length")); EXPECT_EQ(true, res->has_header("Content-Range")); + EXPECT_EQ("bytes 3-5/7", res->get_header_value("Content-Range")); EXPECT_EQ(std::string("def"), res->body); } TEST_F(ServerTest, GetWithRange2) { auto res = cli_.Get("/with-range", {{make_range_header({{1, -1}})}}); ASSERT_TRUE(res); - EXPECT_EQ(206, res->status); + EXPECT_EQ(StatusCode::PartialContent_206, res->status); EXPECT_EQ("6", res->get_header_value("Content-Length")); EXPECT_EQ(true, res->has_header("Content-Range")); + EXPECT_EQ("bytes 1-6/7", res->get_header_value("Content-Range")); EXPECT_EQ(std::string("bcdefg"), res->body); } TEST_F(ServerTest, GetWithRange3) { auto res = cli_.Get("/with-range", {{make_range_header({{0, 0}})}}); ASSERT_TRUE(res); - EXPECT_EQ(206, res->status); + EXPECT_EQ(StatusCode::PartialContent_206, res->status); EXPECT_EQ("1", res->get_header_value("Content-Length")); EXPECT_EQ(true, res->has_header("Content-Range")); + EXPECT_EQ("bytes 0-0/7", res->get_header_value("Content-Range")); EXPECT_EQ(std::string("a"), res->body); } TEST_F(ServerTest, GetWithRange4) { auto res = cli_.Get("/with-range", {{make_range_header({{-1, 2}})}}); ASSERT_TRUE(res); - EXPECT_EQ(206, res->status); + EXPECT_EQ(StatusCode::PartialContent_206, res->status); EXPECT_EQ("2", res->get_header_value("Content-Length")); EXPECT_EQ(true, res->has_header("Content-Range")); + EXPECT_EQ("bytes 5-6/7", res->get_header_value("Content-Range")); EXPECT_EQ(std::string("fg"), res->body); } TEST_F(ServerTest, GetWithRangeOffsetGreaterThanContent) { auto res = cli_.Get("/with-range", {{make_range_header({{10000, 20000}})}}); ASSERT_TRUE(res); - EXPECT_EQ(416, res->status); + EXPECT_EQ(StatusCode::RangeNotSatisfiable_416, res->status); } TEST_F(ServerTest, GetWithRangeMultipart) { auto res = cli_.Get("/with-range", {{make_range_header({{1, 2}, {4, 5}})}}); ASSERT_TRUE(res); - EXPECT_EQ(206, res->status); - EXPECT_EQ("269", res->get_header_value("Content-Length")); + EXPECT_EQ(StatusCode::PartialContent_206, res->status); + EXPECT_EQ("267", res->get_header_value("Content-Length")); EXPECT_EQ(false, res->has_header("Content-Range")); - EXPECT_EQ(269U, res->body.size()); + EXPECT_EQ(267U, res->body.size()); } TEST_F(ServerTest, GetWithRangeMultipartOffsetGreaterThanContent) { auto res = cli_.Get("/with-range", {{make_range_header({{-1, 2}, {10000, 30000}})}}); ASSERT_TRUE(res); - EXPECT_EQ(416, res->status); + EXPECT_EQ(StatusCode::RangeNotSatisfiable_416, res->status); +} + +TEST_F(ServerTest, Issue1772) { + auto res = cli_.Get("/issue1772", {{make_range_header({{1000, -1}})}}); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::Unauthorized_401, res->status); } TEST_F(ServerTest, GetStreamedChunked) { auto res = cli_.Get("/streamed-chunked"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ(std::string("123456789"), res->body); } TEST_F(ServerTest, GetStreamedChunked2) { auto res = cli_.Get("/streamed-chunked2"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); + EXPECT_EQ(std::string("123456789"), res->body); +} + +TEST_F(ServerTest, GetStreamedChunkedWithTrailer) { + auto res = cli_.Get("/streamed-chunked-with-trailer"); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ(std::string("123456789"), res->body); + EXPECT_EQ(std::string("DummyVal1"), res->get_header_value("Dummy1")); + EXPECT_EQ(std::string("DummyVal2"), res->get_header_value("Dummy2")); } TEST_F(ServerTest, LargeChunkedPost) { @@ -2764,30 +3202,36 @@ TEST_F(ServerTest, LargeChunkedPost) { auto ret = cli_.send(req, *res, error); ASSERT_TRUE(ret); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST_F(ServerTest, GetMethodRemoteAddr) { auto res = cli_.Get("/remote_addr"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("text/plain", res->get_header_value("Content-Type")); EXPECT_TRUE(res->body == "::1" || res->body == "127.0.0.1"); } +TEST_F(ServerTest, GetMethodLocalAddr) { + auto res = cli_.Get("/local_addr"); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::OK_200, res->status); + EXPECT_EQ("text/plain", res->get_header_value("Content-Type")); + EXPECT_TRUE(res->body == std::string("::1:").append(to_string(PORT)) || + res->body == std::string("127.0.0.1:").append(to_string(PORT))); +} + TEST_F(ServerTest, HTTPResponseSplitting) { auto res = cli_.Get("/http_response_splitting"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST_F(ServerTest, SlowRequest) { - request_threads_.push_back( - std::thread([=]() { auto res = cli_.Get("/slow"); })); - request_threads_.push_back( - std::thread([=]() { auto res = cli_.Get("/slow"); })); - request_threads_.push_back( - std::thread([=]() { auto res = cli_.Get("/slow"); })); + request_threads_.emplace_back([this]() { auto res = cli_.Get("/slow"); }); + request_threads_.emplace_back([this]() { auto res = cli_.Get("/slow"); }); + request_threads_.emplace_back([this]() { auto res = cli_.Get("/slow"); }); } #if 0 @@ -2805,7 +3249,7 @@ TEST_F(ServerTest, SlowPost) { "text/plain"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST_F(ServerTest, SlowPostFail) { @@ -2829,7 +3273,7 @@ TEST_F(ServerTest, SlowPostFail) { TEST_F(ServerTest, Put) { auto res = cli_.Put("/put", "PUT", "text/plain"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("PUT", res->body); } @@ -2837,14 +3281,13 @@ TEST_F(ServerTest, PutWithContentProvider) { auto res = cli_.Put( "/put", 3, [](size_t /*offset*/, size_t /*length*/, DataSink &sink) { - EXPECT_TRUE(sink.is_writable()); sink.os << "PUT"; return true; }, "text/plain"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("PUT", res->body); } @@ -2864,7 +3307,6 @@ TEST_F(ServerTest, PutWithContentProviderWithoutLength) { auto res = cli_.Put( "/put", [](size_t /*offset*/, DataSink &sink) { - EXPECT_TRUE(sink.is_writable()); sink.os << "PUT"; sink.done(); return true; @@ -2872,7 +3314,7 @@ TEST_F(ServerTest, PutWithContentProviderWithoutLength) { "text/plain"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("PUT", res->body); } @@ -2891,14 +3333,13 @@ TEST_F(ServerTest, PutWithContentProviderWithGzip) { auto res = cli_.Put( "/put", 3, [](size_t /*offset*/, size_t /*length*/, DataSink &sink) { - EXPECT_TRUE(sink.is_writable()); sink.os << "PUT"; return true; }, "text/plain"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("PUT", res->body); } @@ -2920,7 +3361,6 @@ TEST_F(ServerTest, PutWithContentProviderWithoutLengthWithGzip) { auto res = cli_.Put( "/put", [](size_t /*offset*/, DataSink &sink) { - EXPECT_TRUE(sink.is_writable()); sink.os << "PUT"; sink.done(); return true; @@ -2928,7 +3368,7 @@ TEST_F(ServerTest, PutWithContentProviderWithoutLengthWithGzip) { "text/plain"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("PUT", res->body); } @@ -2947,7 +3387,7 @@ TEST_F(ServerTest, PutLargeFileWithGzip) { auto res = cli_.Put("/put-large", LARGE_DATA, "text/plain"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ(LARGE_DATA, res->body); } @@ -2965,9 +3405,9 @@ TEST_F(ServerTest, PutLargeFileWithGzip2) { auto res = cli.Put("/put-large", LARGE_DATA, "text/plain"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ(LARGE_DATA, res->body); - EXPECT_EQ(101942u, res.get_request_header_value("Content-Length")); + EXPECT_EQ(101942u, res.get_request_header_value_u64("Content-Length")); EXPECT_EQ("gzip", res.get_request_header_value("Content-Encoding")); } @@ -2980,7 +3420,7 @@ TEST_F(ServerTest, PutContentWithDeflate) { "\170\234\013\010\015\001\0\001\361\0\372", "text/plain"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("PUT", res->body); } @@ -2990,7 +3430,7 @@ TEST_F(ServerTest, GetStreamedChunkedWithGzip) { auto res = cli_.Get("/streamed-chunked", headers); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ(std::string("123456789"), res->body); } @@ -3000,10 +3440,16 @@ TEST_F(ServerTest, GetStreamedChunkedWithGzip2) { auto res = cli_.Get("/streamed-chunked2", headers); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ(std::string("123456789"), res->body); } +TEST_F(ServerTest, SplitDelimiterInPathRegex) { + auto res = cli_.Get("/regex-with-delimiter?key=^(?.*(value))"); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::OK_200, res->status); +} + TEST(GzipDecompressor, ChunkedDecompression) { std::string data; for (size_t i = 0; i < 32 * 1024; ++i) { @@ -3015,8 +3461,10 @@ TEST(GzipDecompressor, ChunkedDecompression) { httplib::detail::gzip_compressor compressor; bool result = compressor.compress( data.data(), data.size(), - /*last=*/true, [&](const char *data, size_t size) { - compressed_data.insert(compressed_data.size(), data, size); + /*last=*/true, + [&](const char *compressed_data_chunk, size_t compressed_data_size) { + compressed_data.insert(compressed_data.size(), compressed_data_chunk, + compressed_data_size); return true; }); ASSERT_TRUE(result); @@ -3026,7 +3474,7 @@ TEST(GzipDecompressor, ChunkedDecompression) { { httplib::detail::gzip_decompressor decompressor; - // Chunk size is chosen specificaly to have a decompressed chunk size equal + // Chunk size is chosen specifically to have a decompressed chunk size equal // to 16384 bytes 16384 bytes is the size of decompressor output buffer size_t chunk_size = 130; for (size_t chunk_begin = 0; chunk_begin < compressed_data.size(); @@ -3035,8 +3483,11 @@ TEST(GzipDecompressor, ChunkedDecompression) { std::min(compressed_data.size() - chunk_begin, chunk_size); bool result = decompressor.decompress( compressed_data.data() + chunk_begin, current_chunk_size, - [&](const char *data, size_t size) { - decompressed_data.insert(decompressed_data.size(), data, size); + [&](const char *decompressed_data_chunk, + size_t decompressed_data_chunk_size) { + decompressed_data.insert(decompressed_data.size(), + decompressed_data_chunk, + decompressed_data_chunk_size); return true; }); ASSERT_TRUE(result); @@ -3045,6 +3496,59 @@ TEST(GzipDecompressor, ChunkedDecompression) { ASSERT_EQ(data, decompressed_data); } +TEST(GzipDecompressor, DeflateDecompression) { + std::string original_text = "Raw deflate without gzip"; + unsigned char data[32] = {0x78, 0x9C, 0x0B, 0x4A, 0x2C, 0x57, 0x48, 0x49, + 0x4D, 0xCB, 0x49, 0x2C, 0x49, 0x55, 0x28, 0xCF, + 0x2C, 0xC9, 0xC8, 0x2F, 0x2D, 0x51, 0x48, 0xAF, + 0xCA, 0x2C, 0x00, 0x00, 0x6F, 0x98, 0x09, 0x2E}; + std::string compressed_data(data, data + sizeof(data) / sizeof(data[0])); + + std::string decompressed_data; + { + httplib::detail::gzip_decompressor decompressor; + + bool result = decompressor.decompress( + compressed_data.data(), compressed_data.size(), + [&](const char *decompressed_data_chunk, + size_t decompressed_data_chunk_size) { + decompressed_data.insert(decompressed_data.size(), + decompressed_data_chunk, + decompressed_data_chunk_size); + return true; + }); + ASSERT_TRUE(result); + } + ASSERT_EQ(original_text, decompressed_data); +} + +TEST(GzipDecompressor, DeflateDecompressionTrailingBytes) { + std::string original_text = "Raw deflate without gzip"; + unsigned char data[40] = {0x78, 0x9C, 0x0B, 0x4A, 0x2C, 0x57, 0x48, 0x49, + 0x4D, 0xCB, 0x49, 0x2C, 0x49, 0x55, 0x28, 0xCF, + 0x2C, 0xC9, 0xC8, 0x2F, 0x2D, 0x51, 0x48, 0xAF, + 0xCA, 0x2C, 0x00, 0x00, 0x6F, 0x98, 0x09, 0x2E, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + std::string compressed_data(data, data + sizeof(data) / sizeof(data[0])); + + std::string decompressed_data; + { + httplib::detail::gzip_decompressor decompressor; + + bool result = decompressor.decompress( + compressed_data.data(), compressed_data.size(), + [&](const char *decompressed_data_chunk, + size_t decompressed_data_chunk_size) { + decompressed_data.insert(decompressed_data.size(), + decompressed_data_chunk, + decompressed_data_chunk_size); + return true; + }); + ASSERT_TRUE(result); + } + ASSERT_EQ(original_text, decompressed_data); +} + #ifdef _WIN32 TEST(GzipDecompressor, LargeRandomData) { @@ -3101,7 +3605,7 @@ TEST_F(ServerTest, GetStreamedChunkedWithBrotli) { auto res = cli_.Get("/streamed-chunked", headers); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ(std::string("123456789"), res->body); } @@ -3111,7 +3615,7 @@ TEST_F(ServerTest, GetStreamedChunkedWithBrotli2) { auto res = cli_.Get("/streamed-chunked2", headers); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ(std::string("123456789"), res->body); } #endif @@ -3119,28 +3623,28 @@ TEST_F(ServerTest, GetStreamedChunkedWithBrotli2) { TEST_F(ServerTest, Patch) { auto res = cli_.Patch("/patch", "PATCH", "text/plain"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("PATCH", res->body); } TEST_F(ServerTest, Delete) { auto res = cli_.Delete("/delete"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("DELETE", res->body); } TEST_F(ServerTest, DeleteContentReceiver) { auto res = cli_.Delete("/delete-body", "content", "text/plain"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("content", res->body); } TEST_F(ServerTest, Options) { auto res = cli_.Options("*"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("GET, POST, HEAD, OPTIONS", res->get_header_value("Allow")); EXPECT_TRUE(res->body.empty()); } @@ -3148,13 +3652,13 @@ TEST_F(ServerTest, Options) { TEST_F(ServerTest, URL) { auto res = cli_.Get("/request-target?aaa=bbb&ccc=ddd"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST_F(ServerTest, ArrayParam) { auto res = cli_.Get("/array-param?array=value1&array=value2&array=value3"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST_F(ServerTest, NoMultipleHeaders) { @@ -3162,17 +3666,17 @@ TEST_F(ServerTest, NoMultipleHeaders) { auto res = cli_.Post("/validate-no-multiple-headers", headers, "hello", "text/plain"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST_F(ServerTest, PostContentReceiver) { auto res = cli_.Post("/content_receiver", "content", "text/plain"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); ASSERT_EQ("content", res->body); } -TEST_F(ServerTest, PostMulitpartFilsContentReceiver) { +TEST_F(ServerTest, PostMultipartFileContentReceiver) { MultipartFormDataItems items = { {"text1", "text default", "", ""}, {"text2", "aωb", "", ""}, @@ -3184,10 +3688,10 @@ TEST_F(ServerTest, PostMulitpartFilsContentReceiver) { auto res = cli_.Post("/content_receiver", items); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } -TEST_F(ServerTest, PostMulitpartPlusBoundary) { +TEST_F(ServerTest, PostMultipartPlusBoundary) { MultipartFormDataItems items = { {"text1", "text default", "", ""}, {"text2", "aωb", "", ""}, @@ -3219,28 +3723,28 @@ TEST_F(ServerTest, PostMulitpartPlusBoundary) { auto res = cli_.Post("/content_receiver", body, content_type.c_str()); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST_F(ServerTest, PostContentReceiverGzip) { cli_.set_compress(true); auto res = cli_.Post("/content_receiver", "content", "text/plain"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); ASSERT_EQ("content", res->body); } TEST_F(ServerTest, PutContentReceiver) { auto res = cli_.Put("/content_receiver", "content", "text/plain"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); ASSERT_EQ("content", res->body); } TEST_F(ServerTest, PatchContentReceiver) { auto res = cli_.Patch("/content_receiver", "content", "text/plain"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); ASSERT_EQ("content", res->body); } @@ -3248,7 +3752,7 @@ TEST_F(ServerTest, PostQueryStringAndBody) { auto res = cli_.Post("/query-string-and-body?key=value", "content", "text/plain"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); } TEST_F(ServerTest, HTTP2Magic) { @@ -3262,35 +3766,35 @@ TEST_F(ServerTest, HTTP2Magic) { auto ret = cli_.send(req, *res, error); ASSERT_TRUE(ret); - EXPECT_EQ(400, res->status); + EXPECT_EQ(StatusCode::BadRequest_400, res->status); } TEST_F(ServerTest, KeepAlive) { auto res = cli_.Get("/hi"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("text/plain", res->get_header_value("Content-Type")); EXPECT_EQ("Hello World!", res->body); res = cli_.Get("/hi"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("text/plain", res->get_header_value("Content-Type")); EXPECT_EQ("Hello World!", res->body); res = cli_.Get("/hi"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("text/plain", res->get_header_value("Content-Type")); EXPECT_EQ("Hello World!", res->body); res = cli_.Get("/not-exist"); ASSERT_TRUE(res); - EXPECT_EQ(404, res->status); + EXPECT_EQ(StatusCode::NotFound_404, res->status); res = cli_.Post("/empty", "", "text/plain"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("text/plain", res->get_header_value("Content-Type")); EXPECT_EQ("empty", res->body); EXPECT_EQ("close", res->get_header_value("Connection")); @@ -3299,14 +3803,14 @@ TEST_F(ServerTest, KeepAlive) { "/empty", 0, [&](size_t, size_t, DataSink &) { return true; }, "text/plain"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("text/plain", res->get_header_value("Content-Type")); EXPECT_EQ("empty", res->body); cli_.set_keep_alive(false); res = cli_.Get("/last-request"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("close", res->get_header_value("Connection")); } @@ -3330,7 +3834,7 @@ TEST_F(ServerTest, Gzip) { EXPECT_EQ("123456789012345678901234567890123456789012345678901234567890123456" "7890123456789012345678901234567890", res->body); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST_F(ServerTest, GzipWithoutAcceptEncoding) { @@ -3343,7 +3847,7 @@ TEST_F(ServerTest, GzipWithoutAcceptEncoding) { EXPECT_EQ("123456789012345678901234567890123456789012345678901234567890123456" "7890123456789012345678901234567890", res->body); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST_F(ServerTest, GzipWithContentReceiver) { @@ -3364,7 +3868,7 @@ TEST_F(ServerTest, GzipWithContentReceiver) { EXPECT_EQ("123456789012345678901234567890123456789012345678901234567890123456" "7890123456789012345678901234567890", body); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST_F(ServerTest, GzipWithoutDecompressing) { @@ -3379,7 +3883,7 @@ TEST_F(ServerTest, GzipWithoutDecompressing) { EXPECT_EQ("text/plain", res->get_header_value("Content-Type")); EXPECT_EQ("33", res->get_header_value("Content-Length")); EXPECT_EQ(33U, res->body.size()); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST_F(ServerTest, GzipWithContentReceiverWithoutAcceptEncoding) { @@ -3397,7 +3901,7 @@ TEST_F(ServerTest, GzipWithContentReceiverWithoutAcceptEncoding) { EXPECT_EQ("123456789012345678901234567890123456789012345678901234567890123456" "7890123456789012345678901234567890", body); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST_F(ServerTest, NoGzip) { @@ -3412,7 +3916,7 @@ TEST_F(ServerTest, NoGzip) { EXPECT_EQ("123456789012345678901234567890123456789012345678901234567890123456" "7890123456789012345678901234567890", res->body); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST_F(ServerTest, NoGzipWithContentReceiver) { @@ -3433,7 +3937,7 @@ TEST_F(ServerTest, NoGzipWithContentReceiver) { EXPECT_EQ("123456789012345678901234567890123456789012345678901234567890123456" "7890123456789012345678901234567890", body); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST_F(ServerTest, MultipartFormDataGzip) { @@ -3446,7 +3950,7 @@ TEST_F(ServerTest, MultipartFormDataGzip) { auto res = cli_.Post("/compress-multipart", items); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } #endif @@ -3463,7 +3967,7 @@ TEST_F(ServerTest, Brotli) { EXPECT_EQ("123456789012345678901234567890123456789012345678901234567890123456" "7890123456789012345678901234567890", res->body); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } #endif @@ -3510,9 +4014,13 @@ TEST(ServerRequestParsingTest, TrimWhitespaceFromHeaderValues) { }); thread t = thread([&] { svr.listen(HOST, PORT); }); - while (!svr.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } + auto se = detail::scope_exit([&] { + svr.stop(); + t.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); // Only space and horizontal tab are whitespace. Make sure other whitespace- // like characters are not treated the same - use vertical tab and escape. @@ -3522,8 +4030,6 @@ TEST(ServerRequestParsingTest, TrimWhitespaceFromHeaderValues) { "\r\n"; ASSERT_TRUE(send_request(5, req)); - svr.stop(); - t.join(); EXPECT_EQ(header_value, "\v bar \x1B"); } @@ -3545,14 +4051,16 @@ static void test_raw_request(const std::string &req, svr.set_read_timeout(std::chrono::seconds(client_read_timeout_sec + 1)); bool listen_thread_ok = false; thread t = thread([&] { listen_thread_ok = svr.listen(HOST, PORT); }); - while (!svr.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } + auto se = detail::scope_exit([&] { + svr.stop(); + t.join(); + ASSERT_FALSE(svr.is_running()); + EXPECT_TRUE(listen_thread_ok); + }); + + svr.wait_until_ready(); ASSERT_TRUE(send_request(client_read_timeout_sec, req, out)); - svr.stop(); - t.join(); - EXPECT_TRUE(listen_thread_ok); } TEST(ServerRequestParsingTest, ReadHeadersRegexComplexity) { @@ -3603,10 +4111,10 @@ TEST(ServerRequestParsingTest, ReadHeadersRegexComplexity2) { "&&&%%%"); } -TEST(ServerRequestParsingTest, ExcessiveWhitespaceInUnparseableHeaderLine) { +TEST(ServerRequestParsingTest, ExcessiveWhitespaceInUnparsableHeaderLine) { // Make sure this doesn't crash the server. // In a previous version of the header line regex, the "\r" rendered the line - // unparseable and the regex engine repeatedly backtracked, trying to look for + // unparsable and the regex engine repeatedly backtracked, trying to look for // a new position where the leading white space ended and the field value // began. // The crash occurs with libc++ but not libstdc++. @@ -3673,21 +4181,20 @@ TEST(ServerStopTest, StopServerWithChunkedTransmission) { svr.Get("/events", [](const Request & /*req*/, Response &res) { res.set_header("Cache-Control", "no-cache"); - res.set_chunked_content_provider("text/event-stream", [](size_t offset, - DataSink &sink) { - char buffer[27]; - auto size = static_cast(sprintf(buffer, "data:%zd\n\n", offset)); - auto ret = sink.write(buffer, size); - EXPECT_TRUE(ret); - std::this_thread::sleep_for(std::chrono::seconds(1)); - return true; - }); + res.set_chunked_content_provider( + "text/event-stream", [](size_t offset, DataSink &sink) { + std::string s = "data:"; + s += std::to_string(offset); + s += "\n\n"; + auto ret = sink.write(s.data(), s.size()); + EXPECT_TRUE(ret); + std::this_thread::sleep_for(std::chrono::seconds(1)); + return true; + }); }); auto listen_thread = std::thread([&svr]() { svr.listen("localhost", PORT); }); - while (!svr.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } + svr.wait_until_ready(); Client client(HOST, PORT); const Headers headers = {{"Accept", "text/event-stream"}}; @@ -3697,16 +4204,51 @@ TEST(ServerStopTest, StopServerWithChunkedTransmission) { "/events", headers, [](const char * /*data*/, size_t /*len*/) -> bool { return true; }); }); + auto se = detail::scope_exit([&] { + svr.stop(); + get_thread.join(); + listen_thread.join(); + ASSERT_FALSE(svr.is_running()); + }); // Give GET time to get a few messages. std::this_thread::sleep_for(std::chrono::seconds(2)); +} - svr.stop(); +TEST(ServerStopTest, ClientAccessAfterServerDown) { + httplib::Server svr; + svr.Post("/hi", + [&](const httplib::Request & /*req*/, httplib::Response &res) { + res.status = StatusCode::OK_200; + }); - listen_thread.join(); - get_thread.join(); + auto thread = std::thread([&]() { svr.listen(HOST, PORT); }); + svr.wait_until_ready(); + + Client cli(HOST, PORT); + + auto res = cli.Post("/hi", "data", "text/plain"); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::OK_200, res->status); + + svr.stop(); + thread.join(); ASSERT_FALSE(svr.is_running()); + + res = cli.Post("/hi", "data", "text/plain"); + ASSERT_FALSE(res); +} + +TEST(ServerStopTest, ListenFailure) { + Server svr; + auto t = thread([&]() { + auto ret = svr.listen("????", PORT); + EXPECT_FALSE(ret); + }); + svr.wait_until_ready(); + svr.stop(); + t.join(); } TEST(StreamingTest, NoContentLengthStreaming) { @@ -3724,9 +4266,13 @@ TEST(StreamingTest, NoContentLengthStreaming) { }); auto listen_thread = std::thread([&svr]() { svr.listen("localhost", PORT); }); - while (!svr.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } + auto listen_se = detail::scope_exit([&] { + svr.stop(); + listen_thread.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); Client client(HOST, PORT); @@ -3739,28 +4285,23 @@ TEST(StreamingTest, NoContentLengthStreaming) { }); EXPECT_EQ("aaabbb", s); }); + auto get_se = detail::scope_exit([&] { get_thread.join(); }); // Give GET time to get a few messages. std::this_thread::sleep_for(std::chrono::milliseconds(500)); - - svr.stop(); - - listen_thread.join(); - get_thread.join(); - - ASSERT_FALSE(svr.is_running()); } TEST(MountTest, Unmount) { Server svr; auto listen_thread = std::thread([&svr]() { svr.listen("localhost", PORT); }); - while (!svr.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } + auto se = detail::scope_exit([&] { + svr.stop(); + listen_thread.join(); + ASSERT_FALSE(svr.is_running()); + }); - // Give GET time to get a few messages. - std::this_thread::sleep_for(std::chrono::seconds(1)); + svr.wait_until_ready(); Client cli("localhost", PORT); @@ -3768,61 +4309,67 @@ TEST(MountTest, Unmount) { auto res = cli.Get("/"); ASSERT_TRUE(res); - EXPECT_EQ(404, res->status); + EXPECT_EQ(StatusCode::NotFound_404, res->status); res = cli.Get("/mount2/dir/test.html"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); svr.set_mount_point("/", "./www"); res = cli.Get("/dir/"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); svr.remove_mount_point("/"); res = cli.Get("/dir/"); ASSERT_TRUE(res); - EXPECT_EQ(404, res->status); + EXPECT_EQ(StatusCode::NotFound_404, res->status); svr.remove_mount_point("/mount2"); res = cli.Get("/mount2/dir/test.html"); ASSERT_TRUE(res); - EXPECT_EQ(404, res->status); - - svr.stop(); - listen_thread.join(); - ASSERT_FALSE(svr.is_running()); + EXPECT_EQ(StatusCode::NotFound_404, res->status); } #ifndef CPPHTTPLIB_NO_EXCEPTIONS TEST(ExceptionTest, ThrowExceptionInHandler) { Server svr; - svr.Get("/hi", [&](const Request & /*req*/, Response & /*res*/) { + svr.Get("/exception", [&](const Request & /*req*/, Response & /*res*/) { throw std::runtime_error("exception..."); - // res.set_content("Hello World!", "text/plain"); + }); + + svr.Get("/unknown", [&](const Request & /*req*/, Response & /*res*/) { + throw std::runtime_error("exception\r\n..."); }); auto listen_thread = std::thread([&svr]() { svr.listen("localhost", PORT); }); - while (!svr.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } + auto se = detail::scope_exit([&] { + svr.stop(); + listen_thread.join(); + ASSERT_FALSE(svr.is_running()); + }); - // Give GET time to get a few messages. - std::this_thread::sleep_for(std::chrono::seconds(1)); + svr.wait_until_ready(); Client cli("localhost", PORT); - auto res = cli.Get("/hi"); - ASSERT_TRUE(res); - EXPECT_EQ(500, res->status); - ASSERT_TRUE(res->has_header("EXCEPTION_WHAT")); - EXPECT_EQ("exception...", res->get_header_value("EXCEPTION_WHAT")); + { + auto res = cli.Get("/exception"); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::InternalServerError_500, res->status); + ASSERT_TRUE(res->has_header("EXCEPTION_WHAT")); + EXPECT_EQ("exception...", res->get_header_value("EXCEPTION_WHAT")); + } - svr.stop(); - listen_thread.join(); - ASSERT_FALSE(svr.is_running()); + { + auto res = cli.Get("/unknown"); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::InternalServerError_500, res->status); + ASSERT_TRUE(res->has_header("EXCEPTION_WHAT")); + EXPECT_EQ("exception\\r\\n...", res->get_header_value("EXCEPTION_WHAT")); + } } #endif @@ -3839,60 +4386,102 @@ TEST(KeepAliveTest, ReadTimeout) { }); auto listen_thread = std::thread([&svr]() { svr.listen("localhost", PORT); }); - while (!svr.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } + auto se = detail::scope_exit([&] { + svr.stop(); + listen_thread.join(); + ASSERT_FALSE(svr.is_running()); + }); - // Give GET time to get a few messages. - std::this_thread::sleep_for(std::chrono::seconds(1)); + svr.wait_until_ready(); Client cli("localhost", PORT); cli.set_keep_alive(true); cli.set_read_timeout(std::chrono::seconds(1)); auto resa = cli.Get("/a"); - ASSERT_TRUE(!resa); + ASSERT_FALSE(resa); EXPECT_EQ(Error::Read, resa.error()); auto resb = cli.Get("/b"); ASSERT_TRUE(resb); - EXPECT_EQ(200, resb->status); + EXPECT_EQ(StatusCode::OK_200, resb->status); EXPECT_EQ("b", resb->body); - - svr.stop(); - listen_thread.join(); - ASSERT_FALSE(svr.is_running()); } TEST(KeepAliveTest, Issue1041) { - const auto resourcePath = "/hi"; - Server svr; svr.set_keep_alive_timeout(3); - svr.Get(resourcePath, [](const httplib::Request &, httplib::Response &res) { + svr.Get("/hi", [](const httplib::Request &, httplib::Response &res) { res.set_content("Hello World!", "text/plain"); }); - auto a2 = std::async(std::launch::async, [&svr] { svr.listen(HOST, PORT); }); - std::this_thread::sleep_for(std::chrono::milliseconds(200)); + auto listen_thread = std::thread([&svr] { svr.listen(HOST, PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + listen_thread.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); Client cli(HOST, PORT); cli.set_keep_alive(true); - auto result = cli.Get(resourcePath); + auto result = cli.Get("/hi"); ASSERT_TRUE(result); - EXPECT_EQ(200, result->status); + EXPECT_EQ(StatusCode::OK_200, result->status); std::this_thread::sleep_for(std::chrono::seconds(5)); - result = cli.Get(resourcePath); + result = cli.Get("/hi"); ASSERT_TRUE(result); - EXPECT_EQ(200, result->status); + EXPECT_EQ(StatusCode::OK_200, result->status); +} - svr.stop(); - a2.wait(); +#ifdef CPPHTTPLIB_OPENSSL_SUPPORT +TEST(KeepAliveTest, SSLClientReconnection) { + SSLServer svr(SERVER_CERT_FILE, SERVER_PRIVATE_KEY_FILE); + ASSERT_TRUE(svr.is_valid()); + svr.set_keep_alive_timeout(1); + + svr.Get("/hi", [](const httplib::Request &, httplib::Response &res) { + res.set_content("Hello World!", "text/plain"); + }); + + auto listen_thread = std::thread([&svr] { svr.listen(HOST, PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + listen_thread.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); + + SSLClient cli(HOST, PORT); + cli.enable_server_certificate_verification(false); + cli.set_keep_alive(true); + + auto result = cli.Get("/hi"); + ASSERT_TRUE(result); + EXPECT_EQ(StatusCode::OK_200, result->status); + + result = cli.Get("/hi"); + ASSERT_TRUE(result); + EXPECT_EQ(StatusCode::OK_200, result->status); + + std::this_thread::sleep_for(std::chrono::seconds(2)); + + // Recoonect + result = cli.Get("/hi"); + ASSERT_TRUE(result); + EXPECT_EQ(StatusCode::OK_200, result->status); + + result = cli.Get("/hi"); + ASSERT_TRUE(result); + EXPECT_EQ(StatusCode::OK_200, result->status); } +#endif TEST(ClientProblemDetectionTest, ContentProvider) { Server svr; @@ -3911,25 +4500,38 @@ TEST(ClientProblemDetectionTest, ContentProvider) { [](bool success) { ASSERT_FALSE(success); }); }); + svr.Get("/empty", [&](const Request & /*req*/, Response &res) { + res.set_content_provider( + 0, "text/plain", + [&](size_t /*offset*/, size_t /*length*/, DataSink & /*sink*/) -> bool { + EXPECT_TRUE(false); + return true; + }, + [](bool success) { ASSERT_FALSE(success); }); + }); + auto listen_thread = std::thread([&svr]() { svr.listen("localhost", PORT); }); - while (!svr.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } + auto se = detail::scope_exit([&] { + svr.stop(); + listen_thread.join(); + ASSERT_FALSE(svr.is_running()); + }); - // Give GET time to get a few messages. - std::this_thread::sleep_for(std::chrono::seconds(1)); + svr.wait_until_ready(); Client cli("localhost", PORT); - auto res = cli.Get("/hi", [&](const char * /*data*/, size_t /*data_length*/) { - return false; - }); - - ASSERT_FALSE(res); + { + auto res = cli.Get("/hi", [&](const char * /*data*/, + size_t /*data_length*/) { return false; }); + ASSERT_FALSE(res); + } - svr.stop(); - listen_thread.join(); - ASSERT_FALSE(svr.is_running()); + { + auto res = cli.Get("/empty", [&](const char * /*data*/, + size_t /*data_length*/) { return false; }); + ASSERT_TRUE(res); + } } TEST(ErrorHandlerWithContentProviderTest, ErrorHandler) { @@ -3946,23 +4548,57 @@ TEST(ErrorHandlerWithContentProviderTest, ErrorHandler) { }); auto listen_thread = std::thread([&svr]() { svr.listen("localhost", PORT); }); - while (!svr.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } + auto se = detail::scope_exit([&] { + svr.stop(); + listen_thread.join(); + ASSERT_FALSE(svr.is_running()); + }); - // Give GET time to get a few messages. - std::this_thread::sleep_for(std::chrono::seconds(1)); + svr.wait_until_ready(); Client cli("localhost", PORT); auto res = cli.Get("/"); ASSERT_TRUE(res); - EXPECT_EQ(404, res->status); + EXPECT_EQ(StatusCode::NotFound_404, res->status); EXPECT_EQ("helloworld", res->body); +} - svr.stop(); - listen_thread.join(); - ASSERT_FALSE(svr.is_running()); +TEST(LongPollingTest, ClientCloseDetection) { + Server svr; + + svr.Get("/events", [&](const Request & /*req*/, Response &res) { + res.set_chunked_content_provider( + "text/plain", [](std::size_t const, DataSink &sink) -> bool { + EXPECT_TRUE(sink.is_writable()); // the socket is alive + sink.os << "hello"; + + auto count = 10; + while (count > 0 && sink.is_writable()) { + this_thread::sleep_for(chrono::milliseconds(10)); + } + EXPECT_FALSE(sink.is_writable()); // the socket is closed + return true; + }); + }); + + auto listen_thread = std::thread([&svr]() { svr.listen("localhost", PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + listen_thread.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); + + Client cli("localhost", PORT); + + auto res = cli.Get("/events", [&](const char *data, size_t data_length) { + EXPECT_EQ("hello", string(data, data_length)); + return false; // close the socket immediately. + }); + + ASSERT_FALSE(res); } TEST(GetWithParametersTest, GetWithParameters) { @@ -3986,11 +4622,20 @@ TEST(GetWithParametersTest, GetWithParameters) { EXPECT_EQ("bar", req.get_param_value("param2")); }); + svr.Get("/users/:id", [&](const Request &req, Response &) { + EXPECT_EQ("user-id", req.path_params.at("id")); + EXPECT_EQ("foo", req.get_param_value("param1")); + EXPECT_EQ("bar", req.get_param_value("param2")); + }); + auto listen_thread = std::thread([&svr]() { svr.listen(HOST, PORT); }); - while (!svr.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } - std::this_thread::sleep_for(std::chrono::seconds(1)); + auto se = detail::scope_exit([&] { + svr.stop(); + listen_thread.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); { Client cli(HOST, PORT); @@ -4002,7 +4647,7 @@ TEST(GetWithParametersTest, GetWithParameters) { auto res = cli.Get("/", params, Headers{}); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } { @@ -4011,7 +4656,7 @@ TEST(GetWithParametersTest, GetWithParameters) { auto res = cli.Get("/params?hello=world&hello2=world2&hello3=world3"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } { @@ -4020,12 +4665,17 @@ TEST(GetWithParametersTest, GetWithParameters) { auto res = cli.Get("/resources/resource-id?param1=foo¶m2=bar"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } - svr.stop(); - listen_thread.join(); - ASSERT_FALSE(svr.is_running()); + { + Client cli(HOST, PORT); + + auto res = cli.Get("/users/user-id?param1=foo¶m2=bar"); + + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::OK_200, res->status); + } } TEST(GetWithParametersTest, GetWithParameters2) { @@ -4037,10 +4687,13 @@ TEST(GetWithParametersTest, GetWithParameters2) { }); auto listen_thread = std::thread([&svr]() { svr.listen("localhost", PORT); }); - while (!svr.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } - std::this_thread::sleep_for(std::chrono::seconds(1)); + auto se = detail::scope_exit([&] { + svr.stop(); + listen_thread.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); Client cli("localhost", PORT); @@ -4055,31 +4708,40 @@ TEST(GetWithParametersTest, GetWithParameters2) { }); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("world", body); - - svr.stop(); - listen_thread.join(); - ASSERT_FALSE(svr.is_running()); } TEST(ClientDefaultHeadersTest, DefaultHeaders_Online) { - Client cli("httpbin.org"); +#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN + auto host = "httpbin.org"; + auto path = std::string{"/range/32"}; +#else + auto host = "nghttp2.org"; + auto path = std::string{"/httpbin/range/32"}; +#endif + +#ifdef CPPHTTPLIB_OPENSSL_SUPPORT + SSLClient cli(host); +#else + Client cli(host); +#endif + cli.set_default_headers({make_range_header({{1, 10}})}); cli.set_connection_timeout(5); { - auto res = cli.Get("/range/32"); + auto res = cli.Get(path); ASSERT_TRUE(res); EXPECT_EQ("bcdefghijk", res->body); - EXPECT_EQ(206, res->status); + EXPECT_EQ(StatusCode::PartialContent_206, res->status); } { - auto res = cli.Get("/range/32"); + auto res = cli.Get(path); ASSERT_TRUE(res); EXPECT_EQ("bcdefghijk", res->body); - EXPECT_EQ(206, res->status); + EXPECT_EQ(StatusCode::PartialContent_206, res->status); } } @@ -4092,23 +4754,22 @@ TEST(ServerDefaultHeadersTest, DefaultHeaders) { }); auto listen_thread = std::thread([&svr]() { svr.listen("localhost", PORT); }); - while (!svr.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } - std::this_thread::sleep_for(std::chrono::seconds(1)); + auto se = detail::scope_exit([&] { + svr.stop(); + listen_thread.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); Client cli("localhost", PORT); auto res = cli.Get("/"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("ok", res->body); EXPECT_EQ("World", res->get_header_value("Hello")); - - svr.stop(); - listen_thread.join(); - ASSERT_FALSE(svr.is_running()); } #ifdef CPPHTTPLIB_OPENSSL_SUPPORT @@ -4126,12 +4787,13 @@ TEST(KeepAliveTest, ReadTimeoutSSL) { }); auto listen_thread = std::thread([&svr]() { svr.listen("localhost", PORT); }); - while (!svr.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } + auto se = detail::scope_exit([&] { + svr.stop(); + listen_thread.join(); + ASSERT_FALSE(svr.is_running()); + }); - // Give GET time to get a few messages. - std::this_thread::sleep_for(std::chrono::seconds(1)); + svr.wait_until_ready(); SSLClient cli("localhost", PORT); cli.enable_server_certificate_verification(false); @@ -4144,12 +4806,8 @@ TEST(KeepAliveTest, ReadTimeoutSSL) { auto resb = cli.Get("/b"); ASSERT_TRUE(resb); - EXPECT_EQ(200, resb->status); + EXPECT_EQ(StatusCode::OK_200, resb->status); EXPECT_EQ("b", resb->body); - - svr.stop(); - listen_thread.join(); - ASSERT_FALSE(svr.is_running()); } #endif @@ -4172,11 +4830,10 @@ class ServerTestWithAI_PASSIVE : public ::testing::Test { res.set_content("Hello World!", "text/plain"); }); - t_ = thread([&]() { ASSERT_TRUE(svr_.listen(nullptr, PORT, AI_PASSIVE)); }); + t_ = thread( + [&]() { ASSERT_TRUE(svr_.listen(std::string(), PORT, AI_PASSIVE)); }); - while (!svr_.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } + svr_.wait_until_ready(); } virtual void TearDown() { @@ -4197,7 +4854,7 @@ class ServerTestWithAI_PASSIVE : public ::testing::Test { TEST_F(ServerTestWithAI_PASSIVE, GetMethod200) { auto res = cli_.Get("/hi"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("text/plain", res->get_header_value("Content-Type")); EXPECT_EQ("Hello World!", res->body); } @@ -4213,9 +4870,7 @@ class ServerUpDownTest : public ::testing::Test { ASSERT_TRUE(svr_.listen_after_bind()); }); - while (!svr_.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } + svr_.wait_until_ready(); } virtual void TearDown() { @@ -4256,9 +4911,7 @@ class PayloadMaxLengthTest : public ::testing::Test { t_ = thread([&]() { ASSERT_TRUE(svr_.listen(HOST, PORT)); }); - while (!svr_.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } + svr_.wait_until_ready(); } virtual void TearDown() { @@ -4279,13 +4932,33 @@ class PayloadMaxLengthTest : public ::testing::Test { TEST_F(PayloadMaxLengthTest, ExceedLimit) { auto res = cli_.Post("/test", "123456789", "text/plain"); ASSERT_TRUE(res); - EXPECT_EQ(413, res->status); + EXPECT_EQ(StatusCode::PayloadTooLarge_413, res->status); res = cli_.Post("/test", "12345678", "text/plain"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); +} + +TEST(HostAndPortPropertiesTest, NoSSL) { + httplib::Client cli("www.google.com", 1234); + ASSERT_EQ("www.google.com", cli.host()); + ASSERT_EQ(1234, cli.port()); +} + +TEST(HostAndPortPropertiesTest, NoSSLWithSimpleAPI) { + httplib::Client cli("www.google.com:1234"); + ASSERT_EQ("www.google.com", cli.host()); + ASSERT_EQ(1234, cli.port()); } +#ifdef CPPHTTPLIB_OPENSSL_SUPPORT +TEST(HostAndPortPropertiesTest, SSL) { + httplib::SSLClient cli("www.google.com"); + ASSERT_EQ("www.google.com", cli.host()); + ASSERT_EQ(443, cli.port()); +} +#endif + #ifdef CPPHTTPLIB_OPENSSL_SUPPORT TEST(SSLClientTest, UpdateCAStore) { httplib::SSLClient httplib_client("www.google.com"); @@ -4301,17 +4974,25 @@ TEST(SSLClientTest, UpdateCAStore) { } TEST(SSLClientTest, ServerNameIndication_Online) { - SSLClient cli("httpbin.org", 443); - auto res = cli.Get("/get"); +#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN + auto host = "httpbin.org"; + auto path = std::string{"/get"}; +#else + auto host = "nghttp2.org"; + auto path = std::string{"/httpbin/get"}; +#endif + + SSLClient cli(host, 443); + auto res = cli.Get(path); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); } TEST(SSLClientTest, ServerCertificateVerification1_Online) { - SSLClient cli("google.com"); + Client cli("https://google.com"); auto res = cli.Get("/"); ASSERT_TRUE(res); - ASSERT_EQ(301, res->status); + ASSERT_EQ(StatusCode::MovedPermanently_301, res->status); } TEST(SSLClientTest, ServerCertificateVerification2_Online) { @@ -4328,7 +5009,7 @@ TEST(SSLClientTest, ServerCertificateVerification3_Online) { cli.set_ca_cert_path(CA_CERT_FILE); auto res = cli.Get("/"); ASSERT_TRUE(res); - ASSERT_EQ(301, res->status); + ASSERT_EQ(StatusCode::MovedPermanently_301, res->status); } TEST(SSLClientTest, ServerCertificateVerification4) { @@ -4342,7 +5023,12 @@ TEST(SSLClientTest, ServerCertificateVerification4) { }); thread t = thread([&]() { ASSERT_TRUE(svr.listen("127.0.0.1", PORT)); }); - std::this_thread::sleep_for(std::chrono::milliseconds(1)); + auto se = detail::scope_exit([&] { + t.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); SSLClient cli("127.0.0.1", PORT); cli.set_ca_cert_path(SERVER_CERT2_FILE); @@ -4351,9 +5037,50 @@ TEST(SSLClientTest, ServerCertificateVerification4) { auto res = cli.Get("/test"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); +} - t.join(); +TEST(SSLClientTest, ServerCertificateVerification5_Online) { + std::string cert; + detail::read_file(CA_CERT_FILE, cert); + + SSLClient cli("google.com"); + cli.load_ca_cert_store(cert.data(), cert.size()); + const auto res = cli.Get("/"); + ASSERT_TRUE(res); + ASSERT_EQ(StatusCode::MovedPermanently_301, res->status); +} + +TEST(SSLClientTest, ServerCertificateVerification6_Online) { + // clang-format off + static constexpr char cert[] = + "GlobalSign Root CA\n" + "==================\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkGA1UEBhMCQkUx\n" + "GTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jvb3QgQ0ExGzAZBgNVBAMTEkds\n" + "b2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAwMDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNV\n" + "BAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYD\n" + "VQQDExJHbG9iYWxTaWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDa\n" + "DuaZjc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavpxy0Sy6sc\n" + "THAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp1Wrjsok6Vjk4bwY8iGlb\n" + "Kk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdGsnUOhugZitVtbNV4FpWi6cgKOOvyJBNP\n" + "c1STE4U6G7weNLWLBYy5d4ux2x8gkasJU26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrX\n" + "gzT/LCrBbBlDSgeF59N89iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV\n" + "HRMBAf8EBTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0BAQUF\n" + "AAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOzyj1hTdNGCbM+w6Dj\n" + "Y1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE38NflNUVyRRBnMRddWQVDf9VMOyG\n" + "j/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymPAbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhH\n" + "hm4qxFYxldBniYUr+WymXUadDKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveC\n" + "X4XSQRjbgbMEHMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==\n" + "-----END CERTIFICATE-----\n"; + // clang-format on + + SSLClient cli("google.com"); + cli.load_ca_cert_store(cert, sizeof(cert)); + const auto res = cli.Get("/"); + ASSERT_TRUE(res); + ASSERT_EQ(StatusCode::MovedPermanently_301, res->status); } TEST(SSLClientTest, WildcardHostNameMatch_Online) { @@ -4365,7 +5092,7 @@ TEST(SSLClientTest, WildcardHostNameMatch_Online) { auto res = cli.Get("/"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); } #if 0 @@ -4378,7 +5105,7 @@ TEST(SSLClientTest, SetInterfaceWithINET6) { auto res = cli->Get("/get"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); } #endif @@ -4412,7 +5139,12 @@ TEST(SSLClientServerTest, ClientCertPresent) { }); thread t = thread([&]() { ASSERT_TRUE(svr.listen(HOST, PORT)); }); - std::this_thread::sleep_for(std::chrono::milliseconds(1)); + auto se = detail::scope_exit([&] { + t.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); SSLClient cli(HOST, PORT, CLIENT_CERT_FILE, CLIENT_PRIVATE_KEY_FILE); cli.enable_server_certificate_verification(false); @@ -4420,9 +5152,7 @@ TEST(SSLClientServerTest, ClientCertPresent) { auto res = cli.Get("/test"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); - - t.join(); + ASSERT_EQ(StatusCode::OK_200, res->status); } #if !defined(_WIN32) || defined(OPENSSL_USE_APPLINK) @@ -4484,7 +5214,12 @@ TEST(SSLClientServerTest, MemoryClientCertPresent) { }); thread t = thread([&]() { ASSERT_TRUE(svr.listen(HOST, PORT)); }); - std::this_thread::sleep_for(std::chrono::milliseconds(1)); + auto se = detail::scope_exit([&] { + t.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); SSLClient cli(HOST, PORT, client_cert, client_private_key); cli.enable_server_certificate_verification(false); @@ -4492,14 +5227,12 @@ TEST(SSLClientServerTest, MemoryClientCertPresent) { auto res = cli.Get("/test"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); X509_free(server_cert); EVP_PKEY_free(server_private_key); X509_free(client_cert); EVP_PKEY_free(client_private_key); - - t.join(); } #endif @@ -4511,17 +5244,19 @@ TEST(SSLClientServerTest, ClientCertMissing) { svr.Get("/test", [&](const Request &, Response &) { ASSERT_TRUE(false); }); thread t = thread([&]() { ASSERT_TRUE(svr.listen(HOST, PORT)); }); - std::this_thread::sleep_for(std::chrono::milliseconds(1)); + auto se = detail::scope_exit([&] { + svr.stop(); + t.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); SSLClient cli(HOST, PORT); auto res = cli.Get("/test"); cli.set_connection_timeout(30); ASSERT_TRUE(!res); EXPECT_EQ(Error::SSLServerVerification, res.error()); - - svr.stop(); - - t.join(); } TEST(SSLClientServerTest, TrustDirOptional) { @@ -4534,7 +5269,12 @@ TEST(SSLClientServerTest, TrustDirOptional) { }); thread t = thread([&]() { ASSERT_TRUE(svr.listen(HOST, PORT)); }); - std::this_thread::sleep_for(std::chrono::milliseconds(1)); + auto se = detail::scope_exit([&] { + t.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); SSLClient cli(HOST, PORT, CLIENT_CERT_FILE, CLIENT_PRIVATE_KEY_FILE); cli.enable_server_certificate_verification(false); @@ -4542,9 +5282,7 @@ TEST(SSLClientServerTest, TrustDirOptional) { auto res = cli.Get("/test"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); - - t.join(); + ASSERT_EQ(StatusCode::OK_200, res->status); } TEST(SSLClientServerTest, SSLConnectTimeout) { @@ -4557,12 +5295,12 @@ TEST(SSLClientServerTest, SSLConnectTimeout) { client_ca_cert_dir_path), stop_(false) {} - bool stop_; + std::atomic_bool stop_; private: bool process_and_close_socket(socket_t /*sock*/) override { // Don't create SSL context - while (!stop_) { + while (!stop_.load()) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); } return true; @@ -4577,7 +5315,14 @@ TEST(SSLClientServerTest, SSLConnectTimeout) { }); thread t = thread([&]() { ASSERT_TRUE(svr.listen(HOST, PORT)); }); - std::this_thread::sleep_for(std::chrono::milliseconds(1)); + auto se = detail::scope_exit([&] { + svr.stop_ = true; + svr.stop(); + t.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); SSLClient cli(HOST, PORT, CLIENT_CERT_FILE, CLIENT_PRIVATE_KEY_FILE); cli.enable_server_certificate_verification(false); @@ -4586,10 +5331,6 @@ TEST(SSLClientServerTest, SSLConnectTimeout) { auto res = cli.Get("/test"); ASSERT_TRUE(!res); EXPECT_EQ(Error::SSLConnection, res.error()); - - svr.stop_ = true; - svr.stop(); - t.join(); } TEST(SSLClientServerTest, CustomizeServerSSLCtx) { @@ -4648,7 +5389,12 @@ TEST(SSLClientServerTest, CustomizeServerSSLCtx) { }); thread t = thread([&]() { ASSERT_TRUE(svr.listen(HOST, PORT)); }); - std::this_thread::sleep_for(std::chrono::milliseconds(1)); + auto se = detail::scope_exit([&] { + t.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); SSLClient cli(HOST, PORT, CLIENT_CERT_FILE, CLIENT_PRIVATE_KEY_FILE); cli.enable_server_certificate_verification(false); @@ -4656,9 +5402,7 @@ TEST(SSLClientServerTest, CustomizeServerSSLCtx) { auto res = cli.Get("/test"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); - - t.join(); + ASSERT_EQ(StatusCode::OK_200, res->status); } // Disabled due to the out-of-memory problem on GitHub Actions Workflows @@ -4682,9 +5426,13 @@ TEST(SSLClientServerTest, DISABLED_LargeDataTransfer) { }); auto listen_thread = std::thread([&svr]() { svr.listen("localhost", PORT); }); - while (!svr.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } + auto se = detail::scope_exit([&] { + svr.stop(); + listen_thread.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); // client POST SSLClient cli("localhost", PORT); @@ -4695,14 +5443,9 @@ TEST(SSLClientServerTest, DISABLED_LargeDataTransfer) { large_size_byte, "application/octet-stream"); // compare - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ(large_size_byte, res->body.size()); EXPECT_EQ(0, std::memcmp(binary.data(), res->body.data(), large_size_byte)); - - // cleanup - svr.stop(); - listen_thread.join(); - ASSERT_FALSE(svr.is_running()); } #endif @@ -4739,8 +5482,76 @@ TEST(SendAPI, SimpleInterface_Online) { auto res = cli.send(req); ASSERT_TRUE(res); - EXPECT_EQ(301, res->status); + EXPECT_EQ(StatusCode::MovedPermanently_301, res->status); +} + +TEST(ClientImplMethods, GetSocketTest) { + httplib::Server svr; + svr.Get("/", [&](const httplib::Request & /*req*/, httplib::Response &res) { + res.status = StatusCode::OK_200; + }); + + auto thread = std::thread([&]() { svr.listen("127.0.0.1", 3333); }); + auto se = detail::scope_exit([&] { + svr.stop(); + thread.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); + + { + httplib::Client cli("http://127.0.0.1:3333"); + cli.set_keep_alive(true); + + // Use the behavior of cpp-httplib of opening the connection + // only when the first request happens. If that changes, + // this test would be obsolete. + + EXPECT_EQ(cli.socket(), INVALID_SOCKET); + + // This also implicitly tests the server. But other tests would fail much + // earlier than this one to be considered. + + auto res = cli.Get("/"); + ASSERT_TRUE(res); + + EXPECT_EQ(StatusCode::OK_200, res->status); + ASSERT_TRUE(cli.socket() != INVALID_SOCKET); + } +} + +// Disabled due to out-of-memory problem on GitHub Actions +#ifdef _WIN64 +TEST(ServerLargeContentTest, DISABLED_SendLargeContent) { + // allocate content size larger than 2GB in memory + const size_t content_size = 2LL * 1024LL * 1024LL * 1024LL + 1LL; + char *content = (char *)malloc(content_size); + ASSERT_TRUE(content); + + Server svr; + svr.Get("/foo", + [=](const httplib::Request & /*req*/, httplib::Response &res) { + res.set_content(content, content_size, "application/octet-stream"); + }); + + auto listen_thread = std::thread([&svr]() { svr.listen(HOST, PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + listen_thread.join(); + if (content) free(content); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); + + Client cli(HOST, PORT); + auto res = cli.Get("/foo"); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::OK_200, res->status); + EXPECT_EQ(content_size, res->body.length()); } +#endif #ifdef CPPHTTPLIB_OPENSSL_SUPPORT TEST(YahooRedirectTest2, SimpleInterface_Online) { @@ -4748,13 +5559,13 @@ TEST(YahooRedirectTest2, SimpleInterface_Online) { auto res = cli.Get("/"); ASSERT_TRUE(res); - EXPECT_EQ(301, res->status); + EXPECT_EQ(StatusCode::MovedPermanently_301, res->status); cli.set_follow_location(true); res = cli.Get("/"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); - EXPECT_EQ("https://yahoo.com/", res->location); + EXPECT_EQ(StatusCode::OK_200, res->status); + EXPECT_EQ("https://www.yahoo.com/", res->location); } TEST(YahooRedirectTest3, SimpleInterface_Online) { @@ -4762,12 +5573,12 @@ TEST(YahooRedirectTest3, SimpleInterface_Online) { auto res = cli.Get("/"); ASSERT_TRUE(res); - EXPECT_EQ(301, res->status); + EXPECT_EQ(StatusCode::MovedPermanently_301, res->status); cli.set_follow_location(true); res = cli.Get("/"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("https://www.yahoo.com/", res->location); } @@ -4781,17 +5592,17 @@ TEST(YahooRedirectTest3, NewResultInterface_Online) { ASSERT_FALSE(res == nullptr); ASSERT_TRUE(res != nullptr); EXPECT_EQ(Error::Success, res.error()); - EXPECT_EQ(301, res.value().status); - EXPECT_EQ(301, (*res).status); - EXPECT_EQ(301, res->status); + EXPECT_EQ(StatusCode::MovedPermanently_301, res.value().status); + EXPECT_EQ(StatusCode::MovedPermanently_301, (*res).status); + EXPECT_EQ(StatusCode::MovedPermanently_301, res->status); cli.set_follow_location(true); res = cli.Get("/"); ASSERT_TRUE(res); EXPECT_EQ(Error::Success, res.error()); - EXPECT_EQ(200, res.value().status); - EXPECT_EQ(200, (*res).status); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res.value().status); + EXPECT_EQ(StatusCode::OK_200, (*res).status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ("https://www.yahoo.com/", res->location); } @@ -4802,7 +5613,7 @@ TEST(DecodeWithChunkedEncoding, BrotliEncoding_Online) { cli.Get("/ajax/libs/jquery/3.5.1/jquery.js", {{"Accept-Encoding", "br"}}); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ(287630U, res->body.size()); EXPECT_EQ("application/javascript; charset=utf-8", res->get_header_value("Content-Type")); @@ -4817,7 +5628,7 @@ TEST(HttpsToHttpRedirectTest, SimpleInterface_Online) { "redirect-to?url=http%3A%2F%2Fwww.google.com&status_code=302"); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST(HttpsToHttpRedirectTest2, SimpleInterface_Online) { @@ -4830,7 +5641,7 @@ TEST(HttpsToHttpRedirectTest2, SimpleInterface_Online) { auto res = cli.Get("/httpbin/redirect-to", params, Headers{}); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST(HttpsToHttpRedirectTest3, SimpleInterface_Online) { @@ -4842,7 +5653,7 @@ TEST(HttpsToHttpRedirectTest3, SimpleInterface_Online) { auto res = cli.Get("/httpbin/redirect-to?status_code=302", params, Headers{}); ASSERT_TRUE(res); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST(HttpToHttpsRedirectTest, CertFile) { @@ -4862,7 +5673,14 @@ TEST(HttpToHttpsRedirectTest, CertFile) { thread t = thread([&]() { ASSERT_TRUE(svr.listen("127.0.0.1", PORT)); }); thread t2 = thread([&]() { ASSERT_TRUE(ssl_svr.listen("127.0.0.1", 1235)); }); - std::this_thread::sleep_for(std::chrono::milliseconds(1)); + auto se = detail::scope_exit([&] { + t2.join(); + t.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); + ssl_svr.wait_until_ready(); Client cli("127.0.0.1", PORT); cli.set_ca_cert_path(SERVER_CERT2_FILE); @@ -4872,10 +5690,7 @@ TEST(HttpToHttpsRedirectTest, CertFile) { auto res = cli.Get("/index"); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); - - t.join(); - t2.join(); + ASSERT_EQ(StatusCode::OK_200, res->status); } TEST(MultipartFormDataTest, LargeData) { @@ -4914,10 +5729,13 @@ TEST(MultipartFormDataTest, LargeData) { }); auto t = std::thread([&]() { svr.listen("localhost", 8080); }); - while (!svr.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } - std::this_thread::sleep_for(std::chrono::seconds(1)); + auto se = detail::scope_exit([&] { + svr.stop(); + t.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); { std::string data(1024 * 1024 * 2, '.'); @@ -4934,11 +5752,1158 @@ TEST(MultipartFormDataTest, LargeData) { auto res = cli.Post("/post", items); ASSERT_TRUE(res); - ASSERT_EQ(200, res->status); + ASSERT_EQ(StatusCode::OK_200, res->status); } +} - svr.stop(); - t.join(); +TEST(MultipartFormDataTest, DataProviderItems) { + + std::random_device seed_gen; + std::mt19937 random(seed_gen()); + + std::string rand1; + rand1.resize(1000); + std::generate(rand1.begin(), rand1.end(), [&]() { return random(); }); + + std::string rand2; + rand2.resize(3000); + std::generate(rand2.begin(), rand2.end(), [&]() { return random(); }); + + SSLServer svr(SERVER_CERT_FILE, SERVER_PRIVATE_KEY_FILE); + + svr.Post("/post-none", [&](const Request &req, Response & /*res*/, + const ContentReader &content_reader) { + ASSERT_FALSE(req.is_multipart_form_data()); + + std::string body; + content_reader([&](const char *data, size_t data_length) { + body.append(data, data_length); + return true; + }); + + EXPECT_EQ(body, ""); + }); + + svr.Post("/post-items", [&](const Request &req, Response & /*res*/, + const ContentReader &content_reader) { + ASSERT_TRUE(req.is_multipart_form_data()); + MultipartFormDataItems files; + content_reader( + [&](const MultipartFormData &file) { + files.push_back(file); + return true; + }, + [&](const char *data, size_t data_length) { + files.back().content.append(data, data_length); + return true; + }); + + ASSERT_TRUE(files.size() == 2); + + EXPECT_EQ(std::string(files[0].name), "name1"); + EXPECT_EQ(files[0].content, "Testing123"); + EXPECT_EQ(files[0].filename, "filename1"); + EXPECT_EQ(files[0].content_type, "application/octet-stream"); + + EXPECT_EQ(files[1].name, "name2"); + EXPECT_EQ(files[1].content, "Testing456"); + EXPECT_EQ(files[1].filename, ""); + EXPECT_EQ(files[1].content_type, ""); + }); + + svr.Post("/post-providers", [&](const Request &req, Response & /*res*/, + const ContentReader &content_reader) { + ASSERT_TRUE(req.is_multipart_form_data()); + MultipartFormDataItems files; + content_reader( + [&](const MultipartFormData &file) { + files.push_back(file); + return true; + }, + [&](const char *data, size_t data_length) { + files.back().content.append(data, data_length); + return true; + }); + + ASSERT_TRUE(files.size() == 2); + + EXPECT_EQ(files[0].name, "name3"); + EXPECT_EQ(files[0].content, rand1); + EXPECT_EQ(files[0].filename, "filename3"); + EXPECT_EQ(files[0].content_type, ""); + + EXPECT_EQ(files[1].name, "name4"); + EXPECT_EQ(files[1].content, rand2); + EXPECT_EQ(files[1].filename, "filename4"); + EXPECT_EQ(files[1].content_type, ""); + }); + + svr.Post("/post-both", [&](const Request &req, Response & /*res*/, + const ContentReader &content_reader) { + ASSERT_TRUE(req.is_multipart_form_data()); + MultipartFormDataItems files; + content_reader( + [&](const MultipartFormData &file) { + files.push_back(file); + return true; + }, + [&](const char *data, size_t data_length) { + files.back().content.append(data, data_length); + return true; + }); + + ASSERT_TRUE(files.size() == 4); + + EXPECT_EQ(std::string(files[0].name), "name1"); + EXPECT_EQ(files[0].content, "Testing123"); + EXPECT_EQ(files[0].filename, "filename1"); + EXPECT_EQ(files[0].content_type, "application/octet-stream"); + + EXPECT_EQ(files[1].name, "name2"); + EXPECT_EQ(files[1].content, "Testing456"); + EXPECT_EQ(files[1].filename, ""); + EXPECT_EQ(files[1].content_type, ""); + + EXPECT_EQ(files[2].name, "name3"); + EXPECT_EQ(files[2].content, rand1); + EXPECT_EQ(files[2].filename, "filename3"); + EXPECT_EQ(files[2].content_type, ""); + + EXPECT_EQ(files[3].name, "name4"); + EXPECT_EQ(files[3].content, rand2); + EXPECT_EQ(files[3].filename, "filename4"); + EXPECT_EQ(files[3].content_type, ""); + }); + + auto t = std::thread([&]() { svr.listen("localhost", 8080); }); + auto se = detail::scope_exit([&] { + svr.stop(); + t.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); + + { + Client cli("https://localhost:8080"); + cli.enable_server_certificate_verification(false); + + MultipartFormDataItems items{ + {"name1", "Testing123", "filename1", "application/octet-stream"}, + {"name2", "Testing456", "", ""}, // not a file + }; + + { + auto res = cli.Post("/post-none", {}, {}, {}); + ASSERT_TRUE(res); + ASSERT_EQ(StatusCode::OK_200, res->status); + } + + MultipartFormDataProviderItems providers; + + { + auto res = + cli.Post("/post-items", {}, items, providers); // empty providers + ASSERT_TRUE(res); + ASSERT_EQ(StatusCode::OK_200, res->status); + } + + providers.push_back({"name3", + [&](size_t offset, httplib::DataSink &sink) -> bool { + // test the offset is given correctly at each step + if (!offset) + sink.os.write(rand1.data(), 30); + else if (offset == 30) + sink.os.write(rand1.data() + 30, 300); + else if (offset == 330) + sink.os.write(rand1.data() + 330, 670); + else if (offset == rand1.size()) + sink.done(); + return true; + }, + "filename3", + {}}); + + providers.push_back({"name4", + [&](size_t offset, httplib::DataSink &sink) -> bool { + // test the offset is given correctly at each step + if (!offset) + sink.os.write(rand2.data(), 2000); + else if (offset == 2000) + sink.os.write(rand2.data() + 2000, 1); + else if (offset == 2001) + sink.os.write(rand2.data() + 2001, 999); + else if (offset == rand2.size()) + sink.done(); + return true; + }, + "filename4", + {}}); + + { + auto res = cli.Post("/post-providers", {}, {}, providers); + ASSERT_TRUE(res); + ASSERT_EQ(StatusCode::OK_200, res->status); + } + + { + auto res = cli.Post("/post-both", {}, items, providers); + ASSERT_TRUE(res); + ASSERT_EQ(StatusCode::OK_200, res->status); + } + } } -#endif +TEST(MultipartFormDataTest, BadHeader) { + Server svr; + svr.Post("/post", [&](const Request & /*req*/, Response &res) { + res.set_content("ok", "text/plain"); + }); + + thread t = thread([&] { svr.listen(HOST, PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + t.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); + + const std::string body = + "This is the preamble. It is to be ignored, though it\r\n" + "is a handy place for composition agents to include an\r\n" + "explanatory note to non-MIME conformant readers.\r\n" + "\r\n" + "\r\n" + "--simple boundary\r\n" + "Content-Disposition: form-data; name=\"field1\"\r\n" + ": BAD...\r\n" + "\r\n" + "value1\r\n" + "--simple boundary\r\n" + "Content-Disposition: form-data; name=\"field2\"; " + "filename=\"example.txt\"\r\n" + "\r\n" + "value2\r\n" + "--simple boundary--\r\n" + "This is the epilogue. It is also to be ignored.\r\n"; + + std::string content_type = + R"(multipart/form-data; boundary="simple boundary")"; + + Client cli(HOST, PORT); + auto res = cli.Post("/post", body, content_type.c_str()); + + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::BadRequest_400, res->status); +} + +TEST(MultipartFormDataTest, WithPreamble) { + Server svr; + svr.Post("/post", [&](const Request & /*req*/, Response &res) { + res.set_content("ok", "text/plain"); + }); + + thread t = thread([&] { svr.listen(HOST, PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + t.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); + + const std::string body = + "This is the preamble. It is to be ignored, though it\r\n" + "is a handy place for composition agents to include an\r\n" + "explanatory note to non-MIME conformant readers.\r\n" + "\r\n" + "\r\n" + "--simple boundary\r\n" + "Content-Disposition: form-data; name=\"field1\"\r\n" + "\r\n" + "value1\r\n" + "--simple boundary\r\n" + "Content-Disposition: form-data; name=\"field2\"; " + "filename=\"example.txt\"\r\n" + "\r\n" + "value2\r\n" + "--simple boundary--\r\n" + "This is the epilogue. It is also to be ignored.\r\n"; + + std::string content_type = + R"(multipart/form-data; boundary="simple boundary")"; + + Client cli(HOST, PORT); + auto res = cli.Post("/post", body, content_type.c_str()); + + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::OK_200, res->status); +} + +TEST(MultipartFormDataTest, PostCustomBoundary) { + SSLServer svr(SERVER_CERT_FILE, SERVER_PRIVATE_KEY_FILE); + + svr.Post("/post_customboundary", [&](const Request &req, Response & /*res*/, + const ContentReader &content_reader) { + if (req.is_multipart_form_data()) { + MultipartFormDataItems files; + content_reader( + [&](const MultipartFormData &file) { + files.push_back(file); + return true; + }, + [&](const char *data, size_t data_length) { + files.back().content.append(data, data_length); + return true; + }); + + EXPECT_TRUE(std::string(files[0].name) == "document"); + EXPECT_EQ(size_t(1024 * 1024 * 2), files[0].content.size()); + EXPECT_TRUE(files[0].filename == "2MB_data"); + EXPECT_TRUE(files[0].content_type == "application/octet-stream"); + + EXPECT_TRUE(files[1].name == "hello"); + EXPECT_TRUE(files[1].content == "world"); + EXPECT_TRUE(files[1].filename == ""); + EXPECT_TRUE(files[1].content_type == ""); + } else { + std::string body; + content_reader([&](const char *data, size_t data_length) { + body.append(data, data_length); + return true; + }); + } + }); + + auto t = std::thread([&]() { svr.listen("localhost", 8080); }); + auto se = detail::scope_exit([&] { + svr.stop(); + t.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); + + { + std::string data(1024 * 1024 * 2, '.'); + std::stringstream buffer; + buffer << data; + + Client cli("https://localhost:8080"); + cli.enable_server_certificate_verification(false); + + MultipartFormDataItems items{ + {"document", buffer.str(), "2MB_data", "application/octet-stream"}, + {"hello", "world", "", ""}, + }; + + auto res = cli.Post("/post_customboundary", {}, items, "abc-abc"); + ASSERT_TRUE(res); + ASSERT_EQ(StatusCode::OK_200, res->status); + } +} + +TEST(MultipartFormDataTest, PostInvalidBoundaryChars) { + std::string data(1024 * 1024 * 2, '&'); + std::stringstream buffer; + buffer << data; + + Client cli("https://localhost:8080"); + + MultipartFormDataItems items{ + {"document", buffer.str(), "2MB_data", "application/octet-stream"}, + {"hello", "world", "", ""}, + }; + + for (const char &c : " \t\r\n") { + auto res = + cli.Post("/invalid_boundary", {}, items, string("abc123").append(1, c)); + ASSERT_EQ(Error::UnsupportedMultipartBoundaryChars, res.error()); + ASSERT_FALSE(res); + } +} + +TEST(MultipartFormDataTest, PutFormData) { + SSLServer svr(SERVER_CERT_FILE, SERVER_PRIVATE_KEY_FILE); + + svr.Put("/put", [&](const Request &req, const Response & /*res*/, + const ContentReader &content_reader) { + if (req.is_multipart_form_data()) { + MultipartFormDataItems files; + content_reader( + [&](const MultipartFormData &file) { + files.push_back(file); + return true; + }, + [&](const char *data, size_t data_length) { + files.back().content.append(data, data_length); + return true; + }); + + EXPECT_TRUE(std::string(files[0].name) == "document"); + EXPECT_EQ(size_t(1024 * 1024 * 2), files[0].content.size()); + EXPECT_TRUE(files[0].filename == "2MB_data"); + EXPECT_TRUE(files[0].content_type == "application/octet-stream"); + + EXPECT_TRUE(files[1].name == "hello"); + EXPECT_TRUE(files[1].content == "world"); + EXPECT_TRUE(files[1].filename == ""); + EXPECT_TRUE(files[1].content_type == ""); + } else { + std::string body; + content_reader([&](const char *data, size_t data_length) { + body.append(data, data_length); + return true; + }); + } + }); + + auto t = std::thread([&]() { svr.listen("localhost", 8080); }); + auto se = detail::scope_exit([&] { + svr.stop(); + t.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); + + { + std::string data(1024 * 1024 * 2, '&'); + std::stringstream buffer; + buffer << data; + + Client cli("https://localhost:8080"); + cli.enable_server_certificate_verification(false); + + MultipartFormDataItems items{ + {"document", buffer.str(), "2MB_data", "application/octet-stream"}, + {"hello", "world", "", ""}, + }; + + auto res = cli.Put("/put", items); + ASSERT_TRUE(res); + ASSERT_EQ(StatusCode::OK_200, res->status); + } +} + +TEST(MultipartFormDataTest, PutFormDataCustomBoundary) { + SSLServer svr(SERVER_CERT_FILE, SERVER_PRIVATE_KEY_FILE); + + svr.Put("/put_customboundary", + [&](const Request &req, const Response & /*res*/, + const ContentReader &content_reader) { + if (req.is_multipart_form_data()) { + MultipartFormDataItems files; + content_reader( + [&](const MultipartFormData &file) { + files.push_back(file); + return true; + }, + [&](const char *data, size_t data_length) { + files.back().content.append(data, data_length); + return true; + }); + + EXPECT_TRUE(std::string(files[0].name) == "document"); + EXPECT_EQ(size_t(1024 * 1024 * 2), files[0].content.size()); + EXPECT_TRUE(files[0].filename == "2MB_data"); + EXPECT_TRUE(files[0].content_type == "application/octet-stream"); + + EXPECT_TRUE(files[1].name == "hello"); + EXPECT_TRUE(files[1].content == "world"); + EXPECT_TRUE(files[1].filename == ""); + EXPECT_TRUE(files[1].content_type == ""); + } else { + std::string body; + content_reader([&](const char *data, size_t data_length) { + body.append(data, data_length); + return true; + }); + } + }); + + auto t = std::thread([&]() { svr.listen("localhost", 8080); }); + auto se = detail::scope_exit([&] { + svr.stop(); + t.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); + + { + std::string data(1024 * 1024 * 2, '&'); + std::stringstream buffer; + buffer << data; + + Client cli("https://localhost:8080"); + cli.enable_server_certificate_verification(false); + + MultipartFormDataItems items{ + {"document", buffer.str(), "2MB_data", "application/octet-stream"}, + {"hello", "world", "", ""}, + }; + + auto res = cli.Put("/put_customboundary", {}, items, "abc-abc_"); + ASSERT_TRUE(res); + ASSERT_EQ(StatusCode::OK_200, res->status); + } +} + +TEST(MultipartFormDataTest, PutInvalidBoundaryChars) { + std::string data(1024 * 1024 * 2, '&'); + std::stringstream buffer; + buffer << data; + + Client cli("https://localhost:8080"); + cli.enable_server_certificate_verification(false); + + MultipartFormDataItems items{ + {"document", buffer.str(), "2MB_data", "application/octet-stream"}, + {"hello", "world", "", ""}, + }; + + for (const char &c : " \t\r\n") { + auto res = cli.Put("/put", {}, items, string("abc123").append(1, c)); + ASSERT_EQ(Error::UnsupportedMultipartBoundaryChars, res.error()); + ASSERT_FALSE(res); + } +} + +TEST(MultipartFormDataTest, AlternateFilename) { + auto handled = false; + + Server svr; + svr.Post("/test", [&](const Request &req, Response &res) { + ASSERT_EQ(3u, req.files.size()); + + auto it = req.files.begin(); + ASSERT_EQ("file1", it->second.name); + ASSERT_EQ("A.txt", it->second.filename); + ASSERT_EQ("text/plain", it->second.content_type); + ASSERT_EQ("Content of a.txt.\r\n", it->second.content); + + ++it; + ASSERT_EQ("file2", it->second.name); + ASSERT_EQ("a.html", it->second.filename); + ASSERT_EQ("text/html", it->second.content_type); + ASSERT_EQ("Content of a.html.\r\n", + it->second.content); + + ++it; + ASSERT_EQ("text", it->second.name); + ASSERT_EQ("", it->second.filename); + ASSERT_EQ("", it->second.content_type); + ASSERT_EQ("text default", it->second.content); + + res.set_content("ok", "text/plain"); + + handled = true; + }); + + thread t = thread([&] { svr.listen(HOST, PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + t.join(); + ASSERT_FALSE(svr.is_running()); + ASSERT_TRUE(handled); + }); + + svr.wait_until_ready(); + + auto req = "POST /test HTTP/1.1\r\n" + "Content-Type: multipart/form-data;boundary=--------\r\n" + "Content-Length: 399\r\n" + "\r\n" + "----------\r\n" + "Content-Disposition: form-data; name=\"text\"\r\n" + "\r\n" + "text default\r\n" + "----------\r\n" + "Content-Disposition: form-data; filename*=\"UTF-8''%41.txt\"; " + "filename=\"a.txt\"; name=\"file1\"\r\n" + "Content-Type: text/plain\r\n" + "\r\n" + "Content of a.txt.\r\n" + "\r\n" + "----------\r\n" + "Content-Disposition: form-data; name=\"file2\" ;filename = " + "\"a.html\"\r\n" + "Content-Type: text/html\r\n" + "\r\n" + "Content of a.html.\r\n" + "\r\n" + "------------\r\n"; + + ASSERT_TRUE(send_request(1, req)); +} + +TEST(MultipartFormDataTest, CloseDelimiterWithoutCRLF) { + auto handled = false; + + Server svr; + svr.Post("/test", [&](const Request &req, Response &) { + ASSERT_EQ(2u, req.files.size()); + + auto it = req.files.begin(); + ASSERT_EQ("text1", it->second.name); + ASSERT_EQ("text1", it->second.content); + + ++it; + ASSERT_EQ("text2", it->second.name); + ASSERT_EQ("text2", it->second.content); + + handled = true; + }); + + thread t = thread([&] { svr.listen(HOST, PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + t.join(); + ASSERT_FALSE(svr.is_running()); + ASSERT_TRUE(handled); + }); + + svr.wait_until_ready(); + + auto req = "POST /test HTTP/1.1\r\n" + "Content-Type: multipart/form-data;boundary=--------\r\n" + "Content-Length: 146\r\n" + "\r\n----------\r\n" + "Content-Disposition: form-data; name=\"text1\"\r\n" + "\r\n" + "text1" + "\r\n----------\r\n" + "Content-Disposition: form-data; name=\"text2\"\r\n" + "\r\n" + "text2" + "\r\n------------"; + + std::string resonse; + ASSERT_TRUE(send_request(1, req, &resonse)); + ASSERT_EQ("200", resonse.substr(9, 3)); +} + +TEST(MultipartFormDataTest, ContentLength) { + auto handled = false; + + Server svr; + svr.Post("/test", [&](const Request &req, Response &) { + ASSERT_EQ(2u, req.files.size()); + + auto it = req.files.begin(); + ASSERT_EQ("text1", it->second.name); + ASSERT_EQ("text1", it->second.content); + + ++it; + ASSERT_EQ("text2", it->second.name); + ASSERT_EQ("text2", it->second.content); + + handled = true; + }); + + thread t = thread([&] { svr.listen(HOST, PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + t.join(); + ASSERT_FALSE(svr.is_running()); + ASSERT_TRUE(handled); + }); + + svr.wait_until_ready(); + + auto req = "POST /test HTTP/1.1\r\n" + "Content-Type: multipart/form-data;boundary=--------\r\n" + "Content-Length: 167\r\n" + "\r\n----------\r\n" + "Content-Disposition: form-data; name=\"text1\"\r\n" + "Content-Length: 5\r\n" + "\r\n" + "text1" + "\r\n----------\r\n" + "Content-Disposition: form-data; name=\"text2\"\r\n" + "\r\n" + "text2" + "\r\n------------\r\n"; + + std::string resonse; + ASSERT_TRUE(send_request(1, req, &resonse)); + ASSERT_EQ("200", resonse.substr(9, 3)); +} + +#endif + +#ifndef _WIN32 +class UnixSocketTest : public ::testing::Test { +protected: + void TearDown() override { std::remove(pathname_.c_str()); } + + void client_GET(const std::string &addr) { + httplib::Client cli{addr}; + cli.set_address_family(AF_UNIX); + ASSERT_TRUE(cli.is_valid()); + + const auto &result = cli.Get(pattern_); + ASSERT_TRUE(result) << "error: " << result.error(); + + const auto &resp = result.value(); + EXPECT_EQ(resp.status, StatusCode::OK_200); + EXPECT_EQ(resp.body, content_); + } + + const std::string pathname_{"./httplib-server.sock"}; + const std::string pattern_{"/hi"}; + const std::string content_{"Hello World!"}; +}; + +TEST_F(UnixSocketTest, pathname) { + httplib::Server svr; + svr.Get(pattern_, [&](const httplib::Request &, httplib::Response &res) { + res.set_content(content_, "text/plain"); + }); + + std::thread t{[&] { + ASSERT_TRUE(svr.set_address_family(AF_UNIX).listen(pathname_, 80)); + }}; + auto se = detail::scope_exit([&] { + svr.stop(); + t.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); + ASSERT_TRUE(svr.is_running()); + + client_GET(pathname_); +} + +#if defined(__linux__) || \ + /* __APPLE__ */ (defined(SOL_LOCAL) && defined(SO_PEERPID)) +TEST_F(UnixSocketTest, PeerPid) { + httplib::Server svr; + std::string remote_port_val; + svr.Get(pattern_, [&](const httplib::Request &req, httplib::Response &res) { + res.set_content(content_, "text/plain"); + remote_port_val = req.get_header_value("REMOTE_PORT"); + }); + + std::thread t{[&] { + ASSERT_TRUE(svr.set_address_family(AF_UNIX).listen(pathname_, 80)); + }}; + auto se = detail::scope_exit([&] { + svr.stop(); + t.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); + ASSERT_TRUE(svr.is_running()); + + client_GET(pathname_); + EXPECT_EQ(std::to_string(getpid()), remote_port_val); +} +#endif + +#ifdef __linux__ +TEST_F(UnixSocketTest, abstract) { + constexpr char svr_path[]{"\x00httplib-server.sock"}; + const std::string abstract_addr{svr_path, sizeof(svr_path) - 1}; + + httplib::Server svr; + svr.Get(pattern_, [&](const httplib::Request &, httplib::Response &res) { + res.set_content(content_, "text/plain"); + }); + + std::thread t{[&] { + ASSERT_TRUE(svr.set_address_family(AF_UNIX).listen(abstract_addr, 80)); + }}; + auto se = detail::scope_exit([&] { + svr.stop(); + t.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); + ASSERT_TRUE(svr.is_running()); + + client_GET(abstract_addr); +} +#endif + +TEST(SocketStream, is_writable_UNIX) { + int fds[2]; + ASSERT_EQ(0, socketpair(AF_UNIX, SOCK_STREAM, 0, fds)); + + const auto asSocketStream = [&](socket_t fd, + std::function func) { + return detail::process_client_socket(fd, 0, 0, 0, 0, func); + }; + asSocketStream(fds[0], [&](Stream &s0) { + EXPECT_EQ(s0.socket(), fds[0]); + EXPECT_TRUE(s0.is_writable()); + + EXPECT_EQ(0, close(fds[1])); + EXPECT_FALSE(s0.is_writable()); + + return true; + }); + EXPECT_EQ(0, close(fds[0])); +} + +TEST(SocketStream, is_writable_INET) { + sockaddr_in addr; + memset(&addr, 0, sizeof(addr)); + addr.sin_family = AF_INET; + addr.sin_port = htons(PORT + 1); + addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + + int disconnected_svr_sock = -1; + std::thread svr{[&] { + const int s = socket(AF_INET, SOCK_STREAM, 0); + ASSERT_LE(0, s); + ASSERT_EQ(0, ::bind(s, reinterpret_cast(&addr), sizeof(addr))); + ASSERT_EQ(0, listen(s, 1)); + ASSERT_LE(0, disconnected_svr_sock = accept(s, nullptr, nullptr)); + ASSERT_EQ(0, close(s)); + }}; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + + std::thread cli{[&] { + const int s = socket(AF_INET, SOCK_STREAM, 0); + ASSERT_LE(0, s); + ASSERT_EQ(0, connect(s, reinterpret_cast(&addr), sizeof(addr))); + ASSERT_EQ(0, close(s)); + }}; + cli.join(); + svr.join(); + ASSERT_NE(disconnected_svr_sock, -1); + + const auto asSocketStream = [&](socket_t fd, + std::function func) { + return detail::process_client_socket(fd, 0, 0, 0, 0, func); + }; + asSocketStream(disconnected_svr_sock, [&](Stream &ss) { + EXPECT_EQ(ss.socket(), disconnected_svr_sock); + EXPECT_FALSE(ss.is_writable()); + + return true; + }); + + ASSERT_EQ(0, close(disconnected_svr_sock)); +} +#endif // #ifndef _WIN32 + +TEST(TaskQueueTest, IncreaseAtomicInteger) { + static constexpr unsigned int number_of_tasks{1000000}; + std::atomic_uint count{0}; + std::unique_ptr task_queue{ + new ThreadPool{CPPHTTPLIB_THREAD_POOL_COUNT}}; + + for (unsigned int i = 0; i < number_of_tasks; ++i) { + auto queued = task_queue->enqueue( + [&count] { count.fetch_add(1, std::memory_order_relaxed); }); + EXPECT_TRUE(queued); + } + + EXPECT_NO_THROW(task_queue->shutdown()); + EXPECT_EQ(number_of_tasks, count.load()); +} + +TEST(TaskQueueTest, IncreaseAtomicIntegerWithQueueLimit) { + static constexpr unsigned int number_of_tasks{1000000}; + static constexpr unsigned int qlimit{2}; + unsigned int queued_count{0}; + std::atomic_uint count{0}; + std::unique_ptr task_queue{ + new ThreadPool{/*num_threads=*/1, qlimit}}; + + for (unsigned int i = 0; i < number_of_tasks; ++i) { + if (task_queue->enqueue( + [&count] { count.fetch_add(1, std::memory_order_relaxed); })) { + queued_count++; + } + } + + EXPECT_NO_THROW(task_queue->shutdown()); + EXPECT_EQ(queued_count, count.load()); + EXPECT_TRUE(queued_count <= number_of_tasks); + EXPECT_TRUE(queued_count >= qlimit); +} + +TEST(TaskQueueTest, MaxQueuedRequests) { + static constexpr unsigned int qlimit{3}; + std::unique_ptr task_queue{new ThreadPool{1, qlimit}}; + std::condition_variable sem_cv; + std::mutex sem_mtx; + int credits = 0; + bool queued; + + /* Fill up the queue with tasks that will block until we give them credits to + * complete. */ + for (unsigned int n = 0; n <= qlimit;) { + queued = task_queue->enqueue([&sem_mtx, &sem_cv, &credits] { + std::unique_lock lock(sem_mtx); + while (credits <= 0) { + sem_cv.wait(lock); + } + /* Consume the credit and signal the test code if they are all gone. */ + if (--credits == 0) { sem_cv.notify_one(); } + }); + + if (n < qlimit) { + /* The first qlimit enqueues must succeed. */ + EXPECT_TRUE(queued); + } else { + /* The last one will succeed only when the worker thread + * starts and dequeues the first blocking task. Although + * not necessary for the correctness of this test, we sleep for + * a short while to avoid busy waiting. */ + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + } + if (queued) { n++; } + } + + /* Further enqueues must fail since the queue is full. */ + for (auto i = 0; i < 4; i++) { + queued = task_queue->enqueue([] {}); + EXPECT_FALSE(queued); + } + + /* Give the credits to allow the previous tasks to complete. */ + { + std::unique_lock lock(sem_mtx); + credits += qlimit + 1; + } + sem_cv.notify_all(); + + /* Wait for all the credits to be consumed. */ + { + std::unique_lock lock(sem_mtx); + while (credits > 0) { + sem_cv.wait(lock); + } + } + + /* Check that we are able again to enqueue at least qlimit tasks. */ + for (unsigned int i = 0; i < qlimit; i++) { + queued = task_queue->enqueue([] {}); + EXPECT_TRUE(queued); + } + + EXPECT_NO_THROW(task_queue->shutdown()); +} + +TEST(RedirectTest, RedirectToUrlWithQueryParameters) { + Server svr; + + svr.Get("/", [](const Request & /*req*/, Response &res) { + res.set_redirect(R"(/hello?key=val%26key2%3Dval2)"); + }); + + svr.Get("/hello", [](const Request &req, Response &res) { + res.set_content(req.get_param_value("key"), "text/plain"); + }); + + auto thread = std::thread([&]() { svr.listen(HOST, PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + thread.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); + + { + Client cli(HOST, PORT); + cli.set_follow_location(true); + + auto res = cli.Get("/"); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::OK_200, res->status); + EXPECT_EQ("val&key2=val2", res->body); + } +} + +TEST(VulnerabilityTest, CRLFInjection) { + Server svr; + + svr.Post("/test1", [](const Request & /*req*/, Response &res) { + res.set_content("Hello 1", "text/plain"); + }); + + svr.Delete("/test2", [](const Request & /*req*/, Response &res) { + res.set_content("Hello 2", "text/plain"); + }); + + svr.Put("/test3", [](const Request & /*req*/, Response &res) { + res.set_content("Hello 3", "text/plain"); + }); + + svr.Patch("/test4", [](const Request & /*req*/, Response &res) { + res.set_content("Hello 4", "text/plain"); + }); + + svr.set_logger([](const Request &req, const Response & /*res*/) { + for (const auto &x : req.headers) { + auto key = x.first; + EXPECT_STRNE("evil", key.c_str()); + } + }); + + auto thread = std::thread([&]() { svr.listen(HOST, PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + thread.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); + + { + Client cli(HOST, PORT); + + cli.Post("/test1", "A=B", + "application/x-www-form-urlencoded\r\nevil: hello1"); + cli.Delete("/test2", "A=B", "text/plain\r\nevil: hello2"); + cli.Put("/test3", "text", "text/plain\r\nevil: hello3"); + cli.Patch("/test4", "content", "text/plain\r\nevil: hello4"); + } +} + +TEST(PathParamsTest, StaticMatch) { + const auto pattern = "/users/all"; + detail::PathParamsMatcher matcher(pattern); + + Request request; + request.path = "/users/all"; + ASSERT_TRUE(matcher.match(request)); + + std::unordered_map expected_params = {}; + + EXPECT_EQ(request.path_params, expected_params); +} + +TEST(PathParamsTest, StaticMismatch) { + const auto pattern = "/users/all"; + detail::PathParamsMatcher matcher(pattern); + + Request request; + request.path = "/users/1"; + ASSERT_FALSE(matcher.match(request)); +} + +TEST(PathParamsTest, SingleParamInTheMiddle) { + const auto pattern = "/users/:id/subscriptions"; + detail::PathParamsMatcher matcher(pattern); + + Request request; + request.path = "/users/42/subscriptions"; + ASSERT_TRUE(matcher.match(request)); + + std::unordered_map expected_params = {{"id", "42"}}; + + EXPECT_EQ(request.path_params, expected_params); +} + +TEST(PathParamsTest, SingleParamInTheEnd) { + const auto pattern = "/users/:id"; + detail::PathParamsMatcher matcher(pattern); + + Request request; + request.path = "/users/24"; + ASSERT_TRUE(matcher.match(request)); + + std::unordered_map expected_params = {{"id", "24"}}; + + EXPECT_EQ(request.path_params, expected_params); +} + +TEST(PathParamsTest, SingleParamInTheEndTrailingSlash) { + const auto pattern = "/users/:id/"; + detail::PathParamsMatcher matcher(pattern); + + Request request; + request.path = "/users/42/"; + ASSERT_TRUE(matcher.match(request)); + std::unordered_map expected_params = {{"id", "42"}}; + + EXPECT_EQ(request.path_params, expected_params); +} + +TEST(PathParamsTest, EmptyParam) { + const auto pattern = "/users/:id/"; + detail::PathParamsMatcher matcher(pattern); + + Request request; + request.path = "/users//"; + ASSERT_TRUE(matcher.match(request)); + + std::unordered_map expected_params = {{"id", ""}}; + + EXPECT_EQ(request.path_params, expected_params); +} + +TEST(PathParamsTest, FragmentMismatch) { + const auto pattern = "/users/:id/"; + detail::PathParamsMatcher matcher(pattern); + + Request request; + request.path = "/admins/24/"; + ASSERT_FALSE(matcher.match(request)); +} + +TEST(PathParamsTest, ExtraFragments) { + const auto pattern = "/users/:id"; + detail::PathParamsMatcher matcher(pattern); + + Request request; + request.path = "/users/42/subscriptions"; + ASSERT_FALSE(matcher.match(request)); +} + +TEST(PathParamsTest, MissingTrailingParam) { + const auto pattern = "/users/:id"; + detail::PathParamsMatcher matcher(pattern); + + Request request; + request.path = "/users"; + ASSERT_FALSE(matcher.match(request)); +} + +TEST(PathParamsTest, MissingParamInTheMiddle) { + const auto pattern = "/users/:id/subscriptions"; + detail::PathParamsMatcher matcher(pattern); + + Request request; + request.path = "/users/subscriptions"; + ASSERT_FALSE(matcher.match(request)); +} + +TEST(PathParamsTest, MultipleParams) { + const auto pattern = "/users/:userid/subscriptions/:subid"; + detail::PathParamsMatcher matcher(pattern); + + Request request; + request.path = "/users/42/subscriptions/2"; + ASSERT_TRUE(matcher.match(request)); + + std::unordered_map expected_params = { + {"userid", "42"}, {"subid", "2"}}; + + EXPECT_EQ(request.path_params, expected_params); +} + +TEST(PathParamsTest, SequenceOfParams) { + const auto pattern = "/values/:x/:y/:z"; + detail::PathParamsMatcher matcher(pattern); + + Request request; + request.path = "/values/1/2/3"; + ASSERT_TRUE(matcher.match(request)); + + std::unordered_map expected_params = { + {"x", "1"}, {"y", "2"}, {"z", "3"}}; + + EXPECT_EQ(request.path_params, expected_params); +} diff --git a/external_imported/cpp-httplib/test/test.vcxproj b/external_imported/cpp-httplib/test/test.vcxproj index 22739d60e..b169311b1 100644 --- a/external_imported/cpp-httplib/test/test.vcxproj +++ b/external_imported/cpp-httplib/test/test.vcxproj @@ -116,6 +116,7 @@ true + /bigobj %(AdditionalOptions) Console @@ -158,6 +159,7 @@ true + /bigobj %(AdditionalOptions) Console diff --git a/external_imported/cpp-httplib/test/test_proxy.cc b/external_imported/cpp-httplib/test/test_proxy.cc index 941b74714..88a8ba963 100644 --- a/external_imported/cpp-httplib/test/test_proxy.cc +++ b/external_imported/cpp-httplib/test/test_proxy.cc @@ -10,7 +10,7 @@ void ProxyTest(T& cli, bool basic) { cli.set_proxy("localhost", basic ? 3128 : 3129); auto res = cli.Get("/httpbin/get"); ASSERT_TRUE(res != nullptr); - EXPECT_EQ(407, res->status); + EXPECT_EQ(StatusCode::ProxyAuthenticationRequired_407, res->status); } TEST(ProxyTest, NoSSLBasic) { @@ -51,7 +51,7 @@ void RedirectProxyText(T& cli, const char *path, bool basic) { auto res = cli.Get(path); ASSERT_TRUE(res != nullptr); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } TEST(RedirectTest, HTTPBinNoSSLBasic) { @@ -82,7 +82,7 @@ TEST(RedirectTest, YouTubeNoSSLBasic) { RedirectProxyText(cli, "/", true); } -TEST(RedirectTest, YouTubeNoSSLDigest) { +TEST(RedirectTest, DISABLED_YouTubeNoSSLDigest) { Client cli("youtube.com"); RedirectProxyText(cli, "/", false); } @@ -108,7 +108,7 @@ void BaseAuthTestFromHTTPWatch(T& cli) { { auto res = cli.Get("/basic-auth/hello/world"); ASSERT_TRUE(res != nullptr); - EXPECT_EQ(401, res->status); + EXPECT_EQ(StatusCode::Unauthorized_401, res->status); } { @@ -117,7 +117,7 @@ void BaseAuthTestFromHTTPWatch(T& cli) { {make_basic_authentication_header("hello", "world")}); ASSERT_TRUE(res != nullptr); EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n", res->body); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } { @@ -125,21 +125,21 @@ void BaseAuthTestFromHTTPWatch(T& cli) { auto res = cli.Get("/basic-auth/hello/world"); ASSERT_TRUE(res != nullptr); EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n", res->body); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } { cli.set_basic_auth("hello", "bad"); auto res = cli.Get("/basic-auth/hello/world"); ASSERT_TRUE(res != nullptr); - EXPECT_EQ(401, res->status); + EXPECT_EQ(StatusCode::Unauthorized_401, res->status); } { cli.set_basic_auth("bad", "world"); auto res = cli.Get("/basic-auth/hello/world"); ASSERT_TRUE(res != nullptr); - EXPECT_EQ(401, res->status); + EXPECT_EQ(StatusCode::Unauthorized_401, res->status); } } @@ -166,7 +166,7 @@ void DigestAuthTestFromHTTPWatch(T& cli) { { auto res = cli.Get("/digest-auth/auth/hello/world"); ASSERT_TRUE(res != nullptr); - EXPECT_EQ(401, res->status); + EXPECT_EQ(StatusCode::Unauthorized_401, res->status); } { @@ -182,23 +182,23 @@ void DigestAuthTestFromHTTPWatch(T& cli) { auto res = cli.Get(path.c_str()); ASSERT_TRUE(res != nullptr); EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n", res->body); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } cli.set_digest_auth("hello", "bad"); for (auto path : paths) { auto res = cli.Get(path.c_str()); ASSERT_TRUE(res != nullptr); - EXPECT_EQ(401, res->status); + EXPECT_EQ(StatusCode::Unauthorized_401, res->status); } // NOTE: Until httpbin.org fixes issue #46, the following test is commented - // out. Plese see https://httpbin.org/digest-auth/auth/hello/world + // out. Please see https://httpbin.org/digest-auth/auth/hello/world // cli.set_digest_auth("bad", "world"); // for (auto path : paths) { // auto res = cli.Get(path.c_str()); // ASSERT_TRUE(res != nullptr); - // EXPECT_EQ(401, res->status); + // EXPECT_EQ(StatusCode::Unauthorized_401, res->status); // } } } @@ -234,11 +234,11 @@ void KeepAliveTest(T& cli, bool basic) { { auto res = cli.Get("/httpbin/get"); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } { auto res = cli.Get("/httpbin/redirect/2"); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } { @@ -252,7 +252,7 @@ void KeepAliveTest(T& cli, bool basic) { for (auto path: paths) { auto res = cli.Get(path.c_str()); EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n", res->body); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } } @@ -260,7 +260,7 @@ void KeepAliveTest(T& cli, bool basic) { int count = 10; while (count--) { auto res = cli.Get("/httpbin/get"); - EXPECT_EQ(200, res->status); + EXPECT_EQ(StatusCode::OK_200, res->status); } } } diff --git a/external_imported/cpp-httplib/test/www/dir/1MB.txt b/external_imported/cpp-httplib/test/www/dir/1MB.txt new file mode 100644 index 000000000..f5a9c204f --- /dev/null +++ b/external_imported/cpp-httplib/test/www/dir/1MB.txt @@ -0,0 +1,8192 @@ +9254835974458887629672873635789957411886024698554157393849494864228024962939550688297074527198420261051675205999609689838587412 +7948702662533481896767559573369920938242346354580061545409242090168773727371802699309443935396635866263937828773324526334321892 +7929250312741837331511829643632683169694074912332726993582394725302853411901337696207186358524323117172520907433878952968176465 +9486937364148093931718552300016332142708943190856638524388888569011747617956915519539025796115901484762122047712200094207683584 +0703675740855407318047361595661595146837376373951978537785605481083388906490085533348547865459237835407372374738389274773789264 +3524314516560200536698529022539598732463389124803873184044464663165630452635665559603483233341839268186056673186867104904449866 +3388466377320953222057779182433549144340237502432464295061371141084500222833875925546082542869030852833895137466510262849050187 +2359980877010447170873386178573828860442255448874794721230413368694441497441338856684036949118353204002591974711928301953002372 +6372613557152801003023836434406997863096739346637849381675791163293956729985652182807911615231198696051411047800847064484769940 +4555399892730282159333189930818248844009737851281434494736943722577947684829017806688345340403991974811107725657399196027995602 +3976607710681047393460981746843991626375149576917517874980586155555711990727221948467045177979554215577477183785345135535682148 +8981224019853812859833307577420310576654838103212699667682513798088777109119729024038590682109547975734687407898816774007038892 +9017123764104410282402525387418186790830943654104676998756681754083664849203556615995024922746652778319099999725942494552746687 +4602993085345245279681119328539229356959910969065035141679707233267342542524482900839390718291823532073464112692162110160887576 +8646564120617234541914353449310981315044240998894442066188871011899825887695202156119273906958004776559173081177243291448706570 +4866033151494706872899672197703352421058356661105030485577210664650513250767511742264039882291373723618030276740280451621184372 +9438899492601727676139376045138079061355198567322008270344297244790265795845160675322685239683610065522225253070076549915962270 +8389935622999431104891971065250599273560270041530059453015141663393829191008304620453278274234791447194116642959854046669653221 +4390066870930359126190473237338490788280116222078414392005864878004044572924012489353108185972058375678318527434060575546457283 +0571024164252835918003185534087097269093594036226831977994875139354124615791501602629221816855731144878875700135493432353006251 +5927821910139360288795697248742701824779517711136895716699422565064551330393130338804982871980774254446227613970394730940420871 +3742377272014443550088749485134437400845098911378170974616143540710504172620523980130687874417124218036934374655684373965565750 +1478423915766121994159683752043056020433068572256778826939436280481378432842397489866548450027752963017529841096517341127140258 +8566764493817154363962092792522076892737665735147823735202597353071978920287229637466345140359899735477359400126088124931881468 +8940255760337363163978793913265843793885760290540433771518954295210648595347128727773745692808704267887587662204824695198843990 +0899757006576147578169404543275069681042994730814241204020586377450354179962282687398746645565905502250948590090052580759060254 +6486974981051360582508378437652320531515639324364424491392656403886587101611394285202791775180181840494403192370521504242888310 +0832863857962097233772304981176182241414796661234070317886749751979535621508014316193777356696545211120669034308685700669047575 +1601920560631092775469657814901382577801938745924198963515833985856042317888652481510158158143597978988591350058772254540887509 +2132235148831014717469033542114409228818750252221985002159849994061876844567039235968616101425307518401162305005282076459564485 +3749005491254116003221964938075605607977980187695543266859111481060871108661145469674590183816636520815523589998805144183387552 +3454557776795930937812464849331806246436437524220402821725671887519345824588678830784061509096255092713692879753496348543679698 +6604711892156464428503873379368266697844691398807542828869396127474509499861163107833096454590997165019449027223124752455672795 +1464056065563451406292025100441586772081609300298880665395988771146415490692648836974652685280576941091682396423173897267646839 +0355383165630525414486907132932207574564820206814521900700480593494653392345246480522618317569197186894847097184780188176595384 +2234714652935409724403164799544553996270776652429105659472464101488105672623286713328942045106946821859926624587221567145826782 +0309935578008890373154226142294034025862773115052182464935233315361839771441799453095926400038395389556682588458216003237653863 +1061156071932484650516913321439215405043703716040614962270232640142284681169472791577978618224769535957766957086206741391709970 +7647351716205014294072195135184469100518783539374945598848168573993875333505334011212625117442647232720744618603822330582078365 +6190042304849971211815384939288709598033150233044255711655989057889996862762413082297341687788607689416591830790638752880761817 +3350993967482666602170935703513835999165561197161777938477157925978429670778105685120890113130859239045083522459241247368307415 +5460081669964922086720150722963115784946235169601550836667474277946931369187925788894576312382075479577915204545165252523196796 +9483728931707116749644793319165741326903913011722074179317419072713429472369240811255731316334667969479890293999075667048649131 +3479265891282260862086967904220845208360231245372151218473448305464967324382299780822943482467600298687513476936031155077963601 +5358607166888753271639287331221882667306965170073890751994864930247242443182503197751744519602399141153643026523167858853130538 +7454234112327473005509721991333469328638161495819890863131852055720398755713433050343878076412540696773945682790587599473898772 +1829500286670935139918198012253669665196719074234685642111242009658467409729732638466770339415767564217863874440642300491597266 +5585497029761221358413402963546931530898077983556347511671398790492531247609197801647309393017719703556474420667077635431137035 +8446511749461154540070308470454488783535318141900958816289412388611370858697615498746416636102261400237788596935028958347787028 +3125589335242227429164632721324285385335478344437654660712476162463759322956724441170491898597020350367163787012219584863841888 +6802337989299969519242898184367047999251583706804577726542893830886334416591927545136810611568115854449708934129157129519681281 +4502536799805954583144549032621959969753071050956941684132891200046324576389173182566153807220810192479638581311891427849367417 +6325541021938064574977797529368876421571303611445571554655335842928934553745122110842178236045825160364424732178843094315127909 +7416551206319999579172591987511489686313571898121634456963111089610744020435972487389528243640299599133169203384400119064268257 +5942558924368052900576494867848083529988242331335385049200017447913990221665638834941940132033114280719741451021709322013495656 +3034267296680277379429583962288582457402893052674209528241394670330734634693333770067544918231098413897817493181756172191761769 +4462568735945386723562623780129364617626340957792264088426814103842409805756856047587770203362285297182877719759239486173167134 +8181657858983878076788365457679611406051878073922935400724071002626732091440173091689286855430601190105542880854867957669944342 +1682764258327911438109776589215105175058720345720016147450773913501679216877023673201387960875767306750352156509386560915532694 +4168453046768399507263930483191895109159119018724369742162771101927944398681984030667327651300421681200981291741743361136642792 +5961214949092908589726506803431211408890378633711553535211419472586275853572210445315467622414789208830684013971300686277675328 +9269710543143964341467182430089608998710751826481978504336310277969086698368677287182389959721242273938854619109417313330166529 +8486459999966843090378171773263091325696386996545517566407679424699279968298703891528397394384066258625248890398189881141241156 +1449849546688513154852662654151484110306993368687380709636409815697889872688403677017676988174939843342948688833489247136945501 +3026821425662283243215241228426396875362999466310497066906176240972976192127107346129568606866349374029240104708104443230866441 +4888599832610923002904596161762304764008702325429097763470366526898011656507069583771589908698710318907474941536590688671464002 +2187786798670885931014137550230451723811271617853032443909991254363190383287294838940424051082728434647528986018234698035977262 +4010150476565439429491060857277549534561616385054516756344772776300804281913985317098584407945908254666687113999982299034911916 +9543106789274635042741853569705907409683466986445551664737067041728196021666244823741197574167419992584104093228192902092720801 +1102588771206288521669854794170734776396759389699841902844928003578465247527168100807066013305698109312645455547945036883046986 +3363256734764708042924448420459037705906529627671525144633382899415555101340497992824046104327698365969273385304329013580634534 +5814024400502542484138080303093675479908925878015957334513036393579080542663814740530799226052633254072603206379019404756963615 +8568459878266889844587337958272179244147420281407959235700418194754222652142770182396574372220705526302797889629403089542338729 +8226364273353855713782831639652716359809735693921459950536413341806490125092787610897542413754704628839004798504470781343226879 +9564108089806303912196187245286576464060313163695650258929860024346682416259472890719900060340274063102211811727469052257146328 +0723807096388817245239864356681843226170736144832701238842559718295427226555369395998370081796589238415142792914737246512392617 +4241424816471283201248965000004171003042756134627995493041482479770591013182623840449510466593158465328399081296605282376713554 +9973513220590332519460381924338347505856779256581376567327469745338170108702340101128824216183825500136464452346025348049667485 +8383897971629124447860057453350337067099519586684049058435585462779736095630666963739484221218567448740285624710665297561214099 +9964116268591382706460872763874878534297946361217165257274977145088020502651470013064060961213429959898581048432243027406481577 +4824315082578790346775943088343852549806522479147355182415674805204204673847884219703487656256651056490611337757236524094938348 +7062382447597254598729362880233858271292436951748099256624309342834053225940366427538355199347489811241328865453894894705029296 +9735693411211619628088603452483215272175364970550497151583596541206523461527332458408984429879086514102509879665768932131692226 +6961688387629152540756216546017259642317857065168508958573052496210655276891659756089714383999813015316305245290357709870563638 +3863034723721495784723589237391107262786771026496285596990386769945707595340965195448259401890929565886615037974745228156868323 +3287577904832967842610714371567414265151412481754216777139400930821306278453396427971928947503983582862250196984342590738386627 +1791128295449101351282899590128118669109794265058849951756999066974826947872800232214872176234126177766951584517353226892319930 +8805052099840613606036822579273082344123139982418321238213526119536401574939527633217151490658267375799590895845553195225375174 +1355928510541796297379079857922955866076933929404227257481153317061720856509437585235189609477388103725696248255380889259925943 +1402201875930840177564779603131963190398447445546273482826943610197406605496467698637182093544726028048446184407465904504733488 +1834037129267281181848805100644706716446934703366578946950288560270548606368029542736413168537166947783032181537827321728818305 +2399588088866368871684803227983829485917501647912319399696731866908470118289600881964063135888922021379521028829404789266368968 +5637489977535077950426899162426475829892339881113388204978816994197921201698140466319573566765752657389499556451516488232245559 +6112692169213605381302831305889438504096793315962284966459192757358537426473374519814657784899843476819443537896967951107338491 +7895505461382759098793722523795396339534176000429147383719128841803883949006205025948100090981495836498310874463726230844486437 +9522042614500829901321795525603265978871144309432521198633117362072879318547949126425751870262081563243482328537146079314556599 +5093542621599279420676140514142072884094585996707002095359240117940447064308608734332029368110977503867431654445743620282821742 +2074818355004815481495949283111185240895061522427508730372487670815127557063465146879286952537668866636765956480834805349247418 +0982616183770170277896101663961256388046096956303414645662042291995673037815635718874781061367093483701372208717092453548930045 +3197990341408426456860501773717322183556963874016603497159407408857792270849795326742052795163483613191779561704529979153717213 +0442381165605136382176204027769856937910886725474913822447353042136166362618403395513606165988761350028767809916274534709139581 +1546533500647539778292217072989397950692244341857345231008319214990106951110301762058019968223873956867021450221558460837271796 +1089583682950702039719953402978240768135379617758154644301927987331573523265837746123630494418924793748993674977892210713791382 +2010498095473532597719948269554932451554991652103201520706494302534512806373772862577948592827967992187111665796229241795272327 +4495947525239030494005205359163320911969546009892986032715554824732415447400580445227801191434206229755544175085033640445463730 +5799343664533857261737308836915890943267341995945607000250119768647338018370977116150224513412795224930773162810128318361091070 +2845165641335198012087900200223115487995666447653144922411381435396653532150893427712002942030941647409112450887593516206623257 +5995936189970345951128332927675055555031225056766626864377451946716279426300206796784320339236602175243416848009874418064376734 +2751388225971927284674719275737386426623723915170272496656834116124167598744380632642578314683658323664087930294748983479134152 +4463890675024338744201454760164930410895360686852249316115526602608580347281230566360947860956394767605509297995646286805155429 +3902535272296902694906404269870261097232828009262961508419387381919670436136425912908116240583462930917866834873246313946702767 +0171550221706917129701789274673785241823132172160837286626181116666263103300493781986590027327174868610919833041462749008446670 +1233446436949798212579086729206735034953949556045481891487880919889748751337486349345808929953562851746791383784762700811827813 +3273320169223863915019571833988285591541029709234409949795661766708317004888223115613777281294607726043777706813741640111212754 +2476840221289778122524588163601454015024966289209119530584971298419043747426874336591254749329149388984462650479516131162264547 +8321322112340265706034027413610131445579234122444443539849216325832257070066442940612976748450142222873158683339615189385385401 +2845301295555610107931163495080379964949955895954082606347174241430747973616106979000794362756653542557197433894470866065773098 +7002289110540946230118386265586199860767183813803128176222583812066464632835592487506968002253203796340562076570806978606547027 +0518614265711371822209002835579969441398099868205035333550662371029236766960492501859441092496004547436756442048667962205035734 +4662742623053069471722274771033535333247780680117662494001501801076484609461801093095512629224389725470873708072969419161134986 +8879423231727024904174405990021786946862967043559824446453539979244586561718968470449066018656109597862462444251052806647222165 +2462868109247823087920350263249330583062507248433983310105749602411182363633125913535849740456631462938827755069526554867046297 +0556317986368239387236732047607114173950737209007825151623731055762898522619516377121452352573813859619423710420648830645140602 +0693502619716624171936460417629499350461603844160041861287075322351538559343745415528939056080652464222483749575581089457335292 +4766904028429523888256867990946783862212788485169555738269492360138212802976905819698072914952002888319407814152289904290372830 +3063149485419553279766015944554584134585112055860455417890621924246024514671960271622075351843821409825893454426591239346175825 +4138071925467858356596514010874840756148724225545969356853427243328235466057330927837715365449101436095007553412409485033663473 +1718208277388066697955637942282188804022877425156297722332673824998500535568426990569492133060260476735245935911435663031104540 +7259896781146483425619092546253937377799155709431757305830799439617510543866635784180461435471514956432054478723110546701399601 +4212208190748800869765878332993087846354727233690197986460622890272309218632979045510485708917467310543076772888886969650697402 +5830555875156620379814707898244277917838097196097913596741388644704517369937389656755811401456911697429799824431768975340394565 +5218384019129708961023696421751573471619498755822698446106554346210228582416782419196987283985815988033363104751364948821321736 +1511408675805990625863697514171112598891753956197059919478438005392395089087719396999097527167894172833319566356364163919692543 +6760864061185222844062388472607262118669410742190580800609818458141651702885176634837319000673951554557807668749868767849900633 +4624693982782044541974663953840367719217355838087352148000020445830027606519679992919499646684217452676557562945022247829061975 +2885293059896283301736153794239325555898371313303885556968069349802848506212069388120502744705750493536808390340479824477084109 +4742565846910523167821445663540712005957374896244507720218360942226085109738527921622092099772083368812073433747682045449511884 +6164131243427554092783794384838205105688550227514505179310025715143470000166045228305059905780171994193190773288044579516190413 +6196746209214286300600159852801523856096528659384736317041341206058064233216653841144231397934288134905891354902685060365011048 +5888543435289034798476752259935453803961756168693460157400272434328483248778988626059542292033153708506682448981834226044225475 +3520105979519175798851693163134966793094384503981145911295918784323346445102768597120762535638265452619900970085082259502423098 +6023108133594199401032707688284772080067633191011227704160888217224741219472651134131857620995953537078628999627600457859691029 +7135355737374006279317910328897677569526320656280275576870747086734764513800879537763010892690268998504415888806085447064856828 +7067645951048993310751362481424429404370974532580270127897680271443323793244595619510531091473812713032955994538657114149409819 +4429631547566328842887647552139562050329710358137821590185444827892759275367380722401524911377817064992340751082835810723755618 +7949457580263990600187866192739809055130641391600646169338376355962933757309772135951086682561238922534649604316450790162767470 +6778696718174528127426896010544648198065903564137512038147927254912585276060875391066341248912566730098691603844487954144583289 +9567988530970013733492869819764508889770837509952069384446637448211216157716267753953316429209184585653933599673133926099458608 +3413492966631743395005504952764856687552734825362970605800032693220033767913422924066513158712050177343306017113090503548595910 +6782760373416377101401788671756172877579108677684185994928623883970442286211028728581037425407354811624955553337741266271223038 +4228769569080076083693265874897262718489495320015615486943453828550003614854151710616339504422293141400194809493593482338761720 +1275749976017493214306625272092330580872354604747422498275624636561377503079831465248194508227879655351358840776762816388383155 +4044611547062276323077587550347056464054608166550263311750875441257836393920920323092209759398994038142599127607649577377981910 +4521255521824521693676238300467676986666555950395922139641083951517880343036286546664953201729241686129223651162600610883998263 +4053431348518058012397818472045875672812077824208246071436792077005700411785602017912645840401853632467140385402691379589989961 +5296228207351306866595027867237475870719440724477597041700391443928732836085081541635185416372585087892465757549359102233343361 +5753047891155830333399279611743974102446066339908340811693445790222472707295688908858729491663915472040238337620182908302697924 +1508699849153464593476010736879669905272623521348097908417836104685217230447793112158735284635375208948973376371517941685224649 +0333224377446486130711894052961084313686306998844675785828086842465862992758130724435712277355911443550657464532883107599718794 +6835605634916383199967953082993703931572871914916373072477880100548805151438790628235173925034028725412169450381473208146789756 +5647596797800233744008641095874820885871714922036190240494729749620603436690380840330661337877272707920476284213555812599419547 +5513261332211064956118510684223202485323331553849116007081552356506786559518794150443263231676076605407451231256028775857402194 +0513233346964413426058663133294017428893643801135629939987380889256710071523164000264715556002787400893978524476668487881682249 +2238557041006601823583800792379249859430190860772025645499651325329407777431099926158122243379494002959281894688702064542524790 +5329597914788889055993063859757359411515855405549076867209561054324585069797183524577493085961561532791013967475565456058906425 +1727267651465421481105710991587303136944086691165624660300683125601416772368166283177444892976868345022274558919475820725390404 +9723590243421203442884921434798664645968065479222983928276913077586527562214486087189922112591555037425227530771384194025142882 +2491150360749458092334991769156796313818947278756674701926505201943095015129003490350920079450451251986198697962197375931585963 +3288323311745586996701741630221983319300390047571862205264349777484027201608059718085154305903308263735198400749807369566973087 +1513669962911297058622557295345513797998471626294474435337069062590410594233688469673875484253912558586263976338954760252676149 +5698941909248281308488717883921117273305117757034931046904729563167368375307728972002962702645828488935279252804415118514787991 +4226862654077359109954473957002792990601772994320272543965433892756039129932073592057677191275583708907760929447157089919000104 +5013015202975115790118348806423060224599193301855272198220793587287609415484559416236588999749109103840932649489845113026318936 +0096212754630289886604076288072412229982106747320501739034720205607227829189554712104511341545586461792092663001971581276075105 +1400830012525551115910295470153382076377587383792342868236429581401216573706230071139732339253271088253819425521718399148426972 +8130329129443141149308342972871751834898890054061408002066328617017958243761248655943163660366018684672224076482931610024551435 +1612470444029502611969134698674683976299405806211129021898957209691274647456212891723004609478869086828079731180673443147282673 +2207763612557030174078525394691981763423880246207823469307642881721011975478949627177448531469379452033830830547116487954748579 +8943550014526152971159374128630625318393391528677655228099671641521821415999666028671716937719971706453115362098995997004338463 +6633791090761145650463177053061879817237525424207069349153087084514135819202898699531517360951263097509259970351913296855368085 +3253556229437227815840782322932038842610282009077575504105765620857277275220518640524545781112378703944765595787111117088536490 +3612778048987899240807648365404713381232983899393777316948941796158037305227415310986733359795685540845368139757679718651388721 +0329656082303032301035960655149116897998069813522388783445067885544697734848160954106786926689147778838221235161040983098545023 +4949145925422482842946072091038603570358418034882170359973918018079551251028978485799644769497234033416966830413282850538365544 +9688715528548523732988559882524759509039740049260246259447423254924760566724656561201075170029641287177630144231062011355479091 +9326655743860681005816798142139776662356020296561383131825601205038606699757827396575776760705487871722516625005501108342115046 +4862493770761711413231246894538240278199950440029797832691068222332648670966923316771267216815856555063431665762362373752681261 +7759348913324715341816977430054410931106803880118579894939051307627827449748451051704548335839341424354678283555009009093334643 +5035504534504599464259968803145065603468459325562475588547886212145426779673200191888479107787688352706387961887120658923163596 +7064143605981003619608323632499268464142806140873807593464533126484595249138527994250140164063377300752448939069709418760740581 +3405460804222472492156715297971710492718005664789725902179902462523655008185987881883912400930038752420707768027434069222517179 +6201754337957471374021641947490208688904315801118730053700597398632018696041671232277781587402859428981324544384470959282694488 +6581501955752939978682011949909110724289175482558070539947143137365139752819830357605189104362596510417675677952395485738392629 +5415386438105335984223237131949793153812658394744575126207919072784736846230789712179591745207901814607314375532066326818332653 +3916132472388884065768704630042622537625667251509691545801542090771247404318802955070620862627476301969800427094218570764969521 +4673296443835065767694158631727161041961301871016507435883528289555722603890069782368970629525870136617529702747543702356107980 +3969736866659860369283152300636814307559050510391015595957669034065148689817184431746719346979216411505522453887905503375134993 +2033209673996359127998948182294581452192221728807476998740417776019537129643269360367751767407520936424856588589036363660084548 +8920359577043563701436228560312778025314413146903691717334802285060730546542075837699964573276987471415144914980259764316759773 +3627657012409360919929372833162804983136382545072275729679633045374976939117136265913209976809144657411039862524163682772934353 +7062667690768603813766580397495981633020198031283191319322060508875443418955017187814158494951274114076243932640382433951906100 +7089164714588749807180199878456232640504233132283953906601030144605887922753172274055475279148519962245834295034899100856266109 +6314588522281633268271129575999011547246790816567972537919142521521537511380072338334215014034228037819143744053883142669885047 +1533466041592069230562893355289214460798489775583299853132986367560533284715718053651634282346811547110422080041794519104713892 +4512970626101824923414591998781160477443695022763348614143799819070327746195782058463430126505518264262282025424239196981682678 +0616389983515682792619586855106396642118585620436668809283536133165065564894495800101984339481469054418070569566522216534870046 +3480404934288007401354060197932800798509063792079011642804930003377191431422069063134440047889535881274567178940747418743011151 +6923077833597121569133964233884887129884707102983051918568192593065049229148460460606709813558966649828440283419826988551789494 +7928629618912970441223379654942167876674509009329326197500704752789973531185610595644942798244043453568923441723724834770288101 +5686916225325175369639383018669733714398867749909229151589872339897763998251848983094518391124033198227341074940345064217565274 +6976813108342658294069521014494920511978448452850030848500379855545152314960261910035283177013574685072898109220517966532820914 +1235440485859974578507661524414185881273494203471328032423655298610228309217218895796957468358842309363210353318874365415441005 +4775757215064448647761305923181381380005564211124254441169985896444461359377488533806177746993363765363744834471832298666899659 +6549502546484198000053617666533373457701974326516846596770901748191355355442117405686714513545060992856554971022392931918431672 +7550521620433789157641377352042796699563142807992890238677899811145361588800069593324309664156547033893582449253982866608790396 +8335832703903786234598337454771069254394148676210696718885661839587950139009136903487221685179093872236368600881697661914186761 +6081423646547430855633909798819189360248786532594620983774708429259122445948885539867620755942089483824811916664871291112367965 +6763010129734054857751250818823088329080234337202140258490696882947562857997890963039131549439624749888135285626495741851799125 +3823814359862336359300824370629334246257087407174522366323576913384874982113357872199582879993086251942490130349296563220714459 +5201936494493880745125428463676510521663426683417020693977788479860674628237207703884747094987717754212968764024565059007572287 +5656800692578264688131164439239627529022443380780216659445516384845610830241501827976377913518196568744298647947111534785980646 +1465035810576162949068709350012676100595272189178329025511241633720229686245517256992739629981296918245960598907587127807526613 +3498649092457065189914681277177637039326561250640746889454833842625621406771442705555721525931725554548176228818511280348712812 +1526903631217370487596090586369687092431736602852047414002552907015226570166585529226164536775440508494117144839832365340311216 +7172800070700446830268660237981558246985408200103623671258540515214258800554645764441093416997150958224932045592907480540349584 +8145891984169127686107656905169532154735243264685794264058843466267191409417280492627793038318403119617408184518297221316412215 +3733585102819835157576236492205872180664881259553134950516961350305063296415930019908542524245430548400901559537444244647471710 +8919107817519795022023748231546623121376187758240479239499900553296636944913506176758776881811178925344276782657634277574411018 +0087408240115194690559689367771085179492160150159772172117583670772068640711181227707347785373406551286722418977845204918371862 +4087671496873156369239006050995430210075877655341012369255927938969111714405072240508066221092434986016434496634246773638497705 +3997764933956408083465951727938645280914517402927065500370134817839436837421504452664821784855528363909858322652715776945384928 +6358034140171396799781808478643680937510756584505346662094931360684566558016245219693809041873394197337373027746374913052226841 +3523525169184690915788330052438367441556380178099903982632705234888141866441214930597392851790874812046196446764134474357280196 +7912390044622498326943727559828557263667260605437809865126129166669886288145038860031004268429510310452514645934110806061259377 +8350389661397820495902304825219183306686077590455378114318515252557794852940943308375379300282537760761994418165168215848774199 +4335948571309322083199073879107610257555821153883090762370374143145191005083410872058977433580493717339726072170334542991808382 +0741068478360850873822704930167309345230781173492590875420659162725013692793497218747184011101436665668426379299561926131540226 +9684119382210299933488533355753954403421331470099036025961973755235128720357457186896140454721156015369426494838464841418224574 +2606550410151415944627360045368428365343042196701567415760981599314167562524281114850783881875311867997694821988388783550617647 +3906118902121264712371873625367711895188485445955724568729752600563482629569914020509331709891753567605376276818895453947988485 +1946035303735634882855442231649687139100528774921727985325887697840697252312164193587116219630593036960739462878472488751794288 +7553042934057050700594030020764349497635594011506182646429625749401961796662698874719407015328877341348471848266936805626731614 +3965083773308342246671432838925759649742042738645731254867213711401607696364783002153346490446057228458139827872431818981641456 +6290917282609648173484002432007182859707772380995362779354118181323028872604689080381882966273198128487451758287389558544864092 +5135412345654409193398015818933242323380089276961210614666090376540312839620184116491698184580875294639581135409937430385452967 +7814752714924949029739912516676992468879575093818117912716084850528773868618697654019734174399226706840162753982136880421595798 +8344230549785765490790122830425599688553302815508985004520791080241214227127540251939234623642895839337504147995870998311297157 +1312261536153577576475501063559792340822581967430971162124952202625290357772475691141555237352878643256411801046597748593662978 +5420113078044378326245454890074054926337548530109656935414953837202844128511917486560998089330806876653700112974245139455110655 +1446316293204894461498438056975498718142802987046646526458433588790266320884188848067627056955062757523352642280099730639892974 +8768410207973700878297712434460869178087366365740643368423050061014329802628323539796504787700469737820946806556379851425348409 +6903484946126406722104799612810275531016737884354336960835748710713062889887930835389522081146458095107803234373499389860789149 +6113798456809198989364723468291582407592480139088852307707256783165897446795918270682937158869421622443360894104220836046672216 +1297180429334742843324101908319081257574325368096788573404226330238491288173549545719251363488582787945804486932260991191153289 +6310060489009039954463983763054135671085760401926391779699811819750329003225671390731075907159344886944959170333579705985011394 +8928332308562582665591113793712076278529561597438667031252620919756801258278599576959931680328088876910755153375346545987026059 +6122799394738485298698282219069449469308864175448069521079405422190290510333027132055402559422290946776150886848955390869348557 +3298127120443406100122108547957183131539174057790900079286455780159808161628252012286085211125545510059619150351442374519647873 +7895547723969636832110890595697353438517639756208042458909186966958825057542753856885651750056062715953653156961335641588198051 +7242277604059435612451710438360700839539630420328128639238629662384680381167202360792624305492770524378775130253064094350170239 +6328910744252096963453975544360333319092492567496656064841933375445672717827688660311871137666274201081402086421470543791139037 +1263075806974163649200998435369614522606717804984408053096263479824896274273438278637073802016955266073407127338686266295417138 +3380472791463934939167548524939273036820154830243043930199471181363843017057589926197441097934643398001941245455025305275718778 +6053039097745341259474392045998222000183392630902077243215225896980913571132934688432219430448989534298905581203790323081204451 +9398618592749592673582297312578194153271726432191886003886455601016177152460729663034185278967994135744387261240974218700552874 +5660578626067455796320901716488860867842597868415619043285914590213707161427735661103212503097888685177044222466862770614738888 +7523554669658437443860955048187147707950298396691077287510802686031319997279006079308577219459278947413769480723164988814047848 +7728230896579900984081254526628677638403672817908586482917564357430378814260695955826428360637353362697491648099319657648279806 +1471506063396451021205086178083016198973053283515072407397794280863574093292850961361893442271480652011908263493969049518154719 +1271663389268841465526530211516124798508874084299647641127612963439336172485890973748223056840291177210000865573662838724859865 +1558003045612329244947071838328209194658672648215862136590055290358556159847830215232765640226279624286079243381635121169856392 +5235686772055013347630127336838697764880220575101940207293906989459723943700375632099865606791689918944793971999840022845627855 +3362608893556970872086765317357229622168187942063554148251194799624231946317410456787560024770536041305554794440402555379048363 +5400711312343982155393978124014413441498824140561950458826861214386401267011236483424009049988004220217832202185519723172983734 +4739966966771226209909624912450025675969022747113454805529677743180928548967947375791545038561055048316262023987945828187738406 +8806383430961455857801815047901978280522034447065757458634887588704123408758546678452281010485610787173222519794754395918755668 +1313032694820263690081002684124072214508820793025272277314613304407858220279657882431787747545642867929558977205831435007980692 +3821423807029286765485523471547535800355065560255771366935624333716101960889324812432465967939307158664437101875808531730514686 +0552828401027435473969844207309352000803571913860014776373394805498998489404828887974801011916107676224063398083299850490285852 +3252785594630414326772320135663653623232974740345887923006984684749440127689169558676316478796812920656203083787608388272541143 +0886829100701462879464273672433682081314775699581471366939184918943997271841997863805609882688632845996559926289731733309941773 +1588621110929737275611330049699746179538000510503020090443485760166202124848757232989323035029655555830280894064603577880623924 +9460393092105077041540924186306320293949908924617136654677663794806814239207321566509608838781326729111423409256038330560254768 +2457234134203393682333223194421969884096521962196051357781698196280191186003044231263105047089066125824374037625184294564841726 +1139020355104202113948476242624526315291276395095210708873598278111336130644448701938653730158050834519082575031500159059606323 +5508845274116902540996666349891489554638610844733883825695366107090243640688502082955261760220172087743405531646494097110373564 +6139164128879727447485151113660365410811051772254913947601863445614936478465117644061091010800284725353254306320280311126282508 +3691867968556520735423213939515627425003649240791159831598564334907098275550400308993911728901273767070664323401959466199812550 +4385285527314360012494827503644449196670340936661875727271329351754418864846693134514944138823292825239723190822861243721969511 +3358507325257641984977160116136111658256532073729689685425144586604492783647635836225848095839938544002404873700622644589011676 +0802250613087293781581129847507424374630865942136402236774163044580066760450481644654868348223850714885941401523519942001370346 +4033651642172702525694267019009943272304377112789600524789052835595443304754361088227651039992096267114223436584457492049115625 +1008702122009370555007456522799161340685826326521804374437361823776598365128302875870953921955751574077453333491368066562183540 +8297016982983877478208126579509560908805708870139177751490524014204560610778740303237644832086788493774257972604784310184677682 +6595999611158451837934955382339066842486744152636969464066220937412139592293869816659174158028425151865523439443968468476337116 +8189453034430471397425280708179774110697730501130625090567026833440338110187758034977661201862518966699911402128869207946665922 +2967301009332385012982602845125958037212145265901920840751275900004234804254302792404413397360100212415586648851954797337031843 +4621309795646253111797549932297844132545282162620476457572874699573469126157531277320612819758228011208417228396419529928921453 +8015689409373876308149147646698419734053674168732622753328286778805854267784590171527922720365829353861437404497654095122385810 +3928532819894452405285805315911246752486216644456327155370715615309647716023031992277092232949890587556921144870096925641170977 +8706990895052933118940892301863446619427769704201470123344557113277628075518257745853511560735206426541219526593186205677069195 +9323565048038756996967463636608859147371871703253988562924960678047445864387523330892542610569708364248757858563962167618047606 +7400110024724615888960177029937719273668926142229826804752461957263527604940620456908940268767529855383328656980509173310228171 +2961079316835291946492496420673777366632570317335815018560521820389694972648667220189874230520964455139599084822803458488491752 +2053325276467463411017022059798270225751157375504499399426618848961341529109405849259510473132610506746820731096435354555540869 +8022085653261752864363248353443911714595466837953116893617432029480864961559617145874891482509931363773686667586008577729590619 +9511531059462330034969446429670396910393858411286019648142180898913734931062268324002479006487407711948954747504728441451817299 +2402899664016344765585783952968436864461868976736500943447165022135283244224710415767003722013469693233516880183011359108783628 +3912070384615994999455640965424049848090544713337811655011624123059617272139004908000480810430015004300019350285545631530421459 +7040129421344930471792157420616841533490962354840490248534268666426427664847776443733801972606800005209711387678959754783758169 +4514744752921544867887197341433819468485319076219844212297689345457872671062595496333380534044033301910072934964202067332750929 +7744301249953061021059801665718252827169031698368805857673827901657376462120738712603816558346872095129968009454819539063410887 +6694959951385441493938996005094705323326365638007625755937236084671116883434472854253964886004560210329640317017985931432992507 +9830755088107356428137960573336610521897465624860840691251416368635190221352342520096074021567053917840102300469951496094532646 +0386151915867137989482068036180096232759486104299898530934407665433761886348452364475713105652919177827149093478062390353337982 +5026237611119968967543921268886408485214827943839163757065518470886816959612437396882015040264309844556286249899479340530273455 +3790585606726228419436731177762295480034329918020969162076958086843994331135466429174339242003665276457867681590462499745066166 +2010072822988771442333707800353630624045735130580706054631404185963369356383377732515576219388977808173711224814572042638811746 +7799862036041836103498954213010085023304912197271099528776247085017591855736447939941510010043072233516636490128682332435837718 +5444031310957599380550217779540801553000957068137470959947071825380695799288846148959315246034349773291226461068837384267657314 +2720831922046271298345192916201975278989464655822747470522487119845175483171802764985807888092086888555468865508558747670561030 +5037268239030155207644532217893862758398321608270496665238719184860604497280537678204406616537105359104541182047680859111844623 +4406453518829809819978030558459040108565356220631255519247977687593573153889331324518157228436273334635625807524985686484922311 +7999885151695902136577261421847256015439589971601084977870060297320803728853045230722764838994142711659330991658042253610623719 +7149325976325848648664235796296763337498794913699316628172271388813068172391895353748736320858783488531575015143960860926515250 +9988100123929774124197265328008141820710758495752123486181540545695574140507942678614702580850949656109084164982037643220132234 +0375655311441060929515636645306301671876166021260474227545267428349070029167644989380583812184485451805574601129180998157634256 +2128590561140195400524100610776393812855470570049174388092975612532917892277799041074366790055894057834557983976227857050864930 +3547444389508771568810075527864526064121655767293193457033048336615284399475478737509966968763107403398079684015244980874035979 +8519927849602061794266560801914694036469483013102023144973737181284943231700919734522079332185384045910178109811932848109276138 +3567893790780435626536700059643971391023938979188277544418757492427060624484762199641583855650960393640504524655219454811384399 +1735108417168233650163860054247929680595797171838825452321119827231787146560622246912322232224942016739093046379276365165998295 +2756695873865903361436041234030623662053438358924238813701743016813195378135003338279782291211315013357508842537428877943825850 +6550701509812921278785065189524058197762485207459987155095767921276575821627138362297358879947692406013849533700244092475658064 +1746417294003960060064872265575781963057635907396407260460748957479942537372418296161245217676807862873866767635894044939661427 +2752800199195253529712854754798642118106991591404644917342058968657791030752834046050164301961614256798982226629143783613672100 +0156432932446788502003627727688728508740309980174215347673828299641766130526832968939502574943042109833631744090112189289099293 +3949539215662926707735521667894130134427486982796357220482855624651559957655963754443694394481228836760254413314867991125537370 +0833694740794893624914563726494064663925162779653035815936273173351045298468454290966312347207985664544908635066940292067018215 +0068104260838913669470167249521001975928318786418160510709377212045134485178004263296128628173776672447600907854928188803969244 +5213186606414124173974080816812650470078589656434215381413340547874523982782714789910645183938314140377172417321651847315127943 +3831079213870153648590263375611549325132489817138611364392701108960231363751036773655982850004119077364131468986709426279928740 +0816735516514168218608953096598217254388061619583961807831532937684267549690578384517226873045647249368898189499267589557763196 +7614683199694761607567513771357320522896560891215582525317620218466204798420014498841517198000714225395529432437408592988810647 +6493791813371800888731383040408467219612486147146096499615909931691397312978653723829961950808111958324158561777510444489457609 +4673680562966535580522867179325650694242060572148395328716350087210015917993916484085808071728589768362522840828065262726854285 +9484597285206848463033004828740831651691831183702931423669671299973340807479819361399029066256705512283915649297270684923293120 +1714285317558703325551063623439102862882087552524008272992080310001454376923262343097189280399813634553559119888320098054640112 +6878492562141548781762151287184309582512789444294394903670308453724775992147414690794148922865626436020007876554089383158780819 +9151911784071444893456939300122542765400868095022473582458690303654492910301968711120089416900205538880607052645783814509878005 +1882377638793327163743947324933816937365677683669086577608915703348630259888777501270806753764247220631643679580537815123548411 +6272056421434812628524453496821198676269890972424881983781819205395093370536909259477553372703891212584194254740307122112225533 +9681870026283102041075727337579428100736459914910652574617863758549452931286799490040297351890738617979595875678774646214173033 +4185695124550535533485860637896723654154834853472854068710912474987668413470803105179616610921355620666097149488574561869489797 +3333789216162396397679204330436931257560768258425513267401621836728579265694014546537584859527037491359360764924746663506919770 +2081504393567373511045831331064517139188352171030907247345004840816407938277996907076471099879274974679268216987024065310558333 +4237450865130692858281322184224268516039222037739605355087614033374925113958908332718451900205100215886486089988991485524969556 +7929075290163499129098877300162688469599528046726233844196457006510599251899484746828484574667591829570772351512078305736672654 +9048657921163013454470683806356852138380411128268107788272256300715016144618475970710912738205043728268553865691241054834233600 +7029431095139361764456603528202380622931434502522594214209499225882330762428652317267948702623321489577844016464692915246359712 +1105356646640216883904536505154508223476242075189032231521222657818953039915135319911079058876034135094530224254031516149971890 +9040945596327638323723931073336767619159273652642403035784821558395849500879059623038153539774239738033911626241510146918039749 +5283073188137753905883236902928531799079492225443087557262624838420087547899455213109577396225125545248301841891417389453351792 +7168518951278682051937542342148124215459196543677153007216757499379420036959725544058917170458823956258437616459586004329579552 +5203183504391078070063471026373757432195663011756522268894506479810617330340549685777010011742133881536309636471645529762659089 +4854999787239813251707701121392165868052289429676407362096901868531485589830231940346048063593475645736706551014468995600111842 +4955763538748975069385515923948951672972674499411759026560381765340448515748581186486358853253830173480680063909301824002408127 +9640228631714593257928903905827590703526290377038235443447387587380382054598578561742893844220053769466029427853174638397427339 +7206862882358947361070854137919196014699723353543071743024301192848154276186984110546320724917862537765542130378492262094573104 +9132037902884622149627426018038745128067438979528182768862440252858820253995972446342211888009471423051493159698724414795710825 +4044729478097558603438562691316366082632115863305337165834502683246949426265600257894877978230675496217762990369003197560692400 +1914819988622085254720645203900712417397542695171367605811941681178792903669629925720096971822910923986744641852805301639652708 +2489879698662595408916009150319958484334649360641536805110449468835050783501013718256899380316883895243102069697127104742796718 +4988423693542042725154817443015091705766869067613353141088272355694386531680806067437655514967029170154529196712934789617792274 +9999952996574987268331116423939940247569869095269736111023291772144901858552922926558494336795934151397996022792048113880115874 +1453279672186008281192597269984891593458554070326190463606379023362133764652707672957322700161490484448540753367821464532839504 +8011800610118047251507565848810514239096971840458570325653839372359200258329325658866372171001058138732560340444368314621028592 +8193050742913890615185212677939019076499475354863399017606329114085259623153218920828787136128272822531407941969673998134066236 +6165032662878134088891598296730315347615307351518186514382605872591152954913301540364688295560996800081490449469152762525841628 +6574519924837827479315694440706135165231391744110344384147108151733208482344899812368417803491072197299164648305134049390042783 +4020778253016163495293946067531529520938183648436344477015365877950549136205835548741134429268197026979922853216037833912140076 +2560367110629307999607135522026567041549325633921424597293236948045008668100091755427842685667533245402093886980655601060106544 +8546203408136109675436916166218885966337393842202215612854795887800951672240495314500504099192631873269330473780375743830861472 +9788815056490265802740571039729926738317636325182129335295512619052159101153870121975439793577984106855088335077085584239297075 +0607830196004382404188902942190311303589870612777737359147435465863424442529799140567063628056860095478745600686399779891523221 +6451811221617351847394635729026502559474989696391694472537910902735717543356566711060840045900392940941333171363021277998101010 +5131780001821762931334985227662541898093578808808129086254438607279239181340438600040947973426848418990057822839591824881359023 +1781431927220093804299065870243095263893435123368341056371775420733487563878765425465471958566683414339834418118022714155686281 +7855784526694976383147640552245153733193000678558101047345867400675345449097722230036412101539440443445801673442840764573276547 +7277064664195765848534013590019916383557749169375559963951776576181466602296914352536749809247940247872302329782226925806468043 +7192135649991318277247808266477765244997880386860464765070023950465490749600254005312168230797058556941811885358619067264540155 +7745942254017380214048240376624237449522972214173349323588251697136718540827110673334670762835744617609275818957162829921297194 +9308025524075793350930587214905796399488049433256186463627589329393236892726854692113712455277309297788479077266643487682416715 +0884436213404481146144542589017779230742715119840784000653264872459751590076369675379177572780987987657953814990135600852985178 +3730124530298931373240431341115710398974380360265132276809345755075936226833617497570877144367390338090832665519341170114016004 +4487614165841966483390809601332500844989818602599615930254525814591372642009685306021109318297597415196166334778397096512192919 +9738135052767202788355804851260065753666213740432424577877433994081030576175406007197406894692674226624886870624390536370450115 +4972079333970854412711805268652812255100648740561624233549801666164086630826247751458218621070591048081789263645429911196722042 +6264477153602121971771346665126521727114186506364463613567938860398188315590497953212091430368302124372365408850328299694402187 +7096923163132078408222622634338258654575603652287595704602066710353019363339205986259588116309830845020074124235604674290929803 +8620319232582906151287500817533307221837336344013921731345438451489042597967502976685688377786979657248449082964352894633940456 +2338290774645460787964275902190755185934483199622353782037807590665967507775691698706742149485822727584225845398159573488959138 +9690411512559467787285374715845943612220011261976368220307963458032917206195128934924351124238497339947198608551639030163894645 +2522942273087160899325601687017261599086953489151039944965907240532011926664847298253352884442034273091440472287878013270485552 +1149024375555901235741559582840384810679491209306220816791833779666244374445454015124428345163452944670223052356961455086641846 +4911582198911887147216938492382715818668300238279079306283822841054803949022104243393368739761683072273825914099989412306146198 +9386705286204083264591504191247314048641049210231970001783669995174466309042384199881382505454205575494098905658585266777083412 +6597181522016787958122306510209743227930379650431716531860926286813430719462209935654406493573792531684209677728726902971780496 +7454713877871827759953186012939103462107245349313356776395316754209733644734837949073664445059496108161795213098031298387675255 +8608951097824554197185243937211248657800767047324365682759725200979621123783045604563185385990004228189141941283634284151650878 +5110742662179788336448957887870922104701629467080657819437644833165127617594897707891497065965495615130086622172410875337801320 +2393400609667414757827986008711153834467770780863121443973568354701559598965757992398836770293536284505657099974035105460765424 +5696578078800033701889220099620389665546740070731873354278406253021517777757298261519059116566359233204858968015644380662525991 +0719487243613892918578289524307174160805716406329931625803050285847534463223682481335815436403441752588538391995273084423051287 +6507583132575286651290896026205391515246827860101127710478694329951379556419208073957900692792049817183622267407642643093594278 +1377392380718866307096826670910831948575020464783957275980748872622490677834200043136176315679139636646826582155786548373039619 +6270395893591295820132189201839068186418319333704429754904087462921395570639063307809781688462251183623162844581418406608429879 +5043135604579355727135840436265306254474995931628655768285052525690960177800386175175072542969753822246288489006113161219380471 +2468870042718971405890990067722938578347935929978019468025646064389136067817188723296206441343678326386730657242344326326352583 +4850753963828793552300794217123706294629474328454245842829452531896699931041364932772984481884556840376569123447688057207356583 +7057042541510451935323810217032483925746383540989928451101483213770975125680075200108338616874937924879361446516778250185550748 +0832810498555353548220097752070786325088219810053096162098021215047558250904896030368053916311890910240442204298949146112466005 +6040761853883330139655359121858985041009457655416978338162675746762113717003221699855200571002086517873586911211646864010901906 +7256461701161490507120388412005575681572262509069280090655692691681966297281536854053796037221572903258227405845942489932658062 +8784119159896217889610742272823513831023300901198251714365380671379756902059751391678189474782942687418296669663414454093527211 +1713004342725426977027637006978967397759795215758374886596544583647960566243025979142738914314172995528789806147213520151545065 +6148932160477331319836946915602714548850688076504811022908366977684207197869071392739615383347277286078886115107459496844571114 +2443445647690017845788068401719782165485185661849045242867722200580611203950026796072201135775981201642969396670605705878495845 +1294371619212953132417647548708472622197636506856370676160451382994700324005284453279834375908065277166478082791508699598722770 +0053575986014268796134989286247216849523870686352637864684792640382519878279886269694672196689841813884729761559800125789968281 +4079017492141445585825743793710894771763718871198578437956220555470157513268225528361787107561094227364687598864249537846090985 +3335615421853085612471428388452383268898317706526014807014690533942186796242785098624189594771605450015209158202436565395838528 +6313851017796457232684831975868577197008285743175695149676285515896251363246115689779921987378115615609824156064808941150859547 +2765806218554516717364886537785391971358807028025829434420213828068755277959823238847926003687327479957197440099922200245318093 +0743837871847609090197592779267491068691643664874076633968061486254606691482824855693172784961663018432092989740850414577990750 +6025684120312451259686658587433694029989987324349789159690905104220972232002229613273265979326232104213906084669828970966380427 +6946689887211552778830098495751925653354785324514999092963991842666284889259310987400348941690948665027526678850288865496058905 +6762732711489921976841952967909655635081188142889946182277259409310226741889437458160117435942945024450654816897944448992096154 +5422044978529069360644478126257492572807446085424868838210351520631277115650603746786970481265582987466949165123354295111201812 +4211276624640084315612918421177060204230299421803486633824592006573340606615889580523464227765304350439006450951838160825473751 +1889210243603037535646067281045805960008570285172891727145769267831573879630019508324069996866828486890146852983707941528252170 +6433944896458400005722683036542919674416232401927258992043251760109983309622060221449241884161395267285324969554809613236559401 +5926828496890530602862162152396620975722541268836002211191264684743325984168877494942640619948750726132999624105124012640906283 +8437529190279374121273890161340277025282882572337700420322280964590810755716568643364840307879983400203857287989101011632690781 +5802276041061620122710926329386353739806320420710281218622737558209391349689462899753335081329268758815057487656715890733084223 +8915069186666442083922633115688459542249351209368361689010535548757066038294153139851377020698884275592572198938097053313533421 +3618393873597153740469607428584632822338908997205070091595456519416863149036488990139674096344263132753025929808588767591996177 +8414765535715090848046152050822658084473018911692025473276058620384118863100457752482347145023516317250246454398495927754913591 +4409298010504839698734131748484717641239465901635152376312170896985346043211365815426588368753012122770591860188057761705660735 +5937603186684235090583457539320837412342393238618817530913846014346149555309319385019839106489932216877734882102311404478731716 +7896182092904946306296521788524236999972318921384942071102716941043024956484573567729385887708261561271188936395359650621440543 +9381772394748371157597820184835066654518409316544350915121960781236322808659004922335381181699829103134517372303100027463245782 +2615260350961768130102419692323579521155005867350775325462551282112894826272075572040191002407099324856614539494210810480930402 +1838597774381264536500359028476517592435681239463143604712064430411599943084702827260512914320943321785685269655653280527187527 +6303497221483801786682166005068915785511014637493079986822276972242808097676862236960849777047832121671397043713182928176830651 +4198254431094795957177601291882860974299955452519675630067202852553365287181631847719984611318356336562220811004590160639271651 +2089050062014249099555113392986787327862396528284354504971691665000330719435672605372528268724943691397193582081997337212460855 +8717657741330116057938366732697730717547522872552360477855457981234742653137379848417305649320084599648948083741462795882532206 +9986804236567371664160082803763334644507241277854017370156980387812678877717978239570818728942909512587707736901227099845780710 +1187012467446764171881903676699687486363209718049359334271085642494010609014855350532206473984262423560106107436149534409159662 +2848539362765385732985316450544140366071147981646641820740677994697597799634870260463776941968992688323272637389950097251845343 +2181340059702615616436136969810778034448257219485660110664564303142589278244498041564775661983269433643752893242421364842071587 +6511475958145031560867412663572535560224504744829799500512261131519166232318015397419472829178929843115481631831351152969869230 +5907563295429072630722334129008428981723806690819380400545768764609783317272102244876794754684900328466037092277858030276039049 +6371121545042724094475375695524854871280733127714683231595927748253222937280791764025222016369882957071507439090065827190758754 +1326490274618829941454831367643360383905788459550667904893538378442057279259437234426288871318674319032806392619399812416955409 +2775275011488829091588325070565060813564196841900611728756018532857865700574781000487644896468359788252916194701281784442869238 +5475404321259151425741175250657761031096608313986258427026901467928877964154516924617882931075782136380173762818340243425882456 +8098506275539721604499982773326806644420333816118778369209316210417120818431663778002427348509174034183157653013145092651819004 +3184928471078890543345386093573923680647427432807794321314997911033358058808825224490515008557540951525337845495688169454435522 +2663993815050031607786993170355950506772886776860845172901406916363156294602197804936561148186445731375733299997098917913770308 +9652206542382536216286608096098963262843138133196068261154952924480494400928138047212132673039123404498669742532274932056703877 +0803886057269071094490544437295692503919136095718722047240291609927251689451657849380414877514143018375735518559305335464120670 +0151936480170888759767939879997438315844081206201757776198680712499035405650084830184555439755477818487911581690050566831394218 +6229367230673286153903588882341483871782570684557378319370079577894075314574849976163949953230620503498800993353619885098682722 +0775734990307483598683533921005381003594918538823910337693583925400749988570440308274068133400598419503446320537735625031687287 +2279164484478563946971740937436182665660391281989609876479617857522997660917074445342075564734477309946731477007826609533166522 +3758123683039815493345731508244661356741376276550143129350958441510802897891765417564525850067802663207435432004216770694226804 +5619370786333060777254420771287566622455383721762137194440628363338996839313233289419808657699323597544032060605130001017679348 +1117350732097568268814555936831091979923626150476679569711035279777989299558634893220687598099570940599334574372587146302188862 +7465078440908857228369280211059007709404158916443923372217270156208307015594931088483508995735817533317081734115339967063512432 +0277551433478001259984748926007853394677528181409165584238991766092184666080139589261333280556946872045412337141801061054086949 +0700754560549557192840941960533883683916477333049889110496053434388836650044089728945956844381845980096615663986249384912038818 +1729833498846421646108320742580046475400334773592611265395391377127688594599285540845684396076777993728243626683212706942573378 +4323511472129830807288869567946309250674678068275114664508496611904796208234885435751853338278854135085398181237686024172180393 +1312943548505486065871582599174831836548648084308970713256187466678464307897110260321658188877464727357499093515658589884692245 +7139584610276191442567513021000360376560327542398104492743671139951823728316211591532169872633220764756742780779371664542606277 +8013300125828426771757381146217871760111879193645766888697436656318066675243280906292568248974540959337990973627561398675008197 +5419373124232954726590126551016645137142696380830673731392642951542537238565961064580394978042654467730915963421765890733361548 +8922925533382884854249653772799918390864697404746308525228860651400300505857310156341812355891928439789989969029099008533806665 +0128219411137135309941467559688405403979836275303036131774092714874831957845954239946311223981403764141665925425006138193699503 +4023035360745761142363755560440975222622652382698883967356728120684964102122995320575139970015373461400690787473496703365503109 +2193654449177213661881030975620088565679413977376323484863510871705861613106991010472484286534395967108522932664799263272973605 +1651932770511765948726250021128129739307128956256839990590743197977037091662728274789578774568077274689428101918180304889077378 +5017924617218629587957879829522315523692604428645809008208520226544692314383658761425382226132125228054011492055441635314272210 +6749666157481037578188762106676697225815856020636806090419991079970372071289788209874954711658011019178097283297120172931963024 +3867624578607959056494862536265389313506274108084087969185322137028561490827818437756426384470803080867883480797295503488443754 +0266755732085811371635896735784706558323514361613693558482118358007540674486152236347627273339110326422500120960164943514979392 +5851591583094022546650594344855608619956936942520965617453776819147723734709318492888126759979035908706037791854416714517089588 +7488779820804386679237327683610073367094612676999550051056279635818725821831859618176236859057491859294403215135785905001415728 +3397867405536078184923760377846341551636533657104459673180071634565287960125731400588939475716477977856211995657191117602660471 +6368419292461966253403926350187375212915416793685707098775001247308325202429711397391995493844090131420300451991006099818565158 +3171884061798508018743336874067220372374917564318502076615548912819919624484325005878069566693150527749974672352053137075239471 +6765298415501192506923578604075674679460732604669110708523132941578157177568853063216936080050749029655642031375231708316371762 +3941656184595817536876952668926168956461631341364895778129612449325569155094729678326528659230305783051788455638170048468709384 +9344704062107618220092102502671070488066523904860951808964071896990152691743696929206393427492236495869384495623953241985933433 +2329954473357680885309244441022618801570174231106127708621760839070677029891079166854592191885991850284207932518637882898896696 +2253197905988134418498970803242763736997197997987724202146481273276883471048373064146605033007993208986500108914474101742235859 +4471673346443282932636516218151183887721959139730007987788845685281052854907139082610271978365656275535187015151917676999391516 +1490454357895502187362105850833658593130025904397280081248261243837433753996643256759896119495710470799362993945917928340275859 +4187480193910225053682324326478852139878506761849860931936128187212907303727615513834095500089467988300420504891523377586019041 +2552835341088538861109696869815032626256269959324139802181242249722241877212898021098564840649196902417063584333206994390607317 +1538928060054617317449920025668989345408124114562616395808759769278572186743963855933221653177548947045222630757626854233433755 +5185848360760696218717214816135397052477034052026614446970415328439572221368707488898468973353428786860987024947961924953899839 +2985590716831731870038599668250152561736463733069492744631154471689685148003517537536069537952391933185169671069870236035572482 +0858819385615354860719000425698572982937868475649379251912477519089804489107469755432874178918458772943168929318750385686530082 +4333886362870957848081259613648289163828064171655224322239708870842553708643760011978783227657321411272976905508646641961780912 +2833169683733846355069467452629978104797868384861004576520122658047677739451418977045812632716306848990938028931383957425588061 +6045777379942977654526927417023844498064089452756699867598470436037381168815462649457696613017471951809000988548875034178737874 +9160331824383077463591927113486291567227954453778702317129507491730495740733772073822607464672707613182092741352901404225499494 +2171629178354382148962537134449119312001738349076684871759101972177169632459401670960405086152157843086489006781537667287047896 +5465718260392150704046827088996611582230320415786650066647900151553492798388495126103785840394545507668150495076747239741124643 +1419544523318047856148530079232229449051190304992694484547233964026124081035121194889038106213961089629592355710172833338936041 +5735074574334557161220421706612819925561806730824425800383474349667304718298810588448596848386045836391940535442755152772209476 +4477743831927353467775816826229193246462805293097367869721250682503407993182691455177890744118461259199550137591872314970843570 +9614009267031215091375702771630372739884751484563943485109876681877458872527820916316860531787616767154557713108421464243252888 +5725244451595751926785755645396186934606833650722629688279447836080615920686865486122499155337740847620671316549690747377719416 +9886724243384291436035548475563689452903302006875551792856774087989888845839795026561561511158603968657727537570783565987096483 +4338269257625836943750609173139824275314999458619895874921046346622761766613817248643045610302260828228899586867769128173831852 +1927251435241586742325643335703829021262110618516121300640702167056777723519853174450793473043913595814696522118527504244796457 +3599578411448167894106533981801012494310659214850381649569414007781396645447499689729938374104814729448345077680781325687345087 +6129529633831819171439689515282408943585760656344118595138870514119273973014358876594274788901442968142994742135926265337385656 +2522744449484255252321589542733596606602045925005526885282459116039248444399754430448309551058351839870771919853241700908753171 +8095397674156020153025647112643503525783203561945051043117484225509753196255050991995918313572389826508756030729780202503607157 +0514732746209410237098921106270758705122238404358107693018072790601247661147289735400790334022315641411924147791473123654604067 +2183481353624169330708810250088442996270202852800382852132922090252387617856118236197486397057001588957700864557493511482566082 +0159554686938426672550427425422201760923684567404107605954807954862252513544057244716697622930133085009155635119267747535809775 +1603870374074406842079458547774759610733574985005768921583657069449807861035511349884403260777475545081121567326386609338253275 +2866478551802452645398860404273568244013340206033503958336009745540839717584645607628126532817660071722429335530485083943886111 +4372806755879104949087031501622642625790498233747556727536449464577828956704936323795941826197457122033168971930280473743209480 +3510521745467987614604622504324811929598409501462197588604391588467606320835512728358214802216357643065451820237801293132895101 +8869176817884529359989957422435201680723727230870849702923220814297956988224073755455624237386035731957272496882413670632312027 +4987041709615070926110617696999725204352784063869478762637421619822949085893727644701242995534552198616152209092394050930669848 +7400973738218421741284556096408600962957422728138542260382229658265717929340410249216494966480842797114656043729408022372140555 +5357622280419421430680077268491817179160449030679507850055675685514803114136633487732178706581280425610186327901499849008080553 +2063614935667238312237638365326101007587181929899519898020565403780654677915752203035463564958973934599571280127628650025231204 +7510339610097271890758575355760181313472729121504677949019841665976993380277166759244310422659174282752504901557558455360101043 +6704624590746564335785852066839780043541376118703961641315331313655337920280405840841448353766789935381787637277026193365826955 +5718584531080420228299782199614112550723022759714938401551695221278973774269123526563402857239118115571007974128747966574892058 +7406616537246908705363274038771943716880888382315653131428051669734785136535017075892856676521312977758275400592055721561155447 +8191030503034523458658590430731690106155340044400945735308786298326190302983231623869556707507267012762969572969229893222326020 +2781627756283482808592633115010135954787388098836449433663074354764942592857302479394320001436105974173300167981736974256889069 +0749889909665269146510382674032370824445149525831032970035921874308716508078712017288693000420564774687445800320014347768102977 +9500582955080504298493442003839451470653349230762999448413032412395803444854529134420395637374428892260393652466859653474793248 +5578683404816116099839255848388989533623282136956100112356341602163894219640627502458957004434668830525937659394378712613593339 +1328818081682559186294868249152029912791110338139114004470380993085670292745974492137182403037306610656137695392960137614180452 +9752978688889728250401766859342517990190156836045937377483717028864519242478723992053825465496992411244434140736698055778811865 +5764034558119091657996034001136138512460220698471156208113839665880299241195462026376651406117658603193270831455055313097779290 +8887190533917978952783942478895262358255953083684956216049958401478271139454139129915935858174062762845986202401574727546757519 +9965112384492455902741039666831644918325589401840520355227650968749201419553213336728867559952057316374095495633674649247673155 +6547477349678905420240149432846633096396537735337479158019850832661246628844505249719392841713290257003652108726047676880419068 +4709595063724483081528398865202332209399887790016225322294096330311019868576291990108551198704968033034014495019187100300731545 +3677983555491782274707240632393630038558613476413675438434221141668472183743225033730344641440692723378405837243484642959062746 +5604991163272359834040422515862505640037839519050818603112192411600677144216422234215431187611787844494127075718764452791848799 +4854476179924301594123281798645361490338402536310431288082224776520403651635476604940174850365038818289755315902382966023203577 +0810744335357702561567797304986145218660883831691187353402861163846458499952189536879044115452318681728624510324860015033788398 +3979771283995380891938289539381044182171976827997056764348788204187193621090041996206584024348644400402675325221299998818648561 +8560553235856018013965529605400965645682933039991913219712272084018424710938107420465401522172404020985846364794336906931979136 +4463662321945447989909156167276620401617659159053053338198477063314745749076987397606793494767276193523264007206178167936213596 +6945045570777520341473278974105523918485559285787445842507870137014286454851350178004328369233461521852484045058748849569462881 +7175394733133381132769602280613000317015438488548919976504824538838731947546613872200764083627777984989422833194236427886436510 +6841401583932488101726607361270514543381198032082148492961394207816779730163687527133913837138426969504533356370971942113680465 +7438297763442758000905394998453798098283316097089007654200747461809281986645383560583766595972712154827834692097585224878349332 +9365726487547590990433290508632050107564671461069290060500347861396555664994103630437491491318643117772003180597703910105848664 +6611643426610581687045714856705413399193072506247927181637882082436528718891021527134176567154185837899481317325358321239700678 +1557904502034099580005949862058754523860889792700842593217321816597173581797908357156234792521428404814333336278006477527454771 +5551300020237036342120897324580866490216118116991149735001002790662102209629270626643498774459628186650438561401066616780089887 +6490963755355736580386978526346909059361347064280111211229508805478817906115930155049278075845715671257641653870466615953910939 +5214778972551839841667874021257601195235129654518890488743898996335333591775608284908553206841411120044347642321931257964395096 +5963500480745033263837415489981452116756935833729630104233601643805643301868453891208377454731826714298746739883158478178624208 +8078825488224820778954240186836158374373671746556003072588357835036884385547573916766540198508057742745190671930027702184464479 +7807519854130748159210155879811678899722270728200599689770154189194726372412310007746266228667023082290285051427818296004435318 +8849779730758648974379073101178990211676693852201291929217145528640734853429497077571161674011066495817276757324157483849716817 +3827352998411927949530005101476246283441759897176637008058185334546170312583858564041585383266413483217734023667361663656510262 +4989459887640993845875939547459055523785574975836774839383442442772727790780196274204446558595371067248953971633261788681833422 +1430260652446882399259326117845029992780579944482914613560754920430392419419801174119306529200876322246749783122971752437529985 +1073402550916699040362018956704245437401832452382196705545206547444352132288265525961915924743830388330363555452775455714221746 +1446616034452999060536906307198084433181209978784238878045014349105221877679941993115397416711191417693894301857690745032510836 +2955390019036983033546377278387952218996955027373523655965784118029086980123579985775681000785897246210289721704232358897262443 +1116899333926038276430989136011993311064835969966384464160468735201645112827713375177166600414004561963808951457633980244174631 +3365167597668328545027411315066184915713562624842225290359331084124729347322094220584503855828183282959730835678676639554531692 +3703132630286521554741077336255711977522731641435705473997030102644612053700886241315456330580773390018414386585814426113751822 +9217494111509421272989272558690493322060649433443466464859990829891612802636240902558280843106767641519024486333577210250455758 +1991150751561946927232491146002439007601543254992434751580119323409611022604175456900099304707614992483865118197257172247468485 +4718289269042762658615396540607439436267108037664826892947523927247548349191063673761417193077849996352799507438421286155035753 +3670003174685490297784963434080516316824119943018705327982929605778412196093833118187456471893403114829335230172542023511761918 +3530299462397538994353624879221057016014513591355266971800473995195599575301873296387357918288523036075230002667564181209941862 +5652465756063919538830640228613516853681348031923008502389424015416629283480087157633179737963541694567718976270634283296698772 +0628398273786061322495772855081114777882254155541640367813109541283460927308493462443462004237680494256941289350455650052190389 +6530923425528750248516830645859529161548508001636146477492907827739674571658452569696309864671893300056851989854105052764500328 +6377838408857911124605696723808145124469491655188029699697020610066790779133275460162800601521823852930699312176096876169139587 +0939964825101402137367079294180090650010316165686145129739428563266232844352675969324123159076365905057635263730951535508592474 +1811804823447992196520518580949056544426238843325335935996032408627339563545875884333166832898448807558706376176980463476019811 +1853671195949445539340843650229575714750539986544526174232405759132358558190475375028485355385394868549681406717987759935904458 +0905656451763972780540932190579104438556329939472118207647554428546869843074735432587357981463196272333295652269129883611649971 +8081235587163561191593283995607470950948702816215035438010567011848029435878836700192088876498542980088266248768136664360732349 +9048395346539903256416069243232533610069691095414640231288922049229368354092313481960519237230458713935632653201847905841902926 +3586899375981532151071970206889742452371614510846757239619094223086588901204291404135214382914427118575565088049023826713070734 +2259183814776114935570816268571424671175423119794189492522671432476564901966405647187984087627618260356094922535155595764746633 +8775939779211866982932257974707044029673787248018990390269181484731175023868082868637570701885688930003111950730117366747034776 +7292037040878433775921745075599110933471784681597260046655966261287697859339714368407310137037826533774841074326027111292219013 +0255740507228750627788675142293353045696200562639503837065555027761345191438643278181859657112500994447007605647817675710357329 +2976075331061106900800437561657304517961915727589721564040507512613786451696450429048216474153539650176719572123959448008900012 +3408433706045747990792868143612079234278596536479367304972783738238238625919742682436942402201332632706821698633101418726786131 +8375660756604324838036937822438189146692980841058943655646096987446498055875487503182581651007976496878268593478897138465125407 +0302161625788138941756180586844882835162635784547013096553214201480525116709804815394793585124634598219195269074280104207728072 +4667838900407600665351205946634451166183916253892825653381319301710998507256107777186848085957403008238368100522944303632213848 +0568234978451633682200113830676859774853569376506354250671989943595147694543341125278943952146653132296950198184251693558754266 +0837997184654618266464229835853893240382511414642926848175904359357425914225875122515607126936089890130506925127703951001817058 +7698607971927804322206607636649779969047920064098738740542516881736563449825854806194526365935192809082449412467250570813092077 +7597321887811111154968364298503454292989382990719881362442172931187037500402048057328677657705369081382090672410230632333022578 +5702691344767100466202486216169170905325756285673048601355109036801723677816257513289352210067825399512675664902709627155754391 +9534899164623786842509061739505443727104012615679366121874758009252764781464695793453679090140639672566086270483355150124722338 +3629599380125790239429932208245186801604452556987851483665390481177058173633973798236252529147955843797090679456499291551397899 +1654839141753372209578242837530384383897899016697607163271741042796206564645006293555562819243718356635356102675076651792712069 +0330578183767799422174048823749345411130436371482070584047136107077445803065143356378310883097325525812461948426463818958359831 +0535837083229949247061916351323305805073161284351843348700635104127671026579915150619625693973299904452300157134992421628495782 +9135533592025422741289488252334208635046166354163256661447685205945401888767478319569656787569357811074256962118550453119004362 +9301751134736346294356523345255306657038167822211402293117443464784840025659169376501953957672727051530179579688902595680131766 +2105969846665539329882900056874716520798786759023512793122449365556804018453805656203040461898429839786920406056455733868681013 +8994359707951012841246179634189829024194191300675090705148350390247850109295388787831386650321294752877084504137894482370739618 +9241947230769626839032573755018849701961689378840022528468670515360403514925600595045782712624516468191893178057825723173315417 +0398704518600034083166938112120280977963993296425790225059839016038745051472686938943167918298644018861694001602670324180907739 +2829253174521666979009820015551029220993105373115142695444414232286946938928961493390386858301002697320226848958500348592987936 +4933376341875898717948810316592654389756790528913140902980810511129982071300880573916140408222881362220907631175682400695211957 +2728405831786952505365442116971677026094675638127255014104635321119617454191227198408175192550442007477181962648595382032863011 +3335513609023390087365324523236604049358730860336918649941016742564809500323096143070248679219333226141951672644858949079743290 +2564143013685722767288600853878709769356311565059463598251742499173323941411533573854915762183775988798690410191696639340413240 +0493448733483595346076056156947860868081377709049727106924154044343435604871736849228001533150906569243527614792377672885378205 +5757247991130415486385859064419869200094851432494013487858837812428585929428086640566084149796652609672519627454844564932256297 +4669558478660881121021903646645372020041434507907448258764267056511994202274610206718051374682457426295364768694292186976277202 +1564360996091464350826834839280932166253903015206256531264131271209638480781609315412345487344374301996139188255108960560840234 +9176534815648639973257109408451729832095062649822000160147163265683826755303899059727567592934572490764864402347275743547218198 +1866055495605517210298107031806201932208987305284317169767415130763125409722583393741250961695800822861253047933789380082578910 +7563809612558319699283127796207634523042191451596228205984495682290513031662522019531400901314878626864267750108819514332947951 +6013217317646435086018804719571761416592333129643806900438788455325630320446510012694647580590342912656641492584092556696246675 +0844610636935384963725961540456988648961187114742364338486232200258126457044861826644153851981432318719173242496404738484829592 +3080829363782082227074488901159023270312983944302028828324523976099006110195688729810726298266450333348633619065288392022236229 +8005690472921247866581261895577036104640057531331680489329654614207889686295106419176764455962025382611644995861348654828098933 +8502321967575148172006469677676125932579572402208147927471694132908710196626265784804209764246638587086749717612279459712731943 +8253507041283227562754413288994720899007749153170225893148651683553291625294974124954074490050789574119491844797138467527966227 +0130509196073119104402816135401821552059355465255575401457469499625193746950815086568670490180348072693785487568778765124602003 +0665248124119376664057125582265850335568981888916788294854156077917276025925880496268355143677289608433935345978812154208855268 +8995137970182597573167629723687168196388018417038021858197249313810312106750976993518701591284371821222304917627037046364482239 +3380163047424234535936046961259910243886634603953810906816744443879125914109276466757734603864050055610106148478096732039481501 +0050863632424997195774488430947153709833716798293363139764056905080948883372556055175360309201107604690863026027029304809129018 +3159045522676282622055741762907017038764983291766901157880220174438440331565498671114637842462602216932285417970008975756029800 +3552237063449291059014349162828946704972597219745549772402644156576458713144836954411568696563098211658803621586740322438123527 +8553792749167921622407818214329886287689794104816641507269131593430918574387850051670847355476478466155909359159406347347073422 +4529077230987714405406119382703861571668341576429308147647968381984164008665288474312273798880569173169482210427510225857144151 +6873466267196323702969428729542596817149488353193513581368049814798979078196465830515246880993440065883452528995023407220294628 +3423764900702625807926494346022071251875105005653050523263476206366063134157656968651581937910705560688575444683225925304492434 +2952113637739291573792177591055762311484591345740602655920022962868733639951191003783483933798477891209504511076833970415208477 +5918285063915228730571970492875778946493408022023485280196322884176264848374770469091671934052402742006902024842930375953314997 +0188283754328437589051211543538670804314085522712102214064193375644277314824255259794129098802312806481056628400349306174297818 +7400374465412082001463306963438819366261869661341067811137716763449961651069723995940239925017934226230532596999220744932707685 +6210672490680638537370704393760193333970297977253365672997212980801329671424210333810500664050546692669173806880821364438329547 +0441850655848799432631375117017035628999017015487913470494267041654835295714453029034648907258088418618148803149605119491595378 +0667709470097778550996561398901373747557627918533058120957567808028277879620594852014529739234370013800886373620787541449928329 +3125515897530266841998191196333295200100578758020333846745697177799969213733901430202219148194889600422499239512275441137216920 +5650415027342249979224454839045392096843643602822206652387425455763721764312986203030589819856297909492941454232871627676382600 +9334860923952422719693805188600329744718934283065130982713900165662458916981874159673444880197331666542991521443060535788337790 +2260464469972488038180467803562022523783671731570132720326212442908194344858555602668263231905684505806559421525279834670049624 +7792295078720351079690690721334629651981883246931635344717773193932081371713539221551527543695110154112122644215377568071412160 +9195473483543180179899660415512485164196998646076213127620507751563271324222304453084630241541418631528227182134165081602418516 +6107199131518105376224811112336028754695240510430182476876463353393744511821873843541677824666782764783493452855094114804483949 +4681701662176678506643507046144062278379351438997367570137464357422720669913574736380880061893275748247043675527436431955366100 +7149553832033242764660394022295041894654956152213899886346680985491273200086975419330405272293533518246991447255727068177450390 +3655198436587622677364860349928319378663047397528676907239140945275682820405657108502041392682979560846597921188888907265931036 +6476533442276806500783053564071177712515831376234094631885310570178318133342242810813665266902989059805523937906419013727894188 +5431372487274298724777517697230193875880937677668764659986523658830811826735084723524757461022654674192380627828684371745612348 +3820846618376083469895407196241963862417850743410179248545973893510278183277393709562656195366243761330452232662018800107769440 +2069720833072682115347026542393190511365870201586051736004598121210837565385863777323843786272509797134422300430192141780468920 +0442031082909423594641218252063553777303614020588281829250848330051744891712248697144729676289337492695365177253047051776547762 +7268639820077382077506959745238922291525171731315329144119549984484846531136030620064784882237444115815092112452964098100945835 +9872606636855509027099907122315750101939814965155251567403611737103452272009598076995597635176083234788901670535978209531433759 +1085327638195333244518594079295886331726523118261222009427508754702667381643585015276186491128806622593525832828640622269002176 +8000558812466886549021793247340135947691306446427709528028498200426365682563584527832696795214569479985794618339152398807896264 +6187988847312530289136504030984674599402925257102785831329312431749794271223626066515601194350356075536808657593446997124519277 +8221593778261506773470868068030158332034878924556789236087379527748372902142937754401272228850387450354124993708739623158789162 +0522225048132576688432285718958345124544338046135042578516691967468794904627442698787375554323557096004260191198734997094093259 +2462493092358156921232365706546429643442698260566011347797207644508552329524610339812245114706710736520675636593241151933904714 +8168806409481440220552654041925492552985114821706878419857282323004033916474011864732600044228285384350058041710798941857144196 +8456183927145192331984325229219292792322346278563254801756089348717336352552507588302857665733398806159165657708323657950532344 +7959027432654889449179694030583164431534165468437531025326379868797173494533488353046359898220027884040904102921916878818230634 +1572671474039612214962772842653777925720919829404267236601529791378862012346769450214240286963754895280462160430824808649254296 +2713235643749557564532205594282964657763877791499599519104896455051738725475670902079776954156280521778944415643098383791627273 +6105964254598123007279257593697900824845572590247120355844905046052760198392683039070579501029336629655707492386250995234644336 +2615762358163929247483738668566291188631481608731204506773561888479176007728316484171079619334578564058039995926257045933155309 +9915284962226636771930258072321745421222389817234966851925987744510291810977458517680205953227386190750476782698954854970577352 +5673578687374046860672064496277781044455548859373704110716891640260365042726694184132711815871762240294031220477588483951772686 +8668728817231201425334885333412781573848400038328099971193361147160493544335456580227648349461318031327984792185171580102807503 +0169567182553246331404084202997183149669206523460201655479386533242862563036582654644409484005992680312894606697548079677284436 +2408634459821807360135371085559754639951676453609356475891807606645289547821918227592956096670383760258316085039325249167270345 +0639753426126492725051857242781368140995333223012553263382165242568922620303770347983405643905206504900791961601071942284936427 +0871588895354801816598052309754202243843057099627863238724184518284044817748295192358320828895054008513930794283973928514112196 +9798654324310664456635488952439998180995428408476235283937134417681364575355417817510233366035067348678178856527757300827180944 +0038123007290989063863175985592778519488056333171045377703085872568160778246582018586168915869948568385646644298618780983546355 +7869384600764512734048062223566504717806018441987433044570169614606144975153300488119826197625737171672582011169222743563965980 +6977293818241046999651425289984525444775996710580402650890897413638457082477468109575400763448366802872239506128418904706794072 +5799904603862986594106662322483455329279349540532965537255861860553280872874108710364305979053889159756036410545175996560632213 +1905113425852351684154357685504469533745516493501062212340862826870385326709406031686063551224557399310052952422838419329227931 +7546871961833002037605725905779115533289685288706841277287949763530450546184456445185142124516259820881277398739985868903009290 +5390552777664596373149764240028438950449670876087502765011571015373476441820757391918243018050536384628502031771242890575429423 +5602898175403670523511959645093602460733826479169195731008780332981500631244059144423791577718260284080812356359230721779826632 +0282070388225563293057775488479437333861437827295440192975141284220068554470734762243654683900921775316128776798676828649464561 +7044919729960370651911034098935618095727733916533962937362197410606374931103363062973825850629444853848346339446960413652519614 +7923852433886365419446901963455158024361204561948757781294971510735411634498000899993250692952771388573089449720039510778006556 +6448339128502198442312788117252393804187619178631365039260121533649897690132658417974431016238776431953884429473283621621760928 +4796673454480093007496675559950785558242785307210144883418877108437084521237518409035829359990440607609053004656855467826840969 +2539967222010309449705096804270772495367746726394308555148839954759386392982542739753442093370829925036983594533194718249508227 +5349079635800249074525176724894658939051245265345143033311987922668779171808073614407324686649849960572890952798590407394876104 +8881074380416317599148271017700792806364855765066986663556628051754736630602571628284291106232498605571402693983906331712030753 +9874937506608818776772074340810498838067037288381814044995123846119534641571274807743575095446827709625774292925956993651483030 +1351712538266765203986454072646816009684736475838189392745470191271779327758375268068178391759551780428792430541942252314370156 +8407859484892460620078868667802179357348492180685724246644370230014476781983275135684947107880402240406891839259873980451085903 +4906163533191850256268583682454988749837419823578079473319346296433799092047235338380155019552271132115175763259341940167374009 +0058465924482070913500147064727037054124622100326796664614046484792704959337155884709332716325316023891570424872580884952438266 +2436800291590505288180953642913700972896437288014085488105811040747638787748114199225450616098949678241069300416404785919318926 +1934599170792002326313718708164205938810092585230289681773510059324899654472028348104884160918328871998687720554532160558923223 +2833310668093246151983045850009608661418327316614685260920047242208439507520352050936476946684777115573214252016051709311522733 +5806306154432125296361988853844471579270461201267503074861984238054921903008010783021332277527690547871326604862832931571535476 +6953887201338700880983597387777946758689636635028887005208234910693065403037992011989492126099118102129494636864406808581750418 +8449828487903174265578895543349223421139970247142747092518020699819810023484608128979286359504168816826179123882092074937458466 +8429190917143583035383484835202769619898592015997875633392860989349020465819040052129531463007708159553740489427112502433350259 +0015541288911157030703391088218525575081861192862772160417721389983310098584001488671913042391958271599517521875772879817883670 +8715721723667422477987285388090627370795114420296274720333968016528373376502351404697409435351445641183117232448408900877983999 +8085119600169893659072473239891529571989304915800525658372770589231187553832358134049724486998092398100951195327740893124363904 +6825971614998820258858203237294363381385260403003703481866209020749805588161211696398124406863222077112906818160524737133236376 +4791287439396340287050946270382309108183116290058907007033269789030152170762597022242414148156450382489069745048352057183456698 +7699407910303700018163871163387977417734630895740976320842794125644044206230844211892365927545147294624099819954065586859396532 +3131672188768311610064467750350104984282723151135474654890501043106825950749943883966630006426594607652504022624213316206819824 +2381097970942205624530028578508606408894416081148567879895026246182144217645044116693226312513033539646866882479709987958089969 +8906558060289356651604127285059333055318644242901255378341192868378040612451560944688746385088366187655524363293058496259834503 +6045783943499511329380195312503328218913377235931966010737751685331040259612353101709972563764048165640905281453608759750462107 +2697778235378791219808122722229257971170129904297461026446932149333464400232434190909889478146390656698937276924878791295257123 +2803907707992452534631676946969649948134841465957319668276815925648168701088565169944440306293458637327427324437179025248962792 +4731713616143649458304003973798123909714421863335575637937266819992047643342146589405067966192841049385855050988705354679370809 +5372002945727744156997261317197525282324231196500161732336217784763019914950265863384886596392669097800628799874734609235337063 +0503789478310331174915570738552836640716185310681333898360502850585012405514745303614418697185463616197057663173866523087604838 +0675037169916204490298120588020089851962810662807481941976840354009840553886735946987601156791667665686995459100468477453975696 +6834794049663185275577105102245452812771387897018848470724588835525127031721746222497385677737902506111966509521044773531500357 +5329174285407427305661763207997349560549428910454568831186538339414510256938492615597532037011523362904523476314189986503671291 +2718934812220309630578226399896956440076865897466517017205703733213982937662658920267819470286608114781834913036578565065677437 +0292082835411024840424424503720769844545589088751119682651139453690649901159394940442554457210310520610468908232856172200322893 +2168944494860484191151489757452268440986053558799687398611861491809004454116677153114993411395893222172780575772632409234094898 +0022046237220608888434835342573839194475118566063006131560443847533169495969846042538404623478526559762435571079702487933385421 +2451919192203771937523596048769324041291130793137730493766482430142235410357050813575163787479425148259744336129889104511577631 +4142550759732390528563707063152034344178846568888223418447224601319163578533878251799463243956174732623278426810354689051255154 +3970640202120158350260730117870456696154229567633606514596475612129033212370234978048801831781364493706668262862093481931515716 +6561924140099494620364526936808552193114041143469574838371934269300545161105733392695711211423415123016324534422409169998476243 +2456534483029530345127697481939835893243537886692901492470290039455511175154304300500928667293566968811328935461117311498383274 +7770989718625939764088550940976599710169478296655836026852130278698487150688281647540447530622442916288092929799874814879443957 +9848763764198437026743206591847265528425238321090574928951078930719540533808196681934811602035009442951951047723353414154858302 +5787946077159159168774450433330444862738778849768023490388074911496672265084989382578533753038885946437129868548176233233930301 +8580017107399342108923739552269357825947129658651850931301283981215557531809779053507136238066452267893979878894161383251981836 +9913766525707178278575810543038685579648619267169136094328824697618419625108889858389235878109542078438921757522374605654744287 +4829229647563208502985033637245591132219509835319418276937992741995767258780935271942567981080789563695276467555561800638017448 +1643138233933525491385701115282638884356620775214978523597941747167932566311974729439511528404991306505854174907409034566035713 +6143827997778747391148759316186369744390378766441792907186485522361511087226349625577289271875444080879557771349971812896783921 +8151037464162282243454432112145953184331053916340169687740205103102595400733446898088691425582734935373310066807019088114280263 +8729904943075565576008704186063345542320788733990798433124383054387825974302546390620173375209936756748717665874520884924479185 +9888909645307351789982700065033105216388788398262734159940626037880383673919937047828435841493103609687935677331602519191613414 +8850737384099163846794178899558085730334694261907207404022320796803770107876986360807427894048245601008966306481139963465178636 +9603978263464022093387313902323305847024620528667574592309994157800256182557220046954796119376040712963053063896476690374286989 +3405947975994172973640043088019552492100802303545308377567580689104604977659913539104938989315677959717470803854511462658064563 +3191162645413432233404183050706031855638390349798393321645475424393193065096426473922012746067572812705091078572123464528104522 +5754070330806062132016998542325199869791387417374085617357171312577717425296247007640670351991232446756043415004205160478899347 +1725194535387949369475223998736399458938442651506418282232173272224426998356393475616690357433350683532939697909185050724112276 +1531609961298179460965979011464443408544699180131732903518616680630569852510445519164321486062756903290742218453214665562625462 +4277461038526097907874522581743597670466704734455633690080575913829222964025366450929288253518473640288917518499198469245997685 +7420143434734074307744766434941598412413533864920547945213441905542326713457623437002740516606230037868321117285609425877483514 +5509703411252690324400121230820675240247540075031296148576782911392574907974824839505516956261324207298130826703943230789524466 +6235427271350178310739006810179034776823843871399578101065895786301705049659021548642844679899589499916930305008178597329009228 +8708376738514576473422684695199014327164139367786002985515660277291737951903297112627302613852418677997201436504553518932602363 +9576506417537859055584148204389221076679317163739081159093922729562344633399336320523856409926599959155324451664857304036979342 +7821519375657055506931717396389844553686714012907465431386872822303418480617283652851337727643122589592938283893016029851450741 +4046931470136635022512650864971382510668763279223722442081085741561189482186827034926915081819290103926309450155161557982601266 +4715454308438516658794722092196206636934007267582801367477453071665674490724227142539801920570519231994847446963269786268119916 +9168041401535492095223153393392138627537574429611826175866774713151956729343684934892542983754029148830727112711391973335239513 +6515970901191127073416539618442535739664555006336299291335206114647465786032988393861387837528101930282563813184667131516357399 +6965025115159934457674823672748261872585621777883115554117585206762204650484234255271173958058407125541367807442514328611570278 +4831064230665616198380860322957982656881003885916660535633639193463684058409926839010861838915803748651536627056017889319571392 +2850377483892889368048618651662404196455568541580082178826055899571765132140934322132515590245447090853398672580050380575567268 +3835035801788676880902622563977805200108581423258706942731469718506605351522050771195525463348620059942550507473397926975656075 +8170641249931936194409801838731827726032358290235160889838261562910412201128942409820711534658779929527668900047257962358847821 +3914141889006189906618830872826326907793134446571712010041037077410013305523598603376182060668984447359850821728080727595426748 +0524288363005399115153078597028593878897064055724890623451683531614421839812503951731500983120346087995189240459208148107096125 +4155453406508028056687037448768955586471685200246991147018630064209861444093780513311415335160348800209398873165630411940689888 +6507947702834259046810555837139361937816955993601288388902706347465220128545880169696095175041923698015462911423095653174399855 +3762547022058799188111929405215622052455625552628888943381861262479627747983891009023031983537685246888772136743333720092806316 +1214549690057757944760791464294073960482795674578197576015074847454616235022841464586043262062684847644609779311315421146732973 +8541338437296411555067873828147460205050118794445175546707442427376724688646895066999337376018755680130878200128406968859847082 +9053903102817499105181101245913670467308052365562812081988351351621302283720868904030918069105268441314194378171102376175885834 +7390879175657202991792721024454048282348887367327525251428650799473344325817058656761335824140200255463527106801978883972849023 +9114858631082305511415208423205161099795092979957887353079774012813446208145355233313207283275642795951235302177270570702859527 +9437270466650300884205636449007422609778006468400075137707364599220020468818147412256802671321760977139033664343323597425197602 +0302618076580610803854795974063518981909366239035024103586093127902225268380234904318024257226627138837362185766291678782029207 +3947830739969480621126671162942463986987058328256455824368521897685045168203062702288692030759860685197940546125045250168790201 +0514803654436570370324022741742361761085767189089724981006110323674867393784988265456553747645514420643289677440464150052019123 +5223236088122199447858422156052424410894574207990368063564291905403412016110145065374098953504598451976662453874666981008325424 +8373293703798267046749026333095880042002196112554036817370313956674653924174972808775910245525212215059736970917924397257890308 +2688275927997288192485396746573266295779844438202521819272050705543165472702597009969819708658965256689368204413111379773538064 +5084094239742086467203807611090720704742678798346329233433650521401666169943202745736920597870661200400002701183019652790391816 +9022357095836768187469229301323281507939417769215045474272231522798590708421786910823915726035891376298601448255283206715063088 +7293988737791411397897393109492140546674166871313197493347838700746175919251207836436115320719048184023218823514733017767389387 +7188783211699643174822974868235729901402276203893157987109644622416046761772620967723823455916506713613144614196470266830456333 +3793370001173936142455344055973062003252783611956485218268240522116090384604646513391487197827194186399975132117817107687082668 +3534299426891086746037016872943029880008565862091417500370811850667508670706496943938696062708498042156433801209832903518387378 +3612904603444715041436728628573199366360323396870491816934924984624193337784171063290043144432026274325167439913901462851257791 +8301153338470277907154944290430893973748596163892611069628643761048471308522954471189690031882490684526895423581669049412645780 +9532276724709021001315582137581907800630208033706211952374871095930264465397182584969831143514075753862615083949416688307055905 +8388236378283440896890187881320950399116639874885181013806820276432717798539692296166413239097562927693580121835296266376329989 +7227163697631743317865706478603326970676879690725149096075601615664615649563621319796915072035936935656249230727588009066864898 +4030193127531435008439718127581289588778728561167418433131262502679346011703797827534339742404719888498611315489306325294200918 +0822596041854995877122241367357937629640300673554434225279391124715516842541288461765835730255187409409295964047110843143360218 +8020810762143625695211304403500380226297593451193440072241550883222759127723312388393491431821749019440262383840735943032001195 +8318237479489554100626369597427649553987985282444811016365279010859228891440704149689826185729924642137537603090218575037482996 +5366847590778547088514990246112762636619967032116058526965593868078207507263589910269699995373744003756645473632293041062685541 +9610845056170949836472700450287286628803643135098265884778110832410350875689137416100768678349522724998316556986352522714663266 +1503726130267377258411268772164465860231491482249362263232011498460531343555282835085236658598989040170763967052694908347332552 +9494811816089738912922010509947751572303760145536902984045309394480942411502821839970060527331347541450194445987076121267053844 +0578064800062529101700072602908332148334858119123936457716348054959136175842817084891684097218981249238233949488256020176601607 +8655837084859592004656876506460130727405913211331057771278893395802267144808219629460783237220481671207469404413079770236276202 +2474357024202046544233057042050406320202093782109005795759352430295741395906001878748884723478079164300747108788119563090468194 +9729275772864119080887672349769974091030926766697899488139685369926038289554489717497100438993101868557613700320201349470541544 +9690121476368923069792412981332423045488814436625785624017824621004713254286195984412682695459029135822031307061078889173619865 +7378777371791906660635984844468930766958298884404755753328140351948727806677530013266236008432182713748064589578467419387451399 +5958115863312505525587296099572988051567717080297066945899741469832877228284562546192870097158128338501540449059947967484049806 +1525360297576645372782766370344139731393001666478941675207716176663153356185352097531952067180451056483850877049391450796637643 +0957180541118429393622724140553758348088782996643755097821436674434023381251140872906157549968145359578492278555879752671991774 +6216547228847936682579390485586625009476953902113956539812453553726263850745606267922068236416232274799633682965858910518609181 +9364762411101864870815658017284551581396524871993598349274914322101521556813705161096159781789698091708777511072561306773711005 +9372502462001712636254133123395734859574314940832644465721405982847453658518168263698099694805090947049141539874161892364044592 +2081215406680382103751369362572309567943724594570823605875011736925225634106628852644577321897191396835476563249653975626106030 +4349971249994089684132392481061788229278189139063384564147513903173876133019427848009965641301113400947275878225261721625731279 +0221661121010559617008273964451895647239826707650461656354872916410348912631911913485548662828141859786059545072528125011374221 +4423053386826713852263693496635804173362348029571154806846975163821408623542798104298751000786068795017683260714515841078366993 +8161127671355970070573405532186939626037976009760161070135615665381704277318637283166773287886342633146869956929128780714287331 +4724406673554759228867043031026142833731777584308969100843251135369865682593955020981079390823701606661557011686336153922127671 +6320174341401698137531688064847461308245007114188039688579142931690284251799997677320348583442367762054912291140917964811725137 +8202757825011219494192886746445679726841310275929718330630078072572216660349917135633404881654966136524906313940172149175596901 +4973259052196790674213907468121479716985489021755170094314094085515986880378978689367545392713051595516162518064260512413271805 +1589006020451052603264805726624921702203140540281094471735610296632014298925191276086205769087410850492910589262019474771202876 +5301512438781961299615681939122770744864098845659058825055415852695585895078281739508660406939859772275150311279745599614771126 +4288153404604175490400855789649207035885124038840820254085618553577028061229192741635233861987354455133991517534727391845052478 +6258955556704090814031626148938140929500657324155298474719121746871071846048890688770977276676240866370191127535467056926311394 +9986426460698287989606477786579619338308357811140009068302509875335795457387693847614672598016435455104290716649294340111672025 +5987575195605597807571132149058303080863960035941811196802177359118666488648716460574884370433012992324776906424681910784438914 +3212828929093079665577584834614675181147027766122500255332258719353578136517199306847607401381636227698622152320466280962873067 +4298697726297500762842637031315949284066464528353792900058970168170276550530718742305480231641988165044232612666352048235992340 +6528595274852601267138855685497658048124785482783676783853867479073934060681129115971059226209525138395957477851256838662435594 +6333253678417649760854615241319608105505866305579272971991684020242948061790638726814427247631657265086447512599362760504729659 +0050552281101516551597310571530814588813676939570968218933911952205870242379775297989531959401920856446210979962385790387518282 +8767289958783485919140054170755933223361121752964753574235200401049015889601531517259131960751322512615901642287582440268512260 +3451721805339224609531183820195682695971871204396323817335046115539455320833063731322682287797699412707522241064736997253801427 +9838095438421652946093122030638044112929662006537527680294782737078006325003341225082530500978086841673076833294743067222781678 +9343880589742192946487883613246357871516859764774916328816004546765194900049207055237803648799342279688804719689248327413730472 +0721971662815930264205326239766135366858450956630362245585637639859898001993676716328053273905567456704608882800064784850223773 +0571787432542029050900323916790197508546510517976343882254348928206749045986326975042209032481347983325984442399998495068210198 +6252008138898607709468342620809002496223471138515742069863151888069692871096460617937300581107228988473399264367167623204729419 +2797770513682558101443641688720044042871553905410373246365721075390692021825457052959920292945148726156660506042073326859993576 +9943199450035463537495910614331149365062244685626306093678223057245690588586113869249388996930139917906887631260478153521760102 +1950460426985566320913113822097771379876492753786278737646554639417059453209917138732302032256017931681335738155323404263671794 +2838332702415027792861677040542052438018840283865010592299818970494138350530560217854544968425238656792859418734080761867272852 +6010463746369529626569768506440616846423788144981864845682008740038225629815725166282753185272670640607060429451038753678650440 +3603428316928538153550803942955541314085414603075220414550257874931378714081625009020301955524753074400211685480928675879412454 +9843069053870715332522840750526561812419932672015609424516373833579891793837439080150576601064726524016745608185730860593580037 +4790338120349419657809887950279987231778879709683733319593125286240898651454362025515251496405484678061036071464115462928635106 +4812436174990135339020055889098969606774850114068102256726271424987296420443648067709292253692100724695627779636510134753572039 +8737165463831035630144985978697481580718872897801411679391604620458063323095158841009595789901639579062186093555920948550517282 +6684194497843892923374409974962663409557384721186689597945008117535697913915795350771799536776499659499378233933827449930665824 +7081582116471192658574426394048422901610749624872891986363877792779389085331435286663561611309448994925468965045010492951543901 +3680646340800173339218788077063204059241257097481947777145409084202800888856762009180382127277534304230302616826742040805136435 +8971885064485253090204122142512764196490013452340872579790701372873179615012971724582237981895972101835369658929642000295179467 +3378697466160221993719637822345980287088027594206423215053076460092623235649859970956549802453476198188280999027211336510921505 +2652711751748836279015697510746966396333400935969997511167766407036252126460465825405459671454621493581082715193532241502957665 +0853017906034458377960386056517204258262136080721053029202866891152909200067791240221407899628896204792320935757942824137109755 +1860549007099165197284140872678756594535459353075535851412365063078974696027557562375802944288504306767016261985686187927040312 +6976439902255838121317145194266076485068757990450059106045155783172858632535344129113251970702093415466811410640476211193415639 +0223864295074452283847305560600110714424512989818888930888094361164360320952698546375108408821282297940103191521862113682311023 +1062349856533324628662077342594233105268417141054370232872638557841382516201012169119621084906023902818960772903834214834404456 +6774964345965594961633616650657071025352025214474328041017041037485163730502274877992356272868337521422636796698369213270452116 +3863759791559426852045781221052728648632252466126078672480213084512794723010528131976170544126507023866299598547784848361822975 +6029193859923289086357438220756059069241393076481467455226491973473927966812070493726378405565631775752820893408930243604143389 +8322645429369121872596731546622494472770504292226778137537611049076304139170096181584862462563435300455143882748092410271989379 +5326365807733260201580801629433084263428632745627040818781791453399164548163815232430786017320082301681273560908524949863305250 +0127708812120756378948747377847983639315742195284498126386446424753766099623540522826797908737477298768890173160498925727449025 +2938525448223494002554985481215274772014195861665818544594199880542548809977177276693721985173829796357491362226406805154130568 +8969218337326188250536163628581836759650127208671515917790854163363077352794417610106050375787449708519147175922505361662892084 +9818570904194161360123724397774706465600642465735373239577049512865171271762814912171304543676985961805640424586977875904966200 +5504575938770959529220023577243022588499122259144158193746005510614090936240126010183628014128216077152330048541538274583951558 +1040854914239994126791549056393295346381943572230033663200164558894293446713116407420635913349055999596494259230893231105260703 +2206196014061006612340848198814409910794456229071521204012047591463330479752534343609457402515951279901699854399989958952429475 +7726196843265136180636204555752895156585913253117092477574090168474904085406088453119889514918675712220848883891583790692329162 +2932979781809321279966736276684170473868093894960203921581294390763273096543783962941941740885305313552176422059326344349963187 +7716303606885535604492911546074803956458411462697046763121884171908019143640932002882802971285171891988638807617682091180833424 +6415461043036191035529625558425951185907448251833755623616264167570352631169542482639741527208649286390063877760359771911261699 +2470130258381358062929085215957585938262216089039199788226601264737025509814505817029779107756588940453410080897136093992799084 +8707632659399021754985431789449236853018112947892026429638184953314257900880019675773825490255337783864219014358786450842397851 +5533932851049276649253727477601106534672571299541307151668502286973847937896722437084410916259029864044870523541806218077954614 +7765554877085157744714903505492619912731173476480412564678818534684847115861709661320561820994876787782948571629974821128726525 +4958648468242228861341995358858962307381366972784922066788447146487993304134477988625345942386711833780639553271598395688961584 +1195610154724201767373227499183087873970044260009821201260837039944092568903479517438262374212926002997007192595185854104973828 +1619364472726153539242937799692428699593667255284692675884347709702639988899768923848970457805127213116307471608615036594270036 +9983245059851562634241554611084024908123182475839572134087792577459483664336562817481606414919540980247553055009390347181343478 +6678203813070191242843917525205623295811411258351922528980269188922471356248950351834938277372740881478275242174992792567496074 +4143356634732380642139347869145766266914672583108623737574556686979737703412637109328384991661662700191639112734811399558605096 +1208518184191671627470570937029456222980556566946874634805220009038965108642318793927711482497435062563764442708954406150308502 +9023312095876743701169506435873830799968604505754154998579861924311377960500475654542205202570979796896262463835446621504771900 +1307938351217139321342488304983730107947723886674861520928741265078308049241789485663045316829261201640722069914290181463616514 +3662774552959414495906707805907185396346911240417542898771207054497319717662592108767592192807181086654802759806348618578837674 +1314737004679848142363776160351558775692327407524329957179113590512266999745499877585915362625510835561292623778541138597816039 +0237557760056059081432345998516737302912533244471786164779569231630397999149258259824248258872090314272651220971111732309368883 +6627477978424025488072609778273019056422203214910145966781125727030515618065001832071393756745595983343475497495207623260839724 +3342966216908293442342817978848639488604191273604917723840719378411000753792919755939336669416561658839344042868764649850515740 +4843734023345647692176295441180249482639581287413972097837107583698158034620661397371501344888180961705583629809207419852455696 +4443380077789857586353070023335893700728665808003439355680624696628418230215872552816714310195766329481088338871468994321119252 +9699439754749964974015300163681954912050318298048480045612220669380962262620582805353459791375378214164628533298845978013550599 +5105714350835688155081910384711576767489399113130569825483778697383765314872304014753426304269107388256780976698871683305123430 +7876749639965180153007689268468639912304158853044482532644498399416286758021429281245070574658924487014301816203665832428101533 +0785808281226435244861112112960701400035860271883263300268756398080488577467688265527817734331234380039587960227981962626600939 +3364281430281513574894870100381156896475296131097244720576919647275082387947394192830802845871083057512101147458345259973497437 +2352548478260815071941762637203003924467368412816659772061510861905396984310747338352315940227937768901334141297190271981978620 +7421497155149250772882271160825127041610751435166048440557936723442915599683580765855387190581730147042311189334715395286473607 +9469405090355283185848987802133089556363626275612421572132540664555746805117424373802421917096772214790891162942671883468819382 +1589417274385691408452755936967864047060787328586473526198572660582234669906554955441129992972950187613542002387015080229290084 +6570356377915672505761938151404215475617807815543585573009407518371861507851745477702147309937407690084987324419699405440825645 +0612011361559116532371585728822626979903698606786712794256913394582020905043090461211508518273342883931278463866340432838401156 +6760882395086214518227285005993629709889190889508417455761844997600135276044719721514847763212602718036483323892756763864051034 +9188515996754462022639889466629680669832215175040501200558563344456278764716592388326318156786971890684957626542747491478209927 +8987779229113917038185012511339563267826387201889188999106457112243660191988731669456871109523244231764354533555547239773405699 +6489667993193399907320056380302219372587627376810666191791189051092938301013845696380002825207303265588504074647639636023424359 +5972299897263342080767319345606033144822159869746010125714876643532020183420706758750193523599953077555495726481141414611132824 +5084488926501974380578938135730935789462111699625550813110845128956753975680460172778115855586076226024263960948204752675321380 +2481196609759725214010722486828189087368975741750919937794099496934509151874334791821893377695611203497436421390537165843568949 +5731231776297026471145248406339411301301972034255825750883890535679456779763247607668575953175369910078981695492172415999716775 +4579188403021146726016160128342968838235818738719371073259844121400672340573224465598262036627730489472180977859344538916635018 +4072803135751982897056486221080699066662076832459383392956264311706786163956015331215770418998634239350534320417157397046765970 +1201062381226118587752910736476250954770728984407318744902312031409265281863798225473350200683876473994417794886956931818743554 +4970302735301544243501924330552682090042743013078749961722848840311456198559231934700094783625178641374367971636230883796585194 +7528520099930871600504738859526542685454459947737830229008160696355714649737859829804718726706633142812661022345510571151124118 +8421496990755255433515708880870288195255467739826209142506221198099596830401844825962275951060431553735295340571732198670724017 +8936767354220444343191661460546264683941090169583805460925893859976635128662736335459378982086771782291262296836018682528094985 +2091822408378038044344571653062122443897076701230437493508375904957950547708046448886825832044918141237713293307448531246301325 +3809577056439308352524023850120731400555497421961772257434416551729487887916281181723448155709611102047050048200739035199609339 +3691135325949817192195090067443211343266627775946016712851865749742799362777412328641698096396095788341581675313236780103509391 +7728571205866997785438131913054881617576104163904406501238204339704104937888486853321561284077020503299289883355914615218277880 +1111888880906892863133264981628224969781528602979570581183128605546822078255116005933260161155631478832277334536041066268750461 +0079412603436706091984459336642210703864450821510237108480924013766858888811236465849216492858539373276328300134023520401083981 +9032711135936968864615808603415924938529404508326233015998723558019026312135753805702013665081865026922455487474085399902382380 +1925270181168851392094205156290625337733809503843149282248914199479920984244708969137863994130437975788618973591803506088013062 +5670224338144189138135191184201868809626683864671529567267492650290228767102161777058656146469480714765930525720049680179040530 +7230690280352425636146176530879993888167423730080287061127174186402752375468464868170738182852209838339454679149339529988407952 +5792512066685362806154726245973930382853685512688261188341000372263049656702777229779863118583825044769296407053427341340382043 +9064288699746230367766305172967912478546347888349770026780079432939827599619309710342120385387650986045115258506762134679333064 +0440596074705090759141142692292577561658123037036520266673482910698027486128518652316613594364723726387332531338654819095216165 +6586405699035556181676379611570196812319147084489164717015394853295535428378692362698265567241807453037131148384149957093387466 +9613627657031243653069021006489437859522461371334813124213550061172753326963975967858093098270917873153645156857962187738174651 +1136920419639517807349446907609250529925657860858085930986434051082566457439789550530915328824048952555143480521491002977432620 +9723285190605612751574356382595987410097040493290287438645066768564593720132821343589116869402530302205558307160327389977244390 +9364492329019171456987187525681281472110463501074399197748223709921114091308897093844593961700969890959904837552334397994454560 +3052838056301761186571362672662664380662089189821373489289767638693120179754848616628936578638481820222476538767896516701765186 +5650968841999476243265351662185220984505585094177664675790716289996388896832182868460012463094065416068468660526498381293391126 +9133890615055659775962704691788335028541094043193982847019337250184246131745395473435608325229593796115617156815138186553076713 +2129458246410892733861841029801352092648607760367150219892460311630359921628868730343711772190656001417014669173768985351029224 +1665772830534776231474157241609092342166046079774561656411248463883336203142778691223352454530469529359343352214726777533890124 +8331713345182730719576279806483123633260411891324365421657390996528436543606816818186451009421810586108827795803801756029033502 +1364037207944391495829014284717167206349222584053304291053816472070825719135329033244226893785498596526306122826589748158594087 +5166290726387661882217520391175991236803942524737711932725364262567914513184343152964650814367428507369519194246642124353850820 +0827084375654733169383428093676562471650179031999648254047083978351359301318312364388282400723012984805620892215650029052432539 +3941456090006715583530315193770635520541951076921761324088412023106545476103418543330517872032796586561611105128147089091776975 +1738857734263197422168561159954861725900337109733462635773133902960240600973009046170223803445433108730659547191448827977753217 +2930699447354813297267803165810088809944869393780407968089194813574507757841359950100327174854511476594508709317805723583889020 +7143123510044372032973820765560757174132206252079849711539375893206623268969901549499791778646394614259993009419795504303081399 +1805751816651443729216778302694093259724338799262345264750249439983832664270852123252647682716640466581767974713902148881103321 +8726470726559295990593930464431140413396151555993515614244807290113117258035592083195115356107951148992883803789239385817695980 +3921614672869622892796645795274584202330027636891305986908354816884938844639467554178364479042973665199423978535726526806853994 +1879696934764137925030122852767473404168885624623810742903886724883175975872670995314600387454933128918537822599476294544895031 +6035100939350635436051361083289099777664034736094529995818610825799950536521416106176327389907566363175789821848187634785837579 +9000534727303607788183270598866205796784604375642000912263136681354291802540390456321071569535579301082240092546052754082125140 +1036718094258942656960699558474884940333329012199962569808690163604756147670835128428656230386743308384472157735698077816035891 +6071364091704432824311172611510490775020204802190669441798310247002139209451209194509056421614671635249279135552841468497623698 +4388935023201010068076632458613446034376062184128689428896319432854524321580911853120662708261911385263651607882193115809188251 +7169742597495615052582018265793684790742777650121858370707225197495242787747124696863007018741360971574027831332907655096436810 +0422401456149077117264566129183248282220685815602963735110673297177754943137791219212563311879171990788150209340116758159767140 +2965862835354985730344339045722772376955873793360410786309094363480176270871774839639924049136780870709007238189898961666868275 +2861817902533679195525000340605947416733205573982037034681250485524002724047643727596821058644083422061496633576063860945664624 +2693808963859011255454082437160794171986401169181404558686995397058453911479501396355062702756373669284391335723793677898504528 +7653550559325583799147678302921854984957213549656349312970370601725315750255349048113259251600824306253788257181726835044331139 +2669198588461532129599972595504488308041821964826043635029559596161652526633086414778498340817442875389328897830361220046753460 +2464008866849845585427596306460289186014718930150794200485697147420894155928351507966633760981788686260275637265508592186109230 +8485080800308772606343366155948976547130610312843499421865489766584635822710314441085925235277117540126323440360094147819765072 +3284154124684872982729898726330863362356401302174583854830959819131037571458234265917476543549149369136036055331113709805046443 +6448518117737425864310082406263081225358862769781154236900286043306718901307704827192440877547054996291784365092391305036785917 +6937932081779624691771675203207782587255392167526245881985222450132700822827458180664476166098376639952639111122762216172733126 +4351428226863320079499951081487882664115198758192473811033557945313783704183329712942802900894464150489698398293843181571708391 +4008673285830233165375165239225902635382169451174378889470574573298752951780171507430341658864697744996790183195739971709305547 +3512291497844318467447674406573948587271898370849211096489030445902905335005315909627516994616160913716819045790842998532630215 +5522629798725110629827671497041697233370597035945650285606531591280806838835367751631589755667302233305861288279338186531242009 +4038072792258238775154639697267095650759428219766235775721809805667537846787229698544718121429627243715285966487077144477541907 +5934583620628679989854657650575271470278836721346368661646073065566282621355114101575479793022577251192819889432201758294108462 +4480564984351469882094948004921988867959440174254223793056014056869119031094103106976186436427858310194322489736576393894678612 +6908132113303990201784965196474475898344897609537622286517498106001289334026874927830753197509682053509801560482547631691338408 +9319954675495203754314132567507992211027517777636008035159464490278748417535817989110579370702464528694578198640300697978306801 +4761479515872183180982458008106034482409223233605055754850233921649363735633967021409784641062684672780275455212963103609820201 +2564622328254102204752883685136476152747302286902963024211546476863845751873654900973840371931652957066788857238841473470464835 +0397866053032166080589875219701391296400993039583315649582052801128849941725263617220137826074241870851980225112051857130648469 +8173011294494728142605327204039773210726054522101869637370867240485919811250566145341338527471719086407653593120324797075262800 +9276563059829040598662749592867289249306923572562392127787551507493862417784430100714677869547866344355462003505196714057035937 +3281114518664069193538073304543737277406653201799960331850340753228936196208065150992985287938425817855366760648223669372651097 +2101840795886669078503855800666686104431608113029414404488344962534581805317909553125776693807861855300451192405993773968098583 +6961316934095858314386858284332606626453618369372169846037717301254036577518610498824984225850477019844523165578520651885370736 +5674574044356298030636615794164061879134353864364329335297710010416084563498871752753647964277918366926080825456181880254954413 +1539836063070409136278143569348758593204080100329208721008698517483741296128676983168524689365145284941105915339931290444395066 +5870435438526474510831874542069716476806976094126759545431524918894521691790318139213265279009865120135936482961615836310836321 +2764563926650270576320235999861005882574146665848294584476765322933617549606955812826398821817999980232276039438569048353472002 +4681622264311366983045853037646736891614380849223091345272419576321258005567715693518336948951455962926248349277346106557405718 +8956877856487148384136234859130353374642270367915456930125213227196134161996004529594088595345226945903651779962975528996861250 +8929969605933523152819203271238663371252277051363612117118809528465712440154903065164514629518743371367297353604095710696093004 +7157581534746462952501632250334837099070591121491848742704449306300549604064489388204805910975177833999231196480535164260229721 +0485019965651431731437912577838502867419408108382589212055345268265256532718527981331506279373063176342764821347791812231845829 +7209745175723014456091749043194092299024100594164185069424964912279120968460389124726898963864775282217153874785467678332297469 +6065725443439620053836394925815928161931638271242410865193688681337289422879252019985383178533022928491349413174307090957339832 +4700128875271375466912640968373319232662860319940601106545249660353269122104137983304514576260940899048020820371598690778056227 +7730285573414592054013879878236163258148114953801223831916249666510471398921760574945529246282567489263612670937049902168944246 +9130285817898813367964618316152272977147568779205131506356566544347370722993791917334237866531951886887339933938523558239665651 +6324176517408834364349803908520408107012550850560156082064698531696664057881361151779666150135225685603149038329558618588277296 +8952307375129199935262885586527056730554419885668513403462367686079193825971303716999017662160537275706617381132201851911575059 +9097939471326158030329763386527360778246814576714519406324120582675890884898234797792200042538307916074737348191079713801271431 +3543558395840050080153435933135880595590305720081325097084551423268599148459068228435603649060705649929053840511309887473304515 +9764838954490408335606543556024437767253488401288444187782685927977837265995938637882104106333802927203512151240662538609957779 +2886694819124240943375973107339251767858923004989669776842476259662336587537006376705925903350515688363082070599436191295014286 +4373652465925317661858189411340138062597385913063993168012584788091469995881494867908911062927314918797351706279530078724029778 +2064997451678388426343449295809472909654204980492286328038224332702407992526584281413262450071832225709127884717383554674100721 +7539736814358108443787011442956856478411159063433502735600777534624427911961386455371172130290891500709946519469882478498227746 +6726050228227536316385485897543745820479149980410361188284581130022635250330849613983713225572081803265842903422696226592604564 +7194667876267325769087238008916325523655281922437602110657822708321617107090571364990182422106391457560890252879023326941272951 +8084067244599983014933199534424787256031530896533024441147175887371345390886210891424383817784357384520863399170708018540336261 +6756491974545573085147283999623619067108143004190487704098038956692693217789059190015343978239812814528286370354978428552071154 +7449780712548692282752907313327411787266027754878897309843460775599392567392973717717866266635813723308899529146352109375925165 +4589899290541494280337702591008141258629373350544520604291218705671399173981123075630121451176103241759370092474254377359262199 +6674505740657078583031897307527013973936077370107324719073133704686647880878285508608449940595668407790459295575945823755660650 +4398342537751131171214988271811959189579782716426212830903406974442463464257365397952526980356187741927953055943122410685033921 +0094907389935032343867848721405008172219352354700721989014087040463745373039712419507660947640188922848825854691917677041514246 +1508958586684510982818262867790308592204381251380001158886369026776930843982561684403451614590888186936500388011892045824866501 +5793657116945434882250299286723935630635472763043771513002492162136250578168782159984593375232995341440779322489270838200480406 +1528263927376996749090311110890532617677357745138138771708962614857985706783193215918275341078100860497124422089882672715412665 +8047862045380193284671628316345513578527766132655289631199372572297400350940186548315099505461109159626804827405877434015762079 +4497649985437114106619275583585240709212568170308750996103273375973255643809512987167799126855604592582070720993954457629607433 +4115202807426887388976298359856110123402007311986746450130132490988863002251413157990023529650615874660044346489668889392287152 +6927862701563682169262409452072639909156413247108366389659864970583248090206725794860315733927719571533833830245401473668394282 +6642155549542044431836970672852504846515539364245490047433571110732970388069323446548403285359639096781185191635964711812010789 +3758505500262572544806847683378518452890545811878275350915244958015902281380798955282380990829046266914505428380626717794710699 +8543173740869008063671194651581188030729498726094049008714991031352383511909957936902571701241692397622133551499445586152966454 +8558201709766887626106558682087493174247508346751479027758498057382070135663052096489680200478789301589881335174285636803583368 +4021046412548985259286576563116974009718144433360698911802741759233868394233863822972297994024437477811572624976113883122932672 +5381918891212001167216621281602456221735226414991801854696667000136111863626404844152191631832767778925457352443210000412625595 +5545489652781686362831418324972755141214447870296324256972282335912548489681306938005662008761939913552064594595349128397481698 +1089524707879456280414931183450523776892076608328015438392554074880142678157014194242067164456688702421957600153913700978618426 +8305117650117364060258714900356625435051024551440455926273115470939757929013176898347131589373525848240533670222323888613399302 +8471548092796793462446437655496090111004563242834114582368336961549825665258690557364306703617109594457055331363141186121145408 +2838670852038846380823335210551520468349670239701607224866707358833084563155287946007354912983177147283657585469121005219622389 +5789402261399916318681167359698620197070246205566424633235135391148334480479925501535906551354569207810065959398048065712057919 +7261986944279592176600370192037825062903228830667505762121478097517284917101606104242575975523312739096999493662697366954853560 +9155879998783130488358931786153797296783212124287955652349632245457365996542148509944356865191456587886152913113892875578626974 +9514039241881963923397516312505696923391431643577404694192615351139994947842245479233801981061807552927418310904314043203688694 +4614887134561403862531573523675942563015366589167507205886559178959551755768826801165790017789960028672209846259757000436195062 +6712756378314975481834508159845487505561014170818191973740730433116802799842074666829329785272494733308089058087919052323067808 +4343294134478763284253795500389053885558601278822120237277266312668433120502431917455874080753529426382802888951317455320771924 +2376278290758786366787499337556544479743289945243171688237218372051181305516529407353834157305915645651032848895215696121925178 +3277461207520288197080048258823569914990769314412444872094153856107817656040287107340131396038173497845042121242427193089822818 +0292406985223320173089591545488895576256166382750650552107291481212988120961054843360076945546651513119822979777064017606102333 +4155585975612603215642148373485509667928447809166188682093526614287990594479841858693261264552895318696996233565563963262273017 +3435051958110889869116245172555488932493678104217964596210912258968214519860568648927109250277169274770553939366194092044056400 +5580589234840522431968399852060022338678890148720329696753155804394492049184529967776995091977565256891476404577309506725891693 +7335500310521157522656023934693183042792687707804385279531540473816692277059506917018062802407212114266734977379325447178574076 +1771613660964024539818471437377426571013833744798577093945387086328616540439686380471290881092187502982926867793090143460960995 +2854310614938011180157233734163443946405910506035197343508210254223120818772340019254546366421372519708012585990732220553479817 +1257049653581939929259306981138171825335308854774522129783756061113569283775667916315356572397505175426434698580681752134340583 +0335808023777690523056395860773496290527877864032944037336174082899748170635967157534100283308552217210895819668943595660390141 +0793041940236886441234025927232106929006722186357450970274155143635586525537995503752589941375247670685666954666533793877981889 +5778831921482018016340449172209749049865029154730502990831586948434948616688177219302113345681124510479338999307531273610240254 +0006855309162866716967524960032543880915882390415328777432560766307982993890466192334347172872288555702927609941028091228916549 +7852480060739012387300892561223523799609034777867042713542472004721462831725545348869852796577495340595446292276187383478785958 +7959977096587753530877434044450370650017598273016702141156049535064683872702373865885204993323178473693440316927580843350832264 +5711255434828429627433858416873855046302807982520306738509536092504233877047237492422270856933123651986965389822895956478482440 +6861826464075028721520622101929991628946998804166738863536077306024363695385475918930843524639833318710346078946645157384213109 +3481268732060383732986016495680958177849607099558634081654518008026716403239770966732475944721762791451888118885285069414233963 +8027947110287197529845522807009685886470194904262452476975443162530080660974564750582146126181908103247560999247950332233807322 +7124796294345362297022824568300955114164662928041497399401450052218863148267186902693402640989732333727359655944286809966607247 +6673207022195790654496166749745020173181219341922393697843282922354805033819231485054350962234180921218558256719281039871046137 +9465616068877625982160091084356867655695114307535279252535857794074660077470905649500203254845487633889884403918357791957962609 +5439735864176545493786682348080515776951063552894497267405045766639566000474520462761676673185451169867195127044329565448901474 +4077128683528317505947720920671307017612997849640361880751590889728513950754717072470243203246494346250198972938371059265537757 +1744350487793132663117639969909905883135140378094636348689423577493817809958662291757247314354678873465246383300244542531431911 +4940086036767442787655065360411221974038277063722727918083568388107313711402640446340277014461054034344740215045925518041320283 +6681118829208967331321877862087707476476072276521025702668676229506021840555589912885589031283416146794110309804988142636941186 +2405582757418961820523544833021078187732693088350227346014916968640935524755515218365262141583526578487828351593275991676198367 +2826944841325179084380122395615301242526065149184196022148551459509194360014728846066978997793718470140240650758184827065285092 +2993193263125920746329597500608467852384071869621346018318097029329594882972558366328973665134862355812606060309541457130668022 +4276324020092753413044519728088179483413580580809338027992824022071273342649903541028827269643668077697566268171224024282173079 +3298668219738409681902878367215423318085688425654045440812819269643490157963034537370434474347979142141704582114328144364074548 +3331207723416487218945222041751113899922244456772815194220564328760009807415143846017951460454941724943113249362066483407691380 +6952116171208702291147492954583173797003314720166450613568401114973391179929136073418264108322111138297086137222772204563421106 +7600975435069311874768177860666996344740802287521757586619300995824931951698677022696322801985871429773970218124919477206966901 +3780912628061324155929062282119787356103921261553217430966183645130255649596951891774470507549609157651291460007364039518971745 +3378164561008341242097804088752883493567850412617992500593780122329644848355808639540910546811625908951376798420135130564695711 +1010690664052506424047390590878204998037797666671722315517689809912733797153349697357764209138638827429140983606619452818262145 +9300376547277559089699722018353829113301128665766029981150643108015654465357713345760938255089553063389045170395343438086345129 +5388574617722177598048137212627225252667251794017646238607267836072085293351506292982031628145496634572585511875570432312724337 +2949102931084425964911707872142235444671368657598878661624977383342922503912907622387561510392479663939836372865380891249214191 +4125450850629924708967370485579795410196136664949644795471576226816969360966521409006096786481214505471016659590219454123795063 +1052876846080196429866636468392224678653280363636952881423630013978399548705549755495939234226751546533383899311389616571394812 +4742555980388054447437326569075723750771475897619661025765632486508214470920970384046022812610698865095434736181621465694089157 +8053089116717921661140443537567547341019450706571788438437303262785839761518407332728972316994708287799676864196511854612689905 +9729609228443111962917503361177873795233721041675657438816948255161968110343038443890530223545306466481706693430767571885086143 +5688308264781028505036247702821583514666470671292172916350280224873269657299593653174145005772915708578064978186214186153683267 +2204744465132776025498386899741825318473763441099667987231878067919021578886769657107832299974638025812458213339029056421384587 +2941505567992035598339903647769230684834003209355669548196807243023989038563917277881744820709582631259852618961087166384306292 +8258024223124059927265905619693379087206675705618331236606891852566067360854244728445479329673501981619440816785961582356678690 +6012067901366243313604096658402361049393912691496270752442176761357212025454418262374116671287518874273805796136109140975751742 +1773101052368269774971707329316287503544657412042811119480548137588711677240886794469483314479010931714923252443537409707971115 +6673163431438354320152064250744844641052080216051967752388682876816416999627859168211126178210239748498710723469312339914116142 +5806996877521195102255361656866436538966669931939141317697197556942791721788110932577145668299881351690980272915197702021298156 +3837290410389303517128116353347856259353484969554892124616182205192313287433755106122400179494690010200326668121477882253979202 +4517266820218197081941589722796747209204288657893693887244618207431797169277035145695561271253339157663193312460041285285239201 +9619778362364427885644889878069243475033064627573715740274290928496163757241181156603865800841856421952950186816149922823346976 +2573799739461267334017539893388809186322465134575561495883735717608135099991766507451755547789018617434096932254961072365198882 +5105319049917763260343536285268328841500875349287045804710455434303605043562842410645690374572514107603618866501621709959657187 +7151556358315357415841531703618215410583915203575998268810030381640117079961254114904804786046065507943854733690644791284850608 +8204760879007736798651157366669090166543821998311590636584404376075249452086719646757979910467231964531015916233682304625227803 +7147573127581292166990486442215222962358403851938571275150035153036061725108691622876773795056511233146161151053768550862751540 +6784559304983902886590174698622574195988266824149602039534916660889368814614010342767085921580402597291566274193343471685906410 +7880113249001482900851888199979393787162065292926067710104923584703156779327643300580458887132435255065678627456912854660490039 +1350749751135031413626228320025567623412283741939627729115634082906593503710519533248918652855496972010878915554543211009367225 +0004322455171197190670578109680045148889288778920452116958832375230435697820421502377733900228528866659062527967209953101213734 +2911494504322931801753348544419729543749078880072226980969166346711819931480214331433779640233877327672317049984114641749562870 +2396528513460618041259531318301991286281693049268735199694175803321673323893916691134629842475605991446026813330356086230228330 +8981164060702124227875449453939249569083280933393885800497807219622718057632147355043854391102180378987437281964171835261740700 +4207084959173122310540889440071390175078165835125695056930143838697501277302913507401666310496334451392319525169760616015349520 +1210081234448921940981378280200458404260945592669718748037205896059223823726981351910671794263375996276697272684781727338912271 +0029168415827572351727213122061796310780992187543596747141643738703113178475108090159020344233281790182332311601803329178285993 +3777296404075934053174216751857062118469565443797038517380817156541529651488369770373411767683949249420334108704951789531604654 +0677478972172417855596910438873967997191564526032435944553932413671467038312980120163881839182106666575810117448701361229089668 +2906070251543291085920125260549397785656115356661440571177943054793731483489419102892567240649669779614310761600563474068066656 +8852394653036692892038076417261650066148179764783605637155006560905389777668215992491194523484007340075319390767759607804494192 +5467138831557823428775541689197797741887498255851810682591799669249141593216801183262480761866825456541084229589715596536290776 +7751352765591319462216158866914539056239902442050723154683435064019845231969816008347645334022334350198037412040594819924724593 +3021915992015948439763471750840891829476672656242373621059864369709314486194930162083489346397306741461969474457136306652660884 +3810149798323432950565012468358334053474435740399651150333513841619654716521117976746459459286758520929133377210685994781661011 +4783431510440557379639204082385220913253340902177656244399207972984745234341006126872839573292250089207868222847639289722379753 +7370438575710728204326451494061012215276912157251877502908542289047363288154325283991522374002173371912625950441590135539908011 +3066350412780717315157416276543477507139338679594873856557881443518665559120844101586947952288770461228629756299270909156776058 +0225437513080408599402290104732039265518603222598728765215485627157659513804399230415740373980117223389491501554877516067224969 +6906447098674865317783282853291741419024882827886344308680586123738306172623618313185104401579759220967002703474556768483264969 +7905688354362418737693115373990150326675244455866285863285017259126406290824772728738190085605025791061658351412473817132182003 +0647939692176384124068167344966453433916156302209336971942526032217331539621915101096729732974008611758025821638418841239335586 +8207612011209373495228760846993905535758093646702045474203894639020884032055233069612162464709714659219943117947340234145019206 +6685510574753704984128082407027684573335104766797904438216667655851315902097650094638260466258758906563426639941626773728838182 +2859725751851113943873234212381842264933438665075493160334098268584252964692288511136721035397358821669241681360772178239556283 +5410817225831141636647896001039576920297438613631278187702231335198482845481821124632157811564428311298381077638390915142518664 +5603082383902365441423743060726658870177085955695406252400018823076710944733837738608757044351867174051742821082475300834328708 +8478410686281696423470828758415498795393164508886616098722313596122431017415306773664281061410625509783895380848928242909573156 +1195618788186485122683528679683670597289650244657656876407897279500115335276331331011520690820997358881740005917663903217514124 +1469313024861648921401247135353735958071127626605430535836717325791385228578496115248025350543355198105506645012545576867598396 +4272483837056013890177205566878534986867897273483516131338967706119399325076036529394304714161849476343886942682280685872295940 +6971223873405564611431588388181753597862284579604627783908270991876509853907693857394999066866716324481756490631331601939564088 +8692753456851589867469578350330459046916706027508903379244973723114291207510039578602992677933126396343784500936297228340222600 +3596764762533798756045077959160866048043299983905049607435425529900440769757414376919342785743646389458775443875643589233861301 +9939277922617044929198368291152778217422406940588205287822196961674791811253436361915620783243520085430696637802610907731339802 +9987990017965498772438500667174890865212624587022291536612477503056361052627799082687991851074848222861818981269823302761583997 +8147838382210431535807715103935094271794068054691587562868334683152631170314268604516246803968415953907592500669227061338962852 +5229815249263579089803694020966160885001383014770540554119854860763174611534378849807683267399405523325826175066050422465261245 +3718808810539902175097435162693814660278935973946526145133557384972950132995651178561319774914749271123710684959722970432994100 +9959643168956842935132972702456973644474462349184166563719137832114600377784944150813295076399096859538689536653676932352320454 +3562313742471254053603374767998733448940422800590796399248016870732131873285978468485675936836421845482343165519443520207502472 +6212070810123317420939860915076451492474105989853395883410582273920108061505858814970010182505273303507369510379631126623445635 +0255217936242316574157324758578917396184805700986741727460755136645033816635143639164644674079087020280816581372010788765004026 +8089847944137656769780273194285160566134507215012061013579883469551314461311271302478380193931275275686279445049118291696625976 +5717365181365376852569097535965171977412985242766246364289767242179344339616335652390309582781287529277190209039953388689399517 +7041440160561255381091312862643936475613988744385378977312543669992877553324112750381702041222192086102659343479767405018249915 +2110051683946677346707980171411807954606467103478530131043035978033107947826868347943468663705645386376022529329242653151632937 +3379574154524802337331393517730441276946707038997138141465007355281465799683250899916025487713716291942082244114027843952458642 +5030312724644064165890328712593254449923448331621966613833157539215136234997090424298061395610381815885285290455631522924868317 +4994969373293084869354149476773798201740005462072247291096910619119410509333790774262072570461057954016819195195682237016634823 +4014617100181465701775054953697719420102573860376968588430229723536957418028396409863878695628364581200214130204435051219695552 +9995923662150908682939564279380158287700441111607726222291472481672861788611478655050339588555615320984584521234687823576281254 +7451463346941792082220143976579354392136627715379752529027471716966012381538802459409604897867012386933986500209811720725405141 +5447700282385988297313347229401494009078606483625633850809103068410968238448493407439403040224936061985927544263475630989480459 +1276956495071860259959641422731621493130581830343261790000300846232499293476144299954615667025912420799180581171607386310558493 +5072567626180671481702538305209899197776259094898315797269647260887831166441294066368414302707370453117631015362578331461379694 +1152681127657219064376008724117880126055071670561685874051473152694654802783634954044854697360607744867225915714681210070391625 +4963921877303857727536312369203728666152509364270556408792999159107647346567121427484742607873371889230959069964077737186080579 +2539117036539210376394880318723799879677288248068497337514544989379323165067241670457629058952981263712005132132192204500173772 +6813760519782616773952896216661044250831393786872842763541388164566337619519250295645333112400558661044316307967715017816016933 +2537593940009216399181185307950727066601997003943463162691283637037387944868769661465346762713541328987499170590124382561225808 +2775885197315288545943935069058879566010060299863101752754477420864624440405321494564586899592105748495227288314078895511070581 +5073590254176183749859074321316849201765757369989203202482670238574028719679448337609628523768999643298161243528454637871645997 +4654524903507892912886995134469509913539767744116890388991007614902224668150391846827264198768560243067636303891131378158227338 +0324734826151939630626306117202466456571054839140771329647402994885021118469683547773949974151585727386291916309232652285623776 +1825578079957905035730446040937650014976367810409736691475746813209385827351129150863065044732028040265416217520597270250595073 +3855654215693196726130528392601924163490164258356468808028166928343554047073423362885338439044483545871577569335583661986547054 +7793570955613127244841652451443245937038624291178210631123294830620894480548406463322651814043971289378075631025886964612359732 +2535751039273171851827163526482017707846468207349048105786558968816006070754676314714316763865097547820424829616783998998577881 +2844480806501005182020568712353744447818200854387376634450572497810731969576672980314852204195217762355809650187750497828976590 +0779679209849300532787708183193857610170295918273464149221680774855800423860839661690361920242424552243626034568783063475060030 +0715723560396890811677256708000602036818903166537471742271498254161510038321801193648871563911124555662395779532361864351019488 +0796637275901473841659277764647010680246421160415288649143217531307967149087210418850695712273237810379507829287822942082290828 +2503374558287484037225872566037347531382781922322502069198289211129714070730191986360007963273941619249637438751324038507743444 +1257552500220289953409007738059857241268432142060119245938800646680659562080913958426385782354999183544917531229451796428251407 +0627725746927523912542272514587614535547975158991752064909670083277315643027595358743280831654266470167938798514468394097718636 +8318980485800264189777412075113224818829974167411737699158537404003402647667510002613635249834073904159437111364326870286724933 +8736390761693005617348059895960699070609999931133577397987040270060440645814471436005094800905267014783073740415604380803498206 +5542024002024944354928529036523594800851472969896531771028010643441490945234844042008320398276632902810470392426566175025658836 +7031032484519885828134561441713514585691824451116624144085217816423547864679125010423917860268671111391465300826171047260397179 +8220783551779338773320989765886440391559510492663544076020535514257589749352990988564034320388602959557187208585104844145026439 +8020438087951116022977373383495534674635129594766601601387483705748972280627013851396530590121458524210171753315286548207527820 +8153810125605918943918826453140421737748512940456044065444292520385926730447939082216173702077609971171912049413332448203544586 +0886669881112435179401237673978622874656264303143999122578352317897806033193993865036799045024203333380525337357889563568831448 +3748676570310585965679075167577833926365276411040601559021494474638574451420952356408036362315997810486031449429712897242856220 +0680179178809075888645900355703866665848623566100723748395628721560414660071214664781095082893581316152736759533950009932003975 +0830073511229116156443164078334884149650348116571315260656550335371524295132896582152314795929439939447827419494358066689706173 +3038785789686019127115381229380791436051546935860047229508729818282744657378118473627065099573727853891404083449592265655152693 +7387679714798835215773140865910355708661822160467627107526217765214393654304740207983760504979185513943991488603347106187504836 +4959345618457216694880885929572868404119594959297665383045694122211724921300914575522725438253647266552305439505601459584619177 +0467037747326795908961510775114924268777468775918327644966642534544042676564308146590029193764372898938024544197186375500357840 +8285890907673262212647988009259010379723054727978121814340184295658072413264615156697842474728575585169324914900743103535246719 +8911662589073033021628854642652750279152366994152376376433694906661951714454207190114956328995857009825646477784015810868978338 +6105850627169563438884040914539421660727931317710596144077279839188308966168911142486835009941100149861369756674171355191560490 +2993431983320455272922883788672722733898158280538086533775288120030297726075605253307507669239723828996651212708874872223213527 +2383871203918607138972250186349539349163142546547549565946027359258489597478748862408648058675393278207850385093331126182621573 +9149363763947487276724850656041160743708661373179229186384365572255499194358074217364047819850970764281787263423869876082053909 +5827019270739581666492975342346328261479975112685223225619643483040396563898673337995672909483700478627244101352870984979237732 +6998285824391825859392150613924432428270654497491969804735086552708299672203935039153979762171440238901122660133544046138761976 +9253330844439113156612382643124565174653829532487393981769888635312756386927331059248556801164857640315799609889660186200071275 +5612390497528583434894505132668347409216226770741805847223173711771542665456899372500390460954330204857624315915587829701045748 +3597132578062559495102590042788395347495253649400865738509995118091093608521019322954235222572297567318636643867386469580449507 +8425515407736939284693677162137557410259923224830338231554842919234034510500493129925331580967001474100531060588153614511993338 +9601991297057389436503665001505251866564553593237174176487901010113004032749058341666775216970685449376017846133214652240838962 +1863773381844384208184694104858797647539515137932214592371546918752008772143433088976967184397882651789039128762093118018510138 +8436667156247339295567342218063358078249911156583296510351786615409192064411950727914656163850098232887122260394676405120111886 +7683313388786537579802951656666063632278774842670516448032010207156251926218292168775800210222391153956472045994503212219850049 +8209641417161775663979384085179876713787424866821458112247475298894421880117371699371735285979992519666751909878379569083863705 +5145614759445599831570000861590726100099887859826097034388914355367729544959518374514940678332048394297378845981970826760413852 +8761767120217732947982706113384060618324856798940745761981931692821487049372786616858603289668185012412091827806837321112104047 +9255297129664160944098264261547065105677964568103165093339743646349513755899758152316922927563473869566225326724560456097296052 +8120768832977744822631836021474402079390526097477803448973026451821196612519143995594879311933463926655409414749552006489267940 +7017154772060236322937445448043347707331947096778317016923510498198624836901896034874919545286197554142622789268469355512048260 +4180409321511968885143370514200618650235742405287713769661977834572569077057120974054874981770237845015640851329981775003008191 +2674007147813616401003929214576628097932821870524475792725335810151140502429235053500438517449175945097953478389066531072308154 +2478433215760250770512406042154394331540911914042172939884164584979797404189940441889258451913067147217070836370940898306980314 +1416691061574950251933857581530784660502363969157027453652188159283670553356947339926944472421121743170291855577403109297001923 +9846364489252978228078702013876774947354134510165101268064021721322665802683013959144338916544348159574015107727356473797086745 +5487580365242793847184389294498037980764980441864399341257536426029899353090372478661527651346349015000812904186890490170512422 +0317001187750772629199900746610544979042670580491329322209673449299816557793150957519344382208574308527216206006597313873698350 +3641287214039996737900834675182665853779449596351604582635503134884649233644728626688852457677654231608768591360986911023898427 +6414868015450446904060895609231719309486232701910101120865147273052264604064433289410480856555673255517305129013544577242362891 +0524147637426415811762515415524550268148125432394280267631328443360400295790051752698236429135771292548014257090019134991791562 +9227410989021340348714125220582535723860559138846179511512191891037914244234245126229571603923532773311387103298341477228375501 +4041581080402587294355936437638145699274625343476210354812865278292813236740766242635378473283614144250925302804707242340663339 +0724867859827673965725683173043844289022888248735884487800477685080844896245015920731492673699852061747889861151283779392092379 +5909276888786182094219448158615991460321912732697015860009933234510620643391119454097956755043612428806923128306819132701862789 +5863973408297121204616907602368353757254965361693796331036727921299882051062544545347637276552415740930878434572627384251645258 +2609867181490019825132280383807303218611438271972259358234476006167125808789720811193408861105326321587061359193074883011503250 +2053550365140441314774770422273440770268402358845803831349391590570354084402287239858709867448417600167758148787965827714400727 +7156914133575985423380170082307013620095209686338890246264669241382877333719091759478776099336392938215841439510174135934515390 +4831194527648288858829733221197151800308714018772578642206404911045931696147282373784233544435117870290316107286565703640910861 +3300965303400428799995252612196866095687126018105212822125411581947708785019993474053195560005697252054488325120896486904066095 +5685043938431323336868482886553258817526871549549389321696880672458619872963868160503420041705844727261813948644337640127844475 +8437858633093280150489850618743229089133908480393577494682517449743840953324665700848231841040716763791338769325607594504384201 +5092632498177396936492730922026153200701191354311511401621705191001018224605697557158822145660532720002740219521243300566753090 +0884695364629948365817606370132571392316227842180869160712531089788912972870842630687441550199592940590099216041036498458331435 +7030125885795773170445439886698551870214797580800884149092936799091801845209138388276070168782087225547258102113578759536143915 +8807215865608701057987377248776702944861046260230342503936276411275965656745488818885694005475308409675094846381271540973613956 +6869008153507650455021791206721217199858946589909935757514740552973399919912521587008600090842850454930346920106313925959869436 +8747302342382237757458390343882591560184411401946674013753631245032512422678856746902092711874356365404625893572768808561925896 +1816616401614372016489584185015076832989812362352963164309054653174766477426767816672229374164734973950570074316503361323429424 +1677262729710288413972124464110274430459973064690910792449284824422312855723898793069294265613363135307936039462077553033385323 +0904814204574628728334178723557725337676246503641550973591704771295724843533583760990530372617065538876854581885105724368370399 +5318034405787225786821497050581659615205871549939335953839157390829611482749151979571742480565357809673956661177238715716708421 +5050974915162203984880371984109598616980412684284404767484126024659745317958728060034806278671739980663056141392010690752871879 +3910704359349884254016812391071406772666793577154924194799659346664635964157482006918898999240501149700799097400684650477119203 +0922138102426301243886965897610590765176893150415296968278489084200960754236095696787157337789651225430707548067049568646321905 +9034532106902339573322445743023271918597056331210862099117907113669633072759130199009133076195985791779283506809079562559701881 +8961339360352958868430789580169262538709387737102199957461921100064868143051486287683576990974108237901843716454745741895109283 +3895519300319620380905559168583475674843131617139726705719237185238119833221024548683898215318859806049104445070815116282206901 +3205107673082159654286800880087962054713784047147807335322961266542952563116519811400145837980005316237797804651103815235446781 +4645211086556795731679627686638624553276782440503123281227932461374131645478394881186841410205689089468850242938656791425398127 +8527652116361873059872046061450470630778597394637649835734537239971727675715042761592888819669786191505268650105293343814467234 +4729851960520632361339165114787166123924351946142914574237488059076517558856540707604936767815825051810582920267228276662907034 +4922524498676764577221603274496474839043188887553906964245432382389882944444308052516105844797654740378920402689234115734188908 +5209597697295900954976185802188459574638626316316754990028635919463918798002460967253179124238772322245122243876066379489508079 +4508289933039159505453489164861720999217265104842659882479905333119333431390108947303039851217725991104705191344280222412086293 +8069168568134508776661939124641765187854999589971548041638843098203486147656735371454412494419404765242018465434846607552127178 +2927086453284193065980223266739988186690361081906781869605569767794118257589865157784413584255650425147523732344110338440580815 +1748049647890769557692421227727549481557775151410048868814718985045151061237011017099100528551045245586497019590105694556854099 +5925541326979395577276086387515399363166724218914221343444459910602377753889752768375789640169881596578910501727353216027189265 +0670300499827706283025120061244353545380543254798985391943205942681540582832008582661334249048815794102101737939011541318568554 +1807401946172440506670841188965007674553832019157741404977051650612570825055419487071388288683499429125090172081236081328128795 +1574208400432062514192736694804153587958619698259830513687209529110862276181211516095950235354568516040903749851761677661305637 +4121149896620030430814848794433445919918770329319490730619096312332656236065824412598168467443676868836685315118978623516376785 +7498488621509709129976594981432727530944618723741457356588286547102533914121132990321805599546945869002131411100756554367181741 +2582026542886480869734858959495104201677107827620049653093381222272376273695750172303884972292405628020932588645381010082785621 +4289447606077369793749546092089501817143072386741950941157247080345113014329756464038358626070033871947884567651488044623905631 +2542825564877135509885226287724296817068865459213301536696178082552402072123707396192496897302967815948042943248544343979991813 +2226470997115317096784601264496380718265218871198752715837658374418501244345114451866417686910079224568758319235433015428196960 +8662720543840647608329817530425275416788291903848716280076563958924728751343578053506896388100895823567897044421928057610378475 +4719351914296817015503837199703117466548446025449281302558021903566930798786374684451211437854302542934198900108681526080958767 +3447640954611982803365820977016952430036387460526610055495899354375691830575753318086903113772624764685535267168082007345740305 +1797213012073375178436558221355605782112077809669165249433528557235690262339894762165301931035587761808175461223039297448962130 +6950060736132243209446984212914140861957832417030579738364918001660026811196800334571314378298274260059705895036596817108824926 +9243829747951735931284002210476722019445511064984030772651417194277223668272106134988724834976681779756839767862454568373306618 +4177035873387789691442645602142232402697759139202124087044601161733861189197322918438352811683833924407803890384828993570282474 +4594126055178872656922618774167034354795564094725497124745719061896909861368756961278327080697512762579612758334700763137442983 +5295668887669717485226390123467973887358507953479829153694623729169375830523050788966597377361980793027344718171019365784257200 +9888285370457729318303943315282858750583399490083047557333008218529891417381026015175475841289968239416942724745429537867737999 +3215943066766119309004524839024701086312759322446215895076113158100056596170634794503064752363481133827922180405978563689758589 +5959944414411467463305736849422386192090664596675188756343645002538240622043092367067855848705606619349233737685916244645398642 +3415921462522850660711019463447810831161516098186857649733922254277645246597288489872824421913456035668900907466154510857353878 +0820770271351282269897729773480908180216209552917101530859717823023591831191252679348064887785178954716044181664367902784712050 +4837078657362119194233933526772924288995857318513107274934487922952892071107573280347076419494020490239809987105400407903583211 +4566520950673320089105623215464822027247924240083971798563728505499902175676964769999078225165976694000667473401833118202304025 +6860738161875565205941822290237567447513259073024464364524976929966835518792473395436546988594137222229184152759954076791794830 +3322947265984158060992158624663708425488918876383348951122905125836522038089874259881383269124957101134232722838965307585611944 +2514815461210894795746476799700740431234580399243562016925036790171527515771508119826976806830254109945111480181093741053447775 +5733504011133442490826886677777865571712956442700084777358932735387221216646199198889278425501261656719619101527490023033629983 +6816820665025994462583833453804933866931009904653183983658207938144775757074429801900721418490709180940459786270732207357575723 +8952696642268346283355069787962809893365964014926493914452473794524489554221368619837559042723108457610361497745820672215991860 +4686726618791630599619015305428791046600757619220375372642195506961581791667069381025833026424470965152344317512976704970780861 +7817535100493702359961847958187008692676255354707895369219620793484182638707169828174557995935583658475438688352992259510602626 +7874029548817067666626239631331985390475404826024086339339243583071276348104332609325698630718922399423989995185805657290031135 +2250809137006081215712604683009748641626154723738138936917095298080941105465629041740614734952469019573555032467949707456686827 +9015780860040863502309304151201467772727168204445161990634325579174702838004535428730659838209979201561616665321137059277802195 +7650185512550554196643188069669262493680280748343975919639135449289335914799374871448334387269516977974949025899212288538454112 +8893662379603774306702720358700430713868475310661351513479439829552220384722225613968805831874918699875259504799262267715048953 +6970047041565543406988313458814942522252185061892588920654751003945616453031191382091583403673677641380943374412110595010134653 +9871101512999920825593895837672777862350486799080847951285270490204712290524251977042420133385216867854292673426124017430550114 +4761750275074356557669956909154179090706612051478635506091941757942400068895124161242203046266249256221284982009220935209300242 +8708015446206142670623126732884105024418284851295914904738375122444129503796268180002105711502782904456582492253779456800326918 +0613210293625239057781585677639979950255289284707390038337154693725678298193172844000279478330485593483147704265272812526895779 +2716164189514060813320272610067774089300292554132648786501937337701166054949053895064937132503546260829302791728809439780621266 +7313188607076954454240146509025347232689443993903699487707438769611328865209183398377855897661913914996316621615825549781446347 +1784361684093575880030474001414660619024654155783784777347697077774197795864389624206377564266630250281594010870492871026068899 +1515638387019036333906018359538519902111800466842577317066502746814101599618916383605825219038858550204877062732542814333739145 +9220084992150752811004335287492444508585899566926596972214201784424729857471199982968054884285888711269768545472118962801716609 +3225729665605184922610258057387753797602084282592399424014307116412082926636660405157448703031528431483170813038850013412917589 +0896837209572767267939653527113544043129466184693048843785638628896239995824306624383959725609177449846462355536652421863726297 +6350549459745687058464464835566280558244152696093628407065101518502946110700562358545869437041517797874386126356678480069546762 +7437438880206605630925397821472561939196877744334362718590301519068712375301433711985727209285202108430567240861306104506294438 +3997013218626793371442945794751768102167128014691257491799130532817890787884088430906840628465718832537193051422942089432586522 +5767261809159521411906210527732505137517003452232973525892796163942363843586179566469412536807588910846358095073973053136806664 +3610420406657475104037145580225980872688624964111041381549594329404718245302720059446156211318636072750134363504069278172819616 +6203445793416289171078116228949526537345367573758934511473904862922585007326728074024526181186924979509692268351022430367531902 +6396903617968213357545062076755915835538061764765669442173658896006627193712410945197598872950553456423579139305216599382954077 +0380250815827704962815549731957552434336266476872009617222288199268494650352751383734703683895685962764217150385921949138345511 +8687569627504118278687806727964146837523838460065586633962532325989849682060922414609471208083225295893531164710651416235932804 +7419608622045901350837303269139752477969857182975189849619797931283834755645259685017775129366698872709262322484867769237487261 +2446574648357299934768068561355356119075191099390351323266829442188920299959413380468532819783426950868690325166385302101461953 +4690378580819708064900475904899019106498140395743178471011674929320871266333196561704778715716963538368801024314408279647276339 +2089232113041890885410086998151297290297216269518414003124742833718798363559663862672468722436254498875698485622178498338429914 +6550115139019878137719854465346267455296956376622672210869101826618943385242099068657285404811000189142469975735597865828978322 +5550336328979484745931555695487878550858216320770924583332798110114879836414978841309407295358874518788123614542792919395667790 +0067101966073227418786203809533671075851186310058420930636457857938955159488144881158165188969895896949949174391923269110027161 +8258211496051765933329722240348370716824091139227581167499651455166693356343053246387421021603939871942981451611393932490380081 +1143232998448167618984488431281685110452032295577636699995232387576558530063365443650214541186195345336376561664260667081107636 +9153874053518331378425571758003432585952239206770799268110257888073536748287123822972824857968518689632999374391956653833541643 +5746454771428065810576182766708428737462219904665952012954717596322305804801076045993811560187169208752861306869132853087960769 +9312948167988600676884786283729313554222793557251794907465964089218336400060941052967060271657136677975942167674352571570304004 +6999898093303477247632176216594681728525645905467929567402604064471637964034911185817952376210008390273053006469300379255866531 +1000632388106711156678341302292429215991586500122697419661097904387224375829260375948304920442750157857268831027577641937349960 +0561600453741069995026478401094735925203677529242298315347820295756013844421038599646676315356655360880496025651231310731701615 +2967967299264819933654047107088552569694325550743639578846283279457367587777819171468331383302126179626852498959303153806267304 +0993137404276474214149260182488025202243237418254946278036864473980040065830274036040054866953015031416924556900973301250401325 +0611401987313671825312920644599670850377089684826838922442681491359233283306670402386279700142617583474055662080523345059224691 +5939710996631567268204735821745742750433473750474145824948890280584535509141301239485088599010310179272128880118496394992466934 +3357460688499765569727929892732936606129832020628130664357730146150594561279515636082352905831482949527411745350155774277195108 +7138561333287682465057643618887421608272303910896561253448290571853039520359195699641420904384787139962581486218527455895010235 +5098065276517497532201660511210544476729427289544804994012760004734407796257346283172974549503877915741488118551582294732680387 +9918245303994525211620190522775746453648980603544567886385199869862202445674868474533709002221515555801308081350907650459178667 +8721390287975913893819238889792260446828081274233551710328471981963516819510944667867602212793558775770710289206007250029862895 +1280952122455041043530594319244152931145497436315530258653194357643115496210565410757613267156777417895715618326341142914815577 +7155758483619829149138641241642134167637824757268284393191488835351550697663275036059641871170325362834558782380774852273848821 +9812670602301209189800121141901793479005817704022886493550881027819499284489381378125534965938777548562514868791510874667018247 +0362874203793328000664031717659796956361927785166994482222033051420000873310315385500469809294516134684467763731164514267312822 +5076794324739899424289073581881385172449093717540058394689713271226423655501988369216296397971568827556688651950460247532081671 +2211691279142831153117347297369818334578478434502829176759746633980926915557525626263924160377780019382684610945724739361356924 +9219339881449560885105533284707871200679261887421531149034514599874409542178946360778835736536874753087132328398630153344208176 +1738323078966650030040964282424869456011617229198020575179773319844636313591780039750411848469791355249483448877218482996481058 +7662725242856974627520011178425574682734942204257582618062074645522175607162830607624141450906516065750218377963070171888324843 +4118042284044277227029777215730052173836438075783336538165120621022353806541561734384066342123951846452650796265263415816226504 +9577454228253953925531431429190317095770965424733462598360193026659796995068726322946365945449373804244913417484873047389958047 +2530447003714965976379236094037411278014717964765934254550861704945379408174897820528178412885512242072953354276409893858269606 +8161920683332117194434729439905850512943519462231619259091383414069915670154194411541846032268055950920748136328515080957772524 +4455001394112823835403683958904433147118332238523201500644925421808301905477707785391327088921953707802405649821266420465223561 +6446522347006213132203935166470869874136295692811490433897687621265910913874552752126752166818595258011990560857727236113871905 +9408818174849694926607806886600067803753381428797382723099805698620415041534972953179055866017711870699147517868454045402246335 +4135626065428509052074741682443536368971147858952760160985560880547769122981012756994845114634562103177568847660082033374741355 +6629483302659977998713743227246471116209038004192175569114510152669193408163108052671223081581651955384894038833735367319970945 +2019914369819713476232512996482094786229436696697562766992595975532622307992117773104105916821954959122045124593739046172932273 +1444770368011659028126820519729159232409884803442212877208399135578736969682832974964729860145229172744181374244786183467104294 +5285602663449673777986234552062489192832103368544537902433053581936823853505740285888319749907423551259460167786803225430704894 +0644806832972865011089771228494426041526498427256197014809301589227000243312341210098122668991020924989347084902763173739593342 +8397927825150753855181618641584202156450292633924809550510911217351590362959737037094558684222129548773410325105794129798697578 +2130742130526719507540424131716191473755652175799405630787752600339151530661377691130274509280084673031861647779131553466473489 +8949445645797314751748458206320095870152672752275260151260265707878555413048057771903238190200758654160960860864191150393477626 +1150155207111417862229200794999414320488018094694431946879621916439109486610009948685634866137188097525670175207351289611083094 +3459879841467541763732336521769192414341573430800023957612803685733924880739274791648569413015334203212412056584388583105695911 +4207107909576145869607620085461426361544959409669769028641359260476393776996951928885197026584290166920423018039379739461412804 +2471437021597594937922441016847924078362096363319644062767483944790539470640965768192086646725793415577156194561524796709562342 +2281835051710898850388364318434644955789879751829726732802303436684019874264646806723409567549761608858039525219541663231620839 +2007932711287625313296243751903200023005400873291491556838807519342296983784742524733445763971687078693207166472588686547509634 +7628738900800911617227705711930133205924637233313615650647097515124961199263711780307927527262674727498690057241315682922136505 +0493387404859274797132212785618181333173806092520644500400240017059008198178246301124430115868753110589721037771703980382573162 +1169775643061410030855660308847307357939679557417322697395889694976054211267593984893969933792226845025198715121269754643254572 +1728088919686607770305974714811474045083911324960307426887087611368014116902540202262357011208475439646884185432232498389602471 +9413509858059972641349538923181108900150612516616095667778909942463828217847216087159443807284569471198894585206492715160193699 +6728843665008266563029199158801993529576549886997200057517865461162768723429256920925422142043184781462681238742660537092344889 +1931599731390297037090231505612731169969829636622229470099002019655957459951531223643763907113518395449915860761987492535032339 +5034107674301251502545019517381773020837552557746624579624919732008873147762835295630900229992866373514578020722517390727520774 +8983019600230774694685639778625463724553591351398381775880431832781553934906986888770789153951456721760712116772577734503027958 +0722579888130638672105073329597090462417149082738030373661949401575813793082783579270436569787902655097641040401368636813371427 +7854245354370422693429496181630052949425191073877308843275368739572310979470712820505147110988781661197587183674125970895995542 +9743873036934859621564820909920160132335721185173809848423866981847229831790016569684947679721801847602901060080188329396305906 +3397337816832712119749817143233767742905059889912076656163289731022283191890667300707504214144077245819520343407565716275839778 +1635431146179533618869624816029047896887367730042516939278216433734900869272992829571445669607086349418935403567352277456520703 +6762725385281999872315155129365300727718531348063401770341896591345777984146395511533572557918080490707700609701643325567678181 +4555558906784569913680220888302706502231120206554070127879841389783669163314482027219519085496782129580409038602612227824819543 +4625553964652973015688630098326028308371988997070002772661734916972323600534194087341555003249709049635157603584665553841867805 +5469615145572204179649517877754736243473051237336198742915870594247954290354530866927776592105619674425818013502199456960100742 +0688295929947456127268347042202884584629259939771429635850789571181349570944477662818026788804604769581716692572546910654441173 +1781053017263760670442837500622338443773255350157040419311002126378320391255428265011649731680948453211623587016944241093429272 +4424881884807343597741531983608658269276205760340198024603987236049280398955549067330598233254907076437393855435114528768763737 +6402747544261459973943024136936806092529416389402993987239813694282531255632557296852083229095761340348625572700195393957513287 +1528386320984169104784676953231416483588713316281109988780398093348714641247346320098277064757682809088330401558069087928359793 +4836620934876383780592087107373057072272745160875663949786761387509864704698529847777036861011698566433232612309834845364039380 +3575337583851040701388845815054721473930456788213430385395140774983959957647809720764167375524924858966015899435919948180069180 +3727628368963430480869218342563326331182798677393171005831460902561217359479597768311004931085102290184621530025879576836660947 +3475800984573188366693910563609274312878602294132115102801727644998770488363543862638723091471157432089891694987852322137790631 +5023683657353497036212732071088147337120821028934424904568945720202766911488162370473709710449329167955152043455364639983165681 +4313458074953427422966761496213154547288857367926863109897916806997328848306557928981283734566043834603735209469550380544603011 +4769534552591442528339142072463485535584209788041390319662187991947284630203143273451030277553655546597381665676996289780792291 +8029659403865541723176070298858179302484672898090770785814054293418165410123040143090326214914018331298053460618863938939353357 +2504331261837289138046426704519324433487258219679900506483638261532541113835978749947580235779347318410118894160450785891787503 +9154332931976583483472163920590162126815140207546760699499178902132160947370072538150136322051659957346811166868803166980109050 +0222142484013400331297859576897114613785020913334195683798252363342695111135735081039945217905782047137997143182303582893239120 +9813120425348259494442258981684713118897639132890990099359593568005985530954284388860261356040562648449500126432442951864251191 +9491055336614888264152467342246996843863880300943314768116172425467094897669780084992632583894436406804533915530813948074710378 +5125880262000217074108251922916601396846452955978383367381037097928649700928330600429463193168987527289334840125068384753709726 +3250963913544985283516074025079436289530032965000091704733601456641384410110473920750483277883697522865698072624602352586775278 +6909533273650494192857472271669762600062165210442469141500817398520087420757013742072500281461753556164642072928308813935348280 +4807129228896091173010215184046472764333315290810434138260279373142369497015166184160402673619706065463269358547161491925056454 +7992119117554165493880872181423830045252323577778753354174393490633929436643377607848377532573742197373252323683113537849603683 +8841806293434459100805456108210596607134914383853585818153512788887296784056237782465358856155449499271949927041469376892328564 +1632152697497520229603928059316997370226452543375632335002549957119486189260078571706186257203470953055703949967851861921520731 +5864396596718182058160283419308429964136934231008821382389697128204242562370820069167753381761875728312424003987892871207159646 +3666084774918882500462621483992172725824109862896378199142479129987559328773744933469602552905906375001745899273316469658254151 +3498338535962144862096688449703329334091149790999664223656029226119319000718124150843673811902580542556051470065598276315050434 +2588642538822153267060185463367170199110995449008021906678609426788891572594252587471982661988824671301251499893937578926745391 +9319707795744627065170409664872689583830132047201026242383522246999299133923376128562725383185342894837098008031828134646969110 +0671702811161136021518386108886822361915633677386996222331112492876474384896788653692739997207795179082317779078270838374606210 +0529680562308620614160670757652951824510508056181488035417621544956335930822186390269360882386498654576366806627786546389748223 +7121344007162987446407144751532917923911603613369296361423444081791345960568825786153422255467670330488573438324604236300940295 +7856126749900534423962976560155869500794418586760356971148877729423323229897743690930063998855496652306786264023420507384957613 +1115472217398806310578221635364703110916537667405172225846214402717552527160481181622222803507823937807179294058810167262993525 +7733396618045594337624445678237438829647882527257597412143681872681853625778555809127382419530057648275810262641644934924071181 +3613929384294435871056622853422519700112176582857461049491276578382237331260522744886532614099866550813707901946900039411643678 +2471863854966531804604197010815017888282961247506056635263741803813648407515388558830396273074055989597305977778886391310447068 +5772682018682680181055188634541777077934406094474845232952841473576584969574909042981622739932442934509311768673906919851347223 +1971820335809415226886329944736554280331033759806916931583970783266805147633904060778157532814909009520404718412464333929846412 +9304789467519446866413824868897777103238294214707967726874145548954743749977770022421296628566823077488711722686581183789601459 +4520829387352906480220193366391017100275344244933837568936172706668016811057327408759076674979685576296077953383462420493700931 +8246906431343919288012465266462141639350962646993227082304804964566869105156074039984736745415005176673660764795387467919402546 +0186162998111273052854513690953012281012706484313894676418003816742150384731546652072390520748548343581415404883693106949598503 +7407453409468893649012012693295080963235028162714227398127099455397823529445343521263605978197734068303737481555026299674237511 +1229395187707069269668822522188040767339600015117257223444650130799671208076697307072988709360546665590067811729152682754853792 +2543283984004058807502208094435749036903952553879602762556029245920852075326946498509084553554503835502118795067551626235164267 +2007797747581357604343336945727914338356814330722751353631792234077965818274628997502349441503414970786616526353391356822676384 +5194656346701670632084824377074289402109258239302810982753490912710811175011533673266509733689435108026608580234617657393376969 +9037146495591802460947583581948869619219502922722697707400434384802310554421740985009894719409552319891457897233615461251631720 +3990697080273078766162376909117528749470352764935216917028329174981312070290561402015804824976866738329336998564205666524939715 +7848352778978178394189920640395834604512765967920164240559275230242580756053219581598506048812354481467677378211973577424576951 +9532477816991813127692436491685156204938010748592475096875883131377908630365761647389532075843048673325944084338736570456096797 +6164242821944626959915759190590818947629953857895701779138738262444662644883838599728736964664029753263536337011632748825080378 +2817015241236739478928849304183816788634913242150862112550226668153792859950263630837585979285928908928017849179569989536100198 +3188299380080735588065637018955883708261980780287989654193640067585824757814983887808561472404025858752559638368589207857289458 +2148159553153805396206627740954877447246881212999958661604167091735503989349952300666940107138834649908131455364478740204253214 +5183812867943299697018327767670320460762394440257519747758147645570356514775758990004394658301628734229570022912960712413921130 +2264795742893091605616321707447640168594382931899898384410937459110317820561426704161424031904340033048159158399357351652777596 +2139572365125527551258839222311219599103367463992672950511023648604600231272790630354961828455031402437496547839035832950304233 +5563173043827945218120288721053385228256759107947287607765533263965688120561373605092351078219345874822210656978425318969319770 +8518350618323036588967937820117667974812517069373788130975907844737917546000454481446588184420492343516807727330574227463796535 +2208092079415381688598883619322045535433174373692220944523386140424053570720154062384759984606718110454232154813303857905183459 +0403764445312406400743177177292964855962834587085077838226697948324657642954983884229554291774482754430895940798928630071520949 +1218078030268093244894387180566099112644808636942463725970271185753041625812549630461585448271241111674252623627152709755765524 +4640249030477405125378434884747349008061139769305596841781606951188241867017869136729477063722445205619856063985162910427240398 +2909590245662898324814954125183873527735419113049232565629860534526664160220755933343864533662307471463902405211409478015729764 +1532024154051612895466466141175266647835257739963433595273778351297990606120134172421391748505385924656782899507982823237116066 +7625676430217706141880242765715903813773188383257526213002250997251341961521914541749167347954676286972265765550795698115431540 +3971204449523415473814450392924406717851351635913252062373246080376997499866289003353070967905385783507116089156113219681812229 +7080951492315882179871809720207741914174481310077398153033680591523295504167580131795931815413662606081970038126846874489797367 +2964040579217611595547760234190477290346436427835968877980338437548172752209833653855504469466390943293257324156532489625950388 +3972616808815375498057586682316341344883202169607183819718037286789995473261003288017415010063837288806976576286819527639032681 +1290138051725002391039102512231630818525813814320415691425261417707087230623051869853213472687397101016144678883680930245168423 +3850834662586016207855419987088023334696460550057253060411826174208076438814838201928582833181083830814307068201908029863175971 +7944749902703521228274612063687297856087416799604592533936372400167341391775276233906976252493497295192482610468181988345091916 +7011096175582468584236690812621406307216715768647084636075068364924266221366474623044001441060540006895424513815585241978347109 +9612362696533734373153334851655466254197093486211639205861389987966709302035551682330490724447416578042696870553662285651851441 +0111552534765233442760444257765948564305822466469203165903339169326584537556214779726091179725355707166736526121645211226756106 +5885039259881836616302187141071464709494663689251644989212209295897461744225634984400183422383926438027326803031066696585257111 +5396579069429715251643225942479087285188610492026082322649552644481241838275988175206718743351678720472794668564948833054357449 +8688233606386980591001497882755114729508367160997540301693192893291539036951478433163921320714186025327605130043325851253234451 +4872214673472278544834646890891722960548978190052377730643946484747055518801507106492936171927846554906068388153908514485343068 +7214840374326612339276352609419398397127314205763710059777054421447567554750695002090543962570373028396055745121721373269382936 +4524482436241914482911352925071095921316760701089039169544052169552093783128384931032814298463081577630793680822839743941613795 +4223734008339327317027315036935919017365387705335808468598641390301926191406305147914145568155445735877807426352454856646393111 +5101170944379204574558835956241764204898906557725918071785044288986731351021322301083120247570462572136590876553271594974477165 +1498954940338463049076496039744592188429182308195708965464178219513192666612550201124332096109168498851228361187923717360547190 +2838593784210615507907908324852279814008797652951109874718831612968151452611605913542110950712021617053098075818112497307624799 +9381906333865113269293243176861228537211612376105763917319466803899016867981408631123044887142147183129506705177986309824780722 +5409043531218283220619747469806558139995337403975277796517573718341286548125289716392847076083882092014379916668361163684338425 +1904893321014375227674131798347455361695847285890504332145250525132622615658888584205703776156043946440538442055020240373771823 +1351830991497076875181168528408533516757044944191964801761366476485666222599596030732870772285002472325833568217236712614883027 +7315021210616605619597435420913698876375528968662848736161937624720303296895982028335232063555260929924269983942028091369465040 +5072200871530059327653441988927547294080741487165355628851444397293608964873155978474929308924899776875776153220999350338874781 +7297806144047991652107617589673777407092234699017295323732250434070279346790076112443512292202647551871470787944370705490593514 +8338680194506251068070541345811382066184901866943035469419313397753521282182668152084983612781310002659403231835343007351253055 +6114581775690037701739519471149107309520083450078485755172388779153808947468636573364766942355736298359796132744647242525151199 +7574059840087355237287159427555431111919013708861023222908038566164641505519732443177083128309239177653941203870945389834998157 +0673474392377001399825892148070125779937209491690893896089896421739180565135864053866800087116893052683453216209088258021309774 +4693630023596081716394525302256706650097913048822663453433130852833930985337805085115332988734054335391426675730296735748012109 +1093024463171151726057935490277564245957695353097684106836395483499057575855912524860400186656839768087931489404973303617192884 +7635877951810419014091014411375539957398983529537012020519286943703105851379947162885419241335326379003488660213681674994537920 +7313912009934610962402221459721660669217906503605255214027757570091733853488694769091622366303142874602414314687218525998341547 +1566050559171006939210753283371737704974135991991141945660050193578931524036467433476181347487862613613591250793557188528520720 +8176429431061693107924500762483197651311460029641913001176379201100638867103309766025948024030323914130084770751860668764418979 +1729648696441840023063291425166270194908270401060650039064514332458826292034060316832564595611388754933869606578691497545240684 +5096948893204927421293649874213362565576773971352082850459718459918977951318599802521678656926223913450782713343578245294043312 +3086541714606171194181739777107223773075014101828171109460641650405365226657056099487143258905930679574237317845176027548390939 +7740302926757091096782313708390498469422515280866564744352174072524950077317896546008807496266670386420521998084434771204151893 +5027934064208470666653625072824590692528078583512194513874229573957257382460729248431045517338285948895199087965965424240384379 +4571860754401274665671127939865476298997613160622025616980368067727347277864838846767268485621173877779887690613158095362529635 +6944876714447267999239762443038959101083236381747476636643523496718859843462703424789350147757356429745707937022796547995361159 +1608685279655308172831370710312433300754386599666997983340912162248117716366440489547493562293368632280675661325251959965144367 +0470115155279779686716584895721905617913807392365128663764858517955975388392843450401077964641050043314321327171303982059553970 +6215103349524529478271694130462996515027440018395285605756916821272681672383831564950333676633547276622946473458222960324229716 +5752661076880540890733587009248458903926085507327954333035749203073156883894621881819872469950016600034383209674501094959670531 +1945586770541986321354980385963397070039734408942633942296911586196737659678600361467268366772660352728384921986880900512427348 +0224298460720490332231265716874929497392701347632450314627063512555464017409367105505507132766860559659364230297395631822230539 +1702023132625842749699356356536784362975613947059773629978196487288877402990298821674431326788769352305708774873068640207819256 +0837874454109632180336808361233189153201698197837194960277668995755988025271886650717010166150668262322432532297058508033324759 +3169311626099247379274799980132948823347592107280599635475818048919814215035606030291543579920124429871014029266938736200412702 +1914619565140979302991699155094170839054951976790499833713849411741065459327090513567799966465721776223514774008243762437394273 +0284830262288056137733605741424808121279641702537891966081045603173960192239888264018200262442793489277094386722616393425116590 +1173151387211465492751444105592198529015440250049757464822160661232074007786672709170841572180341360083386765961004042180282066 +2747834197332941363146926817441453515366505571978984487189489275517487274745916049268403158626553738640115381387510687487708488 +1958762131814281375452347210594453320648975262319481726099981862965271971390001963271654018154213822420613244796687794506233768 +5861590138913305751605474142329109238465204802867089486028021810232894377402829167243953763417451369079334074531476305390636648 +6931736509544684644323440543056340368361669695138186889701847677102848670844548402669049251722131793379128120867567738961962646 +6821092152578736586590175476051687813270318648206546383329391485549308897384882743702278026541948728683530021908873051239269012 +3127870261792191598343155115866595959890760429348459173942873213248004394755219777755565345896164898508858847846745938219558572 +4104690546998169355396414252792133064383123628337383872945199098541769741499506855287626343383400914652705990644014540006261236 +8792100596328961741396764802811919634888917999468524631681735602589600555328679349075778614192998476904702613310979642799638155 +6734793674993705010403616483433595873080508573310753327845752574399663353072797746592366100412052447212721125322772808600316385 +0099515723538668132596125963466202152817452490708599517233532239221132293841708379481396652887673374586403485713968074564071453 +0083805755888358130747915433250146084164753782259744459712819051842998158461581619972310157769421457011089633907439164606444507 +7652876608005273562462370933960187647117519619868786042595158425921249718553500241273244226393132978251127763667423654542879946 +4405249132813172389850479368504130884719811118887711374371841091799443512801595585892341132692059703325567321860246290919547167 +6941199045895501309914547487559727954258599982156757774973817213033640726217789962907551298312065690327505399614397188477788050 +5358645453073717607933338901589045055393757684759513577031387645637409945004898936885098068574782470685593557377991753572387018 +4706013177574137609818422036943485331576839280415982210652357962891328244924452137995064340517319656166353370990119146719861836 +6329505987385677903166233247184756000826411332850477352758018273420949926789280244169127178212529891658087198774279941207714390 +1511370436371213645604523617727839098695940567432172783593724006252095799407942743832278211803447800402891197805298593983426545 +3022464264863164058488714249339098231034997516428008392896433897781383885524218363385806736382055438093644340647396074293733782 +4501101178543767329620885826562169899606635544112652117620964836027885674519772391619599940633712271697963657935450955634525900 +6375010018855545330452050093482150077359764898798182405456683026765532905675606074372556178229924063905296358938093169081598198 +8483257277634207523851089755598501951207216079577367620523344599612671928857960638762403403726285770712060711385777082614045533 +8256451384331378443868986535492407706512110875647453641525322621598498933275339800741719049869908400644823204415096675208523961 +9398321546440720870569872262936542811668490033035472870984698676634686438176528523891161540254323161470512628073841436944062388 +7797071423711013392162710663609589623668119033549706301015274145920933018984092472146696838533855941884096071158160204252589379 +4261414209517939560365542448209082777049757262017603674203052224119028323101718025778556206926756191607192650438859403548542695 +1466289085237622991161102650836935979121797669268051582725264475273671975785294342068745493084363600896894177743687712147368123 +9181597431483593985916614200861015600827448233462428138664038851972627461175903260548893373194383862378492912625568875647273959 +9257826929421951643418775488431746425388390160227055490497812088985726596130954189607412047036836095076045019637105980229125135 +0051088814685847441269344262748461773674703937437029964258894662753422844953047676499113437643607083551852374126649110465539183 +9719703193787962011022241398606941751940065229976379345648357311141518661729448144028369831751739729767389915436519514302519528 +4754705205114290966030322546625592332320235853494013451121235653943274561055976709436804717429731588488742125670116982095506624 +7915307785043160782062481393173682663021526076353055172054644485732609943157735268019683657488875580064373381138013382280006724 +1348120551409342824081918999927191374394809490457882851229963796819461455853157081977254041113267197827298870478281259789531341 +3812065821388690082091959389908490155933727232741583927718485507099116748923648769090644447688804257458798099398350465758474495 +2937863476645119756329442458144939324030284617554341982278719802555921010666415523070911564773110585363083165465312366738827231 +9179756558387423308702990244249813252311594585173041207944901196092166608366163256489844497165091829615643175666074910233765563 +6459378049219057988171618077989915820678435345205197081776728544947416949166191536837274889454949606246062308000247423136050336 +9590694274127077084581072678020481871509177233838867384578103147792423645131300534630220077747270144036126808318115046320973761 +0633314308759908977900550446703882605141401119276147159777634200043370016079844602659915203435729306675829065339742126589258345 +1889317316284541412519941066954231638054475095114130395821846044209964998882207473650227876029465587838652109009674311273487678 +1491201614697119361909884499515016131285970573442170426537294317539659125369759905519191669796894139802704690179128614455530965 +7312991894729010255958350913145958890797364015827373553097639087944419042322472672141767845335817123220952073258598944857610720 +1824787410780276399243095677626477613009119292679764840577779945279669981000204638159164277233130499426714911295485793124165881 +3599221696151384019695918691913331345308102473844702422853474390767392532790500021180165318933884607342905862054572886894689533 +7797578535955366187957171752724494492272818965402286074464704517072955420112819202222670121573771410655986788904078893257371168 +3476992235872213742357632857624847275225481432286353014243838356580086497628026465199448029895990288276361657184717108337186384 +7666621551208709893696388991140973902647787737649797506777580191326933697405674502023865297304974748640809764705859758691017754 +6544825495307606554357924631329747091007811292348124154567821317868772060770803350068486092232254680993513246201748613742385991 +6866165375349816659160016479507285079045466715841081115993221601429358066993308321907376618487248492349626318569998572862307928 +2954124850369537534496609519161469912394832203382444510628904117251662671751490677012621979800464348066614680001698354593940135 +0193499508454379205949576005154484505543366786538069430200252986165917146991374529470556848495722371613024998552648030029385354 +6300091436093722524653066330745577837674427424963685925900231612998930766803747751089009018089480544176580489192755004987058784 +0521904612577648015929532704786690696377674858853171421019639025087849558650954768145265982042719739087464082587058116910545924 +2995811242507764873679857631100733041164546962708369112790103328792294311269786039292022283070742012101949352297665947227182231 +0598910805263795572231168128611351576632001399408367899641814748409013513401170040370795100905848171920487777572798457368620639 +5688904469919555388263250672582090539068694827337359228605791133091700320455439594271216798892203930514646320638691425342088585 +8515424974655688512862245643897078195523156507477939116050565619183311712594098054858317849757764852624936019665610738326843069 +5113156995533534391502169817952742278838176530218998980784387996273419179922080679783505603663683376521615832986618021979492127 +1086319824275441488370793880965889728722603318901376609034648244802721809098732997770252918945517263258021059460064891744542026 +1590099478966776519298307952043122519324124336024594288380180094489716784777893529727657815697554594607079223393500535902031225 +7357641282650721485620638312466056185406173433791953981763404688139736645500991900862738958018055032882772556895285743906215162 +1650489828204176805947705046005072475080530548765982426627534295084219207983407930870882583588364915870597364960371942080426209 +4961456796449042167841011430036294492463136865448894885627513655748299627165496853898722132001299392052298889154231937053221092 +9292679093929935825812492666003758036634836903177775163898869080980492856814299385978432904050294518519563887081873640579238706 +3011512315941368814678516363524198263828364895022582836616309022291899256400386653229758118495144379060943664767132561955347093 +7994582030787878507087359159314617931782658556072425334054967106060186618004693028010903789497198319676911594575116984344480865 +6353605238667338186351983657599555627480760430658384201616896420757729940462911589836581183482303716623193619087127242146945823 +5587627832512661518234488087236957525879895860979271923639746468639388295216331627000259398878042734326931204663332399636686573 +0672965511904852366825996694902980930309250905369947812120763277890579450585046143580711709629358309790006863408567461111578107 +7579999047873643551313574662014234072727914277127742448350969386406545430650595860664380236476144348769728322529154001617830780 +7768720905776990806878980911933213548469388055876623124525549575902760321680062870410042191450149173795942693780209583496274718 +7500581851674961002356261345542689400915034872242480502581980604450197467020488142845109390383270729947278076491900579496982299 +2129690101587171429651661009917402506767801016536968984813683892465052790569498753467876499730105980696506174974591421872344509 +7047018820490212289369541715584056487037206133357581281018603240803633328043751106808274944483601431153046581012102597333076902 +8327884098495349573228357110403653478827808473415101824363258200250596339218554185491862934594792362506926494486378909931564949 +1740056330174856891125669279294923651309763604203532765617783458152533228430452541997637109088581841891669514331609715059758968 +4197367157825328214419156751555885819747937310581379204615061923091469679845199014292435432070508700023932922581376409143095993 +2165125379005342133424590972755612895768392827051354709297231877589314385116008084334202246281649011825694669304551295469244979 +4509728839111272144692019658264673559690649474179262646699331625117318888277703635865926266976720285188867979085670193580891875 +7275477166128052446741208082801962510905074668975005769114065221711777393514237422266031434604625793424024653464475330291262873 +0817046411197027445752205700663441451626769878011224256767794721900542448009071309280703954949009199107668829370562168637408040 +9787763619368655981881242490879775693879040221802840519661369579710229328600940826654427779387311550329699789056384531195194998 +2723448594543172549888888596962814780076107260643457934204621584814413545214573904777806106803313154411323713368897701260407449 +8000951726014956095448794689858919573269714659606606617498924039765372767236447524498222062645212525371056330185170891625286898 +7400634580995643373473457408678165048789850829161271772842260046851336944770097590727744202976687517001530085639423877373364847 +6131960772116097152434381501203781193864171006504601138647645912125860654370952251962787439280635180850121164508129160794934976 +8194796768491845741394186667260815254416308027847649620467735109219757947751470402197659639068665099777922925932497275155739813 +5209664008657449547795035193830830788192397569777052795318568835532699855624203558168754541268446171707037486010417690857467487 +8377976554519991606329945190868959375772837211176688945495596448296939525690240337764633216663866800325009183616688088580000528 +5192787146614999641495067302066620692218333148024412938301229255333067720338121642154391246693289222550082295681213541896998006 +8136852204722481664059335120578115477689164853072624921786692464359828604653937695373728935390680120663294293493176103289690254 +1144435038869128719771735108732844672639943553994309593207501141582954078007058121278827020008994616209652065957537243296195065 +0970656298377136326223895516660489631269402730038663872646787518014244370067321464425302758563853474605729399708299081361238244 +0240779629525661769222180612134943092596901392802155389763359378856115803129803025504659400407739325825079102512268146609621569 +1920020849630289059227598433172661405103577932866917079329997842631426173495463282180424424558897910324932519322784595681717233 +1144193327801538649747431966846093543676528159861420323208804005782998653152702827377592130780075570401214786834816747288844424 +7672000694647648348909906701159130777349487715893771185782393615180543175659863092467698777377397102350383295634648499503885338 +0495630306491592179663093479474155305629241895069310776977867647781537028272341913619281785471238537339471770501056143359192572 +7308837601725546836619910084602280257935558569169920782961917685472285154488319168403367545336906857013748237755825054290532894 +9661814404701500878628706398803486793202614438164625925828662516099882010742067149392493627954571934045651513234013334682059852 +0312168977557161126723210896500911203207572745509229840888786198868413208045541779692684493190694384662556740715047630385587973 +8520266389063839477339561111091620930884162729262785462465146299021058533677470756448900131157092740484913244873616221850614852 +2366892600338849323238354679971377016007007696850190096980341739336594207986799037588279474367471064265784394163814443326245256 +4911325423638475961054407270474262985635705119625522856108931080012973303196967168739739944802380176010145279834846779349851937 +4257810389850148158544144932315012034020829622092429506782620637342284858172415547207765264086812199822149360687311593339577078 +9708659858477940738903030251204629213359548332123829955153191520032561522000846708640602917979387525987407975336034837147466054 +8086930623135121532860695594083516763569498334428501641151038532550501591735570621442476271723263173645629791905305955098548029 +2777352200022791503781001509067591047738954816120020121065054036180446105221458464420759433938919480637654297994424050557216733 +4557327979787779116307153599001198923403057470538783746410924085722270113118125208362788921890249447415394699853853075390237309 +4365884384429048241521760483369109759203884801440475321881130286288789565265074980716663859447668954490193155283240957032437631 +2400761044210689572007006009552492603834440745618264315468884643834376009957185817870038205575856137576307667033965516109840180 +9737040417279915834911486990827520959476936502177184234720809847197612305989565105760154340868284644203521456078055612096029018 +9781808678278846885397125652129297898882169803910679237997846224593685450165476495607070948013373905740079438009246883252169515 +7739852920294363425633218123401420673829295163516060432640021373043583962110762867984429100483394773437741380363822754539046324 +0883431115446791272406513984118239461183841794345923431236238292749873478934884995894017966307053473725524062094771916898837907 +6139386014396316197310075826416043562421564641768733346779156742528616231256212666391070181857228107399708720583287723130892055 +8564495834035892079724353995520557131026025067703760714350598180164418444716168502414005579666385014431317699567383147791141861 +2311406885413424305003701677451722846677377710768986204839545491722958560065098823523147478261771908820851989126482817082569115 +9602340226869859614696378992497033778548537442058541618817057710375353486743749797455027651809309416058045995383235110379798461 +9628709222162680949961060074815226201933096277151174310696525731658668144988286362519156716805236829848685383992849148064465103 +9735346812240729849346428396581006547963793149866858949294858741576251512791660305611651687839731531035722282235292660633788691 +9538042061855430905977346502656421504814621398394569363683719060626568625659708532699356988708790883640172621307887407813836364 +6305019984976325257337569429166547690694053229542307273781369534773313407694544352991644928363693848808898178142342306260087117 +1805704646504085604801764484506100460470712673185793035853367748681894021658904030806253312188697070560965442489042489792077571 +2490985236219600794455119570755743690829793064352980492197865586952595298856978623488801799239792633697972577551080842006688049 +4451839628325290929728145285465077829042998419941805433824084767085375358192064592570165051059371791323138480645291403839150350 +2979438318932849641805788421308077401361414307061802172300131888869924632094305534351210554801463479850767128364891176166829465 +8872921500436141106816138238492673770588860037153870977927285412564501357209059187194899313386454964167921543412282921398037659 +7636485131279033828460677166640282160440679145358607334279812434544494120552175807283800350790566307285400625724030248887429340 +4680751592769547019498010899871228144441828285042700998685644394131763248290312908027689367430340488843863114128754770298553903 +7371408142591796865710653973046215109255786437157352313924442478531290092820677548020730647005559727973069973416903159076053104 +0296204614919758433624657596498376245793058852298819735885655373134544548701918947319286620768915718576221199382936906689136966 +4514861015660728180490886079334753171354215683899059435960727947953401618302867137487819801076786142685334483700384896695954037 +2862199178730357056510866292501440152986864077701674864131708177930481209373944027435441136206079828523990989033623289788521958 +3232125855905003070647322986167904784829417211608519129888545490992306400854811324029764732798696566611533605039116218287211064 +3328048087467522304174357185558580322486932881453149442008314359000540253074863751401069345083176437332910631591438430165816043 +6086110405144344067589331082608930355326779125945673110136783179380891079747539440654925994890579005806127474614509336396435324 +7215091301714414443069868776064064504395207482808517829405383379414684365187710912963053526301972343897304816484149722894728342 +2436471129882505774580140273945136647748090634204279933544155848974105586771383680141377892142181597367201114241681187884944773 +2048644482475865853030326358622959819676030401734261133906361439604280224652350627125083350512410927294034793877892580606553735 +3602935472072437248748601211519488988169731855279575778400706577254567463123219123896535430970244921999769114868734160215986062 +7783657628040022836086246510234417653915945131795351860293548640058155931582229824232337815003665382949403984933860425849161499 +7472148054410673792713655531708222900140217409627089428063743914621052166172358563633841329724840401144427912925448192355476917 +0347053733535476550133949622008506766494989314867137093489295258193336447136204549399148001892481820212852414088927422900419709 +9639078047884835538046942482094804161605891002036742318046907668105442784580061293938476627159719249453272549683221805416505790 +1032786228200415283294994910054729118848671075845281886209463073179728081317785205722424406468440642562912784973899656483223098 +6968595178017412521208376863115552570593292656764798517030930445070380603195697501931025439581550142699705302804245618724490111 +5453654356413064906966652124099905267347821364144623020142756809037695527255942562866173971391249170311659304510623511853516154 +2732536262071170918681622064325048337837520111884271935643287214208402090379942906531363266640024631740298714867728868944222573 +3147285446615157276563228822132897878376378847350594831988142529113309891139340761458000809351957235529902167556281922497506368 +4354478919601617063477169153215969873898414180925342349186710519974948744199229908589593712396666250201617868945303106857533139 +6882511013607261756622150246671069745871933132400620002505947164316958006187665439907383822926483113411891198332966708317599278 +5134964407461253261959522854559873663187547708050982034442691200555341283933873911454057728258698109359806239057894517156699836 +6450666103279081547887551782344908272320062944069880747023544207556937435206656509659651679103507702121341392065845820245893429 +0369780371537429488949966165797604230927289652620569227359744404503741546226260737989821878745670653730192856868459952515531054 +3093345869807819730548713734544643718538694047498494322996726007960107180939172720629651622711868833028333458719243526925076960 +7989599203565850572942150442657633965818968052176208211383992661670496993990824695668976291478797155039216428981397014999174383 +1307119242405531123217610464790254600437026788611070015681427406612197589802556879143899518155467294982590879340815458735590885 +7771734336463859132744468610337712969586326511610847632572701236574882685603506834926412287387742247547804989759024383729486919 +5271411219228882208040644078382620627789689028134461694434130394862996168758457553833289759810275955726724366779012750280404286 +9512730467284947060387240979546511277358650894416265360099607348235188428440048072383761268322342324845297508884228837212297345 +5520192598997086640709924048681358015575115024163991652287513881247554854286841200564378110057343645081513230448973403055902132 +7020240592700662201858752560247475343913953666111892278775820432145603140381127320826667055090149454135269196723432849201394471 +5046712344141591199667738249797803701007407397593500840656021101416075518278507896267944040576213675962509419570331142339223528 +5009173314040221242742971167778009936788547416346651832329001334847054317513290947080798012432976916063888435394522306337209156 +1366848096908460688950147484431870925661107449748979391978321496249695501280906214711588783547789400280700153426360634008817145 +5032320677216082097266187853807984797656213614647275198101803139086954569491022740666386321968921335192817122277500443048900363 +5004785469025981206660221297903847696398366951138307001168655587727211921402639926973173862035209940308951165885978641411045411 +8785398824958308479147867520302086574154227898640917802025901098713415060910391722736844682709559806414137007346900318504025652 +4829177039724412998798470463159506613910620057768809973408365008034259886542242550978070824664073713620021235802691404413458167 +9261226904113620784725763761828029554734562287674270893824453948307773514334280989553881807221303459863642843519335273228474128 +3311573735232406552245381370523373424363177967581228254334269537766809380288366330679697723673023553333593300509406940840178257 +5850353980111617800710390835159343131583882096987317262767588967118575624615788759557354550955443154249258491730584290096574346 +6058742867661098727133777961247323273097355895095662383648934730004254372357455111922489913009492093823561131792526688980983778 +7068373836217667990225856363415691473206022105532884987579074277226993152918608006384495892970483440333181267244554192632887695 +0375929236714973683664267906774009903162875936131255110025871545553310661098253000439303508717945000859600253447780364023263921 +3589236909622208939924919255987333064134666511205037102476749734554331712415072770445515704120917930961110839990243914307170158 +6795584768746356073781978623124211251870230688353778395309754364333319536742360245765209901147398777468379230149142523181377411 +2729948487677410474357762288343380948554393380782338431844676175646578459942584025062978984890983296713845183696219799180782039 +8853156389861615819589926505138052323380550759364020828050387019448769426662074170464533329827565869171293278882331249180195752 +5354617268287092363055229579924827016859348547054043349609066878817933385065188678139799271936447212380584467570750380867131343 +6669574812003056132820086160683395897628895296098843871784268115803999250621428898234509785779912888254113882189729913124138323 +1094710833263258542617692112795417986473641110466966207723302828445199198995397058382901854029835381782441946019335577334721714 +7084654187809403875061887873785967514836739155665927380077234732823032340675248478794617424267309726934964316167994411232825813 +8586810770368457480021270214945101098418804122645991758117744041940927633232985858835902473466474854825024480648895385708401183 +5596898921066046808429836093228050083092077217562084369964360104846761170405526779538921555848456229448715495096371173722462344 +5660195590159993019077789825004164832246820538076625410586718868028600352830449932992980717485232030870587444549082470943172077 +0821935416600837395349048851468072663127356309332941980901438793730151587795962214031501434310617749617534269164881521735791175 +3042072934705160703532059769445721283937901499649463824595439982424043872605434635393216517511777007087089174560510963232009367 +5464155662396168936608488040261163576038165196682279135320764015816698209508887367606848299565138365679605265583581996112669276 +6753095562768549798586933346781184629087517744898743057935941129179204236737611864578907720852163937289062427955626269555922129 +5716541079272109791401178359438691238957049044014297693164836859127158377764717929820749372762244199830728156908190474636597721 +6048348633690063166546832299456572409599753235001536610146572139811087134501881675589119526672410909520126024302026020371798099 +1171674402450497762501699459068107617561003253876215131387056282446344211385618131395030296408469586922564210025675216461987907 +9312371022806876440175927558224158477356755411023006311819103124252221341547172708634888791607917037276394431911343613744399883 +0922159956723896116809200304280546821592880397796462717485456950002852867129487923589665229233372270334774238944990617682919310 +7658709241655408916654408381196074058493866541161875193933692025333882777349795393761970679827330490202099389041851596493234215 +9234545178442642967566968436599668141535683259923279950462781030512766827071494181783393026832191674347556257505316419663487762 +0041257342453564273568929735796453624713683399848511617479340816490608890963355058355974856413150349382759095918170362098854394 +9592779304960316507865578967321355607760068698329045954497816675023927602619347677723250166350520531047186145206536424990428337 +4299316161376269795506896486995922307501710625151467203920818965364151628354223037516185750241653836563366411298238504451597789 +8841671421275735676647633262528681899530392131503705721695449652045887039670882496194478043622621695748874619557992717633215233 +2073059696519439089739646800449388322820261958926389800326850308700850275001529873409140035288149114816334962577827586268363961 +2490360047432436143344657376283381577226551875079136121637392911221073093866166045906272906769849919522908370281254710635409730 +4974848754591262059988003622570276863287575164608170178580822963208162146400835022943896925242423440936618793540028102479004702 +4372126595413379264526984770633204109208673880518625238463206225086878596008443858616399507133771134539070683384873925072702058 +0639171273649854719051709551224607779261350414555233764709993649110326667200717789312129165461963429321431418833445603440663689 +7186962822361873750181210266660607397813719262382253059434948056476254707273143420389570046116876618519383113357898774377253891 +4319529017033432347952439153798524883464591210553274851928717915148566352954737293867412627976883192261494139098284868083014649 +2622939111808623590774562258070588172127827495395694013730379591966886930134915200669202327099882207686441261515920355425526638 +1200973651071533307294108492132851108586204275141332635739794068695424575790972361088170979623763207458716935295604008671317983 +1251374850775260697268191392326213755565839271682628582402356668458562455145193885654924842502488021956636839087993338831884363 +2092679910172237700017761223090447686346621171455515944807634834063707579619074178681232780539980362324148874096831135359068248 +7059799025589703414119220067452626516006331839767724497907056535882707433149950178268364082722639297792594500281095862497786970 +4542905544332920101592075397986385645511891063856851014878633174032148021231620025882083670673312205077519194573640381350698919 +1312255205389657370322617251904525722465432117955235178041221031184821368449334584954069933722375723026079372281725777733909489 +8940234530803425309074547064952811642951856360280155612932727691967562499759113316867977300723413954039644096858319695187621995 +1667713304364140592650059312268785120415368020836414159057787321290823207568631669529330852196553357371986318924246623685192637 +0422089184234642438098080557484372830069143118691288742408958852833389685002956551956492581208496774233386094905265339874099483 +1677835356907666147956557529262732608196197501168021350247232245111279150809917571509855702652690905689682229523319549019678024 +3645155615476272052329623583943381582821256380614894465459876556622453836730749021655688760168012160726745987877981868221817319 +5647755640891329597098392215119820185325320967799221680909508299218493251878104661039386657485694867555315346235424508828545406 +2249500944046395955203873004372279572553883458895334843433140571043474669708074473381457065865063499709405786900325552248426583 +1230511579171467602223112925195512272958191569060831817009891427720423564097069405239471201694564617244826682098552152177059273 +8469866721000791525531110152439789939013289745066720962189402891838096512969001059723536174778699525713458075138245336864075519 +1296905270266717168150361331577154511349585629938472384230294812334459038517468323643620870384471376627488513753063864443527971 +8484849516117452587091720711551100043539596219785764133452403530020825880462282298393651618450654255243582938022557870602084123 +1944353914349184905366261486479354722961723711488366658700425467290309892874206605011693831609609440448499484127167958439545979 +1904342525350793098590501390656028964534129323617049186915074724786886755773131382892183343708636631327982725884104881408443775 +4047731221209068512782993439144246721190758070966515666060478086425710216870076434550244885851035049595368742260028400195490338 +3375747312957348876639595293489234210411377963219380216708693519698209655124852272292375830483071612875799792380567345928238534 +5110079232697543396393866568868109799067673989898575725771625847005572590499345721422620239447760726870678880204127450730489419 +1892883230935369730591390745517921975081616548082333381141791553938700817410468926449238904528671037503779324573001732065035519 +8395077376884962568002904176016991329810132526312963614723727626088091850321489438757392596606168596638103913778878129196298132 +3938927636631738411085232552592623008752473475775738216360990000223836611551924314564820835426069886741001153829625505334993487 +1299692449183332553204542348863840181665273246414104121624684776356638436277872632132123576236177751436546351690643540205371844 +9194356489958293805818668234623245496942584158879649161401045859846964460358471563904833418667460716546730472435403875780613403 +9275256836090272445757731146730052254532930338266683064726986679677894399506235508548851649563290194895324537517696553037056936 +6401315045565945782629076626066813595555038611734944119511046358367624104666208828448443470577765348785145599426526721185590575 +0586738484454531185743029468713911469676776854865676690022624209621140076731906638884334409090253652724218159918793965233464039 +3171209020852465810305033445747086308509991604961680580404820907479024353374887015602705890939142087700418451581794807689385348 +9424311150932643701645157338987499029528852262438813754400403069738023146915551968014972578206454343730343122265559473474927849 +7742146609950233423816671939328483772283214892322537597846916524424589673152890736557038920458731659652032921748569241119859976 +6687533180189782962288035952098447575892236672807319984532899523336137857362773056256776453970744401322852572058367357860586750 +5112973080188345114036362904396465766939815911981737447433859679102909113460170044475876180448426521815838110280974934802651453 +0141366660566071877771992446357332649851216791119528638672163150044856967323023760152081614645879961910911227845879654515023475 +2214123760185353539707121031098580866690882823675580600794715047520486504684525675655152270550399135886572417008928998130462848 +9223973656232181173590003292639341133004977532862200821270596930208889426180465089396056658959981954090935260888619248916061940 +6623578698318166136431412779326115216613003933902509874343492190835346614403255698238178964137991654202739789058288364219841871 +8291158969189181550110191401002122993337707939239499805961356987899937471416091612952104089354586248344316163672726189677077009 +2569911973118347742318591298716009672334442600647034815935927622454202539592391699029450660978546827587095337413939180709898411 +0899648100113650188435064875802395140965508050973328163902047496526339571954451436627138016940395531683176282436292339394573885 +3218116539223354243511329358754444736017570099304122222814440304223163469524526595019625005310578387024223128529473465323727623 +2903847495538482030544840551895363794476928236443136637630260470246965452066473119820100467512281726986329810864283236603867046 +4226586385557184936270267709088518321173404628666811633771213904835009960571786348833009556180773685058946093743512399598902672 +8536593915600232712348175092402812063615932808932457150254760365196790780020038688785606653890320304533826035350207715944668272 +7207307332779658122899268750088169215451053148485733154400660830345046074837509653982716901490942833776007996597381089382249055 +7354364139715042807616100729619187431380023428907586266528433249618278407719620456619422594117403277614144426686677487237152240 +7463017222778211045789643242204755641148330540930800826901784405753146374489626927527265867849180494980902054821139633747003818 +5151230162674659769071431499839596583910959703956345024479063722159584629356540852497161935430481786349464090482420412307760810 +9834488101241849496636150547202745300929538510953947644624667132590235877398283748992791388091916279125999482122365178401663101 +3799117737061812716778711014651789301773605485731280987694315010080752800132070053513995645594283497896886041897544784262244652 +7787706667573783951864085352707088626343810856713494836743287556709150843482692271254078127357988781374166954894723733919964351 +3850833609175684557920955809259004150766406752693874551692602542748508158101511651908521148570349768720243116655926752800025156 +0542333256075861408967459343438031423694963841751597298639419078331767590705140401244001636510150856151990464720632445051520472 +6303430699933496407768275797041897577889994294810383735293345544688537126863233465001327982318529841153751728223029693637728347 +5397568768462052741831355049132795323985421528118062025164276988946171985642590654143451292287062379578161283874235728279748519 +4640901822963272018953105436900070403241616145463711907565248533620946580204196365483196723416387548557874992063706490486368853 +2187665586968675889547896116950223441017696539693810802819756256217188102291391477467930773393197219210849036472348714939348493 +0530870138541801269405772003173391922440292694411582576482977240988452402062182324365937231322664832700142793000599915699446377 +3232764179605713808662558293727950897506959582972158149863534091415959234408922619772945504672047855130269189456164558749700864 +7976387712997851037838832161690498586021679479533477214488890351913481087239877288703362839723676811186594991567854176580725967 +8767096970476797579593159059506720944428573124512821132135870916546309651522551842044412513318859523946351494542237948488449896 +0718064204159475781113170590472579807866358541733298234646266805452325502205676982790448617382183104529620072495546016035798369 +6656888096932816475747398102488120987337320254949271905969490909227960204913812078261626642629009104843808070570261399892364887 +7197928827518406319220242665874355187232953000643123084932578105682719648228431872207900564999025910692470162420939628457406240 +9390054304943829673541677221189814900027963471043254648597886086990795714249446234111674340418457357710907778877224567169903636 +3047190706971324195888140547475741620358462920833528017528636158028581644462796976018091635090361132164631234849610385434473088 +1299169151001233913629789222426928990506746164121889744635941525381099603593944992448532482489564134843216370953945058018816372 +8022886634541463283701288620853613352158026264893049477075544241214340204041747957155846007535087712499320675089565208063975842 +8518974453812680488184297781261482966404248280615326837256707090751389480480211355208009414536208955423929547041219391948623885 +3604467721690594055924832819820324481035373705830034807313911053016213471052470202123999030910736617997566930544442854033269439 +0783963633104292458209399376532444272248160361826344666316224873723641667255667675127680227315908535163742986352235015659049712 +4004639628899564002311837850986616952858773518487977784208052701702476955042845648511721265262737849283604073030798668836277183 +0862408653011082563803132060254754932254909982790619138767168477417959797920610077885997837256974272446346326081237570982197007 +0940886136952306043500899870090754863364443344376526643707265847999796477272121932881155662360934605500536289044543909420287159 +9325468416880604404675394196786101658805312863903480479928341990160539724867416343519113232899201923506345096672360143197907320 +7602604379899247751883206653536848520843218205588950289513511227638017895858870330990465204694386615676242643330003217066315632 +0851199846447079085502271034855714656668178101657497639831079366789502032474686387227843449343312220724903806454747746782689424 +4098848471040002241791388735422021963275960354775258076923928679254165040693087908221190070756034164623860222301010088075103056 +3055192757629057465255631284293545235726639464473675957498678493846951810733281325747646636144880693592596312740548434768830767 +6731474905682791005984276464714844713588718904361218261812425686803684106123652431919970410078795392818111582997268429659349585 +7924410389518202685905806688713577803625532077879713115752972677622209346192681858566234259911076164694414416704969551453021886 +9355683562980634479815919874568756218379958083872036318959815690363034752884522901587704723069489938561066700856799286608658620 +0543220462343036193244858851552821480362000689940188453022451557344919396300863983139599553360452940548134852258624017234867371 +1067014527356580183151961289434647684360706506035600010429135039073802230973345888131418619960777100132646812026883383699827970 +5359069383361932605007503288578185157851793814788353694181498218990573049785293883804780055838358139459377587968253742572072043 +4573719136273381835268729540845328454994954362222395612112318303745157807658681724375200294326161779060096534923740884933625708 +3514458846264455850674231783280205705825729759163794635971944702176098831501306476593168602881301267771422854514181550204581778 +2814589926430879599930014687698610766303495462811227979670379853246555977897078815634814137435467174275073493314846601851573261 +9109412328394243903990091864894855454386078755925003658916610663445020722891205775398782367407839761338086985543481077581229638 +1491723826525165284311575346657279958318121038102570973778417404071686643040506005133105712555305338320966176072017676784923629 +5488218241739200538202629320385686355121297434909655261539604247574676965715827475716615737941607238002608903015929093309168488 +6222350309549145806267049598652344478433516262239158892817022906333942210072994901250459132730572231739319182532518293889630019 +8044072077285353283240535057997955717161542654506209603492744952552847242899140500411096612225095709028876598587942929972397072 +1885954490526928165806858149219735696470308645981279734404025197278823077339850867123073835557226495747843398970587652389656636 +3636990744440216604699149114584326945110057025978680402356462092308935861145193409488632679598241716104734129398885084544095857 +6069902893386332364062130016921517943943574898468298687528180638591233629526536463888804022514538460226447545474670300837773440 +0715242925233223925302043184620521073165032928562060926764419538572558168218946544243657541925010495652673050247406203961490742 +4163377094941935791929068796922863289449570870715728363127254502097952823099544701660693419650850191571787642058768071578191335 +2362149372830570291861457450525257727016337864275693314681112878356465000993320675510813633779009823896594571255519867010367760 +9335339409871128425332395511671431500329529218909754194982323897857550540930935004728114503428724192561034251245345901549129065 +0756506273973719264925319448914314432556471353593665242663682345436151888535592338801660197397976918922142540903105362128344221 +7296939654818049488767067190718755957947538340790260392001857532393622868997477129188922872359726386124323878376837617352814907 +4078579999111217939011699307760285871218819333972182125286903838312055662520500719903656687016759241817857273468272683917688574 +8726333004719198815434960721386959090224338905967680668744954339106442434132414526246207631805974218944345895924595868424575128 +8809968439523768418749746186037611280882890683322020074536396621763557542013569567593054212148112921735580176883820120783267348 +2537069038616920940158973428724068585048795501013293376681740631186566951229973336427931288891824421015980577224523633941036996 +7974808176187279818828936860482106588007126950454089943602952411737485839990023098877207814888492767150658782003308086338815157 +1588659669715002646102364063331711646691061797936643322785359527528662208821134749050337274899095692843563066296876088924734707 +4549130202526685872258479111021810868210332005793914145311147798812593113617843971880716197778981371491177307945521311901222788 +8560297570244477829694687977784621455987068942424983136944870380427057052887779787702603030649524780263375021654142024115901877 +2048774313776039429808088171712835186320571466269472744364892701622816406146475324290364012640387008030349061922998372137187474 +1958983930518040048400877463606239970518078952389442564587925608445408847664043055091202257080066087803944336882062127350978604 +4065348283423540496042896789726757274478123900698244046915478972359449728574613924262102889566496871444268574144572205450579978 +3629438124450409423602990222911509881985430704078927765904795404045938118161221397917848075421341126252805098426191320837834521 +8085534923914835313209677375813349364458599796275600866316693139878003025545882010477316042716780306226946838431532163667037127 +9898915134568321964545103764074604849670802062543079353666823915979509779221620608508897413582424170944308180311897168957048017 +5385323115399849956058889239701492340513864492761797303099763383900112373871513361204005145800948160917012448658958645510687464 +8637322858113048873422361029279103210946558131854412009103898341572774795544194370639320402689943405658836056138282160542993169 +3301482949893831756487465487869018898293856072780727019945397657149862423574816057140762598392679733606145316506298182753363157 +1989885295563430148607778298379580655148124775805236404809749482897588166275331919278290911157248463196182871139898936725797368 +8850340804158989499571102548588275214111587736824329752538481445797164191835592201791780416442465525643066854658921528683230761 +1421812723062059588410998478367550671697961940333154251595442093624642651562126033425248558504164225223871598921143098979968917 +2477995193068866106116650832975646638319811948342255800290956070421894468168681224145709091760495793451121243995417375669474096 +3150729646482352886032550446062928871539222609285098660402450856512727724053427921573737445175821849100475781418189174380995632 +7046750620615596575236877490285020288321290904270312430965440858488622217217317102253600290127052465317624607416177498383288106 +9945695686299042380678429305385240697039293151977430358157956385467140053019250720885367675692664936064594234820657654969335744 +5571751022714308898152825948152037875574841245733361004625842517428626308101356793475497881525020804091668118665745094943275801 +8608762448666074656196662829963227928222015907465782465504699762597437156318531429585635263586424089541092855892902609967867982 +1978685830753176969518395838040278058667840236176435782603960672407003909222439483538760352906908927302768494238355233209217253 +7074071920319953536604510843365153876170171633349491568232092272150542222706006804946809770825099582766752656052960983718114235 +3280496115751440895543554193849398007467023324006497516116534251153591572725745514291959829061315518724947165745450390160259001 +0601737046591989613120616719919874653529282948250689745032606820130735453268070027901333295387220734852357272804293331117523997 +6136958737937467562116926228263651346592589988767235293060122410789132148757897567424381946719333849272080001742385628150689944 +1891595701639675010992493605507619576155702842803896050077803395482631144748035073236453571286662875633494080865014296782405059 +6994138350962374748911276067098522195781999897499082597900135054301540799702368264182765273926228557006482725202228009397664985 +7788023609935244035749201882811852725625300846793646185552122933557882704452555648205100150340311907075711931570895497802594450 +2197653103798752067286172607092220822596982226247423576487125070944191009560709583893589326623076734376750057424185701225493266 +8863132327252007877822761700057804325184406486939470443703245734365105772001424789573894937476178130538608010471355446757855177 +8174190110749058109791874932401725786307915411703003043709908238217181652029602262116068758446055873309569311805547464496642142 +2490958747068677929992898459199669839140241121204680850335549077174567238373970308977898462513690749136086901700597984427253536 +5982357462083434284507903055152940486985159078049952746161034961672224995628192794860546561549979398991180455860037140923248338 +8926976775587697462174304166383030496921336111150196335640267063653243971405939737115496867091474614902122111713955464436671112 +2328015592752422584686538755738383160041067711192111211555671470860520931401458590260603642848665758765427324349701633338120285 +3238367054704111120178059574962944110115171398341904274585267575082605150464279484097073060481753901121878225454945359042570553 +3450237761306126967240618521993384597368444622149529677366929462149782561575513795963740446321127465963106959992420775690369312 +3448814725588587245567368751607825271329254275986408132599484784341832975302652140521158378926626072460485474580935278488412601 +9150780220021887436734602033408383688852530542191765389359753381850912455739194414678686576674855611507802645590418679170889751 +4835292344245385826099978982021385208338079311915794842181613685383986799333650292340449601221579759524765161463912861431586003 +8364091375971775721571844301438463624297900164446658688640976105663184901553656708363187917609334998277021278755741801258289094 +7084708048206234641953289421943297010794421803966656094223814335341165874897678668246105857901156960186097878571917343164253048 +1580091826012825586670694920435572709977363754508123881333362672498821977048126176623956391025928031884064853593246953559407401 +1343143393297933839473552543351834063051545756389274017156011730389906161525821950360013682370064447544881706475110217230969461 +3302514538150761859786668968377489515133804300482090273478961905590177116881654275768644498073647264106408418864420104945624333 +1455642109436975199690456185370628722356663838058282076416293074142932077562024273500214654758558303856335007961702080005015078 +8063031532965823241531821249811544926127012157501395220835632529512891602224510304171587094059291180949555426978545235398053558 +6792060710713434110654251175014016166953632439786838514140951524356192499726146571336067500056531834668571621898017480292338282 +1437695510093265077864080367192602710341444418961408220405302548941539890702354912153612054318858614633735009858764482449040861 +5181414865532338468286437374705876616670683310417100729198121447458573292151625305538384979133781114543503822301014850960361423 +0442509889959385737920714766510641471461284309092021412176656794047214218226892073311469169814612693044014585717564971417728218 +2325595356223658506960436649084028083363095352384800259697237546709925440654926883086116058532378827751785516901620186132035077 +5272017869427934924377297497212161665902064352062568107159660976294283182349751217848859566575424801083760720335160297859673425 +4927647302447341405487506286250768152116103802235113601574433911840768325925117428685709060725568588745725091307806563183578704 +6009173829226300709392490503960716312095637543299322573027471284752881663572097511651811613598957587604124624018835545870558611 +9874256128717490827444943646188644499417848153072863603454092200052312279880710501340245614763095671533551439274986414901802322 +0712116664532492284027602515056442554560965687688409213710573265303359796914199163349296608736358741384041138558244053035969858 +9693983191087651982342027390681525334777714170455444776207288727295047097906322701667199571113890318007616548536163726817679168 +6706523778360875477183129443881169868743369990013775836046887154518569535610947164990958856446973388802060554267647855673512269 +5862057420569669693068391429181291253874208771601116624815603880238130385298427887023332027652265710135551985724073597417285974 +1151313997638402328677281725415458206631525714244607205307139347412188214659490398369065819541976622293080801350270699351750349 +5489131825943276548129703872359273308252153537674522058679810049913479398153870812359217912596783251244700635734540612732369203 +3810123181289945953628771451906051867522552261199661987069529884844103683969181491185606510174695973406830793843872394354042162 +3346242314263710422512316433607417431578705396179309838772547308651613774189871178285455805352015354652802479496815910335754476 +5032059944587174601615131788722847272253927881072336845872496308794095355330608135957953660775615970673613290442946086962710905 +3407385896995114869865346803277241560730078573870063366755416777507927736959074993460049742600768481558296737228998922109024099 +0049052520096863687692070927701978011226142548782375715516453178031755305702747877694502859869129537906539333534520649523091710 +0991259574063512483397592194908683392249793361680299501959035992654866098958575700878621835330177239453007223378603834381079687 +1103177507554459538813745204571902700244177530864339036101223775180048578597548931452670546251696214644617674818880606435247986 +4019388020763636749355438098141001952281422670022244785922521428313256185545192914769702955966048643204981030086298329088086717 +1549239391810219717095199987772454895177623386763902046734720379092060908409042895882464384442634362486868518995850543330943745 +5263274887172899674152253042181056688293450964020128773142784973127071891058343458622006778652971493625047746423062870250661196 +2492300927820520335243072396524887229850551524757145264574209619185242101186100663595852135831547431534587842715149723823788454 +0239821705984933412196203741296576026949577895980132509651253316722691651055934018399445089497754941402505430183658650264000569 +4454480470480799484331207273048645656468167612178274351303856622687362159020726843169180682079344623827123515453025370828135970 +6142817374030811769491227966611452974299687874240073880283247099440633899922286466254504368749938286010203764066551001971357963 +9169371099648374900400474139097217260717487967105154156622253602791903705738661081630850020115390238371457432815879031763979788 +5560591117813511863922620504148281644660212448276865905578433181502848473767100143776780656617049797235772123812344362645447507 +7125601127543091335948203843174929841142906765885076202058923049770681372235738838189576737300366872775686393117885907972185950 +3813261893105186097817193647097680347436595910522013775725325978428043833139417789267610377229028363642103442485430761044994912 +3166100516390908023193075423476442023657276364366869002050485177701831320339505415669888608102030204859429175627661908828955978 +9494583112215459385851845969134725676775320276319447511947728695272882901489693777569547667119292451041697329224102769821139225 +7691777515996491255498611230620011375291757353871825879292337748953866037150788019954259501731583992956846734646612549716437169 +4674403391449814677760084246730522440833433795684947826674440906657230316614951017230444639014782979009506122819959837960185292 +0124355369267161692186629219979251945207193338015531285271750882020294586168274943975716404048435047057151424920598922068881892 +4259039872889979839195103377532319383985569925201669042943584292754218542022884377759029683915124413393419307275904131879991019 +1735669223208908684334277224397343396336961848404316449603849894027168642444303310792840158007116435560970914275701222063897926 +4461905512399641675513869110628312166872040099906116555152852234330620387342830937229572832948858700069818699059571737043133655 +2317566091257832110561031578973018527337285656514910017567896208598685109912802746001639928928505435442403312983994465299665281 +7100315234971800925514182498331922330287575769352512401970636582041663941571732261396082519132641394516031353060487765740093218 +9334108345710950934819716799864030596011645738530063495673802842261253827926601866855793893356025796840470669373855061371630452 +9938632519142602121728449903028585427271086908360215670337654867014624403654411514574585082225609074457979619906343109374814363 +8543685485409092161128411354085800792705928451605723409112677460751012429082851977989992688721655128865875431794910678786635771 +7286092726668793850700794820169050814700948490519583438078010079869324333131287831724247406778611721612540484173599614481822185 +4574626770701467258525092815137010178678255624898097602082268698327798870150981485054197815103745515005378748184630266101601233 +6996566956298539914158437280054873330111337840249130739283399579411421525420812145476940206933841167306808654076518530796691101 +8418268977140865314494741099167445020028244920345037125932530888607409097769183652295273473400544354104335924214164055029523702 +8653179301531871439574603212631671179611383475494609355467328013854637990353997237551580336715104250041179882078593885288177498 +6757096834181706624090949791934584516326051126444323415129234296822035888300651545387936037901447054120865724936805272897353272 +3719471070090385271298581540906250911443020297189549719410313905300350268160333497598330190662838247612158675798074496367653467 +7420546839654007142424912212795950734732168508855699265941182387494625335487354878640173067010282119575715050167662820992299427 +8999971488927790060730948508800281979058687995045352068109470869864835768781397747295222955822196732634803342790733054201967597 +6576480323890189237090109618880316708942469888066595108911237671288781962755118036472198419023002661197238821372958077703913188 +0030541257153278168215715641021711922462243607936192442241352641161941478602829260934238679472069149540374325351015851641339748 +2308535064234691761213175923993413124441933619616103905759452431159366446936203305785164404138919753229165645626046227853031827 +9274311478528593074600453989280243110143811549871941292371158642466286143077576823957560727090752083042241440289345317446749500 +1173344584450748636805732688311608479601983149113524409946668094326431976475189882181347248492781101482302481266734427266149348 +6919145353409181506683417908661000530570384104910516382895650835980412723990294313264588477866084060873540703108364930450237118 +5325748279790493246685409745464007302387808804042056122442284885720787803880628218787879564860434934892913815793329423983574457 +6453232382761168189611119093517182812167138336965744983593436983776900497001902946217406040709180061277827817549237791463409689 +5084186690867471312419665514325307095801242831316185457562663155798586037028408988187703062546161289787145296742552136882463426 +8870611874224684584815641540909217473850820482485529973916085066540438294865034479488663791703681082228740535939513197426568394 +3829342886981207956995705990631766515300196466846957375041259104048073176049856454632700433183856168388096468289412653196954791 +5561500767524576355366009997865394697845244227185393733933754620619491997202491015533470742012384145261633852618565246889880329 +6777844984653507188325486982839438152297369628419739121210603276755667853986365800165693953505799574103492924940759456778294070 +2214788746856145315547663790110177531050862742765653751073730521273798413515040644084618990342819820992718598911810035213540952 +8641245540354058813605493935866324134857506571449379897541736929598327494870227097960497570120553215541706501704428439721082223 +1700972466803583171420254007427289345043866532653318330426834471075577492940413011600530531542381075895357213715112384747031546 +4123673880740060770118806009141779021375877044026069684883815887385967786493701519196377144556351001736897028481481645941513408 +2662387772790420942409426074953672031980544055539694698764834339968798663047095391766181294233657281432203121874861027827377503 +3000685337077147654086746625753896686864534986031835702363775205640514651662788785826457436508900020141827996232430281971022030 +3024908258360292259670809665500668877816383415506517420287409766113445399746700536527732408780456759980633419485517682977905050 +7609884167715679957397855272558744514159873182477148797463658401514781751802711120892880095270644173320069885204433134067923423 +0014100455158046473463596055055311019866188559065450226001282429179589867255611231640796556419411721523548855378235369309657647 +9633011209397874287442661801560684815176053929256216322999478244794557838852723961384875065741787167826618848105863793521919749 +5428219888294008773249094303237486065991730028127620139643719301859855449270217745813940272539972852306476328220561773494939103 +4521537632739898925531910531504909038824924540851609471635849282948417316063275786486909546139512668787750779344864961591530650 +0285764732059028849862258838048464137495797174589639632732738487543884739338580280553036435526582504329979148309470441850901993 +3193744331770081476790157034764887938574991726583896870321256839758584043852505285610942913104942834651377543523173599555843275 +7417116084257040522072018694176431604709041564144995596676144624737792695410277079523480490262409478745371723464489814999444924 +0087200564277539488709914626916914001557170500699327915642055990350944184767970585140183066326636283502929299531353689075738930 +9142572663076266551791245195307340496553949814370587843903642543965453293671993338189766065010527351493298615638788367806472270 +3051117521339185890745759762693550854894691691802102995243849634880012010573871449566457109934687770743470466412945533888196288 +4158491602681925772695910708467090530134341332595220736564785569416215771589193350272179369165509097131151416084829009479740145 +1103853287929082360008599627015884781258703830958532256506076724299192350494313751000293453841630584783094561339455205657099017 +6669316988454995197629701325242327637911706551201433838323166461015137492273818007712193923739461699066479249555708713191227011 +2113634008934694195638896909191311796132499125975665209093925839375449400491235035672664100786917876149509780668632265414075514 +0126792384563810279878665722622429577480527747103593555729429055584348852183674740137123973052149872227487163624179929217676754 +0429035865573402523285948804441336965668748085575713483346016033116457998360922288296258888389027618101688101669309692510329301 +4327425318090553450075452219201170395108911828576562899226660479453870050953529030012653173886753094327406771671224243820895023 +5520772008782057192477714645125967892355088889936328957302124838926954775059515639556003228522011635026617680256545865946919398 +5091701805891827972817338370300267783615596474978619035655959815481776653782092336443749908777349150397039742672328322075757599 +5790089502501043722549854203882262801131152082075103693079735744546403353282880501020065196803852275180952587214373981006637291 +9796322418193084084142426874342342820014220995329829353218013607479946651207097461896332568716316883980489998209799290426511423 +2380307550005537574650358548246683232060877572246000949898947779365886734692122861965160733025000170093436288569747823376036955 +1082935962455046112099818942036953428151667543776795511944294244788427450015296441783391903107987172541886534905100146388519657 +8380489382633120509090625034073608336127658262734309778765867742476489991527857117594934853404329609845740341120593238746572358 +0633586457978329098387174811695256037738146638558272816343120362030421967763476640034051908578551893496813666553354240880945358 +5373098216766144042601726925416970539214195693276289721208185447267076741060153916852700809475592729479267755151190925441394762 +0437558873199426030384531618231327018631366219163826316141114912440580402838580312314548478509711368795320884000345769917178052 +5639423930316613774685180001977671844817204570499797609653987640525926925309564084656003072725353558374445587925969239833796829 +1210135977251946489323174272650887900867086890978166723808871820517325894679293066521051888521481265231417131690626664853728495 +0539462898410401286175566033379657439604282033567012883413399478842279156974842259796901368805265470365140797961756617874554244 +8867613639089241484274514628778139575529407010929548231466056716290533770512410612299882134379199476168691871070113322417352240 +4833451141363445314543208606007459133355986460223413209331799936622495058516670427933156376684533870032838911569984108849259357 +4227813092685468088212208364841572112496680733745196711345105782294865361331232982776705201607924522572931046426758698077037314 +3298920484699256928312414816543062270280813072616261084031990462638788100585936907797010649601422888227353971911450080527103430 +8677297821634129486433214400771371293863980023792460946229497228182272173859417196509074761854532992353908622744248599410546426 +6781620363930103389596792660725581404654123168036180688431615736861252151699433810032668453228299140054818608750957825124796595 +8122906022184441989524946520995601380863784338127264956306250128205898953341684941467474429559908562531894365353100792345598520 +0411240004527716081891095406341655736648076045216518268298111043258024354531159970495009766409513979584877788837540685928510096 +8110610731150417715423694936324187409013994345563727775716872413402896219029394300366269945656385788061342489896665541029423618 +3755150141442065122724114186286854845339699980415816422951602029278923264626041281480497555316143381278936597056953084064028022 +9997198501283363781790158682287440631540353151583792163912187892594225150451760679251039984200332891341466144376776153588743411 +8117278660244194155818259161232321467141273951036898758016163015261776236723767428479024530348209694127274271155128147667928805 +0936167378563389999940015556970429817708525142859666613441735283201399969921725036498088504412772933143791841603758820099231969 +1224164983307664154773003073878449221074064106296765689183370554165942272977254560731754387603794592725273703193699452227243648 +0945223186347621257574665017745770814803043072264123465865881332861490934432664674134678310921895127370062396231037904388566491 +5578757540264948131008953288936928142006135647005490612913881156326258717861846071301620618495929699330750590715333343381570370 +8766152138213724166896984751062466183413369758646701425025924527217037621942282338912065834670044626031344011383552551288896568 +3053487311706357675549287442389024758844523549667853410498690516184480612259764698839374235801509026206625335813997095967736808 +0878702145089270046099454388880300081151816870001049594773880813882330822460954086402671799804568587855965385027526964053573154 +4675804956846633737319204649690805027179329770063541964923158992410097311744090492573918964775287855196910884200372242948299414 +9493162547793763389979831614732404846665474684277822658912090008789913594349007683276852208398902139951370774691434150042517692 +7345730422542157756414350209374237744157462270676494668123673800976571405254566784526649041229590418069453350314530822807850416 +1964598394787617389494252382959463826235528571672258679974212194662236832005305369294264438079751870505403383373187745093885686 +8249944446042573821740194113388700642890510755384482816288425486723007601353010761537384611960083168099219424928983664383056396 +3337126174819661239061831213486837993026986769690178323635308622147431003839607372786324521326222541843059384926020501381139876 +3550125336344588588098791695947139914704682212688259894589141433972450950443922835504195392482891358587151935390940488550833886 +7749712101826086175922145824388719830543614893730681609524662863877518177721578349626789661635402530736054829364302745002369020 +7052231140791673822400576065079175225485411488088090330405642998541294857834801823806307475957421894499261138427284899379872160 +1843292586638145520787104685467083303977045950130084986120058743550949902430669077350548793220932862849879063881005931348774482 +1487754184031131275500703273842524528318488976791651801275003631033587218395976230647938697685183895874331282612016119932243681 +9443865463893265996646234621765924400556069796282223873874118161895663217586723720163197972926787252465189277090874867985305943 +0897354453697180183636362963351299526862015366834373289147517835099724224465741319067052046603751698502499127219361448464402391 +5704747041899601180624074915530540633028597706644514489974845238123048510465569828429534100611326273262355319658327363672387706 +8316996307878784269659645906887598359322978350217418291053466278096200407791776549885681670136754711514051366460206315185892069 +4722848610616728633370187439001656108169740264355894513804107426599369076853462061213905264840303368831514494760256744683488217 +3692367810726295806823047818393633700597950772879297341267237845287738595298116096169937443486203130496785989216239853131904645 +2667811751880900529395751251780403233472004508704751605995052039171718893677809009851286227285227934697321953881347551922850785 +6909280644240056221753293916337855667825910341176418724960272141306897770589964342155201798900696411923242239316269753447770119 +0999650808847959816984860421127802079006195715319055574680057716511026426618826912583374854994252722086849395905477181959336308 +6682428165643537701794115175085151859549462586484758294772142985146427091765603916714315410145159899524436580396471513525615313 +0287601495196877948543109041275994870460190783889596253917385102642407519701386785758190101150573237633840832279432894588540853 +8953039640516871936098610139590123074456039528834700886251621001651688622097083336798736244961699802438533721144359429291546962 +9090712409265567652916908423800558494486073728012853735882650836864723820428807816418262790577395429269519877994493798687893365 +1660175388130474812877157640023025667491901812382385258466335889928876299301453437354017152844077297406456989761054934994390342 +9934657654239690864626478281461559020855371564678749001531999572350068313050489634121119934441378970500982348402296361517516343 +6359086489575862410458280767790738382982543594459454924194612177893193423779790100018577922756855011303081967830570557786235066 +9627300155446988370785806212844429529453154177930814144914555470252140016234923123986998575098139584073958387735640106379021856 +1431322355214385540867355391544675004031897330982334142717560574603867105320387323557316017902469957357722433291210791176477230 +2894506203039713875024969465668820869708991702780944843854568441944017095189870471544531770235169544173059692732034123691090895 +9985087463071783533894010510378579436608410386134175083499511116916575290748570942191993555978994826375337547024070760036740444 +6261306132531269467443124232293674590069389935930085698373191334535132795190967480627467212037239181698443751352939224782894445 +2120942222786996279924477488386308186164427794112389492451650285444010405583566731254920895180572589153915684428013418667038463 +1430800636064677716455907326084896393465425867531959255704442690767435730899236888138775592453451717734356391997983296892276722 +6245887023168571979343600695324609549057431178812999538431044619282851448174071578424122279044132430998592688952289021834131681 +9674276988668745718949139392247616305459443871778443070291211471809698194880071407948810420513382171773670397147925755783987072 +8396960072488524616931349500116793025065793132740236508100883299116095620726458675309257154864629749532773543158061852267047338 +4708002781694658659895872218532749075225884113621393683821853677375696999740077965880387656889715948194663339565410394344347289 +5555870327192777337829881158886331270254424879662205835411641384434648950116158681537009743933205450514200494453854527945997900 +7477629425593340948832945986684831020436243430891488737957650425170704516063535499519492960538931301090427592749932503236484184 +8423876423875909116240287411777889735748877901032042101830839646783823015629217546200038215020201848216827890202734808048558954 +0807456230133883710789676060781653192722644571250120561750361830812875165496905115518629620725251203869040049714454953862738741 +5303451865971911125648060457840129182131488705975454818569283523145391216818437057554152537823305765736049257100852046148635621 +1261116302127532039373528605959266607418243283938981652100937053779793268699698358833723678904084230346993115051100507293779300 +8426944066403361349421019695464969608724905091684569968020665596067769625988182192985084507208329554219894020546830342373194912 +9836620096551496246720748973842622026481410313119306152287268352751048064398407415273133860155815754408933010180348795503748753 +4609338756911699625776639967309034003047928015509904888467025680057353339055998784262880963136510735792422530687128803685177960 +3794220657491630690779260465220147420857430753103256706506076703567632175129351004805264212916552247643663829004772139169350940 +7434241221131032055118140342385838086277269231509234123959703170231052929402882172699084758826526485094213048561191825363736939 +0904036155468367437756029547852649525568053491591721559536888529587622171812488273446127650656057211625693401063929504404510727 +8594239813337093390867462989975908087174105244731466049861585875653241923202495711120654077327719056153590078128352003621088112 +6550980939146114945715655019872060022635651047970499718424015515740106255804720532248662461951505100400404921280927158680583839 +6741404050546354494349489969507458195999859785965336806692031040435145352201853821004643353403220778871762826594034649052903693 +5050161106286616149825562707832775275340760357578872487646716309800665185049903572794595588208600449320559114964177323489795050 +7988668426398349050514452498533331732900030359537800440340518464659495823291497139184592287414133272356549392805616744235453149 +9266075338762306748845630416478232159198106165396768656800162018036519950819645985549720852139273704724379986117806399232175170 +5556988932197330115132604542704979085477903108338527639954740461587257180160289420796745117217674397152069207476864049579397740 +2173348172420527062990485233356407054265180085263061116024667765176353870469789794863489543966815025332527451848905334447400043 +2653295629344700441742575198328366052220017722996829827117810780652298604720896185508927603921863120335461979927552660891307644 +0066285895594775046166427188466940243950248922228033222148293913898651489477743932715196100030572189599370661700468278120150796 +9557220581453859816276169005234368536133383160153382159372481458293494645221000658600106273797363754949138070903261376602472730 +3805492311138707905865671027330890704509145113408439234581134791375788711343962876719164349282530634198140214550594966178264550 +1436926045326544742314469119616902325996600826173849367078861191857896132772006881206929709595222480758410968732831090627983535 +1444386260983859263563013696700221044836992640755935489313754181471481261753184503838050091200730279031416065367564840157446166 +2902149047863838396186395637335864504592375088936920775765866174611877001827681253531321463980847446832448377620176627133555161 +4791558390249335499772225358752569718358080171845842601137108723166037557543519329054572216953276760772287383669070062122544693 +3653096889815826831439877436629034472435210543189243295673175535474384447647824085044069839822212271287638158109858092072312186 +0748574544351788265285261914954044165932622710335856937231283900552445994528620171010664109729214838117784033934235805145199914 +5275894527081180465946457660332530286653207667782652877623355615488795343761394166684000047525776778529177571402318083997867530 +6467109418857304686760026137696284413841248686101454431645726165291910757652786986378480149853820055715870646485922893256858093 +6676215878298696393785441082359744916852977084427450114208277030042915360587042453548139647735771416607502451093388273522788649 +7671054706470997891661682369520143839129305382788490682363534839812789784359519127806453517900921204537766515545890569275307893 +1361042207361371441527086792533736691205317414847988400835638938786015770536113548366581806919926001472840811854920801842703777 +3513103534581691803636903931367504112887620002748826537288400922168108606124444688399865918353400722960622289440592437281395265 +7889386408564819031497565924192895193912656422791697412472168255473833561450568882333025985344661645666990267705103860364236866 +4138536431654239332667925068305482627915123154662709208870044077990559363503200410357003059370208164876016094801255094919175222 +8463391696176344840026735185830036495571599978819527559041511392555529527154011417043582657075386914403021244017762572439715299 +6162318218961162791019379824579408557803275130662824155987476456514181881477682742571553987831058318649000691189597142635269772 +0762970133488857814721372272166424064692356325030921377174309564434883115428450738561984323237757935361350713032425828308741123 +4714351982559489932236335028957017819906944707422172680018267561533474486226912008423131335876195206249325093723564894293512080 +2816500946584950779938046762589915909515704971018715869504032011106342871269261795583577290967260307340084652876419981696310087 +2895004364486838513889537109545822827678603850445221912466809759993491507875666091568956682275842225830234855225383245575493552 +2650099647818037615116956954341655646634963643235750472739733468509790968870462418042203958941068786618484819431710507936599802 +7533481270625343830151159727689285867369942408696652407015806894633372367355011778476566950994358633971847804532262002525341326 +6932860309305588424128816753568417315152512711756820693574982607856846643933251360676478873401876049759834996395397442053366771 +6368418934202491624332453410763014824694322271983857287392943327020965722037743354197029665328443075456374222598320483575376742 +4282586458471797802238473382178433687724169447427314412337761093512867942490521429740324461721167516599618126259885014134320111 +6677394682606606653900300409179091142196198876169170096213616729601352901860163965806655227312385454363306654134273762118341113 +7643573234932937551595703701897895283801028602846877296702625125220327139117379468939484216431057135643790896852072143295568124 +7835389220407382114018498622358193237717282193191181508848234026347203068182480302817923964772670420825100195578203841958774014 +0034680494236515185913110737330886189937723492058708152408147979713114102686546086347368499582981596157232052021983733385897893 +9959931900795867812310134476649406402976231824404571628106712844354935633442704883886435745579659139240624317737165693276684021 +7687653483916295211948300957846886688394120859824086212655110896478780014654869246794209169764271870284569926071280986536129686 +5389201304796699165935771717834181664385244359824248801827481372360749339940576454594000410357902778074011200874064037958889186 +2726930691205319100949599707692925525547420349048657283658532712722412081334373160958039199607974848481872853703890943042973921 +7254087398978104571457211604241039805468739560240953011032729779871018385163199958508492807104550542120182914215024552352099374 +0577915788776618918085672242537299536604399259342051743390425673863630842390420280176568564228989365174973256614738413491070038 +6830892093137210682654019600696831217364160874783778871977883927322860408992703263164973180938595498029716242874574648385670449 +5774283228582139254923100205140724149936447963980034063069342493084827233283799090727386532026590721266521634433539903773672657 +8489342339836233604189107412549422519166707342446243631744337172427688799797300485425305108241084447320396355017099790987982304 +5579039086144583780301772101084268454284211524135896968194358624225126732215388025582474957280102865197930121676550220972263090 +3389908879281737422526309759732063914252217622801815648828128392852505613143446838612931228798897371072027044252222238376051988 +3571583131629499703290168358948884937302565954157189422433659984916252703476429662770576623285862465399735505261324990848316694 +9423186355018278041568884367207433805709684366572651006506138520185260823230823570755489649379382727052958581331266615555167678 +6126444225712076374139461277391085492256424369818965208777930082776462483927136117628590877335005615182912506580467844672001776 +2323186582401204627524733122349298471005163415025134564249126647383086521203590734419048262603709759435997087128843414545136629 +1421280371866708001926278928901318288694248295906455469958649830300570517830927222281187526547437638030692046413330135004977193 +4201689423423687675024635448407327285565295542200018160703811061939134316388397382336397162201256369493787936488029791585101767 +1265877778847130342563633758037018164444481581498122824054055477037485608751037801526946223069038643514687690116234164514587643 +6465410554863527094647350795029177204941109231775452235798798372912591022108733306213831496272836341289051922220644943607370174 +4555709604071919166868299016817656945294419168762671940808165674695761877170460702219178063962280901485563918842254363745508105 +0013210837712837766354170359690869396554185818181209225721015219925108353810498389109811284979505591805687297968690234266672264 +3540066879463905504617792447842885657986052603128773981944573151451301111933677250259888942146768184470087035596773903177095378 +5526250295384032490751656419926139482444274162610961490517202317645513359417017299610996672882236901128269120411948696682951298 +1147928498844392902179227619628807696892271738030552398135463750372457058220840887917423404648021366673468670510142397314290816 +2022158104950164034675577261500173802135526124382488977804744045573154829053227880877248106935421683250032295002832455111826392 +8408395848784043250462314109208469565763023368052967204488715596813441318603486322106989843882974610129619714497130039489786739 +0214994088989310972413925550111779902382656332396702390689823464515504633177056625665996413210331231059059122014949611785985118 +5638643037266704666895115401268842632588292722777701463135298698439281447394022408579092978979422708178801226855288373349007705 +8326215915178072795379523340039085009563169070517125775679474479863606678664704404360480187047960485640111421757696617713004548 +7011793090984794876958820884434550749243106407550272966012525399145703465211673094494166304978135466245182409167311669917812035 +0646616697055433264306514791141300386873739412778313053422926573847874849306566154499488632029298944379782617421929711377514401 +9297384752555069074761141370510516463922575237795983591479132397584337422724053423993525662073888857524562744276272922807488244 +1675900193060201503933483483504265157956265823054822690157216718534136770295979836197494827206847083365905242438375193125219057 +1431083489513661032602020638770515681536739853677363483613015298018233407875797334225693452983166033993589897236847768729569036 +3412842920266990322594256412420427432972591970945387529406395749977856430023496367881365081011414676715347811993981995507454759 +5814144158348481510698013052752762134884248303529348153673229587940320030719465454064415732294560941869034046035698546780721067 +3694293937312762744233869259702927434016315955447360677690945403418821029256532787548058243155743890295919743842535871205350185 +8704385056392271497806649473016369833786145282019863224686988090496033200166054190979749241314009880507707963024916288921654292 +3157093902990992972624660747840907228349704051194371097267625916545775966277296334446546102566702460108399894331979790861994643 +6211141708601791603941445199717151439636201237385208163393264036156546491266459438443028650233309419884755515206198073403412631 +7609935217879726233731421923555596716242460372189351557516117275999330506730738459524772217152788164129973955538645698104965588 +9847824808961328798019186709647321679530290047204083126132050648182784705034270305452693472108814807665149578959595630309221057 +2336424726766825888588931956562955321343032371214572623650620016457504060828907233038750693736196960807811513112341914628133531 +9997503724107344142689181995651896815056436454295876248977561163594537358114242360861284248276610577578928061231272901007371912 +2013755472268039887671228509805013770238575064767125406070391538875450803622634669600191763159687914916440803301533482646017516 +5799981996920369911160876482866900908859555470100550461338722440379485926728401393736777675182480925560316384661340355950830168 +4131746820931543634876854491169439418699998977639325418048790558796894160516876451374044889060607036066881936080985211558198717 +8071462893187814119459304307555930509471933902061826760709069595504601694208191737856286699434878770893482761009503838844594596 +7181730908337307386590819037242463777795080011670425589895801753553643404874388537396185083285326538843075531064088612600268485 +7874226918011033625880877484768842271536701038369116084490113476976040281425980324472775723714911411152630252812320962593721057 +0414263983887707664017378501754926805713789236380580564348508099662975168539697702344553508537455836440798954696577079098427990 +5498272997168152869729083312401990047724554350008563240202328869525129660589507428406050419409546123885174117080636577540661417 +2321805983098426879552953451815149973073351984882483766093075912871745174124737636496091875961776384678278562342333189413446156 +7532047930885191527458749856036064187500060909405487710845907268217223665450938676158247000950256593423837838865029236735406065 +4326287344295297838879679103933460283015103512394382866450845885799711951741393486898208614864273534333346921541450681108663424 +8567495767845161425037712088656492510273651099963049803480674659806775332933320452431001042997191274150089937218301268747409008 +1892491166044214033213915009098534855928106088594182060850901874215590307570900626843004514029616915218847005161443909006676086 +3105173474201156958194039816160955452881468075916368040511971709028208813038518932050264340243550030216756906608101248802881284 +5437478863331533890468364414134511741947560918971502005022258558696334726057777326125552089511046269814814736730962698056311073 +4951554244048858298258123156812226947705933314291630536799208713986095914743504621255604040168912151175487398095913442501527517 +1612279415688868683265625113331706654838561784474685978138326507909792993504451472859581305912676732125668231491237540161852687 +1352117401098609459260904440848555453118498774861101544577811081137171667682199549961162875051222443028292136608108908775783291 +4668566015341904293075901042719184643021339885314119600028221153413672044545251474917661767760069310540295768155060202109602728 +2520334200236839012091693839792035322503068072072460065591632021254758742371667902074341537861212278319285847598815912703706243 +3175268051143981660033747106123282192419159048635214903634052864839951778255031756400562020446144172393222917501787673701002700 +6674523291734748122422773809147614700484318146175088254981107335895144969807349660283900516719746118645468637821636061386059378 +4188188277626583767786502184322569089569789412892621297176431619545847378700138574560707680259428721989759555839556974186233480 +7390532896972001905316907714622971854007628170763072962479615247643615622571558632228493177244362089074929594584800973845536848 +9849264610200952816901406520106384682505741852721568226048835135789532787094701294801848704745256861395407908649513920150263639 +7854370986367091444291966220372693018093730764321979930716154354135718272983430773038337101141108835455952869661500155683833074 +9808115836250545782744528663456612751035343126746511715032833222650951208562936847133894670903159578406935434899681616157157677 +5449933772771897148631641377562540641640474848389783754029100557570032554566006191465792063723092795517702238425793412416470001 +2937905058909924731783049378468003437910238645835264792097079136587087350442777867813702093887200643761896159097869017005937395 +7717133729012763683884090295651337537034023162131283487583227409327777370699292346651312872193008211062413650051860746533410200 +4095695950110108518764643338298928366182339223897361738328378044503564041168430011712729973754089101835569129650304327287404972 +1174584897511466194183788253926349029362049505536254582209201338252575420290164983455933289840278231035884030712260894346134552 +7761765877961955439161913415420485543948776016504802146528406434389546215574979243086360938551004600037990661153084242444222743 +4353062554304250531566068529474211745999775668076123932253052153101156786485645664269792342453816897835171506547074839704777091 +8193385707206057241016991296332616186095885707895014417445978963635638843413167453713147741250557894417823842378892716883564383 +4414701258878541571780503656512173574547903536405524255843710113697817741762054938128322216548020454736882148058230445988304376 +8363544420911047180282206501238156287142986596377518728647856328365181602387822102287895774281073353368828111014956911375392578 +5780430022747871965685716392391425352083934583867099701698503567269032511748940082003282777645389137257025389413017452674572537 +2606024393701221307694529871431154164540614164993497271619958131424791186768644684669356636777831879397734272673335705649633002 +4789715983933276471694982923444249864558464851612286765926229253919876317314926011029164829296322542092827015562884359904206642 +4213428153587165381335521523932052241841163300973801287138253226845490672931816978773941803990440278669979647051465348624079105 +3419168581475572983260190361701934633564914249990805271700921787735379441310149748846950460105295646015883522763651311765718139 +0643017584581435034370880134992336308617187531872808223433939732921528795419567765739615646487503731718827467059811489514462708 +8240926821672036119484675230474136343520006840157742512260506574754560864426113591474981060698558545401924390339201368669580151 +2180431409945375285121040004138946753923265119496541829137171528887590486854621739462433884861201148650039065347599969036034946 +1220794484575763660002325630268586558185893116790653322219525972500497727914800636242536069684827121496593553311794674511534108 +1435781606190730034271758074654507450242292934136120417582018758847558210750517197211614624177861297537749923102696299059068262 +0472496196020370020276610485121224239313415267755759579734483426439502592786733423472402917351281201878422928096327388672118427 +5664545446808704741371688000935805171339458791507069541059893057148797349299303009996748288669321167515451714205892864440743408 +3539189653746007637884781151821846130210806166359445842675385724193537198834368015119520365512286626859121785638758771673116936 +7228747311262908816869990638505266862436414983330364594232199408818881369887998094729811275091341031498735810192826600585848478 +0205817711643909986528303579098875467050350065610591795091066174715779956393527864740830714556714738435192795203670003124014759 +9197293866434029742096641108142225947219962019182256790387923893087254917713809995074288755692595202295289706002058647970706318 +5801028709225408662416729985040929435165270531028696258985082752391299922713342941633843800570338856731347298583819618303436452 +8554584149353583626116529209271190042567689752495849141906628210792514969913837494587223513509196504949988416482688661169416704 +1402557567228850127015457900783688564010064141030969351494178978419198543363884975731636660451573493841983931009293074401767946 +3030096749835569373371333947576923588432247404291305005146406298391452901679290153566364898274791521766815033709118309495674776 +5711698251707518922789190956913393869735623141004406498318629780886567378932420667481352170410684788247915724815490088304482484 +3076891999474110399724898312925906240059216711193634437769661170118805829580169752019184852464954183024109801959695130678652316 +5549698831705307512844145517641207234201273500862193514468462342310564088815360136277681192006596458241962992029526454841238730 +6411622599480809121036108851843289420809827360922656655734346202711742438003990222191272251022816208079113097900823895134384085 +8642218596518127375568301272202091207693967578318544987425186514107159773089906580986790334784827799489119999185876094206749612 +0920817351118635692704580562112859516048707763068110821230955827967708140350064043987570026933663880446183554485511010170742288 +6208781018246003491238792622187493762169792217017386868912187285653248963115594278272915569084370195923738619149855997663765716 +2725282513427928049648973662146630492856487618068183730067763515357833597788940914019736675580475997314248706127026547890194380 +0912098065082008833983417148631289829848433926717155189805055489641556714887595710925279228500591899600062727405015074732933183 +5895616117549258380703685066950990019495929210886386708101945826998030626417636766877015647925822567530097432835311405452851781 +3061662816058323226135782103379493145683394691280827163116839270882202901941521202335712663514020076981153846416619848715503675 +3704213022599283410938645199398840870678548274677230864636710751729466573816253072905154246398964963820890925958414003660031502 +4630926004977081614276851598024033198734821505047735799361816301169717640380369512425102474864033576302498992022080746889954455 +8300690807062719013236716321873014112140959900671073008576129360776883572345888774946590273926184154530838752149268349654124927 +3447912234767016528327462063192808290048544233618790028527492173810076784214345126091690768646666027973848294720038771161886178 +5457890600658613094704911994422834789695852986406564746776631261869186614541778685993675186223192485017919263967183543307324819 +5220338990377375643418843097310570471194246573225298484773451484736001523372710934922163010657077255170019875356114982042678628 +3627624529201855124798528837400884425278033564368552915095248122583917121126951781145851039073704399808416096566055979179720996 +6138215215437842405346946457258803271828305596332127664808930703097188386621950424243497121232196129953435128118553466623324068 +5920381194124220091735356882290501723032521874921419228504863143247804084726835859796865644318358484363167764149683837216715113 +9615036434361215242420376195665243628638184799766269042140156331651635843944014951375098750172039065463946417568449326243598402 +2848169979084951950982695318867752277301100025960923376831113692149385936857810916874319944880663028251022532340529140647508871 +9496200698078244875645144567349529530108679183666387943211721642572053750534478253516851058589093730399207634528878897274151362 +2928780676487223500661310045048476864951396027388478482164226318809641027170548978608486524888062863065934362652787878241515138 +6280140376322091582258435509210383633979192424770386485640747341583226684971908322655364759264755383681296473387197771187476598 +7993834385710389281257683754961049197160221786960013125265044154150064439440391405850545737192660609079271627770663100625583357 +6072190114323511020360786591498148692349156157375850747362774972374185937176303811511475665210532862701141979885066767496308496 +6809986728266957224821129384937931767139546739620244968569547174693124128355961928311295430759387663715690541708892900136725621 +8713302194814326105418406542612287987228114780045964567511737165272440568730052294690749670110950977545749571399774020053301568 +7216372973252354647766828421771297596834262561708247359782436050128141372353679212726164448161015103612893738264244644610968102 +5490158565324437536585310937019467679460278414170537463829112562515850928229747475007728895628087831498962809803771938282971625 +7508575669851979183836777758657815365989035447083239066619058708444094473391492540134970134555418935400444033568972945852753572 +2681051665685441434594259287440247146082524888648989023037549139977692642794573123372272447282566487899476245382067369090850227 +3516664349028783594652935471979981657724225297147289075312362875423752912404004312370632615551263897637065247961679885605652690 +9466216134195188009940680229231563219004828730503835830166900891639648098483491041893870240357033427709041628218884025561211450 +4848574180102172215721912201870496816515688173491866267900855346017402326765363320124474261873980008204988494006538252079431490 +0175523216285771758146998384814407339456495403123042145864725622594607160861096627528216923235632801268714390775921555811885643 +3472489136602420352765486727018974617090254641528435634640334942425890346384541194932965110314503859645146781896767507525832148 +3797532143892746774112201800929601204074380314303366575611389855222496601937222584569281001864863917059035591510412512996095572 +6540831912166873834974788036724952907724341969947205585823842409980011722639587514582627960169448155988074691268777322159243577 +8665277823830969067856126267665294223334216725032631778088124483157924821285251588520602045895388804877588758409591955378022156 +6073508435137376529408576041907918073738449051031545977935509368280423831551346121480713109837860058648169729195905582970167345 +3067341878979134838523394919669124325563435281537910461171499830549480992384643061189946199980549578258740383418503347009079843 +6535435940186811905537955923044494920097170641355108274375772163581055863892145187878626476077935978473720854007118125956368393 +7039488100826115931812511833016243383119511518291750301509797980336012158668128482275262947277553272940357496952990711563149829 +6786417640541461059254040553435360397444650993725507452127477820766859236159070974204514281362156361495968903161994222700825800 +2231234046323964842602361033236684311038633571563965762668970125159431168316364793191351729000958068187715242930876778118365126 +0967020148060045963966458121640283348948132407097784342111426011211692372274414489985481236783110642969061229593384194970583663 +0518863000584387454760957529314643812512823643579550158516331617073251164731368407116086238782619225015253603821594850218277314 +9500480699512272865605970060364505765826990178852739273720908237913877224017867775678563171957729835114722642208632758208282247 +9138815300684460564222550599375232818221500256241474012816587003367381334232108533309664763635997507997023730828738583077664669 +8788277264997082732015978733262501251796460091814731315709354222338224334551918351172940509755714499856609104221032539934398062 +5201268981606265439495692981057225390935909458631770334121087316181673897848115792408678690299457980695904707677321358225662858 +1753894444989509786731779001286291244699622264775676367978135041545186928742736879462156569826451402964970455781449463407937916 +0502111951096040580120210611615484977765606052460541731989539917916976249725653281972573849533515652151626503088059881052346467 +3880078154575290219658231687424062098862063067654268460424536569017374872824177081255701341783967148208402475928724455704261768 +4392256036256639333393028072709593018903870460743710545351823219115495656631234924513636506499865017761998475934414247147614073 +9879823269518650692917107025520590107178762204459762006129828636469652976104262657652867426597078219790167485035259125893130526 +4491505097353181156857564911252591317148670618490859288558887139051313551147429010258650026546020137477020225229299116254389267 +6985649712270923660498384674089852650962875340575045596604964662128408959309248980968270692814095597628820086983662450615030773 +6856393844414418123694511010327503283724147879193562418774164993500731367874976787177535887228795026180482876909284579667315939 +6933319890504711538399213021011090982613851985557386817639509779738587337666166285748238443831950809951451700040304637246662798 +8972237565184004138743415214250280650420991574154677063216686873786654244381615346208802365774879184715316421935088510122029692 +6620712954831004627906209308475373401688370427674946161939930227860450185388905612087218953668667006558048824549749639289702982 +2252979368901033426647735610872049783979382409247439935969647741186385842273253355085952551816588123321471149874812539836048112 +4296535534263007024565979896369915411490254323267398694533004344505948807352166933785377686738429645888455485219163542489241753 +3740204196364178691705296568637646938043711157073683455458837069839389554673644717418013786210053159123354215579725572298341488 +9402853270709855032434056268150751702914142055269816941745088351607954708943354365301302743628246326922883750858759728646811815 +7702984283703968225748705248163911320353463996186650929366431271533557842658056577524133407573715263399635592058138266058468047 +0714364441200044139354320382443415251209148277388628504182113543224388038221246572844030594506529807381529435302712895155562998 +0439249856337395882945730885613068512496256701244515252923706394988734280606704794447812748091162906835016774939625011625452587 +8701684848748737861671752322431955447724661967607517009813604790923987516158908955881849157986515334551799664962438730731109340 +1331695486624815425190823239475277990544123745272288937823732446789801006674641059010522745250663013852871097862751638189259629 +0016943722810447477028299392663967547809929491638369830715943306970577569121839921705532284065788504261357162084070598074698898 +8301370408134947453196729774027640676030589016291539644959237246218491449189371838582480346507102754824929019477369849852385466 +2141296007314745921128534279212951822200061786556429858733058886029876384472876002241385397319110771995753216118435172891077520 +9778033995372614700099511429265411943800576787023724043391866778854759353346452408608492285235768924255415140931221126895275706 +6825951183619818611745057594180574765846145064255544523604725057011807870654883273137368630387060066151211603237021909384345606 +6330524686796934177420756525152826921339672339044318925623881985016143335928837573713885535605018904858579244102576335089585010 +6476163553560279805504121578981537068558170447489713068606370855078339092366601341950660196338341527489856914865088585338744059 +9336566578276542977779339876759708356666986167810967015943735975240831465492474205336898814725322385265950743359319117386285955 +1003736656415305664502391530550831810874960043692083942495595913831106487788016650162073804988081719551806867379947943364891966 +4573789346107222063252149996048100164143705560186510044433851243141510350751823081763496713992637129016266999061673393254758192 +0532366470306788734368951439658028825164454629260106890282620855033982533015451546843353901652120510130789111458392221784617757 +3253852880221087799999614626290882768972817659832607861376923098885595639154736935283503251479471872499871522284582447822302040 +6285682722317206257124522813577367514121775302484636697810948128394195942996079881830875566043123925277038343926112033315427349 +3775226925665315936530276286731605375257672911376828473612175726312446039948354980701402997357293119532073936998664168131452515 +9033989479402366425600648174316259705202840220576987680353222246016330572206033521947195443476632332503203414941943726000075449 +3497459952076058462828783375726894554577596495151945532419592454939988268844456907659575363299273992966202955633347460395801503 +3425070812671430759768577458384150050234482462127557226191091262303333548668785285283704391650036078067518873006221217224813250 +1772566105841430765131974198596141137685703304393653624186537427347991201369580105964338526460016536799639038488848966636423096 +6770176829068426450217510320589346020757715335312260267538371974073805419798173049507293562584393319422383700569196675270010649 +8817107380879373164458511189191184591118659927137093795839429896643513855977855984835472389317216929700259038397397174527984545 +9182176191236023496232040243155433201447895622909243154991531577802143936144665255362367572046313372242799588041424257757065202 +6776868876338528332502171518394602792217092464624165442452676081627495348032268487133922812426314590277917132179444733559137458 +2894505940700668608956696393712351416879091173479440509500831009675626499007967467374789971290965256917798968433095199887640804 +2933556414955828193417995654373126786599609721238527340939127371332396349156901995803794360944816870450892560704118441975220867 +8553706670591731040619297656286157301262507708170329674504933402137245881090232925455937213553504830839742590855235282434383116 +9795978189578883639204205303262814903090980902741535992637415797011196591002116065669674171784371634354111486560182744790314795 +4119132103638186216017314646897106719838984255536083613903341238051086509058863316947216192276628486590741349320633205188806897 +5670698885913664671019828424294908157556037863822378418679559826760134301152250392322845741422553340998938758664406467756180798 +7800330341660310724142951110753435998016854748165017611258286920601003037645494210716339815788133485140202482683448446213209716 +8180605035942700911937960726293062276511453378796626425148211321573098417580088171144007867547815289216240544844126601589466966 +7821272307041782298994133562164496850666805515425583415056198384421212580796187662587737326754702942280674718201253410570348983 +1042240816866808878998548317060777151321655529169893824595029339588028328148179827446446643616423322057981572730612868764050015 +1252481771070461052389437601673649482439048233841755345725688472923079857771939132303119904339949419801565589936559095363036112 +9690992931777916802696331919514208983516033826094247916936120742724743873182994969726283601645253015955852055017097669830871832 +5020330232719825823684760306159154637346729706124058199917604069885798242234996370123942691457916122474221663868046994104598933 +3075139912987034850456516141324884611162536977850304751997334983975217864864834605427571083113425269670859785386338318467147612 +0588929507981854517277972648054247858977149919377574480251256787460673116218337687478964763305472549592601599187647039007311159 +8091499973422866102588159323886136790375349337327388200287148626779716184548302459458465936817938524771802569873742301251650117 +7114931231277684778417144640504976098202413303636808727117937611520910337365455884518757181692362707318939628346107928380267487 +4950235887683950624565704360578955553783208046483127644086525832912071037741169842458625817412278583829306158758057435134618696 +8199425955265652644399992914133529916068954186792582922740480043066932022166380883075792995446339961281184510898029007416993672 +9600726548050421231768431078919064425306219469503912968092554459127359674333330276775477837154780938957377807571696713004700625 +7295599369136487293154800206051955319915985280570186743302107975100582206721744471004980480977594771538574498512856521123216578 +6297798457301239668561079936581574605258366525996359269984364801565322122584365843225724581654618783605926367931879918225442452 +6533005631078137948109852121400341144965267577414971222703110484819122046478368287561575133762804019638669026806894198861867537 +9875087635268237028446411260770380453643015454432015279985047995719605753073640336797720945754884595273185611911133456865738261 +1289442162696753398201423924491482730765830984320927644525084976853458311031303193411990973143614781325043459014068347046089289 +5407587059442212092113638721767282263392344800170580359252927060347500966261590384053868270413268344224069405566567860000139705 +8360711621827142923632844470555921440996634627172367848310520969393805873503222609811062308946619951688125101610027026987846081 +0944723049476073716566027637737569127176067300129222186002435041592350356420231369282460258580648007773781925508162225156920162 +8475983626059931171149310298021646566523963848825823192493400102745845807108661239544077702836139330088359628977689491846874286 +9167471361458822389556369913209606973474148790242038515231761016355472551050907573614312829544645064709238887157780557241782741 +7014298247554687536486236050770971039248187073536082362810060976896826815113357515444053263548215504897920396644014795535941249 +0560999088691723682614108804238530988595549473233071643241045493910124491974900926784898185428410219894939857122959475910314078 +0706992135879838500099998224229773341412566822617554024599579881313516475013871821845580144033844736871959630619808210884015298 +3257284534077293882786787542863570138992146936142087051892058183105267975351672517356758026095332624891123361507959805527300464 +4074440343205139647276844490970010808052229358468787479224053850708044118534407822903344480715673998402733320764968913814756460 +7541792444051749131437550370667287159419463038893712135130829128921018730253201583423068101308427818790061823168162915307740555 +1517558628903132612936551305596370414201320454890625631435775037687907085643182588609436062805330988597026150223859036793476645 +6591140085443467002438387440547002194892167702007183254656681949652141186889776360123350307460795672547510863464622633652798129 +7586611318404573147896264171755514255213812732114705872658268827371541849326158561820698871403138855140301594042187495345343587 +8296969079616469879346007981374601146907653922591351081026313152884017339179855411584129459367820354848581380738645777750515335 +8731520753126192088044684618604970364839081511006806274832524720914395021711036520236353757973882463981033460910456305044738117 +8522729809358153390546384877141395094866223397312997581315815377215593011496352023911920483284381829852239261360027871178466434 +1761342609588366253125631150586581982113849076981180786682830283076537811478367306351425774976563602440271445970009753618288192 +2190966255981782407270090701820316391321596233574351800067587131465490412933509752425381764960420707947936543904169527628499764 +9513655081411394282745221856716659032453348163674130701896927299389413958771625248039619427975826651601280801943472380714643137 +0617514295978753057337209914173385759751936634152085643157967813155609425512280471102235144051790721763863647958187237685008587 +3639355491023500583172147594486316367021278514106274611239107265098592491987675254836995000835549078267373162122839134981244694 +3032030608995234928881439477961757003027720355891764881759463215674265954842081986273329762678139617217680974433220699552082278 +1162323720318256232198753258939220028085022540772566418699150206741508982674558652349158167206478285853624098497667218452569282 +5449383863141380776369123912608347050738601579475359170938129811063143046219515664348459639566915361115334890006657006031842097 +0352577524785516785715741803748070461694324222115473415680064156677430016348738412256655844328208932407174179588633693022145069 +3240824351920886083704779764410813380504193208597077988968552959949184540967132284829781189340533621232738907229081350464536533 +9963137564898255760485048365009768861444430624328428769392562608655048396702090989488644412080235346086820241525013306324575413 +6313120896902229376551555163469139342705609183907471905448131939609829452611107992213294654747615543541094148280055017927542670 +2193326928610645174628017287211712211408683079421721839813537852939457890561997238125898536070007981217325358023811789787011723 +8243869736268481951401784440593310926754240433539070013976127357814953175386685024013642745787559590618261612069606519053423542 +0179110493828168312231149822817828204338127248358983471224771340698766448231962762617835559498180861959832229135237920163613151 +4787386815157272287656433720722356482569671165537977997843012106191355180546649834098738516604856452092754246704403258051505371 +0634701773994997694376147550495812360818423051628930021511577756465075343321034591427451854134383867627150784580620161049855432 +0766676598258381037189024267219785521248498516810290597640526034223344261052531930836169758828566004912961881921058343147697444 +6482511785125094948376527886610692241647293945078604787929517099856009510498982203730650348969745313708621728477885759515338493 +5205196085155489849560658125068733947071196666550006357643461400687947338189762369344420067691692171235090223284004207347050790 +9809626775201561107404043309301598988061425083419682730787633868247584100867048954636838021112840948572297116645919603622359907 +0822943415366943321888436141210445288839456758217953163265370657515497810970631795622846252681104767475177503937782564413276889 +0099794234571476050102251924980186262893747705880229668101192044145818046711997376029940219465691893053496893208450200931362078 +7338980161503676399103395907119988361285887220551606875942870878016149229490400212073840391368478482151725734739290023095487410 +7899326915683751786630813196982092775796371026481722729931635095642264999233728389534905015911812126591048864589797672830096696 +2751118177471534985294175817313968889734356500489672942275914873801559720503551024017816293024629330339229860581633938440765263 +2579409952433198069628120504384999886282779583918285844878077794508256550262226622072460752726666294025165627679376513073930940 +1557518549380248705140615993858146675367318700594928368305022009826106738355680320673267541599976659073767016002316705812605118 +0706655774414337358133841048392051795234166451755892548200847217249090290629891786004054678210061272314883459040459769608941760 +1894242091014594788195514987048397793320863358408872612791768967887371355399390803287124928045545098723504490408131463760999333 +3060272094521186414251733828941054176318890330197109603090531231771409739699564694060282342629340263255630493316904735659002049 +1028815907660526325417480678219858187627208188992524766305787455603486273947607751634385261335594552079352038645485771077029993 +0683468157651545576501200944305620051155390867906355388005127965874177601579306536442110166029928489048442610212141268455617318 +0988081700313980006604864032962026305268670102163784987963985127384885587927642407664223367758558519122248185218742873483956807 +8435692954315269375984976106264988536738299966701776101047442064080401887709348151446333391726616352591853741366988778921917957 +8956328839854159854532673749984321247777028190876411555620913589749860701945785300696279975495557163768982684990843868186778431 +2520325381475441756157721367873710939223796803781885424158254911912476533014496257166233162377942526340788173572154209732321202 +8180099306765466453860728219641256442389031828386563717730489464926442454808958172470108839488494541309400369186661157251374638 +0628247148382602252920534144240581556722670156430583076620252695866327968997749969112676595494827895760196984828212360640034869 +1083401588117745555669152288505435653771338944376475705488767101152826312238533625308441022273664874833693060276780849703095095 +1156085057274283778724094356821366624982478225088443694900412624860954703963723162086763699442272343649549404340286403255643105 +7910121814653271873529362722249047841930063953194714561480180469523505989148782328178679381325533730833709002539304255163521040 +1625855113537607234401449098110230513476322963277630854102799933050565678807805089239388422442620697922678611315082884292068865 +4371620713456528072846857825011777710835705836437187394614071662418465730864540826899869210260117229659041798505650538477261368 +8985576750846387981996728278040998786610281073838965731512714567426037576813755214228497693635971824751946973019990502558550741 +3401249486943615979298276104790818107736649764729969044884395409904447217117866856126816079991915988836153438356752147841144170 +4762938795985970542856369222277414531064648102624695688826552014393694646959714635482411149329964264665288374841117934547255987 +8266183745098026650707351627828760547702165330658530132998099760473617506446329738701905894912433667123567916471538563863907720 +1749733602645901685261363936495062217041689057898136406969925562689807608184144495204588063954048062251421026224871438707736424 +8548102168448428644279598842714118177587767821370906237000294038845928905112282335030976267725288843840126116450813362024012439 +5938499597145637343173003399875431713125443282016722261731991805628239317480073706051380874344456692406363674536084190692646142 +0730500561374089587897509875647211800809704761282604727960645054003482860298243507208373227297725664305984934399424216469588628 +8419154111597746163254112932894914530620901371133608712199806376981269451117389112518987662727134188058972066300128519445766440 +7937806580759161251998478953470159484262859343028238192145225348422179576900021837242945100592904945106701907680168893307572302 +7516873429370795478978284132360296301129718931677825172903818753611017830921544550227392257770205145640364461713731347634995836 +4812445494938381664839724186613091405433366166945041207304600303147241282114042034521353097954231266436563888803937496834589712 +3378087498752524611421562976032943128888258876939559646852575538636633313807640898785156463287303741217790696080003514700600687 +2916828602935343245489574829087284839505734067476926451104496434541582983914416281292812699388088495707067652976139900162078153 +1962925444708479245069456050692574860960690835458249514553536707157865617717301444683893731781098151767222498616081872995504896 +8173903682609218746993851247188524280631112843215665762250628484523471921122641923241385617676960635551184550463145418449684690 +2919933149036430836155770474842583951453613631150982113752681626101371527818957365564134323888669717562193735500885632774199608 +1609040194815030093545138643057865379099082109649230423000768558709693305039551156969735710643672277845208035827493067182565724 +6908049177553254273158603203912637795720376483171212869602699514186725461068506421013630496115516175113680573200157037543353536 +7096806396941038667344905110986317666939904573544009284947400783005195693194103701914010433669991415780015087815639572682791514 +3680756978168727352707707927350530897842094443052210887958488018513662258743146529661558086974070289076864455883890457256934114 +1990854389059420349848505548169668954938843880071111806085356892226974097003547436768393216697877346132002814225746150600875921 +4374492277982018508835930955357380285574652568017468028145914088210165891776161047538281175076369924948661559170128551211440651 +6393090046195615488795758266312386404911848462625030168594274415704463604586947949625250757933039912135660379167156550736214014 +5728243934436503311699358540925223297549609990942386098315769782770878982264993140803173130768644963918006938211060093506696811 +8242993502087208931436768299544970974899425557012952209431499521399155627662162396837380424393929443574272383673835625796387465 +2907417733054963303298412175669470571774232019901402324926626651661243360954715973085766036500273697051651414938093042950467378 +6785894337286818807967188916007632157799934091531302525882785328964971157321099749451607078727217297793573097237856806946698841 +2698558719450879861393803875387234736047009367170703129862250880475805397892793129358764218650002148641764709592993056227677164 +0081971305438865752091446464085352177755237063190907377734114566649793616356658589817576855323559323530686449621884731840150788 +1826939540243947080817186653825740075444935631469715645767626335326860305087307127848152820195439244125563274241365606473310540 +8086243883958240578268878611599696204485799969418845316458163879163274209827292559109804125366908746820981499563030997204003905 +0386391010049409963011357239704626669689746915426124197111331235480408669200583724344735150698143659880232480059746405028850204 +7070621356175994235487518719187218494861976025281218293612423462113181646903473241591007825352754630207984555163787848738511210 +5746214941035113394857005157649321493185603337720914119128667915231061424163637568324581504110784614852811094476768652380182856 +9112517888906528267503001049949573135127874375506725576149307826638851599758326023611417494647191891545342374452874064341534379 +2427813650814077661287436979575407398921688136831196702246080880472345267198382221158754713144173467705458354166291752011017130 +3427037443878854401716449891823089902160247151232344993329995686205840347612271617101573796125148445827775208799719717001561364 +6663271105359323644532079372626792834540392816461024173260479629489907065371009161907255452160867279588979514640773444750654047 +5973386387254971355387042682264494417370956942797373987206113528047687059080572493246240752693790196755839336183495531383520500 +0786113322119991260636829390212550532753074849695602064584008995135867708856455125847634381213436388672553141147016113632022246 +5315245540985412852477846866194175059739189599584743384794049685678013782286205098025299864897730658726559776885622145372207093 +2947046237055804495388214736381241294012375243250351412075115454784594240484997746146442841037234277389231586332048832314609602 +4940560326735767175083614737052886039378277408442894735731934794992054788139312451587128497131293085948245032106415584594528368 +0132772291233611554088929401128017045937329980274933241381990578374018596495898631586186020586965351932668997510872004538098971 +6387651070790112849045385204698059096706128798635300671169181792420546539133767532896269735055635232257735434930885609585584847 +9016459024097607724588041340562451108743288014737496316921528251742165151671257409207041532182399287641327587310586187223956817 +7534883738445463926481692970148340291005837757179973259685921796789142441810657257829230854362459214897426800925224271446152113 +0560193061957298132549489635518745231685759631661778699250394638322691452161479836232887573811183208096513244778566157714733211 +1547430295477490963534296984638628258877576273566145152920369666682577588376652374130208299869130148553971805471715526321961195 +6131510592032893543765491267410178707297913936975805122290905928404238596549066769665229727337467790389337961037867643489553699 +0609065177988688342181444376437189336384085173474299503743870199156371216381879438127542687917993261590322648797772549606051885 +5486486858037007564853644084702405129390388809213365108089374357918264647019430516503970264903210163964653753490047274772902330 +0461300174226405350596681300475321223682365336534045385167141718398138848125986935473489411898994178547406946367385725330213907 +1293509274626976153463652826393079169386713361776443893666230924263947932847701762953659799461100689690446626123374959253884277 +1306373580520533113454583490110255646387329350405309931889447247185635126485724261288069862689556565591921946727772549017471108 +4575946994632942954732825619796920704805541065043930109567542878956936210283544264617080903536339854736947121491562648913229061 +3705434044613436537344272909123399762720035093491390444488810776264889843570633561219106570438196072991495500597843887820183050 +9436774296203905562085230110417550251074216179370977223886873788396051869595539699599654175540263842606847704783570758848289347 +8739544541060559735321933455321086474549444477666793232318769795339438758735396350156993223591143789407202109979058296632555075 +4292457420547255026544250001229816943682894619632431862491477990869504856164569154248439119907994750443837979614731379296026483 +7759359950784829354681821925764141180511597239315053998175532245470389364554510124781233539932768390441633522487434841829277108 +6460068597420725351564334958788443977520626552046510044910725038151710003467025913052244964411427404827820741380296783360351862 +5211054158075000733081570753562084145801231533068994378093380973748015206056523195741701721944088905307131000364624646104412959 +5581089920926259625216459931700561828077094118449960988240945610479754976194870306805076133937666171790939426378434449418282506 +6039057527913534217575393813423847928955750038761332266774182283692275076570170104686335201401167177077211434292507428463611621 +0405115165537284758792010216853186661681734615099607405177733845109910013152569350731884598363743840624814198617754273927011515 +1407618016023682414983073935592618659194377480743081488662206405541839291934958759003119610099774589701968015068594030177949217 +0790315691986911016674475309797543936300728937674591920985541138152579574295860682375269717640514911824203818306809998011275060 +4382117983381412972994275528147432373242673418215434465602805780063289348278856395267652713597654578622689358031371373016193682 +4971203890127140128708179164505005602256484886747097346823610758765747601150832737555748482400760746795103492345268624660081193 +1238474101549902789927134668369786012288633703563425355984226013256465916402333622807942597885223175366854363298056733781480165 +2475056989181989715935840837103963570756393472493139600699839539995767516688497969127775142807367604482540314805881080534085920 +5110483916952128964226635567750120557932419254741576165448818621280817929369091427028028668168593266857526132988629197479499338 +7382097529770364245616319813419439630747996451787212372784898440040645194051307376865641947314145623284843530906118562837024282 +1180719306858134644273288620402473339088866088558646666749328622134176944113672979075244216767608666882416653166422367766359934 +7454692494850748528168077614552490356358640467830959916873691009192683520419187156489031520981784955116022176529954332656159900 +5703126531777606205672012335960434796458742284617167876316278828807209603472901804370309819783462306443611963348173237324352923 +7622935915352142387734818536448742013947936195902370636105913778439778154319304174619967238291501475263405722167671985219327033 +4192469391918128902822325360387297654953797790226858555687025028458729211895927349803665945095655786671449147679921097155626406 +2780677237649339975622761955036413080116980723465856549727438471457957358521359815258203894427475417964365478268462653223640340 +6384355742271287800278025268983527483432389226283229170112845354988683227778986191910815226499442938779725664362022274661446656 +8983529286956750153487719136198257278584599062333134754547317517831680020077715886321603644059583997509690986046227389994861108 +7329782796097322937140185361853575699691754834694652931632748528792770060065607908729085140248378226282625852546158156687855610 +7542858690282896923167331772353246169388345238738453225427851985834084721866947550098641275435407170332769801857389664211235898 +5799583185812386717849837795175430854770749931463501139883970148364355569591352178627597816164651268936590016366615235430971843 +1626691744466309451182517845050907803525893409042451069687831523577743242687080029262942742968372360368621788807914146915526880 +5318459023686131069631243003764992320489381131276662425282581511713606116289353391248019203404378565007089996278162834011328054 +2940914263304203321901619997487124198689066488749388375440671721678381773728920019056941032982814050260828373786697860844945937 +0935106263610485636127316359361586585062460943315331019818757835533567856247177900197592421873824025425985298148601575872003838 +7678845567273084139170475285839065925039600025616987691701666903861540800590513965950744386259900437461673353720707990879400851 +8954549187260534626790030686600472676242184422173770737899202674956746463128211733652450269429272431346452882295888511514249530 +2678743312277245350760231139022995628706226321476561623183303095250671287742041881664219630594695703026351221927214229218759706 +8754746770599874955073426285210045733061478934256278154824723752843570542480374148666553082213624470594178380618511944338556770 +1258342170448502309847524118053510267304683961421264512188294654208652383435713573419843151024833136714917076044792376946554552 +2686790894179727162588194653073820095034068415445717821765878768235572220948743946189649565838289653662296142578461681042115408 +4979975702994756010947392018214486397764251254586716632357033001934850295130508675410334819960903160411122706650159720668896818 +3588969475934951426055953320940144471459990302441248110905750552714828775127383961567862284258836730043491152173444309138622805 +0885835602018492226235865580484440117123283431801851414462459989105042310153202450298431895243159623304698553633960555968674076 +2495404637338396778354332975443524901010204103490577360377282407257576116606492214532864036869380580423420924036214250605437552 +0273823801820228766960129999040441972228765926389245168282516822705610151382079832776017382538534107323345050070717318572440468 +3719693296470114077607298610532514071278447231443437795910351532332738448270051379404482177889663554053263746637709700053641967 +9828951429348008059079973550469791268813640030847883313731919419849614743360559828672182938947231250356355114573949483277719010 +8160147790535337222916241165963603517851503563087426894556730214593005608351479878086372777584308199478067490440060949884647159 +2948684894394971841029364986618911826288588400559264365297543464936912860908849309130216792677280193265598685884468366012698447 +3139146768567604514882268160880542261286448423327913447026774946542138981930662613526814753066924945383435581070740645979592320 +2648770517875200683345474598491811627153093170689853703611806314466352414707945002443742160480066256003350127740349411901099140 +3308592816806695381210143529051488111319581220479904092647583948868369653515446635908476209492392955841254295107008775348098134 +9546057832057661112548846778480873064251831646186943320977718022174333455691510572548784701482794043711785251965805930805124302 +9797598220825240487337675580868560618123083511865310119111306172185132317065154479238514833175902325985968356007574306322665172 +6169700545459665615556940263207457415925074513750097043236324790451429771342105725243301487094857682554118664272164353388631072 +2065773265591123476370674843120027879502951065822173174917589895449890375502164860452910893685397468281488262706240927914630538 +1707471421521563472417257512298478800552951214730430454446551411959701879859928077389843110236600965268158074916952323108191254 +2504020366275453319690764881376901720307904782764373433647976640867427413961893744590272111954111461916745192557787193817126040 +1588579151481338108756894573873934357158704669830936720767495898488860812251579113152660788061419535504615986627104261122375990 +7331623622011754370645778091243569467777379728540842719407347993337611435365175147413009114962875879124181378102542276566594108 +7484609326756980072187285780841286543812762762534587441056462410575222582806689121646585229111979073490526305371963936438467919 +5706586317647554978296224372749817614542161459685489294484897802898801747536653246958762657311576344225567199024088879682797895 +7982416710167868709570332702438980645861985176457876981357976675349506324625350574864591977896798566893422693217353865223434242 +4612810517637816971256206727690640808547458195070320671241318078156152911173576755031013652809873321281227880993755057868636257 +5869566853914426396407700744200965755799089377206196772845889331869496057116760154715122075783787728423594874902542137832225559 +9589225721722482637458883619679136109478999500918895037360018469933679740571642521146059558547268528193088694289457407297389417 +8114608149302113225536168603740452239048816211285413122470267658232185443153634579198429078537401989102386028340268733889611123 +1658771744647637356624539664960206812688702241127922503053926273465214516451739790546967335354319444825617690989800359892589856 +0053465651697302095039711511050038742810220818349852842019182724663703883278427036626489847521335203092583455303768771456368837 +9461783935995459315552854731516681231226811974225458662840484653357703794689886592991537310946084831023202899386375997693481512 +4533585921481186000403378289480817856084298244494770175994273545179036968044114231324393781909984894250047249639320078105176941 +0088337423065130496692628858394850230047403024636567775158827661121094757863694577077324592397639708861018849419374525563390572 +9433907825695888321692655143225283986904641901823924591220365135713855259383744336203797993519930945597887702113356326830645826 +6988446116797840398450853279454162958768243775646820798515687585868046231740714350466068297160555230698894793181661331483900976 +3228255598385373641636782196372646263654896275851591790742732186929071139789500558984105284755563028281035328678092579289714000 +4681011094010579149015425103883784622081638214345888273901960768244903621448040859732301956914911242855175944393888342553563087 +2560980412018398873410432462155957943116348971819529996430919042949095207925589612393187400930103605496273814170584912659092382 +9069469616610979589154787060025562176784632650316733720274832314981371020706161084351225782272365506817110974959084699634535788 +6765587755549143676480283034752182178980320308874937062805295265849032617917049285075020134633510431916668093086266525800515736 +1987129393090049213521579473208927794007157494973792406906256045288699283419276005662236119067885571670938877198469481410429981 +3722619269607651225319072582934109199126677644296125933160645018724047938190291886105626593185859522559253131444513872231301882 +3878903450400959596968323921819162239731394330071230682797573061816799122019281619186466630116704421984435128057686311537024574 +2171772674581440679441147914828465322671796713303729214917204516452594596558898159147461291026535836576291138961274078954494387 +1278996875658664588862768319875101010284199226028473900312140448349990579106956212227946883352757991736474264479730037979113425 +8251737524782800721142346398693390112514424073577724343296177123905498209033583895128953063498814237667366732979745537429555278 +0896743149526940034664390783553213882383502205749882093466354195761918368893140199641725113693740413564898871253806941096124190 +7796854830589872123486600630498401268330698814798157768931103798808711643064916232366065296644778046047073412187780619253278677 +6500537503531609708551372800808683958268146390074367413801774325497534682441389495398023074938743544207866592122064463211672009 +8374007659269318743410884141200642883663626493756879447578129358932170292700541285549708569643545027306452528039696051958912164 +5461313220523803049639223578843432913631643532704665479011316367050573380692644563882130994146341345324086855525040200238888685 +8089200828994642111859047971321583377842360402699515255215765930754030446170133309029861283548123601950771958367816928039501979 +4921861981592932540366839797291842409375656173168252866766746284441002285941098783812692417408647250610811303546299712956961745 +9167799975366484899208629064327399424255199740686280222254809555146344897012896217389558240697588684347940576269967072665683864 +9259388885200851860744997606520800745929512006692275733677005833780389985037437438896650034386964970221299725643606029624930990 +1923555984126235140744073661251739569863134027553494228555366490941034788475845541690058986834251129830243447779754071605873640 +8546321296959618681680784347875855095908171158196021873844044080735403609307093046577378976184646301996038465275795577308210631 +0292841602799520083981301964025702228115813520124006499666068950846030422607104364257191751077960220252620197225981403964787782 +1502322992487049171872430148257934075524270686852895414785698734102981748355080650539194240735935759095611779799454232906920170 +7645673745116807956634247517521534891766878215315481669195796109233157590171328181080639943010458633508897705148841450600988472 +5372622766288568973430030404326811200585106334044292931194542876927622884286129265334479806408440904927200146880239590676743160 +9737852886366125426992930022076166695307759649277919719824038921587655496096287480936269368326605698820270793854355939980396762 +3180790631743853089037422811844405317287386545411386410379668362987107109358079426452748318127402761332147799830440163526016129 +9051792458167155549317710812956107571797762247756516089487421498534083002847984096816239076561386593955153876706013822381927681 +4173095560231171732875361485159122658902814416236442472154640300288401422165407659115651941434514022078384640403200843998671972 +5966470556331046673745430553457883526280940892044422560744252802816860579980940340917982940500224988618235941234788610789509168 +0789375239650015659257828854233372959702664651151444414363942452653680312005125741160555543069598467797693116222658921071003474 +8906623899466461239060702070337224569185523906567051838309830757794131815206179504935357263945463042333252081048931892858013514 +2565946185596833054040544913117114680329109501977878093743966290348734278988799428312347727405020457211698124070822545220367599 +7887639027440626642608258462581197685627001806341140783071773706310063459682140433859377089948217599328491885205500920242752765 +9105042785087589492163764806502467978793005126850254340679666786999523605304678430709511644540488408967072195820451312364898977 +4806602335002501148210169758225301946374240051070758860058332659173580299590222924023022260764063882929324416573334085874519685 +8860484115578005776711551777005731510087855975894724843956874006078066036507250577776451260714027733005242056180700853839120022 +9972510062716845450929888769682540876602068670550887529330503339523242901354677312818632650357341649500497585776441604969459550 +2623606137079639076047135393717143616094073824102105929404170935516181957666178130675618698894069752882863773580174806425770058 +4036671892720176871088682314351824213287902597131301780764439176800136663620269901795969751693427552587437595932156820043424392 +0677294124292240149296066696637747776445858679559483174535961774585189431151122220911414705647847144029722579499169874681984001 +3515611659295600392682520429928899147250410034409210806506732173247308027181439461299331344368884698174936563300497600474483708 +0063773420552619484426050490136425686777123343387056930411442496315945289353053161802745807953399447036489317450479861853401831 +1025437802898670603956439520711493780674154126180902484921242469929281393551385642769157018539956452797615106532069322627218483 +8759796578568398063968102679425317647163292357375418469803494058822777510870684874739268000355169575539187937262850844553141671 +0520130761108166376660600783005143635657232142524978468353606381401953088627097253750920455395288123559132491257402067683088919 +2890887289996966535342242107315365601206035014159576380219737883962373302977227719789793402712556663655879816814402801231940391 +7075049290134330330911964129274745947329781151686133509827045508476840011833420977165532815261601339404747681713954176358695787 +4190862513692697255977164180664759574127822507052658315853043337010650269787647027656260221445450941719360532423677717036461514 +6908155746961875390092893184110336543104604423996158420042649680420697682015958655453176718660496277341803127921088518280061343 +8331309328194407889735199978235437818800306669005429636917360222653217191676841870581785131998034245906906399415366961802496511 +4025301862689940996141896458524993405457637230423945068131717803505952316603722440206101338781745994056920279938566008667957974 +8407156560172061727221211500538117499687747789630891734019549331980906693172176957439813668311313041124185359330130579817813671 +7466416959132373028000515440426004927338552129675365950832267054293724597329240325990928091976976797329108528262309484406803795 +7029882344252063506996455416881601769204928489785629548747090770306190718064516950313796925310576174715934481881905681054628070 +6880642279419324327941511209000580929409891074059158709439715032933825582097408872913695012908119133558817540571147731630417054 +0450976304961807996926719984418185237945644387146277128118939816965978556618267349869880710186417738649005061794411263100794703 +7430304052534898545934660709004803179571319216041424124846029027406133093839979267839656729246840664461817790155804024698154985 +7645544772776077953527747512204638297554270388027111651502874795299134795410937797070656228161921719694817879801901345933313665 +1313410076049663998827811921356048583498283359569530324863158193199961087225704771561935232487625934010979224924950123845221938 +5542450907649094312430747916423053695607417672358828335758664117685424978394617325307248658166202146920547925646776725087468720 +8125710483678181819120321493187443931435742819361342552711290450551262872707443639793745995943576289709507020621251828473114770 +5808995455056792083922234742431742082106369821885564948694790039533752228468465967393391425326441602867483086230714643155046641 +2407915004627569028579526596926110527896052886334582385573230907225818330304996992697006735418150830862621130034997989250568103 +4747836691209220024929494385208567863244371223110054782899030754719240501536232821233744154670656379727685527957774155672319475 +9632183735133215405359145903218054467186662532650851575633645907886287911612022173510068469813052313582577723168904869118582615 +1758443894147315526858202229285381300192667883978558926059924490571584269631902778078169815289434853467255533171050775547788250 +6827379725903576619807972215479471705793002981926808670091729392075163455575073588508765374074600361763199064144608650998814612 +1139348883195112842120618191199370895634072657781661691958053236883789482321308598352679539450892103726749423679416567117182472 +5628380449503846780627597266237186381426941668768981275727365655268389180764025467621494196092237996217033830813378898293373834 +6249982118767143075646051931844250281862161753132641089322013640269043322260625061753846454820580624883961230554153956989845603 +1506389246361534372134008198497771836659467625678409854914006570144648661265229365915719554541771143877999578976720337073985818 +7005263179523699177762675340194056182817188450058666203568903779623473238455975919469726862072009578002483873154457672262756142 +2974648493466373909300392298493641388947991203930909247567333382267233769728042131150238686456747730553128288781731025800074389 +5103801198075821222369482103926218823537252278659224466101143285542928579893855240568803378461857010249847636234366813910593321 +8255444368358914408018189587539831385866661807993390145935560791507824844153502737089683973595182396850151415917641412882278385 +6994623624086457510788033568938511176649748143257081559534249807952079088004873263643117220080770572410226081636499222544341556 +5868861827549149829709753995576140261303291609060728919357591890769431437067208298630183272025511291993873213366101172628545169 +3536668590020988868465523872067378130539719812107645831862475320339405404292929655894962610265222780223832442563481658864747632 +3855559579815655284020206856324714890689773172461142431850331038157366681406979208119201701019291754639995462477549126425391350 +8450291792039621077539436402960450989801386738795258875543765926494042577259109968714035988972694939518009619956412673656801521 +9433075795122748111293126771649210779744396506362417079033687912993766618349565561906099136133480366162159291355560623721579187 +3378797875509332216281558051343681937584540368139917115626876588840206579792879445323063696609803160334574023091211019696117960 +8286659856511129135392256673984667705469454940089344874655311260297659378259031305125448870028720171028350742267966605006358033 +1559883131888908511800248016547342952257309383028102249271256078844439208862517563884780187208616611438790446776997799461384713 +9213000700276768725565441947730287329227888200262127732583001595805481558214719061412862292967561082950848644790833398460564723 +1237463356367627789252505343790157426584837476951882453112990120548575795054118752744721410491509448371890573822392145256573546 +0705282244277315586839396249472907788988824858086668101214804950902161992883203183045693099700874860748969961552066568180233875 +3649804362910298143091615106831740058421008356128934335979284102172120855125136327683861035088765145754792315464262726624806783 +9434730144784579817482674138286237679514020123482574946846405367389289759453442305761634017866345369865209680919734485563877769 +7735810389258589718835809442124950108708303704945904199371845065484839372522859566124912994258804441548671551838820818437896075 +7383779025406555287701082383561184897642996999173556341153509465466385364878232088945280693653997350128318569872380406482923450 +0873625836034957145587001580511059464110231294763738687292419746897783167632026738408026265866915946594910670670203196220111099 +7591072259741426420367322902499121885937012842290323842004604562106110626665272233088406003591488022718144482545987747891823870 +9175117307974364573779518417573849521480439605413624062061689756346227400155445091604379572899069013192269044493766848399848392 +5240204070345240378009455038862456326732346785249576960346569277468135720674493354585769115025511723751059422380004118585409709 +3349173998694448270286501817135410477702569648480525937208264068896413487832339295364105296137401893118290448960552591536754124 +2721855377073042117183109540215181252714104113649070283807754222580162122302324470826848007123339852921541117150545915474905734 +4442237467667117475961916917266329385273400917266015718314637687934575915917583933649989627896013912399205012102463085560527584 +4091026285900629392132231811067909337191049861336953793421590084466340471776345574531068461460044327698926685026108185944785273 +5202568174541673346987530914965105932805689677456919213224331168071054852507039901870720345655716025476685968559834858758422493 +0614858796890361150654138608860068135509273139791153876597516417474596470901950497034522305572817639212080825359999795816120790 +4690019462662785935463711750437540580321430169890806355137538513325878535253326703788253684313085653375194280379587086774403636 +1192297531414960747356858854539457018921020998476941206542822005080405209643807598603349026957600933047420780702135587594220420 +6385879114957936148095665992720513226197859511089355764654052901972661068207137358088876405026746758171573905075146612191621724 +7225256074560068850195651541217829216290435321680622077492940113765770295891334808874940394348277026794361425754981697514840551 +6579386119350941004072171940171520374772062901476128261790580552298150743389764668933362002827319670377285437400224631386514541 +8225060930462866114265671430768226751533399557663700459188510439035058277166158167696828360029527807376628848000272330091576713 +0060985472860653127812993949032906458731116791182858234879179245998734711417931089452148679024170798661176089885161196837664106 +3722805008939449259124307009136610112592018063781886320098372656598331954054355261215122816645348365251690431718100984807641151 +7671563753475866652087409998956658850991352510305691362750704516857124752942784347614592502287785972007339688267613862027066735 +1058283061155393934892259910225706182663785747481861117691921311446649045132526185682558542054377226003665649454406375422089246 +9732227956822666337303879201449758438032098745926653063569926833474234804332766368153105341066282800778041496886005184241210550 +3671076559003594556531982936604847786145732585941552091406028722895252734130685947197552543811727116647815405252804851390263345 +6932108260738047486627928786730592183240725916073436786293871274003576099287405402166418657664483313714856186223383473022466647 +3109816045417430083537878210451471667742535838802468841651352736464574926057073048472886864367560530408263557356129708697457730 +5131047990674797494394562345612521219564146779615283892037401029449518064490250135341621616256327661631926681344727899774392825 +9793560539429965156147946048811944830887554283992612919784433839525971829092056423046384752108153956186882584119526879128063725 +4848894438740997315189560856906795393017681147097928684567412396811955257068230623390617279746246419592475583485164533349133972 +9247196347885177565475533963701634576057917406510305607776085697222055528129649096213092034549229625900854393776713393006598014 +0895574299458423626122169092017122327940337399418681543962293182652716019527292869659349372977261887962838657423721599638764034 +8069818312801265892359056947805299813404068292205524125399036272188934298155723014962611157660369164361085013693243392717540968 +1746313469892957608005716135870516847580996237870651257913684437466577959076954626426758903637186057505535214913540381448786350 +0826130380070802481888865468100577235559992056039751752075537240976306665243883422413804381659448597324700429367218879041686316 +8783969310605138136810926575209117557352903553802462523920408350875226887462880478648547408932195087998226093346126517623953622 +3655963588132204550439064715232312197339282921758181601943083078440247650220106399066615678880555199248431536315260442825292972 +2898418712339146920156618115849473564647025888554958680753487875973131958912468912448106432964749351366422577093050105438712807 +1852498129286540733225557917645869957332090278845330056842464816843083325044360873406582227952116884337704935341689726805650922 +3976284069253193914079828201683985526108157492968673193265258027640406409120387997580216531505549000204500196895696438933985023 +7344227386409800578949975082890327124630045606308364332447462178940410322375677488036092734345158152279018751575711953710675611 +1365860719506143953539467521806358327791893587420884033512557356449628421974197081525171097681451739962654458105945042338824044 +7339951041651291336434788317295707347631976285149811926440821662705811682404836418364754712250487175296474328282212659994274238 +0212161973979980092408896174977830808566631947896643996545492647236993898876722578200269918604906863319277003087190525085408577 +4872695328272197013637039406318385585335721591609046713028487734545081008963689929406578869624586103965589484238888590831714070 +3093781382852235095749474972285903266360882836791963595009076006750220113661602476802687021999748113402446232401462878936110934 +6435034693320558902105688910308538965196623309949466683973971294957981775446228096356658904951613108961843850602970532678592796 +9900412913465232057825708257994535036127184304885007026505543104350741668197223958911527343764741682299736861152999772201279599 +0514985184283479308437214277006973884479296109534451984897036545588323471166529442587769709637302971344236763633165248653048272 +2548677505362732783025625571327094753804197898599649990120724885114160782630110803234921618274764179324553264262464188071111602 +1490102219572319216164107062405778780633273426833137366869390517112371874174117264586848123441331500645236212846316718716883477 +6374557134532066647778099833443353940716636987739316642710720220881882944339283639205849477871629369917099561362221287484469397 +5537933700604880504714026554029166587597577826204845542181354963551493735767539318268321221914383282788245529093887530478824907 +4539736948571324006868573970323898689460869616752573795437663232396854974783326373421982301397494963660135114656842200560632231 +5417628879269942844019831356484605118567348015685889718110291011794547506306795984565230200245047127434730978214554859175571386 +5244295129306313578981901753289283565322938724988065200258490956019375699629296714989839545066652554067148655850643910689520282 +2971836240187409511885225271973597558472371014435493899110877817281998758924278138897958733963027723716372919312791817550414257 +3718036377547310037822620295119160273747183347935451508155041258644862468137971759991204189248362267356043409939280563151645203 +2059403653814048643066476915696010105560937121353588493219472721117585709084500577027269061641086537899045745026346755806963182 +4321247098580397470005864122314116779988792921164422171095663365610591552259489098505982208555327107941284015766148898178511334 +4129075760977557106793231123557041651779523250483585239932004312719534628408382643294636229121610127684366632908893383504173184 +2529072874533404417364878145806482135038499775952105421793815591456627903830117948809720387389717200574623969207051170720940841 +8319746694698707336604137199806790228573013581807699678418425604568242103303802544153333753105945256725487631110225791990763711 +3880160358558853965367146276153313624158725831047412244380280879089394407413109649993209520904697096729360273647396579418687376 +2091906829462709596208568404663223009844823381264480008433097662223468678702122339891481765380241818468489069582210313140199504 +7634167069455911451763369770809802453049016134384625283172635485682336911180471943157282346432504400241673963332048163371168819 +6945528084709716553738011980160563280642542751055915815221655609127228922438332498633425574184424076324567457335614537707491118 +6855985221224698806898182154405013337026345633363958698774698699505064139860586968819626692305575161911369355200549282693239574 +9661995161189339321012455875057211575581587182476156883528607442238967236926672903199283225630412167629967841892682077069456544 +5556977126081270383421853880021926196747677623279360503448724398127284807443362608046943892392030345708092629807650879718315338 +2008556770184273576766805643194174770708191017610672185545130733621276522353464775534219302741371801405182864900478774809576537 +3865082900785088869003731961311138273432940384506242628178208362272250891137755623037615929981020628600026015312604846649871045 +1810271541153370013506194385701474067688519311563701121092950023460871685900667973434789085894353689769155959515852286976707125 +9220855281244525680311255117572398240118776083069705246489217127641378521494501271090294888487837045515780398860147999941580644 +7341485956164711767365322167960284966203049807458284565556017984048646824943506319395879136232290301571995491168074801397213067 +5371405547126368328180403806382396944697802094247261778722922120527093199887586224288144259646007747572032786762234373440343768 +9641998676406552363362334096338343938226513712459780071504106769464358782102176567281764333076640338559714360625098972864983029 +5780224793125175832096440772460219675603258721147649221639684097269727175225573293185628479999177881598175668238919939024400140 +5871315749737173437146622211284749783435729572078139529891438562616324259909214610231102730312223921245301659630109254504380334 +6697637358599635782137313649853967748604644159075078379860391872979880640358744386814475406235163749464766557762029498100317344 +9260432917913444420430985635427292687992391436924828756222785655924726309271829922076362876173530631675597755661167920958784469 +8008272163146127952220122593079694523591964786341879588418492633364085713190449203278430539536800444410958318893570820694596913 +5865771428552651226808077349460469511350507824410126508014924137043903316541107301501243645730254790431504727160432598689746741 +0797866504326277547835398517451743711623314102885283925539211029404096358855485908679412360891989483761400122402649553985042303 +6315338269917337190802305575034003552890761126872174385267928282692687307003769845400327640284655468895977857113820663582843212 +5883143761391732179613778683464000760776952507578651405618216504779945736760856433526347237980076786027307666785673805176780505 +2608019170724255979187609288672429113478903050968752935506997075853793110328285209939065370268834945095553185289660445134585271 +5934178091636548622002305410563118241322636012045119794891759960583808782939464117247149044590174301040963274743429124451974081 +9822212841254646950102433569804383682318140936706127266382165162763534213426673482380144302560262856995513292329891211427952322 +4939074943058922639133209628604240951813644498408022254626546671648111368884617471264005460319454857408802054462873323814596304 +3567851550694955955743156890344607975932611999373517821856035756405925438219730313496771878294219292907299376903706456079314724 +4355891716120089571168867921156570013309057339164893294310027619061553640293850173132141828093723591781265620877693908024633891 +3432150765823697928455051347308237232788126878764759364421680111689906395962403729413891780224106047993476140159348719814489238 +0234684991575714928121012708547654894568292786765465546202194583822334911755447378931758555122045328265456840620648627956740582 +6213762564459648735386518381734716590458385722741140951208497160837103126054522292981022939593107580769282971517719856277138950 +9795430658880195944561326976463238641719113418421451290008508454179670774519228875316092692131997401436104108663905564902246214 +9652373982485787988119955149332007099514930250170109206849474570844779657182243727422415156736246473756296181666403081597210612 +6363221919442807657179269261813196315614323943076172547080772762082497876523976444410926957078802241443845971487934887307740781 +8442538716705496485993660458983193034639571775952652456130115624584796446966906201307091498198760859970990751619599499849168922 +7540755071266549940783200519568012630337075342163311989445430751720634069245959298519839175642543857453232073106471321794307960 +1699245059009156264426959609151370644710641713396754020166970217700932248280718651485571836633670709702375632170998942628345680 +0816396190588432801059693946646313280382672711087244012208759747817406868034578850546787526313820913242493648577159472787123381 +0759322746357530465987827894614798343895157467747058744481984104257507440485290934854164189380366013210043776529824930881371048 +6385658080000822018084506735695449199723297410443658699992360702264595362859622022028092450523165950738306668328519968101921178 +9290969633149036611961423129438616262578501454017560337962795366936304454531175225394994520495848281893733418969823834849646325 +4866905011511861701376543806753349151579844197278285044705460570867283644779510401658626041128258372474841328027560368075591684 +4097340967374048459759351247293757377219970623863320131555594933368226711740987383236414710324945367020743532195606500683770435 +8777289231702354648686196142357855572861820397757772835817870476148855333166772599103631182225390962911857675993162562793056451 +1643701292272316612682496492137369576459996136135417810378930005125534965897227946840522877611416279622753205256995171831362038 +0366738891350724663780781742018384952618867530073606447030185424566647732433327301660674858875240792034393577096349757765316310 +8289591408206074373434407333542355057011414872348953466323958988208406535831896578204946085981588003478321397316316325936083627 +9704718565559121039339280928457498417206123777131839564784077774260566019404908403357317188872113841441577298919813210986548633 +9293886303171570837540716535349361584600602170148405662530496205079833641395026663688854207586823003823193883976384903470625532 +1727675041270249998973772127828169098733155135266069947499638944765750528948036161984830730668217006998355034769138526948886812 +0092789759212121413625842309085282315688319684507180858726957280563112424218015623004324904038907228951254860936129174811193610 +7248502251808372373101361237612617365642190393287142805878594705588056326330546884029678052177636399750149538893582015648656691 +3367150919108114535725714981888781359653934702237037159199343298241562681613327166427987327289684634196866794561168570101129576 +3376393226054192039386172081865991731275655717454440752850294664224843539838937920883445641690602345087514795742186569107517414 +3623971382393048718491241619316545941650237621831224965329865224908967972818626887372855949653336237529478398264567160685068577 +4052813893095863733367924664141451148648087387776942749014403408537141959668060633169208644494300366994545481397333067992909358 +0667669402093903159518564734675653958529086910570255872008713355774046040785518290333034404789497402572158389475386895486868259 +7468963766629011848413788837165962853506507117471181320045844652746289086413801588758664510368868946415159144280007188633881726 +7244685543653493127669292847190750279258471265994953355225441242455255911176450067019362851931161106818923851255323971731656588 +5234890473800747514454607303289634698091529945347698407177688996229422965619449293992367330399443066079751703944482713291326343 +6459044264277571164204689989304404957960666476059760392612837445978755062781098058819661144475485054149528425812865761888665230 +4335062014272927898970122302854052906295227383275313276798239957308395793035503825814636802802824167294443473540831595897555019 +7272548964073946058176039524239703608785612474858328053422538963447385787828187985994849316214926394617015487472147004996421715 +5996250931763812814551030631847429127490485716717613966608339966170653265360723312151608339298980087240888475983661731432872181 +2297536852364764322872184823063403907099469015512172454623275616030363118664676670421610327708607480232788374190290021972622793 +6341746181410744070773088966325798253704849845010112635545932402181743821794042899160348845322610793015131752714444557452077603 +0974929188283489944704823132680006629007254931129889666199080416689925517182595848963795936091170595822025233402048475030835352 +6345563891720858751435127759306670956633219054037703933137927110019397801896389210768937954353107771885376564624836527498565777 +7406605189056950050564580620487220225704555865872099535962165458171814654057503675391062376917680202395298499820248250031013118 +9646002186451042668001138188414741520592517338749162144757726571293411846579111672780359450504540363461450479439757376293399965 +5620887367929571798109873216776069586763980872092222280624201174614361433514239488022226011723867237579885237366697226018636145 +7658816676965243906096876039909445364177324988679848256414790985301032302828151276736018655718069421805321528401722943260148087 +3504531887253350368429518151187892137924735559724530027941664978322897818820489478004391185810494126054267658700325358193119630 +6476950573687760010199531144942136546086284325150545828401223666989902218958065517474495615521528611225439578736181496123291235 +8141273699960775743878136458997315091877968088833966155435545803714212437024032432947661397098373986850161208575249088483734667 +7526564869781879172205819920641629162261070844597301726270751056013595355206013946667713217060767795442616244184317275433955181 +6807778755059399042252363801724898729347456888637350665052001794960468288523356956423878794195125458046129085019792922364372832 +9606605635909164393346308754559022246397895156754911940817409436883533684563312856180585298884265000503280045621922703129043223 +1353282688124152832117904166784884443448057703427122162928095824570260033806131301099883014390489674198929314751517488130229287 +3941712694041861559776002423763440625536805158907454771393762216105225325673929237051966211204216493810015246774275044495594616 +3694132772158289887311123798026659094603586436166517150338257882694213224057803554027693325965893134619716724281180373864668897 +0965421930380580362871564338408316626579345707567981028006568747619015807088576948951469852219385041334895298633260796214042764 +4365061209195177145333592267894941789748549729388820653503884365772532158665492262305741107905299439181875779535940222413616201 +7002692668339856374514202085788525299569973429859432424389034479629705876996023622182434169328690891870930429505413389490533136 +4295933444463189433951574721728951160043627069745406122977006157620687110134601604174649175489421916452229565760756130297102064 +1960368933597422050626608328849588309269037647433491188814133197810733941601294848194060829957660144812059760171213031036827489 +5163673581923411040228773859014781426438397455478270422462230943695383387244412044104565525899545629313341781559828594738866880 +9340062964014870509227099698887936675774112546104074153547361150335199188541340855227153532746778775047019132401967059701871242 +3486224254115155530038741441994666898680466167832566881940775772365423817200581937154559007068187829334117784945473428671685916 +6007443619236946702946484250753989318115938165448366527641686620981129998037010871500824063178061129082786722904909804168031283 +5077049104333703032159256335893142225775472800145797927383645074150506549583979834771372332786212436563421519736302401896553214 +9328253090460566002578048864828230612968529907510194421722878024618561333479693530779323192843841998003032594026649617397117033 +6902940885468724446328665796554679901999854957523032465138455983570952184108442966984143957137952183112915545991326476857170678 +1147940566264959316051371696041947904637481710293264721589819021588178200143221071704512368347198312678908673679523259812561827 +1664627873674389755627490418493705966611982979380988314739579220409030725477944088566536789756067951060713524593551031845158984 +3598081566704365022254984411009080907751257030857437625615151390400729972784657938585703465777027605245686537246903748184890274 +3743523412032108137414706768919475408652123860125336712812291505493576913938367683595349130153523703056997225766687176144402340 +0831940301479210349558229457276992358900461281585291044594812536347699257011182959431429011534075284989504481274394019519138849 +5294182590907051056305209676408046536522421503936187377406071503791132907536141109384530248717758304915645762984125835020638228 +2925263782209751558565689180869492270244285946019041108330056058905348740666223484108200048676063426609063511425234359377856803 +5066811579460770402822516077692569897555102184861090248580603480179709451447581598869819018321983813091599472628576647298283510 +6074763977940235151776420120127969582510026900568916108091774893522283047922950769687105424389690185426520673414305707753060144 +1829809239775426957360751626081187328513913192137296926783947378382044283754109795780048763911203026361961183033933012273700578 +6256148707335785289325167505290076615535370263567053348838880542975561767345020465640090418173271179915907484593965695502745441 +2416400711412329501943051474827325196149637971289654356289167838113336024091716837472756809029018726324544210527893716549434408 +2077670900805210878733285491095692143052856294682669529394939361462198474814099442765549871744436963471806447226559851872954947 +9082929602325709346337243734095265641562540772131425161193766826203999287761238275537747088073534676484013517045928815906520421 +5721840157618684926859754448303249283214882375060250302441861554867804071849460117284782240184817225436567120551507130457965054 +3640323862784940017360312940091490694469989530945043763136591022334344797040629558445856236949010602808244365211211804494530091 +6701192226260174575156745632984043284760428280836716963199179332091776863302070789290228857289693019520852953529236479717683160 +7117865720410815041230240613271283107726446255341876904224653305719269008887983911844926604802435682901331270611392890319564523 +6692783449614566649026808017316150504276465383033625466313163064737973819404507236614011588134611220037079763294452798973884759 +0914820111491787540225084826895277018554164459289529667607470230351077932208310255555375301186238522549530796497320559115264320 +5836662613656654780353360816866098001238641884282152191319830259179620144977780872729828947449487560906147944637380292807461055 +6561572680280173994959056296932010485999239763428796091258639640337313710982242786240160248574519338042692530967139936885572234 +2825509566854748807330632140109077953768464116764873006974740017020211637781546586566316927017884251448954820201170637677959988 +0832497323156260043765386414739221132824464852853436205409279663532624738981652928962852787063322728977472723705113895939816648 +3887836720640005567311856937351200913471468555895780989932698604802967755682558413334239668009044766569135994431992317817193615 +9488541867758126379374062288207207762501971013768400508156207999323493728384215408284344930017408986904527951285518045057193770 +1193456086093196883061110691053041347131507623254475732487481683124957212918787096719880296652189465479161772651216902388161935 +9023602670135872848924155417498176225830627494225163432154996996459879170929691453342113731711303819248475466023815067381174572 +2080493294756115922317931111866355542145263306791051695700043555158422272380979294286809277064163627702612725392431921737967789 +5506584820111354803017904304944193794950330337626863953844116710622843699200721933361001889997152111163384731679702997569228667 +4453953407265344555661480951607569587119336749659238396970668832430048807500071385571032957421002113212240607304287845329689873 +9400568404300352678168177542306869394633571699501805048687025644577243527012594817839631515308187464636399822139186673563109194 +0383996386779379889997394025888104236940479474160100383602505977089098334042031033748699121508022116963448387393566265472288965 +0847531693445140037287515174964594859379085364324835476807557964238229721804605800683718605401718393447954937423707976551995646 +8901279644569224520056558762822223149315014455057454435980383798016264269841766056870811144787284148299586773970705052525539895 +0256120889703056267161520334600912740468642740690884187820554569479971860126461193414499951106260376564440623032634236822171234 +9700910582776001785061958742334821043319568168457980526939228569330951842352229610659307009566518307187068255993195333178816924 +8084009439471986482548298108494644279210299285939700414080731141355145274821687079465639330167799278714667429384500519830074150 +7502762255088959326392982513450122047410180131292434743496089993750128169949631240918611287380175422097126458912263961350683605 +9825024574318602570230904976205086057242856859840660113304499069379218541308171998260227484149937812807157987838492362751492073 +5236013621279011602439272005713397632062733928777510296548649421999353087528124960783236699168282936749555076309059950538448044 +6316174264399599155501461815935271957641181470379962431535756895151732821144407472754664303419949275610161730902538833181412620 +4057262138394989003315257406621046570918156102356055537411042166653273066886196141130782850554134831168704085162214611295749827 +1728494807516097505065593608124398864640297391491113562997206711322054216710834884111534067711304959653237337706486015754839628 +5402941401919360128506367871554679221289967323748328989926516006333132440966780154068277893259475878724270654107817685397502294 +5331749302510962305291613004333202326722920832094875206002590142911609625146433305314091631233538797653208605364527924132244946 +6532771118816432093996083328883576769019322364788699903259151365484388584381218032915424365355589731770063912720956702509258388 +3882789530639893098899335537330679624810372563783381211488557543067129370526059579061942074775015254040779746533167078485769900 +3805020437690986060459807837031266916198079638277454221416718947378635541609908151334933790442634344916435987118766221380030868 +1492873283652410067454455812350782971829174602968575413579966330593167559586103530053302924740897504468176712345572924410751989 +1402681422012394852214397745855323854981769611609240399129690457712558487768725787104039715649959552365787249656873757201153712 +7034615208236270834171130441362610841044504351389336191409989539270321328989800821619371048375553928712514470949748975085093770 +4290878195796201049040671016672715493368576254144716365945552067883559930088219118750514982822693100430367769784775351909372687 +4911033872681823931983855759969195568792322301570737362071175550474999508803728901587248248809147697357896852570255543589500900 +1706971004869558605860088419347382200967993695904618287963224847080176675951145483137675636512072408162582506993137174472960694 +5573663486380813348973168761749599259962367833751791115712074445847171992391927789752756447549332777671869328971664763925290830 +3549115232652328982096333522858191070453865857146234126898896140406643330756492575988127393599824952457257137615690188707592890 +1525981890012719417710592274397314151142262744434946961995671692595224961001445969622314797497698000523423663899015096913051877 +5058249696800337974138653960205886721218275906496709288754537792787671454609339328245451684579097878838116584542322616579053187 +8462720851869420776547815997374420654356793047547706068426425982466357700923014078111329124212863212450480733486009748682342594 +8687099289779458763026259506520765785275805315714163404563447144528065795533004752634001703743154416316364697795177031670571395 +7862389886797621228571167458335190181377137309906389411269247283889070732381228453233824760431622453252798014077600435024553202 +9884611862481302466807813924732912660462964877829202613446787892509006450191623119538981968974508042576824347741032177030382425 +3275371888164672951716608075300420614160898739974183834737152799222716640347298255880801705875381815950138367820787575063612645 +9756093031018363423853254508819810837905492342390007409090686184553436757595124339753724654015162734521998021981012802729263275 +3427616385168365599989752741868814273183927471411894804297652680678085002922251517971806076560284843234235639397961184180625624 +1126099034992853577542894567722591646934072315106827450408752081909824273574814734547622072209980280969251694858199479989346866 +8324744163428589301098203537736106384602289116499145216551769186060030444438336222899526023763743834415207190662514180019708518 +9860319477002084962218177584666884101089885263708103715532250072465740590415811526551340778700948662719303811079801949032990730 +9442895797928578191430950680716135775881506952099465712614129706777971670822951940768332168877767587109595551931372470789023062 +9676406861977772053008009279919036888396717196766804819265649832410502497794545528956267262992497398344695416980354321065043902 +3430450368036376703613028439245508507778168871582511449294099014869582746432398446542812126358198966694091267937409209466063739 +3928978146389085853115437005111689057451518521401216175319263947818787743509560003599577334399518674836615112723186476720359894 +4447676769726440097553180938842032872197723469668279942479093598413513198335476789357764400869873866217837103053672831807359964 +9438439139166494727711797686854076602382501450775000543946895474100528401256910882752544466058353451178988269998012104071279388 +6796506900519353467866660536525382267232333410870940350598284296015115345501330091034294987205096937204489666809908368374224287 +2156069024262468587697645236488193119228612123037868983120993219205723939445417381491095019098927648926035392978843470867760614 +7821524721406495642677263766762922840188657758664683038649201210659149304382137313140079079190066786903508941027377579459577045 +2846438208088991099137843881611431007996513901288343001595074297103385844197112994321057890476648269334831505632974358825733750 +1231729513446989718094794150861322831069880594276720936717092445853573977523050237490193119260788535329095088882720971495287598 +6552792304258966749461747651069123750999083956204720301600561922121624443601785058830034234673249878353748610370038504030736047 +4350618220429461920496227812205841572163867546971596032105207072905191109123570652010474485250661135080242831754570708916683989 +3648963905128198988374985403745574043149005801382728738825016196793544318399117519577715497903566248991289200713376389062963733 +9079224255192675318799042558252967439629275533715026478752109034505102371733784051667760885774671501306079109448761994271014212 +1512159183483513720286072997122368280567403105173759926916954869853277451339001028186617037332009159449259382498277868408842981 +5560323178755830694146107056035341050323807669577457330458808700666012312546070466530820114714620579338594279601664840585122075 +1503852393417110615057020185323349829356846940778480270527833679702648854699330937650632301666517518142397830288536621388668145 +3710500442232649775196536006291799614616427004022039024161898799546077671371127704078583325133930080437162856065176543455363091 +9667028302235222877392627005222715604718844825560371250888081705125248380997161235203510947690674677658525524540413177350345055 +1651124581699981562124791312861972388295643691956825406823017359302629847041679857625842731954319702741028762561310737659882575 +7234973146912955319568057648697281752581304980681832088301794847222733894976160526360976917273669474157112988773823160903919773 +7236452528456462658486826400719408745377253190375111579049732814880300278553197889206203166333133501206064778109147665779882391 +7682375338032730875672864027350071637472437979382544031201751667224513438710165103834022186623616196654886225240056588996350179 +0853897451837131243025169955161135908558413022976148659863288496875873894764829106676107357256982339087954980489000376844916919 +8360603574420141848805577433559168689130304284043047944444385048148193572183817853604188280975779635124804366554607129505815592 +5620546941760373757081442569363535705009166704002199788324439031196454334794954999272772623824166956059123197810751221134756232 +8439866566091270892187388961159863817415914847036125600694319372852752155914048990490541073567566380258061226260248539927574844 +3029318850407273236073024405659942071591211229297986931569472429177060698779317028894343293006454758184946754805713329630249820 +2687678405796666588388227397973494711846620655765600330508932225839545844068520955016865194693435829894249625192750034081363961 +0826642719445444861688478619229100303043863369218122546764063288271554588608667295145429271395132923307142550915748046259216532 +0468573883399305338589054269280928735368128284996899601120318736730996079626128417354949909634397399033464297120851931573621836 +3410567460401768661525344506338831729399382001213762232285178082217011433200810491330007874531405259479829710109345021089321397 +4652171379208756546308171186440327278368902304830062446989533198226580273246735128676055302820200408293662986737676930578153746 +2150739333645551554065559172680067798805779396460259578671413082802669062176930977818789038399646027209326563780688854879437364 +5947149323195596075203471654735880096964253215673415065855952449622950653788545812330777657299303345667765138612882163698466977 +2308935140239438613941108953213493640813697893782475635075053824082277617694735156671731366529539638010664196515846143425205110 +8579861845970706058547725114635120976593327222009873742050798971923964666256857891243866172081317410728590091574945331275284201 +6824605749924142731964725200957618055202505975317938345133949930752079669713432776367891693447902213677009365812998801001720273 +9233059182009261025428591058709759978362385968915457411652886788541048883340218037203772730667179361924214082717915090369829831 +2313518106392278036401430877932921941234750269539064717318812526416633477902124303231275087598527988161235948020286385526463743 +3838476810771838510370563675061364260967203242139687527568417240328961372800287193798489828795160993501686735937478711295496291 +1519858055532723186083206022574209495517859134830555261865370844903580200999194798031588523243896559267197627522165919682799739 +9373974604821907639636032716761671130085088834596447375314712571767917652624045445822422980937123575808022402072804691330745798 +1179538903767384713618264919378659303577920743409425206952169277638505227558099310711226481165660388253070855325241107221381882 +1789290788643749161623308260296145948321831584631161915478987224126348775962249568727630631570400533850489485693171250304745466 +6433974998050768158826396562741859990471614366251286876757878787725794466582791436968613297526831824776182286993388108679611273 +6110623308937612049537824555231489221014173246666865428966654501963681680683054782880195354576356714786682961340119163196471017 +7065396261977852039518801715732959486507529242741135438482938793950709913003256496248997903954928882444470989824659787821204683 +9252764834270969572461432198412629509667322770306467304657216423067070489844755342237360066917220335677138645076622463524222641 +2863822477918798068216749348395676325852006154849615936810666235080045937062299799315963185719888255745874252084645488043646414 +7004033498629565919058730350299817723186869899372617107591275993421694639356397475575742082851089041949288607800654160534708316 +4190299271083535674187523239133194914262331993315335908926599556351517813335151871562105201268635100775530492262605262924734429 +9412474523205479108160235037378746252342301320435142535429384588026050874475919119800213524490595720796240406073642925771858154 +2913084106745765525951041794109785827673640207212541754087108553407118981892598453634040675583256537303820724542193091642590800 +6534476025728340988278166932729090239881218889572681282009000341783806869952125287383734393447529192404697677486779298438469322 +2829214412991708861478313576349293840205174852775802339069812401323737815710652651384534932732051408295532745074816386764349267 +7099631393624915897100017625766879968866232677413779562258136847735611193368355358377164844416154018729080207420593111993431521 +9679117084184583456113996444214687961259734088670459741393316532022602071869803421115792325270648228861169427886111180946003583 +9793622141632553469977231970499144123659775068372909299552862631976151882730222347477076919808461706462627308819362671717147651 +8286017842303147776294340423265613507963077365773181170674484922475010476392279295555883161702991597407378465228254838715678283 +7139981166981912432328248939664037584747665029041762831645786266577343138070260044935844528507385472563673503510303215480074901 +6952789894317576895242795097137355300336216988450939924501915977563360873810170551299455217264567889345472118057178061331257728 +1694193485067381935776175208128377412895577843695434073687471815717642677045054952476930977756497488385115713913555764776948263 +2231234433522295956531798985522781927112508008839457523109337600193193052076325806292222155384767900607744680674492935529295805 +7875818939048046279625548208487559794494231792862975497567734812838016356460114239167085114060525364762528245992233228644094327 +5021327908105698731349894818836329218148701613108177279681910593746940136925470307141167410364253643713010143547929247739518061 +9070977175221547245640857484222877237472955055880739878012461158071643167060432840330043982130511367475881160956788509827952621 +3413847694252380420294340031416724229995257917239755969134460592475590887547733435481300484633477930736275363875263891668995643 +6581430213176248276716948697514387283511867935196454364984608140452221982505162813367283133818168866214263555481101556955727420 +0078360325719735185976311476426092189177189796469613813653608015870137963763116020948507804890688620493269983909621885486957143 +5618073667256477516793467657312199638612399475873899685969826531992817695372605952175192740133201709617218497592077143464993595 +9686528263740598514413702973825670801929614448327903726180967797157579946183718568106283503561970266617924646393019216381949796 +7239480687825534075396618625255444191589146664116441837547061247242846107878949219756732241373337771333630723471570758001480280 +2126415066562760335451168640052256439621013367706107505889219639609857343988288214828754545448713238798703235273922756046005812 +0281498418252644767093639973704165385252675952065796869316299823450944375075913221341612192647317518382010547568017829174497579 +1057968057525848488438423398887379257534282986505898261044295544509349907137424691109525427205047296410961152317113953498675027 +8037990675600906293845109738467043233236225877257801109348395466430705164075214123065322814006154190811607337254708305938085250 +7210750787555252394437778367913891376849871377061775971887348544361550409572803722815881181222850658661431069707417398802536368 +3948215469610248733031315237243553696794016591253408216711885250561262516305255457076505242344244633141474145222490778655694723 +6617637025342831507631846476937783337058482960397621355078541340935495458638237325584632545957068938913331687735591931648307374 +8523372206558862816505119548118888594916440410353297374883874035661877591624592793870237386066600870369847319996357899821848884 +2706665246531670922861049993051412169291896643639078882262700663889473964251112689202969447822598990637782956377227324903867608 +4848299459820567898610921948177867341511272056149848749209193175952272681698383112955078617288403697439760095671946801857673079 +1356542472568516852079785586485413072353853487441642185000260635680413178133480855130718255056119475830508178140915142512386038 +6695877448601376560251771173382757011161242171039619918232438391997384640483554361477105518555170292200647684746099630559477876 +3728050473071484393708670159181207753885192509059591605951929761162380613874243004953769191772521075466929499282741107419333117 +7606734018487546777450475520310398974869459655169606480072758933265326533542081878074199816338268783853568241202511239916973258 +1633835831994903654810299535109070687398984404650301845605445387393310102422388713024846802629758902868815270339924811537344859 +8928571046801342106880818013492293682607259787490363620233716285093685649713330924728743681650501355104561967670012038426873625 +9125730098479474089046067867529096250921613432172766348896492595710398358975815806788579245423344223729093128465048555061302778 +3282236766431701005576011421891586267683372954054171332350103840612998244535378427127331925639537865313201470923709392166490250 +0060953065190643840375181038485605085116833098863859869877736596835368776079089936760138916464834786551291455693169964704950417 +7199761056487159527818318808980388404160177710661891595418127883387542011797165555082211982772990941128288012248134317959535274 +3151702008500412396300814816932022272142827209737059555958537947102106965289850740478085447869942031637107833939492398930644696 +5466978918720768258413199259613003866496795654264247159666752558539556973496507886748391341566752558990139978324598436936793928 +7875629494705039695595741518975797423129800053333398650746169290789301147238968164288511049704954808998463415048261417058627843 +3675014761845381637345570687526385375856012330298649384510964329070850231207976330807099687112778366295062201878036276787748707 +4186642715813159153197640948334883431130155154184492235081536887094317988019087470651733545171824399201735161775652002448517265 +4661100517204949080442753518341612732523752379970048081237708561434446413436675964518402865361477156495973338379138615279891674 +3104047228288563492721376497746751756302186258285396146017997376211045579689813619459200950120798719227167890408329425880640799 +8361120737152440781721610389840480574105404073477545436637229579684528270718993412816918987324414005130598864358095704485655816 +2635022304411690520549036888248912012839104866750669849182202670549996591599148236127250813538958602763034624939004690945598644 +7161693686069093177957527866565203934639363610988615731752113714098234889877144865056494208717095238090181742851725619039913679 +7926731919437873880030756176008264549114452715998481120029937345677673326677605995613852123446385084312717926880869469763207023 +2138495852046091769881664603146562927499752742224823433380060312750362684368906102817542844818392822621059272739767561472497448 +3487585927757204836571198808541456058695288628326581580540815649602826692062251298954681717253220499784757374087955966951533070 +4467286406109149470022526422047665420981641926169730080064026643952810388751979407214952628713107539097869076094466606508205808 +0329251645328585224993793572099403208481085245076448698022757086335438075955415420248533451214205820043135499362946801092902796 +0976117055234786919615481110380099853162437989837673156044051970682580784609511428623279845514623277521398030431160849037450740 +8697358783561542570626868871304762629606530282055602229180460161462702998318108546783149370269213126706148977779508293460733304 +5685401232626893164468498498310349947377219975132662081047738432680920912627837266028376099158214591714411685177672935669560017 +1991014855525662209159171891334726717439346791115150429082237201563017187579488089876803702248258879215762021955798945536843228 +3358779497231258973228903279307787602968091467986183211284685640196892409994105852728310998830904989480714242762651865855421586 +5348281152141939663360571564939207399533427205490276937846050282692131755481373457167966144301656498283646918663467663563230116 +0442219576879355438661813222738756969322895770177941048443578213219939881424295242319200710244313116242014329915750902609753298 +6880215129386746871145799105266743824027120004725079746962555401718867449525806260178086747751584880447035314395435465651034570 +5590819486053989106201536213480377379276227468376756122798396628016810991489235173054754920663273388709967201645610835786499004 +9939124283008389379680409146709896607754411605235108861950292912142332714272148567105156028757875660670111321491114463297009230 +2097548826892083113543893580713808393001576983724545670281722041343097928800752617116438879952016563025042978404320211936405203 +6082731184886898638758782020161455765775544117220425974704422223842521161418889571069655363278462600259872240060382048674290190 +2889620681353481574769346958935531281292735580442822115141047535414968598234054161580569343948696497621906027825367798221210232 +0975609392326975398368477771498401808897612300017559800926232766502316691201583773217274029458304062931758320244725915302928993 +2656060793106179140097207671393073878144623719159743370358884637219392258120064605880204498430784571518779561821815030688040645 +5261532754299991261842655852754335348627643855237017342819255089240352732014055394202970458645445920979909498339363437891353307 +2437642062562451324051185886722830951326647012880268770841964036842838215823451274151497274115272960818748924818830295293023164 +6427726746699539771500247174272715628837777269348318525014112099038948379809971189523179740600410427829712055609005231760641337 +2123549160662241455227582001148252334968910254759170985955722387116765936697038502260200822286774138322324033501219326909463806 +0821193700130194457116090490985590394866182284594574006494500813138155877966705322490599457628280712279954157952750704655060385 +3280391474844631197279842080980749627555722515522776772617462578270115902754706089142103829738218939451926197117850790818482759 +1294311329582945102206118794968530880988413255047180804846373165792608079444603588122636074961065406623564621335429415769062656 +8977139076449153307860216027207885939587708357239425724499000050811065643249463642868728678159848609219920477201880783130814232 +6033248813331250043643381559597258568598550852601730339407737331740193572873459479638405202147132462334764720678461849283231967 +5244706826495860145056785602766589976181173320167438082817365766859974115630195914700440671364272919565408159761417527099133015 +5244648245024168084347025892989203801674105350823195087890804798433093162301085522657402786073312465657131861678950736152896502 +7020998265858326008838932594312667517103689364315007929663379806725932670838335332530002316590322181497959301133051038639381171 +3173858772156448895864459261457987925785493055610741437909826143835126197998316368571824712159171580331713288750535891179500215 +2461289349520625956975133669730507522155477555105599302736241191876700580974296813158063100071375109901417730679844357856593047 +7673877787687493268983420698315905381260558449663590054448103444553449366277579160597491777336624754840213430260072450113764481 +2114017564926717940676432504294232477129802350412122813350795229854770687737407776153546967564248142801354985562159014016660409 +7639567903574424627121988012936196690968952173335045547572877439937623104537739475753166073603089257419976655666993295754279243 +5512010810515840583007802011584440810442039388430026796415104195890917308156926213851922793907826473532250186114497099571038088 +1090443322487112398586196562777035714693242567109619766467418285811180453954969091778067062185341924208029182725946749209676264 +9663462321929487207790152045012463956298339314526151434668136673612071349597053270833334450801647517402244793354108502290993012 +7465047517200443480317342789716535487720038254767800382013521445375492608318405493546080410946096145404154482214436078102318897 +3241343339884810074493047134584332154632775327907375423171218727031001503885369275032870180181698599353279959939076928392091092 +3566208126745756363429701058439360596278930537654250601183842796400352091131220495755538686838579076983412474092980588063067246 +4135280622573899686743659033428766204732217042537180031329938266218979406566474637509065330050474399644477629470645922989131608 +7243489726801527985565622807882110752891684081535249425920277363697188485817835521822988850811873532635201983418016593214492469 +8143017528502801938786431108109170005870927726570176129291655180782741998755590156671788445329312481442984040900285747284336895 +5565100360014106030272353666080827357535103165363399802552515662750922553611500390854921288593734087100792149327574407938377815 +4240318921296779247997230590857031671134516419731819431863267883435154179769593315054293181367248263035923946261410558920492931 +3065344926131172598974832603770803242453631170305261893085619634353617662701712503317939637731383890741691116709803904180847998 +9640635307154881695674450558215122808610162087865073261126743708282066313632270460083280371892143332906784831299555537946109939 +0645039315913940793949968013785570770789031780794104310782057130859521600859343415595288573910289771410236190253921849657190998 +2817116940059523621717397073394274259776453515913607417038665482821641102656240840561075406926383495205691566077252073640483438 +6876828215210014803339974347992473188369840859181281062746399956666218336920552262054357048613213862945863515439475503711072752 +1206178405392180823761458212656703549891855527651389518191357531805984535259972031066177734136716154598488260571189715523538978 +4990265766954047391630449528696946350646833442858182431131915610086870866589089866607870181211091256487223226710174280311854030 +6161821498017905298626518871081902325899313379230902725132275803649959728622670760552023317532682229232464170889758455581169141 +2416184842590677978922625659052895162548385411298782741233394356631320019382233371212037232115448059660819419247622831630454503 +8975030577721689746153882576268854827896373568358085985637110827886139292888578025729952622899410488518168089967179203288999038 +0077221628423351964468120440528719933928163566191359047160562478933063353123985611799118577768774930246047770557959247998776831 +1721135782157358288734205102478591394569267133297228431858377971925993589071779657700502192679741782178657102555324869244446359 +7869917278483084269980405860197759252589350638010408763257025389708116328761797581159680452123249311643134587279719495772936617 +8130672462738712860454774853313086658312258840823449860002088944658955778609509469061098214154416089413962879973327200377762688 +8704019840879290058261002736123709853095591291334597972059260229183193853550672628813904508834589255323455601476677738648315934 +3234707347670711573887321944356094703845291499731243740116195333742959154260950396149564697796845304852992191344817095433298019 +4556001053283765367945967785584518418747873282740299536406596053579536242035383267115157980628785476579854884310834210027387315 +3952399660098012461635956108592408478331533765191761940733106633178973207757390760027945616808844645166556348572120907508405281 +9620717181599113391181876705169833156639227504083941308593882555592005786644351550764764616222603704206370090556397818828816448 +1082150428965180471148236660642979232846204673076692680655912004876027643170213363695294926023526278443457817518033465638673749 +5350172689969152071949149368789531895369178652578561324968877842847433493285130074155790255799028895045897756190837543509860775 +8482306198938020753154634340975595193686061652677880586337892305604321362120530299145893988789835870281018804163394448979511499 +7488870885383052769468046156937025798795341295237597526911841052145121608390932943180983640617731865473642038426653712735002335 +9011612227214170561522052833657180847394409367216727282193072678838450183604374539578667642858779645471672950276478435834423943 +0042627888400396166577808028511674909710254329416152368725303977021338640330576476481308582201268866056584880471857573435293178 +9268879578435020158729300163317051184609265956929202720052876516659404370185319984314639348524347471621091689443144604058655054 +5852357719309697687694316961668030847489545691322959818739069805501234210837740692288860145679956618287254425865421435945272722 +7947183003454715593442541393266684657719476151125892217474788448864376694397034056195614730803146207684810002655419508268188406 +0212392708824827732017576889397138488570370042723523923833128481673477500325568912519958461261978143669880070457987816169424188 +1965090700335288348865794109082688653306331467742286624350702924857750689705564771477934006408695884251431946386364556639034176 +6475202723487206164676214732339055881658522754087991356304799053722702797567004357975452415295767243300651018833595864642447417 +4933751846153559955643592816488612142322342560545913045826692544542626150928640726729092043333739064265750508139974673275834713 +2427576527067163076789990338481516933446902541780767233056948866977560689363984682741766823172377515643032993191346658956321461 +7240324801931427740710853207105854320415521035336023346171992089619399728628105888007254180361185035803733126321368733856723085 +1503702321045090573654976317248889826950138261936742489712456263150062608622387827772363799121813242734818379753299053724286228 +5076095412377646585652542244868299631686826272014334350505998081702990345584728215380800687580035780236658004071510394469994071 +9933250676927268802066614172669848689165401909644815070604643321993975291059605403370117318954869373816750869659405704139511279 +1490487519262534395623800813247168885091994099496258142463552140723866858712657283749576144012562970919330051773400199590563572 +8265606609996094143464919138293434901647769730550988047626306005465014764814728223656959001378552960458572921902571777313119856 +0301901698751025073371353819870024706444286250847057963018585025053110220589734085318599463450687736352183212884401020231957087 +4456959908526601850236631528599915374848039675582388183944917813443948321814362879113998039695208714072018715891598727749400184 +7983572039054110543265312946188122716587941443406593149730482849110607363599698686119685785597056173835119438876589991354302327 +0157777305454082280716591110467065838967277498987788761274920512893356487762316080383017175970582934458813655903151031833258038 +6820568297362586686149767416323236376371752928724979488399337093603770184434877480032885947231535650930077949030676059598788698 +8108972963805156390445400882624903314064494634772981427763122632358977184343156109534055951999238879890515883719506599847044143 +5178486334616508289086769240536520705517396788807705586482419714104331671474772634945045486037353039747544411584344166691513962 +8343543694892040940224135766807400138072678909751563547074645700842179499138145819361180694589974178543789544801347334713872045 +9708545131525935820756667264787954116125739691093797584888706242100925330533736446977764101332858478855148268301440155677807429 +8363906279880507853775707450188819239306527160717217937065519073363784713378967477694756526571005707114651691767780955073859818 +5651083308096512159550753176200623584419958971162109603579598590262428369134046173758247656339396228143231420340091898293104843 +4302402395996304257050404831355580727247848379655438560342120245630874884033522016540414633929586663157231554069390318916865498 +2822530065271711681487170629161962249557718383135273443686990757846857063424817696146359531243469019949939521304535035359286967 +4074330918579124906980668220696463605660380759667033381676449310911291881680221895239419422515427861193964219305035700436309668 +3698935243696912496491762756802269973014707849066246048122302860046406677238810686973357352423777172732249145383686882436002629 +2170964033471347644711273905006241361125626168342597916481066003694402986372839549149179850327741026797871619199281396638967050 +3740578777458341247832731137954141104761544067127564384269992513879476807275980026551471675919580563967451050762083496336212971 +7234069436162575416758566662736313504628826119312240011212647893254386199394411434394192850902621006968244175625150393585420756 +0819505443586556219267270131584242241933754418772049304646166400049758424842433111724173775260453475529050201556290830854251309 +8694504279853225298817987700209881068598742151871017058490633074185456825579641586256200310473031416146096103034054724162968499 +1678422417003132262043356103744836118876129032014712571839148276942048121918851516621273265839886300177612597618998212159348375 +2526979362189085413641977979132635792430656327264789820332281372901762624494315668746921549021511066663733746233883697857770994 +0998995661761657851385372991367035240872501467476816162857262794643509591735415040438155899974797001865973911239317650890930815 +0189734426599237495702149267240934080052773268635893422129378135841786547348314154856133018855495625125449892981908291205858083 +1077322089308800545276469380562276682750368988122928137210856581036772006900205486477908581832538965073059726766472615915649559 +7595664231420716081656297104542741477179939201745233207227457362234020070465865805626851389405073254933773440235630530654929440 +4561326689796974026193323140357607026602878702428514108628434286473624453127013395116455824218643518830181373377505009554553648 +5175104916514700448781338224183451234036582197678358641053766734457042147404203339056493172875783393464733980674769043154128903 +9625053130166787806916253108452498110678784874573415439254136465274322837153616892957540974054903367967131773174510386204520192 +4708907023698793329968287054491892003035884220479471761449794976142360667172403302792534515419470234070842851218805657152102504 +5165815294615880424810698811972894519218327570376404414484865603951627216319921021460205245622341179697179353800333764741713858 +3375832459808523959735342163302977206974789134934574309888193442489681770595931407566150654834927560855722717629843449379732533 +0696873250701946777504053721122628669489758761941472800177248115996803185013999823071443413470671100299081264402635064626229095 +8025269049201568533557667082941257090329107268081485134499591411578665111542402290969079825247733361568938034890137999482482426 +8413571137578802277713985161717245739847221863546744280234586017009016274669615970285654793200770322063367655004275873714400764 +0799707402410991916198286689965775278824664119744877317308731118045964149958722032731308079677323234905411311426216785693702443 +4397846375057495792019955808977919911307473873070308655227892822037825751568866737076516050806909779275729314309462325310751161 +5878515311252357335941687228452716020488777361851148660668041257248641752627888839374533734775241618706657533250097255962909759 +7924103963089477116974416014956752830485444377913838660792557425488769129517146048639663168698011387132583363962130759916380103 +8854627858331158799334753893263279859800213644437374816465531701511843970386899153300191498875238863924442400115037208900760391 +6931077305054934679510399257137017692212293765671016977117885559987800112104522229358688690556795828786584220491722127422607686 +1161689224772384204986305992766453244735906304538266466175104130240871760142886069723737054629941552777930420547825827115890782 +1184882323411827620265622192040661772065557335415769691870166844416649885380327832148533301202237904520864333379649271453239928 +2427936123038564183450762355240415926776086706660362490151633725587501086167861442974904906015877742003232322938651897499721504 +7575735828907721001810713381085000197583517056663976862531026160720187808215284714716227545242555746984605470134836970810868686 +7690274030579086519662066594780770842382679015250578750543674207604336237491570959207826549369435808803521562398005006071237827 +1591235570232351829740515082573934645171861807176059621044839781347865804129548447089911918892970375115928184446756254541226685 +2615960213766977626603096139489045595459731295282305420627566186367919926990597793979775395219871115824222384407322704217828184 +7269890378837649922156673232477845852726935996940584696490442582150880559450498906939124023442999694271016368614887466665480687 +2492299648986452580995323839604907135499552296977074591849011346778726414701224990442027943081442825619102646860492552917507521 +1791849743502515995886083914654782544108637930226038487802556564179211481768559160141129157276978288393204371047755590042629364 +2476979194376897909780308753936290021359131405027064825271771828980164040364357335094434041723555965477129434483174161190644661 +8416023154844136801169958073248822091441560069684654659045233353502161929981208692256561137140555110119558013208216615513472071 +8088260724856516409808086622373800856820389920242427841076949364650960501816473316120878023138924750918248626057879988336142195 +8686116426096280530843620941389111299655341997827197141570086674404151699053951971920289530070752071000490045958486626799786432 +6549357623845124371617655875408646869879278421775346320373177073222854384021377119568271293703313232299103659136776571632693838 +6591886804108118051730248844194375009874244915537509136047158661056246282742880964703031154340229700891206754898355101039366979 +7268446901106376070498745112524561027602391892725887518917435705098580461006376837385629028194839014124169131891549609455012171 +2285131899533028794555938374512548939747904214953588004250694538667660139983891321230034509152717542342156366790660293952707870 +7433656872059365457021513060668191880971221287545847083471271690608548455879533083319220177538857519457319889888751900959653068 +9242848205306926609548172769597825608518368367889673409305233019839916718283755877093610440755381268416027885226989117854626319 +8543014996495123544046729990961256012932771211075541381188839964005105738775284593953696325073738652709607173130510895811417458 +1100281056074250163495442070917233405800039282178047058927490789657980634481405379098411400723381012395226453993698124096414583 +1497707784106353163476884094382224594079935684207379351580860836917141337699813295106036949622008098195962892923132082743352822 +0227639803444432864090266134712772762851750164363159986164200332551145986599690734005702172852457747000704439537884708919681464 +3297805927942628853699179019515733067501114704121488080361171310117107236329567894778609250864163044875868270159183178936230020 +5632160100910553597455671868785895773407892040726468337688933116567628214043646404787040937392191211462332257825317687874338725 +2296104873433207092085115555734422123208784998029195153841807872132818719198275132977492788603520666575735728468601968901331765 +8507664661851267844375807200747151263758160914796423476220162799279781135476440706809418288627923653896822426541736985486808537 +8804577755163112469882477676592666556395113447285604375941404675578061757730014398552781158003833295830499727417346600077947853 +5831914326747916706642066586312780276779650520761789440673709492335505292573240738337240722730985752273930258542997960743098240 +0068020053146252182779250786628431011150801984991349353593228652822215156799328870412166924618702218796377703357100331644399678 +8109188902158713215146842638263856459757440491023323555585167449490157093903282451159411558188534514053282926080246371635200972 +1083689238510925211444565358062724034393858074119865447872227462830480815166007221130324188970568012551002420122076677588668537 +8348566408824119448641450955381151117598257925347235252204110951120532544649854733446808547885490496232547849386772180981787081 +4560676276145414580213909440734926632475864478909927595616312861612204269485671554044668485757818928586611911258131650112268582 +6442754729881254198230970045300311192828701003356370115227215491493010569367089158620723231028014912810350816540331381099940995 +2865041663295338237509904105995789610569727200605222728767332785967873952215814407401152907766797309671425581760149058652925760 +4017820912206849712695013871311183547029336150750415340954915312119753021914893470116876327839429907255892388374033828544982922 +6915440546354439943941953788638484102813214756761743923515532313884486004173505190595536349294404018810183152351908266279594331 +2928244470990795144278024903861617956853603900951440210459677120550845092043556188794480813102688176816346489991301120405759270 +1186435866287315352826686449165308561598819563912734578580650689933009781657638259105653726859937343022833693021987646952723005 +8712542566252718904406054272317438859093977264257379132707981296910101101713844533871886378161442772031073848272459192591830784 +1058110999534770164492882010801967465978671453250245066874219221865094533085057504007502380425647847612715483754244102708112443 +1742666667868535721098914454487184166505673192687612783065836658057498575235907333228055857705494275550823062941047285844371213 +4854496575428807093051119901176270909165842784911651361479733219811770760153017103816762799215219103460967340988812865617828044 +1917561105792307812885764646858740340976693913696981626941718101122829669609931847477816007131803415395929587982744622533841587 +9667546614449025826471505952967761841638682554759010436234535597997076544716136876213634826200883843816631177929989595634824997 +9075236896089146108414434690485647098336762127620316996183949539422311636347004018452729032082455756224021955521110115243171929 +7022352504520236787549133408418756692328586206498166126138700604093881377702931259764322041155662852059678496015745189492835117 +7091800587591451755394603236816915477651467511713772374848670866752841854518597403280700140135675063538245814642015579501650431 +3475133641567131461159293976535068676192194831897897611380261311134218099223461446586431446131415308645022873899564559364425282 +3789965382702942084656483383865958903699057640653956948168423022124988840895696969117651267238844593486453639829783832289036588 +1651772364049655351227109534629863148340655489696054950189023140607819232747963074764923819690470465024081626771998338862194589 +8535421442026745607190566634422441543153174467912420591988970152959270609189415618141521453452531554132027545470737271909694248 +4266576066028018898848004953928316732798903447774832407967130237423961865629656870579836679541833228863492849112635373253768730 +9318620813778397458907750295204099889575365028367626038475757355404525059311775107234951920852829456542067713455662881377001712 +9660563316063581065664074432670545816492979485719464785114250983280531864483884025594604925138921571079067953012249664289286107 +4733006686229685087965270923863015490601420365854224908680910247314401508516820945614321593880289181386292705522860502467700146 +9595467875394655716250868523623848001720836247002935008259127820208612390799061964695134992188932480652490964335096936081240148 +1812489955447149372964288932685703059456499125726325849419752698359991222537673326627718506868098338620828381688669635638529284 +2277365318750471576552640984213353147488350298228497735938404810800516562727031985237579073707417430708173600319624539956749453 +8558865515990107426689500711926656694092773040192992037548490908808858324669008603563963750417300374317505710614289622964156217 +2457409596680804630516887336784028949728779145781319560216200606134423822190318186800036885710141555957030479473061434184735920 +9100569805069607595713477651532945125488629510591455102444809609662844669593112401315706794492448332303051585825039449951564890 +2934068975480357331702373570405176114572488785747724819226534222897314789801301206100799457068445592290174980265109976510186964 +6974436264361115896790352170073260547419486352304459996628335808264941225228110927615548124284539746249063361590443246656233810 +2022987197590236256417410387584617910709314684989417286318087666015073752226802244527631727840148104686143554769788772100971964 +3931314203567669848668014170818609543271827823841957939988437792149776879965413983671414699512124596470803895106449229017252962 +1646897058572253319802460817369397398067528887800488520057974357980724071070615260303277654527720835652573050782049698374251316 +0612949136289175984348022991134845911118529208723293255584972808307452158666230105816460375784187988904522880654792018341929152 +6230320383294577758148209875436786980246088588555018398742402423700033755813061790265512976391765915810238317924960933176044915 +6724326703636717615730930803229989144709304487765743249773045992631205387565818549594275877262188712201760168274734486308418567 +9793449160017973876181891146468573134118620184336387033315592292444997748610681437980592831049932965491128002640896459624743912 +4292773888056347657265747923515456543197563688072118373801968694939175467616839381912904118459023550508906592936405878500629369 +0726575398511990054804247570050536297610421442312874646372000460857738421341575986454091454129764640046210072544927787587872609 +6223497359073574286258812426783136238045789247117981734256875260415121593723556039489844073919163685845325053278772517808357882 +4805353931456319684552807410713836603840908704132137938671395582768618313934438378980539779778185823334069713366782891327854771 +6127074671224214243978383308821083055917752075116334068237357481944923919216084154202678626979129283869929664457025576182992309 +9095642603811777857467738034071749226163187428061948529437320054852470403172207781014210493833697169288095448800181203251014035 +4736481344099852996408105951657679269262847981157582390462101509329835494113215114942443801348682136828613264161536188227115466 +4003055863718708771225642500990071025833297545571403747979992978828908605722348616364122656556369792934466258936918430294297508 +0884716108700884651920742851823456839844922966806960079344733214332219603718719129110850475334654765668025057309956984350345154 +4885236271502923816983822161323233481126598003985902081480145736364185121032980985643061033399360057443356862260970037248156868 +9095109506937315402103438551736664529148909771957666146775454439817301965157339466426336556934667643823128218330998524081566484 +9554172468178139926024925040064147501158211448170728837042601105476806693933691272219558658718966118313273471191896511638062325 +9954369358233682690458005171274421730241048095790588467590844502525588085948164312745806267036443692262270244497152879755376313 +8540761990884030057918282213961331175575293790886064372121411245265558611444044299259702033859938015653338871057063134186390567 +2937295853774855369815055903708691070046531641376115545763368983982874877046797588826386810643172084809422213611867667864377575 +7456129086242673800167308357557286842740029636829456648911252509981444991813390655015368895052836323823418477931875989888413494 +7619903401290202996353920197163165845104216512134977822317453208086977782938058360962563863616931222677006031494617743246676098 +8619837607929254793532399964916863199570819754247459608169557658376643077622610923724449371091028101105519894212018425361113161 +0198232737234871539712619394554173033293046636313472444724663228704935678432306609229598127499957898688691002287353410535746129 +9160344825935915883479808009630827527538308033068458669327511758149831271072074138691690968888119139014429832927001663077896093 +6075520157463461341098226057137016444093714810741234441217965271334334440753561468859945005901907007749818800609799068435785758 +0546092246435123497159753904346692263278071121042508101131684892541656872975812647089730436015791483195690674123772749878087282 +6758449872382291050831212201949792798424861556134983601310627614120558124555112900385099751123167702480059628861813816928572678 +2294380967592455168636104873737766456888729486890507823276579714836828251933669783531511408873018452811541618386657467835047578 +9771964953738092240932562360117185595020635073758269035209960005817272212266420970453644822258523689081214708732161974226486482 +2078896042427351080221479050978223463317038184395717248909464597626365437809427793625231151897894098417132582150723722131356816 +2733651127665461066112679225653017158187022844835577848138599970119201959393371465576981148627618500453766449113619920556794832 +3098796406035170187586479893078215549068777188615428168013041309627717475700524281634638706348659216956344427373631234955931788 +8266607652077744997152631910857696622624195835857414262086680438204284388121731692389911117940177851680318293050972437430080491 +5263662912508589659968304863826115756592152285582835871560573052117732379831943224939230850768149596127803763098910581308889239 +1399259544384714811458348148272122374447108528351486026748375991519038080289258112233626298579932128994892803010854830711867003 +0120562601270662181088525907457246972630366755109340652778459673777734310903812432648671068725042051752322546900077059823883777 +1071975377081858251465844724729282629412278512504579575631776161691808267150394386844729953211628319505799528227342615586982667 +5142190253907427483211782117002935160362621628506088192922092212154140185826659904555543974037176549370222198088358512119912742 +7709122677369521964052899819214134971313049580616225982506654419124826044743127724976092244678406630989264402052401911579629855 +5241083294500875288635504487164898666527862404520007162909767182104068330196614730977680503144106835763690135404371824827295654 +6210246422372066059297630639990103921525353988425004032130811899385175353438423745075299078297982811812894692845392714907314914 +6639687154171290857100923298064297354897427312066201467165805288117452112109293854180789331988821851079333157010919824197308857 +2725453575267288288994357675260613771455378866560128031996095809604727908410382843600101001039972876558637948184365207490031492 +3022829447684501701771651529957077694566855215179433255048106574130176149607854191690519660804326926806696105896923466573489014 +2276500150756721393101309310240889850130747890241895231090329328679796493201088708899083812272168509412763541079565359287160502 +0441480433094880222135017379174984153891031352882663477623197838966247123264644246447696041370087767283894667315757217159981846 +6600209627389381111032923919248323966625789375205223637463959729585017236548352912218466643214096190786355523902607233701011308 +0879209770503108176937425508560832114089876275039410069927508813642206128497418765988069857902212785710790868994707145334746457 +1573213691519886100372421851125709104684878670999887084420803400476797705625591520633797149282934213606570900108998582064311163 +8676807063736715112005822408555267407647050728641117839753641320386536310057649950460984214505375532528456592558681408856748600 +0458633214841398749014431880145127111888700604235741500367092065118505389545560189317863466505700948103428117858933891140917600 +5132202176401630576193346962510769965520088034746560321030328807272795203005246723655044384670879356197070618995577734499503916 +6506939563329550580672846170456665825955418030610189100857896112174782009029170826779986506077333681379230762539236049071683000 +6370393487113254502942284063528147627172601717639450424195980075047464787096908959060881173708540962987133431304917906118868338 +9267746888420071021500735075663336736361717345091433424161991124952838871022030399503645263408791327784786086730026429717318657 +1672147391408891002327479016767689503494648768717682253138108661180075426978036916352251329255918145397491166698770599594009604 +1973656522713866421729264353952482643307862403936073686775977710379738331755646451684387173747099995521827339722863619385237499 +5408235756969453434913224193378329404979503566466468217232986076880098924660185616188785089771941834979789440134998311199906069 +2232778818840350786605080110308895419763433233707234872571290509162878857914634432096414764357358087088039057924071148091731175 +6015400792410124384152213047000568844879712268022351230585299428537516602169557527154990684330404034064121063393300034030430905 +2306055374539312465651241264233074065955242079361211680462145344554747450796349210759636113482252702608031612245403353997125476 +3803253691034432130798363413192595243576410393487613462409388440991106589264853952016023685661448176427389232941666704057678369 +8628747721532797463638681268551173019525973277356279608142072485533442125834239673920151827309537064739870526314899247429664781 +9025827660968538606553886333865132013576294269585884802265251611104643759277860774328243246331432389944537967831541391858902940 +1930816587488360252688732499160213070813273038333861895643529140656993608246150830322861238139209540926180077253222099793719072 +8959519042048720068153629627140256241685908963439182993973204720950662335620899080859042503691987552467007737450276337233761755 +6288965328635383011799009079228464765004787324704548708119617161002013632986577780042057914052383556753286042031709306907755664 +9921350932285357024268612614215975988614776231803905241441720250462994526451363159473639866331342141233807338499617054943944238 +0578049360816576019800945237402222592171684814088734743903979539564400529178521960883785173251341874550331866956766247772470369 +6083904254700701911630159329372053705191987684688500636724033475465777760911461588784110437867357713431148790643538763108521995 +0296263770538400456769346062348737783795801732870097577376952964730500440617573963135158364912865598645263299913463769215039071 +9483488255991073328145731534454837990839423394416473517085030613349147333787972449423197209621559003595529788900553100012406747 +6566884594766054381929553636693829055015384572992260492476307544253448277903698366356427152189807274375674035466963843196695551 +6323074679661834194813723642658721376145252523971723277400835325217197190050897668239821693181091121061162219401288326146881306 +1808318984353930429816050257400279035517547964016766257303295002919848213345027516727642354899576468006486504355233740324100211 +0373421583654094261005790222006220690243740321608605292144463259644370384862300052723119124037021639917903672109294422220446746 +0968367458627898019517765631253210766036998155063276402536135475040822567588712196840514962484791203840216962030611173316284918 +6730753402413401318179055308056338575836289967262947906669540139949663260817034924092055901733213326920487904492973772740252118 +6813399504142772729322264698007839309738863435169195740088479397131114450638902610593694986422730992468798340242051077542153965 +9094257292692469011371694239749935666279240094911204646416349941755315640280190692332906803301138668428433338486284139761451437 +4927696735702519573953727266824755919361553550569177388087634691983381789617481807188380885676894329271297374663349552211867549 +6214976348118306656535007501010457882239285954427884872811741042673638154912694956412208130004776408704809831151781445974935728 +0120629582751291565009219505554682954747176012178127728953108970378564330824283571745236870527703343674549433801104649142185888 +3235814158776446629647585300745371840827518705724793256416163401064594247074494980560274282618040988687418212805930332830675213 +9481691238337366800610093527436128723725108303743340453678113695806808341554588638276662497395500403037304969340369996972707032 +4082676737625354210464419813293767706297361241754982481007296169725698649583516782177058747437891980516222464440989464874961596 +6461961406394849542189779035893533584829634128015156718397540384299215958366542622049511074988966488475073248255117221338638960 +0142933164629079463406544918744481398396204306933357431841214352733485790844296470933212820449310522157583393441447538375216436 +3436698506912676403242337919492000906428711269510381173399936468041047249569064777837314598565623718618433285256806067639636763 +8460415932660725184337524946121929924205499042071794021186039050613143778222559008526610557979170270365704047948250328090311884 +8815703597819948360630939744751577068004694199231149936335126538352407733636909351409964233765563167198074923729461436493523959 +0713926842635856417640343723268323797389202591360887205782568996458244122502082280450763638212538223700620622044815212320168684 +9492871418408066338755969200124883796242190267635257673723366249954282292979482645457308347074754036142876356477739278675875440 +2183538168589813954235091042917215997797441009968993171615399263341109892414323128649997905799043937988646881424204624530006049 +7733957096488341212048475007904035717627062565794383079540365496869348281433928986222996400495215587152772750589584231009322321 +6967167721546910451512704467642578730007590171739084668065616508498732163764275594573615283985791091469103384452900988352107000 +6807413612465354023458660940481659053886101973060578770973513038430471528121342377174140575232152423951725002933862875035962993 +5491625968951170241792359320698419197951622254963187269169519754789130928703155856710378168285319433421425146672702276206900357 +6582314544521282948303668171056488977803778991914594073284490075274341682398796202525053587573368003492350674264590216915743030 +0229180917308822559423399370500197589688253700875858499871606888817412759424516191276640847554118760685723541416666202243509736 +9274208984682823732942979222927492539292245964003720945726994325795924579380001664666341956208236538074900737136200088724900215 +5814292572624892701632682972030886871485930705868231267185916589385811869703139406294452824977282139608709779376891002163708313 +4033763100173660376690182575379995726083861081926510802579785312647154456013703372795547129639766049095465742696104516613357933 +2568315805640894925038031436747677782703800879694535494046794349191040639680313707242709239136167699797774023104845097743799234 +6763080953224487156488442945555613963349180931811315907436001825754710792409694328952798340996992622252003347436512459358128857 +3954533989335010638156841066648473526011867397359480295694595402042037502438174479721797977373598413288286342098814213128179837 +2396433612158432510452891115965816912823381888049756989510546093247222344511226918341455435352327199403241839439420506108676964 +0795850610161143815844607948060775881656537958435083754755508315612517655376939244238451149176008256028242905067513932423707050 +3517402986146524008574508829340726577308717530546869694363472906429850377209335971237767032862995433224020904386089476753728648 +7922151222682324169544546785791039508552110735905147311483313421452486749631056709157326288104257728264776617306059521303067262 +9433265821676424821718658733270406951796862690935463256100330389699577509374904038151899940074906081844482171701461900939078601 +6186077218855804555456232441080881439587655776678203701080218698681846807414980313213113823373021577317623820418853903404980853 +2057729858963790488672801591735476430626710017313638370400064539747700089967564851982820372204387613607305955240060602392589527 +0383881550897793438940267029950019121382581949345028853214775595378737481122241954444306274659828618843592228475107234699152687 +5284798962706326315885441962112759776606317588723708150855167126722288961236786090248841992912344949773249220873179712041971922 +9678187960541674562218790198419395947752158216709587927827286969325482868753908887434457039802709422399284864987575179916747347 +5327838914777072714692085263368643404584146218804037383216974773265161119155906542869845216416813947477024304569196702936579095 +6268003933265575972147374394617649572960257762413423428779104569461013465964897200866208582709538990234194911357542427621601938 +8074876525846270711334089333528645517621667077382560706349198812216415510664481057225472908752257947691952856523071940619013694 +8017368030459649790293701927587307177007662644838805113977690349437913275410750363651007980050566471766249753077608880102272532 +1982797159364965178888531580373430260986522031868350608333752657707407931000254944024943348168140524874484514493735113742249981 +6288538584949755098193652659249807271937205648283720864311553381239244146100739200355642491916783137202534161705603274089556521 +9354739749045138253043275273268328367815186805183694069007675806235940663397422177024952828447038786641822001541524569479714913 +7698528117160783953905420058390896481011235446749390616223922774275291430828661119528466868454607218473820114505896776059375354 +1619019266174818706077047840193129831420498197596777970098691437675408999864116292704117680089265101055969410774137278714249866 +3704870678985840970113166302795462489950063082099943547515245655672648446079824717316402600594084559028770660910436751665528235 +4429408197253611572221699160867353954702111945889329273311821911416970564822252007768702453855504730931208682912670990901446785 +5056501125351085290367349611566587022633517744283896529455313187439470673480194626772000636195743336806541403680260332379718964 +4062991551971333412504544251310884322830607074386974123640580284992839293238984564989258127209764459890435786526862148574118080 +2625522665812777011614768650094518338934467618573508691312860257788451631146950375887371627144471854275002143114396671788841878 +2226696461215179698643658067033045890658991544538880319431666117259518073995053382607108900045909290904771038098705696699068324 +6726532088338857549906950143621062126429461929145317128221035122460444306074528944822699784500814789341052158726046904507897034 +6793037164285887325166583356411787362893236497739544799385622176244058491240539097656877256235845151279052346581850041111149908 +4093573044381701004333825958081420923185855648955716595548583153752167241574306747073123301312447687906770815027018933422227596 +6707271839374572454938209957923490292030537274459728356418336773458317286912917431092307541994164910938497543069009665010432516 +7241600538166073336929364870095691302789706058064621204209320909673557421090888354529446748882788614331747011940455844576764284 +7137143302702161225320499515565654830535431434870632910006167776519433451398361978770695152191140156154509207190258738746324525 +7177837461622149136708945368215880972643302158259696018853584758017706472295497707280871705217770629770641478542481671610250773 +5554013978114456033660343221358867604345109625580200393288313536168463029481940254044728394046188030569648323861618169629477000 +8748988786120543881188413407361779739580428614335192009085939766971185616502526635854198592751325209395171686208426924544564152 +6617729010736669611153048037379873649289970538055287963581277014784710903080627770559078145423490012308690390159447385760636617 +1396112919025930755072794022535421762089970913319020087082933809741223660404657644541118861471741622430838236195432385726159361 +7249197652757615950334012535738132798576509936889286629270864681020298782574659494783085110319815705595177485744225974776618676 +4858557343521566530159783491610288461205535017137620369901510860776505101408698469561089138749268742702921025433191359814405089 +1405508073047405874902803040100792069570430571449445778558936794822787960786336616853548170322337310425822658832018643837559079 +7255075818431908394615699437073631405701119134607024097267578921840611418622682373870814723883284591259922905738590072345115516 +4240694967339735201081972989105259182809574142617805837465112261091318429255228721568810181664317538777929819157212160575829023 +2748237669200464565992816533713130419647283186413179673011963172187269272224647869974262327569585442612854368077691269344188871 +1222760335817459965853292578856201576938118519312855304508610105281112231513426234814422228921425942855517206703964421120719762 +5224765636718330925202872259803187360837016560225525039097597027027310508724003400835919326880989701929146674585353105826375662 +4608686356759945389820261327877835956104857982859971343770150256738677287345081654437248462809898624047205228119203349515135144 +6762635128848980939500701402251709503914581106728361156687648893186497005364492516596632908393739083848785619442884628144162198 +9408219837678921746467927680318487696309519621970987584546154535257273988915610716263345779849862915767049642549659017655936977 +2878461866210176159858735856155729710212544372367962529421415383498942572742627275020994117127943578105501057737118382232121164 +6202970140395425040275648643808519609153095822076099220917958127812733404125781257612941188098229102786208245263355552763155862 +3412899983063072356219645639174430993848691176774827540248823520470123385464397586328853608924297363157128484769714643392030260 +7516335187749776239975100738544129195651952155894618035351972235899711941435830137791970183095848641340212385537760526454996975 +9326117473414458915105300842976184452176417489508025383214692364884363250764059076859137855740438113389750789393201920849913143 +8213713819060950631004232834986002902474872793703875917119551478078092258435100422531909399249521481966638648761188280089875780 +4759150755939784604117474362263502288999681621525995527689733138120086197663894427404346527959682389904515329738583325486736756 +9325978425209872464237977527958499931962722888446298443732493719892549369851302316811008601401750818556435135705126450083049922 +6347121675883203194927076244218929133933870815129366063255106247006180593262999464959953693728515646161688550961478583928288648 +1770297585530292141472219789662846895032928913171250259285237148388628954759446094661658933173846573153793706711301693991850474 +0792606603197595851399011444059807607822829889531316870539398964731417122727677982590799094547174678976545309066723508642538395 +7542251187115005568283732133757451228935803355815247833157647444961116649664568241618566131440468159056245333148920222556848970 +1686590915600101341570938724862037843381611006851337958368672209742162426192678307570447318588843817286911928534762475716887889 +5985898442600265569905129276649109155018541224177922670883691334985077196371351903258301592600475229763499481236752268688794381 +9908334038229937596478744640386393429233365920050089472460888907538665294038594595567391991275514366380037563916695381509760722 +6697176988394487279550132960940875716670256744139528862226095599316038741474608986574869723524996958686407456560239747388319182 +5272345146409276991368562911742268892736319679968918454777104809692672080906197146972033144703725807051487037561295160467451538 +3361581138752178146561886363234614574825214993383047665369152075131490893168140965966229773832573946751662445845244243875117807 +8497747825333018837277204487016088859935993376161231128402571833027091271675038762646104326773996163504827534262519513030402352 +2850247104178367791237021165640248127529302018809122924281078393572312164207913339929888292707995450264033189457174311609184073 +8924909933371581642458243436549195910810805622486372258791244747556044533591204446068293714215938334798650520367000310196349472 +4508128384366452869820524778886955415968833938807781198993008689473057745756213279992800316467476453813822465284911857999907387 +2023953430847273884483235864052375615320236609720705596526699723117087569499174093607783752368506950667179330339328300764225536 +2114055767363508202672868934173997107264743852817603394956504753530153541861401139621693806395357957937922300502759889840467545 +0621018093521434841220357944235687355230152336239627344725027296978480489999738827553268628247847786834042126152054295485896741 +1728177905254640772617413047936979080771772313470023078251325162582234445493894126314939244900306139362255151328277418578396047 +1792422884816727055970087290849551106652457784152258102530082023142369893647618177451355631227247379577671860849853688299849551 +1175037347149672092098074310747361251964753674884333700769847744830036555394374700856740987145924794681060765600644641697283847 +9174589667717240975144336198616364140632445180996668524271118863864525314244946497799850056518633949293612226613509484575056441 +3024489420602308444377762407441001512681502589345978196662197798484057230208048085644756143263157845710447555275495197040972213 +5990095737215350840694710792788564049039561363466293476205766559255673678361573392948770517450420686662337759686497763541080151 +5536095650185550909008740808818202276021308469567387829730017248451381382214473271435330569988489076831395673641296020100168963 +8691489605876605176450990544960425812802030262532258796192840475047025803288315858498575542856190938582743335067317105863072855 +8766959566097551451268355313989562707945501704157509911384107284566676448181401117485715830603954518469086610851712800284373857 +2622452939630203014872224939693671859800249164641618680985148159351811785234412541320836473437263872332827932949209391274805175 +6798235720998149184680985250493187047397164050502295623889415695762080775856311836882958794525078302171514915009308220188324579 +7404140736104785086437030648484406734008243907361526117865122472043884228991384547907143497695706699559582484787176857952820522 +8804256451428134606481551907263647977538193140987930551038510575189609463453621867637464848455610801693723759700181203650436839 +2454914648531519297448584075603475998203868332048006750382533505496359960760723675619846780966293281981298326598027774066580197 +7995861529357273876737015678397822856184868318896981667361295506177063218216975663372922918478316465965515092121524544927046347 +7075516111646427841984461388320881450094372462158722036978724530408790912720869813138049436688811195541657354372228803333585071 +6429445107361977048898774220057765467210817429170612447918756002833100352538329968035564836996813252177717820091122268457886430 +7174078917945962391527335388096356842601813618444449251961003226992399982772853124625379285502923443657958530018722098893816397 +4966136548214340660067711135963960273659031432856630667889996071606345454141323196469871177597395097849304859547230071866679596 +3726141431238995322616590363658851982624885785492321657227849247981548495242247508727680411775990290110420891478204977360853532 +1644317907061571688813615690182418379232646792079005297020445585096706983621152261491067330546246215457831060764875633375743540 +0260037498619368766791619780583839981870124397870392302778118229013764892065306663721631976910781105530817819103416467777655922 +1257160865985307861172892171513923812618825522832093610372208245587343312911128848417617475098350804052464802003464019493811163 +3766028847159301257741274325560482246090419451830573366629957679849625493927009484554531296839025641820596875488169323390321224 +8232388226007759579919663974563407506786051531271638328419810743863932368666194478382016978871056258046863096095307264426924960 +4549834654287891305590680957281622094960361243150054432811463994295196664383435297694301203486327605844830810715344529812950660 +5753311902123482227347291010505867923405362170620911512612976729652957268599586765352146177919457594239032123428411979879139233 +1756522666058959488542110121660842887596621268641851969762507171503624064440144225359791257651455405971257235743672383114242117 +3669744927951794530124706132421697781115421405857509254735757547057701496218013526040546290811670945415111481766033696065077908 +3743986898663416455838782244658330408591406810811925113737418608085893951934341548820971030074613077943621026895167359064570606 +9471978412930979202834282673808363212715221979769900548835760002508328425519756934140019511728229374555172954389643589129389588 +9455543651731906114795743817911783078297338344457513508249293073101170733009370971042675747320086133963697038647918247059612888 +8987238012717473365026512535048463787033301244418231940438539856074603360903070483058902057658066015083363248256775852399567354 +3364502373064620236820638615612559600453180311037005397530277541350185917242503038852432559174885033399595723295543954546558084 +9899331087165498351833150053347482195081440704956752507876144131532942935103436324218551370249739155812929164520262875021494783 +6908904643032400627041773579937621950623563067061899745276566450404645141582156514162192031414915906603166745603027411059622640 +6495757281070400862553880509625330137059949973388167457480215447233006890221821337932185784669081820552176614865399261551583475 +5214987707999082292941559306056717820096495439266384956685554643672988468125971218644583921446293636673793845912080991022068721 +9098075542650837679681095355197850211686123726685262897042587789900344672369748441583193738857149324437982999889236683375639656 +3454737499177458611505297150687929879276146562076664745364918792408073476880967147036390541767431864129948395331642282070602239 +6878237499611110425456520778926623547629857959652095556385934261653929146175223058776396057712180642186976052559776640567287939 +9117825842497962507655739795549675536045986355442960959176637564697703951624943028930326642942379066897205661256857648338706258 +5607249824040048715831055763915681630425710558796489860046207669351392908027930067134903067626066854044057840603625024212216072 +6132093035960157469992103741008683953459144927130308314821395510817197195888871912314613073270790771658400690547770532514734857 +2289766523163076031024159344583085122839051296194651927355671209701571188590931542840886950235609126079848243347538568462648984 +5766639281060869652151900461538022230554309323803322083408453315192390160247383316259588161796028371801133887539960085255308323 +9483650441565836194775795637439945189737766569777908677905305601319160962603730861873961369931413625520373523170442339205096446 +6397277751314562067770288602692729550017088466152598972362685935373861021657565974015373030623318967239986491125515528075018887 +5402601339014610197678055292860126657475597634829577844878918241260173909075027791997352414032212153167271561905364752619385786 +8491863948995147633786778542070447298998068007279647829967199136460489001972567744945790789456373114064713748773853626265799228 +2370209092117301003097542080527068882722669167429990641325299940901538545419032212913930826834352316812337709858765794889107909 +1398631884718147949515763634548480975677014453715972288924837802795200463595978496786857308537512388719226166051585776739717368 +6941189534316796817726911487247546420252712714875639017653467949442416805399033991555627055669486555645886651826109264153186819 +4940516166674720818220542130511334825103331157208156275492549414655335399338455554953498955587141484886410449146234826660024826 +6659792948006838082450272697160209259339168888357685416533244048793279607628259013570705943914832132649302220555803191155769678 +3450607770354143996892622745433805449122734203977711922327068576407370897444833149206827486642681899060356549533970828759001934 +5727275520263633514968976110225542746359061074870472786303946464842833869445090010825025879958856002949152638295200941043841906 +1327175710840731608371208629917959139504834096615996636184118498113010168900528468440699292352911245996048410672241669829930509 +5804872329617982647538232786144744032881485213965459136524837612293635959247462464117508493059931748287964717902656930987863246 +4277723315738568098484054986328302182182023008609946701266751039890388797338292226205365731416488922689962862442504898912370823 +0169167783207015850910326779335592201489472916428336283983741331168324385837589731443211700684040249551018329769335204931232483 +5298537282274168905097783252545295159931996045324669229561719918373117774516092756810950028198012718738992851067743291059615923 +9444851345487696935698137109913963152214976022384665735269814043959675847649595558507091607437770303094115672250928216923641250 +2149472592686716079768844857346451000286201002122320769034758020998927559101579776094371380910427183625784710226757782544230415 +0647876642293735785152692483992423954470320088754545909378609961100700126777198798362991474951795873563734734785888619665299138 +5849838488444430649533263787538811331357728938722568950445006777515651519234515285808516388251516110101450462227962034131202241 +7276104739525907372419126181186384546119321638501786879645354354875497667502927550069197442007577146458961731206493061524033007 +9422217503140335187736221742892478886207544102369268483447607791356773560830807813772377547585429918129160635826252418480968692 +4951724274446263780114357613049442315030582695389596800003586264063614032462365896162651936067640252887621519671734335954108739 +7454566191860852039559843736923834077952568697550937244831873949705841445761551247253789687164216518186201016215799884228535871 +8439893371971012000885553951535059948361302183174942319645796198457357286423328894929588756597087846522596101434099524110623679 +2208231333330844864465745363677908966068876448934931718761801046807820975248234034617078513450119384012451530340905431793537946 +2305572597375584599916270867173159433891169944691281508143382202813205881528811308590035206333627177252785229699333403132814188 +6581817307307772248849032636830370028521484024024459152842727518740380359881146898101434552487760886134249651169919754088451088 +9972253499037895070298514770518285390402914258598519025675691003304065496834156654347189749182550625905099172508363395356804877 +5758008808025624632351941198979018660594929305107322792450818499652772086629264781844489198081813129733546688788720899531192457 +2745675328488913480621264293304705435951452309540398654081411328496424730516137398740590505211615977997709945823736263422098774 +4319217301030265407335508264753089155109074707762624338354639950177679811707826932551029618948153019495825747590381756914645981 +9125342547489286004121333337059776054538539726153714180036823804029952720452919240063140345998373975940156807239544138619226508 +7242675874264000704878339896544038336920890771642735504973073959953113142490324395737352393349120127057115852252907686376626747 +3473321596354209308933007945651010752129252885281924230373167976919072240297072208573755175225599946410500654362886750707794528 +5727589543974524706691693259117706864773673979587751324354353742658357813584415514973239116989629743388388478173856874552697761 +1142418605095869987288446285147568178401344806595851658792922110020211362874700057924021743582095514290749364426026381491938886 +7017216586801442390706943294273005287782115442259090512088524168970016375416554459606914186390125156135455842825317699271637907 +0211233315441242280840462166926685973850749956345775689925242698347596240183158491250150173733543845430700552741593194555804750 +1797724078344241125893042060239537330994558786922162379383591805537659608535521283089375039292199790021670953442916099772863332 +6130652679697033488878720295305832453720948952785209088953761883766005724826476556165454243473790630572440696210857988190704713 +4744821686581324503785124383460438165434233854467259677279955943920755162775872557500679297287992727542016808831027373389642811 +8818850180176632238377551894120301699425047464434209428644888921239546400810384063448594908229208386662084553428371435016786566 +2565402723149127183692936818466510584042955514361987237908845951130503356391102529543147109435545190864583265738886354448729716 +2555888389438655691918145095510314610669012618591908132566801282747594112804817710376968735883323783155393749243633468461076212 +4037970808854790499072817736929400553034907676890898900783090149602127450205466513482819048073679969106848951996174948205730701 +0816030875372524859030697931442206128673990318458281042368684773151576092499288971063578724086458233384930941299441451767263066 +1664521612180858396451529620088930659358500352782541669595817923485051339758066634536721977274523994998146473981701939017205602 +2524104027099484717563367769361246592695182470261402965977193164101572566284710942794698915634141627566609476347965721168530986 +4359025426573155220274777012266852482447049345363636421786714781355224872652596955092178684933842367455487342490049229104686636 +1405127824749409497462184480237538519293466992317964479311951604897323056429690265101169427550747026874617333157171121236924703 +6018076627013550295381656119236991061160617457180144979226462876301063552180250667955529552359828561142316939674528337208856344 +4374830018868998904944977293261195517662546966324518234611103690143089662138017933662034152841911712239931096922875112835748433 +0236447221655510600424621887641222992324877860049632049076965940501963553949996895966286320389211270787434721126820780971624253 +1124118658886218410732481795333541469161905682578320893049989427979158879370075562912903672274463984603712619157580009287344826 +1490073439715132975375184719480763004789606934374075237219980119217402660147346676094869754304392997432951402325274930204871342 +7507088153751893726167389642050254715794421419546083151335746591084804700733010001661585164038391983336305667211157845088930512 +9454605864819889656904342091511833717539963300409957365660591244004512939427858955522107791635547956216918186634105330346773979 +0658593516322846162016300446203238142166026181710436615937557978420890524597354295972144917810824199008158678995080211427722929 +8980589661160288330719076634082892363742482807739228207426629330991685667550752678607146578792931470069849286956087928508404855 +0981420843325337105199162550260043516249035154228170027681913983488364730292863723816365277728171439162179656110789246164875870 +7235989772218476249654125554327002628917857770756363184283174214585030441232386973067535578285982100385381595377232095167172355 +8531968481709055316167180990447601481938541581517577911736493317452245372585792259012856477270057051421673563226983021870172320 +3966519268023261060863087111821082801296148611252172465597370204173800451852480272015584093876590792853690848377385063421097933 +4667059194375637666825712724740535719642601441210189891690016272378550854485280624499553958549215837331920055819015130335235748 +5180652276625067336617174370015460185337302241346649852510792894228685353669611675801310899772318114006268028233834332313504023 +1941303813100529733477333374209673305915978659212933725574700988773740701325826021523545062039757705261878074707241548966802269 +2746067443336418197240323253838643666106109625323987238695096142699993722607024221029583744572542375113816178166737688431737737 +1790082381839115387609873262982695752275538347088304949304931589485737690198187441832377091589179048950816796427590616885843542 +5552689266955858826481326722121453449315123458065490624658389457610909531278210069460670951157478754958271396713130819467585412 +8161144774814776141255994752061769287038765060690866140571952344698969957192475271081186838639007943816699743960034503332953194 +8789192141356424274503562578603345033063547574284980009602843989229909463071658256259561315235167835094522110712803401150014304 +2269120125327746733199585385420581800688978135760399189023545691870920243025811096318243711254873352522759304218250492540601301 +3220660009367443347579325094663071621014417170436158246461857082697811419327408184450532404128001876815109034413458694764955526 +4236810019612678173215181621403086283786465950563987195979676317579127299901400746488219293603220797858502005948349760508971512 +0842456999754267165377711495312735495780613161991580964945616998690779002045181519007002606802172925174094502143404195978695837 +4416749583760585438101952975396064089728080431113199590836008764153005621794368480547875309689843049490843783015113705286745691 +0795274682904383996694242263473123412015847505963674606830368047427506205910859669522416907398900276339485220277009294111636658 +0726660439712285671104280059752886748116228091939311944983809111670167487220776456879193368274819545300958924106260054971842623 +8150764216086897115298219326429987785009191738597276238467913392040684511353140756968540557235239878544391001829270153861846092 +4383222134341106409110971398373626248863354871646454326385144812872101996077996725153807549596115873770116755372384144360289549 +8170673501302124114120744895395545744756695363267571023745570418014263093634951684729982428233593809293841917967048459961199699 +9763136038244743451806991825890314924556837135102471133555361059824564665398157293669951119702184740695499289874076409711970682 +1422421956968116348857989939957276677533229421063047970708284154758036180433546990214632661390471026182712000805513222171655488 +0790454789270387069048408785812014404576158995323548751958890039523932351478622587142638056133836919868045535455845844392024399 +6828229983228262659292226957969701095193296498963956591476120614340834793473477949399153199148731691820887892496627505449096093 +8624492093374718033878604413583151815223479591147786368391299257097621796393142945746725700896309907581595691253852161958930992 +7107729406703783687280485106218574382700030054257355689626925093581880354626104182184797971451190514868852721286584413091561305 +8741987234103316893377380144344514006198840745678799814654988835056150781397439910157073114301452768509065135515533734967678598 +2735043292667576626222020726140529203825880750760734206750175908534901067729659839678099054130592189468939769616706044680647240 +2763006819383647925527431911808115681683993973822624367816274873450252222984650251537326892288304742295886859351709349425297650 +7134753100395351301348083365117683812003850761712390745630056031799089854945233811860729771699517948808663082113548033370410055 +2156718353193091760663949540389192861228968135157606923907872289234299014121301709409557692508414639141148641363055713300497167 +9323046502608972228620000366263176485575290223984881067717695579312796433503231136630486297616245185739116228913473000321724069 +3402413948021099348085449161508115950805641814124236561124067595528674925736958070838477983849773356429271615279624883406948406 +2586362309829746055325863292755259087415528960697154410026073785183365372343620398551768197389974234910915413966255239135166137 +6948141006945340339297784658800718813009858499271702100629421441689482806248257882748211373263608811093415305500022007093455945 +0842258683716404942736428616895358695656655266518974938995151040768012671515151979466768515865903424648012383400333040320383895 +5049269512019956300105561497239010604854186206683961343893764070138734690927147819767835829400814779254514025647466904224213470 +9569948375696342652641662102284605174592869950745185014008552719701570802715911338264166097617707320465336842190177333964575034 +9428680684767284183633020532362541285325879314896297017757679938122092115670160403478099811406505218708402491047782860144041267 +2048668363875460097326211666406188941409324970507852534507916458181293600129195542233794471499710031501087442970014489278431811 +3405993437193068750979763065800204417948705854493241428660974718747020128492308645680153785966021095932035295060527677641892559 +2814589083509652662902787080397228682431174828014560598681492336798258054680671382857806718386021239491601389601875295478518945 +5986699496572944083337074930929834075993621216590713141225309670719782429561351058677320246208472110574056384475102009208825158 +3701143845992716374497567663523592738178836225177899343548036997338523733500001300643656167477000925420983129066143726434092701 +7423291379038754262185514882391794604313384501082737513845672893062736061561920457702887522180551612186897189287428790772663945 +8038882462960387008399150903931548842040303337569963977574310341965170156166264463639669524288945874943197641758694114087360524 +6755427287648373311476510042437767363082433235534497669444705172475485394287772438817148371693824101932257743465051113814804574 +3302584529244780057393036854445554623243089576362550605055694156880682183315829897197741778897975736012282052319045886108088033 +8087176493289867561968800923375092924482419715512093174473694625106772042668885277666098646361898523510402733964872800445131037 +8320007995921770348498605128869111626930267035943426816435809551556518111290098800524644244409358410267473862764842446130048523 +1436098828025610017328979458386153232076446194265248731690143382189291992244935737904603822794261840119592775301158595671929956 +1859896675014716704798696047818739852245706249557223427847334266658566082156593745460337399765187932861285602937611319183698837 +8695387218535720582564065835479455701900416698839376472323627804365945785468346621682197696163783828936362978547295808542269445 +8279752484506847142094417985544033613129823835703913986703044915444548737906032583690923865665220094573089105884291792454719678 +1316169725449877686068579181522410565098719766530274437681078973112896904796812316498589687674134438686508004774642199962324204 +4690063619499878869524791692206588255254568407388459022366711747832387099104508881401463078787110967721065394141648606132537550 +1451429470869671002057789223158518659342906175930490990163086609677315590447420960904216338864582531646704745882645257996753003 +3594769224483393076962577578336775804994360716705648101110515582304099946203974654110102114903083901640907564773113403226112614 +7842811390980512417623967516307862595714647209118659868698680060437058188686064362842966029195804418885454481156401460457680810 +1353730331240432284758809177395482784888827256712163440645440749728289433010840369051942073911490213001477219496896397735829211 +4601945158211709423733169616586120219445506544455684681994448828365740758425856347182450418912396580393258871768216932273389644 +7546606883962070377792485250777570864737360035965255716590780907370097846008363755114568550428189781279182714576817370377989913 +5909871699164748481388103916215854782263584875652627145927520783000462057342075067627629231607264735052014948668522278967261465 +7789853062938105623444363261994088544665616630390123445507860288440231593034911635167838522597643333127458708364830418263896184 +1286144438352596484065325500754944308173042437315362632781599996019422261591416810474894175619846059414717720198222378370653571 +6971462477582470633206125394932199429053380382783796898399516803651438673139498531736021776634684941580638746309619120992683170 +8629432822993724963855361987882118654589234693568266212440633573606219295689682039033133123609808063033145394447533709295411896 +0281594967652261579794466637274919984182923757681634332365968310833409307348568763974412665592870158544818035335013012421932763 +7655826860692715418764005666669293766929001138134358352328235302135813053504743107776878655717896623753934484760219931500298692 +9290168663678775972562133999711785783179036668870829240738642007250789936063529444287722257668245891843786516368999364205453698 +1388094089899362163718773572230079214466119375080348978705038480095898940916060131319234067470176587422484787467679366538347868 +8017293664803927630769729168954945146012294840940686008911896485848777037133106837925465110245874730110174759001141830380040038 +0120439722450454617928179479243857705288134086458602893871161972846537382451740227055242495699985657918659780373398590814158015 +9185549346791665800883510913273745072991047690371888044204398878541170797025220849684634548447569944177523688037116487344544844 +3983330147768673814424552255794031561316294164196820680509267685360230979960997521617397764375675161021883986966830273621436840 +5559819786199323213875219658620019627595340113429135282821726501703289978583492131096279542835050405087347140325687712807079487 +9787946090092230362250195573096660493646419587912974580035697132589473417918325240116393969464922906025196729087774385693764553 +9860355320714920060965670358032280168554148297437945180860387882403591842300282814921233640661490871801402207762626482522032047 +3097025361491117451005377278198487212237099544908247111077372764356886263791448989161160949762415522639831639294698581458345985 +7119461403366321455704765813404706513096376229662175435103856904757065360840168635845572631764671801632765978886309611217770123 +2355725108730791813146700353437818727398062989969964100944171032459233591148110740093249920429111285758187817891195538479372333 +7717147589069034365041184332554553609756818941590171329038369697464604453126540943732615622700321916184110353125350100127752260 +5400719243883713007355805618610788516934976237500923767706894033322172234355015854525038569883308926393709084041999484656996753 +1283666031444516796129629651038339271512674202354596553588525167158551065999313761923723647718179391480101442800341777895133996 +0753973775383179955400385390016380992296547654995782315767306424246762945687075752145691419815405005932537449947304486849576643 +2979180958396224767297581462043320034127704743702992357878029772922817116999851784773690688789215232089766369127969016032601856 +3851573261415488209314332793330099314068046066211719044146103127781354079770099732602779302176734228288014045681315375260376275 +5613084622744138175415292879907528314309988380989805830104342547726499059288400078772029464667932988421246953056079406071204771 +4586730576036740853854978952480253788859203002939257757392716256983049436420156853771221502897572109716517239674204969203181474 +0982119350191052441755943123327258611832950316806139591389360751863567226397368531779203766930988225110737707276225086269268083 +1166609927459152345242074308503846915870742513191815496448329154263550697382001973332037653901875197894977220232463712982961473 +8742250538546251559619529217497793362557849446641056066254726761640756859174902719692841027963345440941200289292587371677456563 +1787473730619074666648808301286212846168364513813858291223488226257956569272198811926719725754005926219281926579718279777830444 +9964885779070155802556863992597887379404305287991864566420006473195804170299129414259096081893003248613986369776375193541122827 +8679261717535638702784929128089835277682571491318590535314932208130153018789998592505582846756436233025096155853923159667457622 +0064101062279216730164192200983393569735835140706754353527254528463606619322108164129797836707319607352924077829068257856221565 +4098966914598730293864163204728437998349124344700052324246741119119244973881766239805489297351925527481613098094358252765642656 +3256631812453399632987567720287450907847236484423613740997675264597104916297183865029408528402827703543717537820987540612308827 +9763193844988062420108359297687488837148328286540087218373263127565810612066788312087172343604520200144217517124505185828378183 +0839169941798971803467138716750724876136916222233258526467257984594030393990037357389464526262272705365500201964650768865692587 +6552250604997641261294087071350242489522328429130222914193744223497369981001341679952214443941383946458063259049876349424028513 +2213974436158368636025109248174911312580051245505113315795959437260475388392500593400331863318219524296806654096778830779216940 +4878685599516319690797457606707664358483790224825508827231099632903629838432588023623129489722939201221165328880348763488094404 +4425772854689128756512183299147748549960529805463272504802739617344094375960651486501133996216955411590283887952698362709773340 +3400068591062085249345178361745959828363146278918068111168494145377017234716441154409189698261322125169944980545699464089750536 +8846865398199885991570109728269877331973845988335052515573008133676441111176443077214835337189028637762538757833593083011292020 +5146028640720658045073881058022137119722140728994381646856170548927402303281330627742305686994941764560406751703346767750713886 +7209258975092391507951817856714755923161856176501059139093203502102911025009832983122251947751287786516716014787221574638939756 +4031047248735708744857275535082996528246946792080390060989384866585501142477546435169883331570932498501313613151748523824910672 +5636536308963660510951867259797466984603129916969819578084787382312187680895777499152465628258228314680156051454804934741689251 +0512085879302345402847429395015269085320583560263939898103230391420972595529857458723736782481282792113866713373594735837816637 +7989131244460061235927200538684991689192443600011394251966967305334141431951393722271395226793607939272662478632186079903315157 +4105861225129127048237596511466748710669457275423951266966241892139141936555720690437418563605034436351637331842274069357984239 +7714780490538701008702866992517751463558344819912101444037343071198346617249265664311758101747127784897043351442589412949637554 +0794058900554049165331519254294841158439399536633260010261808293322453935679510287405960977887161196498223064393352481611148599 +1300801876528225731545729262391681879452425698425569733040068970789105907778300649408653356394071182530765139660697696280006682 +9500403460028711452841481826687628011337250118712797471026118134978473459279189369396543791538899643830373887355243212938105191 +0873118171200026341001915337132116843336126642682077009436271005094613931653248785836179383736770204896797782028704969977499350 +0015763840495758341501065058600781266869591393444306380925176998016954972799133300711081355008885083487358653288976991291458433 +1182038281534129680784410839850542254891681906855217404657576532842299794168911463577129652659153953666202320168343676218151354 +4489515205537483086890747806185147028159038841561163491305751443503026033718219551299657596422184541173585136713789948319572208 +5427049518844513938239013971033113865769356316346953363872557559769111015332419532829697997722648255367995610629118024243751562 +2407474388820183495631279695253839995841338363502759887550630065930650395810552864219034911688436057782562693639597408091177372 +6597246835826333390472023469934087393575305915386587464255626374910540525559513620612895257369286541372428722814356277369790926 +0540482329932732167361734686964636330198342028336626252732092257904785101659859937597352536082164206650257784256989122547150860 +6958569549047812907458129176134743095874743438183862052347741885494624143736509130890665487847350948675120079666371405006768737 +8780431675373547960195603385932928721012510177772630104840609721475744144915357267790854338213160647630650329373129575638594956 +9496521524390891252020171500116808958864975665633521384560269916937417268750283135245520953900937858745308291830904258244389317 +0015367958131832930196538448945414897381505579147872992058659675192664335486653438990141847260783598099119731774723267313420147 +7668586967951300028516829535113315808229408687973080784960696295388250987543953394689424360452251573606982659417899250410280988 +0855610169950498351316129660470090096789046559977941298373823170600445713232790694833343261118257499105417238723309775430866295 +2330553865870284141777533356762036585595078938692432368606760459748846645365953536258322870084801797022785593339163737467833147 +6997226216417469287126591633487052682393389785830401431520389186301156111690874765557617527284900760279233718743071166517225051 +9560345000426728260399841368953209835209100487337639538936954570820031680886090876109665021023200759147113373797389077298422122 +8175155068276335352679806117326566700814346009488428499581701401590558929437455938924635624938224553855781741120788865291783407 +2295536946679503673362429092591476438921243024065802176610048872694278802256805275897901963915809617356852239830206442834187860 +1980560976965565165140981488552352620248220002599581191144636050647934285203553865821505084561426414945738261567792216102403148 +1151908591260497769379834919810177114427370448525005415075150280396616811812913926897078347185577604045023394052213732465977204 +5152624009308747654657296667409633669797187558140762249677298229159695566185953786763883703575683368256625993695568514289670471 +5898396239237604417219674285036697981388707533386023577734556605753254850219222927862511398982564982295186931657039590148578018 +5932796785525089331274908323688642021701636412080489905006446995970747450915290182470813258134915840332610387871533886024451368 +8138194206803987511384906150527820013265474338857553899093509868964543274546783521373587071739152356855552276377502435950664343 +6671221923018976396144288089085545597962326938710922261699996323322275457923099268605292778087753199123847741515682942101433343 +0553836973054122354894964985734607674790792609106461042226839499946875666977767744836458472114784382708675816804952000351499560 +2364997010884637465860014885474868656892220025469289156670808481103243684995557245150848863996066555128792257705475749161690025 +4110649532154387762250909130921439734079690118528643911754202049214907597563788601359791270067268169269560624171237553348861595 +5940616224028249469894892261151683448506705471885912971357007128279832881479611563158245452847817654715394431167451576558923691 +2701950548115303007534807474569747157173002064876638265966317419898895957065042960548048125830083650783906003217529190210069108 +9448438509033254495362865744281724512323137198768884725254104680523096628653622761003126111128301647813853623032837646549389708 +8800961571279179907403520239170262557803310568213744508717356574441764473623277516011904000012404016704294869157929203333991614 +5621867976685621217499877201966531190154493625522363719922688125680349437187226891224242675375445798588375405091275415995993660 +6776602064451444697704536229609651834393352676778641614610712731028707328894803760218379598569050464723477953936124087430950917 +8609350069628812265374110081821823052163446196500492527833170210965201939797385205224718774402651526872691305286672629217382035 +8488697066441224751559631066164022076293716903983024132971083317225244640782734589625800094058649006568726351629980984900472989 +5845746441409288197669763941632849306888745439411555999404218596367981143977695990224865577494042079971012624349908586273448094 +3944731944003065116712174476397673714373918870846441482703374457072218866041336694655582361341131880499845103050687313792470342 +7857292237476195260600973001695477364449307421802939526518179464787823934178232688755800049682688090660718430541383983270572304 +0611341821464316878794523833266573224644012837504558841156871904475125652999503438286924058574554384509785291956022252381864357 +0405626679943651292212678664558286589975871490755359605369624889948784641951887207653741241486219388021477385980747033128784838 +0349563685997861866328510113314436119201124870929479544327167409917885140426561670911266619220856732660355093308773694213795936 +3842271417777258599324767675283259950186722960735488702869088413460362934496727774403713216022454808579752649987147082209915211 +7262086846799716572297263071380322488276591389406786696601706848938742607301811413241169596156442149745813064652698654676224030 +5774876540806221409456713575924968982273367206175097023050483195829231424480633395579433434537883182331511499750784779245974304 +6819745509357317439429415625378554567362388569070215909977624507836378437106698876357999443207523376055325643289588788312580731 +7833148656904363694334569121139758945904938915660261426660062808527488257575416983895078937523942074734502850315306918181450849 +0874641305830980547277712020017148651915548171250649493853510014278214375521776229277631115079740388430042785920214556466053488 +8302249778400205215684880334891997915871809162392886542987069548288428411471154533517912205528047987025944754683578880543791606 +0358320982227642668267885208147099122293592290139450664586369209811129197752858004803010616081626472750567559363814707696436535 +0313506752837594147209139665385131531998918025147449755897149885365821721038971422038604629058413601987368885444084132780675032 +8698373618661979252204221364880007737028947769589369624595251994724054095272484618585409406539000761630748495654887039290015310 +0800818173175869261167775704612174999230343952148568401102639665953327107535357309312915124706207238389207300777172747117401698 +0640073150863859675544943154734483059715378564796905159762945298307365280446171698542814284025032267504158534248530901828343035 +0873201504993233632733239057534034773053022444340692497950449652566396669145334447109018793398061041589027430348848568737315985 +0702523531880691374404054678759180464956226260133696133658291458560416403819468440250477647013266610552428012647058409477074911 +2679888054788444461424298005407130238905755507645631966764120317200939342102226493489457200513433158963725232826211305616759400 +6659241756332251314783750854468182797311328498121933543014291040088680657858265588241030117849346100683667795040402222839296842 +8277427249362157833641670896337597700968219737912856460330555628526942419632625557211562429343845027815601523792180592076379859 +9754404607631948362062894438912954500557072195072644550642458309860663622333701157823267362150209715197912528880882392701349340 +9392967484360182578733939528902161701930343748675665636284278981486199253820383071398887821347218338053979003089742707812914379 +2904235361284953393462862403685101898073830804299574939556200135991635904384199077467177409693740584708928799458835571980205648 +8121614185438088992376830836290018683875444583668400234525664787649173577729566744205001928280399848363250846307170382670891227 +1379156561645180509829419293369128655964653490776933715927876086576622995107120980971557236204092369803081979966524323872401105 +8210634652239640140303181717302977441319086010060056823202877048062527278336721358234059108992008083109338742139836036323492605 +7384031376893772770300054085703713950658765604751229388016547464754511995220292088356538057488534591958960218276518555883565725 +4074775956662864334941163174462487475635543748972688834049926463696503634025310758502751556398690346342648412837461668031647927 +6365750302288055740676475554487791055706610049861824646116595120976061102018119073494765991803213702717674747175954421813209939 +8009331937511328151001411154015547213063838109162601512214845406533014265983012161008264010599651427488015290161524354573353234 +6470978945561557225050621564665550894387519941185513668617316911095236397590508616848692919250154411755818493336504839734750031 +3525111855377922515708294426372763399105358667430235504503228627410198905334837234851992023849271193012460177555030458178964902 +2832205291216922852095126506355099210740893308816704635379794133382523761361826241501772732710458333973916837834880210080414250 +9084082447350749526849475397900892283815818083030975632291741303292925823304366055091504295072069505478412237935230243114270458 +8733240614953524515745727759843129756538792646920469274157284227528661937418719037781765126256474601006075476554791323844619684 +1035243868690685092085007530104395247063420667025726455865466535541087734271159372906562129287612463548495628710375386966180600 +5440542501876451157868698528285357586655663503645304099842630588650168915815059917415278238955617758631802903768822104984447821 +2018849475721498910886528030895133588236820109040257215930892013189827568406433756483461049360024443491773721292902184969255790 +8822875627013591731684908728396697952056849491038175568000507526035874582989907019189676297477355884544173196568562596540184740 +6207027832469439408465681825635058880584562540284002435337574271598044807397129809411607354965616450909115426381853724556891033 +7221658030059861817521753782741366902139395897501991336285575875528980544038829626149666345302799699624831576475243396464744984 +1649540253799052538081391692469181324705607910980425515252483873483980593877409055481936471747872491282539042199279780879543216 +4236145733824367590860331474571745015558798839670826761096891349398910243527132904379844441054007921880393265550231971508677926 +9325201276405157061556423958329163005949768823959483768715570931105074676418085399720398268434277889429566019457186074673651582 +1556755082109554008455021604947841187746491317217027281220528571996910808491743715098726471698066342041982149950618417860098084 +9612051527440619756444098523237719085720236857461176953239899550769256325996619384467815272576473677824512425753715748473823644 +3293706412332532029368150574309147409666660955800738909802362577371939197344269404239579009973609254902956047445459161013030585 +3889810572293351817285095560307955387570122899356894847953368306309169743185951491528192204482516204225431961214922057114411745 +2466537795850541088028557343809549480793529110899163252329393397207265339963882361084755962562912216879860134066671514387618346 +7860354854395803331508980945959835169783983572284248855654573657487835485311040917221652836888254950796354469715116733559514443 +9649687850645361629683896013084952406507914922578933911589068814423571506614639956792270631464418346423540206296752844238915237 +6020288012912630828121914201273847417936995938147436941121877369382021368921214557882494996867880498498027992143690818597132057 +7464732232055318247290946075477625177092427701352448918522702341636498386700884661390140882325113012278493389309349523351396213 +9696483275515491260944768055252019253491922403588385357522280969636691193420388846988546363998678336385777443993831313531774583 +6282522032399446565965739736752150396232120722412203505719106262036358824681398508892551567229346012725815333843066908465157756 +9407628149379572734413508114861082667244920525693627019900560538557779908157912341364139167913811711711544677292025506854245811 +3464634373606321375959043076084467134891991975403488809906777158185809859079955799214529934428440394715803296141747865907907489 +9423993889790762040142434803114305323935291193328498665927373291227929076575533913306444776443880643225751481031179680675214923 +3368470912062297700011980465345274304044785588310672874869214201316579834207228249128013243107286248089143869069547088156308777 +1414590222708121116814503748513196371955339806257298864789960510451079590735116383580469454857965360874314128844784304143454069 +8766678394720390254448078037404671513243310605018703312189431738938607517130277658972087080448195787216475306011123823302381254 +3391550184839202307004590614178501644771630600861096494601392733266531850599404613838770697571965897048614790913072319558856284 +7803230787138777594218452988887094396749088370117209351285801556001096168575241228759515079363186428923678980339871398190852582 +4019696628533985636279505759337532628472390302841917324608852947709111244515112700445738982371253756187679740389512024539739520 +4770847899134941839230668652175028834007538603739876886601634289336067458758592877494727624461743546957277223347887135182085175 +9704365765485920770156655545282270424007413902597806432869012806155483311798101235310454409760720811406614955012826140011450968 +0313480515097495573412839063893028999786645804567919951099814820194282264604422806064547777371073192487100289094441987847150568 +1657543112009039941765308947835121413396501421019711136903259340105124014460634621836811024214292779775980478293474663062122820 +9705767650372955367904858685510440746508331239334572782478185604370866609254504064506288513924921428844442806366648997093161941 +3489214963851233247024856358669087681654387218345765317192165484089902190489810844772030255183904855574220071570304690043795231 +2065091959221855386411960322245401320421129454685844655947550889456851989959823948526569728196088066488438899595441765150072821 +4429114819428348855107669954324003559235452502739679008927728613312163086830142833511895866448006257958165946765071157730382695 +9882679827690443780755577550740154748999710142655073573245474660654485200341800425388615819101330831466686148830980748666684090 +7163405135812565179670235235614927720441373285793867065291904861238349709700184831060873375476942470039510660809272264903320798 +4462917767939061046448018044214701368685457860623889616757211734619696932095108903120448131130054208365085745531785639497736359 +8218165839330532616994196742532527473553555966673141549749982047712150106818828620285541917373915693522694719282613944281399835 +8674485087809037160526520795860814268331241546826667372648249043039257847644579120849321232434718628926179993145231262359579173 +6402705380929919120941181769537062173912605142768108201761013755197467816367902585985810911153925853453654100594647121313245913 +0666872833826033632401371436548685693080139022484100159022033636174658329127466366162032910540421919446428986161784748017789598 +4723199613767942411247930612753447325541505390129994382585659648148388692327147276519250190560063905452973361339890280400124358 +6913416888336681958297148217827338479648390575317941960750631878321348332412104016113215430987661026879407929196484877377640061 +8494663204235300224243052398541725825482919073092074355975063032796596426605495082752541621103997044605964809112021627153615430 +1932408491193512375077001954464823146678231602554522550896013165127235920096414910813761330938337552089472955671775628068540474 +8216732019553272236739723100215131535386354969462704414412180804694918899617675023795044921436432605559415902678545425651517812 +8025247190590822148102225680479409002058106823871348717740963812585351667254545007307100968605826752214724522314039708032085185 +2898242245907570507615621864533672777989484514162394933849338212142607118088404798508269488444104500180113716320167923336719325 +6087711919535546884547342110103435389748847458344462232091767124995184518172878034781269231230242533893228603793308922587510107 +4591474660599204864799066811331150365409997858447042372594886218949250820247279474918230135657009456785941687614114216570961562 +0712145092385555182611993058740320634997625075753366666542910024626577807784857468873721417913984050547176339602792705731039726 +5904226911569176720780206777188612328120845124057780320649670149526594811111907198960857717925291216166167928639613716137663067 +4307416456452371611701931195073322788105756639763524372948315105493615715372579618838296610933712476520491005806495650421658587 +8328103991782890592563008949384942150246156275152343753139757736003563406755966669814359044466955928045317799518086337670918431 +0138083133435376046718367707916060720252112445257291714225747183751131216668718597844623190537189131972377334685833227229634752 +6238721382625606157004023423898943602807707672999152909288657052128785368828226605301253816178238566671806542598902348311422328 +8320139586923410723937149546492213794676826048701166669784481756530412597915193651538414740148097847037639468257092287852640305 +5479022830982203377478476331811758576901670233527290215872232363518816501458927070562308753377018843087767143244104321568604135 +7369186061703793181459759961931363593408835426106781211446368072605366366571248851597783995945722926222426820630491316650527779 +8828573417201809585216027386210261861298732060253123609864528252840272478045882739663756003736716392199489082689850824432511971 +8111646983909651153366476446390221276039522740932580204249319217339578537772918571217444956420257260371077236650618481206170288 +2935054551970379324008798030984106801055948226939968902171687217907155340893582643366397894579369212912093597160438593641683669 +2485378257568528389277310889609277386833678172566456312002344737328227016110453362502908568225831332260414575845627976066579941 +3482852162228716106007258452673841400279159876124086723321209861347673279139378292982201754962295388660515249705755465339980807 +8586012495756212505119149505421333725699491270326513988475156468533804482583378661782959257850441126447111003717332538997317723 +1776086627675735007130894098661445494477133237650830139159997474669449285984774365441233470966013545796673243563388041724650925 +4871204375981896728514583939521811481161849278118060344334503543763509824336823270998963842004711517359429526921820434423765506 +4949119417418804810189631493303008698556136954410752013975187350631734375598695358460132019129899037320268439555839944615572946 +2352205983666568424098911534581381260867463768189900460175744875437666192115066390019086651996365032553554531097825841729484867 +6396761821871154925250940721334814793716957966097731930384514803099552848004844714015522077211735687647117734547230837853524693 +1596031648179998000220637673943792334209148422484797868537888852196932416293373918035158752836265069893009384789762509582269339 +9695024706050496247098862490788952376578622083442656866053965079277898118236124486093149364786379996025483226916387856904200464 +5207178534801739733741859262250257717063345689422848102283865760573174574242830519134626672907219548945944321186449133371889496 +8091522599148708961675484538617588113615426169855145369191110338586586013267131819054886276010519517578355159744969858769754154 +1409888192657898889323633959345553144675637666158270953101126274823625732454329591205013981131246606853736622675628645701807371 +9520905296639004266979383969455080705361676763621326243504360544161563837353776252465278766865244727756979870759572455920688699 +9581386171160687133121725147597447299189214610587624098233087649334093755829602691095533964193964555227483958747057992036054166 +8721053344317784071933338712749304229416314171955616978192540365793299631623144229526476496982594982691261090976385827573975900 +7821592310703338108652726889016577851582851275588755649801212540201927028394346407971389167170778763825909054893860501536766294 +1680216758688189041294684581042122535978201496230771039365667061380634389195094311357702877874169983055267901138828354564408227 +3161070157288336465271541894601581266294703722546655378330486847268915166615856440605517140340676687703279431660743947236511822 +7741994422834194190860106225475557703581613419594307564273066500384493526007784089212735294217591917854424698645245431154845570 +7453435530259083182485810144347944810673614929556646679467919668579911140259730381818980942598880746925296760172341499274790409 +2328005309406832991426090784212693827689769275846169654962563240745452602435209585710235753460014401490458336687380630135023071 +5366592739312999644456849006548399917819901894358497737731098338943033079178655254808256654806548883980302404456845406302737523 +7903862311453131512315977712627346676478344399846058399879029101474967706599628983635802084695117268292559579897221003598626395 +1226042367447825280036345293351132154926212820976803484997329381495188404459278925205516668444497544901886948777923893344531981 +6856828147900151315527595804653628550631963940129883617356848115429626055627960941822258407367220366681493979858804129725050531 +5342427449777364357294403483728929672993293331804282077540029002773232860603723492768689779320843055290078442091489307669129440 +2646993961014124319764296539370434958358249722078956842849671467698536721940846395173191197670777284048312934901527571955362838 +0198542559113109732314309858412233715215167131228324026800689688315670022802995393900835564840785241774828835077665262843753444 +9550183762744591451958276893980778053478437092327149970098767098796188062615518630585477187237482484844353645352242801527565339 +4554133259430221270883589344804016824319680145988501368070988742027201586296359667866696516024912143872664381709357471736498210 +5093801098192097809224518282804541968783581829389873304181998214634779593308644761544892301474532546795113168811568716153209669 +1410860371073926432124196875939453572716037044352794395231284292433400177009767688979893244784882963302195811252949131002020348 +1963827673323077855623143768105648991600618303185458508264555147286917125868559346485583695956446151749324530132278047444739067 +6874456031627491486993438537612795741124963717273593326065380547768578196708046010574823669488232340781667689355939847002297664 +9059011156256654537948571823030159169978023672567790424242785131594034312912382632898662220373433122635586320057460971136026042 +4324851680908243245093083193503431558790765585803419091388697495752260988154385332510991556891584925155976792883412406678432776 +5169890219592441180988843355694784180780002217839745830787310928598719082559628331291213329365294364549008762394123896795514907 +4029304916499522070046006091292088087865888798317559803991873835903034439822636248876206336683085957754970026069257438125567024 +5122833726152490145361691490840338977240905109443464507374230617046450541939205551391476680636725777819582830317640677472291259 +8887879121383290774133008351057610071339235010888965861277804156037797773751958774639837524541250075316907358014661336099985243 +8039061153806899718406603277773464956989757949717475056088907096202984062415028201715624897091896396812284772715615886727140592 +0697572299245622972158982736674917157478112408603912440899066443377237594315710291599368603222944799827489902803052151032150505 +7013603271652485049620063445001242816749693945247727354086779497318820787447165373787134099987577277741625609459410605718145900 +0792184428093364028147126779227116462983472771162905140500152025984437549037622220978921623538498863508150200422542729027788614 +4411728159030287378714419332373354590292666051672346415137756916116829485503628039118411108736302251425180386282192968531233608 +3508034331771430567756401746605566004814192531598982097023747313496871602413228109505959309225451717487757635602112764447022631 +3428939513944422073187530514913804210377096901814387277664055693937327821063211837805670103207586535472844416128884599982345779 +3765013258236529201610750246167509469405857415384290132571908547691847116538830356937781623544344792657443940779980096189839626 +9024565602139835552337325332903285437411134785405743434839219379066510469685518924233636921521087402359934033983973385991471002 +2649847962568274167726165208946386788572121523811142222528040146116227215917720262618074588389904637062666528544746561556536935 +2620030538510199023964637151697713281829456055441798954059894139613970616409824903577033806155241943903044175681019965795785283 +6461188416880024087073825761424480883587286299792763357082205040327994699188993856940062456204962545880583868705703598889787721 +5944413986797134250694896844973795638537262177510549522817774683727110576630405084332924025735617088037709220742387561124513292 +1615973751057225002195236737059699517585264539200525680337988614003524501832730480276366257598203042140690301023569755795697899 +9008200222469601333665860661780983941015300488620597776980944258674129973552734738060885268066420909348372616142102733523433267 +5003598890783029733738430164315966147920008508177297711130783619606431201578483617231981134136392404255762575061631480099367673 +4714080230392459893569173674100327560113467502678424574866012722633975629063693151545366570327641280682622355521718987259238801 +4739385038824895235096103000674296240229268577109938375885209481939108319170129231324096236414336990925757528939018270228944966 +2361210030668060864499350273214477998565800871680472680681932947260121232176894643185754378295528202618772690219192407686919753 +5156059412217536746848726448056144396547837914584560922069735882550291341190213498634134528385275982127813806960692781201779053 +7966885142214723811725348168549783205309168240872140544601559983829401790243561220385975487819401267336194223205730538148703619 +2086985085185073545036414851529838204481235650803097024838796015231330542654233028002529608154776678617456164886732320375739646 +0833105952434512974899609076351921948939569136092110228925816092118172001373677700416412487399777738494320581470807407424704877 +8185614688665309617727123329966574828512583312557787490171669059879359795468437113583190694186011613831079902014081217754134725 +7131783601536200912167420913195076409694857630710552837087267662216383925992631278943851251589580445676689967886327863559646484 +9888310805734900531289699098784350167801387862535778038559729898236704661594447329313866535642213694637004811239940871137589762 +8123715241748226553144892581245052850529932097715696995932059624924557269075540247991049472713937530723957720713793716760718395 +6093034172460809629440737053209815131819638726936540787299401716655839213840485847609031890782549934060830350478366179240604434 +6633327894940509763972045245237235718323112502675490128278367355639972323817271838806709048068724517131782516093900913433491465 +5582353019666679291426183344951264862654895560952921265198755899160545875749490172299073507227437486882523588711701507976499572 +7489002650231525223980434094738594856401532028510616419177773329613390523750901433006132084090755184848290450781826037290985462 +0539323854296447671459242043430937704073386171637825236119340677027183609466820564020370547139050173937355911835070350187485451 +6965582154750741810065288181652685394941853476132562873871859640024361243300296805283748325817168878484565585632754351908511680 +2886210467566660836736517150078351812871682359935951946868379376912994012664524203941072154686353570579681603704825530456774626 +9665362335544365210262820037867343620764616695075643840510926473275049084133707571284177399685539645626628023165977084111958392 +0177820463043321585863992470028736425683626513381632161117010851699245594406701811450201210813697392240877275493182279748367019 +7250981623715632368538564967386387747576695271655268440119068242579103997269027655460321699463398768768277613166901925556040578 +2730921762116366900155596821064099866827590787028023864778747307107976624095851829841563684215591447795700215410952638220148923 +8642501753068607515960160175361362264643558443610150876742595480796702902130477857992388072241713968623856298400849938588555032 +1187308644994319305723690746675187962892871980887310999328792568364489164541385679772588717510375815217942384186220430941913143 +7605854751867100384861067666196612302899049367936234596159545293447341885894031370313641111815396044152641244256403303821921174 +8006560725678932454993887223171401960145271946857211912769628951507047840598467703395747670926287903550867839502877316151413748 +5747061868485506527664044246509977629632520838572005928929416857628593497937173916677705472302579778727680532363758751491026938 +3023153622006915734476058970896478596388304728569523091701672491484313935627044876208043141561946195882862365574965158147452289 +8540852691422877019070250316861163162391778272197273383387116022030059687803664857766804536240988573448290819394431972776651275 +9021443311810736715901066501558981319880316837771114344162148017989800388690774710489918382047318311988709068050500771418272212 +7599513906333939122554708100671399521304710290565461919067937465641955962609388316053120501043224440969693966990639899533003437 +3190313864768728595063193176469208637792413542897116168001394022157595453909893711585707042678368387735204900683732630413423309 +6043003917729256108805619361421477310316625655437814740309514638761344462517487426501249646525209961899684542352037279524879981 +6813035487710494491438894246146083397270552071559892438473910394670225142289451782904407545380437720612171136664498766583513111 +5704425501897608539934816199146825064755643795555188152948142674213138361295684789361927194878162187162220359319096077044697338 +1170042273866788055113160203247185045523345121557337349823787766288071325865947069357672811750151752362658390610542086745537803 +0182650295086344086825098102966797093995388649163271139864646408250278380402342942834021881070263294572807189069134900984272374 +0906668841731928141540118014775032666661994283184008007242068962044782267000273516374045366478779586459658472979356032532424400 +9941559950477797261120283165043361871515058911345852440301289987592080477208449029732297262652194811701835630896804400526302181 +9586422168434769367306983212903836891536506488360440148109923788291834492143450307170521991049310812325101209435949795579328604 +8845618327364168114007785559410459235882830447965260478796725064238526247677648804067848274177910485949526784938820751326532317 +2508842138180368207641530038974478572707059622379262380563191970615374835570345785749767510398007047615953484581417608147080414 +6150921916969845997446844026937752931358496152526223613349123080269156525204842351030887676736715854630790139383298746726376238 +0031087628812333418550306049252849828620365883770156880965318518371047868891562748685920081560624079882621440888924178323074068 +8556547813934656680983629186991073869359264408784267940961601835440468005712703124932656473056207782384291231611143830784642169 +4764006946356475094019331519107580885428818699148255825445877812529420751612646315832517900095651843319599421976422128038327435 +6209251031135205676846184796239439073588798115331056299413787815047447544760251266043212878984345103105431840273907195809002871 +3654931993884850780377252970969582655676559449815451929264323578834644743068604576736541418957979028943061560532360261664725787 +1145330876015831126155307819990268909839073491920596329763420311698726840745194869089228905040694957988171983477254803375572985 +8257437969668449439729079801079379205727147223003815670652927114347162605507272520770488283403449339977650008075057150876981627 +8526350745722665602676982911174850303165259851752432760991481586280102205346134401601648981884690319798225175260769925489404224 +4638271898447020123724423300538195550321048052825314720561544239062181964769986570926083174181155377779882057584541395809301918 +6106817249634524848855511452769182264081765291797239837907787970553958190403210902425419707216288535844322802242224844682625560 +0987012833422099095295557450557916850795807069003361331869709388270541973078686998103429124404642889230735965872322730527661759 +0637705394090134454432592452488278594036085049343720666733736875565892704518648963039960363828210137149300479545174722900885474 +0438909745910598389431226270312843755719991811348892485728211852221096700168476622881940496574796916264512821293932878797623865 +5429545451401418793893535526425687987849470147455674595433976709030225358630706349020692453458568350635883987698939555558472630 +1147145098629672646090540159437091576295858909288901226882948677153091610088843747423989951237804279634707873305141146001310035 +1453067258355914230711608884942303119909820139748995292741299997309447939834224950618749891034712331269306844559292626045946290 +0350632260797112269078999525007760708741928859358707432624911128337604559525225243942115958112015615876335010570860522898738781 +1402978628312279477469329446037732401120697968328000813953667479029085290308524043626235410022744559135665074491331563473370347 +9337757755044278436081677756600946862635252212939271849678018763209718297572192696470355304192247185638719953361091249281203364 +5405880207322161294391822123973103190408090878564615457135856917654118957703067143223083955082019279925860379183853717628861577 +7799366841975673356259200026023839542055869990618462031135739235438635258865047764693545067810235010528954960166478294307447628 +2027467028086256924839310527875817129214597755080392073496545377860632428440004957401492609606750537328284161904594401425287572 +0946928415702129545673169191304792948477302426781915513863540380482590408165885780307409257801864775225156808756934724074392504 +6885597618942836774284752567772379904321306380471869189416734595292130350179577547119957964477389742383246612250778027835962842 +8375378564184742787926400597138354486910116541106048723078444753508902260690644823241797242756355368838174606975331846084479482 +3212968824505986851162688090961261899834237009593445525206396148505570975743205626589129717163778397732428341839974826649188402 +6250784433605236331523177619946160387836454523224441645894992796160653797716355919979290100324224314406791061386652716371890152 +4400989435392530316607884601954369502551234892963245103254821300716613610559994576020035792556553491043544497572846045958494663 +5437689141597501417826982456539318735177994543195003033035189307876601341936559142966278723819207128349590261078232012690448383 +2240565515565951781099043148895044873938264025267367187036427905278273314523689584565134739736805096906657362307932608184624022 +3576329018410785775670826940638079688618282322990520892260090365771287681416891560096002562633570097542699787911417555916230717 +2453291822907103982064112069025122300625453433920178638265846617355201994938801382944512864303440296743023682910689965580508346 +3275346241221900813564939920509014369583021411699796257800366335780055834288641882272217012847000156622653258224710526325808198 +1761823047477639207496107226016946214853880512328754599996142453344143869395811453079561049784458849323538032761380820785136205 +2258773098932947134988484220635633194802789720564239663961212480883691013756304617477696306260192353528126108628749643695576613 +6833244981505084786837439890389565039428783638198451342774797405426073205683183254178026538685346206428799444442723636136435573 +9080842459252171303872018490896413638818633597602353810855257937546412235233854346618680040369752485990328489156699457496819504 +5734956183309699603857071255358660306282081929816419207249476965467352584050195709593369245076183392383809049796820142290983389 +0663950400843838925251438784404925348605007257769726864605575147487057019983649102686292523010863667700171976798290888401737766 +3133554911232814826547253321321519762370231796859406653514455605268584403622162920523841843001241629651167179835787795168834729 +9915875102181929094696545619337694209374642713183714372607433054204210229685880508097695696888633628128273726076768020385810595 +2987095117021662238907432053186678763052465613665295736124815230360572136345177452861949998291445717212884676001873754746660396 +2589155650613427623626563286829473395485125944790254164155482476888221798281733050713864337019212875437294907722695910181965531 +8195108479458493218118347693154287549401864008165971140576262020179031350059154171267408221692360825699802778787719114529741055 +2994227854778559135194271668156980433699910463754412118741685322605625614010496732911474348010716497147621915462772990056635740 +9885103937597375812527288674502022238204092589207503781840088970784707532373479354579114899440649532568358342845263798451171893 +1120400390759648596081862269355864764100400822617213332109125827310532445408926542692499006220714769552811438530408840934868695 +9637352403752939344901814991765254063329438135234927589317161742716459240954818619945185528105201605559036407476820639345279573 +0967725725520221343652248725994878515580037117626550685849684690414565200284452932891511103030564811419601323232328459974123969 +5151667166514928638097099027082126182546856178488195923185506331245117707219875304117100373941938587261574361349595466933901648 +3122056019614029244775838489907181693402454194031630939340884628769127341314464687448572665248434305566402372170442289658220344 +7261444332642187051262725693834547125915901896179000263992637439997458766108204237403853459573909864356641282495892771557042023 +6977452997091657310159593635773017261586291897746068707373152247429150821576531204588421265308077483457611680883539505380780214 +3922860418447742388907173493206552834918162458673611316176697519544920126038326376534410690399328547067085820148163398020288911 +4131844303372153660043567296613439825919900174540571926796003444468128320273120297033737036976412016725245066800816469650561843 +0565592489986925533018758592782811877964316768421296500160427160146511217146432195095933744734673635804950107620352420106654863 +6645406729317349776240373018557665618972564221260681309297356903494539710063100566543717860365197783559220679304253096607594218 +8395581134093404449211217585032937525052183907591091053649490577579801329664352206258963567937765723904612138153463659172391420 +2858367788679710677058155486700833423902690944634848842142528244040019800469662248189870722506296487688337321695524703236140988 +9562335938642263288699025637860876864417622879634601222106055965060418025394207515941236354344664880329773638937529679471456359 +3869629127425084307826072099872319475018151572502025420028453624372211412720817771154291359747053407476074728284771551844057529 +1190185706672366345077026144989614660307994733718658435474012628808621940611349704306495070342196599139286091306151010932970462 +9675509101851273861946201556462769919002921112388488480221448504521451553534147109710141587683279463216951321945573166307639217 +6672697005271871616738575015318763914957713525828413258526916822948066768551357315714715932196912191677461856418144576263544333 +4907150429612203297659855554908990742757537394357200499303314336795187732766056993269698914296065846201908473023132752908744956 +6150083396086150456609926582054844276634569272470435640456573226419822868710777542210573165448531019738194685407995076708226492 +2678786284405544977160356904372320894983311525398796027674382539921414318300162458602130818377816924569056780073177178248997811 +1585303840969268907598807940355932272770894001504038659615940425154386157294260258784536698627961267225191113300660353374029144 +4866449090853757246935294981633041248861600653432843768265539085865624263955878975774708775312072236190746445124355521953038339 +0619885412382828558999175920193016334591402367369763220140054897008235791975355396141026004273210423619062237213937060537525842 +8976484958039104695613723977251336268561215466702146950426183444969792826975925369611735319989524615202694816932040830397174311 +9564951821673710247264553143623225237946783695563652359502341538660577772441234930760198015851060420035149363908475167289811549 +6152784468367404157734119802017549287296220448855141063864170092034156049229526992205564211402819767239639089903951267480899195 +1084349314003385023967647400823528491190700765335630550586981662116778098851626565057148602128362406840285312235675524872617927 +5940674859942896006453306875133525569054425493267698876245403823203215376527985578976643008721792339745957322665402353157011446 +1029563432263058113381593903721587363928336506888785654392441615160711392515188910321841843403492466442469739247826795396883496 +7172639941661127457144015058984534581536740542737103665437103773621233103380626067034160263026558390443198760839727420004712631 +9914873013707039718441199896815680469326923849342274027255430706708553663676894461369886145860075954707988128252410758852549672 +1551922530995012072301491677655182006822391780785787705916872826260151900149221019724939267128249948853451126842232399605725462 +6980483373104508461112547210954800274259585332622017453698311994963928004018795768275261593898964198667538969022507330787533788 +8940619208645823836214853361748146283829606466502798396069751370937123229891589445495370452889766339397264192786388083894708555 +7956574006856378561036342289467521536334236359576203113726730817643632648603038458281607027513534064039819509732524551295593096 +5939647576077639500586029620496592494701352335060993013958711501324112331829653462612315976140447947573865479895456805542744172 +8296423959232512165579460974983453693457497491285869113279013506974543084139634238126476293873284263151589338438860044240330996 +3782355276288558083473518137834514003242038994143031796041577911531844210313799581374155317783854201414730465792201716701206550 +7105406465035531748842630956573813909293101829709167100331101814849787778408887961527614275809837033921260676349397115972110690 +9643615107680266865840715334731751157919061855580521203957602157773380969437003086918579100512932764454793288187949797876169125 +3320437252833110321043772044039248321368660878095814104499448998676046985620748260108371162632325229365624907230743947154301806 +3552088981131531046172808385452694435204741530370783735986679874877536428004908486014008409001068550950540888673128998784481805 +7440503329453373467657006789991046671852958451887155184801369224781302834630349870843861530093008719949904514151022786314021716 +2709390621195321800279652002200952192418979261420927427122958490897500556999549527116421814590121223682055231817153659082402135 +8861992826208042869383343763880314283402643395875744203109296333659792215641368608715044344315779183133340656043459727198349780 +2734853139703811794155039071217208536677070354393864907407146911703003457454092806351920281851834356124440898064979131802059323 +1762234053491518617088128044036706357776327020285634889111113700954005526394521483443227952188980642686375398780347144135711592 +4027397751732022026309364751091606371427768246571192961054471672221120559486812200168063013361795376094462318094221786026438363 +0392038021743121561693528064882454352142444617962196680006981383051817202169379782864384242280286939946138589599414498933359730 +0182070858522164858867574874421689046928982559988292189961850204180007351631664423841067686122468503764793368632417463823286265 +0700191191614031195459835157848968083002627564348814468750050055060620960050671214092145749062318287857521361265309131257106421 +0309993332034066779054757057884677047198784197094514566927373158826040214788501636945490789604082561095662632988383214277496388 +8146430655840989789550968117320096504739356599535135443521661785643633703575650679430439992282453217709233862686803968241138826 +7498984628272507825242938050646337866580174070972879570659031107873223367860364402212183428942145402115290592836227443279445979 +6978276114539892419020829624768340474210713091442435775100177879638010349673639613552216581396012901447719087628078745824194120 +8522095336564609176473140966826492093656451125709888847406519188859548795021576488451306844892007565711047730272408121668647900 +8524767921694471514347227180326839537161579546977834075174921433329341884828393393398191832645952423890037661848882505051151043 +2944580067530192277404349067174032715610611074091485944569506105415953050308842454649185132382815370040650599793085560858695708 +1141032332340176333446374984947231196716478639118202128308413932621313966803046203929215874583358851861354789012133869833074749 +9480985593249065406361871874582636508161948209786505592954264261087303579799611153927773325602584185048591266936288024303976476 +7322835259534879703369663910307964057121123765236316839734559189401161415410496300232441653039670294405632163031483814775087095 +7887660928641822340331849719497888363217187995951806289777062854449559129016492535377000453799053164705981391283757823729876400 +6020813393115291018308864451756852473844549771230553274019875173525511163873500444811237248088951714603052752360262642567865853 +6201967072308522428055969416019910663232530141827188975690227560728650829855364963013282370083361622353100870401742620986225707 +2869802657723987122733883328526226736949680510879014974422147235169606191520933028844627505009715152702759247026991603640320467 +4241131697918560404418795016499808486429648304834823604182336854359989655705275261891160035233666029073733408580774645759107173 +6464198087662041784095710258475229347049766003901523983606673438365749432588484287371422883288614656304912471987516429205303532 +2029089639113957845701115097046043607676790299218866434022020078360708383436488957906770062559366765186955585351813372430895635 +6464504289920784076224333417714908863182256990967502428628619515039237321418833968508382684390570422398059844256244914931448759 +6529784435502409492045275382927262616866859838773431100600230894559679830532230924353989524323228472158682810144077054469603044 +1378563204070129032409938042343154208174485755861395799608824865872543930138962034925792279431758568493941395394754047686715676 +8867499345143102872671197738475892292486346568581939250404454964808538362896520373387072413955104371842316500056740851235207639 +2274346030168140429762079586632175197653839654847793978202115595048824365507532766797058257757822432716594523867292474757570615 +8116418268033688475580223253494948603537184329744599083311334953737050247127839879240255833527455107807664847505065047983484396 +2629458032033571400314592548790506246485500676837502841162113579334258598171571921210523629971864377357109335285657941548264619 +0524276024669364832317266608416143775893545796330992023551256594493130557067547024156422646526989759981543218213803553279470269 +7049845656048970965053022592938828183548869262256486091586477018991837255857719144475359084653581143521408001578287580561915936 +9529610539570129132154472887914287431871889778678946943105713104741010716248000242330469610192173796870030679714772937881344366 +0545264556901297919417188117578751509627881737016436472816406518703771084849520268761391513510275790321817000658619656930708957 +1126630442325657535785952978581421903165028332745161812379117711348541046986438165712940213350699237254925482467553006850919218 +5721411832634196862603413999653849373180502518946059378586343176647830400545625593156677745062236816423794840646924829283523696 +9566889818345214089079695756528442838502922581513940730675014653702918250796815796276266282500947845827720283326159797147319082 +9317560741024728849503640154852784294588264197172188120649331980986731376355567665746330692183280397742589194244588569542845631 +3577828329965372354724624706136258680035391223875847298805321085928193394693686066077198681054782793606636920380474314204706128 +3316822771568615892652610314018713244424614540516258058981790879447066097870072989300359291800915299516058342141748356513095635 +5061676595203394978368391202469283356586340799916518917181619890218937093078654617621002548811013022192072875054917226111499567 +2293159175827100175340065081112035701753220885751903235819929349733241991099088182499008327172200193308932710369190557345577793 +7287877879088510408061450710486988984638957628372307246581657037353807145126249736162916823230146250853818942298633104586163230 +7832024984477944259180948598164959684871867948848537597567339850852013498502229835859692193114794153895539003144519694217709429 +8852158774260606249546637223424939759148603134570091996953512424441839401422606873114052812717989308319825300637980593162367504 +4443868737007280155976070920335648272365458102007219456742917706885599061474160397874769568586074099945991122357965710810304405 +6905794745598083595623675442819199614676323588131811003338385631872023890221085694977414242799825541355735846812034684719203047 +0457011399186690441251124301781521567240706876614307067167646882762698974983127872249705063133235031055532098528898796399551640 +9652581539551646223682272835407450811885069347498654352393131589816331647166209087054200913809824196442611900896852634745826036 +6159069172552131589074592658415752799244670288018595097465086916954714517572062029793973193555030320732773860687445556056374048 +5349001165930930982732148212936887040004758525708856986464739067246746909509060364496603927468208068059374896651091078566710130 +6254982141720413268677308357696628123925721390150502950572640806864637896561429156063059840807574455370484872143372214422469569 +2175489787129382942852202790241971823638922108920609980574885762787573196139571654120370722438096597478384547338469999448759583 +5779677161907195059713244890541696081649739347821725617254499816041573948157136918495996244811587574062062152794567408848302587 +2529817818204143798110200493373689828340608796471631850589769739013205825657411890682974212480864416875107897957894840172709126 +8663943826538718474564967927014748693701498556781723819074861406711142155938775092841806948205850959520646877840367557220520678 +7792447422465445177106699668289442956655097062959653482152033676820332098951332376110889269353539366684304599313150351375802284 +0121046685822850120961765570267263832452267770816505513149214924261156051159905321694021977473033018289683251782668439030324894 +8869657128937432079954235872959567283205921860119040052090516147170061627077989260167387744379514761600478703309504193576305611 +5381561915778733491108127139487324618000049052071735127115368151009776782599438434551832876965146125033956869670863387976299721 +0949362683385697791271115461446907297573048650262795825751967646029677499691298037462050809938530416641818484223928338242122429 +9766820839983470977275951789763019956067562051439591397901411073621068841669094149499180916451056538781312613407170881646764399 +6524347269748594984863393554929474287488214701192085748591350202439606866037583191335302568028741994749726846505035406608976877 +2807315518903493816008029815670675803410749049697801438415798820359073479308467800153777926573033244523898966885887408576598556 +2253435971693966005243248611373406144205306206628977772254035623423592393288603285157497164481644751059433660694427679833172764 +2802621839144263944769655055452576122669485060013276462140874654840615169333830556593045220363613387004343762888697682047116295 +6079893975072940528060570984236651746363761678873252309931727588216926947288076839743652207728678149523270862367475616321714661 +6924992946415404337508448250054422067066309322273329866764351438985216249046429085623842949432537700067268248539671410894502789 +8240333706088312915806196572306355577223650119535205051323962302240268709606481125217437426747720173549677961990418013172593155 +6781963827534077258276934309689853954408488415498885594714929736965951139633336078246485722224486449322009472875775669311469575 +9358007010281073437748629060353526682504603164238126641900438090676758229061250503441387135871208008336678965627603224246244049 +5356708068957856933330346985639541006539430131114293957097055267024756313531830324556261486697384925986987181884646073628504968 +6088781492829096627570053299366443750840538654491246720498646497885473443660031433479078885663560146413659899024021823265546612 +4698755327188359177076358836200498034389012684305157808211750883923932482111066086636126223845187785757048164121301047675382008 +4187475464845783395113764420886751702440050366103999318308171948006157647282740757274766917041519563322385269555023048099709528 +0571195389552617367126852668538451980401879674162973150705011024259186076369903231002763667511763488135226006543931654677750804 +0619275562362999032336486727097255819748979447931027384044606019902431591438640635467977566427621673095319535200747603235302696 +4867604449981342383768009732025809614182230646572537976384930951101533738349930256172344711040076994914315737263468451025930022 +9527865696943210023342715736597334765710291291516121893348495349788313734498145749015674214471321122949483123539062028956769641 +9765176523721839937410174251025970316488964877877371126040698433360574265827174483074565633308845572364434646203497713132542776 +7378651477723436227947997821691317672343016210083663443777377182287912898006288444888091959123188074922030160615537818420033213 +8447189492947088531974966589067358589089364485475991918412867217338548681050492469752464750298772894247076136639226285280041834 +5454360318746876235873485912565983134779435530640178745325450114100396790737296942281564432762776663339965033474759509011312252 +1273643557029602462258772262515086262035743506025601400592823850215645680844288819770466248021756708616474262140257830085882080 +3749316335624058049683001015861489646556394155367973498744773935515065243970160613827515488862189910777219950612111041830333142 +8451480666232257772267491027370674681436846933893722515862731717525412660342458091112720313220482317659721562206466780128741773 +6590252632454850440238194247507400433748088629955607174486085725118788995595732312569896819608944355538496441101640124949497789 +1257684894384392174484251124503854845960148691603301944875996738800826596693185375085047729958430171553740436704869195063748372 +5735178593590752060263331193146970071579446804835972630866651058153595857973419849597143669821080829676089777998056446703836684 +9360907310859244502541304513473974522087020370096397612021384703925636952795854616525882877878108950663963286923299046586524224 +4736748114460524678435616682271235781989815828869520783049700875658488695718736121600271316948975177628944650186309894116256839 +0122265134749874764508072046641714144031116931952372994620287753392883858943809994533079487667165865233880719017940897178306317 +7314139776044966808676160030164847624119585864721750026892048897546015469276703858536945215709271741054424782569701147500084232 +7758065860697872155705967293772173137656465001477901257876428931468366029449777184812467116641975319314916341175480998066511678 +8213787357873005347083763974187729721493820664650580516006337664286359010259386041876040802392491656717630783835571533641496104 +1539726264552952565436503783866624559510200362458151625173082533487696535010112807775556729174429917223668593210128877186508887 +8321470309679685999475535888469479559195982218922599887296055650137375133750432460874145869352229391171673429325865805622380834 +2056541359048531447828515960692963929079449940672170706409337197174760052966541653050946881379320800572898168412293068662723053 +6860373992960297640329729816572073853997874011764757398797944036292846733897735820446934726176024024757470895603256455220029335 +4569926110072668348278664329257941057438032693980297647417188505086076585913708391932628924011735966680243663432137597450444007 +4011230494392556854932236273332089389934747612548401261998294903567663125297736568382740395489945640372131150054623072337132335 +6844595318925439547616931848005923901307170686601327728283791660587722758968622818978597514280133292570491476960507397213932185 +3642313707941792113315508020910489195204450745180517492522873324890987317406946100562361363175345008151634614618218325839525506 +2427692898230648928178646301964171781644216637535917410571457842164951317391990752953058484915364895813865613835337731245388877 +7010431184482412816244666073504621100130866578971286677458525711336280431605171233723698610913008947422033976946085031938114793 +0877515916454772093488878527862660314336276524158489551235818954456016892617227185085470522620693855915519816376238143161430319 +8799443736799287358483938545063592502641553678820618531061987381595925735003006045937462381053795139314188939327005235192961861 +6759340733723316487592044207138087167698990178309899096979902164464364089126370344350744470572331313727851480014896363857798812 +7052560097987652474276867365814450520379120040581256992867022098643876725081745248682691582583629292763400638018100065591005268 +3106774405492401515494177672517042073837303505772295474776502959089196445416987270369786947855131616223965006450641692994332025 +5855582574286277020845503779828089079164761761910842413066849248818854888626393445367304058754822066188520015897444131019700263 +9198472044843711981048071735258326011544302082682349755642269651044020224003915379747598044212429909878394016016714106491656407 +7815377808589332772544290119723706266101079820396212755543706404343739006942558946534655221133089320660150834947988585978442816 +5845893139549225714132593150193123229669033684893833205775336633241518807901847649594321897137880458298454663559120194776464523 +0400879116612606005027575801357996533825782630360057558670923510328348895013335023158934967383007297478557740608358705255176983 +7266683495403368714481550525556638200455893453737443660389337826017810731088543589057015038655883579293647540385262180527785917 +9515154749550773405200793344557941722519749405852747512969927332977178984307036495472318127241347248808326472175619457986406723 +9518368191888409210468669956186116750302181387390597344128917877355951593149853095697850106850745402883068932235000062455347402 +6771238670568019918070196745624606843885430053371888544619960477580892136283363206743364325496202732003423537704812210825777485 +6482929731992099113054720411204927077100453390882438863808021020983016716953161187024589380636187873278841457216002930842647147 +9086580408882584727439595283961649388079282398490521121307077379799427026353954996467076132654318458754445407020982965846766574 +9211933498567658239813690464315557516873798138696846826984940696375072209871675004339676866312551085733908702422475770451671522 +8116601759554721517887607233127079564923984623323605008410478991117346586220447102577578587384958136197341044972808673740184098 +7135146663669772129679997894669791690347234150535985440597324857772792781041329129123706810764665585549577867626836104138395091 +6171338134734949666403237923355751356314985925381428193696582138260452767497882006262979715518886220518431969713213052164146287 +0631430030464172255146123719714749762611746753803707576735960990848350628824677285326419791772891874510486806367078208015683527 +9792995724212035781617488647953282247761468865566020082106220151676123008979512284726786406279413459522157229217252165905352918 +2536766618340462486482122665210247152075138704341907443423031644884751559830028648873890163595496896608683668686938870179657834 +4207985050934314372862959059606329918091261977012574425026916852113090691158385845006538026326042605485030114114277066770366995 +0403083121980863784638665369135497943380554934143397132755814677874063414921737247611566476833724738395380308234640207731607371 +3017035318366003181883008020161130977715784016586015636467061595058652062869875350107267130020471568933409734170464250203156306 +7978597058687788859694752086622825044743069638461579429486476003366615826282892684888720644513019714307671128574626623134255754 +3225178060856930853571262377435203804205020419212526191171244624283460959473575918723283729545170705498401123341048944419740415 +9391613362743685159686501403436221835235931626375947101387495019232220333271032937655938586143908770909065649064710101953494614 +6134742532053652776330925214492259910738874571044952830222662538392022245336085949987893286559101791675451325204933710093660895 +3150091954112952712726674404458997796890860249938694466648235513572474974162093062356467502005784802581269257972393197375619808 +5518818055326965608441276354480052128774778908643152331498791242682676747511171669510551698928872813137576082004507231113018234 +1869442353797750668263237704646436989107574039444714294394574053634166211680018322567901718394177095139221750525981664718345874 +6533895638718548550755018968962814261467954303937753456123595613702977896395623181616704065331577434094624992851719491928609615 +0190398690201868871739512766894228210227318255924906586297140986714101681237768762073978231156784378903908446734627746278198818 +7031625744207762150055633900029138852849133531239672839021846058540394772383588961074862090538883314417964060795273709151209027 +9458808924606129446923894166510777560369040702494184195952257501705875876785777050661631817125173124207320372163502777664965913 +3571992627283246607384090417534713518631913006344389649603958134572814682981286787015904497353080342805307719694940285614675633 +2468021847965102322233545270789228088801077254585303970545296705237224231512698609584385993582329483075661032700231251161660423 +0192713398720255736106913269405387578211504390721637672765578917354808072397586108294538148319234789867624965197532780016350565 +3634551422633123938462201786680417505451646469018713382722643171537409460426340292141021655461958038710203141816197429713424286 +2547844227738650654059981449340163279595536790994781981453043554676804995664853696521066106987131049223085671186846778658607485 +8528870512517578936416926762107480564174061090150629794502095506665701012457777925443164598343164919674568006002249856403680494 +2627259489744462745552373437029184782032929858142986221112288622061305496355657681071521590855144706970497835664724912122006599 +6545391156443312660152544214378226475642958908136790116192718647739147551525217967757101506789062053773824320749961986081365820 +9807243716856995753119727006541625638999515827040154011379764506202860312616961954158869599676568905867509226176218277805150630 +2073942766462908233406965969896132634247796801676354098426177499898295515362604488579021522583028021857262554533983809115858178 +8347131968232485092731301472083865394183193666260253997648555077371404915951205500140212998582177455804377214724298329527661383 +1594405101691517143629153539833183982495777310394687166385933138800061962945009756356701243200756906586574077923344666352145020 +0197245967822981167194710233250484229803417371108743341686105467298388178153158024123847938905011673366872874417478036778662336 +7258512385396982458981727808434299320938547592708453258132441101938548683407696744955847650770224320115020029123283233005466171 +5842172497719189784583681309409508840094316855599405125810349460717428156132068389884811129531014665690641559952450142631134435 +3120882941134196144363251034342986015603525881548802680508329909569735321266175483509995349121263055144465010373367684170785550 +4158635639323481056067212351252293942485312028596582540399759383658505450921291350114073361212206891492359937785370602986743900 +3248674367436665982259747983227106329784209726320992248877150489251570771053020539956408865849029873307934125408634817191607873 +5454247998356721456240658773994350865596498454154991883699218368604475173834985657275975908620474089305230670921518592231403386 +7351062162946891390363227270397968233004651810177775309863584286429947693132180002624305405957468154601633114090431896806560396 +8578733043161456354664012245929168398575757646163138337526746639222181428391936995137008559247216584486677942670927998985802859 +9200314360845834380351667184778736242928721806415925103242410837162869501355174790557366226463713207146043374288777068201363073 +1884840380691470035098733943006470724355475360919052895346183170077857886208887006329282319454011758272954888828936243319780379 +5906121108044999002595816055500975401842454091232971454535066145382445630442880279299409925299375855072691591936952415415855608 +7427547736672177870270669416923472904176994726042270600865769556468182342137641250127961474267696372215125069986572926580684930 +1283565631209283359581543095011894542058022145233771315616803743285668523226044837411757706026740916352039927306329889089649349 +4270078841384513763036784211367232205576108266657423596077336951308763566593324577257390215814671195914760219863020884678789417 +1094797252284852472558752948074017934025826602284347674097641546447667688812462875419412834529814608042996511263599028929742238 +1967645060681138182820884931078366878249535027007771792225806188604957386423876036386080705880427884926800392921951044407013636 +3181566611581199324907272529442720663293855144200609139564151757908337725071341353176155541142076746946246524270499526229012582 +6539374062743440091085243475167651698361455560983223707251591133463685518000037795208788191244350973724875956194617703899137414 +1430821502040369247348912270128694893351423782952149316135243013570919313886614565161358637079094402119428463930234964822013013 +2907845492061431274313604396416192334514224786448855288597321564420931438182778758210128537309848899766746069430202195659612336 +4975634130177816916191624410591783555638901610254745557743055701024321622685828565315892206810167787457147305784539222040470909 +3426187794037654633853814952285180680406547839298481434679476618025289610702493051123252356926166123963245694601391065308079166 +1560694708414872555648575097110162943981198563540849019446854403562264846931619983425916923587136273462584821828465235074422917 +9261979271695865979574032703343588466946379682055875729180379739323087400969273393174411780309814669530363099378105348978942035 +6060070323917526453062047842877465074776912567111669196792162790002591482979059554932579116312700674668070694919873464603223754 +1894071532823340571620020715489409265478540234593867913381245139145940908648942949383027523114581382713294341230059675979933347 +0475001838386962980608799805753326787172142674741106499743819708928855603482127536974433291922816520616537305575646417283646800 +1407873654137191433607314317494815145886982224527312502679184216570574189580738684704012553837521804108283635888649341886347674 +0746298331021251518403002440748995086111379224255590828431961727677994867561042572035686044830391992128329363200090117946273786 +3394767633292754355096521352490384715569381533683416319072637548165685703657478638050012390155682264692286629389917053497837436 +4659095138863302858042866246863612004771584058240848977405503610643181773657781348444480569875240316081167661626347187543347285 +7911879124009359945066105568437670726515538210712672838972140937144499494198784053146413298370949806905102557089313540518536047 +2387001299041180490187017325756798839893484841126540625119691321202951445764540357103908077323391792392357443606419429134662703 +1311387664343269938420538390428981548672980222893983525849983661962674897972783374663857036358464131799985348402057774789061484 +8274461005931054626156020913275021215007841002783185917701579638808358640962009486666957046897388731341995785176631521816719220 +0104967747699292212229371707417874791998945791320492326714053322534677090261456035102963665329391198512545240166335302214953529 +6438295329258114463806507486440728873144766916788136148990852634546220929994618127547833759089567150425084541257262887419748944 +0763510822819190844430827630471119922358130707131670435790654181644862502449964467386506947657809851105256327118765427086936245 +2850131634530202363427136221800593088389014446941597649063703366121196898996686256705732620416208851855006823708510518951595042 +8751603030878422139220116631069675693727662503215348707642267571256820475012856064445690912370994140681017385311381651837184429 +8337808674514385942347760110022916345088925240957432454452424792146056100857933925448423669501901023480223134384961261737051238 +4413770733662528673309544847059059161282542697670213119975814848684886926540572546980353008826625285683672206383376561174283585 +2470179376522057019705141639334564346002921054122405868536589549939044185327352857788406922050956188186959812914331458433168181 +2179183768538040087965101925166314083741211822328135691819236749579736222030235331381929418960851621953749706426251383153679388 +6697638737127992949029219495456980219928837272379992149835670720157263752765848341694925460132961677719444757263352390287952092 +4093217437367696270862739890376907333913414784572650839225342564140670817115158483271922969611210426005659701735005263854191680 +0504868284114293941201391805305848644129473248052919285116546768968370400211720819698688057290313111673099410825833594935299522 +2193387285480585675810105037896679125123370546559641586098343943853768828725430307316784909701983568646060993578149869405653861 +2934591075689506327550526527978208181872636707486069235044785075612292358262482648814374144402086535106182407978781842722397427 +3764043018357659628728101790307107498150768318990432916850503907920600389618490690749145152636599605594698036095369786495988258 +6957155927715716313765479257750780421880426026172174055737331392383266819616843853222801559499877374057106670897236097150948636 +5427827682310804721340200045877249335498355065518235785095376215323629999016684789788057540796773407165234965827360566567682463 +0931247633662980846735922260231265500967979148521116776842985570907612389971711829938070907548905323760203422391349321697221760 +7882789193682587165711403864901445874796286061561018238012019307540878080647271091752229028944021330264150343818926048069144244 +3829234846305757977743751433953176195429230057570537421684266250781148509555390682508579644164157541082064669789683815095364787 +7604939164496265670478495045765555257915418238903189606069500034604107925625520169975834751123093859423683572718773062691097465 +9536565688839857043404968751102502068918401627692404156712144798677665827278179931457967293092502383995754188611043728483106278 +9597088053951878542145390264364113151329590157432302502341917977233379257169202042072712802096599668573120272798291944153363375 +7607153187541747861933137718609189822023639083176590969309128534131402001720049300131597786926920331444518080594310667529269598 +1927075329456693896562301483770530596686903351047943440879405951056391325510081534440975417269136288862213745763314617080452571 +4793088300460286258221203503876214260288694619740795021100096527276740956582412254816142704747725930689538001063488725674114094 +9964651944235263688993656306565044507502459642744800444126035956827838480470927964887269362894767336619648517065502062761621016 +6129875810846273188094595526245494198400294797450838878997940481886389039479255372079045644823922532826285987109316717080651452 +1158870497644577891842220310991400298247186591687353490986090963675370236688750155704648708257105452733670085922368068618952508 +3951586474153083065442516047977847063483146004542723388081748533379792081337808607910165722930346295608653437371334690508592931 +1348798137260798951844725481726752185101778730990513125012632961668430932041485231492712161518123487434868038690945449294611190 +6621726374054578571840509185550584952608718450715584685612358931363303426238432883301985179247942967408291991891183249754595852 +4638603540391846589823234253913403535906012903538328082937776681713183362324668976651509798060188640593955628086698902190682737 +1314136004568121579468174164410670114683609747309631647110337083615027244209788221757184880343776037559026360829925134683110860 +2743916110589248861852284646250771021137678508599837301158835778690463663553082493519868901155377573114305779992715972859595723 +2324106156194950900453760356879741607730365869344607490682695136931314492042609961479060353962654666877592314030242319785217157 +7037168535189901999950898708785124945709252827963059451445136357835564541820565609455192709322939082485154440865255543678569770 +9896528396971770400160528156211153078421941311469208430939294234515837583618887123400678449175339595403746664662044325400329517 +8261684885541466594581605303831216257932122772017718190045767780517645346911853652853978624682959833140344555022435113362676062 +7591075563360347900183625940068873872381827943795851765368024187038497412028598183964746465300474453614206176090307713158346489 +3374371123832409332000144159517441149498304308931146086397279524284139118811410468196667079250510555507523645907234786379143531 +0501327353064942573752656984727083020738199901757943687656464477159443799349546909245912076525128236088399431523118269843367482 +8613396151458427790408589367894556692924575676708650976493092298687011565830641071449135943255849354462437020422889320020232241 +9743887743932345248629409670762729564753828800124861494449000192569258881214737190612239921652995520457700328791744959299446113 +7181302058928852380763877100101757115044093853940723929209952955676211472249441292704903663335543383186649963257659728968301134 +0388255348661563721653151594456333702528830265445870529546222473972548233646402200780627751622560467191291529956825231887562559 +3526669851709736895997935055319638614407522325558293993145073133898821442020970359820377176459127571138998803488194418913023474 +8960318055715147737928173496291103297340011637615159200331936657806625012838282253984371770704650788787874077528191805071976481 +7124181681951361717176138891836878456339953961111533220751215226320942283255447821785246102801554680118941275936544271258524058 +6005709566240667298294089625210827175355499791073268532752944587487068732200218887976443970173147332812756704491687536620579417 +8523733324824779870890616722944885692254782796148238417811553337420218355790067774624307813310722411932853894530043351212104621 +4208314480849782328920489549263981924145677154566910149000272410262683233827903445768177081248117495913152923052663893776265183 +9942787773857699223811513925994334863462094677096830079955240744467436994912827703793978101340756041298804409547081408298801222 +9436460738640015479585458718857778968516432654013043215917075749663128588920464616671554576564466134592276012302780087016944245 +5682263919237157166619832653999221365676490237394196490562353201595416072759662040168607378605240879904649331264075658653944374 +3188760460625654041085468641256306887215807672289682883500357801180231951265973876967365453175824452139544361480252271534860563 +3489612971636788170285039991175495323686795856259626029428439316305263410995491370010061781397716962628385590075791887118786041 +5311327330508694662530309261695611418858308192623059112240071130884198746415297821301302430358551661316850076909001762997643991 +7081644935973288072050639441580584025029531691351232277986672643518925684337072256344249262810387549624475090299911463668556533 +2269997305729536278296569991307939885225827949212711278683260974334694618965859001446604029046584493463719653785353337281283459 +5669018591396191702482439366148219818778884802332484502882028894694251543216632761518648364549018220678109701293026473478656784 +5216611642715035439533559692613121139357309471021194983124318134640525984115565217254793009252347891534891058775512107043759248 +2075136627102497321632846769129196363043810766007725332614332304423370092169449259610020916402169233919813196199842388493441962 +5246508710864902175515674209765293421695856922741891032048768583212886538286815573096956696932708558353574597425799726517739782 +8036312671737074585001040104552777443725646270711497123342871845885341214930320018750607319709014145767035316932229927380726251 +0928548556204438876091471205246192546298228533150898999146677973522875037893164503792472130409496157160476844265385841682474739 +9233703771903675834839283547585483443926383504808637869079921199402511859863654798938168359018632590649252624952570683979540091 +1817221547279336881324191918747916105439761395909101897519754743532665651720607836479601826466707285601138161807075561528644357 +6507813758533570073431536118758351858756886547831285242021547001802317103965340085013359438004591048652288218222633904693766526 +5939230267672950104631374960137514687520839197558900123956846637455545802654473302741665702939840951606373658402834814254928601 +8899091999774572904211301414279903590789989799671058329810205159495566404297154849221520843334449344645035156970528552300030222 +6795649886498390391442973828383660673784035290138239807079635557460618362207456840361649348840778636144683493328779008559160150 +2312967328418841937893181097506584921132253955130661944022425054340098558673444397656011485902801524597729549862183491017801616 +8364392130149044788968141245875416756772094094121947877022476352773253705820364822300001844264751712000950605882778006252697459 +3173455702957684349309232875767407323242741753471239292204928826580888927330167241766284958168551480352850879501139241966892452 +3677753858072439789438100033278254013052115660199724677408997086225534466921024361672151595117485386004966423349406051295735713 +1033555069901179500855772626876468463729168610634688507726870943003645664213844575844814874933857419440136881531279514876328051 +6902431911053955232595350941009434993084829394137562877137241909400659809326832785642273291709998822359902244140526746390924526 +3598394230231172238038637497155035177663453584383356974229908339909881383831792443286626244348781344679035766390554002582686748 +1986522033280153369322100953745103819643767567342601672718065640720320991063977205827436045236651592119137181084201370425284749 +6005671239600468501156161076186950720461257574394357624099400895752471978287422522141370855745760936595412914180235254380961690 +1248432656688783102677099988123915947205672369413239452092262942922895352363751338938332396260328925306803441684111264080959934 +7043361968005295354938534781857472787124249512274641194624952254981027355960086055922235901916884500390183949326239914435749876 +5900769760705257904732141569222453308536443186947518812790214535222294555869866712002026766787105689583023017833746154510155688 +5602689240796761919744677404697558271913792067417789140292202440216539736230658588620970781000844620550456371994946471279052637 +6983815257060123566373254198705908764725007305820906210985164414734561111049679088421536404461082246253221142258100082860407483 +9787291977224975917546280204714841440857941451156318425600052380180319358748436390813045531423344721155836168161085909646309385 +4242317405737007113338681399774018133792533519976132559943781717607228562711266632582303687475696334211416518106220430942562440 +8001103370755032373531777436355301854609759653124445242732075706459884158212645376386153155459030396899392086527430085304137547 +7061352207839212087427452963168038388774060848015551117972221521512460122751953993512403134647980990954916284061921026824432536 +2639034110356917513777636397443311536328136804898636889890450733741495575783711662670202058347655591164148410498512181752116112 +8649347704311634713230582416874077536749261618798919119607870454970552954421518115988625118329175121493449500857931770229652333 +7998158841528743978260913418602919615786831528127648656825638874370061930628233997562266898051264651939263641927874506380487439 +1169319905978231587648398211672101766334393172127691275996797499245406750863796639040056909542250284633880406494091612313210866 +0317572128063301907416088057966656497607301508200217804677889135103287897506118599601843251561058377858126583470533794642274814 +4690147674695890988264540020570125563698789420115878750835681272646540842126992805764557197985389253255527910197264650144295636 +5798557941192958990661384529989091262630978788566879170732007097819131006336590152363030155153413704404260928053167322809868601 +6850987001199817141644762090308087270676753863496477045191783385382914059759989907264265980509298271071343239640773196627310409 +4389027546704283892663222266104915372633460042956234973983464977451929104395584092104280081159181521725125037452942372440981206 +6675905477554320026243055974304148345728455542853879050278442548087322107774875373656985055242105650999387599625064478196226162 +5421451962648003632206646262643905337837657920982111146977004270602922886008501562566012949545116457517171981566495094457953170 +2653749527617823956383177123455781619052217065408026747322738616321944929384445431993242259268884094539560852964142946672208945 +8593461023191475746268918563613277494098559522521079968069246435865433845367704112809898386514701303501214965468624316127309978 +1864190494247307693037266993358200097794635502447995520938928657994547718890764619887745240985736437934807473704761456024575292 +4959121097171972205063831718099245216438006228886790229146916547085014590026042332430672777678300137100806650898573540666242384 +3655898393459642632004541036291612193425851747783279795401104056847304510228417238922574433467131806129145867390315264166063875 +3665579208506648402815517926487551967245716952452342336509872884242496327353828450388024010049265610889985970803926589219237453 +1676400095916770050334175293677803863116549153471866784271105726012628596876429530293900006500470621643237024986843048814960581 +6303887230138382981362522022235864197895867379102358980372057655831897690287262572451017096062107356032913949946624176978299116 +5005151176823509060156202781958197462286719252108370751542425598689093613819219880986961622340717811406826396835254749852492414 +9810879199072089316354376552239141698257935918222963398002559226752773027118660428719265494441568442234264661966547139854597318 +7873099218250455002270603753696336287379126088262705830929170584620542532170428705348694262962278699570554235741942919271113853 +0853097378201921331418681617335834926523454159799372408812168044016229123296540289846574743942294543985242874224122532498334672 +1490594866688679908867416614545427520723745911612132408696699789261886952468259502210832466240663473598353736119026236378375966 +7870513434223037902717553793135590258545562641705185546860782749440609431080399391577848963291799745623426666134231053217546405 +9446201870461219368892707181895875357863356844636097852807754420432074309846001997057609966109454410826649254380546761753175861 +2761057480832813584246237846523502525922933474798627724801784019360724008460215340269094831023982649184534291701279975122991786 +6747259709148196213568727070749193520741364779274424639307959421349714799461578583982498969579857164144199424813392167578660320 +2903178417498559526330742642780679790900780361831699904848420604973586382034364851787093357442413598696765925470890327590522104 +1850819839601928427102795504066478105300817488452603819717168073205087377109510653761519361878295067555599575161123548496116519 +4527800014440544203257680309603709183834604758224679743597378438522340853371773245388147497516647805604078269186299047096706230 +6498133304861002880698895980139890714606455707071690798907848409609045542981039802321508092873754941535671659985239738644320953 +5988405032666743320254142929561597654494413403431947291535930103688912359712380841156852022207805099821357330225186728532082090 +5547768444839618341918220237864475011631317876613320699268333350020360283617553420136149953194413589978795210753934389762807735 +1597329107893662665482951708145282526843200385584016605115945831916977370397498490572333755725067314085934032787782477551454989 +8425608912417288932359069001529317862434139520899814966998471303722622773872512411876898983545914085663888123444680470167948505 +0434379133165396213883414761877309648582182115178764180968488658223225128338783723464562383576437566308911246233632408447704048 +9663996367177301008227471941256368607999821009483324708241288407336982656214907935931597532047696000543001055538357367423684843 +1080054249718909513852149584485289714580193379500564799748250805755830508642143351393106365614646908548224506838553676335276275 +3599779694595660288226660287150289204263669082115248096828431008225170485272045909181946378454893228880239576553739907190878426 +5885850036699891408378122906193395367309415591691241926759692588330412581784093438940668271882079466692153184239937668982303474 +7878175454828248795271539884473981581982185106585811627218428403581816331240364769920118073711196193240357920319448764087086718 +9383157433735677366088538314691739001878394272868474296524756761536638899101995873845026009993980779305151574599223381548532836 +3668859832227797331952981131294963911962283005597571432352599223356213488863688452877543275627906341710804574808946808990599277 +4561238331796792049632393877616772107198692076748218412457533127281687506143050581347703755397549089646358464889763941628738646 +4287040673613995225940479030356811166110299081667864088662964809883579567473005653984288637714354335572597312336813053771357145 +7067167172790181728147512916597493867072803164173683458648511730308061884633961295638170464699169569357249648229427546009552241 +2411562579887913980455816507682929933659712945876292627871263596090842188654178242939374681016381916432972311121058175582055725 +4171582020877122298082911042822107332503076877376941726903575210668249614607891518640837866322224789915987615341840992350582413 +4400620040237405249285698955673350511161843009038833792839643496604322064832266848854377214512824709405806535993728236489108631 +0795420398459113177519012283723869747981824916722015034363766243369266801152099213940570568038081676315926730528271844090048984 +8736235449371678977947912073661875499227319547901313273871106645387069884378420956151320072268281471236296252518071417869812398 +7190598905022008877003332225740349664805580192380729307470319849086922459614014566654582713365646665851557294353631593510036953 +6381552204220558217529826167930690334372579521383903206328505035888174852614555542283456959315756641772011982607288085297853686 +1349874783384878827773365548625629981523061054390679273761674753812182403462337719746346989770142792526923785272095298042279054 +8890444037528702976987014556298735324481383261103576223990679497009263015064472090831542516594399577027449370238294863246623636 +0336415324118608522678012840335823229090847361254516690870558705257294993006716462941193893800422308988102399798523789694443112 +1923359529945753787122624465725573807149022119989195390997561541611804328914617110055244794800371476974622186846094996027068986 +6556505900937451676724626863029277508817962303859724405355623034880805936586542708527460464895044273023827975806326940478307069 +8592969583414428893231495897818982129258755657382413367672348099201190652878055544751096757376276397486791497622706985221853529 +2908214067134856191896613437551307015999440525676444599333628882928075642102806483213033250837448355509306721853006604031173677 +5140214739575524129341946985893116412008106149871779041808900801409064849278864166852383463573647719274024968463791254976359299 +8847571119606652336355242986018768524604507411735194803338041421026584303361841828532589747052208612636774062068296366532983021 +8655354613872561646045351810915955927958378666435016019460717328781560793954138282423423334855186987151419088975164710160358441 +0049260799204162100696414303845623303274803491195157588921793903647526766706979672202295037308810197036167390246126788340972486 +6425819895447745350399433314412535917516434906996482513931003678441923085763619185652238830813722611071936854791527455947241273 +1522067822697883751451720158852174772439898925807262503934468921130385503850561421474472046621939053613032754307326343494446468 +0373529669975958588899685583408106767873002561071952257411549791159364132364256139331134266337194556486549929770686277721381623 +8699593258141567800940600698126100601323395696274203924322395263563919165964829715731584976772134953809087705318959395613991572 +4912970610760196588068419702343479920035578132234944550622679160245214714573304402887577273891607583288099465093463035431694610 +3905758432785910691737893861264914959634002377051354781210095863851654985098474884630562136246052330525659496807184083910344772 +6004796506916845030772132724200525430268203485146341239363234592583508467825890468047631822102162429469995405739029446103026786 +2936254882880449606977442748506803270167246097479977977827447584435796513203817330397221813580364844509174311882193765156654656 +6587840516915974691152625347076034414185867253449830309514472874859872212804040804281552578684775759016088925401886242253588410 +2136162082678649695650433358835719979490577896244051036608023014229544782516370023231616157535453095718156293168346470255374077 +7531511647981041419067438947595659704304601529630424537788677553031920743289991068705064547597248153946867352942473723492529159 +0056165493810107660174271077633956520600765977621759777545425851195592595759244720831020706108951012298629188421930844092200174 +6642191140454110070088900972029229475358599582028206307088525106506003848087788102905904900131739063517620939825620312143365317 +0312737363283798477941966380713988316123472457978241774897278441026567305606285826664686434652740990763564567342068867452842418 +0562084816143782025599524978888894444210155619376771675521151554796594041637061218094181094152665322539245369886205219847245940 +0029405789079825038952711651290857359659229927344229997950428696846444420150303484487905236128836752670607196713086924265912777 +9562937968844743614454574043893713056224816312429825464738549426759328345347674841205841958347360767579803402491577142236137115 +0533906692397009484027899629862953135204910641799594877569760336943034406380230261140675352675702660262675371335224685084951739 +1782949915965578201764231201307179274400901440982114344774078855036237671988151622145580473895458193522528339933303018706591388 +2624100076711766326191346479084275280944607050965314374143191066314104835834695035041295363869510686680641979042639548470149337 +7092183008459177550878010123635992307868170928762105253223870251579666192277376903965022436031647547645865700232025464698571152 +3958091554628717576397311569044621708700856680671753736603162545139430701751294444844592994780440200375396353670083705904818899 +1158314027781793782715830446196630725174972102720930236759032571130842037840584037988906905557214975416804249578167992887315936 +9206031432141826113994005343808438088835006886050009647865275969654889753018433197685269199002634601456210696285807629459472336 +4978328489062061200804108082671938204870858983057488740461332416429168822452529945581949038775475758752323372301506063733079805 +7738055653647518591404108351211994677622659177154884456890162864455435902069510745121823508583748140331565330826498449431014143 +0674653178829590152076432119041481195951363053106794226287750227106636545367810520707295978843237959311321898828560534345440055 +8038620990007430479290370430002421271720574168054663731040351369363896772189503927548376910184417619479114290519008175905383545 +7118330213438952390733597389988833345665275766596109498963112726494459652684601428898616858980054673653547857404417055361966561 +1587037091185968630608431240360245295772438686943763646925036642543820946055469856983284464996007864493360253900748905383563580 +8745104358873817076497065734218673552778861792932465886098953358042048623712145278501699290745480384052380874247143800362538370 +6251997645750683187872814541336341689788360883547457593458471177846675162375769376759272289262293759496680413378317765946726569 +9307054144320271279835934039640502070988256340708987512314880763049398513262419383032058404111149286657762258132166819869740391 +6208679111601546062938461491996426928719837110414091479969117767614499297075986816870114797028327349760763930021316392342344670 +6195338739848107103644806413130142942032473433624064988762100818410644021199176248704887358790343589713845228788844183335779186 +1206612776301905227273380391656909985775786692526546380296204581461396277505352115889617471623174433491331255641939009226704644 +2188221413330256108594133828534885890151834345250541767462459786862391647167810214086311680548340646481922395107065550293841987 +0422053725280997492804556037165046616311376881740818579026242231815216233417949738101116086586716392810175144442461269235250030 +1446402688506317648015492449267953446562377233978895904366659114613140191253374875252211719488638375761957759777329556920444079 +4742234209552120961058674900214350131325585573620862943651827639544267432934381233345762116672659741592229252195548093031985971 +2686838533752676886446680927399440863720061868372851834815109578907201299828776117754439315722227995606329153759209194448678185 +3375830903591078788002755338696975595441586005976260188707036346541857769978992173498220429575524475532930877665817876092460756 +9351987353933462923395374235495972847763917223789357531623204700947268441087397398182190787387926517802157283116535834305980686 +9492332135897364643664989358260446062172464533880475533980243165095186005367740562491795933632109829107385087893207785894397713 +6433768862702582156901779207532027093153001807004150434114821705300991777142257598550961217676112326241485864463713890885328141 +4370423630135664116118217486548726531069411489498186055038679029605744527511210064431632487827249384739496221986798075711280160 +4424010886610887880437216748921409021429656729228727372446155715321241952848523185619209556774687672654909818027324033748491821 +5647085557243826965464774431484515106691575517669395491646712200606275072075247550415886971532904779039992053369051837694948246 +4648536696394853995288135284563546131345084094639405448329957974626886591260968153163248670156108903690012016896947562864068947 +9335817025706673645248672808655206936988229988506868855512246059364735571373658692183981236508753893624162179393300884572562525 +8454550045708811850843967602772364889207411447386933113146884803720821905371224276398839301167373376393299604166530531671536817 +9469613971479940226446065344175803391558840869442680476409858979317446638566865770776832153252927434674599753345041690804354354 +6652209314699751202444785726308628207785053079762876873537555813669271605409315256570040001991644970781331622466129179499281915 +1961444894849498696928429106294385830964606511500699941607840002024216695044414216800293243595307021832292431154543081449089313 +1962091622249577961316459709116638715944104552499484128514903058588880092425282180366103208523455810521574844650965568635887113 +4368421159409460609897114428104781398719260897374658539676968461604386468189383954460163078825080336107872167576349496495408685 +9649536539795842583228826048018046721092374785553431643665884938389496673231436870435149786802809160883735413992798925929876704 +5235671264707293479931013726706891341489539237837731840177933783526465474894432047982015526419973235553573918270319559547403086 +4039735888376366609018757028506161014783678583356813250677778613982578318008203758267120384291005999279443777316382864592311739 +1217739163779382661260606469702245656794710548611797988738048091846590739807732824364552075368990683393959928284317293320069867 +4916615035875154768600732328677330949063202236875210951540534956404960395079564144372822026855682749788976197007630147709880516 +6877745432713411450666647170018266444463633969867263093231179811756276204043142296040101066040921365338143870829243201412736978 +5181332217031028793650384590762724542630876907198977592730043310368021901782721530053394250577461993296684728562642042745578204 +8059743569954838104598948856222744875810352375978155248926213114786009876969666524615446586588275065587752809296977777941299366 +4960623850950107986976011274245247425368704858396317272530283837294761704449561833295704741998045363670811422098828233894939307 +3391941685834457637274247913999521308752675840541536848418544996656831007389255133631777457133457716285009673478699826403200309 +4519130151833287959851246691876615538787874185186936205145712978930546123861640155395430711723899715676633532061887829247109590 +1676546877970973940392277995447472865522499015178996256227821980732651914936762181112328377073844485649563827098289006561421904 +4935465846415256812459944886042442740776629289289624483798607070666905637221701286036356829140962976615020452048228461943046845 +5324252244416512745242538847575585469682159371913734134263569496276780441518422322618507872746192259540742513974372774167973337 +4061947105362693262133270759088934938816594942342421443896871674922874493598103930292152723174036554995062078161445343075609331 +2764956618470182052214734830103729160245043907968784028181813618886443201986039333396356809943270121754709713915646568740151206 +3370863211220134665256513439944166456784396566762502427753466744044215577692010267595936563128872570057590311781066772952724628 +1434093271982951335221748052776429614044261679575670437872151960576974124250079774604982905427771724749469647670243244251475834 +1955236107353798168181042526280355939682930522521300010742221556820749544725933966041624888393993154502962490618839145486969576 +6290416028546495661266540757687391083370341491184427521635724821327522535027514382783824919995740288516481937621675853899158115 +1271233716574270260984632585239413670925887252984501086126979534236923438493445631129740540692858583194337904806381657298903618 +3300535021488010384891010505876121956740827701335944021678777354223576529240510607458801670448052514469687591418109583216371899 +3485417441989301906542262637698405742722722240100485896839477201597733807155335120248775000837222824525999750714790729423644465 +3411348746879651113262757268624543364109755847832677598538228869268434533167862688737780726486206863057323257234642767012961381 +2165814758833781311422742619981746792464126525574786109619341095871177233773859607236931880493129178559812250332066463408514532 +7726034975123054527871123751165334996022991283473243555448093241244802428165706217812562663617393968824053366244173854470750856 +6095264928940472527983481330401867205683258753243162756860090551147348417813873221392674935402798968661528287131244490650915944 +4846998428123345187768488062434480479219313046695253889842680691405315693254169660178067961065703759896641710892485894972873800 +1685615608144031413476448920807056587474093195656920132969415782126007882727463216577625078022336565533036012495150175153154793 +3655761747568001155088833871531145294046756206587264284578974630056937095900549928662096625015556765632408742933996850251895951 +0111954704076325038375601656210245491836721039674987643056715722213989286056097567862156918863302428121309646750177612394901330 +8415584072851574023474900634488379027144152280913594573298990276864512420566377677406310761330579752357658832083046689763512425 +5360991991088493887837058948075647761797269956784924198250160336333432026534756149206974204145691725795668303825556473066440146 +6308534942697410882776557732300657800112150355078878291669302663342797528117730903433654703116183867380240849386640798032108726 +1472159005438778436757327262797064431019220263757862409221343714482887707767271424863105342534371712556647665588514796238299461 +7911386503568215258552458522450938485043355503569972624134133652411157539448177529209200030556438822689089819514432813580599189 +2365679543813190286281972504483805742897733392239676734466218958339246807222637911353738424980809257547217933600526785327528737 +8206666715147505843269892459203855284050942439891047557154055608815102510800979065603928242478158845237310517156379667384978425 +8564365639950704666389094627317673103441553979461958229265682055180735168285879029143428791049454750378104825426147990982959332 +4829102499976584107337249497306375535937865662615510579219221293219668812136853030161705938471830225621587949094705819774556069 +5123783679768692703321434015951275136482214434898378095577232958805557078721200098045359198446613744587543829867662788092598136 +6929950567989350660377223378484336709625123004431484409297585830087971734242391343301362221372782329683381841402343240854937627 +3027430314645534840941417243615965839776590781088050407903488696621208213787375420065466391992905505392720776395628578270203968 +5561557545896908531566696290176040220677116087315281719465429326728445015278079287297460019260738872427151255654689514071849986 +1828538379287013993210377215462458395873947138158932974395044262987261065763556796656318930386507150893214229366028840942649836 +2063121041445493166725834460800448260568700963104181570946402318291105228818528098805135391601388005156357001178185451101272800 +3370800872347836800855502143109732296211615709327616533336180819117537969874343031967516246129400847851680499950308763513532698 +2261251707986576560067694894090522658489287994163408241552992222074332750687259975120713193581210288235466997453538082950570613 +5547333609592722700682015971929817349283991994515812388316385424977175852402318951978198762120074865379726347089860459367729850 +0402544338102912384265553136946539662518389179790301064640333604344279296879018653656722109731114774692564467347146643170192535 +8993673525857276993127971955065805434826324155448624528360859774191561165506877746667502530039089420897916681025323026574636061 +3901599392791219781553830625484740571991825540511807354859441733493239937466053566374517381465227962291796387571020809725382544 +7574422026948740113868646418886560822423385797395522913481336942061412395775696211559412859927044430059903817069457531153931671 +3666927872751409403909634814246127285265889024700225210198280286825210509773750861772507551910169158603017385059974490577083038 +6432266277247351230987806521470687675699096976848067098507903096237956371518053276015484587153777797643144785970196659271124201 +8805175031746648720776866745620376390338985825396413633102505797368825729966186841638401277578013322523402620704692665720430906 +8623786671348700175861755678175427019767971457395145977447813890266721740858466375677681653108760786751356531141090929913781526 +3195648380237469630693855838585465684458789117617495694729011729035913248141836338293691788762707190185659273515849140203833275 +0597402941284234251455344083137079916499435796408338558567042346638713911874856299057564768580158647502818908352952487514100356 +0970868650564875484386825809898953941148685658470222784359891344183429634142985332602653810091182805015332286021467238333362385 +4744217325804259157671625823323830396696824326946849733799160663706608011805733632306227156863544912264884279245494044730337851 +0084125575216079610672037870038502647338343776533232876650551512543864312081271558094734273891229896844012952524148474639077490 +3953838752044271045872553760612072547541462596253868540540395181295139378941954659771594736894686221229277026890071243182491089 +1570455075037097901528554345355410026197839647129067342374536771901052967778273115724862482455356615889491970844930623438114267 +1113425143150646440502818701009316634243943336310155606852136330886016200376990719743484314150050963993583980070237708157561869 +2850497678307680310432965409960545878246397108725852340253836659713228648432015357639072103145170515437738478376685162370275788 +3326664187179079200022042294919767104163644624649594061308737509813605056856101998334843842071022724849290393928923994480353310 +5498899160503467457596940573659595416916940383633806231810327042150722695852999362605105557507669885448657908253818192962915295 +7340742801283937313388827545354690848045358633204829321755059875964474925792234042792682433581007092726558257928146358188938017 +3788737611929951605093399738060446796551970972956586328702617346062935531918635358396384018139217900704517134300111877098173771 +6556088236400468643295262663772005261144129747959817416429151644418457406109514416151746327186627985567345268051259611187659664 +9265455725916581745797982714801820234080260053210177213938914050671185571980281286595729366143889579286214314682943150406601728 +0316466611292764222191535471075816173597528297677167091929792260801201488249926367457821134968651224754973624583045814966898991 +7240870813182642979734405654373311183972717838426383954790596720674570866884378092938010438980361304392635321123093916926377699 +1098769261784660364965755629864526449156402293650490776352458745073647855811975287018649518441512140869999035534937655163547223 +7318570673563180482204840468935262794048795191854962451038993504158655689641517360974735911839513301305317748540458018312631163 +0444738341332226086089060414609016104084271113844087095538006211914540457624942221411569773470678982159365460154412977671269730 +7214452687225977763650799051005862709711542484791447215218763058978813997928801482608042879518784727437915756166238817248827266 +6180378877242192988083619217841832407955378736448569454941330027911152317402955093457538120111385592095583433817050629741079340 +5629107620334905196700840557766414405147144002648539402508824797133924214385476958587576623195377053042403089302692454844253984 +3318554062977863170044352262420619308431178765567333623647941692615442475752129139395428889369180754179899164103774056228855177 +1724684496632837895268448877487345538070342201067523252247951553639414362390924781555578381060846820725528271757795755177666280 +3668536899528123873671104403554809934477255454000919778770432207141030247047304569687086172422809626838419879927821205317757198 +4281376208790055629568334266876725167967493231201019877577819781783383068774238210201096426961674885308966481435486534817275888 +7577712459257967273487604669410934219901389126865013214764147583539515778668315529487762810385482472159142915583111160208903283 +2092476036780853093515438486821087167147843243339127524062892009959789660882873649427006559335981769826686296878365166850602867 +3343172251567689761041900651298644580155321777412234282871319882978374041565615637937824367712999898962026386244164131814440583 +2523107617535787966332348997625949033914601433430397210697903069041012073594953603672415272693571514416319482962732360550203007 +2354311337820780136418582226046355285087018441007811818178174630131348892691010862349686382003869512529793089372921566890105315 +1170999065500729991421364651545352790769082161371433138736113416719659099975772914182032395782369105406892855739430280792570755 +1474708015575641879072739292610329996968899496702225715923818519908679748009454327877467225863186123383312506444593821059541320 +2519230317068471671990663024614062738285094805102560284217361596105049865919692357067522503590280759438003713619649669926160819 +8477593117311192072667283113407927363527106554972169624278711433088640030184820529565097341512033077210672824164404101920707697 +5928625658638382607550288328629457639763193426953494665267869864411489469568811023649446369996193687172148618677078694284120641 +1646459774821145583534736023501469753322215654392655710781868598002276354678420510784519315703507997622744075405271188494799548 +5604976454282399594837769165955324714117059445288436250408738807427315530171196984735484375626981702836635871509821590209332491 +1535805646302302016352504827863133089568000814854822798689081283591430708834238105002833054643250911507660006657799194089124227 +5554971708100609197716368094861383459498089313293558900360605415466184945588159656825590482066432370186681671169454435798038380 +3849073431364569441656271420494005561747519609440641325324675204133825604638188550112139476449622000662627992498117594394096623 +4191048491581987672722516757004987334900086209495744999112552193520096404679809481469054957100693375905822779214877756331765654 +3967826927260531495518865955487463010124395050606347758705435971911583515293152693887305102817702226005465633434328368776552721 +0431488077940753541035965504802229919911746684489825460131664577839381215244988219702491643455403072485117531612606199932108314 +9410075360076281631174487118204030545727872004911310355915647215932318325233997786962419782803117783722823043531791703707719546 +9979899286512850189031098302495325193753351855488331350658951722090011555997930787556662797780665452620638874492236108755984250 +0652520709290586245394513350104966676213533639227604453023649959625928591554435452582297988094318689720723128469217871904823318 +5154138924950867908591044177967760020371009497593629645137446770819235001454567589699623753759581616298742234368099793781827967 +3473470305718567484348272233839660441345062709145235638650446308235096448960992127705010353860654270452060145032963280540290644 +0926811026419214969150491345419181845874142492157134486078145329290631845342202476471135442659122079092431512088292118497802805 +9354612782399796245605885928858715130206027789349453872862552261402417530015360315458931199778666063128483794096976323329377872 +9050549362931470711847062862659110650055274307045585443522892077774880073956334195774718662309192081402741882514069042809280212 +3388599022582995822369209018970901943500870352576118339149315315976479926966165136544818295802570738444044829469770910136539354 +6564372944547448237407512632251508379320872549342100765184348768929229061655816110427490635344170087149155652249787176557737086 +9304726910793034348084164624446844756267779275838929154374342302538079381563499255177774157465080422281305646532991405754916981 +5079495135477953063596578815549589683659295982170939553637877137130071575921564130005951724009912627770427858856970687414583660 +6190459320672966822341653503087470382689354052580606552329874275327388332913948910878502521194902477705810238260537165258752153 +1741863988657791139389205030367955495311579034712194218460880036525975053623461402320730996642095747448443229185546281279794016 +4885628580837209961221029576497258511104739050257941549091025711288015307691459924906488083252587010968968824529177652581775801 +0763397108119317156892696282929270919177456927168774057189218655020688126030914415663313590555442617356391166888501048989509961 +5152773773826793584772678203560374056030587370542989568481592013810907285435722199937156448541686535030998055918516459522290076 +1305239048493423602262076973364789510528152271858803400583562336066393859447415629511735131940444974630579121650398527184965704 +6991327733592729480669828930382613428226140528036104065114673331048967012900401318314500711300298883332334369070527930012816139 +3452427216705740390119289172699570798671134046758624232397496740015824965414235594660630239994200610360038450127723765597890208 +5175730522105055786800808015853823181610779386663930878893825884556056314059074930365519187914921351319328315180621551748091601 +5714910102916106131414571159732353736678835156815504392107562506650484480968671954066774178137781734638792008562430877641109527 +5369362810620715036409904025968522864824364325482506902964133711312038294053559282742499233287959154156854383883148516152426070 +0230923585180985083743915234845529953134912525464096240500757424789301872897111680226897303301395426146920411464973830228585960 +2828878183082532630135919486366960583430058092282156338048743819662184574743797715878229822611358535700802659064501248149009579 +8877808967697355352896283886616902601338873980280498803907441157295597934158728665206373488691687917104704283343745205639622462 +3315755549989540644308207351384163575736340700335343877848915517455194885659684732058284726257857232622941934453881121004726782 +3002928241602670019659934407449689182082678896433504272332382719662522606641231869982252041696766531509399818750721950486163498 +7932472000788041651204426873094409270765907861252426634561030946897515784875744395710037381070458145660220907030271894709835605 +0606375828713960156150750275120802286593052131450659403286977242629895839703700510410871815684746087294738637398861554742127265 +0927164114710800842124744207418934599056137681039495980981311410777428870205405129624149605463522859752503128770836084491952252 +2931015631747347657009129018143774038849625686108045440606651923845534431071983109500879593401459457270781303275371634919948465 +0387570468949867854454498257661547651091256802128345749601432500529628510635061338338862610989893855279059054348321900538486115 +8602609964344200881430293688135456245345432239342905412584133371544661893209862399991442865006457440325878578391699643241518820 +0476780634258919055579958686158323045730786320160920071950074973087521728400869220442510810405620758553467843454120670874658001 +4611389884432116865691971525430161735365815156176932740053507703667082841676421694566703484160697073157865364859324160407900243 +7848340394578239725877088114075619051748487906575872632940285638137907126466280399912812673908953355586620975122613901023009092 +9989300098497815617534003740634757576144040056489564419015441642507944260710401355749819839918602861170379515547533183230261689 +2978159531889967729748526061427217809996789425967856884930963977509421860822261926488518659963801830737928324899351448743506636 +7739373703546853709971163541284486539624807396328266253157406157316793793115843617866707276779926556010088380028395990807722966 +5262595518780890084621315703653759393744008415536932695809891522083236025326969192829600448033930003810949789949558452866508165 +6709958307107045609075677759152351429582355756238261042407300818561928024091909129169346687529817528488405441096301840942497835 +7939846806218683995681953891663100594898796616302246789629809345268814966245162531052163166438108697094692065750286916247302592 +6376737923232528630569024819762238692074089057479592609265302063789788269041103846131589957468529143458603367428237467202691677 +1164704135075482622437354706246898083995113224930951841406301203169957259318901636559771075096487643893444519082342460614778341 +7571486167299822050740707597065176588093664070641995447134130614103674235649546121137008292829783010870775335672457433796269838 +0786000364088666248224822824647357946129181563136369891309362023665749511277214956791187825832905762312557124459238096857752088 +0224756578418586950260891776975306306690545499717256072289157907934175802791666439540405671709869057148319796761025632922961188 +4317800666800783644393485986576298736917563650897164304571720738720115271226750820847348337143207594067034889090129746637573061 +4992035733871695023603260755794332051946719932307664611429871720394241080075351265170984927835215008078524349098428854934511014 +7791275210894880460866040577708447085440157107534047266197077167838868317086743808903866856598023308194718747427381845326367182 +9440053603247145332820937897067937394376812799936768352012215925676355028026697201409962671443788824047418146714929473243964178 +4694097429621088759426437344831944205038778311615485599880533035443309753228841592516038076111818420993913946554412796041546011 +0591550477943256220239415601324460355602248522402154416815822080226505160015237485088369250676462054718340071691237191715854643 +3754782628510988470286589139121850755775569961153502324797466418949716647077195388880488321524207926209705534645689175931304390 +4293579894293631845176289384983754244067774813502510037057302019611329180738850594681778906215406264239719011424001198377631320 +9407877792875650325539404181214900230679005444970369243950847777718535539213759142124477926938032002586130641694624396314012506 +2378295522687601357905408069624354294555654221781438340067666919648970200524898545019520189688682193849864964964428853699551465 +7923565501350073769051751525297874085786148453411032926127268603914648170142127584914619282268063761170983684501064629044484389 +9840829700300902841805899697228329095218443610475399628627070805326825976451593789370050027841655892248443960659103428515769018 +7131899325280315528312838930296738263099442057104969325259438333829573217299432626262718217616786664813337230788868035555543551 +1613365891642882106953566519548821305418260262459032678151796367238313756913498686906585565640299870573937524634136703149075431 +9289249177275626622021358990349141206245802827466686634188302681734388914438573274476670571970132658340810522019108097685976679 +1999547679043388007539431538024419806104005321474063902499212939182657952169737390109212206767202350076020372910741798343053860 +0796380798378956338026387089364560910203624767639137927998294096484424294854533260048523991232484163916572752125119143647479084 +3312139471300109845789877486922941094495320192955690413961709171195278169767812527830359720778178037462244636938901054061989359 +6446495700380140348116004473224522745585963020017740642418321329101387653563805874445580561212083040164396327873544239022001568 +8221316129071405562026280838341093594207054207388991782744751735089766826502781865742057843922709134454840546015717044077633360 +8884079984504038495190808918953678045353356097676798230492279289061735280457857280913457619377057884683523850527395740839623992 +7553178237304616708890828475106185796221210507905405468874982714460646413397054645663825587287675092464040250385703334315092608 +4773590965589763472535194103574470410955536365729704648777555516672917330870335268784268577673152078292448804242825553568245947 +6215819528050303270969774851839361036143312160025453398613079612450766506304878967542263517886001609950018287965333798559597461 +2170641880151969257726247627112079520687196427192459411452224132231427774555020194976266757454256306589376845325708061001674166 +0808706168526831621497924679232450195651965661724083005213398910330404632324992737223126731122399064939390308377239660504899222 +3551818900906904056676616710573047283299775444456072812898768689067250392820375890588789819477340760813736549269624861064751893 +0906163675906901070688176210778473069828249578452605511950224714556564390138087101450788624170738723043479291100038259738176381 +8078282667536765535434830984808011662048300628237758542292327990288591220497965448597597894673766538440553768610799486540893085 +4239348796188542060619155351521608241401936444825596707153268722768490308653700045149495791462321531911996176024726025953987339 +4599085925561530429435581768120454911625188723603840101001827808010649207159239374191781479981311865586606666121770067310616172 +7104627786436327756821840719455701887978236563257187943017156401785911149438142292942970899875188032869983742209547431350943402 +3524068403178617373975067637980111980036408360680020858787573852832862969725456560160112278450433733839443039332972392923338691 +7361417128175114993261450629674608141894725708171510038678649037487846100911817687890240766440318417379790915067480509929873884 +4192563045095005960884279637612799513276543500165975164906153877957210268650229031342852943158004290795716146485254485943610979 +5527495850605424448537975358841328894172810067249914112763981461492106207569150714303562508512966364997576085520454249415595925 +7749567920199753428291369733514893066123672937987655345561072264405494064545300253825630928142777746597418333809686090132329222 +2347190729828800374979423249344630750463633445579902195914226451238506679798785890126552693482294276302768079721653123608475225 +0152265832264604743532240505688517479981918489770686750786602858928368893549157302414453807821089110756269039234757397043529808 +6533482130565176488100655388961819118126865617901005108218775489706817843329452026358354168685608881349897826461107138466301657 +1298673036456454794414764858082769061588499493558362877721489608505337579335664200621558841720543957496547716133300368539580407 +6422724558120550176442233652100893764139597343252110471726917934375351595018103999311490022927771281873120822851829841201522060 +8271532119297676915199374389042651216528118441258413260870365096855873207948565556782103615860771982841168346920959540519710060 +6184875439923588759440136066343058630113336838104030510817176224460276957688775424874821399346650313045479118572616668489003296 +2897490483936533080760701381789308980122333755911815060695347160990990030052801534871717538234667743972256918252210649169228903 +3655303333861985799802708736697214310308014845445976122762735834979387407451810326226050509201808567673064245381176975037733147 +9657194682720093768010430501297373816646166065617291768151706574173498067197264972548166688571305758669319121229890115185819057 +3103510865220902456203344829140970552995511866958564974902239021728149583173073409170941518663482580344763138822732758130711321 +2350688930344799523350604942490602629624759567547933020887009924743050812335493964555189623547661668513628841842940808414417517 +7886476590659571641831046458439879022628434419829165109717986460127979081642839919400368933401267954441646768446103515126565637 +1110171943300926097143589488105661141081024879644220948038639183302967863702059520939356184545779690411373217502283638534283105 +6427345179711846867068806487631152636131101160079927489950186169690439565446479010213897921064107507425078506360801250554414400 +9449471539328516576998441231176991412965843783160858329264144663894049487064693073174535162944480509103362252131259963289347661 +6448977729584408680822098278848838996541448014927561863895692613238880261580223887644439627676547583170203035028358611234118545 +5113424393568423046116537671317616837784363459294529414397028767453793820041115557136079295159075170242753593066820395440768961 +0357417280340583283641050541304196888459267811242609025317032935293813444330705702581551660482757892548218860632259447912758396 +8759325176891928932295819377731294216097307260061594553902071464538665097894582707057397147529275324299057601238957576630914051 +7741473646777114825234899359211272805439289189063644808522711602498268477174042815308766568204260129647306647359885729554656976 +9309329125552267123498982148765832181281490321112798033562587148057414223743472931562572470841497241968346307379573830843375864 +5689803719011022683494640589564528393539106647783122400405858218032186185463041208001667912281578057825422723357469418158669943 +4135592927602852287576618966571253116928765233133651892018881037343848794704599894714843595981667962009408311650894622157342917 +4255899203623494824224271003677968232634091967503097880844441755720576147137952557139636719564772738964156856519335241825543143 +3626415788714735175257556917344733999894086186508542273673131627361802049868502277018604195271807930087879067221107134172074310 +7958546281467926023449343568661101832138815620051349600621939712639392675220715111033777811540451328852498746778968470255323001 +5507407940398075053567751242109569783310327198481187906287038704370431459121242392319816826310134418784694594320070284603132253 +8500952612124145512973435903996934578404485074378319984371754538530064680891506823775364453662506914230333187130946894042814136 +0265665148790173017555028894292865406694173385138855281737615651927882128657965562089006870021634293021436977249028055567123606 +5915024874219893422458723773331806018064564044582475437209765195603359789772265483078502778595048000442697079452809908661825491 +9974005988977051807595272626225779862046223804794634926553502843630881070875123298869912614128545778960915871587536819171698115 +4134066090737503736509722416899089791584075227377094759873530554067748069082533106208531237181423743510501202120010884006504203 +2130661127717575197825945847274376219456565491166146558949366985214290031939401399735403160414646904595040915898139346351713694 +6324612167251656207707087624536097155449639896731425226748776831598133504224173609907231060039276944120772510687900080346884581 +6779168745096711200457711019042996058420593520557512225066879514823155886446534991145884583182566717602534510076749929656585763 +2645365584973687585388329644555202088022989110607367050144776537693714417352526613252012599647340542087230486009799844093446266 +3564846704113295525583758182164662009216216712683832484187612989237709031101278092921642250525269665257513687371728284688457875 +4269555170494408895577906466689197972679804550565920918614809933468304708581306933698168463484178291731316450813136298166976686 +7026547610376955852909877173580002842485362728362791349023862313373489864426541187364755041770087263084268647054320360965911322 +5647079585282992247752748756022346611926842984561046976951468976647765336240687959117772104657541464074764281634923169020133548 +6986017692163536989579104384975828200486159266813636401205178471888697579916647226641294586286142850042407781409124499578432265 +7557633520998487338874304841131912835862129914096167258884138035045133191763280844957441725806050932560746430226219247549692154 +2059549946818227720943211781526111003981250924876459433602235222747377311088585283118957625555745513105052583294040713888376552 +6312790236548842295363447664682859100743206688687480099078223631017589800121679494388116457487107923554186562511797306252062729 +9341961249268388400507893558690543848588537117611908256806356375473026278316829039260672100995233732139958201591529357001905122 +7622440629036046952745648171252074362090378664664601861125598525510174413032785951294400218362705244805632366004605852186841943 +5591402799903315324575404129541681549710964981665090508369906992078809669693743879553048600144250375936726479837822625004211533 +0078063724382242661885925388201522364426479724179540766386042648425409841158873221737967588237291116048440934261723138640261227 +7668975572438016377259095768317171394189060199749631603972553612209575383312005377253743770387375624576792404785414546299669225 +6702311775340274741303788836209727482858012234498189667215083952930215080983474097496335600683835003845218991908331419228161974 +5844861014709438146848025778890120727743982063500046236695299463240688553674143271469625051120980545361183599015488717404464199 +1417923931690244544999340897859985367002505948231379127672256195312588278402509195472407043750082438215262579893876014989408706 +0852865918577980935645894147403286685964996381094297648429648506192278067863183038777421574419694387317777907505729693297708412 +1477876485508630104652801640230580883493634454785840756974806839665717736338880683347432665781835143575902380330089255654038083 +1333574195103318490380293307280457872559202823396902837942959887393577658742570521479101307298105809134466724699237489092865507 +8231986011655928132234768712876079867027010505901813055232448036254614645338353115984374755578779894249199293331904818734171378 +5291198257745669262198453729172996916240029288161181812810389503650167962679364773038871747909175248874112616641407342566234542 +9827656930274121781454100476261391707245667711266140909114058056141317855910068833712824192869630959336254369672357008292856548 +5323877306540282063144065009953089367459505720096157841731259977506672262970125862602619551379971955654409939177527714243403057 +3533286954907536500237907021493132000340867715658050587581466366920687545465498963798769329374590369604149184427380755601882748 +2772451245387121398103687673837186367345979531432828052838695364605611707914643359500610696276887453665009271796449018655863587 +0698238146791660163022661497107232088142858713995181413650802098858185207125972232613318849001183174321522406825869523281989408 +8598554632732565974534400037249824032956321514858885348539735224820260572526802963756049116642833599682551125312131721936464816 +8777244479719589766354029439548567013317807112981262942768196141952117452742612964786718669561362298781178596889656657857438059 +5923903176580798552139931019374192553986137461354795191944498128759243022494357593594711086051327159717361960027267213667050902 +7713620888965717050672864796196500874403820011858648932283473719914877636081597753296264071668416201048071423687724652867885227 +1226026168424754948160701743250583052114587429759744035821120491264623002950973529144113414105707200986835221503669020815368719 +4301615723202468195623453039744894794833018107887889921748034816356630393443669846540007477652862272296203141137911353369865567 +3701305132741529846291547614776780687562767296077648285050793745319685122361946265802267010089656480989090754766793951985030256 +8873911333836369977427224870430320356503521006657767633627578973429639446804587551411591770027775298708856911679457385890346605 +1569544828599021231532143176442191013631066377985711192575263159095165119051577468547654466026788861257476052155683756383480477 +1570683253965182842006010673097287497172850525327662453055182206979693937570550092128731857505346441332074707878996538911947435 +7826422261424373910786428920393564290525228206911026303685173218951588837324122530045948404629473803092607834231045937648966971 +2638900097751822798368796230240210897707934867384226561665436456581464223307579261127638844885560109562036790807667670390644417 +4192581432555251427389363044896326951734847648428400345150360499669512737809145524003991223977279428592712065139442479960445332 +3942282183806384991949767715266661401310060486291440972343510267352817495541237489262806877081824812836064827724828303648923419 +9223072015234086234796090436383818568296143232241955872923081786551697504279591818923391084950971313678554302938168053766302337 +5040295146817500973605556893314901715843407186937767008367308307925199801486021624397893053770707845409279496052311813731054362 +1647014082822566848815080638989025226353949427396868720941862068805915405636344175116957293867502515550210403185422186297987101 +2299194118400856813156210708210682041625725297454205612569506042325388570654000072012600316753710747599029554756191357595113351 +9406123252615695607363852828573549803486496914881699175306276755265739836369938313041363024110056929623864023133434302918217876 +4012400092952627260881136088985623398889677549475347950880378929158923209470729028820934081657587476645444580153423943137551662 +7552074556799764537114289715930906335072549730926411552458159805302034148895295264056331531618830126090300007948842259905560480 +2034810936658458335936482208711459668407533754842615732173788255099444966005654249703291665433879743623245887203502319367176453 +2055826854912228554738248289886125490164761646368783638608966701408500405439745351176591154838568604792386814062201460103196028 +1704883259604470302949798965476058273811653448846315941108597287428362004683627667421915628743842382745845960365444382205614441 +8276093407998769926806805283999661528492618490261728950220171409852969042576745011296912080496971648424710213822281461166346433 +7954055459730823465679899905176049956104235683646988019468094197473567154076726095028250041409673376986848760985312614035795365 +3541288526820871183022785627606776202868249144458419432875958263707872906136295450220559956136362126175679096582857639739948725 +4938942457166622758688764402917253914836669353169972138509951712963418233559611193066044779423979184123891151058275415387004481 +0186693532983400032989768484986211599974215771878040648121115240600011282719832395142348174280309789242173034859607865458058836 +9693011226500711160574222437812022981161460007590617976243921827767353835606291414448435195278815539213466555449489307049996549 +9509118537609881549110785870137427018215479109414974529881125038407426313589072435487055670013225428915901526956102119247020213 +7469585110154725916486236087220807528982687428584047123899577899339622871539124688449741918490207266633825962457784296958609358 +2301098947514645707894405697878233655395086728296961354861714139621104988822145498752087551938260818588440041204929785479253335 +7195002791628422640170129886701270065601981205842819128758172220230767271007555891989535523140754390046908600193906165109046248 +2903714800754690075212414752414239844419261581404644710369810146988392192489474219249291646325601976712417376991598429990116224 +6657841194866308789835186691755481781807363317310203480516610021219245717136441915610841540149737012207330154276656421683007775 +6496393167312732418345038041143115847682160487308598451735321809667649213873941020106124895016322422646066096706495173559340273 +6190352286444996698010567042083025249630998980474746852300834243586692391358290885793710964591096599205367697354040455225748995 +3808084112830212575642888231806203048547309288414193348028410780142000603799742289999737003393558049032105240979729430950416734 +2055001806906934446231057752350125761310442613239626005937018173389749155377417284662314193484961591256165582045826903566815287 +1770910475516651085946142895420353886980271498962773028208448011256576219469415630937607816862320717646276543446021775437024856 +7317728070174544541281155663261784538153312462326658626789839195595942323601274570763560759947639040733318592217361764664122267 +5163497922629734181478583586735139172337995385407882365183581289857390438660661367597010604158349602523776584737697559311077546 +1232290524053006728473192557288773310853272463002083064021874545276391652038777534156787659533007696087737660972241935746823998 +4820797373925070252089423136204599368358477176708061478789645953897583587905165644362770501568086914083487441612509546270070041 +2710844937068669762717114936914428075765570984673461573362652998653398467217253506007120061287151708786386990808903587499291676 +1722239692416177387037629004556867021409013954231954955946248469232703827805268278720272112690685704443311442687874485358911812 +0696442461522918873003473056316397138103158503920758588244927506442635208935867088943853508413143951321019830428306333251201396 +5237490053651269730925587281174140512120043151663340911938612562084343250088788816613613533254540244890538135550921235569055235 +3652159735685467737870844804342436795620955533935479356452033442056822975104591188103222254197338188275216408256009062112739968 +7134994798879023357613115067249723046493042657115745023241318111461450746096281739377465898982050597074346498759749836646750845 +5435539953004427145646816313257688146440880667736243466005411373421754461366941715230523658976477672479751504847483760926576034 +1189232066364746161715297654667683387924489405288055983423309925216635045159783671997425077719999713937624968743960815866938439 +3458042402161473455431554634378956977066496820341904422146434258908727947177474383440746332129391825690966243498723403254667650 +8583588769346353411734495459871858141713721510897174001175951449320360912321580651780695549218819369972998610310409490019288172 +9334204527475060600189111850610268775609506754404225935699578359127242186303638934810994186504201384645847184324944047027889017 +9180203944559928543575350648779851174917364441299737433952437533215087774057147807226819191868491441590442039396662591808502513 +2164065534579878437699757090955883471447031879403082053258427608568820018565147466627486801491876503507730663614122066321703246 +1913587358432681308736116815399127159387589682764288441702400713256228014611237877207779478537639968530764623959147519370506561 +6235255735630858442517033591935698933960554844760005512206225607812740106611830794710056776637176558829867814913080368920324943 +5410646760661322485781048142156629014814968811323925705022272475371023640394527122828545405831491808608741154836760565505004928 +2033787078461763925201661733809116559798197426225447373091087213252755823492809148960852025727421510534412088471340160144342242 +4053406317407103820908867515275579307068390637321468991384194322089645112923727349244540751951979469134053290718220589958599078 +3285805403257089050405641613610899794397383496324785340103859171172319440876039603408630922409574370487373867533449326075083340 +2983815868763252323303322070522064853273357744420576029234853609842229699640881843769482230526051119476446187157115583149336835 +2361402646872012433986880843871560611945683230864891757700569780134284216871106221826645632387373922861192629580123373279881156 +3429998671996373176825887742582100895464377776504251588052739302345778540285554961799280437565093922440989079226166655301999596 +0886198944491737540229136497483278400920360475905860689648388002698383026711966163612310598810941558644533048630182341670726792 +3224790998309426141510868353814679975103849323867287287851298934668662832191399524482143116612939771691776186144211021701423317 +4793327096193585617231688937441621332297850907599875602232326960040073326201864681000919760060752937975322888247984232424151851 +0809471069558103959275275538388584472907830398322459954494433179596574461777867507710018713571052848608078849868820600263934936 +8295056327643509778568235977901421687599218957335038414287972297917509776356464814745628543893936365866982215021206066423916526 +0069175389099655621827463771703163016234772278712340002459468537149630573879420643113985870282366118625694647368265400040980694 +0185330675548785458492267177712810772887558224559469934081174511045410475070695699952516120170917198086628352522241811643698589 +3432240470257950810314775679834800845473620978487244838484905235351184086387166599707527028976915030731776500593580501517198631 +7221196580395629622683771151068414253703527355840765726766691589948635031125477445246126627685840897423930890628894585553998214 +0691851299476896761562326144030082656664005132402228246129440862040530711922127884942717942941321981606132599740710622690829340 +6387805954414104944165651355643971413515987568344486496225929165033526273702557885861628429072595508259134031569932407466556139 +1855370060311355098279801028503699206359780131940779590143641110125855998712927294283001777864930865688001454553164651367990176 +3395026397066375956526282504048669461521946610830298850923781230518236171386053536666469499692151678856847055919172630657325178 +3046849923385707165827109497171128710135811605592578271326373856764418443760349195924655728319788343802029428671675457416769456 +5261821042279220321036999746346900717107895012894353289951489320917708733388530368251182473743527841343292751660664418023250390 +8824252317744508579970406643025576979363288136493464811540150480851485119103480579103156985795448940762007262203877811330652870 +3204055616321408250954812676138625194951030184386810613892670161995606664768252471283913135456955545480933087872315934450481826 +0110599619290339021324056958678493559294456117665436489672772960474962839844256174658530179997209334133515553960451214172384426 +3123165163841681474367010429491835679876709672710839983993762107872490425945162980229932665274102783110995818120564672709048084 +2232035395926446390712487234338471590552947684994788621710474575654186707905435367680711475885293815543060949577152083169955046 +3350028292251658928286123588620947938740352179851517866242963626384508167950485172272074373493999323206780786225244298185666999 +4138239667749081340443940138823062129167164095346506708209137890234837357780622504863833649209158347489730999565991588612008781 +4664217286110698633018092758084011823559493288270590581425742146586929149871453186482768470820080489858199024057046533515257475 +1359038127174952081563588721035499113638671173404164924825530484539148472501653910385502837523160916070082537168043390775386612 +1436923728210391122200372504366645991744778858443244990595402772009992024820412617754275410349299293608939703285522116131987750 +7070475686255460177418547021473687579971194688396164244442299931146128832803904423667313289561781005593542663645306028982529133 +8234121263247251924212841508107137520536152642698580769661242285329043039771966387613256643214231439403217580461965950616775878 +5413104246474816660429811639531866004425878342745986000581091374331764631199000564830359002609727849512990017018293163945873976 +9271235506027321498393346844536657245544343198147802739604119444238511848559098921026630558834845589124777635275843923942487146 +6915026105020117228571904488841353205308577369931061433915716936274811913573096342546878245443525669417786920642396110509919680 +6739657651695868636149376334284237799146008295879768907577994879004415279621922483186516644311320818173589692203657526672858471 +9876510782436209693056682744986249105883882516043932138260023370268816469981968622627487020614107433825722570906101692145161092 +8947476576936475757290736092762279169953016586726757242391235235637432154172158901821960951603571049760362400377076037216546585 +2735502157822565784279289258228694712999190257163908804541511707522385665999422960150232894155188313507493238330302410605425296 +7940101946087505879550405973067848188833812225296523952905032878875050817047074123446017999571197850004230072472112763344801201 +6857142063692961406887982913011490273637829211932192499375592176104274764580285681098203860236999583984675192011342612589287803 +2211465020826460764614937570329924717346527293528447660776999654426823206473097384092520163892337570587601913303602876478051786 +5272016532080322083507311689593741698084734458418980219100525429302190098183573551213250917695957795596851135451614813138939428 +5194225250639639525068156399214932189538746207985167145356511964074580667075083175359149568969997574350520456153735083289658446 +1455560636188297319680331471565963722123437735473357325582592487841750254758281060767877781711667628353861132757458093517522296 +9590937580052253974622159164858580322392765535712215396895455529996073185392085906968002802221878982904887664044332656986715431 +9536212991471446618363328764237863492326635377747715439634427901843465449556160996406079848698687609807559175166455209276718369 +0962150554158891455114948237812845566152678283675857088563676954226626094608713709080121062121158536561703886898127526222898762 +8414892749163551177217490205399965970236826061221918459810953818518538232318451456451553658102845761329243527433596909757880804 +9825158812532083534774503272169600063323718458433952873310136391419269694767849055513012348666684447456130828029837154887287827 +4062509382360859964541627147185929761392475832974190883249337770970320052156457280268514718326951417528373787461693447362886601 +9802384514195519930363615938594105163103928246792737359775050266251933928460657553568168049147890604569802307087230082628479583 +5935332407364708394968146809867463424837289762388992341535259500067286459397511377634976747563308326968703921946360640378185893 +4569961338778055670213869684862788995924625160473819440389284613604453202763523485241482845106528449769880720371645531620509281 +4202560683681703431369153262516802980502196714639887848169937613326674387122996761898343353693436995583214395894151975156893071 +5332713363776927366695888962587179393484799105075109946348286416315933464459810857879632369155531524704654845441581407617245460 +1504145331569763505220832523847632508529957830567158287689592530569297300966404712183597770247546234814056520028432048220079902 +1149483717724666058290549158624685899733135096369862966589441778195807957291623190196664952975922610237417399523101511538417768 +0036082673459241242094083136368293175771615652653244493296672289353318399016588588663275146926170769838811055155231491519921092 +2671555423322348703897548437846131134228893160392027737396758641632859270434645917320325207654186499204544521705733245689882718 +2041837354468721403869880661989984614132154115011011100068745419042193490192096797533733270459341389726436281948139045659902298 +6287265676207191576589342058985373273830354712920659876843903556929428288343172794038913384089049546744993546672999661244015504 +7671119447680097893124176344032941210873441607294204020878536819662836852561652631058964593184756766213107639235733279668108014 +1503597944873319896726432783506968518844581130482208284211813252594573116879179483819354129815885419312761420721174077013349076 +2090575099698794920755209276799477214063322134870825766478922887601572992873375806104725864045048652936083491870937541080699093 +4276983494146036588052551210478424032928358829122542012906258904015903858342990969060460111480318597431250609578131562003677515 +9113189915457840484343399644582165727880755692052210886524470220995792925869536099894161015143779391596346691130912281801612173 +9319631208845800137369253760266414764140198516858735371828537522929558300406662683159046086394078157278265484925694452296859315 +8349237034176302850857262350204638637311808275176159745110236526981407472953488387189243977498778789698586980560479570319641349 +4582085067641332005668306046922050438876194786256238539902378554139808224133740244623740910175342259941720827473284689401445459 +7345697903120299815105938454414060402797077914470248272961589951135290709800128402376384567445478103311791196342258909767408438 +1687450542289596593441156541948105976556022804241843599203672068561696047317558154471118174352593930389361496742548511304322359 +6498489819476221747377877067530863799486747795199009866503783070729160667495759546595972752749803505545796148381282603736838562 +1116947692218975950285800049524721556053629253858269322416639882955425601685355611062823222776368062359326543474366782696365362 +1876190167722031024686917347027779070009896358771654643412669083054810506078866218417271851286420021860907338434817211204686529 +7526344148737332091666585836660697055361931941977353720336283268157952341498338628673162826343734542380046878989163995116270895 +0881257474139601407433704222324056930283355591807454770810061687372318085122818010133000433045729252354366007849932042280735696 +5414676249451280636930231638752958380804768673433252210159619334608464253621441055450445428123593855381938626029786836437726558 +1472864902858611995686957469529408189014561042091105708978737612763064100403995245584630738467933358860436751349270719679653915 +4154741684647123464440327863242393005522818718477064168160551024239993656696764829360125195215986845682299044548790324197334138 +3620127277527314655388754016922253350206555973782560191527034271929722748456430219013528002841930398470078939445946816067765376 +1722243978849829693580351795930973604730338879610427564825410468950337347468265193351290232895574144876817631258161159766300943 +7560827667474386459711757237346751568066838129529407855307314365209698298457841298119589066095648716960974765231576411494919727 +8647954673176727645450541867878958992452684388452058871232181090099976607265059152633077058376469186824930991444056731009872982 +2534991973200933430036026714058825873362205723979737750638944916727241098322793656977758591967127159597583155643556576943448135 +7155096296084695428953865082662825849460303226866978634425536379072621988021237204615220061198468810868414563936757985215986294 +0328355158636181420325206501518296045012302259181045466662110690600154986730477840865756276397313811576274178347247630894639601 +6488666618858920723988680761139802965152715427776544103393791345032803457282545151397254870010332315293514763142030945537580212 +8490792796508337321795619849060108983218521200268617175020002271232501077412217793566906763151880182142093233096870432790215644 +6497520222357920618391446425720257029473583117356819552842063897560547456381395533477059429635070000008137772848031720176668971 +8337012837324253697188573699623123203170708166950795276999966009577648906818828342730326847639721034032786616971040641824194318 +8936005757600971054320025253057644372313238443033194219596927715787049581460393528422411161050154583706800554645719354006707835 +4215727593152764210346931899527305466845340439034432649923099270817579403876601746194619933095404333412889852431784452755466843 +2088097487158522551752685495115047141137278634729729587648195891955992392424399063377394353752520259570862609415201408164480501 +3544474831228092443689968228780611679861586419457086393251353177701671796943515744580842421181721325756988105402798156643588821 +9778536795257051681439799124663145890473401144931092912457976024515106053860305458288529123695426810921506064347775651216836501 +8629179794286699832017474082041208054529672919556607496647432513709724969762646139135868191228785586347557306843431128687158014 +7106456703557605702232569911033196736598272397024373712296482733842097318351505429979256730289847489156750506335880609744614597 +9660558924487542734143121356331540689398560467085012517453390341732092436780513934245365179678624863881161450471818695381011735 +3612453516034902143796136205048511802780802772294479133906585232123112871839607661282061340027850740910859483338299107807956460 +7138724118583930096084405139356471004624454913317962414308274669136174812224878197906201370412577330455805945128690650516949333 +1730291821726950196206552159924266720782365385611242853448279354949948923432277012453511172303822029259754519038931979427529263 +0548575047242616318508715072515332204278272517306960109310804996719916332590161894788700070468159978743034429043329057033741956 +6780889499085964528861899269034340070621419803779139024411147795371750105312955245739852543595775978340360773771494478163557276 +8779458235824687171901362922249920581085853186181780124486013927395708657432957030172044779093473433280766667409407392636463029 +6492579411705822845905066201120652601308459859010659739650561022388466983198156117882306744218369432413488854001765063909641296 +8476320260631331607201248389753502857961661494677170435281685503191366884817616726638971291309647117085069726218509290967362859 +0810139343653776833125734038676243930878414416044335363929863448842581458674823745747264416650503948061405425537368655356993636 +5246772266327550199529567399996744188644213516458735587639817991224447177904904043235549503266714688854194981790228117033924563 +5461999291173972450770635507697104176866762020802521790899644748842731393628432841194003711839701487245460386154522697276378209 +5508101058683508523829079387008807816663732920071304290119836347773461806818814318630035261732455767269492882409702742637950576 +4599609444549117705097045766405200220153090927581307100167391516722145681413981100426906534790499705750570830947858845925010025 +1009651634984508835728715571045793550385433404603846489058904184111368085059460823145504327889561854662565906194985160507019989 +9357881999324778923494272780697498659881414033472270442304085245770043338219929173021287371666801815069695486701740310076529915 +4608279080766236606674170110085478654830337635040537744779366742642067739517988003498779451425063495418123468371481260706586708 +2700839483986172436829409192485873721128692643705335631914640430691426436305173498220746572777225402080014675196382731227699368 +0086136702746607717078625347234495013215002090165872533540039551264212687781885399476155438281141614343873696580481400589706298 +1705902722746414058890369373242227296762941970919549616605978259694120130539911344963309277369189903126883321693536398430654697 +5704737347400443449757566987270236468633966314353505101478851263083176174429030344023607680553018559157482487272502931014168203 +0929253853547791644998906236759598501768018124990991199353184644473283908513254590068607924929473380232470364424573291631346278 +7114456427076321654054593005258016944651062956332800845969220254804995756234489111294820165405880256529733135691041245584370134 +8553075127747556822577563288536391683930679292906640525736392953226223500696613649419343205087984527799731174525862937043354377 +7195787380049689624114711568372766827743368052980829823446372539589421589808988393401756593651612425875577606936738214349475949 +0181544697505469142362834711903740140759734959010974977126438624042186356553593244884210506676336566524109269413687671228874205 +2896686735795141476730158554607522934103668703053995570782216706155323744964613382384967846986182100960586040580173953854307263 +0286768549279297394586785263108063892918942908459235186623403809969114153282154910435594392237358132752498428484045697160025994 +5955615832427009939764606346259378692931215536161617155986791397037887173705219219646647075071165536665651942885935717666403172 +4276536421804556864922554676992233459439755861177568827029918375612999063128068548901725736512083925758415949098712083242055096 +1725062474106111957956927114735687646594918046204634711666975260667778901437761819647914937715436330233142512856404865653199627 +1291532637755334170692403451392823323540177224847012033326608939686606026939972956526341007272336243309559194347525857345975521 +4741600004754011316928740091902596508371266808717732973936254941000335221943249074812743110404969466723162046697491974991225004 +9085942759791031775731739206062635146158396893656161608173687371708987211298821225045306367484626014700868922039873009889166761 +2541340395518961317950998826785729636172355473248648132541946680948357368185423797382627281741493372551999786014593359188997484 +5815863362546532185070737662568520327034674676319716730206859041401224197894669598892125005912741187360523778711460345399659500 +5019261584110255017064950229895215051849707546749811603776445037494938571872346104053773024040213974077890562979334359709174595 +8333959703819799129975411673347762248495046754138982930023526377690018754531518740079491735091275401960400702618787889510076010 +4581333314409607030057543494344952121287231730028937956224706941567517833092451729648212810249480493474654543033507398453170912 +7852221502784071535646166335599143402394637641678513241517161191111016811759837825114453186940577300367319815188600287295217212 +2010730508881189649006207896145313350898015140508068016693226343978406558747353752836658017965545008809220423091595161424950648 +0496642867065050893136545829132837570390366632826974250747266589629788809643453838849392317508541173149110672931572489980731531 +5044656574615736195246481865299114510211631762807229391764826087155637720268154669986339615396192306621947657967460512382581862 +3895441416167225879629472693046552479446299590678533650004819143386099678646479751244788463147638567925169013110241886917506841 +2313203706796269432481996570645174678020808456857425673026366797683548661197668493887407113195800476443548512276825541513285096 +8842881585797604763305986235159142379357301472286513544030211227645270193019240287343188528847284806872333232004379253392212209 +2688409746134847438143178885250323822851284371547861492401669288415720100963691981973327453125586959600245064339903637953701615 +2157845883601129857682095395770985605599007238545319703595004924079346833281510603116153010794429037127659368861617341676777914 +4401447994414721274888256152671021736338924549726141907269816501834171190194745666679544881448528084111510223352357146390678748 +1598441987414496519030297478102458680201205753852279934039229453001433839642149793337137629917651258040708764206181523433254292 +8502235049697025555092849971402076674867464110183607528142090872909056796241616598564935589465706229822069262366265937628292137 +0055816249709410284431305701461181450452686881595061600026629505373443676670339321519731346337868758756244867546936430600344835 +2653221234894262976174352794968903515069018957828772393070009300269049849197795885320787480595346792949215526978359438371233230 +2573198395480105527983836130766181207518943018866225650015829519188519988960108721260257064720088842555685468531102293009893766 +7692694226464861550196190446675400547348832497307906496613188251375658889565533214610868096123194257835553142178169804139054021 +7725637998171173785445603097719118044612631181543666841703322233562489202164880099839601175940461517268783567897496005081890093 +1623476912740353658966890439792885600281612076194740147557413318421891935617196959684345685434629547787219047616918564873155095 +7025393340892141498709286165315521796432685307146924561201314330411100254047950443336104515273461423562157427134079178986568513 +3037051173501455568382307906695636378996155638857317043809314274578391987572790382804869815651855972786188467330565714827922500 +4074893387854201023525918388726764794855730871461446351512218023803177488574497502040250654764531910469820302411970861290475346 +4505685142400586418253034395353236203805450253479017801928704774791824048811941055335303586560686324885362705510247805420001343 +3089154219080968310703760534064569831009505236913263817236675143668487294264949278958590434251398242365729091805726174530517140 +0036394729791915199963247134854987262729782792900430729405932713576759938708525288045097625035200406357341027793528833641758308 +6352067888617175431411674423431768301646476262241768575619045274936408735985350498083851711439785845206739316196883719103192098 +4796246905383107193048562525408958439687461541231738438567101188983088993969984494129981508412118318349184613817013959589269737 +6278309646817389075935268193490507135536415367887824086765490270943493340352420279233033265958209197334685770879485799469719026 +6501644826983757753799478095020135205854302975462551896895597291920140799672078608383168757287535179491461326280401680688209269 +6878526040144420355891683769364803589616260114471471935609824723068550467740012749917856656207461894693384857525476785223522600 +9913533038664755944016342494625355616351591218888135528544319832829890186060691211822484503271002284261557646472978467535245524 +6548210843247451049422320528853823425570998217119732063096360026534131251690098102596630502775298567714836475115745947762170767 +8887884056401989307352068428168695321737823154308274924885994114161224059109503941221400198439058269599476104839310697936760947 +1499621302434101869959148741723191678491689696644090274728115214408462354277075304721665902694379966811617179086736989510478453 +4472180192689505631132593579798684787021607827033405644669077356547531106428251322335834054519860462918400592332567647993370324 +9048351300356674084399149618697303904545693491523593398209411550081390607196236295352104843258693200555492607047645055200473684 +3904033119579621911938196032662442953927339169769049079015529114126726770405396769752836907821633197786728940414757447592836029 +5698177775039384194905994353296325732870874582783505440992449252246418852133705888017732270642203555475460239299507823556669568 +4584762886535479770675275444567493237009137069030861149601485784515963297935895153471843170037858613325007001549210631837023209 +2986230798529869904729567059889517914570160421964137879893497645563877292347055745496295096825111567999357916375574494934291205 +7206470066816931559279891084092643447735267681920960477832257393262206090265312234429580381825327805715755696980240563671249333 +4975196191021868367044398019078519059684387790904063324517862970957096304027938042892083911602143438683752393325035772333502998 +1316065614559478287404397163400580119624302865064035828659428240183667221604845265166461282189820016614382937134407772850983969 +6172722824726265969836224691170018753182037736393837492582066024393428721754417142086323296047227886511163988288746175386143366 +3150098340574634288363424590978979671688129464997330011306067549875063142531548626552657667362582081599069751262734236839198246 +7320831408674583797739325661435931815687746601771458516299735930183747747803369077854960129285952199586802721391111341133770000 +9781649076575876416834626425635920411598588075542620127671675851163249442163030188821293485762987388143543674662920406406559708 +5939935563329383384304248329695829758747483676028520127505271048590567171170009956748249750276404393523654234793402435394531559 +0252668408043754647206021991183069125065854666835585971567158743285135342908676173306885768974453965943775589652707957703958897 +6941205372351396701250517551254482102589310971175662401605631499693168133844709297036538928165453987035113124871313193061665449 +9276802658913609967848115344605249848453532699908586062377147315012593156326148344297014110306443933718879254374138651819351013 +9358073205389217401007942156414789371666731131537345827743121944929460937083473364444624266082970336996459723671391030112788573 +1765411908158890001229050208942988203575712050271091972655376675898080722954958732806828573013490785204118792568609729781493352 +2380302146221749454886974990613671789801805162408638634096879268990438108120689272991357553079627023448340790990962415597084280 +4048096687228528057040549427950909321059124104059954691594133361792928522598487445722858314871353602305792037504518403367795101 +8791402885580812697264727719699410880547796108771833960539902147827417638408675493518018213254819498104814348795878620396366601 +0903924261354725492168290232167217374559865613331033632981304605379493456181688182582298294804821827770454840207003173905889439 +2319227785834038175693137220680318778454701304164120192954225359327542167556566637258412033259709183354710843065358146305555525 +8673917622829080548174920911891769587355766435165634787328419281721579009044997104872530471989859299305155593643127267879722422 +6682290955279007939673997760490906289041187907827046608623932479656002087546101920096135789193088482019418559812270396482968185 +2423495240985101912282160197226440146044901932777702865325863608790152621900419953459804469566930950992382020196553029673452779 +3436610407681610128962456711300906610774647139359864663150800708313215865508716982334525964257676579485350065609743793059790523 +8492723526317024179966715344536215615681812917282255110526575184184812878258269018344255337700911624857617809339928700208173945 +3637336636381056356070802698487403636259922727330027710606038599582455818066875278487848716217844022297313070587219989978367370 +0060775392327016214743079646392570709223503152196217613938079763344036433088567530057235155273916070612559581478927578508356337 +2980025169096765222953776328674278356394573802596587538549701911336821174109269755308129020228887624742741743790423872778133411 +4050821812671715448039700197323622949979651733365312936187264385591443824448095216098907529899820693216629857601750862463957125 +3142033473651787251598564785166706147991399595143208797800693772522221250290172822723884818192653997830457442015732513857367482 +2434227934816021841461320189923052035591521089170168079786149675686974463633607305584810474242944486308070058500812306124076610 +7715099107942733927512136192299373968619398158672679676087995950860231222104112656659877314698556942502196127845551909712373108 +4069114461731658732633727592893010579600135097271095735648535688306732518715682620335083055144068477571815102417990371455419096 +4513648336048758526599148974167943082379478315281923441623546714332454634302169701041016212788185513022911448815223921787570792 +3624469067047527512170727298754069896031789622645772484827952155406739967506695954077541651367850929296976343602998185574427928 +7941267068022945446692718780586230511573764935339043083147537297266971720289420223564631007244922385010298582167405543731618295 +6806852318072988521804655880278600099719660787055120319799397720389095148995402664025461591174050670273042539667806005860061500 +7207008027571345636661751333090766740919387017591058445443344334627123396031143577924484316316865139392646603641126628696936857 +3077564139261564206167503001531356981773542928052096642681673223984499732941393025220000573381152245673838328811500670802459159 +0948542799001533682410297780373013799791748346265940949566539377367731087302452174028989049580452869089162990037685957268273937 +0880681561126138584261480022891283215404751141789014380796409952816321543905013512146286826522138659411899727000462608467450535 +5880091566261256557011783504868257620770129211977999169370084785384096209807922714348396458806443353193445034311369641072095970 +0556656033549253864960039890721015883335372132680590369609602226419085993403091634173432095151442616233244407104672122152816903 +0104165883408627525444104591380562545622183558159751831249938218150151310276941351661814981521482974647621742382874619909936820 +7313501231477817301767451446702735705428503662442130539627888646852578831768325107739301527824363969429357121983438884878755269 +4393819179422351389843662394835319603450398553466130430331252873486799616761474948216299677793061438633632338236018231007238273 +7068094772817742176160590443426997804722265949259567119852638283512544860402755698118178658952516755701578554245375512654131546 +1929058509678608173068953824208364147161581285515961193245483567752314654578018433833005722739540799467152027333949229966280869 +6336730057716861143854645697201406300653307680945816167555425942108475384088151314617817926634797063108952284581676269870141278 +6513049997339587705695549544072595339278305253913271901919825663866146612507671581432953692087570028664604274026412331620371074 +8287494858287111672511595795429201499531492727612182441663719617940686643391436311349735908431637719847434127985592417043341276 +3683439281027866311263196237695664936547654237370870765012602749829825808040000867227133823847412406422822451359747985192576292 +8080745720999988790691750589159999510681935221965279452806039652949988754070864815196625235801191787296756531552141564212907151 +7193959478339407643118308465039555507133342674876808586706138734909756613087265895500010160295176435656450676824231321652261709 +0364925287385399527025737739685585498448664221812361858587254459582955070942164513804426958941634994463722930608065187062143205 +1510248350334956246451724384468817066713416535078509857129529545180481755289335535116009464206553367625156566677354615817653859 +7881465671702288772143540937915254400157725015862757578041600213873551218117006116952755764443062859739372284691117745149958234 +9088672142145404730278835893039966187590126325943635642412358143475145374782213403246198035026788070070178049812453881844272867 +0338668401687420146135473027030982411204915710337406365921420685513130184588295184291465724202435316806267038332889397443572598 +0839432579664022013756612378573508309364105293988945101718659897497738253028464952712017100629220365209543091962896609529479679 +3205960596777307708890129013560513946330763313564335478005273643120628824046289255031118424365183741647820073945909472936879735 +4620269579622752421433383654982653678424583328146692271652411473449919421964392617935515652881545262048907644967697133592449864 +4910971218311134291321139032124590602851436712963785978946343853100496072075735946195731359706831946181264874128557978861454843 +1011713617018211148846555458691095625992954032111035185714620653734574566700313717404927859717431081627049246861417661324499234 +5786110524543942705885896839017534087003537095772880970962648591315518710892525409209474091669813346069319857029093908507508520 +8853954861830714292944628596393329384568570114810794672937003168548384708307820733820193722197605410037476744326684584534487320 +8506177470614128104032179365484641505802789779285846461790237297261018747968281039195118146388862647365824837138881138267868859 +0627387322960768524871037409484459085875896325439489116621528742302285368082254073124593119410595219290194886865353532781155425 +6809698357496328576273024691628485594217747112697681983376999200098136183929376787562599199562809870612840417370015973807170130 +4180345838072561608049345847198586105129570485513244519517878528919531649387592676465860801665435795014078048815567745274248672 +3354246532695167434429089502120887783749962531689888071529106417054905309204892456124468634666345233412562908228212778433482865 +8025350198646920310690370174859009390241456508358264258699021020277939851249666503547743318751810595431556900870080845029269395 +5024287042925036023658377259430412863334903203075207016434236014370755084100466996153432751138550920390967655897565334875107985 +5140055633415509862050689677756134057716739901647883241169162784527852235725792016297971735177502489661133426961482215258022336 +8037402896490266221826083726250897311919802495381754225581047474087034884706618427848292889662240224463663278752931604522244404 +7043755425948194930791058610151488175614282166409617670305934153837246327320668633959913213103337798602482509159766659520973014 +8270324793209592396753604357772106280615543278837901728489074421806486555551552367821526140160754356205673704266414947144922428 +1799358966488711764366695558613904123247231097498677269788824167860157320461004934898696811210735916673092405907643647942161633 +2879051334510139198581358891368404052755328890835533066541217913121822938905792625249238474950146832344471977043224365781135389 +4792241156268785166424579695585412116561708898561202729978503519790831983242726846466172154727854320602695467825448826562117055 +6892572380716177090374320438112277052543379149328749706362112028296715205065873069869487739216648881329625482801871208985853567 +6373214964682547847971295488976163394711102004330268920420740567984995588029489900437674583804505907280376076761512694288533949 +5155665472119733684583254908202345934203146938766729952819115305923223221786312083916415057710647121628060022705929366547804604 +4979219068691159117673733260174579718275355270622127824048810725346461586407079827993239800649367405496829848031012026874839047 +5453326819721439241285068650662264327283806902040744362117833297041970217611203752467289267570303110513926750426867300123044678 +0552826491452886926336136137608744868267813981244854176639767832954709406334434073383918878421433694185303125198608436174948723 +8232804838617139276458679276053642834353480357742672915996943482707728711707722990226821986645110256211853787080947091570985448 +4530019597199416503606666321373773776661468897805635174486648284631882284913728030703703554479870389738113486662451982640555230 +7993338222145807140991352100542338400006637591961344296816299971822252698512532704506078851263452743784059409504687946969377470 +7050536882923788373466054136459774772814292349043369279413441771827357318562815124739087054575308713882488227553010491099772197 +6089909596225409017825449105685851204483516303044569069782656841637982677940745207225513250507661349031619934115869792030545534 +5623878938475449105483656355950820776480123283684344289877071474158657289092937164564108821983834915760732145489786160801928029 +4816804046415869731980026155380698391293302660706933603124933543082802974288753245590234004708950597141938648083597306991959548 +6285742091945356496670113754904503990748375484181907762641311090270050878330341468974330973619534202556739616012441626266016429 +9943182264167678058972498083665971330560261159232616995578303066019814909746442924781284268163340228187122534568268386331093065 +7152421562633124939028810156815250340969816324770306713467508016775028986746579511353296216202084745909078793312626258806625843 +1270211232086431110376182218366306020098067244906289836262668331857252429211967620796216066094322098532350592071668917821894836 +3845983140880841145716906938062904326623489852177531923802141898083667738472813358868563811996856141869924840103531518902763682 +6718003149619307421590918630236184183948486678786725981990313301354204177947073223184765980604578217913950986068011309908008603 +0928467335337181093723613708048071495790652643180583079182628211576154222901059273081503840088736880283912228917857747961420216 +2166551801482676965109266503314605693500879290753119500152110927158165273225738493344045059814681043424105403563256277265130147 +5602984870377735940956944951929383106107020907201382858387070933315397423879633043403789726957228735509198228676824257307906832 +4033785332705686886894233935205324983504447579271074658738235607798108047836471901273736322254888901735575902110174004577938609 +3402493343952267342344754443371491773245869528553143427384549726736187617570093360565939837511071410896535571400200988988962479 +0467384270228802505542012448307525976842449031499613137353277852822620338697586513075361354863064717799164245330603052561106892 +8842259346260183856170976867586760896719736933276441816021638614978497367736310097708762890208045248689587229972592272876387473 +3259167318440772369838882122021007960375389506141034220872992638686407702750133638151910546511598120704345383522282582904780462 +5442641858108090041720094339574637116216554948307838544047344475741751117118100567565238848037532377180455225898883679663375089 +9577142779120614628627441392665993338561362305904130927688924256501300629907368310744468665785794738752761659537261334710214003 +8036648554081009787955952496618722107214483438085877494384608581966978660817589075759692849806559360759821555215575625537328994 +6018332837847583031691963477349319171451400074031373390713717042745436212897138228273237021196246257873177739985799453366628180 +2105213797394649680881845019293842601907281739434203168302170068885354441461289080251599722778415734193180238772976142195797481 +8846734820754645249343903444980443492288225807913782286509632765370978666435328327850741457922220028478728899676269184885886857 +6241211337754447826883159708571545245319208827655835686933251362672810423079630739434073408653288828495537708526658804579257936 +6272761641480084516721023070052621557056643754854336674557368573875689625068313256900499409409105292963555938180247719262631692 +3370472297661265053196085477234369632895929368519546792630928565306505801718550038387422423219452220411081683199640562587649457 +3951837878713231474233482132735598466639480024677257398672432796607337555329635538613813318615303256000562507502749357845826125 +4701181391450803850270234592090970559917694412710413114961034587689766035663731463069166460549538653431143701866309605231883521 +5130066101866721176356898240445132440597653755333619647577387320361484004480200635865792415170670027337193740214918631143418262 +0808586953125247209833845490228639118624854066699258124848785165048528440583631961380212929557758370252911013779599196305478822 +5521493745858166529682225371969453760228060851280399420192708176554476472315839318021751905690807649055065100259488774569707365 +6158697507308922777896716663452883986126333631244914987739404979553039259206951208801722656773710392910263349735278566679339104 +5235852402635719195587338866742022182421541295397761869128302452896058848115769056351269147058952464962337808384290518791915445 +1541410356265877277120453080537595028913680044162125110791583969590059857305994592466475393255534238742387386696685456308459612 +0685998205305456113478494375669069867507303172663122574416432766684294168665147860680796606372059541989820238442687325132846277 +1106867923762001975234815885590982053876420748926951108789589029118783643675464846081587064829483161231369554788911064379449191 +5812396650186976221479400172298188629572727898176974211003232401377793666992976058114854815038333629709686365618467427463150786 +1384329026943982531591592399085803625354634016228493888015194258739954993856952956641410330220082208258103940975869674221124275 +0959625394390538490258630101489160874897384983747423071388118372125410613424612801559234232776779480366009970965890340120701045 +2667599636961907870724269931710369308622554291093494631427897956168577372077593727180133140549717498300507170013965255252092132 +1737339475235603869117715688789198413446311276950893765017909814539886259628403094769733766342691082854440546058895772248646612 +9197218961185262852748275379196855788331061390003979168135259363646749693751540875250641291188297420332987544882702271806564544 +5155345846357272505381130365306178806560153732924148036950818502559878423925856638459435711194956693467002588044226649914787035 +0339515088331009475687588955523954567747189933073011102332237830656095392839856108022616789694653613303860633782147528467869258 +0130375935586298049775383191407798098669127243484570035128574481514435908283974501169023065679639597582504503336586846159045241 +7077631278309415202815413204154287337150040264985085284229097360757947744868068694211304208527582045828778373828218901884299318 +9750268301116713110151838109753966293343621088077855224277949045570521139532153236249008822916991091102238861514323117478408697 +7155195645472829181908341253643812659814915997068241585467987778740169901860636348467280424257966646686476472265113081410661304 +3489215851493494198992712587668351276298911212514851702684901497030382245009336388185220072052801963314343348536393431861793824 +7433750102437336219240711853055477575713689475760799540383502439038522399381791672647025184537779822386053913810580122038174879 +3818754166719135070632269620576055650986227950584996452818776818068696309115722467830916362575260788613336625118633863774586835 +2178221238069038687341161131798367556148830622561463128345189400786005116148867892392990638096974925106944221425159061603022670 +5524790379877915422325982255364820388029995625235481186060304010456803568052174332647747736403777805245458180638361448671813038 +2561932270943099179760490101865479784716200934807733561691561384108933097340199742932516818080682737612322848740218966854945307 +9080116601255117121383041648878380955264484146894062161454022932953200141179550531168588724355886537447858132714146647197563370 +5582470235237288151308759910566681678927176948236130886004032182125845977161600117740547183580925791449145036400529238606663420 +7837033717084727015977259234033008100455368360038870286352550514822219714510463917848677542164460976523276256801252857727025894 +7130094419267655355009949375142847444276972876916939298289507233195397404513990497114810662137361054915518609388753530456478940 +5388394232615483120266638817714522427995662494049561316381620397442848359037023023824190702655956805505137789130807808295750670 +7728487145979981298300914926600023112696314252375455071809186812868701327870915067718357028716612327551252066278398582389353164 +7289773656445897637637801900198614044295973498998341687324987147175709042706190580765940871231724558042584698396691392833921161 +8657047381454227627618374146397069336202044856822409754902332810974380485722671719214725867693990943072348305834409116868276317 +2768386266640115552548464265203598491327266098674766891714414339959283543826573869249667218521183972556730897770799418342118136 +8189160219232646049490114563802577964294955901129433201250836705921020927053769046687178122894793267915461627258608458791264898 +0219476902780453916709467789696795567878369111867867605857135264741583700268708214119151342234570678050700247598575853332533925 +1642635008587172832360657829315478456525706956941480551250122576528755981779071461911390584857611720174162647873804473942063599 +4967685799379026281672422049403080588839491839093762962697369896023527084701530700159221622072624944257435732610627292851813751 +2044450251147619884660437582513822729870849508689036347657931033634388064328200140554626737296767003665386040440053850111272335 +9965191238699562685527207327106427173242624391995490667681457409129351701642801367806048618652102824703936861574242876103982267 +8167136500949575593721265813173669081199030452059803613088300447991271804667292549385675921231605005292459008477827396828396980 +6509840801282604124983554742769070687886591529251914833953844029743868619125159895774188014042708540332420119945175514865123729 +3692321786307153306613998657737637076488435978265420180472674598878806315670458550057067811482012301407908299677656750462270208 +3553454561634700149917505664871758279230385607072819176680565522193204640320948453398810380708601224770333475704117532694153974 +9739801831118688634434296635463933483606562392700839399728340475392493400599816097076262424865867680957927823749646379318466788 +8207485786494651396331129651303688013258032982874538569357681541288542572016965208057337584986821728683984473782485195031290559 +8109594698571552972881573904540885927360173123269475341745160895931951290769944326526035760450300948152494775976334153020903866 +1739268973385061826289687149889229189956753685868472054090051279828873221786295847959246538258862203254463138510475016160891729 +6472588945675080220223551738194925153786626106262423384260557370130433634861152559973124770729011313810073811203315002214957767 +6317904094534761856637133735479679945651270156668746266850573869850630241143818143990553888552953747865302101114447970138765661 +6050111904910844217007312990287283030132792651432799525258590083326102644255354794948740529248987597130140253327270495396985608 +7218279207220544832644649289313013019030346375149234023654949206605352146548635130815666273562950986058561700625454917451118233 +4591089295985815819108775507988478501559092837715809067331448086286924500664248339776158516774620654659269297333948779421651033 +0402389695369287676425439165311946884646996933164719659142031175373351707836712648952147263228223229642458870791042562919539663 +1663280408606348818705021370639699925355411336760403455952690546859354756234316710656534265824067538349235703012760994218438928 +7331947252166763395452202287514396143003916184577374680861816449247026988630652041781591100537950521820855164931956884346869156 +0167992341341885278124354492799177573677966259864026035120911925009272011711402759093945175436356249669782240856162554344304896 +4307297970448548637044676901410933338328417297377294558704310254387943692431491233869228400552419559003867252598836554809147959 +0400912691036342469718967629054695345164844205186330491298158594966799688436822836744333087245877645780438275466738783338029984 +1522719795609161172147875781283157496792619720043728981895906145341666050986634594495047649741152246939806507306609930123284981 +2105358148148398274033567712304765375367909977448660123752729616799410712586037852322616433905738649313626209308187391551045434 +8184050603718152729487919051152176341217780682835043432591401578282222377677030156609712538101741280977544353648960619498088312 +9780539921497865045552480951265192490326869876857256607893887668594821322177012473373977135212994227092237257692716960309499930 +8387530951877561556746885813088050059098237284649866946622347108029066952894002584214015925808803683837814966224683534722188788 +0980315065961365338422640630321175434205379462185984915822930473041804521924781482514510231643402826027992447752984590090815631 +8885215984427616592965846360943654237762984211426187791836287528989189066470173789608783423601639354776027707428728361921725733 +1713545761488733797112097100438352878478186093850974631628293903780866218943733017611561596620119895299713346283509695880279900 +7056694123692100328413045552536384469910897094450012862955826233283495356986105417266885152765210669772149818027501922143072697 +5044288331991180937483810266252299436099022518584143328384527105505463981298174129945339074070183868941494344473296478243433481 +4945558387028214187495664309036767910507538072289226775563326183770144119596728765797237537898375774364456608274929793323186859 +2322622760682958787774419794236441627708513520567224931868094563846705540632720743482044172976408519449985880794628778392723979 +7704734167762682724779119792543440260650654515136102295412021984201525761889238911775278953009856036983484297176809989345351898 +7538438504892134535588424111693601136717057553968849287415515571796218046474942306436018172239215803280193264125771352664266396 +7105221455394922182238669063185805229847494225913363125711170315190206996126469146603174629254473614090501455991736786538113046 +8157168667432314271904818365481089200297683424381896431649087725330131885687876217074390326660020019876852812089717929283102567 +5370154297245853419804188360942032243192631168128880436140877705786486797146832449934263947276552080089455965696884234934971523 +8611893045023888017310198960086212752413461499017699656702018998940525757023063840379418108573223175879013713671744193748767015 +1169024393509843272061563781622978325016779395605303924999369153283788827391502842037817134058668089767959752756676201396896441 +7712715405049463369575317556974267677998279848759269048895603544096481338768211601218741510541248300317436674252540127015114391 +4834430831243295519098671812863396000922057166207709070811235493720931115916983299692520931163380069504267039634742271991229413 +9287385557045725218161176454965763264083042136444478713449129334549410452033352200798030615759042237027156709457224173930955024 +9440754327156472541302944326043902553561785824204549770748860453197398189036670911169331773914895138408417009555757899645501252 +5832453847611197719596117303718224745254716796559500451686231076822545459079358621425609803998655831572289152307921157534370594 +6716617297863540993457906819123068181321563782640587142663699479729095230755403564453694626863314955875318305864016967285927449 +6751752585208130882471772146338918033811645841373896388668212294917320582400645793013617832138799866544853495551795042553770974 +7292062075462511235154219336433250111030971448383048960076039173673865773457243289124490997622252180509835724029497464904686356 +1703189532838988444479300672213603786659157307392869303094005510273480520540799882625565441527626460538592793551679614793917597 +5131469474921792991086626550504407821816558283404370799177646663722782715758886649389166252871185413421418269585717891891693033 +7009640276492618793739187876608008054508113875022453329081433650929497189681068056166559133270910556458288747450052550799593778 +3775026817449250262071158797005661647517869545017156045641434181332078515755353689003930497030264487465467676524742489128433074 +9510101337115987091584562788637829217924129844325702143952753831115106454935897717213086048464400730491846668741988349250815009 +0460642398157894924642248578767274436367563791950971068099635643161955689433389352445513881354534070645863359289997626236597102 +7422701275758347504612869999447090197900987293675125648746188541872170309069628366658720207642452150511782301406643296921604925 +5722148742542704368310731836532013521833785510008023772247459847917061172721772791747731176316362682231389997934194900072780568 +6833294401022288062004523032063979096666714062815023108654665205678873446818506366372748896978903704125253114795333767006805633 +0409503844899480726742485372066289542014116663615248040053134473634302073503009858583019797024883588714394669118201212140331049 +0801167094699960082079962007695468661043658656967418331551197267388919434693010620339366679098731235659707521841235334772751876 +6325143950028159251006278830542343903327924750282184108026273734472327418765244935721260982532015689685569244807990908472766627 +7594072557268049752783928609937336033485545218183637235406635759394992632389014311377829965838907592318760198667367240484412343 +5995370105199099659966025879437447340499996959986818273399469349454086733538293008250823125200112169460372394345464200255398128 +0278006855752348475839798168839058164956107248521078548181749550904031782397298429598863198195066959241173235250539525076363890 +2434406818995447305231609382502170967538696884871023912846712870860599713914006479152902091530717543673744437190057705732209450 +2049303158709878586595288112356673888760379702189055053773161541139894881284696826212357934526729889089168985110486922861784281 +1480496657855804936389615128385812000095228481966854328817796490269872553734151219601055960998715934877799282526137718284428232 +8638224569717329657108787802886111345753795000064618991042853502960039658407299390014418474102137277340588865538873397922966731 +2915504391345921079597753766165614369426311302871553494239227907927104755401277811135239511652090480469130728548314080193845714 +4662543498990058418814498281187250236958894998429926084397929019382124044722273292092351973221932689481754974738766719140738353 +4190409245555651289372817877351684664080842342410487693494611165285252514427042631380484145603968868053004939443493512729765220 +0119636369629430093021488300230179969441757666478935315483114992540843688913867607317956666306088259979412209337113112892142162 +0522344915049743379719646407210766405374162220565183535557053495876729008927029380341012939110046953015244548503515867668213581 +5545277258914067549098676802369675716209629211229823278440028400844384130766676038181293025311537464968008032689589725571813893 +7241917831784954432887951874113610869422570389407469506150472467208362227227524708480496950010505902724279188045395824562149045 +4536217193131427845613009167815485956442321803951137596941709381463070724725318338865720453796245623311051568325407640234609643 +4950000863730017668562367944404823933355943718044346155630933481082791520987136962663882167172001786426520967022022083855046918 +9948462347102121864710644896101448735320408682918327475914042821856145185407258575043429392954988610306816855047216892742882375 +7607463192368539597117886391111127498537601742711656094819081284338644518509840706151881140781291037342960935079170415736099697 +8170547034180787962131392617751093115453333934584190242119875787080041916215989194964046994229463391170868877473670939015394600 +4967067863801616048208692428984726982425267929231942089387972467090049190181520316912402532109719978404281158192349591335918000 +0182827511598856652325488782019351042712700704721955971553105284410000877214479216605042256842199795133210940783113951447780445 +2845448586343352856456977029480170139895515001400772533947791028664521178270989590999530566461508232129548565121491303912378773 +3186958087525040737796735368369363073980409705399259078085185801788329795473492605756831924612159181775569516279264645527914405 +3736227582287369825938099577236266512057139246043733096797986415476742434871074557767615701953628932757311718425644125724233706 +7173052386737821682078985950554267597062731307233678638341260916391599502956775154905191238402444341035490900454688563799626952 +5147641961470238255748645042116320141678230506441721302812017771332190399762353180889095100320685446894708468194573746305094928 +3469096230652662675602711465325424276546888133056279141284661309882996606616677713056958440903862720614419241163546636652676601 +4000176045790898594283018168562878609386243501149259496688481941480198035420169390431588952838073985685288362095448469635565752 +9472291341301030094187025146867336563674988987757598438413852630025766068250538948297399599973328446303590662904124689712678759 +5558918453683884045568116648619640982031099812596210893142179251292478971547413993326289821580230193948481450670535256195029562 +4928975689440726890177460501590676962108712941853309133182477027909307432937071388936253714931106477057738446899643424898539007 +8940244387920877438974129853648880036120882337129881652544245505645048735775452951748876363983239868801033134946650378020657016 +3701058033103724656733182793045707161803086804756890720227008032425755334349001190669627279911430274518624636020186433616060892 +5795048614649402340472644254299779685615196268626556186825992241948964494636129874107575230767378691185971658847979564205979820 +1236133846548113964258787812605512858795064801453710507748252434757524711761598464790831987938492943750974650361247007836117825 +8985069765244610015917016588371467517920803422724008738355002305222843175513547415525425623310272808519127269635589538855868669 +4866637881580384758530553032050127301271010383021829168699459836736308865544704254424297016793922754172114529453114659796809124 +3421197137282279783180092595776656118340512425979400729754872785822827951114365899638513626864234673281733350488813180030409671 +6116540261589173059806435182727298140303534088364505375974117730218290182662177594123794279119735348291936701406861588485281875 +0383388028538445842643371054045990749985217056001543711456417105050188186522673179186319252532355654228417953034579705914850138 +3589398737652268493665223622209314271095213796466114005222254738357264490629049957974234088293478306962011737255628545244120278 +9242006644961491221804556688452952473719954034253935879343918188942010496090705258446852742963029458182305909452754390287793730 +8783068031607497439341603800503578168008017096526972920750091440007773022446775696934539156855822636256531074692478856955931965 +8800823547223548709312492609422799167744315137636030763502283934241170303284109496261288800964950861563894408561284405190045969 +0236871653896771373931349637525093015261721424149322538581449425146949187109336492808412768678305259961228548229258526615055933 +6808296006076261647807027264924130647898638203490518417736498838185026931804266322409312178542687977048973852811639981510309567 +6711783212313531503601350937924384067635440627869411288664439772524317458074685185346606914709019186196743715338064452022403271 +1329461726620692353133812940387503225279782302791789101276394351197294472993751698133198738485236134603208512597461992464092534 +7712409812790062450698418919781788475967301395142101015147156004348821394973951402124816517835984222889123201533407163528809483 +8878866193884252627688867520926767781102452754391877549372235240772045942305940402248699505448319900090404392151869967674502128 +2483008370299951549301955588790277512316664972307031593695383033586616221934522732614016251454351893271188672805879216575868904 +8930668992950485150931537517355790279447532793020359504907584544928499659083716918240980733762266979363328381222043500384239731 +5449783313063957701679502215046202754515996947849788011011244404372242125949053935941173427778943061308870747330558976279745268 +0087442866677315281344307628368254568290685263159851300491709072441620656219856549470063530059686910247545618397733080267966459 +4275923776467144475919672663054261638444876359385278313589184049205522647886045588220547740175271213225571694335593813888699266 +5631076970562565479284442184748121529273149320713280238168313146627141356684124916604998541431548094125068927278902251637629771 +4049873854233479495273404123122985718709224211298472591495302249456292201698069758048348513785824572699432884088465158829077277 +6601450724720706904135791943277181797939378581152182984849501639363583354753791712537234399122836156611327530479415218232099189 +5823047280117680731777259023254262177630139266484401163220777646941723211983561493087099972956890435877152661438838138706007958 +3871525096685339470645850417153350859644241363604522957863652066029739101996436761253594694922069548250943637910124220796682359 +3789021225120290908842849945791566951268040039302726617891236371450848884685584694857899475642048623621033883942963333740640913 +3413392907322042998743788130668642581010260731658079311951196515199970920919298587850590756579979416052745401954692899254629962 +1834576186290812892686277778078188491493029363265052305832102758282145333131211542287672262899869561233857209736661910966320185 +8640618069436548861856298762841794920426604496493168277782652390652529026370866518863711574378563335650089395301480857411365309 +1062855694706861343683613721473054277513151272875708166067829305351279095564881057460121748427296483260938003342506900294399166 +6708351271129793412643921214770696882147428525507519544681246954889801321262715754608536636546303081680171501901796848282715773 +8170065360748835664225539865399039511547738151434626699419911223518847738407528346693417347838281049824633463358386526323379557 +9773283803239608948889044323843524447778250704201869489766199362127854167469574262448141201863158740882252497005327174568985690 +9629170341829493159540502281159419978757497174339132063688621315745991750554750919122418499757801567167615195540686775308036772 +6813737486648360157997154949184994770910737848857708594705159108226498818076724620595499835896899658135344576077658527954169440 +4916163367448740109143119472115171909713176429892100499193749017654102572161123098799425438195950481418848253249246794538567213 +1943648585194380435794184207380836831419456414164714608475465257187830071751668999365832434059345210749956754565801799757863175 +3687162724713568040156043932976576841434569787909011626375244300886516755159434297033774573216110685196819615175124148320455479 +3344419757198679638351706919063941845054040199124828713172593196435249592482470220242606177271518431150127043364815791934444495 +1400008065520008098162065199768125759577818782918099045365313282741980846275621548204708560469294053250492025107214712766610441 +4165080021198705915210786508550601653226551217888163799551833017968067846988341804528031533804959471453060256667445828562593413 +0316539921143167379344751397929218943090424282667061717675506492829683232765044382831375540458280475310930354270466628024378573 +4617204749069035253813713597661824629929473681227979210717594546338035842018470292109616982725985026372103084242143325201934501 +7628437040946835252535863570081482725836702391432238382009021257963849956941583278276159017021059243802411805222128391491555532 +7118276592277047948538579672067937116293934455417400255981648387252807293008272125197089405857447395662820745517911550198420495 +4817641036360381588057889324736649206689772293316553388319983835732003282890192751493367420760022776216834345866178180918425947 +4046762929816361002114402224273088310438847474234192226897299571581711857975564268312621600137920668387355607049886008638057179 +9349209580226030857313156556379575691164723527464611358492523658913876021766102463374095835678962118324213355237312840525047153 +4458386832215216090846608267034928117933000209670619365236847239547649406543272314067052926849866069213065858041288568227157782 +0323889725674406704675299432615839196837602006707700866051572397447613281818928460518366859474985370527579091269025122957262918 +8693066533952054034279975214015256982660363796184125831239795876267900616583623647519579472331003311428117914837252346650454796 +6978896914173575690746678387000060698232734806725458177123404206650082946025871125219582890983005045333389163168584620102734094 +0208343185195645077429621338459120990032615146936965171481121547620265509203707449471143882951101626839387108073423291107985197 +3806694565547588080124701297594558579857621291153844744163973871845300036486064506978169189349641947450555475680771354116721127 +7571370673293744335868791633492268450482890329783462471218711903016708619390949407758233183647172103050542587791975330523548939 +6895867004702083992837053115350359081392183348123057432804437516085126480426796559419343457573809103554769814374422319272987621 +0493741336702343083547043049060106406621621423866156744878463280624931631638757753907480473151395705318815364246326098575320029 +6546610394497897246218305493409122075422636049647756434404729742804710870898441487104017723846320578576625101570540009682146545 +1011863982645118776769923031005075048502898177517353081584252680645039932448249490068383719149012492191034530578466311073324350 +0940022141946663679361628444591959010381878575634668757912852707910261260983582304441366347012174417975464831931140858093450475 +0648068206853955526969735294213923796512233785864528730934169006767896899020079186828212231303729771906306615698951701782896040 +7705404267837637281673906483600597132329707232579985805240515664780686649377686946124141035632716982723408330472426681691722063 +5719449931034079305356439666263973565128713593058013796099786122163872295053911196817120195135137786906005302955333296169099953 +1565007759742421563846584208111412785562612780177121771600395311757381072903942514964351796547320888609281738762831301074727155 +4840914538717807330571774867536594427640229999158918266573255879619306849868398528582717693006558964074770743956975947230605506 +8434170706163547151705112191666162854461320116071520338539133193324696905732424568076770881016026396766250345270611437134977029 +7078829392513262023910437193357139649522860536333445198136202621793588265321546711781743395796073320028953300954811115494631443 +0358109781392845465184944557313417160881340633391419971812545527651450314512749202620144080637491419201752326439158460989691315 +6502021443239860929638929077452949976769441697009577432157105021271893283919677666379901876413440307841861569738215346309784385 +3775582600443257869423701993595504734055924868316007937741523410145241997102735147790121190918364977637486443176097526249923371 +4637116062887697972788560169232687166734847960365006931173635513798426534363094553967229788862861423059133919581108100325100963 +7530945856385218994386045042760138610248296085030904585153248074916348965900743636913197206787899808540051760130445456596005975 +0082651589864980975976353455996961471089119847766125021188045871260940417581575204228376995886410553255809049908515562710519369 +1760176651046607404619158827695196639809040360410321347276093208667279377323033464221881041272072298115933348047136279306992189 +4449900653089574942697877619922022124081013931968320543380925350254859461377805018823478776678186127822712476112142520129506611 +5360537273314488942383696459647239094488670283840872805432523968819547360255856276619301822761467290415157270983258323381158842 +4069470180647648022724489031315390330623675246416531426538288357194889582860078070141817901349890459635960185352818352346101741 +7844251807909360860529020528005655952345376045413861757127236316061244993838373872852044455049706576181912407467785016013363013 +9052782242469623627138305243693885375972159761715793565717369599576257075617300500868041008633881912456191819467065232604757474 +6257367548773919654525538912712606831341580701967173140576682703453195979358288347264315572356542410824096892368844905848969800 +0225531033632269859821449136659749178099595609866207288912288428688139123199517309089785003185562015618879502978274246919977195 +3412420395378666741269488926730591786905587902546167052955793049551854045851796515140844301739953615780488764468845360750173095 +5314569125098157310473890637519564038989130593324658307078574903372187794019987998391252363359372204089006276213106238012887639 +6663953749875926737127213800088216077686383881272422931892106536521390323291590624983492836817664288184016273391511477345251544 +8638673096407867791116469531963581105938614830552680798696429006418115851082700139624263097469936097502648484256024821946642846 +3261638416472717635495620507090713763983290274773473746283045337514051847664087913092670813304318998742601034170158553214610079 +8880759198069479182867513797991706527425937623927208476182273090404608783390855357409578977746370113730628533384722500327769010 +7964841863629197861004282115308229708980836184692237168958174288698996726561927516939282475998327300490824455643829853959878546 +4078550144875137620442196894251820235783690433882002285566789090860837373159507997956136455505729693351610325429624900264497493 +6050282912476085926950954499140111563620447106769829012752567207785593165136710295523078591701424407957863045561973215300362256 +7166661176552788865443610475451627720514979209097163741564119254519710530732032781304320231265321064373366029789454524964576034 +5731838949398822830420671258681703806386818639376155723888774861742977966282701086517327314375297715355669245126118723701881276 +1224558805186365369295742263213010659311742471260411491616914473284160243356280450620150570408750609913288411042993040473195864 +3965363040687291139829734658431286318462224708522925124414942719604612215357576250193871596416258769483377169469309016314582237 +6893425774786606424591335564336597467021697313261577560777519605605111465025332099784940659090512446671447989183060023172745349 +4463023117754025492704298169088346276715292811942385607520313996627188228077675005968319409041724080200894220147117291796736469 +2838367610734769148543248796176416656292040941138404572575878998139182976355595776291061040689581132913463002164503763638521768 +3585007037968899533646050958305472231296473689572926896126127396786068936357337467731293075452760614111507010520769025993887156 +3025256134722351463444782906552873128386686368275305328178049328442606382059696387241124580313700815579068965097895955058791706 +4888785355196252887855666442682481926655016587897905441501499624695729356509071382797002137717002280304447105900656692938689937 +7373767636755443505506466024295128010399690845976961083809222125377563226037530095320414396885247587842781981216438439176626761 +1467040097296217610154727986310524824930119662672041177376733844872215017687323322767179584613934704188382812120901100084067248 +0055261010703792927114582278798343530536332871891286962151403775103518820096790537756954678439988840466572934380472009105374277 +8745186553258777370952969850546252235196298235316976663904366268611878480055244838332857644576178557847556193922108941720480963 +7310291886872239579954842039199219595404202222951474277713284211951970030467647252785199038918806323250107496561396165925992981 +0269739665100112200470147709926216131752562563116766321854129961314938822821859829783043904077776487245854331065090150597583869 +6022034598022521394602277250974332652859372516801989113143038045232940829875622476147452690929605127893923207935810728978176813 +8336719184987758081413476270877983896287998313373933528191759149653154025750363065606417948489184358633308380877845477894994394 +2211461131853873156810302948765499385999974459433061226146423964769287619911252503115962272972255899290410107199334224556606196 +1402532784763926313823670409002705225482185592078872442217786835593632982577282903273472588503956076522785281354947952227775013 +4429564170373891691353053299293858952840011672714332817264920331107567378250030393312486800497701640449816183190591793478209061 +6696515680454660415306312055092012435204898424655900246268144415272389485588150485707845045690614308427142660270754614963190500 +2858971388307084324374434247865554208042477256400063151868591675576690659860039137955754547923321131572573666015058716528677560 +8082431519645786853787074095747644469767343409908775777981556502295146873300678603062293673505033125364497124824045616025095406 +7796338540952910648733467788030865929612271961440794230689497348772551503718356824778119200166125356293580937006896521596909494 +6623286777262305838866280436574493459341503722464731387299068764367690003490556552997864648359791608273875942027789979081747901 +2820762823681177751588883983434913077317012385982082727245344446265775140411273692313089468167013918322825570599659499017461253 +8261747834117161824733335000918969440857899686470868022119901936951959497914248555296472517607486195543086996762943719289544222 +9801799673583374329577712601117604429044210658931033348348701101269055569381455391166077387776701104476767458640618577366620088 +4812671524372167827325442166901095131227009588677251478248615586184246419258110774327904940522040756539440861199193515869861850 +8664636186261176234317788607818904273283245654628256017166703040583397980518196864696741148650137946657712844496351414683354360 +9233785042626900594870398424394786589093845861107111076865742457098507103631392813148996022790966610376381301013746723765671101 +5599585345939628248728616861490756773613146232759270658252490655694524473642364799716984131253156192355158951050342077829511934 +1018115413367504225955575347257464735373797464835594482025360169817251469418319729479090655145106287600720398462808509722342523 +6277929810316831402715379663360019513470321307271888286707156176722601290897267704973159272389968049881611196311224142002818283 +3935507653397356468132051961271044279593473480413318195705016813924079917284710536189206698836513833423232062305170527285530270 +5930541214728728710514258849354991541204981028873011695299038161284051747700208580498162480391834623057628739847088944321070540 +2131178112490366896971016249779880442716420462976316622931349965957507940779710818286842266030393060843328131735676772739856028 +5339433698747921036431228649318038784378241814872129036313002907877189828316605458939009159662654429547906907634851960924867766 +2725144295031618884966653121214453016640389429569724950019640175004023672074204183536974715285043574870846234625695507751624691 +1101023040899658835128880208200979236233784480432079242348382094125974376887755928733596001730428491870299057160651502141598807 +7529805201863368482438225714843876867695794742159176187308623091428831090441762886002331398279108448588579520003248961018841987 +8520639531359520492110038481387012497220545183327686786319255787574425654228049283708164761318908288816634942299623177967850311 +6808287068903794688768313922352685578188040716704660250946776133077382541811421559714303292759615754217647905753791800896114429 +5661937959933192849164004778980526700005624355990312125795014118394734147334017327033918908976463421944496702296931260093163478 +6866390898079223822127023182717821447021210719486206672090868302561371850042810557962915762631762160188811564644765871940463260 +1983784957124576912722518060888269293020694751991232003856484645400501387457614453894654158242083061986108255912461168024044362 +5023757063288290577909452112558045920010016969071712896564748738667312129264760935144195712725562634643903560619975222875598092 +0140266427651227095088902077296483470532188392053269670883135265668245606745264278532552540957167938303029227319042084398428852 +7212818706985477890259174108784143029357600406814727037979412733984989889987109358055090912357026404921211609781959966663957665 +3885309358663398776897062600124335478996053317484403001725157655044282776168453835403175508740651996708988152698983678588345737 +3549561496006579864153172902480324325137781423364931522958523431287424861594425297230970169266435951937028485126756644018421959 +2100522734881499893473520957404272588614489603694208305341205355969403603944823313607027770883562580199458807047182736184431355 +3558566826776678787162145637003470985297896846344237649664211727912542844807936273529611661291547660198761650362176216275159276 +1697273051970401823436818435327916444246809126780823246257873146180484087471375537086616586114897794676638646530157453530809297 +1877141731822379123458355749374949833686834219493808460922026220049948042459289931477172440353720942293259692771867444391010663 +0596114677690135744062023310258035439858771664427542203238516588128327906442218908975480077474481540939986337760369812161668739 +7140350695399428116941903267710113882542083290951701275369344655927910523637037185426739245384522097331905044898640671070017500 +7453482207139204385313210256702640687353020750058344407280878423180101848431141829884177527114462939147014281506261604724365378 +5747051408867537658614820169384534962462911220360124367460201651929905485919878430356918185750947336103425001412723806012420037 +7672418158298677361496394053891368709542765466425399242228084774006250993472472890952527381058062695609973430135097018848485375 +2721910797057123953879416244095325096151158592383520642643416351496904866623597785985406941433201519864328401275343395705908857 +0642983563496035432630122777955167888076028823131047975325063367604577001605053104073667764503079932854743114362110563627584697 +1737450520589955785122525243234607141022634008326290553045379074437558301788691892914015378729774742647378096844792864200227145 +8049477947243449894011256046326611511617306926576503154750985615770186729781372043096871431456514521234719945343529143211616132 +4060930164560164022219102032312173710730634459253495956116881900466752536260684001258460015562183214690371015163609148581576715 +4339672054138260157605312889148304084301210593319661500758836115820325521753635857005220500312010112221791048318710925629489360 +9098118884517110952549620567550824645268745886275953112452963794466205654973301959016969502644339312155829940467386423970146851 +2030422710629305679756784568188030405053813130034967510951876362126306529129246017456183221963883892572064857246348841309902207 +4014325197777088687588337561652558142332091500654763031260105487352116429628561906919380099545877339112314250562226830515084041 +3366554959465306038343578751837494403196208574534790117389855546409717054044483042532146409499847066640874035730246190276785027 +7784874865116514506998867941821004659533959527747303526874272093224628939120659783314979799979608075209344316698881835617720838 +6440603777916554902557821762272317634207749152011454338456295029524399535728380230269435936275288518444494136138485427687743672 +3697767429372731488197371169546304182440802429138205900920907076873491237616407487249087243231746614255961699354564621444166710 +1737116215657118949418096366707426664676852506304031637797388892083081543972250240515279155087924413491083737598642466601038186 +5943501997584026886556269657780895221836455524956899348998644491412008841758015117023754182242908647650511196372757530427844200 +7126098691386230123347928604422159107062602585844839531380975985325229120484080904014468470157441597070403077589128617082084491 +0277414078111008949169676840880976444791578133697866086476338429943906280786246925904505101785927908752510981120731146336711732 +5011921703942318242688882518650473013576715256957336272842712546671709676486379489552317943731327342059730625728957322661925103 +0879272542563908841343149899911945430473689164183260890378649854294324088836226655479509126988786763035689227450447066454969580 +3635797692910230406460094517526461454920959082159212413377990917407487877377494660930246389887432321322711771671714018210018244 +5496909568572645176488382324921312621177838539677336553279411765862833091060541060811106495286938550448561214644311877956532326 +1372848285800862888898722477263959718622329488994306400315469392140836614515990231729283982778367781183582185203884353672168533 +6002585963544294141850925971586001726265376264686412361898087738304610666926697454083310088708743790359728974336913706461189057 +9544994601782264143680659072037087516325897282651078850550946582804440990613134903404213391711941451230258293606634693846961977 +4294296739368718314807261871407488388139897913896057193551518458028526780686105950168593279489650803151515173510050942218207014 +4440222769538547178501749374936219442687195706297985586916321673062155148432380676822216859833618467359812508595764374585042802 +7090291929148830504311787542972555491835675686001439326827409601590115100758667523079283454747571560861565934370463671494879471 +6306207613636744929606340131323412825985507087453258431275338612289333774848983021189785244607159387364635876091430264215902551 +6978625947059991073203270373760209952614062079324674488242868605448441131389947105750784088354616643566884781392969415722350013 +6876895254868693830649346298281314621651851243964761424180528331393082774872122268180557991527876049313013835528942921722633863 +7994555257251266617368145187318488777925218911343096210380569645729516845387191015748935661281511118325824054860678678241487526 +0561712487759666786219959935849355827031795611802441457990195006279656115907452353501575006228849649556626967066612451740817401 +3065700444272921097020103095032561392189274167240364636985217260309148382438375007728649942200430100798750588348282135626863041 +6418290958339960432209597429802884987767056126860829761197583897408153172039938420304452769552704862796110442336483929988890230 +8411149220304441269312528476234638082926201849344380193272700895522547783655344727512614476846755120115181365390739989354909216 +0361827006206843386504436443633849307138803846456656207910374387223474485947474439419270873842802147250905121223284959187002960 +4561901942869500550331725452244098638243866570298342595884556094097612128702524209824571526031229091793929079092201659156014426 +2569784663225002575851412395224946857021846888745089626571792624047307039913201999491767773809090290291368272189546699726924662 +6874345054057523806453164208085928558404937408086499251394158950058605789150302667994062909598865360566447853006716951800116507 +1806892347177795837940597487685027448543886249836281858785204813002880073746279096873385938335081449362375954555853598273582800 +7280197984136582079744511307894765629896405494228558457447110951049222331477610433641974978714281803792968381573777298819652746 +1797088044067027854938520030542484156979879022746379761147066454374087806486473993175758842146367406488679492927645706548068169 +7653106688789014002295870215309142445613718219291306854675259348422471093504331308963443794325054200760084750801107789128152322 +9003923022817082834921721240788410357242843286036977355497738812382673303415071169601837346379966066053060156517838544048108090 +8927903196351477482460887787174517966173931425526452434853205934174795153124436599267973662874006233354646357728472499860554504 +3649137050137288600334652169002894564926317935052375328874723351133720379648102007752831671041946276927861278960706248758820299 +7881676548153486303936365019720006418330263108526672450012829414081940012783530554845066547004930367871816825750941800388750747 +5617499751970255706526710234532717339068075364068621300856559435412791685014748892438638038434662792832126729610856601828058978 +3609505162338640897172019393757051075698357002384746777463891780931828353562474692966266497051217520058712600221078906316845512 +4218942164849049619324701770389240864171286359070468568203895572380950389773235867347931266228357895243861158024586703415416725 +3286877811857113758575603255834974713137243819997694752214133530728139390482439967896436662426005413536915227299430206070281748 +2197090522718698504657769582076344098155286933671656794750871593655253531647336100969432683359373204499872727545324036411875127 +9266329520011965890398156813860326403682885444460637962832683571266360623432333340007962893574859386016733773045469648300215724 +9360218780816808197711206028145267393233058010562551036732947883280144516446467977991400621686114194941533328336858706301853920 +7975466727102526807928730597288066888928449183473417942716701022737828267407136547666947638756923213101355014521544864295487342 +5529807372773853881156331115996145600478892095295063408262502214227819442322854320893250029815358897498644974831455098851752144 +5217677466571168103885153319146030362086428120742099054171064034691470505077333070394007756131235288630142015715989289401952345 +3238751872112411965525172279795754140090657968922574492232135102357083597107656178253770512768121887161690539858563177051498031 +0621143235328817027584926551312004300826256116914067938452329926333908173348351478521275486940271058902772821984682443421901374 +8675029994765542582556780936437230200725353322681947577235834861538086815882331325782379515826004655685444830286018743065534290 +9009226484124905023296329465126310425464799999137557622919308471018246198151834136297559364600044830857980861753679005100073906 +4026810600660421971978121050945152770853655639964897333811108395111596792046176724058242259398267547036042717629901672105588823 +1701174760060091817941457573061071686086097383906657079983926029247083644956175901708832562604741667581501354921250883246878076 +9360121868675405580012858168094642670756925814930958722345840360155035939830719501362830202256115680429221284715437831407183230 +7627384360887381611002122676157337577850291681707758128451482725333215128574377639863228270429176470896652784523071172226399208 +5924717495388805188609979501739528551778957144375491268555383034743525334962407264117945701829683575948250702090310348063964292 +7285038571762987494406954123411340680613165769286304746181220668099890216085869650378284432589286853709759806525223094629118994 +9108371459503424585162428035918267612861106220506440110173672498423384456764491877643881942033565719022603374698498258614890281 +2119544835856779238923121210216240209691871364625727861760840643200609817224777039142791222829730821468075117365482012776292615 +0287625006985324113383256843550124431381565006783532108722669073077586017057966762263289920449445173729525567088605286164318499 +3802234646726929017573814267132203009806257343348973659561216577528599490870752429375293883854127262090614163544620710283467000 +7574267833171812189998339587827378487203820258567218738257171370030553714438406356225807045913475052445364294909346459733645424 +7057209974818106332836072380332490777736818456915022774135091028181738711236811811377666386715288877847647340595585098875240481 +9197215476954479756497624010576859326493604058234153493216522641384431342823687635555610194191608220091909666730522341780147856 +1119537820044774998504706322100346395055393450296026673688711639572331613882591716507869222690391102545737433635859812821586270 +2028121903848368987212538442391618102128444213522329584551212886903253244685970973210284229639689302832127513289597893485709871 +1139101840913818162477340055623563542434178020287614160741421605723686784042526943742745792272929328869556547712709877327596063 +9107408768006237961652791681788083610784715577214377191666576416371990600318918309907846332307177843177765073709224406749447169 +6733725726008450978073741092474719053157935773438091672305982444490248804288080650618594239161482780330596854243463318510550141 +4618707611170337857871421415147893285747404164961249246066409955331826510336908541776726066361511390478520619795261534651528646 +0029871423726184455790317017373341560382122160829511677232857909382425970016570928985722750518023888742942482674353399294113016 +5851677764630543407742209257890179166834894877003624901201481696534056706522332095998210032002750686323425734736641298781343895 +9906317458124808949504199178481097664951999312281141056844360268819241235749855328929404804574246937697891911753442746410513511 +0301178939436270473741478421267690206733306236983147974561800903978683929049444127508643906957999471564453966363638317098479091 +5695590670680910148994003236516725327853434675592633044599651978504490768012904279502213144296250305384458215615813612885360699 +1739488113025246606429350291878905105006718514335177675021282668693092738324431010591942084632165356255063331639570681777622822 +0452464599884896996261376953519588463160916217402746423924422154683861260191652961898971705302933158251417160490178433853439776 +4496351983750730650624656965901956261109512227868877661440793378743454026849129576683511149685514643006637302234104714172349199 +0650873766138283576167959756442091757660353703079228843249388294567585567331488037468607523624545996431350612623181744202876623 +9217884841612782253645748182653936757610046223059439143748083525756745987386187135434504743166765496977544377259895573270803669 +5233343431863155649799928568730055354198316775389815272387174921789883067246402571006054994197016258947251698092729387460016002 +6222471188835586754619063338314127078684770466144889169048987130424673328124774962008878054843463980934491177848530073946295466 +6092983987521059016788973113331515120050882840886284842856803861355854867424082016223127983920367739842939341557083529339357539 +9152847423135593002663232861455632334026991039822394086654099188131348343461957860123922177650787602787823148319677335222779269 +0688837540315420699495154888659745629289164825587079409113672585691726485783954257060693018031835646491154074592682796993759642 +1560331745546205131052821650865965767504353088368099838110467887791087910699782310016063819056506494246788726522788847044002972 +9843063757395851013539217226262322774482770252168515327930783086524549572291277963238718919614771432829552926078930464389873382 +5165503350814374626462147517304790280393184056104578516266158383058163824599464967401146483647756651293496532192439439145458877 +3334882919381143165661074051363092147447735703148534066554968559573383084492917940343234309775642206678952812922080261015609561 +4150090892422827778476783958648862075260361082863595155851728025658354185826522324370827070485157038772970922137249416500335139 +2270729610239360993359408455484013545432335012129825782822705159183112780581412024925958595707332590452541348227573704213342055 +8812698543571227460191878467610741003808872140196791243938096775905061169632652370417102797369863591037024610630210903737953654 +4650850571724314687005845773201562588529522607481288290365062000530992710204626283641702861862037299641210309359904939817933700 +1541143632255817063903213640253364698002930217355939377060114361273809860644552941254027110592936933650281526566113066201345129 +4904443218069061051090074486584977672087200091073688866301081198367118241651115030647481869824608967401802054144740280994709964 +6714819600988123781424031251846423957142678675252652218273564424036686308763026328451858255344930462603371376203101104448466961 +9509079835837547622180222314290215064732353288206452347849664411672496172109171750484558066698591320017336090478613367662057930 +4411722606999341112288605914814611482715323396030160357274723566603030739104369997016486251468461541345322418772128759607222696 +2948183785699572384084816055776039138878581148811752092336317365102276231176457487558011884744609026187961229782054619496985034 +6425095624545385534119498681567553265889108179726785664829530547971892685921754372850536788921833807429343926950424016846919855 +3908326069100657803588698889883675042505627231337237747168653314558267673583632726264839565017058848634863075879312565153073799 +0321367266050720934662774520376532661682212427124263069420126600109509081952403933716651001460064949865799766176759028464538738 +9741038058065551330442704073919666652946527397570055939551345839830820648016177629571594906346803356773604688620184511211636838 +5025402557710775296650014515224591309232698067998266520271098024189399721692010614452489061642157793190304607388980065831660161 +3865371756663396962706440110406172511579502225888432146828231479035598172810500698253040173626514931478221885791112009689705108 +2972286823839979161832311952971045738890113686974537517223372452946515286365656547601871718080007574659696313592727664057554794 +3671238913457833340723922452738592109309375009714705044237276003225833183922594035143870946960395880735557105535062577056078657 +5639824224660978396027300014663032753936090244783494976851962014859592152013834741021570506331633866559318037963618148063022083 +9565507482964988994686034476299289689477300610763650942914931588839058915298408270882723496065586551944274748829842524532900569 +2950174215698554483745941905548644387438215825109435969023495189379067472134512077000118600012988374494816155364721054534508820 +9518525904194943790633186346738672276318778362232864095452323156494968062204689793145701834333799109246633884847638921045253621 +6777489268860937675801194897856962853781999286279373198884776447439334574892992495036091872659389999472183722596570197112840487 +6940178173947556103657708676822035069381549630078448878860057242455764188710473335746627500154960475546070307022636234086868814 +9329686102999304427635999138246997518586345169303923543680994865014159368545564362656579126189568984209672180187596509411904289 +8400290546843033015441275084455799605870040808860666105081155326036596425585507607789010815662662324838353003534213828215099749 +6262731155067666934829202231823905666280056341904107277513506385716411353609764416145090669300953084810469016331307248958077392 +0982572667217714967858091868055542854621721843072461742877828288780619596753823464439165581485796328231801786913442847252641526 +4848655976411335420584575046674979122655105315200347515565901735274063028061587092460808297171218521824980966675211293241764354 +2938658446761945214970070404972488238286005305727629688975307477962234711112158327154676636619409638849544823620779316735831746 +9233723105727772276287999774922758635916582468201648663126732610340191585232715185516172590941978497752196971596838962424314214 +0715690795433694724565717518703035300373548926507910938888351542625042732566820561320308097626791527666632661894798286702091403 +4964320219506572216963601199129841376254539941692757336784083929771858734782219556315822673159169808692321828354292775097642159 +0335559611733921504268377474272853207366325430567729920137620204884173222566965027114331948190426982554186105784631841860371363 +8033508558384267940900957170710292773682470738089554833769290979485707252598489360936633550982291403202103393568639544279214517 +9104033203529399347159766145704434677301867369574628242547881760927798205454869510642633732888078982477565192220841911379788216 +7987660031763621257245807669247102344394837687835695594169011679441270384265326170270019240149525684618010449694008041756350062 +8151902440733357075969965129856431003770185569733670086864031515027203169324745948550070082363039150127359144961399154724592013 +3790327961179853157835883754649149214290489479319422066362773172577179735157530589191336297098156970651227770438081844185734307 +0727046673630137406560803707058042940068228879956058420026237531511228698088255979495039662974032046384364026969019919437568764 +4204578688546460366354226690592321231974552743860907666913839079477111780605991648504857092410645662298682793993079551732419876 +3756294405429570395559614676089322871628319405115443082409818445213875343993774082306018456892013141571878129826624772129903802 +1915879655542608031603048228973067523323417771894628549592585367737979812887089684899398996853836990904295238545782994463736003 +1862917064901509743356712523964887969381684280627429777002084722985720739317294453681605121270099743339673719320682461749376518 +5235629358000506017419756442938714321316730985284287276160530781176188912088650998156658168743552720877268116184356043543445755 +9443882656574676998601479646029201608533720364834332155558897088411735201080867283586900504743773546108777074700728937687647870 +1677493272605889337983961765432999426943110889282768474699096119469883217687878946342929523139815961885455260346054616901453447 +9942749715588817104901581207188857800673119328816832808571244811062495461360073125883981969697016073423707659358263862951164461 +7589849154636259255662987558451236625196817855393407896633655975124730683842916268495164065502043203437031707489979618651602416 +4877537573726160052953215845080536556910640218250727320033197474127755187683283945624270057808449225177808596236183681916214308 +6307674309759482316304083895463219733480617515657742063182272951154632706337489064696789783685482205360435876431996285794642684 +8643739931017169670588941204387320679922643218218094561807636190505893287798227669018730741719908408353128973453099243266062517 +9595878873331613803340153742041195527735780444717553915355354609332848505998881213100337678158719821578770031967558080136888152 +9826258075448305567391906666815695574763625260042694682673443923778013491658161518721464450500242508138338760627120693213553580 +5553946281220024617384962807582191448987025563460515052097885240434443584003120884005027893320006209592895012188176773812824397 +5351207991648894581591662853877103686069327469518295438143903554689747912914341445196157967066587607931175822601224101946313543 +4718020971952950496510335972370616351651238578779144226177776993578212091520634237018822715136461197024637982739115303152147863 +9502456279815158271330961578383078627663170821879138142148906444928946168505151984176109046790336568113096829851051335078064246 +6953240969636903319954311768057533966261755313567448194782711138760563765547507739230406557393058730942539222575666804143511119 +2069936646276438376676948110321617772893399556260252358509335079746651069969820285929369016951090713864814429938558082689945968 +1521371174145731236232976467624651809029170086344894245707746268123154057519935873219521049882236870962226595226944947282873198 +7819821085451992801895188229558460134173236266804505398682944828070031878272264470195089873005628963880175293100970223151449714 +5581893838568192200692899357118035029378571475716773858918510887575125236858310172913692992079179964473799145336381338174573764 +4769245956084317711076182507252518842194925936437279722455907758875435914157274173921143663890367325067229935879996805150485626 +3134946076248319258593699700301770098983689499295660906642311982752703674969335911328913636983282731424392564971128071529792186 +4653454953851844259383149899336223085116998954459207141602572224661191223836954928657358541085552778110770329785385935394034672 +1848527104180913477755119395683294511819189869818050532796513348646616780772576901429766012659310230873210004958312011164035296 +2958092156871189322732011639055425235756904126336215793291675441374713359747361020499385226744232860514052551561041374928704972 +2212834863497329670476581032210400927271310708293108228424935554688407632484416285274174812931270321948680850009808218617859705 +5759858970411718249018834966145654061840913712087092866138009251429104683711023685469060131756225674409696442152891897372343886 +9744590632172501257249804338242668855862458498369585009073080663432870189779358421204658237236159348444067179731646552147785093 +1487302286960634890703793800583916358993694233181958170067964772301899115902690629049952516027344747956086526751455372742400915 +8338876525824289493587802849949027999302785007312125533604872964433845704867828931952315117389601715858805797176205231916978863 +9771708561966315440823738672686475996359300091791133612159610896088743156170335643885163215910168604808694162494306049091846493 +4260246980990607411798428730055796631495823134395302589335824515261468702425017396399121744052394058025204383900792732372609031 +9971700068769073722960546542881880186840993544233005529300285659415785115249158554970710339057479784757811267863305208596232681 +2366740530644754206054437467535946438364093779279894170145358386159026725061074970741778654202207224942319105808241561149108640 +2131299570746273126264570482316141085118510380774029845237350007337531371596475771574171940133305454244596824947855809667756017 +5149174518393308544163272712602730988826876495407743839625377436405836969824290538418225557277170446225596736304939253815552458 +4121823510749511107366436348094783330267428964699228112245771169272372131739184081655990835742337126629817378548166241761588650 +7681892302838328396599913751062470874471102029977403036886581893796472818466025775981658918091981433719370508505357431231485600 +4066251794397726082230815863792863498887502338665772599923859722198014368910671442996024261604600584351270667582157099044750647 +2453319243126941865196218141928398513931210505017908632678271906294188175528244273588712226403525451579574075491526959814201424 +2165992720884571403675858895697135732268260556618466022757708781513389984131289376166641651464163701439701648503883511692095752 +0809953098069693344801057772787094818934098518685172639722513866511171301116371082267224802273430384579466957516125344869179896 +5481982401939122614289521472353637017126771394148320518526784723238206085981641590886685015768028048372274104457267692145673344 +2306442226244080959840391166046824665212018683995806330612693877379188175903847065416666586796553782166003940513860649019698449 +7839622245401117642004314710277578314230150041129278793586315748881510113272583096733556513373523207978534603403670731996254473 +8688617881383905361473235374450468814839809922748795968256897565635364988983320676159901781893744135189821124712699202769736139 +4654535121453878305432208653573696687720659331945282280482164376466643366264403854440410004602377849435849425047260830549050573 +5901354141130553186089991532215523080159611047438619487077531580624462005235622602720033994742060589665151566143947383285531360 +4404189049080879563477017517544794830939312853525609682809863259313640891722874703005379977055110211171023836236430564193209703 +7229494566794585131912570254848123871703487763830158261455284479338860024826943524410960337002804517176829321597236274083343832 +3895863444104818475102160062282466733057017625695711453552783055209411033854956586687106898952724582542873871156820426292736090 +8900114835631317986947314833806014993742344316565623294563018259706162592235301529753004421871816938486470617127313453996556895 +0571759514976034692556387423658377978720336611483511537576020419517170544073326612329641870061597096528288442406290336718658618 +5351965547349291678130305501394296379111242594063885471825143788366715324130022316640730177505334429253870301505302005277723169 +3916717817342560503418340716556896773392571317597234277462755462162266315055085507027881148045053452399408688937434362014420860 +1395787899840181514485743703752177228078579014380638280483962491760489212783979634460850686798659390084425828810746413759168217 +2135670387347630269927889910568863392759999570308499518950101510541542088393000686133918165399672601047703855590903413630319231 +5402756885639965603367270976348755948712799599490635951531639604227412641095043036804481527401401591963544493042050777198305908 +8529853370862945970036024025436607369800687358272778049961830381455619066198750162208786259673987188349784621840620855238037708 +0287160171661419657676846666977667625410411272514035315874978763125830094141664498713238305106795904657260444752711842879767089 +2429466318667908141926838367968922957966923427083942277132655834855250930739506120606993470384477050842837546690187842884625651 +0859078343456062742869073421013869747003592646292364644445549193378529859368317830004107789688729965524376290149979489394466571 +8035239664854439337661491633430612363668270550373199092404545748888325504908156365529288450637845828980854077097067322982777549 +3141023341289995552305686646515529412648513395018325323202158482204644747543553961230472458295893311161675174437937559470576749 +0847147233703839410907356117466248368234947493218430919253855840473886381053247491509943700747999091387943188137392889875056078 +9027561924408681103294230082697546064172946790782404069187548612190839473120786175725940158419889526634026805571973842865999326 +0264435567708660940819192568711718952454625290701063992984178907184987617554072919582117061061638475508286749372288750484810591 +3758876219081855315432362136232140221117526750802434000370402808679995451358803624973049460963970344708478212627401394392324314 +0737438132749076462394577606428117744360361527711020670066707010174337101948368515240770186600234895342764130573542724774509423 +9073624026312594849755836859839861773390790206872160912057185754009883091290659157623485315161215679742322663821620022079418138 +9512292856680689427009039672717710424584681275009917377139164236516131951125126982668253717705356666975977684408510117347264524 +1614244135791303269397434529358056292497647554306953362312956458703923199969180084694524758403500654442416064508250070732846804 +2519174085201627296034372830011366838603028175377849633378995386798621551863828217907888881997187873208215147973680227021049086 +1003834843003895903348617625671797354229539053440753237068065646834526921585552402882071062806329627104734866652786788079565348 +9629790405359972301542148043545627855421437234097522244411526361848299030888697549739412058687417924390455152178947938956747613 +1220334555078453153775416863741025226449115088431256895031662080047877074330240958104951191074477627437218425259277775462127879 +5330046177874455391020429152325102772616525806909792370732670726443060748075990477694277944732782581654693994482617923050984272 +3673634429035216620140695806733909073383802026068407079504394523147664262305135669486209989893714484828370038683949845972371071 +3708115456116104837959577481370904415573625213784335620684326306607428751455492651914598239687297810388689807875911114963544682 +6275078866641136241403805509431449819259498303907303571719921144438991991012377399643498948247855847742996423485083104296357966 +4819771171509939007698439213480827086866218725106376148904562704537146213203839362150271333692094168029380425896012121918182027 +2363813324380838896838697582331955348538206296702138518105826516120031079298034769024454364560040544650658193748994518844922761 +3584004325313624962617797426518359904557846265454464840046448902633251444504148633006804302389871871448461320891471777760471406 +7015140209188781023966520963877943044151556490498938297548114159848752913311985584190436463500622710986698476383835553548754022 +1839528400463687701674829536257273749291910270980698644016289075485436646251865330303505791679775487148849253452040305315948402 +3145765566550173415234672570838174821210069239627979798684879235063388281638855085067234894023172727303768990495108093511731814 +1483336663514861984292197260930161194717688304395281475857151745194230301582456092278030099203677396095385627051965960418965869 +2854504524032911241727059077016541586716790096641727786446371669834231656716324311341476302384390592511402123780357675520817756 +1896892000036214095213174483595939108751482199845439848320000109938495152786801921343185996467957081886861283697079441114823751 +1013835470696140967938560803552257866025556771879993212750495494783316985507407134125075415195171213975980403552113090097922014 +7515529295471634503543767654884408021479006972212507337901526368761975637401627838535557010674676502841359449244736451534979277 +6386148785910089568558317754358991974549956833481352102962872492406026696207774586778061183616357702706148878186924821100084521 +0786007793408177523760641643227040330556706874975301831960943949711205745890553620154847773954039608277686547389729917607939287 +6601065186724585869718286730900507361468222773067014813540248318802263981782312642062065066278538284353552795463948608367617264 +8710458632884006689061619016115234211820116439477889276589203755014121466655765492211482958675286327074722685854832241409593748 +9721061962175462432000129864627652688757814948302475172688435098625740068901878583888711851475071264973226898929358873311316683 +4174366427344989068552152924708427538956427143878190827546384412926545762544478791156448578168011030464548344644597978114749995 +7360922452061081711320164728509310349083463549987726136205083770590452623618881507969241810844776231293351721107321616807591790 +2550845118266461695500217220306235111000226441822451555820123914245682646337932826709632824811050296875427929721177340139400066 +0537242786569134793043366211458572528023713869510543400208763370329672141795438795279424345734151680580842314157723144187850297 +3691971167907808375655388036762185591921761050859435693988855587355710680373549562866421201047569372572737260475884900803372055 +1007691946206878968978529598838997374929069152901229662680626003917658157134099448777326028788327501120348629153653344792265032 +6789665338488546383152814125714262232923477122140534949024472459646083579525928155625268840134301323030935772657800235228310313 +4868298684968408834649240926318299142611007662477773878693177513443928825272512719998804017438032952107625783388477428012876908 +4309202213419885445857524725380221565049288409243087159437144931986513177158450201360308556789291053726105045930369784581421376 +4918602058560708246713982614793257938660065153424340512931090185661823200932451770267967499779255156975310512692435013776152000 +1110183674703280644653992907629380068789930715341891132020648458097673681456412608084277373854376969813158591776142390000280900 +0445144418946628205657456424237128264942955311965086380583598212294732021966933151948426543613378750502788733253601313302851775 +2374366628960975291734051077636704217339955444337088817734748627762386830985963672836557693273405067738105684469127912825361938 +2027506449534260776940737096467772483868296281393345078755987162674894542324936567113913899614190563606092238595769318736510014 +4601609459626193748838141934701193459914056226332390088463312165368986927729066528661188656389710831973546586554245180984726395 +8820641417137341791284188339243013012221967809583302454529489453970560570507033795822714618813232104921926392983794422966946716 +0917599289793082450351085959141123440985146982836878988204562375158569611940037966919396385952791842444219407364739497415459949 +9477416265026706394163032606799526520617258416558453349947010427060666346412817629143427886670549081801335758913070396959720115 +0666704035859146354165211453275694040361967505403921624893044875089069215309652369723945012113209887458307287755360555234673115 +0255440161315757825615697585801039525106439960924827488627325282298838888854341592966844608858745754258454784788330547612148950 +0874980077738428750262349348089941932765130462263947980854368723919615602845763694707934084120416138718231554631967803081258409 +8981164868907222146030105839525610946849494940635627162577865021292617220051659027789888586435753051650333546661672096178778980 +2620946901150871449077949420947077759285135192780733116251997439655441528374111538899479815498280668657556929167956071921060805 +9030260608320606358567118378046750979991657572292125217943471649264668431650823749458443029769965695844134676138947512285494656 +7911546964476705302214543959264572361084543166660831362636246720337948370592526588629297565497381903059061404007654352003582699 +8922075574627020723499343655693848239182605712427393497956424335482790840429881008002039906918138130808630673506435738463196394 +1030007563952008786387120762737476786971644512140825923263748032598127575949995761019498818566016398257609354069772389656925099 +4044422726596923902940860834745051450250943536191821985629944194928632102239101274072099618807513448554296724965250996986364924 +2354577685813636309146827729776859816069210424412883327405297035176569137490665953223528983078628177275666747947529655966331575 +5477299131598928984485290428357889109417137134680518227595002407302611193611761790018230013945563583265000510580955975339191446 +1619521324601562573756521193045609645344126519940152032470378539517720502293336186421186366939997498341179560168270447355950110 +4230306307869293075421899272149696843537151044956328729562855283491975528896006550623263787552206307775364239158496535813468780 +1611641802461249957884380478543784809385839965522996094364642447223105495756896318541934272292804367584843894271046287233761298 +1709756805199283313621618096481348781674012787506990084789188511001769795898381723775624988249883268986469361054705514036409475 +4042054305280705588082843156563390558519428096353822906407664058875561059644605482196547535261726903242582076817607377960964154 +4253860999746516433043460107715275174182573491654972680242324213294530205657678192111601960601634649905585928529798955700154076 +6676179068384501343541631038132044675296273720164020679619589492139981245074167783663095317254579357724910508792547067262588017 +6293884180622784793929874980896521285454501177558249542530377203281315652064795385736617567836645686619617679168909645709168097 +7743521550856066318163410468235782415369091035062393314878499152138458241235674642599783367386177248502506902767835896501146443 +0483794093371674252980588779386498050198274197464907995529503130294921702208337296889908183028360175355797035085155032755797134 +7360019231801705667141478490298073274830800662389220682649304818227754575701335947775670426238672520023046096705399683924718657 +1560373958818879850684156471739380073353650802319300382801718291634025935869130174150899754981641558303334317282125650661935271 +5092493350585336373714086054348812631829949972662091014907535609939068169965945723736778889287001972766703372105697934518100296 +4734257102525392916687039288087104774233931626636454683584533774360103845888157407165794111547584642769928525653912147278806542 +8822290823497972283964354496248019949369662678090787983018405519062148805449317563743875081526769207312318307346979280704726453 +8280283626279949899078861531461602097441638970306234787225062938541682486544091938804453769368426982357391305981842832099966845 +2217356720554468128605404764499852161966456502338368106620715847133295711653095826628517163144372167241765382757784888551945323 +3293984824292108860635484259719926152739335450946748798660592468126259449417195090268999500256639254414418461654750409028017288 +1675306289991237206693384004427250238261655808453706438418460194044272886240166511333039026240609926117492662156547022216935277 +3798683710262055280473341604637975853707715733359848491914615475081846941708688479067522988710484836724298291195075742855018190 +4581874216800089134728449476207100847781237572690983431502108191722970308605570690039979318708286697553630513952137757229594209 +9413803628857147469961583711007745023208883952507321209502032469098964348049914806057645578293300641835023243516073565578336233 +3421265017714445796604621284137835957308268098924387669789495349357687107880833828961898545436375036341306978848338980923182467 +9343222636188028392447876071807038373006670961664292112334770077234449906744690005047749541517081971030139237186089097495754677 +3197112368581263984569948101844452284212008325999133835851189833940770803601768180655910037983634430639371254776873860967944989 +7762428156063656052457140048976461668407455298961839410706956245596539166362271685772723545123147978715000469199290892122691240 +4878440976953031234401260269958754462435834653516282136155912652234992770322924693740152133726104201502258366755195941397981349 +5410566039278422394352444668313290032035427902945347706947962717669034134093986739640503933965401015646443482046077453432046184 +4739388878693555231586220110918786353416678121114400297535390976972658914130824675010539898056712966138526147925359029678913230 +5886358316255011245098615464017615182438190446564591019394412368509357681569397482568515821423340665852760995420364289038278484 +6311541503127681976206070117236931568310981280275285971795790489631417369196648946460067342315632515195328396495936094906795027 +8224055001487992245066819015245704964683485501844381492046566836373072408682020849321689488337660828971885175876650163928646965 +0254578793821590283140178222280457619069765363934967602749676534057099985483967828656474230988014165618526645571684624945648693 +0109665916508637725280874977575865530242997110923401414431409335639376452646452851515568924163798404754643876369338378812431753 +1218315801760060263870530314784967603071899867258461326183988209146000243519324558810891158838383484826158948667409186010480817 +7903203377696988414945216232421892536173370183150633896237853253925354364816894136252089105545529048726749085139508534886223860 +8148078797101770523716078377874332667044042558325146665083596936734559299430024125955358519934955785765198216278595449870598677 +1116539363983086722722201448783346777178486858969772190694450961667734803002682120934093453206868817575132463247817949468716367 +1637275206589839665316460804048412011573846372603155744795091025936193454883889805228527990919468358500076576823231506244498699 +0027621847956067398935694606560509614067216464874695482321462823676120479915649013012054108931749591716879497574932046754706928 +4550965358813639986179681154209780873107404530149950214180601478806568724333935291072801881538682786052141302073521529721130768 +1636835808005913985865949033373364692120504151732972595493618693947796782831116462924175961942781719381911750675622713009187832 +8144555119970713260660826605512619993205968791014438812251863090080817574324870955751027471809521051989383021792494139844493682 +1585931821612292754292414253292528827165768965683611240737666722015320896218326640019860760530517054982970340862863680710846055 +6536681595996347954437568694119184759342070677456835801973881107420392523103849305532249049602562479138323295711575175876515640 +3486443061013741439479986438866229511864021882422370923187276377158037668029544320414759066219016776345013936686773434186071692 +8652668214037751054395752355562459984977103091936105931037362668574357365575540736744748684242434859190554622399068882473374610 +8580093375714553964201167764812992676992679093090175449230495342109288752328986692009639151993677096258635370756684860954291469 +9964866699458956436463452444822527184213143978744043079921280767307287341419726065990023057954791661193301961189038570454182768 +5099791381798674690627429376704901489902412978407791536768610182213492340739402802196624950327768967894658802241237435134810216 +2644824029820305111520479567245295948221720974051912855629977767969256584700072624737697630748957013069006968156707232150642177 +4694014156265815259320275858444952794733981468869946419687206201356067556770447737925027827372686022309398793525531551762030508 +0692322520193661664579545021783669513925271024381519716157761278129858733071273401229450196329877841294994307214799190419756421 +2529925924690763185785959066401191385349387731434107358942442763904987402826148766868356311114428295259838898928666272489020921 +2079494677073945124622995106365273958525412410850501502163733379133554803716983972906533166904636077433873959124786425510691812 +5600448283577862312179623155268824754692832396408303848264207707120544301021495705368104362648456117090809527815889327217546635 +2343977389207774815138566905589371213682572216665369482458860895527700507201800331270809726620829481769123927780354816652809008 +3857604203317914309286408408516621032904248756858927009945259813983765983907916658284682954733130678932128039594166445571290526 +7783506576165023166951251072092917407173251744876214934915430447355544209919802690055207660666887916247859978935839016078615261 +7480703460843227445195199879222716960672528809567298037159358077924188280933697924269515298429095424116709060884750185401083226 +8717064476124069485152260308142874514219920880901182710267169211713742088964956637523570820108183570127357202528608391772392065 +0183762641286324428853776063863402233453633712505217167155150999046272831538702513532943824820006210590058738974696140094824531 +9112496681140545311761452054846654072950289614507391281868179377997604366151409215985425553727631766796511079991043874131555557 +4848466672408480575274846878733482332783913190570793476048801496992752228173129813319287139570412963303092066006377899503587208 +2004264846825219154033402067536124920004600149381068226608766267724446119288301005499297409144197426544971420258082942394022997 +0140320078386067723015618497818762945156815014583969278200840575341177014900417018827299383394638626203285185921061940008032865 +5962478195492396384491797383201234602669716423445444477699550016949258636112731978273213688262995924599283114955724957765374843 +8311990015515249068920407871121923281094596878515199867380540740586492915851905851867276732161963585489156521545932776243150499 +4592710682075197276504754152068206668838563346968654451648904363538719952128821973082368544846718432978965867108316589932428817 +3552163482893373255049569753046229304178905562057146740570805257427023711941189943044300807285165026750415508222049580394911287 +4596021173135544782173915901528349195173147664807647330846216356295629295015969380040305219923049284417801673254103299322068397 +3943524404368165203936926893260166313850279802117822440456770151714171409778904837544726372346574716859663114202887576413543801 +2969116285326615235890680734637608834483184611588075027596448992877129841445196831709848480423954210927050978003235143506132046 +0153071245386120635128957595884412738484038627307517440237760302728984006580096280602129668935036883924996553872412205753013658 +5621357475787817996023091217050008449865559719579810787563038126520104376758261418798236153692393962370203265309058313384060120 +5031974571476436448786217419749048851015183003367752606459920605017140928435866977820091890996541266633748940714886983142086133 +4562696779266374687250665129144508120768763103068669726719903362264420017240549417302081941962780048493798236161080017811934325 +4744441027688831600256636793504579543928756869184371127623452884135869811364793667736493944686083992892480103958881983194171487 +3993112528998853349337977120649249691278774025202103634228484270608254195748299845801769708524194520077695532568068092195962254 +2329576931503118880223192095103946522402558163495818627264589763485690044385772668639064805859345298816707780560479994433943363 +3218849814933855133187785331003935806771232881004238706522431511966088657254108552621744793383328388740747036182217129765309790 +7924052825089429554499360417535494167874442982520963688982831955472793462543386236218475310833559387701937594241052466519691317 +3120730387098471204669336934308519377296835486747153400369971745719675185172869103202802955453713945706425356726081359191431362 +5436861304614177525957519069526164638577548380287496823470807113570761415650401959363470580496567502232543408020661206474053266 +3120249944908567907826123413136257067078494146549111473184473022022655595636232845880738387277254397911665634549126629364411401 +4035843002062617386757564723259476788690970258752656414372739557004284974159497458955655696811845766981760932359601002427208626 +0779143969819344348002577455948300927630939121921547040685880544649850641595729872650264658050333293212488609440422250520307515 +1460705203029148369614787086632962281691805758071437499284040866802949156450922963941143029043912074471289441815938231327288667 +1549240739672667607945860219999638499322190035348564953406860715951588472937396572245559080251322668950418605324345241657646723 +6681600989234088565629106267156100053645378516406056877177467623317919074902879430656553383602319342476881970725454244483233156 +0192568263169645194866570376494013537343370202553601755904593727729559768993904298684689230055250228064310566719259142616384584 +2226698070135175270997371657677443976168753242911675302780266617573092075405498205119010526964247236701457645067756244640039560 +2411523124866541301070099168413071292074360672744530325093983003307829914552999628543032410966968534244029432252498124255869721 +2032148958117324274615176859919802414958436537913396718375158773684001583339324493639015775574550405787223527127839505198335838 +7873829779466960857655228261450384972633464601331098096364008012962199690499598210503782863578580915221775299630382906076523471 +1033617798236208613493443460691499481184470043787180389655899698166528830636916915480716417683921961582857940369278335021557721 +3570877773431086041166388678403654768190776468384892784896107473099172280071916265352211077124176187206981633533447143541466428 +9162337956051462461244081308639454192982414597589520706270659960902459420484545944118766172576927213645046647438580806130370976 +1679386001024741318115842266812215689927333532837813069949968390429571894735964678235628716093113797167330012932695772923859921 +8804168783787089493714870963570663419696958001331927763315516123670935571014222651056237882407840332672169785104960709919825245 +0497455776366854139775882322268590872937081090128717394425875756408043314452495438785765312873239203328867278937236653265323056 +6042409906538241575209979144212026252259767618647784026916367882392586982801406891358315499203056053321982052638011533498889270 +5665573721287635790869699668106163302621832934471963587290594671222971786422361537494624465628017639194877871599798228379718225 +7432584741479817366719910925645646541846360875945358928938495570674893693392242341873215005147647843928108951666723535877703443 +9626429137239096178611195842928172193314671253797016055524388530347610194243157336306488458466944807366840872517364192307199510 +8872554743012955139567705170988677634651238832225827058388116110755496007697973600003490415480515644505946637930188314840631970 +3992491991103767989877164315291928453885661238942961179632807297112992978760631966972677658662459086278724019257889314597469958 +6669007755891601840756776309575869340114031142955328946684465711503263349456097268207290469828978418533272473362080110971119500 +8033630970428066315841260643530102154382783569132687157611513276699429626479061706898110708339849619210276811595853043955446869 +9768070537230217029438684537825935225327148348372819431279340284261370618005491965480298943126300044774337991256135794900355667 +3657498279192720768668603975934793465689868735015232170607621866439453389115795388712792645934981304662545764256708338815562273 +4841652997648921227154354900004136760485517640549167386012657306424618486993618255961405066483542868908453734101505226047480448 +4390654153631921147807124887078770782524389315313338172327932505555766712042126014521672948387933863420403298182271156860089870 +3083699675349781049946715849913203260143681249018875435801318149856990157414011015651215483550403032096067120964528627647289771 +8136660832504574374548878451558509361941048418373428464399511971079202695299106137651197289051575362091446283996841312766684810 +3676236989934685487277460614965631287879882167402767160319121856718994264197563392677953816932994293095294646864998371569945650 +3049112960977618674809680978004704430920799039334511606915199457270782728770389854739859266964607398443304578468934206463864162 +4020319901840360451062762075624924661391286802372025413278593393390727656336661248466535685907382226627976102440776444559861524 +0166268182450996578449973258577137477283861283683233635300267518223499975003192269667287508860009509128730943175015750710725727 +1027094337033962463834235326303117245639527702316027545974140882034976571260270032549979726479017186330571896766878727628563084 +3735720519280562035416027535373646170800608954405500868661244053278717672230128154298018261865339340499855937060742071802179228 +4620909442780453001381207438741771581539126274686674694429903202199824281873555557550181182902700089108021432193493732079872184 +9458342180011256500005493355500078007350011604607303307732963471459637499551951642174991940916434214889720629725398539493831562 +1757418742866953045608344774690257090125548479597625280633090790836185148048976878560947512134108931123436802430288121604450838 +3439908217353866705662826605127180864607977834354266960510252404933627640585873170058624018410480482791416937234522273135497031 +2172788248827330880258621512418568877495834091216163584166603056260778255791670347944634914745463656259805211952460022859276063 +7062821874356395565274839950114991325558841496177484931811683058289009845398038339874364587482418953564120109998982642304471400 +3698346712015383293895452263862425925615594845734737899372976339855075694671913339207356770288208509103055437248670557197975416 +5731723926926739876475885511154531945948200793682997616742493659519964588297814245753251250515716831733713917292045440536017047 +2326213034490494256432217527368652272393723129996987975280491971552239548286262875444742346718137588580994530639159848308302488 +9664053981063208567695237243202681506536792559295775868533828506782791916794818915656227027388965683683700700077078525885858163 +5667625010472277345606381058073451841188387271842197689932469281333817846476853011214737420944488058943262260113307982047560323 +0376867635943376210756229949512175221086640268169558374511241311647850185329038766762763270981601390818540680562189733654333764 +4491518223112590691196826611428935302844272864063278173063473168207705976253698032183297470010465109985370388667131449602003018 +8802699827748011182168113988637297474486522040228085650948530427329245143454181410142916723537434758973564869412497956238710891 +0653015424586307910784932154517633495234468902775642895621562573878654050393509111804824221865060266482583193591594511748836623 +4094703884414114132180304529532880233548615595688135936066808466092184620343793991343848249436804401054149903884653644876865628 +2718370374189505315521628763517179672356494682994180239553818915110898807872150301279550476267769560111595428023012737770277809 +0983429088572418894311039932871928790123994971756838750348015397853262244219489154464202472581023076365814977799205726076421849 +2244581657719291754700709306659618001196719303854922152332583798578459941542447742263613733064435246505660395020395510382351759 +2371191845917148718985406337649548363315059193935226677398831831786300690640380203874437098924585872141781137278459673035181084 +6868095538827304671263059227883616117642085424440799227282508929248920781388666797060697845611588551792908329555898460456707821 +1192043306305230972108032344493739345654505538181410336224627870081996078504793311999388842368948858806146981869977786056189228 +1263564157432629856155576816827336520937607635620996781728277895852539790604285849253279394716497232033008275892868545867382681 +2337190119883945387644191032300914026172189976929618448527119917727894462635110227775485639758673866947701176216601761844984677 +1541725580846818676211322948610609824222332361334426723507920844056410476870968277509960759021044456134551342168799278225221031 +5808026746515835625867232790523509089624770846326913802756163972740615072842822135746471264238978131846218179577994033108366459 +7209194492748333961784669338759539252535168061991620450390411453076684475148292681430958283119646863377618784660018401847206388 +8164592842234101218973444204368622348477154717654721601252474279965258123105673927507866232148031414671644959483263113289777725 +9536506697075295060127905565119738004002490249111193299408907722018709064690369235720344207608369516256550493184611556526526774 +4560017960261564009218990204461419858845480963206874732488142599183336196461705771053123771553268404282868440226650446328616213 +0784979620602852570679351917990832385632423349482355239911158425540111723754138128518596135522138872178079847769857439148437200 +3065506422221326046922349934844525141835749289303921189806839691414799095653902814723672937020068076690809012734952484971091424 +7531639556490305149862508189711238391327019426642515502558468392326082589336113833462268524671249515158066960751008937821736410 +6252414527138677204351141055246475557495876614593229376289610072418141564580640343324426668169327302426458833085549654617933468 +8091658367794443766667336494599463493723421496560610375457662742614878721712215614199388402972271203457264117746009414601292472 +4908066830822438120188614160836549308604180994779262747990121233555704249867768081188552478880193430879502515548138613493765732 +5079293880539371206967935767115987717076965982796395512686484284292191272158775216705810765026584234552773076439527278292069704 +5164216628992440501162199298685532131413675395537593848742057924552014924010292705113677909421661221880801679108009584398377793 +4121418969859257717214261444608216079650826208617995799712962734646420115576080668425510442736110574190180643945326397724337600 +9884581544962427545759780318699856274991305713483502351242287264905051143111943618139482715140793163760250713362251924403750737 +5001181429052612807248790060512136898354370778167327719757330132811615985502470639866207141577372460429670627788129417134404406 +6178770653157619944192283152223652702640541977712224400210339303510432403323032560310805508239002669348396267104479169736023331 +1565506146888751623012576320991779119855864177643274705087893960131150916233068282254723459661688282729513190349028463435804527 +6845488200397241399013882436401994250911820745822241059508913459645459567274421896167243282273985655453126249904632199335837792 +6040683797579452107027216845343063524780614029426886935760791257030864245182939630838108471908303610357161096840181118609152193 +5867358422344899058837359139467062379239965703229659786120062948805736192330007221916713426793575162507137089954539396331620247 +9120519760679588392286105798236021559061854045122019266108300186277736886734969411204978788065566311792204801446141473355188648 +9729762487738362702158800023376627553944314549674371461896299198497056817939283617350417487984379973531521250384859390378780952 +5278728682099899168824382639886768910340224230494671557124611921288793461227571446099109231672351187529971910075105296077357641 +1730149007222759960804235202582288759192771252526372328644840575023003569331571124411309306137954892577214909905859437364845514 +6359722384817229880817656694157685568966235098606153131789136445509767178564237103959982917552413501317717319150118113725281168 +8331881891680259180368288807257087972744816443005083134263401722243486734946708091896751081947017218318643507133088446490502898 +1564672123742228001093857696640500357335628593848961899541997547484403147074041514838330205353223636545525633021798226061157975 +7577934224848992516208537526305362086756191009198436224096722971843979917310448903629548517759776409320845391838217575441202030 +5842023675100545856824292093806577194777854067803726567456782139496624136800515010149246416535077787552986449619329516458032493 +0373167808153255052885634740314278397690578953752487856466779556596486994777425942109945709709335720717497273570846620327341193 +5952530704523306889233492671665454303269886039975987299656234612350738474857467451882170147036566336312226535534145167519693735 +9607859559588540690534618223279700864577721437927651039992456828233467681820892987538385235563873550538138831743319323285816092 +1624406727909111147099641441681559414299104318980440722709754783222151032344202663364762643657625463452804121615256537142718557 +4340315496406729909696728430969897055002939519672286841554008064322610667892226345008617230358420658804502966997298469146129669 +0210625023915241926959138868143886129423564883883556915150345946486026490910420790564346970440390087533686122782420012907572301 +4721491005031549006749404748103949153294842924575427991607317267682247725581223721840333859898813958860082395329629494670433269 +8089333321693829301610669436388430107322213493559809633043551047784093889175488034859221042528763690657356439399119706918708269 +0081737607011167672164816311361636636595718748621290008823635691873373600228901339494989909273621908199424676593460415730887285 +4160520455923507310701763781457568843470746581847988497318956296776248312754405407533119008905656107514741346097573287623338123 +5386718227154603611476662828982111704301478482540378612558078862521675877095588029121004214011721936617184276464093409939658461 +1979208081789258362592059412017416272899419903367802069424612928998858612300695288310086571610845555893261171864325093713786916 +7319139333841813731995304531194319105663469219744020376897814143833856662869242932535917521586466923358318419175396557400347006 +5043921771833079685531325825310432807800223715751775658072562091646020835717475241682115604301178255769370561929846716138929898 +5795009540103191080406839616053879828656176434583781287476876321448232920090228345539065457933826027880057345811966575002039185 +8576153060956850521311077608763009793771506275720974549550420722202837108735329754654396372138014747847396055096136010954168085 +0509043015950572569270166347532451603412568949379675617083809175396443490772874366901432037667793377607725671409709046037414839 +5757807520296047868933446233650750653295440658940733452331643306076758589809542688132352958487696630197185077693771148210415488 +3493366273573202706880963127674882710949035853748406509260478202136097703296547394474710548706092731416204930859887260446245253 +1707539941222225775800658254639655291940922607284340086831234164821348634212665200587884346716985605251686416602230060503804746 +7119373075229566064030462457605177717171013246215489918839015056056006164706313041702800263980277171617607329962257981016326162 +6663813052725497188713444974040320318581428866821251405183260930030389032259911879414867761739508256774997369921307923003380224 +8543233997255243697045277479565692227756699494957952164631865806868110331658332715068585534381871375140656787606232565908699795 +1127161017080656837915924804407883971278108801828959672411183897706979458144168384325785293840525608900932906069101189576035960 +7746884054099676741518894156142307630763897600710799726835033615686726465390861737711082117067758069961050536090277623500309130 +5637631551447663652036022243883777403508274485804348060822361386569981574710776219228289288499523332852532323527986372935987772 +4799128874055082677319044677884361786887526377254867769810507962743180135340211433750487850964619355570684078365963703331785531 +0073682589254914802156389462761084682583678912826358978335933715271645287806405047356166648799977142475160038979372628423949010 +5037559719886724670132444119093240447382541873564218599313650731701908225623880448841585926824993839038111972019595929993742491 +3846935441857871521862191302228658206156991884533871767438656661539104499878809823997230034119838267962065754111334791148146756 +1506245754838722163589450414720903186576980445131544657545019758753225527419416112605350003805887953770147934624442363883801265 +7711965724693431682894274811945992120534708309601562503539815868676726704850890815034768784240539682384600476706665486329906626 +5956050270087533659778978762952993742209890928275529257391035690977242967921950083594415755279086778292240063613624273000623384 +5061387982251874414971585573609892535056862802605728035065909921406395624271235709374930413322182966464210152496167481038893673 +7793264955081367428964822852138933334974506780923885826935088471472828950440677885279984646325294353993045156334916727728658382 +1917731844388737433964393775321834810791126648863902100900130682254900663770885502300591056044829585219310561565900983432788348 +3993621103753371559559083065225969001381490024230870158740460349214225265354617541796726739208926003200650331011617584531364466 +6446975200293349558151403162258385505474942322796455463090381985898884153879810666921247678344495019592171989327800934238087607 +1116773012813841761179870425820266292137052144431441290909627977940969824030291459806507439794936788928214828707352139273391574 +6029232735235425403035383736905446200540026716844974571516139411975848154720481565143793111521425975198184192780712740114138327 +3438200310045736349450654856319455355471806503450945057852390828051199118282010495739738213447341204668213941183921897766832892 +9512957847613586351781261772535091586107882959218997758350989715296118346024725200133884012765597340862400507624462524830866480 +9478843365776113648646455826476363854336443473601804016310466451767185956320296981753166811182992550179769973329037834636002638 +1745421142947154461000688129964181745046963595109768527672990383210124171587972151958957748633651595231193536560491908213623383 +8381825139460307549572877031135183947681591383140425137518397676071788098018785187454915609863724531998066262732015118963304139 +9818630925621801216199389879103728134389152002296761687336537102178195168590959317811012194485775439363610537061412149495648268 +5576817033233193054333141148999572966012541792116109714940451926593836005748304065707002129553500879663495665687664101078961830 +4255249811578737819490016920102133439336759727576849642889727534022902117660385461887412305323198051682727105599743797538768483 +5664318936157823403995526721241574938566862585452228404066914834889748254113822291330168260243598542768358287033612921584775608 +0493408359374626915181620402845179233550927620380852963377274566085358451742815682206366209318504599243115355217504587070160767 +5099926458337087971802835525020183140934847289656680603935783200084783016975906879446974951582977123093907468193624294378414602 +4993211036037539293757401608261712055642333911428904305517543773653002323722539705273891988338327482438288308063770111207012273 +8875724448927612453412899117913683062983270974383158999932195926949387111141855398745328636343443301765332909049991525667183004 +6179446485196106673286301271613059516541037127280321853066460858041150601008945716021915010720764523897185471929927560029444239 +7849437984569538042541347312104898444874295714765888754190517892771505925662567504469022216257045253341087785885957187833718309 +9972288762936380366686950714951282499790474803745721728891585856096753079311064364081796195123806475478622506713826868777638697 +5194143783169339034131894869316961917794611019135131983101366014715857076410377619181633332553598229324447853163042312520962414 +7850854551539305001687198329060780010579189214774936469033426991594801002823836027328068965959941131816419243666581830678041716 +2062179831972241107526467338284038440066567441767013516710832064119073030278681905009991848241324570216334414105094116172288746 +4795251857046503954973485018229646234695366724410250031504983138843493652944866619750102836093665932368212191653037534272918686 +1825362974498797050137125577095725107017850998954189361286965048355333973664280494182300562942448127524039989758648090694962142 +7512994410145549835156679857014752505125401506747737470958447208937721056830032278112608932324610937928836512547690813007773206 +4386958625254464154906642431853347789932184826155599439488217117827733831342079710541861559451261895702289359997911170346503767 +9160582845194443225222601665399912946931088757458941216770145834719498890068834370787508728005299127862046720974369218083539582 +4881031377785621947067985825999914746359269429111016243690638440462655472434228579718379181809439967478754245522265321625889814 +7583391301685587265357562950095622866121830355803288828241373074939869852539741493888550714334780322503664271906152272539287229 +3706056275918240737054417094100085374094932331005897520832184041773254725650156202489186855782648043533132404772816727073155235 +8593562217884076811451277453364735377701544569033315203869164836320799479709306444027657854268527295924524538225997862678112859 +4570537859634341717395527618756161556420569519217630387646444203036568601265546935410843254883517475649241288633895824882290087 +1279603976070610116464640212199310166444520867245963242449012132718994226744403248200981139871780434324112903659101791778621066 +8744850384566117283317344846157583437411072049976031321951124766354609384768681179440522110424899002915456603055956128713981139 +2086242661312485180876173221212851654741063402662853918748324706267356051777749583559232529239969008936507197332763290031477120 +5741215520375853751719868036345389495144698592395029595732821924732143612679143914116460149908254801423378398341400612840255578 +3112678009802694849286559093313827681147182296039209347542924704088172807791962585025279313952354773038812296501897230865202710 +2464335074070148432312036647984428094369519448454963043288725321796755075626414550577697084871002645789785381682654641241100283 +4946700365473689782081952042866282556327651210752194953923594323433725250140138447685850292340132652464859222629234697220377811 +4116813834263078090553178959891950239969717708797371397856902146227502290357214553371450093318491311749632101080525636146301695 +2152016442288947698443136330933042135184223974200115803798042702098262975256411368585240157169341361695851434355296732786801088 +9469700239580500443632308541309983452163906017765379912144038775472527920834490565234287360219977902823838503195349727039831496 +2028576502159755428471922748239092215954614499408923132851493814161260002491760119779606365853853991681827617094579573055586297 +3640678920108595929213187711839271941417061119448282180155978731064884982006841462863880420761509974612500984423805360525276222 +9057118337335912039094779552592972943649024122835147704439083152493402341167911887606112405528052285968546122798145084807566159 +4304613049097528789015322647077710992450848025235239429386820053371823148160964657760192249248892087179211556970604610852657330 +1245963067779593226119382101475675796217312455063935339967592594066075071514347181089457321147516518204553844378465193273590500 +3560863140415397624008978961463819965678362699058645101497391867248986869781266285523093686811424022579360460735505488281520907 +2803810314481228865478572362393166113955034570401397318410902932552817985751479490450351950758398971928389088057335245044158094 +6904347745025056517093981246275608711548205826384671869194152526627350920208727208140128575295910227390194690418706771705356517 +6784445719916791606648643520294851397681933118673503958741728387886357271190905065762821681465016058740202568162846967243295973 +1820495748778970925066926664077661706850366307799032827973753165199895444172414611070770446635902894354703969177838887030507999 +0792366480532040444153327711554056488308633552915589047332411364711058132183546270866868018652349880999177379420796287072716088 +2231884404962985945388134094475613555762253572694848559208422137166239633417739879274457716224035685193748560132590653034477542 +9227302311116220471908055555125965124068362598930072116668063472712158786276348904469695948132587468164071579543544049342283942 +9611661683770276849635190630772488322125598419492636769106569145188958898006930644639421498885045868655337164693651551682789719 +8113170194159795409724804157277970216585110875118496676005194638884485314135820103479833056690555003499859437927213123666961409 +6776248629614262117061005539488708741664752240716973399951870993215840911122617246729216135676971155075389185544568368200715006 +8136621653681348621828391620654330376833126244814473075974634681828022721817501734663865372891778488609175456672709780494092424 +7509035477896901683836806362847630551058479464889625032860924968434340014421918549778761662492676219077042005549667470710873708 +2649270641258444022173705146602820338815565069036316996296828717613516424116147690610506944602495068800321856748967379303431711 +5231537094318273489411666006633698888790246462698166129109823556983405782712006150780252324827311704109848150151626541203089319 +5293239066624699492800648051071066181862007268310279648019183315312315154420858012591159812489763989269552995744386956174038764 +5180720261104219765835445462051189983679962609760132661239453035110340712611783326617205712026077627868902275865901764502746369 +4450386186789754245435591998462910276602998139642701382886884245787698610667584456364442583085157908011542453439257529663938908 +5226947020891494666123742174916211157087031239651884379910014927950876644487562604700114503798045681730239237952766587287565756 +3462320891328376981719619778327669975981463699579856289946252639770341221258397441894692753073255239973756891174514808164393544 +9266128730309970612623389424292152551017956433451773715730990286170012828117563840968654996015507568606746254308032751484010172 +9555122523637838569715536561794279389081447703619598960381475663155959964617699927258813445644496349054324074619586132556815203 +5221901221258703935673357600398356681976947446424967337708716326590353253394660639230448040100077013280765926948098493319213488 +7738313289310543436800301466124075949448435224583670124694327098481119456888840896351512543815188557251685118660772588456625224 +6115002819234894874533900222654850689485882307323315708374429887345170183105778321445910604513739852020875884337203588872923125 +4481043241227156956639553841037732426965917364470043436075190174090995043087977394594850901991029121373900633832712403510778230 +1122190232976475343331179295988355035324572960682589565916578492624347219825791452145522290660285362795514899273106419997278153 +1419535386080392454227188259532485710914908620105317213100011817889875764632911121751593887025644393163109071422951719422847110 +4026612711274029089236246041114948354793310083266181854689070097597525414068795108775947050469531123122537281180760454160254035 +2729212202223251132035733428110959851887971832113712091873626429082924950281013969697115103891338579818898846568239238607918122 +3944336153317752913161793886424178237035722936447760222478425805766217641600209813232221230340238786982394323446453582721990048 +7389193916919980057221104426235427350670234767999865432553198312811347361703697530913350075859737082487587469312736993623735804 +3544483515704686277538264527506961791275819582201516681389283444580314635355964056417380225809498367162186604237676145482322561 +8044600252747925830317760868421526571377975782889497428302869692743382713250361972424374300944696385157823203594995989063758674 +3762181316198228161833937930845505733610147834846550265056669736693282801787541130363631664735877621678425882651996823896571197 +4895759837384473598984792357851123553619562828621778670882704444499813426092540279529447104250292800981220546692084253328082420 +4664284555514464728238600094152484535233997991752935740228264651440639886242409459644164822259574135218995760166441434144147387 +3498021732532747332097779512063273078194846290742584872890698856916194513341236677884416300942002054144602101645686192153654576 +8855689629475186087358536061769600329981635356231999344927571715122048450556630571843667383074529954198709235538731487573715687 +0984316998018946399866843104618259659452795653432490384229487374720689309493558506727485555071518696965289338830868013877431679 +0444954460337393289812378506420855357215741077375742703669752012654590715324153275679920752247842054109194186158654335712157841 +2806861505564373354176276173563926841713871053400626160801979041772088503472612997224598155147542728678254353573523697935567654 +6201924274245126686318859488923564788418058568530778365444195042057133158737326264356888205129275667061366349202778458019010774 +2825177079603097543301363195546845866777243546459927001122927276132658961336248692066215766333309788747162494346240324193946246 +7328522607444197904276536531669234484641234327006749709725328245867037809150903161226855351918234564454937188245329779811527397 +1625377992337069927288579727970280388115743434164021261444485502332859966787759877144357204976585729746356637542057830900380879 +4756314028565636147037500545330319143265189233753100563686689461353510356901840785161069243491300815016067752040583292254841464 +0425017333645387838654294817531355494569985613245897735076448718279104158222119913920255342054852667882224523660815046839280651 +9062897569747184612738179958208393387812077029581124581459197624411283206076395360970022007778409057996215320186949888642491834 +2577588591174250273899408593063983438617592453792302359558473005206418002455294336176016723332413815891373160708758731967049062 +3790766334026767123109787766877375184100806711868340730414046922950551256206928850545228229670325982658231736019892656930961551 +5274543406306956723055597804421123472449821052046299950205504470231963135543548703265039753201973863356153745730092781664650899 +1020617263114480064430348590768589835423732129147820366131428529210137664442462332795234431300140813802687903923031421483099298 +3305606503022918455845722586154193433226668761115620627747430416848925633688922763380741392673785175993422375485098655310345526 +2853130953848078288453311632699255400113689129756388559283548184844635112023417531659479267970268571040812683475165664822794180 +2783222167931397034746003825257822695087707764404029816076797619920932960124572983887919479900468345097640119343412470086673322 +5063459185940735886394343828328918625032505938760162817991123725871771735016474675217009872180054875341819281047070252038306775 +0743585397605286027482664572990290216960312219499687628442325704541075906118067163819053997876546874075941147761887253181403133 +6865060056069818696891296915545023370983419980885799857058396262667622091719201948407642987224698259796247084724028705854417594 +5103827826152310417357275607217586307830343393236258610369278200854730301259212109525027296782910788706655437239982908254923137 +2959652192735329005701145454769790852470342092444456431448859896236135922540005403226570654335981197446157556763871319983952696 +0906069491801564153648838254163601062811138002404571553190646376754817601328289018602749191681199089353060650264442584766903530 +3785962322135501816792718661619323345882587573641791662855806452191640690223489872037123172150522718319643946771618053874607301 +2342704599377336428681571005102144288192803466969307063516540780329331225964749753260124769353818714585772490856102378132713276 +4346236542835966635872778222659462346707942811767870117146806978169322604045750387880280187005012616459999816635343308178563646 +2604219260434304257671433967264369756269802345023491459538543248359901859356108205297353830910989444923284454022447613985397264 +1822281949178892000423296707942037651472365683251029280064728588016134363373058610506594311454908111460545368768742973357987311 +2329670499086760430314104242828210716854904379725565610986919473143807393666799098016719544449077169306161547903571473642324181 +8934928646320239275117990276319738648757543739070170895539210951333884142223117539519009532014319073300363829125825739466521964 +5363386211310899141728954217940413318460520197666536176317994465965648033515827854532405714333529319178360920611572195490491843 +6452281693971710923703852296775814957821367584399432406445144322839651572894248840082293918339020670715780310479909368596480688 +6791949317913799774656284904153563675547018432823443924016298235065082832647707880299401729868016947630432394689913082273372425 +2712968598557679357916581334926350397464524640833937031346811806334561647348253048938805411658427143226876519485429485016393766 +3501555543617126115194082213265703065410803089224710636262686284845574699295863975355551722711478618786950261560124771603773061 +4778106677024357003045486275897639115668057170330533010873096634039731123238801834051871842868704307554039712015191582514954442 +5218459195255301650149970279364690486331464065970810654696223977244841051824600951397161627678662117382548039349844217280375193 +6369806374093253248520031657537241583648618465123745039819043766572718344368140639003289414418211436811709774570097952888487167 +3212569840247911007598018387084803647762488058555511319640016886915147136497977845568137947542869347226726490373484609221240787 +8115733543956480787117884715874295702599005706164646884593210924736152784838359510894224199377258864940900115663844969555460182 +2035968818201814843503316301816877369650620471604903993852843829395302301918155158237168629501277731356144310878037185323999107 +7016895419441126229181619830275636225832821520441765441532992753638148826237793875874434736200782222141244213180375828740996801 +5879711152250078980107885067914386728437059276590755707069830533352692084569773933300266007591174281283361187767672358396078896 +2103537195144138796197574043874859185879649977538344432422677102393984939164145250471907596342652013494773096173424264207508962 +0637450827987698515011845992398093937196147180755217329303542644463406470700019971836100495535322254679390620873420862364850762 +2242509562912546291760696517385259786276250406593124098460913531494124669973775469757781521279236307631066606896102762073078153 +8737688554624301439839538446862017884613896797755819281023174101498754986747558403862071766932594675733495440363990431783540137 +3643542527592425148722339107873667468772709136145667446671572809454163340131116640859776867285040887038441378816294697995941474 +4072206008606547388536544456067257224875289444010744788037863160664893445070574937489602184055019861155649531412106370948013649 +6183624181311379076807905566573341779391313360549851142539899794930473883081910943750299100861533261211231956101452244671916467 +4790552691647255291761946345206897704211085378644313837821311423673070233392146600975258580259558879486034230540380014801626096 +8493966397430159495762611418791059378501633459275242578770822154956094389019127421733416568122031957966837378624113082091125501 +0539497663700011903785013114734351822728368447618541431249895153026462750771721023669565811790420914410370442390790070707245463 +2527965030066432300857015457970368291786471653036513592059650961230415181073725654607900007084498257528783224577191374901431098 +5466092963804647249090725375187844347347973252108137441562290526430827908072841935677879142427224945383497721669674256500195118 +9408447458584058076150017650238543964665522204847767119461148283020725314993208318241105785737923682521127890161621980525163933 +7752816476751548314213662757572297632611588857400086488089795605852388674435780461993562784936271707018785480608983595358835686 +1627393802741824989025898363620676709684659912421866285079664625171969200262501658717867654051389804050637814037774619076628490 +9122449665202107140311875578301366613855230050319765976709818479408721612162782387682958793989254712472790259401394162587792903 +9264559273820216137804057886666471549044481178190332632113699758788705141611700544482989913381964978281793867160157791927781162 +7442806842403069859300613325533104981898816922110133255013384334075830779759933886533885733793824024671542171085144755776119332 +7374346360629846250873248611855740390376331086859870274251856769041575442564535703086946429812945653348220186072122845016274001 +8100158244663714389704533217051390472696914158612218153906542802690978033894796544874039962095788720080152937661496672600961913 +8620241055478925684985952252838411836616234675852362577897905957450930653087681187667293254151875334644179085362678160756183911 +7978254875299875225763061871403474457110245655385719997304830996169804380424203018555208820048813202142753962116252594621406974 +1364681806031729655441460904058555518845771287158086951978113218142925356256811479736849256168552051145501834683683179144053582 +2064837061784377038174422796078941972546986123715738128334902017019689407784830561790843652346745495974010607663653352384636987 +9087616048769273749416367719522093035127707930211676277159029972485006678648961483209994033836189245748110099847024086616545737 +2425064383233144306141397196556964739088709046393835346029594675076399505634895487000914867003535813058158157320486332684663652 +3641097021982425901903299759975001000185954507785071466003606303822049570876073457705939373716255467071337231807741213874106729 +2074354309025181421785407070622306037112442163872375219312465679573739444271473076859615411141496918260111756219972558400237414 +9209218175245343776137887607783882100053568632353169828579551734386860768832081473967959877027533280331064368843953279403791000 +7265829914895705780556070716875430476662014009364335116363868273301526498001345684876869560767489114942311375190271613882803603 +9073891388696315073189212242611726526377243973277573301675482213008892303352424672983354043608654230919446999369674504952411077 +2313808555572186833151976371065120343070868637724954931470642187595688232146689299510744666262728998553432846824564736716304195 +3769895001051711590090397709284289543423142627611293076964116196325536683515731394758243179761144577336943990391686351744541117 +1964012423430274286597296893918822905314758106425920575603004465793377045724816176059995632780349523671266024041147016652652055 +0559141307894322726836380567121144490621939523042182901839217710526781776038951549469639294413748250130589664480237146063632821 +2784427615240187672159066907559581170138189996990499287132279332580644422377771338142338877270406145886924306247277891647319839 +2650622840124168882146785089864582520075975814107450314378337065910303739372347881027629224527453006767239445485125470798573294 +3280112665923668502905138798645913537592166171499662307256909576761808318862002890184471250591748083711310397550032446473077789 +4839123297739060737950671029462682374736375690549900393153725695518603231578972526440776594614418742798429193873047497505681792 +2160244025080490634108186799676843921536142621408043650219395075800794132235618687434126288996783749492148526728267890467762275 +1151778651927614305188542555589072273825319471951036866487051470913760762080070986450018226884129812856690672034368570260461972 +9126667808863381235489349849691246557114377306076458702232805159967351257175416964221955677360994319567614203175199799743819984 +2789442446232943685597991603590204183390799819475475321518636276804097467590827293001641282750302064255269776064371623832516088 +9048597881455099698450226466082784483581892839976853703691711348479752784919013613635237082895964344395914096977829703979539035 +8807651873851261763689740610852384724724967281185663138373836249447037268804159569417135422054907833329936731832253007919797504 +9682114913920055259992108818897312911322686928213632559659016546514207889796765657343025470035022686294498921433293889021982807 +8817906539189722113102359692407543788732651010055394962852526688290033541790486992705883840600079101359528027208567808930305163 +9801041923433800395009066327257582729179435202758752590945790035180893649947139262456916818609204478389874916889421571462394032 +7712450051093466464431798727528046026835894856944238434402423528849559439733559946888997104896406027931037956349309616326923736 +7381318701427430852131274547674285844624653982181746045743742319196948480723763005752758284784444958915729789741525394299696626 +8012218598270213765952492120607042939337977067878086380794314818747633639449994732495580724511274417714861329582888877331906442 +2523903559053376560461999356914800460953183047966595580074070441846526092785101396532452282664986312641571216344907286853277587 +1243980803716723402043316042450038929890705999070870015541470833748745344879737850504389676782666386423839519311757255510240006 +0284528532586136580475966266604417479884520212063362364900502892825693493079279816397630592037794996982087214380723458893748385 +8491272727902175551882935376152929301347887913314101691264776996119552678466629354884721510455050616404890619695271496162337915 +4545341965713318896843475698632445949069586135305533687841423447686352614650216106958803696792920165610566274323872801678178779 +8253568664915132158211550322533453124118327929548882623091786963905677622475126883200587876894319717512008420758223683547396925 +4320222323998014931144025979173468123790086139354433220062005544015035220976182446830891814234515809043692298378909223491021578 +6069959232219660879097232566121384126364624848136634056377125102029351039021829959177114631501219753707218086851316623762802248 +1243816089430429483661271140945607300465854350055161784219266668283907250544685294916674983006906835039612884905549454140955379 +2940117682598404016293743763452820571055836767681621549318648097809089905651411870200800086998457828557152804031061902717793951 +0887454608619720066585775426385076124950271424460822511049331848391671487328356192926497422819817241814088663154002962024098217 +9444111199203225196678001748854632792810817288744330344130819478809411416720197937516411714390009340089903953898652786438479523 +7598508564858904067093707855688285940754985295788676773297431147947757643127210193954685014018553421494459901761944702436530765 +5554085843289054481441810390185341385291272744398367506999297552891321596456006697431455499740285520112057597547672427356435569 +0013578994633080338189924814677511395910036898885609486453589361725442884886155382037285922038189976648035996103250646536792347 +1883418355117695192895288397176362340054382375638457044029914555409870529840507997093953867543753807297378240486101911704147190 +2990020394219301141282427939313186733000711509741075546302432127423255702951507832353089573401235669455023017949653420450062207 +8315834094959817998047438269545055161942585493293325815723771181252407447320553420868080424394122133699301368250012158017016770 +9114429395330391270070591803725103499827663830583921855069504046749255370339126443177002479229837662039928889147633055859281868 +0939693955047378469672103416236905988750384823305338476710533963327706820167318110473623797427088982971507090747733464699600155 +8097749323633489883895572126941411948413387610953411492455863784508332803867377054591645781447379503035057961144435257072818355 +9192774536491861553570480071143726445650506118482951514380572367117987602662371433431531020944047345411439555055616659122572444 +2538272673224446791161100046059076794348690288664907501420986291128393194698926073716590796828226666658940692534781574652080599 +2296719356672708630298340102476096286223198315529342168688227248665999468122934752834636542066357602969267253948955801596039200 +6907553929212877794229661239340340054507529389112502857484240836627584226292443778415389852020999685448069205241033372399261985 +6092552080660661596415004237982747843962036754844362941207857067711980933061648692291784758051313128780610506614569982941900763 +6594390851938570829005416110125258734178056235062424322731777215369780823020661620803238711218728587137816612075854867828598400 +2369696331217866566447853409278304508453286888356285386844080814982619783652943626843027594633000036437577975836948042581832383 +0948885007237584172710171695745820012612068700229335944852613395850206862454317862915465465928827325249777743488489409096560811 +5495911603990067019527969794975740716100732404562122420639048240417867412633964511077857983711654955131598842753406211465747911 +5938576990907415666730959973171116867930776870120598849297289380213982472240243585128799882672536952585668000017332908127868142 +0055033948608802263653030525631019632385167453147504582749896613855370979829552517051177850239757173815628192095505002356755838 +1575006377951552426189315697593571157901434403253801500948115475871805154047796850271348643125694619380221648554282326550822126 +5246972276283601394823321357823533983734860648197127606415601325852813899044500843947933650765212255657169653289842270182408561 +2963795283400693969427927841410518920229478373496996799858803689356286312942605835353285929732637824507016592351551689198434905 +4524116354075005325609861714463374588743076763717669989113993414649241279740839454455938573607498636902929162122468763846383424 +2179849115762842803410844590988059861418931490923531363860515702620355825744742928541840867928398829472206209785674120570623101 +1132410047750617625576007081275570045071771592714539836172004355577617397790511943990307565673693827096029990088810389666652957 +3079203667265148591706387956264742397674809071114000619637965798572137055721279282178439992636758230593462657176883252897846130 +5344900606236775949063632708480760988922321343844454792539062870953446557548709705912512202634518627191679599405320534739710674 +4862620838291477498931509821859436769537924979388766030614053473312195673928520927507333262772931790461823017698325114264269689 +0377879474949535999373402143435358728101597553950835828260875850446040578864121150552326559433858342085551900119266465442357108 +4145382952202338626169521528905963930174893641795335885386219002691641231007259917968036502863440853204735639598211642320126801 +0053580536687636415170048134719028636721663473814357492351910729926031799390889508364212752500797332425619171871273560570543315 +8050888999124989277531284920879308536986968026163965044507397321505480674446271580916011349473678101309289578265591746813517726 +9127557909914237400136577868957543371638044740008283166851799275961511059368672159330761617818453900045874047935222126146402161 +4101481561011635460925901510238481810190290058999387022386961480571796642806735909558855831574016730200955930521599776711652022 +7452149234766310409197279968867850647491580237728049077688692166936015804308350068889158066597960097627065379539367797830770392 +6879895654050303365324517468233477011666079944449521630351405739029720149442284020545119121309386081120398471736260643772075320 +5115668578180735659993042798673877885823921120201277569914715190894516855160960884928665814998466370463245773786729580361126788 +8473676321663825127148201234179810956242584805477442480418075610556509294721684997709018216961441699698479559880791844442850980 +2548233794760268816189190401306088756408880212519056730724214290704225280819394151931727397286420914387903845669497115561372625 +3358354482836700948199493625980064917823071542164808097350543961229800125334834517703864655364546055166975880935305435123088821 +4029969129548193511513014303632741396672093205336941776475040363815521979058565558783096959704099250216961508907068930707743800 +1178228259948098596059380680409565881553234195364086559565498076952409655440130991639052974945372324956190156780171629355058755 +3717169015464986627001032179838523927735142460855957466743630432390818286505306791995379349323709241837876168544133279436428880 +0351514453291951960472553858319673428002898082287147987459621016579844258976392337653325512601241626465492005157367458123795393 +9131757913676253650480410533013952331883655576543674109012844727933443442812463625615079052305206439748070329783436962037461924 +2344960044770585240104572826430912626099098553793285442582298302002106108601045902079657749391794040816491373923940544837370962 +9188063701594180602103941124399234673973525989100931802175158910488942922514429931243842291939057260146437903218286048586526737 +3095726475590315515951883606439041451987645791724176078005404488548116509110488969805623639698399122683827452715501916665020036 +3403203657780121846439527513421356719526606981096988845264774034545984754667811956286997210908649753612024363260420418331459837 +6454363503953069085653959466382547762654112282647446898596667543948487517796676159860624750118940186171824534509979950086899125 +5534857215488234005757824538224541774649888325359087056984429790126545819871211147018201409980430263764262297169187413523924493 +9520167452539794941218775260774423444492261204451489938948286717754151689428746487424118400020813014135629700319029471552190487 +7649753857278617517384047446362214242830920706961544783469693002591616096695611398984815665331683937899607935227857197308530722 +7670636468635321903676766861271780561993826318676409654225250617146887843176296360469702345236373355189175304203166464435492803 +5456942248296553684603690989598415553795292969337585462669697131930121000520692716176831920728412650435826182698878423955991084 +2896202227362420166816298936702205787111522693592087473120377589659651412246131193859654870409149102874068068052947526362484606 +6206499177988103420772046456006763763163890633653756586913836205106440292257489426046140931638490258992453397047593430476263734 +8271727426541847240045919975482895895407596972876222349935866226855009736203327632117757403576107132386631830517560425145954967 +4982163925157138555939635994371164500846077564198212229817459032427881591645290463697023178851238007473163893076170963474781460 +5340106261127351887331618946742533731988940154583287036382074049074320856289664772105865760586792346984849386692407381048942810 +8539587910802062328556477423232706345676834247983911515809748455837801552264721412722228887311117555317778442883915233779797479 +1727978384302123967727306531882414560603798977850417620003458650086712045078303090511550979287673387880893466154163854646269635 +3674694578655904749986580598395421685146833662087197374056652325798896836233778806349388223093547068287833955056912724333066803 +2847637229990901535043145484946473452323017593046078412652932709449735113175295374406245481235052704111601101677970510368326922 +2791471564967916436181421827384161108238141389611296884460017859614820709694863977807620407661790121758211278587753750388535470 +1311682212671438808292446213587823526675524926735249896308087156166254699859676499961522597030531906137578453887072208144785351 +8861987970713845651946125749765842589051394459161283498525078704659636051445265425124710568264660637581231331333166906616781773 +3433773030784699549858220921642631039795495279596839707512577767723632096893086622754554818674187555230885034907077860457028892 +0456580053379968368017945695164763479833506838952019851181545387562584359601036032261663315698690958554540494006314322814695152 +0089934480486704619783110767294727013349926542271497056296250118282426029001430520413060977864809649544418723152448749796245164 +6374218433638081986774399897692332350976246009622586461188714603950733284096247572024844313234627483374886751903785440297788166 +1964624071497448806005939877571581081852368682713329198774704389508439970356078811686024907131424792844471710419031994307710495 +0920647722499203428391025133284362175932945797352824069655533852410541721344987923656955005597638885921881748026281505225146701 +3234051414875467310335184839402728147911090604477636334326355603404083470772369446633927746336105082555084803709873030579813182 +0797776807854225896647327655002411099428092825155001834564019066984990634531216819521296497699004639732085677368728818595315930 +7917485162442064658421046487728607879599371289976088757626588362451318559683586821768061531908102225442474938214076282479553260 +3281219759953705660325535461460598775637270570011648848817233301493712654518786509665608881437564458093540417006933366539835720 +1421309961668710980725741781573712344943061720229290458895090456489735933725778071381711038599743236066437961925604705889777444 +5346018484213473348778149540609702140487404833149084935132956734625173249282732560039608351835971014828152667004296001672327334 +7640982015534543149522949001287972675835062998825649759593191032854308472369740597155188057572429051521288244481472576347709112 +9082197142126709759172581677046792938596869866773476159806997279087695007866672568094682918889951065921351285356324461616422296 +1936662836367636814393593918150500159197921407091608653457518897602784067757706017281722377124420704953813373267377728149707235 +6165532554189463034890275736530147346375384892741034329027227244542906540148716547806611470041759808947343102903725834811540237 +9921590940060069893953324679767980790622906014798953371116800849894891003273141853411016879477894602450403366892842855960933978 +7315523767557595011955152358473653019805790165086637876204849356737581570450280098237545014539966107468231674446113357850428012 +0791096311925956512226765013630421811573099687378388596324590465120594475232654312603704526616319090075205150090415360289991719 +6209585520294606187513003055352209151687938901113926217849214203137326771247519247105616300171713950372822794825746012319922943 +9070419207282434237195104895273960005868745134822958234433238365905514670266360172103212277318139495451964580465731804042546085 +0338167338157532972668177758079386489083653270128069387600686406564818006155678752863600080494279043355117187180589834925431100 +6075857929007054805987361298779916735419742025429402324367885856941288459616727309405216361897524393233989298288583563658786859 +8295608945048628864124667559446303925571884604451666719475562297491635918267804843940029802361638899118153382320671609177821037 +2582167131471095203583988388775565537112236568527071226697464466863969482609071992299656322827744545682290545625251014139439495 +6711594101773826530320065101211025715415340393938808536071030195055575879765597974028194836866850448633781263352118203830334159 +1911464166497757327229347266491166768994040887477045432967042061773419808596553435219059712816623298485611786304164577509711093 +3950559965553312195375204426888631697136007142008473612408896359608938295800221018496826509159015008898585495437881710932385623 +9874188189105976892158996129334251306053998794609627074731940358792016931428037315501950874633599120688188498035110487709165641 +4173410887164627415991784444779118017795312676797160939963018529923226506062126935003504945358174169319649592822030532548902364 +8585536437904001642599877592181317351676828771494354438414987542591562928890147892012194379909967644778402105597291718886776458 +3150820435297838229930820366686733000243384455249980345366643081949584071763731857162948259797374460060553393333323596509856155 +2746510308210106138913961915766655928022321725147254596535903741506128248245569457512888067134893515592196316478265340857967148 +6054837822399734332369250046782008884610626357811684106025662192613352002782118381922758419491552146516596733810475017566505975 +6253444244691352274570036070483313882748278795425532524034702609588633374333913295809727607310412619066512211586460777396607177 +3167935626890486882612342937895694862011472784369829386553959207681859657350791878067764914715082125859929851130735487337849909 +5973912099248621614115761320919410184939653960557823675647875630413749948258747675478750350454945866579601771984960798194388016 +9736525221109913891380740014791803647462175891768280453619965529263318350088005137408675181210618289125588737889391858187625884 +5353369021308107059796622691343010568879776199002760578714065302617216068310095438159704609241785014319825155619864292170880710 +0495180914933316707105009248960814921465681956792191416760665299694180526760284922837494706424443747428740900047510907222820027 +4261167178860446527279234457781216359164057184535569399549566971774741437839602392078186827336187328588770123788484074481402098 +3638667122645479534954458961543608733857643210245423464371257036918768143627288762652953247716922315676522443004771243444008790 +3924515546743559568892457871009003770852048769643235894176832052809028875813896140562020415910166599360845331504914716199418304 +9539930208848580218543922990732130838884473458954810662182599563214576790823089949536669626168272941913640024171496275351316441 +6014586121604715045014833563011298445249992633905973084716393755263990314978408352185626630254184110544304520462563363100889663 +1480056209827971737404379030390423810733649879094610502529510552900145205746169635070607870308190199905737823014183804945008242 +0269907341608215559877018486447313197581053179139277368261940240899846162645640750726730556726252880111678045833842135360488520 +9452683639389882051701960541518755636274003173728067144992243393027569642308110984514593826650393132965688544590683455796310124 +7380252617100440281579567534384005518334110526934315682916800234325208500512344342386934373532140277510905603770493859349394883 +1640841298979540048287075269187639921568678590871873233480612103263772909669941767642148108401983790040311768132667513845995891 +0797228841202589730512673576721011566549518209931565777081305309555092032097475454967752699515363312040210695622598933787975405 +8668051227922162902176856358741680893763627061240389531754672702747011947735221029021238076999742096989024601711374129582948446 +1940517877834907351003862153234670764674347412348064152632718218140233582465116935278604919054339813155764852687263384383689198 +1258507121750424356317899666874328759136117897322624713333775442411946490404548479399911860814088039900005338783292400154353212 +3215026566497194921100428678498475477212368831513037002482731701747625115899231609161962690257412946823057745227816040916263135 +5553936624046126710513840693074241292678003250027162357678547764315313001417556750343221645935609713903330012474781806462752509 +0087160096352464233135718030584278086059148140723626725159134239250134423251753319043440628036779710209805517160099782393064078 +9318218498563579335348341700906218700126032521018782542069807548617891695409073329049001835630809969460708500370067751685336992 +4208076385552541906663566236770990347477457147392506695455104977958316161334777343709329582406111068678972797895379263213969728 +6469519015224118923867472889765223881558607274601638396572334489644055785283085612422941306760043896876352796674858662547224493 +7581545382840053688960159322695550231110088020621219817091426507061324686155465441741816208389678694769740607167732243171488972 +4513458865704194161496940570841680853750653077515467382681747134693802486964790650970100691348806372555667204130083389487834234 +8611747863343669889389552604708894518837779002018609033906535124466043777729170830388281007572831090596749539330676454829092268 +2614980773184238784409092097541705502166871511835967598046040179529035245968990886914099394023190993075959231506769917989928255 +5078404017663690714097396036195442424905417384596337491669874839339606038090162958546298191413554764614281624619030688715839038 +2641999347004416078674706237266340276545528202969242926658631976187485588763571283416465910176657402769591804490385811120607894 +1022069138109039758566977843736614783843237277066124548095396035264485535383579339344672494958836028783883577568562124831488748 +5036220302308126851203910148295691777409108647096999242270479109438402097077523126876642469999412297820631461204592271671208573 +3765990012871705693020962224239694872611037068970786438641717866334183625110030788667653078611800346467240202316395411589819234 +3782933301188992583378339987527190128332463154672014687853873904582770103495961273158433396887983077621367280840979561172209874 +3749199929332536186794255922364823419316096604597225233951718116228041916547239168206812159635533832324993459328359641335851160 +0949078067861678051433564861906686233060038981581529250289577929864989790385982845786299381823508035058298434160670694386088772 +8589603171909191258961043702444348933790044242468360895051180975009846570524502293795875915077460542906777905339916008769533025 +4696790001285278712597004232911565273828035212555295118585512821803987256554356248161862945364958160311031123882054615472804301 +2136763839544335242427199077661794515629181187002289822787279783807001282765862055208820154228904904403489678312786030757766407 +9614871264207972090235920749815254428999808582182551807788105640461738443833466880592889986393806973211194934814261892282034345 +1053682892737737957362804191027861071649489484546703968499730625323764928679998205513025454613668271807284174919717885935584552 +0107677739834015517323287238318659939175109001778305487593186279160892671682768468572465735391214037913879126299875773890935302 +1453192783717188719965961795655288342172822178539274975297334507529484119848624649135862288188339473719284880061285948938876451 +1104549929363155396273207050870222760506597442331198500643525825130190102095717730285667006432704158844993996831311067931052472 +0828794534801481162296313627002145147495573308897739685396596733882610495059540555269595443659894160127867987587635803471525887 +9824022973580621392509031573913634949593512565298787398230994893915219176490569710003371534856099636970419816555736516423169506 +9878869772576948330900142931880528301401489012367453237909670821957956278129934157555287021598067976133621454184066239649408611 +9449658706952732276667554753119961137301412966671524990966931464264571223338509226807775956572226631814170860570478467598493299 +6650524655470467246688640367290038855618731841663664529545949374735107916410687959478366394614227095766286594581538618985047713 +6086084723895749993359399578577946854255073324766404400181960974843071723540051597517023301307855898898894953430083847202358708 +4753978848939024247917094291054930385042551054372444060172056724142258138979831515270370976027807892767076899036493276499539268 +4888375835344223898032733332908158386194226863203069893727606532739301723911436149446573440019514355993413403576684311443713663 +8296174705195869577823179373277139184472357378750746123040139737885926265459733919518384739329034183096218738593256149149459218 +8744604285228489074099091055498838353604537087151030264581202847750393201247650508352763633370859358894270796201667489608183108 +4803757550419070833057341387873914307394706611793081307683075761521436160450412298883575182283341357874191269212976379223012176 +4435149804710266828206094765772134040146772381477199506975830561360349698395986931196641173574221626045221904844792851097031410 +0140901477445628979104022134212056527853288372076077175566962012356161842830489257088195443545165486451856025672191097292162212 +0064993358872969642733510540028442337052528489493327308542431944612538748472046808937048692371405185247438306806803215040744971 +5863180250517768423942955033295423284494978569038179153339219650484893674393537942959738721683811008504606623434622402463074587 +1057835094428515977317637880823368056821605598124838652727786262421298250352722448869673429472764531868054225289565474229567344 +3983238067434669068143443350182793359210352492378691479389127933138449974060689160199725860332928925347596191014918077016053014 +9909206404814481317875154662284644158413522012241871567063512207157398398808577747347614035401411443650498361772558269985219726 +7744531085141281581884696688318667987388073192993652661160923279555067568241657394706279105517300977887168465546838484164576246 +9611748410338839797298552575152326071882814435353560145135335186607329942289657269580962404267932188572721339477733166705898691 +7946378873728294158344802516673294879896454520313415594420541327407109273815189756012820920103635963852069701484919842956064247 +4874591841062298195410390631359369161750834793590724525846541010552709961171248502344146476896644307714211419632056930049968152 +0852013636597020207693222771451991722621240083418836922565030460173149090294177983564964216327697927947088353859239269055188074 +2400549504774664967997419613371907388057256285629514767888950107220270166626488534296499500671373046737811115964349503266901011 +7846949189277918675793279134349974486913260503583373441600579959916070999842932572749268240452265295033063113981992389359199980 +1807261813286492446582855762770791231541210822077548388510880369998042947014204967053843960432445968862263380028288322991265906 +2762645433260880544005259370505499891003063278739034550726117946384596067905756389481622864019774830490639904899687312014368603 +0877598939078117695418432932115534755404639291467885726434445252435059379183430846339103652602297046524638381772417363883263654 +8359730049870608112690328069372460928467332597727838745244400830648941526818883943362511766258737811338084111308530830389543560 +2410247474136168092178004494614768123474893065682802068994067272461583528237284734448787471492174143726629957921201303786784836 +3419244084207146670255645738668183101897287707313517219103923810981141387894446864639750358126083692639837682548305250192071549 +3436195357834369331471914469743643722462664355231433520254139779344070714371148189113613561574794491575113019678653016828154505 +4439128393642435861391888228862161582205771186938296499633571218847225435482241772976029740807151825694346388408247223423817081 +4171338859609192030035030504936231948955422469935021643277709598491047020926862755743386040228384976638566676326191183360208322 +3510862362886970176404175491659583359746924395962009940383204211293131363439339555697993521569537948812781342292800263161257581 +5726969821251892647951678196842942528264097032325730950425154233756415408461741348237674984518538018983212811201588754756679009 +4778823499024627173529601893322692810338013854983738107737211008580929848242105038076828712411467725165215358148210018424891037 +1496776225022474894349628318466731097093204838845621769757160832213029122420309244726997275518899114578190401052089674878889558 +2150627813505105989559012023523240177523105542484058646465606833626398767902073791909228024464129808047176621447241995834760361 +6052017973982660323612282677894938232580284277106494794233888932365369180563831962638387127741187828046331415436706723759407894 +5180894648613337149931873741726031450761346316713499884971063033267583243155357639761188673059015634957451632776491096066497095 +7359097724129074389636668836328680896804756391700054500433769926703593431467797993796585602417512809374217324038244052246360155 +0320127339112689809171849857331267778192107524355671645529083978652864384633410979534318842451250352236642968028403645196181521 +4118883887076525329129847815663385510560303081843081502700312066224535446821931779450723308317216723461024137619749777688133771 +6860925861993428345905718490095572908986315074234835981417267582301259888782018674341030424958141289788351602467046638469818924 +0143824935249223588362256342022083873670928848969341583470612068807101099916137780686058304339569283167254333748135808339800772 +9845042645815548051061661959342234028016893229602886364367950621055704775648720419681077874002883738984453187494339471937282961 +6185757617018491828131168967624272567910874050935111978401025105754755523134728391834040088198125315748002405260114662632225537 +0001356522238346600683651153474644012974963965580249070955634679932657691126596449770936543341015260416997826513343646145044283 +4828874167962259991499503673600129164632862005208870245173240873585329607224314026307889603968799682624300985376989091014318333 +4168596789573195113960639290119776051474016854378309232971533989042184885619296187870057410925857690307120789952188315701548184 +7815816015467871136014863206025674274535612873638378381437080759117487117954420502148760971346576864484963796596882357424854163 +7278776070084196458814159988413439534481041061939764299982929635630954177993909110795537307351830954498765311432170571984412940 +4866643127910829515007652463394937334032003939291631862785106424516937511685939908344347334073225050202328398177347110978277589 +8801678473026832588217149008639268101698714830248585119117348101801713106570301483277093069752495633755950440945309944552577536 +9617526174545226424763055218268088790352736241937230497521917254797890205799826169553805927031554132395993133419267021828416925 +0588595739388380595646159745519694245103070425108579498054959496392270944865180508024017295767451162258748775694293117545535076 +8702772928743292051022384687311462236447455075709507160040356608423402093661525464261088741775321017969842598962589897299430978 +6237136476697160214138655273076686746008630927947783830802379210660809805387482347921808311217785296709410669748246476297410657 +4956721962293257951828094615247811594706401567441027963919853253912294488061757086648296894406025064932611868738979275806148213 +9236140986639524620047147846000572917224921424609362686790157846221057427556655153843449488971368941339909014048314921826442675 +5366378038534835924469785482056822213525701444985254633404597205774596447015868437597513680309327466710395924280351223623339183 +9261759487436784234076954133371789265925256106206142125748755816777807349896143234487553341181444300315188799020606387261852065 +6449231339989879656134113568400091770993505914272783860814830316499113207580889761456971111735531955653301180535329421263128180 +9593132987957417462820592468596242875901632353771559986709766159903387546786798526051530972235857175987208754226458183961092508 +7166010270941368051527588903270384190676373547534758318035208065713808112773649467017099455130795910402044915843292687098488409 +1937469715418217414858420673158652244798733546985659728265347906685952080207655697652213278741491999837300249957163250199620558 +8228542398195856592161847035652366519403982135370687548941385579105164032051119406009514327346290711302155896619001736994882959 +3637688922930586118891425546901071630399830689323382607140358997300211646909715463890915726479319114588493474688432142961034974 +3846092487931514115420051603659542019430636869539365331821500084544038227936250365288930517356505814134292254191756084661422225 +7491630641568207270697424777290522332626816338241009039782131614678232351819731901409187134000842000166738975995925878926795417 +7070750968877352578247753117115107850387026880348329157736320326010941179590211312594408978595708610843851283204781916328035469 +9579425490712849875219973084577346692279033275981940434988363957383909743141776369454560267346747976256694629456374012164182136 +5715566001611830336152118124700907641876141203182109095013901373890817946278609009427237417191831719001170380251629245333691467 +3777911831700858846402803605902436628175309291503492499557547037759922326055839219601687167716391664999501580752878380637519910 +2345655297190543682328955031766959976133728834616422943753268441547260728586436316967787919247613972239277147037959837372479832 +1264917138428370036605146743753527478105136932962495735773676134552135849746496312485051160777893753074748519890909181403083444 +1019752269689676763134331558096188560591351764633604225395078892173960817806638672836991960044167937282088675278982806967963563 +1646009447412568269213391779579827953653829284427738902923460839464242874336523939561058096952551188341759036552715805796071087 +4514073980834947668053426086988984219335479873558292410478690803080693664498437799009591988658726439726875547569087833595254435 +9375888306479510358575648650751703046541164954438171217850843228076528589259852655316343249086105052230853543970799873699798265 +0497165101239642555970983822927664186264700494353584434852254137560612395432178721562325965038387864052788810184396252265391565 +9637587742861000445296706995627451301787108835157787393998256171661400401789319408568582769562951011299994449045177879050273430 +2769638085862574311449284998834663396793439445498698446119611616703979283028314824805123683773362437290195603306996434216889157 +9746240352274295235857973544138134283682808329702423798784675201114018293748073782256043515882634590777226313897991318556273667 +4701746730536780180098002090253702648694901490740529266632381315672027202981413355374788940709298520432491519903507229198264330 +8070148149525433117389602780506057744721609297582112109576333690538110175139908485162827329907610365996630627743121137187293998 +5104791573207818901442004558359267736381147580646586301522698902268860041597652832411905302035950359208853670857974818287006889 +8341316079342584982610662915730694074266548963632208359785240542883719157226848170269734749166834340935627403531307648991671361 +0980972555646214322144321439065894684434469993258702669138171566031352957356377641038155398195278908409758982420498643103410893 +4371601001168990355540734973104369357289155288304862691393888938344400557230712070949783924178880475136899894295722616103660902 +2650480054074532640486048424756932242389804525662345983096982594522899748828272298964877383316038674083325253436014966605240140 +3856519566975050055663208955514019483009113366052382153385562181732228724721105677879336134186949728875130780075511950816508916 +8078373724394599222427487550133729616625008462045077201670397039714132392823230257154531053190372696559721189464062559107218427 +5533555275076610788085420797340154399319379967237990930040901555785674670104205199936906742420190549652702261090687000720033243 +6220111323366364001766649253557628713894497231901067623752708357435827393686138195041002675760831950319558894058730884453262921 +2672277003207147557184524907281442713352109540367339513087567600977008089227949901291846746947778742548425956666175882640922513 +1341364992092721464190832131115386139839119999152547728030982443332120739263533376607896512917871745789498861904805336640005368 +7658494769549719799407250503812834345058648333149043237321838262779633765459673785919568562329102220327192186018538985265090758 +9891469225677893167626557199385256479464450147340948798817312917938176509424351376822942297600700655298360387396846679746727135 +5585419624514115780086956162546737430419445855772977848266264876064891998070796161296726855803937113862539594644902156882096859 +9369735292641205270247208512449851304357935258980017450069350537303506725253901558161348011161752800022469320895146408450548005 +0250792460158595347750598522833094847081172052676835161342784300572879217498951077354750791561533069799550859447965317570533329 +2215924262194811929293333565918894008757945953561673129802085846175034801490539407544733104736094736753035909391436637603434211 +3003828547025999647155773214469770001753156334255534694689533941988376812539304881256890976599139258146884644045613614613975749 +6800289970404751783592624836999186310592737935219914459902710041374388930994677919752362443845898391179354567028930335795630336 +8505759963363966237797610984127231223565214326257640335015223496586184791131912377414208061741646388077399037761412502229212389 +2367769534630970786705110465175915418118488516256049569042500049966228999665875815493320452276993289094558376973109778079159470 +6740493910513290939463082366133739451516673396242163998658427933891438988618879026121788841470475041492666218138874169322768351 +0357303411110414929271994301686020384849443986791255124503432672170825267728337655437754688169388290097504447359015466216468554 +8192240142847884347063706580178899765888936207019662263339819670804657575316021484690040614562949295841542317355852873318646994 +6622263158780477778507038872483270954479088649415292887077869603719840994025710565546888311161500807362774885446004022146890733 +5176307819234962298055575706826929453118700498832781969398229886642207165799263179818071674130902753482145042794765741675062383 +2751302275326116756435072977812989216925193208517438463427139377868288067976273977283764655073728859395428187073500573181560080 +1845833119022235738677681522695682631533441089840982284202257527507809093077654733824218731845673599302802574363126193666185391 +3166900131346963127277355530406427740614776135936937104096485949875917688047955787215898240293170537866227146364747857832752126 +4669645223062976703005533676266421855057200556768903274559944244985743499257659816488004923631139517399183550005987669212203452 +6297157628559223790562907965128004350109267209905657347407682698178194211365899319173140023292544735908289515011446104226422300 +8502054721545809152280155719799579471628904200160322267901551608506906168294064129630324866997658363940456422902104004108177137 +8611455694956943077268590839116881863962149614279260195002902444128093061737269752861412765172102748566330731758569318211290162 +2118077432186424807711637317365270035214176328074110410477259086405158562676552653953649314850972984909614735542131768665131395 +9130318975369645829745860603018652270421321400871933193989890358079853776989047665775272263249474986926107253991947206182591757 +4325629926598371530112760898633445089584186304063488458578614511450976053503391266403574144006236271752461276059535144816112805 +9310962691558816998084824217608875970240851404516558899699931821439837002656912679683111747809512293159335274051955163666587739 +3902386789985655245291475443305453851903636698632422663873769701394003436882941095444088054500028643416504275287739285414766428 +6731684059779922460344447840778233714899809573570342484286950672469381242333715669289828470432847009362616600780028432025743033 +2276600041430073716292091375271727222342465787797822281415644677410001912257463959430983836963509288786612692459635796134586826 +9782224784159961526251458006646854715817922665126779115397720973464372703397941849152840323345005890646175543131277561028472366 +6526167561528291467123805366888888939086346365110568387291388627679455761130295567840390067905361907699677554800553539940686367 +5318634933920742765367288875699774586510799452591417236786364826083325845867157040527831875773026806940962750032015566117391953 +7493598975572064199793468603272146721884132503560554819191261369489899329392181449153306365084506335645635211479940033483680033 +5666857577286998209607341637144223997808492861427974015972123407497307671199006287616123632355515817115708130939568369663610192 +1205647133800994070282776117664323692713443344045889466640364601504907846992739340462456897562574412472399343745023522153250853 +3330319212199788930516095800858918371890861157149091660451404495244272634139073531985568539542425087248882661841548689414190274 +9339962909966865014181214015249254327772461905399600921043142492498857240896128334661531817157722725029302364254696461600120855 +0275915123664954327692393323944686811113159039391999178218124646929218008261416648150717574114279175738099624550954907847794987 +7571438595941848638134927452374529897917662628583906227103605014116793319790628080501185855732090732338304609688113595225239617 +9130230309512350610529542991215174872450882806867068241227281773112095423160023040208987280292016395893990306260033588936149291 +3745658203217218584383948667226718968580182712181973947156555599253392240064780457939033740602796118129681262618905670233538489 +4412418271808065273371380680584774737632471892264742468899650839254371362867805781616736426407895133489629389395846145646724319 +8489210495984684333844268191310832723383161085211929007986759567690696951893569242504292424131665261321552489038411809330750578 +6574010925786704765333558400961864682658986685222505394734228960816617397028634600968531515638569668302469579752350128387282475 +7078834237219808682337835724461339925697109440081470255808977861161896407485691000442893960515108700590859410043250399284457162 +6826005017559754965121660973424054878627050600950197534543970583792709158920574211453104472613133226055927030752116724686804441 +3714997658728942284217722016417944347609973564690519305766123183125986230197933675112901682033357194516255841107152642532141304 +1057671755594723253182271537993425618933500230542903348744403011513962182314508888904498037845069539547674219152154472098348463 +4167698979868847784276420293320039606112408368549434641654634849595716003611837153708427260322734964264330233981684490094968636 +5842205187892994596332543353231430273153910962730263311288493948447613898642287416656513718409931065308355871917064045665758537 +9483067464396684153711784947324331651250593602460374159868530726671454450164268258494437853338327466263116015842104260460184775 +9918327983152500807062535153855232542858746567492036007943220587038833257219577445237712255513226337182088357385642452970244677 +7796979178949646284046620756567408638628381588842960380640158418933607236535455721736245193350129856456748190582611676103108397 +7474868470568488770868160856619425486013084529184753412392811134951027143914884376770407337322922148422893409126222728159404831 +4025970172900887552972543571216650363430374550536726543515591505239084581125341961497432836939375430662456975979411649814396281 +1376673671354389313333179969625064091561856231653660770117134131024861451548997992193443491241771601133879416546391689721119253 +7812382563778834433247309068407407067582779720037171842393136498269365501469642413788690972515921121053433102407538535462479581 +9706575053071949026852790205126415890557321745536935615519559505631029223517371185086529237733348358256190743027438758336144576 +9006414531022472111125196202814342278375571427110180645405421603811535358205031055882679708681076022342218218061708622772715466 +7014411937404524372862470846165036293398376604107823885481595132489354330681978934995519374885800444029796119672180751145597990 +2217635875626883098820646597303117864519547801664674186453314965253480085119898512655154794357106383983041271503641895125251110 +3512252235837181461231288315033867607629725036297297118913502488196313074376766607719647753171764776345290627421411392489636355 +9367329989873888631983207743830247822211335192876356701620415814984875713241717521999471919347104942898869901044085358319426464 +3886932632919049176756333953836633255259101098478704964812325499313834184343270599669768380535271527046781188364512125103089728 +9085400532850996923140563913725057699601728324308946983801623506065312434754540522710960789580013319731801582815683477412184104 +0482120489559053393661539069411739064074531226478250805786509477678364657275374151794004014104036094940006833641747026194721664 +6223030054108461763808112515000136243498515799834948548188322786124370768805042850586372228996897524679407164853720521651414447 +2045659821087414454414430804224189873085215197748925231475200893842348103097879724089151789730563882183249354356129862099874841 +1315828776287414001746118239879779806183081196189658013775774856212674965726153082362347461854112895332344854176341904165597409 +1213515137476784596057537684608135941219538557595828609988436459029859804112595309586038750020095414785054256852539919216535980 +4484140865975650257767631970278524142097436320367062170812973468859967284286099661751054315067110058820945519136720185944895374 +7742692644036659798892433853855040190699363942257261289132684570773772398269153067661790938476854192452194252168071064023197248 +0852041937859186893599452942342756186406516322350714595377388609314520833365297395472603829432190992959559426685189491282347057 +5433185143289951693194250541689460837628217616946850778491455755537650206858581434235195035172795441448516354831307931147174885 +0450942348007827481803050062279398301950579282155758680606572572109484512358059858330484516434220157350961537316843651345720503 +4380803663067690067136823238680695720389449212682650668097530448778728543739620300359368766106338322729357455486494754904098461 +3264642960305581246967575470210497486665490038206044077023048630121578302316138939937893860519106763145890200076403810118822241 +7107639168089983991587862527040150737165433796689810859573435301169366192576251898692883826389304101824844158348543802249127582 +0669598166832510431109943775944521732861864105283325341271770704933734103372804558821648326293865298432780241079718755089452707 +3568107971104085428061715527742724933050823192969880425640410593395489624255402189258495659521212800172822796344882503818407485 +4194972547530169348356862971069263077075953903800152306693089832494384056021498593498576727061441507427007792270872575143948044 +1172788991936383893646302947517752222941032857029795292428946787677455477081292410506859204482638074930525197495818984377516119 +8708727404823062734669585099177621030117278743659596151369099005394128728746425149879168020045121622056893025422397438542352826 +5536557575335193916360622332260209029723091397745281648820143235533928946294383911963312581783465260511469849131842805230470062 +9799128949323644060685917638538635211442541566486657515013727896653746677089071768007544683389875228688476415065723679786222857 +5615573863935839938823973115950563644124889855629743447770458847381603667537087961954383608440966294356327727154342428403717584 +6135719365304945156195903748702135001035781887797234160617684449358873860897697192990886253607384422197173334101390229305548708 +7355386834242660296627412137907269283682869702323709426719706244145140528071269497974044139621935732608883353990706800769609401 +4117824188478783409286690916041542923147052848706784080198351893505523979781915688089182588499549735693880215954821551279637108 +4670168752285459430877011145545186817108898834243886734027847064654587388165854257852169040893626949216503073312235415138548138 +8311486748387427946913806861679281620866414231742557923760474181682196182819449180979395793050862114181314437692082443568986323 +8048322367949325657177291617359572925594555792044926031542356556453504106573058251613848469630469333674263842694166478603019606 +2241419420107086119951172130953831261301246015464350985640311185360710868324911647982596380951605647282292847958812174415734380 +0207875370509633314857109554449234589264638078127939118196136645009058962335018366740029205503954796978369681506112588271652726 +5224125202089733016629542238144949897132285324338195131993745529968240465385054246763922445031407439625787648928055552616882109 +2793536617404132317781661381899391556171029177272445009604125493001682989300317084296686416290208482553512764370697922889547543 +8188433691033017668731418898412943576673580084814405684350547059200277266867531820522833168888834691511550304066275553413432816 +6069781060072723977215798057681530374205235352090719032425665651313169145801463663003622748057443073337332287692516062915866474 +0991144941963456299854456491439712458220412985735998277280486665724362417204461793739331274746630407706323572187551658131522029 +1128985384630705817449509424373236680198643102398192723995214101875334517122923435752591437827690137749416921444994412824571229 +0933149859869844034267514737213635247382994476023098139584524288805316943149032915781109345152673212416893459588048333327424649 +8431499800476711779747358632413776057189971388402676768615975922425552726845845057116844980552680355154340958763735731899549226 +8999746969039035522234132566990886859367771300359825363759150761208120895977530444860283076544729935781975800213516901282765869 +8578384564148446021966192696855640744733543364607326875346561423047230035981121889907856300901288650704791837601613641976512860 +4782737185453902550739147496508870329447551421595794641391271174654998339963075546317914475664543351090858707240517793471880344 +0532832780888888968522715514533732512924561999915854959906252640056974250958067417634581049729155174966017949852499049433553005 +1013570953208696598838952288133824762193269724513979589866416713036164401176767184475902330276700096926543877198993766233942302 +1558731482683686439823710758826362624215320659618968974586082717778992330445630506757688512508423035162517304559268454636939287 +0350643207571320038261933704850349754594287810435189119965241800581118358691680807766625340717143030794170306528880710869836401 +7542021244067320014248296046012617744009265286583021536650506535157160764351137973007620114482584140630719966828687210278471738 +3972594767241483050839240086921327315906881022442251582254034730627668558044239515436332898375100074941146541911588915186647677 +0697122022586499143860386882839929813751234590790881003673047769341255221587898768035294711863803910391010620206350075218304635 +0915512582808181894140392610882201933416172227163788895549745243551406730258634514282881847090763083210060265428731131498145196 +1501512625884967191270103224021116637844888067197984181082849059840793925774486252348044423174920237439188586936474269289045183 +9546757728181045784907692074408445085975750656689918729547020741600264958315888287557582915125013916814828453001978125724956413 +3762013269830490722798916645093224443451891592652341999436840113601558507630551284115296518475712532341410529593546552381421688 +0535075660768315265313017230395001783344059304089071262026544062275821507449160749765605530180854702975356649517426392492153632 +4462229922158652059017569592409947967925255644154395071833612619360534506981545280294824268624971434641426791536487863590137885 +4122860079882835156235088149203967906043976190683635109983922591971046404170885166646247578979128875141127938069850765269247014 +1129866849265718274907637855113066201183196338524085201233097892015346569822121339489136356302467977157281536251430774161642528 +4989929495806193845801738597980701228751796772240750395477795189154079611747433960930484756810247462060407330702869333431213592 +2584408285550889731205066850550890247663800179003073740079409662955268984464235081016863796902152306425169108972643255331837648 +1846495490902027499953838660575831876113795963871581292212984733841932116361051031722680807069640515568611052917719380714508500 +4730368154761060853591867016650935034777443474265562879400822197268954342492544791524055284219250660710445080227842874954141063 +2999165237216316240588784731941187402326266210523501276042349025855852110771327522344504598981978041650966736224822421754899433 +2237345937661408885897695793709671176319094949111986436639240560063478917538944076082940836147591761497957719533329126550091001 +7598999755791735199200904311392506066249434460145555306422386713523721542555336766166589674039359217816140532997872100172694264 +6085462229902194135463330821695657542854346332891821785703935541518889566865952336969577854576497261635473651422862788436766766 +9330926718781006335569837395334762725138935227106710853342363931868717426383038886351253414292607302835343171708502682390162568 +2759725885383603903963134803626246023341697535265756560586925977858745569648871684971845885034365173610581864076735566479105747 +1316975221277998480665738247654385735782940591833339656446094875845628844928541054371377477189441032462815404076598890156931227 +5084047857098057061549088214576495134500797236087647217879151791731034614882352668503598335757353547259171118367223224526235321 +0797097525215466425082977546510079918770199122108187284931098479825643355771575695825936128687263528517399780086601002282738464 +5882108977367740469432474363253310136350409797015594231680654761034810033039280285322415385168502267113255563957206593967018787 +3765499022319437900072126982943230712423709856742749800481145115762174065774560039072882469409389283337021169962653600686979665 +4601581997618072107980461792417647044978305789885381659804666757198975786036139854382381412304035407153678163339829269303413079 +4804720639771780250811522331538529037693400650190090078194406321327819886301852415216493527923345326577327202798642624789731981 +1262413264233591997549583133381940611046336903584987787247990058376502498817637376736904140547566821566316367905947287384644751 +5776817509537024183629053964111738625804577685331848301319393405578215972673272833105126341165662081776587402862223607527237841 +3028857137505052452119497280084550108942293030946862851209526606327291674235480503744471700882929025765105260116471991605614081 +9340100683840148792620022922546803909003134351687693370396127613819896251128556322124687119185535407506368947843781106277912265 +5837860085277971472343245356960717599185735265281223333386501908378356024658012834775741482445665420888316355875215276412206400 +1493889817668204302273257693995210600140074382228307911629842034054862116792315868260039297702147104111933826341459504324514560 +4753667010660505615221578575743422389046538837003732162433830910088895626144829160559920876420293005201234062697339903600869729 +6354021869352141987691776069755076073591529011311969753213483772524805097648788519425735403544963778868397356812064242294599252 +3007002284988957442402223796792807680185699679494949671140500739304141518373349678385232543712822588498429151363366914067465545 +8768505870421737992314357883218463757749966400771061631074878673057982116800200818694276568644501192730861238043718483873582182 +2517111306024948547742611078204983908881805478217286398022649611447119014425201196572509914583877236045184752832586045682283149 +1376425079937583047628837215348969478849396716756967260659465804416943561566523910593617918317955498182529845524570831173841723 +1739036166752846450279902298627287438597800774942709861167238037011909085160508767640035085875297386568223167138576660874567993 +2749444684052418908020211162253183694144723421354516311236418763218072849726536005435788876083510665834462678112083821685346156 +4979778261313034734593447279308534789267778320343662336147199781647935359075816167778411424508493052174895307203375091235720947 +7206632108909493796814807157234843620292819404196257674170712616419318834035027854762640349933755746419728237290445935893359476 +7972523340752476063451026561953128800722191374241698295085331249527419993680680244353440653002242129183827478637542127263140061 +6106361246560664390746249407209413785337414934577733325155578012914242942249188259728108681483189855141297703781608717770284437 +2459983080689617774602481236618573771655193699359105459132425259318658958293509205828433466503731104595644550263940782605577596 +7182234637562052669040625972588934688697821675314146092726738283785184154736418695256280074985786382718815935852352072100348316 +6798709996334119952629721938215622401513286500076236957073743607147857811179119661766817565585334251822559283874472847953361475 +8077368484549177973605286548826253514295310845993496549862916394171225254015547467894554807332772219846678815481086218479850253 +1557723569466563274008492657223419903746768944164337126986375831639044695750746490501676088871281694494821017358352031765251392 +3419994305802489285895038983304368890483549511884971605938842543322203428568381657097437964153561863023468226697072309642108698 +3155924019915150179568158859379848450337436841515789553391587979303261228659176045375192003213895824215877498665997186076059865 +2999137472267175701076913261675494050812219217526275916261893447733447516002165559492227300890776947227359067981526656072673696 +8601098495166116027734424221556221472614130194797807299983947972112789211510616421380969053402247170620773625487954585201101683 +3246912051329707460282887222043348831157339566467828142441386949856139091307353393247884498427787480035549002968948796358423112 +1150576199110861158548115562719716941558388002376600504843363323295796185489468606412792484061811432762347078760084900402466948 +4752997880608034066503743367113742314926769742881109939696550927489876774818149369014784149716022391683583701555271412269098049 +4122947315189371954201913791790379829165934721428116210038908501041491200253464990161405881080768468552171131345401309484164251 +2900730978305956981781132350165898118101889333020350831669690402919195278513062935410969054110767363793161548411520509850489790 +6317140142444713262780353377445709754525526526100220931420853524029521161445026020859823577131205174501439000115119816705181410 +4499991523210057790779337069784661258008182657881453125037535965670105347302421579889956188914279278573529309721593121892469205 +5508146256593369763940336135259800659809619929794178470062048041370071430831208645554427627646035391559292722312680898801625334 +1648967526716449029810215023304697906807519889979105852637730516484206305531886474058371893246706713362439898050285759339179316 +3759482577410685684593596493926547017312369150876917333521714609230709447558843397643743851645851153700140054595127571231949538 +3562024855350127743440468170916592187245116700044293261821848456699166330596624128415577062851344089770503995251522564366175797 +8477766635255068732724822778949890633417123111391309938080502220545229819981424955190249946666498348138015162432180329219887241 +8326147305998052694691664218432203744648063166741259109591553998325744681167769329433557902221338261010505326465825260282053606 +1089081066369978288230079958586716934294819087031912657105656191281125863299636207713663767265987214971817617524167760055475985 +5956659161052521449892118359418646820302358805073751690270525811449427458601574354728795417080178749838253936083489079736869589 +4756040554221482987126925729358987605986625930694194674956898248814661136244491613548633391179640626903451535330197156879634503 +5269657254348772763363513450959859105237330221730828709908803147787150002260299247932869706456162552333441429917744946610133738 +5165094570822740809419687589443353580562603424278039485215120717937567901150913213688361129548604982677760158365547321585786532 +5721986004191270987440236388972839714531938869537328769699467486823118683325371541953906389947764104960444262942308606574783420 +0825423274999976416479179163665065444342056794814403615470874263539258759123358841581177125724615901000777617590704389294753780 +6742419699812742131364238655136167729098672287631443854160975671169256136755724718145831652290376122821890697634805848496276496 +3900848450956356316829187800619138955746586281240305331127062820418337136267131988611645101253214320267600642044789378308027813 +7768142101816225544376840102775693516634889161775441232950103285109025549587962218777853283361116377890977393111956211092720773 +8166062372469258701826599477785259752674604446062893635372304334593302933414637458058589360745838888558751703330971096452276811 +2564850420537564339701047323195837094030546459418840734199428562634836997313660393990033302759129375346102025176996197579767609 +8872870135828449673289983810960029335233706075121561262257287764860415827304140209641297619500143080704997500176861691643727930 +3523914550868909381989245660265536145050317774721868915147125702074806836551953216452075481799528663908105214114354861340552001 +1593559589951778598427586959614078571783195940556392469576085221648989891950185568932203712798348499019366215767685195049047391 +3677450698912939130282894253043150590674429032380702463421683822229640128060377145549638924052619130706857319423374607432012118 +3201722283329551818782298921051193764095244804825793425784091160773607662095205922340014721050275267634431286245410339294369403 +2407761928636596422414810603411396624762992445889584536298033386878386163466235099237586521069756385945437909851885956052776101 +4551892967264629771755662186507262378960508623998075765778878560332855343021946501189553259398537769291592769103084773248272732 +9106997275950792264693136508466046590049216555344492329753333502148103978681698340982507624277442543719542272924397318970160593 +5003643337652703728951291818235842005801228735393820041591928726474748137284662169580644065969190131576241311478203049648965040 +8986752392715741495979561841249049222033021019539768600866686767034142327899022898431650915325022449300084738502689817549514938 +9360763437700859982761849014720209991738148978736994931574590369983794309597034958260372656270656787930070334337332515206838552 +4451175037964641122624713478708404279076794770827862704532161639277525181767823672699083856308324336587319988741595847500500923 +3042463864865181170367979354550819973787820266099597727415684485159423697903917044701020373206808416942704276522208882269559354 +3048080200899219985092787175219925954199186801590258882778436766885446862979938621696230463254471930200991285622531815432909506 +4494465194385245878424876179842789271630946260267264275467756829223006003558035998437034034758226419782837401641627699056717218 +4254906820448949384513753027180628971432660348348526219339979967375196656324459448972917993637121707012531419527163028051764969 +5795056709264059459045347065077313003930925374715251843125468051992798115117609874425243624614071216341941951333443769594712905 +9786422961702175763231201440570153261798473160575498751716552119467779736203318520988291431980397558340560735449110931384906041 +4425505790631864513694023511858116075339628625002969403915799344384754821079679161200533710912237340094421570796695940926114650 +7558163384552078162151051048460153091046870543482529259775071328325205703384361917997334121827387863984861026567298429845774499 +7024151222382954834390823993921385978213128615164507102313528814208567079688499912070171914927156859122712993045849060653099070 +9429307166946990362134229731057708239430020956417601592711428461279614801214510176796114831132813782448589275144006367262952407 +6718941975166588281116323921210724119843734085559061091993083658912394337924185488399990441930203011310984521684045028699686488 +1289068200800732284238439423123562064066343303384293220311845805205731603115472146721163687728630207002750751276592100892794448 +5346713601139175262412572458619231213504622828349869740030359059521925593845499598173510818770588358689016443776827808183107359 +0509643523301353915236067697449265692352443278187907371809463832094767055096167823904552345535023947977150405485951950799761287 +0296312146861071422545805752124301678869184550494728174693762162879350214577985621448093757895707899661121270041521839117379026 +8409726864010205799722565483699810469720898682668219634727965108320651761711145638969114309423068089263623838477654883333920986 +0701982653061769206880551891091640218809670563459796391962611157072335109465122237619770084725609181414534082646884976727487576 +3526106930335563839568672131933814040405238902124634964052890265269753914225841472646860370300002991439661062411618062909298184 +5489284594499017553239845981638823575689673477128445661568350850251951827238826810782941625211567718831490113495662231409070347 +0761858518186015339779421490664354210470217380607247145985104277374945800693689645130689632481933731656998223732805590077884069 +9539065740290512427091282228814664586680546652097563995149483899551962642839270109575078586841792310434801955703204357001468021 +8203312934682104375075307914019684558657139598128081066927393125488596174624606696359883862043330061635166484866461998328167370 +0125977272761404461319903866680344397363067561278546743044165247263103505646656505183679223334371532724158953424891372755170794 +6917119468055808943262561786048361427010843965462318965409483983665658166958859076133376429071237660115286920877219457193653148 +2210582961962854397595552344204221218872408837841098089244290975638461916790216426889841183579823514753626176299268639366257142 +6938938279494808076759108059141376006848614180404742864748925105751439953802762622388768762467629341123548099684486115445621424 +8751508911757378238494838354486964489105407120238937324611137021997266296685725619021335556120419627792798600024754767811910130 +8942964732151281745754352094851080075271176779020939272053185795856508342400932987956154784656391491859464794187568016580758549 +7093803490558017110343856896961686184727738060163871518042243290379067462803909424058805017311424240997471204900355661374314140 +1566736119124005628798032033275204642554171747963659618881718232992872787295516246973812659316873285663747257448232242034285446 +6562507237663679024109994426672469847713139656813945226527911495634070212834050520202668179078431355382392103665110926728808163 +7163337093376914471075674332970801236470473885515009415164064219689152465011362048740380213961234696943727976782304542628115287 +3743855222420028553131853842508021542825305338712873483864679766747424043976484573734764155416545908654414383080932700776375519 +7834242892295013548785979422302177591758705851513681511359120504187140172485698646885346881713211672798953029529425679446990175 +4633893183134377338289855331963450809211760110920084232081216223646405738494934518180959043407239414117561447413964700328518217 +5433662660787097930154056128793373805525457327147412372094936236754711564146018693671222546348461125048100620268398154557791577 +5116486674264823893675387799935762509658389400995246436075653037631158518006706329179420693907432583221559739906432889568752110 +1646689708083793966601961846963380825939768409816872372745312253381435289673316700861369097472435861788080748455563750632269991 +2394913678196583770021969391869849166343366172108313828891776494450171319520427070741615104344197304147604907461161478146821535 +6970220265997137270733854244424832298730380713169130932100655564124041223879414671509531965328454187192449944156019761861229509 +9043786409994994408835814038392730289274231805044666470305971162880140578631950679277309655392115372566040718447348800220519568 +0260472202194716089247619131312603168906540268723365507831041804698080034582459501938467511494620080710391206340388730610940838 +7326118518322238969330571001468796819573761190336351214992854388628577544497438052708919701742914513344327189122670316147267946 +6390506784888882547755768957113718192319906860888999507544967824165514074944084153555022322181782516106164395236293833936377054 +5714641021392941796626276072711028884736425391454865594302431453743809683815572479844749782164523410744380979378894640742103628 +6367297859579910614284261237130263461592389581599593438725404642412171244089574507753692124870352648825973497683300706972608091 +6528879643690843406788232137812536357500339309765626622435903074816275044864634059559694905228929605192781404349845940406623980 +6885914653705063359510874305420852766939519431522048421204491529430787666838710231728773489324489696476746687650429532899868255 +4233440617969212981294448839630057962261459110072028596849512767604956758310477460111261843845740348872559542671712436710774055 +1508618282454022497140169566835479909506224026572100667557407598641042136865104440157420255694196211078208396396117860451776365 +1507239834904105526832362883413042406464314583874137343256081467177503191240584039921334732134114272817444512404536172921303844 +1462051089737008115697275867129401567569051007638125298802754342170903145796642346081652330045536281219892265708368809837219879 +0453685864744973901237027525243434738854537803039815016737120599127474654581496567442710142699846446910049480896669404203340348 +9346689990227089014642019407223078337725269644715473933462904642091284492249290308972584444368741981346317066840314608857364424 +3692842182371137943388889815198380579665396475153546930512504814795832691928659417816231253704717088404598973194431677726441667 +2526815319204901006066476270701860537782781626529137506566276977867530476935375522834441559090476111355166836264357254224488482 +7009126058180938597916312502300245038383750490075362057823728327394777642420436778059817272275806207554818391187127829756177915 +5110816584935888048243109800031765306763187568267294316288420157299418121619714954580527036028226556975389796598626288986624596 +4019814997533165299992337612192568036796309043358811887855691200355299547444919142751489527995336846485123932685995757878474429 +6005599839728025790953582536623365308961400544193243119538823245141014368431208016452105852057876883877763572171550179791872562 +2500356597670124887859667877622171934055903916486360738831160634956448169247221568037938498171280531058898708454833291828495747 +3109569215216409575065435532987897643346725582420896049058159554867798859087403090846590114662541568279219050551516019161353868 +6185483127396494726368946515385004646852626975268477683334752638226219119476553266373574505398051454753329418244962919295715945 +5344724458607009080560091971792387153222793929070066348570583467465266923727598378490443838259560132593811322661974372369019403 +8458407692595863178782843772482279508788218196221474525584418608306184633515880367399229446502766746947115360332883675953446527 +3121980707768424272697486172479450164639268792099956499632892432254994295106673987928794494946432347077043928557939886000171261 +0577050269924549664323393933836052936324274196559262739026908246179444460993650264121746529145829029909925451248158087279201429 +1182711132849414035693613289891027291528838438771406387710865605582990490514444755922132927296236610194750925496351082081251878 +2109102647103389955876851996958955042517697886815050668367645651505615553003883543425993431580868653965842109551601532047774323 +0249085151080461985544466651926919056622702235431604488689367549402288274733008707563604434799848038664792491456040962095929365 +7278999875589390549123015596410656975040860435505974009899756364318118677742869501641184521884257988494124371969275324199080350 +2143525889485226056728303512644071737922673006177865168448238248795782597126416756968158704999395137061079007456174899879867776 +5408947704672811574519430929617541968994408425732774912564950806181733784295540418756875998713610000715279835936333399272549796 +0046618750251923685648324487668060245166359869535034556031423916249395766390348943983259976779662337330101459084587467420377611 +6066406518226332392745642377882173038406100184159399300600456331777383902825125059202230966872433187523955621780460854740743440 +8412271363530715396852912523334867927661153444730211881314493834485030033457029175684264387115709617680689679312093978999879040 +9657869183165570826073481937962858496613310115706782423102371799566041214554100144472536538085009196821977429400245149738069576 +0816241320499554734167424446072196247447636657341202004109886635882777290094614656786148313850718338218604613751038747577375251 +9117319836426478794488912868694112364734778843674655117850629082666869083673489067903986091210347641126774671760575626609401765 +1008118532396406153376026525242599592034858556342525818569312902010080131834952260460690347206525525021427489641699256115948329 +9403478796471636735520877378951136546880804020374976748551718084257630575582778549740221982719791953968237118454633169542490322 +1286802823239946142833722240859834876694232965252258418975725767245437772637447581851118844815831626565504328510567619469003430 +8292609187732000353612944093829468343729520826414837631688769850723905562968822078612443055462285102551209743540366646373935564 +6195307285792520347832027057354006551256656817339152300843201008404344101735346974655890347210090580920518304844457209111402489 +6224596631460367862650134161563558944936031773882670339156933695467888462978309028912902276648283451994600576418116774756356786 +5472438323418087607827579818345851863545677098783823512135936630219825008658803838212318120192887213931109375285743757983871070 +3462295993623789324823077363153428519235539388072977171154971504655245868325675529422838022778549930317329461099449011610221962 +5200838592621585186795894021330350557903923860725207306860907835414568816984390887997385942459848064357524983387010427408109850 +3373256185275744974070989354450321389766066372305525693275351316959271980719451196548752519719437550201627682282540860722912254 +5801613469773755028551251430496692677302091408721986707132740326731209806971448849117149983546378567141073671063743582525928527 +3697803453226110613863663691507092125649804560354539788548901908917360870034087584677937779281144785927759366742473292064354073 +9963717672138768910209602639579145502161357030053667109664830302862052329208650435316813897369377235565986275115675225384254363 +6761344873607397157287860030945733938977023836366529156220217899463330627464716487783276767734588772780285540219618726811099276 +2472361254288850026102274317845905290678407546967989656293686796378605109224367092391377532276351514638630925654015471910946545 +6893284960359512924679289275759756168128756913637757439682764283483027618435659261867805209746618113123871290501000298928987223 +4604230631532001258913408929361874112508575772563457725381109205712576762498230243782724863115387239822706836827854691589225919 +6353180226120522335706585585655463329450214403091956830465201717296254555917557791034667593584676865134148740185250129625269812 +7681527901091326113048786722462348325784769942754780702258059604458735745233803955056030921585788629283445553041509260093245352 +7309220586489676352977698261496440058970947266199089765873965038198042811288461602506269407874212537834374031596895817266480252 +5671380781713371554805278200673327258182545730441250958579106569242653773093761570049297046722445961242199585137608405012572007 +7828486850550976212754252064205756489990487555478160661135559387233240543781534504267534308047400112433806739577979094229507603 +1735652617764383585639984486995149658650155492118012228612717608699086389981358293860866276067465797190676060353147557719908880 +5809608466540093565672420660893504333126497209645992122475383330847359820073574627113129012380682929130905963299348891171922548 +5002869804918377770158242860178234038771989441187910348213084777623351555039769099812484337067510542127104020429900993982081671 +7709207109088318832932845793851072838104821066587277352066221192004565750065851231562111055731251503571280787745188052871173891 +1300675988020851714469995143129598445432183378365444739669948446307812357058373524561004834384315759687175675721550162755500065 +2986343436898030807360652672895860427883496016032784149587776588259863806298337541233639409877580883769111783951961729854269967 +1601823981755766290542611869833989750039385604668769648848238807861573337182702195579127745245081404264493592362053024115769418 +4107102716492675980158632893016973041072334043127798725365792088221597132425309628489541173280546793641323966773146909247868755 +3819683658930608253697914654878640066261793324512623727802178114862630064529284630973855427311675132424529284212748792990550668 +0736093271588205855246000014782826243591602482151161574269309829561758900770381929089531747951679154943426373942743857678907201 +2579391599623221851200754933465381040789651168701188912204464482208095449667962715138795642341183881460864419304811104815352329 +7570162647614550188694961496075537449438462429576197619766568228578156257291119319362788331980002153009584790725962518357588642 +2867301400919047583578998934993306274019943104502333712247027666654628326692485228040996686989047207277332133939435024962426111 +2800118335388070264161106773949228910777957160444174345990380796529948251126974186339060998840435346432168006747571320370538154 +4476893884627071583698402476874552862205711529686822374264860104226019597554331616506435529408791452032863624032022777509172662 +2387360521387922188586138212711962601419570169405135474539424296757638201501368935895796012267512214174579198583111876438042196 +3207944223864976640314026742675529342045001292563111065130367748865114709153385711357232421423093197866403543774881366812947410 +3024015733350974607130082705448223007580421749047845265584744661269361681112069541859763264352543531462633691003101294808859592 +1169692162436061367720119759930066692678060291627161481443668541634202666603165593913992477700731194838349007676531720171279849 +2751165267818731079924541076614810221037738242037928099580658966017244137214097278777683446450716576425458106456674343770827281 +0396856995901845858069688500739423611458585131275613789773338642449531843526049135797567793850609374983112677866381777610197584 +1531087534395262206112602286543697479767208631357778942636385138053327121554947922895001619615466561594121066079313165604153569 +2093692637556395792176696765614996657813671032355821221008345920651772816571893227375691474134293122057079026746734194976675858 +6656377492316720744820927448196522955924434793647944766092359157144753759050894426200065451501628415477521405487862719508590906 +8342026934212011048128231645702815266555959471653323962526192450377377432253217447538860983839942343996469379287531744331673799 +6119650763732836889688973448048471041648065382987440098529987344461076331072134069257926150018448979279801859696456939951283072 +3364756734455969829310248048507921203362218977909063710162344883654504743601191459570909322659994691353369156210663856657262211 +1878353636597017372001364702577584897453891661198546393569651046602221858825228640216854117340540870937305588763063713204215566 +7246416818039080901692045886943289879346943533530756863194707455582283075691686089441132581902594229725501704594144338085541945 +8508829844172609725721048474190455937918008659794137613216237230265268215971845365542440688734702896182248548131537748110574617 +9749837159931616345230389269791318525672049015765330922830030005687071010042562156668767526231766645728311230400611546831340883 +1042438692813477410787838927504883371438184111986343392632454033632895691282059130126453347410816312739668264804223203706756562 +6361009275683200524885847104957823290376975509915625274519396770442677593644815139040216252662268629183385844801360269251220612 +2229763646114181877287927118379174699532585850694835097303121614336315830870465640665166803477820913104310061050902102789844598 +0133060603914382154852269620976632642294770629603193082836985616373167078617561223317446714275063351779922957184196466970884767 +5219496051735919324804049698971068904312201333312370591154056704186542719979874616042547422134608890139798422893654424476506469 +5309445174646633737921041425428020908437429638540244462052129439971214228921839562115695079069371301404828066341916732725724068 +1929599109824380789046935363381838679112048207357698712063450869013602851026654755608800829647182811384855047709407638244169874 +8711156655539521674331213489806723157012020673218852893220562275184063123762927470825532953422135931696172529627131694897868313 +9146092529763359061139625016856546857269473202244951373230403084240273596615596144680054956193346943461881907308435567570589732 +4427806006379233157431109769793014446131865605460452718401487086503103098553754737499082181376863362004474070049162679495304786 +9908319411586467759323529251895892937674894302534759585448543523471481019079407250526711177578259561097423457479183321229451626 +1131371780154610377491766557592293428206914537775417828678921143427727968850975607814254333398412178045797967112746828184963972 +7463947060005178881443883529993444944563705484864960478232839522887114302507061077267547873033859704180182478601068253214443547 +6363654733262110562720880713693267188885990129857236073837004378034866347649760844198517835526780984480422568814264124396245788 +7422184144089713717140409869475766686474514248637954570906655127051840364408955207306296810118720773449322716315645914875117890 +0847277505961582786741295462154437342373825998662718119420520873688904858163025326891259732777158377960920534957757187301680750 +7127332835591365255818677928303920688285753363566564622227243735455708574607542891965353908456436608550001451776173990862992161 +3829054399301597187964270168808949938169540225900414534726047012413120885338161369990845308813286961059592718025627205221770817 +8092148297686870086401035932812080011392424084497972356658952923082172309746025699168011915919281009722984056602687718337362402 +3027398748877048907651150695381083835937725004446873842854430149618594741819924214123640276762016797602129360641044263480412772 +3710143070992584709931252199044234825397803955966283897640299886246679348943101389030142066287790993761176511866201467864299707 +8525777612726675246376342834401281272453399310074719106459898269090225065025922311415205451670630902470074176854745326883762644 +8262544278833799829033118364917993352082125138925496717970983928091600634758984244372250880458595883955890831596406628913521186 +6897853799297275638235876552327431216883341950745982036695977282177864189708565950522537254131161076036929940837531981536512451 +3213748658129585636531039879081929302798794268346651462737129452506002968774313717689240477017446831448952135158407313634350442 +2055874845167569647361541785365745319937172123917988776868257061731415878495755011208403654576322652419771761741735204486134128 +1873586980474608471307789365974467503495691071252149719435658541818854563735190343177059527503193288117651496365565656653307241 +4168177432498780914163093904219938645313613562804544457122557236850377399062589146156364240794704626265205228184552480787389528 +6002548119488363978641919486071068284491204688921592270835983882131004647117906646204653024128798598225163921424999116659512574 +2157407327085931030684434640191280950835140906873052295703366686157391470840100604628128222870118102675339834080247719766902753 +9516075696286688385617312294770633537786940805769023218236327039881513937432194699645278901401806327344576080861704678059497048 +6871189362548323056223946109945917378776965980493422695153032621053464957232674797346887230723234348508681395275248458966927875 +9336780663866116286377027773514857490216582712388958421219481975628619943979311778012113187699153459212550397452631591800634557 +1884225357321516913996913776484184458840279457439252830670922733976854064570789902403772321837879511792814698370553104269506613 +4608342183802630938543364752477985342180204673563980704638103829760160093636516325877632052705116775395863314477370432360214625 +3293602222611238360052445923968119215574068058661794694301159396049393023879006675439325347420522015724464971518661959121953285 +8043528468318108109054413534510021714964009352370382732039845180887830146914560592175998791412497342760924247174793888155615218 +9953136600515251517270114445026178472065320103271749951560132315486968402879259134348096557033081980214662985678737805295776016 +2082425869735558279582276249486763021868424618618158613101945224876744522204200404218768513612549469324132911065247448884834161 +2715300790048270780472694746992029478410340286154036701148546125752257415749783382221561686531788228065371707859970836437758369 +6586934570724918966767618089617174929582836792685611937969070528242452974277966964414407164887044841543253218406757856518905749 +6701113102105341541135759678684819193668388121785636742894877294681466156143067331027856246686661690573758062813040020779144644 +8573371736029851148801112116958518768083768805313811181481300256743484459392633904102235738743377368774016975057841718194084994 +0319902874585606893329741100525933056084182554392753427931707044407179198386674603799910970919558297811591565044725137884178871 +3211448717893811033719443147078575334620516368575812396883003880411447512133976398395409888756416803178312866623025053382610669 +4561353382089346913344316837392847914820218419836561651969690056195804908190155708078402986544580149409461279682788447362287221 +6541324108089851136771616890125941444979071358059045831564141967544312392874032082755961068514362364886944531733042486972382351 +1947537457345366294923388536623305727166280503481566200274732091551547741549840732121496504900782994752246247415294786133670139 +2790662270964346469038082957923935596601670431239525874522807293008957620170868585946546458722568195100218646703049798761457890 +7207291855021167963306163201383620528292099344156171536132565162121580753163039591601562538194503052311054883261440201088776719 +7081508994123346370534091387062163390235318525916429277771533969354167555829004274478142845946719915110847480617275074050516329 +3008933084371763781228021375479207498806120584984898188493731541257384657224732160257247009445015469067201744844463068899016846 +3400853085115213814503196501389761175483359326430453738990669485692964833263969136641748087708764716019323095274097377414065683 +3262060508094820191682139681063256834961825192399541866597766579614721818676700322392895466758698832928065782064894903472978312 +9760920512587884215163543988536526156574865982745337953096380337326849623081010538502752692990846114093305595114511445577198415 +4534258782640418619628264506406504403447005968106774436451122846867047076694261073542029684272737494317052196031968617018760037 +0005723042928179923030772189645554654702738582913437716383318676665447081003973531059059732707456286646505439805283337167567513 +6867755898727425848664558154624878031288945357600827739272457697556698844756274091214882872082839937589030308224565293706216309 +3727537228724168866963116807318580861851195574160478712150379828696545006021644250770529425526279645439265900826286791538135930 +3153997389799559939607422587882124977791743840140703583207584629133167628782910497529520542920062933572958127405711490497737856 +9067474435390875739488758031979945416769209293461704806750415570467527973320692921500611307072408238071671039355350126215323195 +3397087786775809367683818985726713074834263187298828458889483102002512283284602983872325517586754239568315454503146853407356331 +1156217453455804570907455838506537271360924924818686966590633031323668379608702859282734283827376245634390166587981939981633250 +3412106433453184147582934702569648764561354607002098617356742259624760387826342970038831595863063739528564750876654025034114351 +9541719290749487737141992118412804491779799111981476193385533300689670528815189491502637221085072487226634588032661043056759668 +2892064967147629869694614423619676513067951679311770744515022309616589783655846699918308471661872732172650395986258940991120106 +5144184865919978928920815222171229181997238748998964019938552954342118630154574987629428918689878418879411760377091395290416344 +6885105521575830610256425097707534533542028808834255387318107287078639558846084308180272966744285679093270081574095013341117481 +0825712842225983699546990461215024477130525988490880256409773994103713908818390693122587907689102651005737105310805023272218302 +5661584786775396459681434880691492087318430940497979741425101788956553140338175653002561188152737818909816437963790481976018401 +2333796064755969606150287094100220527676969430567702969130345130599373183629780646448254004373148786027781444947828389799036231 +2370159800594514645060430450080996614777495906387714719376787944968432214762676658329959973122495250133837956302119421564977403 +8812738504000258149359611948440268119800977088619535948947126735318099451090706379617772423943777604512120621890539370786597632 +1363253012488373680482054568974446439190725621429231276569324135313694462859720454323916583978487818838914751980359776090418942 +5309412448985837938866251311974802939648013868273488976753659392241870912692861488024484868367836148433592247524575436350374927 +9969514974899115014452925807661936280550953879875740514792224284344537632692977097082883985126798768022555743127429841568583436 +9127480468310694537875735497900079126170848463529624094796935948030072227221587835070990509651876620138981087391650544865276910 +0663274772751898865701481848764433338510687274568588217413099134231887382122648096865873338497066278774094796953376828006000126 +2223991886894820013487780739895880221686260123953688255289857284508367990146047269272253817887508457566736245360372546074724620 +9022913659536358863270572069247332195356175380482645548420742634480093147625717187780842180713151897503373416116801897541549813 +0040126272697263557284035143648280938089213881029883862911870694532327995219687847437429389232425351493591671711796587562791256 +4017430425461987380494086228031466897556783584467938250558585791601061306591861372175583299944343371927286490389555179774602318 +7872955211264709896492762009841470583148357109101357998512705454425930076065324016499469004837167664624659717653859578461687235 +9667310959423600740682018043806968632350609113790915003388710593533872466670325086871976600837835610439552558719613595783702236 +5280944927395295859052540423240381366808883628148042644568662154130067762884915257137995873057791352572012021048384019627522811 +6995106927652578556591681036413486142384921333996800868230237202393167717311762878194321699747706337864446498735182883503516810 +4894127087101054059360113153040095596503789486674685811347198640008673703554343464924312512011781208631600506972544379180978661 +3653914862578195810106428140030210938175294156340298752901536901851573154592330206774109827394766622168822827213223926407598523 +1752287994131637967328932739154812431240663561508299992489581255396838237199970478414918524473397520840434054432691053868383392 +4475254299662836002489198880413157763837585826054191105485073144949660180125415108179810953128183235091235263489809711965370068 +5618413924400018858280428271296438533254641173714166471746748160577329614446433367969692047250196643164558060988866789634419083 +1976673569829377798715474066924169354140929130742194843186922903877261219583485904128878654906618865153383966440192899927641018 +8533161119710252096705226091491715680664590252842043928311396400578644885931777054299394359376613317844464091496561469756448904 +8685184190096699452877940339075889148354699442923532123110999704074604303853725375307368452619373244845552599196580274471194639 +9829578543429362536437207266353476212156141077734490396691958840205815483098775874456262295189398128556239354143693110486242701 +9970409655619169147931181826146996933740442172396548865369872311637351974239103479278809874040155159335694067867509786798916993 +8934739229131395268686186934227620999682967502345755750450754377980375485746895673108969778424574385778481433357869228670933712 +6403853140387575318798294898252560753364466868740386419346298915926350400035543680556378607221479519818692502368546406996064171 +1053081251212324305626596587814428006013451031378599825941680949090154726066128761151070261252589982556578267160212779194125716 +2889755089191961889036525987804900491217472837363091046321293846058934856253393138783914577483067599584740608242898988136077107 +3871240659195668412257855781781704566864660291767024614816347476774763467463583115867939922590382680508695307915014840948963808 +2822134512303137695995007841922537885648949227095598324952993245073100048846948118672641286579492473549786447729014913418849577 +7115799710686817026544023974604506965289044028358314166807497671714007777434113787389629694840769613243261303424414900494011898 +7392257640112536311638754807439431161718219269700164766558394503991923942217206220355994391249150834799995352874004008637120732 +1738169836253384974782709569139552429502554327170357536474522232448622509720551967534903770682965229229310748674655279819812001 +1013488426299593714852536878758330763717657950972685023529624029812092380027913386862035092137102088651474613519196497838916967 +2365712331332348797178741500614741133803176085015200716152828860157706088237891249512432828832383523202673780925247731837609823 +8343543339820274706718254393402391405027365642281414672601521735599554959777377014041823630157212633295524276413560148004499161 +6041268421639300061742794731401962219148955309257726102832738599350862047986714418077392903665425072627420761149419742624568473 +5903163798089327161860705456299199357142261228683379549747158444438483324626130181126533716219751215937033507622299908730009529 +0388816251038799487192843352437014500990877413652618253793690269472286848421450299377527429839922951807455986611893857644960410 +6747097789593097432933016398117542211434597285816625911203020562919342940284869769635598001370921459163969583961849156409633978 +6058253598655377264266980145151402530578841715801191174134703632064724433621375404185347776838645447066321662228541280092856110 +8706460045506764337863851824656889505997963004840404222919355019179623835893581428684583324979366713626899343900308968866457307 +7217115588869155277775561876870949020701337732105962145058144137569073157203270186719489063643062743100706189008644101702506879 +2134117466607949382162669449831544904500037626615605917490932121868589822502449721652777432598078974018800021624932345792700743 +8772537472143251033025302537735317107162425743475413816038506301465925279856675607449722802889718409431120703912286958510209941 +4868004080038983558128526716248086993854257004538122139718459319434617070817759239833696965506062568522567601751636677225399970 +5772707421791629107161650375371738241195109244751411366251362152446624847548801413381446956815082676765934768156267696685640257 +3337783332137332131442737895629161974159375156476294489620941247396447219121871778030180022268049183913926389862808328015747496 +2718665162373177306261228085712460052227574664675638031209424855973371465310593845908878207798419801473033533102851536608498988 +8594650062259102571664509669089099570629940328720500583665382040942904077679708565306833479512196713193874213822763114277561821 +7763922398020531727099680865423760176807414153322182938644853758445162559723450312367220101572741122819976006288279862925391533 +0609418074163954317311535425632639460543917210847556877142776065667429208580080239400632276304974925905306867007809952150307911 +6324798067968629831501975773028726696101515750158909358262168518496428350181893495977033603403728917956907772455104980623840611 +3585603421384321409739580272281986370246357840985885096013164036482124665391931947880815558360671475167152552411643258730493458 +6674212278514790724079384829207583320586965949581600859999150201711417012504831581096750857003895316139028753798041233239967350 +0724838602272073110730847467620546382405164306488489590470927625949743749910925230346070277479842393578994351426637786933239473 +9758486324598916254826474547605389356962763994905059896268073096288839687527478615702716618454224618511400537520151578922366430 +0912492025822760544865884599694514920137845684369437041888556762598262707248611887100015044910247510922363893211117566916277207 +4970896832680655065722060515676245073680441413700428191825160119923053062012241474629435368642857468208602093702394160800952368 +0401643954061460061469538963715677841733067884978557675498904356226239814257513498478706711931106662782912959490144875688684392 +6427801429230014330280067244320390813250002494116054667882575684276220510978170909405937360209445943389405620264406898441269151 +4513961131947927648793953864754056606418638015682203461287515973198501950396575668694970608763112445843545620657603445132209084 +5756001157040952762796856519600056686459818285012859365932754153307811718432937457957972840218047257233193928872388202493970468 +5745171294650962698731398420701143198082563097452816181021021324846599968746630383827244381072653879098831871344995918422668994 +3440697357810684087609635992103602934958412129332726402190737073092334237927797275626663021730679412659760103153021222137031354 +2561873488408007135940986273685629006346887762950502897998328704241551747655409051903344700915847431066705228403387636950645457 +6677547618819900422307650673816956131536670246263056210725538571359966918216630406962626983531012334568659195035619701341684239 +2420112802529724475156900639848021386946999992189525298915178531829794178899375316321752347503745229384277622075513609101448077 +0978966580118766906719339709431650123507257526495690738543102142511117335171869720713914484644191091368983835287599510980274549 +7253035688826486175835885694607345249760996565501754434755643707038772708239856393717371875268895624588946691881982666455004955 +1229157575767360965832607989363181678043448764770403987112238108580504462888836301106969202711436540526584606392030520555629817 +4303800215068042550679859587110369621335305905151798020996167677493237088394878180209234115765088470219122388293468346691575131 +7160108019683761926270404198160152789263213718306724711634865022789627807005870451606075994736870542860235641292939358601690892 +1281304446363067443221484815128597038007892955460785907630142069752866701460026126386319238710932447939095864553352289508365136 +0314065667002957866858488765937097697311458242916562733459459218151551894102884025238852720369894804551004088501646041028776937 +6071040163745909418176019453877965601147459065352750105116872007917183143758403418504559900007858465882670700927317278238845262 +2057864431401330101261675645065867887669270980722933655585800822914522258771084932227437807465603988558837727049424395413086192 +0838403065062402417019069366493917705353727605973078124319419683057212743574597310780151384502291168595626908520023754345467963 +5237595147390251950945857498093768496867490339391087595954081288707206848402637964670896124834883491892023218043300933428536303 +9038575918527245239784697127935511565993493329345587370301152888215360283868124687096008034911588337723498130857892917083893566 +4326309213195337889918560482484162052931169753291241688638438611871045719430309380350737659700684663483713556511824284273648934 +4109675537859830665204217999322330504340383531423575355281348688917399955785319877102842092110480808916641344634371327017518067 +5976571379562477291805315122658077767583602698526304594638663614898936945525476463455648126285604724437435096863798048639029149 +6805684460338235182637901097297785029718931952225347991353757161498388530429639352729227333463916470311358261242265252454882149 +3713554069757475756235174202220726685159145970448234073615786797869189321230621988473892723703610057245772568034893831333824268 +6384329807418457095553971699330059290079181553384702995369891469896964859336812164228972258241580918221240870171611342340166996 +4238496467737330476039022845048701321182330582443048269767680094107459509184801830653831569366411726902088279531793681281083241 +1389317145760821195180078109186551396173257466092123382087137757380977821227017398905747777928583603397479220222412134551964141 +4172433396133877482307354312025003410197620920424049031355359918529883398507939057731022302176139038905017200234464598134643926 +3776455852500808911518410528880591214453698534859661007977301367112639128608957724121376845610991533136565527742397972171004531 +2169236758277228509207094221732914621136016542832442557119974462763405873279434363734315812872035133971702886820591857401769365 +0469858184126033613406108887661308724723319896168974862654713098974773391394034562612379275030863451007736429954454094411166680 +6170337864185847270755623945219598905895923685556701346236877669819713556924060508835912462997027984549870490684576221788467996 +2684567926478205893568909529013411584469062508988939792621227026970772272619563307265559984083650571137624804538833124458965412 +1535835911469765914801129303385752847166878267150358870063623206823946840223186885612380869419340578863726545596738437580294661 +1159345796279619020659424502037780228138063084481952522217422192474814460650570150288813492963026126513178935693001157815213888 +4115255308469968312956667592729481570942886979872098274544235236610800153069537830562688683755471055934166523033112817689423559 +9188936491751459321231439471707842349428821745374698747871010980962280880750506886802895843191246598782044554283344177438872823 +8347722755763795357915434510354216096329858917788023158970394599943300789945002208151468416849121549451743359325575523192943247 +0386458822265636778073946364464754663546374429692132747455551460488109624863176490317455770854516391720009905789081791014745242 +5441057113825577288143510443291415701276478572336349873718556812697918623782132025707841689574266907977935843620901112527314879 +0138974051576176017602134330816942995720273624834286549509110307443436271222852721817459586302582019304440451903755250893098006 +8714580715983710618302573323538613568787984646210126690769977327196476888780472811559022322326994280966501214045283109750894159 +1238724204438864658817267118920298143255297575901621515081809762078906592560699017605054545611366055292052387838303773046414151 +2117880548683675747162798543936995265803158300313026522266732130084089973850929862579530307924250791678839458713648131052866542 +8688866589649054666206289287368847639201089110726068276561807440633436849032550737263946103998593920752309241137169715090564726 +7992366978913349109203408811669845313806318145335482602504586472079577960741456598112230859758567892658655917499886892820156294 +9269289344377943028314943737975747440225464454099585770665233191895455121597963497469457088101021828673050970000696324467074275 +2620213720505096912466481021388401048520027588680889621938076715558063059090115474427731634806419367474059903683493740456083416 +0419258099585668206386510983923399175364308512576355916179825772896253917529784626455469847416203745543857585138629447495124687 +4926957394763419387802807256844093371043881188012601196274750577103452141865582262123425456983325248975618318937642166941469448 +7745531482212763608085822252151342022701776876422939982991937310338710298056659311711100694774221511805463875602371671771107991 +7622297042918195524581284988624821755976081656742322232878212092814401063399047757727446586120047765852193643525978220488403806 +7694553355731009082341963145016321622315287166497298675517840848325124707270827181601834343475566034855078916693975601380159131 +5691081048224248376219969516692299552551684485812747394911625377626308622713328149116932634160209525550974738125918251287523859 +0467965216958213222976523551707473542482226303543330237484038813545187688169900375790194437313184877958505335015185533760569003 +9313388170020500404223350587859029392425277844920011385363704844190916888907282100497715918895587428711392085764058004531043856 +4805593106127448601646584342013400666164278454947086863410933724954207481882298946080783397578430480735942749099815836074939980 +5829488935963766897295398693976065473334615080031996490066697080972996155867227149556928263586779745098746381741955988476480256 +5145688238158921108920160861540066499070337742408273263858244236306539277333029376512623358171655471201632148566471544471879593 +9921214229435926996318797357630113668084683534980450540625624914828693276400997437801995497337699991160179152196384869788686202 +5452970283364847951628816855350106161884215992345914720345452469417460755112437907196741570679787585797744951997013243245883760 +5291067302501955637725509930308800308821879902449540996764882569862895237545484938003965194362900224359317192536398128214213941 +6161982577027434530385173942460521391267875161999821213546453369930955209737128453903802184733420666743600784696394324963677611 +7259796660195828763104609417030954701404550411856256961919298349416990278446333820166279192694569999689157318159650815071786127 +1409252775006780923895660512761218733793242701073753044161926851887250329246949307610371367921483913476091276544943910212219648 +2024883815854805620725646102396569531338296559295702755514936293184048845778213281077499032309766928238274933799920207837132838 +8210747670883127249029109720500900846638073842072735692712299242482036224417598293305373767651397688387681839834164347629159924 +6849912340362293051521285112884702937904971535989594393302698489020568178389718625627324020502329354706893589619173731210032692 +7043789553739208010357759707009160597258827438739048435319844873364203025319025627611147486361041079291073784131340379802864271 +5630517567000455573262321447961724157507366377593234074637396775521413915860857523966422306759381837353927621547514858375348648 +3907374620037626404876010563369584978900791842626728009855287567645993864184962785602670934980414501849977057712840353440946698 +4146385141059123870591051497280881668008298341992956096236493101498703482256305064373982480667690632647788868461225656591267014 +1968850563894509480587740368883124473858275653505054105229249423142559298770511499954927552803754424222038587228379761857441343 +3593066522032907759239532950409720855609763959255411331452747381650146615224156577229227092417969990679672022642682488460230666 +4777284684581020086703554379926122352924845140673649610422757744893763657846499512591483929572896919893136740342514388775709356 +3278001195584405224574340518455727489287475412287946187833805383833415237459010850315390550944653852931708140442412147400013062 +4193626826135963841422031213601650476649922753686929704940497664287967482680127644394472418039840709944058706759350270065888771 +0496707764123239353916969348556102234417341754509205481354601177831190831135133718891421262586922485229955848858284322651713550 +2364211115463126546765721277139380044647678205497997698025656179147544409871931320460204274120159204240964415234469912669043171 +8252385686403049790333736390573303996823129984313927885511658858105668489196273816414521496403236288238282761677474764476093781 +1249545053006377773498004690990118213356171931577992909398589918937522320753583797192061779831406344206481621920250152295078939 +3709843278222111715104072968292537550135689257500851260250849491755576197121702408117922267107801447424437466479647604658838505 +9854374828488017805142065771759506637983062326803172669751646781389776006196509659848336558123328010610366919010236885546271093 +4449279473317813512456203547757437510023295240020059908269371826627596476653671730054696042131496333128833416321765418914320719 +3406255777740484368806154865989716577772954696365667763046622581695081667791363935783289021366520297269972594689838903064379670 +3971992965532938884360604600128828768832371480402617473079458005449743185395881312301575878592825423836990732749119210579499565 +4964414428994770524920627355735483099389790803639808833122768311697123316450497548024460387672711368021069867385676748771138907 +7272947208705814863061836555172890754692453812368615959884812383294177521377885043762530023437311935454983526848574910569784985 +9715236460972266941105456775641088939352379849288420663874812734503948765928906653066695278788734445614220395365589281481052985 +2219149571492569121653088856413977750911860290899252411873082297287513781665034941515671551141663335672214686872998009233611673 +3252445083210515790502427230581525204628936179674886617751355536540130374691771589975236704266655393863956951833668294842751553 +1066643170812591610511115847160870442604844517253754311969780356590045310298592533473063715395834561034249527692096332630663031 +6094678693574789972643719059293336351890222699519292906160704354339193005774875964485745420773135852897610846364640226020416376 +0078821325017540745977661794444919031229533952549930041702337654768594140134838827623154832919375367293846998623573154781662214 +7359805369711475680734455906157477769170543397898162106347663466476684547058977605857152935135397794083854436364067424905370520 +9053319467618246985715935346228519691376765059011804822695041370567668817595587435020117179808441224160004516561911764361051760 +5279785887324494559284533174001913906340668600486179364934683183133265522486775587610826495582037876134991475823478304604306409 +3941979376926208894324337577802341103192284179207690346815460983649049917703085665853453770292030524017689837132097566609313622 +0874696648882529341619751279943169854047021416531564941329234495433297775450795376776860235960754121606226960482122943806912723 +4403142549129181418798689888112583174439363438245360666469436690361242515845002333293117928704700704567851599171947638983428803 +3086178172887575667595570158882926151846562563832038255451988723965663322118638716096644911129577785347672668155756960077259260 +7016060211620447349613366392265953857687262706207804671997611538526738050334785125634177152240160503249217159499633364839660140 +5489512175142718110444335510020717260552562939322469369407097546446468340557730058147393474938996409762845800786386613781180803 +5316893398694618358236834304108186582233111640280225864142166804368748966281116139163914774116490280764125236118841244780654205 +7528194334785274348270807743401184076977359005808989097790847628594537909545137710117536079654129720175240043680499382931315617 +9670385576675265565821666921824539041489513174876467496206200652157451658908879498586135223489695875901066307973744711118179562 +9293554881752014067237144247792025493783429506129044867060712220683356640982811741139549073541449462843252209357539966735713385 +4766042719100373229390546845449462827735583320023428894346366740071025652090167656518273656932135482003817661060458673642777968 +6301526335239349282461856549816100522037177673330915447520746670914149246304276129215650553527297720437502141660843474787824161 +8981954968443818080133345527259601739419841565729583936192031325311804839597158161812415269217752774138988523259895019553556494 +1375817110090726843596408461202879175175450080051006863993971804570798947994555625585878024069026053117840656838335462247825434 +2951238989342425774096587516368372195370856662387116086488893532196578602234813604266303300411633704142608233959411992656817117 +1078366109359744038481314864313226318060249081213275603047710120330297564750748020015170091244280923403487005151336327967793644 +2590644710984063836471814396137903631095128763841800600303330827770204519245855428525596893191150792386804495821205935562805056 +7587927489845850917488079723623306056569190541982982580007185500509384196528055437763768159799054085157690272308144066104571631 +2716691447638059359782976991714931875589838509515317643963169052633209626064370311932621633892908726622398410656122098501462508 +2187341550744516068766043103052788709422923668066123030675357066234501008353745371362353282261896383609682551818558419836467474 +6386821883063127753430057004971408049021180273353275003607608462963509731380707112452702494852068512020333193164120541304971821 +6414619855917522699462290111082170337250489881403447602549155371621815281167692543542521085921503446688385053019234090686216914 +1514251753750908058132963706101498627247758343884090328099690893144318542740931341743091728225255850843917610568152776796003007 +0586747600603620622562637108763020672642036425806055677095355709416205188154703219135342081900691181922293308472380603914641966 +6943882703466448671671347942866066071729197097929636191832480851465967168936588557508460013143074231989501890259153468168582090 +5106944931177904690443492972535629421878279108027478056702348421231814228319595001969285380236108675594104178148223368821682505 +1013423077468134180344202453328649263556597230333389978398486618230751510288831048067335293062077986298410020248356624260186784 +9609742549854821633067526470397698241682366743287992123678759953855431672859515457048320102063982700799641338555460645670603233 +7227510683690963888209842085118318517866633639207568611885740247627869030070367221673493120062595703412511430540635725690733531 +4166904720216643652362019185541125336279973971095473810174484610634739482031555699998920445667293351815342116856019765913024721 +0204685598907595748165591866024787377707833163733227729761204199756529370097242687722444149797918578951904826714174399654373078 +0029695243252514591043935308120948291772608227171634548103690625246068887952914933102467669452782090604646361027594958463008648 +0606043910237689889945195721316745105694059044358961433889516172023390307325162841023925000976730946622777686367139699337140288 +6532770425227279669614506342121365572660042996371513972011473090716295756052824631404973053818570282987235859556502147507091296 +5784383703297394066201455976072965897350946662861440804630035111722516300582625065762906422553404492330383168345359661866546635 +7755352359361297136322168309187217709956128684689901207140385336402261861792474715981622821266358097679527860080999492143093132 +1766368206837633471921145548103904997241216165904015409300725066451342178028580494490424756975699571333186681161146526160888637 +6435676017243653308531673583521916536301571057843651379516536378840317706213255198563089909258098489728121633860286779010828363 +4431604721944445862183599288814310892377084499055111017374193726585680550914726436314439993180521094601524845475777232173548652 +8838913044786662722923315829866963645973025803566829523066407753524509752981118743428995908031509623037684132020735808440759714 +6831533201518779101708294838185079163952906812726056828622166710833228863087344104415454342957894082410432960146722394394312810 +0026750412265305432804678135281250107474394107101163961158631241381326874456825116424953228542574854725058161235809819422717951 +0530095666016377728309821374273950714947770494099333703734720428753672558560341529622248519497385032763976784920070775745998492 +9988103492323582802831123529566020729884479858348071107686123450154590877464099472518837056085048970237891379355375854402767816 +5730632914573233372640655739395224654373166501801926999740491530052469701082483441902155873112176686047852502749353152358488650 +2570177044053910045946498496953083595646140791798652856797075918041625426521730745013108556438270557756261535076617672897082024 +8070822196216776547306746987791806776779912117872036753101249436897151550298686891155685227497724326515850755173992122017730073 +8834834453446142095731369167693716173639921382555584546233080228430284169771661090869805523170856183199180807458939980812347666 +3374034628848110181967055896853894757362330956181597331342944383294532319770922905892283292682026888125967189041997170645906930 +2816796708896328193169753615809284330192400628212014852560752820595983573685822703155361815716715825780349446395688288981323009 +7068534005360767613192042797492589713014221879034298952445175191916602695770589539510033643533276163270684273301159972772079846 +0851847960381648176955810985408204753982844887706344041815181406997985867444440863020286602964269777581948956459433973575818007 +7244153065545137632239977736639101263396745129055793110973443976621943425823784182900120559207556057714294191011934647831514642 +6220112071917364308442903062123692544853904143920646475613405698807838684964691297033599042267911174717943845099876701146499041 +1997737579617455507368079950355247973464185824287192636611840482334933626092039322468638416062106707636638684831343949569888001 +9056473674062962705649948566947590595122246493016055906506275120659977645801864949778640366697230510631836906881678697914437413 +9851293934933351435860731679561845700615460829332071112719063019501427379839759911846192375852475742108532990355637732868083608 +1981670764831163220456625777162284911174669042984422665330847096514572430663915704539930674009046717718308791910081803605092076 +1436167228645743999726495063433059497403336540806399989879727825522625780324646087140141119024144101040594738802339934675234494 +4511331339256646611464785947970006064997210981736418145964184001849876673693526718038480153571548117761471182638795979792615062 +1795579829237064976093578272496505322533909223281608272636931019121795380635442871500788593701642237770643966129586714071750006 +2259558543726883196265093171148297545202455060457641437680621020678468079454735539167389894892674876922877875836968284903103240 +5190322659532635977759442475453937445078305277952610411039017125942798503797185204729242079034555967093953206391753749025286545 +3346586896166410527904055884469771043579999692960199777847808583456813215611676699557144873569764821207184084966272170201919310 +8492812746065013433267691323002027533207826063607337577540310499920611687417123621076705455447051576454279273880574231655581484 +7963980271743134112154087260650334248257065896933807620141668762775373128572470229135441642876072741306062133796013873900656717 +7155588355012012778870617504567123068873574015355543463865010611682540901252618661459039457810933495173848721472502301449759789 +6250342428228956319030041026630301654869718238658413832351916020529083012909954188736775565330222063260635143292678318707172682 +6306362489099506339243174369018743275045301435603437084640257826344578993743886263071878533536813315686531934206065891475930962 +7256078764576049009416184871748648772794832357694303718710674780587401830972226331756569564368514137449167545781329158975242668 +5137011302637382277771122596368810380574982751431852882121643844964841634725254405565914232138014950212916177841984286676442765 +0130766950573613943351861223297588274240988343477886895038747758639966388317215304568124673651393253970716618528199527580176531 +6359126988671940758748887099156058290162393017636744749307547677028026325587696225823070273928497980385751428178855356190336058 +1262747164602205208071416052898259778064629199619315166088744120423992672210748461774575909144208599043872184758764391922991513 +1637777143251220955861291729128344859755814246044289400356284088474702731048933137147907743901585132956196475715784684303014662 +2779656199507816022148661387875419531355613321583333187996164541556836852609250800638246651009398874732599973734012124894691052 +7354320128684821812105410562348993616339745664287363950112497961551242247169256027249678322546929448755022227225938009677843721 +8972855810687812606653074585753478301824708270260970161604946179349054120962204468271996990113102973342165999101606421899608935 +2427496334389700886512192278170872300796174251105207296701976843139085003204747190192754643836301630137058164840301068688355227 +3959418860712955101125551436177454788270598656333682307048221492143694319890230219738438292220497263359673419823698673057872078 +3013408623490314068776627587135426768753482653895410991590323095157887499728772798489129923069618646593123822639438579269538635 +1908216328408109211109195709992731650405613610224189255235529994289098765621895894667201782074632616819297670322225038809119550 +0817943537763128333901984566290468707429051150902489063403888015248830107015875323502758058360302496764604163625874755344905059 +7334562477121670573355518606105354751505482715112941146764597746549856497547302376364513456936736713783904762299121613461158516 +5283407076162674672773440443861453333470684691925760891504089347363035836279580135355221825821573398468104182485287843330909617 +7205284306122028970211792875328746564733992888131805747056055043004240391649557442465694153748887961289838987106491544764907052 +2500872325568857502281229098611844366313487869502518915819858430987626410127129066096878146872919622682973073559229804271266907 +8295782206872660046903141337058447164373782585028140797785111578071196136068281762757693333793450310851105370333208052458896958 +1725889330426145518489875923548346134621897254499345669060138933732620752098808224545684009099318550221718273960774029508377011 +6086360263760539829227685105382480409473035021789956560069988221518928563686053953426925951987832850158619577369793062706768043 +4352919017742582830329403068368693550555003865896903349651288061511525716234272382256062983241592888339539171693959034050993111 +7316775446918119981332285689855871890517757525471516688406003916733927585058269512316355228173253797483394637476145877140830653 +4449523419101039158408708904430347733804700552814623747680680614331040890499889250979677397459532347731846180044631683772954511 +8775927277284478472403620186389038850970249719140155845452372844321949705137084066166954690611328982193781479003940799798395822 +7036309001309751772232372080817838422988947200353430157955341599997125428100524596360021893214442902724490483771053395386266905 +2526553722458751882973801186174660169500936459737553375965211051557068305755252365586897544315025598670454207459745656417390706 +2637149880243542713228217652476736046313897745886197441813742086881967480415661410956495847064049122729695529600136287474175290 +1793795271658672504903869428016853432949018555098626397052181786382888682206907544219009649133780351002110388824693692103301828 +1084255129975610497399774428514444229695501619744314654316691842636967058501657387850037557822192693461604997872810120193484078 +1690635325513958119210187262311486075808664902577687177132226261921963946973671413085629761815694454894584772804358916692902290 +8584983060051303667121308176671074873807110361225378981139031261855126176018462516372607208578426174357538994152717337719252523 +4278036428830763724403099207458044021754910574858908048715320547117712294990028756794510860977637952837840922253254728458600984 +7883825345262132475931206135018623229949112586397174487649066363051114417355320278795734783658869193239014023523778761960029033 +8695026444117478979408146585926902316341504795145288358653821833800650855569985787340203101735816503203866669795526287437002033 +0245051742430260486282155254132179648064481192529358125651323989892545661828432074084630060930677773108561342125212783387281955 +1156534912244337917835348237158665382209292463641851049571853921423174805869049378131731211644957860891749912005458383867541676 +5778772564492822262562399502030821202632651082331648596186198421567114506013473886361019711381249854838415342169443696628858178 +4018937636066081000726527827443126701548588875106206226537909295887328559668190334839725133746234608966652449462868965060152769 +8173777546154775498367210355738304841393638757271541666703324260466614672029573295838066643359099243819511379078208545782984277 +3894531584135582441443997552974471433572355979512626259310899921004753808626563585592085956971397408889173848312206978387162122 +4249778224435541775834672279093907849532605623442929414275448734738794025759189569362602709330104719867391830325898742293638318 +5618458472230917207115381643121156657396683440299320861523898119230249426608095966989749077626813445096806473183743262392826169 +5141443017081978141752639960290174384446691905687453519079674615609648441987212131402698830771368709970102768419122745998384912 +2946562140012561122001343127839838295167741172616748608003211961781629115805578417306196780198449660660896672943032048541196007 +3488478058250138575080356458275864826075120035949332139371412714212223138848322951784969631050003335580101622399775487873990978 +4317860282593236100733831872685638869277432762005042347567404549772458118340256499688632865717895145858533810557576307974444603 +1928173630042126038543686101259940626688530747112695018229893249219604395612728537717051374474126617790845613836004135628746556 +6994181584676204860202674587876078621483635083475446039294576324194007589602377577833162510613729896861820149258590200450670657 +9591153201889299370958865743889668888080847094554165557463441635078117012681280739489741681606506751718013927402701136203548044 +1780167360508315641369667116901861812842526826720765686979668702075706357523197794146674984683061754983908320058757429657215020 +4621260027453785113729584439569855185620374311773708057945213037359358758689719104605870656508325190409944963614795797144191442 +6611412529823091494357371703456481103154272600004279607488151916951301067639113190114505272247774489140541745738078452548556834 +8106748866753253878302577929999224844368660368702977874939897082451513356653811013795048262545973632043664542271741351318143337 +0778069182951962287178555694626059563658908945272131830094793792647180018850962827338479100883010796179956428416377824203799082 +9473023880877077477396337686061036427727779399244945597262198872743579391652952681609513942805826872165303709494805916573728492 +6294092277154179951451094865452721844277717466377028709711650186357899779470166784063622634966195721705046717157464710442807466 +5804785796886616339545161571917895816310538794711393196665470438339980915686578699904466139950097093535760550147855823745768311 +4727439998296384114816286463820007469707513836075275400610242782096499770391027100262738743742494025582717951675320717526395925 +5770688225429387772370873623458820190254941682623110262393319797303540835367273621810830554446149103975368995431078077876936297 +2405529175616664747550451981407708416427503988134127731468009719622521436517602196339409678849267725633683568413854707742239684 +1747116986005191343502956460687122356601160408668274191052227378815062922961362392926820216609198684542476134407735883221896780 +2662260497987146574078784874203657867733135048405416920171958838688884627100473968981627006284094098910015991752992842055879818 +7034398681569535649106832499610645350629642323049347631261095876814181084980886779188444300173631359422796869708950194760718387 +6836733703618557086120703365229061728453720426186389529699692510071571231710123347703658534972106524417884249218380254553097325 +9819799847270574690752534052463450597318916271469886310284525865231260264874522733678980911253701800076986898602579299994595517 +9135488779985085378045629972341159746040904128068784460666062698063117787215014912137720162075250475265414449002077183911431414 +9809851736195297213683107966811862847637535801414773082875296684360754325074703853487298740359726050853338447561139214515571992 +1029599022890794387902179784268370369360935567144903247409435981421651841889958031240517172069175107596477581973881408689860362 +7400367259185579353010164869469689488102231791643828135531761198096403804156803391787688285965553218505121457658933398225058406 +5220283029470788325194233641742163486977117357701064964101876499830666046451739488161844284719262317454589282938926798508893597 +4856368375624850629404156042966360434746200563963426632219247842217835149470275034357811087591708435161482657165228727592100816 +6253772836778061529203496032750827006398455227451857109564867169437129073006140463432201664058302222335982176666409479667581160 +2936456922664809261586171438046311878472513284135606095783748274074803411461233988794425470611010249655925624921046206975885663 +7903340067868061097623144373319704434575514501755821812557204930865063397777392798291309341112700415633886191910088310537801960 +5573481392684970852911664492959855735295070104374454536083712417507044706607037494482191236686504544140731669546789850452790174 +0904993356742978486159542255719565213826027717277534463338027027906360296595539148861118855418724089346480767402189286985762676 +1005223076106599446960454896515318564456413560395537757983458843931854126284677517864393826744115625918435152244510791809692478 +2164405990650873094086602365842140190819719314893955030230888932507331906676191911961689961891255808931785984896260979975690681 +3253727014960636085246150995307788585817654532411113862158610700251523142672098671368947509829930523262641611496136611155754050 +5927873322526687970315921879739844277763573086829985560339421326548635360045717801382027508629836290928584431149151932663653210 +4760858192547745555268997678117732829237567270192822266668837972286266876280740550930386549524048812443132805094528566843643923 +0552200604353097511107833851418517885398565041104987050582967853637644070929822812409158588536557876274185029987107810161351297 +8488557995995493390642962339468082402922946581115285486581085810242830297673687274512734725802547502660334048415579446341045330 +5709356062023991965872528242196958896198910586431524813751700975464715731688842846588438403790663597080684309160359805580967928 +1809180118084899386382440090650505696513340627765123157216132637785703218992306349927445013022757227491085193637218705876572392 +0750092974015461540416097560544979024242793468547428554110331500932107320102022511854661891492261408877458706999860502548130498 +6089719190070430700600786193146021409101280174362984471307624705342744373049193769815102419864609660529369826990237068799451547 +9880823550824400406858764215681272127616403736552454898294728046365136835488231881807123019108941139138735003722461424915329488 +7529037321181887616470646776506017170053425836736636947752180676382271801340633168596956291990586642144447067879824547939050775 +0702265125795249993652978449111254341598591409462513412644706330823597010310419837016366205284525093508925291114478065520543206 +2486005489914656200352331842636430195667576175939710807407359823751196926836356542172998603833007594132689750457318477364742581 +7540614426291493245957654051180243018629278083258315716499682711339148507426602166172200768552170520220563426401305349960660512 +2404338617929580850851496148983728094122155851959629735499313721174625488662780908166750428714979229469660586277142190041914098 +2734970584167413642829413555542927092036718157943315563661250374551603827984602155759774285156429894221533968500275418633637182 +6560220052859607041833971976550951076186294969188109531953615241005064465315852535875503380591519469842863315620903120851882868 +4362109461838990069490474891539380133820330011017862518437725479693309451782697543824505868730424985500423739583859994419014638 +5084805381905175100929792755321577290419383142651436157340596535511027236705949268189435276570853108955493181266234603455114274 +8408563281709145363110504396918026400160693545535873614031123523353385515760396989543124701606521301192906747319853776998158894 +2312458699599599230972023213413420672303278131983854442962403875724144311681960596932014490316204359247402654596736629024793653 +9839221740989926513947745565345687824749236841443758276831531279631822480088615812410461505184335496692743570654981097859767887 +0148513962240941032376953093608164659349988907238073209903158402845914764726830224719377417036845150993399330628686012123441747 +5919614485617148484720530134538022911021657584302803306902527053421247675384565988567910916387370777305148589468626006026739483 +7159664152823325316769176118475149162428707398939203649766531576459678350978394525441052205823105345184421463902500121849981000 +8288659993085551546441461743163304405139009826361143974328223331967419739647241073571212327801960556484524118468883764120169524 +2246338306775029095975369446186770386599660011384020498379465046982275031718873753405808637548601707969197710675661519594764281 +9599700671171430778834023658375047244787074487357323294015535711745803913257607799601446000833932736200689998469969708376723008 +5081943791810860552689101511523648202214658112058332928346393590013555144813066914194030280115978731407804149764646197662984115 +8801177359464553557557965020150275317953374369713023241680758235462889780964894972416089799047047809594791811478533742030190073 +0665429844750818754679057503636454736605371676903157540119156106676570191787583727649819947468340786574584101743147082806534991 +3657977605543416424987117022654696293608374996078959363230667155054631271871981115488592293902083994811357408917297410729122498 +1862650934481731910956432936712254764601612734362801048040108459535230079759939514256093409449391542317896091270323008227781776 +6653398313274972684240408723778161592189390653041468423088421653090661249171357282254451145484842067919237970412388771640682294 +4059821256052393643115972017853583376641290368154419793622859038067932722073228138326697082834080833163668963795873824307443161 +4885945116785653293180979216652517189039102100870721593874386070396567484340764036310998065513336640289679790609291581823883333 +3428604720660372157112193405611757297738411485553283296939642822708738180393410023516446689646065368009275111140421244624003704 +5562960052258931350563961074454414104687746794788022658055770332756970270739126216170694306943534685894930524814764997593650416 +3008384543733504706776478261526614225467564069116098586935957253917385357687398588155803265872788670839186222042335779464643037 +3618994828725096012458832876031499829184389279845891008599618731986280732307102787004526300770299430819579608003697211024173693 +9217086377524454012913218100708405723232921242597498783314818967648121936298190307693812351239182876627690699979858904402641018 +6156985750875948360548164905855940506817600324843389599811157633619677210306664432514278405659673075559217581592839918628085400 +4764772987507938088705673246656764726283775492007659316410580014942504090614797117731679264296150069410102991752421283871178501 +9088021494611622294962362961658529846402973311983387998125910749644155422299932240783260368601058914444067830424352644504379196 +7142168355025888186137900382975205885091374237093915396552747486547739152007548268368634296637427030850473757422944218387854757 +7616183325502874293153395715965826837360328123096242771948215374071981140320994435687149135694129364024023152186261051421982087 +2832792230789485819847349814552874874835409931161612591863141976920380812857719621635320076324767599038119716738981834869773741 +2754959867605262800904073710237512445047870616662855713005574347858126481109562377143573312098011061313182520482126994274243272 +5944572495216446034342198294744331850728989442478427239279385418283344155306850003896073771784045248648249808863649089110085745 +4935039678346741118281854023639235666178336524231495974905785711915838245296715638301791203620715851604930385744033263165263809 +7601373980902035512868636064609722029939023536705525076519976556652492714730630698715244783359777077548960439099573621098774644 +6788103237769355632318040401274560065924878241545893694505228598734431875252964572555463844283713282670737691866931493869606535 +0416187164312031460323292595651046052380878338516759425813027437945468646970166296000101963391062426079829338723963248745406623 +0923089990664161924027191610177696764629811421643542437939862866986835556859764272302075103487218202328441244550298063164681875 +2019867260237068480077811032787819165579411546914115220954604696377168121100888419574969311251245311564544879246746582842436916 +6868613732260412990938531237301911324073055318005385120355972354500615925738636280898984348888758911483752216818128353784893125 +4877207978980281193491650735689287510067435635758992016711009033554062927257985428856499572775171602494384045603122508003854191 +5729531014485818371423575856151555802439384687195667542811436864469460636476071341511650757925855405897036006697261458329928553 +5460991959983883494783035364470651652782232918135295761659407906592669701830570881217510435070790362298581095301898060905173789 +7646351028988526172675924552809872541181626761125500157109077472362508995981523449708391893239705562284235588614429905027555758 +1619134181392874715654091932556140391724453901036282239744719175838602787922700433547863998561669814541630538374359332841359124 +0642132589359772875036014752032306706353508991088875094683831897858049315214902256977825841683325136398731544129046064024590934 +8005838235188541103906355513876550842936138467720245485620712847710339766152168792765762537490548824247757795430623230546063661 +1739498737086961685166983125262113774813358028871712079307291894391835363168962025939984050181882718770421839433587670806624476 +4755044069459609604971745446900378189205860081010611662569670882836262612421135453240273781870602310532514360568130085933991129 +7924290416111768289187834903766663006016528601174525638099383915633909474617753311810491476284105443999724682875652267118724896 +5850681695306617855936614324554272763867627188224507120915540200480120428647332751636414058742508052557803594703673781795569627 +5161939368398633733681924028671740682293310854421624725144685852406527972897380355105818239535806432392343196805358469063293155 +8819559114109771559602841216196553885494830284200973490048941610619985614867118986891106961906280843338752508763555675909702206 +6241566490588598271025864796744098875607062200785043619624462705052447512034382219094774621478633751781359662848610200184361678 +8704633729839925740538038689681271982506814499991016892558765319948519205733093865854380442216165127136281006009985719211033451 +5874590475603382790640233559612673482775953839089864470737210616394894296028059828241641608622138456309335058488482647911816483 +8528577480552717173959823507749229677977069134280953275629509898562844929982109573639706635205828305920402590508711781395835713 +0089930344552012906619817966789113931607542416094931145768127062728799915073397115668423507229674038044945322045301649766598530 +0236619236986319774758924493517372212562285619369190213778360087721105343106507409406716723533090029620699768530871602210981580 +4900295631035231554608058112293217835929574133906243363911069130644679986177379278388410792340109628431007635443781281483062060 +4988368133324357435318270787600078029431686121284484541827394881261897104701243599451161363480613963194743733844807088688115634 +5178871803932196297861340370803170767481272576611956494376594793113965439245117335478620700378039639755713637510132362926267306 +1973846871626730910248052978143950536530975380151232887509932339881071793647054810578672393058114957563604971882394961817835491 +8978209292630747251522017252062343300917165930874691119490642832557026684811610939173618238354559097444010525631775837097840951 +8326182506155413337881369137900095820346248710691175947937982923048432643166491650906416257503450243786283464120124419550826667 +6090914463028322098876359782808759824243499333411218847428154348072847658504046701534863522297418259623151406625685618209367317 +4253745664431692653592530190665547218310374995530293912340336697232683775175851639464892393461388136647485464789810252552522056 +9182156878387604674503124667923684369744370052287701241975705851689429509464670883347575783846313229293967680582071694204051095 +3321006971958449910630372247668837211034782309154572655303854890011708581736868651280877351904031869989741999700057554577154390 +1273067298313752548096207203603148138418750927315375729523637857281549085842436944573932481003443446922848528006413314412427332 +1441821872672191871420138772481289303458305298682170739045298765824678050356023853590500427850176428627107627730008396343350473 +1052326101498218606100898713263447573551827490516947668567656571319040829379674136592743558516074455124317265474909140902458087 +7834541971992916704455016525869622512851276565353916338983507230882585013003793323808346566693345857527479053033593116284574877 +6838252895614149905894777313466208709968773989472894570857815422084908815232548928189324969136065895039808122393702760781384523 +2929303794620328740393974372454877708805842222813897741603177439187185228877406834374147233014054610369299556729412885884560745 +4370856078387921623155622787671852014805409807299060561419288539719819906697663945124473843579383816264514077377269614977581685 +3394601383138607507974293429184042736065549935759370359893007688911547744095191909676349245026886870781533913476330551278360831 +5351259816322765307961191402595778339300322026355376338266384698585109900534462235764152505801492032987502080039176402011160649 +6015860540766825761905783450339596728965747988413885573654798343784315606643443103943694670901175274103478596479365688106195479 +9733596316022892971509096088392032363480840038385290255713310540683102401152243848292964926264212842555582110823197263253672828 +1062515708221923559386659794495097841198809034454364525085442636233669203446069926961726048176600711294973993391741061849180079 +9806127623797585819585111237146636415904332057123217989550966977692535517011996512651123910136604576120833852264076101548649068 +0894752723723477938861483316019471992063859736335516787664755140329957520633060255798252299793172160680450787189861312439796670 +3913142052442456614486902320774033281367626065329089488796925098543116615817296515061149179999137691128957532263158924327442783 +4918858536678070436088759702284980929577025191565900433342638171236644159755504144947154030057873677997786393398810399270491800 +8872734106335380929798217774610094691386997739307412068494969134661496618521118209935954632189343140189392135323738890270473225 +1245647673515237131109490917571703008777281273557596852732435015863930630266628924061119974383584899927931767742330245961719796 +6852379757973100072309834676038484260260899346508201154263890305770366822928200041404900931901074539015449894481478124870846606 +5288592940348602075775045536917167753748198797428454287343716300518081003013742004598309648467119358078992444950790157070897622 +6178224434793312241397484872165819485491096197408141733026367177440768594738187232231600889719889461459739097869779145699996070 +2192775687835295828387187709692569714086691619295450894879843196267448458847228413092057333128571855124524447189613776196209305 +6242914540023653075456224110675459930237745861318742551814072907467664681202170417286866153184100097311858010110265935844444511 +5209497239417620919469741474768380931492201661270471587341653498268177621359803201248700031595849957309397980724999380306103922 +0556894331856087053327675958304000445533946185075415894264871473185811965493131424842414390488954096468377128994425485984798739 +0196159676818515225003292466076872625799134390488404188280002687542570342770954127173812843410476595231005479765885421327808255 +2605242865388848411850848235973559236245406311003883744452617685164124063273300160172061005325886640047067612731170493761853684 +3723865217540793835273126631505051186346898929963194134815240955269409964826180214819749886514216356192979128714223656587784030 +1612652380049586827710856241890765244152817303616193799144244842589626119110544403111366867458976947676427002814778923808924618 +3631721504060950588384351554676808360758437911729833313655406741373502411393332262640744499827573245395519111703225362606878417 +1363409383247041202382518900846037480203513170344097014906470642027432914804792692599759592956926861572014354287205548305433650 +9938363167455625445680112095072694438021204263665499289036436205115409602435745285690360330318532747799997172095972559600945294 +3849224957526742255789376070484796163223388025899309472042686406132560940455845848040737742829859477224469824421878404438255777 +9153640594267832855398773722288983227094747426234571630063269545219291207342356377829705537624593717193629488670483397161337722 +4742683466675948276596206085950351177248268507712030644980189541847011659976997997291786802803131893537147312873666734632318013 +0962031832358588577470495716330583413563622072795533159442347186921867618325791765612531566938977664106322136330634216330706485 +3562792846227123177501866289549655646263423972314841727623087546398961182987448990222751356418413165373556965561892665216006475 +0506481362115739578595809306613922949438046074388531145186498774188751322860892046433870735773039483261252104554347599292426213 +6629076659887419139215806756640799939588104500582964705062365481405718348479866775939471858338157222844571173771380330117254323 +9427611277124624517129218643055712610406848999072749557192128496185603527876575966140152280783898310639896801498077008734557576 +4949349263979842274642964286301282439502057095606102606822710846752651420038445554041921101778203644249576817202379962365236644 +9000537778793090403522534841735088671708809700351632320108127651758914457761194719832533167517277944390073544087779452376879039 +2179620974987315833763764525622394287879156162214632089232065378247731638836108414730685627306496030775755582279275263164338314 +9850178620109230660864047257606734366763600031327072575073099542439779650618140023637464021494877439885488556217335419454669846 +7274436451730146692806124202594474275423757115268107978580315116832524063995327727093500514697813597360878942124695394787220781 +8077050800020141873083229149343719418506939350096709806686454834234546620350690053797423042331890117409969910833834635664137578 +4222569085314829230694422189066171115029353200770994620763730497186499678980036529016196644500138184587387164123266827728301061 +9140763168998745887384781477877234025340780171338591152461030018239430263211801503428946233869503372300942372235304400820946852 +8437399467538616927457301639250511729312614497619431195080809960619969552298634956256648869707957943168309430154835637684617202 +9927888920815679261894236713565064562156846670872463967287481642034739020192858148286147625951137420641797396365115772980951219 +3655403238951645285818609634851118279549531888817205406539748497770277166060720853420241694457643803188820531391415953932633187 +8096429698574955422724412934129163958768439154851606366794537099440778504483170647334793461803467077456150095540043989710581777 +2365201968161103470136827409580883843970089911974172408580391996075540014445987053836291636308746569551411995558157351658739831 +6950345059892537018933018077820506883809089865363951638996552650340293111131388149509355326175519823347067351884531383182623006 +9729692983578755541105852708900437725294440871971817004794137742625651321002377622365955498287088740364399525852759257372235252 +4593851734614428386795483124618557640086184414899615960895693770722697765927766996280493365204591488466719654529288305662919475 +0122479598904859751605583470001521191650223688479671370454989314043303051942287523649808609527628133476925823025842389422672084 +3056608819600468295745423499468437706122458751753728982506585826980159252966514250379765257256312249132321573973154317443215255 +1261003464887189939919598811711885508553376196973665253914113359871227784508364309872766800569364687529405313394507842277777341 +3335595614255964343357224505993110214988297629416503148121404268247459966936550735839779347369294370575468296662036041463516505 +7279136021331762991558929156754763672783232261635376259854674650491435829901582103560659803340084857348232939069746185793481086 +7001312755863777334623418958360382433258119385097977803059882470820602915102809159265450380632894446941317444541503087066649605 +8796169740654134032665098260784549928283316353597416172219489498769356834724310846396610790766934291348253075369200618334478026 +8802831163686839169667839421840117736653893219551959966388948111069365662007487678001136916755953605936920644573768537311349838 +9739545132806507773311726139940569054566559814706558048797461242055138311352937387308888484537481230253759123043684421386096698 +0953084370435253065135920609321712138864781756707944630525539032264477854921495176982483322151742604869890730064964430072465893 +8563889642871990807691809483723365775240608384031148556634799934500723149755352447233079304887498827996963939978814660785015524 +4422068594927829463105462477608520539620307156466022889708603842952278355035865136962605151617935839688034493508879959012432457 +1797597440197984699879058451944014171742351115567915351330880426124733117964473476818687526048324044778050824433512831279314278 +3544880014006914530017330247894174199038635755809673971423695196336512713364189925640866570283506889971990951009729565756092473 +7989020444450139152190142450813270776908916050703362005761467814560672206433992898775383186508883181569920382329721780736328572 +5963607248916565843748383716251646836534350100847190837736559193434644723784998135363197913246364668420334826697708573880522965 +3263484959293045146013061177283236124170085863131765193651484251463844732711431227375764646336930721004123585223994485289918901 +0583029668150873954157367992526151571563606918837234329358185868795166989340614129979830550547132857672143145949742222265113600 +7440572366306644814358767338023644569585694763643144805041668167574800647065193962831865616870056333413559981420227280146948103 +7295355536699420073390947523011459995035076225978883439577116325646324872851036992256964558891639573786018094493982547872559135 +7129457262838894246866292831053823350947068553550051302734533231301531811721807950765452389323781067242015285235015915373253500 +7003661686534989695171145431734885832337556123063280208162395256598378269110597151277334587048349487450140097618803853206266757 +9082217774055830430004211027285925285344275476747121049534781396260863522010542259349559050699781590339007899734612452403479287 +3191667292995301649109040619271406402727834137378627737752393244791408796163577067403946973388491815614922007647090321324522320 +2949712664738909367012483650928320008049914477514031653686312257788502415066119921871956279807885221949190218605724017500310920 +3169525625766817202209440542641629818384859195018848363928308881901815336912072399651202491194626625193357131514851165636605801 +7255316665553834762495164950088245569336300767957000036188227515262775800565384194139225891768802813443198621045801692291233140 +2574872647913296219947966169138393924496399035916640976364671914696565353222749621284958305509352891507065537978150518314618840 +1953749417768878991833661315137426428652077503145679920658786397955780176167247358992933014357557538701378753423037285649046608 +4668877807427263578702242652781568611601647436182495270690516771196062145719412914253392449657363828299691513193636571040444936 +6886803557429783411232920271165325523458164084362409904470754437138270784982746722601116409545759719688367256037780110379647023 +2300356518881462544550334413932731049376257074071686920169237332025867743966470152553906187385400688773328478685498436856277618 +3440412356699057087611095963196908710039931495043446625996426055839433344899946522222609944936452224313579344290272586318016202 +8993953982184479368753437594218699447584551919428710623167603425460525558734552005471227418138809891695708393142992004433396157 +1641364290874900167201473644758505077028954784718448987507776152112958786620272578580374033281627136838108776465262593788494546 +7335791534524477898748563122556395894974284747735359153516999217809354333772921832279669823385048414976444462237355621384907691 +2772845418405555209223672772048928810050444241654554863085813477997024445507615114437302354148041362541497074784257678291599777 +7178588655224708624898385615582303156928858845044700179599109039474166324676359828675085010955238472718587302252391630153958817 +7714350463980300266933000010667914572625520828229727411680133017980270989103849220980928606661613727680746076907445089175447948 +8959804988970943750240542329725780454835670277149205665534383835852603494258686925800889072070906952377561912949333090450610435 +9127584427822125708186685340454898072189100248623017561567872674357247419856515640720894591586135918230623264124957308938825903 +8565660274882658423962595807578322116479785809616786494557353542161430392650520437776730973491703217016387298185714704526578560 +9055899627055835280579204790473134990779700561942294557075688923514759353053304752653692669704340622777026507467115119994712711 +6401990429555126633982558874714554382951718476795179895512968275571839503381782370343773457772170386412634133151122279458473043 +0293309378136412704813380987793756861154395548470319616928895806731980671468030021029452883570696897386186564749939824907170573 +1417717547255789991707004411151265689787923836241613415526707758612724058279277154586299713815047231145490533591839466123670638 +8468716387126244026336620863493031193083664955579994896168486675960587844522828676215258682659462698160621004514607084416783102 +1449640886898263771104309544234611139764719954279503593908340282487665393419611852384397377672021450701130079538845214864162053 +8048887383017701836654298226594900075026630240187365178333016065699848058831083230977644940244574444820285738121188435273257549 +7734838976170306869973081121181660448148530318134255364556117593964696552501147168845028313551613495459270535042160362667658266 +1546639029308273692114824601121738207436726090786353640928151613146720401120659236951025944213817893334993036938357931276755092 +3794363877794105698247622335925064622343924657500773158672876932260234127197098205417204884907008074223982761704004122962430390 +2332227732674259579606138447783556533770663844706548255581644643545209413054398521429945056259218551425238380035190336407512204 +2377559578117061565563176922758264522313042429970112963159461355099505172026291216364090521544160711259708331105724128544891227 +6832428920554567726830569490691102432470549042227057932067103955101428247157515420358182404777567376342028775513115385366928419 +4241634693879583625259038169292585038330173637743744110426172931636984875802849325805759410994995655688205543970012859415471525 +4435409455307673255925091284402380740900794676435449835586381572908519616958395334196299914509777009013685912584824599000928046 +3987500940366892833785739644668889848240740024168650731790637517228616861342434915208852629849188021280517196274460956387434019 +9025408507685643206458885320228075047871187183125968258455419735129168110055303698970042275578099161589116560991845557669784646 +3366934559408606275260397226783303207383085083713447307195484607017198247596814686470103165356557218941037264416211493596219700 +9986983198296827970312097410216841561044999906047830934706495494099795173682393665158233220314878778675703926172446242051213291 +7327936388263057744394340969867975674336916032235104437222484250956772949755115175068343392125983148796915268153189466560134516 +4505129238068974615562203042384229709458199180125982048735704933556566236123385106774238252165050271569657572461570289000767894 +3255121682739504137653843468184029546420570010142268916658213975683507187608005044348538495082520951103601067607492368878206287 +4806852545996927533787451480123813559737763425204966730971472301392243492249231539770928832609537982396509758149828504617903683 +3852759316339548366895421554002413138488562983328873969801625973328318967409411308340716647240522981188392227872470754156065273 +9712297766053304902554018245083167928441148337025924749085910105658941917341095233228980927774840543348243226033787592995988515 +5229452832882947701986160360761878773430032426431930521890318903440689202842760168592576826646125537090631410703061420763990796 +9492775501530308620829606600311339640855706549659904872171618766544922435708097161505981598338090549562866490651446857290681656 +1678808597459616937537502211249586561665053229525645425138896011542471614595178170509581277828163045626690556829964393718215591 +7053324203154477437019031580603162546890080238913915157646559489429803976541625693989468806549155901365763128179885048681463067 +8903137465669354155616857417689085085205927330249024040964205952230818210265737328326102255377329508350857922236822007786665553 +2734904576394968648887628638128862963608976988414917192020797115239688653336018428937106985737003652208275177709699892675605393 +2387808386702882349280874532643852585858561738093225119093657885192947905905747402618285721157837466909047447734685099503267111 +4222155360968520550560237616569205752212233789555461181069785768415048417477169723562149137809030351670058489971512620085540222 +4298243051299268952240909211177826836030583513734437502197104884602882464340255753900393068054947046141922743129752936688868680 +1061375462364377985228292590232948700810225069864185759076897910654198361668411325978825417457852278989472721657536588031658991 +3940469338205826791620626804680412258933163753767218044848985297248760060861868407223928680948167632232230076213403901155993516 +4300489987649264460199719443525675282990880539122997731272161031062934060033770185574543151609533413639501738216215062848675971 +2177118188977585453528133388279985990921229278769939253605657684059131396416486258985713207176129279519783451725740599907936598 +5468202247459866994978249422059052436184697608003427416719037990135361500297493876720017894883453685240892163318994013086288251 +0775391987748089844439257445352687468561143051750745275017026626096588861151466861293340177217020485953364933966278607508804835 +1628141832107584076506487704333155316297016420320945282094351104594402285535278391969212402643994113779520387919087141691462578 +4568389047366302665905669107740203378971862242851210284195394536420153604497510004787197852478898999690840962496286253318550921 +5915870003274717803413556085627698745281531034825477926175968946204463905051355885851004345422507537344854894128229093755738123 +3106488353902440267975241920861283331388536648597182081274348906670754514090626662608509624737135193693712779860188833406087992 +7845555194352577902505815561879589158643398041086893321684441920278495085775044919835855368307051779503838399479822915036806084 +1432352323824143885623247262050454612927281487774810795510104248803405617391180050263987964438216016361064912733157137057008420 +8930414578064185485247400714821333921221435324501439994244285682760117301820424406392510602828280562393052749013520039103061655 +3173670884438194788166911165081056822054430147218290866655074231005149200684080014396687574505239932587314443974144267617007284 +1527450743968461168931869720925121234258369083166801029927251949358618661922498099466741377608784560458426370545741910023312926 +3234042028371733121222497619662259149254047701278276017559926645765011785573767542697475259020390524937117767929011666715323342 +4704564242794556338739787095791826301668604024597313082723259898622680965079684337190731792129157208207454560161440807617595099 +0586578102694447320030978034126807967366576180034644346378206991116172450484663474175770472979363179024738326934451423318607575 +6711140559239053730606360957739329179929007703740765446432207582934464258439308670322228705839599858462219965901802441668368441 +8135099406701400995240439771871466473527799329781080913941715241663698683730014850012873125772974693072458542177139084387995864 +6568179602365017697198231075678811557245910639538778108917663715366214082022315024791477373317009595760696873073681125441512291 +7907116539452577187506381898980888332568593365733396512784485641208492339371509014105839017197673863709466309379039960962534849 +4750829188061091962181509528044851805549096285740983094887975885868844208625379458016822827359147295255429793714493083753502809 +7458122759750053134279494636824383187336514214679539541415555708799139748870593845560799552363619897719534116667792275265497323 +5164505983084622666859401822913429103147582979952129213026773147211467590148787858747588041796556975884830210299871356341343674 +3017622046748766474496658478936400050960631692047289817971683454103138868538745678486924385845403439475522996310311537377432294 +4414433427221551082351019813726625491301604743637648323980649889708459225496111765515476857080238229389480546313915805440388154 +7128048414711368158025433805098117535633079017719775105234085215317610434688668866637527464933292899758107458405969861125706230 +3650863400245738680980130673926472854780296246906056457846071189797804208159343552552140320987399388241880735463419185645329289 +3725491818789741913366698889863185159632846810598378698135320769928269090296785595628838126516727088490704926873118733305049981 +1156989564178115063843077403158558596361694573121010738084003904783088187504126348616809589260761446819325657369704310082822306 +3039078554378698516122693013852039986103065748081512292985255853944982748397274910996825923066426171066912792454508578589756672 +1894849971820554276778681262205130604407309897326530536792905116831412406644096303796353324894146354102174288891383230945427806 +6519430441043631674771677332934701069341868125297788424647970576482950339536231483156528606063230103167532910086072700422834732 +5003294909621810744051481544451641763277370208048653102677095428677725528287642449117886584959778219864346164599848968697364087 +6751096317004399279893854072583230132666460132819591435600170059086840170914605351655306551416965997517899522960511150518237562 +5960953398400790636904166620422410033200069198453455057858306095484024517953196610901762809189095112424175853725058162186086849 +2378590573214575182954920757796313474094094261522041549359071498710995391605164191319908953433331128043052410209542459403183882 +6967512166626834760387377091334566417667045028443096775043889705526174743033818006933449908412813794430186357687977532151972724 +6459437209781961727829502811704779207375810741393525593812033931653583330049048561114949732748301604240502210577065589268424394 +5485945220569893838677587873427380906709988368671130490257845675526326075411511740051320570135507392241324306058959038656611327 +9867804575762976412063217986099462524791020332282964702449941371619543236717809914141667173375719858685004628965511347280443141 +2110798992334306839358051076527899985588107686694616660268331099137978416904137377280100977825535315137051402200610861241845328 +0363449860601942956031660094586702469467050513998615147930502263169980700379643465968570908871332692146680759419252634341789329 +4178175171299653546801324512595807182660716928201014996433033979566075147588628538125142107342090640143892070802843256418010103 +0456138779092213905930697158012877976499848878257289818896704580464918962127445564050766970246810568260512090191166877529968532 +5482828669997339487166576516726609979104834674845622909875424783106655102257236764736990686408975204793086071837965911886835119 +0267535380044835507754251971519271244598217325940244403179333727723642934577686643739339224195755654907218801997476469074206459 +0065138464529181013506268966674037435955704351830301533242369638335168171139259359713958529701206344946001165594755646272160394 +9247709545287060822576712084519151900147438436096859182537437687606226004692040127414633767616557761740535046385163645108196795 +3057714321815816843173779617852754091940306380163712243160807705160943819438940855547343479788687898931661575785126108832716960 +9533193667848378687611829528479562728893899352573352696025950207316753012731502558223567081292045437196069989946207141541601008 +2746003049129497733856902406986044430147897422219852413496236136281848127325893646312380454532608491203709112537348345922832907 +5956088319437370932773128721138395583820924421370173711672367829016504396575639303752597289231640106298414733655039838766441635 +6180360982212734271044173784836239476693843516863507994881855803639383910953492384867775507310386199169825014966152355545690080 +3474612962133776522839849256217894365224998226219581308883384099107152737580490415337430321380267679764659802341675603080689884 +8385214883553973286697705130178868327520836907858212929553123995458539418552809580075802670275820221517432874193060009661810485 +7635870550202301972338809565930908660230248958179738819097744222123891965883613360999839391218647211336772299291193850385713932 +0223196991899819000674224598203238140866873922543961390070945675722542943959098310960399662895718004978803705167927661114684329 +1353039351866220611077365279049149758286033094828313328435837478853295648033377121231092341833142961745552118705722131187887027 +0630837254454720024736805497864487627874608261900388501662821043624883721807437900259240409899471051510920617085099514167842832 +1988240186121860008928979530309334258534723646976027619874403865209331775508112215956780097468860667994721263707215073620406836 +6148969112241707992551262221756342003961909547272415999992255159101022681539848421608837594935060720460495066842999521680449846 +3457737254497423194650056810264127963010085423288394333781451846227050135758357730754076741230565869445804248143832527389323252 +9790762908682747953438433738621860423268309500095630988326150834401786630708761812852217486714179905608190957461442085387864531 +1522476382145618120242675473759696978079648715587754580423057134915914494338656294472760447616089310947302406703031809581038470 +0171535968526973835184507085581755238300981407341777890096801351412273999921818828858705625413157216884807494772810429053662454 +8619996360469711195123911341155232797961140155492488752604043466908848244534955186766472286479836154777737654804742176595782417 +0442287907416054215425872961111123258314536732740500399960690027024024360050777203631279476105577959878524421999307563248792796 +5348313098484066077132466864776966488466415145151104355092278471837179740560502130988667962911672913331290100002597980514807384 +6973148695771873711809347394667364106588642004523762177909283034839940053425839430616152779752491636974036365528618662576277264 +7738896628379276240988497456223829719984420682404133841162697625994660783140799400756439398245883415372300490612168611754778835 +2968155785628016494964773780830380372616577140688533547628672148913272007307142811840952334174750520152544790354169079912774158 +6160810488767205184519228782587106677087830138711937806611950216229418417002136640356986986424817853470899640679854298647927259 +7389645808720792658628388654675620007991152874617887911936239398213102595897949513877377839509375811277492184373982237380291082 +1922598786894089615133138929724905768857077536113336665514173213408958842847812824030198485744051056380839435865339196791176969 +2136038443877769241444454895223211664298720250012371885167260344691881420934862218782035849576910341176642258076960704001222187 +3619101830106431706477720342582912973276053324213930842322321478885278765764844239473581443510550046154371836075105045519367692 +6632620878175338782391713943229145276164648915620343082760668528508249819030769842115080099804055533615175586509178038716739002 +6375633941128896351976814553047937414266141967344986676911841486068926852092747499580940682140408121435982416523093436110154753 +3222139045759943847229548540511800241253979460730316619733573541964096618975921352811299052448712030457862855059140594007137487 +5542934473211875603591035637674955693033630753758706551752052733350020451305012112157194134893565133530552290159364523539238466 +9616750069420348886409611437053219761816707838644591613686536212537661191394262393089971240329521480448880783267163369576343597 +7663178436164222857814082876400941903973450706396969842174499622842764650335956819817450043712545807776915977745377365681672284 +2935635454175721831517097628434415466056776136240049950596242823574086540015840252558304179235526092054789562977490616481745276 +2672225222323108279006574534254983148801337991382313626787322270855974712894468368216489102586460739019744587910470428744488347 +4456074219727400675373619105257416175699861456100136151468602175897841754789156021282927447724373220233266891662271346817093855 +1945491471112632720796456775261728821202881302996527116048267476118823402662922873934255261349533307722895013671219044843545536 +3793064262773487395195026532854447589979023796935998929027789654646824047287035198327952786992674028615601422606183219879793442 +1630579923384492024946757118026605898057464509351571155868933384841116903091820066294965297665314366667361460313869589402652652 +5439801899827848778232404947415524928188533947410081530624338414230329436826968163987544645598294181482211511249572440955572589 +9020302797433585342712570197932059030880158484733343798115491391574065623327717092645488738835390428206014044345059915068656197 +6778633319862050630189473515487955936852231827578947650626369925629640725543661083890077620427798703103241551925751730707081567 +2865799458475868282589650599779702798567688820803000453419899694057649460056145012638522245118862822941880894081107383763766480 +9848357801406244621888791600769552120182014301160477310095737436308083268418063998275870777119923015945538580745005505737103338 +7945415897343252007659617183211493332054610541474762203740026194193724624943127621999433384183901217893204226254420212426063638 +7076158492133875552332779907935346207685056687613427451355599366014714317865416656614209291512293922523145859007589727797381122 +9946333250403836274494116934757202951674758307883028448572093526467181950556672615580772027423711017988838817957391185266051907 +2671612744740733351071730789204383122286756475831821553120581637533315869945628262846596800538216358815764391197830622296989405 +6992508792590965425974849365498446258624365117468171476061738700582645427331625361075430086525639161565604855405377972628830548 +1767000101633223839049666007882398066097691088797110243675124836228262533287561681535331091157763899063838214576189418367103407 +6457110670443987985620843280548984156731527065461755656723700576735027138342545097213504695717743645364185206786138748271882473 +1596890724976137980689991632152444686110535638170408866300049744279882252913535065665891060859035882361321345023887058337830307 +3373623078064203672049256820541947607511438489025503639693977760706696248117065715718091918113311545970967574977708709494235026 +3986923221612406956343410179388036231285096894778891156497956823154793926342464675477516471934158222112337889492119504249964378 +8383359661494890362436075780531143970408529612575647080037096675346333712031003814298042719987791032534165077846901212886629083 +1031714454907840175775311491859630739967098843327841882994334085317927475102526174618259645090436553276509976956833748682136561 +9064443423702201811261101290439334315411997283217810869669829733471939988609585312109817796812433049198581074521140984709783531 +1643172980645376942250431938106354165389537074459078140489244293256765030797030616074547245248075610258161012282504441637098927 +1963449744475973480042625489273145165780544076999525577661332442838969621507452441516783367746336168024894911875794707697541031 +7478540879501049129571343735300770536436533927260315165717247241849652331693508424305277324109605811185754598081962423629189840 +6683599827684293037220931133813347833193703737280727037200969748489983084498274135581120006138983726589125846483814619896382039 +1059986341689241962791022654106008362005402932907446471177268388894146241093638783546170660638544503679877547754823916693779241 +6066567318288101759879455792419222471083652734422111018558539534478864130071102091839803023165372816119391124984955696131849946 +6509143418752724874347225367749147359005862337831645120532349014908613153135844609402649987007336422813208143055617331460906483 +3354213199998376189921305928077126664201462525396049040175801721488556837349266500704234038852235700461088952452452884233498199 +4256488814582093977539133655050527294580364706253926894156976648375809383013472871520377935537449640402956782630405195205364082 +4477841383190587477839953144802218475017581377483593956131465077901385252056389226406917609350544701283827958845981175691165035 +9675317500791142255855936241556896374576355116352110763482014692288089584642987642868701466081788634493767773533747361856594926 +1789275548140948127853887574961649444778475578058016075475638253177323030087374164983465707068923303558558151943477905316462894 +6521653020185636533316557444077296865023590390333185648729621716717902230175881569862122737390334951189041533339830180227274093 +2241738740799072036341573074248811436322223477169424669409308388622966605065590062245566692647119962939155999944641570918974529 +1928105019305194521974392400885274260434232105024551451106931113484210411868649822559924165796213171984543031754090678126105970 +7223691850432923916423525460668413682740557862272946646859452084367199412001020057846809103738751744440123325432522452656213927 +3644451389904659220831784890291126628998096321970481352017638587386823902603865110497499248782547323024785254006989249949637036 +2368125490914853885015667449603549765164883918157991257417554348691174190395500642639268158971914968315411160008374937535704060 +2009275459811984599922767470947284560232970282990047819179940733002227635796160576632463265974978503386125557611307429312063703 +5284668210801338637743489600143584813073507148578726973558859500688227447435508050513188287747750741584385175252456997688110085 +3073679804770516059033436419747376347125944073396261678398209865762812539120718854779696622769273119321506920635555831381282691 +7090364017219499874566644997354338979508197792775841533060988865177458368657219876491035282278982441665265219245626731000939486 +0475155794230569303711742143247875808031690475413279208626652350784369479556492756708347931041817323940692567675398118277710202 +5987347394026084150071478790424131834854554229261815024383846088465079695373324503305612702444122591068763896541604539174335033 +4436269510455092220918525983424623113381645210225340601560482106077382634781965165780342556554085651205866195116920957396275838 +3995168889104032757269451494854524514321628575817645123299310077893411388042092201792884422861886303896708749182469953549119697 +4535001242830034769362884028681925364864771844433940737375296944979919237869503095436572944940055711115231301447509402025904715 +1800925216578304292056694261819970660613390371844516635237968892926502845404165792819051199273212724458326926182758338001776015 +5370775490948607047730587515100674887605918594533934598837391246334643161422435117919064366778561014958058716726561922586618810 +4628995498127197780734498354535034114170874670064085395510892816542000534421254922356138052258209965701576585535292854686090278 +3177671938008077658853731628156335766651218454783739782004804667103681002183460703859644141290605438413899770795832449230476552 +3025608055188815266778993615750176656164484757488579062995887277096944086284232725973634996318024169760316516668522315338538984 +6602875499695059755336245084768806035216324561236127708770615233130804510875618781547430556541215471796577953669434492812681721 +7882550875891690926234268000498082339514970368440072348061964280285302475222074394484586936518612822244399239424272459493452968 +5181563270479719492880854609815755784042683606603220498202601700410969538595041484423412424024708099469125521786037119075251369 +1248580037503075406711823500465872772309344548541150892813671393177549861436277865197182621221456420646870403987260426109411933 +8643731351640151069976036541617610531794845092323107755413601880551863223421905943669090586959614825141812500194544006658912658 +9742463384500880801343550699245637258131793581488832729126778269174701627529245091838528797596704702724365423027345604418154777 +1491976930735419986039574314558277854162840810698202905470921161004472351694186257157283632042119485754805929863758038770286999 +8776957710513013252382046879914405882388509080000643024892306629178763000752942096488188622280178608686752194263930907107345039 +7700223390484500013939160057722983340948636861897585123716556883603506625380447610584051517968188462287828774879778811063488262 +2795184513732482674790613434841545867779716565739406351364662664736206685645328526381352909903916053024580749353932896630696063 +4740510819037498201511535054658680017511924766740460699058893969064394902765714052038187304179100787141754044221407272788215435 +0593548885409678785621622325583756109305462458590848222639139506641697602853829884986982801690179238753218240401694408881886033 +7410128478642788707381845999570686789659413433178313527394929430353749262597920022866973734073910557598880611659693295671936482 +4050137980096982959463694663632299864309583041246448456720658864445243964035849113054975666938514766051492807225377478267946248 +9230953430893702870077668677812927912187053690817849571057339797969486866950088035191626753948056471063994773880460982770051756 +3412034824969056166032815703553100561028200933063775986905919463873509475321843375830242381162225467967586471609115452917543492 +2276619135566337663226716925555717587888015126203959605452287702197704113342129180746061351411545746680564903503675372305630554 +0286134594910134037086879568380122070111392862199290853114304309332761209262076794099989915249949904726721530928297666077629849 +4661032688517145326760870540723245614758880946406315180541283633369882854109153204199703802230512566561461752474068428161370873 +9985206963338598229560272298952476210547736996017303976951734650959079279082066159408637306110242916656383381032701493580216738 +5913923322753424774114001206375448829014685918194637698592895629614872898525330558761701771138709572823367430917528581806962699 +9424883011486160624035588850742276732199499002202807230209412116053419259700106808447590894864084149744926170960405759460241951 +0111713605391910548623870259046900302961074850779853822097709685279966809633918351283533571183917553534326378996150978977861347 +1050239621857569309671883851470643478606629045329299864518009651449122046063366124913574153087650803586812245327770871382994089 +7338464051366649209011968493386794592783056535912533194525947811637756396164788969037121048254365052840678648300844862166030403 +8244368111563457237764184604100489524090599993135317160344204589670504422777317128963386304474615794833181756194674508984426359 +6271679168658661069189900053139794326069244916803991726466041535821018909664293827288937825025439753702650278433431356713529954 +5346852690092871593686894605405997962260976572140748476453131018042391268683407218753909113662935434807662980531252367452071209 +0705634605741863631683627483540085543041836023190103343436641588904884705166081263630037435630150915106908441737355700766586129 +2154922713467232816471312647563953292047715226865590918846184574044421063130666383320555928376617359704955430293171097080231031 +6735370005980738361139146789749484206639522950848455336267649778629028940168072161013843975973729190308856690607301961044761977 +9897723534911105404785432577277586147477026587182509778621368216939584671433875920453602299697242616307976245807249371547062253 +3864808728722705732544842322660134226278752025136368637744919793216576700939583871247088670783610602247097814787263304145508390 +6389663947104499816842871432275844541634180937582381422116532840275365272420061136044394514594368541860114545782560162829849217 +6461508204689611076377900958964324912439197085219708917353896453831247651446957118893020342996847989755084869372230374673491989 +8433851389135866749479827490565035784654953912616746305746664585754447284795963325019971006496729330088735987747297399102902166 +1771497470275815103247219843409878702558703790756432271114114625912471360708464566558219993340028146304118900320024587821960404 +5976617030473732204037553918438169303047012033263099608437162902327180494837554619833899125897762143660304278719895133912883606 +7761343244919347585259429796353568917054332343654064758967248953925035366120514799510920191615767532119958355777106600079597516 +3095394058128591553990850297147880385815415033833458376807751479083131186229720635268920776120415936997418185983635572280182597 +6753076258298533536576760943150454522971260918131318703703785217592559654671733288977408306810194844570204346184368392179063403 +6769837756043399718259982003405678775173052005969429887545845745194588303371446514765027612890020128811539282517812340583382742 +1145447512453860943574015365970108349103036202936884373965378227317332374230149559079576915215507294569467043944303098203606050 +8331961563901986606916925958427127071602998579210529763507751756811409645017688889813292902535048662887095342609935463489041490 +9736668802244229960622339427799905563413901438749725163782080129777353814116461004513305940715905434522181472880934497720795747 +8089231465924779558459413345521275018800849869822143818873965081853887737597561843190118386215028657051186337416427295963183576 +5419828194392698210106536176184087551774670922454148544855468554475299499312061306599825835773673050247207685913286844665654322 +2029050617375681673334265164512497368276347055093268045529145666800867914194334235145959975127160210970603920222624846997715913 +3338289728310358326423356618856438897910927180875153967318427145237491006914876971227986916804404786999082347353908985698677388 +7003592673799641258705037230618030712653838166741113566125031462959628644295056269826492276245790120809269461415827782914919523 +7933808111352753578305022191116925704616734794703884497922451694274860316351759525772713769181944674741861315056661705956786856 +8984597543198443392303548683602615735750098545443867287028649374064105213301110278127297110019939173598045760404284726471910865 +7750264118815211285409646722851047280505065647360902845736489925465867330208651476223128001763893620074546763783343802324668030 +7948487261322735741590287466404743224701011374099821413313798593806289098955840277566381979282309078179393391191764372912784048 +2031963937573607333606298955675833689352959686316425308916957187087489102352532079680910868716368077096336327451835608150057007 +8744303746009770077282182559273953960324245388355803375849588763883535017206175431068707914836359928021715134879810455899706000 +5908433402194706392948327209167569206279605516036898586828659659699407482487006764800996251885333845684403771593097852947347762 +3484375963559500648211146100726353736952008101895174614070329067925003079219669004928157370633196400836866091467437872364498774 +2081484205640426298611707106538905461885148824043568864528394387116332857339440668358439402474410629912663441714724196706517933 +3644343088909312558175950443352757850056547896271926536743829402725583986356025290388997593791573353364649376090870755738159871 +3017618967565343354488657372318982952747583634309941675726567297969538505603943497976312767045820564276791044673865996984930840 +6755211147212352533715490737391598930938409102322563339784308800982635726297552669891177376792489264858203303571448544969284885 +7207413969560628720009738274631537646543552986672220301640499255496422838738773705028096119936179105477192211718065255929107570 +3952347918324244189239309810051132796520311457058379135751168560732193370931728585607246787585935133034431471433154073599431184 +5948122133173804973271249039138486246462418117000640467153032385374427588683813496957187641107568040808210363510174360369854945 +6331834561201934486343354906308493614367011264274134644391474781936706762560771237417922164625963715633624786284367782142544668 +7058988605827353891060874777352863740110376065711990117582066617633614262447752203022541270469488891576938820572417323582324874 +7650494373012942929901692837674976301695625545739424778268284160337186164992467580080040539595408395037645199431241659430435207 +8656919176134694488026966726643058582704520649434961668466021566505602068958240292321141423966866142697100141650705135865554164 +6074242737126300341900975693876422564450176547153341379638414445501488034596312318816964962988094532520846350286682968373824742 +4534503855120241805255426868718961329975641710164649957599487128347011734954984504486944932371682996864451326051197976215900771 +6630007989276431575068445405328391722701879448701430734576747641331918162377214794008905979133776103351215776077151862759310804 +6329412106193202180915032816114091690804553056071102324935636935651606678882718350090015499101515918794964067433252126478982521 +1507488089191785086302341745012119227252927110062837567351191646939013086128950794430586208439605756178768284242079693463131834 +5134585587442274519690540303774472196006421738851673713532054649167344075465437753885506375501473079004259777595528824429150142 +0167920777588082886922742091652852786107461336681294679615598036369318540905949328746327769828031291675250740935570893774610363 +0038129096989223899832722064059115068115632289006675498997130267266081648211647293457692956590546845542631469315045748487379716 +2520900382745986244596184110700770194581607346454171538723932383294827821673322365898338493511029865949821494463508742106545267 +0565722884026288308442559359348206336146522003909225136977382087745807490609842307769964489536237904153503877870475885643050177 +2879720936866676112852941496983745298612873646677215750883429056007867869583163799946103524454641087004812983861736126233920563 +2682472400392268500328620582825275316785330033129835929951831594780666869418979561874633816166907302039950903765570878767521214 +6000673278648346135978034734234778737168645117288730828023574501322757674622590092065551189918194137651428146720102471591456653 +5327338501961495043879408610895757013526179026139024561532644668711391863557108491473051168562266679950416482721536337117909482 +5138678303997976985493577927432562758408369467781462054517017307284536794110651849922852301352432225552398279721808418546811336 +5942090618633537593070786933293193872947689557210874049534803895058142797994756021217906395785182382696435144831868446840701054 +0805866230785777399683174946303367253262058687100298157860323746012789121984620953083069679370163347105957163924550067110548159 +4041789012854867563385153833627178486269852350526357948901776390770563029842109776450416321004402898078350462398525384367774030 +2665510818821145216742821558285899523213916502258403631925403804385199376750878427488901928524046342897043307449003184422505729 +2048478041171475190266068119919204384149581828382571880806118238802367751477551342088588974943077841775978105590373879036044712 +2582550167003327483543334770578776146465326561660371559249486818965320307377862762238777770099168908851119806663382875070424505 +5444680706893164832113072218288281376031594555136022935125966599054561592735752631698479935094668438169179747421550309847079353 +7876386229779167984882703960774028877296085268097204654180082218579776041301150186998163564389835397054336008319799363495236122 +3595623959964323543031266473552625582982574960453793645874949571464306599166850005238654688725079784506108930071723727021644099 +9904805562100105780931661247162991156577135587825115134266116050943890998432158388576995701892214120245792294717827415173723116 +3198902109416772023345787207073949684308452839612518670096056433197360112721221131290963458888501686457236376124484894557704239 +1439923839664744053843985184599889045003833780920311682293838839176055898856807867213644378338290067096258257324765963896543835 +5700918940980369141639579109635400284102047501766736959067637462699617150713985354772825179670276479720622682613542577452843978 +5832673606644924997743952540484980626339060224968813632527031664879549813855034184500405400404100621140495713672255224298990414 +7192889419886464319914820529555240869091567523179106161721958129392253172606561099507740238957725006168387598704764060094854671 +3309479510962185342022955705280901753250343720767822070179996628541199963151640899372621594086084748660799272108092321615608962 +4880909425016446720046143938905942262706584339160340379312192206890240470343647456683169242925461208146677458242299921836024115 +9112782389287307875231265914118831295892615090298799256818943475243201711378213965480178556028607894090008691361256922857338305 +7878997196220126636517126620736341433150726102479409458917297307599211520723041036260833938983460239182766740060701211352201191 +8683094774314359941970056128495804368612258860699432526379799515947600345795062224586289908023772808639146020665057226162935485 +9660235891943541046373003698737146580202165968722595524291168751596799140752064994627768069683240083731174671310320210501136516 +3952299801633659008575843631974719807086212606583728034228268635353770341290150958327244666611228164923899770204672751927925499 +1681865396625682674685451758504759903079794185779114689381923935911799262023419094458049787998569136087163049641052695527707434 +7051981372339577512946597699315700689964039969082898958542940125278978182609047860935808672479205043611404976983579300374284797 +9494276685604001130980581987978951663125638076896908522150813094023439651488500315910058707670482621722763754582892271598798239 +2297480620143752383199993430862475021936852109466853279971476608874530008450195147642064323768140191491557557914372058492369456 +3210874548598055876505562103390094444210433165591830328725710043504607452200463576289609058990598342445857989436858490154233543 +8132507672542987199374049904308113523835831443354290371614453927015873910762212637250354565826616538395197156337073925141693484 +6828640682510305462478950222772217556425645114511993512248969567524785308290443499084010706135805334321921588360262285590883409 +2594395457778771868965633838538089838472114546447151674569430202509411063873470113459762471547280714167783037132473173267526307 +1601839698883476534179701757004074668031433379390884724016658551011492507080285489891017007383477491584644025888213433125759305 +7523532561560703539946099285117454732843364985652611667389407913314960693543811095755855340427962780551780192610470189512825524 +0348247544916136977309530119407469259627024645454634138436438519986158560867875479423449700625816301245511994796229708771223160 +3917296084877555076938742844381232454610347414176454495292235478841999037736204668770470759408859717947445502249268193464913498 +9942815514474689741504492308012003642347161752400872994567873248383495234578303317585084447735662421098893789187005435875125952 +7400181919019490047282686705057224403673442901199627215721287263528829739748034312624985655044437343710362758307470148179539661 +8008829134593470730958751998114225068506458584106597781009501241738039124829892755451932663527484529522803117480503191650035801 +3220127286757997144992978308357689318213671314902934383221575508818519767526663815112777913873690474000419949051472231014820267 +1399894109901863236068753449286869832068943284626949416147238270002784106062189067937811371979896380361397172738949505933506481 +4254902873234171699063619785819122642732788292824537159169433666069361612397840595910726633660384383938078177403483650975568259 +2209368179438159444309719519784098123505334554409147220881995692904711982790135929098654648473758048308424437091906340638974131 +8784927854050511928452505266509077489186830632833630361379070849447072741785156478899585449175370978549268898176795868437582718 +3231975833056135924558298656515294400028803078329218944207863428380011023399283981167261222531969361122301223500410734344217228 +0958925958615134583645559459986109673563012970906230471133763988818583110841341249599399387466204289301186261815920165156578985 +1991110694748693828675086932988793084291818416422390423728768580762059411945640551530823790024178761601499474873560699371792162 +5361696020245404957765470178767621215479647553935020898244576640893571391546565492142211775010405579641149396961911772636411704 +5933641384834122776049822258585947581244135364908556513226296636775905866481756079367435635748095205281573764949264635941006411 +5041011491795017405240846374877784042033437774313006536528316953327476960247723830386371163515353865121506304361011426783525735 +5488997063517475914229301557438267886673740763412117613628897204796477231021684048588313466034859903879245472327441120566103502 +8530760385580859337137628786690355170400764087907594224462686544107056072485919968752489909254263413225447887894153248109175652 +6157903578937685041336967794345564722166007100607239958562466608483279980200607600350161886932405833906442195659498278360919430 +9828873150674702059652960737024831945705458855872859591267757719944168191278626072224244567244295799804168245158850647976515767 +6733614592966966657616990010769041211313964384427177615958783894640954404002730067938048093833284287697173874637222402450231077 +0815239310564450548270963278380227549898803833625140660969258768879529883774142739151346026790443492061196604908528916004363340 +4528891650268490704421594911777184311417838640306057034638291330148034732863406008674812263692977851302665645685305101437279625 +3233475352967519524983898638596372885741145463145393518228460271054338502613983364910024616107499752355701791207046590492672193 +1607766030654760272868975035371747266369258074306005268123601506826295532939956628851683606599198929232644016608548496393286833 +0164998823596400554560038697981327950512161089142533974519294883428101099674224630562022297926592367086936345609705271926077768 +7913025882622995728679690258052758137385077334095212932668418477051379462440145509778953697224292738907994604706710137743620276 +5951558921066718365814901585239666946472249768608440652585316569506390348051275814890810652375791805564478189249435436637972574 +9602716095164159166038408316037910403855288603710934148506742938423062837375851102966449162297207365844156933403348477083451353 +4627498098319599205600533412615626896664838788638148524473652142820739172777284703948483540298530565794965460580139030303425684 +1565284739336025065162908150482205331120001945515224141600855715524039864305366369748820024483450351626491054274468986093516231 +5340418952181086209554963565801571626818882174630725995663438985529129315572417340527118943747399687973820656682726051844769221 +4320926831481382140838060220194555123790396897025705923345941235597539508677805522059012930976097312217637965288298799051778479 +0908830534451543414307140854781014820685341080782566962124152921948070095677549807088847640541631088209567823713325266131951427 +6110373879023562027503964302970937405830359276112650695138428936697834271328145752116000081078410010751317037848623862138058557 +8822703971093401247422493922044598594234342733457558225718617586744418222085876701060696882821515543129744401944915912235798465 +6594559520819849307838207390295967732653907650649027886332594421647601798566341345946992510422578734064164433073111139225071621 +6354737391657731503659719583497860062575481051328877369003533126272128322177145084735337788672157007937391387995919117571678161 +6945608633872227095639320829071216249131553642307083427955811490415705093929385003029105106248578633207939138356220965510578956 +8875904572434922005652897358604531384916362396100014485333372047722658292461442588088931849935109173016445065149146280103138497 +6344250852997852406467930596512109372720069308708153172074632971208643949842907827125891877283714403480777088075917332714430078 +2141088112696908575603884902935424862191062652660730968192553423838776572288261313561512545353202622522229101786236940604077536 +5420581455921312988453042096323962394005097705232943223301112814607176607418563604729931333417412031473023307632699354685035657 +4904931609893963364651740622632458671635349731291306084872673976452365611310080979515796567705432384020374827307261624382593308 +4292701172515433578998040448234672894273087795215109333668233787741983605782088266764474905796649724673659270602807201042559641 +0405892711593975173584006410022813365106426354541842020523033260675160988528765885253376470412464249071597201808795790920249321 +2969506372363457771265917606965665281965775472879910780113511573805868748553670687571273946389007257215130433994049155446244186 +9422294818781445710760638755747391659377594672815933259737267891227254986222671631563563954141355946614955207418080860505944166 +0087286626782644309557643177400304492693387991339358406695023215774476540471075851900070969889709559625262772196723374356067617 +5897279697608188221125456894430238474410213921346239465846675042270793388259552491229704041982502727376305057500585797419096572 +9629126678093091084216993559586337141715599917690951379809444249525710962700663884823083705316885810747054287541385125785199583 +7595346119985543253389563272070967517963948640714499895302628870263490256644647992172402145011433583359949875045014139097383990 +7523156213061115787711878716816595972617134587220608008483487762219572353605120083032766155082751752855610567994430397014253895 +3701919959515768374982789437891830642750960645657994589236832995980797844253496076657711645006752860088626834982056251575040225 +0979950855271929320767873941275718754278787090305240807928650242101643623835476811933436063479233606315724201732634520101994785 +8113983065740845934933526321338302277547952641828910682131706421618856976337728051411744765715349602385454916896966865817502458 +3541043147303624444017398708391616664010004834339935228226187248791543655458437287589626370079460316930365464946671005586907844 +6467142906481062672351612846421358624595986748030105764102127849419935691001942740215832120384833855662335231988116688960608695 +2788530799703761722379561161257911074841314957231380008835616333860526518888348729384930186986891972631716493196919384541563044 +9960151488910951179842583784111062968107086150565586865326760613018375413860020781154310137687104793480739369654379775885629180 +5757125618091793590015555342485911625792045336449768530669665131967481618933921507464033442861020327590807013639300157233850794 +0108561117599044904729443235325450727345789731582292014742872599813512719247096059598721914318005872025916402947088829272312140 +0248866797650825595958204057508507830807476195084664283762933417519142347075582529326241506715718869000199121666869916905668032 +8723343677864688450245361288384636252992454056026441166941292835836423200070814147349431308408145782824860695919605646719597656 +4679974361161727145100641660878503281476844268161393833161261969965276371391589006952925603728082872969549646978882403423923010 +1471039994683623569789873331804012722815466719684852070254837711074357511238693361592620597284807521864906755820794891745584020 +0746324287724173135220206601559184495263174825463472438325932765982783597938536871848298666533763661034332204209283999095134727 +8847622479138729829083277482843135313544249094572861179333595590622772221061675396437819003622647477864448706978670376179646671 +2102601933270120920559135994545418775337484717153198432612404295706149728016561442479718981277683958181059597372600330224769132 +1259053282379608711992970881977405077810774056106800273103144031624467658496517236458989974966732962924668833215016485379965273 +8337096778081104941132624055977594869352911917306275484469902456879306916808789684303864335821138065913931420528939044385046271 +4299368276599609244497481316123376963837008957992736164808101728168540138407838646916364855310221850303575133697274394091619868 +2713682765289699129061431150379322274699877403663503040025037596762253721290401208216082436415144118858632156119324419976312546 +2881609371673910343032291044465003849815028985591391451188131927898325558643746240832264615980161723347980750483187867525894824 +1267916226042826987257806754004440337824069605413162886825139485042850988829975658205470396562194892003670768255291562747373670 +9234220033570807048609309912547070817083287541492891357818324994480536846132188820055694019487542207004276192292369053562016777 +0261127578143197454905032632100124793899615216318941692486325853609952184783830755458121912666549923939667928989436426770649961 +5323045993412285553048451071174802746049476412795340271320920389475261483664749025686760199917517732942380222819936015551403774 +9891352074356975839408670998973900071675970495889358565662068888386887973659152279951010618083877084169404988201568384833942255 +3238050166229051707803832286590198074734858215255713288528844554284335600396367554775218985201346513397387400209397068796825742 +5728107211476180762511967972657147473012924183544027968479506893336809289253531374220504641466496667214723927677602095165464315 +9011192930379184487659969643233786997863887173759888022579642343995986799605176120033884333316312893660726740709366636155465721 +8537171701432226276253255188614622965933151059377811653184802609155191205285178705789524447418786231655055288040171432169049130 +2707936970837574068569629371931407362409248401030806380356720552870356587923391333211272591561747393382939386843280495661244314 +1175509422804438381892148322240590701277543376729396595323849510597370466005945680426336918977914561211300792916203174309654171 +4042805192423544654158411198004453353597731647696727421911837745446359133507547657475484034048732290037678198364742205283336338 +9337695707833044354501853716373623356235483326284612569311911355595616206369186001725088755459930335959640295675396477063274478 +5056639209721879485672408789757891131387617511313947970994081160678454602320697412448491839531065552976208944273555314142041880 +4822378866853898824086257862623541730929040197220702007762078231078349736989651940081080724932828161588263934616036801731107678 +7042616549110273896023934480613769270956663187245804271172698934235574549161064775406631472230169390486643998381840493803484843 +4432695989367708020512810012276065008453086786966931783819054126557051679306430656639833606398733688366162720200084451796967553 +5350105131227057106985599834342048762794186401151883770272342638155104883645396726235498798575148882718582404327490926780130044 +5764192533929612390344710894456047465905143834205988681215996081613514814903908502795919703880401811242594826105306055481784823 +3081736917550671392293064759141270028494719167332097201455667940386826052104961288882027240309372922868375595753000121957263246 +4989894866974583276238356566258521642610551259726323252743986766553600472233437943119765905133915493843897768279428421555764861 +6801273161353076961494549671635819940275013580673219344227796480147357333556424794612960445706828140206119824948840749240399787 +1573785648039077385334262023034272384935398204989144292167011651539471971703585283557377107933951650497678725581455181207346698 +4874698339219730333194095651462069186623435369684882832433815952523247766685863473588031370751632910706819521148264821690235129 +1745856207579350369947762735836875634021204626000569901414064309006844235664625468595115296405455194740314530759379861609679354 +1263339035301388606388533163722497011371588322482095769750979879436887231718408664779720990691297703089437248834586600555339842 +6251850491772376275294393458209471528965471290147918965218220499155230361216164967212789860144972751525815583122397986208096706 +3484214175754929920259118693783510869997218078047468018854269713219002531566539459352397848678904622285083238008575450746485192 +5035485477939887603964624838580376893177633857009639663967781579876337080786152281286836780643711497334038142643551235377859312 +5770990490009748551131841465407612077195558195928231585911499648608018583508169531801015305515399706824738442071885239921251502 +5505962701249607762425096231287734763141665342862391398728642501706701840207749211087529147723821274132607543767155647569233366 +9531752996646776228330405381959650186056935054844849148234315573131250892996644098435195362019426286916985576819912113865830014 +1606555436659451432978242703284043412347220692073799660822918397493666695089541486316957331014765996271479614514099842437809535 +0289392478723841946498232349165923942701150815142311799644394965419544149980499852640646717021478951519649059011872310248139100 +5511032978947425845575588456445816057377640214105339473284188761415785249565799756251192934762389301520020016150949209737931857 +8405804800314504366659749363367231268121943183966514746661384830649579675620136873178912503421474419998605051121952540207826204 +7505457456876976664571641545260379929258562329503538400546169325488895767917670975295980264182906923671943997046060564087753548 +1274387949977098682446892314563863257816052408410571422114222854885606494860672338931736657657635104187063013087549529686451859 +5042755850832972022663213277248439000831269961224227718932272498745376713860758630276016079020855254056636945995345396441383249 +6344700532270890968181465829707309620564725384105716449055864407328703719779390283415257182087348958918979888739066384714906447 +2478502268884223599964876320836160710993832544375139942095572555604343446400261859797019349052899588226956407340248510969084412 +2858479499626608853379284122587510516464864248784114135053508629608620108109543831989223100900685873301894882329747241764687394 +3516073975240799285196283516667224035786957693305024409405170967493899593072209653378675045399225752043351688237909816464332488 +7045960591955279992811051225021192695063962021956994060992139199430008815112575669363055918094781304106258599283195179624447775 +8303548637737456436395221856298882133107004338700669993457647426042442520873552718504789607522324772936205923889075833787877983 +4528959091848677214793256254827374251508317477836642431769535470979890535339665561280184226951752824749258073794415152803073480 +1459998553825438645486213601892946519503789985188491129629213533576249295139024141113828276369687768834808863007813942900737363 +7827507025285847290454033855290419493832906414032145098230761761828468254431382777807611448800062745765313713732689219610038574 +3538625159483449646940178756166257692080479081424585343862543469052182432934925669284445293824171233112956439604122644220734705 +8884093066755275809492142335471176239144329953772128474695403479470145379846983260079920680227191033324315471442379828977213518 +8161874018859891048210600302227335518426279312266158906257386817733776024570411483770025016852705510503728654494429243801612182 +6746947553453295308964010256393213729923189009745905892535754926116629620973613924884980514744338995975237628963272677038960017 +2316979912101253225038374374358240155041996499533280966926264100171569427093110935120513047386276224147665309331079377719563345 +5252039218101191323619349210669314090591183299132043388783600602372822313158646436097466384432429894279310347011205483804258365 +8849078102378497326534646727789474466302897639756078400720546541976326397706257168948381071970398216623030217390426497155999023 +3271457271229858454657827770335612567349224212240695221407152662225083082143775459834013524692150107287815992741275927112028076 +6697268153473360409230969649314429281006253608637773637800129431557004336600687209561833649108523766841818697796052616713524406 +1264023927267188505910887476294511895228887727108862538027310305679469919872644028196540981088809214448552558389500274219570341 +2341820289505149961074855375132511787200836031120337305514546465652487797619606591322268017233923749079200060539286691098575276 +7095345917502068750136490067362248249806291619173145831611517423916491683475780750592775740226681145459237438975249038494918255 +5854207316691383141245954956380735287065353365324788816174156724268585661703068556010195412645633774843480772404581791184447848 +5983572806554767884384691619553163176913927916522767085440008009887977162986441335924089064521714048589756802500400756006764546 +8749074908864079527865640561432569820363365495585933467014689209329639785755338623694144042638210864919006966920756182400308068 +1488418928276481402385931315882264463640479342727038934158474806015143604448429971536086762337574137961555181782018130291223711 +7647631250366260770657650732694263292505761395977741171841175592881623563088242488954360090722844918014816525013438918815206919 +1155451667283610662459850201212152183408308503418856279359708202057227744768180593554527508439246428232801124311275672977637096 +3703563826897681685685127020250312031591544945988953353941140195645214477592978106315927871524898358121653801020581142274555566 +0502532594831295067422782714984502485832073390165137849670240378837997996971720348493993863606290066187249274244662460276318689 +0152755194697776938435286119441290637386200629628199446127743622173851669645911455169432495002024405765718643210153464143701889 +2562249212763374000591086405147643148598332714850654045728093130807693494090674026473297812238167578278207216049055667059931109 +1802942091998951751764726262310843905210614073350123667768202638105831131108058708767584753018377136585264570210097378501497188 +9619747156993809984322106521027559385156110152742577368251988283361064503255508785410345421538190771023025825991060075397692057 +7975279398046115700291300736456549463218759811012712333893946746580558137896237287869240420636891089058025806023431754219781359 +4988421426405962855719392598321200928497349040850013918965781094541442225330283536616202634976088463128589329235150833173556905 +8706200507172140856416642848813849966143817717503023224834106896623433469273328907429832511563972309658830234487588093651045739 +1804318877742597644565913208808319750885352430439083436497378247283858616368363127977363367800390625897013789449450637875537399 +6640589174553589654051256599633381120024749952650719727219130629373315456037578535279963334633963259335915488696463449646684320 +8032272830450718870582856393550555068150335019058461099968557096935808325051772579016403379075019846185741776197086257884683319 +9863845517847573376326098832507232200317675290516210661300649571154879306959674077908278504743343209243187243262639791806186829 +8260961262731301702271912238265956345814430445731867024044874570864287595912998480366912356847572447005441275362156399624494941 +9393142035376317879394642824057024278760474627041377093083443136837548371844421180440200277690935722486852916560800667873141543 +2707649253179074679795746660619684282278565191941032558500021642302377918384225264159606437430918854686420568233535916210590247 +3653446714468860199818770176822269463628134871277975181151133360475139855607198727163601307481114241837610243765527921963130342 +7740886414228885927181817969815506430494309276878003524396743847692333838266397442280441863182363662933711077420022986422070281 +1048387053761801939044385077721021658809540040018134673396554017098633248966461113346771441179046101247543088625644697892282167 +8354720955462557218106068480057094392968433715936618376234382444557134795213907950353329761280756136821666440990155365084581402 +3688937719186699342108738462217437423679733279917547383863629404136782590007047571508080094271518356483515978166149181632884691 +9910698753207335191315666777695731726998145344199523600464027456153460564479006998462380767579651598842317204792886070420998182 +9896983218119310999564732404427002821382477892511011450905458994448002735795600011464506066851494867367124445888153203962666112 +0874480478255387464724872537442210377291532518746867402289144019512477208223281547993390653821697806118478800205575150577662857 +4918888004811316598554705337363884151483714153627256672377291874950758530975380513235648385297027498654040181963476939202925535 +2944953053399838723025577285199841577289179795119166022276762443360574684698180143394617215098184693212410119796009072687729739 +9732016373361334253176297777291060712041712200359193577310902701783613655008446771602140682798342306314527926659629849329119883 +6451043591004466592393679872228794008130850294984708968342075888842891418002758594861642712850414025146690654543853793479725972 +3268929657246764345075224814644064768187234583627518324258659649632755014931180023989253455291331973610627056888949488127145955 +4261926089033087120812284628614836440477048559583788705295941729615760122728002946792084729956587080892613331345225489314812847 +1986796721026437522158295162217239471552249715846680613750709615232262912940447904521346670150883469709041492285328187488804299 +6628012528405245613161440847234508491425287943434287101928325272535635664307751412665147263964282878231211570769131706300759265 +7377088066364420743764402212273540338705138073396342307947494852950818207406971919647576428347904811456431944019834650692515506 +4705138654618320095006319217530505261916581737627651424491878629844356338877632449493703212698711863106207638016952512058495841 +3297864919576913522726817303334406976314952205292550373391722910736512885151802773872849953849211298237482028668331950499038336 +8974669281536290012748118151506739167431258730634523888446083432703773451432089051580445107667501300580071396777438663916505890 +6676388335245038478835892287014370527286751599266433016127479958260673956274510190770236842963946164980795747343439314929899367 +9777763357901635768971296015139054097237772494695148781717193551641896481882800982585569826367439263979611639005318235314749057 +2006174408272512048656262525906502452313110102817338015892638328650570498699472308145823254807565718645774486952361348150134146 +8820513608849516349458467726176340280776183307750894733331062785346417632047203675211923303269854905166452369376623717371465515 +0487090344893360730368974812186113379856699749061983876927406730979994152222167896194935782650684486995334925005887216364226178 +4428212757677682587368912604936275746129828292671231661463255473216528603314371364809318568990891647756504476074694167225494387 +6438298664776502895176225722692218937876815974395529173364685280466577427859435428997212680686584089016477667080112002827762955 +5372837358048305432426520203755641518748461432567909426155727245524828496289926253694681592910381964428484012886894327170000564 +0966786693488185832806410657062413915673905612790978639242251067404941406079608751238017548545457392976940768385484687626020964 +7081334569477079676309855956739406608641536536529136201573794386634730088085065014162237881535086131012737674806790302926845508 +3849506256608406770319555639552727023819412680964197246748248202159679944624779483651489821124252171233790787024388338169387126 +1220350189747959004534763654451835109235619957413590127042747161319131890755258681890420398880573552502186079819673130304226319 +7793578559294710797103985830517016163667215076322029333261233893714376644214340079810529332625249572639110330515277641165833848 +3375779071080037456833323971305312807921291040172365572121296035080033198190386403786992644365488916964829938879099337521148544 +2151885079681150752124200634430960212055491111062153428630936693865872096334814997531820067268121582290646921550422149642030109 +8613181778258533141158145972750085504588401393903967265445772834337987637418600396630528732934239316047591685154760079805548066 +6810794208813864500809678470319323448087878028803605043954670396669190693495990898866714597544374154361810960387728955757997027 +3780694542345726440651447280692129044592214402723296549397501233597057657590741164054767713089063618201384926245188297986421050 +8252358803202927045538322743598848427122577241918805031148056119515867274399187693181758263084888023518690338982779085780404769 +2424326538477152923084594002081423911440158206786241827087394911592939363042513317947630468078474296989628062484584400644343448 +6293560419015354447114147053377323271370974957505862615433195073799026219744354293045028357502721448147460831465672262899873109 +7387532795839583928982541818961799651808690944192536299119649406867938059084796080728700163640618737891537102681397327040310310 +8646371766907348023824656340748360066056892200614557523317897955392332090329097835097131487719957799594533173582638863081864212 +4986100049536290446290958993632891990045407747006838784207732735249166707023914891375926737812449203630774188546578985599909811 +1084402346707970131458723746814930784514195757804466199671002857316090262762516878154322011683754629425143857675752082486603247 +8761838577711280264766083372187992430863964477324546898292032760669740251929185543394862067810777754782525582117312630882437464 +0771509220114585291617227270613376384799093204219724418023916278133523270037263368542243169870229505561283586085433377009674011 +9820385787390786107677870809083528732710164474423943477332838364565199183957564959608617849089060421328797474250989472544417321 +7919326323563029775076417955118634250595776343877190502902725431786697484594693383405493496141691115991728752796848704617855725 +2558255581109821405634179872876958166347174474348761073684217931689004048682704410888017280103004988712033725528911209075578017 +9160863221896162516421424469589930231499714756713528296148018288586763465400454214603217797926981201646940396481239125062147650 +9840316514604720267572846195066141632646978531870664811024154364403354983561787177052598257504070314131100093324913554509718449 +9311775701841172266095504345180054522901312438857477399185382790126084433098439433269362739881218978298243657480689874068996355 +3022781945908762278768811002699224365141074026805076790548873962428543441756247033480754889441799694147133688175673557083134054 +5661203741867036406194178717036861247199166773801082533375613708479585773697108277538910907988050442661518792070910621436071059 +0690138478379736786396005725249615711997663990048585261495921831819669914145515073403200894318211855461357229650824823305525133 +1751585791160648049215935161043755494836647727651069321059714784747155745680573976254930604344088093264307898664770655705644210 +7624145261014687805152488774841289678583856425221410365164555890159519557132962343799732888357700797774204345288024762788982261 +7890710552868121263477187455194185399264846143513087916598365744278210315488246993448630198352186843484020444533061474327432896 +8206909625120146564482691781469049022430111838502858582644125909195387775957182358764356323550045553074686821737193044914677910 +8204337650424296695493149708468179951960014630538528111508141341188662936175939750414398867506644825258652647525390439239752201 +1219359010151342200692679606063626284788399861632782010310804100495631217242235430375489322644648855854345633079496117764048987 +6653697464408607985860924202927606340854610960203650555980002938739009437996650927711204711526682854187368829518663287620378635 +9615765538591556297112167827891749863300345638363300995749126057833117511099109253123549891887992882557489784541036449471882403 +5919028352049694001658038819829671235731815415745829048231249060308117257367536285634944658365311943856716917740139982945041953 +5779687741861700152585779009366027675558545586949850924189709461217199740749305528005166461978008407813915390937008493360553115 +5834977903061566139099870190655547716966444068581774636647968617674813198281268006404303675453751976888820043577600761967333881 +6972326585063978838443446520453713997506879344217941897803906052743968972254016142258731934881056702957790715642228115030783951 +1362425902796546798395679404782769752464205460307818179674687205006891103510168328363308032810297518997174255427908231022445396 +1509825900031470252867573280977984303757520410764668672441796612789584482854046983756780462029600563288455226754517497700564660 +7759844224301976256343546717305935453950775711909213261546888518009701479912670689049983757648821113680742909226880646315005569 +8295567234561669944338275143058695909726066802894545455268764288094686590468443329734647916141835949923568889966174907115365925 +8847804451408263609187211738763773284048172606546780028907522556324927271519705281526806470352840988271648499699486513703844773 +6679160425612818347335886820513491773906491628651444000288856405322740614920289642723221399498209432232637228104522990852837747 +4111012689294616788593607591102956684483592350971102538317426326909441395344097833084048144520705500574792401000355907792380226 +8347617047251388711302856164567942061715329050448779661635598992241168749527006373179435024773116055832951174916423963970112173 +9055087726497472517559694026453105136312139238988721622285684818285622456138820844308772825216777711338810456475617988242424162 +4197863232696784218000746661193362219301917851338032677667264033511098062281872897803087758355321546501532794013889570222549856 +6115749894285255554690322957000949336927917916709996337643587065466062558943015944180187981070089004992789679317730749848395116 +4787717685054333694149897473720745326568218218182852236278365043324649884567032268831086174748464582606382556519285049880278120 +3971535819215057024510844131306800637142690099398881617684362973207491682213220003762765264571054110883901103595485168757504333 +3733461701846483183011223494998710865469936261566419212369452729547931045469934427223536598514620405179798084202385746863975487 +6787515125117652836269017536232648894348703796120091034388135038967463209181552965632410604353037772756879239864709539921500366 +6197228209653401639582453147092770443022867307115583008238408014093437109999520308757528533277994723967340185717046004119026260 +0327403058251198538854684801262565688227840370906858688450070334229654311591524491257725374686504434311374381373826709761897189 +6320800720313217016667089641041343357180293991403820786439200978809209918586099663595021544518755767970175732723433500537775215 +8586605557740559261081287090127076957830333678084994220662406403052293892606977228772765289631860524156764537528844813070064403 +8457029064238615286786107279460798384585105993306593540395560420933072225512825677840166549704827482169925869109982598418898944 +0346460363516674840943211123653705144516811133167773396076974206411386351987012791478690845256647926914987854519697980693850902 +4071039292859550793054081697582930309815712485519665021072773643984757349601035844973218854642152867868823320985485836576692696 +3566944195916064023455915853671413519744116499257428302391059795726588226281448949481887857567458305547585518788070366283222643 +4475630384874509141748841479483575783195093285020751153893790442309506156006253308563119939383816229293457633418322795791651798 +2534236711768923060748330398823973796625511107263972895904532310389295669901143468746002992855700338033513519817927059960082258 +3266833442506157497412341209730995861476441931081314990884968759007025722755350805078872002993770048685210269397083340942969079 +3325013293836474893127556216824859727670678446693115589979109778870903809827936806876988266059842178470200459657153466761585276 +9339215768239697841992780261560272323641382940735693971437349481277136632058838727826902049882698280374121176916226254815769890 +0579266322319718076679029381516879866920214093645961826097287139995438556892638562807533592029177968784950961959651824138364712 +6905593271581094882293836027956049322801541013654133342099776388830151131142904625837046121178740403372359293970069573073460036 +1334657560229091661514767192486484034874814804158436588838115645203542626667263606421481459341052191296393864355597357106139612 +8983996484498008491962652081920903788269022697096829121085293173454864230335343930546161539206227982332409686050424799265682960 +5979943191308039044837616371196377606973368879788064283861010090419804092295381096855027541458106648574572073809903498794247525 +5748223869403535883463902896159174890497470441638233019825678773597770107171367867175754297335334571074534607008535043181405194 +8795353535341345876592035589428503364517129250540037247550521782811791666374510791517112671288737422099652323046937343991337828 +1845836116381331085732349956975527066319503790930145646064646988078457512408200058689118375881261700543344729871472397774510391 +9908840174753246368222566017712326787176851291551010131314349894185604484963390215007002796394968662213178018411586445058609354 +3648708782366479438386590662421575557958786432758515733410030956830742717789884410593667200352894830011183921069426063462365103 +0863636445701114598272155058937842933641739192649108654968863927721554489981493578009581287965498827240184001075889430327826948 +4493294744917241293353606762738125798775389304371272784848161045309965481110981617696456977856845295663146310544856961560395701 +5828350063875380289041787243953420472517640405923728557572182762701021146981223831971084235740009591348792854248246191617472390 +8142911427486019533916938360973756294199899650632305767565787069658787674361642673323286198646595884519076147156672045347769575 +6919034458315451231488534732525157456948587079445950850088410378838535977516348080551775162637211781455681436512037018188409356 +4896222628077283599302550538329307529265839416312577475209070966536398530653252477467412899117369638571925172776374288534229909 +2854126939661606237890723618332733028245947026454912620083338662672080884075389624244778233027185136679702658181696482687520771 +5486768970237811447646114465006645965128132304833174901323446834886512598955526763233636026886751282286763353050412483339880879 +9146149867375327619762240148102487012789152939324347118132416925423213349620444217738724989375651879154078406666532230695010261 +6432289704281535683765846177747137478857199113830933135896448323481180075359182281747819927805855289891296771338965010648932514 +3498778884149977137993362603088225708342761654666600988476000304267323094698652989046529561743798096047380169014973930605911712 +1555513950736376520645091335370846495268353191373549111643901821633347913274787967705297774512956543219272395543943905097818713 +9824515005207942672277682844175672734608049189360837751069564229080983682875340351162730595292836110710458156809584248318311829 +8644392801319979903321539224060850887494189887888933968978507838319574610389051812420770840579282228222004146980291262806411960 +7170669714045362254284955377287230002812263383500586848752066007279901210618595185664394253569437180949208007446172620486446640 +1197418824383226696240145317846075038217263309407432715400718235690780656588433075117078422196797078588171900080472556706089444 +6058081175983404316870378185108517992309376387807189465675421456144616633676191879370638648087281836756096354696164358804958793 +7175300097350528879964995120589418404250514397730435804307880003642423238815219743208925752113332762492815676234753855313749687 +2216821005143022212418811965038884804162533171952178272981773050431225972337066809470007006624527746167477143326209744916009321 +2874879795494394023670916234680048368860577149936343642623399857065876920729230526286990908222249218870734087284012928821855198 +4892669237695278094261059350844729450055740052868656916863083244548039117228735586420221099748057054754127348342899320517500476 +4913533064284953905878883623486045020791418669162484614426142342087782118817607434327885376004285685360966673400518425200903095 +5236853047264130432207807874987854720636307899392809936830966680235406253508899133299685304059306299982669510153104336419138281 +2635729217127660380760950574877790788724558832203965184259818062945607402185371541729168619518031385767332811305256686570812707 +2508693777459660048221434065348386546516873503781056818039736884680690592725066422073878336659156014383855199604525567079024098 +2527847075125720859307217125972603526269724367871881994978039745425984811500976939283305909268477371136914408464862183620857832 +0690848798245605847434249059051242459537031098176625887386313497201621005955291382938621297556760277294613833001841927601417783 +7028637829951952641999762601338035213911204478792655772152455046625599760300329777350980475951284319951538433620056110253564781 +6305383937871208842219397097772665248616270756493102017303010524320362272253687689906320569651514870191751716750048983549016387 +2503753802832702119325330648883246982515086513140942076923304514033686102637700160768687271319427097046984664384031053585769263 +8859227992404387206024381418823288245956367455432601449940099288001162654396819305512052575309088805570615034227083337938687529 +4650804026596773751781171691707686499798853858855531297662807643678150070418762900082986264876734988853277036828880591174772676 +9388499761915323706082278918760363181675840316081077581226482199990184463308418161663917171550066696858396843063924348798640785 +1339519437101345180144205804260788988338143185013195486237509665528555982435461459049630103016492555659996037806521222234571639 +4775406178328515482958996000719481194780201067828314313954411507309766697327602402398592936844052573242705274081653994583193860 +3528381321380368083594961454997422094241837847317957074543832643804670074418168234251527826193469648447514505161752970468032251 +5644398364843284455563221983222109730803753471463129763873997470655511240512635865533704491564823907699160432034740568090163512 +2019394829622861074339274739867648100223183661088275367604560854273519173101761322314118755022999112270121442893766921444175618 +1024961245677370458394203192048216519899540056189972652416007572725591801341729111029393594712226889998156435621046992279746041 +0271013842729391960551828591764938026380238772791709945105208575380084459912538928688891874547881085895537996185248760341022722 +6443644163751965239785936903668129878996022934136734635016147841655906985263150160687560568016130320940069489352717984945617017 +3980979401244807308375088961101007696165282732048547089807678715095196311609438432458589671418362252711116197050123998645160718 +5029882228039159089170628100687054725011048437854579104323727026278151658455314659996721845525056734089399419451901797673293081 +6285409273407838783004808714400055644398911907669583936293776767386307697838130877184976183405711337976463042849151509723365986 +3789116449777854153143327216807443418065067164460291516731014023725079965308205893342647719238044202553135045734641879985943779 +8298817649314977181973643591691453651364965447794449764965615478663842601481733390271221156996231579991946480360911957202482419 +9923477919534528913583979154285960230181626227828624997322864558028580882337999440750509388244247586570466385544276236851986673 +6266991152224272268084343794242067444247144028060688211987908624847699372423422643841707689624467016900013832905272766427426840 +1355067343839251713050029297274635544953158759007585898844352763675665452680269506694090597773786276467200134181329183129591894 +1203185079814519449730972616794089846681228932967991544425024262788862162483806670387321965112895932667954720701857303315356633 +3010223406691406448732071777784917670640450961064883921707223591238303897553076936064137492313930301276184114003498965768546700 +5055662053584872171686392213754554115803665951484341184481678793730256377197108916198950525496472627926989148952673813222574403 +9135301836957832126464142557708338619444651703425091454666943559384577035607172295502116858050756179608799326777436914985064677 +7849895476822416074994849352092796372963487124157171056152173017480389097568380804863683908585558640345480249639539155208814003 +9261731284405809837137712563712141454654064296465941789875748814378776568326711784539691121352690345339673695586510989770974288 +9504548640513288992288616894826847158596027709105403654435535528958145029279713253496007210603612311147571118952157286120765811 +3172019293671644099810154685400878900781863310226630973663196219151877477083273521217193649999031944551410361083160211498456657 +4584835039206895266033291139088493090671186991332152100943013968139485825629047583367832339953098893263224674847060194281239454 +0086703131238762939716791409510475698044261061184491246815071586146930458568320808697308895974335329174951890370629879266697586 +4531479959438670471013925537723663881523195629756820131576957595320119441034946472734403049979337927590688920672812290238838992 +4555784600301091463114748695085394421438230893318590726172334093673394223159678897396878630225087240466235943323892469006400425 +3181295825258212728965331361945064921751996326740368121061708410146864334211196041567878993280564094949434554682791503673171658 +0842856419453623298809261289857239402872945556557159985688775020115214582384781860334689651493902766220136835999359515682473907 +9925790212755349035787540271290598847673187935010889467948737594198142964082798741209190025028872359505393133888993203341623719 +6881035084279659821037463368291359288972809796102439700962259394869871767171237148065599497261891353342041591198086826562479936 +3071229176011336182119446125694433597177517266017496957596892485297788477134388949109492032269677674633006492819820954408939636 +2158505696670981583492100994722239785061126885782859457540392078035784726890160616966602169759722004423370966068470851220475055 +1608442432121043588281125489656099832629914426535320512741673998725277196703980523715247319219104260826637474643734228192860916 +4370675331345005605018147797477139808981239675873728794694700612511771169428567641131258023552337644203474230406734637422278712 +0072859216860622480346667080043679784914202926542586524758456470894276035984569755855670540260788837234221463158700441389231519 +5908942320852274627106540557811105888610228644494103402263750822407154871367868699882023311506835501899157241704189414346964284 +1936077419723541310264634055462791796583876957815065743467706393867078774982042343936087382789908364464848533080889495741496533 +7254584486083999860932338903788745031776193198150907253247533783144266741445178920158676792459480942978555519260352341102863868 +2324388659990555102109355727630603564463003730580206681960957998377155433799099008210231393030776738444219722412702108302468947 +9926613338642730749665937063588945780266089547872794933113744630542358661411190558266352099886620858549171525338223571617167711 +8986318093141580580876428982707764579287478469073583981696234648037808185140269756651566921560785874161230201920488349770275568 +1902800771331526181562098287158829944843731017880219524960324079005886150803168559590390474829249427791824941894802034999528722 +3088584384403360990907891602519470935005839028378253171884990772710302832296914348751708792698002306050160936562533914379396209 +1408310312115069530150233048818331378284637723150482392301602795737916335332815872089409379843010863320155338585218615794879180 +9677693345069319403701934383954872660888681515065440356051840106884171038792426226463129841417745680354406721408968771559961954 +4557539513449236642758101806291205473048350296831633561735117237579593752211878576489139742035316348287283326781007355249045447 +0883189604094854361797387824593448971971447378881204753543909216846733915206018358578418844775503490330084862478510316277108659 +4392550432502243314906975265564518025479113098902169136391369512817565837562370156090165943691065253900876426946219189578736203 +8435865573452195078786548417341611434423772217538030617156223901185493595765324312422048299670372764076523094427788078350076588 +8758192779916285126332006796232045283091922027709795938540004604312898200544114013208612412744965934919541932903174519980041254 +1905758872835083202758499042134848212716811095613617523820839042848090697442064092232729193928479222578050789364469898951584433 +2042272602260087723772848808702134767220173723358646135775389214656797340171301999623954978758165595263461874252751080813852370 +6274949154731112794816216220066048303875986872572001517499070940234617966182507743418989487331756345308613913050407521686762445 +6252730979488500452149052167583298496816203113490366754560247487872848255355376484138619549701240217905711665471993273764649239 +2281622687072260169420599936083131206454896277499378500769391609676460024680767553958496006032193910593446808391535507538458599 +2191010913898494379461759294973512837440625801801770581499807998348601134363013493664904191350527640096566620000395093356134597 +1660938804470213933500623938584649317535645503810385086838104030744441292813013981381095457570526776722828297499568794267530527 +0049591878181449823254506571309609592366697654558586847111232650386057621118329999460228856081046031697258812551653592183584022 +6258688415014551491572224840400910043380364244249549379338382107530054462860121947719561782286604468083436850199239844591653106 +2286199429292183729722721966817924988059655688863458946473056847154314312282407066615331874808857982581754086039286737461422747 +9602373046472185399409121350660074121130363291629972502459350277036971026440212505022927430609191673069989761094096992091670991 +7527879946650183351260678785085159093046180958175365176059942440628342275638429735328061936632746613485734744234236065653841137 +0853905941635849403951594887838110573652181835969202362039487221504242797299698627659839204874816529447544114385531980406666739 +8062623009337523311886378539061039298966733017052114071143987228104904834551295397466673191503750551657795489921304516776700376 +9007862096833941572335165844081198462047136819292917564132567522715598859947138927117299956642745110763969251319858190814717852 +8138958664951405431541453825461330550794221363483549976099721937150607149588852431715285804748382531904426919820630714135461983 +2082397885435139903190314072146037819079478576247984221600827812796545457214101194496220097049368103574832514769701472385466387 +6896832416290927778053721602166743175733725992261187904101998561355457754417056692268681305083190893002118259512241765998122185 +2636968504609327449982531058224266443456972154252698660084884189652857349507395676672582020179531698016039374573532855093674020 +1136026577034357822803043248989730467073666295507784903395493121839773911132783532427651934810756742564183961335402101819870313 +4917099632663820977131969667158301701831087873930909603855469814730542409624643679930249460380846245995843352815176947927777445 +7319944731827475004706218777611396753968431393783636860295774463198452128755272715443101250558014321901313052738593050746571261 +1707391395815003284391913583753339859531852184651610466904418403752429242924142601415582143805388089376849781779454300111958363 +9869108151029888337540428241180238714963181644033868424652184814249832670934245802862990793758097055499023243559198701686575666 +0187337650771748598070996214382876748717075026419386245187486192182726086987036097255846930650043060886509574171932845313409481 +6310275245723435456702127325230222604362757109683102954203602714184216564293906952316506569915992137104170152492029578927512300 +2305363922251604346990506838961419388192179030700159072409204210540634525740072656419492493606787180195424067534096459265589672 +9014680664163948601215499948895470475969838465633327315676059364457476028555130517706511356929094761498786703750352514595140558 +9277484889618105650227338993928615130344847104186489285414725102606461111639517477747291575877009412511989063198428666104065406 +5967555124952181729420151522869271680843682059283488086279627160865021360567069797183031645357984651583784813809428355166017913 +3607122306789653495447270140672966362274565501229973599229667563911606772081598572491953192767189192005766778789005815828610262 +2082222249317420567583150769393704141643717042001944511315146960110297197944325284159980684280693676403148609684883994123930097 +8731372124960991940185405379357412214932260280623846110357067671501251533776628907031655983387403452673941318358548346602760124 +1976021347697640428375581819297827333264016242688348297392388997119461967525771833238891591593742490277240125530759579876491077 +6072466888350935400785328899402008544459154165636826625026958037650740601926412225205263947146298128779293383020953022202454362 +8044034560774166401511114766914479073842481064943729623980836043134237110449322364783254518711575480004977127696613076710220521 +0564017571074921724777748862479718313010297525498781712387929033234996773668361156592993020275412793744070740135811199115493778 +8419964042103133610587792208097044601548949029168486670192222439144702607241592021192461521821947279760550828661220709620486303 +1088814982734131440185884327578226836944316287501836068430921447613687229952034388566585290882851495307655765844223170274340586 +9005799435401477659962899657617685769970912656575731463413483835844226203192655446200112583102919467583122082891247399200176783 +1851901588702515045318382295536798092875597244431065042731697266394552848998020859370638943554279437980607960337319274852691748 +4157648096188098267490705839256314766006302678665206847589272557754575914579199683296869793220703658904894112352768597742132369 +8723572441033421822131850984144065793127526826673880856427241209325971643349588168485181604003549286943794523645867631822180512 +9961788999122788832400015923298335447164102572685865228181427272076170219015236471640964326542574283167180040163937092128142732 +4937228274511747775697611764578391450794749466871545726021901964860582325608076362650424934625277209649989981489750831225970741 +5984541310271980053712817247539372152339967892775462123252335196274653874061592183413734875908267266920758029830479031847869228 +3871371830143074933411065987051697909188835376373962685096571028998970101211924718499411402849248202339306457377199877126871389 +0586547099952007576979285722825771295071780721616176263387445055392095793671230602073249233658371312728279604207471382798903479 +8923577166944872998618492077791653391106848257807366227129544881151900203904339062941439729248722161475876280041042987870134297 +6237224656556330445619379055992474217471454724969182529987949872722998015945413515067495314489889032179791415649686011073157477 +3003735334796840694489912665109880649358659073702150516968523096869480344821929684468744926264579118587187974938771984262183130 +9005753590334142936036827167253181517255166676962390793299722321456204920350620126047032582007457817410580787154332130609567063 +6768747081081207028623866855036005032042045118427663709885224327750939144410815093506371403873404919815687844934325487062884410 +9939375834444884922802271908890569123942112471025359287053666892829043053920922878243233005965596366467035614279935114942794959 +4228677728256796231027207112191813165638914358249269082781564785198933238543379292199026489661901488181239514397059686005148486 +9858539705692720243176916548886314393535919032096542151105543882501065636878211469917818253828853172821658378951042353768012326 +4422150194025015880156761058170304509425792379790006321176948407538912546088068547813798000277530779888405928477531694464231990 +9405650213736879289008838391184069127301195712710013925801226563743554996233482554161918019454022970208565224871459380574639835 +9130794172100568378934252595907690555743933712658951585006391044055921485334952756122241280828770097902109351842319381201019204 +5387985013440379266230518099534711152536460959269911655397255034626367231069408969413762813968064236154692333107664286960252886 +0837118680763800551465069959598175835527467398611671504215567143391659195926190188250898459493898805547983688580472819756799921 +3903220661160023222988830014776994424185300024466935537043911148899196047568212527843430862631973366330579525805431481011727438 +6908486037368642919233388174527626955887348839535505480142124695672332446751550909649591921180619995217291566458925431968029596 +5922782959375057616516378703156580986104482212435661177276107010237081047649806919032851751263569965116169589560831643100864715 +9530369870366296156375956282332841862206458152569867266578623568655520592049072587837930649946891321926334502571392866551701600 +2244120737959672078726164762991283327806243441107419508409939471693616693409630730506528517088302223393878360169050233927904848 +1173648771365582895309968552846929556758030253414605906336548466169612035971381029462786542081116525705113252983939162686385109 +3234155840835288921699357747660762996672264982174457829675917923339715647526557875639742064383339589189545825487931401530995501 +6887665436803180794927923177816956708553785264323074693008344374916559316617894764427215802134641031792988573701240438184249750 +3839539179042881405914564139952865952209303008409731497507386952470654995467985010268759732897359668659271914262252626200604099 +3901076984640950131960333781644223983532267536121313347358475229440208418673453842347657506344090138736051557656821297434982077 +1623302641135870181311409682200177224901019997404700215147219379739297672524540935209651730504196225871915072497095486880839456 +8525315354478812852093356397223120386907828133392270722811606375757983394361481913342296750609970915686272616757634461450159831 +1758237483830901977324883248068822612744747099358422855339260889327800667524049577373525949059825015390160043063670312221072626 +0817646239152869131112173902854770980862701701464607169211772950069653293230684510278012053087035337608494974396015461535406222 +8646346589715796030816122730522353992998487085588488148264344066530587174128544229529685414458831257128748560990578804587360715 +4892783957104711928531643465336739867007712821809759300577073458900066680389265377353301997705565938884080611069388312576416304 +2814927389151100129042633757615682635990656949553591616128856450443418496471442467646240189440950521511107482659253501599167684 +6135116334119022986012296077975055833220297155080260438551907096128989879928867449175546615606752828933549694825257606317586967 +7016532424149169529714586507287588315821039767281860867212525388739062009398857291177966375322314074508942295009826535646980545 +1130704846522761465358987904002837038112315864342341500267273512280490182439691698104185495677754466174462509539951393350430049 +6239545452060864474289817540605900770875649791603624701849860428246844860967392240963173839859434643202570338001444647069601535 +2892256768296868079082781775690843873409200886346998104928582896183217369070621962623861890767458984640863725872163427837396161 +1015987233236680540127175130575507867333440719260832000405122222181144252353002520085749044160442813319007733231316952017735844 +9207122991749764391450668652103974356514593013095625877412964336676292277200308352297929615022995501002585354045748416214004090 +5010570807508645991981283973843421015013551379801238469792061968346208698033924105198332080219826873915414042770997813678587105 +7079764317445013461353198084076807018884451655619023138435629015461147032511308684817994462582990789356614515379970417351047112 +9725881506883451817378068264565401988152381111185798791532824098438029254469346518084626414715068349480830207550031462251028658 +1504691090829009028694497048664643697386279163491642380984787314683252474807267403308118309227599112336474348292331546087385709 +8374045238326514850352601439525770150385106432876360117179641265901618172845807500617241643296725102357385086749024223414320695 +8751924711372854963768655608131773099674117966941670496696797649406607434691461307943445287152706412809962107879642575743136123 +0303974873561466480968743445273196900705427451656962370162651211903195479518829395352847623644931113876694882674530035776397562 +7062275706646629882491960277069009716984996924439240397590784333436313250958554553224460478301293892351431447612983420608299779 +4021998564670601304459878729468539224393130081394097452696802435298562203672631426231047502881058781296871522825905804208338252 +6603870763394362689777694406864771464497251023441752146535341971346977029094361489321326128197028616266687437237475295317363781 +9156020188117437220553660891624641158468448699614504995148457693527457205903178159270764484168386506020072977552224361333700137 +6800793585132251294965485406539737210356860431874461572263005112556102550605119443415354337340356018964066943951864924412299915 +9176918467253843792621229869758475550809947953676328982327607776920014653501974832672677357939313552991103607402118582223524673 +9686597280549256712036750220654564584483912204263497709158167656617008449221355316543489486938189978195357412962551710086697028 +0388429487175354035020158054103632924527177834523214082900849111108930893956355794346651605160826522047668675831813135358949190 +4345101694469873179969332042811556018423606297108948984557961826035019597070396285751114257989897953296299318364378614357933290 +4949793892609892089229851776026934561460317731511255552266868980253783700717106802153694611663582999276204920297363252094371934 +3674663375108601609896202396621130718019413744942494222052103933540452779973933501106619925311069127219850907767043719608829470 +2702622493254040904859153876396184987380395898007693621320399251663876437827374821903867019473977298529862021085159803043642262 +7628804430192406674682789691745692230306369379190920544277057351743344722619473702262372514469670378356778783948762245486971339 +0209360041654178829792127599208780855624409037374530019447406585398770659754872987726192651460619482209256452092276066423476738 +4709783672042319775995641852494077105915433063897114034300326610462577068371066683331006070063551265931785531029670403665686700 +4587667003896460717120912220270889981167563292172474600789871114756272885374551741764032376074283701965139574996577462686971467 +3848976224442081690472022609003207496720929495444016043645809920259850317579964113261377231461428538754038582648249855596427337 +6172335672098748490848298205075949543310509985651798361629655073050078700179132155025462638010290501496311312192593367695422649 +5726384573393389957861087954363684393648224844030047057212547523809090733733447320925926719918185564312722906061784825834541657 +4665490918503684461998203394016725914244105391374685986007968106627529172068516391306150797382538751326421691707344779240051404 +2641961236056444783029513171308212582932163735856854734301365261361011265730957017358847540597925397759304056715637265630175924 +3143119314616534179607705689766936638499515116711864605104806787742064610741185862931157231900890917045797092416341390041404007 +3447931172643093407899075956016941324761309449689246711224867235309324518097331543836073039264012951510199018054862544697302228 +1563566785164424421738528286186718541346261171578886688118979569809183215506908080307606078120020216388497864724764057557754295 +8570889786931244194585660557574434060147391448332058484468219132867607862446662006468299620134301595151046310252336800694251427 +0217713452224504960721091364387786965013258053103569599886166960333008816549340813042469646283329089138949995982273574974215868 +5241363057936964400802812697301682184281492778601196784957952838829973528993067785327299171845639921011068758599950934223980914 +3238619506166339720940794008445086813283016112070588367871958447351766426343723002443074101469688320695818179265745434758910694 +6296789680362763149161376071869217199662771928863547592423030630832336241218625794010606091635986342053359908043568336874619758 +5796450483018638379674081988788071939094611782491186354599577562913830254367966241420426194905385522339051453836242132016154075 +7739106134294761084702741107955615651072406250165155261201936784282832131480551569227393410480076418655073059966098939360374229 +2971567365547701845803783070635993312664824380381023912535236337973918393748125160984639017693662692774791712740599492208482304 +2270720904622266004044552929046382853488397030569658054130832432158967100326401536494483965188041727224259066348964879067583812 +3443273270836744114169351145812281297836105568675664537098362750380900035541986757124762712416133474277811013584828903165701857 +5742987445704693742780012691654778768416076035850059897986267208927114643299349752186944079949266040605774961616317552910045136 +1240573283641630694358812830029096031820509750547875205950719721469746524236951030334909216603563649107173637973757255912252238 +1182181309135378156725140117731218230316055150298076621940456444204177883491865113883523054776801063888819486505485385264913416 +5069068146388574137237425212952037225400371744975152454660711335647864580574001943714998326035983681508282903233341771279568745 +8467943310622656536228892538026964919357667642832630682651110048817452858559725652837991052187308635773654812551494387013316194 +6440134083862480163392226300450457593962112666903507568451147153007397865298280740371802995538252604177619078977124651051346524 +0537206772933648445348418297957633068071300723364120286017796847418742109018037795201017609886014503958468715621463005263787770 +3432430202920291906940764640954727327787760258258401409130943189103009317398784374181000619017547537895364515789076658241461815 +5914935373373404632064261928025631881068410722283620043865276873695737002786518062855969064577740316535280772509182462064465423 +4663807875203623784262624547123565729447932492414543360035449489544264792983057557527120665531457725601958452570287012086637115 +0847474551270439717567791117916716520890209772268515126243374020404961236068669964591032312120458856151122774707229179093256702 +2728583785414355071386563956562688209782901746373262288816864290881579324219562028197868974414398025024344306680144426091625030 +0910829767068265611067617086376443471268114912189289789288578161296371552096260414590275441364898692653660772972831143055685254 +6907552020126899986435407709381912657932246467804972165765350364308400598137400904853881086873855469475626923756560878726730206 +9692227748520363042215131444256441345425607520902904049752565589636006403442938604002826527897011684910364030121356648587505405 +4764025506989776287250936345001157192241256998927684892678268726606209680040843191546472014984020704327316352200558172668843000 +0564503985848436331698791790813182963520559967441699554268886929254925633860614440306175833628563304317763920599751129071094309 +0175566287557279025857970584297243285600759435104151831150200001725607992873593941524916608511725999483859291253760003734973775 +3039168535120967789573627753936889933310390638519872912077737282540474993630496322839461848810678646381314301370434612679202453 +5290955424609618789728513231303753525180260090737043547498273247450093929519045624882089783253628274100484171694237532423254859 +8186844862044986653314802892230697717326617551815053423012041608272398516591496440428962043914698069230013270892802838135287280 +2942112717174269473287862314996229628874313075502005461595688743732840097634991389852224318945641142059923309434297254976695326 +2444525231843962298275031069381314438305678331941237253189959661616931936428403908777740475422459580996785256969423138340880864 +3680179310627154010609137293613898326769365871171324366981855057912989303388559760676270131578093527806064422528032847530674921 +9355461118722504639190973677696806900807813249020915988601326357024391608006515894656601520223498473406143763133984605551760635 +2692839783034034225135191314183486878688437669767719161941937422862653760924569831725084821460846216076710658987697058689127356 +3364076178555288032798058397361297765867389733546080821420688209714329880465424718281983378741966307965647446727248970877582835 +5097154920011309551648620026419749934729546113147672841385317729841476832905993191729886098778334663461209723905553676387326787 +7544038203057755483948118938898802083672133837458011190981229303171157034238018580240354203030584798053880317332961525265980136 +1511152526450600575245224610801100379737911240153008627074626764499468695975779959724757934622234502314480579416277867481722879 +9208761275469748679977983637248710137550354113725122267268928582906191386758550109656015747293931779066403562806751200098816649 +2774371960428126935364571996703554555526862912399267217503390978028481995519553561409174881144281743002477593997449474113614320 +3283118387697337618913008345214573134792212133551845640272542182183565756097005950085429574121104212579366752791246087630740431 +2251626647794796903046417171601708089033102353726791435541243544024082843362831636356376144988414260766152555993385246920667885 +4120430579803988192186052185336786436260523534744839109920724061087523726726856003315563861271636470368332064799342319979701963 +1178460847308168095740461067148790390275190816124283621727277092177096823111400887004927669450338704196432823728793780107282726 +6147466566392578561700534815888328209861843963585876273190658740165656380640111544922854734365367040797352367883442096872576161 +0655254149992445465845820920429897376775083347655359252308973271695549200271712623988532809944592500421544522541040542744651771 +8895306524774577797925949127567789976094837338117657136712633080384090456221881872243825996086082147423517476054977573177854050 +4943011385246149882784947556915542478920754812582717541224558316858308474902436139789610336015128572291595765038163819815572793 +0059519490142292292642467486355644357871443222407272677363258010549846343690410511589487255437861629574221414317395258487976995 +6701428890977392343133134256358135045673673123158832116303929634062094950503008501398110339118434776130231986975400156621462276 +4809112204042804726404274446015570840535663272343219408139885535879522105193162064034829419212674983141334515042809663864776730 +3339872236842534294842100648778519220364381792736266281427277880995347117460315427394400908444602067720779504370559025897150525 +0666515892628240976196163023835072227181720931267205367481763695114784962335391370607825220441784558120081030826294430035145825 +5990171621923618467399400881105334235398291318764791324436841208478784739274728174080402657482105706012062680090302017358495564 +5800215155555227538662802534678916888507797284554941341847639680300462071370712985768701847640442454877861723356457893345549450 +0044372835991682943791367236860846326267985956993372513320157207230356385776345982286545530591945027191940491720657627496371424 +3896431871159669144163572836324937737933585239956934241358540063356296466656555165061326841756648545874963895216091891197215432 +1150436121846416639357239779525130732656046114770001886098939931426129354428928259723637803567803101198938817466591948073654097 +3680333838160206864509221215320873122528703603282455751545397796927467717336094169326962640299653768153008615924472102530867643 +6770050643269265320774249712789524649226429216132578192388680218997460246361157967129125548877818859824163987287642561738796200 +5254046150685030619784205850259746232647288005274167276588953501245671262327906633892459399349248665683674586756619925085832749 +8138659441098017401153449742392984232024716079021347321627336986000612605589176674195767657558188526805373912850372987580206973 +8191739475819996816485468724355025309335206345790673864079265551398839303546015301031614690697079405116794058344817857751170058 +5907733664187032783992586304169841870946162957846844623230375351751398150941213221188521406317499729525031329275753209552972135 +9176007624492506072188440485436086995355405038611315169617103420795642254487038087275622057368505174049950711687063028236514019 +2054382102455304130470152360854926810408620809647732343016107388521668970316223874173994646760209951211428665814705542349614124 +6010507266966547829863386841978029050310064720150129583679215294838434102788460967870976228374996605588773396271433676057289822 +7051841412308687295953020826737760628903413518500966433370038504670238126933304749517485860557144247313921158680957030845329616 +2360033770199629503223807832521648961131842719239878810835014788911969787608442436353630358920568228223028658040834409931217202 +8400997693934004696590555410764211165674028575041130093079293183383749718414250933932351869983505392135593326730456694681893830 +9601966479081797142729057700273038016579775812303462568369987589932810195102540708796028133906200420900692102185183676170434137 +3162497370959471401670744764602103343725945241209609871641803759642428128312023652491828868062451307296471228615569464816843941 +8764436487815154921343571706294950245330020417561336192910050884197950522678946771691143370350696790098631293864395203215663546 +2103973531056753606278933160819590888661208989653023859755262642075600795082475977389553769715231157147229187302967554388198370 +5511263147464601148510010944839861149087736327442223343582633059022202904665113422199247896714934045390179111585670544907398745 +6503691628140930095878935309503466424485388886339832328600458315631288162890181616057639363435222140281269282576385033650710680 +8454254370393439429040009560609022779619788056284224520991161927353411842168395626223590494290282053470410540843450407987926472 +1336825679355920509182270187363852809609898538144457557442453481966013998014732868105005901821373796606751500831791325616529203 +5075118330341336536977717509239821947081842843667207368538939749602952519028901304254002381236022047524790390418089280097834547 +7087002693940685994858725839374363930880942852293359924965925052590869503751762743229260822706873201650092697209849276502693145 +7306083000612674447155484200177291509744727003567573915026132438684216504412932709214471251820240604475149792423248249870477794 +1828750345492089414352178700274996717656637631789061874232476374372589026121784200003799632748786969419729627555600483655428983 +1419038605582900945308948756881180557106644399148478031842482768934058982366460243721966998715761966320233275607842960609086807 +8995674775072395937621113944922442969450956475559169579744736615353848691595206952225921509080923588771792361528472949801095259 +8071164393093218807836177998870397618178243287174730595843254576188688725044187468313573761652235487642008727514328298453902298 +0249472421551084408818726321837167660068433212182140863918498142778473568559604363644028430498972834010437189971676814372359835 +6326215711122626023900879284642848379045342532983675870120785391214889560676166670449442675798343547201651587376372310330260972 +7721128349367234491190961548434288775058240627555576639847795303346657927088312538298685663289068965153779510427872075661840307 +6404054826004851129562529146035965093659305313594131922007840749997852785915480413483418179403471734301385082608331943522033365 +9733723661694274986939415998932370600151791965983225598026282848806043753357041009447678948117256393500635321688798336983220809 +3023589135170563869561312040343087996767334919517638058142422305672311345678035221436322642357974773060658747505711133889241231 +1715152441111565992971519735514891973779991073609482568950260394204089469526267416519043590653468197703445241031998318436540928 +2571161687670398639649025206286059219618343667065497532146361041751088315806996390315937024865023472982359206847895714744923905 +5104856285757044366877940768642231044057490201353054349716001939164041109356173546969025877651803874584635636362767779008126317 +3656921864783698643075571406752016536758441120671704957195627803118074461526120679475816346733176098378409722349965248254591396 +1131443502066788861338718815939549028179403039813213172777877033453234020243883715396074872970863142546452822669185069959899184 +3828769910844736669658151259692028871696603091005326667495981150974845310134146991259645265882236097619326183020932698293809389 +4299190605742357746915386971343055529972124390299804481008342198376182446383261925929177219506772125075974364335839610948010146 +1147666764087177430198110110312435274731031579695008275499991697667495238558041459480531076474591001063866865437151222907417625 +3118583599222787818632900781019308738830040805599161996484071877144944130661026998282751748208682924005109173737574254051272267 +7248376535827628635806240316333585049198937287552863170331727642858039762809709721675292461634836370227092107000659180675306750 +5306506627623780068062337884640840561088552876565604494700675337745509144650468822636638698294453362040534422173031206225551013 +4252579308534696009946359817557643262143167696605231236359117810698816646524895198187607892477097108960784373761400944824549798 +6045449932335488814802338206074710052382801251742328755176048705595171441928353779134497634248965450262069632636038949744898591 +5048702418591439721957110373280102402968469372594873031440576890966279374555142674908990757259647232567240212811527932452059539 +6445116473158402926922663638150560761537491240522157144544441504700466911488897981059188305240921784775901100861995605851341634 +6426302952753103378949324692632848243080208624864503932730319385221633332864218296337728836033257029589381148577572779689079838 +8323351033213327371073881110283228611521471023685177945561596153462821296338506612181495253533007296541471850977144060198153791 +8612240193336900124220751825865213792796718254928148410457543169565765686381156512821242185857562689521331372459681870446271120 +2190046770619246800670427384048126037985607253433475697587520496744179478706647309818755439429545326720329201172200607765064227 +3736184856673482672738889087427014657874110745468152414492168023597661163943017362999706603380493625843592458433287608755926735 +4182865681401614720438201427164757077032257161772988732629306857669039790289782177374506368443513627759379215518499475202046737 +0697566863573366009839193988358046426820897141853585923998497091914817356341676241151406963597520055377063092845547594101697448 +9770510287164808256026738019695567751276805483623280478598925336381177794945569958800804342768914035606587017994256909693642474 +7259755154611086941695255874435534803016372667978524879504844920733928636400671846029963027849546724083520281554956394251995619 +1834558695670914755649864898844629047200426021450454765139131674876570357846943407935142270035129746721137853801869970041785717 +1163596604514706992103337640896730977362836499853948987124318776421720842943109071494096297915872890046802390417171851693498985 +6696873506860390067654571204036998680608912603658516851469732917336706912396900863519518863153116679969409193499475151912748965 +5772630153097284117632752487886616553301227224710840592032831301443809681968538716385350119500103381352429438906070006049324510 +7255320449590155185339594353774382542901912346562333365165993746566717810379624006716063017965110258762932735063223456498216112 +6248309487192090873881009634314790029246770378814629258114526635202683322798948006269443152846896870196478753064865917440440787 +1079237303256511529274839846470858035223497145513826461412560940325017754834231423361883666751693338383865225187216612119160015 +4861549012935871901840283860561328549067295489644918336638431557892707608901138017599623121810750153111482390969696067122547247 +2439131148441383234199376711842415663942174805857098114579871600691759196917341291603802573327405138562282722593414751206457843 +1973359935209045256671529911507316084304214657632392500349841226204006608244837820483129185333807659672251730206136609040933140 +8184943256874541309753395121370721662620513066937352652876771594490437810449353276322830929392380590748672786848276069239565457 +3348707026381104836690412750227080237859968000391150025633563394577801401905026748085615086352851413067595432050498561008571529 +1877075667972855586652155165911443897166143801340467259805712033287524340520335275436517702758812944056177253493418193171478211 +3774854369590560985587771159245595691913575127970445498501177157738494672527414527162836050852813684096791146417973149365483037 +6704552131555310027219368793280881514598163193897955852905718685913917573430057096937340959824715120372466589909944315684960960 +1012314375846207604646749185426484171598374093369935297204972798525329648052886568477644707532784462941904877487489747098535818 +7985674284714583813663198777955800874049562438949351977791559431711873042288148908962573859023348239888106006645129281470473018 +9254850687404139400561382825175974131012329412859199274634520950110017567085977669352012785318630525841745235957179742713982397 +5097303689162257167085390435448404263178199429357071875772715774544733708487138600770119134943129539543347602041901144161660698 +6953181183113203630678272715731094392489433607360104735402092320971396494926265205286840279679199637087859730680473846380532205 +7565033230336604389926974822292700950491849340699150720775179860790531037997637976970549940150909535407513425455328335706561853 +5335368312471755733760541805372968424193070274491865313428788002453279122401760512494622819480016105587606929438634932015824839 +5559016338160351661853688320039654018084969722536423822579994200012801736919709694310831609907486201946501673508356764142877308 +7309191546539260723637253628477957548575327772499530308454034050815650925443083418507106015799454347735223841084017225944595226 +4885590707691548323545253419048477650698836445425272829459034786263150039138385336170173040262385017882023012446601786508537725 +3159300795992899648874466508404624507417341674483549750138299511054547355595935184376005929821246479521411349307469101710751249 +2708412392547375974662585574062716099744667256888486220537125770970468132844596575936704205294434437646542619212125911160088350 +7671842861670510559275736664436986661209239228900436842961873275642777838933287515196746049787877411927981310119576400549956135 +8080578380146388148902757671260230173280743467984486835312292349158474503715607238743382799824745964056080082925917323860644616 +2120225379169780135148292573265658608927358543522142151484031366388491618786494744941370627406622031907792989518445311039563243 +6616422310981362438162790258221845503573731451992162868203601740290116853659138924079987226446597241351646843845278977024986205 +3662517640661488061073964114703410205367685498808240378692251201166863090113025726146269622096930731719426952075506480919216671 +4823643457908716999726557603223790753609939423361772712423018042932577115436095139459068730410826645568806300379584835433450946 +7837676208477360145796134097352072195957133041368812408314333472555459775670645841696822521516557015970698046160780950308863139 +5015658403765286649459660652152764801017680991103667912937430519322186712931073677796456215078436603241360959178629806771058487 +9139921128024002577938454673706047243620589115000240242563021016654786832806633509254081676514023612790990852595917560180876986 +9308821204883025320496874045455981233709125160954382611635568126874562312377547977111739040746530325193651004237373402504537024 +1600821697316131396065115975797494969376263815891380490449703227459763844691726208596151555303610430036532384862800860173068687 +1677749011530966588655330008218462556189908006964342216676682876215290543872066380630113889263010720992320394875173725292986311 +6989579261987669045792589013853182107944124182584456537044269091571439065320682853599165887592383283334586801282099984394392022 +9970108676029913047954776468886108937529661369633484559390003673582932372797656385704195055160295258401674267521236080828952316 +3273802761420937902459164150004835781371893878839475301617292925707508874975102558388990001315786419341804043737604037226331752 +6423865093791333509337877707981916567162340796885934470115945789596479789320653277617641131277451340371426117129794514423620761 +7417609321834214164793102707841568625675868448913528641242723253295495191476269874558175687931888576975179732585669568870748778 +5922089337143793314961512325922930026645734559888635155138481555659443901618808201784727019382947895019140665125084159195324704 +2832300412363246058905063308416630201890917641050411420603351067801736891124820850891397186056454796477918095532199343583413766 +3842538349880871712437577001398701888177344881522702272474861972439339253087204797211344636084653095826769076765966355059432859 +9877839498202302366738674681533509411775934456542381162185787945980551914209016996885507489310451917077029188324180322160260432 +2738878897545393488539641042595991720479279596803533846602159358145022104838297930283221202267258855473584700375502341592186375 +9062102173051107870783580788794675784912283028909776152369743147402812551267763802726764393893702046520930303504745751378996798 +1890158543698671287785156969862722836025364759849336645190863408137034806850238192071351320453303572785270717307117565718365448 +7734822410504169526033583218346170435610106103279145679136488844339942839493180608845290017442034674025577300763459944350044123 +6105040904995754702216898271414142776115817083443246834852579568391309141621714380298793479424942862844759389997283360409266478 +8207744090633188685115276563756960203356370566871533095111186389044186232441179082078908516925531610020829064403059153715127765 +4543411669625489070844963508370766554494552051662899693726257799474616282059274838670819153036396550543481066774790569529843561 +6679799651036598201198464287278166599830430479287605906552407498711145045497296895091710143423667516678729308766311555682391918 +9060618446032966067396024483927774799271013972963401931215359008050857228820472502367068320857075813753280582206475097498167537 +1091834892775689353192772704190529392359261014072163618697328287354942394830079331974933337512857161868992496906607708010073398 +5364177554337994653512816619520240821994073186844625407311661314696382001907220045017648487411581430791143507856735567122196867 +0716761726451434192525856251744493844256079661428358229774069510316066898590543756088198375973992063361152435222465923662351366 +0043075513893517349925411233398957648025096112448548886678072991181902374596438596256297098774636238148028169588473828501924259 +3228516645884143195864667466124866845099402543607000135666586926382976262509368071827459582454935921975303881150829096536404067 +4761157693052962556888050028734514069905365690844215214316263823173976897101122538440327270223709317772895230031391498145736860 +6385041084622772519780334652630409495229736116311103527030831268982936563366735822928512879378203876837625284271193343076105495 +8825229991999801614347782438381474867852878074358430022437396713162807802543161593009219312576950358519990247724194904234397934 +7703801976947027234960802861233790319790676821468496141323682139060568458559647230530529267618724263639883376817372167884440632 +1726382143017323548108870010820096752312836426102452450577004449101845698867822824844060001600494219691513701486376765683162295 +8567344046439933818792026021934172754782928648841755910876641284145941585066904498876784179002951113808421135227067381608911653 +2236981696764483162752804813037353468784452076739585261632267090804876266610444767882886160729217192498345880705115733282372008 +1313046830998564657547840785183730714291004250275503590948256987454019097344722968276149211207582987088443854985798581722550023 +9063006406664758572850022859344148370428972822517076773683529207252067208935050546823673576957790680951020623419459032466629849 +7938928170423206022080881849589066531884975323736816185913375521669990715327020849225286810140422793741838143465182856377816749 +1265756842388175742586708059491362377918488379984875832030848543287918941984050070389106581268802594158962582407355351035627049 +5900221712437059899622129468224343840497771816212975521659975058333318690798732737341876177817630804815720469182652538833483463 +5823081639915099173836211725045578069819187508359785075471465778986260818861591546963352470179514396250583548650281488440780418 +7451048170517299540822354367273854496577812259623792325601325690996083083112151683648900535783537568629739368276233311118065909 +9084734714613092289461178939653038690130944168935857129538400432419569476969252314501208058863985767404598559353985694589773895 +6277214607560240011967714168838143750302367595949536752213657372427124984199709048837186130780108450270594932950252051594320147 +3499572321088417920853211811454866152496225537457554175697449661675274675801653044218258736968600625898775131530277707042339508 +9914225219653958408220404955503421597988800462882509224240059485399789816322467527449242209991095322026817971575335077154317985 +5278081500892846628897442768350495212681297210154604830667333056587120720522354514329460517681155334733974540010110756237411297 +8210591237075811936724693019310304435150990235368637778807792760313222154371335709089813727563208995319466715986861635780866968 +7932415587435911762210037637958044637519791039364219987373646146500303943912999127265553435145017969397164413915816752545161718 +5633226031400350789184112011648210881013020831437183038308240362781644283374155015679893305443987813011631237184023671550613020 +5811978080228290171238069706605813947244025818423549831774560590994763911374360626408512454006214897383037052649605527910939842 +1578662832737601740265954708879993575835470810729170613732770615041114798158887175252200232752097837948350852301754510131346245 +6068409444406865116594371496646576550470605636603063539678037419994055698404550683594340710909264161990867009969259182486360989 +3207255402572128867597708386762297362519921843080894171603067736003753278183424031926979188196805787920726466251458690002582913 +5008569364534625206093594865389861974491057988729642501378201086357626134901180260883065306275795854872408871966970358994916566 +5260870280380960692056382943423819321600456629197713258529958092905135072192290151897612011642141070383635146934909632500071674 +5103943101344555719687493820066438065019249811470335254469779344109290667032018362593087359223818942995619770011635033602760781 +6090182191502983738438010896590866621707943859659299906860770756177151013807688207972939771298998138528654622092955429850905653 +1626336772125369872523005387925612023085181385255260458074393235131647700974860337649978590067937668268507156384372177447503498 +0983088220975640726485831380650348574527016263360984693517646111104451963030529155545125362875373684368744288268392996464031787 +1886577864886560438915496753180364296870396016073972814584707172757602216484353054194841318491639088652070784986581587056423963 +5791295955798452846006486957884980659241458306340044696019455166134558465794056766142717707049752847050948964499027310212291201 +3920118159051788842792018209898781792646763214510193250573669914454162275192491103856842226701566784572791940951044194717542411 +5568425247114245514540844570366702834465456557122445652286286614869534230920871827766118797945440453053831301603663599611151007 +9132285049335898106348530191639824752961756612096827245060794650887002292087021431444313048295402370831165699527783501924024187 +9094264576555332744996979181892440388769625070877328456545115444598432716233979462060670021904359658071557042696819752714761359 +2624335032983933790947468174067700780434730280286305837296068262033116687738482347338258135450536831314508366201724139587815922 +8450751384747855334597310320588125802084226440657572189418133991724784364158225409421748567123411489197359560319327166452150553 +0217315146965805878176534045386582646736519057669936823885725039838691917663928104666774688631639185290691596050519297245051431 +7940957013433199012061114563562278128253591876081307949974283942244584406336676182042124767131849195077146222822951756668914757 +6589005956437167623060683298552386150740712051896264556502825752701728084586373026820140301271827258402697782005508526864025995 +3287288894211530920495178421618385358928209601522908652144815977173646436635300032777312309529559530424309089857544514218168330 +6097483328468004536631471410495796391660358670051698715076410248502303660016161800128810231929174703618080502422800241933644130 +2956392224013095847029227680428083425620941588942686433369479814315411693725173853101111802188051631515982053459377355277916857 +3065681935968907368748287973480293783213808382487086015879418794067438804225330554229750223350574245985145312570124344685276455 +3489772935059313564818602631010215526615299221297140830316899208960430528821219213991899112889288129943720176337014173173174332 +4169981630658215328566362976636435099613640630157506404256612156966851420692144492745499377619802506248375541742742014068421649 +3723697831339666759125999969874386488250045997138226100381868783065151573396084764792101954730971063666073382268822664370648202 +7695739092394145422409597895972497681500338948172798211529024633083754418602669479252615594701113082363308526566375385313538692 +0362024243582700927996091721261779876357892824920462321831613846936511858949877169168914710103805138231321626700946199996026230 +0910370398336603134902288593437904852970471827636244578441003561376156126397047213862430430449454667576391124197185148345471598 +5028346423876572027639326365391106837855425740087158529449602646500698308039624506892347711322718143846562617911464289132024496 +9181010776426759091535139982513243227866023899159123168014651495554175929065144279128447458894513674919834462361991122972799428 +6472902683846165829490192503189706567753176937559527683694767361120216602239730653948099377610225798683453077405631209096231256 +0512986051426035486790488833906991553793296020140460296126591780195814787329857676072922129878562425136025882880600984983973989 +8577540121631192413042201337007929873227061283325668352988181356692287167551269236062168964313569524237889901244379824573640154 +5738145734013901847027973765976787682776812683421111101939034836663608749968365412229382487929512185391212964474327857768911300 +7562207836356806317921677823535902895646261255973726228824124734902468677105214682457780953879753523764199156291556619449942205 +6685144408630396033374384521831023348395708816803320958823787110609396335187767019703187308157675845831700883961350733812554544 +7576609828782901349340272529157644117188745883108516505970478068227119245704450471362770646680973620118556831550370068906691429 +7387998131808587529731801781598911046784196725282943998624870759033897379214694560999940160160935915403688360574784745832951209 +6248576464881189569842693329569180599977760906738941622134746107827192298531798906163755685774369390363347404463590563452485459 +0534570888244129725519284614466994594106901806409139995601464274045789187815608635654309801136434736637205014712781222746921224 +7852721958335248170761829133326246797700730414740667697834509581576475365734827900004460335634027879413672459976734498386195835 +5088370360545200433735093090688791665393907039059272593032100436084501418577206986549399579720624028466951070544585214365207165 +6435187129368614449937580538296933531792687165143536181239511296901417188887649499928950174527974591005214327286330726199831884 +5864261175041853165789209708620714822361777843032399821785843235985913827357647540975103877312914819841724359018056154229990484 +1936832320986190570216413377747783409617074645446275675504398782817281167330026961325947267465552277788937638823143961712338389 +6643014994016028760819796829700070956205113377466899907953033114796754643995517690305975245695734383895488045495784881027449542 +9277149772110266765516542199009389979979428729803481968242094114554310414335680714665255584623073310801300516821617747378223514 +5122582985363185134103472499467534154970594419472963412571152321765481331992341844237099548533622925469977982035402603376599366 +5702039170472823969912601643296899307773750835106819267275831078282467998094066465029472821615682366477091470622470049719032042 +0671010358945492991105729283517652015315441687350701252921272273957729883415005085140318681745681298665587818639399209287652478 +8504952151973256765543113775190946452315557877268395630007206112950274261280515123602637574614066439170518948486082023049534264 +8318785147359309244073883391968368385030412213804815219561275632927036049996919071912768810313118985299449822580618372563128123 +5447965794084022881336224721150430474622954063445132529997642171980649882452452874371660709010271333178089011623650142945593513 +7498570392070031176556263724838104407401975655807188803601068318852915004571680712468602581133705435004279673319305506280782318 +4235251770160613000830130983063100984485301111420207302571915861863284245935054969687285090784775829404258632032504825073887582 +6407248272722201582954889873840796724288126199508498948167917317499903480984445960848498060154084891463403285778107348687889003 +4953941330396268815099409977237615027521463257528034758197037642240947224961515275989640733601052280398818164960445717239008728 +4426630124553142687273205330644281511721380282097626819427510520776002629092574526215543555846304555626987349130475830717662512 +2679622415503744585776560549326024439456730222065789254179516934309405880579097989297964155354764447981652276792153719461894070 +6549452078295195952851972101892868752466073329081552637836554870868329745518970415001754631788228704301414087107528862687179382 +3095714010946058367115405111675588241660359378724218257897889232511664785827286570897205547229279697287663245465265895194075831 +9805465298621739062011152177896594580714703932025865262409510756369094551491315344002976208292437754134178483455044310999687172 +5635853083465443752399385809613532628000929554168679920157180193163062291041706935484519604033746044464716659982230583915172977 +1397085494342438160066950214161726216316797535747161972858218528442291370670389809452231490128596440810108729216233152926963393 +8718938957831579949398261083744948669476176529513240710990560722588644755296402086806852345746538236347718030640062631744819555 +9204989031916871283227517942830744003831314993547893753197955379403077174291901637842637655437310798500528596483721526174221178 +4510621681082500438705444746385938892179962383128718253236867948364044872547102979732643922151263657382171953178711857903512864 +3434625913079139632847162412927858083774910063803492872036606235419074389757800463882617655159555904544646003283714069095719127 +9422478480758793975004764634088848124200701219293815383644557399151474644429876593122326476162568364525117348282565684006439054 +6415412788931044743766779624337137193856769272687596658353208728053926044570228051289974744446738511898266628888688489033821326 +3857187055764486798882511807937125159502970249818799519647825055901143034107396715341111836431533491237288074873324479254847609 +1944275217447109672414805304798039892872048551668309961639053276921203694927946551682999672834794575568139407200344761188832584 +9228691574818073805866351085919567356330517627511140717776424135867621344167516969731782408297076690641510925488519425339786231 +2831239904815704920016412032913992948413502229392159186483640311971384616648328934218616172408437024641339341534952850417631408 +7800709599423404547224077175920136421077429331304204846667623312748910375272177983791546978316206296185604509872479031731294077 +6784795879386865023891006814459422181459242147354385223330262696056730516247499993593952360113613078289229711721789291466201911 +1558378948527819137236700414103122090944390583763494240148255786716027072401897565958932034145583789267171948650451004479200278 +5903365269957297061267790413012843976619330012086443873201405355132327717135407147467813950090532723390786355726062359803253439 +7629287528827946090011668159293077488731123501345393936384022425933097863996545653037874008416991412735073016080615679561676815 +3237960418959875052085168366152912866396485668534444686608623522780325138572281373258421046475238324527598957994900036953588632 +9883457218912143598750744649289916045155230666253998012127292069605955397882251577278616463161982956480851083203582599294132885 +8739605725967415654345383552272209454198363876790394143551885453633595477692847087747048445889713841117432214889427740276964122 +1808274594398149686259653460592417452536265711085053636183889817336547379067581749366999937190487929782077243956107305394452893 +2858306534503555758138192142342374976569912519114070071304001216131565171144485590883323767986065555672710513575942087665489357 +4757258115582473299797872077008431880804766429204591994348523186470015406253571125582684142251809933836340635261386229168816736 +9918555292750664784762306372865895993392873092492120139178044227677315162874458415577767229742354738329991177067335396671747156 +9915416169565774505455198608946138326580556663002878103141442158950284935423931276623631554768708518659417736110868144091121408 +7485024844800932215930566743200643612646843426043824587026297306446562930746643938917961270550045568670866510426684185886721448 +4920398501344484751530060228048138752162844188260697740262204586350188489261031255952257367650241279996726021255197979400713310 +0983903945365766675649828378701431579004857069167244696371192650313930100887222144395396003002837274898192175630515559492616368 +3277569441388072350944394279081011821982637576381780324461779633187405677617459795408379063310477462661505822241372624056397980 +2796195339856562934096874382820282192099707799004934067504550995736513197478848274092619553245513516215920528915358178045259427 +3947135872153511247151284668940911981933985156149720562664695031030349744372110088157223178406720212021960705751648342245477823 +8276198303392861443910819050105767637970397653898744484200995946877348235373325786715347188697829025445506211703973576651655150 +5882576032689008918318143363475006909501115410116941599853261283394744451901101910507633092078494500214632287815925595536310673 +7269241743888980922214944937348603959760552838607959592411748713582006971089673926445144319837129979120595791416170081356544964 +3311215693514569183444297282757452024106434743342415838798070572517431245405339373780763180400593713529558089381582197573125752 +4556878108283717136754864320383151773421100605854818531410424407658443836201366417280243912680383714161438889747985913112617159 +3825283938152818066103999819485641639048153915591788440799327104545750772861261496085802570014233362502408220258846139854490942 +3543037705426699624325696485612282411023745859388735341967646420985563945181345313960301854453402790876180716518598169356488497 +0055015399759018591540911328290609447855851641187622864276870240973176403939507548117764594583218172186919643238977138111158956 +2302146157347717928300258596580246250649908644352652697865369736710811431250945078622499892640698932203651495464626034751579299 +0465216581077322245370388400939469195489616593652097640401043603078806904801413336072374703228412879808024013691780444525050754 +9151727760868811886689437563229171390965138504950138407176506255752456724326383897323049258585289255126700265024238726662681731 +0098281899254404044904741984338800905867702052389334861534065540083641450439874866038625038945827791603161398328731872690722059 +6264530562489216043969280034408943083142765136686187837798682491792210809601751533837187815038112873969767271421029102693650921 +7670518311894906730059859298650685509520663627502700465860614043829130684092155123515969024766529965326820247830045239762876384 +1971827918374425559499103800305418434180845901819771222995898394549615763182780848478726307902754377493105414864115497763562067 +7293146824231836764324358936471102982745003549454252992884038807314576844595566006507289403671236553892547396334547842381936455 +3707012658412106034610065750021436552038057251146149724375405389299956024255098042568008242870114719254029045709055991603654930 +4543749521242879802728408392725236169206369176046813175364511678612424177154836269263324760122983569594445005273913013269664551 +5817700093174352547416009939112502133121085536020612539401905269863944981266637678387919942591042471679114800424206674615903746 +9928390417067700668674925186060124842260894166668581468768675095262594932684909013159566891337437296287921942274275342136808279 +1720526807320641693668140417766107453595978158154018754776221360462162393984770342801365549647871062173743896063916005240392253 +5161802386530577435326894842370519298812054283209695964545050386222673476579184628919106024296128426895608065795872894836272477 +9269809290510364760281346041981538977140734635535715877861564862122154561230471413453427434440292536928348809500100637413855174 +0657501300841813074935854851050163894991818276164751987873048063138250805404584707419292446697964047248725308217946641983844311 +8063478785147013188508380911686106501438761736788881545360437305874844044022285005421389985126661063912349587081288388003345466 +5080385912620164034274035663131591931589292314684519240800453976434478145811035864455399019210261903984106215732682395895799522 +0939020059406813121907073513079575778716665344964094359764782266431575550874973231091097656538411338304404129653958312868999842 +6732798933518323978985303323091966916070134400750942228988862433672654847071015762525448860254590537863809085645618465872667306 +0427846766351683194895724811056690695837239230026578986973494357639196637007765612283664140977141629336513743191474504552821790 +3228155682944358310924291228796943417467684350283874136741330013804595358442242749651649995689037646356343539795964269040555905 +6826145487746532059740843858150338835296508366342272235981293613561407683050389559856243442342524690245207486156018191382164551 +1327436225221742602074234993619036983345996345216008664910823535986496447271949044534929738194453356131648251656209560053354614 +0407290886807276555505472513777566509192309345071661761386510676177956004136233159240180697853305064135526857625954524710679122 +1431829687708285619275876929673787963838663779016128696006658789855078135858492072768308764926825429711165034052613724177837083 +7028553048202580189681827868563421125284289066186493489485470631057243002992982744971998313406439308961352814738730662842546474 +1661580089658576037549874036611720164076275368701553799369961428692585978010787204558502174932891500734632543309652429899761996 +9575856899639421670892327891209797029282817824375074240277705275435359082312316792956844954585652271368228646822716619012170165 +4690146795978834583378953218274128128954879679834962721495470431115747652300230454490265247933455376976025418712883919785265770 +4032584676449148273007032590154174755542691092611500872882432669889260868344191769763590664159630537010368972815582431630162563 +5692592732110530293190433213941741940871216528267789341138499704212959459631375151781937020467215223500973204249438057106028338 +1541214818072382006149334712979978351719934230083959861254175062060206728245934867359880240685020444293227864055618527079589472 +1439159705776204064690488345048299759772753492079024651663143703086754589449249599931908249754660757813918172727140178033198709 +7752381183500066741893133463291861429042158260704598873907314527361438231014952758222297919601552459311683576335125432073345960 +4158788096315630807867178963280856579732177587633674289101034755608242832707107748491269005626588055241208204418618388578035469 +1184416032139115028602210049000593619116279959516862765906011705138739437332038056873961010636018153261556031158803924660448426 +9834587809319862013631879808865489908412831755556199315250744409755028410760389172898604230817719091796600511778684843691064279 +7878372956127669698977302339079670592653146391325443980293253311254734925614678750486528888944734310378404782150993544089766813 +4482271911480681906845899905802627519765113355182171607609262740960268207890619067150293516596923655844247586174848972864721468 +9552003526630991149245651109495761934587784128507108647124483752936558263106644305431230364441437558819641682185001628863763328 +9406159315820904843204929487522677107941937076263988953382649335050929875295580457118791755887589396355358703932935557257606830 +2969493527901243167542109903168828628101917337300403325039813279857934939104326409957807201457446262732489661524241158979368142 +1833967145487476098973136162241392322964264292952490319901422154921305200229075272133864200487657774340560812039475075659326308 +1445298822625141627089594319278576573094647719202883678449230305616300998398218250958603519589651710614887336894157702428315107 +8911019753589361230572967964751571906635823516517521975275494263948066958905939807605210390275340148405377313480598158489558111 +3183749609096747980513864052412964607501407465024842349303716927046134047076464086834827581454812880653390898896534483223922702 +2047220404370553586495348686661844320582343653984119122227275984849504305399708851775077220602618170548438073982557547603633042 +5484875538490583169391720574953649919139069950121342298729189319935008363006908499817188567294646844902804708973781249800855552 +7421001424990409022663446235185073936721530809635245828159482916215742480785440259606637437758227633658889520747280770098045723 +6510075506635860479703887783619213078585799368504850589990946726994909109916359460180863720392604659818835051505356439580781411 +0959165291367850253561235537386721365762207442766902579631829064237987397582522884081947056330594794737026301952693630585102680 +6267281924773054128920399667616892395906931391070201721710734680164804934661829697133693962106573047827000567454860592220102084 +6351225785373403775734572811446819619019190839393144125015360556285521375890386016901082233720031340998488590003458019399286006 +8086983669350678861956334882898616321436714400384547300867927315159417274826609618496301870293049853960758679069277021904136960 +9865037759852510085988938641077600576537641357106366728530348981390205491195956901092388717027996104357442748303975082427786786 +7507248774842522159480897459767378325396763974897420116495369220388118224704985677597657612836164641593242643705906198310715923 +6020323897854469493762019753971728667497338537420217765895884555350482562903234559598367966289598307357713584270039680501758042 +2970682482901424731104641663111768757582340710358846705532647449734646971482108058532929343635001949578504462729212526976463810 +8406644630764947233594179128313043631264609165757699872474368034583055609364865453910940072958562666156078109884350362008700655 +9106501316131398908994689175684333822574784889714347654697727209736986308940910431037486363365667132654371414795819563310659169 +0137910472839714679161637852622472509459014895991142745425159229935069751019575455036034662579025492228994125955644298201357138 +2263663590472781654218931217059804728469684174302359039764853349702219977113201315914188584584955078222068657185984247622363558 +5695450824338155861977114741562006985207639935376048162114526556989656274727076392276059583216303897816482298413238883403403632 +0038975862485843345228895776545691226502347548540923009663654944132545600827380276828701039586345737400863528654887451057233197 +1285772332269416234665537910079978608222632602148452508934499816027147308767944385913555512454637610386856292966968437445496548 +1261330191618765210009782014085845073559775965093415001665110717532374517158996315004359428915981278340620344383170562473911188 +0755483943667647640579099438554263999127548734337936583257964438443463208543269429173892355146856191237124938489437234962714824 +9129303544439064208938552091032859116474732583566245269345387009587018850752964356086348467165770868170114265169858965115946288 +7279622065007376862875602615836848329672073134886504804366938182665036461895999032293214820132094992897811456738921945565996030 +4834236494451378286976564913106384851412866607459667235230175488097172277734513000370973157558689076209485032473704000163914074 +2906852713508769108670361019771730001144071549164484831831379004788411810506441972725735257048988599402331202363984166872400551 +4374843284474261559922201408952633150671870157517305411040726961843624607898601648184347808307024923212656070285299487288795732 +8117441033938778257340076295628604371272466046790715921004843853378457388333862596453687093388500288301007959254642621709441228 +8336419205482595246714478040728678515920231077940527413442313540990859460129785367310524821300597125039005330560255760446207185 +3407569957745240672748410048085824476146107644741791845367520753456514888607145322239479922742610070735465164422006326154369011 +8894279996606564122245246476739025836636961740221798143384506169709797876615015522415620193119156094455114077417058486277270353 +7131151035004395224877087554662361771017971918239145723682405673667071436258453271309611849685373102636336093172827546720740657 +8432145665345782054212385521456100690288045272048653500410117161030682916822394178179943934653293870095835416016828701651397729 +9807379993673315841883406823522043062628694861759093682354411179777001696451399181533177926653740164108712792568617753057780749 +7552198060883514609633356358462724322863739238474217533806217264897669042731651388657558396154686026363774639912794923252267503 +6291771443785740732590982981719905524567339994411151615939323485160260431350712239547320702908777027534814334898810771281406391 +8383725943909858701756050979518960102350055348726092344362770497395426060226252186716626586574811491995835598427931237638307288 +8507265667315900242180544608612147833573934012185340789193936346356941286917069481442515796977733286907179390046007293777378415 +8688298391307343027481331662068268845813946664921272848764804887244314914603468930763919183778517730411504413547554154855526591 +5310568546507610904043747230819248926074837842921381365456929822505503792963441504203788828448597610860322974517666735027993699 +8190512204618058514563016675739391233696406975567198996502543146118326981238682542313301537034074950744994938638623004424018628 +5962797353210542352910227068452267455627736914233254078275501019026029219977380762852165264848013890176220808626487330453830607 +1392715231741123546207682784414187261145744424815836598165304144212321073536110482416294352751979189695534837507189501132643925 +9547196873348778230662094351866444409683500705986806451682346762409749401895555972393170493498341109191510645940668680160665767 +9096955810744288162025152776265225979561511052982298941267330985571152782374720461772752985049704669084322641186449467889515212 +4360617959299125510229120098324080014685874269740158186892010379118371918256414709312045505595343772662619039003425826619680875 +8242651081630156918805572079983037638369031262141838260427869758050055377235638965872717517504788429694521145838583513263909672 +4433259455372438105974775408627724880736064277338137893108385178827104479149305047828800826485922049778207824411348676510055718 +8718825984885049258859271868511156347573558547616835487996237695354831720772501296121171500663173314753159506044722718279173640 +2709996430110563394535123371054969016136174141380219513450493806426805948941155396288218826477132071568170532718023856256400877 +4412955918580719390710872526700485018418160226844433869987075876676044792011973789419662798626013873183203506118837233134120481 +8772819562426148199715932002776622117594716096791960417797687467419822085071157480539482033047913473604918965910085487367720357 +4625085282706988812822930138218466374524023159847349699030998731244290316248877616127354994943514784160430249591960166158827428 +3012297335233487487686932791672504848939891571342804916267615897166810277253170819233520663757428230248104405100538854660927429 +9123919446207336590235297840044149569787830675448852079217813254125078565940555357151112153929694801251132171203795549941163920 +7476175369012980559938118310990110840174599144325883878065361105628152837782089093135806082805172562067617245231771061838879589 +4768469919871257284902195592516344833223851928691778696654759047583702848545509080899254152913598427216007302226235522358460750 +5223927757227044947866784478462919350895723643402842384138354740120256079056226884847266693352002580953694527348195695223607106 +4705073558122375415417200921965563405533347843275197814453910296613637292816403322858277400213988846375567124674868467361795016 +4745728385156852832029629080429064757351207656991841817680115495315482039644479548944488439788311653187692817074819840714497361 +5386314847182104599263810424039609228765878994123179215715094367283327303020988006589792974721368333841513658700314945433634456 +3685020221252259142980926069027074077129168059113331677771782227727933843623094566219277157186574916058687802285827552124321505 +0794558617931775588320039074320252238014802597836590634824227249703483529574186006183975509386000848443692647358501225142361167 +3942679708028160995866607265771564423203677879968679929985370044267348240320617033379072586756373490054605230219409903866795469 +7536599276764983130315949383875187945686502994166320326189211280377933687730984141460802381512939077916932152569652666724046409 +0292377825630966235158683241512971091944539929600065707699283877623772501033680549048220288927590692487589517712276010516389098 +4141777627623117777410741182897322646935774432337593489702909715834793849902052358894916963594941828827118210427424755222982593 +0263099400776234259640984881940007947968250580544744304077736076557953616095573458814306253535718606350692981623255928091096507 +0588327094996262431505059042095661828596107333578122924612340170790916991622052806671333685104366780235136494027277232872825498 +1523246308282008538061408160202517775966824053244715248653671495274650673682535042749033828795099010214859776685551489176975506 +5811209762314534687747281829159103097186141033482266881873367741901377849867980657673782571505747169485443159028925476795003998 +963436785863456565690613348237130676523955561372248056220702510606833697646989872355666869136182759934340379879840576201228LAST diff --git a/external_imported/cpp-httplib/test/www/dir/meson.build b/external_imported/cpp-httplib/test/www/dir/meson.build index 8339b6361..e88ec79fb 100644 --- a/external_imported/cpp-httplib/test/www/dir/meson.build +++ b/external_imported/cpp-httplib/test/www/dir/meson.build @@ -5,3 +5,4 @@ configure_file(input: 'index.html', output: 'index.html', copy: true) configure_file(input: 'test.abcde', output: 'test.abcde', copy: true) configure_file(input: 'test.html', output: 'test.html', copy: true) +configure_file(input: '1MB.txt', output: '1MB.txt', copy: true) diff --git a/external_imported/json/.circleci/config.yml b/external_imported/json/.circleci/config.yml deleted file mode 100644 index 82e509840..000000000 --- a/external_imported/json/.circleci/config.yml +++ /dev/null @@ -1,56 +0,0 @@ -version: 2 -jobs: - build_stable: - docker: - - image: debian:stretch - - steps: - - checkout - - - run: - name: Install required tools - command: 'apt-get update && apt-get install -y gcc g++ git cmake' - - run: - name: Run CMake - command: 'mkdir build ; cd build ; cmake .. -DJSON_BuildTests=On' - - run: - name: Compile - command: 'cmake --build build' - - run: - name: Execute test suite - command: 'cd build ; ctest --output-on-failure -j 2' - - build_bleeding_edge: - docker: - - image: archlinux - - steps: - - checkout - - - run: - name: Install required tools - command: 'pacman -Sy --noconfirm base base-devel gcc git cmake' - - run: - name: Run CMake - command: 'mkdir build ; cd build ; cmake .. -DJSON_BuildTests=On' - - run: - name: Compile - command: 'cmake --build build' - - run: - name: Execute test suite - command: 'cd build ; ctest --output-on-failure -j 2' - -workflows: - version: 2 - build_and_test_all: - jobs: - - build_stable: - filters: - branches: - ignore: - gh-pages - - build_bleeding_edge: - filters: - branches: - ignore: - gh-pages diff --git a/external_imported/json/.cirrus.yml b/external_imported/json/.cirrus.yml new file mode 100644 index 000000000..be6331506 --- /dev/null +++ b/external_imported/json/.cirrus.yml @@ -0,0 +1,17 @@ +arm_container: + image: gcc:latest + +check_task: + check_script: + - wget https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2.tar.gz + - tar xfz cmake-3.20.2.tar.gz + - cd cmake-3.20.2 + - ./configure + - make cmake ctest -j4 + - cd .. + - mkdir build + - cd build + - ../cmake-3.20.2/bin/cmake .. -DJSON_FastTests=ON + - make -j4 + - cd tests + - ../../cmake-3.20.2/bin/ctest -j4 diff --git a/external_imported/json/.clang-tidy b/external_imported/json/.clang-tidy index 046d84f87..339360b08 100644 --- a/external_imported/json/.clang-tidy +++ b/external_imported/json/.clang-tidy @@ -1,23 +1,65 @@ Checks: '*, + -altera-id-dependent-backward-branch, + -altera-struct-pack-align, + -altera-unroll-loops, + -android-cloexec-fopen, + -bugprone-easily-swappable-parameters, + -cert-err58-cpp, + -concurrency-mt-unsafe, + -cppcoreguidelines-avoid-const-or-ref-data-members, + -cppcoreguidelines-avoid-do-while, -cppcoreguidelines-avoid-goto, -cppcoreguidelines-avoid-magic-numbers, + -cppcoreguidelines-avoid-non-const-global-variables, -cppcoreguidelines-macro-usage, + -cppcoreguidelines-pro-bounds-array-to-pointer-decay, + -cppcoreguidelines-pro-bounds-constant-array-index, + -cppcoreguidelines-pro-bounds-pointer-arithmetic, + -cppcoreguidelines-pro-type-reinterpret-cast, + -cppcoreguidelines-pro-type-union-access, + -cppcoreguidelines-rvalue-reference-param-not-moved, + -cppcoreguidelines-virtual-class-destructor, -fuchsia-default-arguments-calls, -fuchsia-default-arguments-declarations, -fuchsia-overloaded-operator, -google-explicit-constructor, + -google-readability-function-size, + -google-runtime-int, -google-runtime-references, -hicpp-avoid-goto, -hicpp-explicit-conversions, + -hicpp-function-size, -hicpp-no-array-decay, + -hicpp-no-assembler, + -hicpp-signed-bitwise, -hicpp-uppercase-literal-suffix, -llvm-header-guard, -llvm-include-order, + -llvmlibc-*, + -misc-use-anonymous-namespace, + -misc-confusable-identifiers, + -misc-include-cleaner, + -misc-no-recursion, -misc-non-private-member-variables-in-classes, + -modernize-concat-nested-namespaces, + -modernize-type-traits, + -modernize-use-constraints, + -modernize-use-nodiscard, -modernize-use-trailing-return-type, + -performance-enum-size, + -readability-function-cognitive-complexity, + -readability-function-size, + -readability-identifier-length, -readability-magic-numbers, + -readability-redundant-access-specifiers, + -readability-simplify-boolean-expr, -readability-uppercase-literal-suffix' CheckOptions: - key: hicpp-special-member-functions.AllowSoleDefaultDtor value: 1 + +WarningsAsErrors: '*' + +#HeaderFilterRegex: '.*nlohmann.*' +HeaderFilterRegex: '.*hpp$' diff --git a/external_imported/json/.github/CODEOWNERS b/external_imported/json/.github/CODEOWNERS index 4d5ee0440..e1e1040fc 100644 --- a/external_imported/json/.github/CODEOWNERS +++ b/external_imported/json/.github/CODEOWNERS @@ -1,5 +1,5 @@ -# JSON for Modern C++ has been originally written by Niels Lohmann. -# Since 2013 over 140 contributors have helped to improve the library. +# JSON for Modern C++ was originally written by Niels Lohmann. +# Since 2013, over 250 contributors have helped to improve the library. # This CODEOWNERS file is only to make sure that @nlohmann is requested # for a code review in case of a pull request. diff --git a/external_imported/json/CODE_OF_CONDUCT.md b/external_imported/json/.github/CODE_OF_CONDUCT.md similarity index 100% rename from external_imported/json/CODE_OF_CONDUCT.md rename to external_imported/json/.github/CODE_OF_CONDUCT.md diff --git a/external_imported/json/.github/CONTRIBUTING.md b/external_imported/json/.github/CONTRIBUTING.md index 7f12d5070..4d33c67bf 100644 --- a/external_imported/json/.github/CONTRIBUTING.md +++ b/external_imported/json/.github/CONTRIBUTING.md @@ -22,17 +22,17 @@ Clearly describe the issue: - If you propose a change or addition, try to give an **example** how the improved code could look like or how to use it. - If you found a compilation error, please tell us which **compiler** (version and operating system) you used and paste the (relevant part of) the error messages to the ticket. -Please stick to the provided issue templates ([bug report](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE/Bug_report.md), [feature request](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE/Feature_request.md), or [question](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE/question.md)) if possible. +Please stick to the provided issue template ([bug report](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE/bug.yml) if possible. For questions, feature or support requests, please [open a discussion](https://github.com/nlohmann/json/discussions/new). ## Files to change -:exclamation: Before you make any changes, note the single-header file [`single_include/nlohmann/json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp) is **generated** from the source files in the [`include/nlohmann` directory](https://github.com/nlohmann/json/tree/develop/include/nlohmann). Please **do not** edit file `single_include/nlohmann/json.hpp` directly, but change the `include/nlohmann` sources and regenerate file `single_include/nlohmann/json.hpp` by executing `make amalgamate`. +:exclamation: Before you make any changes, note the single-header files [`single_include/nlohmann/json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp) and [`single_include/nlohmann/json_fwd.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json_fwd.hpp) are **generated** from the source files in the [`include/nlohmann` directory](https://github.com/nlohmann/json/tree/develop/include/nlohmann). Please **do not** edit the files `single_include/nlohmann/json.hpp` and `single_include/nlohmann/json_fwd.hpp` directly, but change the `include/nlohmann` sources and regenerate the files by executing `make amalgamate`. To make changes, you need to edit the following files: -1. [`include/nlohmann/*`](https://github.com/nlohmann/json/tree/develop/include/nlohmann) - These files are the sources of the library. Before testing or creating a pull request, execute `make amalgamate` to regenerate `single_include/nlohmann/json.hpp`. +1. [`include/nlohmann/*`](https://github.com/nlohmann/json/tree/develop/include/nlohmann) - These files are the sources of the library. Before testing or creating a pull request, execute `make amalgamate` to regenerate `single_include/nlohmann/json.hpp` and `single_include/nlohmann/json_fwd.hpp`. -2. [`test/src/unit-*.cpp`](https://github.com/nlohmann/json/tree/develop/test/src) - These files contain the [doctest](https://github.com/onqtam/doctest) unit tests which currently cover [100 %](https://coveralls.io/github/nlohmann/json) of the library's code. +2. [`tests/src/unit-*.cpp`](https://github.com/nlohmann/json/tree/develop/tests/src) - These files contain the [doctest](https://github.com/onqtam/doctest) unit tests which currently cover [100 %](https://coveralls.io/github/nlohmann/json) of the library's code. Before creating a pull request, execute `make pretty` to make sure that the style is correct, as this will be checked by the CI. If you add or change a feature, please also add a unit test to this file. The unit tests can be compiled and executed with @@ -55,10 +55,10 @@ To make changes, you need to edit the following files: ## Please don't - The C++11 support varies between different **compilers** and versions. Please note the [list of supported compilers](https://github.com/nlohmann/json/blob/master/README.md#supported-compilers). Some compilers like GCC 4.7 (and earlier), Clang 3.3 (and earlier), or Microsoft Visual Studio 13.0 and earlier are known not to work due to missing or incomplete C++11 support. Please refrain from proposing changes that work around these compiler's limitations with `#ifdef`s or other means. -- Specifically, I am aware of compilation problems with **Microsoft Visual Studio** (there even is an [issue label](https://github.com/nlohmann/json/issues?utf8=✓&q=label%3A%22visual+studio%22+) for these kind of bugs). I understand that even in 2016, complete C++11 support isn't there yet. But please also understand that I do not want to drop features or uglify the code just to make Microsoft's sub-standard compiler happy. The past has shown that there are ways to express the functionality such that the code compiles with the most recent MSVC - unfortunately, this is not the main objective of the project. +- Specifically, I am aware of compilation problems with **Microsoft Visual Studio** (there even is an [issue label](https://github.com/nlohmann/json/issues?utf8=✓&q=label%3A%22visual+studio%22+) for this kind of bug). I understand that even in 2016, complete C++11 support isn't there yet. But please also understand that I do not want to drop features or uglify the code just to make Microsoft's sub-standard compiler happy. The past has shown that there are ways to express the functionality such that the code compiles with the most recent MSVC - unfortunately, this is not the main objective of the project. - Please refrain from proposing changes that would **break [JSON](https://json.org) conformance**. If you propose a conformant extension of JSON to be supported by the library, please motivate this extension. - We shall not extend the library to **support comments**. There is quite some [controversy](https://www.reddit.com/r/programming/comments/4v6chu/why_json_doesnt_support_comments_douglas_crockford/) around this topic, and there were quite some [issues](https://github.com/nlohmann/json/issues/376) on this. We believe that JSON is fine without comments. - - We do not preserve the **insertion order of object elements**. The [JSON standard](https://tools.ietf.org/html/rfc7159.html) defines objects as "an unordered collection of zero or more name/value pairs". To this end, this library does not preserve insertion order of name/value pairs. (In fact, keys will be traversed in alphabetical order as `std::map` with `std::less` is used by default.) Note this behavior conforms to the standard, and we shall not change it to any other order. If you do want to preserve the insertion order, you can specialize the object type with containers like [`tsl::ordered_map`](https://github.com/Tessil/ordered-map) or [`nlohmann::fifo_map`](https://github.com/nlohmann/fifo_map). + - We do not preserve the **insertion order of object elements**. The [JSON standard](https://tools.ietf.org/html/rfc8259.html) defines objects as "an unordered collection of zero or more name/value pairs". To this end, this library does not preserve insertion order of name/value pairs. (In fact, keys will be traversed in alphabetical order as `std::map` with `std::less` is used by default.) Note this behavior conforms to the standard, and we shall not change it to any other order. If you do want to preserve the insertion order, you can specialize the object type with containers like [`tsl::ordered_map`](https://github.com/Tessil/ordered-map) or [`nlohmann::fifo_map`](https://github.com/nlohmann/fifo_map). - Please do not open pull requests that address **multiple issues**. diff --git a/external_imported/json/.github/ISSUE_TEMPLATE/Bug_report.md b/external_imported/json/.github/ISSUE_TEMPLATE/Bug_report.md deleted file mode 100644 index 6dfa7d2d8..000000000 --- a/external_imported/json/.github/ISSUE_TEMPLATE/Bug_report.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: 'kind: bug' -assignees: '' - ---- - - - -#### What is the issue you have? - - - - -#### Please describe the steps to reproduce the issue. - - - - -1. -2. -3. - -#### Can you provide a small but working code example? - - - -#### What is the expected behavior? - - - -#### And what is the actual behavior instead? - - - -#### Which compiler and operating system are you using? - - - - -- Compiler: ___ -- Operating system: ___ - -#### Which version of the library did you use? - - - -- [ ] latest release version 3.9.1 -- [ ] other release - please state the version: ___ -- [ ] the `develop` branch - -#### If you experience a compilation error: can you [compile and run the unit tests](https://github.com/nlohmann/json#execute-unit-tests)? - -- [ ] yes -- [ ] no - please copy/paste the error message below diff --git a/external_imported/json/.github/ISSUE_TEMPLATE/bug.yaml b/external_imported/json/.github/ISSUE_TEMPLATE/bug.yaml new file mode 100644 index 000000000..f7acdf18b --- /dev/null +++ b/external_imported/json/.github/ISSUE_TEMPLATE/bug.yaml @@ -0,0 +1,93 @@ +name: Bug Report +description: Create a bug report +labels: + - 'kind: bug' +body: + - type: markdown + attributes: + value: > + Thanks for taking the time to fill out this bug report! + + Make sure you give it a short and specific **title** so that the report + is searchable and uniquely identifiable. + + Note that this form is for bug reports only. Please + [open a discussion](https://github.com/nlohmann/json/discussions/new) + for questions, feature requests, or support requests + - type: textarea + id: summary + attributes: + label: Description + description: > + Please provide an abstract description of the issue to the developers, + and why you consider it to be a bug. Please include any specific links + to the documentation, JSON specification, or code. + validations: + required: true + - type: textarea + id: reproduce + attributes: + label: Reproduction steps + description: > + How do you trigger the bug? Please walk us through step by step. Be as + specific as possible. + validations: + required: true + - type: textarea + id: results + attributes: + label: Expected vs. actual results + description: > + Please describe what you expected to happen after the steps above and + what actually happened. + validations: + required: true + - type: textarea + id: code + attributes: + label: Minimal code example + description: > + If possible, provide a small and self-contained example that triggers + the bug. Please understand that we cannot analyze and debug large code + bases. Please do not paste screenshots here. + render: Shell + - type: textarea + id: output + attributes: + label: Error messages + description: > + Please provide any kind of error output (compilation errors, exception + messages, stack traces, etc.) which can help to diagnose the error. + render: Shell + - type: input + id: compiler + attributes: + label: Compiler and operating system + description: > + On which operating systems and compilers have you observed the issue? + Include as many relevant details about the environment you experienced + the bug in. Make sure you use a + [supported compiler](https://github.com/nlohmann/json#supported-compilers). + validations: + required: true + - type: input + id: version + attributes: + label: Library version + description: > + Which version of the library did you use? If it is a released version, + please enter the version number (e.g., 3.11.3). Otherwise, please enter + the commit hash. If you got the library from another source as the + GitHub repository (e.g., via a package manager), please also state + this. + validations: + required: true + - type: checkboxes + id: validation + attributes: + label: Validation + description: > + Please check these additional steps: + options: + - label: The bug also occurs if the latest version from the [`develop`](https://github.com/nlohmann/json/tree/develop) branch is used. + - label: I can successfully [compile and run the unit tests](https://github.com/nlohmann/json#execute-unit-tests). diff --git a/external_imported/json/.github/PULL_REQUEST_TEMPLATE.md b/external_imported/json/.github/PULL_REQUEST_TEMPLATE.md index 5f303a6e0..c9c7cb793 100644 --- a/external_imported/json/.github/PULL_REQUEST_TEMPLATE.md +++ b/external_imported/json/.github/PULL_REQUEST_TEMPLATE.md @@ -9,11 +9,11 @@ Read the [Contribution Guidelines](https://github.com/nlohmann/json/blob/develop - [ ] Changes are described in the pull request, or an [existing issue is referenced](https://github.com/nlohmann/json/issues). - [ ] The test suite [compiles and runs](https://github.com/nlohmann/json/blob/develop/README.md#execute-unit-tests) without error. - [ ] [Code coverage](https://coveralls.io/github/nlohmann/json) is 100%. Test cases can be added by editing the [test suite](https://github.com/nlohmann/json/tree/develop/test/src). -- [ ] The source code is amalgamated; that is, after making changes to the sources in the `include/nlohmann` directory, run `make amalgamate` to create the single-header file `single_include/nlohmann/json.hpp`. The whole process is described [here](https://github.com/nlohmann/json/blob/develop/.github/CONTRIBUTING.md#files-to-change). +- [ ] The source code is amalgamated; that is, after making changes to the sources in the `include/nlohmann` directory, run `make amalgamate` to create the single-header files `single_include/nlohmann/json.hpp` and `single_include/nlohmann/json_fwd.hpp`. The whole process is described [here](https://github.com/nlohmann/json/blob/develop/.github/CONTRIBUTING.md#files-to-change). ## Please don't - The C++11 support varies between different **compilers** and versions. Please note the [list of supported compilers](https://github.com/nlohmann/json/blob/master/README.md#supported-compilers). Some compilers like GCC 4.7 (and earlier), Clang 3.3 (and earlier), or Microsoft Visual Studio 13.0 and earlier are known not to work due to missing or incomplete C++11 support. Please refrain from proposing changes that work around these compiler's limitations with `#ifdef`s or other means. -- Specifically, I am aware of compilation problems with **Microsoft Visual Studio** (there even is an [issue label](https://github.com/nlohmann/json/issues?utf8=✓&q=label%3A%22visual+studio%22+) for these kind of bugs). I understand that even in 2016, complete C++11 support isn't there yet. But please also understand that I do not want to drop features or uglify the code just to make Microsoft's sub-standard compiler happy. The past has shown that there are ways to express the functionality such that the code compiles with the most recent MSVC - unfortunately, this is not the main objective of the project. +- Specifically, I am aware of compilation problems with **Microsoft Visual Studio** (there even is an [issue label](https://github.com/nlohmann/json/issues?utf8=✓&q=label%3A%22visual+studio%22+) for this kind of bug). I understand that even in 2016, complete C++11 support isn't there yet. But please also understand that I do not want to drop features or uglify the code just to make Microsoft's sub-standard compiler happy. The past has shown that there are ways to express the functionality such that the code compiles with the most recent MSVC - unfortunately, this is not the main objective of the project. - Please refrain from proposing changes that would **break [JSON](https://json.org) conformance**. If you propose a conformant extension of JSON to be supported by the library, please motivate this extension. - Please do not open pull requests that address **multiple issues**. diff --git a/external_imported/json/.github/external_ci/appveyor.yml b/external_imported/json/.github/external_ci/appveyor.yml new file mode 100644 index 000000000..126ed99b3 --- /dev/null +++ b/external_imported/json/.github/external_ci/appveyor.yml @@ -0,0 +1,91 @@ +version: '{build}' + +# only build PRs and commits to develop branch +# (see https://help.appveyor.com/discussions/questions/55079-two-builds-per-commit-to-pull-request) +branches: + only: + - develop + +only_commits: + files: + - .github/external_ci/appveyor.yml + - cmake/ + - include/ + - tests/ + - CMakeLists.txt + +environment: + matrix: + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Debug + platform: x86 + CXX_FLAGS: "/W4 /WX" + CMAKE_OPTIONS: "" + GENERATOR: Visual Studio 14 2015 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Release + platform: x86 + CXX_FLAGS: "/W4 /WX" + CMAKE_OPTIONS: "" + GENERATOR: Visual Studio 14 2015 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Release + platform: x86 + name: with_win_header + CXX_FLAGS: "/W4 /WX" + CMAKE_OPTIONS: "" + GENERATOR: Visual Studio 14 2015 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + configuration: Release + platform: x86 + CXX_FLAGS: "/permissive- /std:c++latest /utf-8 /W4 /WX" + CMAKE_OPTIONS: "" + GENERATOR: Visual Studio 15 2017 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + configuration: Release + platform: x86 + CXX_FLAGS: "/W4 /WX" + CMAKE_OPTIONS: "-DJSON_ImplicitConversions=OFF" + GENERATOR: Visual Studio 16 2019 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Release + platform: x64 + CXX_FLAGS: "/W4 /WX" + CMAKE_OPTIONS: "" + GENERATOR: Visual Studio 14 2015 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + configuration: Release + platform: x64 + CXX_FLAGS: "/permissive- /std:c++latest /Zc:__cplusplus /utf-8 /W4 /WX" + CMAKE_OPTIONS: "" + GENERATOR: Visual Studio 15 2017 + +init: + - cmake --version + - msbuild /version + +install: + - if "%platform%"=="x86" set GENERATOR_PLATFORM=Win32 + +before_build: + # for with_win_header build, inject the inclusion of Windows.h to the single-header library + - ps: if ($env:name -Eq "with_win_header") { $header_path = "single_include\nlohmann\json.hpp" } + - ps: if ($env:name -Eq "with_win_header") { "#include `n" + (Get-Content $header_path | Out-String) | Set-Content $header_path } + - cmake . -G "%GENERATOR%" -A "%GENERATOR_PLATFORM%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" -DJSON_BuildTests=On "%CMAKE_OPTIONS%" + +build_script: + - cmake --build . --config "%configuration%" --parallel 2 + +test_script: + - if "%configuration%"=="Release" ctest -C "%configuration%" --parallel 2 --output-on-failure + # On Debug builds, skip test-unicode_all + # as it is extremely slow to run and cause + # occasional timeouts on AppVeyor. + # More info: https://github.com/nlohmann/json/pull/1570 + - if "%configuration%"=="Debug" ctest --exclude-regex "test-unicode" -C "%configuration%" --parallel 2 --output-on-failure diff --git a/external_imported/json/.github/labeler.yml b/external_imported/json/.github/labeler.yml new file mode 100644 index 000000000..024d3e6da --- /dev/null +++ b/external_imported/json/.github/labeler.yml @@ -0,0 +1,38 @@ +version: 1 + +labels: +- label: "documentation" + files: + - "README.md" + +- label: "documentation" + files: + - "docs/.*" + +- label: "tests" + files: + - "tests/.*" + +- label: "CMake" + files: + - ".*CMakeLists.txt" + +- label: "CMake" + files: + - "cmake/.*" + +- label: "CI" + files: + - "github/workflows/.*" + +- label: "CI" + files: + - "github/external_ci/.*" + +- label: "S" + size-below: 10 +- label: "M" + size-above: 9 + size-below: 100 +- label: "L" + size-above: 100 diff --git a/external_imported/json/.github/workflows/check_amalgamation.yml b/external_imported/json/.github/workflows/check_amalgamation.yml new file mode 100644 index 000000000..0fadb5206 --- /dev/null +++ b/external_imported/json/.github/workflows/check_amalgamation.yml @@ -0,0 +1,70 @@ +name: "Check amalgamation" + +on: + pull_request: + +permissions: read-all + +jobs: + save: + runs-on: ubuntu-latest + steps: + - name: Save PR number + run: | + mkdir -p ./pr + echo ${{ github.event.number }} > ./pr/number + echo ${{ github.event.pull_request.user.login }} > ./pr/author + - uses: actions/upload-artifact@v2 + with: + name: pr + path: pr/ + + check: + runs-on: ubuntu-latest + env: + MAIN_DIR: ${{ github.workspace }}/main + INCLUDE_DIR: ${{ github.workspace }}/main/single_include/nlohmann + TOOL_DIR: ${{ github.workspace }}/tools/tools/amalgamate + ASTYLE_FLAGS: > + --style=allman --indent=spaces=4 --indent-modifiers --indent-switches --indent-preproc-block + --indent-preproc-define --indent-col1-comments --pad-oper --pad-header --align-pointer=type + --align-reference=type --add-brackets --convert-tabs --close-templates --lineend=linux --preserve-date + --formatted + + steps: + - name: Checkout pull request + uses: actions/checkout@v3 + with: + path: main + ref: ${{ github.event.pull_request.head.sha }} + + - name: Checkout tools + uses: actions/checkout@v3 + with: + path: tools + ref: develop + + - name: Install astyle + run: | + sudo apt-get update + sudo apt-get install astyle + + - name: Check amalgamation + run: | + cd $MAIN_DIR + + rm -fr $INCLUDE_DIR/json.hpp~ $INCLUDE_DIR/json_fwd.hpp~ + cp $INCLUDE_DIR/json.hpp $INCLUDE_DIR/json.hpp~ + cp $INCLUDE_DIR/json_fwd.hpp $INCLUDE_DIR/json_fwd.hpp~ + + python3 $TOOL_DIR/amalgamate.py -c $TOOL_DIR/config_json.json -s . + python3 $TOOL_DIR/amalgamate.py -c $TOOL_DIR/config_json_fwd.json -s . + echo "Format (1)" + astyle $ASTYLE_FLAGS --suffix=none --quiet $INCLUDE_DIR/json.hpp $INCLUDE_DIR/json_fwd.hpp + + diff $INCLUDE_DIR/json.hpp~ $INCLUDE_DIR/json.hpp + diff $INCLUDE_DIR/json_fwd.hpp~ $INCLUDE_DIR/json_fwd.hpp + + astyle $ASTYLE_FLAGS $(find docs/examples include tests -type f \( -name '*.hpp' -o -name '*.cpp' -o -name '*.cu' \) -not -path 'tests/thirdparty/*' -not -path 'tests/abi/include/nlohmann/*' | sort) + echo Check + find $MAIN_DIR -name '*.orig' -exec false {} \+ diff --git a/external_imported/json/.github/workflows/cifuzz.yml b/external_imported/json/.github/workflows/cifuzz.yml new file mode 100644 index 000000000..0fd355bce --- /dev/null +++ b/external_imported/json/.github/workflows/cifuzz.yml @@ -0,0 +1,30 @@ +name: CIFuzz +on: [pull_request] + +permissions: + contents: read + +jobs: + Fuzzing: + runs-on: ubuntu-latest + steps: + - name: Build Fuzzers + id: build + uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master + with: + oss-fuzz-project-name: 'json' + dry-run: false + language: c++ + - name: Run Fuzzers + uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master + with: + oss-fuzz-project-name: 'json' + fuzz-seconds: 300 + dry-run: false + language: c++ + - name: Upload Crash + uses: actions/upload-artifact@v3 + if: failure() && steps.build.outcome == 'success' + with: + name: artifacts + path: ./out/artifacts diff --git a/external_imported/json/.github/workflows/codeql-analysis.yml b/external_imported/json/.github/workflows/codeql-analysis.yml index 5ee44a04e..93923a182 100644 --- a/external_imported/json/.github/workflows/codeql-analysis.yml +++ b/external_imported/json/.github/workflows/codeql-analysis.yml @@ -2,53 +2,43 @@ name: "Code scanning - action" on: push: - branches: [develop, ] + branches: + - develop + - master + - release/* pull_request: - # The branches below must be a subset of the branches above - branches: [develop] schedule: - cron: '0 19 * * 1' + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} + cancel-in-progress: true jobs: CodeQL-Build: runs-on: ubuntu-latest + permissions: + security-events: write steps: - name: Checkout repository - uses: actions/checkout@v2 - with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 - - # If this run was triggered by a pull request event, then checkout - # the head of the pull request instead of the merge commit. - - run: git checkout HEAD^2 - if: ${{ github.event_name == 'pull_request' }} + uses: actions/checkout@v3 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - # Override language selection by uncommenting this and choosing your languages - # with: - # languages: go, javascript, csharp, python, cpp, java + uses: github/codeql-action/init@v2 + with: + languages: c-cpp # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - # â„¹ï¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # âœï¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release + uses: github/codeql-action/autobuild@v2 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v2 diff --git a/external_imported/json/.github/workflows/comment_check_amalgamation.yml b/external_imported/json/.github/workflows/comment_check_amalgamation.yml new file mode 100644 index 000000000..2ab5ebb97 --- /dev/null +++ b/external_imported/json/.github/workflows/comment_check_amalgamation.yml @@ -0,0 +1,75 @@ +name: Comment Check Amalgamation +on: + workflow_run: + workflows: ["Check amalgamation"] + types: + - completed + +permissions: {} + +jobs: + comment: + if: ${{ github.event.workflow_run.conclusion == 'failure' }} + runs-on: ubuntu-latest + permissions: + contents: read + actions: read + issues: read + pull-requests: write + steps: + - name: 'Download artifact' + uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6.4.0 + with: + script: | + var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{github.event.workflow_run.id }}, + }); + var matchArtifact = artifacts.data.artifacts.filter((artifact) => { + return artifact.name == "pr" + })[0]; + var download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + var fs = require('fs'); + fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data)); + - run: unzip pr.zip + + - name: 'Comment on PR' + uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6.4.0 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + var fs = require('fs'); + const author = fs.readFileSync('./author') + const issue_number = Number(fs.readFileSync('./number')); + const opts = github.rest.issues.listForRepo.endpoint.merge({ + owner: context.repo.owner, + repo: context.repo.repo, + creator: author, + state: 'all' + }) + let first = true + const issues = await github.paginate(opts) + for (const issue of issues) { + if (issue.number === issue_number) { + continue + } + if (issue.pull_request) { + first = false + break + } + } + await github.rest.issues.createComment({ + issue_number: issue_number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '## 🔴 Amalgamation check failed! 🔴\nThe source code has not been amalgamated.' + + (first ? ' @' + author + ' Please read and follow the [Contribution Guidelines]' + + '(https://github.com/nlohmann/json/blob/develop/.github/CONTRIBUTING.md#files-to-change).' + : '') + }) diff --git a/external_imported/json/.github/workflows/labeler.yml b/external_imported/json/.github/workflows/labeler.yml new file mode 100644 index 000000000..11925e1af --- /dev/null +++ b/external_imported/json/.github/workflows/labeler.yml @@ -0,0 +1,20 @@ +name: "Pull Request Labeler" + +on: + pull_request_target: + types: [opened, synchronize] + +permissions: {} + +jobs: + label: + permissions: + contents: read + pull-requests: write + + runs-on: ubuntu-latest + + steps: + - uses: srvaroa/labeler@master + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/external_imported/json/.github/workflows/macos.yml b/external_imported/json/.github/workflows/macos.yml index 5b178ad05..9ac1fe3fa 100644 --- a/external_imported/json/.github/workflows/macos.yml +++ b/external_imported/json/.github/workflows/macos.yml @@ -1,17 +1,67 @@ name: macOS -on: [push, pull_request] +on: + push: + branches: + - develop + - master + - release/* + pull_request: + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} + cancel-in-progress: true jobs: - build: + xcode_1: + runs-on: macos-11 + strategy: + matrix: + xcode: ['11.7', '12.4', '12.5.1', '13.0'] + env: + DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + + steps: + - uses: actions/checkout@v3 + - name: Run CMake + run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON + - name: Build + run: cmake --build build --parallel 10 + - name: Test + run: cd build ; ctest -j 10 --output-on-failure + + xcode_2: + runs-on: macos-12 + strategy: + matrix: + xcode: ['13.1', '13.2.1', '13.3.1', '13.4.1', '14.0', '14.0.1', '14.1'] + env: + DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + + steps: + - uses: actions/checkout@v3 + - name: Run CMake + run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON + - name: Build + run: cmake --build build --parallel 10 + - name: Test + run: cd build ; ctest -j 10 --output-on-failure + xcode_standards: runs-on: macos-latest + strategy: + matrix: + standard: [11, 14, 17, 20, 23] steps: - - uses: actions/checkout@v1 - - name: cmake - run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On - - name: build - run: cmake --build build --parallel 10 - - name: test - run: cd build ; ctest -j 10 --output-on-failure + - uses: actions/checkout@v3 + - name: Run CMake + run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_TestStandards=${{ matrix.standard }} + - name: Build + run: cmake --build build --parallel 10 + - name: Test + run: cd build ; ctest -j 10 --output-on-failure diff --git a/external_imported/json/.github/workflows/publish_documentation.yml b/external_imported/json/.github/workflows/publish_documentation.yml new file mode 100644 index 000000000..5a32d13a4 --- /dev/null +++ b/external_imported/json/.github/workflows/publish_documentation.yml @@ -0,0 +1,41 @@ +name: Publish documentation + +# publish the documentation on every merge to develop branch +on: + push: + branches: + - develop + paths: + - docs/mkdocs/** + - docs/examples/** + workflow_dispatch: + +permissions: + contents: read + +# we don't want to have concurrent jobs, and we don't want to cancel running jobs to avoid broken publications +concurrency: + group: documentation + cancel-in-progress: false + +jobs: + publish_documentation: + if: github.repository == 'nlohmann/json' + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + + - name: Install and update PlantUML + run: sudo apt-get update ; sudo apt-get install -y plantuml + + - name: Install virtual environment + run: make install_venv -C docs/mkdocs + + - name: Build documentation + run: make build -C docs/mkdocs + + - name: Deploy documentation + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs/mkdocs/site diff --git a/external_imported/json/.github/workflows/ubuntu.yml b/external_imported/json/.github/workflows/ubuntu.yml index d6b654077..35fb9573c 100644 --- a/external_imported/json/.github/workflows/ubuntu.yml +++ b/external_imported/json/.github/workflows/ubuntu.yml @@ -1,64 +1,248 @@ name: Ubuntu -on: [push, pull_request] +on: + push: + branches: + - develop + - master + - release/* + pull_request: + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} + cancel-in-progress: true jobs: - gcc_build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - name: install_gcc - run: | - sudo apt update - sudo apt install gcc-10 g++-10 - shell: bash - - name: cmake - run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On - env: - CC: gcc-10 - CXX: g++-10 - - name: build - run: cmake --build build --parallel 10 - - name: test - run: cd build ; ctest -j 10 --output-on-failure - - clang_build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - name: install_gcc - run: | - sudo apt update - sudo apt install clang-10 - shell: bash - - name: cmake - run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On - env: - CC: clang-10 - CXX: clang++-10 - - name: build - run: cmake --build build --parallel 10 - - name: test - run: cd build ; ctest -j 10 --output-on-failure - - clang_build_cxx20: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - name: install_gcc - run: | - sudo apt update - sudo apt install clang-10 - shell: bash - - name: cmake - run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=ON - env: - CC: clang-10 - CXX: clang++-10 - - name: build - run: cmake --build build --parallel 10 - - name: test - run: cd build ; ctest -j 10 --output-on-failure + ci_test_clang: + runs-on: ubuntu-latest + container: silkeh/clang:dev + steps: + - name: Install git and unzip + run: apt-get update ; apt-get install -y git unzip + - uses: actions/checkout@v3 + - name: Get latest CMake and ninja + uses: lukka/get-cmake@v3.27.7 + - name: Run CMake + run: cmake -S . -B build -DJSON_CI=On + - name: Build + run: cmake --build build --target ci_test_clang + + ci_test_gcc: + runs-on: ubuntu-latest + container: ghcr.io/nlohmann/json-ci:v2.4.0 + steps: + - uses: actions/checkout@v3 + - name: Run CMake + run: cmake -S . -B build -DJSON_CI=On + - name: Build + run: cmake --build build --target ci_test_gcc + + ci_static_analysis: + runs-on: ubuntu-latest + container: ghcr.io/nlohmann/json-ci:v2.4.0 + strategy: + matrix: + target: [ci_cppcheck, ci_test_valgrind, ci_test_amalgamation, ci_test_single_header, ci_single_binaries, ci_infer] + steps: + - uses: actions/checkout@v3 + - name: Run CMake + run: cmake -S . -B build -DJSON_CI=On + - name: Build + run: cmake --build build --target ${{ matrix.target }} + + ci_static_analysis_ubuntu: + runs-on: ubuntu-latest + strategy: + matrix: + target: [ci_cpplint, ci_reproducible_tests, ci_non_git_tests, ci_offline_testdata] + steps: + - uses: actions/checkout@v3 + - name: Get latest CMake and ninja + uses: lukka/get-cmake@v3.27.7 + - name: Run CMake + run: cmake -S . -B build -DJSON_CI=On + - name: Build + run: cmake --build build --target ${{ matrix.target }} + + ci_static_analysis_clang: + runs-on: ubuntu-latest + container: silkeh/clang:dev + strategy: + matrix: + target: [ci_clang_tidy, ci_test_clang_sanitizer, ci_clang_analyze] + steps: + - name: Install git, clang-tools, and unzip + run: apt-get update ; apt-get install -y git clang-tools unzip + - uses: actions/checkout@v3 + - name: Get latest CMake and ninja + uses: lukka/get-cmake@v3.27.7 + - name: Run CMake + run: cmake -S . -B build -DJSON_CI=On + - name: Build + run: cmake --build build --target ${{ matrix.target }} + + ci_cmake_options: + runs-on: ubuntu-latest + container: ubuntu:focal + strategy: + matrix: + target: [ci_cmake_flags, ci_test_diagnostics, ci_test_noexceptions, ci_test_noimplicitconversions, ci_test_legacycomparison, ci_test_noglobaludls] + steps: + - name: Install build-essential + run: apt-get update ; apt-get install -y build-essential unzip wget git + - uses: actions/checkout@v3 + - name: Get latest CMake and ninja + uses: lukka/get-cmake@v3.27.7 + - name: Run CMake + run: cmake -S . -B build -DJSON_CI=On + - name: Build + run: cmake --build build --target ${{ matrix.target }} + + ci_test_coverage: + runs-on: ubuntu-latest + container: ghcr.io/nlohmann/json-ci:v2.4.0 + permissions: + contents: read + checks: write + steps: + - uses: actions/checkout@v3 + - name: Run CMake + run: cmake -S . -B build -DJSON_CI=On + - name: Build + run: cmake --build build --target ci_test_coverage + - name: Archive coverage report + uses: actions/upload-artifact@v3 + with: + name: code-coverage-report + path: ${{ github.workspace }}/build/html + - name: Publish report to Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: ${{ github.workspace }}/build/json.info.filtered.noexcept + + ci_test_compilers_gcc: + runs-on: ubuntu-latest + strategy: + matrix: + compiler: ['4', '5', '6', '7', '8', '9', '10', '11', '12', 'latest'] + container: gcc:${{ matrix.compiler }} + steps: + - uses: actions/checkout@v3 + - name: Get latest CMake and ninja + uses: lukka/get-cmake@v3.27.7 + - name: Run CMake + run: cmake -S . -B build -DJSON_CI=On + - name: Build + run: cmake --build build --target ci_test_compiler_default + + ci_test_compilers_clang: + runs-on: ubuntu-latest + strategy: + matrix: + compiler: ['3.5', '3.6', '3.7', '3.8', '3.9', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15-bullseye', 'latest'] + container: silkeh/clang:${{ matrix.compiler }} + steps: + - name: Install unzip and git + run: apt-get update ; apt-get install -y unzip git + - uses: actions/checkout@v3 + - name: Get latest CMake and ninja + uses: lukka/get-cmake@v3.27.7 + - name: Set env FORCE_STDCPPFS_FLAG for clang 7 / 8 / 9 / 10 + run: echo "JSON_FORCED_GLOBAL_COMPILE_OPTIONS=-DJSON_HAS_FILESYSTEM=0;-DJSON_HAS_EXPERIMENTAL_FILESYSTEM=0" >> "$GITHUB_ENV" + if: ${{ matrix.compiler == '7' || matrix.compiler == '8' || matrix.compiler == '9' || matrix.compiler == '10' }} + - name: Run CMake + run: cmake -S . -B build -DJSON_CI=On + - name: Build + run: cmake --build build --target ci_test_compiler_default + + ci_test_compilers: + runs-on: ubuntu-latest + container: ghcr.io/nlohmann/json-ci:v2.4.0 + strategy: + matrix: + compiler: [g++-4.8] + steps: + - uses: actions/checkout@v3 + - name: Run CMake + run: cmake -S . -B build -DJSON_CI=On + - name: Build + run: cmake --build build --target ci_test_compiler_${{ matrix.compiler }} + + ci_test_standards_gcc: + runs-on: ubuntu-latest + container: ghcr.io/nlohmann/json-ci:v2.4.0 + strategy: + matrix: + standard: [11, 14, 17, 20, 23] + steps: + - uses: actions/checkout@v3 + - name: Run CMake + run: cmake -S . -B build -DJSON_CI=On + - name: Build + run: cmake --build build --target ci_test_gcc_cxx${{ matrix.standard }} + + ci_test_standards_clang: + runs-on: ubuntu-latest + container: silkeh/clang:latest + strategy: + matrix: + standard: [11, 14, 17, 20, 23] + steps: + - name: Install git and unzip + run: apt-get update ; apt-get install -y git unzip + - uses: actions/checkout@v3 + - name: Get latest CMake and ninja + uses: lukka/get-cmake@v3.27.7 + - name: Run CMake + run: cmake -S . -B build -DJSON_CI=On + - name: Build + run: cmake --build build --target ci_test_clang_cxx${{ matrix.standard }} + + ci_cuda_example: + runs-on: ubuntu-latest + container: ghcr.io/nlohmann/json-ci:v2.4.0 + steps: + - uses: actions/checkout@v3 + - name: Run CMake + run: cmake -S . -B build -DJSON_CI=On + - name: Build + run: cmake --build build --target ci_cuda_example + + ci_icpc: + runs-on: ubuntu-latest + container: ghcr.io/nlohmann/json-ci:v2.2.0 + steps: + - uses: actions/checkout@v2 + - name: Run CMake + run: cmake -S . -B build -DJSON_CI=On + - name: Build + run: | + . /opt/intel/oneapi/setvars.sh + cmake --build build --target ci_icpc + + ci_reuse_compliance: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + - name: Install REUSE tool + run: python -m pip install reuse + - name: Run REUSE lint + run: reuse lint + + ci_test_documentation: + runs-on: ubuntu-latest + strategy: + matrix: + target: [ci_test_examples, ci_test_api_documentation] + steps: + - uses: actions/checkout@v3 + - name: Run CMake + run: cmake -S . -B build -DJSON_CI=On + - name: Build + run: cmake --build build --target ${{ matrix.target }} diff --git a/external_imported/json/.github/workflows/windows.yml b/external_imported/json/.github/workflows/windows.yml index 1778c9418..7ddd4be25 100644 --- a/external_imported/json/.github/workflows/windows.yml +++ b/external_imported/json/.github/workflows/windows.yml @@ -1,54 +1,134 @@ name: Windows -on: [push, pull_request] +on: + push: + branches: + - develop + - master + - release/* + pull_request: + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} + cancel-in-progress: true jobs: + mingw: + runs-on: windows-2019 + strategy: + matrix: + architecture: [x64, x86] + + steps: + - uses: actions/checkout@v3 + - name: Set up MinGW + uses: egor-tensin/setup-mingw@v2 + with: + platform: ${{ matrix.architecture }} + version: 12.2.0 # https://github.com/egor-tensin/setup-mingw/issues/14 + - name: Run CMake + run: cmake -S . -B build -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On + - name: Build + run: cmake --build build --parallel 10 + - name: Test + run: cd build ; ctest -j 10 -C Debug --output-on-failure + msvc2019: - runs-on: windows-latest + runs-on: windows-2019 + strategy: + matrix: + build_type: [Debug, Release] + architecture: [Win32, x64] steps: - - uses: actions/checkout@v1 - - name: cmake - run: cmake -S . -B build -G "Visual Studio 16 2019" -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On - - name: build - run: cmake --build build --parallel 10 - - name: test - run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure + - uses: actions/checkout@v3 + - name: Run CMake + run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/W4 /WX" + if: matrix.build_type == 'Release' + - name: Run CMake + run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DJSON_FastTests=ON -DCMAKE_CXX_FLAGS="/W4 /WX" + if: matrix.build_type == 'Debug' + - name: Build + run: cmake --build build --config ${{ matrix.build_type }} --parallel 10 + - name: Test + run: cd build ; ctest -j 10 -C ${{ matrix.build_type }} --output-on-failure - clang10: - runs-on: windows-latest + msvc2019_latest: + runs-on: windows-2019 steps: - - uses: actions/checkout@v1 - - name: install Clang - run: curl -fsSL -o LLVM10.exe https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/LLVM-10.0.0-win64.exe ; 7z x LLVM10.exe -y -o"C:/Program Files/LLVM" - - name: cmake - run: cmake -S . -B build -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang++.exe" -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On - - name: build - run: cmake --build build --parallel 10 - - name: test - run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure + - uses: actions/checkout@v3 + - name: Run CMake + run: cmake -S . -B build -G "Visual Studio 16 2019" -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /W4 /WX" + - name: Build + run: cmake --build build --config Release --parallel 10 + - name: Test + run: cd build ; ctest -j 10 -C Release --output-on-failure - clang-cl-10-x64: - runs-on: windows-latest + msvc2022: + runs-on: windows-2022 + strategy: + matrix: + build_type: [Debug, Release] + architecture: [Win32, x64] steps: - - uses: actions/checkout@v1 - - name: cmake - run: cmake -S . -B build -G "Visual Studio 16 2019" -A x64 -T ClangCL -DJSON_BuildTests=On - - name: build - run: cmake --build build --config Debug --parallel 10 - - name: test + - uses: actions/checkout@v3 + - name: Run CMake + run: cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/W4 /WX" + if: matrix.build_type == 'Release' + - name: Run CMake + run: cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DJSON_FastTests=ON -DCMAKE_CXX_FLAGS="/W4 /WX" + if: matrix.build_type == 'Debug' + - name: Build + run: cmake --build build --config ${{ matrix.build_type }} --parallel 10 + - name: Test + run: cd build ; ctest -j 10 -C ${{ matrix.build_type }} --output-on-failure + + msvc2022_latest: + runs-on: windows-2022 + + steps: + - uses: actions/checkout@v3 + - name: Run CMake + run: cmake -S . -B build -G "Visual Studio 17 2022" -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /W4 /WX" + - name: Build + run: cmake --build build --config Release --parallel 10 + - name: Test + run: cd build ; ctest -j 10 -C Release --output-on-failure + + clang: + runs-on: windows-2019 + strategy: + matrix: + version: [11, 12, 13, 14, 15] + + steps: + - uses: actions/checkout@v3 + - name: Install Clang + run: curl -fsSL -o LLVM${{ matrix.version }}.exe https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ matrix.version }}.0.0/LLVM-${{ matrix.version }}.0.0-win64.exe ; 7z x LLVM${{ matrix.version }}.exe -y -o"C:/Program Files/LLVM" + - name: Run CMake + run: cmake -S . -B build -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang++.exe" -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On + - name: Build + run: cmake --build build --parallel 10 + - name: Test run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure - clang-cl-10-x86: - runs-on: windows-latest + clang-cl-11: + runs-on: windows-2019 + strategy: + matrix: + architecture: [Win32, x64] steps: - - uses: actions/checkout@v1 - - name: cmake - run: cmake -S . -B build -G "Visual Studio 16 2019" -A Win32 -T ClangCL -DJSON_BuildTests=On - - name: build + - uses: actions/checkout@v3 + - name: Run CMake + run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -T ClangCL -DJSON_BuildTests=On + - name: Build run: cmake --build build --config Debug --parallel 10 - - name: test + - name: Test run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure diff --git a/external_imported/json/.gitignore b/external_imported/json/.gitignore index bf938c8ea..bfd52b4c6 100644 --- a/external_imported/json/.gitignore +++ b/external_imported/json/.gitignore @@ -1,36 +1,44 @@ -json_unit -json_benchmarks -json_benchmarks_simple -fuzz-testing - *.dSYM *.o *.gcno *.gcda - -build -build_coverage -clang_analyze_build - -doc/xml -doc/html -me.nlohmann.json.docset - -benchmarks/files/numbers/*.json +.DS_Store .wsjcpp-logs/* .wsjcpp/* -.idea +/.idea /cmake-build-* -test/test-* -/.vs - -doc/mkdocs/venv/ -doc/mkdocs/docs/images -doc/mkdocs/docs/examples -doc/mkdocs/site -doc/mkdocs/docs/__pycache__/ -doc/xml -/doc/docset/nlohmann_json.docset/ +# Visual Studio / Visual Studio Code +/.vs/ +/.vscode/ +/out/ + +# clangd cache +/.cache/ + +# build directories (vscode-cmake-tools, user-defined, ...) +/build*/ + +# fuzzers +/tests/corpus_* +/tests/parse_*_fuzzer + +# documentation +/docs/docset/docSet.dsidx +/docs/docset/JSON_for_Modern_C++.docset/ +/docs/docset/JSON_for_Modern_C++.tgz +/docs/mkdocs/docs/__pycache__/ +/docs/mkdocs/docs/examples/ +/docs/mkdocs/docs/images/json.gif +/docs/mkdocs/site/ +/docs/mkdocs/venv/ + +# serve_header +/localhost.pem +/localhost-key.pem +/serve_header.yml + +# Swift Package Manager build directory +/.build \ No newline at end of file diff --git a/external_imported/json/.lgtm.yml b/external_imported/json/.lgtm.yml new file mode 100644 index 000000000..b62f9fb37 --- /dev/null +++ b/external_imported/json/.lgtm.yml @@ -0,0 +1,4 @@ +path_classifiers: + thirdparty: + - /tools/amalgamate + - /tools/cpplint diff --git a/external_imported/json/.reuse/README.md b/external_imported/json/.reuse/README.md new file mode 100644 index 000000000..29c2b67a1 --- /dev/null +++ b/external_imported/json/.reuse/README.md @@ -0,0 +1,7 @@ +# REUSE Software + +This directory contains supporting files to make the project compliant with the REUSE specification. + +The root `Makefile` contains a target `reuse` that updates copyright headers and checks for compliance. + +See for more information. diff --git a/external_imported/json/.reuse/dep5 b/external_imported/json/.reuse/dep5 new file mode 100644 index 000000000..315cae923 --- /dev/null +++ b/external_imported/json/.reuse/dep5 @@ -0,0 +1,32 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: json +Upstream-Contact: Niels Lohmann +Source: https://github.com/nlohmann/json + +Files: * +Copyright: 2013-2022 Niels Lohmann +License: MIT + +Files: tests/thirdparty/doctest/* +Copyright: 2016-2021 Viktor Kirilov +License: MIT + +Files: tests/thirdparty/fifo_map/* +Copyright: 2015-2017 Niels Lohmann +License: MIT + +Files: tests/thirdparty/Fuzzer/* +Copyright: 2003-2022, LLVM Project. +License: Apache-2.0 + +Files: tests/thirdparty/imapdl/* +Copyright: 2017 Georg Sauthoff +License: GPL-3.0-only + +Files: tools/amalgamate/* +Copyright: 2012 Erik Edlund +License: BSD-3-Clause + +Files: tools/gdb_pretty_printer +Copyright: 2020 Hannes Domani +License: MIT diff --git a/external_imported/json/.reuse/templates/json.jinja2 b/external_imported/json/.reuse/templates/json.jinja2 new file mode 100644 index 000000000..9f7df2a39 --- /dev/null +++ b/external_imported/json/.reuse/templates/json.jinja2 @@ -0,0 +1,11 @@ + __ _____ _____ _____ + __| | __| | | | JSON for Modern C++ +| | |__ | | | | | | version 3.11.3 +|_____|_____|_____|_|___| https://github.com/nlohmann/json + +{% for copyright_line in copyright_lines %} +{{ copyright_line }} +{% endfor %} +{% for expression in spdx_expressions %} +SPDX-License-Identifier: {{ expression }} +{% endfor %} diff --git a/external_imported/json/.reuse/templates/json_support.jinja2 b/external_imported/json/.reuse/templates/json_support.jinja2 new file mode 100644 index 000000000..f12832cb8 --- /dev/null +++ b/external_imported/json/.reuse/templates/json_support.jinja2 @@ -0,0 +1,11 @@ + __ _____ _____ _____ + __| | __| | | | JSON for Modern C++ (supporting code) +| | |__ | | | | | | version 3.11.3 +|_____|_____|_____|_|___| https://github.com/nlohmann/json + +{% for copyright_line in copyright_lines %} +{{ copyright_line }} +{% endfor %} +{% for expression in spdx_expressions %} +SPDX-License-Identifier: {{ expression }} +{% endfor %} diff --git a/external_imported/json/.travis.yml b/external_imported/json/.travis.yml deleted file mode 100644 index f48ee1fd6..000000000 --- a/external_imported/json/.travis.yml +++ /dev/null @@ -1,339 +0,0 @@ -######################### -# project configuration # -######################### - -# C++ project -language: cpp - -dist: trusty -sudo: required -group: edge - - -################ -# build matrix # -################ - -matrix: - include: - - # Valgrind - - os: linux - compiler: gcc - env: - - COMPILER=g++-4.9 - - CMAKE_OPTIONS=-DJSON_Valgrind=ON - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-4.9', 'valgrind', 'ninja-build'] - - # clang sanitizer - - os: linux - compiler: clang - env: - - COMPILER=clang++-7 - - CMAKE_OPTIONS=-DJSON_Sanitizer=ON - - UBSAN_OPTIONS=print_stacktrace=1,suppressions=$(pwd)/test/src/UBSAN.supp - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7'] - packages: ['g++-6', 'clang-7', 'ninja-build'] - before_script: - - export PATH=$PATH:/usr/lib/llvm-7/bin - - # cppcheck - - os: linux - compiler: gcc - env: - - COMPILER=g++-4.9 - - SPECIAL=cppcheck - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-4.9', 'cppcheck', 'ninja-build'] - after_success: - - make cppcheck - - # no exceptions - - os: linux - compiler: gcc - env: - - COMPILER=g++-4.9 - - CMAKE_OPTIONS=-DJSON_NoExceptions=ON - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-4.9', 'ninja-build'] - - # check amalgamation - - os: linux - compiler: gcc - env: - - COMPILER=g++-4.9 - - SPECIAL=amalgamation - - MULTIPLE_HEADERS=ON - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-4.9', 'astyle', 'ninja-build'] - after_success: - - make check-amalgamation - - # Coveralls (http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/) - - - os: linux - compiler: gcc - dist: bionic - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-7', 'ninja-build'] - before_script: - - pip install --user cpp-coveralls - after_success: - - coveralls --build-root test --include include/nlohmann --gcov 'gcov-7' --gcov-options '\-lp' - env: - - COMPILER=g++-7 - - CMAKE_OPTIONS=-DJSON_Coverage=ON - - MULTIPLE_HEADERS=ON - - # Coverity (only for branch coverity_scan) - - - os: linux - compiler: clang - before_install: echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6'] - packages: ['g++-6', 'clang-3.6', 'ninja-build'] - coverity_scan: - project: - name: "nlohmann/json" - description: "Build submitted via Travis CI" - notification_email: niels.lohmann@gmail.com - build_command_prepend: "mkdir coverity_build ; cd coverity_build ; cmake .. ; cd .." - build_command: "make -C coverity_build" - branch_pattern: coverity_scan - env: - - SPECIAL=coverity - - COMPILER=clang++-3.6 - # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created - # via the "travis encrypt" command using the project repo's public key - - secure: "m89SSgE+ASLO38rSKx7MTXK3n5NkP9bIx95jwY71YEiuFzib30PDJ/DifKnXxBjvy/AkCGztErQRk/8ZCvq+4HXozU2knEGnL/RUitvlwbhzfh2D4lmS3BvWBGS3N3NewoPBrRmdcvnT0xjOGXxtZaJ3P74TkB9GBnlz/HmKORA=" - - # OSX / Clang - - - os: osx - osx_image: xcode10.2 - - - os: osx - osx_image: xcode11.2 - - - os: osx - osx_image: xcode12 - - - os: osx - osx_image: xcode12 - env: - - IMPLICIT_CONVERSIONS=OFF - - # Linux / GCC - - - os: linux - compiler: gcc - env: COMPILER=g++-4.8 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-4.8', 'ninja-build'] - - - os: linux - compiler: gcc - env: COMPILER=g++-4.9 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-4.9', 'ninja-build'] - - - os: linux - compiler: gcc - env: COMPILER=g++-5 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-5', 'ninja-build'] - - - os: linux - compiler: gcc - env: COMPILER=g++-6 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-6', 'ninja-build'] - - - os: linux - compiler: gcc - env: COMPILER=g++-7 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-7', 'ninja-build'] - - - os: linux - compiler: gcc - env: COMPILER=g++-8 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-8', 'ninja-build'] - - - os: linux - compiler: gcc - env: COMPILER=g++-9 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-9', 'ninja-build'] - - - os: linux - compiler: gcc - env: - - COMPILER=g++-9 - - IMPLICIT_CONVERSIONS=OFF - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-9', 'ninja-build'] - - - os: linux - compiler: gcc - env: - - COMPILER=g++-9 - - CXX_STANDARD=17 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-9', 'ninja-build'] - - # Linux / Clang - - - os: linux - compiler: clang - env: COMPILER=clang++-3.5 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5'] - packages: ['g++-6', 'clang-3.5', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-3.6 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6'] - packages: ['g++-6', 'clang-3.6', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-3.7 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7'] - packages: ['g++-6', 'clang-3.7', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-3.8 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-6', 'clang-3.8', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-3.9 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-6', 'clang-3.9', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-4.0 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-4.0'] - packages: ['g++-6', 'clang-4.0', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-5.0 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0'] - packages: ['g++-6', 'clang-5.0', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-6.0 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-6.0'] - packages: ['g++-6', 'clang-6.0', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-7 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7'] - packages: ['g++-6', 'clang-7', 'ninja-build'] - - - os: linux - compiler: clang - env: - - COMPILER=clang++-7 - - CXX_STANDARD=17 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7'] - packages: ['g++-7', 'clang-7', 'ninja-build'] - -################ -# build script # -################ - -script: - # get CMake and Ninja (only for systems with brew - macOS) - - | - if [[ (-x $(which brew)) ]]; then - brew update - brew install cmake ninja - brew upgrade cmake - cmake --version - fi - - # make sure CXX is correctly set - - if [[ "${COMPILER}" != "" ]]; then export CXX=${COMPILER}; fi - # by default, use the single-header version - - if [[ "${MULTIPLE_HEADERS}" == "" ]]; then export MULTIPLE_HEADERS=OFF; fi - # by default, use implicit conversions - - if [[ "${IMPLICIT_CONVERSIONS}" == "" ]]; then export IMPLICIT_CONVERSIONS=ON; fi - - # append CXX_STANDARD to CMAKE_OPTIONS if required - - CMAKE_OPTIONS+=${CXX_STANDARD:+ -DCMAKE_CXX_STANDARD=$CXX_STANDARD -DCMAKE_CXX_STANDARD_REQUIRED=ON} - - # compile and execute unit tests - - mkdir -p build && cd build - - cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -DJSON_ImplicitConversions=${IMPLICIT_CONVERSIONS} -DJSON_BuildTests=On -GNinja && cmake --build . --config Release - - ctest -C Release --timeout 2700 -V -j - - cd .. - - # check if homebrew works (only checks develop branch) - - if [ `which brew` ]; then - brew update ; - brew tap nlohmann/json ; - brew install nlohmann_json --HEAD ; - brew test nlohmann_json ; - fi diff --git a/external_imported/json/BUILD.bazel b/external_imported/json/BUILD.bazel new file mode 100644 index 000000000..15d84f16b --- /dev/null +++ b/external_imported/json/BUILD.bazel @@ -0,0 +1,53 @@ +cc_library( + name = "json", + hdrs = [ + "include/nlohmann/adl_serializer.hpp", + "include/nlohmann/byte_container_with_subtype.hpp", + "include/nlohmann/detail/abi_macros.hpp", + "include/nlohmann/detail/conversions/from_json.hpp", + "include/nlohmann/detail/conversions/to_chars.hpp", + "include/nlohmann/detail/conversions/to_json.hpp", + "include/nlohmann/detail/exceptions.hpp", + "include/nlohmann/detail/hash.hpp", + "include/nlohmann/detail/input/binary_reader.hpp", + "include/nlohmann/detail/input/input_adapters.hpp", + "include/nlohmann/detail/input/json_sax.hpp", + "include/nlohmann/detail/input/lexer.hpp", + "include/nlohmann/detail/input/parser.hpp", + "include/nlohmann/detail/input/position_t.hpp", + "include/nlohmann/detail/iterators/internal_iterator.hpp", + "include/nlohmann/detail/iterators/iter_impl.hpp", + "include/nlohmann/detail/iterators/iteration_proxy.hpp", + "include/nlohmann/detail/iterators/iterator_traits.hpp", + "include/nlohmann/detail/iterators/json_reverse_iterator.hpp", + "include/nlohmann/detail/iterators/primitive_iterator.hpp", + "include/nlohmann/detail/json_custom_base_class.hpp", + "include/nlohmann/detail/json_pointer.hpp", + "include/nlohmann/detail/json_ref.hpp", + "include/nlohmann/detail/macro_scope.hpp", + "include/nlohmann/detail/macro_unscope.hpp", + "include/nlohmann/detail/meta/call_std/begin.hpp", + "include/nlohmann/detail/meta/call_std/end.hpp", + "include/nlohmann/detail/meta/cpp_future.hpp", + "include/nlohmann/detail/meta/detected.hpp", + "include/nlohmann/detail/meta/identity_tag.hpp", + "include/nlohmann/detail/meta/is_sax.hpp", + "include/nlohmann/detail/meta/std_fs.hpp", + "include/nlohmann/detail/meta/type_traits.hpp", + "include/nlohmann/detail/meta/void_t.hpp", + "include/nlohmann/detail/output/binary_writer.hpp", + "include/nlohmann/detail/output/output_adapters.hpp", + "include/nlohmann/detail/output/serializer.hpp", + "include/nlohmann/detail/string_concat.hpp", + "include/nlohmann/detail/string_escape.hpp", + "include/nlohmann/detail/value_t.hpp", + "include/nlohmann/json.hpp", + "include/nlohmann/json_fwd.hpp", + "include/nlohmann/ordered_map.hpp", + "include/nlohmann/thirdparty/hedley/hedley.hpp", + "include/nlohmann/thirdparty/hedley/hedley_undef.hpp", + ], + includes = ["include"], + visibility = ["//visibility:public"], + alwayslink = True, +) diff --git a/external_imported/json/CITATION.cff b/external_imported/json/CITATION.cff new file mode 100644 index 000000000..fd3b76713 --- /dev/null +++ b/external_imported/json/CITATION.cff @@ -0,0 +1,14 @@ +cff-version: 1.2.0 +message: "If you use this software, please cite it as below." +authors: + - family-names: Lohmann + given-names: Niels + orcid: https://orcid.org/0000-0001-9037-795X + email: mail@nlohmann.me + website: https://nlohmann.me +title: "JSON for Modern C++" +version: 3.11.3 +date-released: 2023-11-28 +license: MIT +repository-code: "https://github.com/nlohmann" +url: https://json.nlohmann.me diff --git a/external_imported/json/CMakeLists.txt b/external_imported/json/CMakeLists.txt index 36f1cf705..7a49dc47e 100644 --- a/external_imported/json/CMakeLists.txt +++ b/external_imported/json/CMakeLists.txt @@ -1,10 +1,10 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.1...3.14) ## ## PROJECT ## name and version ## -project(nlohmann_json VERSION 3.9.1 LANGUAGES CXX) +project(nlohmann_json VERSION 3.11.3 LANGUAGES CXX) ## ## MAIN_PROJECT CHECK @@ -12,13 +12,14 @@ project(nlohmann_json VERSION 3.9.1 LANGUAGES CXX) ## set(MAIN_PROJECT OFF) if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) - set(MAIN_PROJECT ON) + set(MAIN_PROJECT ON) endif() ## ## INCLUDE ## ## +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) include(ExternalProject) ## @@ -30,11 +31,26 @@ if (POLICY CMP0077) cmake_policy(SET CMP0077 NEW) endif () -option(JSON_BuildTests "Build the unit tests when BUILD_TESTING is enabled." ${MAIN_PROJECT}) -option(JSON_Install "Install CMake targets during install step." ${MAIN_PROJECT}) -option(JSON_MultipleHeaders "Use non-amalgamated version of the library." OFF) -option(JSON_ImplicitConversions "Enable implicit conversions." ON) -option(JSON_Diagnostics "Enable better diagnostic messages." OFF) +# VERSION_GREATER_EQUAL is not available in CMake 3.1 +if(${MAIN_PROJECT} AND (${CMAKE_VERSION} VERSION_EQUAL 3.13 OR ${CMAKE_VERSION} VERSION_GREATER 3.13)) + set(JSON_BuildTests_INIT ON) +else() + set(JSON_BuildTests_INIT OFF) +endif() +option(JSON_BuildTests "Build the unit tests when BUILD_TESTING is enabled." ${JSON_BuildTests_INIT}) +option(JSON_CI "Enable CI build targets." OFF) +option(JSON_Diagnostics "Use extended diagnostic messages." OFF) +option(JSON_GlobalUDLs "Place use-defined string literals in the global namespace." ON) +option(JSON_ImplicitConversions "Enable implicit conversions." ON) +option(JSON_DisableEnumSerialization "Disable default integer enum serialization." OFF) +option(JSON_LegacyDiscardedValueComparison "Enable legacy discarded value comparison." OFF) +option(JSON_Install "Install CMake targets during install step." ${MAIN_PROJECT}) +option(JSON_MultipleHeaders "Use non-amalgamated version of the library." ON) +option(JSON_SystemInclude "Include as system headers (skip for clang-tidy)." OFF) + +if (JSON_CI) + include(ci) +endif () ## ## CONFIGURATION @@ -42,7 +58,7 @@ option(JSON_Diagnostics "Enable better diagnostic messages." OFF) include(GNUInstallDirs) set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME}) -set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE INTERNAL "") +set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}" CACHE INTERNAL "") set(NLOHMANN_JSON_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}") set(NLOHMANN_JSON_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets") set(NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE "cmake/config.cmake.in") @@ -50,7 +66,7 @@ set(NLOHMANN_JSON_CMAKE_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}") set(NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}ConfigVersion.cmake") set(NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Config.cmake") set(NLOHMANN_JSON_CMAKE_PROJECT_TARGETS_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Targets.cmake") -set(NLOHMANN_JSON_PKGCONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig") +set(NLOHMANN_JSON_PKGCONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/pkgconfig") if (JSON_MultipleHeaders) set(NLOHMANN_JSON_INCLUDE_BUILD_DIR "${PROJECT_SOURCE_DIR}/include/") @@ -64,10 +80,22 @@ if (NOT JSON_ImplicitConversions) message(STATUS "Implicit conversions are disabled") endif() +if (JSON_DisableEnumSerialization) + message(STATUS "Enum integer serialization is disabled") +endif() + +if (JSON_LegacyDiscardedValueComparison) + message(STATUS "Legacy discarded value comparison enabled") +endif() + if (JSON_Diagnostics) message(STATUS "Diagnostics enabled") endif() +if (JSON_SystemInclude) + set(NLOHMANN_JSON_SYSTEM_INCLUDE "SYSTEM") +endif() + ## ## TARGET ## create target and add include path @@ -83,15 +111,18 @@ endif() target_compile_definitions( ${NLOHMANN_JSON_TARGET_NAME} INTERFACE - JSON_USE_IMPLICIT_CONVERSIONS=$ - JSON_DIAGNOSTICS=$ + $<$>:JSON_USE_GLOBAL_UDLS=0> + $<$>:JSON_USE_IMPLICIT_CONVERSIONS=0> + $<$:JSON_DISABLE_ENUM_SERIALIZATION=1> + $<$:JSON_DIAGNOSTICS=1> + $<$:JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON=1> ) target_include_directories( ${NLOHMANN_JSON_TARGET_NAME} - INTERFACE + ${NLOHMANN_JSON_SYSTEM_INCLUDE} INTERFACE $ - $ + $ ) ## add debug view definition file for msvc (natvis) @@ -108,8 +139,8 @@ endif() # Install a pkg-config file, so other tools can find this. CONFIGURE_FILE( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkg-config.pc.in" - "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkg-config.pc.in" + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" ) ## @@ -119,7 +150,7 @@ CONFIGURE_FILE( if (JSON_BuildTests) include(CTest) enable_testing() - add_subdirectory(test) + add_subdirectory(tests) endif() ## @@ -155,7 +186,7 @@ if(JSON_Install) FILES ${NLOHMANN_NATVIS_FILE} DESTINATION . ) -endif() + endif() export( TARGETS ${NLOHMANN_JSON_TARGET_NAME} NAMESPACE ${PROJECT_NAME}:: diff --git a/external_imported/json/ChangeLog.md b/external_imported/json/ChangeLog.md index e4cec7c5a..656d68bcf 100644 --- a/external_imported/json/ChangeLog.md +++ b/external_imported/json/ChangeLog.md @@ -1,6 +1,597 @@ # Changelog All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [3.11.2](https://github.com/nlohmann/json/releases/tag/3.11.2) (2022-08-12) + +[Full Changelog](https://github.com/nlohmann/json/compare/v3.11.1...3.11.2) + +- MSVC natvis visualizer does not work after introduction of inline ABI namespace [\#3696](https://github.com/nlohmann/json/issues/3696) +- The use of parenthesis gives compilation errors in some situations [\#3682](https://github.com/nlohmann/json/issues/3682) +- extern from/to\_json result in linker error [\#3657](https://github.com/nlohmann/json/issues/3657) +- json\_fwd.hpp no longer standalone [\#3656](https://github.com/nlohmann/json/issues/3656) +- regression: `.value` is compilation error. [\#3655](https://github.com/nlohmann/json/issues/3655) +- Regression: no match for 'operator!=' comparing json\_pointer and const char \*/string\_t [\#3654](https://github.com/nlohmann/json/issues/3654) +- Regression: call to member function 'value' is ambiguous [\#3652](https://github.com/nlohmann/json/issues/3652) +- macOS 10.15 Actions runner image deprecation [\#3612](https://github.com/nlohmann/json/issues/3612) + +- generate\_natvis.py: validate version number; cleanup [\#3698](https://github.com/nlohmann/json/pull/3698) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Add Python script for generating Natvis file and update file for 3.11.2 [\#3697](https://github.com/nlohmann/json/pull/3697) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- fix typo in json\_pointer.md [\#3692](https://github.com/nlohmann/json/pull/3692) ([eltociear](https://github.com/eltociear)) +- Add amalgamated json-fwd.hpp to release [\#3687](https://github.com/nlohmann/json/pull/3687) ([nlohmann](https://github.com/nlohmann)) +- Documentation updates for 3.11.2 [\#3686](https://github.com/nlohmann/json/pull/3686) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Make json\_pointer usable as map key \(again\) [\#3685](https://github.com/nlohmann/json/pull/3685) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Deprecate json\_pointer/string\_t comparisons [\#3684](https://github.com/nlohmann/json/pull/3684) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Restructure inline namespace and allow version component to be disabled [\#3683](https://github.com/nlohmann/json/pull/3683) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Properly constrain non-string json\_pointer overloads [\#3681](https://github.com/nlohmann/json/pull/3681) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Amalgamate the forward declaration header [\#3679](https://github.com/nlohmann/json/pull/3679) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Fix 'const' qualifier on bool& has no effect [\#3678](https://github.com/nlohmann/json/pull/3678) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Fix whitespace in workflow files [\#3675](https://github.com/nlohmann/json/pull/3675) ([nlohmann](https://github.com/nlohmann)) +- Attempt to fix labeler permissions [\#3674](https://github.com/nlohmann/json/pull/3674) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Refine 'Publish documentation' workflow [\#3673](https://github.com/nlohmann/json/pull/3673) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Documentation change [\#3672](https://github.com/nlohmann/json/pull/3672) ([nlohmann](https://github.com/nlohmann)) +- Add labeler action [\#3671](https://github.com/nlohmann/json/pull/3671) ([nlohmann](https://github.com/nlohmann)) +- Complete contributor list [\#3670](https://github.com/nlohmann/json/pull/3670) ([nlohmann](https://github.com/nlohmann)) +- Add json\_pointer/string\_t equality comparison operators [\#3664](https://github.com/nlohmann/json/pull/3664) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Reimplement value\(\) access functions [\#3663](https://github.com/nlohmann/json/pull/3663) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Complete contributor list [\#3662](https://github.com/nlohmann/json/pull/3662) ([nlohmann](https://github.com/nlohmann)) +- Adjust naming of GitHub action jobs [\#3661](https://github.com/nlohmann/json/pull/3661) ([nlohmann](https://github.com/nlohmann)) +- Publish documentation on push to develop branch [\#3660](https://github.com/nlohmann/json/pull/3660) ([nlohmann](https://github.com/nlohmann)) +- Add Discord badge to README [\#3651](https://github.com/nlohmann/json/pull/3651) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Miscellaneous small fixes [\#3643](https://github.com/nlohmann/json/pull/3643) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Minor BJData fixes [\#3637](https://github.com/nlohmann/json/pull/3637) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Update CI [\#3626](https://github.com/nlohmann/json/pull/3626) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) + +## [v3.11.1](https://github.com/nlohmann/json/releases/tag/v3.11.1) (2022-08-01) + +[Full Changelog](https://github.com/nlohmann/json/compare/v3.11.0...v3.11.1) + +- Regression: no matching literal operator for call to 'operator""\_json' [\#3645](https://github.com/nlohmann/json/issues/3645) +- \_json operator""\(\) [\#3644](https://github.com/nlohmann/json/issues/3644) + +- Fix global UDLs [\#3646](https://github.com/nlohmann/json/pull/3646) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) + +## [v3.11.0](https://github.com/nlohmann/json/releases/tag/v3.11.0) (2022-08-01) + +[Full Changelog](https://github.com/nlohmann/json/compare/v3.10.5...v3.11.0) + +- ICPC: warning \#1098: the qualifier on this friend declaration is ignored [\#3632](https://github.com/nlohmann/json/issues/3632) +- Starting with 3.10.4, just adding `\#include json.hpp` causes compile error: `overload resolution selected deleted operator '=' [\#3620](https://github.com/nlohmann/json/issues/3620) +- xwidgets doesn't compile with version \>3.10.3 [\#3602](https://github.com/nlohmann/json/issues/3602) +- json\_pointer\_\_pop\_back.cpp example does not compile [\#3600](https://github.com/nlohmann/json/issues/3600) +- nlohmann::json::array 'push\_back' is ambiguous [\#3589](https://github.com/nlohmann/json/issues/3589) +- Multiple versions causing conflict [\#3588](https://github.com/nlohmann/json/issues/3588) +- ERROR: ThreadSanitizer: SEGV on unknown address [\#3584](https://github.com/nlohmann/json/issues/3584) +- unicode4 test consistently fails on RISC-V hardware [\#3579](https://github.com/nlohmann/json/issues/3579) +- sax\_parse\(iterator, json\_sax\_t \*\) string callback clobbers spaces [\#3574](https://github.com/nlohmann/json/issues/3574) +- Nlohmann JSON Parse crash with raylib-cpp [\#3570](https://github.com/nlohmann/json/issues/3570) +- ordered\_json doesn't accept keys of types other than string\_t \(e.g., string\_view\) [\#3558](https://github.com/nlohmann/json/issues/3558) +- turning an object into an array [\#3547](https://github.com/nlohmann/json/issues/3547) +- json:parse\_bjdata\_fuzzer: ASSERT: ref\_stack.back\(\)-\>is\_array\(\) [\#3541](https://github.com/nlohmann/json/issues/3541) +- Warning about potential null dereference in GCC 12.1 \(Fedora 36\) [\#3525](https://github.com/nlohmann/json/issues/3525) +- Enable 32bit unit test in CI [\#3524](https://github.com/nlohmann/json/issues/3524) +- Error when roundtripping BJData [\#3519](https://github.com/nlohmann/json/issues/3519) +- ASSERT error while parsing BJData [\#3513](https://github.com/nlohmann/json/issues/3513) +- An exception occurred when sending a string with double quotes [\#3504](https://github.com/nlohmann/json/issues/3504) +- Binary reader for BJData creates incorrect SAX events [\#3503](https://github.com/nlohmann/json/issues/3503) +- It can't support "nan", "inf", "-inf" for float type [\#3494](https://github.com/nlohmann/json/issues/3494) +- ASAN error while parsing BJData \(Heap-buffer-overflow READ 1\) [\#3492](https://github.com/nlohmann/json/issues/3492) +- UBSAN error while parsing BJData \(Null-dereference\) [\#3491](https://github.com/nlohmann/json/issues/3491) +- UBSAN error while parsing BJData \(Invalid-bool-value\) [\#3490](https://github.com/nlohmann/json/issues/3490) +- json:parse\_bjdata\_fuzzer reaches assertion [\#3475](https://github.com/nlohmann/json/issues/3475) +- Compilation with -fmodules-ts and use inside of a module [\#3472](https://github.com/nlohmann/json/issues/3472) +- json.exception.parse\_error.101 only occurs outside of IDE [\#3467](https://github.com/nlohmann/json/issues/3467) +- json:parse\_bjdata\_fuzzer reaches assertion [\#3461](https://github.com/nlohmann/json/issues/3461) +- NLOHMANN\_DEFINE\_TYPE\_NON\_INTRUSIVE\_WITH\_DEFAULT can not parse { "key" : null} [\#3458](https://github.com/nlohmann/json/issues/3458) +- Unable to compile when using Microsoft's \_CRTDBG [\#3457](https://github.com/nlohmann/json/issues/3457) +- Compilation errors when including `` and using `--std=c++17` or above \(MinGW/Win10\) [\#3449](https://github.com/nlohmann/json/issues/3449) +- Weird things on for statement [\#3447](https://github.com/nlohmann/json/issues/3447) +- Parsing error when there is a json string within a Json [\#3445](https://github.com/nlohmann/json/issues/3445) +- ordered\_json vs json types comparison [\#3443](https://github.com/nlohmann/json/issues/3443) +- Error occurred when converting nlohmann::json to std::any [\#3428](https://github.com/nlohmann/json/issues/3428) +- I was forced to report an assertion error when copying an array of strings [\#3419](https://github.com/nlohmann/json/issues/3419) +- About Serialization Error invalid UTF-8 byte at index [\#3414](https://github.com/nlohmann/json/issues/3414) +- Comparison of NaN differs between json and float [\#3409](https://github.com/nlohmann/json/issues/3409) +- when i use it in C++ sserver,it it constantly show that fatal error: adl\_serializer.hpp: No such file or directory [\#3404](https://github.com/nlohmann/json/issues/3404) +- parse error [\#3403](https://github.com/nlohmann/json/issues/3403) +- CMake script MAIN\_PROJECT always OFF [\#3390](https://github.com/nlohmann/json/issues/3390) +- Parser unable to handle large floating point numbers [\#3389](https://github.com/nlohmann/json/issues/3389) +- Compilation error if json\_pointer is used with alternative string type [\#3388](https://github.com/nlohmann/json/issues/3388) +- Unit tests conversions & items fail to build \(Clang \<4.0/C++14 only\) [\#3384](https://github.com/nlohmann/json/issues/3384) +- Regression test for \#3070 is not being run and fails when enabled [\#3377](https://github.com/nlohmann/json/issues/3377) +- Refactor unit tests to use more convenient doctest assertion macros [\#3365](https://github.com/nlohmann/json/issues/3365) +- An json.h issue reported in a static code analyzer [\#3361](https://github.com/nlohmann/json/issues/3361) +- Mixing different JSON\_DIAGNOSTICS settings in separately compiled units leads to core [\#3360](https://github.com/nlohmann/json/issues/3360) +- json::out\_of\_range exception matches against lot of others while testing [\#3352](https://github.com/nlohmann/json/issues/3352) +- use mipsel-openwrt-linux-g++ -std=c++11 to compile, it has some errors "error: 'snprintf' is not a member of 'std'" [\#3349](https://github.com/nlohmann/json/issues/3349) +- Add proper issue templates [\#3348](https://github.com/nlohmann/json/issues/3348) +- switch from json to ordered\_json [\#3343](https://github.com/nlohmann/json/issues/3343) +- Json dump use to compilation errors [\#3339](https://github.com/nlohmann/json/issues/3339) +- Ambiguous conversion from nlohmann::basic\_json\<\> to custom class. [\#3333](https://github.com/nlohmann/json/issues/3333) +- Iterator doesn't satisfy std::incrementable because post-increment may change constness [\#3331](https://github.com/nlohmann/json/issues/3331) +- Inconsistent handling of floating point numbers after parse\(\) [\#3329](https://github.com/nlohmann/json/issues/3329) +- Documentation for `ordered_json` should show proper use of the `parse()` function. [\#3325](https://github.com/nlohmann/json/issues/3325) +- "type must be boolean, but is object" error thrown on non-boolean object [\#3319](https://github.com/nlohmann/json/issues/3319) +- Incomplete Type in request parms [\#3318](https://github.com/nlohmann/json/issues/3318) +- å°ç±³ MIX4 MIUI13 bug [\#3316](https://github.com/nlohmann/json/issues/3316) +- json.exception.parse\_error.101 when parsing data received over a socket [\#3313](https://github.com/nlohmann/json/issues/3313) +- Parse to custom class from unordered\_json breaks on G++11.2.0 with C++20 [\#3312](https://github.com/nlohmann/json/issues/3312) +- try to assign dumped string to a class member varible [\#3300](https://github.com/nlohmann/json/issues/3300) +- includedir in pkgconfig is error if install\_headers\(\) has subdir argument. [\#3284](https://github.com/nlohmann/json/issues/3284) +- SHA-256 sum of json-3.10.5.tar.xz changes over time \(but not the content itself\) [\#3281](https://github.com/nlohmann/json/issues/3281) +- items\(\) method does not follow order of json message [\#3278](https://github.com/nlohmann/json/issues/3278) +- Perplexing template deduction failure serialising a 3rd party type using base class [\#3267](https://github.com/nlohmann/json/issues/3267) +- json.hpp 'isfinite' is not a member of 'std' also isinf; snprintf; stoull and to\_string members of std [\#3263](https://github.com/nlohmann/json/issues/3263) +- JSON build fails for C++ cmake [\#3256](https://github.com/nlohmann/json/issues/3256) +- Unexpected implicit conversion [\#3254](https://github.com/nlohmann/json/issues/3254) +- Add a function that checks for valid json in a C++ string [\#3245](https://github.com/nlohmann/json/issues/3245) +- Replace use of standard IO from error handling [\#3239](https://github.com/nlohmann/json/issues/3239) +- Use Catch for unit tests [\#3232](https://github.com/nlohmann/json/issues/3232) +- Exception thrown during initialization causes a memory leak [\#3215](https://github.com/nlohmann/json/issues/3215) +- Tests failing when compiling with c++20 [\#3207](https://github.com/nlohmann/json/issues/3207) +- ambiguous regression [\#3204](https://github.com/nlohmann/json/issues/3204) +- Deserialization: if class is\_constructible from std::string wrong from\_json overload is being selected, compilation failed [\#3171](https://github.com/nlohmann/json/issues/3171) +- 'clang++ ./json.hpp' with no usage: Compiler syntax problem in clang 3.7.0 \(tizen :/ \) [\#3153](https://github.com/nlohmann/json/issues/3153) +- build failure on upcoming gcc-12: test/src/unit-regression1.cpp:392:22: error: ambiguous overload for 'operator=' [\#3138](https://github.com/nlohmann/json/issues/3138) +- Applying JSON patch creates parent object [\#3134](https://github.com/nlohmann/json/issues/3134) +- Iterators cannot be used with range-v3 [\#3130](https://github.com/nlohmann/json/issues/3130) +- std::shared\_ptr\ == nlohmann::json compiles, which seem undesirable [\#3026](https://github.com/nlohmann/json/issues/3026) +- Error in test\download\_test\_data.vcxproj custom build step when compiling with Visual Studio 2019 16.7.7 msbuild on Windows 10 [\#2593](https://github.com/nlohmann/json/issues/2593) +- Consider putting the user-defined literals in a namespace [\#1682](https://github.com/nlohmann/json/issues/1682) +- Using versioned namespaces [\#1539](https://github.com/nlohmann/json/issues/1539) +- How can I use std::string\_view as the json\_key to "operator \[\]" ? [\#1529](https://github.com/nlohmann/json/issues/1529) +- serialize std::variant\<...\> [\#1261](https://github.com/nlohmann/json/issues/1261) + +- Prepare 3.11.0 release [\#3635](https://github.com/nlohmann/json/pull/3635) ([nlohmann](https://github.com/nlohmann)) +- Fix warning [\#3634](https://github.com/nlohmann/json/pull/3634) ([nlohmann](https://github.com/nlohmann)) +- Add license header to new files [\#3633](https://github.com/nlohmann/json/pull/3633) ([nlohmann](https://github.com/nlohmann)) +- Add a unit test including windows.h [\#3631](https://github.com/nlohmann/json/pull/3631) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Fixed latest build error in msvc platform [\#3630](https://github.com/nlohmann/json/pull/3630) ([KsaNL](https://github.com/KsaNL)) +- Add regression tests for \#3204 and \#3333 [\#3629](https://github.com/nlohmann/json/pull/3629) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Fix patch::add creating nonexistent parents [\#3628](https://github.com/nlohmann/json/pull/3628) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Adjust JSON Pointer examples [\#3622](https://github.com/nlohmann/json/pull/3622) ([nlohmann](https://github.com/nlohmann)) +- Disable exceptions on ICPC [\#3621](https://github.com/nlohmann/json/pull/3621) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- build: install .pc and .cmake files to share/ [\#3619](https://github.com/nlohmann/json/pull/3619) ([Tachi107](https://github.com/Tachi107)) +- Fix MinGW CI failures [\#3618](https://github.com/nlohmann/json/pull/3618) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Fix Unicode test timeout \(for real this time!\) [\#3614](https://github.com/nlohmann/json/pull/3614) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Use 'concurrency' in GitHub workflows [\#3610](https://github.com/nlohmann/json/pull/3610) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Use swap\(\) by ADL [\#3609](https://github.com/nlohmann/json/pull/3609) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Move UDLs out of the global namespace [\#3605](https://github.com/nlohmann/json/pull/3605) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Re-add value\_type detection to distinguish string types [\#3604](https://github.com/nlohmann/json/pull/3604) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Add operator\<\<\(json\_pointer\) [\#3601](https://github.com/nlohmann/json/pull/3601) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Add documentation for comparing json and ordered\_json [\#3599](https://github.com/nlohmann/json/pull/3599) ([nlohmann](https://github.com/nlohmann)) +- Clean up after \#3581 [\#3596](https://github.com/nlohmann/json/pull/3596) ([nlohmann](https://github.com/nlohmann)) +- Add assertion if nullptr is passed to parse function [\#3593](https://github.com/nlohmann/json/pull/3593) ([nlohmann](https://github.com/nlohmann)) +- Minor documentation fixes [\#3592](https://github.com/nlohmann/json/pull/3592) ([nlohmann](https://github.com/nlohmann)) +- Add versioned, ABI-tagged inline namespace and namespace macros [\#3590](https://github.com/nlohmann/json/pull/3590) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Add badge for https://repology.org/project/nlohmann-json/versions [\#3586](https://github.com/nlohmann/json/pull/3586) ([nlohmann](https://github.com/nlohmann)) +- Add error message if test suite cannot be found [\#3585](https://github.com/nlohmann/json/pull/3585) ([nlohmann](https://github.com/nlohmann)) +- add patch\_inplace function [\#3581](https://github.com/nlohmann/json/pull/3581) ([wolfv](https://github.com/wolfv)) +- Enable overriding test properties and set Unicode test timeouts [\#3580](https://github.com/nlohmann/json/pull/3580) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Ignore output directory [\#3572](https://github.com/nlohmann/json/pull/3572) ([NN---](https://github.com/NN---)) +- Optimize output vector adapter write [\#3569](https://github.com/nlohmann/json/pull/3569) ([romainreignier](https://github.com/romainreignier)) +- Add overloads for more key types to ordered\_map and fix ordered\_map::erase\(first, last\) with first == last [\#3564](https://github.com/nlohmann/json/pull/3564) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Make certain usage patterns more prominent in the README [\#3557](https://github.com/nlohmann/json/pull/3557) ([jez](https://github.com/jez)) +- CI: fix "JSON\_MultipleHeaders" option spelling [\#3555](https://github.com/nlohmann/json/pull/3555) ([karzhenkov](https://github.com/karzhenkov)) +- More documentation updates for 3.11.0 [\#3553](https://github.com/nlohmann/json/pull/3553) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Use DOCTEST\_\* compiler macros and suppress pragmas warning [\#3550](https://github.com/nlohmann/json/pull/3550) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Add unit test to make sure iterator\_input\_adapter advances iterators correctly [\#3548](https://github.com/nlohmann/json/pull/3548) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Use REUSE framework [\#3546](https://github.com/nlohmann/json/pull/3546) ([nlohmann](https://github.com/nlohmann)) +- Use `std::iterator_traits` to extract `iterator_category` [\#3544](https://github.com/nlohmann/json/pull/3544) ([Mike-Leo-Smith](https://github.com/Mike-Leo-Smith)) +- BJData dimension length can not be string\_t::npos, fix \#3541 [\#3543](https://github.com/nlohmann/json/pull/3543) ([fangq](https://github.com/fangq)) +- Allow disabling default enum conversions [\#3536](https://github.com/nlohmann/json/pull/3536) ([zxey](https://github.com/zxey)) +- Add to\_json\(\) for std::vector\::reference [\#3534](https://github.com/nlohmann/json/pull/3534) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- CI: Enable 32bit unit test \(3\) [\#3532](https://github.com/nlohmann/json/pull/3532) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Use new CI image [\#3528](https://github.com/nlohmann/json/pull/3528) ([nlohmann](https://github.com/nlohmann)) +- Fix ndarray dimension signedness, fix ndarray length overflow \(2\); add 32bit unit test [\#3523](https://github.com/nlohmann/json/pull/3523) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Small documentation fixes [\#3520](https://github.com/nlohmann/json/pull/3520) ([nlohmann](https://github.com/nlohmann)) +- Add assertion to converting constructor [\#3517](https://github.com/nlohmann/json/pull/3517) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- CI: Remove -Wstrict-overflow [\#3516](https://github.com/nlohmann/json/pull/3516) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Fix nlohmann/json\#3513, explain is\_ndarray flag [\#3514](https://github.com/nlohmann/json/pull/3514) ([fangq](https://github.com/fangq)) +- Prevent ndarray size vector from recursive use, fix nlohmann/json\#3503 [\#3505](https://github.com/nlohmann/json/pull/3505) ([fangq](https://github.com/fangq)) +- prevent ndarray dimension vector from recusive array, nlohmann/json\#3500 [\#3502](https://github.com/nlohmann/json/pull/3502) ([fangq](https://github.com/fangq)) +- Discard optimized containers with negative counts in UBJSON/BJData \(\#3491,\#3492,\#3490\) [\#3500](https://github.com/nlohmann/json/pull/3500) ([fangq](https://github.com/fangq)) +- Update json.hpp [\#3499](https://github.com/nlohmann/json/pull/3499) ([ivanovmp](https://github.com/ivanovmp)) +- Add assertion for invariant in SAX-DOM parser [\#3498](https://github.com/nlohmann/json/pull/3498) ([nlohmann](https://github.com/nlohmann)) +- Add more macOS builders [\#3485](https://github.com/nlohmann/json/pull/3485) ([nlohmann](https://github.com/nlohmann)) +- change bjdata ndarray flag to detect negative size, as part of \#3475 [\#3479](https://github.com/nlohmann/json/pull/3479) ([fangq](https://github.com/fangq)) +- Document fuzzer usage [\#3478](https://github.com/nlohmann/json/pull/3478) ([nlohmann](https://github.com/nlohmann)) +- Add build step for ICPC \(with fixes\) [\#3465](https://github.com/nlohmann/json/pull/3465) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Complete documentation for 3.11.0 [\#3464](https://github.com/nlohmann/json/pull/3464) ([nlohmann](https://github.com/nlohmann)) +- Handle invalid BJData optimized type, fix \#3461 [\#3463](https://github.com/nlohmann/json/pull/3463) ([fangq](https://github.com/fangq)) +- Reorganize directories [\#3462](https://github.com/nlohmann/json/pull/3462) ([nlohmann](https://github.com/nlohmann)) +- Enable rapid testing and development on Compiler Explorer [\#3456](https://github.com/nlohmann/json/pull/3456) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- cpplint 1.6.0 [\#3454](https://github.com/nlohmann/json/pull/3454) ([nlohmann](https://github.com/nlohmann)) +- Disable regression test for \#3070 on GCC \<8.4 [\#3451](https://github.com/nlohmann/json/pull/3451) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Fix C++20/gcc-12 issues \(Part 2\) [\#3446](https://github.com/nlohmann/json/pull/3446) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Overwork documentation [\#3444](https://github.com/nlohmann/json/pull/3444) ([nlohmann](https://github.com/nlohmann)) +- Fix typo in basic\_json documentation [\#3439](https://github.com/nlohmann/json/pull/3439) ([jhnlee](https://github.com/jhnlee)) +- Exclude std::any from implicit conversion \(fixes \#3428\) [\#3437](https://github.com/nlohmann/json/pull/3437) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Document which version introduced the macros [\#3431](https://github.com/nlohmann/json/pull/3431) ([nlohmann](https://github.com/nlohmann)) +- Fix constraints on from\_json\(\) for strings \(fixes \#3171, \#3267, \#3312, \#3384\) [\#3427](https://github.com/nlohmann/json/pull/3427) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- at.md: fix typo [\#3426](https://github.com/nlohmann/json/pull/3426) ([heinemml](https://github.com/heinemml)) +- Implement support for string\_view \(attempt no. 3\) [\#3423](https://github.com/nlohmann/json/pull/3423) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- CI: speedup AppVeyor builds by ~30% [\#3422](https://github.com/nlohmann/json/pull/3422) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Restore disabled check for \#3070 \(except on MSVC\) [\#3421](https://github.com/nlohmann/json/pull/3421) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Update CI image [\#3420](https://github.com/nlohmann/json/pull/3420) ([nlohmann](https://github.com/nlohmann)) +- Add check if different version is also included [\#3418](https://github.com/nlohmann/json/pull/3418) ([nlohmann](https://github.com/nlohmann)) +- Report the right \_\_cplusplus value for MSVC in basic\_json meta\(\) [\#3417](https://github.com/nlohmann/json/pull/3417) ([flagarde](https://github.com/flagarde)) +- CI: windows-2016 has been deprecated; remove jobs [\#3416](https://github.com/nlohmann/json/pull/3416) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Re-template json\_pointer on string type [\#3415](https://github.com/nlohmann/json/pull/3415) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Refactor unit tests to use more convenient doctest assertion macros \(Part 2\) [\#3405](https://github.com/nlohmann/json/pull/3405) ([kkarbowiak](https://github.com/kkarbowiak)) +- Refactor unit tests to use more convenient doctest assertion macros [\#3393](https://github.com/nlohmann/json/pull/3393) ([kkarbowiak](https://github.com/kkarbowiak)) +- Improve unit testing \(Part 1\) [\#3380](https://github.com/nlohmann/json/pull/3380) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Fix C++20/gcc-12 issues \(Part 1\) [\#3379](https://github.com/nlohmann/json/pull/3379) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Add clarification to avoid misunderstanding that cause \#3360 [\#3378](https://github.com/nlohmann/json/pull/3378) ([puffetto](https://github.com/puffetto)) +- Fix ordered\_map ctor with initializer\_list \(fixes \#3343\) [\#3370](https://github.com/nlohmann/json/pull/3370) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Fix and update CI [\#3368](https://github.com/nlohmann/json/pull/3368) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- FetchContent\_MakeAvailable [\#3351](https://github.com/nlohmann/json/pull/3351) ([nlohmann](https://github.com/nlohmann)) +- Avoid clash with Arduino defines [\#3338](https://github.com/nlohmann/json/pull/3338) ([DarkZeros](https://github.com/DarkZeros)) +- Support UBJSON-derived Binary JData \(BJData\) format [\#3336](https://github.com/nlohmann/json/pull/3336) ([fangq](https://github.com/fangq)) +- Make iterator operator++/--\(int\) equality-preserving [\#3332](https://github.com/nlohmann/json/pull/3332) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- Add note on parsing ordered\_json [\#3326](https://github.com/nlohmann/json/pull/3326) ([nlohmann](https://github.com/nlohmann)) +- Fix CITATION.cff and add automatic validation of your citation metadata [\#3320](https://github.com/nlohmann/json/pull/3320) ([fdiblen](https://github.com/fdiblen)) +- .github/workflows/windows.yml: Add support for Visual Studio 2022 [\#3295](https://github.com/nlohmann/json/pull/3295) ([t-b](https://github.com/t-b)) +- Add maintainer targets to create source archive [\#3289](https://github.com/nlohmann/json/pull/3289) ([nlohmann](https://github.com/nlohmann)) +- Fix a typo [\#3265](https://github.com/nlohmann/json/pull/3265) ([fhuberts](https://github.com/fhuberts)) +- Fix typo [\#3249](https://github.com/nlohmann/json/pull/3249) ([rex4539](https://github.com/rex4539)) +- Add documentation for JSON Lines [\#3247](https://github.com/nlohmann/json/pull/3247) ([nlohmann](https://github.com/nlohmann)) +- Improve documentation InputType and IteratorType [\#3246](https://github.com/nlohmann/json/pull/3246) ([nlohmann](https://github.com/nlohmann)) +- Remove stringstream [\#3244](https://github.com/nlohmann/json/pull/3244) ([nlohmann](https://github.com/nlohmann)) +- fix \_MSC\_VER version to check for std::filesystem [\#3240](https://github.com/nlohmann/json/pull/3240) ([gcerretani](https://github.com/gcerretani)) +- Add macros NLOHMANN\_DEFINE\_TYPE\_INTRUSIVE\_WITH\_DEFAULT and ...\_NON\_INTRUSIVE\_WITH\_DEFAULT [\#3143](https://github.com/nlohmann/json/pull/3143) ([pketelsen](https://github.com/pketelsen)) + +## [v3.10.5](https://github.com/nlohmann/json/releases/tag/v3.10.5) (2022-01-03) + +[Full Changelog](https://github.com/nlohmann/json/compare/v3.10.4...v3.10.5) + +- \#include \ doesn't work with gcc-7 when `-std=c++17` is specified. [\#3203](https://github.com/nlohmann/json/issues/3203) +- Not able to use nlohmann json with c++ code built using emscripten to wasm [\#3200](https://github.com/nlohmann/json/issues/3200) +- Warning for shadowed variables [\#3188](https://github.com/nlohmann/json/issues/3188) +- Accessing missing keys on const json object leads to assert [\#3183](https://github.com/nlohmann/json/issues/3183) +- Data member is available, but null is reported, and program throws error [\#3173](https://github.com/nlohmann/json/issues/3173) +- serialization problem, from\_json need construct new object [\#3169](https://github.com/nlohmann/json/issues/3169) +- std::filesystem unavailable on macOS lower deployment targets [\#3156](https://github.com/nlohmann/json/issues/3156) +- \[json.exception.type\_error.305\] cannot use operator\[\] with a string argument with string [\#3151](https://github.com/nlohmann/json/issues/3151) +- json::dump\(\) is not compatible with C++ standards [\#3147](https://github.com/nlohmann/json/issues/3147) +- Issue with json::parse decoding codepoints [\#3142](https://github.com/nlohmann/json/issues/3142) +- Simple parse of json object thinks it should be an array [\#3136](https://github.com/nlohmann/json/issues/3136) +- How to properly read a Json string that may be null in some cases? [\#3135](https://github.com/nlohmann/json/issues/3135) +- Deadlock on create json - windows only [\#3129](https://github.com/nlohmann/json/issues/3129) +- Wrong parsing of int64 values nearest of limit [\#3126](https://github.com/nlohmann/json/issues/3126) +- ordered\_json doesn't support range based erase [\#3108](https://github.com/nlohmann/json/issues/3108) +- Apple build failed with json/single\_include/nlohmann/json.hpp:4384:57: 'path' is unavailable [\#3097](https://github.com/nlohmann/json/issues/3097) +- GCC 7.5.0 with --std=c++17: filesystem: No such file or directory [\#3090](https://github.com/nlohmann/json/issues/3090) +- Drop Travis CI [\#3087](https://github.com/nlohmann/json/issues/3087) +- ordered\_json::reset\(\) compile error with nvcc [\#3013](https://github.com/nlohmann/json/issues/3013) +- Support for unordered\_map as object\_t [\#2932](https://github.com/nlohmann/json/issues/2932) +- Compiler warning with Intel compiler, same as \#755 [\#2712](https://github.com/nlohmann/json/issues/2712) +- Compiler warnings with NVCC 11.2 [\#2676](https://github.com/nlohmann/json/issues/2676) +- some static analysis warning at line 11317 [\#1390](https://github.com/nlohmann/json/issues/1390) +- Compiling with icpc [\#755](https://github.com/nlohmann/json/issues/755) + +- Fix compilation error with NVCC [\#3234](https://github.com/nlohmann/json/pull/3234) ([nlohmann](https://github.com/nlohmann)) +- Remove Travis CI [\#3233](https://github.com/nlohmann/json/pull/3233) ([nlohmann](https://github.com/nlohmann)) +- Add build step for NVCC and fix a warning [\#3227](https://github.com/nlohmann/json/pull/3227) ([nlohmann](https://github.com/nlohmann)) +- Update cpplint [\#3225](https://github.com/nlohmann/json/pull/3225) ([nlohmann](https://github.com/nlohmann)) +- Fix: Warning for shadowed variables \(\#3188\) [\#3193](https://github.com/nlohmann/json/pull/3193) ([kernie](https://github.com/kernie)) +- Fix FAQ hyperlink typo in readme [\#3148](https://github.com/nlohmann/json/pull/3148) ([Prince-Mendiratta](https://github.com/Prince-Mendiratta)) +- Docs: Update `skip_comments` to `ignore_comments` [\#3145](https://github.com/nlohmann/json/pull/3145) ([daniel-kun](https://github.com/daniel-kun)) +- fix typos in documentation [\#3140](https://github.com/nlohmann/json/pull/3140) ([striezel](https://github.com/striezel)) +- Fix spelling [\#3125](https://github.com/nlohmann/json/pull/3125) ([axic](https://github.com/axic)) +- Extend std specializations [\#3121](https://github.com/nlohmann/json/pull/3121) ([nlohmann](https://github.com/nlohmann)) +- Add missing erase\(first, last\) function to ordered\_map [\#3109](https://github.com/nlohmann/json/pull/3109) ([nlohmann](https://github.com/nlohmann)) +- Fix typos in operator\[\] documentation [\#3102](https://github.com/nlohmann/json/pull/3102) ([axnsan12](https://github.com/axnsan12)) +- Add C++17 copies of the test binaries [\#3101](https://github.com/nlohmann/json/pull/3101) ([nlohmann](https://github.com/nlohmann)) +- Add examples for parsing from iterator pair [\#3100](https://github.com/nlohmann/json/pull/3100) ([nlohmann](https://github.com/nlohmann)) +- Update CI [\#3088](https://github.com/nlohmann/json/pull/3088) ([nlohmann](https://github.com/nlohmann)) +- Consolidate documentation [\#3071](https://github.com/nlohmann/json/pull/3071) ([nlohmann](https://github.com/nlohmann)) +- Add recursive update function [\#3069](https://github.com/nlohmann/json/pull/3069) ([nlohmann](https://github.com/nlohmann)) + +## [v3.10.4](https://github.com/nlohmann/json/releases/tag/v3.10.4) (2021-10-16) + +[Full Changelog](https://github.com/nlohmann/json/compare/v3.10.3...v3.10.4) + +- Compiler error in output serializer due to 'incompatible initializer' [\#3081](https://github.com/nlohmann/json/issues/3081) +- Strange behaviour when using std::sort on std::vector\ [\#3080](https://github.com/nlohmann/json/issues/3080) +- Unhandled exception: nlohmann::detail::parse\_error [\#3078](https://github.com/nlohmann/json/issues/3078) +- explicit constructor with default does not compile [\#3077](https://github.com/nlohmann/json/issues/3077) +- Parse an object but get an array using GCC [\#3076](https://github.com/nlohmann/json/issues/3076) +- Version 3.10.3 breaks backward-compatibility with 3.10.2 [\#3070](https://github.com/nlohmann/json/issues/3070) +- Feature request, Add to\_json/from\_json to align with other to/from binary api. [\#3067](https://github.com/nlohmann/json/issues/3067) +- vcpkg is out of date [\#3066](https://github.com/nlohmann/json/issues/3066) + +- Revert invalid fix [\#3082](https://github.com/nlohmann/json/pull/3082) ([nlohmann](https://github.com/nlohmann)) +- Allow to use get with explicit constructor [\#3079](https://github.com/nlohmann/json/pull/3079) ([nlohmann](https://github.com/nlohmann)) +- fix std::filesystem::path regression [\#3073](https://github.com/nlohmann/json/pull/3073) ([theodelrieu](https://github.com/theodelrieu)) + +## [v3.10.3](https://github.com/nlohmann/json/releases/tag/v3.10.3) (2021-10-08) + +[Full Changelog](https://github.com/nlohmann/json/compare/v3.10.2...v3.10.3) + +- Parsing an emtpy string returns a string with size 1 instead of expected 0 [\#3057](https://github.com/nlohmann/json/issues/3057) +- Linking error "duplicate symbol: std::type\_info::operator==" on static build with MinGW [\#3042](https://github.com/nlohmann/json/issues/3042) +- Yet another assertion failure when inserting into arrays with JSON\_DIAGNOSTICS set [\#3032](https://github.com/nlohmann/json/issues/3032) +- accept and parse function not work well with a pure number string [\#3029](https://github.com/nlohmann/json/issues/3029) +- push\_back doesn't work for serializing containers [\#3027](https://github.com/nlohmann/json/issues/3027) +- Strange behaviour when creating array with single element [\#3025](https://github.com/nlohmann/json/issues/3025) +- Input ordered\_json doesn't work [\#3023](https://github.com/nlohmann/json/issues/3023) +- Issue iterating through 'items' [\#3021](https://github.com/nlohmann/json/issues/3021) +- Cannot spell the namespace right [\#3015](https://github.com/nlohmann/json/issues/3015) +- JSON Parse error when reading json object from file [\#3011](https://github.com/nlohmann/json/issues/3011) +- Parent pointer not properly set when using update\(\) [\#3007](https://github.com/nlohmann/json/issues/3007) +- Overwriting terminated null character [\#3001](https://github.com/nlohmann/json/issues/3001) +- 'operator =' is ambiguous on VS2017 [\#2997](https://github.com/nlohmann/json/issues/2997) +- JSON Patch for Array Elements [\#2994](https://github.com/nlohmann/json/issues/2994) +- JSON Parse throwing error [\#2983](https://github.com/nlohmann/json/issues/2983) +- to\_{binary format} does not provide a mechanism for specifying a custom allocator for the returned type. [\#2982](https://github.com/nlohmann/json/issues/2982) +- 3.10.1 zip json.hpp has version number 3.10.0 instead of 3.10.1 [\#2973](https://github.com/nlohmann/json/issues/2973) +- Assertion failure when serializing array with JSON\_DIAGNOSTICS set [\#2926](https://github.com/nlohmann/json/issues/2926) + +- Fix Clang version [\#3040](https://github.com/nlohmann/json/pull/3040) ([nlohmann](https://github.com/nlohmann)) +- Fix assertion failure for JSON\_DIAGNOSTICS [\#3037](https://github.com/nlohmann/json/pull/3037) ([carlsmedstad](https://github.com/carlsmedstad)) +- meta: fix is\_compatible/constructible traits [\#3020](https://github.com/nlohmann/json/pull/3020) ([theodelrieu](https://github.com/theodelrieu)) +- Set parent pointers for values inserted via update\(\) \(fixes \#3007\). [\#3008](https://github.com/nlohmann/json/pull/3008) ([AnthonyVH](https://github.com/AnthonyVH)) +- Allow allocators for output\_vector\_adapter [\#2989](https://github.com/nlohmann/json/pull/2989) ([nlohmann](https://github.com/nlohmann)) +- Re-add Clang 12 [\#2986](https://github.com/nlohmann/json/pull/2986) ([nlohmann](https://github.com/nlohmann)) +- Use new Docker image [\#2981](https://github.com/nlohmann/json/pull/2981) ([nlohmann](https://github.com/nlohmann)) +- Update docset generation script [\#2967](https://github.com/nlohmann/json/pull/2967) ([nlohmann](https://github.com/nlohmann)) + +## [v3.10.2](https://github.com/nlohmann/json/releases/tag/v3.10.2) (2021-08-26) + +[Full Changelog](https://github.com/nlohmann/json/compare/v3.10.1...v3.10.2) + +- Annoying -Wundef on new JSON\_DIAGNOSTICS macro [\#2975](https://github.com/nlohmann/json/issues/2975) +- += issue with multiple redirection. [\#2970](https://github.com/nlohmann/json/issues/2970) +- "incomplete type ‘nlohmann::detail::wide\_string\_input\_helper" compilation error [\#2969](https://github.com/nlohmann/json/issues/2969) + +- Fix -Wunused warnings on JSON\_DIAGNOSTICS [\#2976](https://github.com/nlohmann/json/pull/2976) ([gcerretani](https://github.com/gcerretani)) + +## [v3.10.1](https://github.com/nlohmann/json/releases/tag/v3.10.1) (2021-08-24) + +[Full Changelog](https://github.com/nlohmann/json/compare/v3.10.0...v3.10.1) + +- JSON\_DIAGNOSTICS assertion for ordered\_json [\#2962](https://github.com/nlohmann/json/issues/2962) +- Inserting in unordered json using a pointer retains the leading slash [\#2958](https://github.com/nlohmann/json/issues/2958) +- Test \#9: test-cbor test case sample.json fails in debug mode - Stack overflow [\#2955](https://github.com/nlohmann/json/issues/2955) +- 3.10.0 broke at least the Bear project [\#2953](https://github.com/nlohmann/json/issues/2953) +- 2 tests fail in 3.10.0: cmake\_fetch\_content\_configure, cmake\_fetch\_content\_build [\#2951](https://github.com/nlohmann/json/issues/2951) +- ctest \(58+60,/67 cmake\_import\_configure\) fails when build with -D JSON\_Install:BOOL=OFF because of missing nlohmann\_jsonTargets.cmake [\#2946](https://github.com/nlohmann/json/issues/2946) +- Document vcpkg usage [\#2944](https://github.com/nlohmann/json/issues/2944) +- Linker error LNK2005 when compiling \(x64\) json-3.10.0.zip with Visual Studio 2019 16.11.1 [\#2941](https://github.com/nlohmann/json/issues/2941) +- Move Travis jobs to travis-ci.com [\#2938](https://github.com/nlohmann/json/issues/2938) + +- Fixed typo in docs/api/basic\_json/parse.md [\#2968](https://github.com/nlohmann/json/pull/2968) ([mbadhan](https://github.com/mbadhan)) +- Add link to Homebrew package [\#2966](https://github.com/nlohmann/json/pull/2966) ([nlohmann](https://github.com/nlohmann)) +- Fix parent update for diagnostics with ordered\_json [\#2963](https://github.com/nlohmann/json/pull/2963) ([nlohmann](https://github.com/nlohmann)) +- Set stack size for some unit tests when using MSVC [\#2961](https://github.com/nlohmann/json/pull/2961) ([nlohmann](https://github.com/nlohmann)) +- Add regression test [\#2960](https://github.com/nlohmann/json/pull/2960) ([nlohmann](https://github.com/nlohmann)) +- Update Travis badge [\#2959](https://github.com/nlohmann/json/pull/2959) ([nlohmann](https://github.com/nlohmann)) +- Fix some extra ";" clang warnings [\#2957](https://github.com/nlohmann/json/pull/2957) ([Hallot](https://github.com/Hallot)) +- Add documentation for integration via vcpkg [\#2954](https://github.com/nlohmann/json/pull/2954) ([nlohmann](https://github.com/nlohmann)) +- Avoid duplicate AppVeyor builds [\#2952](https://github.com/nlohmann/json/pull/2952) ([nlohmann](https://github.com/nlohmann)) +- 🚨 fix gdb\_pretty\_printer failure on basic types [\#2950](https://github.com/nlohmann/json/pull/2950) ([senyai](https://github.com/senyai)) +- Add header to use value\_t [\#2948](https://github.com/nlohmann/json/pull/2948) ([nlohmann](https://github.com/nlohmann)) +- Skip some tests if JSON\_Install is not set [\#2947](https://github.com/nlohmann/json/pull/2947) ([nlohmann](https://github.com/nlohmann)) +- Remove outdated json\_unit test binary [\#2945](https://github.com/nlohmann/json/pull/2945) ([nlohmann](https://github.com/nlohmann)) +- Updating the Homebrew Command [\#2943](https://github.com/nlohmann/json/pull/2943) ([amirmasoudabdol](https://github.com/amirmasoudabdol)) + +## [v3.10.0](https://github.com/nlohmann/json/releases/tag/v3.10.0) (2021-08-17) + +[Full Changelog](https://github.com/nlohmann/json/compare/v3.9.1...v3.10.0) + +- Latest version 3.9.1 uses throw instead of JSON\_THROW in the amalgamated json.hpp file [\#2934](https://github.com/nlohmann/json/issues/2934) +- Copy to a variable inside a Structure [\#2933](https://github.com/nlohmann/json/issues/2933) +- warning C4068: unknown pragma 'GCC' on MSVC/cl [\#2924](https://github.com/nlohmann/json/issues/2924) +- Errors during ninja test [\#2918](https://github.com/nlohmann/json/issues/2918) +- compiler warning: "not return a value" [\#2917](https://github.com/nlohmann/json/issues/2917) +- Comparison floating points causes warning [\#2909](https://github.com/nlohmann/json/issues/2909) +- Why can't I have std::vector\ testList? [\#2900](https://github.com/nlohmann/json/issues/2900) +- \[json.hpp\] from releases doesnt work [\#2897](https://github.com/nlohmann/json/issues/2897) +- g++ \(11\) -Wuseless-cast gives lots of warnings [\#2893](https://github.com/nlohmann/json/issues/2893) +- Cannot serialize and immediatly deserialize json to/from bson [\#2892](https://github.com/nlohmann/json/issues/2892) +- Floating-point precision conversion error [\#2876](https://github.com/nlohmann/json/issues/2876) +- How to avoid escaping for an already escaped string in .dump\(\) [\#2870](https://github.com/nlohmann/json/issues/2870) +- can't parse std::vector\ [\#2869](https://github.com/nlohmann/json/issues/2869) +- ASAN detects memory leaks [\#2865](https://github.com/nlohmann/json/issues/2865) +- Binary subtype field cannot represent all CBOR tags [\#2863](https://github.com/nlohmann/json/issues/2863) +- string literals possibly being parsed as another type due to the presence of only digits and full-stops [\#2852](https://github.com/nlohmann/json/issues/2852) +- json::parse\(\) works only with absolute paths [\#2851](https://github.com/nlohmann/json/issues/2851) +- Compiler Warnings on Raspberry Pi OS [\#2850](https://github.com/nlohmann/json/issues/2850) +- Braced initialization and aggregate initialization behavior is different for `json::array()` function call. [\#2848](https://github.com/nlohmann/json/issues/2848) +- 3.9.1: test suite is failing [\#2845](https://github.com/nlohmann/json/issues/2845) +- Documentation for macro JSON\_NO\_IO is missing [\#2842](https://github.com/nlohmann/json/issues/2842) +- Assertion failure when inserting into arrays with JSON\_DIAGNOSTICS set [\#2838](https://github.com/nlohmann/json/issues/2838) +- HELP! There is a memory leak in the code?! [\#2837](https://github.com/nlohmann/json/issues/2837) +- Elegant conversion of a 2-D-json array to a standard C++ array [\#2805](https://github.com/nlohmann/json/issues/2805) +- Swift Package Manager support [\#2802](https://github.com/nlohmann/json/issues/2802) +- Referencing a subkey which doesn't exist gives crash [\#2797](https://github.com/nlohmann/json/issues/2797) +- Failed benchmark due to renamed branch [\#2796](https://github.com/nlohmann/json/issues/2796) +- Build Errors with VS 2019 and json Version 3.9.1 when attempting to replicate SAX Example [\#2782](https://github.com/nlohmann/json/issues/2782) +- Value with spaces cannot be parsed [\#2781](https://github.com/nlohmann/json/issues/2781) +- \[Question\] CBOR rfc support. [\#2779](https://github.com/nlohmann/json/issues/2779) +- Using JSON.hpp header file in Visual Studio 2013 \(C++ Project\) [\#2775](https://github.com/nlohmann/json/issues/2775) +- compilation error on clang-8 + C++17 [\#2759](https://github.com/nlohmann/json/issues/2759) +- Undefined symbol EOF [\#2755](https://github.com/nlohmann/json/issues/2755) +- Parsing a string into json object behaves differently under g++ and MinGW compilers. [\#2746](https://github.com/nlohmann/json/issues/2746) +- big git history size [\#2742](https://github.com/nlohmann/json/issues/2742) +- How to get reference of std::vector\ [\#2735](https://github.com/nlohmann/json/issues/2735) +- CMake failure in VS2019 Community [\#2734](https://github.com/nlohmann/json/issues/2734) +- Possibility to use with custom c++ version to use in intel sgx enclaves [\#2730](https://github.com/nlohmann/json/issues/2730) +- Possibility to use without the dependency to file io and streams to use in intel sgx enclaves [\#2728](https://github.com/nlohmann/json/issues/2728) +- error C2784& error C2839... in my visual studio 2015 compiler [\#2726](https://github.com/nlohmann/json/issues/2726) +- `-fno-expection` not respected anymore in 3.9.1 [\#2725](https://github.com/nlohmann/json/issues/2725) +- When exceptions disabled with JSON\_NOEXCEPTION, lib just aborts without any message [\#2724](https://github.com/nlohmann/json/issues/2724) +- Critical error detected c0000374 on windows10 msvc 2019 16.8.5 [\#2710](https://github.com/nlohmann/json/issues/2710) +- unused parameter error/warning [\#2706](https://github.com/nlohmann/json/issues/2706) +- How to store data into a Map from json file [\#2691](https://github.com/nlohmann/json/issues/2691) +- Tests do not compile with pre-release glibc [\#2686](https://github.com/nlohmann/json/issues/2686) +- compile errors .... chromium-style [\#2680](https://github.com/nlohmann/json/issues/2680) +- .dump\(\) not allowing compact form [\#2678](https://github.com/nlohmann/json/issues/2678) +- error: no matching function for call to ‘nlohmann::basic\_json\<\>::value\(int, std::set\&\)’ [\#2671](https://github.com/nlohmann/json/issues/2671) +- Compiler warning: unused parameter [\#2668](https://github.com/nlohmann/json/issues/2668) +- Deserializing to a struct as shown on the project homepage throws compile time errors [\#2665](https://github.com/nlohmann/json/issues/2665) +- Unable to compile on MSVC 2019 with SDL checking enabled: This function or variable may be unsafe [\#2664](https://github.com/nlohmann/json/issues/2664) +- terminating with uncaught exception of type nlohmann::detail::type\_error: \[json.exception.type\_error.302\] type must be array, but is object [\#2661](https://github.com/nlohmann/json/issues/2661) +- unused-parameter on OSX when Diagnostics is off [\#2658](https://github.com/nlohmann/json/issues/2658) +- std::pair wrong serialization [\#2655](https://github.com/nlohmann/json/issues/2655) +- The result of json is\_number\_integer\(\) function is wrong when read a json file [\#2653](https://github.com/nlohmann/json/issues/2653) +- 2 backslash cause problem [\#2652](https://github.com/nlohmann/json/issues/2652) +- No support for using an external/system copy of Hedley [\#2651](https://github.com/nlohmann/json/issues/2651) +- error: incomplete type 'qfloat16' used in type trait expression [\#2650](https://github.com/nlohmann/json/issues/2650) +- Unused variable in exception class when not using improved diagnostics [\#2646](https://github.com/nlohmann/json/issues/2646) +- I am trying to do this - converting from wstring works incorrectly! [\#2642](https://github.com/nlohmann/json/issues/2642) +- Exception 207 On ARM Processor During Literal String Parsing [\#2634](https://github.com/nlohmann/json/issues/2634) +- double free or corruption \(!prev\) error on Json push\_back and write [\#2632](https://github.com/nlohmann/json/issues/2632) +- nlohmann::detail::parse\_error: syntax error while parsing CBOR string: expected length specification \(0x60-0x7B\) or indefinite string type \(0x7F\) [\#2629](https://github.com/nlohmann/json/issues/2629) +- please allow disabling implicit conversions in non-single-file use [\#2621](https://github.com/nlohmann/json/issues/2621) +- Preserve decimal formatting [\#2618](https://github.com/nlohmann/json/issues/2618) +- Visual Studio Visual Assist code issues reported by VA code inspection of file json.hpp [\#2615](https://github.com/nlohmann/json/issues/2615) +- Missing get function and no viable overloaded '=' on mac [\#2610](https://github.com/nlohmann/json/issues/2610) +- corruption when parse from string [\#2603](https://github.com/nlohmann/json/issues/2603) +- Parse from byte-vector results in compile error [\#2602](https://github.com/nlohmann/json/issues/2602) +- Memory leak when working on ARM Linux [\#2601](https://github.com/nlohmann/json/issues/2601) +- Unhandled exception in test-cbor.exe Stack overflow when debugging project with Visual Studio 2019 16.7.7 compiled with c++17 or c++latest [\#2598](https://github.com/nlohmann/json/issues/2598) +- Error in download\_test\_data.vcxproj when compiling with Visual Studio 2019 16.7.7 Professional msbuild on Windows 10 2004 Professional [\#2594](https://github.com/nlohmann/json/issues/2594) +- Warnings C4715 and C4127 when building json-3.9.1 with Visual Studio 2019 16.7.7 [\#2592](https://github.com/nlohmann/json/issues/2592) +- I tried some change to dump\(\) for \[1,2,3...\] [\#2584](https://github.com/nlohmann/json/issues/2584) +- try/catch block does not catch parsing error [\#2579](https://github.com/nlohmann/json/issues/2579) +- Serializing uint64\_t is broken for large values [\#2578](https://github.com/nlohmann/json/issues/2578) +- deserializing arrays should be part of the library [\#2575](https://github.com/nlohmann/json/issues/2575) +- Deserialization to std::array with non-default constructable types fails [\#2574](https://github.com/nlohmann/json/issues/2574) +- Compilation error when trying to use same type for number\_integer\_t and number\_unsigned\_t in basic\_json template specification. [\#2573](https://github.com/nlohmann/json/issues/2573) +- compiler error: directive output may be truncated writing between 2 and 8 bytes [\#2572](https://github.com/nlohmann/json/issues/2572) +- Incorrect convert map to json when key cannot construct an string i.e. int [\#2564](https://github.com/nlohmann/json/issues/2564) +- no matching function for call to ‘nlohmann::basic\_json\<\>::basic\_json\(\\)’ [\#2559](https://github.com/nlohmann/json/issues/2559) +- type\_error factory creates a dangling pointer \(in VisualStudio 2019\) [\#2535](https://github.com/nlohmann/json/issues/2535) +- Cannot assign from ordered\_json vector\ to value in not ordered json [\#2528](https://github.com/nlohmann/json/issues/2528) +- Qt6: Break changes [\#2519](https://github.com/nlohmann/json/issues/2519) +- valgrind memcheck Illegal instruction when use nlohmann::json::parse [\#2518](https://github.com/nlohmann/json/issues/2518) +- Buffer overflow [\#2515](https://github.com/nlohmann/json/issues/2515) +- Including CTest in the top-level CMakeLists.txt sets BUILD\_TESTING=ON for parent projects [\#2513](https://github.com/nlohmann/json/issues/2513) +- Compilation error when using NLOHMANN\_JSON\_SERIALIZE\_ENUM ordered\_json on libc++ [\#2491](https://github.com/nlohmann/json/issues/2491) +- Missing "void insert\( InputIt first, InputIt last \);" overload in nlohmann::ordered\_map [\#2490](https://github.com/nlohmann/json/issues/2490) +- Could not find a package configuration file provided by "nlohmann\_json" [\#2482](https://github.com/nlohmann/json/issues/2482) +- json becomes empty for unknown reason [\#2470](https://github.com/nlohmann/json/issues/2470) +- Using std::wstring as StringType fails compiling [\#2459](https://github.com/nlohmann/json/issues/2459) +- Sample code in GIF slide outdated \(cannot use emplace\(\) with array\) [\#2457](https://github.com/nlohmann/json/issues/2457) +- from\_json\ is treated as an array on latest MSVC [\#2453](https://github.com/nlohmann/json/issues/2453) +- MemorySanitizer: use-of-uninitialized-value [\#2449](https://github.com/nlohmann/json/issues/2449) +- I need help [\#2441](https://github.com/nlohmann/json/issues/2441) +- type conversion failing with clang ext\_vector\_type [\#2436](https://github.com/nlohmann/json/issues/2436) +- json::parse\(\) can't be resolved under specific circumstances [\#2427](https://github.com/nlohmann/json/issues/2427) +- from\_\*\(ptr, len\) deprecation [\#2426](https://github.com/nlohmann/json/issues/2426) +- Error ONLY in release mode [\#2425](https://github.com/nlohmann/json/issues/2425) +- "Custom data source" exemple make no sense [\#2423](https://github.com/nlohmann/json/issues/2423) +- Refuses to compile in project [\#2419](https://github.com/nlohmann/json/issues/2419) +- Compilation failure of tests with C++20 standard \(caused by change of u8 literals\) [\#2413](https://github.com/nlohmann/json/issues/2413) +- No matching function for call to 'input\_adapter' under Xcode of with nlohmann version 3.9.1 [\#2412](https://github.com/nlohmann/json/issues/2412) +- Git tags are not valid semvers [\#2409](https://github.com/nlohmann/json/issues/2409) +- after dump, stderr output disappear [\#2403](https://github.com/nlohmann/json/issues/2403) +- Using custom string. [\#2398](https://github.com/nlohmann/json/issues/2398) +- value\(\) throws unhandled exception for partially specified json object [\#2393](https://github.com/nlohmann/json/issues/2393) +- assertion on runtime causes program to stop when accessing const json with missing key [\#2392](https://github.com/nlohmann/json/issues/2392) +- Usage with -fno-elide-constructors causes dump\(\) output to be array of `null`s [\#2387](https://github.com/nlohmann/json/issues/2387) +- Build fails with clang-cl due to override of CMAKE\_CXX\_COMPILER\(?\) [\#2384](https://github.com/nlohmann/json/issues/2384) +- std::optional not working with primitive types [\#2383](https://github.com/nlohmann/json/issues/2383) +- Unexpected array when initializing a json const& on gcc 4.8.5 using uniform syntax [\#2370](https://github.com/nlohmann/json/issues/2370) +- setprecision support [\#2362](https://github.com/nlohmann/json/issues/2362) +- json::parse\(allow\_exceptions = false\) documentation is misleading. [\#2360](https://github.com/nlohmann/json/issues/2360) +- std::begin and std::end usage without specifying std namespace [\#2359](https://github.com/nlohmann/json/issues/2359) +- Custom object conversion to json hangs in background thread [\#2358](https://github.com/nlohmann/json/issues/2358) +- Add support of nullable fields to NLOHMANN\_DEFINE\_TYPE\_NON\_INTRUSIVE and NLOHMANN\_DEFINE\_TYPE\_INTRUSIVE [\#2356](https://github.com/nlohmann/json/issues/2356) +- the portfile for the vcpkg is not working. [\#2351](https://github.com/nlohmann/json/issues/2351) +- Compiler warns of implicit fallthrough when defining preprocessor macro NDEBUG [\#2348](https://github.com/nlohmann/json/issues/2348) +- Compile error on Intel compiler running in Windows [\#2346](https://github.com/nlohmann/json/issues/2346) +- Build error caused by overwriting CMAKE\_CXX\_COMPILER [\#2343](https://github.com/nlohmann/json/issues/2343) +- Error: an attribute list cannot appear here JSON\_HEDLEY\_DEPRECATED\_FOR [\#2342](https://github.com/nlohmann/json/issues/2342) +- compiler warning [\#2341](https://github.com/nlohmann/json/issues/2341) +- 3.9.0: tests make build non-reproducible [\#2324](https://github.com/nlohmann/json/issues/2324) +- Initialization different between gcc/clang [\#2311](https://github.com/nlohmann/json/issues/2311) +- Attempt to `get()` a numeric value as a type which cannot represent it should throw [\#2310](https://github.com/nlohmann/json/issues/2310) +- Surprising behaviour with overloaded operators [\#2256](https://github.com/nlohmann/json/issues/2256) +- ADL issue in input\_adapter [\#2248](https://github.com/nlohmann/json/issues/2248) +- Output adapters should be templated. [\#2172](https://github.com/nlohmann/json/issues/2172) +- error when using nlohmann::json, std::function and std::bind [\#2147](https://github.com/nlohmann/json/issues/2147) +- Remove undefined behavior for const operator\[\] [\#2111](https://github.com/nlohmann/json/issues/2111) +- json\({}\) gives null instead of empty object with GCC and -std=c++17 [\#2046](https://github.com/nlohmann/json/issues/2046) +- GDB pretty printing support [\#1952](https://github.com/nlohmann/json/issues/1952) +- Always compile tests with all warnings enabled and error out on warnings [\#1798](https://github.com/nlohmann/json/issues/1798) +- Fixes Cppcheck warnings [\#1759](https://github.com/nlohmann/json/issues/1759) +- How to get position info or parser context with custom from\_json\(\) that may throw exceptions? [\#1508](https://github.com/nlohmann/json/issues/1508) +- Suggestion to improve value\(\) accessors with respect to move semantics [\#1275](https://github.com/nlohmann/json/issues/1275) +- Add Key name to Exception [\#932](https://github.com/nlohmann/json/issues/932) + +- Overwork warning flags [\#2936](https://github.com/nlohmann/json/pull/2936) ([nlohmann](https://github.com/nlohmann)) +- Treat MSVC warnings as errors [\#2930](https://github.com/nlohmann/json/pull/2930) ([nlohmann](https://github.com/nlohmann)) +- All: fix warnings when compiling with -Wswitch-enum [\#2927](https://github.com/nlohmann/json/pull/2927) ([fhuberts](https://github.com/fhuberts)) +- Guard GCC pragmas [\#2925](https://github.com/nlohmann/json/pull/2925) ([nlohmann](https://github.com/nlohmann)) +- Supress -Wfloat-equal on intended float comparisions [\#2911](https://github.com/nlohmann/json/pull/2911) ([Finkman](https://github.com/Finkman)) +- Fix binary subtypes [\#2908](https://github.com/nlohmann/json/pull/2908) ([nlohmann](https://github.com/nlohmann)) +- Fix useless-cast warnings [\#2902](https://github.com/nlohmann/json/pull/2902) ([nlohmann](https://github.com/nlohmann)) +- Add regression test [\#2898](https://github.com/nlohmann/json/pull/2898) ([nlohmann](https://github.com/nlohmann)) +- Refactor Unicode tests [\#2889](https://github.com/nlohmann/json/pull/2889) ([nlohmann](https://github.com/nlohmann)) +- CMake cleanup [\#2885](https://github.com/nlohmann/json/pull/2885) ([nlohmann](https://github.com/nlohmann)) +- Avoid string in case of empty CBOR objects [\#2879](https://github.com/nlohmann/json/pull/2879) ([nlohmann](https://github.com/nlohmann)) +- Suppress C4127 warning in unit-json\_pointer.cpp [\#2875](https://github.com/nlohmann/json/pull/2875) ([nlohmann](https://github.com/nlohmann)) +- Fix truncation warning [\#2874](https://github.com/nlohmann/json/pull/2874) ([nlohmann](https://github.com/nlohmann)) +- Fix memory leak in to\_json [\#2872](https://github.com/nlohmann/json/pull/2872) ([nlohmann](https://github.com/nlohmann)) +- Fix assertion failure in diagnostics [\#2866](https://github.com/nlohmann/json/pull/2866) ([nlohmann](https://github.com/nlohmann)) +- Update documentation [\#2861](https://github.com/nlohmann/json/pull/2861) ([nlohmann](https://github.com/nlohmann)) +- Consistency with `using` in README.md [\#2826](https://github.com/nlohmann/json/pull/2826) ([justanotheranonymoususer](https://github.com/justanotheranonymoususer)) +- Properly constrain the basic\_json conversion operator [\#2825](https://github.com/nlohmann/json/pull/2825) ([ldionne](https://github.com/ldionne)) +- Fix CI [\#2817](https://github.com/nlohmann/json/pull/2817) ([nlohmann](https://github.com/nlohmann)) +- Specified git branch for google benchmark fetch in benchmark test [\#2795](https://github.com/nlohmann/json/pull/2795) ([grafail](https://github.com/grafail)) +- Add C++ standards to macOS matrix [\#2790](https://github.com/nlohmann/json/pull/2790) ([nlohmann](https://github.com/nlohmann)) +- Update URLs to HTTPS [\#2789](https://github.com/nlohmann/json/pull/2789) ([TotalCaesar659](https://github.com/TotalCaesar659)) +- Link to Conan Center package added [\#2771](https://github.com/nlohmann/json/pull/2771) ([offa](https://github.com/offa)) +- Keep consistent formatting [\#2770](https://github.com/nlohmann/json/pull/2770) ([jasmcaus](https://github.com/jasmcaus)) +- Add a cmake option to use SYSTEM in target\_include\_directories [\#2762](https://github.com/nlohmann/json/pull/2762) ([jpl-mac](https://github.com/jpl-mac)) +- replace EOF with std::char\_traits\::eof\(\) [\#2756](https://github.com/nlohmann/json/pull/2756) ([nlohmann](https://github.com/nlohmann)) +- Fix typo in README [\#2754](https://github.com/nlohmann/json/pull/2754) ([mortenfyhn](https://github.com/mortenfyhn)) +- Update documentation [\#2749](https://github.com/nlohmann/json/pull/2749) ([nlohmann](https://github.com/nlohmann)) +- Add documentation for numbers [\#2747](https://github.com/nlohmann/json/pull/2747) ([nlohmann](https://github.com/nlohmann)) +- Use Clang 12 in CI [\#2737](https://github.com/nlohmann/json/pull/2737) ([nlohmann](https://github.com/nlohmann)) +- Fixes \#2730 [\#2731](https://github.com/nlohmann/json/pull/2731) ([theShmoo](https://github.com/theShmoo)) +- Possibility to use without the dependency to file io and streams to use in intel sgx enclaves [\#2729](https://github.com/nlohmann/json/pull/2729) ([theShmoo](https://github.com/theShmoo)) +- Update json.hpp [\#2707](https://github.com/nlohmann/json/pull/2707) ([raduteo](https://github.com/raduteo)) +- pkg-config.pc.in: Don't concatenate paths [\#2690](https://github.com/nlohmann/json/pull/2690) ([doronbehar](https://github.com/doronbehar)) +- add more CI steps [\#2689](https://github.com/nlohmann/json/pull/2689) ([nlohmann](https://github.com/nlohmann)) +- Update doctest from 2.4.4 to 2.4.6 \(fixes \#2686\) [\#2687](https://github.com/nlohmann/json/pull/2687) ([musicinmybrain](https://github.com/musicinmybrain)) +- License fix [\#2683](https://github.com/nlohmann/json/pull/2683) ([nlohmann](https://github.com/nlohmann)) +- Update parse\_exceptions.md - correct `json::exception::parse_error` [\#2679](https://github.com/nlohmann/json/pull/2679) ([frasermarlow](https://github.com/frasermarlow)) +- Remove HEDLEY annotation from exception::what\(\) [\#2673](https://github.com/nlohmann/json/pull/2673) ([remyjette](https://github.com/remyjette)) +- Fix amount of entries in the json object [\#2659](https://github.com/nlohmann/json/pull/2659) ([abbaswasim](https://github.com/abbaswasim)) +- Fix missing 1.78 in example in README.md [\#2625](https://github.com/nlohmann/json/pull/2625) ([wawiesel](https://github.com/wawiesel)) +- Add GDB pretty printer [\#2607](https://github.com/nlohmann/json/pull/2607) ([nlohmann](https://github.com/nlohmann)) +- readme: fix tilde character display [\#2582](https://github.com/nlohmann/json/pull/2582) ([bl-ue](https://github.com/bl-ue)) +- Add support for deserialization of STL containers of non-default constructable types \(fixes \#2574\). [\#2576](https://github.com/nlohmann/json/pull/2576) ([AnthonyVH](https://github.com/AnthonyVH)) +- Better diagnostics [\#2562](https://github.com/nlohmann/json/pull/2562) ([nlohmann](https://github.com/nlohmann)) +- CI targets [\#2561](https://github.com/nlohmann/json/pull/2561) ([nlohmann](https://github.com/nlohmann)) +- Add switch to skip non-reproducible tests. [\#2560](https://github.com/nlohmann/json/pull/2560) ([nlohmann](https://github.com/nlohmann)) +- Fix compilation of input\_adapter\(container\) in edge cases [\#2553](https://github.com/nlohmann/json/pull/2553) ([jasujm](https://github.com/jasujm)) +- Allow parsing from std::byte containers [\#2550](https://github.com/nlohmann/json/pull/2550) ([nlohmann](https://github.com/nlohmann)) +- Travis doesn't run any tests in C++17 mode [\#2540](https://github.com/nlohmann/json/pull/2540) ([karzhenkov](https://github.com/karzhenkov)) +- Doctest is updated to v2.4.3 [\#2538](https://github.com/nlohmann/json/pull/2538) ([YarikTH](https://github.com/YarikTH)) +- Fix warnings [\#2537](https://github.com/nlohmann/json/pull/2537) ([nlohmann](https://github.com/nlohmann)) +- Fix a shadowing warning [\#2536](https://github.com/nlohmann/json/pull/2536) ([nlohmann](https://github.com/nlohmann)) +- Clarify license of is\_complete\_type implementation [\#2534](https://github.com/nlohmann/json/pull/2534) ([nlohmann](https://github.com/nlohmann)) +- Do not unconditionally redefine C++14 constructs [\#2533](https://github.com/nlohmann/json/pull/2533) ([nlohmann](https://github.com/nlohmann)) +- Doctest is updated to v2.4.1 [\#2525](https://github.com/nlohmann/json/pull/2525) ([YarikTH](https://github.com/YarikTH)) +- Add MAIN\_PROJECT check for test and install options [\#2514](https://github.com/nlohmann/json/pull/2514) ([globberwops](https://github.com/globberwops)) +- Ranged insert test section is added in unit-ordered\_json.cpp [\#2512](https://github.com/nlohmann/json/pull/2512) ([YarikTH](https://github.com/YarikTH)) +- Add asserts to suppress C28020 [\#2447](https://github.com/nlohmann/json/pull/2447) ([jbzdarkid](https://github.com/jbzdarkid)) +- Change argument name "subtype" in byte\_container\_with\_subtype [\#2444](https://github.com/nlohmann/json/pull/2444) ([linev](https://github.com/linev)) +- 📠add CPM.Cmake example [\#2406](https://github.com/nlohmann/json/pull/2406) ([leozz37](https://github.com/leozz37)) +- Fix move constructor of json\_ref [\#2405](https://github.com/nlohmann/json/pull/2405) ([karzhenkov](https://github.com/karzhenkov)) +- Properly select "Release" build for Travis [\#2375](https://github.com/nlohmann/json/pull/2375) ([karzhenkov](https://github.com/karzhenkov)) +- Update Hedley [\#2367](https://github.com/nlohmann/json/pull/2367) ([nlohmann](https://github.com/nlohmann)) +- Fix and extend documentation of discarded values [\#2363](https://github.com/nlohmann/json/pull/2363) ([nlohmann](https://github.com/nlohmann)) +- Fix typos in documentation [\#2354](https://github.com/nlohmann/json/pull/2354) ([rbuch](https://github.com/rbuch)) +- Remove "\#define private public" from tests [\#2352](https://github.com/nlohmann/json/pull/2352) ([nlohmann](https://github.com/nlohmann)) +- Remove -Wimplicit-fallthrough warning [\#2349](https://github.com/nlohmann/json/pull/2349) ([nlohmann](https://github.com/nlohmann)) +- Fix code to work without exceptions [\#2347](https://github.com/nlohmann/json/pull/2347) ([nlohmann](https://github.com/nlohmann)) +- fix cmake script overwriting compiler path [\#2344](https://github.com/nlohmann/json/pull/2344) ([ongjunjie](https://github.com/ongjunjie)) + ## [v3.9.1](https://github.com/nlohmann/json/releases/tag/v3.9.1) (2020-08-06) [Full Changelog](https://github.com/nlohmann/json/compare/v3.9.0...v3.9.1) @@ -22,7 +613,6 @@ All notable changes to this project will be documented in this file. This projec - Fix a bug due to missing overloads in ordered\_map container [\#2319](https://github.com/nlohmann/json/pull/2319) ([nlohmann](https://github.com/nlohmann)) - cmake: install pkg-config file relative to current\_binary\_dir [\#2318](https://github.com/nlohmann/json/pull/2318) ([eli-schwartz](https://github.com/eli-schwartz)) - Fixed installation of pkg-config file on other than Ubuntu [\#2314](https://github.com/nlohmann/json/pull/2314) ([xvitaly](https://github.com/xvitaly)) -- Cleanup [\#2303](https://github.com/nlohmann/json/pull/2303) ([nlohmann](https://github.com/nlohmann)) ## [v3.9.0](https://github.com/nlohmann/json/releases/tag/v3.9.0) (2020-07-27) @@ -103,6 +693,7 @@ All notable changes to this project will be documented in this file. This projec - Fix bug in CBOR tag handling [\#2308](https://github.com/nlohmann/json/pull/2308) ([nlohmann](https://github.com/nlohmann)) - added inline to NLOHMANN\_DEFINE\_TYPE\_NON\_INTRUSIVE macro [\#2306](https://github.com/nlohmann/json/pull/2306) ([jwittbrodt](https://github.com/jwittbrodt)) - fixes unused variable 'ex' for \#2304 [\#2305](https://github.com/nlohmann/json/pull/2305) ([AODQ](https://github.com/AODQ)) +- Cleanup [\#2303](https://github.com/nlohmann/json/pull/2303) ([nlohmann](https://github.com/nlohmann)) - Add test with multiple translation units [\#2301](https://github.com/nlohmann/json/pull/2301) ([nlohmann](https://github.com/nlohmann)) - Merge GitHub actions [\#2300](https://github.com/nlohmann/json/pull/2300) ([nlohmann](https://github.com/nlohmann)) - Fix unused parameter [\#2299](https://github.com/nlohmann/json/pull/2299) ([nlohmann](https://github.com/nlohmann)) @@ -135,7 +726,7 @@ All notable changes to this project will be documented in this file. This projec - Use unsigned indizies for array index in json pointer [\#2203](https://github.com/nlohmann/json/pull/2203) ([t-b](https://github.com/t-b)) - Add option to not rely on Internet connectivity during test stage [\#2202](https://github.com/nlohmann/json/pull/2202) ([nlohmann](https://github.com/nlohmann)) - Serialize floating-point numbers with 32 bit when possible \(MessagePack\) [\#2201](https://github.com/nlohmann/json/pull/2201) ([nlohmann](https://github.com/nlohmann)) -- Fix consistency in function `int\_to\_string\(\)` [\#2193](https://github.com/nlohmann/json/pull/2193) ([dota17](https://github.com/dota17)) +- Fix consistency in function `int_to_string()` [\#2193](https://github.com/nlohmann/json/pull/2193) ([dota17](https://github.com/dota17)) - Fix issue\#1275 [\#2181](https://github.com/nlohmann/json/pull/2181) ([dota17](https://github.com/dota17)) - C++20 support by removing swap specialization [\#2176](https://github.com/nlohmann/json/pull/2176) ([gracicot](https://github.com/gracicot)) - Feat/explicit conversion operator [\#1559](https://github.com/nlohmann/json/pull/1559) ([theodelrieu](https://github.com/theodelrieu)) @@ -291,7 +882,6 @@ All notable changes to this project will be documented in this file. This projec - forced type conversion or lexical cast without exception. [\#1955](https://github.com/nlohmann/json/issues/1955) - Add json\_view type support to avoid excessive copying [\#1954](https://github.com/nlohmann/json/issues/1954) - Adding "examples" section for real-life usages [\#1953](https://github.com/nlohmann/json/issues/1953) -- GDB pretty printing support [\#1952](https://github.com/nlohmann/json/issues/1952) - Add nlohmann::json::key\_type [\#1951](https://github.com/nlohmann/json/issues/1951) - cannot use operator\[\] with a string argument with string [\#1949](https://github.com/nlohmann/json/issues/1949) - std::ifstream \>\> json error [\#1948](https://github.com/nlohmann/json/issues/1948) @@ -387,7 +977,7 @@ All notable changes to this project will be documented in this file. This projec - Serialize big data in json [\#1828](https://github.com/nlohmann/json/issues/1828) - Backslash '\' in value causes exception [\#1827](https://github.com/nlohmann/json/issues/1827) - from\_json for non default constructible class with dependency injection [\#1819](https://github.com/nlohmann/json/issues/1819) -- Semi-frequent timeouts in `test-unicode\_all` with 3.6.1 \(aarch64\) [\#1816](https://github.com/nlohmann/json/issues/1816) +- Semi-frequent timeouts in `test-unicode_all` with 3.6.1 \(aarch64\) [\#1816](https://github.com/nlohmann/json/issues/1816) - input\_adapter not user extensible [\#1813](https://github.com/nlohmann/json/issues/1813) - crash at json::destroy on android [\#1812](https://github.com/nlohmann/json/issues/1812) - Logs are repeating while cmake [\#1809](https://github.com/nlohmann/json/issues/1809) @@ -455,11 +1045,33 @@ All notable changes to this project will be documented in this file. This projec - Fix issue\#1719 [\#2044](https://github.com/nlohmann/json/pull/2044) ([dota17](https://github.com/dota17)) - Add missing testcase about NaN in unit-constructor1.cpp [\#2043](https://github.com/nlohmann/json/pull/2043) ([dota17](https://github.com/dota17)) - Templatize basic\_json constructor from json\_ref [\#2034](https://github.com/nlohmann/json/pull/2034) ([ArtemSarmini](https://github.com/ArtemSarmini)) +- Replace deprecated std::is\_pod [\#2033](https://github.com/nlohmann/json/pull/2033) ([nlohmann](https://github.com/nlohmann)) +- Fixes \#1971 \(memory leak in basic\_json::push\_back\) [\#2025](https://github.com/nlohmann/json/pull/2025) ([ArtemSarmini](https://github.com/ArtemSarmini)) - fix \#1982:json\_pointer.contains\(\) exception is incorrectly raised [\#2019](https://github.com/nlohmann/json/pull/2019) ([dota17](https://github.com/dota17)) +- Update LICENSE.MIT [\#2010](https://github.com/nlohmann/json/pull/2010) ([magamig](https://github.com/magamig)) +- PR for \#2006 to test in AppVeyor. [\#2008](https://github.com/nlohmann/json/pull/2008) ([garethsb](https://github.com/garethsb)) +- Added wsjcpp.yml [\#2004](https://github.com/nlohmann/json/pull/2004) ([sea-kg](https://github.com/sea-kg)) +- fix error 'setw' is not a member of 'std' in Wandbox example [\#2002](https://github.com/nlohmann/json/pull/2002) ([alexandermyasnikov](https://github.com/alexandermyasnikov)) - catch exceptions for json\_pointer : ..../+99 [\#1990](https://github.com/nlohmann/json/pull/1990) ([dota17](https://github.com/dota17)) +- Modify the document about operator== [\#1984](https://github.com/nlohmann/json/pull/1984) ([dota17](https://github.com/dota17)) +- Rename argument array\_index to array\_indx in json\_pointer methods [\#1980](https://github.com/nlohmann/json/pull/1980) ([linev](https://github.com/linev)) +- README: Fix string representation of `dump`ed `json` [\#1979](https://github.com/nlohmann/json/pull/1979) ([alexweej](https://github.com/alexweej)) - fix warnings in serializer.hpp for VS2019 [\#1969](https://github.com/nlohmann/json/pull/1969) ([dota17](https://github.com/dota17)) - Fix C26451 warnnings in to\_chars.hpp [\#1967](https://github.com/nlohmann/json/pull/1967) ([dota17](https://github.com/dota17)) +- appveyor.yml: Compile and test with latest version for \_\_cplusplus ma… [\#1958](https://github.com/nlohmann/json/pull/1958) ([t-b](https://github.com/t-b)) +- Fix typo in examples [\#1956](https://github.com/nlohmann/json/pull/1956) ([dota17](https://github.com/dota17)) - templated input adapters [\#1950](https://github.com/nlohmann/json/pull/1950) ([FrancoisChabot](https://github.com/FrancoisChabot)) +- Update README.md : add a FAQ about memory release [\#1933](https://github.com/nlohmann/json/pull/1933) ([dota17](https://github.com/dota17)) +- Some typos [\#1923](https://github.com/nlohmann/json/pull/1923) ([Coeur](https://github.com/Coeur)) +- Fix link to parse function in README [\#1918](https://github.com/nlohmann/json/pull/1918) ([kastiglione](https://github.com/kastiglione)) +- Readme: Updated links to hunter repo & docs [\#1917](https://github.com/nlohmann/json/pull/1917) ([jothepro](https://github.com/jothepro)) +- Adds instruction for using Build2's package manager [\#1909](https://github.com/nlohmann/json/pull/1909) ([Klaim](https://github.com/Klaim)) +- Update README.md [\#1907](https://github.com/nlohmann/json/pull/1907) ([pauljurczak](https://github.com/pauljurczak)) +- Fix warning: ignoring return value [\#1871](https://github.com/nlohmann/json/pull/1871) ([sonulohani](https://github.com/sonulohani)) +- docs: add central repository as conan source to readme [\#1857](https://github.com/nlohmann/json/pull/1857) ([gocarlos](https://github.com/gocarlos)) +- README: Package in MSYS2 renamed to nlohmann-json [\#1853](https://github.com/nlohmann/json/pull/1853) ([podsvirov](https://github.com/podsvirov)) +- Fix msvc warnings [\#1846](https://github.com/nlohmann/json/pull/1846) ([MBalszun](https://github.com/MBalszun)) +- Update tests that generate CMake projects to use main project's C++ compiler [\#1844](https://github.com/nlohmann/json/pull/1844) ([Tridacnid](https://github.com/Tridacnid)) - make CMake's version config file architecture-independent [\#1746](https://github.com/nlohmann/json/pull/1746) ([uhoreg](https://github.com/uhoreg)) - Add binary type support to all binary file formats, as well as an internally represented binary type [\#1662](https://github.com/nlohmann/json/pull/1662) ([OmnipotentEntity](https://github.com/OmnipotentEntity)) @@ -489,7 +1101,7 @@ All notable changes to this project will be documented in this file. This projec - Segmentation fault \(stack overflow\) due to unbounded recursion [\#1419](https://github.com/nlohmann/json/issues/1419) - Stack-overflow \(OSS-Fuzz 4234\) [\#832](https://github.com/nlohmann/json/issues/832) -- Configure WhiteSource Bolt for GitHub [\#1830](https://github.com/nlohmann/json/pull/1830) ([whitesource-bolt-for-github[bot]](https://github.com/apps/whitesource-bolt-for-github)) +- Configure WhiteSource Bolt for GitHub [\#1830](https://github.com/nlohmann/json/pull/1830) ([mend-bolt-for-github[bot]](https://github.com/apps/mend-bolt-for-github)) - Prevent stackoverflow caused by recursive deconstruction [\#1436](https://github.com/nlohmann/json/pull/1436) ([nickaein](https://github.com/nickaein)) ## [v3.7.1](https://github.com/nlohmann/json/releases/tag/v3.7.1) (2019-11-06) @@ -501,7 +1113,7 @@ All notable changes to this project will be documented in this file. This projec - json class should have a get\_or member function [\#1823](https://github.com/nlohmann/json/issues/1823) - NLOHMANN\_JSON\_SERIALIZE\_ENUM macro capture's json objects by value [\#1822](https://github.com/nlohmann/json/issues/1822) - Parse fails when number literals start with zero [\#1820](https://github.com/nlohmann/json/issues/1820) -- Weird behaviour of `contains` with `json\_pointer` [\#1815](https://github.com/nlohmann/json/issues/1815) +- Weird behaviour of `contains` with `json_pointer` [\#1815](https://github.com/nlohmann/json/issues/1815) - strange behaviour with json\_pointer and .contains\(\) [\#1811](https://github.com/nlohmann/json/issues/1811) - Can \#1695 be re-opened? [\#1808](https://github.com/nlohmann/json/issues/1808) - Merge two json objects [\#1807](https://github.com/nlohmann/json/issues/1807) @@ -534,7 +1146,7 @@ All notable changes to this project will be documented in this file. This projec - \[Nested Json Objects\] Segmentation fault [\#1753](https://github.com/nlohmann/json/issues/1753) - remove/replace assert with exceptions [\#1752](https://github.com/nlohmann/json/issues/1752) - Add array support for update\(\) function [\#1751](https://github.com/nlohmann/json/issues/1751) -- Is there a reason the `get\_to` method is defined in `include/nlohmann/json.hpp` but not in `single\_include/nlohmann/json.hpp`? [\#1750](https://github.com/nlohmann/json/issues/1750) +- Is there a reason the `get_to` method is defined in `include/nlohmann/json.hpp` but not in `single_include/nlohmann/json.hpp`? [\#1750](https://github.com/nlohmann/json/issues/1750) - how to validate json object before calling dump\(\) [\#1748](https://github.com/nlohmann/json/issues/1748) - Unable to invoke accessors on json objects in lldb [\#1745](https://github.com/nlohmann/json/issues/1745) - Escaping string before parsing [\#1743](https://github.com/nlohmann/json/issues/1743) @@ -580,7 +1192,6 @@ All notable changes to this project will be documented in this file. This projec - Information: My project uses this awesome library [\#1691](https://github.com/nlohmann/json/issues/1691) - Consider listing files explicitly instead of using GLOB [\#1686](https://github.com/nlohmann/json/issues/1686) - Failing tests on MSVC with VS2019 15.9.13 x64 [\#1685](https://github.com/nlohmann/json/issues/1685) -- Consider putting the user-defined literals in a namespace [\#1682](https://github.com/nlohmann/json/issues/1682) - Change from v2 to v3. Encoding with cp1252 [\#1680](https://github.com/nlohmann/json/issues/1680) - How to add Fifo\_map into json using Cmake [\#1679](https://github.com/nlohmann/json/issues/1679) - include.zip should contain meson.build [\#1672](https://github.com/nlohmann/json/issues/1672) @@ -690,7 +1301,7 @@ All notable changes to this project will be documented in this file. This projec - json::parse return value and errors [\#1595](https://github.com/nlohmann/json/issues/1595) - initializer list constructor makes curly brace initialization fragile [\#1594](https://github.com/nlohmann/json/issues/1594) - trying to log message for missing keyword, difference between \["foo"\] and at\("foo"\) [\#1593](https://github.com/nlohmann/json/issues/1593) -- std::string and std::wstring `to\_json` [\#1592](https://github.com/nlohmann/json/issues/1592) +- std::string and std::wstring `to_json` [\#1592](https://github.com/nlohmann/json/issues/1592) - I have a C structure which I need to convert to a JSON. How do I do it? Haven't found proper examples so far. [\#1591](https://github.com/nlohmann/json/issues/1591) - dump\_escaped possible error ? [\#1589](https://github.com/nlohmann/json/issues/1589) - json::parse\(\) into a vector\ results in unhandled exception [\#1587](https://github.com/nlohmann/json/issues/1587) @@ -732,20 +1343,17 @@ All notable changes to this project will be documented in this file. This projec - \[Help Needed!\] Season of Docs [\#1542](https://github.com/nlohmann/json/issues/1542) - program still abort\(\) or exit\(\) with try catch [\#1541](https://github.com/nlohmann/json/issues/1541) - Have a json::type\_error exception because of JSON object [\#1540](https://github.com/nlohmann/json/issues/1540) -- Using versioned namespaces [\#1539](https://github.com/nlohmann/json/issues/1539) - Quoted numbers [\#1538](https://github.com/nlohmann/json/issues/1538) - Reading a JSON file into an object [\#1537](https://github.com/nlohmann/json/issues/1537) - Releases 3.6.0 and 3.6.1 don't build on conda / windows [\#1536](https://github.com/nlohmann/json/issues/1536) - \[Clang\] warning: use of the 'nodiscard' attribute is a C++17 extension \[-Wc++17-extensions\] [\#1535](https://github.com/nlohmann/json/issues/1535) - wchar\_t/std::wstring json can be created but not accessed [\#1533](https://github.com/nlohmann/json/issues/1533) - json stringify [\#1532](https://github.com/nlohmann/json/issues/1532) -- How can I use std::string\_view as the json\_key to "operator \[\]" ? [\#1529](https://github.com/nlohmann/json/issues/1529) - How can I use it from gcc on RPI [\#1528](https://github.com/nlohmann/json/issues/1528) -- std::pair treated as an array instead of key-value in `std::vector\\>` [\#1520](https://github.com/nlohmann/json/issues/1520) +- std::pair treated as an array instead of key-value in `std::vector>` [\#1520](https://github.com/nlohmann/json/issues/1520) - Excessive Memory Usage for Large Json File [\#1516](https://github.com/nlohmann/json/issues/1516) - SAX dumper [\#1512](https://github.com/nlohmann/json/issues/1512) - Conversion to user type containing a std::vector not working with documented approach [\#1511](https://github.com/nlohmann/json/issues/1511) -- How to get position info or parser context with custom from\_json\(\) that may throw exceptions? [\#1508](https://github.com/nlohmann/json/issues/1508) - Inconsistent use of type alias. [\#1507](https://github.com/nlohmann/json/issues/1507) - Is there a current way to represent strings as json int? [\#1503](https://github.com/nlohmann/json/issues/1503) - Intermittent issues with loadJSON [\#1484](https://github.com/nlohmann/json/issues/1484) @@ -795,7 +1403,7 @@ All notable changes to this project will be documented in this file. This projec - Json object from string from a TCP socket [\#1504](https://github.com/nlohmann/json/issues/1504) - MSVC warning C4946 \("reinterpret\_cast used between related classes"\) compiling json.hpp [\#1502](https://github.com/nlohmann/json/issues/1502) - How to programmatically fill an n-th dimensional JSON object? [\#1501](https://github.com/nlohmann/json/issues/1501) -- Error compiling with clang and `JSON\_NOEXCEPTION`: need to include `cstdlib` [\#1500](https://github.com/nlohmann/json/issues/1500) +- Error compiling with clang and `JSON_NOEXCEPTION`: need to include `cstdlib` [\#1500](https://github.com/nlohmann/json/issues/1500) - The code compiles unsuccessfully with android-ndk-r10e [\#1499](https://github.com/nlohmann/json/issues/1499) - Cmake 3.1 in develop, when is it likely to make it into a stable release? [\#1498](https://github.com/nlohmann/json/issues/1498) - Some Help please object inside array [\#1494](https://github.com/nlohmann/json/issues/1494) @@ -814,7 +1422,7 @@ All notable changes to this project will be documented in this file. This projec - Unable to modify one of the values within the JSON file, and save it [\#1475](https://github.com/nlohmann/json/issues/1475) - Documentation of parse function has two identical @pre causes [\#1473](https://github.com/nlohmann/json/issues/1473) - GCC 9.0 build failure [\#1472](https://github.com/nlohmann/json/issues/1472) -- Can we have an `exists\(\)` method? [\#1471](https://github.com/nlohmann/json/issues/1471) +- Can we have an `exists()` method? [\#1471](https://github.com/nlohmann/json/issues/1471) - How to parse multi object json from file? [\#1470](https://github.com/nlohmann/json/issues/1470) - How to returns the name of the upper object? [\#1467](https://github.com/nlohmann/json/issues/1467) - Error: "tuple\_size" has already been declared in the current scope [\#1466](https://github.com/nlohmann/json/issues/1466) @@ -875,7 +1483,7 @@ All notable changes to this project will be documented in this file. This projec - Do proper endian conversions [\#1489](https://github.com/nlohmann/json/pull/1489) ([andreas-schwab](https://github.com/andreas-schwab)) - Fix documentation [\#1477](https://github.com/nlohmann/json/pull/1477) ([nickaein](https://github.com/nickaein)) - Implement contains\(\) member function [\#1474](https://github.com/nlohmann/json/pull/1474) ([nickaein](https://github.com/nickaein)) -- Add operator/= and operator/ to construct a JSON pointer by appending two JSON pointers [\#1469](https://github.com/nlohmann/json/pull/1469) ([garethsb-sony](https://github.com/garethsb-sony)) +- Add operator/= and operator/ to construct a JSON pointer by appending two JSON pointers [\#1469](https://github.com/nlohmann/json/pull/1469) ([garethsb](https://github.com/garethsb)) - Disable Clang -Wmismatched-tags warning on tuple\_size / tuple\_element [\#1468](https://github.com/nlohmann/json/pull/1468) ([past-due](https://github.com/past-due)) - Disable installation when used as meson subproject. \#1463 [\#1464](https://github.com/nlohmann/json/pull/1464) ([elvisoric](https://github.com/elvisoric)) - docs: README typo [\#1455](https://github.com/nlohmann/json/pull/1455) ([wythe](https://github.com/wythe)) @@ -892,7 +1500,6 @@ All notable changes to this project will be documented in this file. This projec - Fix x64 target platform for appveyor [\#1414](https://github.com/nlohmann/json/pull/1414) ([nickaein](https://github.com/nickaein)) - Improve dump\_integer performance [\#1411](https://github.com/nlohmann/json/pull/1411) ([nickaein](https://github.com/nickaein)) - buildsystem: relax requirement on cmake version [\#1409](https://github.com/nlohmann/json/pull/1409) ([yann-morin-1998](https://github.com/yann-morin-1998)) -- Added Support for Structured Bindings [\#1391](https://github.com/nlohmann/json/pull/1391) ([pratikpc](https://github.com/pratikpc)) - CMake: Optional Install if Embedded [\#1330](https://github.com/nlohmann/json/pull/1330) ([ax3l](https://github.com/ax3l)) ## [v3.5.0](https://github.com/nlohmann/json/releases/tag/v3.5.0) (2018-12-21) @@ -902,7 +1509,6 @@ All notable changes to this project will be documented in this file. This projec - Copyconstructor inserts original into array with single element [\#1397](https://github.com/nlohmann/json/issues/1397) - Get value without explicit typecasting [\#1395](https://github.com/nlohmann/json/issues/1395) - Big file parsing [\#1393](https://github.com/nlohmann/json/issues/1393) -- some static analysis warning at line 11317 [\#1390](https://github.com/nlohmann/json/issues/1390) - Adding Structured Binding Support [\#1388](https://github.com/nlohmann/json/issues/1388) - map\ exhibits unexpected behavior [\#1387](https://github.com/nlohmann/json/issues/1387) - Error Code Return [\#1386](https://github.com/nlohmann/json/issues/1386) @@ -962,6 +1568,7 @@ All notable changes to this project will be documented in this file. This projec - Check value for existence by json\_pointer [\#1194](https://github.com/nlohmann/json/issues/1194) - Feature/add file input adapter [\#1392](https://github.com/nlohmann/json/pull/1392) ([dumarjo](https://github.com/dumarjo)) +- Added Support for Structured Bindings [\#1391](https://github.com/nlohmann/json/pull/1391) ([pratikpc](https://github.com/pratikpc)) - Link to issue \#958 broken [\#1382](https://github.com/nlohmann/json/pull/1382) ([kjpus](https://github.com/kjpus)) - readme: fix typo [\#1380](https://github.com/nlohmann/json/pull/1380) ([manu-chroma](https://github.com/manu-chroma)) - recommend using explicit from JSON conversions [\#1363](https://github.com/nlohmann/json/pull/1363) ([theodelrieu](https://github.com/theodelrieu)) @@ -970,7 +1577,6 @@ All notable changes to this project will be documented in this file. This projec - Set eofbit on exhausted input stream. [\#1343](https://github.com/nlohmann/json/pull/1343) ([mefyl](https://github.com/mefyl)) - Add a SFINAE friendly iterator\_traits and use that instead. [\#1342](https://github.com/nlohmann/json/pull/1342) ([dgavedissian](https://github.com/dgavedissian)) - Fix EOL Whitespaces & CMake Spelling [\#1329](https://github.com/nlohmann/json/pull/1329) ([ax3l](https://github.com/ax3l)) -- Add BSON support [\#1320](https://github.com/nlohmann/json/pull/1320) ([nlohmann](https://github.com/nlohmann)) ## [v3.4.0](https://github.com/nlohmann/json/releases/tag/v3.4.0) (2018-10-30) @@ -1003,13 +1609,13 @@ All notable changes to this project will be documented in this file. This projec - syntax error on right json string [\#1276](https://github.com/nlohmann/json/issues/1276) - Parsing JSON Array where members have no key, using custom types [\#1267](https://github.com/nlohmann/json/issues/1267) - I get a json exception periodically from json::parse for the same json [\#1263](https://github.com/nlohmann/json/issues/1263) -- serialize std::variant\<...\> [\#1261](https://github.com/nlohmann/json/issues/1261) - GCC 8.2.1. Compilation error: invalid conversion from... [\#1246](https://github.com/nlohmann/json/issues/1246) - BSON support [\#1244](https://github.com/nlohmann/json/issues/1244) - enum to json mapping [\#1208](https://github.com/nlohmann/json/issues/1208) - Soften the landing when dumping non-UTF8 strings \(type\_error.316 exception\) [\#1198](https://github.com/nlohmann/json/issues/1198) - Add macro to define enum/JSON mapping [\#1323](https://github.com/nlohmann/json/pull/1323) ([nlohmann](https://github.com/nlohmann)) +- Add BSON support [\#1320](https://github.com/nlohmann/json/pull/1320) ([nlohmann](https://github.com/nlohmann)) - Properly convert constants to CharType [\#1315](https://github.com/nlohmann/json/pull/1315) ([nlohmann](https://github.com/nlohmann)) - Allow to set error handler for decoding errors [\#1314](https://github.com/nlohmann/json/pull/1314) ([nlohmann](https://github.com/nlohmann)) - Add Meson related info to README [\#1305](https://github.com/nlohmann/json/pull/1305) ([koponomarenko](https://github.com/koponomarenko)) @@ -1108,7 +1714,7 @@ All notable changes to this project will be documented in this file. This projec - Add key name when throwing type error [\#1189](https://github.com/nlohmann/json/issues/1189) - Not able to include in visual studio code? [\#1188](https://github.com/nlohmann/json/issues/1188) - Get an Index or row number of an element [\#1186](https://github.com/nlohmann/json/issues/1186) -- Difference between `merge\_patch` and `update` [\#1183](https://github.com/nlohmann/json/issues/1183) +- Difference between `merge_patch` and `update` [\#1183](https://github.com/nlohmann/json/issues/1183) - Is there a way to get an element from a JSON without throwing an exception on failure? [\#1182](https://github.com/nlohmann/json/issues/1182) - to\_string? [\#1181](https://github.com/nlohmann/json/issues/1181) - How to cache a json object's pointer into a map? [\#1180](https://github.com/nlohmann/json/issues/1180) @@ -1244,7 +1850,6 @@ All notable changes to this project will be documented in this file. This projec - How to create a json variable? [\#990](https://github.com/nlohmann/json/issues/990) - istream \>\> json --- 1st character skipped in stream [\#976](https://github.com/nlohmann/json/issues/976) - Add a SAX parser [\#971](https://github.com/nlohmann/json/issues/971) -- Add Key name to Exception [\#932](https://github.com/nlohmann/json/issues/932) - How to solve large json file? [\#927](https://github.com/nlohmann/json/issues/927) - json\_pointer public push\_back, pop\_back [\#837](https://github.com/nlohmann/json/issues/837) - Using input\_adapter in a slightly unexpected way [\#834](https://github.com/nlohmann/json/issues/834) @@ -1298,7 +1903,7 @@ All notable changes to this project will be documented in this file. This projec - "forcing MSVC stacktrace to show which T we're talking about." error [\#980](https://github.com/nlohmann/json/issues/980) - reverse order of serialization [\#979](https://github.com/nlohmann/json/issues/979) - Assigning between different json types [\#977](https://github.com/nlohmann/json/issues/977) -- Support serialisation of `unique\_ptr\<\>` and `shared\_ptr\<\>` [\#975](https://github.com/nlohmann/json/issues/975) +- Support serialisation of `unique_ptr<>` and `shared_ptr<>` [\#975](https://github.com/nlohmann/json/issues/975) - Unexpected end of input \(not same as one before\) [\#974](https://github.com/nlohmann/json/issues/974) - Segfault on direct initializing json object [\#973](https://github.com/nlohmann/json/issues/973) - Segmentation fault on G++ when trying to assign json string literal to custom json type. [\#972](https://github.com/nlohmann/json/issues/972) @@ -1521,7 +2126,6 @@ All notable changes to this project will be documented in this file. This projec - Compilation error with unordered\_map\< int, int \> [\#758](https://github.com/nlohmann/json/issues/758) - CBOR string [\#757](https://github.com/nlohmann/json/issues/757) - Proposal: out\_of\_range should be a subclass of std::out\_of\_range [\#756](https://github.com/nlohmann/json/issues/756) -- Compiling with icpc [\#755](https://github.com/nlohmann/json/issues/755) - Getter is setting the value to null if the key does not exist [\#754](https://github.com/nlohmann/json/issues/754) - parsing works sometimes and crashes others [\#752](https://github.com/nlohmann/json/issues/752) - Static\_assert failed "incompatible pointer type" with Xcode [\#751](https://github.com/nlohmann/json/issues/751) @@ -1597,7 +2201,7 @@ All notable changes to this project will be documented in this file. This projec - Compilation "note" on GCC 6 ARM [\#658](https://github.com/nlohmann/json/issues/658) - Adding additional push\_back/operator+= rvalue overloads for JSON object [\#657](https://github.com/nlohmann/json/issues/657) - dump's parameter "ensure\_ascii" creates too long sequences [\#656](https://github.com/nlohmann/json/issues/656) -- Question: parsing `void \*` [\#655](https://github.com/nlohmann/json/issues/655) +- Question: parsing `void *` [\#655](https://github.com/nlohmann/json/issues/655) - how should I check a string is valid JSON string ? [\#653](https://github.com/nlohmann/json/issues/653) - Question: thread safety of read only accesses [\#651](https://github.com/nlohmann/json/issues/651) - Eclipse: Method 'size' could not be resolved [\#649](https://github.com/nlohmann/json/issues/649) @@ -1626,7 +2230,7 @@ All notable changes to this project will be documented in this file. This projec - Insertion into nested json field [\#621](https://github.com/nlohmann/json/issues/621) - Question: return static json object from function [\#618](https://github.com/nlohmann/json/issues/618) - icc16 error [\#617](https://github.com/nlohmann/json/issues/617) -- \[-Wdeprecated-declarations\] in row `j \>\> ss;` in file `json.hpp:7405:26` and FAILED unit tests with MinGWx64! [\#616](https://github.com/nlohmann/json/issues/616) +- \[-Wdeprecated-declarations\] in row `j >> ss;` in file `json.hpp:7405:26` and FAILED unit tests with MinGWx64! [\#616](https://github.com/nlohmann/json/issues/616) - to\_json for pairs, tuples [\#614](https://github.com/nlohmann/json/issues/614) - Using uninitialized memory 'buf' in line 11173 v2.1.1? [\#613](https://github.com/nlohmann/json/issues/613) - How to parse multiple same Keys of JSON and save them? [\#612](https://github.com/nlohmann/json/issues/612) @@ -1686,7 +2290,7 @@ All notable changes to this project will be documented in this file. This projec - Duplicate symbols error happens while to\_json/from\_json method implemented inside entity definition header file [\#542](https://github.com/nlohmann/json/issues/542) - consider adding a bool json::is\_valid\(std::string const&\) non-member function [\#541](https://github.com/nlohmann/json/issues/541) - Help request [\#539](https://github.com/nlohmann/json/issues/539) -- How to deal with missing keys in `from\_json`? [\#538](https://github.com/nlohmann/json/issues/538) +- How to deal with missing keys in `from_json`? [\#538](https://github.com/nlohmann/json/issues/538) - recursive from\_msgpack implementation will stack overflow [\#537](https://github.com/nlohmann/json/issues/537) - Exception objects must be nothrow copy constructible \(ERR60-CPP\) [\#531](https://github.com/nlohmann/json/issues/531) - Support for multiple root elements [\#529](https://github.com/nlohmann/json/issues/529) @@ -1792,6 +2396,35 @@ All notable changes to this project will be documented in this file. This projec - Digraph warning [\#679](https://github.com/nlohmann/json/pull/679) ([traits](https://github.com/traits)) - massage -\> message [\#678](https://github.com/nlohmann/json/pull/678) ([DmitryKuk](https://github.com/DmitryKuk)) - Fix "not constraint" grammar in docs [\#674](https://github.com/nlohmann/json/pull/674) ([wincent](https://github.com/wincent)) +- Add documentation for integration with CMake and hunter [\#671](https://github.com/nlohmann/json/pull/671) ([dan-42](https://github.com/dan-42)) +- REFACTOR: rewrite CMakeLists.txt for better inlcude and reuse [\#669](https://github.com/nlohmann/json/pull/669) ([dan-42](https://github.com/dan-42)) +- enable\_testing only if the JSON\_BuildTests is ON [\#666](https://github.com/nlohmann/json/pull/666) ([effolkronium](https://github.com/effolkronium)) +- Support moving from rvalues in std::initializer\_list [\#663](https://github.com/nlohmann/json/pull/663) ([himikof](https://github.com/himikof)) +- add ensure\_ascii parameter to dump. \#330 [\#654](https://github.com/nlohmann/json/pull/654) ([ryanjmulder](https://github.com/ryanjmulder)) +- Rename BuildTests to JSON\_BuildTests [\#652](https://github.com/nlohmann/json/pull/652) ([olegendo](https://github.com/olegendo)) +- Don't include \, use std::make\_shared [\#650](https://github.com/nlohmann/json/pull/650) ([olegendo](https://github.com/olegendo)) +- Refacto/split basic json [\#643](https://github.com/nlohmann/json/pull/643) ([theodelrieu](https://github.com/theodelrieu)) +- fix typo in operator\_\_notequal example [\#630](https://github.com/nlohmann/json/pull/630) ([Chocobo1](https://github.com/Chocobo1)) +- Fix MSVC warning C4819 [\#629](https://github.com/nlohmann/json/pull/629) ([Chocobo1](https://github.com/Chocobo1)) +- \[BugFix\] Add parentheses around std::min [\#626](https://github.com/nlohmann/json/pull/626) ([koemeet](https://github.com/koemeet)) +- add pair/tuple conversions [\#624](https://github.com/nlohmann/json/pull/624) ([theodelrieu](https://github.com/theodelrieu)) +- remove std::pair support [\#615](https://github.com/nlohmann/json/pull/615) ([theodelrieu](https://github.com/theodelrieu)) +- Add pair support, fix CompatibleObject conversions \(fixes \#600\) [\#609](https://github.com/nlohmann/json/pull/609) ([theodelrieu](https://github.com/theodelrieu)) +- \#550 Fix iterator related compiling issues for Intel icc [\#598](https://github.com/nlohmann/json/pull/598) ([HenryRLee](https://github.com/HenryRLee)) +- Issue \#593 Fix the arithmetic operators in the iterator and reverse iterator [\#595](https://github.com/nlohmann/json/pull/595) ([HenryRLee](https://github.com/HenryRLee)) +- fix doxygen error of basic\_json::get\(\) [\#583](https://github.com/nlohmann/json/pull/583) ([zhaohuaxishi](https://github.com/zhaohuaxishi)) +- Fixing assignement for iterator wrapper second, and adding unit test [\#579](https://github.com/nlohmann/json/pull/579) ([Type1J](https://github.com/Type1J)) +- Adding first and second properties to iteration\_proxy\_internal [\#578](https://github.com/nlohmann/json/pull/578) ([Type1J](https://github.com/Type1J)) +- Adding support for Meson. [\#576](https://github.com/nlohmann/json/pull/576) ([Type1J](https://github.com/Type1J)) +- add enum class default conversions [\#545](https://github.com/nlohmann/json/pull/545) ([theodelrieu](https://github.com/theodelrieu)) +- Properly pop diagnostics [\#540](https://github.com/nlohmann/json/pull/540) ([tinloaf](https://github.com/tinloaf)) +- Add Visual Studio 17 image to appveyor build matrix [\#536](https://github.com/nlohmann/json/pull/536) ([vpetrigo](https://github.com/vpetrigo)) +- UTF8 encoding enhancement [\#534](https://github.com/nlohmann/json/pull/534) ([TedLyngmo](https://github.com/TedLyngmo)) +- Fix typo [\#530](https://github.com/nlohmann/json/pull/530) ([berkus](https://github.com/berkus)) +- Make exception base class visible in basic\_json [\#526](https://github.com/nlohmann/json/pull/526) ([ghost](https://github.com/ghost)) +- :art: Namespace `uint8_t` from the C++ stdlib [\#510](https://github.com/nlohmann/json/pull/510) ([alexweej](https://github.com/alexweej)) +- add to\_json method for C arrays [\#508](https://github.com/nlohmann/json/pull/508) ([theodelrieu](https://github.com/theodelrieu)) +- Fix -Weffc++ warnings \(GNU 6.3.1\) [\#496](https://github.com/nlohmann/json/pull/496) ([TedLyngmo](https://github.com/TedLyngmo)) ## [v2.1.1](https://github.com/nlohmann/json/releases/tag/v2.1.1) (2017-02-25) @@ -1997,7 +2630,6 @@ All notable changes to this project will be documented in this file. This projec - Fix usage examples' comments for std::multiset [\#321](https://github.com/nlohmann/json/pull/321) ([vasild](https://github.com/vasild)) - Include dir relocation [\#318](https://github.com/nlohmann/json/pull/318) ([ChristophJud](https://github.com/ChristophJud)) - trivial documentation fix [\#313](https://github.com/nlohmann/json/pull/313) ([5tefan](https://github.com/5tefan)) -- unit-constructor1.cpp: Fix floating point truncation warning [\#300](https://github.com/nlohmann/json/pull/300) ([t-b](https://github.com/t-b)) ## [v2.0.5](https://github.com/nlohmann/json/releases/tag/v2.0.5) (2016-09-14) @@ -2030,6 +2662,8 @@ All notable changes to this project will be documented in this file. This projec - Incorrect parsing of large int64\_t numbers [\#287](https://github.com/nlohmann/json/issues/287) - \[question\]: macro to disable floating point support [\#284](https://github.com/nlohmann/json/issues/284) +- unit-constructor1.cpp: Fix floating point truncation warning [\#300](https://github.com/nlohmann/json/pull/300) ([t-b](https://github.com/t-b)) + ## [v2.0.2](https://github.com/nlohmann/json/releases/tag/v2.0.2) (2016-07-31) [Full Changelog](https://github.com/nlohmann/json/compare/v2.0.1...v2.0.2) @@ -2106,6 +2740,7 @@ All notable changes to this project will be documented in this file. This projec - What is within scope? [\#192](https://github.com/nlohmann/json/issues/192) - Bugs in miloyip/nativejson-benchmark: roundtrips [\#187](https://github.com/nlohmann/json/issues/187) - Floating point exceptions [\#181](https://github.com/nlohmann/json/issues/181) +- Integer conversion to unsigned [\#178](https://github.com/nlohmann/json/issues/178) - map string string fails to compile [\#176](https://github.com/nlohmann/json/issues/176) - In basic\_json::basic\_json\(const CompatibleArrayType& val\), the requirement of CompatibleArrayType is not strict enough. [\#174](https://github.com/nlohmann/json/issues/174) - Provide a FAQ [\#163](https://github.com/nlohmann/json/issues/163) @@ -2124,6 +2759,7 @@ All notable changes to this project will be documented in this file. This projec - fixed noexcept; added constexpr [\#208](https://github.com/nlohmann/json/pull/208) ([nlohmann](https://github.com/nlohmann)) - Add support for afl-fuzz testing [\#207](https://github.com/nlohmann/json/pull/207) ([mykter](https://github.com/mykter)) - replaced ssize\_t occurrences with auto \(addresses \#204\) [\#205](https://github.com/nlohmann/json/pull/205) ([nlohmann](https://github.com/nlohmann)) +- Fixed issue \#199 - Small bugs in json.hpp \(get\_number\) and unit.cpp \(non-standard integer type test\) [\#200](https://github.com/nlohmann/json/pull/200) ([twelsby](https://github.com/twelsby)) - Fix broken link [\#197](https://github.com/nlohmann/json/pull/197) ([vog](https://github.com/vog)) - Issue \#195 - update Travis to Trusty due to gcc/clang strtod\(\) bug [\#196](https://github.com/nlohmann/json/pull/196) ([twelsby](https://github.com/twelsby)) - Issue \#178 - Extending support to full uint64\_t/int64\_t range and unsigned type \(updated\) [\#193](https://github.com/nlohmann/json/pull/193) ([twelsby](https://github.com/twelsby)) @@ -2137,7 +2773,6 @@ All notable changes to this project will be documented in this file. This projec - Floating point equality [\#185](https://github.com/nlohmann/json/issues/185) - Unused variables in catch [\#180](https://github.com/nlohmann/json/issues/180) - Typo in documentation [\#179](https://github.com/nlohmann/json/issues/179) -- Integer conversion to unsigned [\#178](https://github.com/nlohmann/json/issues/178) - JSON performance benchmark comparision [\#177](https://github.com/nlohmann/json/issues/177) - Since re2c is often ignored in pull requests, it may make sense to make a contributing.md file [\#175](https://github.com/nlohmann/json/issues/175) - Question about exceptions [\#173](https://github.com/nlohmann/json/issues/173) @@ -2151,11 +2786,11 @@ All notable changes to this project will be documented in this file. This projec - range based for loop for objects [\#83](https://github.com/nlohmann/json/issues/83) - Consider submitting this to the Boost Library Incubator [\#66](https://github.com/nlohmann/json/issues/66) -- Fixed issue \#199 - Small bugs in json.hpp \(get\_number\) and unit.cpp \(non-standard integer type test\) [\#200](https://github.com/nlohmann/json/pull/200) ([twelsby](https://github.com/twelsby)) - Fixed Issue \#186 - add strto\(f|d|ld\) overload wrappers, "-0.0" special case and FP trailing zero [\#191](https://github.com/nlohmann/json/pull/191) ([twelsby](https://github.com/twelsby)) - Issue \#185 - remove approx\(\) and use \#pragma to kill warnings [\#190](https://github.com/nlohmann/json/pull/190) ([twelsby](https://github.com/twelsby)) - Fixed Issue \#171 - added two extra template overloads of operator\[\] for T\* arguments [\#189](https://github.com/nlohmann/json/pull/189) ([twelsby](https://github.com/twelsby)) - Fixed issue \#167 - removed operator ValueType\(\) condition for VS2015 [\#188](https://github.com/nlohmann/json/pull/188) ([twelsby](https://github.com/twelsby)) +- Implementation of get\_ref\(\) [\#184](https://github.com/nlohmann/json/pull/184) ([dariomt](https://github.com/dariomt)) - Fixed some typos in CONTRIBUTING.md [\#182](https://github.com/nlohmann/json/pull/182) ([nibroc](https://github.com/nibroc)) ## [v1.0.0](https://github.com/nlohmann/json/releases/tag/v1.0.0) (2015-12-27) @@ -2165,7 +2800,7 @@ All notable changes to this project will be documented in this file. This projec - add key name to exception [\#160](https://github.com/nlohmann/json/issues/160) - Getting member discarding qualifyer [\#159](https://github.com/nlohmann/json/issues/159) - basic\_json::iterator::value\(\) output includes quotes while basic\_json::iterator::key\(\) doesn't [\#158](https://github.com/nlohmann/json/issues/158) -- Indexing `const basic\_json\<\>` with `const basic\_string\` [\#157](https://github.com/nlohmann/json/issues/157) +- Indexing `const basic_json<>` with `const basic_string` [\#157](https://github.com/nlohmann/json/issues/157) - token\_type\_name\(token\_type t\): not all control paths return a value [\#156](https://github.com/nlohmann/json/issues/156) - prevent json.hpp from emitting compiler warnings [\#154](https://github.com/nlohmann/json/issues/154) - json::parse\(string\) does not check utf8 bom [\#152](https://github.com/nlohmann/json/issues/152) @@ -2197,7 +2832,6 @@ All notable changes to this project will be documented in this file. This projec - Wishlist [\#65](https://github.com/nlohmann/json/issues/65) - Windows/Visual Studio \(through 2013\) is unsupported [\#62](https://github.com/nlohmann/json/issues/62) -- Implementation of get\_ref\(\) [\#184](https://github.com/nlohmann/json/pull/184) ([dariomt](https://github.com/dariomt)) - Replace sprintf with hex function, this fixes \#149 [\#153](https://github.com/nlohmann/json/pull/153) ([whackashoe](https://github.com/whackashoe)) - Fix character skipping after a surrogate pair [\#146](https://github.com/nlohmann/json/pull/146) ([robertmrk](https://github.com/robertmrk)) - Detect correctly pointer-to-const [\#137](https://github.com/nlohmann/json/pull/137) ([dariomt](https://github.com/dariomt)) @@ -2284,13 +2918,25 @@ All notable changes to this project will be documented in this file. This projec - Remove useless typename [\#86](https://github.com/nlohmann/json/pull/86) ([ahamez](https://github.com/ahamez)) - Avoid warning with Xcode's clang [\#85](https://github.com/nlohmann/json/pull/85) ([ahamez](https://github.com/ahamez)) - Fix typos [\#73](https://github.com/nlohmann/json/pull/73) ([aqnouch](https://github.com/aqnouch)) -- Replace `default\_callback` function with `nullptr` and check for null… [\#72](https://github.com/nlohmann/json/pull/72) ([aburgh](https://github.com/aburgh)) +- Replace `default_callback` function with `nullptr` and check for null… [\#72](https://github.com/nlohmann/json/pull/72) ([aburgh](https://github.com/aburgh)) - support enum [\#71](https://github.com/nlohmann/json/pull/71) ([likebeta](https://github.com/likebeta)) - Fix performance regression introduced with the parsing callback feature. [\#69](https://github.com/nlohmann/json/pull/69) ([aburgh](https://github.com/aburgh)) - Improve the implementations of the comparission-operators [\#63](https://github.com/nlohmann/json/pull/63) ([Florianjw](https://github.com/Florianjw)) - Fix compilation of json\_unit with GCC 5 [\#59](https://github.com/nlohmann/json/pull/59) ([dkopecek](https://github.com/dkopecek)) - Parse streams incrementally. [\#40](https://github.com/nlohmann/json/pull/40) ([aburgh](https://github.com/aburgh)) - Feature/small float serialization [\#38](https://github.com/nlohmann/json/pull/38) ([jrandall](https://github.com/jrandall)) +- template version with re2c scanner [\#36](https://github.com/nlohmann/json/pull/36) ([nlohmann](https://github.com/nlohmann)) +- more descriptive documentation in example [\#33](https://github.com/nlohmann/json/pull/33) ([luxe](https://github.com/luxe)) +- Fix string conversion under Clang [\#26](https://github.com/nlohmann/json/pull/26) ([wancw](https://github.com/wancw)) +- Fixed dumping of strings [\#24](https://github.com/nlohmann/json/pull/24) ([Teemperor](https://github.com/Teemperor)) +- Added a remark to the readme that coverage is GCC only for now [\#23](https://github.com/nlohmann/json/pull/23) ([Teemperor](https://github.com/Teemperor)) +- Unicode escaping [\#22](https://github.com/nlohmann/json/pull/22) ([Teemperor](https://github.com/Teemperor)) +- Implemented the JSON spec for string parsing for everything but the \uXXXX escaping [\#21](https://github.com/nlohmann/json/pull/21) ([Teemperor](https://github.com/Teemperor)) +- add the std iterator typedefs to iterator and const\_iterator [\#19](https://github.com/nlohmann/json/pull/19) ([kirkshoop](https://github.com/kirkshoop)) +- Fixed escaped quotes [\#18](https://github.com/nlohmann/json/pull/18) ([Teemperor](https://github.com/Teemperor)) +- Fix double delete on std::bad\_alloc exception [\#14](https://github.com/nlohmann/json/pull/14) ([elliotgoodrich](https://github.com/elliotgoodrich)) +- Added CMake and lcov [\#6](https://github.com/nlohmann/json/pull/6) ([Teemperor](https://github.com/Teemperor)) +- Version 2.0 [\#5](https://github.com/nlohmann/json/pull/5) ([nlohmann](https://github.com/nlohmann)) diff --git a/external_imported/json/LICENSE.MIT b/external_imported/json/LICENSE.MIT index f0622d6dc..1c1f7a690 100644 --- a/external_imported/json/LICENSE.MIT +++ b/external_imported/json/LICENSE.MIT @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2013-2021 Niels Lohmann +Copyright (c) 2013-2022 Niels Lohmann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/external_imported/json/LICENSES/Apache-2.0.txt b/external_imported/json/LICENSES/Apache-2.0.txt new file mode 100644 index 000000000..137069b82 --- /dev/null +++ b/external_imported/json/LICENSES/Apache-2.0.txt @@ -0,0 +1,73 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + + (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + + You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + +To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/external_imported/json/LICENSES/BSD-3-Clause.txt b/external_imported/json/LICENSES/BSD-3-Clause.txt new file mode 100644 index 000000000..ea890afbc --- /dev/null +++ b/external_imported/json/LICENSES/BSD-3-Clause.txt @@ -0,0 +1,11 @@ +Copyright (c) . + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/external_imported/json/LICENSES/GPL-3.0-only.txt b/external_imported/json/LICENSES/GPL-3.0-only.txt new file mode 100644 index 000000000..d41c0bd98 --- /dev/null +++ b/external_imported/json/LICENSES/GPL-3.0-only.txt @@ -0,0 +1,232 @@ +GNU GENERAL PUBLIC LICENSE +Version 3, 29 June 2007 + +Copyright © 2007 Free Software Foundation, Inc. + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +Preamble + +The GNU General Public License is a free, copyleft license for software and other kinds of works. + +The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. + +Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. + +Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and modification follow. + +TERMS AND CONDITIONS + +0. Definitions. + +“This License†refers to version 3 of the GNU General Public License. + +“Copyright†also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. + +“The Program†refers to any copyrightable work licensed under this License. Each licensee is addressed as “youâ€. “Licensees†and “recipients†may be individuals or organizations. + +To “modify†a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version†of the earlier work or a work “based on†the earlier work. + +A “covered work†means either the unmodified Program or a work based on the Program. + +To “propagate†a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. + +To “convey†a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. + +An interactive user interface displays “Appropriate Legal Notices†to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. + +1. Source Code. +The “source code†for a work means the preferred form of the work for making modifications to it. “Object code†means any non-source form of a work. + +A “Standard Interface†means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. + +The “System Libraries†of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Componentâ€, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. + +The “Corresponding Source†for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same work. + +2. Basic Permissions. +All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. + +3. Protecting Users' Legal Rights From Anti-Circumvention Law. +No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. + +When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. + +4. Conveying Verbatim Copies. +You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. + +5. Conveying Modified Source Versions. +You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all noticesâ€. + + c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. + +A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate†if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. + +6. Conveying Non-Source Forms. +You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: + + a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. + + d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. + +A “User Product†is either (1) a “consumer productâ€, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used†refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. + +“Installation Information†for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. + +If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). + +The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. + +7. Additional Terms. +“Additional permissions†are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or authors of the material; or + + e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. + +All other non-permissive additional terms are considered “further restrictions†within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. + +8. Termination. +You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). + +However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. + +Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. + +Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. + +9. Acceptance Not Required for Having Copies. +You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. + +10. Automatic Licensing of Downstream Recipients. +Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. + +An “entity transaction†is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. + +11. Patents. +A “contributor†is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor versionâ€. + +A contributor's “essential patent claims†are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control†includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. + +In the following three paragraphs, a “patent license†is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant†such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. + +If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying†means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. + +A patent license is “discriminatory†if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. + +12. No Surrender of Others' Freedom. +If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. + +13. Use with the GNU Affero General Public License. +Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. + +14. Revised Versions of this License. +The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version†applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. + +If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. + +Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. + +15. Disclaimer of Warranty. +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS†WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. Limitation of Liability. +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +17. Interpretation of Sections 15 and 16. +If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright†line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + +If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about boxâ€. + +You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer†for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . + +The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . diff --git a/external_imported/json/LICENSES/MIT.txt b/external_imported/json/LICENSES/MIT.txt new file mode 100644 index 000000000..2071b23b0 --- /dev/null +++ b/external_imported/json/LICENSES/MIT.txt @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/external_imported/json/Makefile b/external_imported/json/Makefile index d3963f503..a1b4e7328 100644 --- a/external_imported/json/Makefile +++ b/external_imported/json/Makefile @@ -4,9 +4,6 @@ # configuration ########################################################################## -# directory to recent compiler binaries -COMPILER_DIR=/usr/local/opt/llvm/bin - # find GNU sed to use `-i` parameter SED:=$(shell command -v gsed || which sed) @@ -18,8 +15,12 @@ SED:=$(shell command -v gsed || which sed) # the list of sources in the include folder SRCS=$(shell find include -type f | sort) -# the single header (amalgamated from the source files) +# the list of sources in the tests folder +TESTS_SRCS=$(shell find tests -type f \( -name '*.hpp' -o -name '*.cpp' -o -name '*.cu' \) -not -path 'tests/thirdparty/*' -not -path 'tests/abi/include/nlohmann/*' | sort) + +# the single headers (amalgamated from the source files) AMALGAMATED_FILE=single_include/nlohmann/json.hpp +AMALGAMATED_FWD_FILE=single_include/nlohmann/json_fwd.hpp ########################################################################## @@ -28,346 +29,28 @@ AMALGAMATED_FILE=single_include/nlohmann/json.hpp # main target all: - @echo "amalgamate - amalgamate file single_include/nlohmann/json.hpp from the include/nlohmann sources" + @echo "amalgamate - amalgamate files single_include/nlohmann/json{,_fwd}.hpp from the include/nlohmann sources" @echo "ChangeLog.md - generate ChangeLog file" @echo "check-amalgamation - check whether sources have been amalgamated" @echo "clean - remove built files" - @echo "coverage - create coverage information with lcov" - @echo "cppcheck - analyze code with cppcheck" - @echo "cpplint - analyze code with cpplint" - @echo "clang_tidy - analyze code with Clang-Tidy" - @echo "clang_analyze - analyze code with Clang-Analyzer" @echo "doctest - compile example files and check their output" @echo "fuzz_testing - prepare fuzz testing of the JSON parser" @echo "fuzz_testing_bson - prepare fuzz testing of the BSON parser" @echo "fuzz_testing_cbor - prepare fuzz testing of the CBOR parser" @echo "fuzz_testing_msgpack - prepare fuzz testing of the MessagePack parser" @echo "fuzz_testing_ubjson - prepare fuzz testing of the UBJSON parser" - @echo "pedantic_clang - run Clang with maximal warning flags" - @echo "pedantic_gcc - run GCC with maximal warning flags" @echo "pretty - beautify code with Artistic Style" @echo "run_benchmarks - build and run benchmarks" -########################################################################## -# coverage -########################################################################## - -coverage: - rm -fr cmake-build-coverage - mkdir cmake-build-coverage - cd cmake-build-coverage ; cmake .. -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON - cd cmake-build-coverage ; ninja - cd cmake-build-coverage ; ctest -j10 - cd cmake-build-coverage ; ninja lcov_html - open cmake-build-coverage/test/html/index.html - ########################################################################## # documentation tests ########################################################################## # compile example files and check output doctest: - $(MAKE) check_output -C doc - - -########################################################################## -# warning detector -########################################################################## + $(MAKE) check_output -C docs -# calling Clang with all warnings, except: -# -Wno-c++2a-compat: u8 literals will behave differently in C++20... -# -Wno-deprecated-declarations: the library deprecated some functions -# -Wno-documentation-unknown-command: code uses user-defined commands like @complexity -# -Wno-exit-time-destructors: warning in json code triggered by NLOHMANN_JSON_SERIALIZE_ENUM -# -Wno-float-equal: not all comparisons in the tests can be replaced by Approx -# -Wno-missing-prototypes: for NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE -# -Wno-padded: padding is nothing to warn about -# -Wno-range-loop-analysis: items tests "for(const auto i...)" -# -Wno-extra-semi-stmt: spurious warnings for semicolons after JSON_ASSERT() -# -Wno-switch-enum -Wno-covered-switch-default: pedantic/contradicting warnings about switches -# -Wno-weak-vtables: exception class is defined inline, but has virtual method -pedantic_clang: - rm -fr cmake-build-pedantic - CXXFLAGS=" \ - -std=c++11 -Wno-c++98-compat -Wno-c++98-compat-pedantic \ - -Werror \ - -Weverything \ - -Wno-c++2a-compat \ - -Wno-deprecated-declarations \ - -Wno-documentation-unknown-command \ - -Wno-exit-time-destructors \ - -Wno-float-equal \ - -Wno-missing-prototypes \ - -Wno-padded \ - -Wno-range-loop-analysis \ - -Wno-extra-semi-stmt \ - -Wno-switch-enum -Wno-covered-switch-default \ - -Wno-weak-vtables" cmake -S . -B cmake-build-pedantic -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_MultipleHeaders=ON -DJSON_BuildTests=On - cmake --build cmake-build-pedantic - -# calling GCC with most warnings -pedantic_gcc: - rm -fr cmake-build-pedantic - CXXFLAGS=" \ - -std=c++11 \ - -pedantic \ - -Werror \ - --all-warnings \ - --extra-warnings \ - -W \ - -Wno-abi-tag \ - -Waddress \ - -Waddress-of-packed-member \ - -Wno-aggregate-return \ - -Waggressive-loop-optimizations \ - -Waligned-new=all \ - -Wall \ - -Walloc-zero \ - -Walloca \ - -Wanalyzer-double-fclose \ - -Wanalyzer-double-free \ - -Wanalyzer-exposure-through-output-file \ - -Wanalyzer-file-leak \ - -Wanalyzer-free-of-non-heap \ - -Wanalyzer-malloc-leak \ - -Wanalyzer-null-argument \ - -Wanalyzer-null-dereference \ - -Wanalyzer-possible-null-argument \ - -Wanalyzer-possible-null-dereference \ - -Wanalyzer-stale-setjmp-buffer \ - -Wanalyzer-tainted-array-index \ - -Wanalyzer-too-complex \ - -Wanalyzer-unsafe-call-within-signal-handler \ - -Wanalyzer-use-after-free \ - -Wanalyzer-use-of-pointer-in-stale-stack-frame \ - -Warith-conversion \ - -Warray-bounds \ - -Warray-bounds=2 \ - -Wattribute-alias=2 \ - -Wattribute-warning \ - -Wattributes \ - -Wbool-compare \ - -Wbool-operation \ - -Wbuiltin-declaration-mismatch \ - -Wbuiltin-macro-redefined \ - -Wc++0x-compat \ - -Wc++11-compat \ - -Wc++14-compat \ - -Wc++17-compat \ - -Wc++1z-compat \ - -Wc++20-compat \ - -Wc++2a-compat \ - -Wcannot-profile \ - -Wcast-align \ - -Wcast-align=strict \ - -Wcast-function-type \ - -Wcast-qual \ - -Wcatch-value=3 \ - -Wchar-subscripts \ - -Wclass-conversion \ - -Wclass-memaccess \ - -Wclobbered \ - -Wcomma-subscript \ - -Wcomment \ - -Wcomments \ - -Wconditionally-supported \ - -Wconversion \ - -Wconversion-null \ - -Wcoverage-mismatch \ - -Wcpp \ - -Wctor-dtor-privacy \ - -Wdangling-else \ - -Wdate-time \ - -Wdelete-incomplete \ - -Wdelete-non-virtual-dtor \ - -Wdeprecated \ - -Wdeprecated-copy \ - -Wdeprecated-copy-dtor \ - -Wdeprecated-declarations \ - -Wdisabled-optimization \ - -Wdiv-by-zero \ - -Wdouble-promotion \ - -Wduplicated-branches \ - -Wduplicated-cond \ - -Weffc++ \ - -Wempty-body \ - -Wendif-labels \ - -Wenum-compare \ - -Wexpansion-to-defined \ - -Wextra \ - -Wextra-semi \ - -Wfloat-conversion \ - -Wfloat-equal \ - -Wformat -Wformat-contains-nul \ - -Wformat -Wformat-extra-args \ - -Wformat -Wformat-nonliteral \ - -Wformat -Wformat-security \ - -Wformat -Wformat-y2k \ - -Wformat -Wformat-zero-length \ - -Wformat-diag \ - -Wformat-overflow=2 \ - -Wformat-signedness \ - -Wformat-truncation=2 \ - -Wformat=2 \ - -Wframe-address \ - -Wfree-nonheap-object \ - -Whsa \ - -Wif-not-aligned \ - -Wignored-attributes \ - -Wignored-qualifiers \ - -Wimplicit-fallthrough=5 \ - -Winaccessible-base \ - -Winherited-variadic-ctor \ - -Winit-list-lifetime \ - -Winit-self \ - -Winline \ - -Wint-in-bool-context \ - -Wint-to-pointer-cast \ - -Winvalid-memory-model \ - -Winvalid-offsetof \ - -Winvalid-pch \ - -Wliteral-suffix \ - -Wlogical-not-parentheses \ - -Wlogical-op \ - -Wno-long-long \ - -Wlto-type-mismatch \ - -Wmain \ - -Wmaybe-uninitialized \ - -Wmemset-elt-size \ - -Wmemset-transposed-args \ - -Wmisleading-indentation \ - -Wmismatched-tags \ - -Wmissing-attributes \ - -Wmissing-braces \ - -Wno-missing-declarations \ - -Wmissing-field-initializers \ - -Wmissing-include-dirs \ - -Wmissing-profile \ - -Wmultichar \ - -Wmultiple-inheritance \ - -Wmultistatement-macros \ - -Wno-namespaces \ - -Wnarrowing \ - -Wno-noexcept \ - -Wnoexcept-type \ - -Wnon-template-friend \ - -Wnon-virtual-dtor \ - -Wnonnull \ - -Wnonnull-compare \ - -Wnonportable-cfstrings \ - -Wnormalized=nfkc \ - -Wnull-dereference \ - -Wodr \ - -Wold-style-cast \ - -Wopenmp-simd \ - -Woverflow \ - -Woverlength-strings \ - -Woverloaded-virtual \ - -Wpacked \ - -Wpacked-bitfield-compat \ - -Wpacked-not-aligned \ - -Wno-padded \ - -Wparentheses \ - -Wpedantic \ - -Wpessimizing-move \ - -Wplacement-new=2 \ - -Wpmf-conversions \ - -Wpointer-arith \ - -Wpointer-compare \ - -Wpragmas \ - -Wprio-ctor-dtor \ - -Wpsabi \ - -Wredundant-decls \ - -Wredundant-move \ - -Wredundant-tags \ - -Wregister \ - -Wreorder \ - -Wrestrict \ - -Wreturn-local-addr \ - -Wreturn-type \ - -Wscalar-storage-order \ - -Wsequence-point \ - -Wshadow=compatible-local \ - -Wshadow=global \ - -Wshadow=local \ - -Wshift-count-negative \ - -Wshift-count-overflow \ - -Wshift-negative-value \ - -Wshift-overflow=2 \ - -Wsign-compare \ - -Wsign-conversion \ - -Wsign-promo \ - -Wsized-deallocation \ - -Wsizeof-array-argument \ - -Wsizeof-pointer-div \ - -Wsizeof-pointer-memaccess \ - -Wstack-protector \ - -Wstrict-aliasing \ - -Wstrict-aliasing=3 \ - -Wstrict-null-sentinel \ - -Wstrict-overflow \ - -Wstrict-overflow=5 \ - -Wstring-compare \ - -Wstringop-overflow \ - -Wstringop-overflow=4 \ - -Wstringop-truncation \ - -Wsubobject-linkage \ - -Wsuggest-attribute=cold \ - -Wsuggest-attribute=const \ - -Wsuggest-attribute=format \ - -Wsuggest-attribute=malloc \ - -Wsuggest-attribute=noreturn \ - -Wsuggest-attribute=pure \ - -Wsuggest-final-methods \ - -Wsuggest-final-types \ - -Wsuggest-override \ - -Wswitch \ - -Wswitch-bool \ - -Wswitch-default \ - -Wno-switch-enum \ - -Wswitch-outside-range \ - -Wswitch-unreachable \ - -Wsync-nand \ - -Wsynth \ - -Wno-system-headers \ - -Wtautological-compare \ - -Wno-templates \ - -Wterminate \ - -Wtrampolines \ - -Wtrigraphs \ - -Wtype-limits \ - -Wundef \ - -Wuninitialized \ - -Wunknown-pragmas \ - -Wunreachable-code \ - -Wunsafe-loop-optimizations \ - -Wunused \ - -Wunused-but-set-parameter \ - -Wunused-but-set-variable \ - -Wunused-const-variable=2 \ - -Wunused-function \ - -Wunused-label \ - -Wno-unused-local-typedefs \ - -Wunused-macros \ - -Wunused-parameter \ - -Wunused-result \ - -Wunused-value \ - -Wunused-variable \ - -Wuseless-cast \ - -Wvarargs \ - -Wvariadic-macros \ - -Wvector-operation-performance \ - -Wvirtual-inheritance \ - -Wvirtual-move-assign \ - -Wvla \ - -Wvolatile \ - -Wvolatile-register-var \ - -Wwrite-strings \ - -Wzero-as-null-pointer-constant \ - -Wzero-length-bounds \ - " cmake -S . -B cmake-build-pedantic -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_MultipleHeaders=ON -DJSON_BuildTests=On - cmake --build cmake-build-pedantic ########################################################################## # benchmarks @@ -376,10 +59,11 @@ pedantic_gcc: run_benchmarks: rm -fr cmake-build-benchmarks mkdir cmake-build-benchmarks - cd cmake-build-benchmarks ; cmake ../benchmarks -GNinja -DCMAKE_BUILD_TYPE=Release -DJSON_BuildTests=On + cd cmake-build-benchmarks ; cmake ../tests/benchmarks -GNinja -DCMAKE_BUILD_TYPE=Release cd cmake-build-benchmarks ; ninja cd cmake-build-benchmarks ; ./json_benchmarks + ########################################################################## # fuzzing ########################################################################## @@ -388,41 +72,41 @@ run_benchmarks: fuzz_testing: rm -fr fuzz-testing mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out - $(MAKE) parse_afl_fuzzer -C test CXX=afl-clang++ - mv test/parse_afl_fuzzer fuzz-testing/fuzzer - find test/data/json_tests -size -5k -name *json | xargs -I{} cp "{}" fuzz-testing/testcases + $(MAKE) parse_afl_fuzzer -C tests CXX=afl-clang++ + mv tests/parse_afl_fuzzer fuzz-testing/fuzzer + find tests/data/json_tests -size -5k -name *json | xargs -I{} cp "{}" fuzz-testing/testcases @echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer" fuzz_testing_bson: rm -fr fuzz-testing mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out - $(MAKE) parse_bson_fuzzer -C test CXX=afl-clang++ - mv test/parse_bson_fuzzer fuzz-testing/fuzzer - find test/data -size -5k -name *.bson | xargs -I{} cp "{}" fuzz-testing/testcases + $(MAKE) parse_bson_fuzzer -C tests CXX=afl-clang++ + mv tests/parse_bson_fuzzer fuzz-testing/fuzzer + find tests/data -size -5k -name *.bson | xargs -I{} cp "{}" fuzz-testing/testcases @echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer" fuzz_testing_cbor: rm -fr fuzz-testing mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out - $(MAKE) parse_cbor_fuzzer -C test CXX=afl-clang++ - mv test/parse_cbor_fuzzer fuzz-testing/fuzzer - find test/data -size -5k -name *.cbor | xargs -I{} cp "{}" fuzz-testing/testcases + $(MAKE) parse_cbor_fuzzer -C tests CXX=afl-clang++ + mv tests/parse_cbor_fuzzer fuzz-testing/fuzzer + find tests/data -size -5k -name *.cbor | xargs -I{} cp "{}" fuzz-testing/testcases @echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer" fuzz_testing_msgpack: rm -fr fuzz-testing mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out - $(MAKE) parse_msgpack_fuzzer -C test CXX=afl-clang++ - mv test/parse_msgpack_fuzzer fuzz-testing/fuzzer - find test/data -size -5k -name *.msgpack | xargs -I{} cp "{}" fuzz-testing/testcases + $(MAKE) parse_msgpack_fuzzer -C tests CXX=afl-clang++ + mv tests/parse_msgpack_fuzzer fuzz-testing/fuzzer + find tests/data -size -5k -name *.msgpack | xargs -I{} cp "{}" fuzz-testing/testcases @echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer" fuzz_testing_ubjson: rm -fr fuzz-testing mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out - $(MAKE) parse_ubjson_fuzzer -C test CXX=afl-clang++ - mv test/parse_ubjson_fuzzer fuzz-testing/fuzzer - find test/data -size -5k -name *.ubjson | xargs -I{} cp "{}" fuzz-testing/testcases + $(MAKE) parse_ubjson_fuzzer -C tests CXX=afl-clang++ + mv tests/parse_ubjson_fuzzer fuzz-testing/fuzzer + find tests/data -size -5k -name *.ubjson | xargs -I{} cp "{}" fuzz-testing/testcases @echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer" fuzzing-start: @@ -444,33 +128,6 @@ fuzzing-stop: # Static analysis ########################################################################## -# call cppcheck -# Note: this target is called by Travis -cppcheck: - cppcheck --enable=warning --inline-suppr --inconclusive --force --std=c++11 $(AMALGAMATED_FILE) --error-exitcode=1 - -# call Clang Static Analyzer -clang_analyze: - rm -fr cmake-build-clang-analyze - mkdir cmake-build-clang-analyze - cd cmake-build-clang-analyze ; CCC_CXX=$(COMPILER_DIR)/clang++ CXX=$(COMPILER_DIR)/clang++ $(COMPILER_DIR)/scan-build cmake .. -GNinja -DJSON_BuildTests=On - cd cmake-build-clang-analyze ; \ - $(COMPILER_DIR)/scan-build \ - -enable-checker alpha.core.BoolAssignment,alpha.core.CallAndMessageUnInitRefArg,alpha.core.CastSize,alpha.core.CastToStruct,alpha.core.Conversion,alpha.core.DynamicTypeChecker,alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,alpha.core.SizeofPtr,alpha.core.StackAddressAsyncEscape,alpha.core.TestAfterDivZero,alpha.deadcode.UnreachableCode,core.builtin.BuiltinFunctions,core.builtin.NoReturnFunctions,core.CallAndMessage,core.DivideZero,core.DynamicTypePropagation,core.NonnilStringConstants,core.NonNullParamChecker,core.NullDereference,core.StackAddressEscape,core.UndefinedBinaryOperatorResult,core.uninitialized.ArraySubscript,core.uninitialized.Assign,core.uninitialized.Branch,core.uninitialized.CapturedBlockVariable,core.uninitialized.UndefReturn,core.VLASize,cplusplus.InnerPointer,cplusplus.Move,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,cplusplus.SelfAssignment,deadcode.DeadStores,nullability.NullableDereferenced,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull \ - --use-c++=$(COMPILER_DIR)/clang++ -analyze-headers -o report ninja - open cmake-build-clang-analyze/report/*/index.html - -# call cpplint -# Note: some errors expected due to false positives -cpplint: - third_party/cpplint/cpplint.py \ - --filter=-whitespace,-legal,-readability/alt_tokens,-runtime/references,-runtime/explicit \ - --quiet --recursive $(SRCS) - -# call Clang-Tidy -clang_tidy: - $(COMPILER_DIR)/clang-tidy $(SRCS) -- -Iinclude -std=c++11 - # call PVS-Studio Analyzer pvs_studio: rm -fr cmake-build-pvs-studio @@ -480,25 +137,6 @@ pvs_studio: cd cmake-build-pvs-studio ; plog-converter -a'GA:1,2;64:1;CS' -t fullhtml PVS-Studio.log -o pvs open cmake-build-pvs-studio/pvs/index.html -# call Infer static analyzer -infer: - rm -fr cmake-build-infer - mkdir cmake-build-infer - cd cmake-build-infer ; infer compile -- cmake .. -DJSON_MultipleHeaders=ON ; infer run -- make -j 4 - -# call OCLint static analyzer -oclint: - oclint $(SRCS) -report-type html -enable-global-analysis -o oclint_report.html -max-priority-1=10000 -max-priority-2=10000 -max-priority-3=10000 -- -std=c++11 -Iinclude - open oclint_report.html - -# execute the test suite with Clang sanitizers (address and undefined behavior) -clang_sanitize: - rm -fr cmake-build-clang-sanitize - mkdir cmake-build-clang-sanitize - cd cmake-build-clang-sanitize ; CXX=$(COMPILER_DIR)/clang++ cmake .. -DJSON_Sanitizer=On -DJSON_MultipleHeaders=ON -DJSON_BuildTests=On -GNinja - cd cmake-build-clang-sanitize ; ninja - cd cmake-build-clang-sanitize ; ctest -j10 - ########################################################################## # Code format and source amalgamation @@ -507,9 +145,9 @@ clang_sanitize: # call the Artistic Style pretty printer on all source files pretty: astyle \ - --style=allman \ - --indent=spaces=4 \ - --indent-modifiers \ + --style=allman \ + --indent=spaces=4 \ + --indent-modifiers \ --indent-switches \ --indent-preproc-block \ --indent-preproc-define \ @@ -518,71 +156,45 @@ pretty: --pad-header \ --align-pointer=type \ --align-reference=type \ - --add-brackets \ + --add-braces \ + --squeeze-lines=2 \ --convert-tabs \ --close-templates \ --lineend=linux \ --preserve-date \ --suffix=none \ --formatted \ - $(SRCS) $(AMALGAMATED_FILE) test/src/*.cpp test/src/*.hpp benchmarks/src/benchmarks.cpp doc/examples/*.cpp + $(SRCS) $(TESTS_SRCS) $(AMALGAMATED_FILE) $(AMALGAMATED_FWD_FILE) docs/examples/*.cpp # call the Clang-Format on all source files pretty_format: - for FILE in $(SRCS) $(AMALGAMATED_FILE) test/src/*.cpp test/src/*.hpp benchmarks/src/benchmarks.cpp doc/examples/*.cpp; do echo $$FILE; clang-format -i $$FILE; done + for FILE in $(SRCS) $(TESTS_SRCS) $(AMALGAMATED_FILE) docs/examples/*.cpp; do echo $$FILE; clang-format -i $$FILE; done -# create single header file -amalgamate: $(AMALGAMATED_FILE) +# create single header files and pretty print +amalgamate: $(AMALGAMATED_FILE) $(AMALGAMATED_FWD_FILE) + $(MAKE) pretty -# call the amalgamation tool and pretty print +# call the amalgamation tool for json.hpp $(AMALGAMATED_FILE): $(SRCS) - third_party/amalgamate/amalgamate.py -c third_party/amalgamate/config.json -s . --verbose=yes - $(MAKE) pretty + tools/amalgamate/amalgamate.py -c tools/amalgamate/config_json.json -s . --verbose=yes + +# call the amalgamation tool for json_fwd.hpp +$(AMALGAMATED_FWD_FILE): $(SRCS) + tools/amalgamate/amalgamate.py -c tools/amalgamate/config_json_fwd.json -s . --verbose=yes # check if file single_include/nlohmann/json.hpp has been amalgamated from the nlohmann sources # Note: this target is called by Travis check-amalgamation: @mv $(AMALGAMATED_FILE) $(AMALGAMATED_FILE)~ + @mv $(AMALGAMATED_FWD_FILE) $(AMALGAMATED_FWD_FILE)~ @$(MAKE) amalgamate @diff $(AMALGAMATED_FILE) $(AMALGAMATED_FILE)~ || (echo "===================================================================\n Amalgamation required! Please read the contribution guidelines\n in file .github/CONTRIBUTING.md.\n===================================================================" ; mv $(AMALGAMATED_FILE)~ $(AMALGAMATED_FILE) ; false) + @diff $(AMALGAMATED_FWD_FILE) $(AMALGAMATED_FWD_FILE)~ || (echo "===================================================================\n Amalgamation required! Please read the contribution guidelines\n in file .github/CONTRIBUTING.md.\n===================================================================" ; mv $(AMALGAMATED_FWD_FILE)~ $(AMALGAMATED_FWD_FILE) ; false) @mv $(AMALGAMATED_FILE)~ $(AMALGAMATED_FILE) + @mv $(AMALGAMATED_FWD_FILE)~ $(AMALGAMATED_FWD_FILE) -# check if every header in nlohmann includes sufficient headers to be compiled individually -check-single-includes: - @for x in $(SRCS); do \ - echo "Checking self-sufficiency of $$x..." ; \ - echo "#include <$$x>\nint main() {}\n" | $(SED) 's|include/||' > single_include_test.cpp; \ - $(CXX) $(CXXFLAGS) -Iinclude -std=c++11 single_include_test.cpp -o single_include_test; \ - rm -f single_include_test.cpp single_include_test; \ - done - - -########################################################################## -# CMake -########################################################################## - -# grep "^option" CMakeLists.txt test/CMakeLists.txt | $(SED) 's/(/ /' | awk '{print $2}' | xargs - -# check if all flags of our CMake files work -check_cmake_flags_do: - $(CMAKE_BINARY) --version - for flag in JSON_BuildTests JSON_Install JSON_MultipleHeaders JSON_Sanitizer JSON_Valgrind JSON_NoExceptions JSON_Coverage; do \ - rm -fr cmake_build; \ - mkdir cmake_build; \ - echo "\n\n$(CMAKE_BINARY) .. -D$$flag=On\n" ; \ - cd cmake_build ; \ - $(CMAKE_BINARY) -Werror=dev .. -D$$flag=On -DCMAKE_CXX_COMPILE_FEATURES="cxx_std_11;cxx_range_for" -DCMAKE_CXX_FLAGS="-std=gnu++11" ; \ - test -f Makefile || exit 1 ; \ - cd .. ; \ - done; - -# call target `check_cmake_flags_do` twice: once for minimal required CMake version 3.1.0 and once for the installed version -check_cmake_flags: - wget https://github.com/Kitware/CMake/releases/download/v3.1.0/cmake-3.1.0-Darwin64.tar.gz - tar xfz cmake-3.1.0-Darwin64.tar.gz - CMAKE_BINARY=$(abspath cmake-3.1.0-Darwin64/CMake.app/Contents/bin/cmake) $(MAKE) check_cmake_flags_do - CMAKE_BINARY=$(shell which cmake) $(MAKE) check_cmake_flags_do - +BUILD.bazel: $(SRCS) + cmake -P cmake/scripts/gen_bazel_build_file.cmake ########################################################################## # ChangeLog @@ -604,20 +216,31 @@ ChangeLog.md: # Release files ########################################################################## -# Create the files for a release and add signatures and hashes. We use `-X` to make the resulting ZIP file -# reproducible, see . - -release: +# Create a tar.gz archive that contains sufficient files to be used as CMake project (e.g., using FetchContent). The +# archive is created according to the advices of . +json.tar.xz: + mkdir json + rsync -R $(shell find LICENSE.MIT nlohmann_json.natvis CMakeLists.txt cmake/*.in include single_include -type f) json + gtar --sort=name --mtime="@$(shell git log -1 --pretty=%ct)" --owner=0 --group=0 --numeric-owner --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime --create --file - json | xz --compress -9e --threads=2 - > json.tar.xz + rm -fr json + +# We use `-X` to make the resulting ZIP file reproducible, see +# . +include.zip: BUILD.bazel + zip -9 --recurse-paths -X include.zip $(SRCS) $(AMALGAMATED_FILE) $(AMALGAMATED_FWD_FILE) BUILD.bazel WORKSPACE.bazel meson.build LICENSE.MIT + +# Create the files for a release and add signatures and hashes. +release: include.zip json.tar.xz rm -fr release_files mkdir release_files - zip -9 --recurse-paths -X include.zip $(SRCS) $(AMALGAMATED_FILE) meson.build LICENSE.MIT gpg --armor --detach-sig include.zip - mv include.zip include.zip.asc release_files gpg --armor --detach-sig $(AMALGAMATED_FILE) + gpg --armor --detach-sig $(AMALGAMATED_FWD_FILE) + gpg --armor --detach-sig json.tar.xz cp $(AMALGAMATED_FILE) release_files - mv $(AMALGAMATED_FILE).asc release_files - cd release_files ; shasum -a 256 json.hpp > hashes.txt - cd release_files ; shasum -a 256 include.zip >> hashes.txt + cp $(AMALGAMATED_FWD_FILE) release_files + mv $(AMALGAMATED_FILE).asc $(AMALGAMATED_FWD_FILE).asc json.tar.xz json.tar.xz.asc include.zip include.zip.asc release_files + cd release_files ; shasum -a 256 json.hpp include.zip json.tar.xz > hashes.txt ########################################################################## @@ -626,11 +249,11 @@ release: # clean up clean: - rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM test/*.dSYM oclint_report.html + rm -fr fuzz fuzz-testing *.dSYM tests/*.dSYM rm -fr benchmarks/files/numbers/*.json - rm -fr cmake-3.1.0-Darwin64.tar.gz cmake-3.1.0-Darwin64 - rm -fr cmake-build-coverage cmake-build-benchmarks cmake-build-pedantic fuzz-testing cmake-build-clang-analyze cmake-build-pvs-studio cmake-build-infer cmake-build-clang-sanitize cmake_build - $(MAKE) clean -Cdoc + rm -fr cmake-build-benchmarks fuzz-testing cmake-build-pvs-studio release_files + $(MAKE) clean -Cdocs + ########################################################################## # Thirdparty code @@ -641,4 +264,22 @@ update_hedley: curl https://raw.githubusercontent.com/nemequ/hedley/master/hedley.h -o include/nlohmann/thirdparty/hedley/hedley.hpp $(SED) -i 's/HEDLEY_/JSON_HEDLEY_/g' include/nlohmann/thirdparty/hedley/hedley.hpp grep "[[:blank:]]*#[[:blank:]]*undef" include/nlohmann/thirdparty/hedley/hedley.hpp | grep -v "__" | sort | uniq | $(SED) 's/ //g' | $(SED) 's/undef/undef /g' > include/nlohmann/thirdparty/hedley/hedley_undef.hpp + $(SED) -i '1s/^/#pragma once\n\n/' include/nlohmann/thirdparty/hedley/hedley.hpp + $(SED) -i '1s/^/#pragma once\n\n/' include/nlohmann/thirdparty/hedley/hedley_undef.hpp $(MAKE) amalgamate + +########################################################################## +# serve_header.py +########################################################################## + +serve_header: + ./tools/serve_header/serve_header.py --make $(MAKE) + +########################################################################## +# REUSE +########################################################################## + +reuse: + pipx run reuse addheader --recursive single_include include -tjson --license MIT --copyright "Niels Lohmann " --year "2013-2022" + pipx run reuse addheader $(TESTS_SRCS) --style=c -tjson_support --license MIT --copyright "Niels Lohmann " --year "2013-2022" + pipx run reuse lint diff --git a/external_imported/json/Package.swift b/external_imported/json/Package.swift new file mode 100644 index 000000000..2f9c4a1f4 --- /dev/null +++ b/external_imported/json/Package.swift @@ -0,0 +1,22 @@ +// swift-tools-version: 5.9 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "nlohmann-json", + platforms: [ + .iOS(.v12), .macOS(.v10_13), .tvOS(.v12), .watchOS(.v4) + ], + products: [ + .library(name: "json", targets: ["json"]) + ], + targets: [ + .target( + name: "json", + path: "single_include/nlohmann", + publicHeadersPath: "." + ) + ], + cxxLanguageStandard: .cxx11 +) diff --git a/external_imported/json/README.md b/external_imported/json/README.md index 5d354f1ed..910902706 100644 --- a/external_imported/json/README.md +++ b/external_imported/json/README.md @@ -1,33 +1,34 @@ -[![JSON for Modern C++](https://raw.githubusercontent.com/nlohmann/json/master/doc/json.gif)](https://github.com/nlohmann/json/releases) +[![JSON for Modern C++](docs/json.gif)](https://github.com/nlohmann/json/releases) -[![Build Status](https://travis-ci.org/nlohmann/json.svg?branch=master)](https://travis-ci.org/nlohmann/json) [![Build Status](https://ci.appveyor.com/api/projects/status/1acb366xfyg3qybk/branch/develop?svg=true)](https://ci.appveyor.com/project/nlohmann/json) [![Ubuntu](https://github.com/nlohmann/json/workflows/Ubuntu/badge.svg)](https://github.com/nlohmann/json/actions?query=workflow%3AUbuntu) [![macOS](https://github.com/nlohmann/json/workflows/macOS/badge.svg)](https://github.com/nlohmann/json/actions?query=workflow%3AmacOS) [![Windows](https://github.com/nlohmann/json/workflows/Windows/badge.svg)](https://github.com/nlohmann/json/actions?query=workflow%3AWindows) -[![Build Status](https://circleci.com/gh/nlohmann/json.svg?style=svg)](https://circleci.com/gh/nlohmann/json) [![Coverage Status](https://coveralls.io/repos/github/nlohmann/json/badge.svg?branch=develop)](https://coveralls.io/github/nlohmann/json?branch=develop) [![Coverity Scan Build Status](https://scan.coverity.com/projects/5550/badge.svg)](https://scan.coverity.com/projects/nlohmann-json) -[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f3732b3327e34358a0e9d1fe9f661f08)](https://www.codacy.com/app/nlohmann/json?utm_source=github.com&utm_medium=referral&utm_content=nlohmann/json&utm_campaign=Badge_Grade) -[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/nlohmann/json.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/nlohmann/json/context:cpp) +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/e0d1a9d5d6fd46fcb655c4cb930bb3e8)](https://www.codacy.com/gh/nlohmann/json/dashboard?utm_source=github.com&utm_medium=referral&utm_content=nlohmann/json&utm_campaign=Badge_Grade) +[![Cirrus CI](https://api.cirrus-ci.com/github/nlohmann/json.svg)](https://cirrus-ci.com/github/nlohmann/json) [![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/json.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:json) -[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/3lCHrFUZANONKv7a) -[![Documentation](https://img.shields.io/badge/docs-doxygen-blue.svg)](https://nlohmann.github.io/json/doxygen/index.html) +[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/1mp10JbaANo6FUc7) +[![Documentation](https://img.shields.io/badge/docs-mkdocs-blue.svg)](https://json.nlohmann.me) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nlohmann/json/master/LICENSE.MIT) [![GitHub Releases](https://img.shields.io/github/release/nlohmann/json.svg)](https://github.com/nlohmann/json/releases) +[![Vcpkg Version](https://img.shields.io/vcpkg/v/nlohmann-json)](https://vcpkg.link/ports/nlohmann-json) +[![Packaging status](https://repology.org/badge/tiny-repos/nlohmann-json.svg)](https://repology.org/project/nlohmann-json/versions) [![GitHub Downloads](https://img.shields.io/github/downloads/nlohmann/json/total)](https://github.com/nlohmann/json/releases) [![GitHub Issues](https://img.shields.io/github/issues/nlohmann/json.svg)](https://github.com/nlohmann/json/issues) [![Average time to resolve an issue](https://isitmaintained.com/badge/resolution/nlohmann/json.svg)](https://isitmaintained.com/project/nlohmann/json "Average time to resolve an issue") [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/289/badge)](https://bestpractices.coreinfrastructure.org/projects/289) [![GitHub Sponsors](https://img.shields.io/badge/GitHub-Sponsors-ff69b4)](https://github.com/sponsors/nlohmann) +[![REUSE status](https://api.reuse.software/badge/github.com/nlohmann/json)](https://api.reuse.software/info/github.com/nlohmann/json) +[![Discord](https://img.shields.io/discord/1003743314341793913)](https://discord.gg/6mrGXKvX7y) - [Design goals](#design-goals) - [Sponsors](#sponsors) -- [Integration](#integration) - - [CMake](#cmake) - - [Package Managers](#package-managers) - - [Pkg-config](#pkg-config) +- [Support](#support) ([documentation](https://json.nlohmann.me), [FAQ](https://json.nlohmann.me/home/faq/), [discussions](https://github.com/nlohmann/json/discussions), [API](https://json.nlohmann.me/api/basic_json/), [bug issues](https://github.com/nlohmann/json/issues)) - [Examples](#examples) + - [Read JSON from a file](#read-json-from-a-file) + - [Creating `json` objects from JSON literals](#creating-json-objects-from-json-literals) - [JSON as first-class data type](#json-as-first-class-data-type) - [Serialization / Deserialization](#serialization--deserialization) - [STL-like access](#stl-like-access) @@ -37,8 +38,12 @@ - [Implicit conversions](#implicit-conversions) - [Conversions to/from arbitrary types](#arbitrary-types-conversions) - [Specializing enum conversion](#specializing-enum-conversion) - - [Binary formats (BSON, CBOR, MessagePack, and UBJSON)](#binary-formats-bson-cbor-messagepack-and-ubjson) + - [Binary formats (BSON, CBOR, MessagePack, UBJSON, and BJData)](#binary-formats-bson-cbor-messagepack-ubjson-and-bjdata) - [Supported compilers](#supported-compilers) +- [Integration](#integration) + - [CMake](#cmake) + - [Package Managers](#package-managers) + - [Pkg-config](#pkg-config) - [License](#license) - [Contact](#contact) - [Thanks](#thanks) @@ -55,7 +60,7 @@ There are myriads of [JSON](https://json.org) libraries out there, and each may - **Trivial integration**. Our whole code consists of a single header file [`json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp). That's it. No library, no subproject, no dependencies, no complex build system. The class is written in vanilla C++11. All in all, everything should require no adjustment of your compiler flags or project settings. -- **Serious testing**. Our class is heavily [unit-tested](https://github.com/nlohmann/json/tree/develop/test/src) and covers [100%](https://coveralls.io/r/nlohmann/json) of the code, including all exceptional behavior. Furthermore, we checked with [Valgrind](https://valgrind.org) and the [Clang Sanitizers](https://clang.llvm.org/docs/index.html) that there are no memory leaks. [Google OSS-Fuzz](https://github.com/google/oss-fuzz/tree/master/projects/json) additionally runs fuzz tests against all parsers 24/7, effectively executing billions of tests so far. To maintain high quality, the project is following the [Core Infrastructure Initiative (CII) best practices](https://bestpractices.coreinfrastructure.org/projects/289). +- **Serious testing**. Our code is heavily [unit-tested](https://github.com/nlohmann/json/tree/develop/tests/src) and covers [100%](https://coveralls.io/r/nlohmann/json) of the code, including all exceptional behavior. Furthermore, we checked with [Valgrind](https://valgrind.org) and the [Clang Sanitizers](https://clang.llvm.org/docs/index.html) that there are no memory leaks. [Google OSS-Fuzz](https://github.com/google/oss-fuzz/tree/master/projects/json) additionally runs fuzz tests against all parsers 24/7, effectively executing billions of tests so far. To maintain high quality, the project is following the [Core Infrastructure Initiative (CII) best practices](https://bestpractices.coreinfrastructure.org/projects/289). Other aspects were not so important to us: @@ -70,6 +75,10 @@ See the [contribution guidelines](https://github.com/nlohmann/json/blob/master/. You can sponsor this library at [GitHub Sponsors](https://github.com/sponsors/nlohmann). +### :office: Corporate Sponsor + +[![](https://upload.wikimedia.org/wikipedia/commons/thumb/9/9e/Codacy-logo-black.svg/320px-Codacy-logo-black.svg.png)](https://github.com/codacy/About) + ### :label: Named Sponsors - [Michael Hartmann](https://github.com/reFX-Mike) @@ -77,188 +86,86 @@ You can sponsor this library at [GitHub Sponsors](https://github.com/sponsors/nl - [Steve Sperandeo](https://github.com/homer6) - [Robert Jefe Lindstädt](https://github.com/eljefedelrodeodeljefe) - [Steve Wagner](https://github.com/ciroque) +- [Lion Yang](https://github.com/LionNatsu) Thanks everyone! +## Support -## Integration - -[`json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp) is the single required file in `single_include/nlohmann` or [released here](https://github.com/nlohmann/json/releases). You need to add - -```cpp -#include - -// for convenience -using json = nlohmann::json; -``` - -to the files you want to process JSON and set the necessary switches to enable C++11 (e.g., `-std=c++11` for GCC and Clang). - -You can further use file [`include/nlohmann/json_fwd.hpp`](https://github.com/nlohmann/json/blob/develop/include/nlohmann/json_fwd.hpp) for forward-declarations. The installation of json_fwd.hpp (as part of cmake's install step), can be achieved by setting `-DJSON_MultipleHeaders=ON`. +:question: If you have a **question**, please check if it is already answered in the [**FAQ**](https://json.nlohmann.me/home/faq/) or the [**Q&A**](https://github.com/nlohmann/json/discussions/categories/q-a) section. If not, please [**ask a new question**](https://github.com/nlohmann/json/discussions/new) there. -### CMake +:books: If you want to **learn more** about how to use the library, check out the rest of the [**README**](#examples), have a look at [**code examples**](https://github.com/nlohmann/json/tree/develop/docs/examples), or browse through the [**help pages**](https://json.nlohmann.me). -You can also use the `nlohmann_json::nlohmann_json` interface target in CMake. This target populates the appropriate usage requirements for `INTERFACE_INCLUDE_DIRECTORIES` to point to the appropriate include directories and `INTERFACE_COMPILE_FEATURES` for the necessary C++11 flags. +:construction: If you want to understand the **API** better, check out the [**API Reference**](https://json.nlohmann.me/api/basic_json/). -#### External +:bug: If you found a **bug**, please check the [**FAQ**](https://json.nlohmann.me/home/faq/) if it is a known issue or the result of a design decision. Please also have a look at the [**issue list**](https://github.com/nlohmann/json/issues) before you [**create a new issue**](https://github.com/nlohmann/json/issues/new/choose). Please provide as much information as possible to help us understand and reproduce your issue. -To use this library from a CMake project, you can locate it directly with `find_package()` and use the namespaced imported target from the generated package configuration: +There is also a [**docset**](https://github.com/Kapeli/Dash-User-Contributions/tree/master/docsets/JSON_for_Modern_C%2B%2B) for the documentation browsers [Dash](https://kapeli.com/dash), [Velocity](https://velocity.silverlakesoftware.com), and [Zeal](https://zealdocs.org) that contains the full [documentation](https://json.nlohmann.me) as offline resource. -```cmake -# CMakeLists.txt -find_package(nlohmann_json 3.2.0 REQUIRED) -... -add_library(foo ...) -... -target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json) -``` - -The package configuration file, `nlohmann_jsonConfig.cmake`, can be used either from an install tree or directly out of the build tree. - -#### Embedded - -To embed the library directly into an existing CMake project, place the entire source tree in a subdirectory and call `add_subdirectory()` in your `CMakeLists.txt` file: +## Examples -```cmake -# Typically you don't care so much for a third party library's tests to be -# run from your own project's code. -set(JSON_BuildTests OFF CACHE INTERNAL "") +Here are some examples to give you an idea how to use the class. -# If you only include this third party in PRIVATE source files, you do not -# need to install it when your main project gets installed. -# set(JSON_Install OFF CACHE INTERNAL "") +Beside the examples below, you may want to: -# Don't use include(nlohmann_json/CMakeLists.txt) since that carries with it -# unintended consequences that will break the build. It's generally -# discouraged (although not necessarily well documented as such) to use -# include(...) for pulling in other CMake projects anyways. -add_subdirectory(nlohmann_json) -... -add_library(foo ...) -... -target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json) -``` +→ Check the [documentation](https://json.nlohmann.me/)\ +→ Browse the [standalone example files](https://github.com/nlohmann/json/tree/develop/docs/examples) -##### Embedded (FetchContent) +Every API function (documented in the [API Documentation](https://json.nlohmann.me/api/basic_json/)) has a corresponding standalone example file. For example, the [`emplace()`](https://json.nlohmann.me/api/basic_json/emplace/) function has a matching [emplace.cpp](https://github.com/nlohmann/json/blob/develop/docs/examples/emplace.cpp) example file. -Since CMake v3.11, -[FetchContent](https://cmake.org/cmake/help/v3.11/module/FetchContent.html) can -be used to automatically download the repository as a dependency at configure type. +### Read JSON from a file -Example: -```cmake -include(FetchContent) +The `json` class provides an API for manipulating a JSON value. To create a `json` object by reading a JSON file: -FetchContent_Declare(json - GIT_REPOSITORY https://github.com/nlohmann/json.git - GIT_TAG v3.7.3) +```cpp +#include +#include +using json = nlohmann::json; -FetchContent_GetProperties(json) -if(NOT json_POPULATED) - FetchContent_Populate(json) - add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL) -endif() +// ... -target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json) +std::ifstream f("example.json"); +json data = json::parse(f); ``` -**Note**: The repository https://github.com/nlohmann/json download size is huge. -It contains all the dataset used for the benchmarks. You might want to depend on -a smaller repository. For instance, you might want to replace the URL above by -https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent +### Creating `json` objects from JSON literals -#### Supporting Both - -To allow your project to support either an externally supplied or an embedded JSON library, you can use a pattern akin to the following: +Assume you want to create hard-code this literal JSON value in a file, as a `json` object: -``` cmake -# Top level CMakeLists.txt -project(FOO) -... -option(FOO_USE_EXTERNAL_JSON "Use an external JSON library" OFF) -... -add_subdirectory(thirdparty) -... -add_library(foo ...) -... -# Note that the namespaced target will always be available regardless of the -# import method -target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json) -``` -```cmake -# thirdparty/CMakeLists.txt -... -if(FOO_USE_EXTERNAL_JSON) - find_package(nlohmann_json 3.2.0 REQUIRED) -else() - set(JSON_BuildTests OFF CACHE INTERNAL "") - add_subdirectory(nlohmann_json) -endif() -... -``` - -`thirdparty/nlohmann_json` is then a complete copy of this source tree. - -### Package Managers - -:beer: If you are using OS X and [Homebrew](https://brew.sh), just type `brew tap nlohmann/json` and `brew install nlohmann-json` and you're set. If you want the bleeding edge rather than the latest release, use `brew install nlohmann-json --HEAD`. - -If you are using the [Meson Build System](https://mesonbuild.com), add this source tree as a [meson subproject](https://mesonbuild.com/Subprojects.html#using-a-subproject). You may also use the `include.zip` published in this project's [Releases](https://github.com/nlohmann/json/releases) to reduce the size of the vendored source tree. Alternatively, you can get a wrap file by downloading it from [Meson WrapDB](https://wrapdb.mesonbuild.com/nlohmann_json), or simply use `meson wrap install nlohmann_json`. Please see the meson project for any issues regarding the packaging. - -The provided meson.build can also be used as an alternative to cmake for installing `nlohmann_json` system-wide in which case a pkg-config file is installed. To use it, simply have your build system require the `nlohmann_json` pkg-config dependency. In Meson, it is preferred to use the [`dependency()`](https://mesonbuild.com/Reference-manual.html#dependency) object with a subproject fallback, rather than using the subproject directly. - -If you are using [Conan](https://www.conan.io/) to manage your dependencies, merely add `nlohmann_json/x.y.z` to your `conanfile`'s requires, where `x.y.z` is the release version you want to use. Please file issues [here](https://github.com/conan-io/conan-center-index/issues) if you experience problems with the packages. - -If you are using [Spack](https://www.spack.io/) to manage your dependencies, you can use the [`nlohmann-json` package](https://spack.readthedocs.io/en/latest/package_list.html#nlohmann-json). Please see the [spack project](https://github.com/spack/spack) for any issues regarding the packaging. - -If you are using [hunter](https://github.com/cpp-pm/hunter) on your project for external dependencies, then you can use the [nlohmann_json package](https://hunter.readthedocs.io/en/latest/packages/pkg/nlohmann_json.html). Please see the hunter project for any issues regarding the packaging. - -If you are using [Buckaroo](https://buckaroo.pm), you can install this library's module with `buckaroo add github.com/buckaroo-pm/nlohmann-json`. Please file issues [here](https://github.com/buckaroo-pm/nlohmann-json). There is a demo repo [here](https://github.com/njlr/buckaroo-nholmann-json-example). - -If you are using [vcpkg](https://github.com/Microsoft/vcpkg/) on your project for external dependencies, then you can use the [nlohmann-json package](https://github.com/Microsoft/vcpkg/tree/master/ports/nlohmann-json). Please see the vcpkg project for any issues regarding the packaging. - -If you are using [cget](https://cget.readthedocs.io/en/latest/), you can install the latest development version with `cget install nlohmann/json`. A specific version can be installed with `cget install nlohmann/json@v3.1.0`. Also, the multiple header version can be installed by adding the `-DJSON_MultipleHeaders=ON` flag (i.e., `cget install nlohmann/json -DJSON_MultipleHeaders=ON`). - -If you are using [CocoaPods](https://cocoapods.org), you can use the library by adding pod `"nlohmann_json", '~>3.1.2'` to your podfile (see [an example](https://bitbucket.org/benman/nlohmann_json-cocoapod/src/master/)). Please file issues [here](https://bitbucket.org/benman/nlohmann_json-cocoapod/issues?status=new&status=open). - -If you are using [NuGet](https://www.nuget.org), you can use the package [nlohmann.json](https://www.nuget.org/packages/nlohmann.json/). Please check [this extensive description](https://github.com/nlohmann/json/issues/1132#issuecomment-452250255) on how to use the package. Please files issues [here](https://github.com/hnkb/nlohmann-json-nuget/issues). - -If you are using [conda](https://conda.io/), you can use the package [nlohmann_json](https://github.com/conda-forge/nlohmann_json-feedstock) from [conda-forge](https://conda-forge.org) executing `conda install -c conda-forge nlohmann_json`. Please file issues [here](https://github.com/conda-forge/nlohmann_json-feedstock/issues). - -If you are using [MSYS2](https://www.msys2.org/), your can use the [mingw-w64-nlohmann-json](https://packages.msys2.org/base/mingw-w64-nlohmann-json) package, just type `pacman -S mingw-w64-i686-nlohmann-json` or `pacman -S mingw-w64-x86_64-nlohmann-json` for installation. Please file issues [here](https://github.com/msys2/MINGW-packages/issues/new?title=%5Bnlohmann-json%5D) if you experience problems with the packages. - -If you are using [`build2`](https://build2.org), you can use the [`nlohmann-json`](https://cppget.org/nlohmann-json) package from the public repository https://cppget.org or directly from the [package's sources repository](https://github.com/build2-packaging/nlohmann-json). In your project's `manifest` file, just add `depends: nlohmann-json` (probably with some [version constraints](https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml#guide-add-remove-deps)). If you are not familiar with using dependencies in `build2`, [please read this introduction](https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml). -Please file issues [here](https://github.com/build2-packaging/nlohmann-json) if you experience problems with the packages. - -If you are using [`wsjcpp`](https://wsjcpp.org), you can use the command `wsjcpp install "https://github.com/nlohmann/json:develop"` to get the latest version. Note you can change the branch ":develop" to an existing tag or another branch. - -If you are using [`CPM.cmake`](https://github.com/TheLartians/CPM.cmake), you can check this [`example`](https://github.com/TheLartians/CPM.cmake/tree/master/examples/json). After [adding CPM script](https://github.com/TheLartians/CPM.cmake#adding-cpm) to your project, implement the following snippet to your CMake: - -```cmake -CPMAddPackage( - NAME nlohmann_json - GITHUB_REPOSITORY nlohmann/json - VERSION 3.9.1) +```json +{ + "pi": 3.141, + "happy": true +} ``` -### Pkg-config - -If you are using bare Makefiles, you can use `pkg-config` to generate the include flags that point to where the library is installed: +There are various options: -```sh -pkg-config nlohmann_json --cflags -``` +```cpp +// Using (raw) string literals and json::parse +json ex1 = json::parse(R"( + { + "pi": 3.141, + "happy": true + } +)"); -Users of the Meson build system will also be able to use a system wide library, which will be found by `pkg-config`: +// Using user-defined (raw) string literals +using namespace nlohmann::literals; +json ex2 = R"( + { + "pi": 3.141, + "happy": true + } +)"_json; -```meson -json = dependency('nlohmann_json', required: true) +// Using initializer lists +json ex3 = { + {"happy", true}, + {"pi", 3.141}, +}; ``` -## Examples - -Beside the examples below, you may want to check the [documentation](https://nlohmann.github.io/json/) where each function contains a separate code example (e.g., check out [`emplace()`](https://nlohmann.github.io/json/api/basic_json/emplace/)). All [example files](https://github.com/nlohmann/json/tree/develop/doc/examples) can be compiled and executed on their own (e.g., file [emplace.cpp](https://github.com/nlohmann/json/blob/develop/doc/examples/emplace.cpp)). - ### JSON as first-class data type Here are some examples to give you an idea how to use the class. @@ -326,7 +233,7 @@ json j2 = { }; ``` -Note that in all these cases, you never need to "tell" the compiler which JSON value type you want to use. If you want to be explicit or express some edge cases, the functions [`json::array()`](https://nlohmann.github.io/json/api/basic_json/array/) and [`json::object()`](https://nlohmann.github.io/json/api/basic_json/object/) will help: +Note that in all these cases, you never need to "tell" the compiler which JSON value type you want to use. If you want to be explicit or express some edge cases, the functions [`json::array()`](https://json.nlohmann.me/api/basic_json/array/) and [`json::object()`](https://json.nlohmann.me/api/basic_json/object/) will help: ```cpp // a way to express the empty array [] @@ -359,13 +266,18 @@ auto j2 = R"( )"_json; ``` -Note that without appending the `_json` suffix, the passed string literal is not parsed, but just used as JSON string value. That is, `json j = "{ \"happy\": true, \"pi\": 3.141 }"` would just store the string `"{ "happy": true, "pi": 3.141 }"` rather than parsing the actual object. +Note that without appending the `_json` suffix, the passed string literal is not parsed, but just used as JSON string +value. That is, `json j = "{ \"happy\": true, \"pi\": 3.141 }"` would just store the string +`"{ "happy": true, "pi": 3.141 }"` rather than parsing the actual object. + +The string literal should be brought into scope with `using namespace nlohmann::literals;` +(see [`json::parse()`](https://json.nlohmann.me/api/operator_literal_json/)). -The above example can also be expressed explicitly using [`json::parse()`](https://nlohmann.github.io/json/api/basic_json/parse/): +The above example can also be expressed explicitly using [`json::parse()`](https://json.nlohmann.me/api/basic_json/parse/): ```cpp // parse explicitly -auto j3 = json::parse("{ \"happy\": true, \"pi\": 3.141 }"); +auto j3 = json::parse(R"({"happy": true, "pi": 3.141})"); ``` You can also get a string representation of a JSON value (serialize): @@ -390,8 +302,8 @@ Note the difference between serialization and assignment: json j_string = "this is a string"; // retrieve the string value -auto cpp_string = j_string.get(); -// retrieve the string value (alternative when an variable already exists) +auto cpp_string = j_string.template get(); +// retrieve the string value (alternative when a variable already exists) std::string cpp_string2; j_string.get_to(cpp_string2); @@ -399,14 +311,14 @@ j_string.get_to(cpp_string2); std::string serialized_string = j_string.dump(); // output of original string -std::cout << cpp_string << " == " << cpp_string2 << " == " << j_string.get() << '\n'; +std::cout << cpp_string << " == " << cpp_string2 << " == " << j_string.template get() << '\n'; // output of serialized value std::cout << j_string << " == " << serialized_string << std::endl; ``` -[`.dump()`](https://nlohmann.github.io/json/api/basic_json/dump/) returns the originally stored string value. +[`.dump()`](https://json.nlohmann.me/api/basic_json/dump/) returns the originally stored string value. -Note the library only supports UTF-8. When you store strings with different encodings in the library, calling [`dump()`](https://nlohmann.github.io/json/api/basic_json/dump/) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers. +Note the library only supports UTF-8. When you store strings with different encodings in the library, calling [`dump()`](https://json.nlohmann.me/api/basic_json/dump/) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers. #### To/from streams (e.g. files, string streams) @@ -572,15 +484,15 @@ for (auto& element : j) { } // getter/setter -const auto tmp = j[0].get(); +const auto tmp = j[0].template get(); j[1] = 42; bool foo = j.at(2); // comparison -j == "[\"foo\", 42, true, 1.78]"_json; // true +j == R"(["foo", 1, true, 1.78])"_json; // true // other stuff -j.size(); // 3 entries +j.size(); // 4 entries j.empty(); // false j.type(); // json::value_t::array j.clear(); // the array is empty again @@ -700,7 +612,7 @@ json j_ummap(c_ummap); // only one entry for key "three" is used ### JSON Pointer and JSON Patch -The library supports **JSON Pointer** ([RFC 6901](https://tools.ietf.org/html/rfc6901)) as alternative means to address structured values. On top of this, **JSON Patch** ([RFC 6902](https://tools.ietf.org/html/rfc6902)) allows to describe differences between two JSON values - effectively allowing patch and diff operations known from Unix. +The library supports **JSON Pointer** ([RFC 6901](https://tools.ietf.org/html/rfc6901)) as alternative means to address structured values. On top of this, **JSON Patch** ([RFC 6902](https://tools.ietf.org/html/rfc6902)) allows describing differences between two JSON values - effectively allowing patch and diff operations known from Unix. ```cpp // a JSON value @@ -780,7 +692,7 @@ You can switch off implicit conversions by defining `JSON_USE_IMPLICIT_CONVERSIO // strings std::string s1 = "Hello, world!"; json js = s1; -auto s2 = js.get(); +auto s2 = js.template get(); // NOT RECOMMENDED std::string s3 = js; std::string s4; @@ -789,7 +701,7 @@ s4 = js; // Booleans bool b1 = true; json jb = b1; -auto b2 = jb.get(); +auto b2 = jb.template get(); // NOT RECOMMENDED bool b3 = jb; bool b4; @@ -798,7 +710,7 @@ b4 = jb; // numbers int i = 42; json jn = i; -auto f = jn.get(); +auto f = jn.template get(); // NOT RECOMMENDED double f2 = jb; double f3; @@ -841,9 +753,9 @@ j["age"] = p.age; // convert from JSON: copy each value from the JSON object ns::person p { - j["name"].get(), - j["address"].get(), - j["age"].get() + j["name"].template get(), + j["address"].template get(), + j["age"].template get() }; ``` @@ -860,7 +772,7 @@ std::cout << j << std::endl; // {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} // conversion: json -> person -auto p2 = j.get(); +auto p2 = j.template get(); // that's it assert(p == p2); @@ -871,7 +783,7 @@ assert(p == p2); To make this work with one of your types, you only need to provide two functions: ```cpp -using nlohmann::json; +using json = nlohmann::json; namespace ns { void to_json(json& j, const person& p) { @@ -887,14 +799,14 @@ namespace ns { ``` That's all! When calling the `json` constructor with your type, your custom `to_json` method will be automatically called. -Likewise, when calling `get()` or `get_to(your_type&)`, the `from_json` method will be called. +Likewise, when calling `template get()` or `get_to(your_type&)`, the `from_json` method will be called. Some important things: * Those methods **MUST** be in your type's namespace (which can be the global namespace), or the library will not be able to locate them (in this example, they are in namespace `ns`, where `person` is defined). * Those methods **MUST** be available (e.g., proper headers must be included) everywhere you use these conversions. Look at [issue 1108](https://github.com/nlohmann/json/issues/1108) for errors that may occur otherwise. -* When using `get()`, `your_type` **MUST** be [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). (There is a way to bypass this requirement described later.) -* In function `from_json`, use function [`at()`](https://nlohmann.github.io/json/api/basic_json/at/) to access the object values rather than `operator[]`. In case a key does not exist, `at` throws an exception that you can handle, whereas `operator[]` exhibits undefined behavior. +* When using `template get()`, `your_type` **MUST** be [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). (There is a way to bypass this requirement described later.) +* In function `from_json`, use function [`at()`](https://json.nlohmann.me/api/basic_json/at/) to access the object values rather than `operator[]`. In case a key does not exist, `at` throws an exception that you can handle, whereas `operator[]` exhibits undefined behavior. * You do not need to add serializers or deserializers for STL types like `std::vector`: the library already implements these. #### Simplify your life with macros @@ -903,8 +815,8 @@ If you just want to serialize/deserialize some structs, the `to_json`/`from_json There are two macros to make your life easier as long as you (1) want to use a JSON object as serialization and (2) want to use the member variable names as object keys in that object: -- `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(name, member1, member2, ...)` is to be defined inside of the namespace of the class/struct to create code for. -- `NLOHMANN_DEFINE_TYPE_INTRUSIVE(name, member1, member2, ...)` is to be defined inside of the class/struct to create code for. This macro can also access private members. +- `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(name, member1, member2, ...)` is to be defined inside the namespace of the class/struct to create code for. +- `NLOHMANN_DEFINE_TYPE_INTRUSIVE(name, member1, member2, ...)` is to be defined inside the class/struct to create code for. This macro can also access private members. In both macros, the first parameter is the name of the class/struct, and all remaining parameters name the members. @@ -978,8 +890,8 @@ namespace nlohmann { if (j.is_null()) { opt = boost::none; } else { - opt = j.get(); // same as above, but with - // adl_serializer::from_json + opt = j.template get(); // same as above, but with + // adl_serializer::from_json } } }; @@ -1006,10 +918,10 @@ namespace nlohmann { // note: the return type is no longer 'void', and the method only takes // one argument static move_only_type from_json(const json& j) { - return {j.get()}; + return {j.template get()}; } - // Here's the catch! You must provide a to_json method! Otherwise you + // Here's the catch! You must provide a to_json method! Otherwise, you // will not be able to convert move_only_type to json, since you fully // specialized adl_serializer on that type static void to_json(json& j, move_only_type t) { @@ -1021,7 +933,7 @@ namespace nlohmann { #### Can I write my own serializer? (Advanced use) -Yes. You might want to take a look at [`unit-udt.cpp`](https://github.com/nlohmann/json/blob/develop/test/src/unit-udt.cpp) in the test suite, to see a few examples. +Yes. You might want to take a look at [`unit-udt.cpp`](https://github.com/nlohmann/json/blob/develop/tests/src/unit-udt.cpp) in the test suite, to see a few examples. If you write your own serializer, you'll need to do a few things: @@ -1110,24 +1022,24 @@ assert(j == "stopped"); // json string to enum json j3 = "running"; -assert(j3.get() == TS_RUNNING); +assert(j3.template get() == TS_RUNNING); // undefined json value to enum (where the first map entry above is the default) json jPi = 3.14; -assert(jPi.get() == TS_INVALID ); +assert(jPi.template get() == TS_INVALID ); ``` Just as in [Arbitrary Type Conversions](#arbitrary-types-conversions) above, -- `NLOHMANN_JSON_SERIALIZE_ENUM()` MUST be declared in your enum type's namespace (which can be the global namespace), or the library will not be able to locate it and it will default to integer serialization. +- `NLOHMANN_JSON_SERIALIZE_ENUM()` MUST be declared in your enum type's namespace (which can be the global namespace), or the library will not be able to locate it, and it will default to integer serialization. - It MUST be available (e.g., proper headers must be included) everywhere you use the conversions. Other Important points: -- When using `get()`, undefined JSON values will default to the first pair specified in your map. Select this default pair carefully. +- When using `template get()`, undefined JSON values will default to the first pair specified in your map. Select this default pair carefully. - If an enum or JSON value is specified more than once in your map, the first matching occurrence from the top of the map will be returned when converting to or from JSON. -### Binary formats (BSON, CBOR, MessagePack, and UBJSON) +### Binary formats (BSON, CBOR, MessagePack, UBJSON, and BJData) -Though JSON is a ubiquitous data format, it is not a very compact format suitable for data exchange, for instance over a network. Hence, the library supports [BSON](http://bsonspec.org) (Binary JSON), [CBOR](https://cbor.io) (Concise Binary Object Representation), [MessagePack](https://msgpack.org), and [UBJSON](http://ubjson.org) (Universal Binary JSON Specification) to efficiently encode JSON values to byte vectors and to decode such vectors. +Though JSON is a ubiquitous data format, it is not a very compact format suitable for data exchange, for instance over a network. Hence, the library supports [BSON](https://bsonspec.org) (Binary JSON), [CBOR](https://cbor.io) (Concise Binary Object Representation), [MessagePack](https://msgpack.org), [UBJSON](https://ubjson.org) (Universal Binary JSON Specification) and [BJData](https://neurojson.org/bjdata) (Binary JData) to efficiently encode JSON values to byte vectors and to decode such vectors. ```cpp // create a JSON value @@ -1166,7 +1078,7 @@ std::vector v_ubjson = json::to_ubjson(j); json j_from_ubjson = json::from_ubjson(v_ubjson); ``` -The library also supports binary types from BSON, CBOR (byte strings), and MessagePack (bin, ext, fixext). They are stored by default as `std::vector` to be processed outside of the library. +The library also supports binary types from BSON, CBOR (byte strings), and MessagePack (bin, ext, fixext). They are stored by default as `std::vector` to be processed outside the library. ```cpp // CBOR byte string with payload 0xCAFE @@ -1199,15 +1111,17 @@ auto cbor = json::to_msgpack(j); // 0xD5 (fixext2), 0x10, 0xCA, 0xFE ## Supported compilers -Though it's 2021 already, the support for C++11 is still a bit sparse. Currently, the following compilers are known to work: +Though it's 2023 already, the support for C++11 is still a bit sparse. Currently, the following compilers are known to work: -- GCC 4.8 - 11.0 (and possibly later) -- Clang 3.4 - 11.0 (and possibly later) -- Apple Clang 9.1 - 12.3 (and possibly later) +- GCC 4.8 - 12.0 (and possibly later) +- Clang 3.4 - 15.0 (and possibly later) +- Apple Clang 9.1 - 13.1 (and possibly later) - Intel C++ Compiler 17.0.2 (and possibly later) +- Nvidia CUDA Compiler 11.0.221 (and possibly later) - Microsoft Visual C++ 2015 / Build Tools 14.0.25123.0 (and possibly later) - Microsoft Visual C++ 2017 / Build Tools 15.5.180.51428 (and possibly later) - Microsoft Visual C++ 2019 / Build Tools 16.3.1+1def00d3d (and possibly later) +- Microsoft Visual C++ 2022 / Build Tools 19.30.30709.0 (and possibly later) I would be happy to learn about other compilers/versions. @@ -1228,50 +1142,248 @@ Please note: - Unsupported versions of GCC and Clang are rejected by `#error` directives. This can be switched off by defining `JSON_SKIP_UNSUPPORTED_COMPILER_CHECK`. Note that you can expect no support in this case. -The following compilers are currently used in continuous integration at [Travis](https://travis-ci.org/nlohmann/json), [AppVeyor](https://ci.appveyor.com/project/nlohmann/json), [GitHub Actions](https://github.com/nlohmann/json/actions), and [CircleCI](https://circleci.com/gh/nlohmann/json): - -| Compiler | Operating System | CI Provider | -|-------------------------------------------------------------------|--------------------|----------------| -| Apple Clang 10.0.1 (clang-1001.0.46.4); Xcode 10.2.1 | macOS 10.14.4 | Travis | -| Apple Clang 11.0.0 (clang-1100.0.33.12); Xcode 11.2.1 | macOS 10.14.6 | Travis | -| Apple Clang 11.0.3 (clang-1103.0.32.59); Xcode 11.4.1 | macOS 10.15.4 | GitHub Actions | -| Apple Clang 12.0.0 (clang-1200.0.22.7); Xcode 11.4.1 | macOS 10.15.5 | Travis | -| Clang 3.5.0 (3.5.0-4ubuntu2\~trusty2) | Ubuntu 14.04.5 LTS | Travis | -| Clang 3.6.2 (3.6.2-svn240577-1\~exp1) | Ubuntu 14.04.5 LTS | Travis | -| Clang 3.7.1 (3.7.1-svn253571-1\~exp1) | Ubuntu 14.04.5 LTS | Travis | -| Clang 3.8.0 (3.8.0-2ubuntu3\~trusty5) | Ubuntu 14.04.5 LTS | Travis | -| Clang 3.9.1 (3.9.1-4ubuntu3\~14.04.3) | Ubuntu 14.04.5 LTS | Travis | -| Clang 4.0.1 (4.0.1-svn305264-1\~exp1) | Ubuntu 14.04.5 LTS | Travis | -| Clang 5.0.2 (version 5.0.2-svn328729-1\~exp1\~20180509123505.100) | Ubuntu 14.04.5 LTS | Travis | -| Clang 6.0.1 (6.0.1-svn334776-1\~exp1\~20190309042707.121) | Ubuntu 14.04.5 LTS | Travis | -| Clang 7.1.0 (7.1.0-svn353565-1\~exp1\~20190419134007.64) | Ubuntu 14.04.5 LTS | Travis | -| Clang 7.5.0 (Ubuntu 7.5.0-3ubuntu1\~18.04) | Ubuntu 18.04.4 LTS | Travis | -| Clang 9.0.0 (x86_64-pc-windows-msvc) | Windows-10.0.17763 | GitHub Actions | -| Clang 10.0.0 (x86_64-pc-windows-msvc) | Windows-10.0.17763 | GitHub Actions | -| GCC 4.8.5 (Ubuntu 4.8.5-4ubuntu8\~14.04.2) | Ubuntu 14.04.5 LTS | Travis | -| GCC 4.9.4 (Ubuntu 4.9.4-2ubuntu1\~14.04.1) | Ubuntu 14.04.5 LTS | Travis | -| GCC 5.5.0 (Ubuntu 5.5.0-12ubuntu1\~14.04) | Ubuntu 14.04.5 LTS | Travis | -| GCC 6.3.0 (Debian 6.3.0-18+deb9u1) | Debian 9 | Circle CI | -| GCC 6.5.0 (Ubuntu 6.5.0-2ubuntu1\~14.04.1) | Ubuntu 14.04.5 LTS | Travis | -| GCC 7.3.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) | Windows-6.3.9600 | AppVeyor | -| GCC 7.5.0 (Ubuntu 7.5.0-3ubuntu1\~14.04.1) | Ubuntu 14.04.5 LTS | Travis | -| GCC 7.5.0 (Ubuntu 7.5.0-3ubuntu1\~18.04) | Ubuntu 18.04.4 LTS | GitHub Actions | -| GCC 8.4.0 (Ubuntu 8.4.0-1ubuntu1\~14.04) | Ubuntu 14.04.5 LTS | Travis | -| GCC 9.3.0 (Ubuntu 9.3.0-11ubuntu0\~14.04) | Ubuntu 14.04.5 LTS | Travis | -| GCC 10.1.0 (Arch Linux latest) | Arch Linux | Circle CI | -| MSVC 19.0.24241.7 (Build Engine version 14.0.25420.1) | Windows-6.3.9600 | AppVeyor | -| MSVC 19.16.27035.0 (15.9.21+g9802d43bc3 for .NET Framework) | Windows-10.0.14393 | AppVeyor | -| MSVC 19.25.28614.0 (Build Engine version 16.5.0+d4cbfca49 for .NET Framework) | Windows-10.0.17763 | AppVeyor | -| MSVC 19.25.28614.0 (Build Engine version 16.5.0+d4cbfca49 for .NET Framework) | Windows-10.0.17763 | GitHub Actions | -| MSVC 19.25.28614.0 (Build Engine version 16.5.0+d4cbfca49 for .NET Framework) with ClangCL 10.0.0 | Windows-10.0.17763 | GitHub Actions | +The following compilers are currently used in continuous integration at [AppVeyor](https://ci.appveyor.com/project/nlohmann/json), [Cirrus CI](https://cirrus-ci.com/github/nlohmann/json), and [GitHub Actions](https://github.com/nlohmann/json/actions): + +| Compiler | Operating System | CI Provider | +|--------------------------------------------------------------------------------------------------------|--------------------|----------------| +| Apple Clang 11.0.3 (clang-1103.0.32.62); Xcode 11.7 | macOS 11.7.1 | GitHub Actions | +| Apple Clang 12.0.0 (clang-1200.0.32.29); Xcode 12.4 | macOS 11.7.1 | GitHub Actions | +| Apple Clang 12.0.5 (clang-1205.0.22.11); Xcode 12.5.1 | macOS 11.7.1 | GitHub Actions | +| Apple Clang 13.0.0 (clang-1300.0.29.3); Xcode 13.0 | macOS 11.7.1 | GitHub Actions | +| Apple Clang 13.0.0 (clang-1300.0.29.3); Xcode 13.1 | macOS 12.6.1 | GitHub Actions | +| Apple Clang 13.0.0 (clang-1300.0.29.30); Xcode 13.2.1 | macOS 12.6.1 | GitHub Actions | +| Apple Clang 13.1.6 (clang-1316.0.21.2.3); Xcode 13.3.1 | macOS 12.6.1 | GitHub Actions | +| Apple Clang 13.1.6 (clang-1316.0.21.2.5); Xcode 13.4.1 | macOS 12.6.1 | GitHub Actions | +| Apple Clang 14.0.0 (clang-1400.0.29.102); Xcode 14.0 | macOS 12.6.1 | GitHub Actions | +| Apple Clang 14.0.0 (clang-1400.0.29.102); Xcode 14.0.1 | macOS 12.6.1 | GitHub Actions | +| Apple Clang 14.0.0 (clang-1400.0.29.202); Xcode 14.1 | macOS 12.6.1 | GitHub Actions | +| Clang 3.5.2 | Ubuntu 20.04.3 LTS | GitHub Actions | +| Clang 3.6.2 | Ubuntu 20.04.3 LTS | GitHub Actions | +| Clang 3.7.1 | Ubuntu 20.04.3 LTS | GitHub Actions | +| Clang 3.8.1 | Ubuntu 20.04.3 LTS | GitHub Actions | +| Clang 3.9.1 | Ubuntu 20.04.3 LTS | GitHub Actions | +| Clang 4.0.1 | Ubuntu 20.04.3 LTS | GitHub Actions | +| Clang 5.0.2 | Ubuntu 20.04.3 LTS | GitHub Actions | +| Clang 6.0.1 | Ubuntu 20.04.3 LTS | GitHub Actions | +| Clang 7.0.1 | Ubuntu 20.04.3 LTS | GitHub Actions | +| Clang 8.0.0 | Ubuntu 20.04.3 LTS | GitHub Actions | +| Clang 9.0.0 | Ubuntu 20.04.3 LTS | GitHub Actions | +| Clang 10.0.0 | Ubuntu 20.04.3 LTS | GitHub Actions | +| Clang 10.0.0 with GNU-like command-line | Windows-10.0.17763 | GitHub Actions | +| Clang 11.0.0 with GNU-like command-line | Windows-10.0.17763 | GitHub Actions | +| Clang 11.0.0 with MSVC-like command-line | Windows-10.0.17763 | GitHub Actions | +| Clang 11.0.0 | Ubuntu 20.04.3 LTS | GitHub Actions | +| Clang 12.0.0 | Ubuntu 20.04.3 LTS | GitHub Actions | +| Clang 12.0.0 with GNU-like command-line | Windows-10.0.17763 | GitHub Actions | +| Clang 13.0.0 | Ubuntu 20.04.3 LTS | GitHub Actions | +| Clang 13.0.0 with GNU-like command-line | Windows-10.0.17763 | GitHub Actions | +| Clang 14.0.0 | Ubuntu 20.04.3 LTS | GitHub Actions | +| Clang 14.0.0 with GNU-like command-line | Windows-10.0.17763 | GitHub Actions | +| Clang 15.0.0 with GNU-like command-line | Windows-10.0.17763 | GitHub Actions | +| Clang 15.0.4 | Ubuntu 20.04.3 LTS | GitHub Actions | +| Clang 16.0.0 (16.0.0-++20221031071727+500876226c60-1~exp1~20221031071831.439) | Ubuntu 20.04.3 LTS | GitHub Actions | +| GCC 4.8.5 (Ubuntu 4.8.5-4ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions | +| GCC 4.9.4 | Ubuntu 20.04.3 LTS | GitHub Actions | +| GCC 5.5.0 | Ubuntu 20.04.3 LTS | GitHub Actions | +| GCC 6.5.0 | Ubuntu 20.04.3 LTS | GitHub Actions | +| GCC 7.5.0 | Ubuntu 20.04.3 LTS | GitHub Actions | +| GCC 8.1.0 (i686-posix-dwarf-rev0, Built by MinGW-W64 project) | Windows-10.0.17763 | GitHub Actions | +| GCC 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) | Windows-10.0.17763 | GitHub Actions | +| GCC 8.5.0 | Ubuntu 20.04.3 LTS | GitHub Actions | +| GCC 9.5.0 | Ubuntu 20.04.3 LTS | GitHub Actions | +| GCC 10.4.0 | Ubuntu 20.04.3 LTS | GitHub Actions | +| GCC 11.1.0 | Ubuntu (aarch64) | Cirrus CI | +| GCC 11.3.0 | Ubuntu 20.04.3 LTS | GitHub Actions | +| GCC 12.2.0 | Ubuntu 20.04.3 LTS | GitHub Actions | +| GCC 13.0.0 20220605 (experimental) | Ubuntu 20.04.3 LTS | GitHub Actions | +| Intel C++ Compiler 2021.5.0.20211109 | Ubuntu 20.04.3 LTS | GitHub Actions | +| NVCC 11.0.221 | Ubuntu 20.04.3 LTS | GitHub Actions | +| Visual Studio 14 2015 MSVC 19.0.24241.7 (Build Engine version 14.0.25420.1) | Windows-6.3.9600 | AppVeyor | +| Visual Studio 15 2017 MSVC 19.16.27035.0 (Build Engine version 15.9.21+g9802d43bc3 for .NET Framework) | Windows-10.0.14393 | AppVeyor | +| Visual Studio 16 2019 MSVC 19.28.29912.0 (Build Engine version 16.9.0+57a23d249 for .NET Framework) | Windows-10.0.17763 | GitHub Actions | +| Visual Studio 16 2019 MSVC 19.28.29912.0 (Build Engine version 16.9.0+57a23d249 for .NET Framework) | Windows-10.0.17763 | AppVeyor | +| Visual Studio 17 2022 MSVC 19.30.30709.0 (Build Engine version 17.0.31804.368 for .NET Framework) | Windows-10.0.20348 | GitHub Actions | + + +## Integration + +[`json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp) is the single required file in `single_include/nlohmann` or [released here](https://github.com/nlohmann/json/releases). You need to add + +```cpp +#include + +// for convenience +using json = nlohmann::json; +``` + +to the files you want to process JSON and set the necessary switches to enable C++11 (e.g., `-std=c++11` for GCC and Clang). + +You can further use file [`include/nlohmann/json_fwd.hpp`](https://github.com/nlohmann/json/blob/develop/include/nlohmann/json_fwd.hpp) for forward-declarations. The installation of json_fwd.hpp (as part of cmake's install step), can be achieved by setting `-DJSON_MultipleHeaders=ON`. + +### CMake + +You can also use the `nlohmann_json::nlohmann_json` interface target in CMake. This target populates the appropriate usage requirements for `INTERFACE_INCLUDE_DIRECTORIES` to point to the appropriate include directories and `INTERFACE_COMPILE_FEATURES` for the necessary C++11 flags. + +#### External + +To use this library from a CMake project, you can locate it directly with `find_package()` and use the namespaced imported target from the generated package configuration: + +```cmake +# CMakeLists.txt +find_package(nlohmann_json 3.2.0 REQUIRED) +... +add_library(foo ...) +... +target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json) +``` + +The package configuration file, `nlohmann_jsonConfig.cmake`, can be used either from an install tree or directly out of the build tree. + +#### Embedded + +To embed the library directly into an existing CMake project, place the entire source tree in a subdirectory and call `add_subdirectory()` in your `CMakeLists.txt` file: + +```cmake +# Typically you don't care so much for a third party library's tests to be +# run from your own project's code. +set(JSON_BuildTests OFF CACHE INTERNAL "") + +# If you only include this third party in PRIVATE source files, you do not +# need to install it when your main project gets installed. +# set(JSON_Install OFF CACHE INTERNAL "") + +# Don't use include(nlohmann_json/CMakeLists.txt) since that carries with it +# unintended consequences that will break the build. It's generally +# discouraged (although not necessarily well documented as such) to use +# include(...) for pulling in other CMake projects anyways. +add_subdirectory(nlohmann_json) +... +add_library(foo ...) +... +target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json) +``` + +##### Embedded (FetchContent) + +Since CMake v3.11, +[FetchContent](https://cmake.org/cmake/help/v3.11/module/FetchContent.html) can +be used to automatically download a release as a dependency at configure time. + +Example: +```cmake +include(FetchContent) + +FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz) +FetchContent_MakeAvailable(json) + +target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json) +``` + +**Note**: It is recommended to use the URL approach described above which is supported as of version 3.10.0. See + for more information. + +#### Supporting Both + +To allow your project to support either an externally supplied or an embedded JSON library, you can use a pattern akin to the following: + +``` cmake +# Top level CMakeLists.txt +project(FOO) +... +option(FOO_USE_EXTERNAL_JSON "Use an external JSON library" OFF) +... +add_subdirectory(thirdparty) +... +add_library(foo ...) +... +# Note that the namespaced target will always be available regardless of the +# import method +target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json) +``` +```cmake +# thirdparty/CMakeLists.txt +... +if(FOO_USE_EXTERNAL_JSON) + find_package(nlohmann_json 3.2.0 REQUIRED) +else() + set(JSON_BuildTests OFF CACHE INTERNAL "") + add_subdirectory(nlohmann_json) +endif() +... +``` + +`thirdparty/nlohmann_json` is then a complete copy of this source tree. + +### Package Managers + +:beer: If you are using OS X and [Homebrew](https://brew.sh), just type `brew install nlohmann-json` and you're set. If you want the bleeding edge rather than the latest release, use `brew install nlohmann-json --HEAD`. See [nlohmann-json](https://formulae.brew.sh/formula/nlohmann-json) for more information. + +If you are using the [Meson Build System](https://mesonbuild.com), add this source tree as a [meson subproject](https://mesonbuild.com/Subprojects.html#using-a-subproject). You may also use the `include.zip` published in this project's [Releases](https://github.com/nlohmann/json/releases) to reduce the size of the vendored source tree. Alternatively, you can get a wrap file by downloading it from [Meson WrapDB](https://wrapdb.mesonbuild.com/nlohmann_json), or simply use `meson wrap install nlohmann_json`. Please see the meson project for any issues regarding the packaging. + +The provided `meson.build` can also be used as an alternative to CMake for installing `nlohmann_json` system-wide in which case a pkg-config file is installed. To use it, simply have your build system require the `nlohmann_json` pkg-config dependency. In Meson, it is preferred to use the [`dependency()`](https://mesonbuild.com/Reference-manual.html#dependency) object with a subproject fallback, rather than using the subproject directly. + +If you are using [Bazel](https://bazel.build/) you can simply reference this repository using `http_archive` or `git_repository` and depend on `@nlohmann_json//:json`. + +If you are using [Conan](https://www.conan.io/) to manage your dependencies, merely add [`nlohmann_json/x.y.z`](https://conan.io/center/nlohmann_json) to your `conanfile`'s requires, where `x.y.z` is the release version you want to use. Please file issues [here](https://github.com/conan-io/conan-center-index/issues) if you experience problems with the packages. + +If you are using [Spack](https://www.spack.io/) to manage your dependencies, you can use the [`nlohmann-json` package](https://spack.readthedocs.io/en/latest/package_list.html#nlohmann-json). Please see the [spack project](https://github.com/spack/spack) for any issues regarding the packaging. + +If you are using [hunter](https://github.com/cpp-pm/hunter) on your project for external dependencies, then you can use the [nlohmann_json package](https://hunter.readthedocs.io/en/latest/packages/pkg/nlohmann_json.html). Please see the hunter project for any issues regarding the packaging. + +If you are using [Buckaroo](https://buckaroo.pm), you can install this library's module with `buckaroo add github.com/buckaroo-pm/nlohmann-json`. Please file issues [here](https://github.com/buckaroo-pm/nlohmann-json). There is a demo repo [here](https://github.com/njlr/buckaroo-nholmann-json-example). + +If you are using [vcpkg](https://github.com/Microsoft/vcpkg/) on your project for external dependencies, then you can install the [nlohmann-json package](https://github.com/Microsoft/vcpkg/tree/master/ports/nlohmann-json) with `vcpkg install nlohmann-json` and follow the then displayed descriptions. Please see the vcpkg project for any issues regarding the packaging. + +If you are using [cget](https://cget.readthedocs.io/en/latest/), you can install the latest development version with `cget install nlohmann/json`. A specific version can be installed with `cget install nlohmann/json@v3.1.0`. Also, the multiple header version can be installed by adding the `-DJSON_MultipleHeaders=ON` flag (i.e., `cget install nlohmann/json -DJSON_MultipleHeaders=ON`). + +If you are using [CocoaPods](https://cocoapods.org), you can use the library by adding pod `"nlohmann_json", '~>3.1.2'` to your podfile (see [an example](https://bitbucket.org/benman/nlohmann_json-cocoapod/src/master/)). Please file issues [here](https://bitbucket.org/benman/nlohmann_json-cocoapod/issues?status=new&status=open). + +If you are using [Swift Package Manager](https://swift.org/package-manager/), you can use the library by adding a package dependency to this repository. And target dependency as `.product(name: "nlohmann-json", package: "json")`. + +If you are using [NuGet](https://www.nuget.org), you can use the package [nlohmann.json](https://www.nuget.org/packages/nlohmann.json/). Please check [this extensive description](https://github.com/nlohmann/json/issues/1132#issuecomment-452250255) on how to use the package. Please file issues [here](https://github.com/hnkb/nlohmann-json-nuget/issues). + +If you are using [conda](https://conda.io/), you can use the package [nlohmann_json](https://github.com/conda-forge/nlohmann_json-feedstock) from [conda-forge](https://conda-forge.org) executing `conda install -c conda-forge nlohmann_json`. Please file issues [here](https://github.com/conda-forge/nlohmann_json-feedstock/issues). + +If you are using [MSYS2](https://www.msys2.org/), you can use the [mingw-w64-nlohmann-json](https://packages.msys2.org/base/mingw-w64-nlohmann-json) package, just type `pacman -S mingw-w64-i686-nlohmann-json` or `pacman -S mingw-w64-x86_64-nlohmann-json` for installation. Please file issues [here](https://github.com/msys2/MINGW-packages/issues/new?title=%5Bnlohmann-json%5D) if you experience problems with the packages. + +If you are using [MacPorts](https://ports.macports.org), execute `sudo port install nlohmann-json` to install the [nlohmann-json](https://ports.macports.org/port/nlohmann-json/) package. + +If you are using [`build2`](https://build2.org), you can use the [`nlohmann-json`](https://cppget.org/nlohmann-json) package from the public repository https://cppget.org or directly from the [package's sources repository](https://github.com/build2-packaging/nlohmann-json). In your project's `manifest` file, just add `depends: nlohmann-json` (probably with some [version constraints](https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml#guide-add-remove-deps)). If you are not familiar with using dependencies in `build2`, [please read this introduction](https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml). +Please file issues [here](https://github.com/build2-packaging/nlohmann-json) if you experience problems with the packages. + +If you are using [`wsjcpp`](https://wsjcpp.org), you can use the command `wsjcpp install "https://github.com/nlohmann/json:develop"` to get the latest version. Note you can change the branch ":develop" to an existing tag or another branch. + +If you are using [`CPM.cmake`](https://github.com/TheLartians/CPM.cmake), you can check this [`example`](https://github.com/TheLartians/CPM.cmake/tree/master/examples/json). After [adding CPM script](https://github.com/TheLartians/CPM.cmake#adding-cpm) to your project, implement the following snippet to your CMake: + +```cmake +CPMAddPackage( + NAME nlohmann_json + GITHUB_REPOSITORY nlohmann/json + VERSION 3.9.1) +``` + +### Pkg-config + +If you are using bare Makefiles, you can use `pkg-config` to generate the include flags that point to where the library is installed: + +```sh +pkg-config nlohmann_json --cflags +``` + +Users of the Meson build system will also be able to use a system-wide library, which will be found by `pkg-config`: + +```meson +json = dependency('nlohmann_json', required: true) +``` + ## License - + -The class is licensed under the [MIT License](http://opensource.org/licenses/MIT): +The class is licensed under the [MIT License](https://opensource.org/licenses/MIT): -Copyright © 2013-2021 [Niels Lohmann](https://nlohmann.me) +Copyright © 2013-2022 [Niels Lohmann](https://nlohmann.me) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Softwareâ€), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: @@ -1281,12 +1393,14 @@ THE SOFTWARE IS PROVIDED “AS ISâ€, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR I * * * -The class contains the UTF-8 Decoder from Bjoern Hoehrmann which is licensed under the [MIT License](http://opensource.org/licenses/MIT) (see above). Copyright © 2008-2009 [Björn Hoehrmann](https://bjoern.hoehrmann.de/) +The class contains the UTF-8 Decoder from Bjoern Hoehrmann which is licensed under the [MIT License](https://opensource.org/licenses/MIT) (see above). Copyright © 2008-2009 [Björn Hoehrmann](https://bjoern.hoehrmann.de/) -The class contains a slightly modified version of the Grisu2 algorithm from Florian Loitsch which is licensed under the [MIT License](http://opensource.org/licenses/MIT) (see above). Copyright © 2009 [Florian Loitsch](https://florian.loitsch.com/) +The class contains a slightly modified version of the Grisu2 algorithm from Florian Loitsch which is licensed under the [MIT License](https://opensource.org/licenses/MIT) (see above). Copyright © 2009 [Florian Loitsch](https://florian.loitsch.com/) The class contains a copy of [Hedley](https://nemequ.github.io/hedley/) from Evan Nemerson which is licensed as [CC0-1.0](https://creativecommons.org/publicdomain/zero/1.0/). +The class contains parts of [Google Abseil](https://github.com/abseil/abseil-cpp) which is licensed under the [Apache 2.0 License](https://opensource.org/licenses/Apache-2.0). + ## Contact If you have questions regarding the library, I would like to invite you to [open an issue at GitHub](https://github.com/nlohmann/json/issues/new/choose). Please describe your request, problem, or question as detailed as possible, and also mention the version of the library you are using as well as the version of your compiler and operating system. Opening an issue at GitHub allows other users and contributors to this library to collaborate. For instance, I have little experience with MSVC, and most issues in this regard have been solved by a growing community. If you have a look at the [closed issues](https://github.com/nlohmann/json/issues?q=is%3Aissue+is%3Aclosed), you will see that we react quite timely in most cases. @@ -1301,234 +1415,354 @@ Only if your request would contain confidential information, please [send me an I deeply appreciate the help of the following people. - - -- [Teemperor](https://github.com/Teemperor) implemented CMake support and lcov integration, realized escape and Unicode handling in the string parser, and fixed the JSON serialization. -- [elliotgoodrich](https://github.com/elliotgoodrich) fixed an issue with double deletion in the iterator classes. -- [kirkshoop](https://github.com/kirkshoop) made the iterators of the class composable to other libraries. -- [wancw](https://github.com/wanwc) fixed a bug that hindered the class to compile with Clang. -- Tomas Ã…blad found a bug in the iterator implementation. -- [Joshua C. Randall](https://github.com/jrandall) fixed a bug in the floating-point serialization. -- [Aaron Burghardt](https://github.com/aburgh) implemented code to parse streams incrementally. Furthermore, he greatly improved the parser class by allowing the definition of a filter function to discard undesired elements while parsing. -- [Daniel KopeÄek](https://github.com/dkopecek) fixed a bug in the compilation with GCC 5.0. -- [Florian Weber](https://github.com/Florianjw) fixed a bug in and improved the performance of the comparison operators. -- [Eric Cornelius](https://github.com/EricMCornelius) pointed out a bug in the handling with NaN and infinity values. He also improved the performance of the string escaping. -- [易æ€é¾™](https://github.com/likebeta) implemented a conversion from anonymous enums. -- [kepkin](https://github.com/kepkin) patiently pushed forward the support for Microsoft Visual studio. -- [gregmarr](https://github.com/gregmarr) simplified the implementation of reverse iterators and helped with numerous hints and improvements. In particular, he pushed forward the implementation of user-defined types. -- [Caio Luppi](https://github.com/caiovlp) fixed a bug in the Unicode handling. -- [dariomt](https://github.com/dariomt) fixed some typos in the examples. -- [Daniel Frey](https://github.com/d-frey) cleaned up some pointers and implemented exception-safe memory allocation. -- [Colin Hirsch](https://github.com/ColinH) took care of a small namespace issue. -- [Huu Nguyen](https://github.com/whoshuu) correct a variable name in the documentation. -- [Silverweed](https://github.com/silverweed) overloaded `parse()` to accept an rvalue reference. -- [dariomt](https://github.com/dariomt) fixed a subtlety in MSVC type support and implemented the `get_ref()` function to get a reference to stored values. -- [ZahlGraf](https://github.com/ZahlGraf) added a workaround that allows compilation using Android NDK. -- [whackashoe](https://github.com/whackashoe) replaced a function that was marked as unsafe by Visual Studio. -- [406345](https://github.com/406345) fixed two small warnings. -- [Glen Fernandes](https://github.com/glenfe) noted a potential portability problem in the `has_mapped_type` function. -- [Corbin Hughes](https://github.com/nibroc) fixed some typos in the contribution guidelines. -- [twelsby](https://github.com/twelsby) fixed the array subscript operator, an issue that failed the MSVC build, and floating-point parsing/dumping. He further added support for unsigned integer numbers and implemented better roundtrip support for parsed numbers. -- [Volker Diels-Grabsch](https://github.com/vog) fixed a link in the README file. -- [msm-](https://github.com/msm-) added support for American Fuzzy Lop. -- [Annihil](https://github.com/Annihil) fixed an example in the README file. -- [Themercee](https://github.com/Themercee) noted a wrong URL in the README file. -- [Lv Zheng](https://github.com/lv-zheng) fixed a namespace issue with `int64_t` and `uint64_t`. -- [abc100m](https://github.com/abc100m) analyzed the issues with GCC 4.8 and proposed a [partial solution](https://github.com/nlohmann/json/pull/212). -- [zewt](https://github.com/zewt) added useful notes to the README file about Android. -- [Róbert Márki](https://github.com/robertmrk) added a fix to use move iterators and improved the integration via CMake. -- [Chris Kitching](https://github.com/ChrisKitching) cleaned up the CMake files. -- [Tom Needham](https://github.com/06needhamt) fixed a subtle bug with MSVC 2015 which was also proposed by [Michael K.](https://github.com/Epidal). -- [Mário Feroldi](https://github.com/thelostt) fixed a small typo. -- [duncanwerner](https://github.com/duncanwerner) found a really embarrassing performance regression in the 2.0.0 release. -- [Damien](https://github.com/dtoma) fixed one of the last conversion warnings. -- [Thomas Braun](https://github.com/t-b) fixed a warning in a test case and adjusted MSVC calls in the CI. -- [Théo DELRIEU](https://github.com/theodelrieu) patiently and constructively oversaw the long way toward [iterator-range parsing](https://github.com/nlohmann/json/issues/290). He also implemented the magic behind the serialization/deserialization of user-defined types and split the single header file into smaller chunks. -- [Stefan](https://github.com/5tefan) fixed a minor issue in the documentation. -- [Vasil Dimov](https://github.com/vasild) fixed the documentation regarding conversions from `std::multiset`. -- [ChristophJud](https://github.com/ChristophJud) overworked the CMake files to ease project inclusion. -- [Vladimir Petrigo](https://github.com/vpetrigo) made a SFINAE hack more readable and added Visual Studio 17 to the build matrix. -- [Denis Andrejew](https://github.com/seeekr) fixed a grammar issue in the README file. -- [Pierre-Antoine Lacaze](https://github.com/palacaze) found a subtle bug in the `dump()` function. -- [TurpentineDistillery](https://github.com/TurpentineDistillery) pointed to [`std::locale::classic()`](https://en.cppreference.com/w/cpp/locale/locale/classic) to avoid too much locale joggling, found some nice performance improvements in the parser, improved the benchmarking code, and realized locale-independent number parsing and printing. -- [cgzones](https://github.com/cgzones) had an idea how to fix the Coverity scan. -- [Jared Grubb](https://github.com/jaredgrubb) silenced a nasty documentation warning. -- [Yixin Zhang](https://github.com/qwename) fixed an integer overflow check. -- [Bosswestfalen](https://github.com/Bosswestfalen) merged two iterator classes into a smaller one. -- [Daniel599](https://github.com/Daniel599) helped to get Travis execute the tests with Clang's sanitizers. -- [Jonathan Lee](https://github.com/vjon) fixed an example in the README file. -- [gnzlbg](https://github.com/gnzlbg) supported the implementation of user-defined types. -- [Alexej Harm](https://github.com/qis) helped to get the user-defined types working with Visual Studio. -- [Jared Grubb](https://github.com/jaredgrubb) supported the implementation of user-defined types. -- [EnricoBilla](https://github.com/EnricoBilla) noted a typo in an example. -- [Martin HoÅ™eňovský](https://github.com/horenmar) found a way for a 2x speedup for the compilation time of the test suite. -- [ukhegg](https://github.com/ukhegg) found proposed an improvement for the examples section. -- [rswanson-ihi](https://github.com/rswanson-ihi) noted a typo in the README. -- [Mihai Stan](https://github.com/stanmihai4) fixed a bug in the comparison with `nullptr`s. -- [Tushar Maheshwari](https://github.com/tusharpm) added [cotire](https://github.com/sakra/cotire) support to speed up the compilation. -- [TedLyngmo](https://github.com/TedLyngmo) noted a typo in the README, removed unnecessary bit arithmetic, and fixed some `-Weffc++` warnings. -- [Krzysztof WoÅ›](https://github.com/krzysztofwos) made exceptions more visible. -- [ftillier](https://github.com/ftillier) fixed a compiler warning. -- [tinloaf](https://github.com/tinloaf) made sure all pushed warnings are properly popped. -- [Fytch](https://github.com/Fytch) found a bug in the documentation. -- [Jay Sistar](https://github.com/Type1J) implemented a Meson build description. -- [Henry Lee](https://github.com/HenryRLee) fixed a warning in ICC and improved the iterator implementation. -- [Vincent Thiery](https://github.com/vthiery) maintains a package for the Conan package manager. -- [Steffen](https://github.com/koemeet) fixed a potential issue with MSVC and `std::min`. -- [Mike Tzou](https://github.com/Chocobo1) fixed some typos. -- [amrcode](https://github.com/amrcode) noted a misleading documentation about comparison of floats. -- [Oleg Endo](https://github.com/olegendo) reduced the memory consumption by replacing `` with ``. -- [dan-42](https://github.com/dan-42) cleaned up the CMake files to simplify including/reusing of the library. -- [Nikita Ofitserov](https://github.com/himikof) allowed for moving values from initializer lists. -- [Greg Hurrell](https://github.com/wincent) fixed a typo. -- [Dmitry Kukovinets](https://github.com/DmitryKuk) fixed a typo. -- [kbthomp1](https://github.com/kbthomp1) fixed an issue related to the Intel OSX compiler. -- [Markus Werle](https://github.com/daixtrose) fixed a typo. -- [WebProdPP](https://github.com/WebProdPP) fixed a subtle error in a precondition check. -- [Alex](https://github.com/leha-bot) noted an error in a code sample. -- [Tom de Geus](https://github.com/tdegeus) reported some warnings with ICC and helped fixing them. -- [Perry Kundert](https://github.com/pjkundert) simplified reading from input streams. -- [Sonu Lohani](https://github.com/sonulohani) fixed a small compilation error. -- [Jamie Seward](https://github.com/jseward) fixed all MSVC warnings. -- [Nate Vargas](https://github.com/eld00d) added a Doxygen tag file. -- [pvleuven](https://github.com/pvleuven) helped fixing a warning in ICC. -- [Pavel](https://github.com/crea7or) helped fixing some warnings in MSVC. -- [Jamie Seward](https://github.com/jseward) avoided unnecessary string copies in `find()` and `count()`. -- [Mitja](https://github.com/Itja) fixed some typos. -- [Jorrit Wronski](https://github.com/jowr) updated the Hunter package links. -- [Matthias Möller](https://github.com/TinyTinni) added a `.natvis` for the MSVC debug view. -- [bogemic](https://github.com/bogemic) fixed some C++17 deprecation warnings. -- [Eren Okka](https://github.com/erengy) fixed some MSVC warnings. -- [abolz](https://github.com/abolz) integrated the Grisu2 algorithm for proper floating-point formatting, allowing more roundtrip checks to succeed. -- [Vadim Evard](https://github.com/Pipeliner) fixed a Markdown issue in the README. -- [zerodefect](https://github.com/zerodefect) fixed a compiler warning. -- [Kert](https://github.com/kaidokert) allowed to template the string type in the serialization and added the possibility to override the exceptional behavior. -- [mark-99](https://github.com/mark-99) helped fixing an ICC error. -- [Patrik Huber](https://github.com/patrikhuber) fixed links in the README file. -- [johnfb](https://github.com/johnfb) found a bug in the implementation of CBOR's indefinite length strings. -- [Paul Fultz II](https://github.com/pfultz2) added a note on the cget package manager. -- [Wilson Lin](https://github.com/wla80) made the integration section of the README more concise. -- [RalfBielig](https://github.com/ralfbielig) detected and fixed a memory leak in the parser callback. -- [agrianius](https://github.com/agrianius) allowed to dump JSON to an alternative string type. -- [Kevin Tonon](https://github.com/ktonon) overworked the C++11 compiler checks in CMake. -- [Axel Huebl](https://github.com/ax3l) simplified a CMake check and added support for the [Spack package manager](https://spack.io). -- [Carlos O'Ryan](https://github.com/coryan) fixed a typo. -- [James Upjohn](https://github.com/jammehcow) fixed a version number in the compilers section. -- [Chuck Atkins](https://github.com/chuckatkins) adjusted the CMake files to the CMake packaging guidelines and provided documentation for the CMake integration. -- [Jan Schöppach](https://github.com/dns13) fixed a typo. -- [martin-mfg](https://github.com/martin-mfg) fixed a typo. -- [Matthias Möller](https://github.com/TinyTinni) removed the dependency from `std::stringstream`. -- [agrianius](https://github.com/agrianius) added code to use alternative string implementations. -- [Daniel599](https://github.com/Daniel599) allowed to use more algorithms with the `items()` function. -- [Julius Rakow](https://github.com/jrakow) fixed the Meson include directory and fixed the links to [cppreference.com](cppreference.com). -- [Sonu Lohani](https://github.com/sonulohani) fixed the compilation with MSVC 2015 in debug mode. -- [grembo](https://github.com/grembo) fixed the test suite and re-enabled several test cases. -- [Hyeon Kim](https://github.com/simnalamburt) introduced the macro `JSON_INTERNAL_CATCH` to control the exception handling inside the library. -- [thyu](https://github.com/thyu) fixed a compiler warning. -- [David Guthrie](https://github.com/LEgregius) fixed a subtle compilation error with Clang 3.4.2. -- [Dennis Fischer](https://github.com/dennisfischer) allowed to call `find_package` without installing the library. -- [Hyeon Kim](https://github.com/simnalamburt) fixed an issue with a double macro definition. -- [Ben Berman](https://github.com/rivertam) made some error messages more understandable. -- [zakalibit](https://github.com/zakalibit) fixed a compilation problem with the Intel C++ compiler. -- [mandreyel](https://github.com/mandreyel) fixed a compilation problem. -- [Kostiantyn Ponomarenko](https://github.com/koponomarenko) added version and license information to the Meson build file. -- [Henry Schreiner](https://github.com/henryiii) added support for GCC 4.8. -- [knilch](https://github.com/knilch0r) made sure the test suite does not stall when run in the wrong directory. -- [Antonio Borondo](https://github.com/antonioborondo) fixed an MSVC 2017 warning. -- [Dan Gendreau](https://github.com/dgendreau) implemented the `NLOHMANN_JSON_SERIALIZE_ENUM` macro to quickly define a enum/JSON mapping. -- [efp](https://github.com/efp) added line and column information to parse errors. -- [julian-becker](https://github.com/julian-becker) added BSON support. -- [Pratik Chowdhury](https://github.com/pratikpc) added support for structured bindings. -- [David Avedissian](https://github.com/davedissian) added support for Clang 5.0.1 (PS4 version). -- [Jonathan Dumaresq](https://github.com/dumarjo) implemented an input adapter to read from `FILE*`. -- [kjpus](https://github.com/kjpus) fixed a link in the documentation. -- [Manvendra Singh](https://github.com/manu-chroma) fixed a typo in the documentation. -- [ziggurat29](https://github.com/ziggurat29) fixed an MSVC warning. -- [Sylvain Corlay](https://github.com/SylvainCorlay) added code to avoid an issue with MSVC. -- [mefyl](https://github.com/mefyl) fixed a bug when JSON was parsed from an input stream. -- [Millian Poquet](https://github.com/mpoquet) allowed to install the library via Meson. -- [Michael Behrns-Miller](https://github.com/moodboom) found an issue with a missing namespace. -- [Nasztanovics Ferenc](https://github.com/naszta) fixed a compilation issue with libc 2.12. -- [Andreas Schwab](https://github.com/andreas-schwab) fixed the endian conversion. -- [Mark-Dunning](https://github.com/Mark-Dunning) fixed a warning in MSVC. -- [Gareth Sylvester-Bradley](https://github.com/garethsb-sony) added `operator/` for JSON Pointers. -- [John-Mark](https://github.com/johnmarkwayve) noted a missing header. -- [Vitaly Zaitsev](https://github.com/xvitaly) fixed compilation with GCC 9.0. -- [Laurent Stacul](https://github.com/stac47) fixed compilation with GCC 9.0. -- [Ivor Wanders](https://github.com/iwanders) helped reducing the CMake requirement to version 3.1. -- [njlr](https://github.com/njlr) updated the Buckaroo instructions. -- [Lion](https://github.com/lieff) fixed a compilation issue with GCC 7 on CentOS. -- [Isaac Nickaein](https://github.com/nickaein) improved the integer serialization performance and implemented the `contains()` function. -- [past-due](https://github.com/past-due) suppressed an unfixable warning. -- [Elvis Oric](https://github.com/elvisoric) improved Meson support. -- [MatÄ›j Plch](https://github.com/Afforix) fixed an example in the README. -- [Mark Beckwith](https://github.com/wythe) fixed a typo. -- [scinart](https://github.com/scinart) fixed bug in the serializer. -- [Patrick Boettcher](https://github.com/pboettch) implemented `push_back()` and `pop_back()` for JSON Pointers. -- [Bruno Oliveira](https://github.com/nicoddemus) added support for Conda. -- [Michele Caini](https://github.com/skypjack) fixed links in the README. -- [Hani](https://github.com/hnkb) documented how to install the library with NuGet. -- [Mark Beckwith](https://github.com/wythe) fixed a typo. -- [yann-morin-1998](https://github.com/yann-morin-1998) helped reducing the CMake requirement to version 3.1. -- [Konstantin Podsvirov](https://github.com/podsvirov) maintains a package for the MSYS2 software distro. -- [remyabel](https://github.com/remyabel) added GNUInstallDirs to the CMake files. -- [Taylor Howard](https://github.com/taylorhoward92) fixed a unit test. -- [Gabe Ron](https://github.com/Macr0Nerd) implemented the `to_string` method. -- [Watal M. Iwasaki](https://github.com/heavywatal) fixed a Clang warning. -- [Viktor Kirilov](https://github.com/onqtam) switched the unit tests from [Catch](https://github.com/philsquared/Catch) to [doctest](https://github.com/onqtam/doctest) -- [Juncheng E](https://github.com/ejcjason) fixed a typo. -- [tete17](https://github.com/tete17) fixed a bug in the `contains` function. -- [Xav83](https://github.com/Xav83) fixed some cppcheck warnings. -- [0xflotus](https://github.com/0xflotus) fixed some typos. -- [Christian Deneke](https://github.com/chris0x44) added a const version of `json_pointer::back`. -- [Julien Hamaide](https://github.com/crazyjul) made the `items()` function work with custom string types. -- [Evan Nemerson](https://github.com/nemequ) updated fixed a bug in Hedley and updated this library accordingly. -- [Florian Pigorsch](https://github.com/flopp) fixed a lot of typos. -- [Camille Bégué](https://github.com/cbegue) fixed an issue in the conversion from `std::pair` and `std::tuple` to `json`. -- [Anthony VH](https://github.com/AnthonyVH) fixed a compile error in an enum deserialization. -- [Yuriy Vountesmery](https://github.com/ua-code-dragon) noted a subtle bug in a preprocessor check. -- [Chen](https://github.com/dota17) fixed numerous issues in the library. -- [Antony Kellermann](https://github.com/aokellermann) added a CI step for GCC 10.1. -- [Alex](https://github.com/gistrec) fixed an MSVC warning. -- [Rainer](https://github.com/rvjr) proposed an improvement in the floating-point serialization in CBOR. -- [Francois Chabot](https://github.com/FrancoisChabot) made performance improvements in the input adapters. -- [Arthur Sonzogni](https://github.com/ArthurSonzogni) documented how the library can be included via `FetchContent`. -- [Rimas MiseviÄius](https://github.com/rmisev) fixed an error message. -- [Alexander Myasnikov](https://github.com/alexandermyasnikov) fixed some examples and a link in the README. -- [Hubert Chathi](https://github.com/uhoreg) made CMake's version config file architecture-independent. -- [OmnipotentEntity](https://github.com/OmnipotentEntity) implemented the binary values for CBOR, MessagePack, BSON, and UBJSON. -- [ArtemSarmini](https://github.com/ArtemSarmini) fixed a compilation issue with GCC 10 and fixed a leak. -- [Evgenii Sopov](https://github.com/sea-kg) integrated the library to the wsjcpp package manager. -- [Sergey Linev](https://github.com/linev) fixed a compiler warning. -- [Miguel Magalhães](https://github.com/magamig) fixed the year in the copyright. -- [Gareth Sylvester-Bradley](https://github.com/garethsb-sony) fixed a compilation issue with MSVC. -- [Alexander “weej†Jones](https://github.com/alex-weej) fixed an example in the README. -- [Antoine CÅ“ur](https://github.com/Coeur) fixed some typos in the documentation. -- [jothepro](https://github.com/jothepro) updated links to the Hunter package. -- [Dave Lee](https://github.com/kastiglione) fixed link in the README. -- [Joël Lamotte](https://github.com/Klaim) added instruction for using Build2's package manager. -- [Paul Jurczak](https://github.com/pauljurczak) fixed an example in the README. -- [Sonu Lohani](https://github.com/sonulohani) fixed a warning. -- [Carlos Gomes Martinho](https://github.com/gocarlos) updated the Conan package source. -- [Konstantin Podsvirov](https://github.com/podsvirov) fixed the MSYS2 package documentation. -- [Tridacnid](https://github.com/Tridacnid) improved the CMake tests. -- [Michael](https://github.com/MBalszun) fixed MSVC warnings. -- [Quentin Barbarat](https://github.com/quentin-dev) fixed an example in the documentation. -- [XyFreak](https://github.com/XyFreak) fixed a compiler warning. -- [TotalCaesar659](https://github.com/TotalCaesar659) fixed links in the README. -- [Tanuj Garg](https://github.com/tanuj208) improved the fuzzer coverage for UBSAN input. -- [AODQ](https://github.com/AODQ) fixed a compiler warning. -- [jwittbrodt](https://github.com/jwittbrodt) made `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE` inline. -- [pfeatherstone](https://github.com/pfeatherstone) improved the upper bound of arguments of the `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`/`NLOHMANN_DEFINE_TYPE_INTRUSIVE` macros. -- [Jan Procházka](https://github.com/jprochazk) fixed a bug in the CBOR parser for binary and string values. -- [T0b1-iOS](https://github.com/T0b1-iOS) fixed a bug in the new hash implementation. -- [Matthew Bauer](https://github.com/matthewbauer) adjusted the CBOR writer to create tags for binary subtypes. -- [gatopeich](https://github.com/gatopeich) implemented an ordered map container for `nlohmann::ordered_json`. -- [Érico Nogueira Rolim](https://github.com/ericonr) added support for pkg-config. -- [KonanM](https://github.com/KonanM) proposed an implementation for the `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`/`NLOHMANN_DEFINE_TYPE_INTRUSIVE` macros. -- [Guillaume Racicot](https://github.com/gracicot) implemented `string_view` support and allowed C++20 support. -- [Alex Reinking](https://github.com/alexreinking) improved CMake support for `FetchContent`. -- [Hannes Domani](https://github.com/ssbssa) provided a GDB pretty printer. + + +1. [Teemperor](https://github.com/Teemperor) implemented CMake support and lcov integration, realized escape and Unicode handling in the string parser, and fixed the JSON serialization. +2. [elliotgoodrich](https://github.com/elliotgoodrich) fixed an issue with double deletion in the iterator classes. +3. [kirkshoop](https://github.com/kirkshoop) made the iterators of the class composable to other libraries. +4. [wancw](https://github.com/wanwc) fixed a bug that hindered the class to compile with Clang. +5. Tomas Ã…blad found a bug in the iterator implementation. +6. [Joshua C. Randall](https://github.com/jrandall) fixed a bug in the floating-point serialization. +7. [Aaron Burghardt](https://github.com/aburgh) implemented code to parse streams incrementally. Furthermore, he greatly improved the parser class by allowing the definition of a filter function to discard undesired elements while parsing. +8. [Daniel KopeÄek](https://github.com/dkopecek) fixed a bug in the compilation with GCC 5.0. +9. [Florian Weber](https://github.com/Florianjw) fixed a bug in and improved the performance of the comparison operators. +10. [Eric Cornelius](https://github.com/EricMCornelius) pointed out a bug in the handling with NaN and infinity values. He also improved the performance of the string escaping. +11. [易æ€é¾™](https://github.com/likebeta) implemented a conversion from anonymous enums. +12. [kepkin](https://github.com/kepkin) patiently pushed forward the support for Microsoft Visual studio. +13. [gregmarr](https://github.com/gregmarr) simplified the implementation of reverse iterators and helped with numerous hints and improvements. In particular, he pushed forward the implementation of user-defined types. +14. [Caio Luppi](https://github.com/caiovlp) fixed a bug in the Unicode handling. +15. [dariomt](https://github.com/dariomt) fixed some typos in the examples. +16. [Daniel Frey](https://github.com/d-frey) cleaned up some pointers and implemented exception-safe memory allocation. +17. [Colin Hirsch](https://github.com/ColinH) took care of a small namespace issue. +18. [Huu Nguyen](https://github.com/whoshuu) correct a variable name in the documentation. +19. [Silverweed](https://github.com/silverweed) overloaded `parse()` to accept an rvalue reference. +20. [dariomt](https://github.com/dariomt) fixed a subtlety in MSVC type support and implemented the `get_ref()` function to get a reference to stored values. +21. [ZahlGraf](https://github.com/ZahlGraf) added a workaround that allows compilation using Android NDK. +22. [whackashoe](https://github.com/whackashoe) replaced a function that was marked as unsafe by Visual Studio. +23. [406345](https://github.com/406345) fixed two small warnings. +24. [Glen Fernandes](https://github.com/glenfe) noted a potential portability problem in the `has_mapped_type` function. +25. [Corbin Hughes](https://github.com/nibroc) fixed some typos in the contribution guidelines. +26. [twelsby](https://github.com/twelsby) fixed the array subscript operator, an issue that failed the MSVC build, and floating-point parsing/dumping. He further added support for unsigned integer numbers and implemented better roundtrip support for parsed numbers. +27. [Volker Diels-Grabsch](https://github.com/vog) fixed a link in the README file. +28. [msm-](https://github.com/msm-) added support for American Fuzzy Lop. +29. [Annihil](https://github.com/Annihil) fixed an example in the README file. +30. [Themercee](https://github.com/Themercee) noted a wrong URL in the README file. +31. [Lv Zheng](https://github.com/lv-zheng) fixed a namespace issue with `int64_t` and `uint64_t`. +32. [abc100m](https://github.com/abc100m) analyzed the issues with GCC 4.8 and proposed a [partial solution](https://github.com/nlohmann/json/pull/212). +33. [zewt](https://github.com/zewt) added useful notes to the README file about Android. +34. [Róbert Márki](https://github.com/robertmrk) added a fix to use move iterators and improved the integration via CMake. +35. [Chris Kitching](https://github.com/ChrisKitching) cleaned up the CMake files. +36. [Tom Needham](https://github.com/06needhamt) fixed a subtle bug with MSVC 2015 which was also proposed by [Michael K.](https://github.com/Epidal). +37. [Mário Feroldi](https://github.com/thelostt) fixed a small typo. +38. [duncanwerner](https://github.com/duncanwerner) found a really embarrassing performance regression in the 2.0.0 release. +39. [Damien](https://github.com/dtoma) fixed one of the last conversion warnings. +40. [Thomas Braun](https://github.com/t-b) fixed a warning in a test case and adjusted MSVC calls in the CI. +41. [Théo DELRIEU](https://github.com/theodelrieu) patiently and constructively oversaw the long way toward [iterator-range parsing](https://github.com/nlohmann/json/issues/290). He also implemented the magic behind the serialization/deserialization of user-defined types and split the single header file into smaller chunks. +42. [Stefan](https://github.com/5tefan) fixed a minor issue in the documentation. +43. [Vasil Dimov](https://github.com/vasild) fixed the documentation regarding conversions from `std::multiset`. +44. [ChristophJud](https://github.com/ChristophJud) overworked the CMake files to ease project inclusion. +45. [Vladimir Petrigo](https://github.com/vpetrigo) made a SFINAE hack more readable and added Visual Studio 17 to the build matrix. +46. [Denis Andrejew](https://github.com/seeekr) fixed a grammar issue in the README file. +47. [Pierre-Antoine Lacaze](https://github.com/palacaze) found a subtle bug in the `dump()` function. +48. [TurpentineDistillery](https://github.com/TurpentineDistillery) pointed to [`std::locale::classic()`](https://en.cppreference.com/w/cpp/locale/locale/classic) to avoid too much locale joggling, found some nice performance improvements in the parser, improved the benchmarking code, and realized locale-independent number parsing and printing. +49. [cgzones](https://github.com/cgzones) had an idea how to fix the Coverity scan. +50. [Jared Grubb](https://github.com/jaredgrubb) silenced a nasty documentation warning. +51. [Yixin Zhang](https://github.com/qwename) fixed an integer overflow check. +52. [Bosswestfalen](https://github.com/Bosswestfalen) merged two iterator classes into a smaller one. +53. [Daniel599](https://github.com/Daniel599) helped to get Travis execute the tests with Clang's sanitizers. +54. [Jonathan Lee](https://github.com/vjon) fixed an example in the README file. +55. [gnzlbg](https://github.com/gnzlbg) supported the implementation of user-defined types. +56. [Alexej Harm](https://github.com/qis) helped to get the user-defined types working with Visual Studio. +57. [Jared Grubb](https://github.com/jaredgrubb) supported the implementation of user-defined types. +58. [EnricoBilla](https://github.com/EnricoBilla) noted a typo in an example. +59. [Martin HoÅ™eňovský](https://github.com/horenmar) found a way for a 2x speedup for the compilation time of the test suite. +60. [ukhegg](https://github.com/ukhegg) found proposed an improvement for the examples section. +61. [rswanson-ihi](https://github.com/rswanson-ihi) noted a typo in the README. +62. [Mihai Stan](https://github.com/stanmihai4) fixed a bug in the comparison with `nullptr`s. +63. [Tushar Maheshwari](https://github.com/tusharpm) added [cotire](https://github.com/sakra/cotire) support to speed up the compilation. +64. [TedLyngmo](https://github.com/TedLyngmo) noted a typo in the README, removed unnecessary bit arithmetic, and fixed some `-Weffc++` warnings. +65. [Krzysztof WoÅ›](https://github.com/krzysztofwos) made exceptions more visible. +66. [ftillier](https://github.com/ftillier) fixed a compiler warning. +67. [tinloaf](https://github.com/tinloaf) made sure all pushed warnings are properly popped. +68. [Fytch](https://github.com/Fytch) found a bug in the documentation. +69. [Jay Sistar](https://github.com/Type1J) implemented a Meson build description. +70. [Henry Lee](https://github.com/HenryRLee) fixed a warning in ICC and improved the iterator implementation. +71. [Vincent Thiery](https://github.com/vthiery) maintains a package for the Conan package manager. +72. [Steffen](https://github.com/koemeet) fixed a potential issue with MSVC and `std::min`. +73. [Mike Tzou](https://github.com/Chocobo1) fixed some typos. +74. [amrcode](https://github.com/amrcode) noted a misleading documentation about comparison of floats. +75. [Oleg Endo](https://github.com/olegendo) reduced the memory consumption by replacing `` with ``. +76. [dan-42](https://github.com/dan-42) cleaned up the CMake files to simplify including/reusing of the library. +77. [Nikita Ofitserov](https://github.com/himikof) allowed for moving values from initializer lists. +78. [Greg Hurrell](https://github.com/wincent) fixed a typo. +79. [Dmitry Kukovinets](https://github.com/DmitryKuk) fixed a typo. +80. [kbthomp1](https://github.com/kbthomp1) fixed an issue related to the Intel OSX compiler. +81. [Markus Werle](https://github.com/daixtrose) fixed a typo. +82. [WebProdPP](https://github.com/WebProdPP) fixed a subtle error in a precondition check. +83. [Alex](https://github.com/leha-bot) noted an error in a code sample. +84. [Tom de Geus](https://github.com/tdegeus) reported some warnings with ICC and helped to fix them. +85. [Perry Kundert](https://github.com/pjkundert) simplified reading from input streams. +86. [Sonu Lohani](https://github.com/sonulohani) fixed a small compilation error. +87. [Jamie Seward](https://github.com/jseward) fixed all MSVC warnings. +88. [Nate Vargas](https://github.com/eld00d) added a Doxygen tag file. +89. [pvleuven](https://github.com/pvleuven) helped to fix a warning in ICC. +90. [Pavel](https://github.com/crea7or) helped to fix some warnings in MSVC. +91. [Jamie Seward](https://github.com/jseward) avoided unnecessary string copies in `find()` and `count()`. +92. [Mitja](https://github.com/Itja) fixed some typos. +93. [Jorrit Wronski](https://github.com/jowr) updated the Hunter package links. +94. [Matthias Möller](https://github.com/TinyTinni) added a `.natvis` for the MSVC debug view. +95. [bogemic](https://github.com/bogemic) fixed some C++17 deprecation warnings. +96. [Eren Okka](https://github.com/erengy) fixed some MSVC warnings. +97. [abolz](https://github.com/abolz) integrated the Grisu2 algorithm for proper floating-point formatting, allowing more roundtrip checks to succeed. +98. [Vadim Evard](https://github.com/Pipeliner) fixed a Markdown issue in the README. +99. [zerodefect](https://github.com/zerodefect) fixed a compiler warning. +100. [Kert](https://github.com/kaidokert) allowed to template the string type in the serialization and added the possibility to override the exceptional behavior. +101. [mark-99](https://github.com/mark-99) helped fixing an ICC error. +102. [Patrik Huber](https://github.com/patrikhuber) fixed links in the README file. +103. [johnfb](https://github.com/johnfb) found a bug in the implementation of CBOR's indefinite length strings. +104. [Paul Fultz II](https://github.com/pfultz2) added a note on the cget package manager. +105. [Wilson Lin](https://github.com/wla80) made the integration section of the README more concise. +106. [RalfBielig](https://github.com/ralfbielig) detected and fixed a memory leak in the parser callback. +107. [agrianius](https://github.com/agrianius) allowed to dump JSON to an alternative string type. +108. [Kevin Tonon](https://github.com/ktonon) overworked the C++11 compiler checks in CMake. +109. [Axel Huebl](https://github.com/ax3l) simplified a CMake check and added support for the [Spack package manager](https://spack.io). +110. [Carlos O'Ryan](https://github.com/coryan) fixed a typo. +111. [James Upjohn](https://github.com/jammehcow) fixed a version number in the compilers section. +112. [Chuck Atkins](https://github.com/chuckatkins) adjusted the CMake files to the CMake packaging guidelines and provided documentation for the CMake integration. +113. [Jan Schöppach](https://github.com/dns13) fixed a typo. +114. [martin-mfg](https://github.com/martin-mfg) fixed a typo. +115. [Matthias Möller](https://github.com/TinyTinni) removed the dependency from `std::stringstream`. +116. [agrianius](https://github.com/agrianius) added code to use alternative string implementations. +117. [Daniel599](https://github.com/Daniel599) allowed to use more algorithms with the `items()` function. +118. [Julius Rakow](https://github.com/jrakow) fixed the Meson include directory and fixed the links to [cppreference.com](cppreference.com). +119. [Sonu Lohani](https://github.com/sonulohani) fixed the compilation with MSVC 2015 in debug mode. +120. [grembo](https://github.com/grembo) fixed the test suite and re-enabled several test cases. +121. [Hyeon Kim](https://github.com/simnalamburt) introduced the macro `JSON_INTERNAL_CATCH` to control the exception handling inside the library. +122. [thyu](https://github.com/thyu) fixed a compiler warning. +123. [David Guthrie](https://github.com/LEgregius) fixed a subtle compilation error with Clang 3.4.2. +124. [Dennis Fischer](https://github.com/dennisfischer) allowed to call `find_package` without installing the library. +125. [Hyeon Kim](https://github.com/simnalamburt) fixed an issue with a double macro definition. +126. [Ben Berman](https://github.com/rivertam) made some error messages more understandable. +127. [zakalibit](https://github.com/zakalibit) fixed a compilation problem with the Intel C++ compiler. +128. [mandreyel](https://github.com/mandreyel) fixed a compilation problem. +129. [Kostiantyn Ponomarenko](https://github.com/koponomarenko) added version and license information to the Meson build file. +130. [Henry Schreiner](https://github.com/henryiii) added support for GCC 4.8. +131. [knilch](https://github.com/knilch0r) made sure the test suite does not stall when run in the wrong directory. +132. [Antonio Borondo](https://github.com/antonioborondo) fixed an MSVC 2017 warning. +133. [Dan Gendreau](https://github.com/dgendreau) implemented the `NLOHMANN_JSON_SERIALIZE_ENUM` macro to quickly define an enum/JSON mapping. +134. [efp](https://github.com/efp) added line and column information to parse errors. +135. [julian-becker](https://github.com/julian-becker) added BSON support. +136. [Pratik Chowdhury](https://github.com/pratikpc) added support for structured bindings. +137. [David Avedissian](https://github.com/davedissian) added support for Clang 5.0.1 (PS4 version). +138. [Jonathan Dumaresq](https://github.com/dumarjo) implemented an input adapter to read from `FILE*`. +139. [kjpus](https://github.com/kjpus) fixed a link in the documentation. +140. [Manvendra Singh](https://github.com/manu-chroma) fixed a typo in the documentation. +141. [ziggurat29](https://github.com/ziggurat29) fixed an MSVC warning. +142. [Sylvain Corlay](https://github.com/SylvainCorlay) added code to avoid an issue with MSVC. +143. [mefyl](https://github.com/mefyl) fixed a bug when JSON was parsed from an input stream. +144. [Millian Poquet](https://github.com/mpoquet) allowed to install the library via Meson. +145. [Michael Behrns-Miller](https://github.com/moodboom) found an issue with a missing namespace. +146. [Nasztanovics Ferenc](https://github.com/naszta) fixed a compilation issue with libc 2.12. +147. [Andreas Schwab](https://github.com/andreas-schwab) fixed the endian conversion. +148. [Mark-Dunning](https://github.com/Mark-Dunning) fixed a warning in MSVC. +149. [Gareth Sylvester-Bradley](https://github.com/garethsb-sony) added `operator/` for JSON Pointers. +150. [John-Mark](https://github.com/johnmarkwayve) noted a missing header. +151. [Vitaly Zaitsev](https://github.com/xvitaly) fixed compilation with GCC 9.0. +152. [Laurent Stacul](https://github.com/stac47) fixed compilation with GCC 9.0. +153. [Ivor Wanders](https://github.com/iwanders) helped to reduce the CMake requirement to version 3.1. +154. [njlr](https://github.com/njlr) updated the Buckaroo instructions. +155. [Lion](https://github.com/lieff) fixed a compilation issue with GCC 7 on CentOS. +156. [Isaac Nickaein](https://github.com/nickaein) improved the integer serialization performance and implemented the `contains()` function. +157. [past-due](https://github.com/past-due) suppressed an unfixable warning. +158. [Elvis Oric](https://github.com/elvisoric) improved Meson support. +159. [MatÄ›j Plch](https://github.com/Afforix) fixed an example in the README. +160. [Mark Beckwith](https://github.com/wythe) fixed a typo. +161. [scinart](https://github.com/scinart) fixed bug in the serializer. +162. [Patrick Boettcher](https://github.com/pboettch) implemented `push_back()` and `pop_back()` for JSON Pointers. +163. [Bruno Oliveira](https://github.com/nicoddemus) added support for Conda. +164. [Michele Caini](https://github.com/skypjack) fixed links in the README. +165. [Hani](https://github.com/hnkb) documented how to install the library with NuGet. +166. [Mark Beckwith](https://github.com/wythe) fixed a typo. +167. [yann-morin-1998](https://github.com/yann-morin-1998) helped to reduce the CMake requirement to version 3.1. +168. [Konstantin Podsvirov](https://github.com/podsvirov) maintains a package for the MSYS2 software distro. +169. [remyabel](https://github.com/remyabel) added GNUInstallDirs to the CMake files. +170. [Taylor Howard](https://github.com/taylorhoward92) fixed a unit test. +171. [Gabe Ron](https://github.com/Macr0Nerd) implemented the `to_string` method. +172. [Watal M. Iwasaki](https://github.com/heavywatal) fixed a Clang warning. +173. [Viktor Kirilov](https://github.com/onqtam) switched the unit tests from [Catch](https://github.com/philsquared/Catch) to [doctest](https://github.com/onqtam/doctest) +174. [Juncheng E](https://github.com/ejcjason) fixed a typo. +175. [tete17](https://github.com/tete17) fixed a bug in the `contains` function. +176. [Xav83](https://github.com/Xav83) fixed some cppcheck warnings. +177. [0xflotus](https://github.com/0xflotus) fixed some typos. +178. [Christian Deneke](https://github.com/chris0x44) added a const version of `json_pointer::back`. +179. [Julien Hamaide](https://github.com/crazyjul) made the `items()` function work with custom string types. +180. [Evan Nemerson](https://github.com/nemequ) updated fixed a bug in Hedley and updated this library accordingly. +181. [Florian Pigorsch](https://github.com/flopp) fixed a lot of typos. +182. [Camille Bégué](https://github.com/cbegue) fixed an issue in the conversion from `std::pair` and `std::tuple` to `json`. +183. [Anthony VH](https://github.com/AnthonyVH) fixed a compile error in an enum deserialization. +184. [Yuriy Vountesmery](https://github.com/ua-code-dragon) noted a subtle bug in a preprocessor check. +185. [Chen](https://github.com/dota17) fixed numerous issues in the library. +186. [Antony Kellermann](https://github.com/aokellermann) added a CI step for GCC 10.1. +187. [Alex](https://github.com/gistrec) fixed an MSVC warning. +188. [Rainer](https://github.com/rvjr) proposed an improvement in the floating-point serialization in CBOR. +189. [Francois Chabot](https://github.com/FrancoisChabot) made performance improvements in the input adapters. +190. [Arthur Sonzogni](https://github.com/ArthurSonzogni) documented how the library can be included via `FetchContent`. +191. [Rimas MiseviÄius](https://github.com/rmisev) fixed an error message. +192. [Alexander Myasnikov](https://github.com/alexandermyasnikov) fixed some examples and a link in the README. +193. [Hubert Chathi](https://github.com/uhoreg) made CMake's version config file architecture-independent. +194. [OmnipotentEntity](https://github.com/OmnipotentEntity) implemented the binary values for CBOR, MessagePack, BSON, and UBJSON. +195. [ArtemSarmini](https://github.com/ArtemSarmini) fixed a compilation issue with GCC 10 and fixed a leak. +196. [Evgenii Sopov](https://github.com/sea-kg) integrated the library to the wsjcpp package manager. +197. [Sergey Linev](https://github.com/linev) fixed a compiler warning. +198. [Miguel Magalhães](https://github.com/magamig) fixed the year in the copyright. +199. [Gareth Sylvester-Bradley](https://github.com/garethsb-sony) fixed a compilation issue with MSVC. +200. [Alexander “weej†Jones](https://github.com/alex-weej) fixed an example in the README. +201. [Antoine CÅ“ur](https://github.com/Coeur) fixed some typos in the documentation. +202. [jothepro](https://github.com/jothepro) updated links to the Hunter package. +203. [Dave Lee](https://github.com/kastiglione) fixed link in the README. +204. [Joël Lamotte](https://github.com/Klaim) added instruction for using Build2's package manager. +205. [Paul Jurczak](https://github.com/pauljurczak) fixed an example in the README. +206. [Sonu Lohani](https://github.com/sonulohani) fixed a warning. +207. [Carlos Gomes Martinho](https://github.com/gocarlos) updated the Conan package source. +208. [Konstantin Podsvirov](https://github.com/podsvirov) fixed the MSYS2 package documentation. +209. [Tridacnid](https://github.com/Tridacnid) improved the CMake tests. +210. [Michael](https://github.com/MBalszun) fixed MSVC warnings. +211. [Quentin Barbarat](https://github.com/quentin-dev) fixed an example in the documentation. +212. [XyFreak](https://github.com/XyFreak) fixed a compiler warning. +213. [TotalCaesar659](https://github.com/TotalCaesar659) fixed links in the README. +214. [Tanuj Garg](https://github.com/tanuj208) improved the fuzzer coverage for UBSAN input. +215. [AODQ](https://github.com/AODQ) fixed a compiler warning. +216. [jwittbrodt](https://github.com/jwittbrodt) made `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE` inline. +217. [pfeatherstone](https://github.com/pfeatherstone) improved the upper bound of arguments of the `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`/`NLOHMANN_DEFINE_TYPE_INTRUSIVE` macros. +218. [Jan Procházka](https://github.com/jprochazk) fixed a bug in the CBOR parser for binary and string values. +219. [T0b1-iOS](https://github.com/T0b1-iOS) fixed a bug in the new hash implementation. +220. [Matthew Bauer](https://github.com/matthewbauer) adjusted the CBOR writer to create tags for binary subtypes. +221. [gatopeich](https://github.com/gatopeich) implemented an ordered map container for `nlohmann::ordered_json`. +222. [Érico Nogueira Rolim](https://github.com/ericonr) added support for pkg-config. +223. [KonanM](https://github.com/KonanM) proposed an implementation for the `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`/`NLOHMANN_DEFINE_TYPE_INTRUSIVE` macros. +224. [Guillaume Racicot](https://github.com/gracicot) implemented `string_view` support and allowed C++20 support. +225. [Alex Reinking](https://github.com/alexreinking) improved CMake support for `FetchContent`. +226. [Hannes Domani](https://github.com/ssbssa) provided a GDB pretty printer. +227. Lars Wirzenius reviewed the README file. +228. [Jun Jie](https://github.com/ongjunjie) fixed a compiler path in the CMake scripts. +229. [Ronak Buch](https://github.com/rbuch) fixed typos in the documentation. +230. [Alexander Karzhenkov](https://github.com/karzhenkov) fixed a move constructor and the Travis builds. +231. [Leonardo Lima](https://github.com/leozz37) added CPM.Cmake support. +232. [Joseph Blackman](https://github.com/jbzdarkid) fixed a warning. +233. [Yaroslav](https://github.com/YarikTH) updated doctest and implemented unit tests. +234. [Martin Stump](https://github.com/globberwops) fixed a bug in the CMake files. +235. [Jaakko Moisio](https://github.com/jasujm) fixed a bug in the input adapters. +236. [bl-ue](https://github.com/bl-ue) fixed some Markdown issues in the README file. +237. [William A. Wieselquist](https://github.com/wawiesel) fixed an example from the README. +238. [abbaswasim](https://github.com/abbaswasim) fixed an example from the README. +239. [Remy Jette](https://github.com/remyjette) fixed a warning. +240. [Fraser](https://github.com/frasermarlow) fixed the documentation. +241. [Ben Beasley](https://github.com/musicinmybrain) updated doctest. +242. [Doron Behar](https://github.com/doronbehar) fixed pkg-config.pc. +243. [raduteo](https://github.com/raduteo) fixed a warning. +244. [David Pfahler](https://github.com/theShmoo) added the possibility to compile the library without I/O support. +245. [Morten Fyhn Amundsen](https://github.com/mortenfyhn) fixed a typo. +246. [jpl-mac](https://github.com/jpl-mac) allowed to treat the library as a system header in CMake. +247. [Jason Dsouza](https://github.com/jasmcaus) fixed the indentation of the CMake file. +248. [offa](https://github.com/offa) added a link to Conan Center to the documentation. +249. [TotalCaesar659](https://github.com/TotalCaesar659) updated the links in the documentation to use HTTPS. +250. [Rafail Giavrimis](https://github.com/grafail) fixed the Google Benchmark default branch. +251. [Louis Dionne](https://github.com/ldionne) fixed a conversion operator. +252. [justanotheranonymoususer](https://github.com/justanotheranonymoususer) made the examples in the README more consistent. +253. [Finkman](https://github.com/Finkman) suppressed some `-Wfloat-equal` warnings. +254. [Ferry Huberts](https://github.com/fhuberts) fixed `-Wswitch-enum` warnings. +255. [Arseniy Terekhin](https://github.com/senyai) made the GDB pretty-printer robust against unset variable names. +256. [Amir Masoud Abdol](https://github.com/amirmasoudabdol) updated the Homebrew command as nlohmann/json is now in homebrew-core. +257. [Hallot](https://github.com/Hallot) fixed some `-Wextra-semi-stmt warnings`. +258. [Giovanni Cerretani](https://github.com/gcerretani) fixed `-Wunused` warnings on `JSON_DIAGNOSTICS`. +259. [Bogdan Popescu](https://github.com/Kapeli) hosts the [docset](https://github.com/Kapeli/Dash-User-Contributions/tree/master/docsets/JSON_for_Modern_C%2B%2B) for offline documentation viewers. +260. [Carl Smedstad](https://github.com/carlsmedstad) fixed an assertion error when using `JSON_DIAGNOSTICS`. +261. [miikka75](https://github.com/miikka75) provided an important fix to compile C++17 code with Clang 9. +262. [Maarten Becker](https://github.com/kernie) fixed a warning for shadowed variables. +263. [Cristi Vîjdea](https://github.com/axnsan12) fixed typos in the `operator[]` documentation. +264. [Alex Beregszaszi](https://github.com/axic) fixed spelling mistakes in comments. +265. [Dirk Stolle](https://github.com/striezel) fixed typos in documentation. +266. [Daniel Albuschat](https://github.com/daniel-kun) corrected the parameter name in the `parse` documentation. +267. [Prince Mendiratta](https://github.com/Prince-Mendiratta) fixed a link to the FAQ. +268. [Florian Albrechtskirchinger](https://github.com/falbrechtskirchinger) implemented `std::string_view` support for object keys and made dozens of other improvements. +269. [Qianqian Fang](https://github.com/fangq) implemented the Binary JData (BJData) format. +270. [pketelsen](https://github.com/pketelsen) added macros `NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT` and `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT`. +271. [DarkZeros](https://github.com/DarkZeros) adjusted to code to not clash with Arduino defines. +272. [flagarde](https://github.com/flagarde) fixed the output of `meta()` for MSVC. +273. [Giovanni Cerretani](https://github.com/gcerretani) fixed a check for `std::filesystem`. +274. [Dimitris Apostolou](https://github.com/rex4539) fixed a typo. +275. [Ferry Huberts](https://github.com/fhuberts) fixed a typo. +276. [Michael Nosthoff](https://github.com/heinemml) fixed a typo. +277. [JungHoon Lee](https://github.com/jhnlee) fixed a typo. +278. [Faruk D.](https://github.com/fdiblen) fixed the CITATION.CFF file. +279. [Andrea Cocito](https://github.com/puffetto) added a clarification on macro usage to the documentation. +280. [Krzysiek Karbowiak](https://github.com/kkarbowiak) refactored the tests to use `CHECK_THROWS_WITH_AS`. +281. [Chaoqi Zhang](https://github.com/prncoprs) fixed a typo. +282. [ivanovmp](https://github.com/ivanovmp) fixed a whitespace error. +283. [KsaNL](https://github.com/KsaNL) fixed a build error when including ``. +284. [Andrea Pappacoda](https://github.com/Tachi107) moved `.pc` and `.cmake` files to `share` directory. +285. [Wolf Vollprecht](https://github.com/wolfv) added the `patch_inplace` function. +286. [Jake Zimmerman](https://github.com/jez) highlighted common usage patterns in the README file. +287. [NN](https://github.com/NN---) added the Visual Studio output directory to `.gitignore`. +288. [Romain Reignier](https://github.com/romainreignier) improved the performance the vector output adapter. +289. [Mike](https://github.com/Mike-Leo-Smith) fixed the `std::iterator_traits`. +290. [Richard Hozák](https://github.com/zxey) added macro `JSON_NO_ENUM` to disable default enum conversions. +291. [vakokako](https://github.com/vakokako) fixed tests when compiling with C++20. +292. [Alexander “weej†Jones](https://github.com/alexweej) fixed an example in the README. +293. [Eli Schwartz](https://github.com/eli-schwartz) added more files to the `include.zip` archive. +294. [Kevin Lu](https://github.com/kevinlul) fixed a compilation issue when typedefs with certain names were present. +295. [Trevor Hickey](https://github.com/luxe) improved the description of an example. +296. [Jef LeCompte](https://github.com/jef) updated the year in the README file. +297. [Alexandre Hamez](https://github.com/ahamez) fixed a warning. +298. [Maninderpal Badhan](https://github.com/mbadhan) fixed a typo. +299. [kevin--](https://github.com/kevin--) added a note to an example in the README file. +300. [I](https://github.com/wx257osn2) fixed a typo. +301. [Gregorio Litenstein](https://github.com/Lord-Kamina) fixed the Clang detection. +302. [Andreas Smas](https://github.com/andoma) added a Doozer badge. +303. [WanCW](https://github.com/wancw) fixed the string conversion with Clang. +304. [zhaohuaxishi](https://github.com/zhaohuaxishi) fixed a Doxygen error. +305. [emvivre](https://github.com/emvivre) removed an invalid parameter from CMake. +306. [Tobias Hermann](https://github.com/Dobiasd) fixed a link in the README file. +307. [Michael](https://github.com/traits) fixed a warning. +308. [Ryan Mulder](https://github.com/ryanjmulder) added `ensure_ascii` to the `dump` function. +309. [Muri Nicanor](https://github.com/murinicanor) fixed the `sed` discovery in the Makefile. +310. [David Avedissian](https://github.com/dgavedissian) implemented SFINAE-friendly `iterator_traits`. +311. [AQNOUCH Mohammed](https://github.com/aqnouch) fixed a typo in the README. +312. [Gareth Sylvester-Bradley](https://github.com/garethsb) added `operator/=` and `operator/` to construct JSON pointers. +313. [Michael Macnair](https://github.com/mykter) added support for afl-fuzz testing. +314. [Berkus Decker](https://github.com/berkus) fixed a typo in the README. +315. [Illia Polishchuk](https://github.com/effolkronium) improved the CMake testing. +316. [Ikko Ashimine](https://github.com/eltociear) fixed a typo. +317. [Raphael Grimm](https://github.com/barcode) added the possibility to define a custom base class. +318. [tocic](https://github.com/tocic) fixed typos in the documentation. +319. [Vertexwahn](https://github.com/Vertexwahn) added Bazel build support. +320. [Dirk Stolle](https://github.com/striezel) fixed typos in the documentation. +321. [DavidKorczynski](https://github.com/DavidKorczynski) added a CIFuzz CI GitHub action. +322. [Finkman](https://github.com/Finkman) fixed the debug pretty-printer. +323. [Florian Segginger](https://github.com/floriansegginger) bumped the years in the README. +324. [haadfida](https://github.com/haadfida) cleaned up the badges of used services. +325. [Arsen Arsenović](https://github.com/ArsenArsen) fixed a build error. +326. [theevilone45](https://github.com/theevilone45) fixed a typo in a CMake file. +327. [Sergei Trofimovich](https://github.com/trofi) fixed the custom allocator support. +328. [Joyce](https://github.com/joycebrum) fixed some security issues in the GitHub workflows. +329. [Nicolas Jakob](https://github.com/njakob) add vcpkg version badge. +330. [Tomerkm](https://github.com/Tomerkm) added tests. +331. [No.](https://github.com/tusooa) fixed the use of `get<>` calls. +332. [taro](https://github.com/tarolling) fixed a typo in the `CODEOWNERS` file. +333. [Ikko Eltociear Ashimine](https://github.com/eltociear) fixed a typo. +334. [Felix Yan](https://github.com/felixonmars) fixed a typo in the README. +335. [HO-COOH](https://github.com/HO-COOH) fixed a parentheses in the documentation. +336. [Ivor Wanders](https://github.com/iwanders) fixed the examples to catch exception by `const&`. +337. [miny1233](https://github.com/miny1233) fixed a parentheses in the documentation. +338. [tomalakgeretkal](https://github.com/tomalakgeretkal) fixed a compilation error. +339. [alferov](https://github.com/ALF-ONE) fixed a compilation error. +340. [Craig Scott](https://github.com/craigscott-crascit) fixed a deprecation warning in CMake. +341. [Vyacheslav Zhdanovskiy](https://github.com/ZeronSix) added macros for serialization-only types. +342. [Mathieu Westphal](https://github.com/mwestphal) fixed typos. +343. [scribam](https://github.com/scribam) fixed the MinGW workflow. +344. [Aleksei Sapitskii](https://github.com/aleksproger) added support for Apple's Swift Package Manager. +345. [Benjamin Buch](https://github.com/bebuch) fixed the installation path in CMake. +346. [Colby Haskell](https://github.com/colbychaskell) clarified the parse error message in case a file cannot be opened. Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I forgot someone. @@ -1541,32 +1775,29 @@ The library itself consists of a single header file licensed under the MIT licen - [**American fuzzy lop**](https://lcamtuf.coredump.cx/afl/) for fuzz testing - [**AppVeyor**](https://www.appveyor.com) for [continuous integration](https://ci.appveyor.com/project/nlohmann/json) on Windows - [**Artistic Style**](http://astyle.sourceforge.net) for automatic source code indentation -- [**CircleCI**](https://circleci.com) for [continuous integration](https://circleci.com/gh/nlohmann/json). - [**Clang**](https://clang.llvm.org) for compilation with code sanitizers - [**CMake**](https://cmake.org) for build automation -- [**Codacity**](https://www.codacy.com) for further [code analysis](https://www.codacy.com/app/nlohmann/json) +- [**Codacy**](https://www.codacy.com) for further [code analysis](https://www.codacy.com/app/nlohmann/json) - [**Coveralls**](https://coveralls.io) to measure [code coverage](https://coveralls.io/github/nlohmann/json) - [**Coverity Scan**](https://scan.coverity.com) for [static analysis](https://scan.coverity.com/projects/nlohmann-json) - [**cppcheck**](http://cppcheck.sourceforge.net) for static analysis - [**doctest**](https://github.com/onqtam/doctest) for the unit tests -- [**Doxygen**](https://www.doxygen.nl/index.html) to generate [documentation](https://nlohmann.github.io/json/doxygen/index.html) - [**git-update-ghpages**](https://github.com/rstacruz/git-update-ghpages) to upload the documentation to gh-pages - [**GitHub Changelog Generator**](https://github.com/skywinder/github-changelog-generator) to generate the [ChangeLog](https://github.com/nlohmann/json/blob/develop/ChangeLog.md) - [**Google Benchmark**](https://github.com/google/benchmark) to implement the benchmarks - [**Hedley**](https://nemequ.github.io/hedley/) to avoid re-inventing several compiler-agnostic feature macros -- [**lcov**](http://ltp.sourceforge.net/coverage/lcov.php) to process coverage information and create a HTML view +- [**lcov**](http://ltp.sourceforge.net/coverage/lcov.php) to process coverage information and create an HTML view - [**libFuzzer**](https://llvm.org/docs/LibFuzzer.html) to implement fuzz testing for OSS-Fuzz +- [**Material for MkDocs**](https://squidfunk.github.io/mkdocs-material/) for the style of the documentation site +- [**MkDocs**](https://www.mkdocs.org) for the documentation site - [**OSS-Fuzz**](https://github.com/google/oss-fuzz) for continuous fuzz testing of the library ([project repository](https://github.com/google/oss-fuzz/tree/master/projects/json)) - [**Probot**](https://probot.github.io) for automating maintainer tasks such as closing stale issues, requesting missing information, or detecting toxic comments. -- [**send_to_wandbox**](https://github.com/nlohmann/json/blob/develop/doc/scripts/send_to_wandbox.py) to send code examples to [Wandbox](http://melpon.org/wandbox) -- [**Travis**](https://travis-ci.org) for [continuous integration](https://travis-ci.org/nlohmann/json) on Linux and macOS - [**Valgrind**](https://valgrind.org) to check for correct memory management -- [**Wandbox**](https://wandbox.org) for [online examples](https://wandbox.org/permlink/3lCHrFUZANONKv7a) ## Projects using JSON for Modern C++ -The library is currently used in Apple macOS Sierra and iOS 10. I am not sure what they are using the library for, but I am happy that it runs on so many devices. +The library is currently used in Apple macOS Sierra-Monterey and iOS 10-15. I am not sure what they are using the library for, but I am happy that it runs on so many devices. ## Notes @@ -1581,7 +1812,8 @@ The library supports **Unicode input** as follows: - [Unicode noncharacters](https://www.unicode.org/faq/private_use.html#nonchar1) will not be replaced by the library. - Invalid surrogates (e.g., incomplete pairs such as `\uDEAD`) will yield parse errors. - The strings stored in the library are UTF-8 encoded. When using the default string type (`std::string`), note that its length/size functions return the number of stored bytes rather than the number of characters or glyphs. -- When you store strings with different encodings in the library, calling [`dump()`](https://nlohmann.github.io/json/api/basic_json/dump/) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers. +- When you store strings with different encodings in the library, calling [`dump()`](https://json.nlohmann.me/api/basic_json/dump/) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers. +- To store wide strings (e.g., `std::wstring`), you need to convert them to a UTF-8 encoded `std::string` before, see [an example](https://json.nlohmann.me/home/faq/#wide-string-handling). ### Comments in JSON @@ -1608,17 +1840,17 @@ If you do want to preserve the insertion order, you can try the type [`nlohmann: We checked with Valgrind and the Address Sanitizer (ASAN) that there are no memory leaks. -If you find that a parsing program with this library does not release memory, please consider the following case and it maybe unrelated to this library. +If you find that a parsing program with this library does not release memory, please consider the following case, and it may be unrelated to this library. **Your program is compiled with glibc.** There is a tunable threshold that glibc uses to decide whether to actually return memory to the system or whether to cache it for later reuse. If in your program you make lots of small allocations and those small allocations are not a contiguous block and are presumably below the threshold, then they will not get returned to the OS. Here is a related issue [#1924](https://github.com/nlohmann/json/issues/1924). ### Further notes -- The code contains numerous debug **assertions** which can be switched off by defining the preprocessor macro `NDEBUG`, see the [documentation of `assert`](https://en.cppreference.com/w/cpp/error/assert). In particular, note [`operator[]`](https://nlohmann.github.io/json/api/basic_json/operator%5B%5D/) implements **unchecked access** for const objects: If the given key is not present, the behavior is undefined (think of a dereferenced null pointer) and yields an [assertion failure](https://github.com/nlohmann/json/issues/289) if assertions are switched on. If you are not sure whether an element in an object exists, use checked access with the [`at()` function](https://nlohmann.github.io/json/api/basic_json/at/). Furthermore, you can define `JSON_ASSERT(x)` to replace calls to `assert(x)`. -- As the exact type of a number is not defined in the [JSON specification](https://tools.ietf.org/html/rfc8259.html), this library tries to choose the best fitting C++ number type automatically. As a result, the type `double` may be used to store numbers which may yield [**floating-point exceptions**](https://github.com/nlohmann/json/issues/181) in certain rare situations if floating-point exceptions have been unmasked in the calling code. These exceptions are not caused by the library and need to be fixed in the calling code, such as by re-masking the exceptions prior to calling library functions. +- The code contains numerous debug **assertions** which can be switched off by defining the preprocessor macro `NDEBUG`, see the [documentation of `assert`](https://en.cppreference.com/w/cpp/error/assert). In particular, note [`operator[]`](https://json.nlohmann.me/api/basic_json/operator%5B%5D/) implements **unchecked access** for const objects: If the given key is not present, the behavior is undefined (think of a dereferenced null pointer) and yields an [assertion failure](https://github.com/nlohmann/json/issues/289) if assertions are switched on. If you are not sure whether an element in an object exists, use checked access with the [`at()` function](https://json.nlohmann.me/api/basic_json/at/). Furthermore, you can define `JSON_ASSERT(x)` to replace calls to `assert(x)`. +- As the exact number type is not defined in the [JSON specification](https://tools.ietf.org/html/rfc8259.html), this library tries to choose the best fitting C++ number type automatically. As a result, the type `double` may be used to store numbers which may yield [**floating-point exceptions**](https://github.com/nlohmann/json/issues/181) in certain rare situations if floating-point exceptions have been unmasked in the calling code. These exceptions are not caused by the library and need to be fixed in the calling code, such as by re-masking the exceptions prior to calling library functions. - The code can be compiled without C++ **runtime type identification** features; that is, you can use the `-fno-rtti` compiler flag. -- **Exceptions** are used widely within the library. They can, however, be switched off with either using the compiler flag `-fno-exceptions` or by defining the symbol `JSON_NOEXCEPTION`. In this case, exceptions are replaced by `abort()` calls. You can further control this behavior by defining `JSON_THROW_USER` (overriding `throw`), `JSON_TRY_USER` (overriding `try`), and `JSON_CATCH_USER` (overriding `catch`). Note that `JSON_THROW_USER` should leave the current scope (e.g., by throwing or aborting), as continuing after it may yield undefined behavior. +- **Exceptions** are used widely within the library. They can, however, be switched off with either using the compiler flag `-fno-exceptions` or by defining the symbol `JSON_NOEXCEPTION`. In this case, exceptions are replaced by `abort()` calls. You can further control this behavior by defining `JSON_THROW_USER` (overriding `throw`), `JSON_TRY_USER` (overriding `try`), and `JSON_CATCH_USER` (overriding `catch`). Note that `JSON_THROW_USER` should leave the current scope (e.g., by throwing or aborting), as continuing after it may yield undefined behavior. Note the explanatory [`what()`](https://en.cppreference.com/w/cpp/error/exception/what) string of exceptions is not available for MSVC if exceptions are disabled, see [#2824](https://github.com/nlohmann/json/discussions/2824). ## Execute unit tests @@ -1634,7 +1866,23 @@ $ ctest --output-on-failure Note that during the `ctest` stage, several JSON test files are downloaded from an [external repository](https://github.com/nlohmann/json_test_data). If policies forbid downloading artifacts during testing, you can download the files yourself and pass the directory with the test files via `-DJSON_TestDataDirectory=path` to CMake. Then, no Internet connectivity is required. See [issue #2189](https://github.com/nlohmann/json/issues/2189) for more information. -In case you have downloaded the library rather than checked out the code via Git, test `cmake_fetch_content_configure`. Please execute `ctest -LE git_required` to skip these tests. See [issue #2189](https://github.com/nlohmann/json/issues/2189) for more information. +If the test suite is not found, several test suites will fail like this: + +``` +=============================================================================== +json/tests/src/make_test_data_available.hpp:21: +TEST CASE: check test suite is downloaded + +json/tests/src/make_test_data_available.hpp:23: FATAL ERROR: REQUIRE( utils::check_testsuite_downloaded() ) is NOT correct! + values: REQUIRE( false ) + logged: Test data not found in 'json/cmake-build-debug/json_test_data'. + Please execute target 'download_test_data' before running this test suite. + See for more information. + +=============================================================================== +``` + +In case you have downloaded the library rather than checked out the code via Git, test `cmake_fetch_content_configure` will fail. Please execute `ctest -LE git_required` to skip these tests. See [issue #2189](https://github.com/nlohmann/json/issues/2189) for more information. Some tests change the installed files and hence make the whole process not reproducible. Please execute `ctest -LE not_reproducible` to skip these tests. See [issue #2324](https://github.com/nlohmann/json/issues/2324) for more information. diff --git a/external_imported/json/WORKSPACE.bazel b/external_imported/json/WORKSPACE.bazel new file mode 100644 index 000000000..2b2ae9dba --- /dev/null +++ b/external_imported/json/WORKSPACE.bazel @@ -0,0 +1 @@ +workspace(name = "nlohmann_json") diff --git a/external_imported/json/appveyor.yml b/external_imported/json/appveyor.yml deleted file mode 100644 index 5836f88d0..000000000 --- a/external_imported/json/appveyor.yml +++ /dev/null @@ -1,147 +0,0 @@ -version: '{build}' - -environment: - matrix: - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - configuration: Debug - platform: x86 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 14 2015 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - configuration: Debug - platform: x86 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 15 2017 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - configuration: Debug - platform: x86 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 16 2019 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - configuration: Debug - platform: x64 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 16 2019 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - configuration: Debug - COMPILER: mingw - platform: x86 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Ninja - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - configuration: Release - COMPILER: mingw - platform: x86 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Ninja - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - configuration: Release - platform: x86 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 14 2015 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - configuration: Release - platform: x86 - name: with_win_header - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 14 2015 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - configuration: Release - platform: x86 - CXX_FLAGS: "/permissive- /std:c++latest /utf-8" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 15 2017 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - configuration: Release - platform: x86 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "-DJSON_ImplicitConversions=OFF" - GENERATOR: Visual Studio 16 2019 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - configuration: Release - platform: x64 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 16 2019 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - configuration: Release - platform: x64 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 14 2015 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - configuration: Release - platform: x64 - CXX_FLAGS: "/permissive- /std:c++latest /Zc:__cplusplus /utf-8 /F4000000" - LINKER_FLAGS: "/STACK:4000000" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 15 2017 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - configuration: Release - platform: x64 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 16 2019 - -init: - - cmake --version - - msbuild /version - -install: - - if "%COMPILER%"=="mingw" appveyor DownloadFile https://github.com/ninja-build/ninja/releases/download/v1.6.0/ninja-win.zip -FileName ninja.zip - - if "%COMPILER%"=="mingw" 7z x ninja.zip -oC:\projects\deps\ninja > nul - - if "%COMPILER%"=="mingw" set PATH=C:\projects\deps\ninja;%PATH% - - if "%COMPILER%"=="mingw" set PATH=C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin;%PATH% - - if "%COMPILER%"=="mingw" g++ --version - - if "%platform%"=="x86" set GENERATOR_PLATFORM=Win32 - -before_build: - # for with_win_header build, inject the inclusion of Windows.h to the single-header library - - ps: if ($env:name -Eq "with_win_header") { $header_path = "single_include\nlohmann\json.hpp" } - - ps: if ($env:name -Eq "with_win_header") { "#include `n" + (Get-Content $header_path | Out-String) | Set-Content $header_path } - - if "%GENERATOR%"=="Ninja" (cmake . -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%configuration%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" -DJSON_BuildTests=On "%CMAKE_OPTIONS%") else (cmake . -G "%GENERATOR%" -A "%GENERATOR_PLATFORM%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" -DJSON_BuildTests=On "%CMAKE_OPTIONS%") - -build_script: - - cmake --build . --config "%configuration%" - -test_script: - - if "%configuration%"=="Release" ctest -C "%configuration%" -V -j - # On Debug builds, skip test-unicode_all - # as it is extremely slow to run and cause - # occasional timeouts on AppVeyor. - # More info: https://github.com/nlohmann/json/pull/1570 - - if "%configuration%"=="Debug" ctest --exclude-regex "test-unicode" -C "%configuration%" -V -j diff --git a/external_imported/json/benchmarks/CMakeLists.txt b/external_imported/json/benchmarks/CMakeLists.txt deleted file mode 100644 index 86063dbad..000000000 --- a/external_imported/json/benchmarks/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(JSON_Benchmarks LANGUAGES CXX) - -# set compiler flags -if((CMAKE_CXX_COMPILER_ID MATCHES GNU) OR (CMAKE_CXX_COMPILER_ID MATCHES Clang)) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -DNDEBUG -O3") -endif() - -# configure Google Benchmarks -set(BENCHMARK_ENABLE_TESTING OFF CACHE INTERNAL "" FORCE) -add_subdirectory(thirdparty/benchmark) - -# header directories -include_directories(thirdparty) -include_directories(${CMAKE_SOURCE_DIR}/../single_include) - -# download test data -include(${CMAKE_SOURCE_DIR}/../cmake/download_test_data.cmake) - -# benchmark binary -add_executable(json_benchmarks src/benchmarks.cpp) -target_compile_features(json_benchmarks PRIVATE cxx_std_11) -target_link_libraries(json_benchmarks benchmark ${CMAKE_THREAD_LIBS_INIT}) -add_dependencies(json_benchmarks download_test_data) -target_include_directories(json_benchmarks PRIVATE ${CMAKE_BINARY_DIR}/include) diff --git a/external_imported/json/benchmarks/src/benchmarks.cpp b/external_imported/json/benchmarks/src/benchmarks.cpp deleted file mode 100644 index 4f32a61a2..000000000 --- a/external_imported/json/benchmarks/src/benchmarks.cpp +++ /dev/null @@ -1,110 +0,0 @@ -#include "benchmark/benchmark.h" -#include -#include -#include - -using json = nlohmann::json; - -////////////////////////////////////////////////////////////////////////////// -// parse JSON from file -////////////////////////////////////////////////////////////////////////////// - -static void ParseFile(benchmark::State& state, const char* filename) -{ - while (state.KeepRunning()) - { - state.PauseTiming(); - auto* f = new std::ifstream(filename); - auto* j = new json(); - state.ResumeTiming(); - - *j = json::parse(*f); - - state.PauseTiming(); - delete f; - delete j; - state.ResumeTiming(); - } - - std::ifstream file(filename, std::ios::binary | std::ios::ate); - state.SetBytesProcessed(state.iterations() * file.tellg()); -} -BENCHMARK_CAPTURE(ParseFile, jeopardy, TEST_DATA_DIRECTORY "/jeopardy/jeopardy.json"); -BENCHMARK_CAPTURE(ParseFile, canada, TEST_DATA_DIRECTORY "/nativejson-benchmark/canada.json"); -BENCHMARK_CAPTURE(ParseFile, citm_catalog, TEST_DATA_DIRECTORY "/nativejson-benchmark/citm_catalog.json"); -BENCHMARK_CAPTURE(ParseFile, twitter, TEST_DATA_DIRECTORY "/nativejson-benchmark/twitter.json"); -BENCHMARK_CAPTURE(ParseFile, floats, TEST_DATA_DIRECTORY "/regression/floats.json"); -BENCHMARK_CAPTURE(ParseFile, signed_ints, TEST_DATA_DIRECTORY "/regression/signed_ints.json"); -BENCHMARK_CAPTURE(ParseFile, unsigned_ints, TEST_DATA_DIRECTORY "/regression/unsigned_ints.json"); -BENCHMARK_CAPTURE(ParseFile, small_signed_ints, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json"); - -////////////////////////////////////////////////////////////////////////////// -// parse JSON from string -////////////////////////////////////////////////////////////////////////////// - -static void ParseString(benchmark::State& state, const char* filename) -{ - std::ifstream f(filename); - std::string str((std::istreambuf_iterator(f)), std::istreambuf_iterator()); - - while (state.KeepRunning()) - { - state.PauseTiming(); - auto* j = new json(); - state.ResumeTiming(); - - *j = json::parse(str); - - state.PauseTiming(); - delete j; - state.ResumeTiming(); - } - - state.SetBytesProcessed(state.iterations() * str.size()); -} -BENCHMARK_CAPTURE(ParseString, jeopardy, TEST_DATA_DIRECTORY "/jeopardy/jeopardy.json"); -BENCHMARK_CAPTURE(ParseString, canada, TEST_DATA_DIRECTORY "/nativejson-benchmark/canada.json"); -BENCHMARK_CAPTURE(ParseString, citm_catalog, TEST_DATA_DIRECTORY "/nativejson-benchmark/citm_catalog.json"); -BENCHMARK_CAPTURE(ParseString, twitter, TEST_DATA_DIRECTORY "/nativejson-benchmark/twitter.json"); -BENCHMARK_CAPTURE(ParseString, floats, TEST_DATA_DIRECTORY "/regression/floats.json"); -BENCHMARK_CAPTURE(ParseString, signed_ints, TEST_DATA_DIRECTORY "/regression/signed_ints.json"); -BENCHMARK_CAPTURE(ParseString, unsigned_ints, TEST_DATA_DIRECTORY "/regression/unsigned_ints.json"); -BENCHMARK_CAPTURE(ParseString, small_signed_ints, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json"); - - -////////////////////////////////////////////////////////////////////////////// -// serialize JSON -////////////////////////////////////////////////////////////////////////////// - -static void Dump(benchmark::State& state, const char* filename, int indent) -{ - std::ifstream f(filename); - std::string str((std::istreambuf_iterator(f)), std::istreambuf_iterator()); - json j = json::parse(str); - - while (state.KeepRunning()) - { - j.dump(indent); - } - - state.SetBytesProcessed(state.iterations() * j.dump(indent).size()); -} -BENCHMARK_CAPTURE(Dump, jeopardy / -, TEST_DATA_DIRECTORY "/jeopardy/jeopardy.json", -1); -BENCHMARK_CAPTURE(Dump, jeopardy / 4, TEST_DATA_DIRECTORY "/jeopardy/jeopardy.json", 4); -BENCHMARK_CAPTURE(Dump, canada / -, TEST_DATA_DIRECTORY "/nativejson-benchmark/canada.json", -1); -BENCHMARK_CAPTURE(Dump, canada / 4, TEST_DATA_DIRECTORY "/nativejson-benchmark/canada.json", 4); -BENCHMARK_CAPTURE(Dump, citm_catalog / -, TEST_DATA_DIRECTORY "/nativejson-benchmark/citm_catalog.json", -1); -BENCHMARK_CAPTURE(Dump, citm_catalog / 4, TEST_DATA_DIRECTORY "/nativejson-benchmark/citm_catalog.json", 4); -BENCHMARK_CAPTURE(Dump, twitter / -, TEST_DATA_DIRECTORY "/nativejson-benchmark/twitter.json", -1); -BENCHMARK_CAPTURE(Dump, twitter / 4, TEST_DATA_DIRECTORY "/nativejson-benchmark/twitter.json", 4); -BENCHMARK_CAPTURE(Dump, floats / -, TEST_DATA_DIRECTORY "/regression/floats.json", -1); -BENCHMARK_CAPTURE(Dump, floats / 4, TEST_DATA_DIRECTORY "/regression/floats.json", 4); -BENCHMARK_CAPTURE(Dump, signed_ints / -, TEST_DATA_DIRECTORY "/regression/signed_ints.json", -1); -BENCHMARK_CAPTURE(Dump, signed_ints / 4, TEST_DATA_DIRECTORY "/regression/signed_ints.json", 4); -BENCHMARK_CAPTURE(Dump, unsigned_ints / -, TEST_DATA_DIRECTORY "/regression/unsigned_ints.json", -1); -BENCHMARK_CAPTURE(Dump, unsigned_ints / 4, TEST_DATA_DIRECTORY "/regression/unsigned_ints.json", 4); -BENCHMARK_CAPTURE(Dump, small_signed_ints / -, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json", -1); -BENCHMARK_CAPTURE(Dump, small_signed_ints / 4, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json", 4); - - -BENCHMARK_MAIN(); diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/AUTHORS b/external_imported/json/benchmarks/thirdparty/benchmark/AUTHORS deleted file mode 100755 index f8219036d..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/AUTHORS +++ /dev/null @@ -1,46 +0,0 @@ -# This is the official list of benchmark authors for copyright purposes. -# This file is distinct from the CONTRIBUTORS files. -# See the latter for an explanation. -# -# Names should be added to this file as: -# Name or Organization -# The email address is not required for organizations. -# -# Please keep the list sorted. - -Albert Pretorius -Arne Beer -Carto -Christopher Seymour -David Coeurjolly -Deniz Evrenci -Dirac Research -Dominik Czarnota -Eric Fiselier -Eugene Zhuk -Evgeny Safronov -Felix Homann -Google Inc. -International Business Machines Corporation -Ismael Jimenez Martinez -Jern-Kuan Leong -JianXiong Zhou -Joao Paulo Magalhaes -Jussi Knuuttila -Kaito Udagawa -Kishan Kumar -Lei Xu -Matt Clarkson -Maxim Vafin -MongoDB Inc. -Nick Hutchinson -Oleksandr Sochka -Paul Redmond -Radoslav Yovchev -Roman Lebedev -Shuo Chen -Steinar H. Gunderson -Stripe, Inc. -Yixuan Qiu -Yusuke Suzuki -Zbigniew Skowron diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/BUILD.bazel b/external_imported/json/benchmarks/thirdparty/benchmark/BUILD.bazel deleted file mode 100755 index 6ee69f290..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/BUILD.bazel +++ /dev/null @@ -1,42 +0,0 @@ -licenses(["notice"]) - -config_setting( - name = "windows", - values = { - "cpu": "x64_windows", - }, - visibility = [":__subpackages__"], -) - -cc_library( - name = "benchmark", - srcs = glob( - [ - "src/*.cc", - "src/*.h", - ], - exclude = ["src/benchmark_main.cc"], - ), - hdrs = ["include/benchmark/benchmark.h"], - linkopts = select({ - ":windows": ["-DEFAULTLIB:shlwapi.lib"], - "//conditions:default": ["-pthread"], - }), - strip_include_prefix = "include", - visibility = ["//visibility:public"], -) - -cc_library( - name = "benchmark_main", - srcs = ["src/benchmark_main.cc"], - hdrs = ["include/benchmark/benchmark.h"], - strip_include_prefix = "include", - visibility = ["//visibility:public"], - deps = [":benchmark"], -) - -cc_library( - name = "benchmark_internal_headers", - hdrs = glob(["src/*.h"]), - visibility = ["//test:__pkg__"], -) diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/CMakeLists.txt b/external_imported/json/benchmarks/thirdparty/benchmark/CMakeLists.txt deleted file mode 100755 index b1c1d3d5a..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/CMakeLists.txt +++ /dev/null @@ -1,251 +0,0 @@ -cmake_minimum_required (VERSION 2.8.12) - -project (benchmark) - -foreach(p - CMP0054 # CMake 3.1 - CMP0056 # export EXE_LINKER_FLAGS to try_run - CMP0057 # Support no if() IN_LIST operator - ) - if(POLICY ${p}) - cmake_policy(SET ${p} NEW) - endif() -endforeach() - -option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." ON) -option(BENCHMARK_ENABLE_EXCEPTIONS "Enable the use of exceptions in the benchmark library." ON) -option(BENCHMARK_ENABLE_LTO "Enable link time optimisation of the benchmark library." OFF) -option(BENCHMARK_USE_LIBCXX "Build and test using libc++ as the standard library." OFF) -option(BENCHMARK_BUILD_32_BITS "Build a 32 bit version of the library." OFF) -option(BENCHMARK_ENABLE_INSTALL "Enable installation of benchmark. (Projects embedding benchmark may want to turn this OFF.)" ON) - -# Allow unmet dependencies to be met using CMake's ExternalProject mechanics, which -# may require downloading the source code. -option(BENCHMARK_DOWNLOAD_DEPENDENCIES "Allow the downloading and in-tree building of unmet dependencies" OFF) - -# This option can be used to disable building and running unit tests which depend on gtest -# in cases where it is not possible to build or find a valid version of gtest. -option(BENCHMARK_ENABLE_GTEST_TESTS "Enable building the unit tests which depend on gtest" ON) - -set(ENABLE_ASSEMBLY_TESTS_DEFAULT OFF) -function(should_enable_assembly_tests) - if(CMAKE_BUILD_TYPE) - string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER) - if (${CMAKE_BUILD_TYPE_LOWER} MATCHES "coverage") - # FIXME: The --coverage flag needs to be removed when building assembly - # tests for this to work. - return() - endif() - endif() - if (MSVC) - return() - elseif(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") - return() - elseif(NOT CMAKE_SIZEOF_VOID_P EQUAL 8) - # FIXME: Make these work on 32 bit builds - return() - elseif(BENCHMARK_BUILD_32_BITS) - # FIXME: Make these work on 32 bit builds - return() - endif() - find_program(LLVM_FILECHECK_EXE FileCheck) - if (LLVM_FILECHECK_EXE) - set(LLVM_FILECHECK_EXE "${LLVM_FILECHECK_EXE}" CACHE PATH "llvm filecheck" FORCE) - message(STATUS "LLVM FileCheck Found: ${LLVM_FILECHECK_EXE}") - else() - message(STATUS "Failed to find LLVM FileCheck") - return() - endif() - set(ENABLE_ASSEMBLY_TESTS_DEFAULT ON PARENT_SCOPE) -endfunction() -should_enable_assembly_tests() - -# This option disables the building and running of the assembly verification tests -option(BENCHMARK_ENABLE_ASSEMBLY_TESTS "Enable building and running the assembly tests" - ${ENABLE_ASSEMBLY_TESTS_DEFAULT}) - -# Make sure we can import out CMake functions -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules") -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - - -# Read the git tags to determine the project version -include(GetGitVersion) -get_git_version(GIT_VERSION) - -# Tell the user what versions we are using -string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" VERSION ${GIT_VERSION}) -message("-- Version: ${VERSION}") - -# The version of the libraries -set(GENERIC_LIB_VERSION ${VERSION}) -string(SUBSTRING ${VERSION} 0 1 GENERIC_LIB_SOVERSION) - -# Import our CMake modules -include(CheckCXXCompilerFlag) -include(AddCXXCompilerFlag) -include(CXXFeatureCheck) - -if (BENCHMARK_BUILD_32_BITS) - add_required_cxx_compiler_flag(-m32) -endif() - -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - # Turn compiler warnings up to 11 - string(REGEX REPLACE "[-/]W[1-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") - add_definitions(-D_CRT_SECURE_NO_WARNINGS) - - if (NOT BENCHMARK_ENABLE_EXCEPTIONS) - add_cxx_compiler_flag(-EHs-) - add_cxx_compiler_flag(-EHa-) - endif() - # Link time optimisation - if (BENCHMARK_ENABLE_LTO) - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GL") - set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG") - set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG") - set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG") - - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /GL") - string(REGEX REPLACE "[-/]INCREMENTAL" "/INCREMENTAL:NO" CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO}") - set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG") - string(REGEX REPLACE "[-/]INCREMENTAL" "/INCREMENTAL:NO" CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO}") - set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /LTCG") - string(REGEX REPLACE "[-/]INCREMENTAL" "/INCREMENTAL:NO" CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}") - set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /LTCG") - - set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /GL") - set(CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL "${CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL} /LTCG") - set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL} /LTCG") - set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /LTCG") - endif() -else() - # Try and enable C++11. Don't use C++14 because it doesn't work in some - # configurations. - add_cxx_compiler_flag(-std=c++11) - if (NOT HAVE_CXX_FLAG_STD_CXX11) - add_cxx_compiler_flag(-std=c++0x) - endif() - - # Turn compiler warnings up to 11 - add_cxx_compiler_flag(-Wall) - - add_cxx_compiler_flag(-Wextra) - add_cxx_compiler_flag(-Wshadow) - add_cxx_compiler_flag(-Werror RELEASE) - add_cxx_compiler_flag(-Werror RELWITHDEBINFO) - add_cxx_compiler_flag(-Werror MINSIZEREL) - add_cxx_compiler_flag(-pedantic) - add_cxx_compiler_flag(-pedantic-errors) - add_cxx_compiler_flag(-Wshorten-64-to-32) - add_cxx_compiler_flag(-Wfloat-equal) - add_cxx_compiler_flag(-fstrict-aliasing) - if (NOT BENCHMARK_ENABLE_EXCEPTIONS) - add_cxx_compiler_flag(-fno-exceptions) - endif() - - if (HAVE_CXX_FLAG_FSTRICT_ALIASING) - if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel") #ICC17u2: Many false positives for Wstrict-aliasing - add_cxx_compiler_flag(-Wstrict-aliasing) - endif() - endif() - # ICC17u2: overloaded virtual function "benchmark::Fixture::SetUp" is only partially overridden - # (because of deprecated overload) - add_cxx_compiler_flag(-wd654) - add_cxx_compiler_flag(-Wthread-safety) - if (HAVE_CXX_FLAG_WTHREAD_SAFETY) - cxx_feature_check(THREAD_SAFETY_ATTRIBUTES) - endif() - - # On most UNIX like platforms g++ and clang++ define _GNU_SOURCE as a - # predefined macro, which turns on all of the wonderful libc extensions. - # However g++ doesn't do this in Cygwin so we have to define it ourselfs - # since we depend on GNU/POSIX/BSD extensions. - if (CYGWIN) - add_definitions(-D_GNU_SOURCE=1) - endif() - - # Link time optimisation - if (BENCHMARK_ENABLE_LTO) - add_cxx_compiler_flag(-flto) - if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") - find_program(GCC_AR gcc-ar) - if (GCC_AR) - set(CMAKE_AR ${GCC_AR}) - endif() - find_program(GCC_RANLIB gcc-ranlib) - if (GCC_RANLIB) - set(CMAKE_RANLIB ${GCC_RANLIB}) - endif() - elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") - include(llvm-toolchain) - endif() - endif() - - # Coverage build type - set(BENCHMARK_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_DEBUG}" - CACHE STRING "Flags used by the C++ compiler during coverage builds." - FORCE) - set(BENCHMARK_EXE_LINKER_FLAGS_COVERAGE "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" - CACHE STRING "Flags used for linking binaries during coverage builds." - FORCE) - set(BENCHMARK_SHARED_LINKER_FLAGS_COVERAGE "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" - CACHE STRING "Flags used by the shared libraries linker during coverage builds." - FORCE) - mark_as_advanced( - BENCHMARK_CXX_FLAGS_COVERAGE - BENCHMARK_EXE_LINKER_FLAGS_COVERAGE - BENCHMARK_SHARED_LINKER_FLAGS_COVERAGE) - set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING - "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Coverage.") - add_cxx_compiler_flag(--coverage COVERAGE) -endif() - -if (BENCHMARK_USE_LIBCXX) - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - add_cxx_compiler_flag(-stdlib=libc++) - elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR - "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") - add_cxx_compiler_flag(-nostdinc++) - message("libc++ header path must be manually specified using CMAKE_CXX_FLAGS") - # Adding -nodefaultlibs directly to CMAKE__LINKER_FLAGS will break - # configuration checks such as 'find_package(Threads)' - list(APPEND BENCHMARK_CXX_LINKER_FLAGS -nodefaultlibs) - # -lc++ cannot be added directly to CMAKE__LINKER_FLAGS because - # linker flags appear before all linker inputs and -lc++ must appear after. - list(APPEND BENCHMARK_CXX_LIBRARIES c++) - else() - message(FATAL_ERROR "-DBENCHMARK_USE_LIBCXX:BOOL=ON is not supported for compiler") - endif() -endif(BENCHMARK_USE_LIBCXX) - -# C++ feature checks -# Determine the correct regular expression engine to use -cxx_feature_check(STD_REGEX) -cxx_feature_check(GNU_POSIX_REGEX) -cxx_feature_check(POSIX_REGEX) -if(NOT HAVE_STD_REGEX AND NOT HAVE_GNU_POSIX_REGEX AND NOT HAVE_POSIX_REGEX) - message(FATAL_ERROR "Failed to determine the source files for the regular expression backend") -endif() -if (NOT BENCHMARK_ENABLE_EXCEPTIONS AND HAVE_STD_REGEX - AND NOT HAVE_GNU_POSIX_REGEX AND NOT HAVE_POSIX_REGEX) - message(WARNING "Using std::regex with exceptions disabled is not fully supported") -endif() -cxx_feature_check(STEADY_CLOCK) -# Ensure we have pthreads -find_package(Threads REQUIRED) - -# Set up directories -include_directories(${PROJECT_SOURCE_DIR}/include) - -# Build the targets -add_subdirectory(src) - -if (BENCHMARK_ENABLE_TESTING) - enable_testing() - if (BENCHMARK_ENABLE_GTEST_TESTS) - include(HandleGTest) - endif() - add_subdirectory(test) -endif() diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/CONTRIBUTING.md b/external_imported/json/benchmarks/thirdparty/benchmark/CONTRIBUTING.md deleted file mode 100755 index 43de4c9d4..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/CONTRIBUTING.md +++ /dev/null @@ -1,58 +0,0 @@ -# How to contribute # - -We'd love to accept your patches and contributions to this project. There are -a just a few small guidelines you need to follow. - - -## Contributor License Agreement ## - -Contributions to any Google project must be accompanied by a Contributor -License Agreement. This is not a copyright **assignment**, it simply gives -Google permission to use and redistribute your contributions as part of the -project. - - * If you are an individual writing original source code and you're sure you - own the intellectual property, then you'll need to sign an [individual - CLA][]. - - * If you work for a company that wants to allow you to contribute your work, - then you'll need to sign a [corporate CLA][]. - -You generally only need to submit a CLA once, so if you've already submitted -one (even if it was for a different project), you probably don't need to do it -again. - -[individual CLA]: https://developers.google.com/open-source/cla/individual -[corporate CLA]: https://developers.google.com/open-source/cla/corporate - -Once your CLA is submitted (or if you already submitted one for -another Google project), make a commit adding yourself to the -[AUTHORS][] and [CONTRIBUTORS][] files. This commit can be part -of your first [pull request][]. - -[AUTHORS]: AUTHORS -[CONTRIBUTORS]: CONTRIBUTORS - - -## Submitting a patch ## - - 1. It's generally best to start by opening a new issue describing the bug or - feature you're intending to fix. Even if you think it's relatively minor, - it's helpful to know what people are working on. Mention in the initial - issue that you are planning to work on that bug or feature so that it can - be assigned to you. - - 1. Follow the normal process of [forking][] the project, and setup a new - branch to work in. It's important that each group of changes be done in - separate branches in order to ensure that a pull request only includes the - commits related to that bug or feature. - - 1. Do your best to have [well-formed commit messages][] for each change. - This provides consistency throughout the project, and ensures that commit - messages are able to be formatted properly by various git tools. - - 1. Finally, push the commits to your fork and submit a [pull request][]. - -[forking]: https://help.github.com/articles/fork-a-repo -[well-formed commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html -[pull request]: https://help.github.com/articles/creating-a-pull-request diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/CONTRIBUTORS b/external_imported/json/benchmarks/thirdparty/benchmark/CONTRIBUTORS deleted file mode 100755 index 1cf04db17..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/CONTRIBUTORS +++ /dev/null @@ -1,65 +0,0 @@ -# People who have agreed to one of the CLAs and can contribute patches. -# The AUTHORS file lists the copyright holders; this file -# lists people. For example, Google employees are listed here -# but not in AUTHORS, because Google holds the copyright. -# -# Names should be added to this file only after verifying that -# the individual or the individual's organization has agreed to -# the appropriate Contributor License Agreement, found here: -# -# https://developers.google.com/open-source/cla/individual -# https://developers.google.com/open-source/cla/corporate -# -# The agreement for individuals can be filled out on the web. -# -# When adding J Random Contributor's name to this file, -# either J's name or J's organization's name should be -# added to the AUTHORS file, depending on whether the -# individual or corporate CLA was used. -# -# Names should be added to this file as: -# Name -# -# Please keep the list sorted. - -Albert Pretorius -Arne Beer -Billy Robert O'Neal III -Chris Kennelly -Christopher Seymour -David Coeurjolly -Deniz Evrenci -Dominic Hamon -Dominik Czarnota -Eric Fiselier -Eugene Zhuk -Evgeny Safronov -Felix Homann -Ismael Jimenez Martinez -Jern-Kuan Leong -JianXiong Zhou -Joao Paulo Magalhaes -John Millikin -Jussi Knuuttila -Kai Wolf -Kishan Kumar -Kaito Udagawa -Lei Xu -Matt Clarkson -Maxim Vafin -Nick Hutchinson -Oleksandr Sochka -Pascal Leroy -Paul Redmond -Pierre Phaneuf -Radoslav Yovchev -Raul Marin -Ray Glover -Robert Guo -Roman Lebedev -Shuo Chen -Tobias UlvgÃ¥rd -Tom Madams -Yixuan Qiu -Yusuke Suzuki -Zbigniew Skowron diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/LICENSE b/external_imported/json/benchmarks/thirdparty/benchmark/LICENSE deleted file mode 100755 index d64569567..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/README.md b/external_imported/json/benchmarks/thirdparty/benchmark/README.md deleted file mode 100755 index 0341c31bd..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/README.md +++ /dev/null @@ -1,950 +0,0 @@ -# benchmark -[![Build Status](https://travis-ci.org/google/benchmark.svg?branch=master)](https://travis-ci.org/google/benchmark) -[![Build status](https://ci.appveyor.com/api/projects/status/u0qsyp7t1tk7cpxs/branch/master?svg=true)](https://ci.appveyor.com/project/google/benchmark/branch/master) -[![Coverage Status](https://coveralls.io/repos/google/benchmark/badge.svg)](https://coveralls.io/r/google/benchmark) -[![slackin](https://slackin-iqtfqnpzxd.now.sh/badge.svg)](https://slackin-iqtfqnpzxd.now.sh/) - -A library to support the benchmarking of functions, similar to unit-tests. - -Discussion group: https://groups.google.com/d/forum/benchmark-discuss - -IRC channel: https://freenode.net #googlebenchmark - -[Known issues and common problems](#known-issues) - -[Additional Tooling Documentation](docs/tools.md) - -[Assembly Testing Documentation](docs/AssemblyTests.md) - - -## Building - -The basic steps for configuring and building the library look like this: - -```bash -$ git clone https://github.com/google/benchmark.git -# Benchmark requires Google Test as a dependency. Add the source tree as a subdirectory. -$ git clone https://github.com/google/googletest.git benchmark/googletest -$ mkdir build && cd build -$ cmake -G [options] ../benchmark -# Assuming a makefile generator was used -$ make -``` - -Note that Google Benchmark requires Google Test to build and run the tests. This -dependency can be provided two ways: - -* Checkout the Google Test sources into `benchmark/googletest` as above. -* Otherwise, if `-DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON` is specified during - configuration, the library will automatically download and build any required - dependencies. - -If you do not wish to build and run the tests, add `-DBENCHMARK_ENABLE_GTEST_TESTS=OFF` -to `CMAKE_ARGS`. - - -## Installation Guide - -For Ubuntu and Debian Based System - -First make sure you have git and cmake installed (If not please install it) - -``` -sudo apt-get install git -sudo apt-get install cmake -``` - -Now, let's clone the repository and build it - -``` -git clone https://github.com/google/benchmark.git -cd benchmark -git clone https://github.com/google/googletest.git -mkdir build -cd build -cmake .. -DCMAKE_BUILD_TYPE=RELEASE -make -``` - -We need to install the library globally now - -``` -sudo make install -``` - -Now you have google/benchmark installed in your machine -Note: Don't forget to link to pthread library while building - -## Stable and Experimental Library Versions - -The main branch contains the latest stable version of the benchmarking library; -the API of which can be considered largely stable, with source breaking changes -being made only upon the release of a new major version. - -Newer, experimental, features are implemented and tested on the -[`v2` branch](https://github.com/google/benchmark/tree/v2). Users who wish -to use, test, and provide feedback on the new features are encouraged to try -this branch. However, this branch provides no stability guarantees and reserves -the right to change and break the API at any time. - -##Prerequisite knowledge - -Before attempting to understand this framework one should ideally have some familiarity with the structure and format of the Google Test framework, upon which it is based. Documentation for Google Test, including a "Getting Started" (primer) guide, is available here: -https://github.com/google/googletest/blob/master/googletest/docs/Documentation.md - - -## Example usage -### Basic usage -Define a function that executes the code to be measured. - -```c++ -#include - -static void BM_StringCreation(benchmark::State& state) { - for (auto _ : state) - std::string empty_string; -} -// Register the function as a benchmark -BENCHMARK(BM_StringCreation); - -// Define another benchmark -static void BM_StringCopy(benchmark::State& state) { - std::string x = "hello"; - for (auto _ : state) - std::string copy(x); -} -BENCHMARK(BM_StringCopy); - -BENCHMARK_MAIN(); -``` - -Don't forget to inform your linker to add benchmark library e.g. through -`-lbenchmark` compilation flag. Alternatively, you may leave out the -`BENCHMARK_MAIN();` at the end of the source file and link against -`-lbenchmark_main` to get the same default behavior. - -The benchmark library will reporting the timing for the code within the `for(...)` loop. - -### Passing arguments -Sometimes a family of benchmarks can be implemented with just one routine that -takes an extra argument to specify which one of the family of benchmarks to -run. For example, the following code defines a family of benchmarks for -measuring the speed of `memcpy()` calls of different lengths: - -```c++ -static void BM_memcpy(benchmark::State& state) { - char* src = new char[state.range(0)]; - char* dst = new char[state.range(0)]; - memset(src, 'x', state.range(0)); - for (auto _ : state) - memcpy(dst, src, state.range(0)); - state.SetBytesProcessed(int64_t(state.iterations()) * - int64_t(state.range(0))); - delete[] src; - delete[] dst; -} -BENCHMARK(BM_memcpy)->Arg(8)->Arg(64)->Arg(512)->Arg(1<<10)->Arg(8<<10); -``` - -The preceding code is quite repetitive, and can be replaced with the following -short-hand. The following invocation will pick a few appropriate arguments in -the specified range and will generate a benchmark for each such argument. - -```c++ -BENCHMARK(BM_memcpy)->Range(8, 8<<10); -``` - -By default the arguments in the range are generated in multiples of eight and -the command above selects [ 8, 64, 512, 4k, 8k ]. In the following code the -range multiplier is changed to multiples of two. - -```c++ -BENCHMARK(BM_memcpy)->RangeMultiplier(2)->Range(8, 8<<10); -``` -Now arguments generated are [ 8, 16, 32, 64, 128, 256, 512, 1024, 2k, 4k, 8k ]. - -You might have a benchmark that depends on two or more inputs. For example, the -following code defines a family of benchmarks for measuring the speed of set -insertion. - -```c++ -static void BM_SetInsert(benchmark::State& state) { - std::set data; - for (auto _ : state) { - state.PauseTiming(); - data = ConstructRandomSet(state.range(0)); - state.ResumeTiming(); - for (int j = 0; j < state.range(1); ++j) - data.insert(RandomNumber()); - } -} -BENCHMARK(BM_SetInsert) - ->Args({1<<10, 128}) - ->Args({2<<10, 128}) - ->Args({4<<10, 128}) - ->Args({8<<10, 128}) - ->Args({1<<10, 512}) - ->Args({2<<10, 512}) - ->Args({4<<10, 512}) - ->Args({8<<10, 512}); -``` - -The preceding code is quite repetitive, and can be replaced with the following -short-hand. The following macro will pick a few appropriate arguments in the -product of the two specified ranges and will generate a benchmark for each such -pair. - -```c++ -BENCHMARK(BM_SetInsert)->Ranges({{1<<10, 8<<10}, {128, 512}}); -``` - -For more complex patterns of inputs, passing a custom function to `Apply` allows -programmatic specification of an arbitrary set of arguments on which to run the -benchmark. The following example enumerates a dense range on one parameter, -and a sparse range on the second. - -```c++ -static void CustomArguments(benchmark::internal::Benchmark* b) { - for (int i = 0; i <= 10; ++i) - for (int j = 32; j <= 1024*1024; j *= 8) - b->Args({i, j}); -} -BENCHMARK(BM_SetInsert)->Apply(CustomArguments); -``` - -### Calculate asymptotic complexity (Big O) -Asymptotic complexity might be calculated for a family of benchmarks. The -following code will calculate the coefficient for the high-order term in the -running time and the normalized root-mean square error of string comparison. - -```c++ -static void BM_StringCompare(benchmark::State& state) { - std::string s1(state.range(0), '-'); - std::string s2(state.range(0), '-'); - for (auto _ : state) { - benchmark::DoNotOptimize(s1.compare(s2)); - } - state.SetComplexityN(state.range(0)); -} -BENCHMARK(BM_StringCompare) - ->RangeMultiplier(2)->Range(1<<10, 1<<18)->Complexity(benchmark::oN); -``` - -As shown in the following invocation, asymptotic complexity might also be -calculated automatically. - -```c++ -BENCHMARK(BM_StringCompare) - ->RangeMultiplier(2)->Range(1<<10, 1<<18)->Complexity(); -``` - -The following code will specify asymptotic complexity with a lambda function, -that might be used to customize high-order term calculation. - -```c++ -BENCHMARK(BM_StringCompare)->RangeMultiplier(2) - ->Range(1<<10, 1<<18)->Complexity([](int n)->double{return n; }); -``` - -### Templated benchmarks -Templated benchmarks work the same way: This example produces and consumes -messages of size `sizeof(v)` `range_x` times. It also outputs throughput in the -absence of multiprogramming. - -```c++ -template int BM_Sequential(benchmark::State& state) { - Q q; - typename Q::value_type v; - for (auto _ : state) { - for (int i = state.range(0); i--; ) - q.push(v); - for (int e = state.range(0); e--; ) - q.Wait(&v); - } - // actually messages, not bytes: - state.SetBytesProcessed( - static_cast(state.iterations())*state.range(0)); -} -BENCHMARK_TEMPLATE(BM_Sequential, WaitQueue)->Range(1<<0, 1<<10); -``` - -Three macros are provided for adding benchmark templates. - -```c++ -#ifdef BENCHMARK_HAS_CXX11 -#define BENCHMARK_TEMPLATE(func, ...) // Takes any number of parameters. -#else // C++ < C++11 -#define BENCHMARK_TEMPLATE(func, arg1) -#endif -#define BENCHMARK_TEMPLATE1(func, arg1) -#define BENCHMARK_TEMPLATE2(func, arg1, arg2) -``` - -### A Faster KeepRunning loop - -In C++11 mode, a ranged-based for loop should be used in preference to -the `KeepRunning` loop for running the benchmarks. For example: - -```c++ -static void BM_Fast(benchmark::State &state) { - for (auto _ : state) { - FastOperation(); - } -} -BENCHMARK(BM_Fast); -``` - -The reason the ranged-for loop is faster than using `KeepRunning`, is -because `KeepRunning` requires a memory load and store of the iteration count -ever iteration, whereas the ranged-for variant is able to keep the iteration count -in a register. - -For example, an empty inner loop of using the ranged-based for method looks like: - -```asm -# Loop Init - mov rbx, qword ptr [r14 + 104] - call benchmark::State::StartKeepRunning() - test rbx, rbx - je .LoopEnd -.LoopHeader: # =>This Inner Loop Header: Depth=1 - add rbx, -1 - jne .LoopHeader -.LoopEnd: -``` - -Compared to an empty `KeepRunning` loop, which looks like: - -```asm -.LoopHeader: # in Loop: Header=BB0_3 Depth=1 - cmp byte ptr [rbx], 1 - jne .LoopInit -.LoopBody: # =>This Inner Loop Header: Depth=1 - mov rax, qword ptr [rbx + 8] - lea rcx, [rax + 1] - mov qword ptr [rbx + 8], rcx - cmp rax, qword ptr [rbx + 104] - jb .LoopHeader - jmp .LoopEnd -.LoopInit: - mov rdi, rbx - call benchmark::State::StartKeepRunning() - jmp .LoopBody -.LoopEnd: -``` - -Unless C++03 compatibility is required, the ranged-for variant of writing -the benchmark loop should be preferred. - -## Passing arbitrary arguments to a benchmark -In C++11 it is possible to define a benchmark that takes an arbitrary number -of extra arguments. The `BENCHMARK_CAPTURE(func, test_case_name, ...args)` -macro creates a benchmark that invokes `func` with the `benchmark::State` as -the first argument followed by the specified `args...`. -The `test_case_name` is appended to the name of the benchmark and -should describe the values passed. - -```c++ -template -void BM_takes_args(benchmark::State& state, ExtraArgs&&... extra_args) { - [...] -} -// Registers a benchmark named "BM_takes_args/int_string_test" that passes -// the specified values to `extra_args`. -BENCHMARK_CAPTURE(BM_takes_args, int_string_test, 42, std::string("abc")); -``` -Note that elements of `...args` may refer to global variables. Users should -avoid modifying global state inside of a benchmark. - -## Using RegisterBenchmark(name, fn, args...) - -The `RegisterBenchmark(name, func, args...)` function provides an alternative -way to create and register benchmarks. -`RegisterBenchmark(name, func, args...)` creates, registers, and returns a -pointer to a new benchmark with the specified `name` that invokes -`func(st, args...)` where `st` is a `benchmark::State` object. - -Unlike the `BENCHMARK` registration macros, which can only be used at the global -scope, the `RegisterBenchmark` can be called anywhere. This allows for -benchmark tests to be registered programmatically. - -Additionally `RegisterBenchmark` allows any callable object to be registered -as a benchmark. Including capturing lambdas and function objects. - -For Example: -```c++ -auto BM_test = [](benchmark::State& st, auto Inputs) { /* ... */ }; - -int main(int argc, char** argv) { - for (auto& test_input : { /* ... */ }) - benchmark::RegisterBenchmark(test_input.name(), BM_test, test_input); - benchmark::Initialize(&argc, argv); - benchmark::RunSpecifiedBenchmarks(); -} -``` - -### Multithreaded benchmarks -In a multithreaded test (benchmark invoked by multiple threads simultaneously), -it is guaranteed that none of the threads will start until all have reached -the start of the benchmark loop, and all will have finished before any thread -exits the benchmark loop. (This behavior is also provided by the `KeepRunning()` -API) As such, any global setup or teardown can be wrapped in a check against the thread -index: - -```c++ -static void BM_MultiThreaded(benchmark::State& state) { - if (state.thread_index == 0) { - // Setup code here. - } - for (auto _ : state) { - // Run the test as normal. - } - if (state.thread_index == 0) { - // Teardown code here. - } -} -BENCHMARK(BM_MultiThreaded)->Threads(2); -``` - -If the benchmarked code itself uses threads and you want to compare it to -single-threaded code, you may want to use real-time ("wallclock") measurements -for latency comparisons: - -```c++ -BENCHMARK(BM_test)->Range(8, 8<<10)->UseRealTime(); -``` - -Without `UseRealTime`, CPU time is used by default. - - -## Manual timing -For benchmarking something for which neither CPU time nor real-time are -correct or accurate enough, completely manual timing is supported using -the `UseManualTime` function. - -When `UseManualTime` is used, the benchmarked code must call -`SetIterationTime` once per iteration of the benchmark loop to -report the manually measured time. - -An example use case for this is benchmarking GPU execution (e.g. OpenCL -or CUDA kernels, OpenGL or Vulkan or Direct3D draw calls), which cannot -be accurately measured using CPU time or real-time. Instead, they can be -measured accurately using a dedicated API, and these measurement results -can be reported back with `SetIterationTime`. - -```c++ -static void BM_ManualTiming(benchmark::State& state) { - int microseconds = state.range(0); - std::chrono::duration sleep_duration { - static_cast(microseconds) - }; - - for (auto _ : state) { - auto start = std::chrono::high_resolution_clock::now(); - // Simulate some useful workload with a sleep - std::this_thread::sleep_for(sleep_duration); - auto end = std::chrono::high_resolution_clock::now(); - - auto elapsed_seconds = - std::chrono::duration_cast>( - end - start); - - state.SetIterationTime(elapsed_seconds.count()); - } -} -BENCHMARK(BM_ManualTiming)->Range(1, 1<<17)->UseManualTime(); -``` - -### Preventing optimisation -To prevent a value or expression from being optimized away by the compiler -the `benchmark::DoNotOptimize(...)` and `benchmark::ClobberMemory()` -functions can be used. - -```c++ -static void BM_test(benchmark::State& state) { - for (auto _ : state) { - int x = 0; - for (int i=0; i < 64; ++i) { - benchmark::DoNotOptimize(x += i); - } - } -} -``` - -`DoNotOptimize()` forces the *result* of `` to be stored in either -memory or a register. For GNU based compilers it acts as read/write barrier -for global memory. More specifically it forces the compiler to flush pending -writes to memory and reload any other values as necessary. - -Note that `DoNotOptimize()` does not prevent optimizations on `` -in any way. `` may even be removed entirely when the result is already -known. For example: - -```c++ - /* Example 1: `` is removed entirely. */ - int foo(int x) { return x + 42; } - while (...) DoNotOptimize(foo(0)); // Optimized to DoNotOptimize(42); - - /* Example 2: Result of '' is only reused */ - int bar(int) __attribute__((const)); - while (...) DoNotOptimize(bar(0)); // Optimized to: - // int __result__ = bar(0); - // while (...) DoNotOptimize(__result__); -``` - -The second tool for preventing optimizations is `ClobberMemory()`. In essence -`ClobberMemory()` forces the compiler to perform all pending writes to global -memory. Memory managed by block scope objects must be "escaped" using -`DoNotOptimize(...)` before it can be clobbered. In the below example -`ClobberMemory()` prevents the call to `v.push_back(42)` from being optimized -away. - -```c++ -static void BM_vector_push_back(benchmark::State& state) { - for (auto _ : state) { - std::vector v; - v.reserve(1); - benchmark::DoNotOptimize(v.data()); // Allow v.data() to be clobbered. - v.push_back(42); - benchmark::ClobberMemory(); // Force 42 to be written to memory. - } -} -``` - -Note that `ClobberMemory()` is only available for GNU or MSVC based compilers. - -### Set time unit manually -If a benchmark runs a few milliseconds it may be hard to visually compare the -measured times, since the output data is given in nanoseconds per default. In -order to manually set the time unit, you can specify it manually: - -```c++ -BENCHMARK(BM_test)->Unit(benchmark::kMillisecond); -``` - -## Controlling number of iterations -In all cases, the number of iterations for which the benchmark is run is -governed by the amount of time the benchmark takes. Concretely, the number of -iterations is at least one, not more than 1e9, until CPU time is greater than -the minimum time, or the wallclock time is 5x minimum time. The minimum time is -set as a flag `--benchmark_min_time` or per benchmark by calling `MinTime` on -the registered benchmark object. - -## Reporting the mean, median and standard deviation by repeated benchmarks -By default each benchmark is run once and that single result is reported. -However benchmarks are often noisy and a single result may not be representative -of the overall behavior. For this reason it's possible to repeatedly rerun the -benchmark. - -The number of runs of each benchmark is specified globally by the -`--benchmark_repetitions` flag or on a per benchmark basis by calling -`Repetitions` on the registered benchmark object. When a benchmark is run more -than once the mean, median and standard deviation of the runs will be reported. - -Additionally the `--benchmark_report_aggregates_only={true|false}` flag or -`ReportAggregatesOnly(bool)` function can be used to change how repeated tests -are reported. By default the result of each repeated run is reported. When this -option is `true` only the mean, median and standard deviation of the runs is reported. -Calling `ReportAggregatesOnly(bool)` on a registered benchmark object overrides -the value of the flag for that benchmark. - -## User-defined statistics for repeated benchmarks -While having mean, median and standard deviation is nice, this may not be -enough for everyone. For example you may want to know what is the largest -observation, e.g. because you have some real-time constraints. This is easy. -The following code will specify a custom statistic to be calculated, defined -by a lambda function. - -```c++ -void BM_spin_empty(benchmark::State& state) { - for (auto _ : state) { - for (int x = 0; x < state.range(0); ++x) { - benchmark::DoNotOptimize(x); - } - } -} - -BENCHMARK(BM_spin_empty) - ->ComputeStatistics("max", [](const std::vector& v) -> double { - return *(std::max_element(std::begin(v), std::end(v))); - }) - ->Arg(512); -``` - -## Fixtures -Fixture tests are created by -first defining a type that derives from `::benchmark::Fixture` and then -creating/registering the tests using the following macros: - -* `BENCHMARK_F(ClassName, Method)` -* `BENCHMARK_DEFINE_F(ClassName, Method)` -* `BENCHMARK_REGISTER_F(ClassName, Method)` - -For Example: - -```c++ -class MyFixture : public benchmark::Fixture {}; - -BENCHMARK_F(MyFixture, FooTest)(benchmark::State& st) { - for (auto _ : st) { - ... - } -} - -BENCHMARK_DEFINE_F(MyFixture, BarTest)(benchmark::State& st) { - for (auto _ : st) { - ... - } -} -/* BarTest is NOT registered */ -BENCHMARK_REGISTER_F(MyFixture, BarTest)->Threads(2); -/* BarTest is now registered */ -``` - -### Templated fixtures -Also you can create templated fixture by using the following macros: - -* `BENCHMARK_TEMPLATE_F(ClassName, Method, ...)` -* `BENCHMARK_TEMPLATE_DEFINE_F(ClassName, Method, ...)` - -For example: -```c++ -template -class MyFixture : public benchmark::Fixture {}; - -BENCHMARK_TEMPLATE_F(MyFixture, IntTest, int)(benchmark::State& st) { - for (auto _ : st) { - ... - } -} - -BENCHMARK_TEMPLATE_DEFINE_F(MyFixture, DoubleTest, double)(benchmark::State& st) { - for (auto _ : st) { - ... - } -} - -BENCHMARK_REGISTER_F(MyFixture, DoubleTest)->Threads(2); -``` - -## User-defined counters - -You can add your own counters with user-defined names. The example below -will add columns "Foo", "Bar" and "Baz" in its output: - -```c++ -static void UserCountersExample1(benchmark::State& state) { - double numFoos = 0, numBars = 0, numBazs = 0; - for (auto _ : state) { - // ... count Foo,Bar,Baz events - } - state.counters["Foo"] = numFoos; - state.counters["Bar"] = numBars; - state.counters["Baz"] = numBazs; -} -``` - -The `state.counters` object is a `std::map` with `std::string` keys -and `Counter` values. The latter is a `double`-like class, via an implicit -conversion to `double&`. Thus you can use all of the standard arithmetic -assignment operators (`=,+=,-=,*=,/=`) to change the value of each counter. - -In multithreaded benchmarks, each counter is set on the calling thread only. -When the benchmark finishes, the counters from each thread will be summed; -the resulting sum is the value which will be shown for the benchmark. - -The `Counter` constructor accepts two parameters: the value as a `double` -and a bit flag which allows you to show counters as rates and/or as -per-thread averages: - -```c++ - // sets a simple counter - state.counters["Foo"] = numFoos; - - // Set the counter as a rate. It will be presented divided - // by the duration of the benchmark. - state.counters["FooRate"] = Counter(numFoos, benchmark::Counter::kIsRate); - - // Set the counter as a thread-average quantity. It will - // be presented divided by the number of threads. - state.counters["FooAvg"] = Counter(numFoos, benchmark::Counter::kAvgThreads); - - // There's also a combined flag: - state.counters["FooAvgRate"] = Counter(numFoos,benchmark::Counter::kAvgThreadsRate); -``` - -When you're compiling in C++11 mode or later you can use `insert()` with -`std::initializer_list`: - -```c++ - // With C++11, this can be done: - state.counters.insert({{"Foo", numFoos}, {"Bar", numBars}, {"Baz", numBazs}}); - // ... instead of: - state.counters["Foo"] = numFoos; - state.counters["Bar"] = numBars; - state.counters["Baz"] = numBazs; -``` - -### Counter reporting - -When using the console reporter, by default, user counters are are printed at -the end after the table, the same way as ``bytes_processed`` and -``items_processed``. This is best for cases in which there are few counters, -or where there are only a couple of lines per benchmark. Here's an example of -the default output: - -``` ------------------------------------------------------------------------------- -Benchmark Time CPU Iterations UserCounters... ------------------------------------------------------------------------------- -BM_UserCounter/threads:8 2248 ns 10277 ns 68808 Bar=16 Bat=40 Baz=24 Foo=8 -BM_UserCounter/threads:1 9797 ns 9788 ns 71523 Bar=2 Bat=5 Baz=3 Foo=1024m -BM_UserCounter/threads:2 4924 ns 9842 ns 71036 Bar=4 Bat=10 Baz=6 Foo=2 -BM_UserCounter/threads:4 2589 ns 10284 ns 68012 Bar=8 Bat=20 Baz=12 Foo=4 -BM_UserCounter/threads:8 2212 ns 10287 ns 68040 Bar=16 Bat=40 Baz=24 Foo=8 -BM_UserCounter/threads:16 1782 ns 10278 ns 68144 Bar=32 Bat=80 Baz=48 Foo=16 -BM_UserCounter/threads:32 1291 ns 10296 ns 68256 Bar=64 Bat=160 Baz=96 Foo=32 -BM_UserCounter/threads:4 2615 ns 10307 ns 68040 Bar=8 Bat=20 Baz=12 Foo=4 -BM_Factorial 26 ns 26 ns 26608979 40320 -BM_Factorial/real_time 26 ns 26 ns 26587936 40320 -BM_CalculatePiRange/1 16 ns 16 ns 45704255 0 -BM_CalculatePiRange/8 73 ns 73 ns 9520927 3.28374 -BM_CalculatePiRange/64 609 ns 609 ns 1140647 3.15746 -BM_CalculatePiRange/512 4900 ns 4901 ns 142696 3.14355 -``` - -If this doesn't suit you, you can print each counter as a table column by -passing the flag `--benchmark_counters_tabular=true` to the benchmark -application. This is best for cases in which there are a lot of counters, or -a lot of lines per individual benchmark. Note that this will trigger a -reprinting of the table header any time the counter set changes between -individual benchmarks. Here's an example of corresponding output when -`--benchmark_counters_tabular=true` is passed: - -``` ---------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations Bar Bat Baz Foo ---------------------------------------------------------------------------------------- -BM_UserCounter/threads:8 2198 ns 9953 ns 70688 16 40 24 8 -BM_UserCounter/threads:1 9504 ns 9504 ns 73787 2 5 3 1 -BM_UserCounter/threads:2 4775 ns 9550 ns 72606 4 10 6 2 -BM_UserCounter/threads:4 2508 ns 9951 ns 70332 8 20 12 4 -BM_UserCounter/threads:8 2055 ns 9933 ns 70344 16 40 24 8 -BM_UserCounter/threads:16 1610 ns 9946 ns 70720 32 80 48 16 -BM_UserCounter/threads:32 1192 ns 9948 ns 70496 64 160 96 32 -BM_UserCounter/threads:4 2506 ns 9949 ns 70332 8 20 12 4 --------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------- -BM_Factorial 26 ns 26 ns 26392245 40320 -BM_Factorial/real_time 26 ns 26 ns 26494107 40320 -BM_CalculatePiRange/1 15 ns 15 ns 45571597 0 -BM_CalculatePiRange/8 74 ns 74 ns 9450212 3.28374 -BM_CalculatePiRange/64 595 ns 595 ns 1173901 3.15746 -BM_CalculatePiRange/512 4752 ns 4752 ns 147380 3.14355 -BM_CalculatePiRange/4k 37970 ns 37972 ns 18453 3.14184 -BM_CalculatePiRange/32k 303733 ns 303744 ns 2305 3.14162 -BM_CalculatePiRange/256k 2434095 ns 2434186 ns 288 3.1416 -BM_CalculatePiRange/1024k 9721140 ns 9721413 ns 71 3.14159 -BM_CalculatePi/threads:8 2255 ns 9943 ns 70936 -``` -Note above the additional header printed when the benchmark changes from -``BM_UserCounter`` to ``BM_Factorial``. This is because ``BM_Factorial`` does -not have the same counter set as ``BM_UserCounter``. - -## Exiting Benchmarks in Error - -When errors caused by external influences, such as file I/O and network -communication, occur within a benchmark the -`State::SkipWithError(const char* msg)` function can be used to skip that run -of benchmark and report the error. Note that only future iterations of the -`KeepRunning()` are skipped. For the ranged-for version of the benchmark loop -Users must explicitly exit the loop, otherwise all iterations will be performed. -Users may explicitly return to exit the benchmark immediately. - -The `SkipWithError(...)` function may be used at any point within the benchmark, -including before and after the benchmark loop. - -For example: - -```c++ -static void BM_test(benchmark::State& state) { - auto resource = GetResource(); - if (!resource.good()) { - state.SkipWithError("Resource is not good!"); - // KeepRunning() loop will not be entered. - } - for (state.KeepRunning()) { - auto data = resource.read_data(); - if (!resource.good()) { - state.SkipWithError("Failed to read data!"); - break; // Needed to skip the rest of the iteration. - } - do_stuff(data); - } -} - -static void BM_test_ranged_fo(benchmark::State & state) { - state.SkipWithError("test will not be entered"); - for (auto _ : state) { - state.SkipWithError("Failed!"); - break; // REQUIRED to prevent all further iterations. - } -} -``` - -## Running a subset of the benchmarks - -The `--benchmark_filter=` option can be used to only run the benchmarks -which match the specified ``. For example: - -```bash -$ ./run_benchmarks.x --benchmark_filter=BM_memcpy/32 -Run on (1 X 2300 MHz CPU ) -2016-06-25 19:34:24 -Benchmark Time CPU Iterations ----------------------------------------------------- -BM_memcpy/32 11 ns 11 ns 79545455 -BM_memcpy/32k 2181 ns 2185 ns 324074 -BM_memcpy/32 12 ns 12 ns 54687500 -BM_memcpy/32k 1834 ns 1837 ns 357143 -``` - - -## Output Formats -The library supports multiple output formats. Use the -`--benchmark_format=` flag to set the format type. `console` -is the default format. - -The Console format is intended to be a human readable format. By default -the format generates color output. Context is output on stderr and the -tabular data on stdout. Example tabular output looks like: -``` -Benchmark Time(ns) CPU(ns) Iterations ----------------------------------------------------------------------- -BM_SetInsert/1024/1 28928 29349 23853 133.097kB/s 33.2742k items/s -BM_SetInsert/1024/8 32065 32913 21375 949.487kB/s 237.372k items/s -BM_SetInsert/1024/10 33157 33648 21431 1.13369MB/s 290.225k items/s -``` - -The JSON format outputs human readable json split into two top level attributes. -The `context` attribute contains information about the run in general, including -information about the CPU and the date. -The `benchmarks` attribute contains a list of every benchmark run. Example json -output looks like: -```json -{ - "context": { - "date": "2015/03/17-18:40:25", - "num_cpus": 40, - "mhz_per_cpu": 2801, - "cpu_scaling_enabled": false, - "build_type": "debug" - }, - "benchmarks": [ - { - "name": "BM_SetInsert/1024/1", - "iterations": 94877, - "real_time": 29275, - "cpu_time": 29836, - "bytes_per_second": 134066, - "items_per_second": 33516 - }, - { - "name": "BM_SetInsert/1024/8", - "iterations": 21609, - "real_time": 32317, - "cpu_time": 32429, - "bytes_per_second": 986770, - "items_per_second": 246693 - }, - { - "name": "BM_SetInsert/1024/10", - "iterations": 21393, - "real_time": 32724, - "cpu_time": 33355, - "bytes_per_second": 1199226, - "items_per_second": 299807 - } - ] -} -``` - -The CSV format outputs comma-separated values. The `context` is output on stderr -and the CSV itself on stdout. Example CSV output looks like: -``` -name,iterations,real_time,cpu_time,bytes_per_second,items_per_second,label -"BM_SetInsert/1024/1",65465,17890.7,8407.45,475768,118942, -"BM_SetInsert/1024/8",116606,18810.1,9766.64,3.27646e+06,819115, -"BM_SetInsert/1024/10",106365,17238.4,8421.53,4.74973e+06,1.18743e+06, -``` - -## Output Files -The library supports writing the output of the benchmark to a file specified -by `--benchmark_out=`. The format of the output can be specified -using `--benchmark_out_format={json|console|csv}`. Specifying -`--benchmark_out` does not suppress the console output. - -## Debug vs Release -By default, benchmark builds as a debug library. You will see a warning in the output when this is the case. To build it as a release library instead, use: - -``` -cmake -DCMAKE_BUILD_TYPE=Release -``` - -To enable link-time optimisation, use - -``` -cmake -DCMAKE_BUILD_TYPE=Release -DBENCHMARK_ENABLE_LTO=true -``` - -If you are using gcc, you might need to set `GCC_AR` and `GCC_RANLIB` cmake cache variables, if autodetection fails. -If you are using clang, you may need to set `LLVMAR_EXECUTABLE`, `LLVMNM_EXECUTABLE` and `LLVMRANLIB_EXECUTABLE` cmake cache variables. - -## Linking against the library - -When the library is built using GCC it is necessary to link with `-pthread`, -due to how GCC implements `std::thread`. - -For GCC 4.x failing to link to pthreads will lead to runtime exceptions, not linker errors. -See [issue #67](https://github.com/google/benchmark/issues/67) for more details. - -## Compiler Support - -Google Benchmark uses C++11 when building the library. As such we require -a modern C++ toolchain, both compiler and standard library. - -The following minimum versions are strongly recommended build the library: - -* GCC 4.8 -* Clang 3.4 -* Visual Studio 2013 -* Intel 2015 Update 1 - -Anything older *may* work. - -Note: Using the library and its headers in C++03 is supported. C++11 is only -required to build the library. - -## Disable CPU frequency scaling -If you see this error: -``` -***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead. -``` -you might want to disable the CPU frequency scaling while running the benchmark: -```bash -sudo cpupower frequency-set --governor performance -./mybench -sudo cpupower frequency-set --governor powersave -``` - -# Known Issues - -### Windows with CMake - -* Users must manually link `shlwapi.lib`. Failure to do so may result -in unresolved symbols. - -### Solaris - -* Users must explicitly link with kstat library (-lkstat compilation flag). diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/WORKSPACE b/external_imported/json/benchmarks/thirdparty/benchmark/WORKSPACE deleted file mode 100755 index 54734f1ea..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/WORKSPACE +++ /dev/null @@ -1,7 +0,0 @@ -workspace(name = "com_github_google_benchmark") - -http_archive( - name = "com_google_googletest", - urls = ["https://github.com/google/googletest/archive/3f0cf6b62ad1eb50d8736538363d3580dd640c3e.zip"], - strip_prefix = "googletest-3f0cf6b62ad1eb50d8736538363d3580dd640c3e", -) diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/appveyor.yml b/external_imported/json/benchmarks/thirdparty/benchmark/appveyor.yml deleted file mode 100755 index e99c6e77f..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/appveyor.yml +++ /dev/null @@ -1,56 +0,0 @@ -version: '{build}' - -image: Visual Studio 2017 - -configuration: - - Debug - - Release - -environment: - matrix: - - compiler: msvc-15-seh - generator: "Visual Studio 15 2017" - - - compiler: msvc-15-seh - generator: "Visual Studio 15 2017 Win64" - - - compiler: msvc-14-seh - generator: "Visual Studio 14 2015" - - - compiler: msvc-14-seh - generator: "Visual Studio 14 2015 Win64" - - - compiler: msvc-12-seh - generator: "Visual Studio 12 2013" - - - compiler: msvc-12-seh - generator: "Visual Studio 12 2013 Win64" - - - compiler: gcc-5.3.0-posix - generator: "MinGW Makefiles" - cxx_path: 'C:\mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0\mingw32\bin' - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - -matrix: - fast_finish: true - -install: - # git bash conflicts with MinGW makefiles - - if "%generator%"=="MinGW Makefiles" (set "PATH=%PATH:C:\Program Files\Git\usr\bin;=%") - - if not "%cxx_path%"=="" (set "PATH=%PATH%;%cxx_path%") - -build_script: - - md _build -Force - - cd _build - - echo %configuration% - - cmake -G "%generator%" "-DCMAKE_BUILD_TYPE=%configuration%" -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON .. - - cmake --build . --config %configuration% - -test_script: - - ctest -c %configuration% --timeout 300 --output-on-failure - -artifacts: - - path: '_build/CMakeFiles/*.log' - name: logs - - path: '_build/Testing/**/*.xml' - name: test_results diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/AddCXXCompilerFlag.cmake b/external_imported/json/benchmarks/thirdparty/benchmark/cmake/AddCXXCompilerFlag.cmake deleted file mode 100755 index d0d209981..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/AddCXXCompilerFlag.cmake +++ /dev/null @@ -1,74 +0,0 @@ -# - Adds a compiler flag if it is supported by the compiler -# -# This function checks that the supplied compiler flag is supported and then -# adds it to the corresponding compiler flags -# -# add_cxx_compiler_flag( []) -# -# - Example -# -# include(AddCXXCompilerFlag) -# add_cxx_compiler_flag(-Wall) -# add_cxx_compiler_flag(-no-strict-aliasing RELEASE) -# Requires CMake 2.6+ - -if(__add_cxx_compiler_flag) - return() -endif() -set(__add_cxx_compiler_flag INCLUDED) - -include(CheckCXXCompilerFlag) - -function(mangle_compiler_flag FLAG OUTPUT) - string(TOUPPER "HAVE_CXX_FLAG_${FLAG}" SANITIZED_FLAG) - string(REPLACE "+" "X" SANITIZED_FLAG ${SANITIZED_FLAG}) - string(REGEX REPLACE "[^A-Za-z_0-9]" "_" SANITIZED_FLAG ${SANITIZED_FLAG}) - string(REGEX REPLACE "_+" "_" SANITIZED_FLAG ${SANITIZED_FLAG}) - set(${OUTPUT} "${SANITIZED_FLAG}" PARENT_SCOPE) -endfunction(mangle_compiler_flag) - -function(add_cxx_compiler_flag FLAG) - mangle_compiler_flag("${FLAG}" MANGLED_FLAG) - set(OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}") - check_cxx_compiler_flag("${FLAG}" ${MANGLED_FLAG}) - set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}") - if(${MANGLED_FLAG}) - set(VARIANT ${ARGV1}) - if(ARGV1) - string(TOUPPER "_${VARIANT}" VARIANT) - endif() - set(CMAKE_CXX_FLAGS${VARIANT} "${CMAKE_CXX_FLAGS${VARIANT}} ${BENCHMARK_CXX_FLAGS${VARIANT}} ${FLAG}" PARENT_SCOPE) - endif() -endfunction() - -function(add_required_cxx_compiler_flag FLAG) - mangle_compiler_flag("${FLAG}" MANGLED_FLAG) - set(OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}") - check_cxx_compiler_flag("${FLAG}" ${MANGLED_FLAG}) - set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}") - if(${MANGLED_FLAG}) - set(VARIANT ${ARGV1}) - if(ARGV1) - string(TOUPPER "_${VARIANT}" VARIANT) - endif() - set(CMAKE_CXX_FLAGS${VARIANT} "${CMAKE_CXX_FLAGS${VARIANT}} ${FLAG}" PARENT_SCOPE) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAG}" PARENT_SCOPE) - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${FLAG}" PARENT_SCOPE) - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${FLAG}" PARENT_SCOPE) - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}" PARENT_SCOPE) - else() - message(FATAL_ERROR "Required flag '${FLAG}' is not supported by the compiler") - endif() -endfunction() - -function(check_cxx_warning_flag FLAG) - mangle_compiler_flag("${FLAG}" MANGLED_FLAG) - set(OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") - # Add -Werror to ensure the compiler generates an error if the warning flag - # doesn't exist. - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror ${FLAG}") - check_cxx_compiler_flag("${FLAG}" ${MANGLED_FLAG}) - set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}") -endfunction() diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/CXXFeatureCheck.cmake b/external_imported/json/benchmarks/thirdparty/benchmark/cmake/CXXFeatureCheck.cmake deleted file mode 100755 index c4c4d660f..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/CXXFeatureCheck.cmake +++ /dev/null @@ -1,64 +0,0 @@ -# - Compile and run code to check for C++ features -# -# This functions compiles a source file under the `cmake` folder -# and adds the corresponding `HAVE_[FILENAME]` flag to the CMake -# environment -# -# cxx_feature_check( []) -# -# - Example -# -# include(CXXFeatureCheck) -# cxx_feature_check(STD_REGEX) -# Requires CMake 2.8.12+ - -if(__cxx_feature_check) - return() -endif() -set(__cxx_feature_check INCLUDED) - -function(cxx_feature_check FILE) - string(TOLOWER ${FILE} FILE) - string(TOUPPER ${FILE} VAR) - string(TOUPPER "HAVE_${VAR}" FEATURE) - if (DEFINED HAVE_${VAR}) - set(HAVE_${VAR} 1 PARENT_SCOPE) - add_definitions(-DHAVE_${VAR}) - return() - endif() - - if (NOT DEFINED COMPILE_${FEATURE}) - message("-- Performing Test ${FEATURE}") - if(CMAKE_CROSSCOMPILING) - try_compile(COMPILE_${FEATURE} - ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${FILE}.cpp - CMAKE_FLAGS ${BENCHMARK_CXX_LINKER_FLAGS} - LINK_LIBRARIES ${BENCHMARK_CXX_LIBRARIES}) - if(COMPILE_${FEATURE}) - message(WARNING - "If you see build failures due to cross compilation, try setting HAVE_${VAR} to 0") - set(RUN_${FEATURE} 0) - else() - set(RUN_${FEATURE} 1) - endif() - else() - message("-- Performing Test ${FEATURE}") - try_run(RUN_${FEATURE} COMPILE_${FEATURE} - ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${FILE}.cpp - CMAKE_FLAGS ${BENCHMARK_CXX_LINKER_FLAGS} - LINK_LIBRARIES ${BENCHMARK_CXX_LIBRARIES}) - endif() - endif() - - if(RUN_${FEATURE} EQUAL 0) - message("-- Performing Test ${FEATURE} -- success") - set(HAVE_${VAR} 1 PARENT_SCOPE) - add_definitions(-DHAVE_${VAR}) - else() - if(NOT COMPILE_${FEATURE}) - message("-- Performing Test ${FEATURE} -- failed to compile") - else() - message("-- Performing Test ${FEATURE} -- compiled but failed to run") - endif() - endif() -endfunction() diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/Config.cmake.in b/external_imported/json/benchmarks/thirdparty/benchmark/cmake/Config.cmake.in deleted file mode 100755 index 6e9256eea..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/Config.cmake.in +++ /dev/null @@ -1 +0,0 @@ -include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/GetGitVersion.cmake b/external_imported/json/benchmarks/thirdparty/benchmark/cmake/GetGitVersion.cmake deleted file mode 100755 index 88cebe3a1..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/GetGitVersion.cmake +++ /dev/null @@ -1,54 +0,0 @@ -# - Returns a version string from Git tags -# -# This function inspects the annotated git tags for the project and returns a string -# into a CMake variable -# -# get_git_version() -# -# - Example -# -# include(GetGitVersion) -# get_git_version(GIT_VERSION) -# -# Requires CMake 2.8.11+ -find_package(Git) - -if(__get_git_version) - return() -endif() -set(__get_git_version INCLUDED) - -function(get_git_version var) - if(GIT_EXECUTABLE) - execute_process(COMMAND ${GIT_EXECUTABLE} describe --match "v[0-9]*.[0-9]*.[0-9]*" --abbrev=8 - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - RESULT_VARIABLE status - OUTPUT_VARIABLE GIT_VERSION - ERROR_QUIET) - if(${status}) - set(GIT_VERSION "v0.0.0") - else() - string(STRIP ${GIT_VERSION} GIT_VERSION) - string(REGEX REPLACE "-[0-9]+-g" "-" GIT_VERSION ${GIT_VERSION}) - endif() - - # Work out if the repository is dirty - execute_process(COMMAND ${GIT_EXECUTABLE} update-index -q --refresh - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_QUIET - ERROR_QUIET) - execute_process(COMMAND ${GIT_EXECUTABLE} diff-index --name-only HEAD -- - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE GIT_DIFF_INDEX - ERROR_QUIET) - string(COMPARE NOTEQUAL "${GIT_DIFF_INDEX}" "" GIT_DIRTY) - if (${GIT_DIRTY}) - set(GIT_VERSION "${GIT_VERSION}-dirty") - endif() - else() - set(GIT_VERSION "v0.0.0") - endif() - - message("-- git Version: ${GIT_VERSION}") - set(${var} ${GIT_VERSION} PARENT_SCOPE) -endfunction() diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/HandleGTest.cmake b/external_imported/json/benchmarks/thirdparty/benchmark/cmake/HandleGTest.cmake deleted file mode 100755 index 7ce1a633d..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/HandleGTest.cmake +++ /dev/null @@ -1,113 +0,0 @@ - -include(split_list) - -macro(build_external_gtest) - include(ExternalProject) - set(GTEST_FLAGS "") - if (BENCHMARK_USE_LIBCXX) - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - list(APPEND GTEST_FLAGS -stdlib=libc++) - else() - message(WARNING "Unsupported compiler (${CMAKE_CXX_COMPILER}) when using libc++") - endif() - endif() - if (BENCHMARK_BUILD_32_BITS) - list(APPEND GTEST_FLAGS -m32) - endif() - if (NOT "${CMAKE_CXX_FLAGS}" STREQUAL "") - list(APPEND GTEST_FLAGS ${CMAKE_CXX_FLAGS}) - endif() - string(TOUPPER "${CMAKE_BUILD_TYPE}" GTEST_BUILD_TYPE) - if ("${GTEST_BUILD_TYPE}" STREQUAL "COVERAGE") - set(GTEST_BUILD_TYPE "DEBUG") - endif() - # FIXME: Since 10/Feb/2017 the googletest trunk has had a bug where - # -Werror=unused-function fires during the build on OS X. This is a temporary - # workaround to keep our travis bots from failing. It should be removed - # once gtest is fixed. - if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - list(APPEND GTEST_FLAGS "-Wno-unused-function") - endif() - split_list(GTEST_FLAGS) - set(EXCLUDE_FROM_ALL_OPT "") - set(EXCLUDE_FROM_ALL_VALUE "") - if (${CMAKE_VERSION} VERSION_GREATER "3.0.99") - set(EXCLUDE_FROM_ALL_OPT "EXCLUDE_FROM_ALL") - set(EXCLUDE_FROM_ALL_VALUE "ON") - endif() - ExternalProject_Add(googletest - ${EXCLUDE_FROM_ALL_OPT} ${EXCLUDE_FROM_ALL_VALUE} - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG master - PREFIX "${CMAKE_BINARY_DIR}/googletest" - INSTALL_DIR "${CMAKE_BINARY_DIR}/googletest" - CMAKE_CACHE_ARGS - -DCMAKE_BUILD_TYPE:STRING=${GTEST_BUILD_TYPE} - -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER} - -DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER} - -DCMAKE_INSTALL_PREFIX:PATH= - -DCMAKE_INSTALL_LIBDIR:PATH=/lib - -DCMAKE_CXX_FLAGS:STRING=${GTEST_FLAGS} - -Dgtest_force_shared_crt:BOOL=ON - ) - - ExternalProject_Get_Property(googletest install_dir) - set(GTEST_INCLUDE_DIRS ${install_dir}/include) - file(MAKE_DIRECTORY ${GTEST_INCLUDE_DIRS}) - - set(LIB_SUFFIX "${CMAKE_STATIC_LIBRARY_SUFFIX}") - set(LIB_PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}") - if("${GTEST_BUILD_TYPE}" STREQUAL "DEBUG") - set(LIB_SUFFIX "d${CMAKE_STATIC_LIBRARY_SUFFIX}") - endif() - - # Use gmock_main instead of gtest_main because it initializes gtest as well. - # Note: The libraries are listed in reverse order of their dependancies. - foreach(LIB gtest gmock gmock_main) - add_library(${LIB} UNKNOWN IMPORTED) - set_target_properties(${LIB} PROPERTIES - IMPORTED_LOCATION ${install_dir}/lib/${LIB_PREFIX}${LIB}${LIB_SUFFIX} - INTERFACE_INCLUDE_DIRECTORIES ${GTEST_INCLUDE_DIRS} - INTERFACE_LINK_LIBRARIES "${GTEST_BOTH_LIBRARIES}" - ) - add_dependencies(${LIB} googletest) - list(APPEND GTEST_BOTH_LIBRARIES ${LIB}) - endforeach() -endmacro(build_external_gtest) - -if (BENCHMARK_ENABLE_GTEST_TESTS) - if (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/googletest) - set(GTEST_ROOT "${CMAKE_SOURCE_DIR}/googletest") - set(INSTALL_GTEST OFF CACHE INTERNAL "") - set(INSTALL_GMOCK OFF CACHE INTERNAL "") - add_subdirectory(${CMAKE_SOURCE_DIR}/googletest) - set(GTEST_BOTH_LIBRARIES gtest gmock gmock_main) - foreach(HEADER test mock) - # CMake 2.8 and older don't respect INTERFACE_INCLUDE_DIRECTORIES, so we - # have to add the paths ourselves. - set(HFILE g${HEADER}/g${HEADER}.h) - set(HPATH ${GTEST_ROOT}/google${HEADER}/include) - find_path(HEADER_PATH_${HEADER} ${HFILE} - NO_DEFAULT_PATHS - HINTS ${HPATH} - ) - if (NOT HEADER_PATH_${HEADER}) - message(FATAL_ERROR "Failed to find header ${HFILE} in ${HPATH}") - endif() - list(APPEND GTEST_INCLUDE_DIRS ${HEADER_PATH_${HEADER}}) - endforeach() - elseif(BENCHMARK_DOWNLOAD_DEPENDENCIES) - build_external_gtest() - else() - find_package(GTest REQUIRED) - find_path(GMOCK_INCLUDE_DIRS gmock/gmock.h - HINTS ${GTEST_INCLUDE_DIRS}) - if (NOT GMOCK_INCLUDE_DIRS) - message(FATAL_ERROR "Failed to find header gmock/gmock.h with hint ${GTEST_INCLUDE_DIRS}") - endif() - set(GTEST_INCLUDE_DIRS ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS}) - # FIXME: We don't currently require the gmock library to build the tests, - # and it's likely we won't find it, so we don't try. As long as we've - # found the gmock/gmock.h header and gtest_main that should be good enough. - endif() -endif() diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/Modules/FindLLVMAr.cmake b/external_imported/json/benchmarks/thirdparty/benchmark/cmake/Modules/FindLLVMAr.cmake deleted file mode 100755 index 23469813c..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/Modules/FindLLVMAr.cmake +++ /dev/null @@ -1,16 +0,0 @@ -include(FeatureSummary) - -find_program(LLVMAR_EXECUTABLE - NAMES llvm-ar - DOC "The llvm-ar executable" - ) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(LLVMAr - DEFAULT_MSG - LLVMAR_EXECUTABLE) - -SET_PACKAGE_PROPERTIES(LLVMAr PROPERTIES - URL https://llvm.org/docs/CommandGuide/llvm-ar.html - DESCRIPTION "create, modify, and extract from archives" -) diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/Modules/FindLLVMNm.cmake b/external_imported/json/benchmarks/thirdparty/benchmark/cmake/Modules/FindLLVMNm.cmake deleted file mode 100755 index e56430a04..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/Modules/FindLLVMNm.cmake +++ /dev/null @@ -1,16 +0,0 @@ -include(FeatureSummary) - -find_program(LLVMNM_EXECUTABLE - NAMES llvm-nm - DOC "The llvm-nm executable" - ) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(LLVMNm - DEFAULT_MSG - LLVMNM_EXECUTABLE) - -SET_PACKAGE_PROPERTIES(LLVMNm PROPERTIES - URL https://llvm.org/docs/CommandGuide/llvm-nm.html - DESCRIPTION "list LLVM bitcode and object file’s symbol table" -) diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/Modules/FindLLVMRanLib.cmake b/external_imported/json/benchmarks/thirdparty/benchmark/cmake/Modules/FindLLVMRanLib.cmake deleted file mode 100755 index 7b53e1a79..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/Modules/FindLLVMRanLib.cmake +++ /dev/null @@ -1,15 +0,0 @@ -include(FeatureSummary) - -find_program(LLVMRANLIB_EXECUTABLE - NAMES llvm-ranlib - DOC "The llvm-ranlib executable" - ) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(LLVMRanLib - DEFAULT_MSG - LLVMRANLIB_EXECUTABLE) - -SET_PACKAGE_PROPERTIES(LLVMRanLib PROPERTIES - DESCRIPTION "generate index for LLVM archive" -) diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/benchmark.pc.in b/external_imported/json/benchmarks/thirdparty/benchmark/cmake/benchmark.pc.in deleted file mode 100755 index 1e84bff68..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/benchmark.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix} -libdir=${prefix}/lib -includedir=${prefix}/include - -Name: @PROJECT_NAME@ -Description: Google microbenchmark framework -Version: @VERSION@ - -Libs: -L${libdir} -lbenchmark -Cflags: -I${includedir} diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/gnu_posix_regex.cpp b/external_imported/json/benchmarks/thirdparty/benchmark/cmake/gnu_posix_regex.cpp deleted file mode 100755 index b5b91cdab..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/gnu_posix_regex.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include -int main() { - std::string str = "test0159"; - regex_t re; - int ec = regcomp(&re, "^[a-z]+[0-9]+$", REG_EXTENDED | REG_NOSUB); - if (ec != 0) { - return ec; - } - return regexec(&re, str.c_str(), 0, nullptr, 0) ? -1 : 0; -} - diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/llvm-toolchain.cmake b/external_imported/json/benchmarks/thirdparty/benchmark/cmake/llvm-toolchain.cmake deleted file mode 100755 index fc119e52f..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/llvm-toolchain.cmake +++ /dev/null @@ -1,8 +0,0 @@ -find_package(LLVMAr REQUIRED) -set(CMAKE_AR "${LLVMAR_EXECUTABLE}" CACHE FILEPATH "" FORCE) - -find_package(LLVMNm REQUIRED) -set(CMAKE_NM "${LLVMNM_EXECUTABLE}" CACHE FILEPATH "" FORCE) - -find_package(LLVMRanLib REQUIRED) -set(CMAKE_RANLIB "${LLVMRANLIB_EXECUTABLE}" CACHE FILEPATH "" FORCE) diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/posix_regex.cpp b/external_imported/json/benchmarks/thirdparty/benchmark/cmake/posix_regex.cpp deleted file mode 100755 index 466dc6256..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/posix_regex.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -int main() { - std::string str = "test0159"; - regex_t re; - int ec = regcomp(&re, "^[a-z]+[0-9]+$", REG_EXTENDED | REG_NOSUB); - if (ec != 0) { - return ec; - } - int ret = regexec(&re, str.c_str(), 0, nullptr, 0) ? -1 : 0; - regfree(&re); - return ret; -} - diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/split_list.cmake b/external_imported/json/benchmarks/thirdparty/benchmark/cmake/split_list.cmake deleted file mode 100755 index 67aed3fdc..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/split_list.cmake +++ /dev/null @@ -1,3 +0,0 @@ -macro(split_list listname) - string(REPLACE ";" " " ${listname} "${${listname}}") -endmacro() diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/std_regex.cpp b/external_imported/json/benchmarks/thirdparty/benchmark/cmake/std_regex.cpp deleted file mode 100755 index 696f2a26b..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/std_regex.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include -int main() { - const std::string str = "test0159"; - std::regex re; - re = std::regex("^[a-z]+[0-9]+$", - std::regex_constants::extended | std::regex_constants::nosubs); - return std::regex_search(str, re) ? 0 : -1; -} - diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/steady_clock.cpp b/external_imported/json/benchmarks/thirdparty/benchmark/cmake/steady_clock.cpp deleted file mode 100755 index 66d50d17e..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/steady_clock.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -int main() { - typedef std::chrono::steady_clock Clock; - Clock::time_point tp = Clock::now(); - ((void)tp); -} diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/thread_safety_attributes.cpp b/external_imported/json/benchmarks/thirdparty/benchmark/cmake/thread_safety_attributes.cpp deleted file mode 100755 index 46161babd..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/cmake/thread_safety_attributes.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#define HAVE_THREAD_SAFETY_ATTRIBUTES -#include "../src/mutex.h" - -int main() {} diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/docs/AssemblyTests.md b/external_imported/json/benchmarks/thirdparty/benchmark/docs/AssemblyTests.md deleted file mode 100755 index 1fbdc269b..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/docs/AssemblyTests.md +++ /dev/null @@ -1,147 +0,0 @@ -# Assembly Tests - -The Benchmark library provides a number of functions whose primary -purpose in to affect assembly generation, including `DoNotOptimize` -and `ClobberMemory`. In addition there are other functions, -such as `KeepRunning`, for which generating good assembly is paramount. - -For these functions it's important to have tests that verify the -correctness and quality of the implementation. This requires testing -the code generated by the compiler. - -This document describes how the Benchmark library tests compiler output, -as well as how to properly write new tests. - - -## Anatomy of a Test - -Writing a test has two steps: - -* Write the code you want to generate assembly for. -* Add `// CHECK` lines to match against the verified assembly. - -Example: -```c++ - -// CHECK-LABEL: test_add: -extern "C" int test_add() { - extern int ExternInt; - return ExternInt + 1; - - // CHECK: movl ExternInt(%rip), %eax - // CHECK: addl %eax - // CHECK: ret -} - -``` - -#### LLVM Filecheck - -[LLVM's Filecheck](https://llvm.org/docs/CommandGuide/FileCheck.html) -is used to test the generated assembly against the `// CHECK` lines -specified in the tests source file. Please see the documentation -linked above for information on how to write `CHECK` directives. - -#### Tips and Tricks: - -* Tests should match the minimal amount of output required to establish -correctness. `CHECK` directives don't have to match on the exact next line -after the previous match, so tests should omit checks for unimportant -bits of assembly. ([`CHECK-NEXT`](https://llvm.org/docs/CommandGuide/FileCheck.html#the-check-next-directive) -can be used to ensure a match occurs exactly after the previous match). - -* The tests are compiled with `-O3 -g0`. So we're only testing the -optimized output. - -* The assembly output is further cleaned up using `tools/strip_asm.py`. -This removes comments, assembler directives, and unused labels before -the test is run. - -* The generated and stripped assembly file for a test is output under -`/test/.s` - -* Filecheck supports using [`CHECK` prefixes](https://llvm.org/docs/CommandGuide/FileCheck.html#cmdoption-check-prefixes) -to specify lines that should only match in certain situations. -The Benchmark tests use `CHECK-CLANG` and `CHECK-GNU` for lines that -are only expected to match Clang or GCC's output respectively. Normal -`CHECK` lines match against all compilers. (Note: `CHECK-NOT` and -`CHECK-LABEL` are NOT prefixes. They are versions of non-prefixed -`CHECK` lines) - -* Use `extern "C"` to disable name mangling for specific functions. This -makes them easier to name in the `CHECK` lines. - - -## Problems Writing Portable Tests - -Writing tests which check the code generated by a compiler are -inherently non-portable. Different compilers and even different compiler -versions may generate entirely different code. The Benchmark tests -must tolerate this. - -LLVM Filecheck provides a number of mechanisms to help write -"more portable" tests; including [matching using regular expressions](https://llvm.org/docs/CommandGuide/FileCheck.html#filecheck-pattern-matching-syntax), -allowing the creation of [named variables](https://llvm.org/docs/CommandGuide/FileCheck.html#filecheck-variables) -for later matching, and [checking non-sequential matches](https://llvm.org/docs/CommandGuide/FileCheck.html#the-check-dag-directive). - -#### Capturing Variables - -For example, say GCC stores a variable in a register but Clang stores -it in memory. To write a test that tolerates both cases we "capture" -the destination of the store, and then use the captured expression -to write the remainder of the test. - -```c++ -// CHECK-LABEL: test_div_no_op_into_shr: -extern "C" void test_div_no_op_into_shr(int value) { - int divisor = 2; - benchmark::DoNotOptimize(divisor); // hide the value from the optimizer - return value / divisor; - - // CHECK: movl $2, [[DEST:.*]] - // CHECK: idivl [[DEST]] - // CHECK: ret -} -``` - -#### Using Regular Expressions to Match Differing Output - -Often tests require testing assembly lines which may subtly differ -between compilers or compiler versions. A common example of this -is matching stack frame addresses. In this case regular expressions -can be used to match the differing bits of output. For example: - -```c++ -int ExternInt; -struct Point { int x, y, z; }; - -// CHECK-LABEL: test_store_point: -extern "C" void test_store_point() { - Point p{ExternInt, ExternInt, ExternInt}; - benchmark::DoNotOptimize(p); - - // CHECK: movl ExternInt(%rip), %eax - // CHECK: movl %eax, -{{[0-9]+}}(%rsp) - // CHECK: movl %eax, -{{[0-9]+}}(%rsp) - // CHECK: movl %eax, -{{[0-9]+}}(%rsp) - // CHECK: ret -} -``` - -## Current Requirements and Limitations - -The tests require Filecheck to be installed along the `PATH` of the -build machine. Otherwise the tests will be disabled. - -Additionally, as mentioned in the previous section, codegen tests are -inherently non-portable. Currently the tests are limited to: - -* x86_64 targets. -* Compiled with GCC or Clang - -Further work could be done, at least on a limited basis, to extend the -tests to other architectures and compilers (using `CHECK` prefixes). - -Furthermore, the tests fail for builds which specify additional flags -that modify code generation, including `--coverage` or `-fsanitize=`. - diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/docs/tools.md b/external_imported/json/benchmarks/thirdparty/benchmark/docs/tools.md deleted file mode 100755 index 70500bd32..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/docs/tools.md +++ /dev/null @@ -1,242 +0,0 @@ -# Benchmark Tools - -## compare_bench.py - -The `compare_bench.py` utility which can be used to compare the result of benchmarks. -The program is invoked like: - -``` bash -$ compare_bench.py [benchmark options]... -``` - -Where `` and `` either specify a benchmark executable file, or a JSON output file. The type of the input file is automatically detected. If a benchmark executable is specified then the benchmark is run to obtain the results. Otherwise the results are simply loaded from the output file. - -`[benchmark options]` will be passed to the benchmarks invocations. They can be anything that binary accepts, be it either normal `--benchmark_*` parameters, or some custom parameters your binary takes. - -The sample output using the JSON test files under `Inputs/` gives: - -``` bash -$ ./compare_bench.py ./gbench/Inputs/test1_run1.json ./gbench/Inputs/test1_run2.json -Comparing ./gbench/Inputs/test1_run1.json to ./gbench/Inputs/test1_run2.json -Benchmark Time CPU Time Old Time New CPU Old CPU New -------------------------------------------------------------------------------------------------------------- -BM_SameTimes +0.0000 +0.0000 10 10 10 10 -BM_2xFaster -0.5000 -0.5000 50 25 50 25 -BM_2xSlower +1.0000 +1.0000 50 100 50 100 -BM_1PercentFaster -0.0100 -0.0100 100 99 100 99 -BM_1PercentSlower +0.0100 +0.0100 100 101 100 101 -BM_10PercentFaster -0.1000 -0.1000 100 90 100 90 -BM_10PercentSlower +0.1000 +0.1000 100 110 100 110 -BM_100xSlower +99.0000 +99.0000 100 10000 100 10000 -BM_100xFaster -0.9900 -0.9900 10000 100 10000 100 -BM_10PercentCPUToTime +0.1000 -0.1000 100 110 100 90 -BM_ThirdFaster -0.3333 -0.3334 100 67 100 67 -BM_BadTimeUnit -0.9000 +0.2000 0 0 0 1 -``` - -As you can note, the values in `Time` and `CPU` columns are calculated as `(new - old) / |old|`. - -When a benchmark executable is run, the raw output from the benchmark is printed in real time to stdout. The sample output using `benchmark/basic_test` for both arguments looks like: - -``` -./compare_bench.py test/basic_test test/basic_test --benchmark_filter=BM_empty.* -RUNNING: test/basic_test --benchmark_filter=BM_empty.* --benchmark_out=/tmp/tmpN7LF3a -Run on (8 X 4000 MHz CPU s) -2017-11-07 23:28:36 ---------------------------------------------------------------------- -Benchmark Time CPU Iterations ---------------------------------------------------------------------- -BM_empty 4 ns 4 ns 170178757 -BM_empty/threads:8 1 ns 7 ns 103868920 -BM_empty_stop_start 0 ns 0 ns 1000000000 -BM_empty_stop_start/threads:8 0 ns 0 ns 1403031720 -RUNNING: /test/basic_test --benchmark_filter=BM_empty.* --benchmark_out=/tmp/tmplvrIp8 -Run on (8 X 4000 MHz CPU s) -2017-11-07 23:28:38 ---------------------------------------------------------------------- -Benchmark Time CPU Iterations ---------------------------------------------------------------------- -BM_empty 4 ns 4 ns 169534855 -BM_empty/threads:8 1 ns 7 ns 104188776 -BM_empty_stop_start 0 ns 0 ns 1000000000 -BM_empty_stop_start/threads:8 0 ns 0 ns 1404159424 -Comparing ../build/test/basic_test to ../build/test/basic_test -Benchmark Time CPU Time Old Time New CPU Old CPU New ---------------------------------------------------------------------------------------------------------------------- -BM_empty -0.0048 -0.0049 4 4 4 4 -BM_empty/threads:8 -0.0123 -0.0054 1 1 7 7 -BM_empty_stop_start -0.0000 -0.0000 0 0 0 0 -BM_empty_stop_start/threads:8 -0.0029 +0.0001 0 0 0 0 - -``` - -As you can note, the values in `Time` and `CPU` columns are calculated as `(new - old) / |old|`. -Obviously this example doesn't give any useful output, but it's intended to show the output format when 'compare_bench.py' needs to run benchmarks. - -## compare.py - -The `compare.py` can be used to compare the result of benchmarks. -There are three modes of operation: - -1. Just compare two benchmarks, what `compare_bench.py` did. -The program is invoked like: - -``` bash -$ compare.py benchmarks [benchmark options]... -``` -Where `` and `` either specify a benchmark executable file, or a JSON output file. The type of the input file is automatically detected. If a benchmark executable is specified then the benchmark is run to obtain the results. Otherwise the results are simply loaded from the output file. - -`[benchmark options]` will be passed to the benchmarks invocations. They can be anything that binary accepts, be it either normal `--benchmark_*` parameters, or some custom parameters your binary takes. - -Example output: -``` -$ ./compare.py benchmarks ./a.out ./a.out -RUNNING: ./a.out --benchmark_out=/tmp/tmprBT5nW -Run on (8 X 4000 MHz CPU s) -2017-11-07 21:16:44 ------------------------------------------------------- -Benchmark Time CPU Iterations ------------------------------------------------------- -BM_memcpy/8 36 ns 36 ns 19101577 211.669MB/s -BM_memcpy/64 76 ns 76 ns 9412571 800.199MB/s -BM_memcpy/512 84 ns 84 ns 8249070 5.64771GB/s -BM_memcpy/1024 116 ns 116 ns 6181763 8.19505GB/s -BM_memcpy/8192 643 ns 643 ns 1062855 11.8636GB/s -BM_copy/8 222 ns 222 ns 3137987 34.3772MB/s -BM_copy/64 1608 ns 1608 ns 432758 37.9501MB/s -BM_copy/512 12589 ns 12589 ns 54806 38.7867MB/s -BM_copy/1024 25169 ns 25169 ns 27713 38.8003MB/s -BM_copy/8192 201165 ns 201112 ns 3486 38.8466MB/s -RUNNING: ./a.out --benchmark_out=/tmp/tmpt1wwG_ -Run on (8 X 4000 MHz CPU s) -2017-11-07 21:16:53 ------------------------------------------------------- -Benchmark Time CPU Iterations ------------------------------------------------------- -BM_memcpy/8 36 ns 36 ns 19397903 211.255MB/s -BM_memcpy/64 73 ns 73 ns 9691174 839.635MB/s -BM_memcpy/512 85 ns 85 ns 8312329 5.60101GB/s -BM_memcpy/1024 118 ns 118 ns 6438774 8.11608GB/s -BM_memcpy/8192 656 ns 656 ns 1068644 11.6277GB/s -BM_copy/8 223 ns 223 ns 3146977 34.2338MB/s -BM_copy/64 1611 ns 1611 ns 435340 37.8751MB/s -BM_copy/512 12622 ns 12622 ns 54818 38.6844MB/s -BM_copy/1024 25257 ns 25239 ns 27779 38.6927MB/s -BM_copy/8192 205013 ns 205010 ns 3479 38.108MB/s -Comparing ./a.out to ./a.out -Benchmark Time CPU Time Old Time New CPU Old CPU New ------------------------------------------------------------------------------------------------------- -BM_memcpy/8 +0.0020 +0.0020 36 36 36 36 -BM_memcpy/64 -0.0468 -0.0470 76 73 76 73 -BM_memcpy/512 +0.0081 +0.0083 84 85 84 85 -BM_memcpy/1024 +0.0098 +0.0097 116 118 116 118 -BM_memcpy/8192 +0.0200 +0.0203 643 656 643 656 -BM_copy/8 +0.0046 +0.0042 222 223 222 223 -BM_copy/64 +0.0020 +0.0020 1608 1611 1608 1611 -BM_copy/512 +0.0027 +0.0026 12589 12622 12589 12622 -BM_copy/1024 +0.0035 +0.0028 25169 25257 25169 25239 -BM_copy/8192 +0.0191 +0.0194 201165 205013 201112 205010 -``` - -What it does is for the every benchmark from the first run it looks for the benchmark with exactly the same name in the second run, and then compares the results. If the names differ, the benchmark is omitted from the diff. -As you can note, the values in `Time` and `CPU` columns are calculated as `(new - old) / |old|`. - -2. Compare two different filters of one benchmark -The program is invoked like: - -``` bash -$ compare.py filters [benchmark options]... -``` -Where `` either specify a benchmark executable file, or a JSON output file. The type of the input file is automatically detected. If a benchmark executable is specified then the benchmark is run to obtain the results. Otherwise the results are simply loaded from the output file. - -Where `` and `` are the same regex filters that you would pass to the `[--benchmark_filter=]` parameter of the benchmark binary. - -`[benchmark options]` will be passed to the benchmarks invocations. They can be anything that binary accepts, be it either normal `--benchmark_*` parameters, or some custom parameters your binary takes. - -Example output: -``` -$ ./compare.py filters ./a.out BM_memcpy BM_copy -RUNNING: ./a.out --benchmark_filter=BM_memcpy --benchmark_out=/tmp/tmpBWKk0k -Run on (8 X 4000 MHz CPU s) -2017-11-07 21:37:28 ------------------------------------------------------- -Benchmark Time CPU Iterations ------------------------------------------------------- -BM_memcpy/8 36 ns 36 ns 17891491 211.215MB/s -BM_memcpy/64 74 ns 74 ns 9400999 825.646MB/s -BM_memcpy/512 87 ns 87 ns 8027453 5.46126GB/s -BM_memcpy/1024 111 ns 111 ns 6116853 8.5648GB/s -BM_memcpy/8192 657 ns 656 ns 1064679 11.6247GB/s -RUNNING: ./a.out --benchmark_filter=BM_copy --benchmark_out=/tmp/tmpAvWcOM -Run on (8 X 4000 MHz CPU s) -2017-11-07 21:37:33 ----------------------------------------------------- -Benchmark Time CPU Iterations ----------------------------------------------------- -BM_copy/8 227 ns 227 ns 3038700 33.6264MB/s -BM_copy/64 1640 ns 1640 ns 426893 37.2154MB/s -BM_copy/512 12804 ns 12801 ns 55417 38.1444MB/s -BM_copy/1024 25409 ns 25407 ns 27516 38.4365MB/s -BM_copy/8192 202986 ns 202990 ns 3454 38.4871MB/s -Comparing BM_memcpy to BM_copy (from ./a.out) -Benchmark Time CPU Time Old Time New CPU Old CPU New --------------------------------------------------------------------------------------------------------------------- -[BM_memcpy vs. BM_copy]/8 +5.2829 +5.2812 36 227 36 227 -[BM_memcpy vs. BM_copy]/64 +21.1719 +21.1856 74 1640 74 1640 -[BM_memcpy vs. BM_copy]/512 +145.6487 +145.6097 87 12804 87 12801 -[BM_memcpy vs. BM_copy]/1024 +227.1860 +227.1776 111 25409 111 25407 -[BM_memcpy vs. BM_copy]/8192 +308.1664 +308.2898 657 202986 656 202990 -``` - -As you can see, it applies filter to the benchmarks, both when running the benchmark, and before doing the diff. And to make the diff work, the matches are replaced with some common string. Thus, you can compare two different benchmark families within one benchmark binary. -As you can note, the values in `Time` and `CPU` columns are calculated as `(new - old) / |old|`. - -3. Compare filter one from benchmark one to filter two from benchmark two: -The program is invoked like: - -``` bash -$ compare.py filters [benchmark options]... -``` - -Where `` and `` either specify a benchmark executable file, or a JSON output file. The type of the input file is automatically detected. If a benchmark executable is specified then the benchmark is run to obtain the results. Otherwise the results are simply loaded from the output file. - -Where `` and `` are the same regex filters that you would pass to the `[--benchmark_filter=]` parameter of the benchmark binary. - -`[benchmark options]` will be passed to the benchmarks invocations. They can be anything that binary accepts, be it either normal `--benchmark_*` parameters, or some custom parameters your binary takes. - -Example output: -``` -$ ./compare.py benchmarksfiltered ./a.out BM_memcpy ./a.out BM_copy -RUNNING: ./a.out --benchmark_filter=BM_memcpy --benchmark_out=/tmp/tmp_FvbYg -Run on (8 X 4000 MHz CPU s) -2017-11-07 21:38:27 ------------------------------------------------------- -Benchmark Time CPU Iterations ------------------------------------------------------- -BM_memcpy/8 37 ns 37 ns 18953482 204.118MB/s -BM_memcpy/64 74 ns 74 ns 9206578 828.245MB/s -BM_memcpy/512 91 ns 91 ns 8086195 5.25476GB/s -BM_memcpy/1024 120 ns 120 ns 5804513 7.95662GB/s -BM_memcpy/8192 664 ns 664 ns 1028363 11.4948GB/s -RUNNING: ./a.out --benchmark_filter=BM_copy --benchmark_out=/tmp/tmpDfL5iE -Run on (8 X 4000 MHz CPU s) -2017-11-07 21:38:32 ----------------------------------------------------- -Benchmark Time CPU Iterations ----------------------------------------------------- -BM_copy/8 230 ns 230 ns 2985909 33.1161MB/s -BM_copy/64 1654 ns 1653 ns 419408 36.9137MB/s -BM_copy/512 13122 ns 13120 ns 53403 37.2156MB/s -BM_copy/1024 26679 ns 26666 ns 26575 36.6218MB/s -BM_copy/8192 215068 ns 215053 ns 3221 36.3283MB/s -Comparing BM_memcpy (from ./a.out) to BM_copy (from ./a.out) -Benchmark Time CPU Time Old Time New CPU Old CPU New --------------------------------------------------------------------------------------------------------------------- -[BM_memcpy vs. BM_copy]/8 +5.1649 +5.1637 37 230 37 230 -[BM_memcpy vs. BM_copy]/64 +21.4352 +21.4374 74 1654 74 1653 -[BM_memcpy vs. BM_copy]/512 +143.6022 +143.5865 91 13122 91 13120 -[BM_memcpy vs. BM_copy]/1024 +221.5903 +221.4790 120 26679 120 26666 -[BM_memcpy vs. BM_copy]/8192 +322.9059 +323.0096 664 215068 664 215053 -``` -This is a mix of the previous two modes, two (potentially different) benchmark binaries are run, and a different filter is applied to each one. -As you can note, the values in `Time` and `CPU` columns are calculated as `(new - old) / |old|`. diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/include/benchmark/benchmark.h b/external_imported/json/benchmarks/thirdparty/benchmark/include/benchmark/benchmark.h deleted file mode 100755 index 23dd3d09b..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/include/benchmark/benchmark.h +++ /dev/null @@ -1,1456 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Support for registering benchmarks for functions. - -/* Example usage: -// Define a function that executes the code to be measured a -// specified number of times: -static void BM_StringCreation(benchmark::State& state) { - for (auto _ : state) - std::string empty_string; -} - -// Register the function as a benchmark -BENCHMARK(BM_StringCreation); - -// Define another benchmark -static void BM_StringCopy(benchmark::State& state) { - std::string x = "hello"; - for (auto _ : state) - std::string copy(x); -} -BENCHMARK(BM_StringCopy); - -// Augment the main() program to invoke benchmarks if specified -// via the --benchmarks command line flag. E.g., -// my_unittest --benchmark_filter=all -// my_unittest --benchmark_filter=BM_StringCreation -// my_unittest --benchmark_filter=String -// my_unittest --benchmark_filter='Copy|Creation' -int main(int argc, char** argv) { - benchmark::Initialize(&argc, argv); - benchmark::RunSpecifiedBenchmarks(); - return 0; -} - -// Sometimes a family of microbenchmarks can be implemented with -// just one routine that takes an extra argument to specify which -// one of the family of benchmarks to run. For example, the following -// code defines a family of microbenchmarks for measuring the speed -// of memcpy() calls of different lengths: - -static void BM_memcpy(benchmark::State& state) { - char* src = new char[state.range(0)]; char* dst = new char[state.range(0)]; - memset(src, 'x', state.range(0)); - for (auto _ : state) - memcpy(dst, src, state.range(0)); - state.SetBytesProcessed(int64_t(state.iterations()) * - int64_t(state.range(0))); - delete[] src; delete[] dst; -} -BENCHMARK(BM_memcpy)->Arg(8)->Arg(64)->Arg(512)->Arg(1<<10)->Arg(8<<10); - -// The preceding code is quite repetitive, and can be replaced with the -// following short-hand. The following invocation will pick a few -// appropriate arguments in the specified range and will generate a -// microbenchmark for each such argument. -BENCHMARK(BM_memcpy)->Range(8, 8<<10); - -// You might have a microbenchmark that depends on two inputs. For -// example, the following code defines a family of microbenchmarks for -// measuring the speed of set insertion. -static void BM_SetInsert(benchmark::State& state) { - set data; - for (auto _ : state) { - state.PauseTiming(); - data = ConstructRandomSet(state.range(0)); - state.ResumeTiming(); - for (int j = 0; j < state.range(1); ++j) - data.insert(RandomNumber()); - } -} -BENCHMARK(BM_SetInsert) - ->Args({1<<10, 128}) - ->Args({2<<10, 128}) - ->Args({4<<10, 128}) - ->Args({8<<10, 128}) - ->Args({1<<10, 512}) - ->Args({2<<10, 512}) - ->Args({4<<10, 512}) - ->Args({8<<10, 512}); - -// The preceding code is quite repetitive, and can be replaced with -// the following short-hand. The following macro will pick a few -// appropriate arguments in the product of the two specified ranges -// and will generate a microbenchmark for each such pair. -BENCHMARK(BM_SetInsert)->Ranges({{1<<10, 8<<10}, {128, 512}}); - -// For more complex patterns of inputs, passing a custom function -// to Apply allows programmatic specification of an -// arbitrary set of arguments to run the microbenchmark on. -// The following example enumerates a dense range on -// one parameter, and a sparse range on the second. -static void CustomArguments(benchmark::internal::Benchmark* b) { - for (int i = 0; i <= 10; ++i) - for (int j = 32; j <= 1024*1024; j *= 8) - b->Args({i, j}); -} -BENCHMARK(BM_SetInsert)->Apply(CustomArguments); - -// Templated microbenchmarks work the same way: -// Produce then consume 'size' messages 'iters' times -// Measures throughput in the absence of multiprogramming. -template int BM_Sequential(benchmark::State& state) { - Q q; - typename Q::value_type v; - for (auto _ : state) { - for (int i = state.range(0); i--; ) - q.push(v); - for (int e = state.range(0); e--; ) - q.Wait(&v); - } - // actually messages, not bytes: - state.SetBytesProcessed( - static_cast(state.iterations())*state.range(0)); -} -BENCHMARK_TEMPLATE(BM_Sequential, WaitQueue)->Range(1<<0, 1<<10); - -Use `Benchmark::MinTime(double t)` to set the minimum time used to run the -benchmark. This option overrides the `benchmark_min_time` flag. - -void BM_test(benchmark::State& state) { - ... body ... -} -BENCHMARK(BM_test)->MinTime(2.0); // Run for at least 2 seconds. - -In a multithreaded test, it is guaranteed that none of the threads will start -until all have reached the loop start, and all will have finished before any -thread exits the loop body. As such, any global setup or teardown you want to -do can be wrapped in a check against the thread index: - -static void BM_MultiThreaded(benchmark::State& state) { - if (state.thread_index == 0) { - // Setup code here. - } - for (auto _ : state) { - // Run the test as normal. - } - if (state.thread_index == 0) { - // Teardown code here. - } -} -BENCHMARK(BM_MultiThreaded)->Threads(4); - - -If a benchmark runs a few milliseconds it may be hard to visually compare the -measured times, since the output data is given in nanoseconds per default. In -order to manually set the time unit, you can specify it manually: - -BENCHMARK(BM_test)->Unit(benchmark::kMillisecond); -*/ - -#ifndef BENCHMARK_BENCHMARK_H_ -#define BENCHMARK_BENCHMARK_H_ - - -// The _MSVC_LANG check should detect Visual Studio 2015 Update 3 and newer. -#if __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) -#define BENCHMARK_HAS_CXX11 -#endif - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(BENCHMARK_HAS_CXX11) -#include -#include -#include -#endif - -#if defined(_MSC_VER) -#include // for _ReadWriteBarrier -#endif - -#ifndef BENCHMARK_HAS_CXX11 -#define BENCHMARK_DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName&); \ - TypeName& operator=(const TypeName&) -#else -#define BENCHMARK_DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName&) = delete; \ - TypeName& operator=(const TypeName&) = delete -#endif - -#if defined(__GNUC__) -#define BENCHMARK_UNUSED __attribute__((unused)) -#define BENCHMARK_ALWAYS_INLINE __attribute__((always_inline)) -#define BENCHMARK_NOEXCEPT noexcept -#define BENCHMARK_NOEXCEPT_OP(x) noexcept(x) -#elif defined(_MSC_VER) && !defined(__clang__) -#define BENCHMARK_UNUSED -#define BENCHMARK_ALWAYS_INLINE __forceinline -#if _MSC_VER >= 1900 -#define BENCHMARK_NOEXCEPT noexcept -#define BENCHMARK_NOEXCEPT_OP(x) noexcept(x) -#else -#define BENCHMARK_NOEXCEPT -#define BENCHMARK_NOEXCEPT_OP(x) -#endif -#define __func__ __FUNCTION__ -#else -#define BENCHMARK_UNUSED -#define BENCHMARK_ALWAYS_INLINE -#define BENCHMARK_NOEXCEPT -#define BENCHMARK_NOEXCEPT_OP(x) -#endif - -#define BENCHMARK_INTERNAL_TOSTRING2(x) #x -#define BENCHMARK_INTERNAL_TOSTRING(x) BENCHMARK_INTERNAL_TOSTRING2(x) - -#if defined(__GNUC__) -#define BENCHMARK_BUILTIN_EXPECT(x, y) __builtin_expect(x, y) -#define BENCHMARK_DEPRECATED_MSG(msg) __attribute__((deprecated(msg))) -#else -#define BENCHMARK_BUILTIN_EXPECT(x, y) x -#define BENCHMARK_DEPRECATED_MSG(msg) -#define BENCHMARK_WARNING_MSG(msg) __pragma(message(__FILE__ "(" BENCHMARK_INTERNAL_TOSTRING(__LINE__) ") : warning note: " msg)) -#endif - -#if defined(__GNUC__) && !defined(__clang__) -#define BENCHMARK_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) -#endif - -namespace benchmark { -class BenchmarkReporter; - -void Initialize(int* argc, char** argv); - -// Report to stdout all arguments in 'argv' as unrecognized except the first. -// Returns true there is at least on unrecognized argument (i.e. 'argc' > 1). -bool ReportUnrecognizedArguments(int argc, char** argv); - -// Generate a list of benchmarks matching the specified --benchmark_filter flag -// and if --benchmark_list_tests is specified return after printing the name -// of each matching benchmark. Otherwise run each matching benchmark and -// report the results. -// -// The second and third overload use the specified 'console_reporter' and -// 'file_reporter' respectively. 'file_reporter' will write to the file -// specified -// by '--benchmark_output'. If '--benchmark_output' is not given the -// 'file_reporter' is ignored. -// -// RETURNS: The number of matching benchmarks. -size_t RunSpecifiedBenchmarks(); -size_t RunSpecifiedBenchmarks(BenchmarkReporter* console_reporter); -size_t RunSpecifiedBenchmarks(BenchmarkReporter* console_reporter, - BenchmarkReporter* file_reporter); - -// If this routine is called, peak memory allocation past this point in the -// benchmark is reported at the end of the benchmark report line. (It is -// computed by running the benchmark once with a single iteration and a memory -// tracer.) -// TODO(dominic) -// void MemoryUsage(); - -namespace internal { -class Benchmark; -class BenchmarkImp; -class BenchmarkFamilies; - -void UseCharPointer(char const volatile*); - -// Take ownership of the pointer and register the benchmark. Return the -// registered benchmark. -Benchmark* RegisterBenchmarkInternal(Benchmark*); - -// Ensure that the standard streams are properly initialized in every TU. -int InitializeStreams(); -BENCHMARK_UNUSED static int stream_init_anchor = InitializeStreams(); - -} // namespace internal - - -#if (!defined(__GNUC__) && !defined(__clang__)) || defined(__pnacl__) || \ - defined(__EMSCRIPTEN__) -# define BENCHMARK_HAS_NO_INLINE_ASSEMBLY -#endif - - -// The DoNotOptimize(...) function can be used to prevent a value or -// expression from being optimized away by the compiler. This function is -// intended to add little to no overhead. -// See: https://youtu.be/nXaxk27zwlk?t=2441 -#ifndef BENCHMARK_HAS_NO_INLINE_ASSEMBLY -template -inline BENCHMARK_ALWAYS_INLINE -void DoNotOptimize(Tp const& value) { - asm volatile("" : : "r,m"(value) : "memory"); -} - -template -inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp& value) { -#if defined(__clang__) - asm volatile("" : "+r,m"(value) : : "memory"); -#else - asm volatile("" : "+m,r"(value) : : "memory"); -#endif -} - -// Force the compiler to flush pending writes to global memory. Acts as an -// effective read/write barrier -inline BENCHMARK_ALWAYS_INLINE void ClobberMemory() { - asm volatile("" : : : "memory"); -} -#elif defined(_MSC_VER) -template -inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp const& value) { - internal::UseCharPointer(&reinterpret_cast(value)); - _ReadWriteBarrier(); -} - -inline BENCHMARK_ALWAYS_INLINE void ClobberMemory() { - _ReadWriteBarrier(); -} -#else -template -inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp const& value) { - internal::UseCharPointer(&reinterpret_cast(value)); -} -// FIXME Add ClobberMemory() for non-gnu and non-msvc compilers -#endif - - - -// This class is used for user-defined counters. -class Counter { -public: - - enum Flags { - kDefaults = 0, - // Mark the counter as a rate. It will be presented divided - // by the duration of the benchmark. - kIsRate = 1, - // Mark the counter as a thread-average quantity. It will be - // presented divided by the number of threads. - kAvgThreads = 2, - // Mark the counter as a thread-average rate. See above. - kAvgThreadsRate = kIsRate|kAvgThreads - }; - - double value; - Flags flags; - - BENCHMARK_ALWAYS_INLINE - Counter(double v = 0., Flags f = kDefaults) : value(v), flags(f) {} - - BENCHMARK_ALWAYS_INLINE operator double const& () const { return value; } - BENCHMARK_ALWAYS_INLINE operator double & () { return value; } - -}; - -// This is the container for the user-defined counters. -typedef std::map UserCounters; - - -// TimeUnit is passed to a benchmark in order to specify the order of magnitude -// for the measured time. -enum TimeUnit { kNanosecond, kMicrosecond, kMillisecond }; - -// BigO is passed to a benchmark in order to specify the asymptotic -// computational -// complexity for the benchmark. In case oAuto is selected, complexity will be -// calculated automatically to the best fit. -enum BigO { oNone, o1, oN, oNSquared, oNCubed, oLogN, oNLogN, oAuto, oLambda }; - -// BigOFunc is passed to a benchmark in order to specify the asymptotic -// computational complexity for the benchmark. -typedef double(BigOFunc)(int64_t); - -// StatisticsFunc is passed to a benchmark in order to compute some descriptive -// statistics over all the measurements of some type -typedef double(StatisticsFunc)(const std::vector&); - -struct Statistics { - std::string name_; - StatisticsFunc* compute_; - - Statistics(std::string name, StatisticsFunc* compute) - : name_(name), compute_(compute) {} -}; - -namespace internal { -class ThreadTimer; -class ThreadManager; - -enum ReportMode -#if defined(BENCHMARK_HAS_CXX11) - : unsigned -#else -#endif - { - RM_Unspecified, // The mode has not been manually specified - RM_Default, // The mode is user-specified as default. - RM_ReportAggregatesOnly -}; -} // namespace internal - -// State is passed to a running Benchmark and contains state for the -// benchmark to use. -class State { - public: - struct StateIterator; - friend struct StateIterator; - - // Returns iterators used to run each iteration of a benchmark using a - // C++11 ranged-based for loop. These functions should not be called directly. - // - // REQUIRES: The benchmark has not started running yet. Neither begin nor end - // have been called previously. - // - // NOTE: KeepRunning may not be used after calling either of these functions. - BENCHMARK_ALWAYS_INLINE StateIterator begin(); - BENCHMARK_ALWAYS_INLINE StateIterator end(); - - // Returns true if the benchmark should continue through another iteration. - // NOTE: A benchmark may not return from the test until KeepRunning() has - // returned false. - bool KeepRunning(); - - // Returns true iff the benchmark should run n more iterations. - // REQUIRES: 'n' > 0. - // NOTE: A benchmark must not return from the test until KeepRunningBatch() - // has returned false. - // NOTE: KeepRunningBatch() may overshoot by up to 'n' iterations. - // - // Intended usage: - // while (state.KeepRunningBatch(1000)) { - // // process 1000 elements - // } - bool KeepRunningBatch(size_t n); - - // REQUIRES: timer is running and 'SkipWithError(...)' has not been called - // by the current thread. - // Stop the benchmark timer. If not called, the timer will be - // automatically stopped after the last iteration of the benchmark loop. - // - // For threaded benchmarks the PauseTiming() function only pauses the timing - // for the current thread. - // - // NOTE: The "real time" measurement is per-thread. If different threads - // report different measurements the largest one is reported. - // - // NOTE: PauseTiming()/ResumeTiming() are relatively - // heavyweight, and so their use should generally be avoided - // within each benchmark iteration, if possible. - void PauseTiming(); - - // REQUIRES: timer is not running and 'SkipWithError(...)' has not been called - // by the current thread. - // Start the benchmark timer. The timer is NOT running on entrance to the - // benchmark function. It begins running after control flow enters the - // benchmark loop. - // - // NOTE: PauseTiming()/ResumeTiming() are relatively - // heavyweight, and so their use should generally be avoided - // within each benchmark iteration, if possible. - void ResumeTiming(); - - // REQUIRES: 'SkipWithError(...)' has not been called previously by the - // current thread. - // Report the benchmark as resulting in an error with the specified 'msg'. - // After this call the user may explicitly 'return' from the benchmark. - // - // If the ranged-for style of benchmark loop is used, the user must explicitly - // break from the loop, otherwise all future iterations will be run. - // If the 'KeepRunning()' loop is used the current thread will automatically - // exit the loop at the end of the current iteration. - // - // For threaded benchmarks only the current thread stops executing and future - // calls to `KeepRunning()` will block until all threads have completed - // the `KeepRunning()` loop. If multiple threads report an error only the - // first error message is used. - // - // NOTE: Calling 'SkipWithError(...)' does not cause the benchmark to exit - // the current scope immediately. If the function is called from within - // the 'KeepRunning()' loop the current iteration will finish. It is the users - // responsibility to exit the scope as needed. - void SkipWithError(const char* msg); - - // REQUIRES: called exactly once per iteration of the benchmarking loop. - // Set the manually measured time for this benchmark iteration, which - // is used instead of automatically measured time if UseManualTime() was - // specified. - // - // For threaded benchmarks the final value will be set to the largest - // reported values. - void SetIterationTime(double seconds); - - // Set the number of bytes processed by the current benchmark - // execution. This routine is typically called once at the end of a - // throughput oriented benchmark. If this routine is called with a - // value > 0, the report is printed in MB/sec instead of nanoseconds - // per iteration. - // - // REQUIRES: a benchmark has exited its benchmarking loop. - BENCHMARK_ALWAYS_INLINE - void SetBytesProcessed(int64_t bytes) { bytes_processed_ = bytes; } - - BENCHMARK_ALWAYS_INLINE - int64_t bytes_processed() const { return bytes_processed_; } - - // If this routine is called with complexity_n > 0 and complexity report is - // requested for the - // family benchmark, then current benchmark will be part of the computation - // and complexity_n will - // represent the length of N. - BENCHMARK_ALWAYS_INLINE - void SetComplexityN(int64_t complexity_n) { complexity_n_ = complexity_n; } - - BENCHMARK_ALWAYS_INLINE - int64_t complexity_length_n() { return complexity_n_; } - - // If this routine is called with items > 0, then an items/s - // label is printed on the benchmark report line for the currently - // executing benchmark. It is typically called at the end of a processing - // benchmark where a processing items/second output is desired. - // - // REQUIRES: a benchmark has exited its benchmarking loop. - BENCHMARK_ALWAYS_INLINE - void SetItemsProcessed(int64_t items) { items_processed_ = items; } - - BENCHMARK_ALWAYS_INLINE - int64_t items_processed() const { return items_processed_; } - - // If this routine is called, the specified label is printed at the - // end of the benchmark report line for the currently executing - // benchmark. Example: - // static void BM_Compress(benchmark::State& state) { - // ... - // double compress = input_size / output_size; - // state.SetLabel(StrFormat("compress:%.1f%%", 100.0*compression)); - // } - // Produces output that looks like: - // BM_Compress 50 50 14115038 compress:27.3% - // - // REQUIRES: a benchmark has exited its benchmarking loop. - void SetLabel(const char* label); - - void BENCHMARK_ALWAYS_INLINE SetLabel(const std::string& str) { - this->SetLabel(str.c_str()); - } - - // Range arguments for this run. CHECKs if the argument has been set. - BENCHMARK_ALWAYS_INLINE - int64_t range(std::size_t pos = 0) const { - assert(range_.size() > pos); - return range_[pos]; - } - - BENCHMARK_DEPRECATED_MSG("use 'range(0)' instead") - int64_t range_x() const { return range(0); } - - BENCHMARK_DEPRECATED_MSG("use 'range(1)' instead") - int64_t range_y() const { return range(1); } - - BENCHMARK_ALWAYS_INLINE - size_t iterations() const { - if (BENCHMARK_BUILTIN_EXPECT(!started_, false)) { - return 0; - } - return max_iterations - total_iterations_ + batch_leftover_; - } - -private: // items we expect on the first cache line (ie 64 bytes of the struct) - - // When total_iterations_ is 0, KeepRunning() and friends will return false. - // May be larger than max_iterations. - size_t total_iterations_; - - // When using KeepRunningBatch(), batch_leftover_ holds the number of - // iterations beyond max_iters that were run. Used to track - // completed_iterations_ accurately. - size_t batch_leftover_; - -public: - const size_t max_iterations; - -private: - bool started_; - bool finished_; - bool error_occurred_; - -private: // items we don't need on the first cache line - std::vector range_; - - int64_t bytes_processed_; - int64_t items_processed_; - - int64_t complexity_n_; - - public: - // Container for user-defined counters. - UserCounters counters; - // Index of the executing thread. Values from [0, threads). - const int thread_index; - // Number of threads concurrently executing the benchmark. - const int threads; - - - // TODO(EricWF) make me private - State(size_t max_iters, const std::vector& ranges, int thread_i, - int n_threads, internal::ThreadTimer* timer, - internal::ThreadManager* manager); - - private: - void StartKeepRunning(); - // Implementation of KeepRunning() and KeepRunningBatch(). - // is_batch must be true unless n is 1. - bool KeepRunningInternal(size_t n, bool is_batch); - void FinishKeepRunning(); - internal::ThreadTimer* timer_; - internal::ThreadManager* manager_; - BENCHMARK_DISALLOW_COPY_AND_ASSIGN(State); -}; - -inline BENCHMARK_ALWAYS_INLINE -bool State::KeepRunning() { - return KeepRunningInternal(1, /*is_batch=*/ false); -} - -inline BENCHMARK_ALWAYS_INLINE -bool State::KeepRunningBatch(size_t n) { - return KeepRunningInternal(n, /*is_batch=*/ true); -} - -inline BENCHMARK_ALWAYS_INLINE -bool State::KeepRunningInternal(size_t n, bool is_batch) { - // total_iterations_ is set to 0 by the constructor, and always set to a - // nonzero value by StartKepRunning(). - assert(n > 0); - // n must be 1 unless is_batch is true. - assert(is_batch || n == 1); - if (BENCHMARK_BUILTIN_EXPECT(total_iterations_ >= n, true)) { - total_iterations_ -= n; - return true; - } - if (!started_) { - StartKeepRunning(); - if (!error_occurred_ && total_iterations_ >= n) { - total_iterations_-= n; - return true; - } - } - // For non-batch runs, total_iterations_ must be 0 by now. - if (is_batch && total_iterations_ != 0) { - batch_leftover_ = n - total_iterations_; - total_iterations_ = 0; - return true; - } - FinishKeepRunning(); - return false; -} - -struct State::StateIterator { - struct BENCHMARK_UNUSED Value {}; - typedef std::forward_iterator_tag iterator_category; - typedef Value value_type; - typedef Value reference; - typedef Value pointer; - typedef std::ptrdiff_t difference_type; - - private: - friend class State; - BENCHMARK_ALWAYS_INLINE - StateIterator() : cached_(0), parent_() {} - - BENCHMARK_ALWAYS_INLINE - explicit StateIterator(State* st) - : cached_(st->error_occurred_ ? 0 : st->max_iterations), parent_(st) {} - - public: - BENCHMARK_ALWAYS_INLINE - Value operator*() const { return Value(); } - - BENCHMARK_ALWAYS_INLINE - StateIterator& operator++() { - assert(cached_ > 0); - --cached_; - return *this; - } - - BENCHMARK_ALWAYS_INLINE - bool operator!=(StateIterator const&) const { - if (BENCHMARK_BUILTIN_EXPECT(cached_ != 0, true)) return true; - parent_->FinishKeepRunning(); - return false; - } - - private: - size_t cached_; - State* const parent_; -}; - -inline BENCHMARK_ALWAYS_INLINE State::StateIterator State::begin() { - return StateIterator(this); -} -inline BENCHMARK_ALWAYS_INLINE State::StateIterator State::end() { - StartKeepRunning(); - return StateIterator(); -} - -namespace internal { - -typedef void(Function)(State&); - -// ------------------------------------------------------ -// Benchmark registration object. The BENCHMARK() macro expands -// into an internal::Benchmark* object. Various methods can -// be called on this object to change the properties of the benchmark. -// Each method returns "this" so that multiple method calls can -// chained into one expression. -class Benchmark { - public: - virtual ~Benchmark(); - - // Note: the following methods all return "this" so that multiple - // method calls can be chained together in one expression. - - // Run this benchmark once with "x" as the extra argument passed - // to the function. - // REQUIRES: The function passed to the constructor must accept an arg1. - Benchmark* Arg(int64_t x); - - // Run this benchmark with the given time unit for the generated output report - Benchmark* Unit(TimeUnit unit); - - // Run this benchmark once for a number of values picked from the - // range [start..limit]. (start and limit are always picked.) - // REQUIRES: The function passed to the constructor must accept an arg1. - Benchmark* Range(int64_t start, int64_t limit); - - // Run this benchmark once for all values in the range [start..limit] with - // specific step - // REQUIRES: The function passed to the constructor must accept an arg1. - Benchmark* DenseRange(int64_t start, int64_t limit, int step = 1); - - // Run this benchmark once with "args" as the extra arguments passed - // to the function. - // REQUIRES: The function passed to the constructor must accept arg1, arg2 ... - Benchmark* Args(const std::vector& args); - - // Equivalent to Args({x, y}) - // NOTE: This is a legacy C++03 interface provided for compatibility only. - // New code should use 'Args'. - Benchmark* ArgPair(int64_t x, int64_t y) { - std::vector args; - args.push_back(x); - args.push_back(y); - return Args(args); - } - - // Run this benchmark once for a number of values picked from the - // ranges [start..limit]. (starts and limits are always picked.) - // REQUIRES: The function passed to the constructor must accept arg1, arg2 ... - Benchmark* Ranges(const std::vector >& ranges); - - // Equivalent to ArgNames({name}) - Benchmark* ArgName(const std::string& name); - - // Set the argument names to display in the benchmark name. If not called, - // only argument values will be shown. - Benchmark* ArgNames(const std::vector& names); - - // Equivalent to Ranges({{lo1, hi1}, {lo2, hi2}}). - // NOTE: This is a legacy C++03 interface provided for compatibility only. - // New code should use 'Ranges'. - Benchmark* RangePair(int64_t lo1, int64_t hi1, int64_t lo2, int64_t hi2) { - std::vector > ranges; - ranges.push_back(std::make_pair(lo1, hi1)); - ranges.push_back(std::make_pair(lo2, hi2)); - return Ranges(ranges); - } - - // Pass this benchmark object to *func, which can customize - // the benchmark by calling various methods like Arg, Args, - // Threads, etc. - Benchmark* Apply(void (*func)(Benchmark* benchmark)); - - // Set the range multiplier for non-dense range. If not called, the range - // multiplier kRangeMultiplier will be used. - Benchmark* RangeMultiplier(int multiplier); - - // Set the minimum amount of time to use when running this benchmark. This - // option overrides the `benchmark_min_time` flag. - // REQUIRES: `t > 0` and `Iterations` has not been called on this benchmark. - Benchmark* MinTime(double t); - - // Specify the amount of iterations that should be run by this benchmark. - // REQUIRES: 'n > 0' and `MinTime` has not been called on this benchmark. - // - // NOTE: This function should only be used when *exact* iteration control is - // needed and never to control or limit how long a benchmark runs, where - // `--benchmark_min_time=N` or `MinTime(...)` should be used instead. - Benchmark* Iterations(size_t n); - - // Specify the amount of times to repeat this benchmark. This option overrides - // the `benchmark_repetitions` flag. - // REQUIRES: `n > 0` - Benchmark* Repetitions(int n); - - // Specify if each repetition of the benchmark should be reported separately - // or if only the final statistics should be reported. If the benchmark - // is not repeated then the single result is always reported. - Benchmark* ReportAggregatesOnly(bool value = true); - - // If a particular benchmark is I/O bound, runs multiple threads internally or - // if for some reason CPU timings are not representative, call this method. If - // called, the elapsed time will be used to control how many iterations are - // run, and in the printing of items/second or MB/seconds values. If not - // called, the cpu time used by the benchmark will be used. - Benchmark* UseRealTime(); - - // If a benchmark must measure time manually (e.g. if GPU execution time is - // being - // measured), call this method. If called, each benchmark iteration should - // call - // SetIterationTime(seconds) to report the measured time, which will be used - // to control how many iterations are run, and in the printing of items/second - // or MB/second values. - Benchmark* UseManualTime(); - - // Set the asymptotic computational complexity for the benchmark. If called - // the asymptotic computational complexity will be shown on the output. - Benchmark* Complexity(BigO complexity = benchmark::oAuto); - - // Set the asymptotic computational complexity for the benchmark. If called - // the asymptotic computational complexity will be shown on the output. - Benchmark* Complexity(BigOFunc* complexity); - - // Add this statistics to be computed over all the values of benchmark run - Benchmark* ComputeStatistics(std::string name, StatisticsFunc* statistics); - - // Support for running multiple copies of the same benchmark concurrently - // in multiple threads. This may be useful when measuring the scaling - // of some piece of code. - - // Run one instance of this benchmark concurrently in t threads. - Benchmark* Threads(int t); - - // Pick a set of values T from [min_threads,max_threads]. - // min_threads and max_threads are always included in T. Run this - // benchmark once for each value in T. The benchmark run for a - // particular value t consists of t threads running the benchmark - // function concurrently. For example, consider: - // BENCHMARK(Foo)->ThreadRange(1,16); - // This will run the following benchmarks: - // Foo in 1 thread - // Foo in 2 threads - // Foo in 4 threads - // Foo in 8 threads - // Foo in 16 threads - Benchmark* ThreadRange(int min_threads, int max_threads); - - // For each value n in the range, run this benchmark once using n threads. - // min_threads and max_threads are always included in the range. - // stride specifies the increment. E.g. DenseThreadRange(1, 8, 3) starts - // a benchmark with 1, 4, 7 and 8 threads. - Benchmark* DenseThreadRange(int min_threads, int max_threads, int stride = 1); - - // Equivalent to ThreadRange(NumCPUs(), NumCPUs()) - Benchmark* ThreadPerCpu(); - - virtual void Run(State& state) = 0; - - // Used inside the benchmark implementation - struct Instance; - - protected: - explicit Benchmark(const char* name); - Benchmark(Benchmark const&); - void SetName(const char* name); - - int ArgsCnt() const; - - private: - friend class BenchmarkFamilies; - - std::string name_; - ReportMode report_mode_; - std::vector arg_names_; // Args for all benchmark runs - std::vector > args_; // Args for all benchmark runs - TimeUnit time_unit_; - int range_multiplier_; - double min_time_; - size_t iterations_; - int repetitions_; - bool use_real_time_; - bool use_manual_time_; - BigO complexity_; - BigOFunc* complexity_lambda_; - std::vector statistics_; - std::vector thread_counts_; - - Benchmark& operator=(Benchmark const&); -}; - -} // namespace internal - -// Create and register a benchmark with the specified 'name' that invokes -// the specified functor 'fn'. -// -// RETURNS: A pointer to the registered benchmark. -internal::Benchmark* RegisterBenchmark(const char* name, - internal::Function* fn); - -#if defined(BENCHMARK_HAS_CXX11) -template -internal::Benchmark* RegisterBenchmark(const char* name, Lambda&& fn); -#endif - -// Remove all registered benchmarks. All pointers to previously registered -// benchmarks are invalidated. -void ClearRegisteredBenchmarks(); - -namespace internal { -// The class used to hold all Benchmarks created from static function. -// (ie those created using the BENCHMARK(...) macros. -class FunctionBenchmark : public Benchmark { - public: - FunctionBenchmark(const char* name, Function* func) - : Benchmark(name), func_(func) {} - - virtual void Run(State& st); - - private: - Function* func_; -}; - -#ifdef BENCHMARK_HAS_CXX11 -template -class LambdaBenchmark : public Benchmark { - public: - virtual void Run(State& st) { lambda_(st); } - - private: - template - LambdaBenchmark(const char* name, OLambda&& lam) - : Benchmark(name), lambda_(std::forward(lam)) {} - - LambdaBenchmark(LambdaBenchmark const&) = delete; - - private: - template - friend Benchmark* ::benchmark::RegisterBenchmark(const char*, Lam&&); - - Lambda lambda_; -}; -#endif - -} // namespace internal - -inline internal::Benchmark* RegisterBenchmark(const char* name, - internal::Function* fn) { - return internal::RegisterBenchmarkInternal( - ::new internal::FunctionBenchmark(name, fn)); -} - -#ifdef BENCHMARK_HAS_CXX11 -template -internal::Benchmark* RegisterBenchmark(const char* name, Lambda&& fn) { - using BenchType = - internal::LambdaBenchmark::type>; - return internal::RegisterBenchmarkInternal( - ::new BenchType(name, std::forward(fn))); -} -#endif - -#if defined(BENCHMARK_HAS_CXX11) && \ - (!defined(BENCHMARK_GCC_VERSION) || BENCHMARK_GCC_VERSION >= 409) -template -internal::Benchmark* RegisterBenchmark(const char* name, Lambda&& fn, - Args&&... args) { - return benchmark::RegisterBenchmark( - name, [=](benchmark::State& st) { fn(st, args...); }); -} -#else -#define BENCHMARK_HAS_NO_VARIADIC_REGISTER_BENCHMARK -#endif - -// The base class for all fixture tests. -class Fixture : public internal::Benchmark { - public: - Fixture() : internal::Benchmark("") {} - - virtual void Run(State& st) { - this->SetUp(st); - this->BenchmarkCase(st); - this->TearDown(st); - } - - // These will be deprecated ... - virtual void SetUp(const State&) {} - virtual void TearDown(const State&) {} - // ... In favor of these. - virtual void SetUp(State& st) { SetUp(const_cast(st)); } - virtual void TearDown(State& st) { TearDown(const_cast(st)); } - - protected: - virtual void BenchmarkCase(State&) = 0; -}; - -} // namespace benchmark - -// ------------------------------------------------------ -// Macro to register benchmarks - -// Check that __COUNTER__ is defined and that __COUNTER__ increases by 1 -// every time it is expanded. X + 1 == X + 0 is used in case X is defined to be -// empty. If X is empty the expression becomes (+1 == +0). -#if defined(__COUNTER__) && (__COUNTER__ + 1 == __COUNTER__ + 0) -#define BENCHMARK_PRIVATE_UNIQUE_ID __COUNTER__ -#else -#define BENCHMARK_PRIVATE_UNIQUE_ID __LINE__ -#endif - -// Helpers for generating unique variable names -#define BENCHMARK_PRIVATE_NAME(n) \ - BENCHMARK_PRIVATE_CONCAT(_benchmark_, BENCHMARK_PRIVATE_UNIQUE_ID, n) -#define BENCHMARK_PRIVATE_CONCAT(a, b, c) BENCHMARK_PRIVATE_CONCAT2(a, b, c) -#define BENCHMARK_PRIVATE_CONCAT2(a, b, c) a##b##c - -#define BENCHMARK_PRIVATE_DECLARE(n) \ - static ::benchmark::internal::Benchmark* BENCHMARK_PRIVATE_NAME(n) \ - BENCHMARK_UNUSED - -#define BENCHMARK(n) \ - BENCHMARK_PRIVATE_DECLARE(n) = \ - (::benchmark::internal::RegisterBenchmarkInternal( \ - new ::benchmark::internal::FunctionBenchmark(#n, n))) - -// Old-style macros -#define BENCHMARK_WITH_ARG(n, a) BENCHMARK(n)->Arg((a)) -#define BENCHMARK_WITH_ARG2(n, a1, a2) BENCHMARK(n)->Args({(a1), (a2)}) -#define BENCHMARK_WITH_UNIT(n, t) BENCHMARK(n)->Unit((t)) -#define BENCHMARK_RANGE(n, lo, hi) BENCHMARK(n)->Range((lo), (hi)) -#define BENCHMARK_RANGE2(n, l1, h1, l2, h2) \ - BENCHMARK(n)->RangePair({{(l1), (h1)}, {(l2), (h2)}}) - -#ifdef BENCHMARK_HAS_CXX11 - -// Register a benchmark which invokes the function specified by `func` -// with the additional arguments specified by `...`. -// -// For example: -// -// template ` -// void BM_takes_args(benchmark::State& state, ExtraArgs&&... extra_args) { -// [...] -//} -// /* Registers a benchmark named "BM_takes_args/int_string_test` */ -// BENCHMARK_CAPTURE(BM_takes_args, int_string_test, 42, std::string("abc")); -#define BENCHMARK_CAPTURE(func, test_case_name, ...) \ - BENCHMARK_PRIVATE_DECLARE(func) = \ - (::benchmark::internal::RegisterBenchmarkInternal( \ - new ::benchmark::internal::FunctionBenchmark( \ - #func "/" #test_case_name, \ - [](::benchmark::State& st) { func(st, __VA_ARGS__); }))) - -#endif // BENCHMARK_HAS_CXX11 - -// This will register a benchmark for a templatized function. For example: -// -// template -// void BM_Foo(int iters); -// -// BENCHMARK_TEMPLATE(BM_Foo, 1); -// -// will register BM_Foo<1> as a benchmark. -#define BENCHMARK_TEMPLATE1(n, a) \ - BENCHMARK_PRIVATE_DECLARE(n) = \ - (::benchmark::internal::RegisterBenchmarkInternal( \ - new ::benchmark::internal::FunctionBenchmark(#n "<" #a ">", n))) - -#define BENCHMARK_TEMPLATE2(n, a, b) \ - BENCHMARK_PRIVATE_DECLARE(n) = \ - (::benchmark::internal::RegisterBenchmarkInternal( \ - new ::benchmark::internal::FunctionBenchmark(#n "<" #a "," #b ">", \ - n))) - -#ifdef BENCHMARK_HAS_CXX11 -#define BENCHMARK_TEMPLATE(n, ...) \ - BENCHMARK_PRIVATE_DECLARE(n) = \ - (::benchmark::internal::RegisterBenchmarkInternal( \ - new ::benchmark::internal::FunctionBenchmark( \ - #n "<" #__VA_ARGS__ ">", n<__VA_ARGS__>))) -#else -#define BENCHMARK_TEMPLATE(n, a) BENCHMARK_TEMPLATE1(n, a) -#endif - -#define BENCHMARK_PRIVATE_DECLARE_F(BaseClass, Method) \ - class BaseClass##_##Method##_Benchmark : public BaseClass { \ - public: \ - BaseClass##_##Method##_Benchmark() : BaseClass() { \ - this->SetName(#BaseClass "/" #Method); \ - } \ - \ - protected: \ - virtual void BenchmarkCase(::benchmark::State&); \ - }; - -#define BENCHMARK_TEMPLATE1_PRIVATE_DECLARE_F(BaseClass, Method, a) \ - class BaseClass##_##Method##_Benchmark : public BaseClass { \ - public: \ - BaseClass##_##Method##_Benchmark() : BaseClass() { \ - this->SetName(#BaseClass"<" #a ">/" #Method); \ - } \ - \ - protected: \ - virtual void BenchmarkCase(::benchmark::State&); \ - }; - -#define BENCHMARK_TEMPLATE2_PRIVATE_DECLARE_F(BaseClass, Method, a, b) \ - class BaseClass##_##Method##_Benchmark : public BaseClass { \ - public: \ - BaseClass##_##Method##_Benchmark() : BaseClass() { \ - this->SetName(#BaseClass"<" #a "," #b ">/" #Method); \ - } \ - \ - protected: \ - virtual void BenchmarkCase(::benchmark::State&); \ - }; - -#ifdef BENCHMARK_HAS_CXX11 -#define BENCHMARK_TEMPLATE_PRIVATE_DECLARE_F(BaseClass, Method, ...) \ - class BaseClass##_##Method##_Benchmark : public BaseClass<__VA_ARGS__> { \ - public: \ - BaseClass##_##Method##_Benchmark() : BaseClass<__VA_ARGS__>() { \ - this->SetName(#BaseClass"<" #__VA_ARGS__ ">/" #Method); \ - } \ - \ - protected: \ - virtual void BenchmarkCase(::benchmark::State&); \ - }; -#else -#define BENCHMARK_TEMPLATE_PRIVATE_DECLARE_F(n, a) BENCHMARK_TEMPLATE1_PRIVATE_DECLARE_F(n, a) -#endif - -#define BENCHMARK_DEFINE_F(BaseClass, Method) \ - BENCHMARK_PRIVATE_DECLARE_F(BaseClass, Method) \ - void BaseClass##_##Method##_Benchmark::BenchmarkCase - -#define BENCHMARK_TEMPLATE1_DEFINE_F(BaseClass, Method, a) \ - BENCHMARK_TEMPLATE1_PRIVATE_DECLARE_F(BaseClass, Method, a) \ - void BaseClass##_##Method##_Benchmark::BenchmarkCase - -#define BENCHMARK_TEMPLATE2_DEFINE_F(BaseClass, Method, a, b) \ - BENCHMARK_TEMPLATE2_PRIVATE_DECLARE_F(BaseClass, Method, a, b) \ - void BaseClass##_##Method##_Benchmark::BenchmarkCase - -#ifdef BENCHMARK_HAS_CXX11 -#define BENCHMARK_TEMPLATE_DEFINE_F(BaseClass, Method, ...) \ - BENCHMARK_TEMPLATE_PRIVATE_DECLARE_F(BaseClass, Method, __VA_ARGS__) \ - void BaseClass##_##Method##_Benchmark::BenchmarkCase -#else -#define BENCHMARK_TEMPLATE_DEFINE_F(BaseClass, Method, a) BENCHMARK_TEMPLATE1_DEFINE_F(BaseClass, Method, a) -#endif - -#define BENCHMARK_REGISTER_F(BaseClass, Method) \ - BENCHMARK_PRIVATE_REGISTER_F(BaseClass##_##Method##_Benchmark) - -#define BENCHMARK_PRIVATE_REGISTER_F(TestName) \ - BENCHMARK_PRIVATE_DECLARE(TestName) = \ - (::benchmark::internal::RegisterBenchmarkInternal(new TestName())) - -// This macro will define and register a benchmark within a fixture class. -#define BENCHMARK_F(BaseClass, Method) \ - BENCHMARK_PRIVATE_DECLARE_F(BaseClass, Method) \ - BENCHMARK_REGISTER_F(BaseClass, Method); \ - void BaseClass##_##Method##_Benchmark::BenchmarkCase - -#define BENCHMARK_TEMPLATE1_F(BaseClass, Method, a) \ - BENCHMARK_TEMPLATE1_PRIVATE_DECLARE_F(BaseClass, Method, a) \ - BENCHMARK_REGISTER_F(BaseClass, Method); \ - void BaseClass##_##Method##_Benchmark::BenchmarkCase - -#define BENCHMARK_TEMPLATE2_F(BaseClass, Method, a, b) \ - BENCHMARK_TEMPLATE2_PRIVATE_DECLARE_F(BaseClass, Method, a, b) \ - BENCHMARK_REGISTER_F(BaseClass, Method); \ - void BaseClass##_##Method##_Benchmark::BenchmarkCase - -#ifdef BENCHMARK_HAS_CXX11 -#define BENCHMARK_TEMPLATE_F(BaseClass, Method, ...) \ - BENCHMARK_TEMPLATE_PRIVATE_DECLARE_F(BaseClass, Method, __VA_ARGS__) \ - BENCHMARK_REGISTER_F(BaseClass, Method); \ - void BaseClass##_##Method##_Benchmark::BenchmarkCase -#else -#define BENCHMARK_TEMPLATE_F(BaseClass, Method, a) BENCHMARK_TEMPLATE1_F(BaseClass, Method, a) -#endif - -// Helper macro to create a main routine in a test that runs the benchmarks -#define BENCHMARK_MAIN() \ - int main(int argc, char** argv) { \ - ::benchmark::Initialize(&argc, argv); \ - if (::benchmark::ReportUnrecognizedArguments(argc, argv)) return 1; \ - ::benchmark::RunSpecifiedBenchmarks(); \ - } \ - int main(int, char**) - - -// ------------------------------------------------------ -// Benchmark Reporters - -namespace benchmark { - -struct CPUInfo { - struct CacheInfo { - std::string type; - int level; - int size; - int num_sharing; - }; - - int num_cpus; - double cycles_per_second; - std::vector caches; - bool scaling_enabled; - - static const CPUInfo& Get(); - - private: - CPUInfo(); - BENCHMARK_DISALLOW_COPY_AND_ASSIGN(CPUInfo); -}; - -// Interface for custom benchmark result printers. -// By default, benchmark reports are printed to stdout. However an application -// can control the destination of the reports by calling -// RunSpecifiedBenchmarks and passing it a custom reporter object. -// The reporter object must implement the following interface. -class BenchmarkReporter { - public: - struct Context { - CPUInfo const& cpu_info; - // The number of chars in the longest benchmark name. - size_t name_field_width; - static const char *executable_name; - Context(); - }; - - struct Run { - Run() - : error_occurred(false), - iterations(1), - time_unit(kNanosecond), - real_accumulated_time(0), - cpu_accumulated_time(0), - bytes_per_second(0), - items_per_second(0), - max_heapbytes_used(0), - complexity(oNone), - complexity_lambda(), - complexity_n(0), - report_big_o(false), - report_rms(false), - counters() {} - - std::string benchmark_name; - std::string report_label; // Empty if not set by benchmark. - bool error_occurred; - std::string error_message; - - int64_t iterations; - TimeUnit time_unit; - double real_accumulated_time; - double cpu_accumulated_time; - - // Return a value representing the real time per iteration in the unit - // specified by 'time_unit'. - // NOTE: If 'iterations' is zero the returned value represents the - // accumulated time. - double GetAdjustedRealTime() const; - - // Return a value representing the cpu time per iteration in the unit - // specified by 'time_unit'. - // NOTE: If 'iterations' is zero the returned value represents the - // accumulated time. - double GetAdjustedCPUTime() const; - - // Zero if not set by benchmark. - double bytes_per_second; - double items_per_second; - - // This is set to 0.0 if memory tracing is not enabled. - double max_heapbytes_used; - - // Keep track of arguments to compute asymptotic complexity - BigO complexity; - BigOFunc* complexity_lambda; - int64_t complexity_n; - - // what statistics to compute from the measurements - const std::vector* statistics; - - // Inform print function whether the current run is a complexity report - bool report_big_o; - bool report_rms; - - UserCounters counters; - }; - - // Construct a BenchmarkReporter with the output stream set to 'std::cout' - // and the error stream set to 'std::cerr' - BenchmarkReporter(); - - // Called once for every suite of benchmarks run. - // The parameter "context" contains information that the - // reporter may wish to use when generating its report, for example the - // platform under which the benchmarks are running. The benchmark run is - // never started if this function returns false, allowing the reporter - // to skip runs based on the context information. - virtual bool ReportContext(const Context& context) = 0; - - // Called once for each group of benchmark runs, gives information about - // cpu-time and heap memory usage during the benchmark run. If the group - // of runs contained more than two entries then 'report' contains additional - // elements representing the mean and standard deviation of those runs. - // Additionally if this group of runs was the last in a family of benchmarks - // 'reports' contains additional entries representing the asymptotic - // complexity and RMS of that benchmark family. - virtual void ReportRuns(const std::vector& report) = 0; - - // Called once and only once after ever group of benchmarks is run and - // reported. - virtual void Finalize() {} - - // REQUIRES: The object referenced by 'out' is valid for the lifetime - // of the reporter. - void SetOutputStream(std::ostream* out) { - assert(out); - output_stream_ = out; - } - - // REQUIRES: The object referenced by 'err' is valid for the lifetime - // of the reporter. - void SetErrorStream(std::ostream* err) { - assert(err); - error_stream_ = err; - } - - std::ostream& GetOutputStream() const { return *output_stream_; } - - std::ostream& GetErrorStream() const { return *error_stream_; } - - virtual ~BenchmarkReporter(); - - // Write a human readable string to 'out' representing the specified - // 'context'. - // REQUIRES: 'out' is non-null. - static void PrintBasicContext(std::ostream* out, Context const& context); - - private: - std::ostream* output_stream_; - std::ostream* error_stream_; -}; - -// Simple reporter that outputs benchmark data to the console. This is the -// default reporter used by RunSpecifiedBenchmarks(). -class ConsoleReporter : public BenchmarkReporter { -public: - enum OutputOptions { - OO_None = 0, - OO_Color = 1, - OO_Tabular = 2, - OO_ColorTabular = OO_Color|OO_Tabular, - OO_Defaults = OO_ColorTabular - }; - explicit ConsoleReporter(OutputOptions opts_ = OO_Defaults) - : output_options_(opts_), name_field_width_(0), - prev_counters_(), printed_header_(false) {} - - virtual bool ReportContext(const Context& context); - virtual void ReportRuns(const std::vector& reports); - - protected: - virtual void PrintRunData(const Run& report); - virtual void PrintHeader(const Run& report); - - OutputOptions output_options_; - size_t name_field_width_; - UserCounters prev_counters_; - bool printed_header_; -}; - -class JSONReporter : public BenchmarkReporter { - public: - JSONReporter() : first_report_(true) {} - virtual bool ReportContext(const Context& context); - virtual void ReportRuns(const std::vector& reports); - virtual void Finalize(); - - private: - void PrintRunData(const Run& report); - - bool first_report_; -}; - -class CSVReporter : public BenchmarkReporter { - public: - CSVReporter() : printed_header_(false) {} - virtual bool ReportContext(const Context& context); - virtual void ReportRuns(const std::vector& reports); - - private: - void PrintRunData(const Run& report); - - bool printed_header_; - std::set< std::string > user_counter_names_; -}; - -inline const char* GetTimeUnitString(TimeUnit unit) { - switch (unit) { - case kMillisecond: - return "ms"; - case kMicrosecond: - return "us"; - case kNanosecond: - default: - return "ns"; - } -} - -inline double GetTimeUnitMultiplier(TimeUnit unit) { - switch (unit) { - case kMillisecond: - return 1e3; - case kMicrosecond: - return 1e6; - case kNanosecond: - default: - return 1e9; - } -} - -} // namespace benchmark - -#endif // BENCHMARK_BENCHMARK_H_ diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/mingw.py b/external_imported/json/benchmarks/thirdparty/benchmark/mingw.py deleted file mode 100755 index 706ad559d..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/mingw.py +++ /dev/null @@ -1,320 +0,0 @@ -#! /usr/bin/env python -# encoding: utf-8 - -import argparse -import errno -import logging -import os -import platform -import re -import sys -import subprocess -import tempfile - -try: - import winreg -except ImportError: - import _winreg as winreg -try: - import urllib.request as request -except ImportError: - import urllib as request -try: - import urllib.parse as parse -except ImportError: - import urlparse as parse - -class EmptyLogger(object): - ''' - Provides an implementation that performs no logging - ''' - def debug(self, *k, **kw): - pass - def info(self, *k, **kw): - pass - def warn(self, *k, **kw): - pass - def error(self, *k, **kw): - pass - def critical(self, *k, **kw): - pass - def setLevel(self, *k, **kw): - pass - -urls = ( - 'http://downloads.sourceforge.net/project/mingw-w64/Toolchains%20' - 'targetting%20Win32/Personal%20Builds/mingw-builds/installer/' - 'repository.txt', - 'http://downloads.sourceforge.net/project/mingwbuilds/host-windows/' - 'repository.txt' -) -''' -A list of mingw-build repositories -''' - -def repository(urls = urls, log = EmptyLogger()): - ''' - Downloads and parse mingw-build repository files and parses them - ''' - log.info('getting mingw-builds repository') - versions = {} - re_sourceforge = re.compile(r'http://sourceforge.net/projects/([^/]+)/files') - re_sub = r'http://downloads.sourceforge.net/project/\1' - for url in urls: - log.debug(' - requesting: %s', url) - socket = request.urlopen(url) - repo = socket.read() - if not isinstance(repo, str): - repo = repo.decode(); - socket.close() - for entry in repo.split('\n')[:-1]: - value = entry.split('|') - version = tuple([int(n) for n in value[0].strip().split('.')]) - version = versions.setdefault(version, {}) - arch = value[1].strip() - if arch == 'x32': - arch = 'i686' - elif arch == 'x64': - arch = 'x86_64' - arch = version.setdefault(arch, {}) - threading = arch.setdefault(value[2].strip(), {}) - exceptions = threading.setdefault(value[3].strip(), {}) - revision = exceptions.setdefault(int(value[4].strip()[3:]), - re_sourceforge.sub(re_sub, value[5].strip())) - return versions - -def find_in_path(file, path=None): - ''' - Attempts to find an executable in the path - ''' - if platform.system() == 'Windows': - file += '.exe' - if path is None: - path = os.environ.get('PATH', '') - if type(path) is type(''): - path = path.split(os.pathsep) - return list(filter(os.path.exists, - map(lambda dir, file=file: os.path.join(dir, file), path))) - -def find_7zip(log = EmptyLogger()): - ''' - Attempts to find 7zip for unpacking the mingw-build archives - ''' - log.info('finding 7zip') - path = find_in_path('7z') - if not path: - key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\7-Zip') - path, _ = winreg.QueryValueEx(key, 'Path') - path = [os.path.join(path, '7z.exe')] - log.debug('found \'%s\'', path[0]) - return path[0] - -find_7zip() - -def unpack(archive, location, log = EmptyLogger()): - ''' - Unpacks a mingw-builds archive - ''' - sevenzip = find_7zip(log) - log.info('unpacking %s', os.path.basename(archive)) - cmd = [sevenzip, 'x', archive, '-o' + location, '-y'] - log.debug(' - %r', cmd) - with open(os.devnull, 'w') as devnull: - subprocess.check_call(cmd, stdout = devnull) - -def download(url, location, log = EmptyLogger()): - ''' - Downloads and unpacks a mingw-builds archive - ''' - log.info('downloading MinGW') - log.debug(' - url: %s', url) - log.debug(' - location: %s', location) - - re_content = re.compile(r'attachment;[ \t]*filename=(")?([^"]*)(")?[\r\n]*') - - stream = request.urlopen(url) - try: - content = stream.getheader('Content-Disposition') or '' - except AttributeError: - content = stream.headers.getheader('Content-Disposition') or '' - matches = re_content.match(content) - if matches: - filename = matches.group(2) - else: - parsed = parse.urlparse(stream.geturl()) - filename = os.path.basename(parsed.path) - - try: - os.makedirs(location) - except OSError as e: - if e.errno == errno.EEXIST and os.path.isdir(location): - pass - else: - raise - - archive = os.path.join(location, filename) - with open(archive, 'wb') as out: - while True: - buf = stream.read(1024) - if not buf: - break - out.write(buf) - unpack(archive, location, log = log) - os.remove(archive) - - possible = os.path.join(location, 'mingw64') - if not os.path.exists(possible): - possible = os.path.join(location, 'mingw32') - if not os.path.exists(possible): - raise ValueError('Failed to find unpacked MinGW: ' + possible) - return possible - -def root(location = None, arch = None, version = None, threading = None, - exceptions = None, revision = None, log = EmptyLogger()): - ''' - Returns the root folder of a specific version of the mingw-builds variant - of gcc. Will download the compiler if needed - ''' - - # Get the repository if we don't have all the information - if not (arch and version and threading and exceptions and revision): - versions = repository(log = log) - - # Determine some defaults - version = version or max(versions.keys()) - if not arch: - arch = platform.machine().lower() - if arch == 'x86': - arch = 'i686' - elif arch == 'amd64': - arch = 'x86_64' - if not threading: - keys = versions[version][arch].keys() - if 'posix' in keys: - threading = 'posix' - elif 'win32' in keys: - threading = 'win32' - else: - threading = keys[0] - if not exceptions: - keys = versions[version][arch][threading].keys() - if 'seh' in keys: - exceptions = 'seh' - elif 'sjlj' in keys: - exceptions = 'sjlj' - else: - exceptions = keys[0] - if revision == None: - revision = max(versions[version][arch][threading][exceptions].keys()) - if not location: - location = os.path.join(tempfile.gettempdir(), 'mingw-builds') - - # Get the download url - url = versions[version][arch][threading][exceptions][revision] - - # Tell the user whatzzup - log.info('finding MinGW %s', '.'.join(str(v) for v in version)) - log.debug(' - arch: %s', arch) - log.debug(' - threading: %s', threading) - log.debug(' - exceptions: %s', exceptions) - log.debug(' - revision: %s', revision) - log.debug(' - url: %s', url) - - # Store each specific revision differently - slug = '{version}-{arch}-{threading}-{exceptions}-rev{revision}' - slug = slug.format( - version = '.'.join(str(v) for v in version), - arch = arch, - threading = threading, - exceptions = exceptions, - revision = revision - ) - if arch == 'x86_64': - root_dir = os.path.join(location, slug, 'mingw64') - elif arch == 'i686': - root_dir = os.path.join(location, slug, 'mingw32') - else: - raise ValueError('Unknown MinGW arch: ' + arch) - - # Download if needed - if not os.path.exists(root_dir): - downloaded = download(url, os.path.join(location, slug), log = log) - if downloaded != root_dir: - raise ValueError('The location of mingw did not match\n%s\n%s' - % (downloaded, root_dir)) - - return root_dir - -def str2ver(string): - ''' - Converts a version string into a tuple - ''' - try: - version = tuple(int(v) for v in string.split('.')) - if len(version) is not 3: - raise ValueError() - except ValueError: - raise argparse.ArgumentTypeError( - 'please provide a three digit version string') - return version - -def main(): - ''' - Invoked when the script is run directly by the python interpreter - ''' - parser = argparse.ArgumentParser( - description = 'Downloads a specific version of MinGW', - formatter_class = argparse.ArgumentDefaultsHelpFormatter - ) - parser.add_argument('--location', - help = 'the location to download the compiler to', - default = os.path.join(tempfile.gettempdir(), 'mingw-builds')) - parser.add_argument('--arch', required = True, choices = ['i686', 'x86_64'], - help = 'the target MinGW architecture string') - parser.add_argument('--version', type = str2ver, - help = 'the version of GCC to download') - parser.add_argument('--threading', choices = ['posix', 'win32'], - help = 'the threading type of the compiler') - parser.add_argument('--exceptions', choices = ['sjlj', 'seh', 'dwarf'], - help = 'the method to throw exceptions') - parser.add_argument('--revision', type=int, - help = 'the revision of the MinGW release') - group = parser.add_mutually_exclusive_group() - group.add_argument('-v', '--verbose', action='store_true', - help='increase the script output verbosity') - group.add_argument('-q', '--quiet', action='store_true', - help='only print errors and warning') - args = parser.parse_args() - - # Create the logger - logger = logging.getLogger('mingw') - handler = logging.StreamHandler() - formatter = logging.Formatter('%(message)s') - handler.setFormatter(formatter) - logger.addHandler(handler) - logger.setLevel(logging.INFO) - if args.quiet: - logger.setLevel(logging.WARN) - if args.verbose: - logger.setLevel(logging.DEBUG) - - # Get MinGW - root_dir = root(location = args.location, arch = args.arch, - version = args.version, threading = args.threading, - exceptions = args.exceptions, revision = args.revision, - log = logger) - - sys.stdout.write('%s\n' % os.path.join(root_dir, 'bin')) - -if __name__ == '__main__': - try: - main() - except IOError as e: - sys.stderr.write('IO error: %s\n' % e) - sys.exit(1) - except OSError as e: - sys.stderr.write('OS error: %s\n' % e) - sys.exit(1) - except KeyboardInterrupt as e: - sys.stderr.write('Killed\n') - sys.exit(1) diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/releasing.md b/external_imported/json/benchmarks/thirdparty/benchmark/releasing.md deleted file mode 100755 index f0cd7010e..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/releasing.md +++ /dev/null @@ -1,16 +0,0 @@ -# How to release - -* Make sure you're on master and synced to HEAD -* Ensure the project builds and tests run (sanity check only, obviously) - * `parallel -j0 exec ::: test/*_test` can help ensure everything at least - passes -* Prepare release notes - * `git log $(git describe --abbrev=0 --tags)..HEAD` gives you the list of - commits between the last annotated tag and HEAD - * Pick the most interesting. -* Create a release through github's interface - * Note this will create a lightweight tag. - * Update this to an annotated tag: - * `git pull --tags` - * `git tag -a -f ` - * `git push --force origin` diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/CMakeLists.txt b/external_imported/json/benchmarks/thirdparty/benchmark/src/CMakeLists.txt deleted file mode 100755 index 701804ba0..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/CMakeLists.txt +++ /dev/null @@ -1,105 +0,0 @@ -# Allow the source files to find headers in src/ -include_directories(${PROJECT_SOURCE_DIR}/src) - -if (DEFINED BENCHMARK_CXX_LINKER_FLAGS) - list(APPEND CMAKE_SHARED_LINKER_FLAGS ${BENCHMARK_CXX_LINKER_FLAGS}) - list(APPEND CMAKE_MODULE_LINKER_FLAGS ${BENCHMARK_CXX_LINKER_FLAGS}) -endif() - -file(GLOB - SOURCE_FILES - *.cc - ${PROJECT_SOURCE_DIR}/include/benchmark/*.h - ${CMAKE_CURRENT_SOURCE_DIR}/*.h) -list(FILTER SOURCE_FILES EXCLUDE REGEX "benchmark_main\\.cc") - -add_library(benchmark ${SOURCE_FILES}) -set_target_properties(benchmark PROPERTIES - OUTPUT_NAME "benchmark" - VERSION ${GENERIC_LIB_VERSION} - SOVERSION ${GENERIC_LIB_SOVERSION} -) -target_include_directories(benchmark PUBLIC - $ - ) - -# Link threads. -target_link_libraries(benchmark ${BENCHMARK_CXX_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) -find_library(LIBRT rt) -if(LIBRT) - target_link_libraries(benchmark ${LIBRT}) -endif() - -# We need extra libraries on Windows -if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - target_link_libraries(benchmark Shlwapi) -endif() - -# We need extra libraries on Solaris -if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS") - target_link_libraries(benchmark kstat) -endif() - -# Benchmark main library -add_library(benchmark_main "benchmark_main.cc") -set_target_properties(benchmark_main PROPERTIES - OUTPUT_NAME "benchmark_main" - VERSION ${GENERIC_LIB_VERSION} - SOVERSION ${GENERIC_LIB_SOVERSION} -) -target_include_directories(benchmark PUBLIC - $ - ) -target_link_libraries(benchmark_main benchmark) - -set(include_install_dir "include") -set(lib_install_dir "lib/") -set(bin_install_dir "bin/") -set(config_install_dir "lib/cmake/${PROJECT_NAME}") -set(pkgconfig_install_dir "lib/pkgconfig") - -set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") - -set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake") -set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake") -set(pkg_config "${generated_dir}/${PROJECT_NAME}.pc") -set(targets_export_name "${PROJECT_NAME}Targets") - -set(namespace "${PROJECT_NAME}::") - -include(CMakePackageConfigHelpers) -write_basic_package_version_file( - "${version_config}" VERSION ${GIT_VERSION} COMPATIBILITY SameMajorVersion -) - -configure_file("${PROJECT_SOURCE_DIR}/cmake/Config.cmake.in" "${project_config}" @ONLY) -configure_file("${PROJECT_SOURCE_DIR}/cmake/benchmark.pc.in" "${pkg_config}" @ONLY) - -if (BENCHMARK_ENABLE_INSTALL) - # Install target (will install the library to specified CMAKE_INSTALL_PREFIX variable) - install( - TARGETS benchmark benchmark_main - EXPORT ${targets_export_name} - ARCHIVE DESTINATION ${lib_install_dir} - LIBRARY DESTINATION ${lib_install_dir} - RUNTIME DESTINATION ${bin_install_dir} - INCLUDES DESTINATION ${include_install_dir}) - - install( - DIRECTORY "${PROJECT_SOURCE_DIR}/include/benchmark" - DESTINATION ${include_install_dir} - FILES_MATCHING PATTERN "*.*h") - - install( - FILES "${project_config}" "${version_config}" - DESTINATION "${config_install_dir}") - - install( - FILES "${pkg_config}" - DESTINATION "${pkgconfig_install_dir}") - - install( - EXPORT "${targets_export_name}" - NAMESPACE "${namespace}" - DESTINATION "${config_install_dir}") -endif() diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/arraysize.h b/external_imported/json/benchmarks/thirdparty/benchmark/src/arraysize.h deleted file mode 100755 index 51a50f2df..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/arraysize.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef BENCHMARK_ARRAYSIZE_H_ -#define BENCHMARK_ARRAYSIZE_H_ - -#include "internal_macros.h" - -namespace benchmark { -namespace internal { -// The arraysize(arr) macro returns the # of elements in an array arr. -// The expression is a compile-time constant, and therefore can be -// used in defining new arrays, for example. If you use arraysize on -// a pointer by mistake, you will get a compile-time error. -// - -// This template function declaration is used in defining arraysize. -// Note that the function doesn't need an implementation, as we only -// use its type. -template -char (&ArraySizeHelper(T (&array)[N]))[N]; - -// That gcc wants both of these prototypes seems mysterious. VC, for -// its part, can't decide which to use (another mystery). Matching of -// template overloads: the final frontier. -#ifndef COMPILER_MSVC -template -char (&ArraySizeHelper(const T (&array)[N]))[N]; -#endif - -#define arraysize(array) (sizeof(::benchmark::internal::ArraySizeHelper(array))) - -} // end namespace internal -} // end namespace benchmark - -#endif // BENCHMARK_ARRAYSIZE_H_ diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/benchmark.cc b/external_imported/json/benchmarks/thirdparty/benchmark/src/benchmark.cc deleted file mode 100755 index 82b15ac70..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/benchmark.cc +++ /dev/null @@ -1,630 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "benchmark/benchmark.h" -#include "benchmark_api_internal.h" -#include "internal_macros.h" - -#ifndef BENCHMARK_OS_WINDOWS -#ifndef BENCHMARK_OS_FUCHSIA -#include -#endif -#include -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "check.h" -#include "colorprint.h" -#include "commandlineflags.h" -#include "complexity.h" -#include "counter.h" -#include "internal_macros.h" -#include "log.h" -#include "mutex.h" -#include "re.h" -#include "statistics.h" -#include "string_util.h" -#include "thread_manager.h" -#include "thread_timer.h" - -DEFINE_bool(benchmark_list_tests, false, - "Print a list of benchmarks. This option overrides all other " - "options."); - -DEFINE_string(benchmark_filter, ".", - "A regular expression that specifies the set of benchmarks " - "to execute. If this flag is empty, no benchmarks are run. " - "If this flag is the string \"all\", all benchmarks linked " - "into the process are run."); - -DEFINE_double(benchmark_min_time, 0.5, - "Minimum number of seconds we should run benchmark before " - "results are considered significant. For cpu-time based " - "tests, this is the lower bound on the total cpu time " - "used by all threads that make up the test. For real-time " - "based tests, this is the lower bound on the elapsed time " - "of the benchmark execution, regardless of number of " - "threads."); - -DEFINE_int32(benchmark_repetitions, 1, - "The number of runs of each benchmark. If greater than 1, the " - "mean and standard deviation of the runs will be reported."); - -DEFINE_bool(benchmark_report_aggregates_only, false, - "Report the result of each benchmark repetitions. When 'true' is " - "specified only the mean, standard deviation, and other statistics " - "are reported for repeated benchmarks."); - -DEFINE_string(benchmark_format, "console", - "The format to use for console output. Valid values are " - "'console', 'json', or 'csv'."); - -DEFINE_string(benchmark_out_format, "json", - "The format to use for file output. Valid values are " - "'console', 'json', or 'csv'."); - -DEFINE_string(benchmark_out, "", "The file to write additional output to"); - -DEFINE_string(benchmark_color, "auto", - "Whether to use colors in the output. Valid values: " - "'true'/'yes'/1, 'false'/'no'/0, and 'auto'. 'auto' means to use " - "colors if the output is being sent to a terminal and the TERM " - "environment variable is set to a terminal type that supports " - "colors."); - -DEFINE_bool(benchmark_counters_tabular, false, - "Whether to use tabular format when printing user counters to " - "the console. Valid values: 'true'/'yes'/1, 'false'/'no'/0." - "Defaults to false."); - -DEFINE_int32(v, 0, "The level of verbose logging to output"); - -namespace benchmark { - -namespace { -static const size_t kMaxIterations = 1000000000; -} // end namespace - -namespace internal { - -void UseCharPointer(char const volatile*) {} - -namespace { - -BenchmarkReporter::Run CreateRunReport( - const benchmark::internal::Benchmark::Instance& b, - const internal::ThreadManager::Result& results, - double seconds) { - // Create report about this benchmark run. - BenchmarkReporter::Run report; - - report.benchmark_name = b.name; - report.error_occurred = results.has_error_; - report.error_message = results.error_message_; - report.report_label = results.report_label_; - // This is the total iterations across all threads. - report.iterations = results.iterations; - report.time_unit = b.time_unit; - - if (!report.error_occurred) { - double bytes_per_second = 0; - if (results.bytes_processed > 0 && seconds > 0.0) { - bytes_per_second = (results.bytes_processed / seconds); - } - double items_per_second = 0; - if (results.items_processed > 0 && seconds > 0.0) { - items_per_second = (results.items_processed / seconds); - } - - if (b.use_manual_time) { - report.real_accumulated_time = results.manual_time_used; - } else { - report.real_accumulated_time = results.real_time_used; - } - report.cpu_accumulated_time = results.cpu_time_used; - report.bytes_per_second = bytes_per_second; - report.items_per_second = items_per_second; - report.complexity_n = results.complexity_n; - report.complexity = b.complexity; - report.complexity_lambda = b.complexity_lambda; - report.statistics = b.statistics; - report.counters = results.counters; - internal::Finish(&report.counters, seconds, b.threads); - } - return report; -} - -// Execute one thread of benchmark b for the specified number of iterations. -// Adds the stats collected for the thread into *total. -void RunInThread(const benchmark::internal::Benchmark::Instance* b, - size_t iters, int thread_id, - internal::ThreadManager* manager) { - internal::ThreadTimer timer; - State st(iters, b->arg, thread_id, b->threads, &timer, manager); - b->benchmark->Run(st); - CHECK(st.iterations() >= st.max_iterations) - << "Benchmark returned before State::KeepRunning() returned false!"; - { - MutexLock l(manager->GetBenchmarkMutex()); - internal::ThreadManager::Result& results = manager->results; - results.iterations += st.iterations(); - results.cpu_time_used += timer.cpu_time_used(); - results.real_time_used += timer.real_time_used(); - results.manual_time_used += timer.manual_time_used(); - results.bytes_processed += st.bytes_processed(); - results.items_processed += st.items_processed(); - results.complexity_n += st.complexity_length_n(); - internal::Increment(&results.counters, st.counters); - } - manager->NotifyThreadComplete(); -} - -std::vector RunBenchmark( - const benchmark::internal::Benchmark::Instance& b, - std::vector* complexity_reports) { - std::vector reports; // return value - - const bool has_explicit_iteration_count = b.iterations != 0; - size_t iters = has_explicit_iteration_count ? b.iterations : 1; - std::unique_ptr manager; - std::vector pool(b.threads - 1); - const int repeats = - b.repetitions != 0 ? b.repetitions : FLAGS_benchmark_repetitions; - const bool report_aggregates_only = - repeats != 1 && - (b.report_mode == internal::RM_Unspecified - ? FLAGS_benchmark_report_aggregates_only - : b.report_mode == internal::RM_ReportAggregatesOnly); - for (int repetition_num = 0; repetition_num < repeats; repetition_num++) { - for (;;) { - // Try benchmark - VLOG(2) << "Running " << b.name << " for " << iters << "\n"; - - manager.reset(new internal::ThreadManager(b.threads)); - for (std::size_t ti = 0; ti < pool.size(); ++ti) { - pool[ti] = std::thread(&RunInThread, &b, iters, - static_cast(ti + 1), manager.get()); - } - RunInThread(&b, iters, 0, manager.get()); - manager->WaitForAllThreads(); - for (std::thread& thread : pool) thread.join(); - internal::ThreadManager::Result results; - { - MutexLock l(manager->GetBenchmarkMutex()); - results = manager->results; - } - manager.reset(); - // Adjust real/manual time stats since they were reported per thread. - results.real_time_used /= b.threads; - results.manual_time_used /= b.threads; - - VLOG(2) << "Ran in " << results.cpu_time_used << "/" - << results.real_time_used << "\n"; - - // Base decisions off of real time if requested by this benchmark. - double seconds = results.cpu_time_used; - if (b.use_manual_time) { - seconds = results.manual_time_used; - } else if (b.use_real_time) { - seconds = results.real_time_used; - } - - const double min_time = - !IsZero(b.min_time) ? b.min_time : FLAGS_benchmark_min_time; - - // Determine if this run should be reported; Either it has - // run for a sufficient amount of time or because an error was reported. - const bool should_report = repetition_num > 0 - || has_explicit_iteration_count // An exact iteration count was requested - || results.has_error_ - || iters >= kMaxIterations // No chance to try again, we hit the limit. - || seconds >= min_time // the elapsed time is large enough - // CPU time is specified but the elapsed real time greatly exceeds the - // minimum time. Note that user provided timers are except from this - // sanity check. - || ((results.real_time_used >= 5 * min_time) && !b.use_manual_time); - - if (should_report) { - BenchmarkReporter::Run report = CreateRunReport(b, results, seconds); - if (!report.error_occurred && b.complexity != oNone) - complexity_reports->push_back(report); - reports.push_back(report); - break; - } - - // See how much iterations should be increased by - // Note: Avoid division by zero with max(seconds, 1ns). - double multiplier = min_time * 1.4 / std::max(seconds, 1e-9); - // If our last run was at least 10% of FLAGS_benchmark_min_time then we - // use the multiplier directly. Otherwise we use at most 10 times - // expansion. - // NOTE: When the last run was at least 10% of the min time the max - // expansion should be 14x. - bool is_significant = (seconds / min_time) > 0.1; - multiplier = is_significant ? multiplier : std::min(10.0, multiplier); - if (multiplier <= 1.0) multiplier = 2.0; - double next_iters = std::max(multiplier * iters, iters + 1.0); - if (next_iters > kMaxIterations) { - next_iters = kMaxIterations; - } - VLOG(3) << "Next iters: " << next_iters << ", " << multiplier << "\n"; - iters = static_cast(next_iters + 0.5); - } - } - // Calculate additional statistics - auto stat_reports = ComputeStats(reports); - if ((b.complexity != oNone) && b.last_benchmark_instance) { - auto additional_run_stats = ComputeBigO(*complexity_reports); - stat_reports.insert(stat_reports.end(), additional_run_stats.begin(), - additional_run_stats.end()); - complexity_reports->clear(); - } - - if (report_aggregates_only) reports.clear(); - reports.insert(reports.end(), stat_reports.begin(), stat_reports.end()); - return reports; -} - -} // namespace -} // namespace internal - -State::State(size_t max_iters, const std::vector& ranges, int thread_i, - int n_threads, internal::ThreadTimer* timer, - internal::ThreadManager* manager) - : total_iterations_(0), - batch_leftover_(0), - max_iterations(max_iters), - started_(false), - finished_(false), - error_occurred_(false), - range_(ranges), - bytes_processed_(0), - items_processed_(0), - complexity_n_(0), - counters(), - thread_index(thread_i), - threads(n_threads), - timer_(timer), - manager_(manager) { - CHECK(max_iterations != 0) << "At least one iteration must be run"; - CHECK_LT(thread_index, threads) << "thread_index must be less than threads"; - - // Note: The use of offsetof below is technically undefined until C++17 - // because State is not a standard layout type. However, all compilers - // currently provide well-defined behavior as an extension (which is - // demonstrated since constexpr evaluation must diagnose all undefined - // behavior). However, GCC and Clang also warn about this use of offsetof, - // which must be suppressed. -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Winvalid-offsetof" -#endif - // Offset tests to ensure commonly accessed data is on the first cache line. - const int cache_line_size = 64; - static_assert(offsetof(State, error_occurred_) <= - (cache_line_size - sizeof(error_occurred_)), ""); -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif -} - -void State::PauseTiming() { - // Add in time accumulated so far - CHECK(started_ && !finished_ && !error_occurred_); - timer_->StopTimer(); -} - -void State::ResumeTiming() { - CHECK(started_ && !finished_ && !error_occurred_); - timer_->StartTimer(); -} - -void State::SkipWithError(const char* msg) { - CHECK(msg); - error_occurred_ = true; - { - MutexLock l(manager_->GetBenchmarkMutex()); - if (manager_->results.has_error_ == false) { - manager_->results.error_message_ = msg; - manager_->results.has_error_ = true; - } - } - total_iterations_ = 0; - if (timer_->running()) timer_->StopTimer(); -} - -void State::SetIterationTime(double seconds) { - timer_->SetIterationTime(seconds); -} - -void State::SetLabel(const char* label) { - MutexLock l(manager_->GetBenchmarkMutex()); - manager_->results.report_label_ = label; -} - -void State::StartKeepRunning() { - CHECK(!started_ && !finished_); - started_ = true; - total_iterations_ = error_occurred_ ? 0 : max_iterations; - manager_->StartStopBarrier(); - if (!error_occurred_) ResumeTiming(); -} - -void State::FinishKeepRunning() { - CHECK(started_ && (!finished_ || error_occurred_)); - if (!error_occurred_) { - PauseTiming(); - } - // Total iterations has now wrapped around past 0. Fix this. - total_iterations_ = 0; - finished_ = true; - manager_->StartStopBarrier(); -} - -namespace internal { -namespace { - -void RunBenchmarks(const std::vector& benchmarks, - BenchmarkReporter* console_reporter, - BenchmarkReporter* file_reporter) { - // Note the file_reporter can be null. - CHECK(console_reporter != nullptr); - - // Determine the width of the name field using a minimum width of 10. - bool has_repetitions = FLAGS_benchmark_repetitions > 1; - size_t name_field_width = 10; - size_t stat_field_width = 0; - for (const Benchmark::Instance& benchmark : benchmarks) { - name_field_width = - std::max(name_field_width, benchmark.name.size()); - has_repetitions |= benchmark.repetitions > 1; - - for(const auto& Stat : *benchmark.statistics) - stat_field_width = std::max(stat_field_width, Stat.name_.size()); - } - if (has_repetitions) name_field_width += 1 + stat_field_width; - - // Print header here - BenchmarkReporter::Context context; - context.name_field_width = name_field_width; - - // Keep track of running times of all instances of current benchmark - std::vector complexity_reports; - - // We flush streams after invoking reporter methods that write to them. This - // ensures users get timely updates even when streams are not line-buffered. - auto flushStreams = [](BenchmarkReporter* reporter) { - if (!reporter) return; - std::flush(reporter->GetOutputStream()); - std::flush(reporter->GetErrorStream()); - }; - - if (console_reporter->ReportContext(context) && - (!file_reporter || file_reporter->ReportContext(context))) { - flushStreams(console_reporter); - flushStreams(file_reporter); - for (const auto& benchmark : benchmarks) { - std::vector reports = - RunBenchmark(benchmark, &complexity_reports); - console_reporter->ReportRuns(reports); - if (file_reporter) file_reporter->ReportRuns(reports); - flushStreams(console_reporter); - flushStreams(file_reporter); - } - } - console_reporter->Finalize(); - if (file_reporter) file_reporter->Finalize(); - flushStreams(console_reporter); - flushStreams(file_reporter); -} - -std::unique_ptr CreateReporter( - std::string const& name, ConsoleReporter::OutputOptions output_opts) { - typedef std::unique_ptr PtrType; - if (name == "console") { - return PtrType(new ConsoleReporter(output_opts)); - } else if (name == "json") { - return PtrType(new JSONReporter); - } else if (name == "csv") { - return PtrType(new CSVReporter); - } else { - std::cerr << "Unexpected format: '" << name << "'\n"; - std::exit(1); - } -} - -} // end namespace - -bool IsZero(double n) { - return std::abs(n) < std::numeric_limits::epsilon(); -} - -ConsoleReporter::OutputOptions GetOutputOptions(bool force_no_color) { - int output_opts = ConsoleReporter::OO_Defaults; - if ((FLAGS_benchmark_color == "auto" && IsColorTerminal()) || - IsTruthyFlagValue(FLAGS_benchmark_color)) { - output_opts |= ConsoleReporter::OO_Color; - } else { - output_opts &= ~ConsoleReporter::OO_Color; - } - if(force_no_color) { - output_opts &= ~ConsoleReporter::OO_Color; - } - if(FLAGS_benchmark_counters_tabular) { - output_opts |= ConsoleReporter::OO_Tabular; - } else { - output_opts &= ~ConsoleReporter::OO_Tabular; - } - return static_cast< ConsoleReporter::OutputOptions >(output_opts); -} - -} // end namespace internal - -size_t RunSpecifiedBenchmarks() { - return RunSpecifiedBenchmarks(nullptr, nullptr); -} - -size_t RunSpecifiedBenchmarks(BenchmarkReporter* console_reporter) { - return RunSpecifiedBenchmarks(console_reporter, nullptr); -} - -size_t RunSpecifiedBenchmarks(BenchmarkReporter* console_reporter, - BenchmarkReporter* file_reporter) { - std::string spec = FLAGS_benchmark_filter; - if (spec.empty() || spec == "all") - spec = "."; // Regexp that matches all benchmarks - - // Setup the reporters - std::ofstream output_file; - std::unique_ptr default_console_reporter; - std::unique_ptr default_file_reporter; - if (!console_reporter) { - default_console_reporter = internal::CreateReporter( - FLAGS_benchmark_format, internal::GetOutputOptions()); - console_reporter = default_console_reporter.get(); - } - auto& Out = console_reporter->GetOutputStream(); - auto& Err = console_reporter->GetErrorStream(); - - std::string const& fname = FLAGS_benchmark_out; - if (fname.empty() && file_reporter) { - Err << "A custom file reporter was provided but " - "--benchmark_out= was not specified." - << std::endl; - std::exit(1); - } - if (!fname.empty()) { - output_file.open(fname); - if (!output_file.is_open()) { - Err << "invalid file name: '" << fname << std::endl; - std::exit(1); - } - if (!file_reporter) { - default_file_reporter = internal::CreateReporter( - FLAGS_benchmark_out_format, ConsoleReporter::OO_None); - file_reporter = default_file_reporter.get(); - } - file_reporter->SetOutputStream(&output_file); - file_reporter->SetErrorStream(&output_file); - } - - std::vector benchmarks; - if (!FindBenchmarksInternal(spec, &benchmarks, &Err)) return 0; - - if (benchmarks.empty()) { - Err << "Failed to match any benchmarks against regex: " << spec << "\n"; - return 0; - } - - if (FLAGS_benchmark_list_tests) { - for (auto const& benchmark : benchmarks) Out << benchmark.name << "\n"; - } else { - internal::RunBenchmarks(benchmarks, console_reporter, file_reporter); - } - - return benchmarks.size(); -} - -namespace internal { - -void PrintUsageAndExit() { - fprintf(stdout, - "benchmark" - " [--benchmark_list_tests={true|false}]\n" - " [--benchmark_filter=]\n" - " [--benchmark_min_time=]\n" - " [--benchmark_repetitions=]\n" - " [--benchmark_report_aggregates_only={true|false}\n" - " [--benchmark_format=]\n" - " [--benchmark_out=]\n" - " [--benchmark_out_format=]\n" - " [--benchmark_color={auto|true|false}]\n" - " [--benchmark_counters_tabular={true|false}]\n" - " [--v=]\n"); - exit(0); -} - -void ParseCommandLineFlags(int* argc, char** argv) { - using namespace benchmark; - BenchmarkReporter::Context::executable_name = argv[0]; - for (int i = 1; i < *argc; ++i) { - if (ParseBoolFlag(argv[i], "benchmark_list_tests", - &FLAGS_benchmark_list_tests) || - ParseStringFlag(argv[i], "benchmark_filter", &FLAGS_benchmark_filter) || - ParseDoubleFlag(argv[i], "benchmark_min_time", - &FLAGS_benchmark_min_time) || - ParseInt32Flag(argv[i], "benchmark_repetitions", - &FLAGS_benchmark_repetitions) || - ParseBoolFlag(argv[i], "benchmark_report_aggregates_only", - &FLAGS_benchmark_report_aggregates_only) || - ParseStringFlag(argv[i], "benchmark_format", &FLAGS_benchmark_format) || - ParseStringFlag(argv[i], "benchmark_out", &FLAGS_benchmark_out) || - ParseStringFlag(argv[i], "benchmark_out_format", - &FLAGS_benchmark_out_format) || - ParseStringFlag(argv[i], "benchmark_color", &FLAGS_benchmark_color) || - // "color_print" is the deprecated name for "benchmark_color". - // TODO: Remove this. - ParseStringFlag(argv[i], "color_print", &FLAGS_benchmark_color) || - ParseBoolFlag(argv[i], "benchmark_counters_tabular", - &FLAGS_benchmark_counters_tabular) || - ParseInt32Flag(argv[i], "v", &FLAGS_v)) { - for (int j = i; j != *argc - 1; ++j) argv[j] = argv[j + 1]; - - --(*argc); - --i; - } else if (IsFlag(argv[i], "help")) { - PrintUsageAndExit(); - } - } - for (auto const* flag : - {&FLAGS_benchmark_format, &FLAGS_benchmark_out_format}) - if (*flag != "console" && *flag != "json" && *flag != "csv") { - PrintUsageAndExit(); - } - if (FLAGS_benchmark_color.empty()) { - PrintUsageAndExit(); - } -} - -int InitializeStreams() { - static std::ios_base::Init init; - return 0; -} - -} // end namespace internal - -void Initialize(int* argc, char** argv) { - internal::ParseCommandLineFlags(argc, argv); - internal::LogLevel() = FLAGS_v; -} - -bool ReportUnrecognizedArguments(int argc, char** argv) { - for (int i = 1; i < argc; ++i) { - fprintf(stderr, "%s: error: unrecognized command-line flag: %s\n", argv[0], argv[i]); - } - return argc > 1; -} - -} // end namespace benchmark diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/benchmark_api_internal.h b/external_imported/json/benchmarks/thirdparty/benchmark/src/benchmark_api_internal.h deleted file mode 100755 index dd7a3ffe8..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/benchmark_api_internal.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef BENCHMARK_API_INTERNAL_H -#define BENCHMARK_API_INTERNAL_H - -#include "benchmark/benchmark.h" - -#include -#include -#include -#include -#include - -namespace benchmark { -namespace internal { - -// Information kept per benchmark we may want to run -struct Benchmark::Instance { - std::string name; - Benchmark* benchmark; - ReportMode report_mode; - std::vector arg; - TimeUnit time_unit; - int range_multiplier; - bool use_real_time; - bool use_manual_time; - BigO complexity; - BigOFunc* complexity_lambda; - UserCounters counters; - const std::vector* statistics; - bool last_benchmark_instance; - int repetitions; - double min_time; - size_t iterations; - int threads; // Number of concurrent threads to us -}; - -bool FindBenchmarksInternal(const std::string& re, - std::vector* benchmarks, - std::ostream* Err); - -bool IsZero(double n); - -ConsoleReporter::OutputOptions GetOutputOptions(bool force_no_color = false); - -} // end namespace internal -} // end namespace benchmark - -#endif // BENCHMARK_API_INTERNAL_H diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/benchmark_main.cc b/external_imported/json/benchmarks/thirdparty/benchmark/src/benchmark_main.cc deleted file mode 100755 index b3b247831..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/benchmark_main.cc +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2018 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "benchmark/benchmark.h" - -BENCHMARK_MAIN(); diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/benchmark_register.cc b/external_imported/json/benchmarks/thirdparty/benchmark/src/benchmark_register.cc deleted file mode 100755 index dc6f93568..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/benchmark_register.cc +++ /dev/null @@ -1,461 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "benchmark_register.h" - -#ifndef BENCHMARK_OS_WINDOWS -#ifndef BENCHMARK_OS_FUCHSIA -#include -#endif -#include -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "benchmark/benchmark.h" -#include "benchmark_api_internal.h" -#include "check.h" -#include "commandlineflags.h" -#include "complexity.h" -#include "internal_macros.h" -#include "log.h" -#include "mutex.h" -#include "re.h" -#include "statistics.h" -#include "string_util.h" -#include "timers.h" - -namespace benchmark { - -namespace { -// For non-dense Range, intermediate values are powers of kRangeMultiplier. -static const int kRangeMultiplier = 8; -// The size of a benchmark family determines is the number of inputs to repeat -// the benchmark on. If this is "large" then warn the user during configuration. -static const size_t kMaxFamilySize = 100; -} // end namespace - -namespace internal { - -//=============================================================================// -// BenchmarkFamilies -//=============================================================================// - -// Class for managing registered benchmarks. Note that each registered -// benchmark identifies a family of related benchmarks to run. -class BenchmarkFamilies { - public: - static BenchmarkFamilies* GetInstance(); - - // Registers a benchmark family and returns the index assigned to it. - size_t AddBenchmark(std::unique_ptr family); - - // Clear all registered benchmark families. - void ClearBenchmarks(); - - // Extract the list of benchmark instances that match the specified - // regular expression. - bool FindBenchmarks(std::string re, - std::vector* benchmarks, - std::ostream* Err); - - private: - BenchmarkFamilies() {} - - std::vector> families_; - Mutex mutex_; -}; - -BenchmarkFamilies* BenchmarkFamilies::GetInstance() { - static BenchmarkFamilies instance; - return &instance; -} - -size_t BenchmarkFamilies::AddBenchmark(std::unique_ptr family) { - MutexLock l(mutex_); - size_t index = families_.size(); - families_.push_back(std::move(family)); - return index; -} - -void BenchmarkFamilies::ClearBenchmarks() { - MutexLock l(mutex_); - families_.clear(); - families_.shrink_to_fit(); -} - -bool BenchmarkFamilies::FindBenchmarks( - std::string spec, std::vector* benchmarks, - std::ostream* ErrStream) { - CHECK(ErrStream); - auto& Err = *ErrStream; - // Make regular expression out of command-line flag - std::string error_msg; - Regex re; - bool isNegativeFilter = false; - if(spec[0] == '-') { - spec.replace(0, 1, ""); - isNegativeFilter = true; - } - if (!re.Init(spec, &error_msg)) { - Err << "Could not compile benchmark re: " << error_msg << std::endl; - return false; - } - - // Special list of thread counts to use when none are specified - const std::vector one_thread = {1}; - - MutexLock l(mutex_); - for (std::unique_ptr& family : families_) { - // Family was deleted or benchmark doesn't match - if (!family) continue; - - if (family->ArgsCnt() == -1) { - family->Args({}); - } - const std::vector* thread_counts = - (family->thread_counts_.empty() - ? &one_thread - : &static_cast&>(family->thread_counts_)); - const size_t family_size = family->args_.size() * thread_counts->size(); - // The benchmark will be run at least 'family_size' different inputs. - // If 'family_size' is very large warn the user. - if (family_size > kMaxFamilySize) { - Err << "The number of inputs is very large. " << family->name_ - << " will be repeated at least " << family_size << " times.\n"; - } - // reserve in the special case the regex ".", since we know the final - // family size. - if (spec == ".") benchmarks->reserve(family_size); - - for (auto const& args : family->args_) { - for (int num_threads : *thread_counts) { - Benchmark::Instance instance; - instance.name = family->name_; - instance.benchmark = family.get(); - instance.report_mode = family->report_mode_; - instance.arg = args; - instance.time_unit = family->time_unit_; - instance.range_multiplier = family->range_multiplier_; - instance.min_time = family->min_time_; - instance.iterations = family->iterations_; - instance.repetitions = family->repetitions_; - instance.use_real_time = family->use_real_time_; - instance.use_manual_time = family->use_manual_time_; - instance.complexity = family->complexity_; - instance.complexity_lambda = family->complexity_lambda_; - instance.statistics = &family->statistics_; - instance.threads = num_threads; - - // Add arguments to instance name - size_t arg_i = 0; - for (auto const& arg : args) { - instance.name += "/"; - - if (arg_i < family->arg_names_.size()) { - const auto& arg_name = family->arg_names_[arg_i]; - if (!arg_name.empty()) { - instance.name += - StrFormat("%s:", family->arg_names_[arg_i].c_str()); - } - } - - instance.name += StrFormat("%d", arg); - ++arg_i; - } - - if (!IsZero(family->min_time_)) - instance.name += StrFormat("/min_time:%0.3f", family->min_time_); - if (family->iterations_ != 0) - instance.name += StrFormat("/iterations:%d", family->iterations_); - if (family->repetitions_ != 0) - instance.name += StrFormat("/repeats:%d", family->repetitions_); - - if (family->use_manual_time_) { - instance.name += "/manual_time"; - } else if (family->use_real_time_) { - instance.name += "/real_time"; - } - - // Add the number of threads used to the name - if (!family->thread_counts_.empty()) { - instance.name += StrFormat("/threads:%d", instance.threads); - } - - if ((re.Match(instance.name) && !isNegativeFilter) || - (!re.Match(instance.name) && isNegativeFilter)) { - instance.last_benchmark_instance = (&args == &family->args_.back()); - benchmarks->push_back(std::move(instance)); - } - } - } - } - return true; -} - -Benchmark* RegisterBenchmarkInternal(Benchmark* bench) { - std::unique_ptr bench_ptr(bench); - BenchmarkFamilies* families = BenchmarkFamilies::GetInstance(); - families->AddBenchmark(std::move(bench_ptr)); - return bench; -} - -// FIXME: This function is a hack so that benchmark.cc can access -// `BenchmarkFamilies` -bool FindBenchmarksInternal(const std::string& re, - std::vector* benchmarks, - std::ostream* Err) { - return BenchmarkFamilies::GetInstance()->FindBenchmarks(re, benchmarks, Err); -} - -//=============================================================================// -// Benchmark -//=============================================================================// - -Benchmark::Benchmark(const char* name) - : name_(name), - report_mode_(RM_Unspecified), - time_unit_(kNanosecond), - range_multiplier_(kRangeMultiplier), - min_time_(0), - iterations_(0), - repetitions_(0), - use_real_time_(false), - use_manual_time_(false), - complexity_(oNone), - complexity_lambda_(nullptr) { - ComputeStatistics("mean", StatisticsMean); - ComputeStatistics("median", StatisticsMedian); - ComputeStatistics("stddev", StatisticsStdDev); -} - -Benchmark::~Benchmark() {} - -Benchmark* Benchmark::Arg(int64_t x) { - CHECK(ArgsCnt() == -1 || ArgsCnt() == 1); - args_.push_back({x}); - return this; -} - -Benchmark* Benchmark::Unit(TimeUnit unit) { - time_unit_ = unit; - return this; -} - -Benchmark* Benchmark::Range(int64_t start, int64_t limit) { - CHECK(ArgsCnt() == -1 || ArgsCnt() == 1); - std::vector arglist; - AddRange(&arglist, start, limit, range_multiplier_); - - for (int64_t i : arglist) { - args_.push_back({i}); - } - return this; -} - -Benchmark* Benchmark::Ranges( - const std::vector>& ranges) { - CHECK(ArgsCnt() == -1 || ArgsCnt() == static_cast(ranges.size())); - std::vector> arglists(ranges.size()); - std::size_t total = 1; - for (std::size_t i = 0; i < ranges.size(); i++) { - AddRange(&arglists[i], ranges[i].first, ranges[i].second, - range_multiplier_); - total *= arglists[i].size(); - } - - std::vector ctr(arglists.size(), 0); - - for (std::size_t i = 0; i < total; i++) { - std::vector tmp; - tmp.reserve(arglists.size()); - - for (std::size_t j = 0; j < arglists.size(); j++) { - tmp.push_back(arglists[j].at(ctr[j])); - } - - args_.push_back(std::move(tmp)); - - for (std::size_t j = 0; j < arglists.size(); j++) { - if (ctr[j] + 1 < arglists[j].size()) { - ++ctr[j]; - break; - } - ctr[j] = 0; - } - } - return this; -} - -Benchmark* Benchmark::ArgName(const std::string& name) { - CHECK(ArgsCnt() == -1 || ArgsCnt() == 1); - arg_names_ = {name}; - return this; -} - -Benchmark* Benchmark::ArgNames(const std::vector& names) { - CHECK(ArgsCnt() == -1 || ArgsCnt() == static_cast(names.size())); - arg_names_ = names; - return this; -} - -Benchmark* Benchmark::DenseRange(int64_t start, int64_t limit, int step) { - CHECK(ArgsCnt() == -1 || ArgsCnt() == 1); - CHECK_GE(start, 0); - CHECK_LE(start, limit); - for (int64_t arg = start; arg <= limit; arg += step) { - args_.push_back({arg}); - } - return this; -} - -Benchmark* Benchmark::Args(const std::vector& args) { - CHECK(ArgsCnt() == -1 || ArgsCnt() == static_cast(args.size())); - args_.push_back(args); - return this; -} - -Benchmark* Benchmark::Apply(void (*custom_arguments)(Benchmark* benchmark)) { - custom_arguments(this); - return this; -} - -Benchmark* Benchmark::RangeMultiplier(int multiplier) { - CHECK(multiplier > 1); - range_multiplier_ = multiplier; - return this; -} - -Benchmark* Benchmark::MinTime(double t) { - CHECK(t > 0.0); - CHECK(iterations_ == 0); - min_time_ = t; - return this; -} - -Benchmark* Benchmark::Iterations(size_t n) { - CHECK(n > 0); - CHECK(IsZero(min_time_)); - iterations_ = n; - return this; -} - -Benchmark* Benchmark::Repetitions(int n) { - CHECK(n > 0); - repetitions_ = n; - return this; -} - -Benchmark* Benchmark::ReportAggregatesOnly(bool value) { - report_mode_ = value ? RM_ReportAggregatesOnly : RM_Default; - return this; -} - -Benchmark* Benchmark::UseRealTime() { - CHECK(!use_manual_time_) - << "Cannot set UseRealTime and UseManualTime simultaneously."; - use_real_time_ = true; - return this; -} - -Benchmark* Benchmark::UseManualTime() { - CHECK(!use_real_time_) - << "Cannot set UseRealTime and UseManualTime simultaneously."; - use_manual_time_ = true; - return this; -} - -Benchmark* Benchmark::Complexity(BigO complexity) { - complexity_ = complexity; - return this; -} - -Benchmark* Benchmark::Complexity(BigOFunc* complexity) { - complexity_lambda_ = complexity; - complexity_ = oLambda; - return this; -} - -Benchmark* Benchmark::ComputeStatistics(std::string name, - StatisticsFunc* statistics) { - statistics_.emplace_back(name, statistics); - return this; -} - -Benchmark* Benchmark::Threads(int t) { - CHECK_GT(t, 0); - thread_counts_.push_back(t); - return this; -} - -Benchmark* Benchmark::ThreadRange(int min_threads, int max_threads) { - CHECK_GT(min_threads, 0); - CHECK_GE(max_threads, min_threads); - - AddRange(&thread_counts_, min_threads, max_threads, 2); - return this; -} - -Benchmark* Benchmark::DenseThreadRange(int min_threads, int max_threads, - int stride) { - CHECK_GT(min_threads, 0); - CHECK_GE(max_threads, min_threads); - CHECK_GE(stride, 1); - - for (auto i = min_threads; i < max_threads; i += stride) { - thread_counts_.push_back(i); - } - thread_counts_.push_back(max_threads); - return this; -} - -Benchmark* Benchmark::ThreadPerCpu() { - thread_counts_.push_back(CPUInfo::Get().num_cpus); - return this; -} - -void Benchmark::SetName(const char* name) { name_ = name; } - -int Benchmark::ArgsCnt() const { - if (args_.empty()) { - if (arg_names_.empty()) return -1; - return static_cast(arg_names_.size()); - } - return static_cast(args_.front().size()); -} - -//=============================================================================// -// FunctionBenchmark -//=============================================================================// - -void FunctionBenchmark::Run(State& st) { func_(st); } - -} // end namespace internal - -void ClearRegisteredBenchmarks() { - internal::BenchmarkFamilies::GetInstance()->ClearBenchmarks(); -} - -} // end namespace benchmark diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/benchmark_register.h b/external_imported/json/benchmarks/thirdparty/benchmark/src/benchmark_register.h deleted file mode 100755 index 0705e219f..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/benchmark_register.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef BENCHMARK_REGISTER_H -#define BENCHMARK_REGISTER_H - -#include - -#include "check.h" - -template -void AddRange(std::vector* dst, T lo, T hi, int mult) { - CHECK_GE(lo, 0); - CHECK_GE(hi, lo); - CHECK_GE(mult, 2); - - // Add "lo" - dst->push_back(lo); - - static const T kmax = std::numeric_limits::max(); - - // Now space out the benchmarks in multiples of "mult" - for (T i = 1; i < kmax / mult; i *= mult) { - if (i >= hi) break; - if (i > lo) { - dst->push_back(i); - } - } - - // Add "hi" (if different from "lo") - if (hi != lo) { - dst->push_back(hi); - } -} - -#endif // BENCHMARK_REGISTER_H diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/check.h b/external_imported/json/benchmarks/thirdparty/benchmark/src/check.h deleted file mode 100755 index 73bead2fb..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/check.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef CHECK_H_ -#define CHECK_H_ - -#include -#include -#include - -#include "internal_macros.h" -#include "log.h" - -namespace benchmark { -namespace internal { - -typedef void(AbortHandlerT)(); - -inline AbortHandlerT*& GetAbortHandler() { - static AbortHandlerT* handler = &std::abort; - return handler; -} - -BENCHMARK_NORETURN inline void CallAbortHandler() { - GetAbortHandler()(); - std::abort(); // fallback to enforce noreturn -} - -// CheckHandler is the class constructed by failing CHECK macros. CheckHandler -// will log information about the failures and abort when it is destructed. -class CheckHandler { - public: - CheckHandler(const char* check, const char* file, const char* func, int line) - : log_(GetErrorLogInstance()) { - log_ << file << ":" << line << ": " << func << ": Check `" << check - << "' failed. "; - } - - LogType& GetLog() { return log_; } - - BENCHMARK_NORETURN ~CheckHandler() BENCHMARK_NOEXCEPT_OP(false) { - log_ << std::endl; - CallAbortHandler(); - } - - CheckHandler& operator=(const CheckHandler&) = delete; - CheckHandler(const CheckHandler&) = delete; - CheckHandler() = delete; - - private: - LogType& log_; -}; - -} // end namespace internal -} // end namespace benchmark - -// The CHECK macro returns a std::ostream object that can have extra information -// written to it. -#ifndef NDEBUG -#define CHECK(b) \ - (b ? ::benchmark::internal::GetNullLogInstance() \ - : ::benchmark::internal::CheckHandler(#b, __FILE__, __func__, __LINE__) \ - .GetLog()) -#else -#define CHECK(b) ::benchmark::internal::GetNullLogInstance() -#endif - -#define CHECK_EQ(a, b) CHECK((a) == (b)) -#define CHECK_NE(a, b) CHECK((a) != (b)) -#define CHECK_GE(a, b) CHECK((a) >= (b)) -#define CHECK_LE(a, b) CHECK((a) <= (b)) -#define CHECK_GT(a, b) CHECK((a) > (b)) -#define CHECK_LT(a, b) CHECK((a) < (b)) - -#define CHECK_FLOAT_EQ(a, b, eps) CHECK(std::fabs((a) - (b)) < (eps)) -#define CHECK_FLOAT_NE(a, b, eps) CHECK(std::fabs((a) - (b)) >= (eps)) -#define CHECK_FLOAT_GE(a, b, eps) CHECK((a) - (b) > -(eps)) -#define CHECK_FLOAT_LE(a, b, eps) CHECK((b) - (a) > -(eps)) -#define CHECK_FLOAT_GT(a, b, eps) CHECK((a) - (b) > (eps)) -#define CHECK_FLOAT_LT(a, b, eps) CHECK((b) - (a) > (eps)) - -#endif // CHECK_H_ diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/colorprint.cc b/external_imported/json/benchmarks/thirdparty/benchmark/src/colorprint.cc deleted file mode 100755 index 2dec4a8b2..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/colorprint.cc +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "colorprint.h" - -#include -#include -#include -#include -#include -#include - -#include "check.h" -#include "internal_macros.h" - -#ifdef BENCHMARK_OS_WINDOWS -#include -#include -#else -#include -#endif // BENCHMARK_OS_WINDOWS - -namespace benchmark { -namespace { -#ifdef BENCHMARK_OS_WINDOWS -typedef WORD PlatformColorCode; -#else -typedef const char* PlatformColorCode; -#endif - -PlatformColorCode GetPlatformColorCode(LogColor color) { -#ifdef BENCHMARK_OS_WINDOWS - switch (color) { - case COLOR_RED: - return FOREGROUND_RED; - case COLOR_GREEN: - return FOREGROUND_GREEN; - case COLOR_YELLOW: - return FOREGROUND_RED | FOREGROUND_GREEN; - case COLOR_BLUE: - return FOREGROUND_BLUE; - case COLOR_MAGENTA: - return FOREGROUND_BLUE | FOREGROUND_RED; - case COLOR_CYAN: - return FOREGROUND_BLUE | FOREGROUND_GREEN; - case COLOR_WHITE: // fall through to default - default: - return 0; - } -#else - switch (color) { - case COLOR_RED: - return "1"; - case COLOR_GREEN: - return "2"; - case COLOR_YELLOW: - return "3"; - case COLOR_BLUE: - return "4"; - case COLOR_MAGENTA: - return "5"; - case COLOR_CYAN: - return "6"; - case COLOR_WHITE: - return "7"; - default: - return nullptr; - }; -#endif -} - -} // end namespace - -std::string FormatString(const char* msg, va_list args) { - // we might need a second shot at this, so pre-emptivly make a copy - va_list args_cp; - va_copy(args_cp, args); - - std::size_t size = 256; - char local_buff[256]; - auto ret = vsnprintf(local_buff, size, msg, args_cp); - - va_end(args_cp); - - // currently there is no error handling for failure, so this is hack. - CHECK(ret >= 0); - - if (ret == 0) // handle empty expansion - return {}; - else if (static_cast(ret) < size) - return local_buff; - else { - // we did not provide a long enough buffer on our first attempt. - size = (size_t)ret + 1; // + 1 for the null byte - std::unique_ptr buff(new char[size]); - ret = vsnprintf(buff.get(), size, msg, args); - CHECK(ret > 0 && ((size_t)ret) < size); - return buff.get(); - } -} - -std::string FormatString(const char* msg, ...) { - va_list args; - va_start(args, msg); - auto tmp = FormatString(msg, args); - va_end(args); - return tmp; -} - -void ColorPrintf(std::ostream& out, LogColor color, const char* fmt, ...) { - va_list args; - va_start(args, fmt); - ColorPrintf(out, color, fmt, args); - va_end(args); -} - -void ColorPrintf(std::ostream& out, LogColor color, const char* fmt, - va_list args) { -#ifdef BENCHMARK_OS_WINDOWS - ((void)out); // suppress unused warning - - const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE); - - // Gets the current text color. - CONSOLE_SCREEN_BUFFER_INFO buffer_info; - GetConsoleScreenBufferInfo(stdout_handle, &buffer_info); - const WORD old_color_attrs = buffer_info.wAttributes; - - // We need to flush the stream buffers into the console before each - // SetConsoleTextAttribute call lest it affect the text that is already - // printed but has not yet reached the console. - fflush(stdout); - SetConsoleTextAttribute(stdout_handle, - GetPlatformColorCode(color) | FOREGROUND_INTENSITY); - vprintf(fmt, args); - - fflush(stdout); - // Restores the text color. - SetConsoleTextAttribute(stdout_handle, old_color_attrs); -#else - const char* color_code = GetPlatformColorCode(color); - if (color_code) out << FormatString("\033[0;3%sm", color_code); - out << FormatString(fmt, args) << "\033[m"; -#endif -} - -bool IsColorTerminal() { -#if BENCHMARK_OS_WINDOWS - // On Windows the TERM variable is usually not set, but the - // console there does support colors. - return 0 != _isatty(_fileno(stdout)); -#else - // On non-Windows platforms, we rely on the TERM variable. This list of - // supported TERM values is copied from Google Test: - // . - const char* const SUPPORTED_TERM_VALUES[] = { - "xterm", "xterm-color", "xterm-256color", - "screen", "screen-256color", "tmux", - "tmux-256color", "rxvt-unicode", "rxvt-unicode-256color", - "linux", "cygwin", - }; - - const char* const term = getenv("TERM"); - - bool term_supports_color = false; - for (const char* candidate : SUPPORTED_TERM_VALUES) { - if (term && 0 == strcmp(term, candidate)) { - term_supports_color = true; - break; - } - } - - return 0 != isatty(fileno(stdout)) && term_supports_color; -#endif // BENCHMARK_OS_WINDOWS -} - -} // end namespace benchmark diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/colorprint.h b/external_imported/json/benchmarks/thirdparty/benchmark/src/colorprint.h deleted file mode 100755 index 9f6fab9b3..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/colorprint.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef BENCHMARK_COLORPRINT_H_ -#define BENCHMARK_COLORPRINT_H_ - -#include -#include -#include - -namespace benchmark { -enum LogColor { - COLOR_DEFAULT, - COLOR_RED, - COLOR_GREEN, - COLOR_YELLOW, - COLOR_BLUE, - COLOR_MAGENTA, - COLOR_CYAN, - COLOR_WHITE -}; - -std::string FormatString(const char* msg, va_list args); -std::string FormatString(const char* msg, ...); - -void ColorPrintf(std::ostream& out, LogColor color, const char* fmt, - va_list args); -void ColorPrintf(std::ostream& out, LogColor color, const char* fmt, ...); - -// Returns true if stdout appears to be a terminal that supports colored -// output, false otherwise. -bool IsColorTerminal(); - -} // end namespace benchmark - -#endif // BENCHMARK_COLORPRINT_H_ diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/commandlineflags.cc b/external_imported/json/benchmarks/thirdparty/benchmark/src/commandlineflags.cc deleted file mode 100755 index 2fc92517a..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/commandlineflags.cc +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "commandlineflags.h" - -#include -#include -#include -#include -#include - -namespace benchmark { -// Parses 'str' for a 32-bit signed integer. If successful, writes -// the result to *value and returns true; otherwise leaves *value -// unchanged and returns false. -bool ParseInt32(const std::string& src_text, const char* str, int32_t* value) { - // Parses the environment variable as a decimal integer. - char* end = nullptr; - const long long_value = strtol(str, &end, 10); // NOLINT - - // Has strtol() consumed all characters in the string? - if (*end != '\0') { - // No - an invalid character was encountered. - std::cerr << src_text << " is expected to be a 32-bit integer, " - << "but actually has value \"" << str << "\".\n"; - return false; - } - - // Is the parsed value in the range of an Int32? - const int32_t result = static_cast(long_value); - if (long_value == std::numeric_limits::max() || - long_value == std::numeric_limits::min() || - // The parsed value overflows as a long. (strtol() returns - // LONG_MAX or LONG_MIN when the input overflows.) - result != long_value - // The parsed value overflows as an Int32. - ) { - std::cerr << src_text << " is expected to be a 32-bit integer, " - << "but actually has value \"" << str << "\", " - << "which overflows.\n"; - return false; - } - - *value = result; - return true; -} - -// Parses 'str' for a double. If successful, writes the result to *value and -// returns true; otherwise leaves *value unchanged and returns false. -bool ParseDouble(const std::string& src_text, const char* str, double* value) { - // Parses the environment variable as a decimal integer. - char* end = nullptr; - const double double_value = strtod(str, &end); // NOLINT - - // Has strtol() consumed all characters in the string? - if (*end != '\0') { - // No - an invalid character was encountered. - std::cerr << src_text << " is expected to be a double, " - << "but actually has value \"" << str << "\".\n"; - return false; - } - - *value = double_value; - return true; -} - -// Returns the name of the environment variable corresponding to the -// given flag. For example, FlagToEnvVar("foo") will return -// "BENCHMARK_FOO" in the open-source version. -static std::string FlagToEnvVar(const char* flag) { - const std::string flag_str(flag); - - std::string env_var; - for (size_t i = 0; i != flag_str.length(); ++i) - env_var += static_cast(::toupper(flag_str.c_str()[i])); - - return "BENCHMARK_" + env_var; -} - -// Reads and returns the Boolean environment variable corresponding to -// the given flag; if it's not set, returns default_value. -// -// The value is considered true iff it's not "0". -bool BoolFromEnv(const char* flag, bool default_value) { - const std::string env_var = FlagToEnvVar(flag); - const char* const string_value = getenv(env_var.c_str()); - return string_value == nullptr ? default_value - : strcmp(string_value, "0") != 0; -} - -// Reads and returns a 32-bit integer stored in the environment -// variable corresponding to the given flag; if it isn't set or -// doesn't represent a valid 32-bit integer, returns default_value. -int32_t Int32FromEnv(const char* flag, int32_t default_value) { - const std::string env_var = FlagToEnvVar(flag); - const char* const string_value = getenv(env_var.c_str()); - if (string_value == nullptr) { - // The environment variable is not set. - return default_value; - } - - int32_t result = default_value; - if (!ParseInt32(std::string("Environment variable ") + env_var, string_value, - &result)) { - std::cout << "The default value " << default_value << " is used.\n"; - return default_value; - } - - return result; -} - -// Reads and returns the string environment variable corresponding to -// the given flag; if it's not set, returns default_value. -const char* StringFromEnv(const char* flag, const char* default_value) { - const std::string env_var = FlagToEnvVar(flag); - const char* const value = getenv(env_var.c_str()); - return value == nullptr ? default_value : value; -} - -// Parses a string as a command line flag. The string should have -// the format "--flag=value". When def_optional is true, the "=value" -// part can be omitted. -// -// Returns the value of the flag, or nullptr if the parsing failed. -const char* ParseFlagValue(const char* str, const char* flag, - bool def_optional) { - // str and flag must not be nullptr. - if (str == nullptr || flag == nullptr) return nullptr; - - // The flag must start with "--". - const std::string flag_str = std::string("--") + std::string(flag); - const size_t flag_len = flag_str.length(); - if (strncmp(str, flag_str.c_str(), flag_len) != 0) return nullptr; - - // Skips the flag name. - const char* flag_end = str + flag_len; - - // When def_optional is true, it's OK to not have a "=value" part. - if (def_optional && (flag_end[0] == '\0')) return flag_end; - - // If def_optional is true and there are more characters after the - // flag name, or if def_optional is false, there must be a '=' after - // the flag name. - if (flag_end[0] != '=') return nullptr; - - // Returns the string after "=". - return flag_end + 1; -} - -bool ParseBoolFlag(const char* str, const char* flag, bool* value) { - // Gets the value of the flag as a string. - const char* const value_str = ParseFlagValue(str, flag, true); - - // Aborts if the parsing failed. - if (value_str == nullptr) return false; - - // Converts the string value to a bool. - *value = IsTruthyFlagValue(value_str); - return true; -} - -bool ParseInt32Flag(const char* str, const char* flag, int32_t* value) { - // Gets the value of the flag as a string. - const char* const value_str = ParseFlagValue(str, flag, false); - - // Aborts if the parsing failed. - if (value_str == nullptr) return false; - - // Sets *value to the value of the flag. - return ParseInt32(std::string("The value of flag --") + flag, value_str, - value); -} - -bool ParseDoubleFlag(const char* str, const char* flag, double* value) { - // Gets the value of the flag as a string. - const char* const value_str = ParseFlagValue(str, flag, false); - - // Aborts if the parsing failed. - if (value_str == nullptr) return false; - - // Sets *value to the value of the flag. - return ParseDouble(std::string("The value of flag --") + flag, value_str, - value); -} - -bool ParseStringFlag(const char* str, const char* flag, std::string* value) { - // Gets the value of the flag as a string. - const char* const value_str = ParseFlagValue(str, flag, false); - - // Aborts if the parsing failed. - if (value_str == nullptr) return false; - - *value = value_str; - return true; -} - -bool IsFlag(const char* str, const char* flag) { - return (ParseFlagValue(str, flag, true) != nullptr); -} - -bool IsTruthyFlagValue(const std::string& value) { - if (value.empty()) return true; - char ch = value[0]; - return isalnum(ch) && - !(ch == '0' || ch == 'f' || ch == 'F' || ch == 'n' || ch == 'N'); -} -} // end namespace benchmark diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/commandlineflags.h b/external_imported/json/benchmarks/thirdparty/benchmark/src/commandlineflags.h deleted file mode 100755 index 945c9a9fc..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/commandlineflags.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef BENCHMARK_COMMANDLINEFLAGS_H_ -#define BENCHMARK_COMMANDLINEFLAGS_H_ - -#include -#include - -// Macro for referencing flags. -#define FLAG(name) FLAGS_##name - -// Macros for declaring flags. -#define DECLARE_bool(name) extern bool FLAG(name) -#define DECLARE_int32(name) extern int32_t FLAG(name) -#define DECLARE_int64(name) extern int64_t FLAG(name) -#define DECLARE_double(name) extern double FLAG(name) -#define DECLARE_string(name) extern std::string FLAG(name) - -// Macros for defining flags. -#define DEFINE_bool(name, default_val, doc) bool FLAG(name) = (default_val) -#define DEFINE_int32(name, default_val, doc) int32_t FLAG(name) = (default_val) -#define DEFINE_int64(name, default_val, doc) int64_t FLAG(name) = (default_val) -#define DEFINE_double(name, default_val, doc) double FLAG(name) = (default_val) -#define DEFINE_string(name, default_val, doc) \ - std::string FLAG(name) = (default_val) - -namespace benchmark { -// Parses 'str' for a 32-bit signed integer. If successful, writes the result -// to *value and returns true; otherwise leaves *value unchanged and returns -// false. -bool ParseInt32(const std::string& src_text, const char* str, int32_t* value); - -// Parses a bool/Int32/string from the environment variable -// corresponding to the given Google Test flag. -bool BoolFromEnv(const char* flag, bool default_val); -int32_t Int32FromEnv(const char* flag, int32_t default_val); -double DoubleFromEnv(const char* flag, double default_val); -const char* StringFromEnv(const char* flag, const char* default_val); - -// Parses a string for a bool flag, in the form of either -// "--flag=value" or "--flag". -// -// In the former case, the value is taken as true if it passes IsTruthyValue(). -// -// In the latter case, the value is taken as true. -// -// On success, stores the value of the flag in *value, and returns -// true. On failure, returns false without changing *value. -bool ParseBoolFlag(const char* str, const char* flag, bool* value); - -// Parses a string for an Int32 flag, in the form of -// "--flag=value". -// -// On success, stores the value of the flag in *value, and returns -// true. On failure, returns false without changing *value. -bool ParseInt32Flag(const char* str, const char* flag, int32_t* value); - -// Parses a string for a Double flag, in the form of -// "--flag=value". -// -// On success, stores the value of the flag in *value, and returns -// true. On failure, returns false without changing *value. -bool ParseDoubleFlag(const char* str, const char* flag, double* value); - -// Parses a string for a string flag, in the form of -// "--flag=value". -// -// On success, stores the value of the flag in *value, and returns -// true. On failure, returns false without changing *value. -bool ParseStringFlag(const char* str, const char* flag, std::string* value); - -// Returns true if the string matches the flag. -bool IsFlag(const char* str, const char* flag); - -// Returns true unless value starts with one of: '0', 'f', 'F', 'n' or 'N', or -// some non-alphanumeric character. As a special case, also returns true if -// value is the empty string. -bool IsTruthyFlagValue(const std::string& value); -} // end namespace benchmark - -#endif // BENCHMARK_COMMANDLINEFLAGS_H_ diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/complexity.cc b/external_imported/json/benchmarks/thirdparty/benchmark/src/complexity.cc deleted file mode 100755 index 97bf6e09b..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/complexity.cc +++ /dev/null @@ -1,220 +0,0 @@ -// Copyright 2016 Ismael Jimenez Martinez. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Source project : https://github.com/ismaelJimenez/cpp.leastsq -// Adapted to be used with google benchmark - -#include "benchmark/benchmark.h" - -#include -#include -#include "check.h" -#include "complexity.h" - -namespace benchmark { - -// Internal function to calculate the different scalability forms -BigOFunc* FittingCurve(BigO complexity) { - switch (complexity) { - case oN: - return [](int64_t n) -> double { return static_cast(n); }; - case oNSquared: - return [](int64_t n) -> double { return std::pow(n, 2); }; - case oNCubed: - return [](int64_t n) -> double { return std::pow(n, 3); }; - case oLogN: - return [](int64_t n) { return log2(n); }; - case oNLogN: - return [](int64_t n) { return n * log2(n); }; - case o1: - default: - return [](int64_t) { return 1.0; }; - } -} - -// Function to return an string for the calculated complexity -std::string GetBigOString(BigO complexity) { - switch (complexity) { - case oN: - return "N"; - case oNSquared: - return "N^2"; - case oNCubed: - return "N^3"; - case oLogN: - return "lgN"; - case oNLogN: - return "NlgN"; - case o1: - return "(1)"; - default: - return "f(N)"; - } -} - -// Find the coefficient for the high-order term in the running time, by -// minimizing the sum of squares of relative error, for the fitting curve -// given by the lambda expression. -// - n : Vector containing the size of the benchmark tests. -// - time : Vector containing the times for the benchmark tests. -// - fitting_curve : lambda expression (e.g. [](int64_t n) {return n; };). - -// For a deeper explanation on the algorithm logic, look the README file at -// http://github.com/ismaelJimenez/Minimal-Cpp-Least-Squared-Fit - -LeastSq MinimalLeastSq(const std::vector& n, - const std::vector& time, - BigOFunc* fitting_curve) { - double sigma_gn = 0.0; - double sigma_gn_squared = 0.0; - double sigma_time = 0.0; - double sigma_time_gn = 0.0; - - // Calculate least square fitting parameter - for (size_t i = 0; i < n.size(); ++i) { - double gn_i = fitting_curve(n[i]); - sigma_gn += gn_i; - sigma_gn_squared += gn_i * gn_i; - sigma_time += time[i]; - sigma_time_gn += time[i] * gn_i; - } - - LeastSq result; - result.complexity = oLambda; - - // Calculate complexity. - result.coef = sigma_time_gn / sigma_gn_squared; - - // Calculate RMS - double rms = 0.0; - for (size_t i = 0; i < n.size(); ++i) { - double fit = result.coef * fitting_curve(n[i]); - rms += pow((time[i] - fit), 2); - } - - // Normalized RMS by the mean of the observed values - double mean = sigma_time / n.size(); - result.rms = sqrt(rms / n.size()) / mean; - - return result; -} - -// Find the coefficient for the high-order term in the running time, by -// minimizing the sum of squares of relative error. -// - n : Vector containing the size of the benchmark tests. -// - time : Vector containing the times for the benchmark tests. -// - complexity : If different than oAuto, the fitting curve will stick to -// this one. If it is oAuto, it will be calculated the best -// fitting curve. -LeastSq MinimalLeastSq(const std::vector& n, - const std::vector& time, const BigO complexity) { - CHECK_EQ(n.size(), time.size()); - CHECK_GE(n.size(), 2); // Do not compute fitting curve is less than two - // benchmark runs are given - CHECK_NE(complexity, oNone); - - LeastSq best_fit; - - if (complexity == oAuto) { - std::vector fit_curves = {oLogN, oN, oNLogN, oNSquared, oNCubed}; - - // Take o1 as default best fitting curve - best_fit = MinimalLeastSq(n, time, FittingCurve(o1)); - best_fit.complexity = o1; - - // Compute all possible fitting curves and stick to the best one - for (const auto& fit : fit_curves) { - LeastSq current_fit = MinimalLeastSq(n, time, FittingCurve(fit)); - if (current_fit.rms < best_fit.rms) { - best_fit = current_fit; - best_fit.complexity = fit; - } - } - } else { - best_fit = MinimalLeastSq(n, time, FittingCurve(complexity)); - best_fit.complexity = complexity; - } - - return best_fit; -} - -std::vector ComputeBigO( - const std::vector& reports) { - typedef BenchmarkReporter::Run Run; - std::vector results; - - if (reports.size() < 2) return results; - - // Accumulators. - std::vector n; - std::vector real_time; - std::vector cpu_time; - - // Populate the accumulators. - for (const Run& run : reports) { - CHECK_GT(run.complexity_n, 0) << "Did you forget to call SetComplexityN?"; - n.push_back(run.complexity_n); - real_time.push_back(run.real_accumulated_time / run.iterations); - cpu_time.push_back(run.cpu_accumulated_time / run.iterations); - } - - LeastSq result_cpu; - LeastSq result_real; - - if (reports[0].complexity == oLambda) { - result_cpu = MinimalLeastSq(n, cpu_time, reports[0].complexity_lambda); - result_real = MinimalLeastSq(n, real_time, reports[0].complexity_lambda); - } else { - result_cpu = MinimalLeastSq(n, cpu_time, reports[0].complexity); - result_real = MinimalLeastSq(n, real_time, result_cpu.complexity); - } - std::string benchmark_name = - reports[0].benchmark_name.substr(0, reports[0].benchmark_name.find('/')); - - // Get the data from the accumulator to BenchmarkReporter::Run's. - Run big_o; - big_o.benchmark_name = benchmark_name + "_BigO"; - big_o.iterations = 0; - big_o.real_accumulated_time = result_real.coef; - big_o.cpu_accumulated_time = result_cpu.coef; - big_o.report_big_o = true; - big_o.complexity = result_cpu.complexity; - - // All the time results are reported after being multiplied by the - // time unit multiplier. But since RMS is a relative quantity it - // should not be multiplied at all. So, here, we _divide_ it by the - // multiplier so that when it is multiplied later the result is the - // correct one. - double multiplier = GetTimeUnitMultiplier(reports[0].time_unit); - - // Only add label to mean/stddev if it is same for all runs - Run rms; - big_o.report_label = reports[0].report_label; - rms.benchmark_name = benchmark_name + "_RMS"; - rms.report_label = big_o.report_label; - rms.iterations = 0; - rms.real_accumulated_time = result_real.rms / multiplier; - rms.cpu_accumulated_time = result_cpu.rms / multiplier; - rms.report_rms = true; - rms.complexity = result_cpu.complexity; - // don't forget to keep the time unit, or we won't be able to - // recover the correct value. - rms.time_unit = reports[0].time_unit; - - results.push_back(big_o); - results.push_back(rms); - return results; -} - -} // end namespace benchmark diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/complexity.h b/external_imported/json/benchmarks/thirdparty/benchmark/src/complexity.h deleted file mode 100755 index df29b48d2..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/complexity.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2016 Ismael Jimenez Martinez. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Source project : https://github.com/ismaelJimenez/cpp.leastsq -// Adapted to be used with google benchmark - -#ifndef COMPLEXITY_H_ -#define COMPLEXITY_H_ - -#include -#include - -#include "benchmark/benchmark.h" - -namespace benchmark { - -// Return a vector containing the bigO and RMS information for the specified -// list of reports. If 'reports.size() < 2' an empty vector is returned. -std::vector ComputeBigO( - const std::vector& reports); - -// This data structure will contain the result returned by MinimalLeastSq -// - coef : Estimated coeficient for the high-order term as -// interpolated from data. -// - rms : Normalized Root Mean Squared Error. -// - complexity : Scalability form (e.g. oN, oNLogN). In case a scalability -// form has been provided to MinimalLeastSq this will return -// the same value. In case BigO::oAuto has been selected, this -// parameter will return the best fitting curve detected. - -struct LeastSq { - LeastSq() : coef(0.0), rms(0.0), complexity(oNone) {} - - double coef; - double rms; - BigO complexity; -}; - -// Function to return an string for the calculated complexity -std::string GetBigOString(BigO complexity); - -} // end namespace benchmark - -#endif // COMPLEXITY_H_ diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/console_reporter.cc b/external_imported/json/benchmarks/thirdparty/benchmark/src/console_reporter.cc deleted file mode 100755 index 48920ca78..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/console_reporter.cc +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "benchmark/benchmark.h" -#include "complexity.h" -#include "counter.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "check.h" -#include "colorprint.h" -#include "commandlineflags.h" -#include "internal_macros.h" -#include "string_util.h" -#include "timers.h" - -namespace benchmark { - -bool ConsoleReporter::ReportContext(const Context& context) { - name_field_width_ = context.name_field_width; - printed_header_ = false; - prev_counters_.clear(); - - PrintBasicContext(&GetErrorStream(), context); - -#ifdef BENCHMARK_OS_WINDOWS - if ((output_options_ & OO_Color) && &std::cout != &GetOutputStream()) { - GetErrorStream() - << "Color printing is only supported for stdout on windows." - " Disabling color printing\n"; - output_options_ = static_cast< OutputOptions >(output_options_ & ~OO_Color); - } -#endif - - return true; -} - -void ConsoleReporter::PrintHeader(const Run& run) { - std::string str = FormatString("%-*s %13s %13s %10s", static_cast(name_field_width_), - "Benchmark", "Time", "CPU", "Iterations"); - if(!run.counters.empty()) { - if(output_options_ & OO_Tabular) { - for(auto const& c : run.counters) { - str += FormatString(" %10s", c.first.c_str()); - } - } else { - str += " UserCounters..."; - } - } - str += "\n"; - std::string line = std::string(str.length(), '-'); - GetOutputStream() << line << "\n" << str << line << "\n"; -} - -void ConsoleReporter::ReportRuns(const std::vector& reports) { - for (const auto& run : reports) { - // print the header: - // --- if none was printed yet - bool print_header = !printed_header_; - // --- or if the format is tabular and this run - // has different fields from the prev header - print_header |= (output_options_ & OO_Tabular) && - (!internal::SameNames(run.counters, prev_counters_)); - if (print_header) { - printed_header_ = true; - prev_counters_ = run.counters; - PrintHeader(run); - } - // As an alternative to printing the headers like this, we could sort - // the benchmarks by header and then print. But this would require - // waiting for the full results before printing, or printing twice. - PrintRunData(run); - } -} - -static void IgnoreColorPrint(std::ostream& out, LogColor, const char* fmt, - ...) { - va_list args; - va_start(args, fmt); - out << FormatString(fmt, args); - va_end(args); -} - -void ConsoleReporter::PrintRunData(const Run& result) { - typedef void(PrinterFn)(std::ostream&, LogColor, const char*, ...); - auto& Out = GetOutputStream(); - PrinterFn* printer = (output_options_ & OO_Color) ? - (PrinterFn*)ColorPrintf : IgnoreColorPrint; - auto name_color = - (result.report_big_o || result.report_rms) ? COLOR_BLUE : COLOR_GREEN; - printer(Out, name_color, "%-*s ", name_field_width_, - result.benchmark_name.c_str()); - - if (result.error_occurred) { - printer(Out, COLOR_RED, "ERROR OCCURRED: \'%s\'", - result.error_message.c_str()); - printer(Out, COLOR_DEFAULT, "\n"); - return; - } - // Format bytes per second - std::string rate; - if (result.bytes_per_second > 0) { - rate = StrCat(" ", HumanReadableNumber(result.bytes_per_second), "B/s"); - } - - // Format items per second - std::string items; - if (result.items_per_second > 0) { - items = - StrCat(" ", HumanReadableNumber(result.items_per_second), " items/s"); - } - - const double real_time = result.GetAdjustedRealTime(); - const double cpu_time = result.GetAdjustedCPUTime(); - - if (result.report_big_o) { - std::string big_o = GetBigOString(result.complexity); - printer(Out, COLOR_YELLOW, "%10.2f %s %10.2f %s ", real_time, big_o.c_str(), - cpu_time, big_o.c_str()); - } else if (result.report_rms) { - printer(Out, COLOR_YELLOW, "%10.0f %% %10.0f %% ", real_time * 100, - cpu_time * 100); - } else { - const char* timeLabel = GetTimeUnitString(result.time_unit); - printer(Out, COLOR_YELLOW, "%10.0f %s %10.0f %s ", real_time, timeLabel, - cpu_time, timeLabel); - } - - if (!result.report_big_o && !result.report_rms) { - printer(Out, COLOR_CYAN, "%10lld", result.iterations); - } - - for (auto& c : result.counters) { - const std::size_t cNameLen = std::max(std::string::size_type(10), - c.first.length()); - auto const& s = HumanReadableNumber(c.second.value, 1000); - if (output_options_ & OO_Tabular) { - if (c.second.flags & Counter::kIsRate) { - printer(Out, COLOR_DEFAULT, " %*s/s", cNameLen - 2, s.c_str()); - } else { - printer(Out, COLOR_DEFAULT, " %*s", cNameLen, s.c_str()); - } - } else { - const char* unit = (c.second.flags & Counter::kIsRate) ? "/s" : ""; - printer(Out, COLOR_DEFAULT, " %s=%s%s", c.first.c_str(), s.c_str(), - unit); - } - } - - if (!rate.empty()) { - printer(Out, COLOR_DEFAULT, " %*s", 13, rate.c_str()); - } - - if (!items.empty()) { - printer(Out, COLOR_DEFAULT, " %*s", 18, items.c_str()); - } - - if (!result.report_label.empty()) { - printer(Out, COLOR_DEFAULT, " %s", result.report_label.c_str()); - } - - printer(Out, COLOR_DEFAULT, "\n"); -} - -} // end namespace benchmark diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/counter.cc b/external_imported/json/benchmarks/thirdparty/benchmark/src/counter.cc deleted file mode 100755 index ed1aa044e..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/counter.cc +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "counter.h" - -namespace benchmark { -namespace internal { - -double Finish(Counter const& c, double cpu_time, double num_threads) { - double v = c.value; - if (c.flags & Counter::kIsRate) { - v /= cpu_time; - } - if (c.flags & Counter::kAvgThreads) { - v /= num_threads; - } - return v; -} - -void Finish(UserCounters *l, double cpu_time, double num_threads) { - for (auto &c : *l) { - c.second.value = Finish(c.second, cpu_time, num_threads); - } -} - -void Increment(UserCounters *l, UserCounters const& r) { - // add counters present in both or just in *l - for (auto &c : *l) { - auto it = r.find(c.first); - if (it != r.end()) { - c.second.value = c.second + it->second; - } - } - // add counters present in r, but not in *l - for (auto const &tc : r) { - auto it = l->find(tc.first); - if (it == l->end()) { - (*l)[tc.first] = tc.second; - } - } -} - -bool SameNames(UserCounters const& l, UserCounters const& r) { - if (&l == &r) return true; - if (l.size() != r.size()) { - return false; - } - for (auto const& c : l) { - if (r.find(c.first) == r.end()) { - return false; - } - } - return true; -} - -} // end namespace internal -} // end namespace benchmark diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/counter.h b/external_imported/json/benchmarks/thirdparty/benchmark/src/counter.h deleted file mode 100755 index dd6865a31..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/counter.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "benchmark/benchmark.h" - -namespace benchmark { - -// these counter-related functions are hidden to reduce API surface. -namespace internal { -void Finish(UserCounters *l, double time, double num_threads); -void Increment(UserCounters *l, UserCounters const& r); -bool SameNames(UserCounters const& l, UserCounters const& r); -} // end namespace internal - -} //end namespace benchmark diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/csv_reporter.cc b/external_imported/json/benchmarks/thirdparty/benchmark/src/csv_reporter.cc deleted file mode 100755 index 35510645b..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/csv_reporter.cc +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "benchmark/benchmark.h" -#include "complexity.h" - -#include -#include -#include -#include -#include -#include - -#include "string_util.h" -#include "timers.h" -#include "check.h" - -// File format reference: http://edoceo.com/utilitas/csv-file-format. - -namespace benchmark { - -namespace { -std::vector elements = { - "name", "iterations", "real_time", "cpu_time", - "time_unit", "bytes_per_second", "items_per_second", "label", - "error_occurred", "error_message"}; -} // namespace - -bool CSVReporter::ReportContext(const Context& context) { - PrintBasicContext(&GetErrorStream(), context); - return true; -} - -void CSVReporter::ReportRuns(const std::vector & reports) { - std::ostream& Out = GetOutputStream(); - - if (!printed_header_) { - // save the names of all the user counters - for (const auto& run : reports) { - for (const auto& cnt : run.counters) { - user_counter_names_.insert(cnt.first); - } - } - - // print the header - for (auto B = elements.begin(); B != elements.end();) { - Out << *B++; - if (B != elements.end()) Out << ","; - } - for (auto B = user_counter_names_.begin(); B != user_counter_names_.end();) { - Out << ",\"" << *B++ << "\""; - } - Out << "\n"; - - printed_header_ = true; - } else { - // check that all the current counters are saved in the name set - for (const auto& run : reports) { - for (const auto& cnt : run.counters) { - CHECK(user_counter_names_.find(cnt.first) != user_counter_names_.end()) - << "All counters must be present in each run. " - << "Counter named \"" << cnt.first - << "\" was not in a run after being added to the header"; - } - } - } - - // print results for each run - for (const auto& run : reports) { - PrintRunData(run); - } - -} - -void CSVReporter::PrintRunData(const Run & run) { - std::ostream& Out = GetOutputStream(); - - // Field with embedded double-quote characters must be doubled and the field - // delimited with double-quotes. - std::string name = run.benchmark_name; - ReplaceAll(&name, "\"", "\"\""); - Out << '"' << name << "\","; - if (run.error_occurred) { - Out << std::string(elements.size() - 3, ','); - Out << "true,"; - std::string msg = run.error_message; - ReplaceAll(&msg, "\"", "\"\""); - Out << '"' << msg << "\"\n"; - return; - } - - // Do not print iteration on bigO and RMS report - if (!run.report_big_o && !run.report_rms) { - Out << run.iterations; - } - Out << ","; - - Out << run.GetAdjustedRealTime() << ","; - Out << run.GetAdjustedCPUTime() << ","; - - // Do not print timeLabel on bigO and RMS report - if (run.report_big_o) { - Out << GetBigOString(run.complexity); - } else if (!run.report_rms) { - Out << GetTimeUnitString(run.time_unit); - } - Out << ","; - - if (run.bytes_per_second > 0.0) { - Out << run.bytes_per_second; - } - Out << ","; - if (run.items_per_second > 0.0) { - Out << run.items_per_second; - } - Out << ","; - if (!run.report_label.empty()) { - // Field with embedded double-quote characters must be doubled and the field - // delimited with double-quotes. - std::string label = run.report_label; - ReplaceAll(&label, "\"", "\"\""); - Out << "\"" << label << "\""; - } - Out << ",,"; // for error_occurred and error_message - - // Print user counters - for (const auto &ucn : user_counter_names_) { - auto it = run.counters.find(ucn); - if(it == run.counters.end()) { - Out << ","; - } else { - Out << "," << it->second; - } - } - Out << '\n'; -} - -} // end namespace benchmark diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/cycleclock.h b/external_imported/json/benchmarks/thirdparty/benchmark/src/cycleclock.h deleted file mode 100755 index 3b376ac57..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/cycleclock.h +++ /dev/null @@ -1,177 +0,0 @@ -// ---------------------------------------------------------------------- -// CycleClock -// A CycleClock tells you the current time in Cycles. The "time" -// is actually time since power-on. This is like time() but doesn't -// involve a system call and is much more precise. -// -// NOTE: Not all cpu/platform/kernel combinations guarantee that this -// clock increments at a constant rate or is synchronized across all logical -// cpus in a system. -// -// If you need the above guarantees, please consider using a different -// API. There are efforts to provide an interface which provides a millisecond -// granularity and implemented as a memory read. A memory read is generally -// cheaper than the CycleClock for many architectures. -// -// Also, in some out of order CPU implementations, the CycleClock is not -// serializing. So if you're trying to count at cycles granularity, your -// data might be inaccurate due to out of order instruction execution. -// ---------------------------------------------------------------------- - -#ifndef BENCHMARK_CYCLECLOCK_H_ -#define BENCHMARK_CYCLECLOCK_H_ - -#include - -#include "benchmark/benchmark.h" -#include "internal_macros.h" - -#if defined(BENCHMARK_OS_MACOSX) -#include -#endif -// For MSVC, we want to use '_asm rdtsc' when possible (since it works -// with even ancient MSVC compilers), and when not possible the -// __rdtsc intrinsic, declared in . Unfortunately, in some -// environments, and have conflicting -// declarations of some other intrinsics, breaking compilation. -// Therefore, we simply declare __rdtsc ourselves. See also -// http://connect.microsoft.com/VisualStudio/feedback/details/262047 -#if defined(COMPILER_MSVC) && !defined(_M_IX86) -extern "C" uint64_t __rdtsc(); -#pragma intrinsic(__rdtsc) -#endif - -#ifndef BENCHMARK_OS_WINDOWS -#include -#include -#endif - -#ifdef BENCHMARK_OS_EMSCRIPTEN -#include -#endif - -namespace benchmark { -// NOTE: only i386 and x86_64 have been well tested. -// PPC, sparc, alpha, and ia64 are based on -// http://peter.kuscsik.com/wordpress/?p=14 -// with modifications by m3b. See also -// https://setisvn.ssl.berkeley.edu/svn/lib/fftw-3.0.1/kernel/cycle.h -namespace cycleclock { -// This should return the number of cycles since power-on. Thread-safe. -inline BENCHMARK_ALWAYS_INLINE int64_t Now() { -#if defined(BENCHMARK_OS_MACOSX) - // this goes at the top because we need ALL Macs, regardless of - // architecture, to return the number of "mach time units" that - // have passed since startup. See sysinfo.cc where - // InitializeSystemInfo() sets the supposed cpu clock frequency of - // macs to the number of mach time units per second, not actual - // CPU clock frequency (which can change in the face of CPU - // frequency scaling). Also note that when the Mac sleeps, this - // counter pauses; it does not continue counting, nor does it - // reset to zero. - return mach_absolute_time(); -#elif defined(BENCHMARK_OS_EMSCRIPTEN) - // this goes above x86-specific code because old versions of Emscripten - // define __x86_64__, although they have nothing to do with it. - return static_cast(emscripten_get_now() * 1e+6); -#elif defined(__i386__) - int64_t ret; - __asm__ volatile("rdtsc" : "=A"(ret)); - return ret; -#elif defined(__x86_64__) || defined(__amd64__) - uint64_t low, high; - __asm__ volatile("rdtsc" : "=a"(low), "=d"(high)); - return (high << 32) | low; -#elif defined(__powerpc__) || defined(__ppc__) - // This returns a time-base, which is not always precisely a cycle-count. - int64_t tbl, tbu0, tbu1; - asm("mftbu %0" : "=r"(tbu0)); - asm("mftb %0" : "=r"(tbl)); - asm("mftbu %0" : "=r"(tbu1)); - tbl &= -static_cast(tbu0 == tbu1); - // high 32 bits in tbu1; low 32 bits in tbl (tbu0 is garbage) - return (tbu1 << 32) | tbl; -#elif defined(__sparc__) - int64_t tick; - asm(".byte 0x83, 0x41, 0x00, 0x00"); - asm("mov %%g1, %0" : "=r"(tick)); - return tick; -#elif defined(__ia64__) - int64_t itc; - asm("mov %0 = ar.itc" : "=r"(itc)); - return itc; -#elif defined(COMPILER_MSVC) && defined(_M_IX86) - // Older MSVC compilers (like 7.x) don't seem to support the - // __rdtsc intrinsic properly, so I prefer to use _asm instead - // when I know it will work. Otherwise, I'll use __rdtsc and hope - // the code is being compiled with a non-ancient compiler. - _asm rdtsc -#elif defined(COMPILER_MSVC) - return __rdtsc(); -#elif defined(BENCHMARK_OS_NACL) - // Native Client validator on x86/x86-64 allows RDTSC instructions, - // and this case is handled above. Native Client validator on ARM - // rejects MRC instructions (used in the ARM-specific sequence below), - // so we handle it here. Portable Native Client compiles to - // architecture-agnostic bytecode, which doesn't provide any - // cycle counter access mnemonics. - - // Native Client does not provide any API to access cycle counter. - // Use clock_gettime(CLOCK_MONOTONIC, ...) instead of gettimeofday - // because is provides nanosecond resolution (which is noticable at - // least for PNaCl modules running on x86 Mac & Linux). - // Initialize to always return 0 if clock_gettime fails. - struct timespec ts = { 0, 0 }; - clock_gettime(CLOCK_MONOTONIC, &ts); - return static_cast(ts.tv_sec) * 1000000000 + ts.tv_nsec; -#elif defined(__aarch64__) - // System timer of ARMv8 runs at a different frequency than the CPU's. - // The frequency is fixed, typically in the range 1-50MHz. It can be - // read at CNTFRQ special register. We assume the OS has set up - // the virtual timer properly. - int64_t virtual_timer_value; - asm volatile("mrs %0, cntvct_el0" : "=r"(virtual_timer_value)); - return virtual_timer_value; -#elif defined(__ARM_ARCH) - // V6 is the earliest arch that has a standard cyclecount - // Native Client validator doesn't allow MRC instructions. -#if (__ARM_ARCH >= 6) - uint32_t pmccntr; - uint32_t pmuseren; - uint32_t pmcntenset; - // Read the user mode perf monitor counter access permissions. - asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r"(pmuseren)); - if (pmuseren & 1) { // Allows reading perfmon counters for user mode code. - asm volatile("mrc p15, 0, %0, c9, c12, 1" : "=r"(pmcntenset)); - if (pmcntenset & 0x80000000ul) { // Is it counting? - asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(pmccntr)); - // The counter is set up to count every 64th cycle - return static_cast(pmccntr) * 64; // Should optimize to << 6 - } - } -#endif - struct timeval tv; - gettimeofday(&tv, nullptr); - return static_cast(tv.tv_sec) * 1000000 + tv.tv_usec; -#elif defined(__mips__) - // mips apparently only allows rdtsc for superusers, so we fall - // back to gettimeofday. It's possible clock_gettime would be better. - struct timeval tv; - gettimeofday(&tv, nullptr); - return static_cast(tv.tv_sec) * 1000000 + tv.tv_usec; -#elif defined(__s390__) // Covers both s390 and s390x. - // Return the CPU clock. - uint64_t tsc; - asm("stck %0" : "=Q" (tsc) : : "cc"); - return tsc; -#else -// The soft failover to a generic implementation is automatic only for ARM. -// For other platforms the developer is expected to make an attempt to create -// a fast implementation and use generic version if nothing better is available. -#error You need to define CycleTimer for your OS and CPU -#endif -} -} // end namespace cycleclock -} // end namespace benchmark - -#endif // BENCHMARK_CYCLECLOCK_H_ diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/internal_macros.h b/external_imported/json/benchmarks/thirdparty/benchmark/src/internal_macros.h deleted file mode 100755 index edb8a5c0a..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/internal_macros.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef BENCHMARK_INTERNAL_MACROS_H_ -#define BENCHMARK_INTERNAL_MACROS_H_ - -#include "benchmark/benchmark.h" - -#ifndef __has_feature -#define __has_feature(x) 0 -#endif -#ifndef __has_builtin -#define __has_builtin(x) 0 -#endif - -#if defined(__clang__) - #if !defined(COMPILER_CLANG) - #define COMPILER_CLANG - #endif -#elif defined(_MSC_VER) - #if !defined(COMPILER_MSVC) - #define COMPILER_MSVC - #endif -#elif defined(__GNUC__) - #if !defined(COMPILER_GCC) - #define COMPILER_GCC - #endif -#endif - -#if __has_feature(cxx_attributes) - #define BENCHMARK_NORETURN [[noreturn]] -#elif defined(__GNUC__) - #define BENCHMARK_NORETURN __attribute__((noreturn)) -#elif defined(COMPILER_MSVC) - #define BENCHMARK_NORETURN __declspec(noreturn) -#else - #define BENCHMARK_NORETURN -#endif - -#if defined(__CYGWIN__) - #define BENCHMARK_OS_CYGWIN 1 -#elif defined(_WIN32) - #define BENCHMARK_OS_WINDOWS 1 -#elif defined(__APPLE__) - #define BENCHMARK_OS_APPLE 1 - #include "TargetConditionals.h" - #if defined(TARGET_OS_MAC) - #define BENCHMARK_OS_MACOSX 1 - #if defined(TARGET_OS_IPHONE) - #define BENCHMARK_OS_IOS 1 - #endif - #endif -#elif defined(__FreeBSD__) - #define BENCHMARK_OS_FREEBSD 1 -#elif defined(__NetBSD__) - #define BENCHMARK_OS_NETBSD 1 -#elif defined(__OpenBSD__) - #define BENCHMARK_OS_OPENBSD 1 -#elif defined(__linux__) - #define BENCHMARK_OS_LINUX 1 -#elif defined(__native_client__) - #define BENCHMARK_OS_NACL 1 -#elif defined(__EMSCRIPTEN__) - #define BENCHMARK_OS_EMSCRIPTEN 1 -#elif defined(__rtems__) - #define BENCHMARK_OS_RTEMS 1 -#elif defined(__Fuchsia__) -#define BENCHMARK_OS_FUCHSIA 1 -#elif defined (__SVR4) && defined (__sun) -#define BENCHMARK_OS_SOLARIS 1 -#endif - -#if !__has_feature(cxx_exceptions) && !defined(__cpp_exceptions) \ - && !defined(__EXCEPTIONS) - #define BENCHMARK_HAS_NO_EXCEPTIONS -#endif - -#if defined(COMPILER_CLANG) || defined(COMPILER_GCC) - #define BENCHMARK_MAYBE_UNUSED __attribute__((unused)) -#else - #define BENCHMARK_MAYBE_UNUSED -#endif - -#if defined(COMPILER_GCC) || __has_builtin(__builtin_unreachable) - #define BENCHMARK_UNREACHABLE() __builtin_unreachable() -#elif defined(COMPILER_MSVC) - #define BENCHMARK_UNREACHABLE() __assume(false) -#else - #define BENCHMARK_UNREACHABLE() ((void)0) -#endif - -#endif // BENCHMARK_INTERNAL_MACROS_H_ diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/json_reporter.cc b/external_imported/json/benchmarks/thirdparty/benchmark/src/json_reporter.cc deleted file mode 100755 index 685d6b097..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/json_reporter.cc +++ /dev/null @@ -1,205 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "benchmark/benchmark.h" -#include "complexity.h" - -#include -#include -#include -#include -#include -#include -#include // for setprecision -#include - -#include "string_util.h" -#include "timers.h" - -namespace benchmark { - -namespace { - -std::string FormatKV(std::string const& key, std::string const& value) { - return StrFormat("\"%s\": \"%s\"", key.c_str(), value.c_str()); -} - -std::string FormatKV(std::string const& key, const char* value) { - return StrFormat("\"%s\": \"%s\"", key.c_str(), value); -} - -std::string FormatKV(std::string const& key, bool value) { - return StrFormat("\"%s\": %s", key.c_str(), value ? "true" : "false"); -} - -std::string FormatKV(std::string const& key, int64_t value) { - std::stringstream ss; - ss << '"' << key << "\": " << value; - return ss.str(); -} - -std::string FormatKV(std::string const& key, double value) { - std::stringstream ss; - ss << '"' << key << "\": "; - - const auto max_digits10 = std::numeric_limits::max_digits10; - const auto max_fractional_digits10 = max_digits10 - 1; - - ss << std::scientific << std::setprecision(max_fractional_digits10) << value; - return ss.str(); -} - -int64_t RoundDouble(double v) { return static_cast(v + 0.5); } - -} // end namespace - -bool JSONReporter::ReportContext(const Context& context) { - std::ostream& out = GetOutputStream(); - - out << "{\n"; - std::string inner_indent(2, ' '); - - // Open context block and print context information. - out << inner_indent << "\"context\": {\n"; - std::string indent(4, ' '); - - std::string walltime_value = LocalDateTimeString(); - out << indent << FormatKV("date", walltime_value) << ",\n"; - - if (Context::executable_name) { - out << indent << FormatKV("executable", Context::executable_name) << ",\n"; - } - - CPUInfo const& info = context.cpu_info; - out << indent << FormatKV("num_cpus", static_cast(info.num_cpus)) - << ",\n"; - out << indent - << FormatKV("mhz_per_cpu", - RoundDouble(info.cycles_per_second / 1000000.0)) - << ",\n"; - out << indent << FormatKV("cpu_scaling_enabled", info.scaling_enabled) - << ",\n"; - - out << indent << "\"caches\": [\n"; - indent = std::string(6, ' '); - std::string cache_indent(8, ' '); - for (size_t i = 0; i < info.caches.size(); ++i) { - auto& CI = info.caches[i]; - out << indent << "{\n"; - out << cache_indent << FormatKV("type", CI.type) << ",\n"; - out << cache_indent << FormatKV("level", static_cast(CI.level)) - << ",\n"; - out << cache_indent - << FormatKV("size", static_cast(CI.size) * 1000u) << ",\n"; - out << cache_indent - << FormatKV("num_sharing", static_cast(CI.num_sharing)) - << "\n"; - out << indent << "}"; - if (i != info.caches.size() - 1) out << ","; - out << "\n"; - } - indent = std::string(4, ' '); - out << indent << "],\n"; - -#if defined(NDEBUG) - const char build_type[] = "release"; -#else - const char build_type[] = "debug"; -#endif - out << indent << FormatKV("library_build_type", build_type) << "\n"; - // Close context block and open the list of benchmarks. - out << inner_indent << "},\n"; - out << inner_indent << "\"benchmarks\": [\n"; - return true; -} - -void JSONReporter::ReportRuns(std::vector const& reports) { - if (reports.empty()) { - return; - } - std::string indent(4, ' '); - std::ostream& out = GetOutputStream(); - if (!first_report_) { - out << ",\n"; - } - first_report_ = false; - - for (auto it = reports.begin(); it != reports.end(); ++it) { - out << indent << "{\n"; - PrintRunData(*it); - out << indent << '}'; - auto it_cp = it; - if (++it_cp != reports.end()) { - out << ",\n"; - } - } -} - -void JSONReporter::Finalize() { - // Close the list of benchmarks and the top level object. - GetOutputStream() << "\n ]\n}\n"; -} - -void JSONReporter::PrintRunData(Run const& run) { - std::string indent(6, ' '); - std::ostream& out = GetOutputStream(); - out << indent << FormatKV("name", run.benchmark_name) << ",\n"; - if (run.error_occurred) { - out << indent << FormatKV("error_occurred", run.error_occurred) << ",\n"; - out << indent << FormatKV("error_message", run.error_message) << ",\n"; - } - if (!run.report_big_o && !run.report_rms) { - out << indent << FormatKV("iterations", run.iterations) << ",\n"; - out << indent - << FormatKV("real_time", run.GetAdjustedRealTime()) - << ",\n"; - out << indent - << FormatKV("cpu_time", run.GetAdjustedCPUTime()); - out << ",\n" - << indent << FormatKV("time_unit", GetTimeUnitString(run.time_unit)); - } else if (run.report_big_o) { - out << indent - << FormatKV("cpu_coefficient", run.GetAdjustedCPUTime()) - << ",\n"; - out << indent - << FormatKV("real_coefficient", run.GetAdjustedRealTime()) - << ",\n"; - out << indent << FormatKV("big_o", GetBigOString(run.complexity)) << ",\n"; - out << indent << FormatKV("time_unit", GetTimeUnitString(run.time_unit)); - } else if (run.report_rms) { - out << indent - << FormatKV("rms", run.GetAdjustedCPUTime()); - } - if (run.bytes_per_second > 0.0) { - out << ",\n" - << indent - << FormatKV("bytes_per_second", run.bytes_per_second); - } - if (run.items_per_second > 0.0) { - out << ",\n" - << indent - << FormatKV("items_per_second", run.items_per_second); - } - for(auto &c : run.counters) { - out << ",\n" - << indent - << FormatKV(c.first, c.second); - } - if (!run.report_label.empty()) { - out << ",\n" << indent << FormatKV("label", run.report_label); - } - out << '\n'; -} - -} // end namespace benchmark diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/log.h b/external_imported/json/benchmarks/thirdparty/benchmark/src/log.h deleted file mode 100755 index d06e1031d..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/log.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef BENCHMARK_LOG_H_ -#define BENCHMARK_LOG_H_ - -#include -#include - -#include "benchmark/benchmark.h" - -namespace benchmark { -namespace internal { - -typedef std::basic_ostream&(EndLType)(std::basic_ostream&); - -class LogType { - friend LogType& GetNullLogInstance(); - friend LogType& GetErrorLogInstance(); - - // FIXME: Add locking to output. - template - friend LogType& operator<<(LogType&, Tp const&); - friend LogType& operator<<(LogType&, EndLType*); - - private: - LogType(std::ostream* out) : out_(out) {} - std::ostream* out_; - BENCHMARK_DISALLOW_COPY_AND_ASSIGN(LogType); -}; - -template -LogType& operator<<(LogType& log, Tp const& value) { - if (log.out_) { - *log.out_ << value; - } - return log; -} - -inline LogType& operator<<(LogType& log, EndLType* m) { - if (log.out_) { - *log.out_ << m; - } - return log; -} - -inline int& LogLevel() { - static int log_level = 0; - return log_level; -} - -inline LogType& GetNullLogInstance() { - static LogType log(nullptr); - return log; -} - -inline LogType& GetErrorLogInstance() { - static LogType log(&std::clog); - return log; -} - -inline LogType& GetLogInstanceForLevel(int level) { - if (level <= LogLevel()) { - return GetErrorLogInstance(); - } - return GetNullLogInstance(); -} - -} // end namespace internal -} // end namespace benchmark - -#define VLOG(x) \ - (::benchmark::internal::GetLogInstanceForLevel(x) << "-- LOG(" << x << "):" \ - " ") - -#endif diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/mutex.h b/external_imported/json/benchmarks/thirdparty/benchmark/src/mutex.h deleted file mode 100755 index 5f461d05a..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/mutex.h +++ /dev/null @@ -1,155 +0,0 @@ -#ifndef BENCHMARK_MUTEX_H_ -#define BENCHMARK_MUTEX_H_ - -#include -#include - -#include "check.h" - -// Enable thread safety attributes only with clang. -// The attributes can be safely erased when compiling with other compilers. -#if defined(HAVE_THREAD_SAFETY_ATTRIBUTES) -#define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) -#else -#define THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op -#endif - -#define CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(capability(x)) - -#define SCOPED_CAPABILITY THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable) - -#define GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) - -#define PT_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x)) - -#define ACQUIRED_BEFORE(...) \ - THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__)) - -#define ACQUIRED_AFTER(...) \ - THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__)) - -#define REQUIRES(...) \ - THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__)) - -#define REQUIRES_SHARED(...) \ - THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__)) - -#define ACQUIRE(...) \ - THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__)) - -#define ACQUIRE_SHARED(...) \ - THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__)) - -#define RELEASE(...) \ - THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__)) - -#define RELEASE_SHARED(...) \ - THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__)) - -#define TRY_ACQUIRE(...) \ - THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__)) - -#define TRY_ACQUIRE_SHARED(...) \ - THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__)) - -#define EXCLUDES(...) THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__)) - -#define ASSERT_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x)) - -#define ASSERT_SHARED_CAPABILITY(x) \ - THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x)) - -#define RETURN_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x)) - -#define NO_THREAD_SAFETY_ANALYSIS \ - THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis) - -namespace benchmark { - -typedef std::condition_variable Condition; - -// NOTE: Wrappers for std::mutex and std::unique_lock are provided so that -// we can annotate them with thread safety attributes and use the -// -Wthread-safety warning with clang. The standard library types cannot be -// used directly because they do not provided the required annotations. -class CAPABILITY("mutex") Mutex { - public: - Mutex() {} - - void lock() ACQUIRE() { mut_.lock(); } - void unlock() RELEASE() { mut_.unlock(); } - std::mutex& native_handle() { return mut_; } - - private: - std::mutex mut_; -}; - -class SCOPED_CAPABILITY MutexLock { - typedef std::unique_lock MutexLockImp; - - public: - MutexLock(Mutex& m) ACQUIRE(m) : ml_(m.native_handle()) {} - ~MutexLock() RELEASE() {} - MutexLockImp& native_handle() { return ml_; } - - private: - MutexLockImp ml_; -}; - -class Barrier { - public: - Barrier(int num_threads) : running_threads_(num_threads) {} - - // Called by each thread - bool wait() EXCLUDES(lock_) { - bool last_thread = false; - { - MutexLock ml(lock_); - last_thread = createBarrier(ml); - } - if (last_thread) phase_condition_.notify_all(); - return last_thread; - } - - void removeThread() EXCLUDES(lock_) { - MutexLock ml(lock_); - --running_threads_; - if (entered_ != 0) phase_condition_.notify_all(); - } - - private: - Mutex lock_; - Condition phase_condition_; - int running_threads_; - - // State for barrier management - int phase_number_ = 0; - int entered_ = 0; // Number of threads that have entered this barrier - - // Enter the barrier and wait until all other threads have also - // entered the barrier. Returns iff this is the last thread to - // enter the barrier. - bool createBarrier(MutexLock& ml) REQUIRES(lock_) { - CHECK_LT(entered_, running_threads_); - entered_++; - if (entered_ < running_threads_) { - // Wait for all threads to enter - int phase_number_cp = phase_number_; - auto cb = [this, phase_number_cp]() { - return this->phase_number_ > phase_number_cp || - entered_ == running_threads_; // A thread has aborted in error - }; - phase_condition_.wait(ml.native_handle(), cb); - if (phase_number_ > phase_number_cp) return false; - // else (running_threads_ == entered_) and we are the last thread. - } - // Last thread has reached the barrier - phase_number_++; - entered_ = 0; - return true; - } -}; - -} // end namespace benchmark - -#endif // BENCHMARK_MUTEX_H_ diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/re.h b/external_imported/json/benchmarks/thirdparty/benchmark/src/re.h deleted file mode 100755 index 924d2f0ba..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/re.h +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef BENCHMARK_RE_H_ -#define BENCHMARK_RE_H_ - -#include "internal_macros.h" - -#if !defined(HAVE_STD_REGEX) && \ - !defined(HAVE_GNU_POSIX_REGEX) && \ - !defined(HAVE_POSIX_REGEX) - // No explicit regex selection; detect based on builtin hints. - #if defined(BENCHMARK_OS_LINUX) || defined(BENCHMARK_OS_APPLE) - #define HAVE_POSIX_REGEX 1 - #elif __cplusplus >= 199711L - #define HAVE_STD_REGEX 1 - #endif -#endif - -// Prefer C regex libraries when compiling w/o exceptions so that we can -// correctly report errors. -#if defined(BENCHMARK_HAS_NO_EXCEPTIONS) && \ - defined(BENCHMARK_HAVE_STD_REGEX) && \ - (defined(HAVE_GNU_POSIX_REGEX) || defined(HAVE_POSIX_REGEX)) - #undef HAVE_STD_REGEX -#endif - -#if defined(HAVE_STD_REGEX) - #include -#elif defined(HAVE_GNU_POSIX_REGEX) - #include -#elif defined(HAVE_POSIX_REGEX) - #include -#else -#error No regular expression backend was found! -#endif -#include - -#include "check.h" - -namespace benchmark { - -// A wrapper around the POSIX regular expression API that provides automatic -// cleanup -class Regex { - public: - Regex() : init_(false) {} - - ~Regex(); - - // Compile a regular expression matcher from spec. Returns true on success. - // - // On failure (and if error is not nullptr), error is populated with a human - // readable error message if an error occurs. - bool Init(const std::string& spec, std::string* error); - - // Returns whether str matches the compiled regular expression. - bool Match(const std::string& str); - - private: - bool init_; -// Underlying regular expression object -#if defined(HAVE_STD_REGEX) - std::regex re_; -#elif defined(HAVE_POSIX_REGEX) || defined(HAVE_GNU_POSIX_REGEX) - regex_t re_; -#else - #error No regular expression backend implementation available -#endif -}; - -#if defined(HAVE_STD_REGEX) - -inline bool Regex::Init(const std::string& spec, std::string* error) { -#ifdef BENCHMARK_HAS_NO_EXCEPTIONS - ((void)error); // suppress unused warning -#else - try { -#endif - re_ = std::regex(spec, std::regex_constants::extended); - init_ = true; -#ifndef BENCHMARK_HAS_NO_EXCEPTIONS - } catch (const std::regex_error& e) { - if (error) { - *error = e.what(); - } - } -#endif - return init_; -} - -inline Regex::~Regex() {} - -inline bool Regex::Match(const std::string& str) { - if (!init_) { - return false; - } - return std::regex_search(str, re_); -} - -#else -inline bool Regex::Init(const std::string& spec, std::string* error) { - int ec = regcomp(&re_, spec.c_str(), REG_EXTENDED | REG_NOSUB); - if (ec != 0) { - if (error) { - size_t needed = regerror(ec, &re_, nullptr, 0); - char* errbuf = new char[needed]; - regerror(ec, &re_, errbuf, needed); - - // regerror returns the number of bytes necessary to null terminate - // the string, so we move that when assigning to error. - CHECK_NE(needed, 0); - error->assign(errbuf, needed - 1); - - delete[] errbuf; - } - - return false; - } - - init_ = true; - return true; -} - -inline Regex::~Regex() { - if (init_) { - regfree(&re_); - } -} - -inline bool Regex::Match(const std::string& str) { - if (!init_) { - return false; - } - return regexec(&re_, str.c_str(), 0, nullptr, 0) == 0; -} -#endif - -} // end namespace benchmark - -#endif // BENCHMARK_RE_H_ diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/reporter.cc b/external_imported/json/benchmarks/thirdparty/benchmark/src/reporter.cc deleted file mode 100755 index 4b40aaec8..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/reporter.cc +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "benchmark/benchmark.h" -#include "timers.h" - -#include - -#include -#include -#include - -#include "check.h" - -namespace benchmark { - -BenchmarkReporter::BenchmarkReporter() - : output_stream_(&std::cout), error_stream_(&std::cerr) {} - -BenchmarkReporter::~BenchmarkReporter() {} - -void BenchmarkReporter::PrintBasicContext(std::ostream *out, - Context const &context) { - CHECK(out) << "cannot be null"; - auto &Out = *out; - - Out << LocalDateTimeString() << "\n"; - - if (context.executable_name) - Out << "Running " << context.executable_name << "\n"; - - const CPUInfo &info = context.cpu_info; - Out << "Run on (" << info.num_cpus << " X " - << (info.cycles_per_second / 1000000.0) << " MHz CPU " - << ((info.num_cpus > 1) ? "s" : "") << ")\n"; - if (info.caches.size() != 0) { - Out << "CPU Caches:\n"; - for (auto &CInfo : info.caches) { - Out << " L" << CInfo.level << " " << CInfo.type << " " - << (CInfo.size / 1000) << "K"; - if (CInfo.num_sharing != 0) - Out << " (x" << (info.num_cpus / CInfo.num_sharing) << ")"; - Out << "\n"; - } - } - - if (info.scaling_enabled) { - Out << "***WARNING*** CPU scaling is enabled, the benchmark " - "real time measurements may be noisy and will incur extra " - "overhead.\n"; - } - -#ifndef NDEBUG - Out << "***WARNING*** Library was built as DEBUG. Timings may be " - "affected.\n"; -#endif -} - -// No initializer because it's already initialized to NULL. -const char* BenchmarkReporter::Context::executable_name; - -BenchmarkReporter::Context::Context() : cpu_info(CPUInfo::Get()) {} - -double BenchmarkReporter::Run::GetAdjustedRealTime() const { - double new_time = real_accumulated_time * GetTimeUnitMultiplier(time_unit); - if (iterations != 0) new_time /= static_cast(iterations); - return new_time; -} - -double BenchmarkReporter::Run::GetAdjustedCPUTime() const { - double new_time = cpu_accumulated_time * GetTimeUnitMultiplier(time_unit); - if (iterations != 0) new_time /= static_cast(iterations); - return new_time; -} - -} // end namespace benchmark diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/sleep.cc b/external_imported/json/benchmarks/thirdparty/benchmark/src/sleep.cc deleted file mode 100755 index 54aa04a42..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/sleep.cc +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "sleep.h" - -#include -#include -#include - -#include "internal_macros.h" - -#ifdef BENCHMARK_OS_WINDOWS -#include -#endif - -namespace benchmark { -#ifdef BENCHMARK_OS_WINDOWS -// Window's Sleep takes milliseconds argument. -void SleepForMilliseconds(int milliseconds) { Sleep(milliseconds); } -void SleepForSeconds(double seconds) { - SleepForMilliseconds(static_cast(kNumMillisPerSecond * seconds)); -} -#else // BENCHMARK_OS_WINDOWS -void SleepForMicroseconds(int microseconds) { - struct timespec sleep_time; - sleep_time.tv_sec = microseconds / kNumMicrosPerSecond; - sleep_time.tv_nsec = (microseconds % kNumMicrosPerSecond) * kNumNanosPerMicro; - while (nanosleep(&sleep_time, &sleep_time) != 0 && errno == EINTR) - ; // Ignore signals and wait for the full interval to elapse. -} - -void SleepForMilliseconds(int milliseconds) { - SleepForMicroseconds(milliseconds * kNumMicrosPerMilli); -} - -void SleepForSeconds(double seconds) { - SleepForMicroseconds(static_cast(seconds * kNumMicrosPerSecond)); -} -#endif // BENCHMARK_OS_WINDOWS -} // end namespace benchmark diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/sleep.h b/external_imported/json/benchmarks/thirdparty/benchmark/src/sleep.h deleted file mode 100755 index f98551afe..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/sleep.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef BENCHMARK_SLEEP_H_ -#define BENCHMARK_SLEEP_H_ - -namespace benchmark { -const int kNumMillisPerSecond = 1000; -const int kNumMicrosPerMilli = 1000; -const int kNumMicrosPerSecond = kNumMillisPerSecond * 1000; -const int kNumNanosPerMicro = 1000; -const int kNumNanosPerSecond = kNumNanosPerMicro * kNumMicrosPerSecond; - -void SleepForMilliseconds(int milliseconds); -void SleepForSeconds(double seconds); -} // end namespace benchmark - -#endif // BENCHMARK_SLEEP_H_ diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/statistics.cc b/external_imported/json/benchmarks/thirdparty/benchmark/src/statistics.cc deleted file mode 100755 index 1c91e1015..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/statistics.cc +++ /dev/null @@ -1,178 +0,0 @@ -// Copyright 2016 Ismael Jimenez Martinez. All rights reserved. -// Copyright 2017 Roman Lebedev. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "benchmark/benchmark.h" - -#include -#include -#include -#include -#include -#include "check.h" -#include "statistics.h" - -namespace benchmark { - -auto StatisticsSum = [](const std::vector& v) { - return std::accumulate(v.begin(), v.end(), 0.0); -}; - -double StatisticsMean(const std::vector& v) { - if (v.empty()) return 0.0; - return StatisticsSum(v) * (1.0 / v.size()); -} - -double StatisticsMedian(const std::vector& v) { - if (v.size() < 3) return StatisticsMean(v); - std::vector copy(v); - - auto center = copy.begin() + v.size() / 2; - std::nth_element(copy.begin(), center, copy.end()); - - // did we have an odd number of samples? - // if yes, then center is the median - // it no, then we are looking for the average between center and the value before - if(v.size() % 2 == 1) - return *center; - auto center2 = copy.begin() + v.size() / 2 - 1; - std::nth_element(copy.begin(), center2, copy.end()); - return (*center + *center2) / 2.0; -} - -// Return the sum of the squares of this sample set -auto SumSquares = [](const std::vector& v) { - return std::inner_product(v.begin(), v.end(), v.begin(), 0.0); -}; - -auto Sqr = [](const double dat) { return dat * dat; }; -auto Sqrt = [](const double dat) { - // Avoid NaN due to imprecision in the calculations - if (dat < 0.0) return 0.0; - return std::sqrt(dat); -}; - -double StatisticsStdDev(const std::vector& v) { - const auto mean = StatisticsMean(v); - if (v.empty()) return mean; - - // Sample standard deviation is undefined for n = 1 - if (v.size() == 1) - return 0.0; - - const double avg_squares = SumSquares(v) * (1.0 / v.size()); - return Sqrt(v.size() / (v.size() - 1.0) * (avg_squares - Sqr(mean))); -} - -std::vector ComputeStats( - const std::vector& reports) { - typedef BenchmarkReporter::Run Run; - std::vector results; - - auto error_count = - std::count_if(reports.begin(), reports.end(), - [](Run const& run) { return run.error_occurred; }); - - if (reports.size() - error_count < 2) { - // We don't report aggregated data if there was a single run. - return results; - } - - // Accumulators. - std::vector real_accumulated_time_stat; - std::vector cpu_accumulated_time_stat; - std::vector bytes_per_second_stat; - std::vector items_per_second_stat; - - real_accumulated_time_stat.reserve(reports.size()); - cpu_accumulated_time_stat.reserve(reports.size()); - bytes_per_second_stat.reserve(reports.size()); - items_per_second_stat.reserve(reports.size()); - - // All repetitions should be run with the same number of iterations so we - // can take this information from the first benchmark. - int64_t const run_iterations = reports.front().iterations; - // create stats for user counters - struct CounterStat { - Counter c; - std::vector s; - }; - std::map< std::string, CounterStat > counter_stats; - for(Run const& r : reports) { - for(auto const& cnt : r.counters) { - auto it = counter_stats.find(cnt.first); - if(it == counter_stats.end()) { - counter_stats.insert({cnt.first, {cnt.second, std::vector{}}}); - it = counter_stats.find(cnt.first); - it->second.s.reserve(reports.size()); - } else { - CHECK_EQ(counter_stats[cnt.first].c.flags, cnt.second.flags); - } - } - } - - // Populate the accumulators. - for (Run const& run : reports) { - CHECK_EQ(reports[0].benchmark_name, run.benchmark_name); - CHECK_EQ(run_iterations, run.iterations); - if (run.error_occurred) continue; - real_accumulated_time_stat.emplace_back(run.real_accumulated_time); - cpu_accumulated_time_stat.emplace_back(run.cpu_accumulated_time); - items_per_second_stat.emplace_back(run.items_per_second); - bytes_per_second_stat.emplace_back(run.bytes_per_second); - // user counters - for(auto const& cnt : run.counters) { - auto it = counter_stats.find(cnt.first); - CHECK_NE(it, counter_stats.end()); - it->second.s.emplace_back(cnt.second); - } - } - - // Only add label if it is same for all runs - std::string report_label = reports[0].report_label; - for (std::size_t i = 1; i < reports.size(); i++) { - if (reports[i].report_label != report_label) { - report_label = ""; - break; - } - } - - for(const auto& Stat : *reports[0].statistics) { - // Get the data from the accumulator to BenchmarkReporter::Run's. - Run data; - data.benchmark_name = reports[0].benchmark_name + "_" + Stat.name_; - data.report_label = report_label; - data.iterations = run_iterations; - - data.real_accumulated_time = Stat.compute_(real_accumulated_time_stat); - data.cpu_accumulated_time = Stat.compute_(cpu_accumulated_time_stat); - data.bytes_per_second = Stat.compute_(bytes_per_second_stat); - data.items_per_second = Stat.compute_(items_per_second_stat); - - data.time_unit = reports[0].time_unit; - - // user counters - for(auto const& kv : counter_stats) { - const auto uc_stat = Stat.compute_(kv.second.s); - auto c = Counter(uc_stat, counter_stats[kv.first].c.flags); - data.counters[kv.first] = c; - } - - results.push_back(data); - } - - return results; -} - -} // end namespace benchmark diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/statistics.h b/external_imported/json/benchmarks/thirdparty/benchmark/src/statistics.h deleted file mode 100755 index 7eccc8553..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/statistics.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2016 Ismael Jimenez Martinez. All rights reserved. -// Copyright 2017 Roman Lebedev. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STATISTICS_H_ -#define STATISTICS_H_ - -#include - -#include "benchmark/benchmark.h" - -namespace benchmark { - -// Return a vector containing the mean, median and standard devation information -// (and any user-specified info) for the specified list of reports. If 'reports' -// contains less than two non-errored runs an empty vector is returned -std::vector ComputeStats( - const std::vector& reports); - -double StatisticsMean(const std::vector& v); -double StatisticsMedian(const std::vector& v); -double StatisticsStdDev(const std::vector& v); - -} // end namespace benchmark - -#endif // STATISTICS_H_ diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/string_util.cc b/external_imported/json/benchmarks/thirdparty/benchmark/src/string_util.cc deleted file mode 100755 index ebc3acebd..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/string_util.cc +++ /dev/null @@ -1,172 +0,0 @@ -#include "string_util.h" - -#include -#include -#include -#include -#include -#include - -#include "arraysize.h" - -namespace benchmark { -namespace { - -// kilo, Mega, Giga, Tera, Peta, Exa, Zetta, Yotta. -const char kBigSIUnits[] = "kMGTPEZY"; -// Kibi, Mebi, Gibi, Tebi, Pebi, Exbi, Zebi, Yobi. -const char kBigIECUnits[] = "KMGTPEZY"; -// milli, micro, nano, pico, femto, atto, zepto, yocto. -const char kSmallSIUnits[] = "munpfazy"; - -// We require that all three arrays have the same size. -static_assert(arraysize(kBigSIUnits) == arraysize(kBigIECUnits), - "SI and IEC unit arrays must be the same size"); -static_assert(arraysize(kSmallSIUnits) == arraysize(kBigSIUnits), - "Small SI and Big SI unit arrays must be the same size"); - -static const int64_t kUnitsSize = arraysize(kBigSIUnits); - -void ToExponentAndMantissa(double val, double thresh, int precision, - double one_k, std::string* mantissa, - int64_t* exponent) { - std::stringstream mantissa_stream; - - if (val < 0) { - mantissa_stream << "-"; - val = -val; - } - - // Adjust threshold so that it never excludes things which can't be rendered - // in 'precision' digits. - const double adjusted_threshold = - std::max(thresh, 1.0 / std::pow(10.0, precision)); - const double big_threshold = adjusted_threshold * one_k; - const double small_threshold = adjusted_threshold; - // Values in ]simple_threshold,small_threshold[ will be printed as-is - const double simple_threshold = 0.01; - - if (val > big_threshold) { - // Positive powers - double scaled = val; - for (size_t i = 0; i < arraysize(kBigSIUnits); ++i) { - scaled /= one_k; - if (scaled <= big_threshold) { - mantissa_stream << scaled; - *exponent = i + 1; - *mantissa = mantissa_stream.str(); - return; - } - } - mantissa_stream << val; - *exponent = 0; - } else if (val < small_threshold) { - // Negative powers - if (val < simple_threshold) { - double scaled = val; - for (size_t i = 0; i < arraysize(kSmallSIUnits); ++i) { - scaled *= one_k; - if (scaled >= small_threshold) { - mantissa_stream << scaled; - *exponent = -static_cast(i + 1); - *mantissa = mantissa_stream.str(); - return; - } - } - } - mantissa_stream << val; - *exponent = 0; - } else { - mantissa_stream << val; - *exponent = 0; - } - *mantissa = mantissa_stream.str(); -} - -std::string ExponentToPrefix(int64_t exponent, bool iec) { - if (exponent == 0) return ""; - - const int64_t index = (exponent > 0 ? exponent - 1 : -exponent - 1); - if (index >= kUnitsSize) return ""; - - const char* array = - (exponent > 0 ? (iec ? kBigIECUnits : kBigSIUnits) : kSmallSIUnits); - if (iec) - return array[index] + std::string("i"); - else - return std::string(1, array[index]); -} - -std::string ToBinaryStringFullySpecified(double value, double threshold, - int precision, double one_k = 1024.0) { - std::string mantissa; - int64_t exponent; - ToExponentAndMantissa(value, threshold, precision, one_k, &mantissa, - &exponent); - return mantissa + ExponentToPrefix(exponent, false); -} - -} // end namespace - -void AppendHumanReadable(int n, std::string* str) { - std::stringstream ss; - // Round down to the nearest SI prefix. - ss << ToBinaryStringFullySpecified(n, 1.0, 0); - *str += ss.str(); -} - -std::string HumanReadableNumber(double n, double one_k) { - // 1.1 means that figures up to 1.1k should be shown with the next unit down; - // this softens edge effects. - // 1 means that we should show one decimal place of precision. - return ToBinaryStringFullySpecified(n, 1.1, 1, one_k); -} - -std::string StrFormatImp(const char* msg, va_list args) { - // we might need a second shot at this, so pre-emptivly make a copy - va_list args_cp; - va_copy(args_cp, args); - - // TODO(ericwf): use std::array for first attempt to avoid one memory - // allocation guess what the size might be - std::array local_buff; - std::size_t size = local_buff.size(); - // 2015-10-08: vsnprintf is used instead of snd::vsnprintf due to a limitation - // in the android-ndk - auto ret = vsnprintf(local_buff.data(), size, msg, args_cp); - - va_end(args_cp); - - // handle empty expansion - if (ret == 0) return std::string{}; - if (static_cast(ret) < size) - return std::string(local_buff.data()); - - // we did not provide a long enough buffer on our first attempt. - // add 1 to size to account for null-byte in size cast to prevent overflow - size = static_cast(ret) + 1; - auto buff_ptr = std::unique_ptr(new char[size]); - // 2015-10-08: vsnprintf is used instead of snd::vsnprintf due to a limitation - // in the android-ndk - ret = vsnprintf(buff_ptr.get(), size, msg, args); - return std::string(buff_ptr.get()); -} - -std::string StrFormat(const char* format, ...) { - va_list args; - va_start(args, format); - std::string tmp = StrFormatImp(format, args); - va_end(args); - return tmp; -} - -void ReplaceAll(std::string* str, const std::string& from, - const std::string& to) { - std::size_t start = 0; - while ((start = str->find(from, start)) != std::string::npos) { - str->replace(start, from.length(), to); - start += to.length(); - } -} - -} // end namespace benchmark diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/string_util.h b/external_imported/json/benchmarks/thirdparty/benchmark/src/string_util.h deleted file mode 100755 index e70e76987..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/string_util.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef BENCHMARK_STRING_UTIL_H_ -#define BENCHMARK_STRING_UTIL_H_ - -#include -#include -#include -#include "internal_macros.h" - -namespace benchmark { - -void AppendHumanReadable(int n, std::string* str); - -std::string HumanReadableNumber(double n, double one_k = 1024.0); - -std::string StrFormat(const char* format, ...); - -inline std::ostream& StrCatImp(std::ostream& out) BENCHMARK_NOEXCEPT { - return out; -} - -template -inline std::ostream& StrCatImp(std::ostream& out, First&& f, - Rest&&... rest) { - out << std::forward(f); - return StrCatImp(out, std::forward(rest)...); -} - -template -inline std::string StrCat(Args&&... args) { - std::ostringstream ss; - StrCatImp(ss, std::forward(args)...); - return ss.str(); -} - -void ReplaceAll(std::string* str, const std::string& from, - const std::string& to); - -} // end namespace benchmark - -#endif // BENCHMARK_STRING_UTIL_H_ diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/sysinfo.cc b/external_imported/json/benchmarks/thirdparty/benchmark/src/sysinfo.cc deleted file mode 100755 index d19d0ef4c..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/sysinfo.cc +++ /dev/null @@ -1,587 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "internal_macros.h" - -#ifdef BENCHMARK_OS_WINDOWS -#include -#undef StrCat // Don't let StrCat in string_util.h be renamed to lstrcatA -#include -#include -#else -#include -#ifndef BENCHMARK_OS_FUCHSIA -#include -#endif -#include -#include // this header must be included before 'sys/sysctl.h' to avoid compilation error on FreeBSD -#include -#if defined BENCHMARK_OS_FREEBSD || defined BENCHMARK_OS_MACOSX || \ - defined BENCHMARK_OS_NETBSD || defined BENCHMARK_OS_OPENBSD -#define BENCHMARK_HAS_SYSCTL -#include -#endif -#endif -#if defined(BENCHMARK_OS_SOLARIS) -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "check.h" -#include "cycleclock.h" -#include "internal_macros.h" -#include "log.h" -#include "sleep.h" -#include "string_util.h" - -namespace benchmark { -namespace { - -void PrintImp(std::ostream& out) { out << std::endl; } - -template -void PrintImp(std::ostream& out, First&& f, Rest&&... rest) { - out << std::forward(f); - PrintImp(out, std::forward(rest)...); -} - -template -BENCHMARK_NORETURN void PrintErrorAndDie(Args&&... args) { - PrintImp(std::cerr, std::forward(args)...); - std::exit(EXIT_FAILURE); -} - -#ifdef BENCHMARK_HAS_SYSCTL - -/// ValueUnion - A type used to correctly alias the byte-for-byte output of -/// `sysctl` with the result type it's to be interpreted as. -struct ValueUnion { - union DataT { - uint32_t uint32_value; - uint64_t uint64_value; - // For correct aliasing of union members from bytes. - char bytes[8]; - }; - using DataPtr = std::unique_ptr; - - // The size of the data union member + its trailing array size. - size_t Size; - DataPtr Buff; - - public: - ValueUnion() : Size(0), Buff(nullptr, &std::free) {} - - explicit ValueUnion(size_t BuffSize) - : Size(sizeof(DataT) + BuffSize), - Buff(::new (std::malloc(Size)) DataT(), &std::free) {} - - ValueUnion(ValueUnion&& other) = default; - - explicit operator bool() const { return bool(Buff); } - - char* data() const { return Buff->bytes; } - - std::string GetAsString() const { return std::string(data()); } - - int64_t GetAsInteger() const { - if (Size == sizeof(Buff->uint32_value)) - return static_cast(Buff->uint32_value); - else if (Size == sizeof(Buff->uint64_value)) - return static_cast(Buff->uint64_value); - BENCHMARK_UNREACHABLE(); - } - - uint64_t GetAsUnsigned() const { - if (Size == sizeof(Buff->uint32_value)) - return Buff->uint32_value; - else if (Size == sizeof(Buff->uint64_value)) - return Buff->uint64_value; - BENCHMARK_UNREACHABLE(); - } - - template - std::array GetAsArray() { - const int ArrSize = sizeof(T) * N; - CHECK_LE(ArrSize, Size); - std::array Arr; - std::memcpy(Arr.data(), data(), ArrSize); - return Arr; - } -}; - -ValueUnion GetSysctlImp(std::string const& Name) { -#if defined BENCHMARK_OS_OPENBSD - int mib[2]; - - mib[0] = CTL_HW; - if ((Name == "hw.ncpu") || (Name == "hw.cpuspeed")){ - ValueUnion buff(sizeof(int)); - - if (Name == "hw.ncpu") { - mib[1] = HW_NCPU; - } else { - mib[1] = HW_CPUSPEED; - } - - if (sysctl(mib, 2, buff.data(), &buff.Size, nullptr, 0) == -1) { - return ValueUnion(); - } - return buff; - } - return ValueUnion(); -#else - size_t CurBuffSize = 0; - if (sysctlbyname(Name.c_str(), nullptr, &CurBuffSize, nullptr, 0) == -1) - return ValueUnion(); - - ValueUnion buff(CurBuffSize); - if (sysctlbyname(Name.c_str(), buff.data(), &buff.Size, nullptr, 0) == 0) - return buff; - return ValueUnion(); -#endif -} - -BENCHMARK_MAYBE_UNUSED -bool GetSysctl(std::string const& Name, std::string* Out) { - Out->clear(); - auto Buff = GetSysctlImp(Name); - if (!Buff) return false; - Out->assign(Buff.data()); - return true; -} - -template ::value>::type> -bool GetSysctl(std::string const& Name, Tp* Out) { - *Out = 0; - auto Buff = GetSysctlImp(Name); - if (!Buff) return false; - *Out = static_cast(Buff.GetAsUnsigned()); - return true; -} - -template -bool GetSysctl(std::string const& Name, std::array* Out) { - auto Buff = GetSysctlImp(Name); - if (!Buff) return false; - *Out = Buff.GetAsArray(); - return true; -} -#endif - -template -bool ReadFromFile(std::string const& fname, ArgT* arg) { - *arg = ArgT(); - std::ifstream f(fname.c_str()); - if (!f.is_open()) return false; - f >> *arg; - return f.good(); -} - -bool CpuScalingEnabled(int num_cpus) { - // We don't have a valid CPU count, so don't even bother. - if (num_cpus <= 0) return false; -#ifndef BENCHMARK_OS_WINDOWS - // On Linux, the CPUfreq subsystem exposes CPU information as files on the - // local file system. If reading the exported files fails, then we may not be - // running on Linux, so we silently ignore all the read errors. - std::string res; - for (int cpu = 0; cpu < num_cpus; ++cpu) { - std::string governor_file = - StrCat("/sys/devices/system/cpu/cpu", cpu, "/cpufreq/scaling_governor"); - if (ReadFromFile(governor_file, &res) && res != "performance") return true; - } -#endif - return false; -} - -int CountSetBitsInCPUMap(std::string Val) { - auto CountBits = [](std::string Part) { - using CPUMask = std::bitset; - Part = "0x" + Part; - CPUMask Mask(std::stoul(Part, nullptr, 16)); - return static_cast(Mask.count()); - }; - size_t Pos; - int total = 0; - while ((Pos = Val.find(',')) != std::string::npos) { - total += CountBits(Val.substr(0, Pos)); - Val = Val.substr(Pos + 1); - } - if (!Val.empty()) { - total += CountBits(Val); - } - return total; -} - -BENCHMARK_MAYBE_UNUSED -std::vector GetCacheSizesFromKVFS() { - std::vector res; - std::string dir = "/sys/devices/system/cpu/cpu0/cache/"; - int Idx = 0; - while (true) { - CPUInfo::CacheInfo info; - std::string FPath = StrCat(dir, "index", Idx++, "/"); - std::ifstream f(StrCat(FPath, "size").c_str()); - if (!f.is_open()) break; - std::string suffix; - f >> info.size; - if (f.fail()) - PrintErrorAndDie("Failed while reading file '", FPath, "size'"); - if (f.good()) { - f >> suffix; - if (f.bad()) - PrintErrorAndDie( - "Invalid cache size format: failed to read size suffix"); - else if (f && suffix != "K") - PrintErrorAndDie("Invalid cache size format: Expected bytes ", suffix); - else if (suffix == "K") - info.size *= 1000; - } - if (!ReadFromFile(StrCat(FPath, "type"), &info.type)) - PrintErrorAndDie("Failed to read from file ", FPath, "type"); - if (!ReadFromFile(StrCat(FPath, "level"), &info.level)) - PrintErrorAndDie("Failed to read from file ", FPath, "level"); - std::string map_str; - if (!ReadFromFile(StrCat(FPath, "shared_cpu_map"), &map_str)) - PrintErrorAndDie("Failed to read from file ", FPath, "shared_cpu_map"); - info.num_sharing = CountSetBitsInCPUMap(map_str); - res.push_back(info); - } - - return res; -} - -#ifdef BENCHMARK_OS_MACOSX -std::vector GetCacheSizesMacOSX() { - std::vector res; - std::array CacheCounts{{0, 0, 0, 0}}; - GetSysctl("hw.cacheconfig", &CacheCounts); - - struct { - std::string name; - std::string type; - int level; - size_t num_sharing; - } Cases[] = {{"hw.l1dcachesize", "Data", 1, CacheCounts[1]}, - {"hw.l1icachesize", "Instruction", 1, CacheCounts[1]}, - {"hw.l2cachesize", "Unified", 2, CacheCounts[2]}, - {"hw.l3cachesize", "Unified", 3, CacheCounts[3]}}; - for (auto& C : Cases) { - int val; - if (!GetSysctl(C.name, &val)) continue; - CPUInfo::CacheInfo info; - info.type = C.type; - info.level = C.level; - info.size = val; - info.num_sharing = static_cast(C.num_sharing); - res.push_back(std::move(info)); - } - return res; -} -#elif defined(BENCHMARK_OS_WINDOWS) -std::vector GetCacheSizesWindows() { - std::vector res; - DWORD buffer_size = 0; - using PInfo = SYSTEM_LOGICAL_PROCESSOR_INFORMATION; - using CInfo = CACHE_DESCRIPTOR; - - using UPtr = std::unique_ptr; - GetLogicalProcessorInformation(nullptr, &buffer_size); - UPtr buff((PInfo*)malloc(buffer_size), &std::free); - if (!GetLogicalProcessorInformation(buff.get(), &buffer_size)) - PrintErrorAndDie("Failed during call to GetLogicalProcessorInformation: ", - GetLastError()); - - PInfo* it = buff.get(); - PInfo* end = buff.get() + (buffer_size / sizeof(PInfo)); - - for (; it != end; ++it) { - if (it->Relationship != RelationCache) continue; - using BitSet = std::bitset; - BitSet B(it->ProcessorMask); - // To prevent duplicates, only consider caches where CPU 0 is specified - if (!B.test(0)) continue; - CInfo* Cache = &it->Cache; - CPUInfo::CacheInfo C; - C.num_sharing = static_cast(B.count()); - C.level = Cache->Level; - C.size = Cache->Size; - switch (Cache->Type) { - case CacheUnified: - C.type = "Unified"; - break; - case CacheInstruction: - C.type = "Instruction"; - break; - case CacheData: - C.type = "Data"; - break; - case CacheTrace: - C.type = "Trace"; - break; - default: - C.type = "Unknown"; - break; - } - res.push_back(C); - } - return res; -} -#endif - -std::vector GetCacheSizes() { -#ifdef BENCHMARK_OS_MACOSX - return GetCacheSizesMacOSX(); -#elif defined(BENCHMARK_OS_WINDOWS) - return GetCacheSizesWindows(); -#else - return GetCacheSizesFromKVFS(); -#endif -} - -int GetNumCPUs() { -#ifdef BENCHMARK_HAS_SYSCTL - int NumCPU = -1; - if (GetSysctl("hw.ncpu", &NumCPU)) return NumCPU; - fprintf(stderr, "Err: %s\n", strerror(errno)); - std::exit(EXIT_FAILURE); -#elif defined(BENCHMARK_OS_WINDOWS) - SYSTEM_INFO sysinfo; - // Use memset as opposed to = {} to avoid GCC missing initializer false - // positives. - std::memset(&sysinfo, 0, sizeof(SYSTEM_INFO)); - GetSystemInfo(&sysinfo); - return sysinfo.dwNumberOfProcessors; // number of logical - // processors in the current - // group -#elif defined(BENCHMARK_OS_SOLARIS) - // Returns -1 in case of a failure. - int NumCPU = sysconf(_SC_NPROCESSORS_ONLN); - if (NumCPU < 0) { - fprintf(stderr, - "sysconf(_SC_NPROCESSORS_ONLN) failed with error: %s\n", - strerror(errno)); - } - return NumCPU; -#else - int NumCPUs = 0; - int MaxID = -1; - std::ifstream f("/proc/cpuinfo"); - if (!f.is_open()) { - std::cerr << "failed to open /proc/cpuinfo\n"; - return -1; - } - const std::string Key = "processor"; - std::string ln; - while (std::getline(f, ln)) { - if (ln.empty()) continue; - size_t SplitIdx = ln.find(':'); - std::string value; - if (SplitIdx != std::string::npos) value = ln.substr(SplitIdx + 1); - if (ln.size() >= Key.size() && ln.compare(0, Key.size(), Key) == 0) { - NumCPUs++; - if (!value.empty()) { - int CurID = std::stoi(value); - MaxID = std::max(CurID, MaxID); - } - } - } - if (f.bad()) { - std::cerr << "Failure reading /proc/cpuinfo\n"; - return -1; - } - if (!f.eof()) { - std::cerr << "Failed to read to end of /proc/cpuinfo\n"; - return -1; - } - f.close(); - - if ((MaxID + 1) != NumCPUs) { - fprintf(stderr, - "CPU ID assignments in /proc/cpuinfo seem messed up." - " This is usually caused by a bad BIOS.\n"); - } - return NumCPUs; -#endif - BENCHMARK_UNREACHABLE(); -} - -double GetCPUCyclesPerSecond() { -#if defined BENCHMARK_OS_LINUX || defined BENCHMARK_OS_CYGWIN - long freq; - - // If the kernel is exporting the tsc frequency use that. There are issues - // where cpuinfo_max_freq cannot be relied on because the BIOS may be - // exporintg an invalid p-state (on x86) or p-states may be used to put the - // processor in a new mode (turbo mode). Essentially, those frequencies - // cannot always be relied upon. The same reasons apply to /proc/cpuinfo as - // well. - if (ReadFromFile("/sys/devices/system/cpu/cpu0/tsc_freq_khz", &freq) - // If CPU scaling is in effect, we want to use the *maximum* frequency, - // not whatever CPU speed some random processor happens to be using now. - || ReadFromFile("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq", - &freq)) { - // The value is in kHz (as the file name suggests). For example, on a - // 2GHz warpstation, the file contains the value "2000000". - return freq * 1000.0; - } - - const double error_value = -1; - double bogo_clock = error_value; - - std::ifstream f("/proc/cpuinfo"); - if (!f.is_open()) { - std::cerr << "failed to open /proc/cpuinfo\n"; - return error_value; - } - - auto startsWithKey = [](std::string const& Value, std::string const& Key) { - if (Key.size() > Value.size()) return false; - auto Cmp = [&](char X, char Y) { - return std::tolower(X) == std::tolower(Y); - }; - return std::equal(Key.begin(), Key.end(), Value.begin(), Cmp); - }; - - std::string ln; - while (std::getline(f, ln)) { - if (ln.empty()) continue; - size_t SplitIdx = ln.find(':'); - std::string value; - if (SplitIdx != std::string::npos) value = ln.substr(SplitIdx + 1); - // When parsing the "cpu MHz" and "bogomips" (fallback) entries, we only - // accept positive values. Some environments (virtual machines) report zero, - // which would cause infinite looping in WallTime_Init. - if (startsWithKey(ln, "cpu MHz")) { - if (!value.empty()) { - double cycles_per_second = std::stod(value) * 1000000.0; - if (cycles_per_second > 0) return cycles_per_second; - } - } else if (startsWithKey(ln, "bogomips")) { - if (!value.empty()) { - bogo_clock = std::stod(value) * 1000000.0; - if (bogo_clock < 0.0) bogo_clock = error_value; - } - } - } - if (f.bad()) { - std::cerr << "Failure reading /proc/cpuinfo\n"; - return error_value; - } - if (!f.eof()) { - std::cerr << "Failed to read to end of /proc/cpuinfo\n"; - return error_value; - } - f.close(); - // If we found the bogomips clock, but nothing better, we'll use it (but - // we're not happy about it); otherwise, fallback to the rough estimation - // below. - if (bogo_clock >= 0.0) return bogo_clock; - -#elif defined BENCHMARK_HAS_SYSCTL - constexpr auto* FreqStr = -#if defined(BENCHMARK_OS_FREEBSD) || defined(BENCHMARK_OS_NETBSD) - "machdep.tsc_freq"; -#elif defined BENCHMARK_OS_OPENBSD - "hw.cpuspeed"; -#else - "hw.cpufrequency"; -#endif - unsigned long long hz = 0; -#if defined BENCHMARK_OS_OPENBSD - if (GetSysctl(FreqStr, &hz)) return hz * 1000000; -#else - if (GetSysctl(FreqStr, &hz)) return hz; -#endif - fprintf(stderr, "Unable to determine clock rate from sysctl: %s: %s\n", - FreqStr, strerror(errno)); - -#elif defined BENCHMARK_OS_WINDOWS - // In NT, read MHz from the registry. If we fail to do so or we're in win9x - // then make a crude estimate. - DWORD data, data_size = sizeof(data); - if (IsWindowsXPOrGreater() && - SUCCEEDED( - SHGetValueA(HKEY_LOCAL_MACHINE, - "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", - "~MHz", nullptr, &data, &data_size))) - return static_cast((int64_t)data * - (int64_t)(1000 * 1000)); // was mhz -#elif defined (BENCHMARK_OS_SOLARIS) - kstat_ctl_t *kc = kstat_open(); - if (!kc) { - std::cerr << "failed to open /dev/kstat\n"; - return -1; - } - kstat_t *ksp = kstat_lookup(kc, (char*)"cpu_info", -1, (char*)"cpu_info0"); - if (!ksp) { - std::cerr << "failed to lookup in /dev/kstat\n"; - return -1; - } - if (kstat_read(kc, ksp, NULL) < 0) { - std::cerr << "failed to read from /dev/kstat\n"; - return -1; - } - kstat_named_t *knp = - (kstat_named_t*)kstat_data_lookup(ksp, (char*)"current_clock_Hz"); - if (!knp) { - std::cerr << "failed to lookup data in /dev/kstat\n"; - return -1; - } - if (knp->data_type != KSTAT_DATA_UINT64) { - std::cerr << "current_clock_Hz is of unexpected data type: " - << knp->data_type << "\n"; - return -1; - } - double clock_hz = knp->value.ui64; - kstat_close(kc); - return clock_hz; -#endif - // If we've fallen through, attempt to roughly estimate the CPU clock rate. - const int estimate_time_ms = 1000; - const auto start_ticks = cycleclock::Now(); - SleepForMilliseconds(estimate_time_ms); - return static_cast(cycleclock::Now() - start_ticks); -} - -} // end namespace - -const CPUInfo& CPUInfo::Get() { - static const CPUInfo* info = new CPUInfo(); - return *info; -} - -CPUInfo::CPUInfo() - : num_cpus(GetNumCPUs()), - cycles_per_second(GetCPUCyclesPerSecond()), - caches(GetCacheSizes()), - scaling_enabled(CpuScalingEnabled(num_cpus)) {} - -} // end namespace benchmark diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/thread_manager.h b/external_imported/json/benchmarks/thirdparty/benchmark/src/thread_manager.h deleted file mode 100755 index 82b4d72b6..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/thread_manager.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef BENCHMARK_THREAD_MANAGER_H -#define BENCHMARK_THREAD_MANAGER_H - -#include - -#include "benchmark/benchmark.h" -#include "mutex.h" - -namespace benchmark { -namespace internal { - -class ThreadManager { - public: - ThreadManager(int num_threads) - : alive_threads_(num_threads), start_stop_barrier_(num_threads) {} - - Mutex& GetBenchmarkMutex() const RETURN_CAPABILITY(benchmark_mutex_) { - return benchmark_mutex_; - } - - bool StartStopBarrier() EXCLUDES(end_cond_mutex_) { - return start_stop_barrier_.wait(); - } - - void NotifyThreadComplete() EXCLUDES(end_cond_mutex_) { - start_stop_barrier_.removeThread(); - if (--alive_threads_ == 0) { - MutexLock lock(end_cond_mutex_); - end_condition_.notify_all(); - } - } - - void WaitForAllThreads() EXCLUDES(end_cond_mutex_) { - MutexLock lock(end_cond_mutex_); - end_condition_.wait(lock.native_handle(), - [this]() { return alive_threads_ == 0; }); - } - - public: - struct Result { - int64_t iterations = 0; - double real_time_used = 0; - double cpu_time_used = 0; - double manual_time_used = 0; - int64_t bytes_processed = 0; - int64_t items_processed = 0; - int64_t complexity_n = 0; - std::string report_label_; - std::string error_message_; - bool has_error_ = false; - UserCounters counters; - }; - GUARDED_BY(GetBenchmarkMutex()) Result results; - - private: - mutable Mutex benchmark_mutex_; - std::atomic alive_threads_; - Barrier start_stop_barrier_; - Mutex end_cond_mutex_; - Condition end_condition_; -}; - -} // namespace internal -} // namespace benchmark - -#endif // BENCHMARK_THREAD_MANAGER_H diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/thread_timer.h b/external_imported/json/benchmarks/thirdparty/benchmark/src/thread_timer.h deleted file mode 100755 index eaf108e01..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/thread_timer.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef BENCHMARK_THREAD_TIMER_H -#define BENCHMARK_THREAD_TIMER_H - -#include "check.h" -#include "timers.h" - -namespace benchmark { -namespace internal { - -class ThreadTimer { - public: - ThreadTimer() = default; - - // Called by each thread - void StartTimer() { - running_ = true; - start_real_time_ = ChronoClockNow(); - start_cpu_time_ = ThreadCPUUsage(); - } - - // Called by each thread - void StopTimer() { - CHECK(running_); - running_ = false; - real_time_used_ += ChronoClockNow() - start_real_time_; - // Floating point error can result in the subtraction producing a negative - // time. Guard against that. - cpu_time_used_ += std::max(ThreadCPUUsage() - start_cpu_time_, 0); - } - - // Called by each thread - void SetIterationTime(double seconds) { manual_time_used_ += seconds; } - - bool running() const { return running_; } - - // REQUIRES: timer is not running - double real_time_used() { - CHECK(!running_); - return real_time_used_; - } - - // REQUIRES: timer is not running - double cpu_time_used() { - CHECK(!running_); - return cpu_time_used_; - } - - // REQUIRES: timer is not running - double manual_time_used() { - CHECK(!running_); - return manual_time_used_; - } - - private: - bool running_ = false; // Is the timer running - double start_real_time_ = 0; // If running_ - double start_cpu_time_ = 0; // If running_ - - // Accumulated time so far (does not contain current slice if running_) - double real_time_used_ = 0; - double cpu_time_used_ = 0; - // Manually set iteration time. User sets this with SetIterationTime(seconds). - double manual_time_used_ = 0; -}; - -} // namespace internal -} // namespace benchmark - -#endif // BENCHMARK_THREAD_TIMER_H diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/timers.cc b/external_imported/json/benchmarks/thirdparty/benchmark/src/timers.cc deleted file mode 100755 index 2010e2450..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/timers.cc +++ /dev/null @@ -1,217 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "timers.h" -#include "internal_macros.h" - -#ifdef BENCHMARK_OS_WINDOWS -#include -#undef StrCat // Don't let StrCat in string_util.h be renamed to lstrcatA -#include -#include -#else -#include -#ifndef BENCHMARK_OS_FUCHSIA -#include -#endif -#include -#include // this header must be included before 'sys/sysctl.h' to avoid compilation error on FreeBSD -#include -#if defined BENCHMARK_OS_FREEBSD || defined BENCHMARK_OS_MACOSX -#include -#endif -#if defined(BENCHMARK_OS_MACOSX) -#include -#include -#include -#endif -#endif - -#ifdef BENCHMARK_OS_EMSCRIPTEN -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "check.h" -#include "log.h" -#include "sleep.h" -#include "string_util.h" - -namespace benchmark { - -// Suppress unused warnings on helper functions. -#if defined(__GNUC__) -#pragma GCC diagnostic ignored "-Wunused-function" -#endif - -namespace { -#if defined(BENCHMARK_OS_WINDOWS) -double MakeTime(FILETIME const& kernel_time, FILETIME const& user_time) { - ULARGE_INTEGER kernel; - ULARGE_INTEGER user; - kernel.HighPart = kernel_time.dwHighDateTime; - kernel.LowPart = kernel_time.dwLowDateTime; - user.HighPart = user_time.dwHighDateTime; - user.LowPart = user_time.dwLowDateTime; - return (static_cast(kernel.QuadPart) + - static_cast(user.QuadPart)) * - 1e-7; -} -#elif !defined(BENCHMARK_OS_FUCHSIA) -double MakeTime(struct rusage const& ru) { - return (static_cast(ru.ru_utime.tv_sec) + - static_cast(ru.ru_utime.tv_usec) * 1e-6 + - static_cast(ru.ru_stime.tv_sec) + - static_cast(ru.ru_stime.tv_usec) * 1e-6); -} -#endif -#if defined(BENCHMARK_OS_MACOSX) -double MakeTime(thread_basic_info_data_t const& info) { - return (static_cast(info.user_time.seconds) + - static_cast(info.user_time.microseconds) * 1e-6 + - static_cast(info.system_time.seconds) + - static_cast(info.system_time.microseconds) * 1e-6); -} -#endif -#if defined(CLOCK_PROCESS_CPUTIME_ID) || defined(CLOCK_THREAD_CPUTIME_ID) -double MakeTime(struct timespec const& ts) { - return ts.tv_sec + (static_cast(ts.tv_nsec) * 1e-9); -} -#endif - -BENCHMARK_NORETURN static void DiagnoseAndExit(const char* msg) { - std::cerr << "ERROR: " << msg << std::endl; - std::exit(EXIT_FAILURE); -} - -} // end namespace - -double ProcessCPUUsage() { -#if defined(BENCHMARK_OS_WINDOWS) - HANDLE proc = GetCurrentProcess(); - FILETIME creation_time; - FILETIME exit_time; - FILETIME kernel_time; - FILETIME user_time; - if (GetProcessTimes(proc, &creation_time, &exit_time, &kernel_time, - &user_time)) - return MakeTime(kernel_time, user_time); - DiagnoseAndExit("GetProccessTimes() failed"); -#elif defined(BENCHMARK_OS_EMSCRIPTEN) - // clock_gettime(CLOCK_PROCESS_CPUTIME_ID, ...) returns 0 on Emscripten. - // Use Emscripten-specific API. Reported CPU time would be exactly the - // same as total time, but this is ok because there aren't long-latency - // syncronous system calls in Emscripten. - return emscripten_get_now() * 1e-3; -#elif defined(CLOCK_PROCESS_CPUTIME_ID) && !defined(BENCHMARK_OS_MACOSX) - // FIXME We want to use clock_gettime, but its not available in MacOS 10.11. See - // https://github.com/google/benchmark/pull/292 - struct timespec spec; - if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &spec) == 0) - return MakeTime(spec); - DiagnoseAndExit("clock_gettime(CLOCK_PROCESS_CPUTIME_ID, ...) failed"); -#else - struct rusage ru; - if (getrusage(RUSAGE_SELF, &ru) == 0) return MakeTime(ru); - DiagnoseAndExit("getrusage(RUSAGE_SELF, ...) failed"); -#endif -} - -double ThreadCPUUsage() { -#if defined(BENCHMARK_OS_WINDOWS) - HANDLE this_thread = GetCurrentThread(); - FILETIME creation_time; - FILETIME exit_time; - FILETIME kernel_time; - FILETIME user_time; - GetThreadTimes(this_thread, &creation_time, &exit_time, &kernel_time, - &user_time); - return MakeTime(kernel_time, user_time); -#elif defined(BENCHMARK_OS_MACOSX) - // FIXME We want to use clock_gettime, but its not available in MacOS 10.11. See - // https://github.com/google/benchmark/pull/292 - mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT; - thread_basic_info_data_t info; - mach_port_t thread = pthread_mach_thread_np(pthread_self()); - if (thread_info(thread, THREAD_BASIC_INFO, (thread_info_t)&info, &count) == - KERN_SUCCESS) { - return MakeTime(info); - } - DiagnoseAndExit("ThreadCPUUsage() failed when evaluating thread_info"); -#elif defined(BENCHMARK_OS_EMSCRIPTEN) - // Emscripten doesn't support traditional threads - return ProcessCPUUsage(); -#elif defined(BENCHMARK_OS_RTEMS) - // RTEMS doesn't support CLOCK_THREAD_CPUTIME_ID. See - // https://github.com/RTEMS/rtems/blob/master/cpukit/posix/src/clockgettime.c - return ProcessCPUUsage(); -#elif defined(BENCHMARK_OS_SOLARIS) - struct rusage ru; - if (getrusage(RUSAGE_LWP, &ru) == 0) return MakeTime(ru); - DiagnoseAndExit("getrusage(RUSAGE_LWP, ...) failed"); -#elif defined(CLOCK_THREAD_CPUTIME_ID) - struct timespec ts; - if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) == 0) return MakeTime(ts); - DiagnoseAndExit("clock_gettime(CLOCK_THREAD_CPUTIME_ID, ...) failed"); -#else -#error Per-thread timing is not available on your system. -#endif -} - -namespace { - -std::string DateTimeString(bool local) { - typedef std::chrono::system_clock Clock; - std::time_t now = Clock::to_time_t(Clock::now()); - const std::size_t kStorageSize = 128; - char storage[kStorageSize]; - std::size_t written; - - if (local) { -#if defined(BENCHMARK_OS_WINDOWS) - written = - std::strftime(storage, sizeof(storage), "%x %X", ::localtime(&now)); -#else - std::tm timeinfo; - ::localtime_r(&now, &timeinfo); - written = std::strftime(storage, sizeof(storage), "%F %T", &timeinfo); -#endif - } else { -#if defined(BENCHMARK_OS_WINDOWS) - written = std::strftime(storage, sizeof(storage), "%x %X", ::gmtime(&now)); -#else - std::tm timeinfo; - ::gmtime_r(&now, &timeinfo); - written = std::strftime(storage, sizeof(storage), "%F %T", &timeinfo); -#endif - } - CHECK(written < kStorageSize); - ((void)written); // prevent unused variable in optimized mode. - return std::string(storage); -} - -} // end namespace - -std::string LocalDateTimeString() { return DateTimeString(true); } - -} // end namespace benchmark diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/src/timers.h b/external_imported/json/benchmarks/thirdparty/benchmark/src/timers.h deleted file mode 100755 index 65606ccd9..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/src/timers.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef BENCHMARK_TIMERS_H -#define BENCHMARK_TIMERS_H - -#include -#include - -namespace benchmark { - -// Return the CPU usage of the current process -double ProcessCPUUsage(); - -// Return the CPU usage of the children of the current process -double ChildrenCPUUsage(); - -// Return the CPU usage of the current thread -double ThreadCPUUsage(); - -#if defined(HAVE_STEADY_CLOCK) -template -struct ChooseSteadyClock { - typedef std::chrono::high_resolution_clock type; -}; - -template <> -struct ChooseSteadyClock { - typedef std::chrono::steady_clock type; -}; -#endif - -struct ChooseClockType { -#if defined(HAVE_STEADY_CLOCK) - typedef ChooseSteadyClock<>::type type; -#else - typedef std::chrono::high_resolution_clock type; -#endif -}; - -inline double ChronoClockNow() { - typedef ChooseClockType::type ClockType; - using FpSeconds = std::chrono::duration; - return FpSeconds(ClockType::now().time_since_epoch()).count(); -} - -std::string LocalDateTimeString(); - -} // end namespace benchmark - -#endif // BENCHMARK_TIMERS_H diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/tools/compare.py b/external_imported/json/benchmarks/thirdparty/benchmark/tools/compare.py deleted file mode 100755 index f0a4455f5..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/tools/compare.py +++ /dev/null @@ -1,316 +0,0 @@ -#!/usr/bin/env python - -""" -compare.py - versatile benchmark output compare tool -""" - -import argparse -from argparse import ArgumentParser -import sys -import gbench -from gbench import util, report -from gbench.util import * - - -def check_inputs(in1, in2, flags): - """ - Perform checking on the user provided inputs and diagnose any abnormalities - """ - in1_kind, in1_err = classify_input_file(in1) - in2_kind, in2_err = classify_input_file(in2) - output_file = find_benchmark_flag('--benchmark_out=', flags) - output_type = find_benchmark_flag('--benchmark_out_format=', flags) - if in1_kind == IT_Executable and in2_kind == IT_Executable and output_file: - print(("WARNING: '--benchmark_out=%s' will be passed to both " - "benchmarks causing it to be overwritten") % output_file) - if in1_kind == IT_JSON and in2_kind == IT_JSON and len(flags) > 0: - print("WARNING: passing optional flags has no effect since both " - "inputs are JSON") - if output_type is not None and output_type != 'json': - print(("ERROR: passing '--benchmark_out_format=%s' to 'compare.py`" - " is not supported.") % output_type) - sys.exit(1) - - -def create_parser(): - parser = ArgumentParser( - description='versatile benchmark output compare tool') - subparsers = parser.add_subparsers( - help='This tool has multiple modes of operation:', - dest='mode') - - parser_a = subparsers.add_parser( - 'benchmarks', - help='The most simple use-case, compare all the output of these two benchmarks') - baseline = parser_a.add_argument_group( - 'baseline', 'The benchmark baseline') - baseline.add_argument( - 'test_baseline', - metavar='test_baseline', - type=argparse.FileType('r'), - nargs=1, - help='A benchmark executable or JSON output file') - contender = parser_a.add_argument_group( - 'contender', 'The benchmark that will be compared against the baseline') - contender.add_argument( - 'test_contender', - metavar='test_contender', - type=argparse.FileType('r'), - nargs=1, - help='A benchmark executable or JSON output file') - parser_a.add_argument( - 'benchmark_options', - metavar='benchmark_options', - nargs=argparse.REMAINDER, - help='Arguments to pass when running benchmark executables') - - parser_b = subparsers.add_parser( - 'filters', help='Compare filter one with the filter two of benchmark') - baseline = parser_b.add_argument_group( - 'baseline', 'The benchmark baseline') - baseline.add_argument( - 'test', - metavar='test', - type=argparse.FileType('r'), - nargs=1, - help='A benchmark executable or JSON output file') - baseline.add_argument( - 'filter_baseline', - metavar='filter_baseline', - type=str, - nargs=1, - help='The first filter, that will be used as baseline') - contender = parser_b.add_argument_group( - 'contender', 'The benchmark that will be compared against the baseline') - contender.add_argument( - 'filter_contender', - metavar='filter_contender', - type=str, - nargs=1, - help='The second filter, that will be compared against the baseline') - parser_b.add_argument( - 'benchmark_options', - metavar='benchmark_options', - nargs=argparse.REMAINDER, - help='Arguments to pass when running benchmark executables') - - parser_c = subparsers.add_parser( - 'benchmarksfiltered', - help='Compare filter one of first benchmark with filter two of the second benchmark') - baseline = parser_c.add_argument_group( - 'baseline', 'The benchmark baseline') - baseline.add_argument( - 'test_baseline', - metavar='test_baseline', - type=argparse.FileType('r'), - nargs=1, - help='A benchmark executable or JSON output file') - baseline.add_argument( - 'filter_baseline', - metavar='filter_baseline', - type=str, - nargs=1, - help='The first filter, that will be used as baseline') - contender = parser_c.add_argument_group( - 'contender', 'The benchmark that will be compared against the baseline') - contender.add_argument( - 'test_contender', - metavar='test_contender', - type=argparse.FileType('r'), - nargs=1, - help='The second benchmark executable or JSON output file, that will be compared against the baseline') - contender.add_argument( - 'filter_contender', - metavar='filter_contender', - type=str, - nargs=1, - help='The second filter, that will be compared against the baseline') - parser_c.add_argument( - 'benchmark_options', - metavar='benchmark_options', - nargs=argparse.REMAINDER, - help='Arguments to pass when running benchmark executables') - - return parser - - -def main(): - # Parse the command line flags - parser = create_parser() - args, unknown_args = parser.parse_known_args() - if args.mode is None: - parser.print_help() - exit(1) - assert not unknown_args - benchmark_options = args.benchmark_options - - if args.mode == 'benchmarks': - test_baseline = args.test_baseline[0].name - test_contender = args.test_contender[0].name - filter_baseline = '' - filter_contender = '' - - # NOTE: if test_baseline == test_contender, you are analyzing the stdev - - description = 'Comparing %s to %s' % (test_baseline, test_contender) - elif args.mode == 'filters': - test_baseline = args.test[0].name - test_contender = args.test[0].name - filter_baseline = args.filter_baseline[0] - filter_contender = args.filter_contender[0] - - # NOTE: if filter_baseline == filter_contender, you are analyzing the - # stdev - - description = 'Comparing %s to %s (from %s)' % ( - filter_baseline, filter_contender, args.test[0].name) - elif args.mode == 'benchmarksfiltered': - test_baseline = args.test_baseline[0].name - test_contender = args.test_contender[0].name - filter_baseline = args.filter_baseline[0] - filter_contender = args.filter_contender[0] - - # NOTE: if test_baseline == test_contender and - # filter_baseline == filter_contender, you are analyzing the stdev - - description = 'Comparing %s (from %s) to %s (from %s)' % ( - filter_baseline, test_baseline, filter_contender, test_contender) - else: - # should never happen - print("Unrecognized mode of operation: '%s'" % args.mode) - parser.print_help() - exit(1) - - check_inputs(test_baseline, test_contender, benchmark_options) - - options_baseline = [] - options_contender = [] - - if filter_baseline and filter_contender: - options_baseline = ['--benchmark_filter=%s' % filter_baseline] - options_contender = ['--benchmark_filter=%s' % filter_contender] - - # Run the benchmarks and report the results - json1 = json1_orig = gbench.util.run_or_load_benchmark( - test_baseline, benchmark_options + options_baseline) - json2 = json2_orig = gbench.util.run_or_load_benchmark( - test_contender, benchmark_options + options_contender) - - # Now, filter the benchmarks so that the difference report can work - if filter_baseline and filter_contender: - replacement = '[%s vs. %s]' % (filter_baseline, filter_contender) - json1 = gbench.report.filter_benchmark( - json1_orig, filter_baseline, replacement) - json2 = gbench.report.filter_benchmark( - json2_orig, filter_contender, replacement) - - # Diff and output - output_lines = gbench.report.generate_difference_report(json1, json2) - print(description) - for ln in output_lines: - print(ln) - - -import unittest - - -class TestParser(unittest.TestCase): - def setUp(self): - self.parser = create_parser() - testInputs = os.path.join( - os.path.dirname( - os.path.realpath(__file__)), - 'gbench', - 'Inputs') - self.testInput0 = os.path.join(testInputs, 'test1_run1.json') - self.testInput1 = os.path.join(testInputs, 'test1_run2.json') - - def test_benchmarks_basic(self): - parsed = self.parser.parse_args( - ['benchmarks', self.testInput0, self.testInput1]) - self.assertEqual(parsed.mode, 'benchmarks') - self.assertEqual(parsed.test_baseline[0].name, self.testInput0) - self.assertEqual(parsed.test_contender[0].name, self.testInput1) - self.assertFalse(parsed.benchmark_options) - - def test_benchmarks_with_remainder(self): - parsed = self.parser.parse_args( - ['benchmarks', self.testInput0, self.testInput1, 'd']) - self.assertEqual(parsed.mode, 'benchmarks') - self.assertEqual(parsed.test_baseline[0].name, self.testInput0) - self.assertEqual(parsed.test_contender[0].name, self.testInput1) - self.assertEqual(parsed.benchmark_options, ['d']) - - def test_benchmarks_with_remainder_after_doubleminus(self): - parsed = self.parser.parse_args( - ['benchmarks', self.testInput0, self.testInput1, '--', 'e']) - self.assertEqual(parsed.mode, 'benchmarks') - self.assertEqual(parsed.test_baseline[0].name, self.testInput0) - self.assertEqual(parsed.test_contender[0].name, self.testInput1) - self.assertEqual(parsed.benchmark_options, ['e']) - - def test_filters_basic(self): - parsed = self.parser.parse_args( - ['filters', self.testInput0, 'c', 'd']) - self.assertEqual(parsed.mode, 'filters') - self.assertEqual(parsed.test[0].name, self.testInput0) - self.assertEqual(parsed.filter_baseline[0], 'c') - self.assertEqual(parsed.filter_contender[0], 'd') - self.assertFalse(parsed.benchmark_options) - - def test_filters_with_remainder(self): - parsed = self.parser.parse_args( - ['filters', self.testInput0, 'c', 'd', 'e']) - self.assertEqual(parsed.mode, 'filters') - self.assertEqual(parsed.test[0].name, self.testInput0) - self.assertEqual(parsed.filter_baseline[0], 'c') - self.assertEqual(parsed.filter_contender[0], 'd') - self.assertEqual(parsed.benchmark_options, ['e']) - - def test_filters_with_remainder_after_doubleminus(self): - parsed = self.parser.parse_args( - ['filters', self.testInput0, 'c', 'd', '--', 'f']) - self.assertEqual(parsed.mode, 'filters') - self.assertEqual(parsed.test[0].name, self.testInput0) - self.assertEqual(parsed.filter_baseline[0], 'c') - self.assertEqual(parsed.filter_contender[0], 'd') - self.assertEqual(parsed.benchmark_options, ['f']) - - def test_benchmarksfiltered_basic(self): - parsed = self.parser.parse_args( - ['benchmarksfiltered', self.testInput0, 'c', self.testInput1, 'e']) - self.assertEqual(parsed.mode, 'benchmarksfiltered') - self.assertEqual(parsed.test_baseline[0].name, self.testInput0) - self.assertEqual(parsed.filter_baseline[0], 'c') - self.assertEqual(parsed.test_contender[0].name, self.testInput1) - self.assertEqual(parsed.filter_contender[0], 'e') - self.assertFalse(parsed.benchmark_options) - - def test_benchmarksfiltered_with_remainder(self): - parsed = self.parser.parse_args( - ['benchmarksfiltered', self.testInput0, 'c', self.testInput1, 'e', 'f']) - self.assertEqual(parsed.mode, 'benchmarksfiltered') - self.assertEqual(parsed.test_baseline[0].name, self.testInput0) - self.assertEqual(parsed.filter_baseline[0], 'c') - self.assertEqual(parsed.test_contender[0].name, self.testInput1) - self.assertEqual(parsed.filter_contender[0], 'e') - self.assertEqual(parsed.benchmark_options[0], 'f') - - def test_benchmarksfiltered_with_remainder_after_doubleminus(self): - parsed = self.parser.parse_args( - ['benchmarksfiltered', self.testInput0, 'c', self.testInput1, 'e', '--', 'g']) - self.assertEqual(parsed.mode, 'benchmarksfiltered') - self.assertEqual(parsed.test_baseline[0].name, self.testInput0) - self.assertEqual(parsed.filter_baseline[0], 'c') - self.assertEqual(parsed.test_contender[0].name, self.testInput1) - self.assertEqual(parsed.filter_contender[0], 'e') - self.assertEqual(parsed.benchmark_options[0], 'g') - - -if __name__ == '__main__': - # unittest.main() - main() - -# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 -# kate: tab-width: 4; replace-tabs on; indent-width 4; tab-indents: off; -# kate: indent-mode python; remove-trailing-spaces modified; diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/tools/compare_bench.py b/external_imported/json/benchmarks/thirdparty/benchmark/tools/compare_bench.py deleted file mode 100755 index 7bbf0d015..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/tools/compare_bench.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python -""" -compare_bench.py - Compare two benchmarks or their results and report the - difference. -""" -import argparse -from argparse import ArgumentParser -import sys -import gbench -from gbench import util, report -from gbench.util import * - -def check_inputs(in1, in2, flags): - """ - Perform checking on the user provided inputs and diagnose any abnormalities - """ - in1_kind, in1_err = classify_input_file(in1) - in2_kind, in2_err = classify_input_file(in2) - output_file = find_benchmark_flag('--benchmark_out=', flags) - output_type = find_benchmark_flag('--benchmark_out_format=', flags) - if in1_kind == IT_Executable and in2_kind == IT_Executable and output_file: - print(("WARNING: '--benchmark_out=%s' will be passed to both " - "benchmarks causing it to be overwritten") % output_file) - if in1_kind == IT_JSON and in2_kind == IT_JSON and len(flags) > 0: - print("WARNING: passing --benchmark flags has no effect since both " - "inputs are JSON") - if output_type is not None and output_type != 'json': - print(("ERROR: passing '--benchmark_out_format=%s' to 'compare_bench.py`" - " is not supported.") % output_type) - sys.exit(1) - - -def main(): - parser = ArgumentParser( - description='compare the results of two benchmarks') - parser.add_argument( - 'test1', metavar='test1', type=str, nargs=1, - help='A benchmark executable or JSON output file') - parser.add_argument( - 'test2', metavar='test2', type=str, nargs=1, - help='A benchmark executable or JSON output file') - parser.add_argument( - 'benchmark_options', metavar='benchmark_options', nargs=argparse.REMAINDER, - help='Arguments to pass when running benchmark executables' - ) - args, unknown_args = parser.parse_known_args() - # Parse the command line flags - test1 = args.test1[0] - test2 = args.test2[0] - if unknown_args: - # should never happen - print("Unrecognized positional argument arguments: '%s'" - % unknown_args) - exit(1) - benchmark_options = args.benchmark_options - check_inputs(test1, test2, benchmark_options) - # Run the benchmarks and report the results - json1 = gbench.util.run_or_load_benchmark(test1, benchmark_options) - json2 = gbench.util.run_or_load_benchmark(test2, benchmark_options) - output_lines = gbench.report.generate_difference_report(json1, json2) - print('Comparing %s to %s' % (test1, test2)) - for ln in output_lines: - print(ln) - - -if __name__ == '__main__': - main() diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/tools/gbench/Inputs/test1_run1.json b/external_imported/json/benchmarks/thirdparty/benchmark/tools/gbench/Inputs/test1_run1.json deleted file mode 100755 index d7ec6a9c8..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/tools/gbench/Inputs/test1_run1.json +++ /dev/null @@ -1,102 +0,0 @@ -{ - "context": { - "date": "2016-08-02 17:44:46", - "num_cpus": 4, - "mhz_per_cpu": 4228, - "cpu_scaling_enabled": false, - "library_build_type": "release" - }, - "benchmarks": [ - { - "name": "BM_SameTimes", - "iterations": 1000, - "real_time": 10, - "cpu_time": 10, - "time_unit": "ns" - }, - { - "name": "BM_2xFaster", - "iterations": 1000, - "real_time": 50, - "cpu_time": 50, - "time_unit": "ns" - }, - { - "name": "BM_2xSlower", - "iterations": 1000, - "real_time": 50, - "cpu_time": 50, - "time_unit": "ns" - }, - { - "name": "BM_1PercentFaster", - "iterations": 1000, - "real_time": 100, - "cpu_time": 100, - "time_unit": "ns" - }, - { - "name": "BM_1PercentSlower", - "iterations": 1000, - "real_time": 100, - "cpu_time": 100, - "time_unit": "ns" - }, - { - "name": "BM_10PercentFaster", - "iterations": 1000, - "real_time": 100, - "cpu_time": 100, - "time_unit": "ns" - }, - { - "name": "BM_10PercentSlower", - "iterations": 1000, - "real_time": 100, - "cpu_time": 100, - "time_unit": "ns" - }, - { - "name": "BM_100xSlower", - "iterations": 1000, - "real_time": 100, - "cpu_time": 100, - "time_unit": "ns" - }, - { - "name": "BM_100xFaster", - "iterations": 1000, - "real_time": 10000, - "cpu_time": 10000, - "time_unit": "ns" - }, - { - "name": "BM_10PercentCPUToTime", - "iterations": 1000, - "real_time": 100, - "cpu_time": 100, - "time_unit": "ns" - }, - { - "name": "BM_ThirdFaster", - "iterations": 1000, - "real_time": 100, - "cpu_time": 100, - "time_unit": "ns" - }, - { - "name": "BM_BadTimeUnit", - "iterations": 1000, - "real_time": 0.4, - "cpu_time": 0.5, - "time_unit": "s" - }, - { - "name": "BM_DifferentTimeUnit", - "iterations": 1, - "real_time": 1, - "cpu_time": 1, - "time_unit": "s" - } - ] -} diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/tools/gbench/Inputs/test1_run2.json b/external_imported/json/benchmarks/thirdparty/benchmark/tools/gbench/Inputs/test1_run2.json deleted file mode 100755 index 59a5ffaca..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/tools/gbench/Inputs/test1_run2.json +++ /dev/null @@ -1,102 +0,0 @@ -{ - "context": { - "date": "2016-08-02 17:44:46", - "num_cpus": 4, - "mhz_per_cpu": 4228, - "cpu_scaling_enabled": false, - "library_build_type": "release" - }, - "benchmarks": [ - { - "name": "BM_SameTimes", - "iterations": 1000, - "real_time": 10, - "cpu_time": 10, - "time_unit": "ns" - }, - { - "name": "BM_2xFaster", - "iterations": 1000, - "real_time": 25, - "cpu_time": 25, - "time_unit": "ns" - }, - { - "name": "BM_2xSlower", - "iterations": 20833333, - "real_time": 100, - "cpu_time": 100, - "time_unit": "ns" - }, - { - "name": "BM_1PercentFaster", - "iterations": 1000, - "real_time": 98.9999999, - "cpu_time": 98.9999999, - "time_unit": "ns" - }, - { - "name": "BM_1PercentSlower", - "iterations": 1000, - "real_time": 100.9999999, - "cpu_time": 100.9999999, - "time_unit": "ns" - }, - { - "name": "BM_10PercentFaster", - "iterations": 1000, - "real_time": 90, - "cpu_time": 90, - "time_unit": "ns" - }, - { - "name": "BM_10PercentSlower", - "iterations": 1000, - "real_time": 110, - "cpu_time": 110, - "time_unit": "ns" - }, - { - "name": "BM_100xSlower", - "iterations": 1000, - "real_time": 1.0000e+04, - "cpu_time": 1.0000e+04, - "time_unit": "ns" - }, - { - "name": "BM_100xFaster", - "iterations": 1000, - "real_time": 100, - "cpu_time": 100, - "time_unit": "ns" - }, - { - "name": "BM_10PercentCPUToTime", - "iterations": 1000, - "real_time": 110, - "cpu_time": 90, - "time_unit": "ns" - }, - { - "name": "BM_ThirdFaster", - "iterations": 1000, - "real_time": 66.665, - "cpu_time": 66.664, - "time_unit": "ns" - }, - { - "name": "BM_BadTimeUnit", - "iterations": 1000, - "real_time": 0.04, - "cpu_time": 0.6, - "time_unit": "s" - }, - { - "name": "BM_DifferentTimeUnit", - "iterations": 1, - "real_time": 1, - "cpu_time": 1, - "time_unit": "ns" - } - ] -} diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/tools/gbench/Inputs/test2_run.json b/external_imported/json/benchmarks/thirdparty/benchmark/tools/gbench/Inputs/test2_run.json deleted file mode 100755 index 15bc69803..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/tools/gbench/Inputs/test2_run.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "context": { - "date": "2016-08-02 17:44:46", - "num_cpus": 4, - "mhz_per_cpu": 4228, - "cpu_scaling_enabled": false, - "library_build_type": "release" - }, - "benchmarks": [ - { - "name": "BM_Hi", - "iterations": 1234, - "real_time": 42, - "cpu_time": 24, - "time_unit": "ms" - }, - { - "name": "BM_Zero", - "iterations": 1000, - "real_time": 10, - "cpu_time": 10, - "time_unit": "ns" - }, - { - "name": "BM_Zero/4", - "iterations": 4000, - "real_time": 40, - "cpu_time": 40, - "time_unit": "ns" - }, - { - "name": "Prefix/BM_Zero", - "iterations": 2000, - "real_time": 20, - "cpu_time": 20, - "time_unit": "ns" - }, - { - "name": "Prefix/BM_Zero/3", - "iterations": 3000, - "real_time": 30, - "cpu_time": 30, - "time_unit": "ns" - }, - { - "name": "BM_One", - "iterations": 5000, - "real_time": 5, - "cpu_time": 5, - "time_unit": "ns" - }, - { - "name": "BM_One/4", - "iterations": 2000, - "real_time": 20, - "cpu_time": 20, - "time_unit": "ns" - }, - { - "name": "Prefix/BM_One", - "iterations": 1000, - "real_time": 10, - "cpu_time": 10, - "time_unit": "ns" - }, - { - "name": "Prefix/BM_One/3", - "iterations": 1500, - "real_time": 15, - "cpu_time": 15, - "time_unit": "ns" - }, - { - "name": "BM_Bye", - "iterations": 5321, - "real_time": 11, - "cpu_time": 63, - "time_unit": "ns" - } - ] -} diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/tools/gbench/__init__.py b/external_imported/json/benchmarks/thirdparty/benchmark/tools/gbench/__init__.py deleted file mode 100755 index fce1a1acf..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/tools/gbench/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -"""Google Benchmark tooling""" - -__author__ = 'Eric Fiselier' -__email__ = 'eric@efcs.ca' -__versioninfo__ = (0, 5, 0) -__version__ = '.'.join(str(v) for v in __versioninfo__) + 'dev' - -__all__ = [] diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/tools/gbench/report.py b/external_imported/json/benchmarks/thirdparty/benchmark/tools/gbench/report.py deleted file mode 100755 index 0c090981a..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/tools/gbench/report.py +++ /dev/null @@ -1,208 +0,0 @@ -"""report.py - Utilities for reporting statistics about benchmark results -""" -import os -import re -import copy - -class BenchmarkColor(object): - def __init__(self, name, code): - self.name = name - self.code = code - - def __repr__(self): - return '%s%r' % (self.__class__.__name__, - (self.name, self.code)) - - def __format__(self, format): - return self.code - -# Benchmark Colors Enumeration -BC_NONE = BenchmarkColor('NONE', '') -BC_MAGENTA = BenchmarkColor('MAGENTA', '\033[95m') -BC_CYAN = BenchmarkColor('CYAN', '\033[96m') -BC_OKBLUE = BenchmarkColor('OKBLUE', '\033[94m') -BC_HEADER = BenchmarkColor('HEADER', '\033[92m') -BC_WARNING = BenchmarkColor('WARNING', '\033[93m') -BC_WHITE = BenchmarkColor('WHITE', '\033[97m') -BC_FAIL = BenchmarkColor('FAIL', '\033[91m') -BC_ENDC = BenchmarkColor('ENDC', '\033[0m') -BC_BOLD = BenchmarkColor('BOLD', '\033[1m') -BC_UNDERLINE = BenchmarkColor('UNDERLINE', '\033[4m') - -def color_format(use_color, fmt_str, *args, **kwargs): - """ - Return the result of 'fmt_str.format(*args, **kwargs)' after transforming - 'args' and 'kwargs' according to the value of 'use_color'. If 'use_color' - is False then all color codes in 'args' and 'kwargs' are replaced with - the empty string. - """ - assert use_color is True or use_color is False - if not use_color: - args = [arg if not isinstance(arg, BenchmarkColor) else BC_NONE - for arg in args] - kwargs = {key: arg if not isinstance(arg, BenchmarkColor) else BC_NONE - for key, arg in kwargs.items()} - return fmt_str.format(*args, **kwargs) - - -def find_longest_name(benchmark_list): - """ - Return the length of the longest benchmark name in a given list of - benchmark JSON objects - """ - longest_name = 1 - for bc in benchmark_list: - if len(bc['name']) > longest_name: - longest_name = len(bc['name']) - return longest_name - - -def calculate_change(old_val, new_val): - """ - Return a float representing the decimal change between old_val and new_val. - """ - if old_val == 0 and new_val == 0: - return 0.0 - if old_val == 0: - return float(new_val - old_val) / (float(old_val + new_val) / 2) - return float(new_val - old_val) / abs(old_val) - - -def filter_benchmark(json_orig, family, replacement=""): - """ - Apply a filter to the json, and only leave the 'family' of benchmarks. - """ - regex = re.compile(family) - filtered = {} - filtered['benchmarks'] = [] - for be in json_orig['benchmarks']: - if not regex.search(be['name']): - continue - filteredbench = copy.deepcopy(be) # Do NOT modify the old name! - filteredbench['name'] = regex.sub(replacement, filteredbench['name']) - filtered['benchmarks'].append(filteredbench) - return filtered - - -def generate_difference_report(json1, json2, use_color=True): - """ - Calculate and report the difference between each test of two benchmarks - runs specified as 'json1' and 'json2'. - """ - first_col_width = find_longest_name(json1['benchmarks']) - def find_test(name): - for b in json2['benchmarks']: - if b['name'] == name: - return b - return None - first_col_width = max(first_col_width, len('Benchmark')) - first_line = "{:<{}s}Time CPU Time Old Time New CPU Old CPU New".format( - 'Benchmark', 12 + first_col_width) - output_strs = [first_line, '-' * len(first_line)] - - gen = (bn for bn in json1['benchmarks'] if 'real_time' in bn and 'cpu_time' in bn) - for bn in gen: - other_bench = find_test(bn['name']) - if not other_bench: - continue - - if bn['time_unit'] != other_bench['time_unit']: - continue - - def get_color(res): - if res > 0.05: - return BC_FAIL - elif res > -0.07: - return BC_WHITE - else: - return BC_CYAN - fmt_str = "{}{:<{}s}{endc}{}{:+16.4f}{endc}{}{:+16.4f}{endc}{:14.0f}{:14.0f}{endc}{:14.0f}{:14.0f}" - tres = calculate_change(bn['real_time'], other_bench['real_time']) - cpures = calculate_change(bn['cpu_time'], other_bench['cpu_time']) - output_strs += [color_format(use_color, fmt_str, - BC_HEADER, bn['name'], first_col_width, - get_color(tres), tres, get_color(cpures), cpures, - bn['real_time'], other_bench['real_time'], - bn['cpu_time'], other_bench['cpu_time'], - endc=BC_ENDC)] - return output_strs - -############################################################################### -# Unit tests - -import unittest - -class TestReportDifference(unittest.TestCase): - def load_results(self): - import json - testInputs = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Inputs') - testOutput1 = os.path.join(testInputs, 'test1_run1.json') - testOutput2 = os.path.join(testInputs, 'test1_run2.json') - with open(testOutput1, 'r') as f: - json1 = json.load(f) - with open(testOutput2, 'r') as f: - json2 = json.load(f) - return json1, json2 - - def test_basic(self): - expect_lines = [ - ['BM_SameTimes', '+0.0000', '+0.0000', '10', '10', '10', '10'], - ['BM_2xFaster', '-0.5000', '-0.5000', '50', '25', '50', '25'], - ['BM_2xSlower', '+1.0000', '+1.0000', '50', '100', '50', '100'], - ['BM_1PercentFaster', '-0.0100', '-0.0100', '100', '99', '100', '99'], - ['BM_1PercentSlower', '+0.0100', '+0.0100', '100', '101', '100', '101'], - ['BM_10PercentFaster', '-0.1000', '-0.1000', '100', '90', '100', '90'], - ['BM_10PercentSlower', '+0.1000', '+0.1000', '100', '110', '100', '110'], - ['BM_100xSlower', '+99.0000', '+99.0000', '100', '10000', '100', '10000'], - ['BM_100xFaster', '-0.9900', '-0.9900', '10000', '100', '10000', '100'], - ['BM_10PercentCPUToTime', '+0.1000', '-0.1000', '100', '110', '100', '90'], - ['BM_ThirdFaster', '-0.3333', '-0.3334', '100', '67', '100', '67'], - ['BM_BadTimeUnit', '-0.9000', '+0.2000', '0', '0', '0', '1'], - ] - json1, json2 = self.load_results() - output_lines_with_header = generate_difference_report(json1, json2, use_color=False) - output_lines = output_lines_with_header[2:] - print("\n".join(output_lines_with_header)) - self.assertEqual(len(output_lines), len(expect_lines)) - for i in range(0, len(output_lines)): - parts = [x for x in output_lines[i].split(' ') if x] - self.assertEqual(len(parts), 7) - self.assertEqual(parts, expect_lines[i]) - - -class TestReportDifferenceBetweenFamilies(unittest.TestCase): - def load_result(self): - import json - testInputs = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Inputs') - testOutput = os.path.join(testInputs, 'test2_run.json') - with open(testOutput, 'r') as f: - json = json.load(f) - return json - - def test_basic(self): - expect_lines = [ - ['.', '-0.5000', '-0.5000', '10', '5', '10', '5'], - ['./4', '-0.5000', '-0.5000', '40', '20', '40', '20'], - ['Prefix/.', '-0.5000', '-0.5000', '20', '10', '20', '10'], - ['Prefix/./3', '-0.5000', '-0.5000', '30', '15', '30', '15'], - ] - json = self.load_result() - json1 = filter_benchmark(json, "BM_Z.ro", ".") - json2 = filter_benchmark(json, "BM_O.e", ".") - output_lines_with_header = generate_difference_report(json1, json2, use_color=False) - output_lines = output_lines_with_header[2:] - print("\n") - print("\n".join(output_lines_with_header)) - self.assertEqual(len(output_lines), len(expect_lines)) - for i in range(0, len(output_lines)): - parts = [x for x in output_lines[i].split(' ') if x] - self.assertEqual(len(parts), 7) - self.assertEqual(parts, expect_lines[i]) - - -if __name__ == '__main__': - unittest.main() - -# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 -# kate: tab-width: 4; replace-tabs on; indent-width 4; tab-indents: off; -# kate: indent-mode python; remove-trailing-spaces modified; diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/tools/gbench/util.py b/external_imported/json/benchmarks/thirdparty/benchmark/tools/gbench/util.py deleted file mode 100755 index 07c237727..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/tools/gbench/util.py +++ /dev/null @@ -1,159 +0,0 @@ -"""util.py - General utilities for running, loading, and processing benchmarks -""" -import json -import os -import tempfile -import subprocess -import sys - -# Input file type enumeration -IT_Invalid = 0 -IT_JSON = 1 -IT_Executable = 2 - -_num_magic_bytes = 2 if sys.platform.startswith('win') else 4 -def is_executable_file(filename): - """ - Return 'True' if 'filename' names a valid file which is likely - an executable. A file is considered an executable if it starts with the - magic bytes for a EXE, Mach O, or ELF file. - """ - if not os.path.isfile(filename): - return False - with open(filename, mode='rb') as f: - magic_bytes = f.read(_num_magic_bytes) - if sys.platform == 'darwin': - return magic_bytes in [ - b'\xfe\xed\xfa\xce', # MH_MAGIC - b'\xce\xfa\xed\xfe', # MH_CIGAM - b'\xfe\xed\xfa\xcf', # MH_MAGIC_64 - b'\xcf\xfa\xed\xfe', # MH_CIGAM_64 - b'\xca\xfe\xba\xbe', # FAT_MAGIC - b'\xbe\xba\xfe\xca' # FAT_CIGAM - ] - elif sys.platform.startswith('win'): - return magic_bytes == b'MZ' - else: - return magic_bytes == b'\x7FELF' - - -def is_json_file(filename): - """ - Returns 'True' if 'filename' names a valid JSON output file. - 'False' otherwise. - """ - try: - with open(filename, 'r') as f: - json.load(f) - return True - except: - pass - return False - - -def classify_input_file(filename): - """ - Return a tuple (type, msg) where 'type' specifies the classified type - of 'filename'. If 'type' is 'IT_Invalid' then 'msg' is a human readable - string represeting the error. - """ - ftype = IT_Invalid - err_msg = None - if not os.path.exists(filename): - err_msg = "'%s' does not exist" % filename - elif not os.path.isfile(filename): - err_msg = "'%s' does not name a file" % filename - elif is_executable_file(filename): - ftype = IT_Executable - elif is_json_file(filename): - ftype = IT_JSON - else: - err_msg = "'%s' does not name a valid benchmark executable or JSON file" % filename - return ftype, err_msg - - -def check_input_file(filename): - """ - Classify the file named by 'filename' and return the classification. - If the file is classified as 'IT_Invalid' print an error message and exit - the program. - """ - ftype, msg = classify_input_file(filename) - if ftype == IT_Invalid: - print("Invalid input file: %s" % msg) - sys.exit(1) - return ftype - -def find_benchmark_flag(prefix, benchmark_flags): - """ - Search the specified list of flags for a flag matching `` and - if it is found return the arg it specifies. If specified more than once the - last value is returned. If the flag is not found None is returned. - """ - assert prefix.startswith('--') and prefix.endswith('=') - result = None - for f in benchmark_flags: - if f.startswith(prefix): - result = f[len(prefix):] - return result - -def remove_benchmark_flags(prefix, benchmark_flags): - """ - Return a new list containing the specified benchmark_flags except those - with the specified prefix. - """ - assert prefix.startswith('--') and prefix.endswith('=') - return [f for f in benchmark_flags if not f.startswith(prefix)] - -def load_benchmark_results(fname): - """ - Read benchmark output from a file and return the JSON object. - REQUIRES: 'fname' names a file containing JSON benchmark output. - """ - with open(fname, 'r') as f: - return json.load(f) - - -def run_benchmark(exe_name, benchmark_flags): - """ - Run a benchmark specified by 'exe_name' with the specified - 'benchmark_flags'. The benchmark is run directly as a subprocess to preserve - real time console output. - RETURNS: A JSON object representing the benchmark output - """ - output_name = find_benchmark_flag('--benchmark_out=', - benchmark_flags) - is_temp_output = False - if output_name is None: - is_temp_output = True - thandle, output_name = tempfile.mkstemp() - os.close(thandle) - benchmark_flags = list(benchmark_flags) + \ - ['--benchmark_out=%s' % output_name] - - cmd = [exe_name] + benchmark_flags - print("RUNNING: %s" % ' '.join(cmd)) - exitCode = subprocess.call(cmd) - if exitCode != 0: - print('TEST FAILED...') - sys.exit(exitCode) - json_res = load_benchmark_results(output_name) - if is_temp_output: - os.unlink(output_name) - return json_res - - -def run_or_load_benchmark(filename, benchmark_flags): - """ - Get the results for a specified benchmark. If 'filename' specifies - an executable benchmark then the results are generated by running the - benchmark. Otherwise 'filename' must name a valid JSON output file, - which is loaded and the result returned. - """ - ftype = check_input_file(filename) - if ftype == IT_JSON: - return load_benchmark_results(filename) - elif ftype == IT_Executable: - return run_benchmark(filename, benchmark_flags) - else: - assert False # This branch is unreachable \ No newline at end of file diff --git a/external_imported/json/benchmarks/thirdparty/benchmark/tools/strip_asm.py b/external_imported/json/benchmarks/thirdparty/benchmark/tools/strip_asm.py deleted file mode 100755 index 9030550b4..000000000 --- a/external_imported/json/benchmarks/thirdparty/benchmark/tools/strip_asm.py +++ /dev/null @@ -1,151 +0,0 @@ -#!/usr/bin/env python - -""" -strip_asm.py - Cleanup ASM output for the specified file -""" - -from argparse import ArgumentParser -import sys -import os -import re - -def find_used_labels(asm): - found = set() - label_re = re.compile("\s*j[a-z]+\s+\.L([a-zA-Z0-9][a-zA-Z0-9_]*)") - for l in asm.splitlines(): - m = label_re.match(l) - if m: - found.add('.L%s' % m.group(1)) - return found - - -def normalize_labels(asm): - decls = set() - label_decl = re.compile("^[.]{0,1}L([a-zA-Z0-9][a-zA-Z0-9_]*)(?=:)") - for l in asm.splitlines(): - m = label_decl.match(l) - if m: - decls.add(m.group(0)) - if len(decls) == 0: - return asm - needs_dot = next(iter(decls))[0] != '.' - if not needs_dot: - return asm - for ld in decls: - asm = re.sub("(^|\s+)" + ld + "(?=:|\s)", '\\1.' + ld, asm) - return asm - - -def transform_labels(asm): - asm = normalize_labels(asm) - used_decls = find_used_labels(asm) - new_asm = '' - label_decl = re.compile("^\.L([a-zA-Z0-9][a-zA-Z0-9_]*)(?=:)") - for l in asm.splitlines(): - m = label_decl.match(l) - if not m or m.group(0) in used_decls: - new_asm += l - new_asm += '\n' - return new_asm - - -def is_identifier(tk): - if len(tk) == 0: - return False - first = tk[0] - if not first.isalpha() and first != '_': - return False - for i in range(1, len(tk)): - c = tk[i] - if not c.isalnum() and c != '_': - return False - return True - -def process_identifiers(l): - """ - process_identifiers - process all identifiers and modify them to have - consistent names across all platforms; specifically across ELF and MachO. - For example, MachO inserts an additional understore at the beginning of - names. This function removes that. - """ - parts = re.split(r'([a-zA-Z0-9_]+)', l) - new_line = '' - for tk in parts: - if is_identifier(tk): - if tk.startswith('__Z'): - tk = tk[1:] - elif tk.startswith('_') and len(tk) > 1 and \ - tk[1].isalpha() and tk[1] != 'Z': - tk = tk[1:] - new_line += tk - return new_line - - -def process_asm(asm): - """ - Strip the ASM of unwanted directives and lines - """ - new_contents = '' - asm = transform_labels(asm) - - # TODO: Add more things we want to remove - discard_regexes = [ - re.compile("\s+\..*$"), # directive - re.compile("\s*#(NO_APP|APP)$"), #inline ASM - re.compile("\s*#.*$"), # comment line - re.compile("\s*\.globa?l\s*([.a-zA-Z_][a-zA-Z0-9$_.]*)"), #global directive - re.compile("\s*\.(string|asciz|ascii|[1248]?byte|short|word|long|quad|value|zero)"), - ] - keep_regexes = [ - - ] - fn_label_def = re.compile("^[a-zA-Z_][a-zA-Z0-9_.]*:") - for l in asm.splitlines(): - # Remove Mach-O attribute - l = l.replace('@GOTPCREL', '') - add_line = True - for reg in discard_regexes: - if reg.match(l) is not None: - add_line = False - break - for reg in keep_regexes: - if reg.match(l) is not None: - add_line = True - break - if add_line: - if fn_label_def.match(l) and len(new_contents) != 0: - new_contents += '\n' - l = process_identifiers(l) - new_contents += l - new_contents += '\n' - return new_contents - -def main(): - parser = ArgumentParser( - description='generate a stripped assembly file') - parser.add_argument( - 'input', metavar='input', type=str, nargs=1, - help='An input assembly file') - parser.add_argument( - 'out', metavar='output', type=str, nargs=1, - help='The output file') - args, unknown_args = parser.parse_known_args() - input = args.input[0] - output = args.out[0] - if not os.path.isfile(input): - print(("ERROR: input file '%s' does not exist") % input) - sys.exit(1) - contents = None - with open(input, 'r') as f: - contents = f.read() - new_contents = process_asm(contents) - with open(output, 'w') as f: - f.write(new_contents) - - -if __name__ == '__main__': - main() - -# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 -# kate: tab-width: 4; replace-tabs on; indent-width 4; tab-indents: off; -# kate: indent-mode python; remove-trailing-spaces modified; diff --git a/external_imported/json/cmake/ci.cmake b/external_imported/json/cmake/ci.cmake new file mode 100644 index 000000000..bbb2d4cb9 --- /dev/null +++ b/external_imported/json/cmake/ci.cmake @@ -0,0 +1,983 @@ +# number of parallel jobs for CTest +set(N 10) + +############################################################################### +# Needed tools. +############################################################################### + +include(FindPython3) +find_package(Python3 COMPONENTS Interpreter) + +find_program(ASTYLE_TOOL NAMES astyle) +execute_process(COMMAND ${ASTYLE_TOOL} --version OUTPUT_VARIABLE ASTYLE_TOOL_VERSION ERROR_VARIABLE ASTYLE_TOOL_VERSION) +string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" ASTYLE_TOOL_VERSION "${ASTYLE_TOOL_VERSION}") +message(STATUS "🔖 Artistic Style ${ASTYLE_TOOL_VERSION} (${ASTYLE_TOOL})") + +find_program(CLANG_TOOL NAMES clang++-HEAD clang++ clang++-17 clang++-16 clang++-15 clang++-14 clang++-13 clang++-12 clang++-11 clang++) +execute_process(COMMAND ${CLANG_TOOL} --version OUTPUT_VARIABLE CLANG_TOOL_VERSION ERROR_VARIABLE CLANG_TOOL_VERSION) +string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CLANG_TOOL_VERSION "${CLANG_TOOL_VERSION}") +message(STATUS "🔖 Clang ${CLANG_TOOL_VERSION} (${CLANG_TOOL})") + +find_program(CLANG_TIDY_TOOL NAMES clang-tidy-17 clang-tidy-16 clang-tidy-15 clang-tidy-14 clang-tidy-13 clang-tidy-12 clang-tidy-11 clang-tidy) +execute_process(COMMAND ${CLANG_TIDY_TOOL} --version OUTPUT_VARIABLE CLANG_TIDY_TOOL_VERSION ERROR_VARIABLE CLANG_TIDY_TOOL_VERSION) +string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CLANG_TIDY_TOOL_VERSION "${CLANG_TIDY_TOOL_VERSION}") +message(STATUS "🔖 Clang-Tidy ${CLANG_TIDY_TOOL_VERSION} (${CLANG_TIDY_TOOL})") + +message(STATUS "🔖 CMake ${CMAKE_VERSION} (${CMAKE_COMMAND})") + +find_program(CPPCHECK_TOOL NAMES cppcheck) +execute_process(COMMAND ${CPPCHECK_TOOL} --version OUTPUT_VARIABLE CPPCHECK_TOOL_VERSION ERROR_VARIABLE CPPCHECK_TOOL_VERSION) +string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CPPCHECK_TOOL_VERSION "${CPPCHECK_TOOL_VERSION}") +message(STATUS "🔖 Cppcheck ${CPPCHECK_TOOL_VERSION} (${CPPCHECK_TOOL})") + +find_program(GCC_TOOL NAMES g++-latest g++-HEAD g++-13 g++-12 g++-11 g++-10) +execute_process(COMMAND ${GCC_TOOL} --version OUTPUT_VARIABLE GCC_TOOL_VERSION ERROR_VARIABLE GCC_TOOL_VERSION) +string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" GCC_TOOL_VERSION "${GCC_TOOL_VERSION}") +message(STATUS "🔖 GCC ${GCC_TOOL_VERSION} (${GCC_TOOL})") + +find_program(GCOV_TOOL NAMES gcov-HEAD gcov-11 gcov-10 gcov) +execute_process(COMMAND ${GCOV_TOOL} --version OUTPUT_VARIABLE GCOV_TOOL_VERSION ERROR_VARIABLE GCOV_TOOL_VERSION) +string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" GCOV_TOOL_VERSION "${GCOV_TOOL_VERSION}") +message(STATUS "🔖 GCOV ${GCOV_TOOL_VERSION} (${GCOV_TOOL})") + +find_program(GIT_TOOL NAMES git) +execute_process(COMMAND ${GIT_TOOL} --version OUTPUT_VARIABLE GIT_TOOL_VERSION ERROR_VARIABLE GIT_TOOL_VERSION) +string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" GIT_TOOL_VERSION "${GIT_TOOL_VERSION}") +message(STATUS "🔖 Git ${GIT_TOOL_VERSION} (${GIT_TOOL})") + +find_program(IWYU_TOOL NAMES include-what-you-use iwyu) +execute_process(COMMAND ${IWYU_TOOL} --version OUTPUT_VARIABLE IWYU_TOOL_VERSION ERROR_VARIABLE IWYU_TOOL_VERSION) +string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" IWYU_TOOL_VERSION "${IWYU_TOOL_VERSION}") +message(STATUS "🔖 include-what-you-use ${IWYU_TOOL_VERSION} (${IWYU_TOOL})") + +find_program(INFER_TOOL NAMES infer) +execute_process(COMMAND ${INFER_TOOL} --version OUTPUT_VARIABLE INFER_TOOL_VERSION ERROR_VARIABLE INFER_TOOL_VERSION) +string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" INFER_TOOL_VERSION "${INFER_TOOL_VERSION}") +message(STATUS "🔖 Infer ${INFER_TOOL_VERSION} (${INFER_TOOL})") + +find_program(LCOV_TOOL NAMES lcov) +execute_process(COMMAND ${LCOV_TOOL} --version OUTPUT_VARIABLE LCOV_TOOL_VERSION ERROR_VARIABLE LCOV_TOOL_VERSION) +string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" LCOV_TOOL_VERSION "${LCOV_TOOL_VERSION}") +message(STATUS "🔖 LCOV ${LCOV_TOOL_VERSION} (${LCOV_TOOL})") + +find_program(NINJA_TOOL NAMES ninja) +execute_process(COMMAND ${NINJA_TOOL} --version OUTPUT_VARIABLE NINJA_TOOL_VERSION ERROR_VARIABLE NINJA_TOOL_VERSION) +string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" NINJA_TOOL_VERSION "${NINJA_TOOL_VERSION}") +message(STATUS "🔖 Ninja ${NINJA_TOOL_VERSION} (${NINJA_TOOL})") + +find_program(OCLINT_TOOL NAMES oclint-json-compilation-database) +find_program(OCLINT_VERSION_TOOL NAMES oclint) +execute_process(COMMAND ${OCLINT_VERSION_TOOL} --version OUTPUT_VARIABLE OCLINT_TOOL_VERSION ERROR_VARIABLE OCLINT_TOOL_VERSION) +string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" OCLINT_TOOL_VERSION "${OCLINT_TOOL_VERSION}") +message(STATUS "🔖 OCLint ${OCLINT_TOOL_VERSION} (${OCLINT_TOOL})") + +find_program(VALGRIND_TOOL NAMES valgrind) +execute_process(COMMAND ${VALGRIND_TOOL} --version OUTPUT_VARIABLE VALGRIND_TOOL_VERSION ERROR_VARIABLE VALGRIND_TOOL_VERSION) +string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" VALGRIND_TOOL_VERSION "${VALGRIND_TOOL_VERSION}") +message(STATUS "🔖 Valgrind ${VALGRIND_TOOL_VERSION} (${VALGRIND_TOOL})") + +find_program(GENHTML_TOOL NAMES genhtml) +find_program(PLOG_CONVERTER_TOOL NAMES plog-converter) +find_program(PVS_STUDIO_ANALYZER_TOOL NAMES pvs-studio-analyzer) +find_program(SCAN_BUILD_TOOL NAMES scan-build-15 scan-build-14 scan-build-13 scan-build-12 scan-build-11 scan-build) + +# the individual source files +file(GLOB_RECURSE SRC_FILES ${PROJECT_SOURCE_DIR}/include/nlohmann/*.hpp) + +############################################################################### +# Thorough check with recent compilers +############################################################################### + +# Ignored Clang warnings: +# -Wno-c++98-compat The library targets C++11. +# -Wno-c++98-compat-pedantic The library targets C++11. +# -Wno-deprecated-declarations The library contains annotations for deprecated functions. +# -Wno-extra-semi-stmt The library uses std::assert which triggers this warning. +# -Wno-padded We do not care about padding warnings. +# -Wno-covered-switch-default All switches list all cases and a default case. +# -Wno-unsafe-buffer-usage Otherwise Doctest would not compile. +# -Wno-weak-vtables The library is header-only. +# -Wreserved-identifier See https://github.com/onqtam/doctest/issues/536. + +set(CLANG_CXXFLAGS + -Werror + -Weverything + -Wno-c++98-compat + -Wno-c++98-compat-pedantic + -Wno-deprecated-declarations + -Wno-extra-semi-stmt + -Wno-padded + -Wno-covered-switch-default + -Wno-unsafe-buffer-usage + -Wno-weak-vtables + -Wno-reserved-identifier +) + +# Warning flags determined for GCC 13.0 (experimental) with https://github.com/nlohmann/gcc_flags: +# Ignored GCC warnings: +# -Wno-abi-tag We do not care about ABI tags. +# -Wno-aggregate-return The library uses aggregate returns. +# -Wno-long-long The library uses the long long type to interface with system functions. +# -Wno-namespaces The library uses namespaces. +# -Wno-padded We do not care about padding warnings. +# -Wno-system-headers We do not care about warnings in system headers. +# -Wno-templates The library uses templates. + +set(GCC_CXXFLAGS + -pedantic + -Werror + --all-warnings + --extra-warnings + -W + -WNSObject-attribute + -Wno-abi-tag + -Waddress + -Waddress-of-packed-member + -Wno-aggregate-return + -Waggressive-loop-optimizations + -Waligned-new=all + -Wall + -Walloc-zero + -Walloca + -Wanalyzer-double-fclose + -Wanalyzer-double-free + -Wanalyzer-exposure-through-output-file + -Wanalyzer-file-leak + -Wanalyzer-free-of-non-heap + -Wanalyzer-malloc-leak + -Wanalyzer-mismatching-deallocation + -Wanalyzer-null-argument + -Wanalyzer-null-dereference + -Wanalyzer-possible-null-argument + -Wanalyzer-possible-null-dereference + -Wanalyzer-shift-count-negative + -Wanalyzer-shift-count-overflow + -Wanalyzer-stale-setjmp-buffer + -Wanalyzer-tainted-allocation-size + -Wanalyzer-tainted-array-index + -Wanalyzer-tainted-divisor + -Wanalyzer-tainted-offset + -Wanalyzer-tainted-size + -Wanalyzer-too-complex + -Wanalyzer-unsafe-call-within-signal-handler + -Wanalyzer-use-after-free + -Wanalyzer-use-of-pointer-in-stale-stack-frame + -Wanalyzer-use-of-uninitialized-value + -Wanalyzer-va-arg-type-mismatch + -Wanalyzer-va-list-exhausted + -Wanalyzer-va-list-leak + -Wanalyzer-va-list-use-after-va-end + -Wanalyzer-write-to-const + -Wanalyzer-write-to-string-literal + -Warith-conversion + -Warray-bounds=2 + -Warray-compare + -Warray-parameter=2 + -Wattribute-alias=2 + -Wattribute-warning + -Wattributes + -Wbool-compare + -Wbool-operation + -Wbuiltin-declaration-mismatch + -Wbuiltin-macro-redefined + -Wc++0x-compat + -Wc++11-compat + -Wc++11-extensions + -Wc++14-compat + -Wc++14-extensions + -Wc++17-compat + -Wc++17-extensions + -Wc++1z-compat + -Wc++20-compat + -Wc++20-extensions + -Wc++23-extensions + -Wc++2a-compat + -Wcannot-profile + -Wcast-align + -Wcast-align=strict + -Wcast-function-type + -Wcast-qual + -Wcatch-value=3 + -Wchar-subscripts + -Wclass-conversion + -Wclass-memaccess + -Wclobbered + -Wcomma-subscript + -Wcomment + -Wcomments + -Wconditionally-supported + -Wconversion + -Wconversion-null + -Wcoverage-invalid-line-number + -Wcoverage-mismatch + -Wcpp + -Wctad-maybe-unsupported + -Wctor-dtor-privacy + -Wdangling-else + -Wdangling-pointer=2 + -Wdate-time + -Wdelete-incomplete + -Wdelete-non-virtual-dtor + -Wdeprecated + -Wdeprecated-copy + -Wdeprecated-copy-dtor + -Wdeprecated-declarations + -Wdeprecated-enum-enum-conversion + -Wdeprecated-enum-float-conversion + -Wdisabled-optimization + -Wdiv-by-zero + -Wdouble-promotion + -Wduplicated-branches + -Wduplicated-cond + -Weffc++ + -Wempty-body + -Wendif-labels + -Wenum-compare + -Wenum-conversion + -Wexceptions + -Wexpansion-to-defined + -Wextra + -Wextra-semi + -Wfloat-conversion + -Wfloat-equal + -Wformat-diag + -Wformat-overflow=2 + -Wformat-signedness + -Wformat-truncation=2 + -Wformat=2 + -Wframe-address + -Wfree-nonheap-object + -Whsa + -Wif-not-aligned + -Wignored-attributes + -Wignored-qualifiers + -Wimplicit-fallthrough=5 + -Winaccessible-base + -Winfinite-recursion + -Winherited-variadic-ctor + -Winit-list-lifetime + -Winit-self + -Winline + -Wint-in-bool-context + -Wint-to-pointer-cast + -Winterference-size + -Winvalid-imported-macros + -Winvalid-memory-model + -Winvalid-offsetof + -Winvalid-pch + -Wliteral-suffix + -Wlogical-not-parentheses + -Wlogical-op + -Wno-long-long + -Wlto-type-mismatch + -Wmain + -Wmaybe-uninitialized + -Wmemset-elt-size + -Wmemset-transposed-args + -Wmisleading-indentation + -Wmismatched-dealloc + -Wmismatched-new-delete + -Wmismatched-tags + -Wmissing-attributes + -Wmissing-braces + -Wmissing-declarations + -Wmissing-field-initializers + -Wmissing-include-dirs + -Wmissing-profile + -Wmissing-requires + -Wmissing-template-keyword + -Wmultichar + -Wmultiple-inheritance + -Wmultistatement-macros + -Wno-namespaces + -Wnarrowing + -Wnoexcept + -Wnoexcept-type + -Wnon-template-friend + -Wnon-virtual-dtor + -Wnonnull + -Wnonnull-compare + -Wnormalized=nfkc + -Wnull-dereference + -Wodr + -Wold-style-cast + -Wopenacc-parallelism + -Wopenmp-simd + -Woverflow + -Woverlength-strings + -Woverloaded-virtual + -Wpacked + -Wpacked-bitfield-compat + -Wpacked-not-aligned + -Wno-padded + -Wparentheses + -Wpedantic + -Wpessimizing-move + -Wplacement-new=2 + -Wpmf-conversions + -Wpointer-arith + -Wpointer-compare + -Wpragmas + -Wprio-ctor-dtor + -Wpsabi + -Wrange-loop-construct + -Wredundant-decls + -Wredundant-move + -Wredundant-tags + -Wregister + -Wreorder + -Wrestrict + -Wreturn-local-addr + -Wreturn-type + -Wscalar-storage-order + -Wsequence-point + -Wshadow=compatible-local + -Wshadow=global + -Wshadow=local + -Wshift-count-negative + -Wshift-count-overflow + -Wshift-negative-value + -Wshift-overflow=2 + -Wsign-compare + -Wsign-conversion + -Wsign-promo + -Wsized-deallocation + -Wsizeof-array-argument + -Wsizeof-array-div + -Wsizeof-pointer-div + -Wsizeof-pointer-memaccess + -Wstack-protector + -Wstrict-aliasing=3 + -Wstrict-null-sentinel + -Wno-strict-overflow + -Wstring-compare + -Wstringop-overflow=4 + -Wstringop-overread + -Wstringop-truncation + -Wsubobject-linkage + -Wsuggest-attribute=cold + -Wsuggest-attribute=const + -Wsuggest-attribute=format + -Wsuggest-attribute=malloc + -Wsuggest-attribute=noreturn + -Wsuggest-attribute=pure + -Wsuggest-final-methods + -Wsuggest-final-types + -Wsuggest-override + -Wswitch + -Wswitch-bool + -Wswitch-default + -Wswitch-enum + -Wswitch-outside-range + -Wswitch-unreachable + -Wsync-nand + -Wsynth + -Wno-system-headers + -Wtautological-compare + -Wno-templates + -Wterminate + -Wtrampolines + -Wtrigraphs + -Wtrivial-auto-var-init + -Wtsan + -Wtype-limits + -Wundef + -Wuninitialized + -Wunknown-pragmas + -Wunreachable-code + -Wunsafe-loop-optimizations + -Wunused + -Wunused-but-set-parameter + -Wunused-but-set-variable + -Wunused-const-variable=2 + -Wunused-function + -Wunused-label + -Wunused-local-typedefs + -Wunused-macros + -Wunused-parameter + -Wunused-result + -Wunused-value + -Wunused-variable + -Wuse-after-free=3 + -Wuseless-cast + -Wvarargs + -Wvariadic-macros + -Wvector-operation-performance + -Wvexing-parse + -Wvirtual-inheritance + -Wvirtual-move-assign + -Wvla + -Wvla-parameter + -Wvolatile + -Wvolatile-register-var + -Wwrite-strings + -Wzero-as-null-pointer-constant + -Wzero-length-bounds +) + +add_custom_target(ci_test_gcc + COMMAND CXX=${GCC_TOOL} CXXFLAGS="${GCC_CXXFLAGS}" ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DJSON_BuildTests=ON + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_gcc + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_gcc + COMMAND cd ${PROJECT_BINARY_DIR}/build_gcc && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure + COMMENT "Compile and test with GCC using maximal warning flags" +) + +add_custom_target(ci_test_clang + COMMAND CXX=${CLANG_TOOL} CXXFLAGS="${CLANG_CXXFLAGS}" ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DJSON_BuildTests=ON + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_clang + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_clang + COMMAND cd ${PROJECT_BINARY_DIR}/build_clang && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure + COMMENT "Compile and test with Clang using maximal warning flags" +) + +############################################################################### +# Different C++ Standards. +############################################################################### + +foreach(CXX_STANDARD 11 14 17 20 23) + add_custom_target(ci_test_gcc_cxx${CXX_STANDARD} + COMMAND CXX=${GCC_TOOL} CXXFLAGS="${GCC_CXXFLAGS}" ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DJSON_BuildTests=ON -DJSON_FastTests=ON + -DJSON_TestStandards=${CXX_STANDARD} + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_gcc_cxx${CXX_STANDARD} + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_gcc_cxx${CXX_STANDARD} + COMMAND cd ${PROJECT_BINARY_DIR}/build_gcc_cxx${CXX_STANDARD} && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure + COMMENT "Compile and test with GCC for C++${CXX_STANDARD}" + ) + + add_custom_target(ci_test_clang_cxx${CXX_STANDARD} + COMMAND CXX=${CLANG_TOOL} CXXFLAGS="${CLANG_CXXFLAGS}" ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DJSON_BuildTests=ON -DJSON_FastTests=ON + -DJSON_TestStandards=${CXX_STANDARD} + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_clang_cxx${CXX_STANDARD} + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_clang_cxx${CXX_STANDARD} + COMMAND cd ${PROJECT_BINARY_DIR}/build_clang_cxx${CXX_STANDARD} && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure + COMMENT "Compile and test with Clang for C++${CXX_STANDARD}" + ) +endforeach() + +############################################################################### +# Disable exceptions. +############################################################################### + +add_custom_target(ci_test_noexceptions + COMMAND ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DJSON_BuildTests=ON -DCMAKE_CXX_FLAGS=-DJSON_NOEXCEPTION -DDOCTEST_TEST_FILTER=--no-throw + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_noexceptions + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_noexceptions + COMMAND cd ${PROJECT_BINARY_DIR}/build_noexceptions && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure + COMMENT "Compile and test with exceptions switched off" +) + +############################################################################### +# Disable implicit conversions. +############################################################################### + +add_custom_target(ci_test_noimplicitconversions + COMMAND ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DJSON_BuildTests=ON -DJSON_ImplicitConversions=OFF + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_noimplicitconversions + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_noimplicitconversions + COMMAND cd ${PROJECT_BINARY_DIR}/build_noimplicitconversions && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure + COMMENT "Compile and test with implicit conversions switched off" +) + +############################################################################### +# Enable improved diagnostics. +############################################################################### + +add_custom_target(ci_test_diagnostics + COMMAND ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DJSON_BuildTests=ON -DJSON_Diagnostics=ON + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_diagnostics + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_diagnostics + COMMAND cd ${PROJECT_BINARY_DIR}/build_diagnostics && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure + COMMENT "Compile and test with improved diagnostics enabled" +) + +############################################################################### +# Enable legacy discarded value comparison. +############################################################################### + +add_custom_target(ci_test_legacycomparison + COMMAND ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DJSON_BuildTests=ON -DJSON_LegacyDiscardedValueComparison=ON + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_legacycomparison + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_legacycomparison + COMMAND cd ${PROJECT_BINARY_DIR}/build_legacycomparison && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure + COMMENT "Compile and test with legacy discarded value comparison enabled" +) + +############################################################################### +# Disable global UDLs. +############################################################################### + +add_custom_target(ci_test_noglobaludls + COMMAND ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DJSON_BuildTests=ON -DJSON_FastTests=ON -DJSON_GlobalUDLs=OFF + -DCMAKE_CXX_FLAGS=-DJSON_TEST_NO_GLOBAL_UDLS + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_noglobaludls + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_noglobaludls + COMMAND cd ${PROJECT_BINARY_DIR}/build_noglobaludls && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure + COMMENT "Compile and test with global UDLs disabled" +) + +############################################################################### +# Coverage. +############################################################################### + +add_custom_target(ci_test_coverage + COMMAND CXX=g++ ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_CXX_FLAGS="--coverage;-fprofile-arcs;-ftest-coverage" + -DJSON_BuildTests=ON + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_coverage + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_coverage + COMMAND cd ${PROJECT_BINARY_DIR}/build_coverage && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure + + COMMAND CXX=g++ ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_CXX_FLAGS="-m32;--coverage;-fprofile-arcs;-ftest-coverage" + -DJSON_BuildTests=ON -DJSON_32bitTest=ONLY + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_coverage32 + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_coverage32 + COMMAND cd ${PROJECT_BINARY_DIR}/build_coverage32 && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure + + COMMAND ${LCOV_TOOL} --directory . --capture --output-file json.info --rc lcov_branch_coverage=1 + COMMAND ${LCOV_TOOL} -e json.info ${SRC_FILES} --output-file json.info.filtered --rc lcov_branch_coverage=1 + COMMAND ${CMAKE_SOURCE_DIR}/tests/thirdparty/imapdl/filterbr.py json.info.filtered > json.info.filtered.noexcept + COMMAND genhtml --title "JSON for Modern C++" --legend --demangle-cpp --output-directory html --show-details --branch-coverage json.info.filtered.noexcept + + COMMENT "Compile and test with coverage" +) + +############################################################################### +# Sanitizers. +############################################################################### + +set(CLANG_CXX_FLAGS_SANITIZER "-g -O1 -fsanitize=address -fsanitize=undefined -fsanitize=integer -fsanitize=nullability -fno-omit-frame-pointer -fno-sanitize-recover=all -fno-sanitize=unsigned-integer-overflow -fno-sanitize=unsigned-shift-base") + +add_custom_target(ci_test_clang_sanitizer + COMMAND CXX=${CLANG_TOOL} CXXFLAGS=${CLANG_CXX_FLAGS_SANITIZER} ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DJSON_BuildTests=ON + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_clang_sanitizer + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_clang_sanitizer + COMMAND cd ${PROJECT_BINARY_DIR}/build_clang_sanitizer && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure + COMMENT "Compile and test with sanitizers" +) + +############################################################################### +# Check if header is amalgamated and sources are properly indented. +############################################################################### + +set(ASTYLE_FLAGS --style=allman --indent=spaces=4 --indent-modifiers --indent-switches --indent-preproc-block --indent-preproc-define --indent-col1-comments --pad-oper --pad-header --align-pointer=type --align-reference=type --add-brackets --convert-tabs --close-templates --lineend=linux --preserve-date --formatted) + +file(GLOB_RECURSE INDENT_FILES + ${PROJECT_SOURCE_DIR}/include/nlohmann/*.hpp + ${PROJECT_SOURCE_DIR}/tests/src/*.cpp + ${PROJECT_SOURCE_DIR}/tests/src/*.hpp + ${PROJECT_SOURCE_DIR}/tests/benchmarks/src/benchmarks.cpp + ${PROJECT_SOURCE_DIR}/docs/examples/*.cpp +) + +set(include_dir ${PROJECT_SOURCE_DIR}/single_include/nlohmann) +set(tool_dir ${PROJECT_SOURCE_DIR}/tools/amalgamate) +add_custom_target(ci_test_amalgamation + COMMAND rm -fr ${include_dir}/json.hpp~ ${include_dir}/json_fwd.hpp~ + COMMAND cp ${include_dir}/json.hpp ${include_dir}/json.hpp~ + COMMAND cp ${include_dir}/json_fwd.hpp ${include_dir}/json_fwd.hpp~ + + COMMAND ${Python3_EXECUTABLE} ${tool_dir}/amalgamate.py -c ${tool_dir}/config_json.json -s . + COMMAND ${Python3_EXECUTABLE} ${tool_dir}/amalgamate.py -c ${tool_dir}/config_json_fwd.json -s . + COMMAND ${ASTYLE_TOOL} ${ASTYLE_FLAGS} --suffix=none --quiet ${include_dir}/json.hpp ${include_dir}/json_fwd.hpp + + COMMAND diff ${include_dir}/json.hpp~ ${include_dir}/json.hpp + COMMAND diff ${include_dir}/json_fwd.hpp~ ${include_dir}/json_fwd.hpp + + COMMAND ${ASTYLE_TOOL} ${ASTYLE_FLAGS} ${INDENT_FILES} + COMMAND for FILE in `find . -name '*.orig'`\; do false \; done + + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + COMMENT "Check amalgamation and indentation" +) + +############################################################################### +# Build and test using the amalgamated header +############################################################################### + +add_custom_target(ci_test_single_header + COMMAND CXX=${GCC_TOOL} CXXFLAGS="${GCC_CXXFLAGS}" ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DJSON_BuildTests=ON -DJSON_MultipleHeaders=OFF -DJSON_FastTests=ON + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_single_header + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_single_header + COMMAND cd ${PROJECT_BINARY_DIR}/build_single_header && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure + COMMENT "Compile and test single-header version" +) + +############################################################################### +# Valgrind. +############################################################################### + +add_custom_target(ci_test_valgrind + COMMAND CXX=${GCC_TOOL} ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DJSON_BuildTests=ON -DJSON_Valgrind=ON + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_valgrind + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_valgrind + COMMAND cd ${PROJECT_BINARY_DIR}/build_valgrind && ${CMAKE_CTEST_COMMAND} -L valgrind --parallel ${N} --output-on-failure + COMMENT "Compile and test with Valgrind" +) + +############################################################################### +# Check code with Clang Static Analyzer. +############################################################################### + +set(CLANG_ANALYZER_CHECKS "fuchsia.HandleChecker,nullability.NullableDereferenced,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,optin.cplusplus.UninitializedObject,optin.cplusplus.VirtualCall,optin.mpi.MPI-Checker,optin.osx.OSObjectCStyleCast,optin.osx.cocoa.localizability.EmptyLocalizationContextChecker,optin.osx.cocoa.localizability.NonLocalizedStringChecker,optin.performance.GCDAntipattern,optin.performance.Padding,optin.portability.UnixAPI,security.FloatLoopCounter,security.insecureAPI.DeprecatedOrUnsafeBufferHandling,security.insecureAPI.bcmp,security.insecureAPI.bcopy,security.insecureAPI.bzero,security.insecureAPI.rand,security.insecureAPI.strcpy,valist.CopyToSelf,valist.Uninitialized,valist.Unterminated,webkit.NoUncountedMemberChecker,webkit.RefCntblBaseVirtualDtor,core.CallAndMessage,core.DivideZero,core.NonNullParamChecker,core.NullDereference,core.StackAddressEscape,core.UndefinedBinaryOperatorResult,core.VLASize,core.uninitialized.ArraySubscript,core.uninitialized.Assign,core.uninitialized.Branch,core.uninitialized.CapturedBlockVariable,core.uninitialized.UndefReturn,cplusplus.InnerPointer,cplusplus.Move,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,cplusplus.PlacementNew,cplusplus.PureVirtualCall,deadcode.DeadStores,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull,osx.API,osx.MIG,osx.NumberObjectConversion,osx.OSObjectRetainCount,osx.ObjCProperty,osx.SecKeychainAPI,osx.cocoa.AtSync,osx.cocoa.AutoreleaseWrite,osx.cocoa.ClassRelease,osx.cocoa.Dealloc,osx.cocoa.IncompatibleMethodTypes,osx.cocoa.Loops,osx.cocoa.MissingSuperCall,osx.cocoa.NSAutoreleasePool,osx.cocoa.NSError,osx.cocoa.NilArg,osx.cocoa.NonNilReturnValue,osx.cocoa.ObjCGenerics,osx.cocoa.RetainCount,osx.cocoa.RunLoopAutoreleaseLeak,osx.cocoa.SelfInit,osx.cocoa.SuperDealloc,osx.cocoa.UnusedIvars,osx.cocoa.VariadicMethodTypes,osx.coreFoundation.CFError,osx.coreFoundation.CFNumber,osx.coreFoundation.CFRetainRelease,osx.coreFoundation.containers.OutOfBounds,osx.coreFoundation.containers.PointerSizedValues,security.insecureAPI.UncheckedReturn,security.insecureAPI.decodeValueOfObjCType,security.insecureAPI.getpw,security.insecureAPI.gets,security.insecureAPI.mkstemp,security.insecureAPI.mktemp,security.insecureAPI.vfork,unix.API,unix.Malloc,unix.MallocSizeof,unix.MismatchedDeallocator,unix.Vfork,unix.cstring.BadSizeArg,unix.cstring.NullArg") + +add_custom_target(ci_clang_analyze + COMMAND CXX=${CLANG_TOOL} ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DJSON_BuildTests=ON + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_clang_analyze + COMMAND cd ${PROJECT_BINARY_DIR}/build_clang_analyze && ${SCAN_BUILD_TOOL} -enable-checker ${CLANG_ANALYZER_CHECKS} --use-c++=${CLANG_TOOL} -analyze-headers -o ${PROJECT_BINARY_DIR}/report ninja + COMMENT "Check code with Clang Analyzer" +) + +############################################################################### +# Check code with Cppcheck. +############################################################################### + +add_custom_target(ci_cppcheck + COMMAND ${CPPCHECK_TOOL} --enable=warning --suppress=missingReturn --inline-suppr --inconclusive --force --std=c++11 ${PROJECT_SOURCE_DIR}/single_include/nlohmann/json.hpp --error-exitcode=1 + COMMENT "Check code with Cppcheck" +) + +############################################################################### +# Check code with cpplint. +############################################################################### + +add_custom_target(ci_cpplint + COMMAND ${Python3_EXECUTABLE} -mvenv venv_cpplint + COMMAND venv_cpplint/bin/pip3 --quiet install cpplint + COMMAND venv_cpplint/bin/cpplint --filter=-whitespace,-legal,-runtime/references,-runtime/explicit,-runtime/indentation_namespace,-readability/casting,-readability/nolint --quiet --recursive ${SRC_FILES} + COMMENT "Check code with cpplint" + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} +) + +############################################################################### +# Check code with OCLint. +############################################################################### + +file(COPY ${PROJECT_SOURCE_DIR}/single_include/nlohmann/json.hpp DESTINATION ${PROJECT_BINARY_DIR}/src_single) +file(RENAME ${PROJECT_BINARY_DIR}/src_single/json.hpp ${PROJECT_BINARY_DIR}/src_single/all.cpp) +file(APPEND "${PROJECT_BINARY_DIR}/src_single/all.cpp" "\n\nint main()\n{}\n") + +add_executable(single_all ${PROJECT_BINARY_DIR}/src_single/all.cpp) +target_compile_features(single_all PRIVATE cxx_std_11) + +add_custom_target(ci_oclint + COMMAND ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON + -DJSON_BuildTests=OFF -DJSON_CI=ON + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_oclint + COMMAND ${OCLINT_TOOL} -i ${PROJECT_BINARY_DIR}/build_oclint/src_single/all.cpp -p ${PROJECT_BINARY_DIR}/build_oclint -- + -report-type html -enable-global-analysis --max-priority-1=0 --max-priority-2=1000 --max-priority-3=2000 + --disable-rule=MultipleUnaryOperator + --disable-rule=DoubleNegative + --disable-rule=ShortVariableName + --disable-rule=GotoStatement + --disable-rule=LongLine + -o ${PROJECT_BINARY_DIR}/build_oclint/oclint_report.html + COMMENT "Check code with OCLint" +) + +############################################################################### +# Check code with Clang-Tidy. +############################################################################### + +add_custom_target(ci_clang_tidy + COMMAND CXX=${CLANG_TOOL} ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_CLANG_TIDY=${CLANG_TIDY_TOOL} + -DJSON_BuildTests=ON + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_clang_tidy + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_clang_tidy + COMMENT "Check code with Clang-Tidy" +) + +############################################################################### +# Check code with PVS-Studio Analyzer . +############################################################################### + +add_custom_target(ci_pvs_studio + COMMAND CXX=${CLANG_TOOL} ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON + -DJSON_BuildTests=ON + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_pvs_studio + COMMAND cd ${PROJECT_BINARY_DIR}/build_pvs_studio && ${PVS_STUDIO_ANALYZER_TOOL} analyze -j 10 + COMMAND cd ${PROJECT_BINARY_DIR}/build_pvs_studio && ${PLOG_CONVERTER_TOOL} -a'GA:1,2;64:1;CS' -t fullhtml PVS-Studio.log -o pvs + COMMENT "Check code with PVS Studio" +) + +############################################################################### +# Check code with Infer static analyzer. +############################################################################### + +add_custom_target(ci_infer + COMMAND mkdir -p ${PROJECT_BINARY_DIR}/build_infer + COMMAND cd ${PROJECT_BINARY_DIR}/build_infer && ${INFER_TOOL} compile -- ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${PROJECT_SOURCE_DIR} -DJSON_BuildTests=ON + COMMAND cd ${PROJECT_BINARY_DIR}/build_infer && ${INFER_TOOL} run -- make + COMMENT "Check code with Infer" +) + +############################################################################### +# Run test suite with previously downloaded test data. +############################################################################### + +add_custom_target(ci_offline_testdata + COMMAND mkdir -p ${PROJECT_BINARY_DIR}/build_offline_testdata/test_data + COMMAND cd ${PROJECT_BINARY_DIR}/build_offline_testdata/test_data && ${GIT_TOOL} clone -c advice.detachedHead=false --branch v3.1.0 https://github.com/nlohmann/json_test_data.git --quiet --depth 1 + COMMAND ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DJSON_BuildTests=ON -DJSON_FastTests=ON -DJSON_TestDataDirectory=${PROJECT_BINARY_DIR}/build_offline_testdata/test_data/json_test_data + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_offline_testdata + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_offline_testdata + COMMAND cd ${PROJECT_BINARY_DIR}/build_offline_testdata && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure + COMMENT "Check code with previously downloaded test data" +) + +############################################################################### +# Run test suite when project was not checked out from Git +############################################################################### + +add_custom_target(ci_non_git_tests + COMMAND git config --global --add safe.directory ${PROJECT_SOURCE_DIR} + COMMAND mkdir -p ${PROJECT_BINARY_DIR}/build_non_git_tests/sources + COMMAND cd ${PROJECT_SOURCE_DIR} && for FILE in `${GIT_TOOL} ls-tree --name-only HEAD`\; do cp -r $$FILE ${PROJECT_BINARY_DIR}/build_non_git_tests/sources \; done + COMMAND ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DJSON_BuildTests=ON -DJSON_FastTests=ON + -S${PROJECT_BINARY_DIR}/build_non_git_tests/sources -B${PROJECT_BINARY_DIR}/build_non_git_tests + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_non_git_tests + COMMAND cd ${PROJECT_BINARY_DIR}/build_non_git_tests && ${CMAKE_CTEST_COMMAND} --parallel ${N} -LE git_required --output-on-failure + COMMENT "Check code when project was not checked out from Git" +) + +############################################################################### +# Run test suite and exclude tests that change installed files +############################################################################### + +add_custom_target(ci_reproducible_tests + COMMAND ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DJSON_BuildTests=ON -DJSON_FastTests=ON + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_reproducible_tests + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_reproducible_tests + COMMAND cd ${PROJECT_BINARY_DIR}/build_reproducible_tests && ${CMAKE_CTEST_COMMAND} --parallel ${N} -LE not_reproducible --output-on-failure + COMMENT "Check code and exclude tests that change installed files" +) + +############################################################################### +# Check if every header in the include folder includes sufficient headers to +# be compiled individually. +############################################################################### + +set(iwyu_path_and_options ${IWYU_TOOL} -Xiwyu --max_line_length=300) + +foreach(SRC_FILE ${SRC_FILES}) + # get relative path of the header file + file(RELATIVE_PATH RELATIVE_SRC_FILE "${PROJECT_SOURCE_DIR}/include/nlohmann" "${SRC_FILE}") + # replace slashes and strip suffix + string(REPLACE "/" "_" RELATIVE_SRC_FILE "${RELATIVE_SRC_FILE}") + string(REPLACE ".hpp" "" RELATIVE_SRC_FILE "${RELATIVE_SRC_FILE}") + # create code file + file(WRITE "${PROJECT_BINARY_DIR}/src_single/${RELATIVE_SRC_FILE}.cpp" "#include \"${SRC_FILE}\" // IWYU pragma: keep\n\nint main()\n{}\n") + # create executable + add_executable(single_${RELATIVE_SRC_FILE} EXCLUDE_FROM_ALL ${PROJECT_BINARY_DIR}/src_single/${RELATIVE_SRC_FILE}.cpp) + target_include_directories(single_${RELATIVE_SRC_FILE} PRIVATE ${PROJECT_SOURCE_DIR}/include) + target_compile_features(single_${RELATIVE_SRC_FILE} PRIVATE cxx_std_11) + set_property(TARGET single_${RELATIVE_SRC_FILE} PROPERTY CXX_INCLUDE_WHAT_YOU_USE "${iwyu_path_and_options}") + # remember binary for ci_single_binaries target + list(APPEND single_binaries single_${RELATIVE_SRC_FILE}) +endforeach() + +add_custom_target(ci_single_binaries + DEPENDS ${single_binaries} + COMMENT "Check if headers are self-contained" +) + +############################################################################### +# Benchmarks +############################################################################### + +add_custom_target(ci_benchmarks + COMMAND ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Release -GNinja + -S${PROJECT_SOURCE_DIR}/benchmarks -B${PROJECT_BINARY_DIR}/build_benchmarks + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_benchmarks --target json_benchmarks + COMMAND cd ${PROJECT_BINARY_DIR}/build_benchmarks && ./json_benchmarks + COMMENT "Run benchmarks" +) + +############################################################################### +# CMake flags +############################################################################### + +function(ci_get_cmake version var) + set(${var} ${PROJECT_BINARY_DIR}/cmake-${version}/bin/cmake) + add_custom_command( + OUTPUT ${${var}} + COMMAND wget -nc https://github.com/Kitware/CMake/releases/download/v${version}/cmake-${version}.tar.gz + COMMAND tar xfz cmake-${version}.tar.gz + COMMAND rm cmake-${version}.tar.gz + COMMAND ${CMAKE_COMMAND} -S cmake-${version} -B cmake-${version} + COMMAND ${CMAKE_COMMAND} --build cmake-${version} --parallel 10 + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + COMMENT "Download CMake ${version}" + ) + set(${var} ${${var}} PARENT_SCOPE) +endfunction() + +ci_get_cmake(3.1.0 CMAKE_3_1_0_BINARY) +ci_get_cmake(3.13.0 CMAKE_3_13_0_BINARY) + +set(JSON_CMAKE_FLAGS_3_1_0 JSON_Diagnostics JSON_GlobalUDLs JSON_ImplicitConversions JSON_DisableEnumSerialization + JSON_LegacyDiscardedValueComparison JSON_Install JSON_MultipleHeaders JSON_SystemInclude JSON_Valgrind) +set(JSON_CMAKE_FLAGS_3_13_0 JSON_BuildTests) + +function(ci_add_cmake_flags_targets flag min_version) + string(TOLOWER "ci_cmake_flag_${flag}" flag_target) + string(REPLACE . _ min_version_var ${min_version}) + set(cmake_binary ${CMAKE_${min_version_var}_BINARY}) + add_custom_target(${flag_target} + COMMENT "Check CMake flag ${flag} (CMake ${CMAKE_VERSION})" + COMMAND ${CMAKE_COMMAND} + -Werror=dev + -D${flag}=ON + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_${flag_target} + ) + add_custom_target(${flag_target}_${min_version_var} + COMMENT "Check CMake flag ${JSON_CMAKE_FLAG} (CMake ${min_version})" + COMMAND mkdir -pv ${PROJECT_BINARY_DIR}/build_${flag_target}_${min_version_var} + COMMAND cd ${PROJECT_BINARY_DIR}/build_${flag_target}_${min_version_var} + && ${cmake_binary} -Werror=dev ${PROJECT_SOURCE_DIR} -D${flag}=ON + DEPENDS ${cmake_binary} + ) + list(APPEND JSON_CMAKE_FLAG_TARGETS ${JSON_CMAKE_FLAG_TARGET} ${flag_target}_${min_version_var}) + list(APPEND JSON_CMAKE_FLAG_BUILD_DIRS ${PROJECT_BINARY_DIR}/build_${flag_target} ${PROJECT_BINARY_DIR}/build_${flag_target}_${min_version_var}) + set(JSON_CMAKE_FLAG_TARGETS ${JSON_CMAKE_FLAG_TARGETS} PARENT_SCOPE) + set(JSON_CMAKE_FLAG_BUILD_DIRS ${JSON_CMAKE_FLAG_BUILD_DIRS} PARENT_SCOPE) +endfunction() + +foreach(JSON_CMAKE_FLAG ${JSON_CMAKE_FLAGS_3_1_0}) + ci_add_cmake_flags_targets(${JSON_CMAKE_FLAG} 3.1.0) +endforeach() + +foreach(JSON_CMAKE_FLAG ${JSON_CMAKE_FLAGS_3_13_0}) + ci_add_cmake_flags_targets(${JSON_CMAKE_FLAG} 3.13.0) +endforeach() + +add_custom_target(ci_cmake_flags + DEPENDS ${JSON_CMAKE_FLAG_TARGETS} + COMMENT "Check CMake flags" +) + +############################################################################### +# Use more installed compilers. +############################################################################### + +foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-6 g++-7 g++-8 g++-9 g++-10 g++-11 clang++-3.5 clang++-3.6 clang++-3.7 clang++-3.8 clang++-3.9 clang++-4.0 clang++-5.0 clang++-6.0 clang++-7 clang++-8 clang++-9 clang++-10 clang++-11 clang++-12 clang++-13 clang++-14 clang++-15 clang++-16 clang++-17) + find_program(COMPILER_TOOL NAMES ${COMPILER}) + if (COMPILER_TOOL) + unset(ADDITIONAL_FLAGS) + + add_custom_target(ci_test_compiler_${COMPILER} + COMMAND CXX=${COMPILER} ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DJSON_BuildTests=ON -DJSON_FastTests=ON + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_compiler_${COMPILER} + ${ADDITIONAL_FLAGS} + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_compiler_${COMPILER} + COMMAND cd ${PROJECT_BINARY_DIR}/build_compiler_${COMPILER} && ${CMAKE_CTEST_COMMAND} --parallel ${N} --exclude-regex "test-unicode" --output-on-failure + COMMENT "Compile and test with ${COMPILER}" + ) + endif() + unset(COMPILER_TOOL CACHE) +endforeach() + +add_custom_target(ci_test_compiler_default + COMMAND ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DJSON_BuildTests=ON -DJSON_FastTests=ON + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_compiler_default + ${ADDITIONAL_FLAGS} + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_compiler_default --parallel ${N} + COMMAND cd ${PROJECT_BINARY_DIR}/build_compiler_default && ${CMAKE_CTEST_COMMAND} --parallel ${N} --exclude-regex "test-unicode" -LE git_required --output-on-failure + COMMENT "Compile and test with default C++ compiler" +) + +############################################################################### +# CUDA example +############################################################################### + +add_custom_target(ci_cuda_example + COMMAND ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DCMAKE_CUDA_HOST_COMPILER=g++-8 + -S${PROJECT_SOURCE_DIR}/tests/cuda_example -B${PROJECT_BINARY_DIR}/build_cuda_example + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_cuda_example +) + +############################################################################### +# Intel C++ Compiler +############################################################################### + +add_custom_target(ci_icpc + COMMAND ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DCMAKE_C_COMPILER=icc -DCMAKE_CXX_COMPILER=icpc + -DJSON_BuildTests=ON -DJSON_FastTests=ON + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_icpc + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_icpc + COMMAND cd ${PROJECT_BINARY_DIR}/build_icpc && ${CMAKE_CTEST_COMMAND} --parallel ${N} --exclude-regex "test-unicode" --output-on-failure + COMMENT "Compile and test with ICPC" +) + +############################################################################### +# test documentation +############################################################################### + +add_custom_target(ci_test_examples + COMMAND make CXX="${GCC_TOOL}" check_output_portable -j8 + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/docs + COMMENT "Check that all examples compile and create the desired output" +) + +add_custom_target(ci_test_api_documentation + COMMAND ${Python3_EXECUTABLE} scripts/check_structure.py + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/docs/mkdocs + COMMENT "Lint the API documentation" +) + +############################################################################### +# Clean up all generated files. +############################################################################### + +add_custom_target(ci_clean + COMMAND rm -fr ${PROJECT_BINARY_DIR}/build_* cmake-3.1.0-Darwin64 ${JSON_CMAKE_FLAG_BUILD_DIRS} ${single_binaries} + COMMENT "Clean generated directories" +) diff --git a/external_imported/json/cmake/download_test_data.cmake b/external_imported/json/cmake/download_test_data.cmake index f516a7c3b..1bb998dae 100644 --- a/external_imported/json/cmake/download_test_data.cmake +++ b/external_imported/json/cmake/download_test_data.cmake @@ -1,5 +1,5 @@ set(JSON_TEST_DATA_URL https://github.com/nlohmann/json_test_data) -set(JSON_TEST_DATA_VERSION 3.0.0) +set(JSON_TEST_DATA_VERSION 3.1.0) # if variable is set, use test data from given directory rather than downloading them if(JSON_TestDataDirectory) diff --git a/external_imported/json/cmake/pkg-config.pc.in b/external_imported/json/cmake/pkg-config.pc.in index 3541abf0b..d36317f09 100644 --- a/external_imported/json/cmake/pkg-config.pc.in +++ b/external_imported/json/cmake/pkg-config.pc.in @@ -1,4 +1,4 @@ Name: ${PROJECT_NAME} Description: JSON for Modern C++ Version: ${PROJECT_VERSION} -Cflags: -I${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR} +Cflags: -I${CMAKE_INSTALL_FULL_INCLUDEDIR} diff --git a/external_imported/json/cmake/scripts/gen_bazel_build_file.cmake b/external_imported/json/cmake/scripts/gen_bazel_build_file.cmake new file mode 100644 index 000000000..e754d387d --- /dev/null +++ b/external_imported/json/cmake/scripts/gen_bazel_build_file.cmake @@ -0,0 +1,24 @@ +# generate Bazel BUILD file + +set(PROJECT_ROOT "${CMAKE_CURRENT_LIST_DIR}/../..") +set(BUILD_FILE "${PROJECT_ROOT}/BUILD.bazel") + +file(GLOB_RECURSE HEADERS LIST_DIRECTORIES false RELATIVE "${PROJECT_ROOT}" "include/*.hpp") + +file(WRITE "${BUILD_FILE}" [=[ +cc_library( + name = "json", + hdrs = [ +]=]) + +foreach(header ${HEADERS}) + file(APPEND "${BUILD_FILE}" " \"${header}\",\n") +endforeach() + +file(APPEND "${BUILD_FILE}" [=[ + ], + includes = ["include"], + visibility = ["//visibility:public"], + alwayslink = True, +) +]=]) diff --git a/external_imported/json/cmake/test.cmake b/external_imported/json/cmake/test.cmake new file mode 100644 index 000000000..7105b97c3 --- /dev/null +++ b/external_imported/json/cmake/test.cmake @@ -0,0 +1,273 @@ +set(_json_test_cmake_list_file ${CMAKE_CURRENT_LIST_FILE}) + +############################################################################# +# download test data +############################################################################# + +include(download_test_data) + +# test fixture to download test data +add_test(NAME "download_test_data" COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} + --target download_test_data +) +set_tests_properties(download_test_data PROPERTIES FIXTURES_SETUP TEST_DATA) + +if(JSON_Valgrind) + find_program(CMAKE_MEMORYCHECK_COMMAND valgrind) + message(STATUS "Executing test suite with Valgrind (${CMAKE_MEMORYCHECK_COMMAND})") + set(memcheck_command "${CMAKE_MEMORYCHECK_COMMAND} ${CMAKE_MEMORYCHECK_COMMAND_OPTIONS} --error-exitcode=1 --leak-check=full") + separate_arguments(memcheck_command) +endif() + +############################################################################# +# detect standard support +############################################################################# + +# C++11 is the minimum required +set(compiler_supports_cpp_11 TRUE) + +foreach(feature ${CMAKE_CXX_COMPILE_FEATURES}) + if (${feature} STREQUAL cxx_std_14) + set(compiler_supports_cpp_14 TRUE) + elseif (${feature} STREQUAL cxx_std_17) + set(compiler_supports_cpp_17 TRUE) + elseif (${feature} STREQUAL cxx_std_20) + set(compiler_supports_cpp_20 TRUE) + elseif (${feature} STREQUAL cxx_std_23) + set(compiler_supports_cpp_23 TRUE) + endif() +endforeach() + +############################################################################# +# test functions +############################################################################# + +############################################################################# +# json_test_set_test_options( +# all| +# [CXX_STANDARDS all|...] +# [COMPILE_DEFINITIONS ...] +# [COMPILE_FEATURES ...] +# [COMPILE_OPTIONS ...] +# [LINK_LIBRARIES ...] +# [LINK_OPTIONS ...] +# [TEST_PROPERTIES ...]) +# +# Supply test- and standard-specific build settings and/or test properties. +# Specify multiple tests using a list e.g., "test-foo;test-bar". +# +# Must be called BEFORE the test is created. +############################################################################# + +function(json_test_set_test_options tests) + cmake_parse_arguments(args "" "" + "CXX_STANDARDS;COMPILE_DEFINITIONS;COMPILE_FEATURES;COMPILE_OPTIONS;LINK_LIBRARIES;LINK_OPTIONS;TEST_PROPERTIES" + ${ARGN}) + + if(NOT args_CXX_STANDARDS) + set(args_CXX_STANDARDS "all") + endif() + + foreach(test ${tests}) + if("${test}" STREQUAL "all") + set(test "") + endif() + + foreach(cxx_standard ${args_CXX_STANDARDS}) + if("${cxx_standard}" STREQUAL "all") + if("${test}" STREQUAL "") + message(FATAL_ERROR "Not supported. Change defaults in: ${_json_test_cmake_list_file}") + endif() + set(test_interface _json_test_interface_${test}) + else() + set(test_interface _json_test_interface_${test}_cpp_${cxx_standard}) + endif() + + if(NOT TARGET ${test_interface}) + add_library(${test_interface} INTERFACE) + endif() + + target_compile_definitions(${test_interface} INTERFACE ${args_COMPILE_DEFINITIONS}) + target_compile_features(${test_interface} INTERFACE ${args_COMPILE_FEATURES}) + target_compile_options(${test_interface} INTERFACE ${args_COMPILE_OPTIONS}) + target_link_libraries (${test_interface} INTERFACE ${args_LINK_LIBRARIES}) + target_link_options(${test_interface} INTERFACE ${args_LINK_OPTIONS}) + #set_target_properties(${test_interface} PROPERTIES JSON_TEST_PROPERTIES "${args_TEST_PROPERTIES}") + set_property(DIRECTORY PROPERTY + ${test_interface}_TEST_PROPERTIES "${args_TEST_PROPERTIES}" + ) + endforeach() + endforeach() +endfunction() + +# for internal use by _json_test_add_test() +function(_json_test_apply_test_properties test_target properties_target) + #get_target_property(test_properties ${properties_target} JSON_TEST_PROPERTIES) + get_property(test_properties DIRECTORY PROPERTY ${properties_target}_TEST_PROPERTIES) + if(test_properties) + set_tests_properties(${test_target} PROPERTIES ${test_properties}) + endif() +endfunction() + +# for internal use by json_test_add_test_for() +function(_json_test_add_test test_name file main cxx_standard) + set(test_target ${test_name}_cpp${cxx_standard}) + + if(TARGET ${test_target}) + message(FATAL_ERROR "Target ${test_target} has already been added.") + endif() + + add_executable(${test_target} ${file}) + target_link_libraries(${test_target} PRIVATE ${main}) + + # set and require C++ standard + set_target_properties(${test_target} PROPERTIES + CXX_STANDARD ${cxx_standard} + CXX_STANDARD_REQUIRED ON + ) + + # apply standard-specific build settings + if(TARGET _json_test_interface__cpp_${cxx_standard}) + target_link_libraries(${test_target} PRIVATE _json_test_interface__cpp_${cxx_standard}) + endif() + + # apply test-specific build settings + if(TARGET _json_test_interface_${test_name}) + target_link_libraries(${test_target} PRIVATE _json_test_interface_${test_name}) + endif() + + # apply test- and standard-specific build settings + if(TARGET _json_test_interface_${test_name}_cpp_${cxx_standard}) + target_link_libraries(${test_target} PRIVATE + _json_test_interface_${test_name}_cpp_${cxx_standard} + ) + endif() + + if (JSON_FastTests) + add_test(NAME ${test_target} + COMMAND ${test_target} ${DOCTEST_TEST_FILTER} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + else() + add_test(NAME ${test_target} + COMMAND ${test_target} ${DOCTEST_TEST_FILTER} --no-skip + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + endif() + set_tests_properties(${test_target} PROPERTIES LABELS "all" FIXTURES_REQUIRED TEST_DATA) + + # apply standard-specific test properties + if(TARGET _json_test_interface__cpp_${cxx_standard}) + _json_test_apply_test_properties(${test_target} _json_test_interface__cpp_${cxx_standard}) + endif() + + # apply test-specific test properties + if(TARGET _json_test_interface_${test_name}) + _json_test_apply_test_properties(${test_target} _json_test_interface_${test_name}) + endif() + + # apply test- and standard-specific test properties + if(TARGET _json_test_interface_${test_name}_cpp_${cxx_standard}) + _json_test_apply_test_properties(${test_target} + _json_test_interface_${test_name}_cpp_${cxx_standard} + ) + endif() + + if(JSON_Valgrind) + add_test(NAME ${test_target}_valgrind + COMMAND ${memcheck_command} $ ${DOCTEST_TEST_FILTER} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + set_tests_properties(${test_target}_valgrind PROPERTIES + LABELS "valgrind" FIXTURES_REQUIRED TEST_DATA + ) + endif() +endfunction() + +############################################################################# +# json_test_add_test_for( +# +# [NAME ] +# MAIN
+# [CXX_STANDARDS ...] [FORCE]) +# +# Given a unit-foo.cpp, produces +# +# test-foo_cpp +# +# if C++ standard is supported by the compiler and the +# source file contains JSON_HAS_CPP_. +# Use NAME to override the filename-derived test name. +# Use FORCE to create the test regardless of the file containing +# JSON_HAS_CPP_. +# Test targets are linked against
. +# CXX_STANDARDS defaults to "11". +############################################################################# + +function(json_test_add_test_for file) + cmake_parse_arguments(args "FORCE" "MAIN;NAME" "CXX_STANDARDS" ${ARGN}) + + if("${args_MAIN}" STREQUAL "") + message(FATAL_ERROR "Required argument MAIN
missing.") + endif() + + if("${args_NAME}" STREQUAL "") + get_filename_component(file_basename ${file} NAME_WE) + string(REGEX REPLACE "unit-([^$]+)" "test-\\1" test_name ${file_basename}) + else() + set(test_name ${args_NAME}) + if(NOT test_name MATCHES "test-[^$]+") + message(FATAL_ERROR "Test name must start with 'test-'.") + endif() + endif() + + if("${args_CXX_STANDARDS}" STREQUAL "") + set(args_CXX_STANDARDS 11) + endif() + + file(READ ${file} file_content) + foreach(cxx_standard ${args_CXX_STANDARDS}) + if(NOT compiler_supports_cpp_${cxx_standard}) + continue() + endif() + + # add unconditionally if C++11 (default) or forced + if(NOT ("${cxx_standard}" STREQUAL 11 OR args_FORCE)) + string(FIND "${file_content}" JSON_HAS_CPP_${cxx_standard} has_cpp_found) + if(${has_cpp_found} EQUAL -1) + continue() + endif() + endif() + + _json_test_add_test(${test_name} ${file} ${args_MAIN} ${cxx_standard}) + endforeach() +endfunction() + +############################################################################# +# json_test_should_build_32bit_test( +# ) +# +# Check if the 32bit unit test should be built based on the value of +# and store the result in the variables and +# . +############################################################################# + +function(json_test_should_build_32bit_test build_32bit_var build_32bit_only_var input) + set(${build_32bit_only_var} OFF PARENT_SCOPE) + string(TOUPPER "${input}" ${build_32bit_var}) + if("${${build_32bit_var}}" STREQUAL AUTO) + # check if compiler is targeting 32bit by default + include(CheckTypeSize) + check_type_size("size_t" sizeof_size_t LANGUAGE CXX) + if(${sizeof_size_t} AND ${sizeof_size_t} EQUAL 4) + message(STATUS "Auto-enabling 32bit unit test.") + set(${build_32bit_var} ON) + else() + set(${build_32bit_var} OFF) + endif() + elseif("${${build_32bit_var}}" STREQUAL ONLY) + set(${build_32bit_only_var} ON PARENT_SCOPE) + endif() + + set(${build_32bit_var} "${${build_32bit_var}}" PARENT_SCOPE) +endfunction() diff --git a/external_imported/json/doc/Doxyfile b/external_imported/json/doc/Doxyfile deleted file mode 100644 index 45ca8822b..000000000 --- a/external_imported/json/doc/Doxyfile +++ /dev/null @@ -1,335 +0,0 @@ -# Doxyfile 1.9.0 - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- -DOXYFILE_ENCODING = UTF-8 -PROJECT_NAME = "JSON for Modern C++" -PROJECT_NUMBER = 3.9.1 -PROJECT_BRIEF = -PROJECT_LOGO = -OUTPUT_DIRECTORY = . -CREATE_SUBDIRS = NO -ALLOW_UNICODE_NAMES = NO -OUTPUT_LANGUAGE = English -OUTPUT_TEXT_DIRECTION = None -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = NO -ABBREVIATE_BRIEF = -ALWAYS_DETAILED_SEC = YES -INLINE_INHERITED_MEMB = NO -FULL_PATH_NAMES = YES -STRIP_FROM_PATH = -STRIP_FROM_INC_PATH = -SHORT_NAMES = NO -JAVADOC_AUTOBRIEF = NO -JAVADOC_BANNER = NO -QT_AUTOBRIEF = NO -MULTILINE_CPP_IS_BRIEF = NO -PYTHON_DOCSTRING = YES -INHERIT_DOCS = YES -SEPARATE_MEMBER_PAGES = YES -TAB_SIZE = 4 -ALIASES = "complexity=@par Complexity^^" \ - "liveexample{2}=@par Example^^ \1 ^^ @includelineno \2.cpp \n Output (play with this example @htmlinclude \2.link):^^ @verbinclude \2.output ^^ The example code above can be translated with @verbatim g++ -std=c++11 -Isingle_include doc/examples/\2.cpp -o \2 @endverbatim" \ - "requirement=@par Requirements^^" \ - "exceptionsafety=@par Exception safety^^" \ - "iterators=@par Iterator validity^^" -OPTIMIZE_OUTPUT_FOR_C = NO -OPTIMIZE_OUTPUT_JAVA = NO -OPTIMIZE_FOR_FORTRAN = NO -OPTIMIZE_OUTPUT_VHDL = NO -OPTIMIZE_OUTPUT_SLICE = NO -EXTENSION_MAPPING = -MARKDOWN_SUPPORT = YES -TOC_INCLUDE_HEADINGS = 0 -AUTOLINK_SUPPORT = NO -BUILTIN_STL_SUPPORT = YES -CPP_CLI_SUPPORT = NO -SIP_SUPPORT = NO -IDL_PROPERTY_SUPPORT = YES -DISTRIBUTE_GROUP_DOC = NO -GROUP_NESTED_COMPOUNDS = NO -SUBGROUPING = YES -INLINE_GROUPED_CLASSES = NO -INLINE_SIMPLE_STRUCTS = NO -TYPEDEF_HIDES_STRUCT = NO -LOOKUP_CACHE_SIZE = 0 -NUM_PROC_THREADS = 1 -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- -EXTRACT_ALL = YES -EXTRACT_PRIVATE = NO -EXTRACT_PRIV_VIRTUAL = NO -EXTRACT_PACKAGE = YES -EXTRACT_STATIC = YES -EXTRACT_LOCAL_CLASSES = YES -EXTRACT_LOCAL_METHODS = YES -EXTRACT_ANON_NSPACES = YES -RESOLVE_UNNAMED_PARAMS = YES -HIDE_UNDOC_MEMBERS = NO -HIDE_UNDOC_CLASSES = NO -HIDE_FRIEND_COMPOUNDS = NO -HIDE_IN_BODY_DOCS = NO -INTERNAL_DOCS = NO -CASE_SENSE_NAMES = NO -HIDE_SCOPE_NAMES = NO -HIDE_COMPOUND_REFERENCE= NO -SHOW_INCLUDE_FILES = YES -SHOW_GROUPED_MEMB_INC = NO -FORCE_LOCAL_INCLUDES = NO -INLINE_INFO = YES -SORT_MEMBER_DOCS = YES -SORT_BRIEF_DOCS = YES -SORT_MEMBERS_CTORS_1ST = YES -SORT_GROUP_NAMES = NO -SORT_BY_SCOPE_NAME = NO -STRICT_PROTO_MATCHING = NO -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -GENERATE_DEPRECATEDLIST= YES -ENABLED_SECTIONS = -MAX_INITIALIZER_LINES = 30 -SHOW_USED_FILES = NO -SHOW_FILES = NO -SHOW_NAMESPACES = NO -FILE_VERSION_FILTER = -LAYOUT_FILE = -CITE_BIB_FILES = -#--------------------------------------------------------------------------- -# Configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = YES -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_IF_DOC_ERROR = YES -WARN_NO_PARAMDOC = YES -WARN_AS_ERROR = NO -WARN_FORMAT = "$file:$line: $text" -WARN_LOGFILE = -#--------------------------------------------------------------------------- -# Configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = ../single_include/nlohmann/json.hpp \ - index.md -INPUT_ENCODING = UTF-8 -FILE_PATTERNS = -RECURSIVE = NO -EXCLUDE = -EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = -EXCLUDE_SYMBOLS = nlohmann::detail -EXAMPLE_PATH = examples -EXAMPLE_PATTERNS = -EXAMPLE_RECURSIVE = NO -IMAGE_PATH = images -INPUT_FILTER = -FILTER_PATTERNS = -FILTER_SOURCE_FILES = NO -FILTER_SOURCE_PATTERNS = -USE_MDFILE_AS_MAINPAGE = index.md -#--------------------------------------------------------------------------- -# Configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = YES -INLINE_SOURCES = NO -STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = NO -REFERENCES_RELATION = NO -REFERENCES_LINK_SOURCE = NO -SOURCE_TOOLTIPS = YES -USE_HTAGS = NO -VERBATIM_HEADERS = NO -#--------------------------------------------------------------------------- -# Configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = YES -IGNORE_PREFIX = -#--------------------------------------------------------------------------- -# Configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = YES -HTML_OUTPUT = html -HTML_FILE_EXTENSION = .html -HTML_HEADER = -HTML_FOOTER = -HTML_STYLESHEET = -HTML_EXTRA_STYLESHEET = css/mylayout.css -HTML_EXTRA_FILES = -HTML_COLORSTYLE_HUE = 220 -HTML_COLORSTYLE_SAT = 100 -HTML_COLORSTYLE_GAMMA = 80 -HTML_TIMESTAMP = YES -HTML_DYNAMIC_MENUS = YES -HTML_DYNAMIC_SECTIONS = YES -HTML_INDEX_NUM_ENTRIES = 100 -GENERATE_DOCSET = YES -DOCSET_FEEDNAME = "Doxygen generated docs" -DOCSET_BUNDLE_ID = me.nlohmann.json -DOCSET_PUBLISHER_ID = me.nlohmann -DOCSET_PUBLISHER_NAME = NielsLohmann -GENERATE_HTMLHELP = NO -CHM_FILE = -HHC_LOCATION = -GENERATE_CHI = NO -CHM_INDEX_ENCODING = -BINARY_TOC = NO -TOC_EXPAND = NO -GENERATE_QHP = NO -QCH_FILE = -QHP_NAMESPACE = org.doxygen.Project -QHP_VIRTUAL_FOLDER = doc -QHP_CUST_FILTER_NAME = -QHP_CUST_FILTER_ATTRS = -QHP_SECT_FILTER_ATTRS = -QHG_LOCATION = -GENERATE_ECLIPSEHELP = NO -ECLIPSE_DOC_ID = org.doxygen.Project -DISABLE_INDEX = NO -GENERATE_TREEVIEW = NO -ENUM_VALUES_PER_LINE = 4 -TREEVIEW_WIDTH = 250 -EXT_LINKS_IN_WINDOW = NO -HTML_FORMULA_FORMAT = png -FORMULA_FONTSIZE = 10 -FORMULA_TRANSPARENT = YES -FORMULA_MACROFILE = -USE_MATHJAX = NO -MATHJAX_FORMAT = HTML-CSS -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest -MATHJAX_EXTENSIONS = -MATHJAX_CODEFILE = -SEARCHENGINE = YES -SERVER_BASED_SEARCH = NO -EXTERNAL_SEARCH = NO -SEARCHENGINE_URL = -SEARCHDATA_FILE = searchdata.xml -EXTERNAL_SEARCH_ID = -EXTRA_SEARCH_MAPPINGS = -#--------------------------------------------------------------------------- -# Configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = NO -LATEX_OUTPUT = latex -LATEX_CMD_NAME = latex -MAKEINDEX_CMD_NAME = makeindex -LATEX_MAKEINDEX_CMD = \makeindex -COMPACT_LATEX = NO -PAPER_TYPE = a4 -EXTRA_PACKAGES = -LATEX_HEADER = -LATEX_FOOTER = -LATEX_EXTRA_STYLESHEET = -LATEX_EXTRA_FILES = -PDF_HYPERLINKS = YES -USE_PDFLATEX = YES -LATEX_BATCHMODE = NO -LATEX_HIDE_INDICES = NO -LATEX_SOURCE_CODE = NO -LATEX_BIB_STYLE = plain -LATEX_TIMESTAMP = NO -LATEX_EMOJI_DIRECTORY = -#--------------------------------------------------------------------------- -# Configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = NO -RTF_OUTPUT = rtf -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = -RTF_SOURCE_CODE = NO -#--------------------------------------------------------------------------- -# Configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = NO -MAN_OUTPUT = man -MAN_EXTENSION = .3 -MAN_SUBDIR = -MAN_LINKS = NO -#--------------------------------------------------------------------------- -# Configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = YES -XML_OUTPUT = xml -XML_PROGRAMLISTING = YES -XML_NS_MEMB_FILE_SCOPE = NO -#--------------------------------------------------------------------------- -# Configuration options related to the DOCBOOK output -#--------------------------------------------------------------------------- -GENERATE_DOCBOOK = NO -DOCBOOK_OUTPUT = docbook -DOCBOOK_PROGRAMLISTING = NO -#--------------------------------------------------------------------------- -# Configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- -GENERATE_AUTOGEN_DEF = NO -#--------------------------------------------------------------------------- -# Configuration options related to the Perl module output -#--------------------------------------------------------------------------- -GENERATE_PERLMOD = NO -PERLMOD_LATEX = NO -PERLMOD_PRETTY = YES -PERLMOD_MAKEVAR_PREFIX = -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = NO -EXPAND_ONLY_PREDEF = NO -SEARCH_INCLUDES = YES -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = -EXPAND_AS_DEFINED = -SKIP_FUNCTION_MACROS = YES -#--------------------------------------------------------------------------- -# Configuration options related to external references -#--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = html/nlohmann_json.tag -ALLEXTERNALS = NO -EXTERNAL_GROUPS = YES -EXTERNAL_PAGES = YES -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- -CLASS_DIAGRAMS = NO -DIA_PATH = -HIDE_UNDOC_RELATIONS = YES -HAVE_DOT = YES -DOT_NUM_THREADS = 0 -DOT_FONTNAME = Helvetica -DOT_FONTSIZE = 10 -DOT_FONTPATH = -CLASS_GRAPH = NO -COLLABORATION_GRAPH = NO -GROUP_GRAPHS = YES -UML_LOOK = YES -UML_LIMIT_NUM_FIELDS = 10 -DOT_UML_DETAILS = NO -DOT_WRAP_THRESHOLD = 17 -TEMPLATE_RELATIONS = NO -INCLUDE_GRAPH = NO -INCLUDED_BY_GRAPH = NO -CALL_GRAPH = NO -CALLER_GRAPH = NO -GRAPHICAL_HIERARCHY = NO -DIRECTORY_GRAPH = NO -DOT_IMAGE_FORMAT = svg -INTERACTIVE_SVG = YES -DOT_PATH = -DOTFILE_DIRS = -MSCFILE_DIRS = -DIAFILE_DIRS = -PLANTUML_JAR_PATH = -PLANTUML_CFG_FILE = -PLANTUML_INCLUDE_PATH = -DOT_GRAPH_MAX_NODES = 50 -MAX_DOT_GRAPH_DEPTH = 0 -DOT_TRANSPARENT = NO -DOT_MULTI_TARGETS = NO -GENERATE_LEGEND = YES -DOT_CLEANUP = YES diff --git a/external_imported/json/doc/Makefile b/external_imported/json/doc/Makefile deleted file mode 100644 index 9addd3401..000000000 --- a/external_imported/json/doc/Makefile +++ /dev/null @@ -1,92 +0,0 @@ -SRCDIR = ../single_include -SED:=$(shell command -v gsed || which sed) - -all: doxygen - - -########################################################################## -# example files -########################################################################## - -# where are the example cpp files -EXAMPLES = $(wildcard examples/*.cpp) - -# create output from a stand-alone example file -%.output: %.cpp - make $(<:.cpp=) CPPFLAGS="-I $(SRCDIR)" CXXFLAGS="-std=c++11" - ./$(<:.cpp=) > $@ - rm $(<:.cpp=) - -# compare created output with current output of the example files -%.test: %.cpp - make $(<:.cpp=) CPPFLAGS="-I $(SRCDIR)" CXXFLAGS="-std=c++11" - ./$(<:.cpp=) > $@ - diff $@ $(<:.cpp=.output) - rm $(<:.cpp=) $@ - -# create links to try the code online -%.link: %.cpp - rm -fr tmp - mkdir tmp - cp -r $(SRCDIR)/nlohmann tmp - python2 scripts/send_to_wandbox.py tmp $< > $@.tmp - /bin/echo -n "online" > $@ - rm -fr tmp $@.tmp - -# create output from all stand-alone example files -create_output: $(EXAMPLES:.cpp=.output) - -create_links: $(EXAMPLES:.cpp=.link) - -# check output of all stand-alone example files -check_output: $(EXAMPLES:.cpp=.test) - - -clean: - rm -fr me.nlohmann.json.docset html xml $(EXAMPLES:.cpp=) - $(MAKE) clean -C docset - $(MAKE) clean -C mkdocs - - -########################################################################## -# Doxygen HTML documentation -########################################################################## - -# create Doxygen documentation -doxygen: create_output create_links - doxygen - $(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, AllocatorType, JSONSerializer >@@g' html/*.html - $(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, AllocatorType JSONSerializer >@@g' html/*.html - $(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >@@g' html/*.html - $(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >@@g' html/*.html - $(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType JSONSerializer >@@g' html/*.html - $(SED) -i 's@template<template< typename U, typename V, typename... Args > class ObjectType = std::map, template< typename U, typename... Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator, template< typename T, typename SFINAE=void > class JSONSerializer = adl_serializer>@@g' html/*.html - $(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >@@g' html/*.html - $(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >@@g' html/*.html - $(SED) -i 's@JSON_HEDLEY_RETURNS_NON_NULL@@g' html/*.html - $(SED) -i 's@JSON_HEDLEY_WARN_UNUSED_RESULT@@g' html/*.html - -upload: clean doxygen check_output - scripts/git-update-ghpages nlohmann/json html - rm -fr html - open http://nlohmann.github.io/json/ - - -########################################################################## -# docset -########################################################################## - -# create docset for Dash -docset: create_output - cp Doxyfile Doxyfile_docset - $(SED) -i 's/DISABLE_INDEX = NO/DISABLE_INDEX = YES/' Doxyfile_docset - $(SED) -i 's/SEARCHENGINE = YES/SEARCHENGINE = NO/' Doxyfile_docset - $(SED) -i 's@HTML_EXTRA_STYLESHEET = css/mylayout.css@HTML_EXTRA_STYLESHEET = css/mylayout_docset.css@' Doxyfile_docset - rm -fr html *.docset - doxygen Doxyfile_docset - $(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, AllocatorType >@@g' html/*.html - $(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, AllocatorType >@@g' html/*.html - make -C html - mv html/*.docset . - $(SED) -i 's@doxygen@json@' me.nlohmann.json.docset/Contents/Info.plist - rm -fr Doxyfile_docset html diff --git a/external_imported/json/doc/avatars.png b/external_imported/json/doc/avatars.png deleted file mode 100644 index e3c29989e..000000000 Binary files a/external_imported/json/doc/avatars.png and /dev/null differ diff --git a/external_imported/json/doc/css/mylayout.css b/external_imported/json/doc/css/mylayout.css deleted file mode 100644 index fe20b82c5..000000000 --- a/external_imported/json/doc/css/mylayout.css +++ /dev/null @@ -1,26 +0,0 @@ -/* hide lengthy template information */ -.memtemplate, .memTemplParams { - display: none; -} - -/* allow compiler information to wrap */ -/* https://css-tricks.com/snippets/css/make-pre-text-wrap/ */ -pre.fragment { - white-space: pre-wrap; /* css-3 */ - white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ - white-space: -pre-wrap; /* Opera 4-6 */ - white-space: -o-pre-wrap; /* Opera 7 */ - word-wrap: break-word; /* Internet Explorer 5.5+ */ -} - -td.paramname { - vertical-align: top; -} - -.ok_green { - background-color: #89C35C; -} - -.nok_throws { - background-color: #ffa500; -} diff --git a/external_imported/json/doc/css/mylayout_docset.css b/external_imported/json/doc/css/mylayout_docset.css deleted file mode 100644 index 1a67e99df..000000000 --- a/external_imported/json/doc/css/mylayout_docset.css +++ /dev/null @@ -1,27 +0,0 @@ -.memtemplate { - display: none; -} - -.memTemplParams { - display: none; -} - -.navtab { - display: none; -} - -#top, .footer { - display: none; -} - -td.paramname { - vertical-align: top; -} - -.ok_green { - background-color: #89C35C; -} - -.nok_throws { - background-color: #ffa500; -} diff --git a/external_imported/json/doc/docset/Makefile b/external_imported/json/doc/docset/Makefile deleted file mode 100644 index 262540a0c..000000000 --- a/external_imported/json/doc/docset/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -nlohmann_json.docset: Info.plist docSet.sql - $(MAKE) clean - mkdir -p nlohmann_json.docset/Contents/Resources/Documents/ - cp info.plist nlohmann_json.docset/Contents - # build and copy documentation - $(MAKE) build -C ../mkdocs - cp -r ../mkdocs/site/* nlohmann_json.docset/Contents/Resources/Documents - # patch CSS to hide navigation items - echo "\n\nheader, footer, navi, div.md-sidebar--primary, nav.md-tabs--active, a.md-content__button { display: none; }" >> nlohmann_json.docset/Contents/Resources/Documents/assets/stylesheets/main.b5d04df8.min.css - # fix spacing - echo "\n\ndiv.md-sidebar div.md-sidebar--secondary, div.md-main__inner { top: 0; margin-top: 0 }" >> nlohmann_json.docset/Contents/Resources/Documents/assets/stylesheets/main.b5d04df8.min.css - # remove "JSON for Modern C++" from page titles - find nlohmann_json.docset/Contents/Resources/Documents -type f -exec gsed -i 's| - JSON for Modern C++||' {} + - # clean up - rm nlohmann_json.docset/Contents/Resources/Documents/hooks.py - rm nlohmann_json.docset/Contents/Resources/Documents/sitemap.* - # generate index - sqlite3 nlohmann_json.docset/Contents/Resources/docSet.dsidx < docSet.sql - -clean: - rm -fr nlohmann_json.docset diff --git a/external_imported/json/doc/docset/README.md b/external_imported/json/doc/docset/README.md deleted file mode 100644 index b0dd7f81e..000000000 --- a/external_imported/json/doc/docset/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# docset - -The folder contains the required files to create a [docset](https://kapeli.com/docsets) which can be used in -documentation browsers like [Dash](https://kapeli.com/dash), [Velocity](https://velocity.silverlakesoftware.com), or -[Zeal](https://zealdocs.org). - -The docset can be created with - -```sh -make nlohmann_json.docset -``` - -The generated folder `nlohmann_json.docset` can then be opened in the documentation browser. diff --git a/external_imported/json/doc/docset/docSet.sql b/external_imported/json/doc/docset/docSet.sql deleted file mode 100644 index 243612035..000000000 --- a/external_imported/json/doc/docset/docSet.sql +++ /dev/null @@ -1,140 +0,0 @@ -DROP TABLE IF EXISTS searchIndex; -CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT); -CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path); - --- API -INSERT INTO searchIndex(name, type, path) VALUES ('accept', 'Function', 'api/basic_json/accept/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('adl_serializer', 'Class', 'api/adl_serializer/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('array', 'Function', 'api/basic_json/array/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('array_t', 'Type', 'api/basic_json/array_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('at', 'Method', 'api/basic_json/at/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('back', 'Method', 'api/basic_json/back/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json', 'Class', 'api/basic_json/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json', 'Constructor', 'api/basic_json/basic_json/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('begin', 'Method', 'api/basic_json/begin/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('binary', 'Function', 'api/basic_json/binary/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('binary_t', 'Type', 'api/basic_json/binary_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('boolean_t', 'Type', 'api/basic_json/boolean_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('cbegin', 'Method', 'api/basic_json/cbegin/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('cbor_tag_handler_t', 'Enum', 'api/basic_json/cbor_tag_handler_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('cend', 'Method', 'api/basic_json/cend/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('clear', 'Method', 'api/basic_json/clear/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('contains', 'Method', 'api/basic_json/contains/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('count', 'Method', 'api/basic_json/count/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('crbegin', 'Method', 'api/basic_json/crbegin/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('crend', 'Method', 'api/basic_json/crend/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('diff', 'Function', 'api/basic_json/diff/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('dump', 'Method', 'api/basic_json/dump/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('emplace', 'Method', 'api/basic_json/emplace/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('emplace_back', 'Method', 'api/basic_json/emplace_back/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('empty', 'Method', 'api/basic_json/empty/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('end', 'Method', 'api/basic_json/end/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('erase', 'Method', 'api/basic_json/erase/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('error_handler_t', 'Enum', 'api/basic_json/error_handler_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('exception', 'Class', 'api/basic_json/exception/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('find', 'Method', 'api/basic_json/find/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('flatten', 'Method', 'api/basic_json/flatten/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('from_bson', 'Function', 'api/basic_json/from_bson/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('from_cbor', 'Function', 'api/basic_json/from_cbor/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('from_msgpack', 'Function', 'api/basic_json/from_msgpack/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('from_ubjson', 'Function', 'api/basic_json/from_ubjson/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('front', 'Method', 'api/basic_json/front/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('get', 'Method', 'api/basic_json/get/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('get_allocator', 'Function', 'api/basic_json/get_allocator/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('get_binary', 'Method', 'api/basic_json/get_binary/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('get_ptr', 'Method', 'api/basic_json/get_ptr/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('get_ref', 'Method', 'api/basic_json/get_ref/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('get_to', 'Method', 'api/basic_json/get_to/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('input_format_t', 'Enum', 'api/basic_json/input_format_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('insert', 'Method', 'api/basic_json/insert/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('invalid_iterator', 'Class', 'api/basic_json/invalid_iterator/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('is_array', 'Method', 'api/basic_json/is_array/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('is_binary', 'Method', 'api/basic_json/is_binary/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('is_boolean', 'Method', 'api/basic_json/is_boolean/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('is_discarded', 'Method', 'api/basic_json/is_discarded/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('is_null', 'Method', 'api/basic_json/is_null/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('is_number', 'Method', 'api/basic_json/is_number/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('is_number_float', 'Method', 'api/basic_json/is_number_float/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('is_number_integer', 'Method', 'api/basic_json/is_number_integer/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('is_number_unsigned', 'Method', 'api/basic_json/is_number_unsigned/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('is_object', 'Method', 'api/basic_json/is_object/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('is_primitive', 'Method', 'api/basic_json/is_primitive/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('is_string', 'Method', 'api/basic_json/is_string/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('is_structured', 'Method', 'api/basic_json/is_structured/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('items', 'Method', 'api/basic_json/items/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json', 'Class', 'api/json/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer', 'Class', 'api/json_pointer/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_serializer', 'Type', 'api/basic_json/json_serializer/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('max_size', 'Method', 'api/basic_json/max_size/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('merge_patch', 'Method', 'api/basic_json/merge_patch/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('meta', 'Function', 'api/basic_json/meta/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('number_float_t', 'Type', 'api/basic_json/number_float_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('number_integer_t', 'Type', 'api/basic_json/number_integer_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('number_unsigned_t', 'Type', 'api/basic_json/number_unsigned_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('object', 'Function', 'api/basic_json/object/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('object_comparator_t', 'Type', 'api/basic_json/object_comparator_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('object_t', 'Type', 'api/basic_json/object_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('operator!=', 'Operator', 'api/basic_json/operator_ne/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('operator+=', 'Operator', 'api/basic_json/operator+=/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('operator=', 'Operator', 'api/basic_json/operator=/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('operator==', 'Operator', 'api/basic_json/operator_eq/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('operator<', 'Operator', 'api/basic_json/operator_lt/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('operator<=', 'Operator', 'api/basic_json/operator_le/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('operator>', 'Operator', 'api/basic_json/operator_gt/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('operator>=', 'Operator', 'api/basic_json/operator_ge/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('operator[]', 'Operator', 'api/basic_json/operator[]/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('operator""_json', 'Literal', 'api/basic_json/operator_literal_json/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('operator""_json_pointer', 'Literal', 'api/basic_json/operator_literal_json_pointer/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('operator ValueType', 'Operator', 'api/basic_json/operator_ValueType/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('operator value_t', 'Operator', 'api/basic_json/operator_value_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('ordered_json', 'Class', 'api/ordered_json/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('ordered_map', 'Class', 'api/ordered_map/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('out_of_range', 'Class', 'api/basic_json/out_of_range/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('other_error', 'Class', 'api/basic_json/other_error/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('parse', 'Function', 'api/basic_json/parse/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('parse_error', 'Class', 'api/basic_json/parse_error/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('parse_event_t', 'Enum', 'api/basic_json/parse_event_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('parser_callback_t', 'Type', 'api/basic_json/parser_callback_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('patch', 'Method', 'api/basic_json/patch/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('push_back', 'Method', 'api/basic_json/push_back/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('rbegin', 'Method', 'api/basic_json/rbegin/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('rend', 'Method', 'api/basic_json/rend/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('sax_parse', 'Function', 'api/basic_json/sax_parse/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('size', 'Method', 'api/basic_json/size/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('string_t', 'Type', 'api/basic_json/string_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('type', 'Method', 'api/basic_json/type/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('type_error', 'Class', 'api/basic_json/type_error/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('type_name', 'Method', 'api/basic_json/type_name/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('unflatten', 'Method', 'api/basic_json/unflatten/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('update', 'Method', 'api/basic_json/update/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('to_bson', 'Function', 'api/basic_json/to_bson/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('to_cbor', 'Function', 'api/basic_json/to_cbor/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('to_msgpack', 'Function', 'api/basic_json/to_msgpack/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('to_ubjson', 'Function', 'api/basic_json/to_ubjson/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('value', 'Method', 'api/basic_json/value/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('value_t', 'Enum', 'api/basic_json/value_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('~basic_json', 'Method', 'api/basic_json/~basic_json/index.html'); - --- Features -INSERT INTO searchIndex(name, type, path) VALUES ('Binary Formats', 'Guide', 'features/binary_formats/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('BSON', 'Guide', 'features/binary_formats/bson/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('CBOR', 'Guide', 'features/binary_formats/cbor/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('MessagePack', 'Guide', 'features/binary_formats/messagepack/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('UBJSON', 'Guide', 'features/binary_formats/ubjson/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Supported Macros', 'Guide', 'features/macros/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Binary Values', 'Guide', 'features/binary_values/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Comments', 'Guide', 'features/comments/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Iterators', 'Guide', 'features/iterators/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Types', 'Guide', 'features/types/index.html'); - --- Macros -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_ASSERT', 'Macro', 'features/macros/index.html#json_assertx'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_CATCH_USER', 'Macro', 'features/macros/index.html#json_catch_userexception'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_NOEXCEPTION', 'Macro', 'features/macros/index.html#json_noexception'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_SKIP_UNSUPPORTED_COMPILER_CHECK', 'Macro', 'features/macros/index.html#json_skip_unsupported_compiler_check'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_THROW_USER', 'Macro', 'features/macros/index.html#json_throw_userexception'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_TRY_USER', 'Macro', 'features/macros/index.html#json_try_user'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_USE_IMPLICIT_CONVERSIONS', 'Macro', 'features/macros/index.html#json_use_implicit_conversions'); -INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_DEFINE_TYPE_INTRUSIVE', 'Macro', 'features/macros/index.html#nlohmann_define_type_intrusivetype-member'); -INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE', 'Macro', 'features/macros/index.html#nlohmann_define_type_non_intrusivetype-member'); -INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_SERIALIZE_ENUM', 'Macro', 'features/macros/index.html#nlohmann_json_serialize_enumtype'); diff --git a/external_imported/json/doc/examples/README.link b/external_imported/json/doc/examples/README.link deleted file mode 100644 index 2bb56a02a..000000000 --- a/external_imported/json/doc/examples/README.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/accept__string.link b/external_imported/json/doc/examples/accept__string.link deleted file mode 100644 index 8456e3bfc..000000000 --- a/external_imported/json/doc/examples/accept__string.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/array.link b/external_imported/json/doc/examples/array.link deleted file mode 100644 index 4c69b84ec..000000000 --- a/external_imported/json/doc/examples/array.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/at__object_t_key_type.link b/external_imported/json/doc/examples/at__object_t_key_type.link deleted file mode 100644 index 0518fe656..000000000 --- a/external_imported/json/doc/examples/at__object_t_key_type.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/at__object_t_key_type_const.link b/external_imported/json/doc/examples/at__object_t_key_type_const.link deleted file mode 100644 index a7cd73be7..000000000 --- a/external_imported/json/doc/examples/at__object_t_key_type_const.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/at__size_type.link b/external_imported/json/doc/examples/at__size_type.link deleted file mode 100644 index a98adcb03..000000000 --- a/external_imported/json/doc/examples/at__size_type.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/at__size_type_const.link b/external_imported/json/doc/examples/at__size_type_const.link deleted file mode 100644 index 73a13bb1c..000000000 --- a/external_imported/json/doc/examples/at__size_type_const.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/at_json_pointer.cpp b/external_imported/json/doc/examples/at_json_pointer.cpp deleted file mode 100644 index ed450f70d..000000000 --- a/external_imported/json/doc/examples/at_json_pointer.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON value - json j = - { - {"number", 1}, {"string", "foo"}, {"array", {1, 2}} - }; - - // read-only access - - // output element with JSON pointer "/number" - std::cout << j.at("/number"_json_pointer) << '\n'; - // output element with JSON pointer "/string" - std::cout << j.at("/string"_json_pointer) << '\n'; - // output element with JSON pointer "/array" - std::cout << j.at("/array"_json_pointer) << '\n'; - // output element with JSON pointer "/array/1" - std::cout << j.at("/array/1"_json_pointer) << '\n'; - - // writing access - - // change the string - j.at("/string"_json_pointer) = "bar"; - // output the changed string - std::cout << j["string"] << '\n'; - - // change an array element - j.at("/array/1"_json_pointer) = 21; - // output the changed array - std::cout << j["array"] << '\n'; - - - // out_of_range.106 - try - { - // try to use an array index with leading '0' - json::reference ref = j.at("/array/01"_json_pointer); - } - catch (json::parse_error& e) - { - std::cout << e.what() << '\n'; - } - - // out_of_range.109 - try - { - // try to use an array index that is not a number - json::reference ref = j.at("/array/one"_json_pointer); - } - catch (json::parse_error& e) - { - std::cout << e.what() << '\n'; - } - - // out_of_range.401 - try - { - // try to use a an invalid array index - json::reference ref = j.at("/array/4"_json_pointer); - } - catch (json::out_of_range& e) - { - std::cout << e.what() << '\n'; - } - - // out_of_range.402 - try - { - // try to use the array index '-' - json::reference ref = j.at("/array/-"_json_pointer); - } - catch (json::out_of_range& e) - { - std::cout << e.what() << '\n'; - } - - // out_of_range.403 - try - { - // try to use a JSON pointer to an nonexistent object key - json::const_reference ref = j.at("/foo"_json_pointer); - } - catch (json::out_of_range& e) - { - std::cout << e.what() << '\n'; - } - - // out_of_range.404 - try - { - // try to use a JSON pointer that cannot be resolved - json::reference ref = j.at("/number/foo"_json_pointer); - } - catch (json::out_of_range& e) - { - std::cout << e.what() << '\n'; - } -} diff --git a/external_imported/json/doc/examples/at_json_pointer.link b/external_imported/json/doc/examples/at_json_pointer.link deleted file mode 100644 index a4e2c24fc..000000000 --- a/external_imported/json/doc/examples/at_json_pointer.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/at_json_pointer_const.cpp b/external_imported/json/doc/examples/at_json_pointer_const.cpp deleted file mode 100644 index 6f2b2f5ed..000000000 --- a/external_imported/json/doc/examples/at_json_pointer_const.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON value - const json j = - { - {"number", 1}, {"string", "foo"}, {"array", {1, 2}} - }; - - // read-only access - - // output element with JSON pointer "/number" - std::cout << j.at("/number"_json_pointer) << '\n'; - // output element with JSON pointer "/string" - std::cout << j.at("/string"_json_pointer) << '\n'; - // output element with JSON pointer "/array" - std::cout << j.at("/array"_json_pointer) << '\n'; - // output element with JSON pointer "/array/1" - std::cout << j.at("/array/1"_json_pointer) << '\n'; - - // out_of_range.109 - try - { - // try to use an array index that is not a number - json::const_reference ref = j.at("/array/one"_json_pointer); - } - catch (json::parse_error& e) - { - std::cout << e.what() << '\n'; - } - - // out_of_range.401 - try - { - // try to use a an invalid array index - json::const_reference ref = j.at("/array/4"_json_pointer); - } - catch (json::out_of_range& e) - { - std::cout << e.what() << '\n'; - } - - // out_of_range.402 - try - { - // try to use the array index '-' - json::const_reference ref = j.at("/array/-"_json_pointer); - } - catch (json::out_of_range& e) - { - std::cout << e.what() << '\n'; - } - - // out_of_range.403 - try - { - // try to use a JSON pointer to an nonexistent object key - json::const_reference ref = j.at("/foo"_json_pointer); - } - catch (json::out_of_range& e) - { - std::cout << e.what() << '\n'; - } - - // out_of_range.404 - try - { - // try to use a JSON pointer that cannot be resolved - json::const_reference ref = j.at("/number/foo"_json_pointer); - } - catch (json::out_of_range& e) - { - std::cout << e.what() << '\n'; - } -} diff --git a/external_imported/json/doc/examples/at_json_pointer_const.link b/external_imported/json/doc/examples/at_json_pointer_const.link deleted file mode 100644 index f04bf5a67..000000000 --- a/external_imported/json/doc/examples/at_json_pointer_const.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/back.link b/external_imported/json/doc/examples/back.link deleted file mode 100644 index 7fe2400a8..000000000 --- a/external_imported/json/doc/examples/back.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/basic_json__CompatibleType.link b/external_imported/json/doc/examples/basic_json__CompatibleType.link deleted file mode 100644 index a6336474c..000000000 --- a/external_imported/json/doc/examples/basic_json__CompatibleType.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/basic_json__InputIt_InputIt.link b/external_imported/json/doc/examples/basic_json__InputIt_InputIt.link deleted file mode 100644 index 844e914f5..000000000 --- a/external_imported/json/doc/examples/basic_json__InputIt_InputIt.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/basic_json__basic_json.link b/external_imported/json/doc/examples/basic_json__basic_json.link deleted file mode 100644 index 757e2c761..000000000 --- a/external_imported/json/doc/examples/basic_json__basic_json.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/basic_json__copyassignment.link b/external_imported/json/doc/examples/basic_json__copyassignment.link deleted file mode 100644 index 86beb677a..000000000 --- a/external_imported/json/doc/examples/basic_json__copyassignment.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/basic_json__list_init_t.link b/external_imported/json/doc/examples/basic_json__list_init_t.link deleted file mode 100644 index 126f69280..000000000 --- a/external_imported/json/doc/examples/basic_json__list_init_t.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/basic_json__moveconstructor.link b/external_imported/json/doc/examples/basic_json__moveconstructor.link deleted file mode 100644 index 9318284e8..000000000 --- a/external_imported/json/doc/examples/basic_json__moveconstructor.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/basic_json__nullptr_t.link b/external_imported/json/doc/examples/basic_json__nullptr_t.link deleted file mode 100644 index bcc4e9601..000000000 --- a/external_imported/json/doc/examples/basic_json__nullptr_t.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/basic_json__size_type_basic_json.link b/external_imported/json/doc/examples/basic_json__size_type_basic_json.link deleted file mode 100644 index 6a6742b91..000000000 --- a/external_imported/json/doc/examples/basic_json__size_type_basic_json.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/basic_json__value.link b/external_imported/json/doc/examples/basic_json__value.link deleted file mode 100644 index f47a80d6b..000000000 --- a/external_imported/json/doc/examples/basic_json__value.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/basic_json__value_ptr.cpp b/external_imported/json/doc/examples/basic_json__value_ptr.cpp deleted file mode 100644 index f25b7736a..000000000 --- a/external_imported/json/doc/examples/basic_json__value_ptr.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON object with different entry types - json j = - { - {"integer", 1}, - {"floating", 42.23}, - {"string", "hello world"}, - {"boolean", true}, - {"object", {{"key1", 1}, {"key2", 2}}}, - {"array", {1, 2, 3}} - }; - - // access existing values - int v_integer = j.value("/integer"_json_pointer, 0); - double v_floating = j.value("/floating"_json_pointer, 47.11); - - // access nonexisting values and rely on default value - std::string v_string = j.value("/nonexisting"_json_pointer, "oops"); - bool v_boolean = j.value("/nonexisting"_json_pointer, false); - - // output values - std::cout << std::boolalpha << v_integer << " " << v_floating - << " " << v_string << " " << v_boolean << "\n"; -} diff --git a/external_imported/json/doc/examples/basic_json__value_ptr.link b/external_imported/json/doc/examples/basic_json__value_ptr.link deleted file mode 100644 index 14d3851b4..000000000 --- a/external_imported/json/doc/examples/basic_json__value_ptr.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/basic_json__value_t.link b/external_imported/json/doc/examples/basic_json__value_t.link deleted file mode 100644 index d80f2482a..000000000 --- a/external_imported/json/doc/examples/basic_json__value_t.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/begin.link b/external_imported/json/doc/examples/begin.link deleted file mode 100644 index 1f59a9bd7..000000000 --- a/external_imported/json/doc/examples/begin.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/cbegin.link b/external_imported/json/doc/examples/cbegin.link deleted file mode 100644 index 26ff77342..000000000 --- a/external_imported/json/doc/examples/cbegin.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/cend.link b/external_imported/json/doc/examples/cend.link deleted file mode 100644 index a1adb3a82..000000000 --- a/external_imported/json/doc/examples/cend.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/clear.link b/external_imported/json/doc/examples/clear.link deleted file mode 100644 index 0146c1878..000000000 --- a/external_imported/json/doc/examples/clear.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/contains.cpp b/external_imported/json/doc/examples/contains.cpp deleted file mode 100644 index df8201c33..000000000 --- a/external_imported/json/doc/examples/contains.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create some JSON values - json j_object = R"( {"key": "value"} )"_json; - json j_array = R"( [1, 2, 3] )"_json; - - // call contains - std::cout << std::boolalpha << - "j_object contains 'key': " << j_object.contains("key") << '\n' << - "j_object contains 'another': " << j_object.contains("another") << '\n' << - "j_array contains 'key': " << j_array.contains("key") << std::endl; -} diff --git a/external_imported/json/doc/examples/contains.link b/external_imported/json/doc/examples/contains.link deleted file mode 100644 index f57e70268..000000000 --- a/external_imported/json/doc/examples/contains.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/contains_json_pointer.cpp b/external_imported/json/doc/examples/contains_json_pointer.cpp deleted file mode 100644 index 54bcaa9e4..000000000 --- a/external_imported/json/doc/examples/contains_json_pointer.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON value - json j = - { - {"number", 1}, {"string", "foo"}, {"array", {1, 2}} - }; - - std::cout << std::boolalpha - << j.contains("/number"_json_pointer) << '\n' - << j.contains("/string"_json_pointer) << '\n' - << j.contains("/array"_json_pointer) << '\n' - << j.contains("/array/1"_json_pointer) << '\n' - << j.contains("/array/-"_json_pointer) << '\n' - << j.contains("/array/4"_json_pointer) << '\n' - << j.contains("/baz"_json_pointer) << std::endl; - - try - { - // try to use an array index with leading '0' - j.contains("/array/01"_json_pointer); - } - catch (json::parse_error& e) - { - std::cout << e.what() << '\n'; - } - - try - { - // try to use an array index that is not a number - j.contains("/array/one"_json_pointer); - } - catch (json::parse_error& e) - { - std::cout << e.what() << '\n'; - } -} diff --git a/external_imported/json/doc/examples/contains_json_pointer.link b/external_imported/json/doc/examples/contains_json_pointer.link deleted file mode 100644 index 1648e373d..000000000 --- a/external_imported/json/doc/examples/contains_json_pointer.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/count.link b/external_imported/json/doc/examples/count.link deleted file mode 100644 index 2c4c08131..000000000 --- a/external_imported/json/doc/examples/count.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/crbegin.link b/external_imported/json/doc/examples/crbegin.link deleted file mode 100644 index f7da8d6fd..000000000 --- a/external_imported/json/doc/examples/crbegin.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/crend.link b/external_imported/json/doc/examples/crend.link deleted file mode 100644 index fc3d145fd..000000000 --- a/external_imported/json/doc/examples/crend.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/diagnostics_extended.link b/external_imported/json/doc/examples/diagnostics_extended.link deleted file mode 100644 index 9f10da942..000000000 --- a/external_imported/json/doc/examples/diagnostics_extended.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/diagnostics_standard.link b/external_imported/json/doc/examples/diagnostics_standard.link deleted file mode 100644 index cd0453b5e..000000000 --- a/external_imported/json/doc/examples/diagnostics_standard.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/diff.link b/external_imported/json/doc/examples/diff.link deleted file mode 100644 index 7adb19bba..000000000 --- a/external_imported/json/doc/examples/diff.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/dump.link b/external_imported/json/doc/examples/dump.link deleted file mode 100644 index 84d944151..000000000 --- a/external_imported/json/doc/examples/dump.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/emplace.link b/external_imported/json/doc/examples/emplace.link deleted file mode 100644 index 02b41d8bb..000000000 --- a/external_imported/json/doc/examples/emplace.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/emplace_back.link b/external_imported/json/doc/examples/emplace_back.link deleted file mode 100644 index 7290ca695..000000000 --- a/external_imported/json/doc/examples/emplace_back.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/empty.link b/external_imported/json/doc/examples/empty.link deleted file mode 100644 index cfe5867c2..000000000 --- a/external_imported/json/doc/examples/empty.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/end.link b/external_imported/json/doc/examples/end.link deleted file mode 100644 index abe8fedd7..000000000 --- a/external_imported/json/doc/examples/end.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/erase__IteratorType.link b/external_imported/json/doc/examples/erase__IteratorType.link deleted file mode 100644 index f1d7ba51d..000000000 --- a/external_imported/json/doc/examples/erase__IteratorType.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/erase__IteratorType_IteratorType.link b/external_imported/json/doc/examples/erase__IteratorType_IteratorType.link deleted file mode 100644 index 2d6d24c20..000000000 --- a/external_imported/json/doc/examples/erase__IteratorType_IteratorType.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/erase__key_type.link b/external_imported/json/doc/examples/erase__key_type.link deleted file mode 100644 index df8239156..000000000 --- a/external_imported/json/doc/examples/erase__key_type.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/erase__size_type.link b/external_imported/json/doc/examples/erase__size_type.link deleted file mode 100644 index a46d5276c..000000000 --- a/external_imported/json/doc/examples/erase__size_type.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/exception.link b/external_imported/json/doc/examples/exception.link deleted file mode 100644 index 5f40ff4c7..000000000 --- a/external_imported/json/doc/examples/exception.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/find__key_type.link b/external_imported/json/doc/examples/find__key_type.link deleted file mode 100644 index 0bfcc8a70..000000000 --- a/external_imported/json/doc/examples/find__key_type.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/flatten.link b/external_imported/json/doc/examples/flatten.link deleted file mode 100644 index ac836a585..000000000 --- a/external_imported/json/doc/examples/flatten.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/from_bson.cpp b/external_imported/json/doc/examples/from_bson.cpp deleted file mode 100644 index df71dd37e..000000000 --- a/external_imported/json/doc/examples/from_bson.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create byte vector - std::vector v = {0x1b, 0x00, 0x00, 0x00, 0x08, 0x63, 0x6f, 0x6d, - 0x70, 0x61, 0x63, 0x74, 0x00, 0x01, 0x10, 0x73, - 0x63, 0x68, 0x65, 0x6d, 0x61, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00 - }; - - // deserialize it with BSON - json j = json::from_bson(v); - - // print the deserialized JSON value - std::cout << std::setw(2) << j << std::endl; -} diff --git a/external_imported/json/doc/examples/from_bson.link b/external_imported/json/doc/examples/from_bson.link deleted file mode 100644 index 08af52bcc..000000000 --- a/external_imported/json/doc/examples/from_bson.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/from_cbor.cpp b/external_imported/json/doc/examples/from_cbor.cpp deleted file mode 100644 index e49987e55..000000000 --- a/external_imported/json/doc/examples/from_cbor.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create byte vector - std::vector v = {0xa2, 0x67, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, - 0x74, 0xf5, 0x66, 0x73, 0x63, 0x68, 0x65, 0x6d, - 0x61, 0x00 - }; - - // deserialize it with CBOR - json j = json::from_cbor(v); - - // print the deserialized JSON value - std::cout << std::setw(2) << j << std::endl; -} diff --git a/external_imported/json/doc/examples/from_cbor.link b/external_imported/json/doc/examples/from_cbor.link deleted file mode 100644 index bbb578c4a..000000000 --- a/external_imported/json/doc/examples/from_cbor.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/from_msgpack.cpp b/external_imported/json/doc/examples/from_msgpack.cpp deleted file mode 100644 index 67fdc454b..000000000 --- a/external_imported/json/doc/examples/from_msgpack.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create byte vector - std::vector v = {0x82, 0xa7, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, - 0x74, 0xc3, 0xa6, 0x73, 0x63, 0x68, 0x65, 0x6d, - 0x61, 0x00 - }; - - // deserialize it with MessagePack - json j = json::from_msgpack(v); - - // print the deserialized JSON value - std::cout << std::setw(2) << j << std::endl; -} diff --git a/external_imported/json/doc/examples/from_msgpack.link b/external_imported/json/doc/examples/from_msgpack.link deleted file mode 100644 index 77a55594c..000000000 --- a/external_imported/json/doc/examples/from_msgpack.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/from_ubjson.cpp b/external_imported/json/doc/examples/from_ubjson.cpp deleted file mode 100644 index a84057ed1..000000000 --- a/external_imported/json/doc/examples/from_ubjson.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create byte vector - std::vector v = {0x7B, 0x69, 0x07, 0x63, 0x6F, 0x6D, 0x70, 0x61, - 0x63, 0x74, 0x54, 0x69, 0x06, 0x73, 0x63, 0x68, - 0x65, 0x6D, 0x61, 0x69, 0x00, 0x7D - }; - - // deserialize it with UBJSON - json j = json::from_ubjson(v); - - // print the deserialized JSON value - std::cout << std::setw(2) << j << std::endl; -} diff --git a/external_imported/json/doc/examples/from_ubjson.link b/external_imported/json/doc/examples/from_ubjson.link deleted file mode 100644 index c5f82cb48..000000000 --- a/external_imported/json/doc/examples/from_ubjson.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/front.link b/external_imported/json/doc/examples/front.link deleted file mode 100644 index ab3cc8d57..000000000 --- a/external_imported/json/doc/examples/front.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/get__PointerType.cpp b/external_imported/json/doc/examples/get__PointerType.cpp deleted file mode 100644 index 2f32ed7af..000000000 --- a/external_imported/json/doc/examples/get__PointerType.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON number - json value = 17; - - // explicitly getting pointers - auto p1 = value.get(); - auto p2 = value.get(); - auto p3 = value.get(); - auto p4 = value.get(); - auto p5 = value.get(); - - // print the pointees - std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n'; - std::cout << std::boolalpha << (p5 == nullptr) << '\n'; -} diff --git a/external_imported/json/doc/examples/get__PointerType.link b/external_imported/json/doc/examples/get__PointerType.link deleted file mode 100644 index f4a213e15..000000000 --- a/external_imported/json/doc/examples/get__PointerType.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/get__ValueType_const.cpp b/external_imported/json/doc/examples/get__ValueType_const.cpp deleted file mode 100644 index 7a703aaeb..000000000 --- a/external_imported/json/doc/examples/get__ValueType_const.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON value with different types - json json_types = - { - {"boolean", true}, - { - "number", { - {"integer", 42}, - {"floating-point", 17.23} - } - }, - {"string", "Hello, world!"}, - {"array", {1, 2, 3, 4, 5}}, - {"null", nullptr} - }; - - // use explicit conversions - auto v1 = json_types["boolean"].get(); - auto v2 = json_types["number"]["integer"].get(); - auto v3 = json_types["number"]["integer"].get(); - auto v4 = json_types["number"]["floating-point"].get(); - auto v5 = json_types["number"]["floating-point"].get(); - auto v6 = json_types["string"].get(); - auto v7 = json_types["array"].get>(); - auto v8 = json_types.get>(); - - // print the conversion results - std::cout << v1 << '\n'; - std::cout << v2 << ' ' << v3 << '\n'; - std::cout << v4 << ' ' << v5 << '\n'; - std::cout << v6 << '\n'; - - for (auto i : v7) - { - std::cout << i << ' '; - } - std::cout << "\n\n"; - - for (auto i : v8) - { - std::cout << i.first << ": " << i.second << '\n'; - } -} diff --git a/external_imported/json/doc/examples/get__ValueType_const.link b/external_imported/json/doc/examples/get__ValueType_const.link deleted file mode 100644 index cf444a129..000000000 --- a/external_imported/json/doc/examples/get__ValueType_const.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/get_ptr.link b/external_imported/json/doc/examples/get_ptr.link deleted file mode 100644 index 139fd0435..000000000 --- a/external_imported/json/doc/examples/get_ptr.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/get_ref.link b/external_imported/json/doc/examples/get_ref.link deleted file mode 100644 index 360d00229..000000000 --- a/external_imported/json/doc/examples/get_ref.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/get_to.link b/external_imported/json/doc/examples/get_to.link deleted file mode 100644 index 5adf0ec78..000000000 --- a/external_imported/json/doc/examples/get_to.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/insert.link b/external_imported/json/doc/examples/insert.link deleted file mode 100644 index 4d742039f..000000000 --- a/external_imported/json/doc/examples/insert.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/insert__count.link b/external_imported/json/doc/examples/insert__count.link deleted file mode 100644 index 49b892bb7..000000000 --- a/external_imported/json/doc/examples/insert__count.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/insert__ilist.link b/external_imported/json/doc/examples/insert__ilist.link deleted file mode 100644 index ea6760f9e..000000000 --- a/external_imported/json/doc/examples/insert__ilist.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/insert__range.link b/external_imported/json/doc/examples/insert__range.link deleted file mode 100644 index a2c24a087..000000000 --- a/external_imported/json/doc/examples/insert__range.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/insert__range_object.link b/external_imported/json/doc/examples/insert__range_object.link deleted file mode 100644 index 9c45c4739..000000000 --- a/external_imported/json/doc/examples/insert__range_object.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/invalid_iterator.link b/external_imported/json/doc/examples/invalid_iterator.link deleted file mode 100644 index 0ef322e81..000000000 --- a/external_imported/json/doc/examples/invalid_iterator.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/is_array.link b/external_imported/json/doc/examples/is_array.link deleted file mode 100644 index dd17ccbec..000000000 --- a/external_imported/json/doc/examples/is_array.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/is_binary.link b/external_imported/json/doc/examples/is_binary.link deleted file mode 100644 index 0443f9105..000000000 --- a/external_imported/json/doc/examples/is_binary.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/is_boolean.link b/external_imported/json/doc/examples/is_boolean.link deleted file mode 100644 index 3e740d6c6..000000000 --- a/external_imported/json/doc/examples/is_boolean.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/is_discarded.link b/external_imported/json/doc/examples/is_discarded.link deleted file mode 100644 index de93aa944..000000000 --- a/external_imported/json/doc/examples/is_discarded.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/is_null.link b/external_imported/json/doc/examples/is_null.link deleted file mode 100644 index fbeab6e57..000000000 --- a/external_imported/json/doc/examples/is_null.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/is_number.link b/external_imported/json/doc/examples/is_number.link deleted file mode 100644 index b10372a0a..000000000 --- a/external_imported/json/doc/examples/is_number.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/is_number_float.link b/external_imported/json/doc/examples/is_number_float.link deleted file mode 100644 index f58a47f6d..000000000 --- a/external_imported/json/doc/examples/is_number_float.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/is_number_integer.link b/external_imported/json/doc/examples/is_number_integer.link deleted file mode 100644 index 94a351dec..000000000 --- a/external_imported/json/doc/examples/is_number_integer.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/is_number_unsigned.link b/external_imported/json/doc/examples/is_number_unsigned.link deleted file mode 100644 index c8bed2123..000000000 --- a/external_imported/json/doc/examples/is_number_unsigned.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/is_object.link b/external_imported/json/doc/examples/is_object.link deleted file mode 100644 index f8240d977..000000000 --- a/external_imported/json/doc/examples/is_object.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/is_primitive.link b/external_imported/json/doc/examples/is_primitive.link deleted file mode 100644 index 7f1664989..000000000 --- a/external_imported/json/doc/examples/is_primitive.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/is_string.link b/external_imported/json/doc/examples/is_string.link deleted file mode 100644 index 999ccd948..000000000 --- a/external_imported/json/doc/examples/is_string.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/is_structured.link b/external_imported/json/doc/examples/is_structured.link deleted file mode 100644 index e54b5c1ee..000000000 --- a/external_imported/json/doc/examples/is_structured.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/items.link b/external_imported/json/doc/examples/items.link deleted file mode 100644 index 61f135604..000000000 --- a/external_imported/json/doc/examples/items.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/iterator_wrapper.cpp b/external_imported/json/doc/examples/iterator_wrapper.cpp deleted file mode 100644 index 7ef5bc57e..000000000 --- a/external_imported/json/doc/examples/iterator_wrapper.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - - // example for an object - for (auto& x : json::iterator_wrapper(j_object)) - { - std::cout << "key: " << x.key() << ", value: " << x.value() << '\n'; - } - - // example for an array - for (auto& x : json::iterator_wrapper(j_array)) - { - std::cout << "key: " << x.key() << ", value: " << x.value() << '\n'; - } -} diff --git a/external_imported/json/doc/examples/iterator_wrapper.link b/external_imported/json/doc/examples/iterator_wrapper.link deleted file mode 100644 index 43c08ab07..000000000 --- a/external_imported/json/doc/examples/iterator_wrapper.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/iterator_wrapper.output b/external_imported/json/doc/examples/iterator_wrapper.output deleted file mode 100644 index 89b09f524..000000000 --- a/external_imported/json/doc/examples/iterator_wrapper.output +++ /dev/null @@ -1,7 +0,0 @@ -key: one, value: 1 -key: two, value: 2 -key: 0, value: 1 -key: 1, value: 2 -key: 2, value: 4 -key: 3, value: 8 -key: 4, value: 16 diff --git a/external_imported/json/doc/examples/json_pointer.link b/external_imported/json/doc/examples/json_pointer.link deleted file mode 100644 index 1d3074ffe..000000000 --- a/external_imported/json/doc/examples/json_pointer.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/json_pointer__back.cpp b/external_imported/json/doc/examples/json_pointer__back.cpp deleted file mode 100644 index 3d57c589a..000000000 --- a/external_imported/json/doc/examples/json_pointer__back.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // different JSON Pointers - json::json_pointer ptr1("/foo"); - json::json_pointer ptr2("/foo/0"); - - // call empty() - std::cout << "last reference token of " << ptr1 << " is " << ptr1.back() << '\n' - << "last reference token of " << ptr2 << " is " << ptr2.back() << std::endl; -} diff --git a/external_imported/json/doc/examples/json_pointer__back.link b/external_imported/json/doc/examples/json_pointer__back.link deleted file mode 100644 index 0ab9687b6..000000000 --- a/external_imported/json/doc/examples/json_pointer__back.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/json_pointer__back.output b/external_imported/json/doc/examples/json_pointer__back.output deleted file mode 100644 index da4d02794..000000000 --- a/external_imported/json/doc/examples/json_pointer__back.output +++ /dev/null @@ -1,2 +0,0 @@ -last reference token of "/foo" is foo -last reference token of "/foo/0" is 0 diff --git a/external_imported/json/doc/examples/json_pointer__empty.cpp b/external_imported/json/doc/examples/json_pointer__empty.cpp deleted file mode 100644 index 5daaadc6c..000000000 --- a/external_imported/json/doc/examples/json_pointer__empty.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // different JSON Pointers - json::json_pointer ptr0; - json::json_pointer ptr1(""); - json::json_pointer ptr2("/foo"); - json::json_pointer ptr3("/foo/0"); - - // call empty() - std::cout << std::boolalpha - << ptr0 << ": " << ptr0.empty() << '\n' - << ptr1 << ": " << ptr1.empty() << '\n' - << ptr2 << ": " << ptr2.empty() << '\n' - << ptr3 << ": " << ptr3.empty() << std::endl; -} diff --git a/external_imported/json/doc/examples/json_pointer__empty.link b/external_imported/json/doc/examples/json_pointer__empty.link deleted file mode 100644 index bac9163fb..000000000 --- a/external_imported/json/doc/examples/json_pointer__empty.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/json_pointer__operator_add.cpp b/external_imported/json/doc/examples/json_pointer__operator_add.cpp deleted file mode 100644 index a2bbf59e8..000000000 --- a/external_imported/json/doc/examples/json_pointer__operator_add.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON pointer - json::json_pointer ptr("/foo"); - std::cout << ptr << '\n'; - - // append a JSON Pointer - ptr /= json::json_pointer("/bar/baz"); - std::cout << ptr << '\n'; - - // append a string - ptr /= "fob"; - std::cout << ptr << '\n'; - - // append an array index - ptr /= 42; - std::cout << ptr << std::endl; -} diff --git a/external_imported/json/doc/examples/json_pointer__operator_add.link b/external_imported/json/doc/examples/json_pointer__operator_add.link deleted file mode 100644 index 08cfe8c24..000000000 --- a/external_imported/json/doc/examples/json_pointer__operator_add.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/json_pointer__operator_add_binary.cpp b/external_imported/json/doc/examples/json_pointer__operator_add_binary.cpp deleted file mode 100644 index 89e0a6a53..000000000 --- a/external_imported/json/doc/examples/json_pointer__operator_add_binary.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON pointer - json::json_pointer ptr("/foo"); - - // append a JSON Pointer - std::cout << ptr / json::json_pointer("/bar/baz") << '\n'; - - // append a string - std::cout << ptr / "fob" << '\n'; - - // append an array index - std::cout << ptr / 42 << std::endl; -} diff --git a/external_imported/json/doc/examples/json_pointer__operator_add_binary.link b/external_imported/json/doc/examples/json_pointer__operator_add_binary.link deleted file mode 100644 index b973a409f..000000000 --- a/external_imported/json/doc/examples/json_pointer__operator_add_binary.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/json_pointer__parent_pointer.cpp b/external_imported/json/doc/examples/json_pointer__parent_pointer.cpp deleted file mode 100644 index 6021463a1..000000000 --- a/external_imported/json/doc/examples/json_pointer__parent_pointer.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // different JSON Pointers - json::json_pointer ptr1(""); - json::json_pointer ptr2("/foo"); - json::json_pointer ptr3("/foo/0"); - - // call parent_pointer() - std::cout << std::boolalpha - << "parent of " << ptr1 << " is " << ptr1.parent_pointer() << '\n' - << "parent of " << ptr2 << " is " << ptr2.parent_pointer() << '\n' - << "parent of " << ptr3 << " is " << ptr3.parent_pointer() << std::endl; -} diff --git a/external_imported/json/doc/examples/json_pointer__parent_pointer.link b/external_imported/json/doc/examples/json_pointer__parent_pointer.link deleted file mode 100644 index 63edd5eef..000000000 --- a/external_imported/json/doc/examples/json_pointer__parent_pointer.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/json_pointer__pop_back.cpp b/external_imported/json/doc/examples/json_pointer__pop_back.cpp deleted file mode 100644 index ed3417ec1..000000000 --- a/external_imported/json/doc/examples/json_pointer__pop_back.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create empty JSON Pointer - json::json_pointer ptr("/foo/bar/baz"); - std::cout << ptr << '\n'; - - // call pop_back() - ptr.pop_back(); - std::cout << ptr << '\n'; - - ptr.pop_back(); - std::cout << ptr << '\n'; - - ptr.pop_back(); - std::cout << ptr << '\n'; -} diff --git a/external_imported/json/doc/examples/json_pointer__pop_back.link b/external_imported/json/doc/examples/json_pointer__pop_back.link deleted file mode 100644 index 93872948d..000000000 --- a/external_imported/json/doc/examples/json_pointer__pop_back.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/json_pointer__push_back.cpp b/external_imported/json/doc/examples/json_pointer__push_back.cpp deleted file mode 100644 index d6536b3f9..000000000 --- a/external_imported/json/doc/examples/json_pointer__push_back.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create empty JSON Pointer - json::json_pointer ptr; - std::cout << ptr << '\n'; - - // call push_back() - ptr.push_back("foo"); - std::cout << ptr << '\n'; - - ptr.push_back("0"); - std::cout << ptr << '\n'; - - ptr.push_back("bar"); - std::cout << ptr << '\n'; -} diff --git a/external_imported/json/doc/examples/json_pointer__push_back.link b/external_imported/json/doc/examples/json_pointer__push_back.link deleted file mode 100644 index df40229e2..000000000 --- a/external_imported/json/doc/examples/json_pointer__push_back.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/json_pointer__to_string.cpp b/external_imported/json/doc/examples/json_pointer__to_string.cpp deleted file mode 100644 index da397cdf4..000000000 --- a/external_imported/json/doc/examples/json_pointer__to_string.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // different JSON Pointers - json::json_pointer ptr1(""); - json::json_pointer ptr2("/foo"); - json::json_pointer ptr3("/foo/0"); - json::json_pointer ptr4("/"); - json::json_pointer ptr5("/a~1b"); - json::json_pointer ptr6("/c%d"); - json::json_pointer ptr7("/e^f"); - json::json_pointer ptr8("/g|h"); - json::json_pointer ptr9("/i\\j"); - json::json_pointer ptr10("/k\"l"); - json::json_pointer ptr11("/ "); - json::json_pointer ptr12("/m~0n"); - - - std::cout << ptr1.to_string() << '\n' - << ptr2.to_string() << '\n' - << ptr3.to_string() << '\n' - << ptr4.to_string() << '\n' - << ptr5.to_string() << '\n' - << ptr6.to_string() << '\n' - << ptr7.to_string() << '\n' - << ptr8.to_string() << '\n' - << ptr9.to_string() << '\n' - << ptr10.to_string() << '\n' - << ptr11.to_string() << '\n' - << ptr12.to_string() << std::endl; -} diff --git a/external_imported/json/doc/examples/json_pointer__to_string.link b/external_imported/json/doc/examples/json_pointer__to_string.link deleted file mode 100644 index 51eb09342..000000000 --- a/external_imported/json/doc/examples/json_pointer__to_string.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/json_pointer__to_string.output b/external_imported/json/doc/examples/json_pointer__to_string.output deleted file mode 100644 index c4b5ea8fa..000000000 --- a/external_imported/json/doc/examples/json_pointer__to_string.output +++ /dev/null @@ -1,12 +0,0 @@ - -/foo -/foo/0 -/ -/a~1b -/c%d -/e^f -/g|h -/i\j -/k"l -/ -/m~0n diff --git a/external_imported/json/doc/examples/max_size.link b/external_imported/json/doc/examples/max_size.link deleted file mode 100644 index 52bd366c7..000000000 --- a/external_imported/json/doc/examples/max_size.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/max_size.output b/external_imported/json/doc/examples/max_size.output deleted file mode 100644 index 8c79995ba..000000000 --- a/external_imported/json/doc/examples/max_size.output +++ /dev/null @@ -1,7 +0,0 @@ -0 -1 -1 -1 -256204778801521550 -1152921504606846975 -1 diff --git a/external_imported/json/doc/examples/merge_patch.link b/external_imported/json/doc/examples/merge_patch.link deleted file mode 100644 index 241098940..000000000 --- a/external_imported/json/doc/examples/merge_patch.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/meta.link b/external_imported/json/doc/examples/meta.link deleted file mode 100644 index 6955de3d7..000000000 --- a/external_imported/json/doc/examples/meta.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/meta.output b/external_imported/json/doc/examples/meta.output deleted file mode 100644 index 218febb6c..000000000 --- a/external_imported/json/doc/examples/meta.output +++ /dev/null @@ -1,17 +0,0 @@ -{ - "compiler": { - "c++": "201103", - "family": "clang", - "version": "12.0.0 (clang-1200.0.32.28)" - }, - "copyright": "(C) 2013-2021 Niels Lohmann", - "name": "JSON for Modern C++", - "platform": "apple", - "url": "https://github.com/nlohmann/json", - "version": { - "major": 3, - "minor": 9, - "patch": 1, - "string": "3.9.1" - } -} diff --git a/external_imported/json/doc/examples/object.link b/external_imported/json/doc/examples/object.link deleted file mode 100644 index 322128e7e..000000000 --- a/external_imported/json/doc/examples/object.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/operator__ValueType.link b/external_imported/json/doc/examples/operator__ValueType.link deleted file mode 100644 index e4db023a2..000000000 --- a/external_imported/json/doc/examples/operator__ValueType.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/operator__equal.link b/external_imported/json/doc/examples/operator__equal.link deleted file mode 100644 index 966c4f732..000000000 --- a/external_imported/json/doc/examples/operator__equal.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/operator__equal__nullptr_t.link b/external_imported/json/doc/examples/operator__equal__nullptr_t.link deleted file mode 100644 index 5321622b1..000000000 --- a/external_imported/json/doc/examples/operator__equal__nullptr_t.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/operator__greater.link b/external_imported/json/doc/examples/operator__greater.link deleted file mode 100644 index b52b4b832..000000000 --- a/external_imported/json/doc/examples/operator__greater.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/operator__greaterequal.link b/external_imported/json/doc/examples/operator__greaterequal.link deleted file mode 100644 index 7b9b42cfb..000000000 --- a/external_imported/json/doc/examples/operator__greaterequal.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/operator__less.link b/external_imported/json/doc/examples/operator__less.link deleted file mode 100644 index 96d69ee3a..000000000 --- a/external_imported/json/doc/examples/operator__less.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/operator__lessequal.link b/external_imported/json/doc/examples/operator__lessequal.link deleted file mode 100644 index 750c6fcfc..000000000 --- a/external_imported/json/doc/examples/operator__lessequal.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/operator__notequal.link b/external_imported/json/doc/examples/operator__notequal.link deleted file mode 100644 index bb094c4f7..000000000 --- a/external_imported/json/doc/examples/operator__notequal.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/operator__notequal__nullptr_t.link b/external_imported/json/doc/examples/operator__notequal__nullptr_t.link deleted file mode 100644 index 3a013c2e9..000000000 --- a/external_imported/json/doc/examples/operator__notequal__nullptr_t.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/operator__value_t.link b/external_imported/json/doc/examples/operator__value_t.link deleted file mode 100644 index 71cb2143e..000000000 --- a/external_imported/json/doc/examples/operator__value_t.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/operator_deserialize.link b/external_imported/json/doc/examples/operator_deserialize.link deleted file mode 100644 index 2e4f7283a..000000000 --- a/external_imported/json/doc/examples/operator_deserialize.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/operator_serialize.link b/external_imported/json/doc/examples/operator_serialize.link deleted file mode 100644 index f6d157ecf..000000000 --- a/external_imported/json/doc/examples/operator_serialize.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/operatorarray__key_type.link b/external_imported/json/doc/examples/operatorarray__key_type.link deleted file mode 100644 index e03051d58..000000000 --- a/external_imported/json/doc/examples/operatorarray__key_type.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/operatorarray__key_type_const.link b/external_imported/json/doc/examples/operatorarray__key_type_const.link deleted file mode 100644 index a9023380c..000000000 --- a/external_imported/json/doc/examples/operatorarray__key_type_const.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/operatorarray__size_type.link b/external_imported/json/doc/examples/operatorarray__size_type.link deleted file mode 100644 index 73b8b1692..000000000 --- a/external_imported/json/doc/examples/operatorarray__size_type.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/operatorarray__size_type_const.link b/external_imported/json/doc/examples/operatorarray__size_type_const.link deleted file mode 100644 index 3f2301897..000000000 --- a/external_imported/json/doc/examples/operatorarray__size_type_const.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/operatorjson_pointer.cpp b/external_imported/json/doc/examples/operatorjson_pointer.cpp deleted file mode 100644 index 7a0353a1c..000000000 --- a/external_imported/json/doc/examples/operatorjson_pointer.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON value - json j = - { - {"number", 1}, {"string", "foo"}, {"array", {1, 2}} - }; - - // read-only access - - // output element with JSON pointer "/number" - std::cout << j["/number"_json_pointer] << '\n'; - // output element with JSON pointer "/string" - std::cout << j["/string"_json_pointer] << '\n'; - // output element with JSON pointer "/array" - std::cout << j["/array"_json_pointer] << '\n'; - // output element with JSON pointer "/array/1" - std::cout << j["/array/1"_json_pointer] << '\n'; - - // writing access - - // change the string - j["/string"_json_pointer] = "bar"; - // output the changed string - std::cout << j["string"] << '\n'; - - // "change" a nonexisting object entry - j["/boolean"_json_pointer] = true; - // output the changed object - std::cout << j << '\n'; - - // change an array element - j["/array/1"_json_pointer] = 21; - // "change" an array element with nonexisting index - j["/array/4"_json_pointer] = 44; - // output the changed array - std::cout << j["array"] << '\n'; - - // "change" the array element past the end - j["/array/-"_json_pointer] = 55; - // output the changed array - std::cout << j["array"] << '\n'; -} diff --git a/external_imported/json/doc/examples/operatorjson_pointer.link b/external_imported/json/doc/examples/operatorjson_pointer.link deleted file mode 100644 index fa7aecb53..000000000 --- a/external_imported/json/doc/examples/operatorjson_pointer.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/operatorjson_pointer_const.cpp b/external_imported/json/doc/examples/operatorjson_pointer_const.cpp deleted file mode 100644 index a5a437b44..000000000 --- a/external_imported/json/doc/examples/operatorjson_pointer_const.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON value - const json j = - { - {"number", 1}, {"string", "foo"}, {"array", {1, 2}} - }; - - // read-only access - - // output element with JSON pointer "/number" - std::cout << j["/number"_json_pointer] << '\n'; - // output element with JSON pointer "/string" - std::cout << j["/string"_json_pointer] << '\n'; - // output element with JSON pointer "/array" - std::cout << j["/array"_json_pointer] << '\n'; - // output element with JSON pointer "/array/1" - std::cout << j["/array/1"_json_pointer] << '\n'; -} diff --git a/external_imported/json/doc/examples/operatorjson_pointer_const.link b/external_imported/json/doc/examples/operatorjson_pointer_const.link deleted file mode 100644 index eb01e1f03..000000000 --- a/external_imported/json/doc/examples/operatorjson_pointer_const.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/other_error.link b/external_imported/json/doc/examples/other_error.link deleted file mode 100644 index f542efd12..000000000 --- a/external_imported/json/doc/examples/other_error.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/out_of_range.link b/external_imported/json/doc/examples/out_of_range.link deleted file mode 100644 index 25833f31c..000000000 --- a/external_imported/json/doc/examples/out_of_range.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/parse__allow_exceptions.link b/external_imported/json/doc/examples/parse__allow_exceptions.link deleted file mode 100644 index 386dfe8e4..000000000 --- a/external_imported/json/doc/examples/parse__allow_exceptions.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/parse__array__parser_callback_t.link b/external_imported/json/doc/examples/parse__array__parser_callback_t.link deleted file mode 100644 index cdecb14a2..000000000 --- a/external_imported/json/doc/examples/parse__array__parser_callback_t.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/parse__contiguouscontainer__parser_callback_t.link b/external_imported/json/doc/examples/parse__contiguouscontainer__parser_callback_t.link deleted file mode 100644 index c681b8c3f..000000000 --- a/external_imported/json/doc/examples/parse__contiguouscontainer__parser_callback_t.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/parse__istream__parser_callback_t.link b/external_imported/json/doc/examples/parse__istream__parser_callback_t.link deleted file mode 100644 index 21118db29..000000000 --- a/external_imported/json/doc/examples/parse__istream__parser_callback_t.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/parse__iteratortype__parser_callback_t.cpp b/external_imported/json/doc/examples/parse__iteratortype__parser_callback_t.cpp deleted file mode 100644 index 1b5e23d4e..000000000 --- a/external_imported/json/doc/examples/parse__iteratortype__parser_callback_t.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // a JSON text given as std::vector - std::vector text = {'[', '1', ',', '2', ',', '3', ']', '\0'}; - - // parse and serialize JSON - json j_complete = json::parse(text.begin(), text.end()); - std::cout << std::setw(4) << j_complete << "\n\n"; -} diff --git a/external_imported/json/doc/examples/parse__iteratortype__parser_callback_t.link b/external_imported/json/doc/examples/parse__iteratortype__parser_callback_t.link deleted file mode 100644 index d12ba20b7..000000000 --- a/external_imported/json/doc/examples/parse__iteratortype__parser_callback_t.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/parse__string__parser_callback_t.link b/external_imported/json/doc/examples/parse__string__parser_callback_t.link deleted file mode 100644 index 2d24e2ec7..000000000 --- a/external_imported/json/doc/examples/parse__string__parser_callback_t.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/parse_error.link b/external_imported/json/doc/examples/parse_error.link deleted file mode 100644 index f3c0da789..000000000 --- a/external_imported/json/doc/examples/parse_error.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/patch.link b/external_imported/json/doc/examples/patch.link deleted file mode 100644 index d9b370a8d..000000000 --- a/external_imported/json/doc/examples/patch.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/push_back.link b/external_imported/json/doc/examples/push_back.link deleted file mode 100644 index b89d5c635..000000000 --- a/external_imported/json/doc/examples/push_back.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/push_back__initializer_list.link b/external_imported/json/doc/examples/push_back__initializer_list.link deleted file mode 100644 index 4e57e93a3..000000000 --- a/external_imported/json/doc/examples/push_back__initializer_list.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/push_back__object_t__value.link b/external_imported/json/doc/examples/push_back__object_t__value.link deleted file mode 100644 index 6e0cf7b13..000000000 --- a/external_imported/json/doc/examples/push_back__object_t__value.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/rbegin.link b/external_imported/json/doc/examples/rbegin.link deleted file mode 100644 index 06beb46da..000000000 --- a/external_imported/json/doc/examples/rbegin.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/rend.link b/external_imported/json/doc/examples/rend.link deleted file mode 100644 index bf8e33d4b..000000000 --- a/external_imported/json/doc/examples/rend.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/sax_parse.cpp b/external_imported/json/doc/examples/sax_parse.cpp deleted file mode 100644 index 45273eb6c..000000000 --- a/external_imported/json/doc/examples/sax_parse.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include -#include -#include -#include - -using json = nlohmann::json; - -// a simple event consumer that collects string representations of the passed -// values; not inheriting from json::json_sax_t is not required, but can -// help not to forget a required function -class sax_event_consumer : public json::json_sax_t -{ - public: - std::vector events; - - bool null() override - { - events.push_back("value: null"); - return true; - } - - bool boolean(bool val) override - { - events.push_back("value: " + std::string(val ? "true" : "false")); - return true; - } - - bool number_integer(number_integer_t val) override - { - events.push_back("value: " + std::to_string(val)); - return true; - } - - bool number_unsigned(number_unsigned_t val) override - { - events.push_back("value: " + std::to_string(val)); - return true; - } - - bool number_float(number_float_t val, const string_t& s) override - { - events.push_back("value: " + s); - return true; - } - - bool string(string_t& val) override - { - events.push_back("value: " + val); - return true; - } - - bool start_object(std::size_t elements) override - { - events.push_back("start: object"); - return true; - } - - bool end_object() override - { - events.push_back("end: object"); - return true; - } - - bool start_array(std::size_t elements) override - { - events.push_back("start: array"); - return true; - } - - bool end_array() override - { - events.push_back("end: array"); - return true; - } - - bool key(string_t& val) override - { - events.push_back("key: " + val); - return true; - } - - bool binary(json::binary_t& val) override - { - events.push_back("binary"); - return true; - } - - bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override - { - events.push_back("error: " + std::string(ex.what())); - return false; - } -}; - -int main() -{ - // a JSON text - auto text = R"( - { - "Image": { - "Width": 800, - "Height": 600, - "Title": "View from 15th Floor", - "Thumbnail": { - "Url": "http://www.example.com/image/481989943", - "Height": 125, - "Width": 100 - }, - "Animated" : false, - "IDs": [116, 943, 234, 38793], - "Distance": 12.723374634 - } - } - )"; - - // create a SAX event consumer object - sax_event_consumer sec; - - // parse and serialize JSON - bool result = json::sax_parse(text, &sec); - - // output the recorded events - for (auto& event : sec.events) - { - std::cout << "(" << event << ") "; - } - - // output the result of sax_parse - std::cout << "\nresult: " << std::boolalpha << result << std::endl; -} diff --git a/external_imported/json/doc/examples/sax_parse.link b/external_imported/json/doc/examples/sax_parse.link deleted file mode 100644 index 8bab12742..000000000 --- a/external_imported/json/doc/examples/sax_parse.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/sax_parse.output b/external_imported/json/doc/examples/sax_parse.output deleted file mode 100644 index e16c2c4de..000000000 --- a/external_imported/json/doc/examples/sax_parse.output +++ /dev/null @@ -1,2 +0,0 @@ -(start: object) (key: Image) (start: object) (key: Width) (value: 800) (key: Height) (value: 600) (key: Title) (value: View from 15th Floor) (key: Thumbnail) (start: object) (key: Url) (value: http://www.example.com/image/481989943) (key: Height) (value: 125) (key: Width) (value: 100) (end: object) (key: Animated) (value: false) (key: IDs) (start: array) (value: 116) (value: 943) (value: 234) (value: 38793) (end: array) (key: Distance) (value: 12.723374634) (end: object) (end: object) -result: true diff --git a/external_imported/json/doc/examples/size.link b/external_imported/json/doc/examples/size.link deleted file mode 100644 index 31f00cad4..000000000 --- a/external_imported/json/doc/examples/size.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/swap__array_t.link b/external_imported/json/doc/examples/swap__array_t.link deleted file mode 100644 index 75937905d..000000000 --- a/external_imported/json/doc/examples/swap__array_t.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/swap__binary_t.link b/external_imported/json/doc/examples/swap__binary_t.link deleted file mode 100644 index f035a7170..000000000 --- a/external_imported/json/doc/examples/swap__binary_t.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/swap__object_t.link b/external_imported/json/doc/examples/swap__object_t.link deleted file mode 100644 index 45b04995a..000000000 --- a/external_imported/json/doc/examples/swap__object_t.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/swap__reference.link b/external_imported/json/doc/examples/swap__reference.link deleted file mode 100644 index f056ec405..000000000 --- a/external_imported/json/doc/examples/swap__reference.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/swap__string_t.link b/external_imported/json/doc/examples/swap__string_t.link deleted file mode 100644 index 9b00374eb..000000000 --- a/external_imported/json/doc/examples/swap__string_t.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/to_bson.link b/external_imported/json/doc/examples/to_bson.link deleted file mode 100644 index 3bad4a1c4..000000000 --- a/external_imported/json/doc/examples/to_bson.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/to_cbor.link b/external_imported/json/doc/examples/to_cbor.link deleted file mode 100644 index efac9b06c..000000000 --- a/external_imported/json/doc/examples/to_cbor.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/to_msgpack.link b/external_imported/json/doc/examples/to_msgpack.link deleted file mode 100644 index 4c7a078ca..000000000 --- a/external_imported/json/doc/examples/to_msgpack.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/to_ubjson.link b/external_imported/json/doc/examples/to_ubjson.link deleted file mode 100644 index 996e19df1..000000000 --- a/external_imported/json/doc/examples/to_ubjson.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/type.link b/external_imported/json/doc/examples/type.link deleted file mode 100644 index 746aaa644..000000000 --- a/external_imported/json/doc/examples/type.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/type_error.link b/external_imported/json/doc/examples/type_error.link deleted file mode 100644 index d054b5c24..000000000 --- a/external_imported/json/doc/examples/type_error.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/type_name.link b/external_imported/json/doc/examples/type_name.link deleted file mode 100644 index c0c55597e..000000000 --- a/external_imported/json/doc/examples/type_name.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/unflatten.link b/external_imported/json/doc/examples/unflatten.link deleted file mode 100644 index 0d1be78d2..000000000 --- a/external_imported/json/doc/examples/unflatten.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/update.cpp b/external_imported/json/doc/examples/update.cpp deleted file mode 100644 index fecdae760..000000000 --- a/external_imported/json/doc/examples/update.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create two JSON objects - json o1 = R"( {"color": "red", "price": 17.99} )"_json; - json o2 = R"( {"color": "blue", "speed": 100} )"_json; - - // add all keys from o2 to o1 (updating "color") - o1.update(o2); - - // output updated object o1 - std::cout << std::setw(2) << o1 << '\n'; -} diff --git a/external_imported/json/doc/examples/update.link b/external_imported/json/doc/examples/update.link deleted file mode 100644 index 2728616a2..000000000 --- a/external_imported/json/doc/examples/update.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/update.output b/external_imported/json/doc/examples/update.output deleted file mode 100644 index 69f0965af..000000000 --- a/external_imported/json/doc/examples/update.output +++ /dev/null @@ -1,5 +0,0 @@ -{ - "color": "blue", - "price": 17.99, - "speed": 100 -} diff --git a/external_imported/json/doc/examples/update__range.cpp b/external_imported/json/doc/examples/update__range.cpp deleted file mode 100644 index 9f3e521a3..000000000 --- a/external_imported/json/doc/examples/update__range.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create two JSON objects - json o1 = R"( {"color": "red", "price": 17.99} )"_json; - json o2 = R"( {"color": "blue", "speed": 100} )"_json; - - // add all keys from o2 to o1 (updating "color") - o1.update(o2.begin(), o2.end()); - - // output updated object o1 - std::cout << std::setw(2) << o1 << '\n'; -} diff --git a/external_imported/json/doc/examples/update__range.link b/external_imported/json/doc/examples/update__range.link deleted file mode 100644 index 562ebf0ce..000000000 --- a/external_imported/json/doc/examples/update__range.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/external_imported/json/doc/examples/update__range.output b/external_imported/json/doc/examples/update__range.output deleted file mode 100644 index 69f0965af..000000000 --- a/external_imported/json/doc/examples/update__range.output +++ /dev/null @@ -1,5 +0,0 @@ -{ - "color": "blue", - "price": 17.99, - "speed": 100 -} diff --git a/external_imported/json/doc/index.md b/external_imported/json/doc/index.md deleted file mode 100644 index fac8b8563..000000000 --- a/external_imported/json/doc/index.md +++ /dev/null @@ -1,335 +0,0 @@ -# JSON for Modern C++ - -These pages contain the API documentation of JSON for Modern C++, a C++11 header-only JSON class. - -# Contents - -- Classes - - @link nlohmann::basic_json `basic_json`@endlink -- class template for JSON values - - @link nlohmann::json `json`@endlink -- the default specialization of `basic_json`, defined as `basic_json<>` -- [Functions](functions_func.html) - - object inspection - - @link nlohmann::basic_json::dump dump @endlink -- value serialization - - @link nlohmann::basic_json::type type @endlink -- type of the value - - @link nlohmann::basic_json::is_primitive is_primitive @endlink, - @link nlohmann::basic_json::is_structured is_structured @endlink, - @link nlohmann::basic_json::is_null is_null @endlink, - @link nlohmann::basic_json::is_boolean is_boolean @endlink, - @link nlohmann::basic_json::is_number is_number @endlink, - @link nlohmann::basic_json::is_number_integer is_number_integer @endlink, - @link nlohmann::basic_json::is_number_unsigned is_number_unsigned @endlink, - @link nlohmann::basic_json::is_number_float is_number_float @endlink, - @link nlohmann::basic_json::is_object is_object @endlink, - @link nlohmann::basic_json::is_array is_array @endlink, - @link nlohmann::basic_json::is_string is_string @endlink, - @link nlohmann::basic_json::is_discarded is_discarded @endlink, - @link nlohmann::basic_json::is_binary is_binary @endlink -- check for value type - - @link nlohmann::basic_json::operator value_t() const operator value_t @endlink -- type of the value (implicit conversion) - - value access - - @link nlohmann::basic_json::get get @endlink -- get a value - - @link nlohmann::basic_json::get_ptr get_ptr @endlink -- get a value pointer - - @link nlohmann::basic_json::get_ref get_ref @endlink -- get a value reference - - @link nlohmann::basic_json::get_binary get_binary @endlink -- get a binary value - - @link nlohmann::basic_json::operator ValueType() const operator ValueType @endlink -- get a value (implicit conversion) - - @link nlohmann::basic_json::value value @endlink -- get a value from an object and return default value if key is not present - - exceptions - - @link nlohmann::basic_json::parse_error parse_error @endlink for exceptions indicating a parse error - - @link nlohmann::basic_json::invalid_iterator invalid_iterator @endlink for exceptions indicating errors with iterators - - @link nlohmann::basic_json::type_error type_error @endlink for exceptions indicating executing a member function with a wrong type - - @link nlohmann::basic_json::out_of_range out_of_range @endlink for exceptions indicating access out of the defined range - - @link nlohmann::basic_json::other_error other_error @endlink for exceptions indicating other library errors - - lexicographical comparison operators - - @link nlohmann::basic_json::operator== operator== @endlink - - @link nlohmann::basic_json::operator!= operator!= @endlink - - @link nlohmann::basic_json::operator< operator<= @endlink - - @link nlohmann::basic_json::operator<= operator< @endlink - - @link nlohmann::basic_json::operator> operator> @endlink - - @link nlohmann::basic_json::operator>= operator>= @endlink - - serialization - - @link nlohmann::basic_json::dump dump @endlink serialize to string - - @link nlohmann::basic_json::operator<<(std::ostream&, const basic_json &) operator<< @endlink serialize to stream - - deserialization / parsing - - @link nlohmann::basic_json::parse parse @endlink parse from input (string, file, etc.) and return JSON value - - @link nlohmann::basic_json::sax_parse sax_parse @endlink parse from input (string, file, etc.) and generate SAX events - - @link nlohmann::basic_json::operator>>(std::istream&, basic_json&) operator>> @endlink parse from stream - - @link nlohmann::basic_json::accept accept @endlink check for syntax errors without parsing - - @link nlohmann::json_sax SAX interface @endlink define a user-defined SAX event consumer - - @link nlohmann::basic_json::parser_callback_t callback interface @endlink register a callback to the parse function - - [binary formats](binary_formats.md): - - CBOR: @link nlohmann::basic_json::from_cbor from_cbor @endlink / @link nlohmann::basic_json::to_cbor to_cbor @endlink - - MessagePack: @link nlohmann::basic_json::from_msgpack from_msgpack @endlink / @link nlohmann::basic_json::to_msgpack to_msgpack @endlink - - UBJSON: @link nlohmann::basic_json::from_ubjson from_ubjson @endlink / @link nlohmann::basic_json::to_ubjson to_ubjson @endlink - - BSON: @link nlohmann::basic_json::from_bson from_bson @endlink / @link nlohmann::basic_json::to_bson to_bson @endlink -- Types - - @link nlohmann::basic_json::array_t arrays @endlink - - @link nlohmann::basic_json::object_t objects @endlink - - @link nlohmann::basic_json::string_t strings @endlink - - @link nlohmann::basic_json::boolean_t booleans @endlink - - numbers - - @link nlohmann::basic_json::number_integer_t signed integers @endlink - - @link nlohmann::basic_json::number_unsigned_t unsigned integers @endlink - - @link nlohmann::basic_json::number_float_t floating-point @endlink - - @link nlohmann::basic_json::binary_t binary values @endlink -- further JSON standards - - @link nlohmann::json_pointer JSON Pointer @endlink (RFC 6901) - - @link nlohmann::basic_json::patch JSON Patch @endlink (RFC 6902) - - @link nlohmann::basic_json::merge_patch JSON Merge Patch @endlink (RFC 7396) - -# Container function overview - -The container functions known from STL have been extended to support the different value types from JSON. However, not all functions can be applied to all value types. Note that the signature of some functions differ between the types; for instance, `at` may be called with either a string to address a key in an object or with an integer to address a value in an array. - -Note that this table only lists those exceptions thrown due to the type. For instance, the @link nlohmann::basic_json::at(const typename object_t::key_type & key) `at` @endlink function will always throw a @link nlohmann::basic_json::type_error `json::type_error` @endlink exception when called for a string type. When called for an array, it *may* throw an @link nlohmann::basic_json::out_of_range `json::out_of_range` @endlink exception if the passed index is invalid. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
groupfunctionJSON value type
objectarraystringnumberbooleannull
iterators`begin`@link nlohmann::basic_json::begin `begin` @endlink@link nlohmann::basic_json::begin `begin` @endlink@link nlohmann::basic_json::begin `begin` @endlink@link nlohmann::basic_json::begin `begin` @endlink@link nlohmann::basic_json::begin `begin` @endlink@link nlohmann::basic_json::begin `begin` @endlink (returns `end()`)
`cbegin`@link nlohmann::basic_json::cbegin `cbegin` @endlink@link nlohmann::basic_json::cbegin `cbegin` @endlink@link nlohmann::basic_json::cbegin `cbegin` @endlink@link nlohmann::basic_json::cbegin `cbegin` @endlink@link nlohmann::basic_json::cbegin `cbegin` @endlink@link nlohmann::basic_json::cbegin `cbegin` @endlink (returns `cend()`)
`end`@link nlohmann::basic_json::end `end` @endlink@link nlohmann::basic_json::end `end` @endlink@link nlohmann::basic_json::end `end` @endlink@link nlohmann::basic_json::end `end` @endlink@link nlohmann::basic_json::end `end` @endlink@link nlohmann::basic_json::end `end` @endlink
`cend`@link nlohmann::basic_json::cend `cend` @endlink@link nlohmann::basic_json::cend `cend` @endlink@link nlohmann::basic_json::cend `cend` @endlink@link nlohmann::basic_json::cend `cend` @endlink@link nlohmann::basic_json::cend `cend` @endlink@link nlohmann::basic_json::cend `cend` @endlink
`rbegin`@link nlohmann::basic_json::rbegin `rbegin` @endlink@link nlohmann::basic_json::rbegin `rbegin` @endlink@link nlohmann::basic_json::rbegin `rbegin` @endlink@link nlohmann::basic_json::rbegin `rbegin` @endlink@link nlohmann::basic_json::rbegin `rbegin` @endlink@link nlohmann::basic_json::rbegin `rbegin` @endlink
`crbegin`@link nlohmann::basic_json::crbegin `crbegin` @endlink@link nlohmann::basic_json::crbegin `crbegin` @endlink@link nlohmann::basic_json::crbegin `crbegin` @endlink@link nlohmann::basic_json::crbegin `crbegin` @endlink@link nlohmann::basic_json::crbegin `crbegin` @endlink@link nlohmann::basic_json::crbegin `crbegin` @endlink
`rend`@link nlohmann::basic_json::rend `rend` @endlink@link nlohmann::basic_json::rend `rend` @endlink@link nlohmann::basic_json::rend `rend` @endlink@link nlohmann::basic_json::rend `rend` @endlink@link nlohmann::basic_json::rend `rend` @endlink@link nlohmann::basic_json::rend `rend` @endlink
`crend`@link nlohmann::basic_json::crend `crend` @endlink@link nlohmann::basic_json::crend `crend` @endlink@link nlohmann::basic_json::crend `crend` @endlink@link nlohmann::basic_json::crend `crend` @endlink@link nlohmann::basic_json::crend `crend` @endlink@link nlohmann::basic_json::crend `crend` @endlink
element
access
`at`@link nlohmann::basic_json::at(const typename object_t::key_type & key) `at` @endlink@link nlohmann::basic_json::at(size_type) `at` @endlinkthrows @link nlohmann::basic_json::type_error `json::type_error` @endlink (304)throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (304)throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (304)throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (304)
`operator[]`@link nlohmann::basic_json::operator[](const typename object_t::key_type &key) `operator[]` @endlink@link nlohmann::basic_json::operator[](size_type) `operator[]` @endlinkthrows @link nlohmann::basic_json::type_error `json::type_error` @endlink (305)throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (305)throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (305)@link nlohmann::basic_json::operator[](const typename object_t::key_type & key) `operator[]` @endlink (creates object)
@link nlohmann::basic_json::operator[](size_type) `operator[]` @endlink (creates array)
`front`@link nlohmann::basic_json::front `front` @endlink@link nlohmann::basic_json::front `front` @endlink@link nlohmann::basic_json::front `front` @endlink@link nlohmann::basic_json::front `front` @endlink@link nlohmann::basic_json::front `front` @endlinkthrows @link nlohmann::basic_json::invalid_iterator `json::invalid_iterator` @endlink (214)
`back`@link nlohmann::basic_json::back `back` @endlink@link nlohmann::basic_json::back `back` @endlink@link nlohmann::basic_json::back `back` @endlink@link nlohmann::basic_json::back `back` @endlink@link nlohmann::basic_json::back `back` @endlinkthrows @link nlohmann::basic_json::invalid_iterator `json::invalid_iterator` @endlink (214)
capacity`empty`@link nlohmann::basic_json::empty `empty` @endlink@link nlohmann::basic_json::empty `empty` @endlink@link nlohmann::basic_json::empty `empty` @endlink (returns `false`)@link nlohmann::basic_json::empty `empty` @endlink (returns `false`)@link nlohmann::basic_json::empty `empty` @endlink (returns `false`)@link nlohmann::basic_json::empty `empty` @endlink (returns `true`)
`size`@link nlohmann::basic_json::size `size` @endlink@link nlohmann::basic_json::size `size` @endlink@link nlohmann::basic_json::size `size` @endlink (returns `1`)@link nlohmann::basic_json::size `size` @endlink (returns `1`)@link nlohmann::basic_json::size `size` @endlink (returns `1`)@link nlohmann::basic_json::size `size` @endlink (returns `0`)
`max_size_`@link nlohmann::basic_json::max_size `max_size` @endlink@link nlohmann::basic_json::max_size `max_size` @endlink@link nlohmann::basic_json::max_size `max_size` @endlink (returns `1`)@link nlohmann::basic_json::max_size `max_size` @endlink (returns `1`)@link nlohmann::basic_json::max_size `max_size` @endlink (returns `1`)@link nlohmann::basic_json::max_size `max_size` @endlink (returns `0`)
modifiers`clear`@link nlohmann::basic_json::clear `clear` @endlink@link nlohmann::basic_json::clear `clear` @endlink@link nlohmann::basic_json::clear `clear` @endlink@link nlohmann::basic_json::clear `clear` @endlink@link nlohmann::basic_json::clear `clear` @endlink@link nlohmann::basic_json::clear `clear` @endlink
`insert`throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (309)@link nlohmann::basic_json::insert `insert` @endlinkthrows @link nlohmann::basic_json::type_error `json::type_error` @endlink (309)throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (309)throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (309)throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (309)
`erase`@link nlohmann::basic_json::erase `erase` @endlink@link nlohmann::basic_json::erase `erase` @endlink@link nlohmann::basic_json::erase `erase` @endlink (converts to null)@link nlohmann::basic_json::erase `erase` @endlink (converts to null)@link nlohmann::basic_json::erase `erase` @endlink (converts to null)throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (307)
`push_back`@link nlohmann::basic_json::push_back(const typename object_t::value_type & val) `push_back` @endlink@link nlohmann::basic_json::push_back(const nlohmann::basic_json &) `push_back` @endlinkthrows @link nlohmann::basic_json::type_error `json::type_error` @endlink (308)throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (308)throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (308)@link nlohmann::basic_json::push_back(const typename object_t::value_type & val) `push_back` @endlink (creates object)
@link nlohmann::basic_json::push_back(const nlohmann::basic_json &) `push_back` @endlink (creates array)
`emplace` / `emplace_back`@link nlohmann::basic_json::emplace() `emplace` @endlink@link nlohmann::basic_json::emplace_back() `emplace_back` @endlinkthrows @link nlohmann::basic_json::type_error `json::type_error` @endlink (311)throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (311)throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (311)@link nlohmann::basic_json::emplace() `emplace` @endlink (creates object)
@link nlohmann::basic_json::emplace_back() `emplace_back` @endlink (creates array)
`update`@link nlohmann::basic_json::update() `update` @endlinkthrows @link nlohmann::basic_json::type_error `json::type_error` @endlink (312)throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (312)throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (312)throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (312)throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (312)
`swap`@link nlohmann::basic_json::swap `swap` @endlink@link nlohmann::basic_json::swap `swap` @endlink@link nlohmann::basic_json::swap `swap` @endlink@link nlohmann::basic_json::swap `swap` @endlink@link nlohmann::basic_json::swap `swap` @endlink@link nlohmann::basic_json::swap `swap` @endlink
lookup`find`@link nlohmann::basic_json::find `find` @endlink@link nlohmann::basic_json::find `find` @endlink (returns `end()`)@link nlohmann::basic_json::find `find` @endlink (returns `end()`)@link nlohmann::basic_json::find `find` @endlink (returns `end()`)@link nlohmann::basic_json::find `find` @endlink (returns `end()`)@link nlohmann::basic_json::find `find` @endlink (returns `end()`)
`count`@link nlohmann::basic_json::count `count` @endlink@link nlohmann::basic_json::count `count` @endlink (returns `0`)@link nlohmann::basic_json::count `count` @endlink (returns `0`)@link nlohmann::basic_json::count `count` @endlink (returns `0`)@link nlohmann::basic_json::count `count` @endlink (returns `0`)@link nlohmann::basic_json::count `count` @endlink (returns `0`)
`contains`@link nlohmann::basic_json::contains `contains` @endlink@link nlohmann::basic_json::contains `contains` @endlink (returns `false`)@link nlohmann::basic_json::contains `contains` @endlink (returns `false`)@link nlohmann::basic_json::contains `contains` @endlink (returns `false`)@link nlohmann::basic_json::contains `contains` @endlink (returns `false`)@link nlohmann::basic_json::contains `contains` @endlink (returns `false`)
- -@copyright Copyright © 2013-2021 Niels Lohmann. The code is licensed under the [MIT License](http://opensource.org/licenses/MIT). - -@author [Niels Lohmann](http://nlohmann.me) -@see https://github.com/nlohmann/json to download the source code - -@version 3.9.1 diff --git a/external_imported/json/doc/json.gif b/external_imported/json/doc/json.gif deleted file mode 100644 index 7542048ed..000000000 Binary files a/external_imported/json/doc/json.gif and /dev/null differ diff --git a/external_imported/json/doc/mkdocs/Makefile b/external_imported/json/doc/mkdocs/Makefile deleted file mode 100644 index 85bc6a920..000000000 --- a/external_imported/json/doc/mkdocs/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -# serve the site locally -serve: prepare_files - venv/bin/mkdocs serve - -build: prepare_files - venv/bin/mkdocs build - -# create files that are not versioned inside the mkdocs folder -prepare_files: clean - # build Doxygen - $(MAKE) -C .. - # create subfolders - mkdir docs/images docs/examples - # copy images - cp -vr ../json.gif ../images/range-begin-end.svg ../images/range-rbegin-rend.svg ../images/callback_events.png docs/images - # copy examples - cp -vr ../examples/*.cpp ../examples/*.output docs/examples - -# clean subfolders -clean: - rm -fr docs/images docs/examples - -# publish site to GitHub pages -publish: prepare_files - venv/bin/mkdocs gh-deploy --clean --force - -# install a Python virtual environment -install_venv: requirements.txt - python3 -mvenv venv - venv/bin/pip install -r requirements.txt - -# uninstall the virtual environment -uninstall_venv: clean - rm -fr venv diff --git a/external_imported/json/doc/mkdocs/docs/api/adl_serializer.md b/external_imported/json/doc/mkdocs/docs/api/adl_serializer.md deleted file mode 100644 index 7b79747f5..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/adl_serializer.md +++ /dev/null @@ -1,31 +0,0 @@ -# adl_serializer - -```cpp -template -struct adl_serializer; -``` - -Serializer that uses ADL ([Argument-Dependent Lookup](https://en.cppreference.com/w/cpp/language/adl)) to choose -`to_json`/`from_json` functions from the types' namespaces. - -It is implemented similar to - -```cpp -template -struct adl_serializer { - template - static void to_json(BasicJsonType& j, const T& value) { - // calls the "to_json" method in T's namespace - } - - template - static void from_json(const BasicJsonType& j, T& value) { - // same thing, but with the "from_json" method - } -}; -``` - -## Member functions - -- **from_json** - convert a JSON value to any value type -- **to_json** - convert any value type to a JSON value diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/accept.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/accept.md deleted file mode 100644 index b18c5391a..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/accept.md +++ /dev/null @@ -1,90 +0,0 @@ -# basic_json::accept - -```cpp -// (1) -template -static bool accept(InputType&& i, - const bool ignore_comments = false); - -// (2) -template -static bool accept(IteratorType first, IteratorType last, - const bool ignore_comments = false); -``` - -Checks whether the input is valid JSON. - -1. Reads from a compatible input. -2. Reads from a pair of character iterators - - The value_type of the iterator must be a integral type with size of 1, 2 or 4 bytes, which will be interpreted - respectively as UTF-8, UTF-16 and UTF-32. - -Unlike the [`parse`](parse.md) function, this function neither throws an exception in case of invalid JSON input -(i.e., a parse error) nor creates diagnostic information. - -## Template parameters - -`InputType` -: A compatible input, for instance: - - - an `std::istream` object - - a `FILE` pointer - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. - -`IteratorType` -: a compatible iterator type - -## Parameters - -`i` (in) -: Input to parse from. - -`ignore_comments` (in) -: whether comments should be ignored and treated like whitespace (`#!cpp true`) or yield a parse error - (`#!cpp false`); (optional, `#!cpp false` by default) - -`first` (in) -: iterator to start of character range - -`last` (in) -: iterator to end of character range - -## Return value - -Whether the input is valid JSON. - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Complexity - -Linear in the length of the input. The parser is a predictive LL(1) parser. - -## Notes - -(1) A UTF-8 byte order mark is silently ignored. - -## Examples - -??? example - - The example below demonstrates the `accept()` function reading from a string. - - ```cpp - --8<-- "examples/accept__string.cpp" - ``` - - Output: - - ```json - --8<-- "examples/accept__string.output" - ``` - -## Version history - -- Added in version 3.0.0. -- Ignoring comments via `ignore_comments` added in version 3.9.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/array_t.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/array_t.md deleted file mode 100644 index 89e39dbf8..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/array_t.md +++ /dev/null @@ -1,52 +0,0 @@ -# basic_json::array_t - -```cpp -using array_t = ArrayType>; -``` - -The type used to store JSON arrays. - -[RFC 7159](http://rfc7159.net/rfc7159) describes JSON arrays as follows: -> An array is an ordered sequence of zero or more values. - -To store objects in C++, a type is defined by the template parameters explained below. - -## Template parameters - -`ArrayType` -: container type to store arrays (e.g., `std::vector` or `std::list`) - -`AllocatorType` -: the allocator to use for objects (e.g., `std::allocator`) - -## Notes - -#### Default type - -With the default values for `ArrayType` (`std::vector`) and `AllocatorType` (`std::allocator`), the default value for -`array_t` is: - -```cpp -std::vector< - basic_json, // value_type - std::allocator // allocator_type -> -``` - -#### Limits - -[RFC 7159](http://rfc7159.net/rfc7159) specifies: -> An implementation may set limits on the maximum depth of nesting. - -In this class, the array's limit of nesting is not explicitly constrained. However, a maximum depth of nesting may be -introduced by the compiler or runtime environment. A theoretical limit can be queried by calling the -[`max_size`](max_size.md) function of a JSON array. - -#### Storage - -Arrays are stored as pointers in a `basic_json` type. That is, for any access to array values, a pointer of type -`#!cpp array_t*` must be dereferenced. - -## Version history - -- Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/at.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/at.md deleted file mode 100644 index 75977b180..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/at.md +++ /dev/null @@ -1,171 +0,0 @@ -# basic_json::at - -```cpp -// (1) -reference at(size_type idx); -const_reference at(size_type idx) const; - -// (2) -reference at(const typename object_t::key_type& key); -const_reference at(const typename object_t::key_type& key) const; - -// (3) -reference at(const json_pointer& ptr); -const_reference at(const json_pointer& ptr) const; -``` - -1. Returns a reference to the element at specified location `idx`, with bounds checking. -2. Returns a reference to the element at with specified key `key`, with bounds checking. -3. Returns a reference to the element at with specified JSON pointer `ptr`, with bounds checking. - -## Parameters - -`idx` (in) -: index of the element to access - -`key` (in) -: object key of the elements to remove - -`ptr` (in) -: JSON pointer to the desired element - -## Return value - -1. reference to the element at index `idx` -2. reference to the element at key `key` -3. reference to the element pointed to by `ptr` - -## Exceptions - -1. The function can throw the following exceptions: - - Throws [`type_error.304`](../../home/exceptions.md#jsonexceptiontype_error304) if the JSON value is not an array; - in this case, calling `at` with an index makes no sense. See example below. - - Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) if the index `idx` is out of - range of the array; that is, `idx >= size()`. See example below. -2. The function can throw the following exceptions: - - Throws [`type_error.304`](../../home/exceptions.md#jsonexceptiontype_error304) if the JSON value is not an object; - in this case, calling `at` with a key makes no sense. See example below. - - Throws [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if the key `key` is is not - stored in the object; that is, `find(key) == end()`. See example below. -3. The function can throw the following exceptions: - - Throws [`parse_error.106`](../../home/exceptions.md#jsonexceptionparse_error106) if an array index in the passed - JSON pointer `ptr` begins with '0'. See example below. - - Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109) if an array index in the passed - JSON pointer `ptr` is not a number. See example below. - - Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) if an array index in the passed - JSON pointer `ptr` is out of range. See example below. - - Throws [`out_of_range.402`](../../home/exceptions.md#jsonexceptionout_of_range402) if the array index '-' is used - in the passed JSON pointer `ptr`. As `at` provides checked access (and no elements are implicitly inserted), the - index '-' is always invalid. See example below. - - Throws [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if the JSON pointer describes a - key of an object which cannot be found. See example below. - - Throws [`out_of_range.404`](../../home/exceptions.md#jsonexceptionout_of_range404) if the JSON pointer `ptr` can - not be resolved. See example below. - -## Exception safety - -Strong exception safety: if an exception occurs, the original value stays intact. - -## Complexity - -1. Constant -2. Logarithmic in the size of the container. -3. Constant - -## Example - -??? example - - The example below shows how array elements can be read and written using `at()`. It also demonstrates the different - exceptions that can be thrown. - - ```cpp - --8<-- "examples/at__size_type.cpp" - ``` - - Output: - - ```json - --8<-- "examples/at__size_type.output" - ``` - -??? example - - The example below shows how array elements can be read using `at()`. It also demonstrates the different exceptions - that can be thrown. - - ```cpp - --8<-- "examples/at__size_type_const.cpp" - ``` - - Output: - - ```json - --8<-- "examples/at__size_type_const.output" - ``` - -??? example - - The example below shows how object elements can be read and written using `at()`. It also demonstrates the different - exceptions that can be thrown. - - ```cpp - --8<-- "examples/at__object_t_key_type.cpp" - ``` - - Output: - - ```json - --8<-- "examples/at__object_t_key_type.output" - ``` - -??? example - - The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions - that can be thrown. - - ```cpp - --8<-- "examples/at__object_t_key_type_const.cpp" - ``` - - Output: - - ```json - --8<-- "examples/at__object_t_key_type_const.output" - ``` - -??? example - - The example below shows how object elements can be read and written using `at()`. It also demonstrates the different - exceptions that can be thrown. - - ```cpp - --8<-- "examples/at_json_pointer.cpp" - ``` - - Output: - - ```json - --8<-- "examples/at_json_pointer.output" - ``` - -??? example - - The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions - that can be thrown. - - ```cpp - --8<-- "examples/at_json_pointer_const.cpp" - ``` - - Output: - - ```json - --8<-- "examples/at_json_pointer_const.output" - ``` - -## Version history - -1. Added in version 1.0.0. -2. Added in version 1.0.0. -3. Added in version 2.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/back.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/back.md deleted file mode 100644 index 1484153ae..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/back.md +++ /dev/null @@ -1,61 +0,0 @@ -# basic_json::back - -```cpp -reference back(); - -const_reference back() const; -``` - -Returns a reference to the last element in the container. For a JSON container `c`, the expression `c.back()` is -equivalent to - -```cpp -auto tmp = c.end(); ---tmp; -return *tmp; -``` - -## Return value - -In case of a structured type (array or object), a reference to the last element is returned. In case of number, string, -boolean, or binary values, a reference to the value is returned. - -## Exceptions - -If the JSON value is `#!json null`, exception -[`invalid_iterator.214`](../../home/exceptions.md#jsonexceptioninvalid_iterator214) is thrown. - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Complexity - -Constant. - -## Note - -!!! danger - - Calling `back` on an empty array or object is undefined behavior and is **guarded by an assertion**! - -## Example - -??? example - - The following code shows an example for `back()`. - - ```cpp - --8<-- "examples/back.cpp" - ``` - - Output: - - ```json - --8<-- "examples/back.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Adjusted code to return reference to binary values in version 3.8.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/binary.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/binary.md deleted file mode 100644 index 0b1b9f48b..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/binary.md +++ /dev/null @@ -1,50 +0,0 @@ -# basic_json::binary - -```cpp -// (1) -static basic_json binary(const typename binary_t::container_type& init); -static basic_json binary(typename binary_t::container_type&& init); - -// (2) -static basic_json binary(const typename binary_t::container_type& init, - std::uint8_t subtype); -static basic_json binary(typename binary_t::container_type&& init, - std::uint8_t subtype); -``` - -1. Creates a JSON binary array value from a given binary container. -2. Creates a JSON binary array value from a given binary container with subtype. - -Binary values are part of various binary formats, such as CBOR, MessagePack, and BSON. This constructor is used to -create a value for serialization to those formats. - -## Parameters - -`init` (in) -: container containing bytes to use as binary type - -`subtype` (in) -: subtype to use in CBOR, MessagePack, and BSON - -## Return value - -JSON binary array value - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Complexity - -Linear in the size of `init`; constant for `typename binary_t::container_type&& init` versions. - -## Notes - -Note, this function exists because of the difficulty in correctly specifying the correct template overload in the -standard value ctor, as both JSON arrays and JSON binary arrays are backed with some form of a `std::vector`. Because -JSON binary arrays are a non-standard extension it was decided that it would be best to prevent automatic initialization -of a binary array type, for backwards compatibility and so it does not happen on accident. - -## Version history - -- Added in version 3.8.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/binary_t.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/binary_t.md deleted file mode 100644 index 2d6cd574e..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/binary_t.md +++ /dev/null @@ -1,67 +0,0 @@ -# basic_json::binary_t - -```cpp -using binary_t = byte_container_with_subtype; -``` - -This type is a type designed to carry binary data that appears in various serialized formats, such as CBOR's Major Type -2, MessagePack's bin, and BSON's generic binary subtype. This type is NOT a part of standard JSON and exists solely for -compatibility with these binary types. As such, it is simply defined as an ordered sequence of zero or more byte values. - -Additionally, as an implementation detail, the subtype of the binary data is carried around as a `std::uint8_t`, which -is compatible with both of the binary data formats that use binary subtyping, (though the specific numbering is -incompatible with each other, and it is up to the user to translate between them). - -[CBOR's RFC 7049](https://tools.ietf.org/html/rfc7049) describes this type as: -> Major type 2: a byte string. The string's length in bytes is represented following the rules for positive integers -> (major type 0). - -[MessagePack's documentation on the bin type -family](https://github.com/msgpack/msgpack/blob/master/spec.md#bin-format-family) describes this type as: -> Bin format family stores an byte array in 2, 3, or 5 bytes of extra bytes in addition to the size of the byte array. - -[BSON's specifications](http://bsonspec.org/spec.html) describe several binary types; however, this type is intended to -represent the generic binary type which has the description: -> Generic binary subtype - This is the most commonly used binary subtype and should be the 'default' for drivers and -> tools. - -None of these impose any limitations on the internal representation other than the basic unit of storage be some type of -array whose parts are decomposable into bytes. - -The default representation of this binary format is a `#!cpp std::vector`, which is a very common way to -represent a byte array in modern C++. - -## Template parameters - -`BinaryType` -: container type to store arrays - -## Notes - -#### Default type - -The default values for `BinaryType` is `#!cpp std::vector`. - -#### Storage - -Binary Arrays are stored as pointers in a `basic_json` type. That is, for any access to array values, a pointer of the -type `#!cpp binary_t*` must be dereferenced. - -#### Notes on subtypes - -- CBOR - - Binary values are represented as byte strings. Subtypes are written as tags. - -- MessagePack - - If a subtype is given and the binary array contains exactly 1, 2, 4, 8, or 16 elements, the fixext family (fixext1, - fixext2, fixext4, fixext8) is used. For other sizes, the ext family (ext8, ext16, ext32) is used. The subtype is - then added as singed 8-bit integer. - - If no subtype is given, the bin family (bin8, bin16, bin32) is used. - -- BSON - - If a subtype is given, it is used and added as unsigned 8-bit integer. - - If no subtype is given, the generic binary subtype 0x00 is used. - -## Version history - -- Added in version 3.8.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/boolean_t.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/boolean_t.md deleted file mode 100644 index 926a5f9f4..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/boolean_t.md +++ /dev/null @@ -1,26 +0,0 @@ -# basic_json::boolean_t - -```cpp -using boolean_t = BooleanType; -``` - -The type used to store JSON booleans. - -[RFC 7159](http://rfc7159.net/rfc7159) implicitly describes a boolean as a type which differentiates the two literals -`#!json true` and `#!json false`. - -To store objects in C++, a type is defined by the template parameter `BooleanType` which chooses the type to use. - -## Notes - -#### Default type - -With the default values for `BooleanType` (`#!cpp bool`), the default value for `boolean_t` is `#!cpp bool`. - -#### Storage - -Boolean values are stored directly inside a `basic_json` type. - -## Version history - -- Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/cbor_tag_handler_t.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/cbor_tag_handler_t.md deleted file mode 100644 index ea417de55..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/cbor_tag_handler_t.md +++ /dev/null @@ -1,21 +0,0 @@ -# basic_json::cbor_tag_handler_t - -```cpp -enum class cbor_tag_handler_t -{ - error, - ignore -}; -``` - -This enumeration is used in the [`from_cbor`](from_cbor.md) function to choose how to treat tags: - -error -: throw a `parse_error` exception in case of a tag - -ignore -: ignore tags - -## Version history - -- Added in version 3.9.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/clear.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/clear.md deleted file mode 100644 index 5119b8389..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/clear.md +++ /dev/null @@ -1,58 +0,0 @@ -# basic_json::clear - -```cpp -void clear() noexcept; -``` - -Clears the content of a JSON value and resets it to the default value as if [`basic_json(value_t)`](basic_json.md) would -have been called with the current value type from [`type()`](type.md): - -Value type | initial value ------------ | ------------- -null | `null` -boolean | `false` -string | `""` -number | `0` -binary | An empty byte vector -object | `{}` -array | `[]` - -Has the same effect as calling - -```.cpp -*this = basic_json(type()); -``` - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Linear in the size of the JSON value. - -## Notes - -All iterators, pointers and references related to this container are invalidated. - -## Example - -??? example - - The example below shows the effect of `clear()` to different - JSON types. - - ```cpp - --8<-- "examples/clear.cpp" - ``` - - Output: - - ```json - --8<-- "examples/clear.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Added support for binary types in version 3.8.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/contains.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/contains.md deleted file mode 100644 index 1616f0c2d..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/contains.md +++ /dev/null @@ -1,56 +0,0 @@ -# basic_json::contains - -```cpp -template -bool contains(KeyT && key) const; -``` - -Check whether an element exists in a JSON object with key equivalent to `key`. If the element is not found or the JSON -value is not an object, `#!cpp false` is returned. - -## Template parameters - -`KeyT` -: A type for an object key other than `basic_json::json_pointer`. - -## Parameters - -`key` (in) -: key value to check its existence. - -## Return value - -`#!cpp true` if an element with specified `key` exists. If no such element with such key is found or the JSON value is -not an object, `#!cpp false` is returned. - -## Exception safety - -Strong exception safety: if an exception occurs, the original value stays intact. - -## Complexity - -Logarithmic in the size of the JSON object. - -## Notes - -This method always returns `#!cpp false` when executed on a JSON type that is not an object. - -## Example - -??? example - - The example shows how `contains()` is used. - - ```cpp - --8<-- "examples/contains.cpp" - ``` - - Output: - - ```json - --8<-- "examples/contains.output" - ``` - -## Version history - -- Added in version 3.6.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/count.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/count.md deleted file mode 100644 index 34f1605d3..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/count.md +++ /dev/null @@ -1,55 +0,0 @@ -# basic_json::count - -```cpp -template -size_type count(KeyT&& key) const; -``` - -Returns the number of elements with key `key`. If `ObjectType` is the default `std::map` type, the return value will -always be `0` (`key` was not found) or `1` (`key` was found). - -## Template parameters - -`KeyT` -: A type for an object key. - -## Parameters - -`key` (in) -: key value of the element to count. - -## Return value - -Number of elements with key `key`. If the JSON value is not an object, the return value will be `0`. - -## Exception safety - -Strong exception safety: if an exception occurs, the original value stays intact. - -## Complexity - -Logarithmic in the size of the JSON object. - -## Notes - -This method always returns `0` when executed on a JSON type that is not an object. - -## Example - -??? example - - The example shows how `count()` is used. - - ```cpp - --8<-- "examples/count.cpp" - ``` - - Output: - - ```json - --8<-- "examples/count.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/dump.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/dump.md deleted file mode 100644 index cad06ca92..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/dump.md +++ /dev/null @@ -1,66 +0,0 @@ -# basic_json::dump - -```cpp -string_t dump(const int indent = -1, - const char indent_char = ' ', - const bool ensure_ascii = false, - const error_handler_t error_handler = error_handler_t::strict) const; -``` - -Serialization function for JSON values. The function tries to mimic Python's `json.dumps()` function, and currently -supports its `indent` and `ensure_ascii` parameters. - -## Parameters - -`indent` (in) -: If `indent` is nonnegative, then array elements and object members will be pretty-printed with that indent level. An - indent level of `0` will only insert newlines. `-1` (the default) selects the most compact representation. - -`indent_char` (in) -: The character to use for indentation if `indent` is greater than `0`. The default is ` ` (space). - -`ensure_ascii` (in) -: If `ensure_ascii` is true, all non-ASCII characters in the output are escaped with `\uXXXX` sequences, and the - result consists of ASCII characters only. - -`error_handler` (in) -: how to react on decoding errors; there are three possible values (see [`error_handler_t`](error_handler_t.md): - `strict` (throws and exception in case a decoding error occurs; default), `replace` (replace invalid UTF-8 sequences - with U+FFFD), and `ignore` (ignore invalid UTF-8 sequences during serialization; all bytes are copied to the output - unchanged). - -## Return value - -string containing the serialization of the JSON value - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes to any JSON value. - -## Complexity - -Linear. - -## Notes - -Binary values are serialized as object containing two keys: - -- "bytes": an array of bytes as integers -- "subtype": the subtype as integer or `#!json null` if the binary has no subtype - -## Example - -??? example - - The following example shows the effect of different `indent`, `indent_char`, and `ensure_ascii` parameters to the - result of the serialization. - - ```cpp - --8<-- "examples/dump.cpp" - ``` - - Output: - - ```json - --8<-- "examples/dump.output" - ``` diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/empty.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/empty.md deleted file mode 100644 index 151e0739b..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/empty.md +++ /dev/null @@ -1,66 +0,0 @@ -# basic_json::empty - -```cpp -bool empty() const noexcept; -``` - -Checks if a JSON value has no elements (i.e. whether its [`size()`](size.md) is `0`). - -## Return value - -The return value depends on the different types and is defined as follows: - -Value type | return value ------------ | ------------- -null | `#!cpp true` -boolean | `#!cpp false` -string | `#!cpp false` -number | `#!cpp false` -binary | `#!cpp false` -object | result of function `object_t::empty()` -array | result of function `array_t::empty()` - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Constant, as long as [`array_t`](array_t.md) and [`object_t`](object_t.md) satisfy the -[Container](https://en.cppreference.com/w/cpp/named_req/Container) concept; that is, their `empty()` functions have -constant complexity. - -## Possible implementation - -```cpp -bool empty() const noexcept -{ - return size() == 0; -} -``` - -## Notes - -This function does not return whether a string stored as JSON value is empty -- it returns whether the JSON container -itself is empty which is `#!cpp false` in the case of a string. - -## Example - -??? example - - The following code uses `empty()` to check if a JSON object contains any elements. - - ```cpp - --8<-- "examples/empty.cpp" - ``` - - Output: - - ```json - --8<-- "examples/empty.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Extended to return `#!cpp false` for binary types in version 3.8.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/erase.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/erase.md deleted file mode 100644 index 3d80f5bfd..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/erase.md +++ /dev/null @@ -1,177 +0,0 @@ -# basic_json::erase - -```cpp -// (1) -iterator erase(iterator pos); -const_iterator erase(const_iterator pos); - -// (2) -iterator erase(iterator first, iterator last); -const_iterator erase(const_iterator first, const_iterator last); - -// (3) -size_type erase(const typename object_t::key_type& key); - -// (4) -void erase(const size_type idx); -``` - -1. Removes an element from a JSON value specified by iterator `pos`. The iterator `pos` must be valid and - dereferenceable. Thus the `end()` iterator (which is valid, but is not dereferenceable) cannot be used as a value for - `pos`. - - If called on a primitive type other than `#!json null`, the resulting JSON value will be `#!json null`. - -2. Remove an element range specified by `[first; last)` from a JSON value. The iterator `first` does not need to be - dereferenceable if `first == last`: erasing an empty range is a no-op. - - If called on a primitive type other than `#!json null`, the resulting JSON value will be `#!json null`. - -3. Removes an element from a JSON object by key. - -4. Removes an element from a JSON array by index. - -## Parameters - -`pos` (in) -: iterator to the element to remove - -`first` (in) -: iterator to the beginning of the range to remove - -`last` (in) -: iterator past the end of the range to remove - -`key` (in) -: object key of the elements to remove - -`idx` (in) -: array index of the element to remove - -## Return value - -1. Iterator following the last removed element. If the iterator `pos` refers to the last element, the `end()` iterator - is returned. -2. Iterator following the last removed element. If the iterator `last` refers to the last element, the `end()` iterator - is returned. -3. Number of elements removed. If `ObjectType` is the default `std::map` type, the return value will always be `0` - (`key` was not found) or `1` (`key` was found). -4. / - -## Exceptions - -1. The function can throw the following exceptions: - - Throws [`type_error.307`](../../home/exceptions.md#jsonexceptiontype_error307) if called on a `null` value; - example: `"cannot use erase() with null"` - - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an - iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"` - - Throws [`invalid_iterator.205`](../../home/exceptions.md#jsonexceptioninvalid_iterator205) if called on a - primitive type with invalid iterator (i.e., any iterator which is not `begin()`); example: `"iterator out of - range"` -2. The function can throw thw following exceptions: - - Throws [`type_error.307`](../../home/exceptions.md#jsonexceptiontype_error307) if called on a `null` value; - example: `"cannot use erase() with null"` - - Throws [`invalid_iterator.203`](../../home/exceptions.md#jsonexceptioninvalid_iterator203) if called on iterators - which does not belong to the current JSON value; example: `"iterators do not fit current value"` - - Throws [`invalid_iterator.204`](../../home/exceptions.md#jsonexceptioninvalid_iterator204) if called on a - primitive type with invalid iterators (i.e., if `first != begin()` and `last != end()`); example: `"iterators out - of range"` -3. The function can throw thw following exceptions: - - Throws [`type_error.307`](../../home/exceptions.md#jsonexceptiontype_error307) when called on a type other than - JSON object; example: `"cannot use erase() with null"` -4. The function can throw thw following exceptions: - - Throws [`type_error.307`](../../home/exceptions.md#jsonexceptiontype_error307) when called on a type other than - JSON object; example: `"cannot use erase() with null"` - - Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) when `idx >= size()`; example: - `"array index 17 is out of range"` - -## Exception safety - -Strong exception safety: if an exception occurs, the original value stays intact. - -## Complexity - -1. The complexity depends on the type: - - objects: amortized constant - - arrays: linear in distance between `pos` and the end of the container - - strings and binary: linear in the length of the member - - other types: constant -2. The complexity depends on the type: - - objects: `log(size()) + std::distance(first, last)` - - arrays: linear in the distance between `first` and `last`, plus linear - in the distance between `last` and end of the container - - strings and binary: linear in the length of the member - - other types: constant -3. `log(size()) + count(key)` -4. Linear in distance between `idx` and the end of the container. - -## Notes - -1. Invalidates iterators and references at or after the point of the - erase, including the `end()` iterator. -2. / -3. References and iterators to the erased elements are invalidated. Other references and iterators are not affected. -4. / - -## Example - -??? example - - The example shows the effect of `erase()` for different JSON types using an iterator. - - ```cpp - --8<-- "examples/erase__IteratorType.cpp" - ``` - - Output: - - ```json - --8<-- "examples/erase__IteratorType.output" - ``` - -??? example - - The example shows the effect of `erase()` for different JSON types using an iterator range. - - ```cpp - --8<-- "examples/erase__IteratorType_IteratorType.cpp" - ``` - - Output: - - ```json - --8<-- "examples/erase__IteratorType_IteratorType.output" - ``` - -??? example - - The example shows the effect of `erase()` for different JSON types using an object key. - - ```cpp - --8<-- "examples/erase__key_type.cpp" - ``` - - Output: - - ```json - --8<-- "examples/erase__key_type.output" - ``` - -??? example - - The example shows the effect of `erase()` using an array index. - - ```cpp - --8<-- "examples/erase__size_type.cpp" - ``` - - Output: - - ```json - --8<-- "examples/erase__size_type.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Added support for binary types in version 3.8.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/error_handler_t.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/error_handler_t.md deleted file mode 100644 index 050dda14d..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/error_handler_t.md +++ /dev/null @@ -1,25 +0,0 @@ -# basic_json::error_handler_t - -```cpp -enum class error_handler_t { - strict, - replace, - ignore -}; -``` - -This enumeration is used in the [`dump`](dump.md) function to choose how to treat decoding errors while serializing a -`basic_json` value. Three values are differentiated: - -strict -: throw a `type_error` exception in case of invalid UTF-8 - -replace -: replace invalid UTF-8 sequences with U+FFFD (� REPLACEMENT CHARACTER) - -ignore -: ignore invalid UTF-8 sequences; all bytes are copied to the output unchanged - -## Version history - -- Added in version 3.4.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/find.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/find.md deleted file mode 100644 index 5ff4baf61..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/find.md +++ /dev/null @@ -1,59 +0,0 @@ -# basic_json::find - -```cpp -template -iterator find(KeyT&& key); - -template -const_iterator find(KeyT&& key) const -``` - -Finds an element in a JSON object with key equivalent to `key`. If the element is not found or the JSON value is not an -object, `end()` is returned. - -## Template parameters - -`KeyT` -: A type for an object key. - -## Parameters - -`key` (in) -: key value of the element to search for. - -## Return value - -Iterator to an element with key equivalent to `key`. If no such element is found or the JSON value is not an object, -past-the-end (see `end()`) iterator is returned. - -## Exception safety - -Strong exception safety: if an exception occurs, the original value stays intact. - -## Complexity - -Logarithmic in the size of the JSON object. - -## Notes - -This method always returns `end()` when executed on a JSON type that is not an object. - -## Example - -??? example - - The example shows how `find()` is used. - - ```cpp - --8<-- "examples/find__key_type.cpp" - ``` - - Output: - - ```json - --8<-- "examples/find__key_type.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/from_bson.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/from_bson.md deleted file mode 100644 index 6df74f39c..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/from_bson.md +++ /dev/null @@ -1,83 +0,0 @@ -# basic_json::from_bson - -```cpp -// (1) -template -static basic_json from_bson(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true); -// (2) -template -static basic_json from_bson(IteratorType first, IteratorType last, - const bool strict = true, - const bool allow_exceptions = true); -``` - -Deserializes a given input to a JSON value using the BSON (Binary JSON) serialization format. - -1. Reads from a compatible input. -2. Reads from an iterator range. - -## Template parameters - -`InputType` -: A compatible input, for instance: - - - an `std::istream` object - - a `FILE` pointer - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. - -`IteratorType` -: a compatible iterator type - -## Parameters - -`i` (in) -: an input in BSON format convertible to an input adapter - -`first` (in) -: iterator to start of the input - -`last` (in) -: iterator to end of the input - -`strict` (in) -: whether to expect the input to be consumed until EOF (`#!cpp true` by default) - -`allow_exceptions` (in) -: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) - -## Return value - -deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be -`value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Complexity - -Linear in the size of the input. - -## Example - -??? example - - The example shows the deserialization of a byte vector in BSON format to a JSON value. - - ```cpp - --8<-- "examples/from_bson.cpp" - ``` - - Output: - - ```json - --8<-- "examples/from_bson.output" - ``` - -## Version history - -- Added in version 3.4.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/from_cbor.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/from_cbor.md deleted file mode 100644 index ec186fc2a..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/from_cbor.md +++ /dev/null @@ -1,94 +0,0 @@ -# basic_json::from_cbor - -```cpp -// (1) -template -static basic_json from_cbor(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error); - -// (2) -template -static basic_json from_cbor(IteratorType first, IteratorType last, - const bool strict = true, - const bool allow_exceptions = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error); -``` - -Deserializes a given input to a JSON value using the CBOR (Concise Binary Object Representation) serialization format. - -1. Reads from a compatible input. -2. Reads from an iterator range. - -## Template parameters - -`InputType` -: A compatible input, for instance: - - - an `std::istream` object - - a `FILE` pointer - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. - -`IteratorType` -: a compatible iterator type - -## Parameters - -`i` (in) -: an input in CBOR format convertible to an input adapter - -`first` (in) -: iterator to start of the input - -`last` (in) -: iterator to end of the input - -`strict` (in) -: whether to expect the input to be consumed until EOF (`#!cpp true` by default) - -`allow_exceptions` (in) -: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) - -`tag_handler` (in) -: how to treat CBOR tags (optional, `error` by default); see [`cbor_tag_handler_t`](cbor_tag_handler_t.md) for more - information - -## Return value - -deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be -`value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Complexity - -Linear in the size of the input. - -## Example - -??? example - - The example shows the deserialization of a byte vector in CBOR format to a JSON value. - - ```cpp - --8<-- "examples/from_cbor.cpp" - ``` - - Output: - - ```json - --8<-- "examples/from_cbor.output" - ``` - -## Version history - -- Added in version 2.0.9. -- Parameter `start_index` since version 2.1.1. -- Changed to consume input adapters, removed `start_index` parameter, and added `strict` parameter in version 3.0.0. -- Added `allow_exceptions` parameter in version 3.2.0. -- Added `tag_handler` parameter in version 3.9.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/from_msgpack.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/from_msgpack.md deleted file mode 100644 index 9f6852499..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/from_msgpack.md +++ /dev/null @@ -1,86 +0,0 @@ -# basic_json::from_msgpack - -```cpp -// (1) -template -static basic_json from_msgpack(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true); -// (2) -template -static basic_json from_msgpack(IteratorType first, IteratorType last, - const bool strict = true, - const bool allow_exceptions = true); -``` - -Deserializes a given input to a JSON value using the MessagePack serialization format. - -1. Reads from a compatible input. -2. Reads from an iterator range. - -## Template parameters - -`InputType` -: A compatible input, for instance: - - - an `std::istream` object - - a `FILE` pointer - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. - -`IteratorType` -: a compatible iterator type - -## Parameters - -`i` (in) -: an input in MessagePack format convertible to an input adapter - -`first` (in) -: iterator to start of the input - -`last` (in) -: iterator to end of the input - -`strict` (in) -: whether to expect the input to be consumed until EOF (`#!cpp true` by default) - -`allow_exceptions` (in) -: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) - -## Return value - -deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be -`value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Complexity - -Linear in the size of the input. - -## Example - -??? example - - The example shows the deserialization of a byte vector in MessagePack format to a JSON value. - - ```cpp - --8<-- "examples/from_msgpack.cpp" - ``` - - Output: - - ```json - --8<-- "examples/from_msgpack.output" - ``` - -## Version history - -- Added in version 2.0.9. -- Parameter `start_index` since version 2.1.1. -- Changed to consume input adapters, removed `start_index` parameter, and added `strict` parameter in version 3.0.0. -- Added `allow_exceptions` parameter in version 3.2.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/from_ubjson.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/from_ubjson.md deleted file mode 100644 index f6213f293..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/from_ubjson.md +++ /dev/null @@ -1,84 +0,0 @@ -# basic_json::from_ubjson - -```cpp -// (1) -template -static basic_json from_ubjson(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true); -// (2) -template -static basic_json from_ubjson(IteratorType first, IteratorType last, - const bool strict = true, - const bool allow_exceptions = true); -``` - -Deserializes a given input to a JSON value using the UBJSON (Universal Binary JSON) serialization format. - -1. Reads from a compatible input. -2. Reads from an iterator range. - -## Template parameters - -`InputType` -: A compatible input, for instance: - - - an `std::istream` object - - a `FILE` pointer - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. - -`IteratorType` -: a compatible iterator type - -## Parameters - -`i` (in) -: an input in UBJSON format convertible to an input adapter - -`first` (in) -: iterator to start of the input - -`last` (in) -: iterator to end of the input - -`strict` (in) -: whether to expect the input to be consumed until EOF (`#!cpp true` by default) - -`allow_exceptions` (in) -: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) - -## Return value - -deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be -`value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Complexity - -Linear in the size of the input. - -## Example - -??? example - - The example shows the deserialization of a byte vector in UBJSON format to a JSON value. - - ```cpp - --8<-- "examples/from_ubjson.cpp" - ``` - - Output: - - ```json - --8<-- "examples/from_ubjson.output" - ``` - -## Version history - -- Added in version 3.1.0. -- Added `allow_exceptions` parameter in version 3.2.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/get_allocator.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/get_allocator.md deleted file mode 100644 index d4133af7a..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/get_allocator.md +++ /dev/null @@ -1,15 +0,0 @@ -# basic_json::get_allocator - -```cpp -static allocator_type get_allocator(); -``` - -Returns the allocator associated with the container. - -## Return value - -associated allocator - -## Version history - -- Unknown. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/get_binary.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/get_binary.md deleted file mode 100644 index 46d5b652d..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/get_binary.md +++ /dev/null @@ -1,29 +0,0 @@ -# basic_json::get_binary - -```cpp -binary_t& get_binary(); - -const binary_t& get_binary() const; -``` - -Returns a reference to the stored binary value. - -## Return value - -Reference to binary value. - -## Exception safety - -Strong exception safety: if an exception occurs, the original value stays intact. - -## Exceptions - -Throws [`type_error.302`](../../home/exceptions.md#jsonexceptiontype_error302) if the value is not binary - -## Complexity - -Constant. - -## Version history - -- Added in version 3.8.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/index.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/index.md deleted file mode 100644 index e8841e850..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/index.md +++ /dev/null @@ -1,252 +0,0 @@ -# basic_json - -Defined in header `` - -```cpp -template< - template class ObjectType = std::map, - template class ArrayType = std::vector, - class StringType = std::string, - class BooleanType = bool, - class NumberIntegerType = std::int64_t, - class NumberUnsignedType = std::uint64_t, - class NumberFloatType = double, - template class AllocatorType = std::allocator, - template class JSONSerializer = adl_serializer, - class BinaryType = std::vector -> -class basic_json; -``` - -## Specializations - -- [**json**](../json.md) - default specialization -- [**ordered_json**](../ordered_json.md) - specialization that maintains the insertion order of object keys - -## Template parameters - -| Template parameter | Description | Derived type | -| -------------------- | ----------- | ------------ | -| `ObjectType` | type for JSON objects | [`object_t`](object_t.md) | -| `ArrayType` | type for JSON arrays | [`array_t`](array_t.md) | -| `StringType` | type for JSON strings and object keys | [`string_t`](string_t.md) | -| `BooleanType` | type for JSON booleans | [`boolean_t`](boolean_t.md) | -| `NumberIntegerType` | type for JSON integer numbers | [`number_integer_t`](number_integer_t.md) | -| `NumberUnsignedType` | type for JSON unsigned integer numbers | [`number_unsigned_t`](number_unsigned_t.md) | -| `NumberFloatType` | type for JSON floating-point numbers | [`number_float_t`](number_float_t.md) | -| `AllocatorType` | type of the allocator to use | | -| `JSONSerializer` | the serializer to resolve internal calls to `to_json()` and `from_json()` | [`json_serializer`](json_serializer.md) | -| `BinaryType` | type for binary arrays | [`binary_t`](binary_t.md) | - -## Iterator invalidation - -Todo - -## Member types - -- [**adl_serializer**](../adl_serializer.md) - the default serializer -- [**value_t**](value_t.md) - the JSON type enumeration -- [**json_pointer**](../json_pointer.md) - JSON Pointer implementation -- [**json_serializer**](json_serializer.md) - type of the serializer to for conversions from/to JSON -- [**error_handler_t**](error_handler_t.md) - type to choose behavior on decoding errors -- [**cbor_tag_handler_t**](cbor_tag_handler_t.md) - type to choose how to handle CBOR tags -- initializer_list_t -- [**input_format_t**](input_format_t.md) - type to choose the format to parse -- json_sax_t - -### Exceptions - -- [**exception**](exception.md) - general exception of the `basic_json` class - - [**parse_error**](parse_error.md) - exception indicating a parse error - - [**invalid_iterator**](invalid_iterator.md) - exception indicating errors with iterators - - [**type_error**](type_error.md) - exception indicating executing a member function with a wrong type - - [**out_of_range**](out_of_range.md) - exception indicating access out of the defined range - - [**other_error**](other_error.md) - exception indicating other library errors - -### Container types - -| Type | Definition | -| ------------------------ | ---------- | -| `value_type` | `#!cpp basic_json` | -| `reference` | `#!cpp value_type&` | -| `const_reference` | `#!cpp const value_type&` | -| `difference_type` | `#!cpp std::ptrdiff_t` | -| `size_type` | `#!cpp std::size_t` | -| `allocator_type` | `#!cpp AllocatorType` | -| `pointer` | `#!cpp std::allocator_traits::pointer` | -| `const_pointer` | `#!cpp std::allocator_traits::const_pointer` | -| `iterator` | [LegacyBidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator) | -| `const_iterator` | constant [LegacyBidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator) | -| `reverse_iterator` | reverse iterator, derived from `iterator` | -| `const_reverse_iterator` | reverse iterator, derived from `const_iterator` | -| `iteration_proxy` | helper type for [`items`](items.md) function | - -### JSON value data types - -- [**array_t**](array_t.md) - type for arrays -- [**binary_t**](binary_t.md) - type for binary arrays -- [**boolean_t**](boolean_t.md) - type for booleans -- [**number_float_t**](number_float_t.md) - type for numbers (floating-point) -- [**number_integer_t**](number_integer_t.md) - type for numbers (integer) -- [**number_unsigned_t**](number_unsigned_t.md) - type for numbers (unsigned) -- [**object_comparator_t**](object_comparator_t.md) - comparator for objects -- [**object_t**](object_t.md) - type for objects -- [**string_t**](string_t.md) - type for strings - -### Parser callback - -- [**parse_event_t**](parse_event_t.md) - parser event types -- [**parser_callback_t**](parser_callback_t.md) - per-element parser callback type - -## Member functions - -- [(constructor)](basic_json.md) -- [(destructor)](~basic_json.md) -- [**operator=**](operator=.md) - copy assignment -- [**array**](array_t.md) (static) - explicitly create an array -- [**binary**](binary.md) (static) - explicitly create a binary array -- [**object**](object_t.md) (static) - explicitly create an object - -### Object inspection - -Functions to inspect the type of a JSON value. - -- [**type**](type.md) - return the type of the JSON value -- [**operator value_t**](operator_value_t.md) - return the type of the JSON value -- [**type_name**](type_name.md) - return the type as string -- [**is_primitive**](is_primitive.md) - return whether type is primitive -- [**is_structured**](is_structured.md) - return whether type is structured -- [**is_null**](is_null.md) - return whether value is null -- [**is_boolean**](is_boolean.md) - return whether value is a boolean -- [**is_number**](is_number.md) - return whether value is a number -- [**is_number_integer**](is_number_integer.md) - return whether value is an integer number -- [**is_number_unsigned**](is_number_unsigned.md) - return whether value is an unsigned integer number -- [**is_number_float**](is_number_float.md) - return whether value is a floating-point number -- [**is_object**](is_object.md) - return whether value is an object -- [**is_array**](is_array.md) - return whether value is an array -- [**is_string**](is_string.md) - return whether value is a string -- [**is_binary**](is_binary.md) - return whether value is a binary array -- [**is_discarded**](is_discarded.md) - return whether value is discarded - -### Value access - -Direct access to the stored value of a JSON value. - -- [**get**](get.md) - get a value -- [**get_to**](get_to.md) - get a value and write it to a destination -- [**get_ptr**](get_ptr.md) - get a pointer value -- [**get_ref**](get_ref.md) - get a reference value -- [**operator ValueType**](operator_ValueType.md) - get a value -- [**get_binary**](get_binary.md) - get a binary value - -### Element access - -Access to the JSON value - -- [**at**](at.md) - access specified element with bounds checking -- [**operator[]**](operator[].md) - access specified element -- [**value**](value.md) - access specified object element with default value -- [**front**](front.md) - access the first element -- [**back**](back.md) - access the last element - -### Lookup - -- [**find**](find.md) - find an element in a JSON object -- [**count**](count.md) - returns the number of occurrences of a key in a JSON object -- [**contains**](contains.md) - check the existence of an element in a JSON object - -### Iterators - -- [**begin**](begin.md) - returns an iterator to the first element -- [**cbegin**](cbegin.md) - returns a const iterator to the first element -- [**end**](end.md) - returns an iterator to one past the last element -- [**cend**](cend.md) - returns a const iterator to one past the last element -- [**rbegin**](rbegin.md) - returns an iterator to the reverse-beginning -- [**rend**](rend.md) - returns an iterator to the reverse-end -- [**crbegin**](crbegin.md) - returns a const iterator to the reverse-beginning -- [**crend**](crend.md) - returns a const iterator to the reverse-end -- [**items**](items.md) - wrapper to access iterator member functions in range-based for - -### Capacity - -- [**empty**](empty.md) - checks whether the container is empty -- [**size**](size.md) - returns the number of elements -- [**max_size**](max_size.md) - returns the maximum possible number of elements - -### Modifiers - -- [**clear**](clear.md) - clears the contents -- [**push_back**](push_back.md) - add a value to an array/object -- [**operator+=**](operator+=.md) - add a value to an array/object -- [**emplace_back**](emplace_back.md) - add a value to an array -- [**emplace**](emplace.md) - add a value to an object if key does not exist -- [**erase**](erase.md) - remove elements -- [**insert**](insert.md) - inserts elements -- [**update**](update.md) - updates a JSON object from another object, overwriting existing keys -- swap - exchanges the values - -### Lexicographical comparison operators - -- [**operator==**](operator_eq.md) - comparison: equal -- [**operator!=**](operator_ne.md) - comparison: not equal -- [**operator<**](operator_lt.md) - comparison: less than -- [**operator<=**](operator_le.md) - comparison: less than or equal -- [**operator>**](operator_gt.md) - comparison: greater than -- [**operator>=**](operator_ge.md) - comparison: greater than or equal - -### Serialization / Dumping - -- [**dump**](dump.md) - serialization -- to_string - user-defined to_string function for JSON values - -### Deserialization / Parsing - -- [**parse**](parse.md) (static) - deserialize from a compatible input -- [**accept**](accept.md) (static) - check if the input is valid JSON -- [**sax_parse**](sax_parse.md) (static) - generate SAX events - -### JSON Pointer functions - -- [**flatten**](flatten.md) - return flattened JSON value -- [**unflatten**](unflatten.md) - unflatten a previously flattened JSON value - -### JSON Patch functions - -- [**patch**](patch.md) - applies a JSON patch -- [**diff**](diff.md) (static) - creates a diff as a JSON patch - -### JSON Merge Patch functions - -- [**merge_patch**](merge_patch.md) - applies a JSON Merge Patch - -## Static functions - -- [**meta**](meta.md) - returns version information on the library -- [**get_allocator**](get_allocator.md) - returns the allocator associated with the container - -### Binary formats - -- [**from_bson**](from_bson.md) (static) - create a JSON value from an input in BSON format -- [**from_cbor**](from_cbor.md) (static) - create a JSON value from an input in CBOR format -- [**from_msgpack**](from_msgpack.md) (static) - create a JSON value from an input in MessagePack format -- [**from_ubjson**](from_ubjson.md) (static) - create a JSON value from an input in UBJSON format -- [**to_bson**](to_bson.md) (static) - create a BSON serialization of a given JSON value -- [**to_cbor**](to_cbor.md) (static) - create a CBOR serialization of a given JSON value -- [**to_msgpack**](to_msgpack.md) (static) - create a MessagePack serialization of a given JSON value -- [**to_ubjson**](to_ubjson.md) (static) - create a UBJSON serialization of a given JSON value - -## Non-member functions - -- operator<<(std::ostream&) - serialize to stream -- operator>>(std::istream&) - deserialize from stream - -## Literals - -- [**operator""_json**](operator_literal_json.md) - user-defined string literal for JSON values -- [**operator""_json_pointer**](operator_literal_json_pointer.md) - user-defined string literal for JSON pointers - -## Helper classes - -- std::hash -- std::less -- std::swap diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/input_format_t.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/input_format_t.md deleted file mode 100644 index 783085d8e..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/input_format_t.md +++ /dev/null @@ -1,32 +0,0 @@ -# basic_json::input_format_t - -```cpp -enum class input_format_t { - json, - cbor, - msgpack, - ubjson, - bson -}; -``` - -This enumeration is used in the [`sax_parse`](sax_parse.md) function to choose the input format to parse: - -json -: JSON (JavaScript Object Notation) - -cbor -: CBOR (Concise Binary Object Representation) - -msgpack -: MessagePack - -ubjson -: UBJSON (Universal Binary JSON) - -bson -: BSON (Bin­ary JSON) - -## Version history - -- Added in version 3.2.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/invalid_iterator.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/invalid_iterator.md deleted file mode 100644 index b11b27dfc..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/invalid_iterator.md +++ /dev/null @@ -1,59 +0,0 @@ -# basic_json::invalid_iterator - -```cpp -class invalid_iterator : public exception; -``` - -This exception is thrown if iterators passed to a library function do not match the expected semantics. - -Exceptions have ids 2xx. - -```plantuml -std::exception <|-- basic_json::exception -basic_json::exception <|-- basic_json::parse_error -basic_json::exception <|-- basic_json::invalid_iterator -basic_json::exception <|-- basic_json::type_error -basic_json::exception <|-- basic_json::out_of_range -basic_json::exception <|-- basic_json::other_error - -interface std::exception {} - -class basic_json::exception { - + const int id - + const char* what() const -} - -class basic_json::parse_error { - + const std::size_t byte -} - -class basic_json::invalid_iterator #FFFF00 {} -``` - -## Member functions - -- **what** - returns explanatory string - -## Member variables - -- **id** - the id of the exception - -## Example - -??? example - - The following code shows how a `invalid_iterator` exception can be caught. - - ```cpp - --8<-- "examples/invalid_iterator.cpp" - ``` - - Output: - - ```json - --8<-- "examples/invalid_iterator.output" - ``` - -## Version history - -- Since version 3.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_number.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/is_number.md deleted file mode 100644 index 9bcb13144..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_number.md +++ /dev/null @@ -1,50 +0,0 @@ -# basic_json::is_number - -```cpp -constexpr bool is_number() const noexcept; -``` - -This function returns `#!cpp true` if and only if the JSON value is a number. This includes both integer (signed and -unsigned) and floating-point values. - -## Return value - -`#!cpp true` if type is number (regardless whether integer, unsigned integer or floating-type), `#!cpp false` otherwise. - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Possible implementation - -```cpp -constexpr bool is_number() const noexcept -{ - return is_number_integer() || is_number_float(); -} -``` - -## Example - -??? example - - The following code exemplifies `is_number()` for all JSON types. - - ```cpp - --8<-- "examples/is_number.cpp" - ``` - - Output: - - ```json - --8<-- "examples/is_number.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Extended to also return `#!cpp true` for unsigned integers in 2.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_number_float.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/is_number_float.md deleted file mode 100644 index d709bf71b..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_number_float.md +++ /dev/null @@ -1,40 +0,0 @@ -# basic_json::is_number_float - -```cpp -constexpr bool is_number_float() const noexcept; -``` - -This function returns `#!cpp true` if and only if the JSON value is a floating-point number. This excludes signed and -unsigned integer values. - -## Return value - -`#!cpp true` if type is a floating-point number, `#!cpp false` otherwise. - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Example - -??? example - - The following code exemplifies `is_number_float()` for all JSON types. - - ```cpp - --8<-- "examples/is_number_float.cpp" - ``` - - Output: - - ```json - --8<-- "examples/is_number_float.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_number_integer.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/is_number_integer.md deleted file mode 100644 index c308c9296..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_number_integer.md +++ /dev/null @@ -1,41 +0,0 @@ -# basic_json::is_number_integer - -```cpp -constexpr bool is_number_integer() const noexcept; -``` - -This function returns `#!cpp true` if and only if the JSON value is a signed or unsigned integer number. This excludes -floating-point values. - -## Return value - -`#!cpp true` if type is an integer or unsigned integer number, `#!cpp false` otherwise. - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Example - -??? example - - The following code exemplifies `is_number_integer()` for all JSON types. - - ```cpp - --8<-- "examples/is_number_integer.cpp" - ``` - - Output: - - ```json - --8<-- "examples/is_number_integer.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Extended to also return `#!cpp true` for unsigned integers in 2.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_number_unsigned.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/is_number_unsigned.md deleted file mode 100644 index 56493eae6..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_number_unsigned.md +++ /dev/null @@ -1,40 +0,0 @@ -# basic_json::is_number_unsigned - -```cpp -constexpr bool is_number_unsigned() const noexcept; -``` - -This function returns `#!cpp true` if and only if the JSON value is an unsigned integer number. This excludes -floating-point and signed integer values. - -## Return value - -`#!cpp true` if type is an unsigned integer number, `#!cpp false` otherwise. - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Example - -??? example - - The following code exemplifies `is_number_unsigned()` for all JSON types. - - ```cpp - --8<-- "examples/is_number_unsigned.cpp" - ``` - - Output: - - ```json - --8<-- "examples/is_number_unsigned.output" - ``` - -## Version history - -- Added in version 2.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_primitive.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/is_primitive.md deleted file mode 100644 index 37be35c7f..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_primitive.md +++ /dev/null @@ -1,60 +0,0 @@ -# basic_json::is_primitive - -```cpp -constexpr bool is_primitive() const noexcept; -``` - -This function returns `#!cpp true` if and only if the JSON type is primitive (string, number, boolean, `#!json null`, -binary). - -## Return value - -`#!cpp true` if type is primitive (string, number, boolean, `#!json null`, or binary), `#!cpp false` otherwise. - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Possible implementation - -```cpp -constexpr bool is_primitive() const noexcept -{ - return is_null() || is_string() || is_boolean() || is_number() || is_binary(); -} -``` - -## Notes - -The term *primitive* stems from [RFC 8259](https://tools.ietf.org/html/rfc8259): - -> JSON can represent four primitive types (strings, numbers, booleans, and null) and two structured types (objects and -> arrays). - -This library extends primitive types to binary types, because binary types are roughly comparable to strings. Hence, -`is_primitive()` returns `#!cpp true` for binary values. - -## Example - -??? example - - The following code exemplifies `is_primitive()` for all JSON types. - - ```cpp - --8<-- "examples/is_primitive.cpp" - ``` - - Output: - - ```json - --8<-- "examples/is_primitive.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Extended to return `#!cpp true` for binary types in version 3.8.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_structured.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/is_structured.md deleted file mode 100644 index 397579884..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_structured.md +++ /dev/null @@ -1,48 +0,0 @@ -# basic_json::is_structured - -```cpp -constexpr bool is_structured() const noexcept; -``` - -This function returns `#!cpp true` if and only if the JSON type is structured (array or object). - -## Return value - -`#!cpp true` if type is structured (array or object), `#!cpp false` otherwise. - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Notes - -The term *structured* stems from [RFC 8259](https://tools.ietf.org/html/rfc8259): - -> JSON can represent four primitive types (strings, numbers, booleans, and null) and two structured types (objects and -> arrays). - -Note that though strings are containers in C++, they are treated as primitive values in JSON. - -## Example - -??? example - - The following code exemplifies `is_structured()` for all JSON types. - - ```cpp - --8<-- "examples/is_structured.cpp" - ``` - - Output: - - ```json - --8<-- "examples/is_structured.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/json_serializer.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/json_serializer.md deleted file mode 100644 index 89379acf4..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/json_serializer.md +++ /dev/null @@ -1,24 +0,0 @@ -# basic_json::json_serializer - -```cpp -template -using json_serializer = JSONSerializer; -``` - -## Template parameters - -`T` -: type to convert; will be used in the `to_json`/`from_json` functions - -`SFINAE` -: type to add compile type checks via SFINAE; usually `#!cpp void` - -## Notes - -#### Default type - -The default values for `json_serializer` is [`adl_serializer`](../adl_serializer.md). - -## Version history - -- Since version 2.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/max_size.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/max_size.md deleted file mode 100644 index 21fffa717..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/max_size.md +++ /dev/null @@ -1,58 +0,0 @@ -# basic_json::max_size - -```cpp -size_type max_size() const noexcept; -``` - -Returns the maximum number of elements a JSON value is able to hold due to system or library implementation limitations, -i.e. `std::distance(begin(), end())` for the JSON value. - -## Return value - -The return value depends on the different types and is defined as follows: - -Value type | return value ------------ | ------------- -null | `0` (same as [`size()`](size.md)) -boolean | `1` (same as [`size()`](size.md)) -string | `1` (same as [`size()`](size.md)) -number | `1` (same as [`size()`](size.md)) -binary | `1` (same as [`size()`](size.md)) -object | result of function `object_t::max_size()` -array | result of function `array_t::max_size()` - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Constant, as long as [`array_t`](array_t.md) and [`object_t`](object_t.md) satisfy the -[Container](https://en.cppreference.com/w/cpp/named_req/Container) concept; that is, their `max_size()` functions have -constant complexity. - -## Notes - -This function does not return the maximal length of a string stored as JSON value -- it returns the maximal number of -string elements the JSON value can store which is `1`. - -## Example - -??? example - - The following code calls `max_size()` on the different value types. Note the output is implementation specific. - - ```cpp - --8<-- "examples/max_size.cpp" - ``` - - Output: - - ```json - --8<-- "examples/max_size.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Extended to return `1` for binary types in version 3.8.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/meta.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/meta.md deleted file mode 100644 index 807c2aa73..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/meta.md +++ /dev/null @@ -1,48 +0,0 @@ -# basic_json::meta - -```cpp -static basic_json meta(); -``` - -This function returns a JSON object with information about the library, including the version number and information on -the platform and compiler. - -## Return value - -JSON object holding version information - -key | description ------------ | --------------- -`compiler` | Information on the used compiler. It is an object with the following keys: `c++` (the used C++ standard), `family` (the compiler family; possible values are `clang`, `icc`, `gcc`, `ilecpp`, `msvc`, `pgcpp`, `sunpro`, and `unknown`), and `version` (the compiler version). -`copyright` | The copyright line for the library as string. -`name` | The name of the library as string. -`platform` | The used platform as string. Possible values are `win32`, `linux`, `apple`, `unix`, and `unknown`. -`url` | The URL of the project as string. -`version` | The version of the library. It is an object with the following keys: `major`, `minor`, and `patch` as defined by [Semantic Versioning](http://semver.org), and `string` (the version string). - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes to any JSON value. - -## Complexity - -Constant. - -## Example - -The following code shows an example output of the `meta()` -function. - -```cpp ---8<-- "examples/meta.cpp" -``` - -Output: - -```json ---8<-- "examples/meta.output" -``` - -## Version history - -- Added in version 2.1.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/object_comparator_t.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/object_comparator_t.md deleted file mode 100644 index 8fb8656c8..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/object_comparator_t.md +++ /dev/null @@ -1,18 +0,0 @@ -# basic_json::object_comparator_t - -```cpp -// until C++14 -using object_comparator_t = std::less; - -// since C++14 -using object_comparator_t = std::less<>; -``` - -The comparator used in [`object_t`](object_t.md). - -When C++14 is detected, a transparent com parator is used which, when combined with perfect forwarding on find() and -count() calls, prevents unnecessary string construction. - -## Version history - -- Unknown. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator[].md b/external_imported/json/doc/mkdocs/docs/api/basic_json/operator[].md deleted file mode 100644 index 4b36f1a91..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator[].md +++ /dev/null @@ -1,191 +0,0 @@ -# basic_json::operator[] - -```cpp -// (1) -reference operator[](size_type idx); -const_reference operator[](size_type idx) const; - -// (2) -reference operator[](const typename object_t::key_type& key); -const_reference operator[](const typename object_t::key_type& key) const; -template -reference operator[](T* key); -template -const_reference operator[](T* key) const; - -// (3) -reference operator[](const json_pointer& ptr); -const_reference operator[](const json_pointer& ptr) const; -``` - -1. Returns a reference to the element at specified location `idx`. -2. Returns a reference to the element at with specified key `key`. -3. Returns a reference to the element at with specified JSON pointer `ptr`. - -## Template parameters - -`T` -: string literal convertible to `object_t::key_type` - -## Parameters - -`idx` (in) -: index of the element to access - -`key` (in) -: object key of the elements to remove - -`ptr` (in) -: JSON pointer to the desired element - -## Return value - -1. reference to the element at index `idx` -2. reference to the element at key `key` -3. reference to the element pointed to by `ptr` - -## Exceptions - -1. The function can throw the following exceptions: - - Throws [`type_error.305`](../../home/exceptions.md#jsonexceptiontype_error305) if the JSON value is not an array - or null; in that cases, using the `[]` operator with an index makes no sense. -2. The function can throw the following exceptions: - - Throws [`type_error.305`](../../home/exceptions.md#jsonexceptiontype_error305) if the JSON value is not an array - or null; in that cases, using the `[]` operator with an index makes no sense. -3. The function can throw the following exceptions: - - Throws [`parse_error.106`](../../home/exceptions.md#jsonexceptionparse_error106) if an array index in the passed - JSON pointer `ptr` begins with '0'. - - Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109) if an array index in the passed - JSON pointer `ptr` is not a number. - - Throws [`out_of_range.402`](../../home/exceptions.md#jsonexceptionout_of_range402) if the array index '-' is used - in the passed JSON pointer `ptr` for the const version. - - Throws [`out_of_range.404`](../../home/exceptions.md#jsonexceptionout_of_range404) if the JSON pointer `ptr` can - not be resolved. - -## Notes - -!!! danger - - 1. If the element with key `idx` does not exist, the behavior is undefined. - 2. If the element with key `key` does not exist, the behavior is undefined and is **guarded by an assertion**! - -1. The non-const version may add values: If `idx` is beyond the range of the array (i.e., `idx >= size()`), then the - array is silently filled up with `#!json null` values to make `idx` a valid reference to the last stored element. In - case the value was `#!json null` before, it is converted to an array. - -2. If `key` is not found in the object, then it is silently added to the object and filled with a `#!json null` value to - make `key` a valid reference. In case the value was `#!json null` before, it is converted to an object. - -3. `null` values are created in arrays and objects if necessary. - - In particular: - - - If the JSON pointer points to an object key that does not exist, it is created an filled with a `#!json null` - value before a reference to it is returned. - - If the JSON pointer points to an array index that does not exist, it is created an filled with a `#!json null` - value before a reference to it is returned. All indices between the current maximum and the given index are also - filled with `#!json null`. - - The special value `-` is treated as a synonym for the index past the end. - -## Exception safety - -Strong exception safety: if an exception occurs, the original value stays intact. - -## Complexity - -1. Constant if `idx` is in the range of the array. Otherwise linear in `idx - size()`. -2. Logarithmic in the size of the container. -3. Constant - -## Example - -??? example - - The example below shows how array elements can be read and written using `[]` operator. Note the addition of - `#!json null` values. - - ```cpp - --8<-- "examples/operatorarray__size_type.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operatorarray__size_type.output" - ``` - -??? example - - The example below shows how array elements can be read using the `[]` operator. - - ```cpp - --8<-- "examples/operatorarray__size_type_const.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operatorarray__size_type_const.output" - ``` - -??? example - - The example below shows how object elements can be read and written using the `[]` operator. - - ```cpp - --8<-- "examples/operatorarray__key_type.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operatorarray__key_type.output" - ``` - -??? example - - The example below shows how object elements can be read using the `[]` operator. - - ```cpp - --8<-- "examples/operatorarray__key_type_const.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operatorarray__key_type_const.output" - ``` - -??? example - - The example below shows how values can be read and written using JSON Pointers. - - ```cpp - --8<-- "examples/operatorjson_pointer.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operatorjson_pointer.output" - ``` - -??? example - - The example below shows how values can be read using JSON Pointers. - - ```cpp - --8<-- "examples/operatorjson_pointer_const.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operatorjson_pointer_const.output" - ``` - -## Version history - -1. Added in version 1.0.0. -2. Added in version 1.0.0. Overloads for `T* key` added in version 1.1.0. -3. Added in version 2.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_ValueType.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_ValueType.md deleted file mode 100644 index cfb5e64c8..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_ValueType.md +++ /dev/null @@ -1,72 +0,0 @@ -# basic_json::operator ValueType - -```cpp -template -JSON_EXPLICIT operator ValueType() const; -``` - -Implicit type conversion between the JSON value and a compatible value. The call is realized by calling -[`get()`](get.md). See [Notes](#notes) for the meaning of `JSON_EXPLICIT`. - -## Template parameters - -`ValueType` -: the value type to return - -## Return value - -copy of the JSON value, converted to `ValueType` - -## Exceptions - -Depends on what `json_serializer` `from_json()` method throws - -## Complexity - -Linear in the size of the JSON value. - -## Notes - -By default `JSON_EXPLICIT` defined to the empty string, so the signature is: - -```cpp -template -operator ValueType() const; -``` - -If [`JSON_USE_IMPLICIT_CONVERSIONS`](../../features/macros.md#json_use_implicit_conversions) is set to `0`, -`JSON_EXPLICIT` is defined to `#!cpp explicit`: - -```cpp -template -explicit operator ValueType() const; -``` - -That is, implicit conversions can be switched off by defining -[`JSON_USE_IMPLICIT_CONVERSIONS`](../../features/macros.md#json_use_implicit_conversions) to `0`. - -## Example - -??? example - - The example below shows several conversions from JSON values - to other types. There a few things to note: (1) Floating-point numbers can - be converted to integers, (2) A JSON array can be converted to a standard - `std::vector`, (3) A JSON object can be converted to C++ - associative containers such as `std::unordered_map`. - - ```cpp - --8<-- "examples/operator__ValueType.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator__ValueType.output" - ``` - -## Version history - -- Since version 1.0.0. -- Macros `JSON_EXPLICIT`/[`JSON_USE_IMPLICIT_CONVERSIONS`](../../features/macros.md#json_use_implicit_conversions) added - in version 3.9.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_eq.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_eq.md deleted file mode 100644 index 34cf5537d..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_eq.md +++ /dev/null @@ -1,106 +0,0 @@ -# basic_json::operator== - -```cpp -bool operator==(const_reference lhs, const_reference rhs) noexcept; - -template -bool operator==(const_reference lhs, const ScalarType rhs) noexcept; - -template -bool operator==(ScalarType lhs, const const_reference rhs) noexcept; -``` - -Compares two JSON values for equality according to the following rules: - -- Two JSON values are equal if (1) they are not discarded, (2) they are from the same type, and (3) their stored values - are the same according to their respective `operator==`. -- Integer and floating-point numbers are automatically converted before comparison. Note that two NaN values are always - treated as unequal. - -## Template parameters - -`ScalarType` -: a scalar type according to `std::is_scalar::value` - -## Parameters - -`lhs` (in) -: first value to consider - -`rhs` (in) -: second value to consider - -## Return value - -whether the values `lhs` and `rhs` are equal - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Linear. - -## Notes - -!!! note - - - NaN values never compare equal to themselves or to other NaN values. - - JSON `#!cpp null` values are all equal. - - Discarded values never compare equal to themselves. - -!!! note - - Floating-point numbers inside JSON values numbers are compared with `json::number_float_t::operator==` which is - `double::operator==` by default. To compare floating-point while respecting an epsilon, an alternative - [comparison function](https://github.com/mariokonrad/marnav/blob/master/include/marnav/math/floatingpoint.hpp#L34-#L39) - could be used, for instance - - ```cpp - template::value, T>::type> - inline bool is_same(T a, T b, T epsilon = std::numeric_limits::epsilon()) noexcept - { - return std::abs(a - b) <= epsilon; - } - ``` - - Or you can self-defined operator equal function like this: - - ```cpp - bool my_equal(const_reference lhs, const_reference rhs) - { - const auto lhs_type lhs.type(); - const auto rhs_type rhs.type(); - if (lhs_type == rhs_type) - { - switch(lhs_type) - // self_defined case - case value_t::number_float: - return std::abs(lhs - rhs) <= std::numeric_limits::epsilon(); - // other cases remain the same with the original - ... - } - ... - } - ``` - -## Example - -??? example - - The example demonstrates comparing several JSON types. - - ```cpp - --8<-- "examples/operator__equal.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator__equal.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_ge.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_ge.md deleted file mode 100644 index 19834c0d8..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_ge.md +++ /dev/null @@ -1,59 +0,0 @@ -# basic_json::operator>= - -```cpp -bool operator>=(const_reference lhs, const_reference rhs) noexcept, - -template -bool operator>=(const_reference lhs, const ScalarType rhs) noexcept; - -template -bool operator>=(ScalarType lhs, const const_reference rhs) noexcept; -``` - -Compares whether one JSON value `lhs` is greater than or equal to another JSON value `rhs` by calculating -`#!cpp !(lhs < rhs)`. - -## Template parameters - -`ScalarType` -: a scalar type according to `std::is_scalar::value` - -## Parameters - -`lhs` (in) -: first value to consider - -`rhs` (in) -: second value to consider - -## Return value - -whether `lhs` is less than or equal to `rhs` - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Linear. - -## Example - -??? example - - The example demonstrates comparing several JSON types. - - ```cpp - --8<-- "examples/operator__greaterequal.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator__greaterequal.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_gt.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_gt.md deleted file mode 100644 index b9e32629d..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_gt.md +++ /dev/null @@ -1,58 +0,0 @@ -# basic_json::operator> - -```cpp -bool operator>(const_reference lhs, const_reference rhs) noexcept, - -template -bool operator>(const_reference lhs, const ScalarType rhs) noexcept; - -template -bool operator>(ScalarType lhs, const const_reference rhs) noexcept; -``` - -Compares whether one JSON value `lhs` is greater than another JSON value `rhs` by calculating `#!cpp !(lhs <= rhs)`. - -## Template parameters - -`ScalarType` -: a scalar type according to `std::is_scalar::value` - -## Parameters - -`lhs` (in) -: first value to consider - -`rhs` (in) -: second value to consider - -## Return value - -whether `lhs` is greater than `rhs` - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Linear. - -## Example - -??? example - - The example demonstrates comparing several JSON types. - - ```cpp - --8<-- "examples/operator__greater.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator__greater.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_le.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_le.md deleted file mode 100644 index 452ee4966..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_le.md +++ /dev/null @@ -1,59 +0,0 @@ -# basic_json::operator<= - -```cpp -bool operator<=(const_reference lhs, const_reference rhs) noexcept, - -template -bool operator<=(const_reference lhs, const ScalarType rhs) noexcept; - -template -bool operator<=(ScalarType lhs, const const_reference rhs) noexcept; -``` - -Compares whether one JSON value `lhs` is less than or equal to another JSON value `rhs` by calculating -`#cpp !(rhs < lhs)`. - -## Template parameters - -`ScalarType` -: a scalar type according to `std::is_scalar::value` - -## Parameters - -`lhs` (in) -: first value to consider - -`rhs` (in) -: second value to consider - -## Return value - -whether `lhs` is less than or equal to `rhs` - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Linear. - -## Example - -??? example - - The example demonstrates comparing several JSON types. - - ```cpp - --8<-- "examples/operator__lessequal.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator__lessequal.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_literal_json.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_literal_json.md deleted file mode 100644 index 8c96067b9..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_literal_json.md +++ /dev/null @@ -1,32 +0,0 @@ -# basic_json::operator""_json - -```cpp -json operator "" _json(const char* s, std::size_t n) -``` - -This operator implements a user-defined string literal for JSON objects. It can be used by adding `#!cpp _json` to a -string literal and returns a [`json`](../json.md) object if no parse error occurred. - -## Parameters - -`s` (in) -: a string representation of a JSON object - -`n` (in) -: length of string `s` - -## Return value - -[`json`](../json.md) value parsed from `s` - -## Exceptions - -The function can throw anything that [`parse(s, s+n)`](parse.md) would throw. - -## Complexity - -Linear. - -## Version history - -- Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_literal_json_pointer.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_literal_json_pointer.md deleted file mode 100644 index 0316b7c61..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_literal_json_pointer.md +++ /dev/null @@ -1,32 +0,0 @@ -# basic_json::operator""_json_pointer - -```cpp -json_pointer operator "" _json_pointer(const char* s, std::size_t n) -``` - -This operator implements a user-defined string literal for JSON Pointers. It can be used by adding `#!cpp _json_pointer` -to a string literal and returns a [`json_pointer`](../json_pointer.md) object if no parse error occurred. - -## Parameters - -`s` (in) -: a string representation of a JSON Pointer - -`n` (in) -: length of string `s` - -## Return value - -[`json_pointer`](../json_pointer.md) value parsed from `s` - -## Exceptions - -The function can throw anything that [`json_pointer::json_pointer`](../json_pointer.md) would throw. - -## Complexity - -Linear. - -## Version history - -- Added in version 2.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_lt.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_lt.md deleted file mode 100644 index e8d2fb359..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_lt.md +++ /dev/null @@ -1,73 +0,0 @@ -# basic_json::operator< - -```cpp -bool operator<(const_reference lhs, const_reference rhs) noexcept, - -template -bool operator<(const_reference lhs, const ScalarType rhs) noexcept; - -template -bool operator<(ScalarType lhs, const const_reference rhs) noexcept; -``` - -Compares whether one JSON value `lhs` is less than another JSON value `rhs` according to the following rules: - -- If `lhs` and `rhs` have the same type, the values are compared using the default `<` operator. -- Integer and floating-point numbers are automatically converted before comparison -- Discarded values a -- In case `lhs` and `rhs` have different types, the values are ignored and the order of the types is considered, which - is: - 1. null - 2. boolean - 3. number (all types) - 4. object - 5. array - 6. string - 7. binary - - For instance, any boolean value is considered less than any string. - -## Template parameters - -`ScalarType` -: a scalar type according to `std::is_scalar::value` - -## Parameters - -`lhs` (in) -: first value to consider - -`rhs` (in) -: second value to consider - -## Return value - -whether `lhs` is less than `rhs` - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Linear. - -## Example - -??? example - - The example demonstrates comparing several JSON types. - - ```cpp - --8<-- "examples/operator__less.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator__less.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_ne.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_ne.md deleted file mode 100644 index 5a86201ef..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_ne.md +++ /dev/null @@ -1,57 +0,0 @@ -# basic_json::operator!= - -```cpp -bool operator!=(const_reference lhs, const_reference rhs) noexcept; - -template -bool operator!=(const_reference lhs, const ScalarType rhs) noexcept; - -template -bool operator!=(ScalarType lhs, const const_reference rhs) noexcept; -``` - -Compares two JSON values for inequality by calculating `#!cpp !(lhs == rhs)`. - -## Template parameters - -`ScalarType` -: a scalar type according to `std::is_scalar::value` - -## Parameters - -`lhs` (in) -: first value to consider - -`rhs` (in) -: second value to consider - -## Return value - -whether the values `lhs` and `rhs` are not equal - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Linear. - -## Example - -The example demonstrates comparing several JSON -types. - -```cpp ---8<-- "examples/operator__notequal.cpp" -``` - -Output: - -```json ---8<-- "examples/operator__notequal.output" -``` - -## Version history - -- Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_value_t.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_value_t.md deleted file mode 100644 index 52125146c..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator_value_t.md +++ /dev/null @@ -1,54 +0,0 @@ -# basic_json::operator value_t - -```cpp -constexpr operator value_t() const noexcept; -``` - -Return the type of the JSON value as a value from the [`value_t`](value_t.md) enumeration. - -## Return value - -the type of the JSON value - -Value type | return value -------------------------- | ------------------------- -`#!json null` | `value_t::null` -boolean | `value_t::boolean` -string | `value_t::string` -number (integer) | `value_t::number_integer` -number (unsigned integer) | `value_t::number_unsigned` -number (floating-point) | `value_t::number_float` -object | `value_t::object` -array | `value_t::array` -binary | `value_t::binary` -discarded | `value_t::discarded` - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Example - -??? example - - The following code exemplifies `operator value_t()` for all JSON types. - - ```cpp - --8<-- "examples/operator__value_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator__value_t.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Added unsigned integer type in version 2.0.0. -- Added binary type in version 3.8.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/other_error.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/other_error.md deleted file mode 100644 index 492b2d484..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/other_error.md +++ /dev/null @@ -1,59 +0,0 @@ -# basic_json::other_error - -```cpp -class other_error : public exception; -``` - -This exception is thrown in case of errors that cannot be classified with the other exception types. - -Exceptions have ids 5xx. - -```plantuml -std::exception <|-- basic_json::exception -basic_json::exception <|-- basic_json::parse_error -basic_json::exception <|-- basic_json::invalid_iterator -basic_json::exception <|-- basic_json::type_error -basic_json::exception <|-- basic_json::out_of_range -basic_json::exception <|-- basic_json::other_error - -interface std::exception {} - -class basic_json::exception { - + const int id - + const char* what() const -} - -class basic_json::parse_error { - + const std::size_t byte -} - -class basic_json::other_error #FFFF00 {} -``` - -## Member functions - -- **what** - returns explanatory string - -## Member variables - -- **id** - the id of the exception - -## Example - -??? example - - The following code shows how a `other_error` exception can be caught. - - ```cpp - --8<-- "examples/other_error.cpp" - ``` - - Output: - - ```json - --8<-- "examples/other_error.output" - ``` - -## Version history - -- Since version 3.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/out_of_range.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/out_of_range.md deleted file mode 100644 index 47ead87c2..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/out_of_range.md +++ /dev/null @@ -1,60 +0,0 @@ -# basic_json::out_of_range - -```cpp -class out_of_range : public exception; -``` - -This exception is thrown in case a library function is called on an input parameter that exceeds the expected range, for -instance in case of array indices or nonexisting object keys. - -Exceptions have ids 4xx. - -```plantuml -std::exception <|-- basic_json::exception -basic_json::exception <|-- basic_json::parse_error -basic_json::exception <|-- basic_json::invalid_iterator -basic_json::exception <|-- basic_json::type_error -basic_json::exception <|-- basic_json::out_of_range -basic_json::exception <|-- basic_json::other_error - -interface std::exception {} - -class basic_json::exception { - + const int id - + const char* what() const -} - -class basic_json::parse_error { - + const std::size_t byte -} - -class basic_json::out_of_range #FFFF00 {} -``` - -## Member functions - -- **what** - returns explanatory string - -## Member variables - -- **id** - the id of the exception - -## Example - -??? example - - The following code shows how a `out_of_range` exception can be caught. - - ```cpp - --8<-- "examples/out_of_range.cpp" - ``` - - Output: - - ```json - --8<-- "examples/out_of_range.output" - ``` - -## Version history - -- Since version 3.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/parse.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/parse.md deleted file mode 100644 index 1f991b381..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/parse.md +++ /dev/null @@ -1,156 +0,0 @@ -# basic_json::parse - -```cpp -// (1) -template -static basic_json parse(InputType&& i, - const parser_callback_t cb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false); - -// (2) -template -static basic_json parse(IteratorType first, IteratorType last, - const parser_callback_t cb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false); -``` - -1. Deserialize from a compatible input. -2. Deserialize from a pair of character iterators - - The value_type of the iterator must be a integral type with size of 1, 2 or 4 bytes, which will be interpreted - respectively as UTF-8, UTF-16 and UTF-32. - -## Template parameters - -`InputType` -: A compatible input, for instance: - - - an `std::istream` object - - a `FILE` pointer - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. - -`IteratorType` -: a compatible iterator type - -## Parameters - -`i` (in) -: Input to parse from. - -`cb` (in) -: a parser callback function of type [`parser_callback_t`](parser_callback_t.md) which is used to control the - deserialization by filtering unwanted values (optional) - -`allow_exceptions` (in) -: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) - -`ignore_comments` (in) -: whether comments should be ignored and treated like whitespace (`#!cpp true`) or yield a parse error - (`#!cpp false`); (optional, `#!cpp false` by default) - -`first` (in) -: iterator to start of character range - -`last` (in) -: iterator to end of character range - -## Return value - -Deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be -`value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Complexity - -Linear in the length of the input. The parser is a predictive LL(1) parser. The complexity can be higher if the parser -callback function `cb` or reading from (1) the input `i` or (2) the iterator range [`first`, `last`] has a -super-linear complexity. - -## Notes - -(1) A UTF-8 byte order mark is silently ignored. - -## Examples - -??? example "Parsing from a charater array" - - The example below demonstrates the `parse()` function reading from an array. - - ```cpp - --8<-- "examples/parse__array__parser_callback_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/parse__array__parser_callback_t.output" - ``` - -??? example "Parsing from a string" - - The example below demonstrates the `parse()` function with and without callback function. - - ```cpp - --8<-- "examples/parse__string__parser_callback_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/parse__string__parser_callback_t.output" - ``` - -??? example "Parsing from an input stream" - - The example below demonstrates the `parse()` function with and without callback function. - - ```cpp - --8<-- "examples/parse__istream__parser_callback_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/parse__istream__parser_callback_t.output" - ``` - -??? example "Parsing from a contiguous container" - - The example below demonstrates the `parse()` function reading from a contiguous container. - - ```cpp - --8<-- "examples/parse__contiguouscontainer__parser_callback_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/parse__contiguouscontainer__parser_callback_t.output" - ``` - -??? example "Effect of `allow_exceptions` parameter" - - The example below demonstrates the effect of the `allow_exceptions` parameter in the ´parse()` function. - - ```cpp - --8<-- "examples/parse__allow_exceptions.cpp" - ``` - - Output: - - ```json - --8<-- "examples/parse__allow_exceptions.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Overload for contiguous containers (1) added in version 2.0.3. -- Ignoring comments via `ignore_comments` added in version 3.9.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/parse_error.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/parse_error.md deleted file mode 100644 index de0ee4010..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/parse_error.md +++ /dev/null @@ -1,64 +0,0 @@ -# basic_json::parse_error - -```cpp -class parse_error : public exception; -``` - -This exception is thrown by the library when a parse error occurs. Parse errors can occur during the deserialization of -JSON text, BSON, CBOR, MessagePack, UBJSON, as well as when using JSON Patch. - -Exceptions have ids 1xx. - -```plantuml -std::exception <|-- basic_json::exception -basic_json::exception <|-- basic_json::parse_error -basic_json::exception <|-- basic_json::invalid_iterator -basic_json::exception <|-- basic_json::type_error -basic_json::exception <|-- basic_json::out_of_range -basic_json::exception <|-- basic_json::other_error - -interface std::exception {} - -class basic_json::exception { - + const int id - + const char* what() const -} - -class basic_json::parse_error #FFFF00 { - + const std::size_t byte -} -``` - -## Member functions - -- **what** - returns explanatory string - -## Member variables - -- **id** - the id of the exception -- **byte** - byte index of the parse error - -## Note - -For an input with _n_ bytes, 1 is the index of the first character and _n_+1 is the index of the terminating null byte -or the end of file. This also holds true when reading a byte vector for binary formats. - -## Example - -??? example - - The following code shows how a `parse_error` exception can be caught. - - ```cpp - --8<-- "examples/parse_error.cpp" - ``` - - Output: - - ```json - --8<-- "examples/parse_error.output" - ``` - -## Version history - -- Since version 3.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/parser_callback_t.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/parser_callback_t.md deleted file mode 100644 index aeb7c2706..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/parser_callback_t.md +++ /dev/null @@ -1,73 +0,0 @@ -# basic_json::parser_callback_t - -```cpp -template -using parser_callback_t = - std::function; -``` - -With a parser callback function, the result of parsing a JSON text can be influenced. When passed to -[`parse`](parse.md), it is called on certain events (passed as [`parse_event_t`](parse_event_t.md) via parameter -`event`) with a set recursion depth `depth` and context JSON value `parsed`. The return value of the callback function -is a boolean indicating whether the element that emitted the callback shall be kept or not. - -We distinguish six scenarios (determined by the event type) in which the callback function can be called. The following -table describes the values of the parameters `depth`, `event`, and `parsed`. - -parameter `event` | description | parameter `depth` | parameter `parsed` ------------------- | ----------- | ------------------ | ------------------- -`parse_event_t::object_start` | the parser read `{` and started to process a JSON object | depth of the parent of the JSON object | a JSON value with type discarded -`parse_event_t::key` | the parser read a key of a value in an object | depth of the currently parsed JSON object | a JSON string containing the key -`parse_event_t::object_end` | the parser read `}` and finished processing a JSON object | depth of the parent of the JSON object | the parsed JSON object -`parse_event_t::array_start` | the parser read `[` and started to process a JSON array | depth of the parent of the JSON array | a JSON value with type discarded -`parse_event_t::array_end` | the parser read `]` and finished processing a JSON array | depth of the parent of the JSON array | the parsed JSON array -`parse_event_t::value` | the parser finished reading a JSON value | depth of the value | the parsed JSON value - -![Example when certain parse events are triggered](../../images/callback_events.png) - -Discarding a value (i.e., returning `#!cpp false`) has different effects depending on the context in which function was -called: - -- Discarded values in structured types are skipped. That is, the parser will behave as if the discarded value was never - read. -- In case a value outside a structured type is skipped, it is replaced with `null`. This case happens if the top-level - element is skipped. - -## Parameters - -`depth` (in) -: the depth of the recursion during parsing - -`event` (in) -: an event of type [`parse_event_t`](parse_event_t.md) indicating the context in - the callback function has been called - -`parsed` (in, out) -: the current intermediate parse result; note that - writing to this value has no effect for `parse_event_t::key` events - -## Return value - -Whether the JSON value which called the function during parsing should be kept (`#!cpp true`) or not (`#!cpp false`). In -the latter case, it is either skipped completely or replaced by an empty discarded object. - -# Example - -??? example - - The example below demonstrates the `parse()` function with - and without callback function. - - ```cpp - --8<-- "examples/parse__string__parser_callback_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/parse__string__parser_callback_t.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/push_back.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/push_back.md deleted file mode 100644 index c10c94a3e..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/push_back.md +++ /dev/null @@ -1,109 +0,0 @@ -# basic_json::push_back - -```cpp -// (1) -void push_back(basic_json&& val); -void push_back(const basic_json& val); - -// (2) -void push_back(const typename object_t::value_type& val); - -// (3) -void push_back(initializer_list_t init); -``` - -1. Appends the given element `val` to the end of the JSON array. If the function is called on a JSON null value, an - empty array is created before appending `val`. - -2. Inserts the given element `val` to the JSON object. If the function is called on a JSON null value, an empty object - is created before inserting `val`. - -3. This function allows to use `push_back` with an initializer list. In case - - 1. the current value is an object, - 2. the initializer list `init` contains only two elements, and - 3. the first element of `init` is a string, - - `init` is converted into an object element and added using `push_back(const typename object_t::value_type&)`. - Otherwise, `init` is converted to a JSON value and added using `push_back(basic_json&&)`. - -## Parameters - -`val` (in) -: the value to add to the JSON array/object - -`init` (in) -: an initializer list - -## Exceptions - -1. The function can throw the following exceptions: - - Throws [`type_error.308`](../../home/exceptions.md#jsonexceptiontype_error308) when called on a type other than - JSON array or null; example: `"cannot use push_back() with number"` -2. The function can throw the following exceptions: - - Throws [`type_error.308`](../../home/exceptions.md#jsonexceptiontype_error308) when called on a type other than - JSON object or null; example: `"cannot use push_back() with number"` - -## Complexity - -1. Amortized constant. -2. Logarithmic in the size of the container, O(log(`size()`)). -3. Linear in the size of the initializer list `init`. - -## Notes - -(3) This function is required to resolve an ambiguous overload error, because pairs like `{"key", "value"}` can be both - interpreted as `object_t::value_type` or `std::initializer_list`, see - [#235](https://github.com/nlohmann/json/issues/235) for more information. - -## Examples - -??? example - - The example shows how `push_back()` and `+=` can be used to add elements to a JSON array. Note how the `null` value - was silently converted to a JSON array. - - ```cpp - --8<-- "examples/push_back.cpp" - ``` - - Output: - - ```json - --8<-- "examples/push_back.output" - ``` - -??? example - - The example shows how `push_back()` and `+=` can be used to add elements to a JSON object. Note how the `null` value - was silently converted to a JSON object. - - ```cpp - --8<-- "examples/push_back__object_t__value.cpp" - ``` - - Output: - - ```json - --8<-- "examples/push_back__object_t__value.output" - ``` - -??? example - - The example shows how initializer lists are treated as objects when possible. - - ```cpp - --8<-- "examples/push_back__initializer_list.cpp" - ``` - - Output: - - ```json - --8<-- "examples/push_back__initializer_list.output" - ``` - -## Version history - -1. Since version 1.0.0. -2. Since version 1.0.0. -2. Since version 2.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/size.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/size.md deleted file mode 100644 index 36a9daeb6..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/size.md +++ /dev/null @@ -1,57 +0,0 @@ -# basic_json::size - -```cpp -size_type size() const noexcept; -``` - -Returns the number of elements in a JSON value. - -## Return value - -The return value depends on the different types and is defined as follows: - -Value type | return value ------------ | ------------- -null | `0` -boolean | `1` -string | `1` -number | `1` -binary | `1` -object | result of function object_t::size() -array | result of function array_t::size() - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Constant, as long as [`array_t`](array_t.md) and [`object_t`](object_t.md) satisfy the -[Container](https://en.cppreference.com/w/cpp/named_req/Container) concept; that is, their `size()` functions have -constant complexity. - -## Notes - -This function does not return the length of a string stored as JSON value -- it returns the number of elements in the -JSON value which is `1` in the case of a string. - -## Example - -??? example - - The following code calls `size()` on the different value types. - - ```cpp - --8<-- "examples/size.cpp" - ``` - - Output: - - ```json - --8<-- "examples/size.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Extended to return `1` for binary types in version 3.8.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/string_t.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/string_t.md deleted file mode 100644 index acdd351b5..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/string_t.md +++ /dev/null @@ -1,50 +0,0 @@ -# basic_json::string_t - -```cpp -using string_t = StringType; -``` - -The type used to store JSON strings. - -[RFC 7159](http://rfc7159.net/rfc7159) describes JSON strings as follows: -> A string is a sequence of zero or more Unicode characters. - -To store objects in C++, a type is defined by the template parameter described below. Unicode values are split by the -JSON class into byte-sized characters during deserialization. - -## Template parameters - -`StringType` -: the container to store strings (e.g., `std::string`). Note this container is used for keys/names in objects, see - [object_t](object_t.md). - -## Notes - -#### Default type - -With the default values for `StringType` (`std::string`), the default value for `string_t` is `#!cpp std::string`. - -#### Encoding - -Strings are stored in UTF-8 encoding. Therefore, functions like `std::string::size()` or `std::string::length()` return -the number of bytes in the string rather than the number of characters or glyphs. - -#### String comparison - -[RFC 7159](http://rfc7159.net/rfc7159) states: -> Software implementations are typically required to test names of object members for equality. Implementations that -> transform the textual representation into sequences of Unicode code units and then perform the comparison numerically, -> code unit by code unit, are interoperable in the sense that implementations will agree in all cases on equality or -> inequality of two strings. For example, implementations that compare strings with escaped characters unconverted may -> incorrectly find that `"a\\b"` and `"a\u005Cb"` are not equal. - -This implementation is interoperable as it does compare strings code unit by code unit. - -#### Storage - -String values are stored as pointers in a `basic_json` type. That is, for any access to string values, a pointer of type -`string_t*` must be dereferenced. - -## Version history - -- Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/type.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/type.md deleted file mode 100644 index b3482117b..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/type.md +++ /dev/null @@ -1,54 +0,0 @@ -# basic_json::type - -```cpp -constexpr value_t type() const noexcept; -``` - -Return the type of the JSON value as a value from the [`value_t`](value_t.md) enumeration. - -## Return value - -the type of the JSON value - -Value type | return value -------------------------- | ------------------------- -`#!json null` | `value_t::null` -boolean | `value_t::boolean` -string | `value_t::string` -number (integer) | `value_t::number_integer` -number (unsigned integer) | `value_t::number_unsigned` -number (floating-point) | `value_t::number_float` -object | `value_t::object` -array | `value_t::array` -binary | `value_t::binary` -discarded | `value_t::discarded` - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Example - -??? example - - The following code exemplifies `type()` for all JSON types. - - ```cpp - --8<-- "examples/type.cpp" - ``` - - Output: - - ```json - --8<-- "examples/type.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Added unsigned integer type in version 2.0.0. -- Added binary type in version 3.8.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/type_error.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/type_error.md deleted file mode 100644 index ea0154e39..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/type_error.md +++ /dev/null @@ -1,60 +0,0 @@ -# basic_json::type_error - -```cpp -class type_error : public exception; -``` - -This exception is thrown in case of a type error; that is, a library function is executed on a JSON value whose type -does not match the expected semantics. - -Exceptions have ids 3xx. - -```plantuml -std::exception <|-- basic_json::exception -basic_json::exception <|-- basic_json::parse_error -basic_json::exception <|-- basic_json::invalid_iterator -basic_json::exception <|-- basic_json::type_error -basic_json::exception <|-- basic_json::out_of_range -basic_json::exception <|-- basic_json::other_error - -interface std::exception {} - -class basic_json::exception { - + const int id - + const char* what() const -} - -class basic_json::parse_error { - + const std::size_t byte -} - -class basic_json::type_error #FFFF00 {} -``` - -## Member functions - -- **what** - returns explanatory string - -## Member variables - -- **id** - the id of the exception - -## Example - -??? example - - The following code shows how a `type_error` exception can be caught. - - ```cpp - --8<-- "examples/type_error.cpp" - ``` - - Output: - - ```json - --8<-- "examples/type_error.output" - ``` - -## Version history - -- Since version 3.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/type_name.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/type_name.md deleted file mode 100644 index 1a1752610..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/type_name.md +++ /dev/null @@ -1,54 +0,0 @@ -# basic_json::type_name - -```cpp -const char* type_name() const noexcept; -``` - -Returns the type name as string to be used in error messages -- usually to indicate that a function was called on a -wrong JSON type. - -## Return value - -a string representation of a the type ([`value_t`](value_t.md)): - -Value type | return value --------------------------------------------------- | ------------------------- -`#!json null` | `"null"` -boolean | `"boolean"` -string | `"string"` -number (integer, unsigned integer, floating-point) | `"number"` -object | `"object` -array | `"array` -binary | `"binary` -discarded | `"discarded` - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Example - -??? example - - The following code exemplifies `type_name()` for all JSON types. - - ```cpp - --8<-- "examples/type_name.cpp" - ``` - - Output: - - ```json - --8<-- "examples/type_name.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Part of the public API version since 2.1.0. -- Changed return value to `const char*` and added `noexcept` in version 3.0.0. -- Added support for binary type in version 3.8.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/update.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/update.md deleted file mode 100644 index a1837c860..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/update.md +++ /dev/null @@ -1,78 +0,0 @@ -# basic_json::update - -```cpp -// (1) -void update(const_reference j); - -// (2) -void update(const_iterator first, const_iterator last); -``` - -1. Inserts all values from JSON object `j` and overwrites existing keys. -2. Inserts all values from from range `[first, last)` and overwrites existing keys. - -The function is motivated by Python's [dict.update](https://docs.python.org/3.6/library/stdtypes.html#dict.update) -function. - -## Parameters - -`j` (in) -: JSON object to read values from - -`first` (in) -: begin of the range of elements to insert - -`last` (in) -: end of the range of elements to insert - -## Exceptions - -1. The function can throw the following exceptions: - - Throws [`type_error.312`](../../home/exceptions.md#jsonexceptiontype_error312) if called on JSON values other than - objects; example: `"cannot use update() with string"` -2. The function can throw thw following exceptions: - - Throws [`type_error.312`](../../home/exceptions.md#jsonexceptiontype_error312) if called on JSON values other than - objects; example: `"cannot use update() with string"` - - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an - iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"` - - Throws [`invalid_iterator.210`](../../home/exceptions.md#jsonexceptioninvalid_iterator210) if `first` and `last` - do not belong to the same JSON value; example: `"iterators do not fit"` - -## Complexity - -1. O(N*log(size() + N)), where N is the number of elements to insert. -2. O(N*log(size() + N)), where N is the number of elements to insert. - -## Example - -??? example - - The example shows how `update()` is used. - - ```cpp - --8<-- "examples/update.cpp" - ``` - - Output: - - ```json - --8<-- "examples/update.output" - ``` - -??? example - - The example shows how `update()` is used. - - ```cpp - --8<-- "examples/update__range.cpp" - ``` - - Output: - - ```json - --8<-- "examples/update__range.output" - ``` - -## Version history - -- Added in version 3.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/value.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/value.md deleted file mode 100644 index 8fdbc238f..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/value.md +++ /dev/null @@ -1,121 +0,0 @@ -# basic_json::value - -```cpp -// (1) -template -ValueType value(const typename object_t::key_type& key, - const ValueType& default_value) const; - -// (2) -template -ValueType value(const json_pointer& ptr, - const ValueType& default_value) const; -``` - -1. Returns either a copy of an object's element at the specified key `key` or a given default value if no element with - key `key` exists. - - The function is basically equivalent to executing - ```cpp - try { - return at(key); - } catch(out_of_range) { - return default_value; - } - ``` - -2. Returns either a copy of an object's element at the specified JSON pointer `ptr` or a given default value if no value - at `ptr` exists. - - The function is basically equivalent to executing - ```cpp - try { - return at(ptr); - } catch(out_of_range) { - return default_value; - } - ``` - -Unlike [`operator[]`](operator[].md), this function does not implicitly add an element to the position defined by -`key`/`ptr` key. This function is furthermore also applicable to const objects. - -## Template parameters - -`ValueType` -: type compatible to JSON values, for instance `#!cpp int` for JSON integer numbers, `#!cpp bool` for JSON booleans, - or `#!cpp std::vector` types for JSON arrays. Note the type of the expected value at `key`/`ptr` and the default - value `default_value` must be compatible. - -## Parameters - -`key` (in) -: key of the element to access - -`default_value` (in) -: the value to return if key/ptr found no value - -`ptr` (in) -: a JSON pointer to the element to access - -## Return value - -1. copy of the element at key `key` or `default_value` if `key` is not found -1. copy of the element at JSON Pointer `ptr` or `default_value` if no value for `ptr` is found - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no -changes to any JSON value. - -## Exceptions - -1. The function can throw thw following exceptions: - - Throws [`type_error.302`](../../home/exceptions.md#jsonexceptiontype_error302) if `default_value` does not match - the type of the value at `key` - - Throws [`type_error.306`](../../home/exceptions.md#jsonexceptiontype_error306) if the JSON value is not an object; - in that case, using `value()` with a key makes no sense. -2. The function can throw thw following exceptions: - - Throws [`type_error.302`](../../home/exceptions.md#jsonexceptiontype_error302) if `default_value` does not match - the type of the value at `ptr` - - Throws [`type_error.306`](../../home/exceptions.md#jsonexceptiontype_error306) if the JSON value is not an object; - in that case, using `value()` with a key makes no sense. - -## Complexity - -1. Logarithmic in the size of the container. -2. Logarithmic in the size of the container. - -## Example - -??? example - - The example below shows how object elements can be queried with a default value. - - ```cpp - --8<-- "examples/basic_json__value.cpp" - ``` - - Output: - - ```json - --8<-- "examples/basic_json__value.output" - ``` - -??? example - - The example below shows how object elements can be queried with a default value. - - ```cpp - --8<-- "examples/basic_json__value_ptr.cpp" - ``` - - Output: - - ```json - --8<-- "examples/basic_json__value_ptr.output" - ``` - -## Version history - -1. Added in version 1.0.0. -2. Added in version 2.0.2. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/value_t.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/value_t.md deleted file mode 100644 index 5fa9501fc..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/value_t.md +++ /dev/null @@ -1,36 +0,0 @@ -# basic_json::value_t - -```cpp -enum class value_t : std::uint8_t { - null, - object, - array, - string, - boolean, - number_integer, - number_unsigned, - number_float, - binary, - discarded -}; -``` - -This enumeration collects the different JSON types. It is internally used to distinguish the stored values, and the -functions [`is_null`](is_null.md), [`is_object`](is_object.md), [`is_array`](is_array.md), [`is_string`](is_string.md), -[`is_boolean`](is_boolean.md), [`is_number`](is_number.md) (with [`is_number_integer`](is_number_integer.md), -[`is_number_unsigned`](is_number_unsigned.md), and [`is_number_float`](is_number_float.md)), -[`is_discarded`](is_discarded.md), [`is_binary`](is_binary.md), [`is_primitive`](is_primitive.md), and -[`is_structured`](is_structured.md) rely on it. - -## Note - -There are three enumeration entries (number_integer, number_unsigned, and number_float), because the library -distinguishes these three types for numbers: [`number_unsigned_t`](number_unsigned_t.md) is used for unsigned integers, -[`number_integer_t`](number_integer_t.md) is used for signed integers, and [`number_float_t`](number_float_t.md) is used -for floating-point numbers or to approximate integers which do not fit in the limits of their respective type. - -## Version history - -- Added in version 1.0.0. -- Added unsigned integer type in version 2.0.0. -- Added binary type in version 3.8.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/~basic_json.md b/external_imported/json/doc/mkdocs/docs/api/basic_json/~basic_json.md deleted file mode 100644 index b089b0d79..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/~basic_json.md +++ /dev/null @@ -1,19 +0,0 @@ -# basic_json::~basic_json - -```cpp -~basic_json() noexcept -``` - -Destroys the JSON value and frees all allocated memory. - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Linear. - -## Version history - -- Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/json.md b/external_imported/json/doc/mkdocs/docs/api/json.md deleted file mode 100644 index 0aff6d2c0..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/json.md +++ /dev/null @@ -1,5 +0,0 @@ -# json - -```cpp -using json = basic_json<>; -``` diff --git a/external_imported/json/doc/mkdocs/docs/api/json_pointer.md b/external_imported/json/doc/mkdocs/docs/api/json_pointer.md deleted file mode 100644 index 5aa0399cd..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/json_pointer.md +++ /dev/null @@ -1,24 +0,0 @@ -# json_pointer - -```cpp -template -class json_pointer; -``` - -## Template parameters - -`BasicJsonType` -: a specialization of [`basic_json`](basic_json/index.md) - -## Member functions - -- (constructor) -- **to_string** - return a string representation of the JSON pointer -- **operator std::string**- return a string representation of the JSON pointer -- **operator/=** - append to the end of the JSON pointer -- **operator/** - create JSON Pointer by appending -- **parent_pointer** - returns the parent of this JSON pointer -- **pop_back** - remove last reference token -- **back** - return last reference token -- **push_back** - append an unescaped token at the end of the pointer -- **empty** - return whether pointer points to the root document diff --git a/external_imported/json/doc/mkdocs/docs/api/ordered_json.md b/external_imported/json/doc/mkdocs/docs/api/ordered_json.md deleted file mode 100644 index 8ce8dfe3e..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/ordered_json.md +++ /dev/null @@ -1,5 +0,0 @@ -# ordered_json - -```cpp -using ordered_json = basic_json; -``` diff --git a/external_imported/json/doc/mkdocs/docs/api/ordered_map.md b/external_imported/json/doc/mkdocs/docs/api/ordered_map.md deleted file mode 100644 index 1a99b636f..000000000 --- a/external_imported/json/doc/mkdocs/docs/api/ordered_map.md +++ /dev/null @@ -1,7 +0,0 @@ -# ordered_map - -```cpp -template, - class Allocator = std::allocator>> -struct ordered_map : std::vector, Allocator>; -``` diff --git a/external_imported/json/doc/mkdocs/docs/features/arbitrary_types.md b/external_imported/json/doc/mkdocs/docs/features/arbitrary_types.md deleted file mode 100644 index 23913bba2..000000000 --- a/external_imported/json/doc/mkdocs/docs/features/arbitrary_types.md +++ /dev/null @@ -1,264 +0,0 @@ -# Arbitrary Types Conversions - -Every type can be serialized in JSON, not just STL containers and scalar types. Usually, you would do something along those lines: - -```cpp -namespace ns { - // a simple struct to model a person - struct person { - std::string name; - std::string address; - int age; - }; -} - -ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; - -// convert to JSON: copy each value into the JSON object -json j; -j["name"] = p.name; -j["address"] = p.address; -j["age"] = p.age; - -// ... - -// convert from JSON: copy each value from the JSON object -ns::person p { - j["name"].get(), - j["address"].get(), - j["age"].get() -}; -``` - -It works, but that's quite a lot of boilerplate... Fortunately, there's a better way: - -```cpp -// create a person -ns::person p {"Ned Flanders", "744 Evergreen Terrace", 60}; - -// conversion: person -> json -json j = p; - -std::cout << j << std::endl; -// {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} - -// conversion: json -> person -auto p2 = j.get(); - -// that's it -assert(p == p2); -``` - -## Basic usage - -To make this work with one of your types, you only need to provide two functions: - -```cpp -using nlohmann::json; - -namespace ns { - void to_json(json& j, const person& p) { - j = json{ {"name", p.name}, {"address", p.address}, {"age", p.age} }; - } - - void from_json(const json& j, person& p) { - j.at("name").get_to(p.name); - j.at("address").get_to(p.address); - j.at("age").get_to(p.age); - } -} // namespace ns -``` - -That's all! When calling the `json` constructor with your type, your custom `to_json` method will be automatically called. -Likewise, when calling `get()` or `get_to(your_type&)`, the `from_json` method will be called. - -Some important things: - -* Those methods **MUST** be in your type's namespace (which can be the global namespace), or the library will not be able to locate them (in this example, they are in namespace `ns`, where `person` is defined). -* Those methods **MUST** be available (e.g., proper headers must be included) everywhere you use these conversions. Look at [issue 1108](https://github.com/nlohmann/json/issues/1108) for errors that may occur otherwise. -* When using `get()`, `your_type` **MUST** be [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). (There is a way to bypass this requirement described later.) -* In function `from_json`, use function [`at()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a93403e803947b86f4da2d1fb3345cf2c.html#a93403e803947b86f4da2d1fb3345cf2c) to access the object values rather than `operator[]`. In case a key does not exist, `at` throws an exception that you can handle, whereas `operator[]` exhibits undefined behavior. -* You do not need to add serializers or deserializers for STL types like `std::vector`: the library already implements these. - - -## Simplify your life with macros - -If you just want to serialize/deserialize some structs, the `to_json`/`from_json` functions can be a lot of boilerplate. - -There are two macros to make your life easier as long as you (1) want to use a JSON object as serialization and (2) want to use the member variable names as object keys in that object: - -- `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(name, member1, member2, ...)` is to be defined inside of the namespace of the class/struct to create code for. -- `NLOHMANN_DEFINE_TYPE_INTRUSIVE(name, member1, member2, ...)` is to be defined inside of the class/struct to create code for. This macro can also access private members. - -In both macros, the first parameter is the name of the class/struct, and all remaining parameters name the members. - -!!! note - - At most 64 member variables can be passed to `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE` or `NLOHMANN_DEFINE_TYPE_INTRUSIVE`. - -??? example - - The `to_json`/`from_json` functions for the `person` struct above can be created with: - - ```cpp - namespace ns { - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(person, name, address, age) - } - ``` - - Here is an example with private members, where `NLOHMANN_DEFINE_TYPE_INTRUSIVE` is needed: - - ```cpp - namespace ns { - class address { - private: - std::string street; - int housenumber; - int postcode; - - public: - NLOHMANN_DEFINE_TYPE_INTRUSIVE(address, street, housenumber, postcode) - }; - } - ``` - -## How do I convert third-party types? - -This requires a bit more advanced technique. But first, let's see how this conversion mechanism works: - -The library uses **JSON Serializers** to convert types to json. -The default serializer for `nlohmann::json` is `nlohmann::adl_serializer` (ADL means [Argument-Dependent Lookup](https://en.cppreference.com/w/cpp/language/adl)). - -It is implemented like this (simplified): - -```cpp -template -struct adl_serializer { - static void to_json(json& j, const T& value) { - // calls the "to_json" method in T's namespace - } - - static void from_json(const json& j, T& value) { - // same thing, but with the "from_json" method - } -}; -``` - -This serializer works fine when you have control over the type's namespace. However, what about `boost::optional` or `std::filesystem::path` (C++17)? Hijacking the `boost` namespace is pretty bad, and it's illegal to add something other than template specializations to `std`... - -To solve this, you need to add a specialization of `adl_serializer` to the `nlohmann` namespace, here's an example: - -```cpp -// partial specialization (full specialization works too) -namespace nlohmann { - template - struct adl_serializer> { - static void to_json(json& j, const boost::optional& opt) { - if (opt == boost::none) { - j = nullptr; - } else { - j = *opt; // this will call adl_serializer::to_json which will - // find the free function to_json in T's namespace! - } - } - - static void from_json(const json& j, boost::optional& opt) { - if (j.is_null()) { - opt = boost::none; - } else { - opt = j.get(); // same as above, but with - // adl_serializer::from_json - } - } - }; -} -``` - -## How can I use `get()` for non-default constructible/non-copyable types? - -There is a way, if your type is [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible). You will need to specialize the `adl_serializer` as well, but with a special `from_json` overload: - -```cpp -struct move_only_type { - move_only_type() = delete; - move_only_type(int ii): i(ii) {} - move_only_type(const move_only_type&) = delete; - move_only_type(move_only_type&&) = default; - - int i; -}; - -namespace nlohmann { - template <> - struct adl_serializer { - // note: the return type is no longer 'void', and the method only takes - // one argument - static move_only_type from_json(const json& j) { - return {j.get()}; - } - - // Here's the catch! You must provide a to_json method! Otherwise you - // will not be able to convert move_only_type to json, since you fully - // specialized adl_serializer on that type - static void to_json(json& j, move_only_type t) { - j = t.i; - } - }; -} -``` - -## Can I write my own serializer? (Advanced use) - -Yes. You might want to take a look at [`unit-udt.cpp`](https://github.com/nlohmann/json/blob/develop/test/src/unit-udt.cpp) in the test suite, to see a few examples. - -If you write your own serializer, you'll need to do a few things: - -- use a different `basic_json` alias than `nlohmann::json` (the last template parameter of `basic_json` is the `JSONSerializer`) -- use your `basic_json` alias (or a template parameter) in all your `to_json`/`from_json` methods -- use `nlohmann::to_json` and `nlohmann::from_json` when you need ADL - -Here is an example, without simplifications, that only accepts types with a size <= 32, and uses ADL. - -```cpp -// You should use void as a second template argument -// if you don't need compile-time checks on T -template::type> -struct less_than_32_serializer { - template - static void to_json(BasicJsonType& j, T value) { - // we want to use ADL, and call the correct to_json overload - using nlohmann::to_json; // this method is called by adl_serializer, - // this is where the magic happens - to_json(j, value); - } - - template - static void from_json(const BasicJsonType& j, T& value) { - // same thing here - using nlohmann::from_json; - from_json(j, value); - } -}; -``` - -Be **very** careful when reimplementing your serializer, you can stack overflow if you don't pay attention: - -```cpp -template -struct bad_serializer -{ - template - static void to_json(BasicJsonType& j, const T& value) { - // this calls BasicJsonType::json_serializer::to_json(j, value); - // if BasicJsonType::json_serializer == bad_serializer ... oops! - j = value; - } - - template - static void to_json(const BasicJsonType& j, T& value) { - // this calls BasicJsonType::json_serializer::from_json(j, value); - // if BasicJsonType::json_serializer == bad_serializer ... oops! - value = j.template get(); // oops! - } -}; -``` diff --git a/external_imported/json/doc/mkdocs/docs/features/binary_formats/bson.md b/external_imported/json/doc/mkdocs/docs/features/binary_formats/bson.md deleted file mode 100644 index 0ed2a786e..000000000 --- a/external_imported/json/doc/mkdocs/docs/features/binary_formats/bson.md +++ /dev/null @@ -1,94 +0,0 @@ -# BSON - -BSON, short for Bin­ary JSON, is a bin­ary-en­coded seri­al­iz­a­tion of JSON-like doc­u­ments. Like JSON, BSON sup­ports the em­bed­ding of doc­u­ments and ar­rays with­in oth­er doc­u­ments and ar­rays. BSON also con­tains ex­ten­sions that al­low rep­res­ent­a­tion of data types that are not part of the JSON spec. For ex­ample, BSON has a Date type and a BinData type. - -!!! abstract "References" - - - [BSON Website](http://bsonspec.org) - the main source on BSON - - [BSON Specification](http://bsonspec.org/spec.html) - the specification - - -## Serialization - -The library uses the following mapping from JSON values types to BSON types: - -JSON value type | value/range | BSON type | marker ---------------- | --------------------------------- | ----------- | ------ -null | `null` | null | 0x0A -boolean | `true`, `false` | boolean | 0x08 -number_integer | -9223372036854775808..-2147483649 | int64 | 0x12 -number_integer | -2147483648..2147483647 | int32 | 0x10 -number_integer | 2147483648..9223372036854775807 | int64 | 0x12 -number_unsigned | 0..2147483647 | int32 | 0x10 -number_unsigned | 2147483648..9223372036854775807 | int64 | 0x12 -number_unsigned | 9223372036854775808..18446744073709551615| -- | -- -number_float | *any value* | double | 0x01 -string | *any value* | string | 0x02 -array | *any value* | document | 0x04 -object | *any value* | document | 0x03 -binary | *any value* | binary | 0x05 - -!!! warning "Incomplete mapping" - - The mapping is **incomplete**, since only JSON-objects (and things - contained therein) can be serialized to BSON. - Also, integers larger than 9223372036854775807 cannot be serialized to BSON, - and the keys may not contain U+0000, since they are serialized a - zero-terminated c-strings. - -??? example - - ```cpp - --8<-- "examples/to_bson.cpp" - ``` - - Output: - - ```c - --8<-- "examples/to_bson.output" - ``` - - -## Deserialization - -The library maps BSON record types to JSON value types as follows: - -BSON type | BSON marker byte | JSON value type ---------------- | ---------------- | --------------------------- -double | 0x01 | number_float -string | 0x02 | string -document | 0x03 | object -array | 0x04 | array -binary | 0x05 | binary -undefined | 0x06 | *unsupported* -ObjectId | 0x07 | *unsupported* -boolean | 0x08 | boolean -UTC Date-Time | 0x09 | *unsupported* -null | 0x0A | null -Regular Expr. | 0x0B | *unsupported* -DB Pointer | 0x0C | *unsupported* -JavaScript Code | 0x0D | *unsupported* -Symbol | 0x0E | *unsupported* -JavaScript Code | 0x0F | *unsupported* -int32 | 0x10 | number_integer -Timestamp | 0x11 | *unsupported* -128-bit decimal float | 0x13 | *unsupported* -Max Key | 0x7F | *unsupported* -Min Key | 0xFF | *unsupported* - -!!! warning "Incomplete mapping" - - The mapping is **incomplete**. The unsupported mappings are indicated in the table above. - - -??? example - - ```cpp - --8<-- "examples/from_bson.cpp" - ``` - - Output: - - ```json - --8<-- "examples/from_bson.output" - ``` diff --git a/external_imported/json/doc/mkdocs/docs/features/binary_formats/cbor.md b/external_imported/json/doc/mkdocs/docs/features/binary_formats/cbor.md deleted file mode 100644 index daa29be87..000000000 --- a/external_imported/json/doc/mkdocs/docs/features/binary_formats/cbor.md +++ /dev/null @@ -1,177 +0,0 @@ -# CBOR - -The Concise Binary Object Representation (CBOR) is a data format whose design goals include the possibility of extremely small code size, fairly small message size, and extensibility without the need for version negotiation. - -!!! abstract "References" - - - [CBOR Website](http://cbor.io) - the main source on CBOR - - [CBOR Playground](http://cbor.me) - an interactive webpage to translate between JSON and CBOR - - [RFC 7049](https://tools.ietf.org/html/rfc7049) - the CBOR specification - -## Serialization - -The library uses the following mapping from JSON values types to CBOR types according to the CBOR specification (RFC 7049): - -JSON value type | value/range | CBOR type | first byte ---------------- | ------------------------------------------ | ---------------------------------- | --------------- -null | `null` | Null | 0xF6 -boolean | `true` | True | 0xF5 -boolean | `false` | False | 0xF4 -number_integer | -9223372036854775808..-2147483649 | Negative integer (8 bytes follow) | 0x3B -number_integer | -2147483648..-32769 | Negative integer (4 bytes follow) | 0x3A -number_integer | -32768..-129 | Negative integer (2 bytes follow) | 0x39 -number_integer | -128..-25 | Negative integer (1 byte follow) | 0x38 -number_integer | -24..-1 | Negative integer | 0x20..0x37 -number_integer | 0..23 | Integer | 0x00..0x17 -number_integer | 24..255 | Unsigned integer (1 byte follow) | 0x18 -number_integer | 256..65535 | Unsigned integer (2 bytes follow) | 0x19 -number_integer | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A -number_integer | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B -number_unsigned | 0..23 | Integer | 0x00..0x17 -number_unsigned | 24..255 | Unsigned integer (1 byte follow) | 0x18 -number_unsigned | 256..65535 | Unsigned integer (2 bytes follow) | 0x19 -number_unsigned | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A -number_unsigned | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B -number_float | *any value representable by a float* | Single-Precision Float | 0xFA -number_float | *any value NOT representable by a float* | Double-Precision Float | 0xFB -string | *length*: 0..23 | UTF-8 string | 0x60..0x77 -string | *length*: 23..255 | UTF-8 string (1 byte follow) | 0x78 -string | *length*: 256..65535 | UTF-8 string (2 bytes follow) | 0x79 -string | *length*: 65536..4294967295 | UTF-8 string (4 bytes follow) | 0x7A -string | *length*: 4294967296..18446744073709551615 | UTF-8 string (8 bytes follow) | 0x7B -array | *size*: 0..23 | array | 0x80..0x97 -array | *size*: 23..255 | array (1 byte follow) | 0x98 -array | *size*: 256..65535 | array (2 bytes follow) | 0x99 -array | *size*: 65536..4294967295 | array (4 bytes follow) | 0x9A -array | *size*: 4294967296..18446744073709551615 | array (8 bytes follow) | 0x9B -object | *size*: 0..23 | map | 0xA0..0xB7 -object | *size*: 23..255 | map (1 byte follow) | 0xB8 -object | *size*: 256..65535 | map (2 bytes follow) | 0xB9 -object | *size*: 65536..4294967295 | map (4 bytes follow) | 0xBA -object | *size*: 4294967296..18446744073709551615 | map (8 bytes follow) | 0xBB -binary | *size*: 0..23 | byte string | 0x40..0x57 -binary | *size*: 23..255 | byte string (1 byte follow) | 0x58 -binary | *size*: 256..65535 | byte string (2 bytes follow) | 0x59 -binary | *size*: 65536..4294967295 | byte string (4 bytes follow) | 0x5A -binary | *size*: 4294967296..18446744073709551615 | byte string (8 bytes follow) | 0x5B - - -!!! success "Complete mapping" - - The mapping is **complete** in the sense that any JSON value type can be converted to a CBOR value. - -!!! info "NaN/infinity handling" - - If NaN or Infinity are stored inside a JSON number, they are serialized properly. This behavior differs from the normal JSON serialization which serializes NaN or Infinity to `null`. - -!!! info "Unused CBOR types" - - The following CBOR types are not used in the conversion: - - - UTF-8 strings terminated by "break" (0x7F) - - arrays terminated by "break" (0x9F) - - maps terminated by "break" (0xBF) - - byte strings terminated by "break" (0x5F) - - date/time (0xC0..0xC1) - - bignum (0xC2..0xC3) - - decimal fraction (0xC4) - - bigfloat (0xC5) - - expected conversions (0xD5..0xD7) - - simple values (0xE0..0xF3, 0xF8) - - undefined (0xF7) - - half-precision floats (0xF9) - - break (0xFF) - -!!! info "Tagged items" - - Binary subtypes will be serialized as tagged items. See [binary values](../binary_values.md#cbor) for an example. - -??? example - - ```cpp - --8<-- "examples/to_cbor.cpp" - ``` - - Output: - - ```c - --8<-- "examples/to_cbor.output" - ``` - -## Deserialization - -The library maps CBOR types to JSON value types as follows: - -CBOR type | JSON value type | first byte ----------------------- | --------------- | ---------- -Integer | number_unsigned | 0x00..0x17 -Unsigned integer | number_unsigned | 0x18 -Unsigned integer | number_unsigned | 0x19 -Unsigned integer | number_unsigned | 0x1A -Unsigned integer | number_unsigned | 0x1B -Negative integer | number_integer | 0x20..0x37 -Negative integer | number_integer | 0x38 -Negative integer | number_integer | 0x39 -Negative integer | number_integer | 0x3A -Negative integer | number_integer | 0x3B -Byte string | binary | 0x40..0x57 -Byte string | binary | 0x58 -Byte string | binary | 0x59 -Byte string | binary | 0x5A -Byte string | binary | 0x5B -UTF-8 string | string | 0x60..0x77 -UTF-8 string | string | 0x78 -UTF-8 string | string | 0x79 -UTF-8 string | string | 0x7A -UTF-8 string | string | 0x7B -UTF-8 string | string | 0x7F -array | array | 0x80..0x97 -array | array | 0x98 -array | array | 0x99 -array | array | 0x9A -array | array | 0x9B -array | array | 0x9F -map | object | 0xA0..0xB7 -map | object | 0xB8 -map | object | 0xB9 -map | object | 0xBA -map | object | 0xBB -map | object | 0xBF -False | `false` | 0xF4 -True | `true` | 0xF5 -Null | `null` | 0xF6 -Half-Precision Float | number_float | 0xF9 -Single-Precision Float | number_float | 0xFA -Double-Precision Float | number_float | 0xFB - -!!! warning "Incomplete mapping" - - The mapping is **incomplete** in the sense that not all CBOR types can be converted to a JSON value. The following CBOR types are not supported and will yield parse errors: - - - date/time (0xC0..0xC1) - - bignum (0xC2..0xC3) - - decimal fraction (0xC4) - - bigfloat (0xC5) - - expected conversions (0xD5..0xD7) - - simple values (0xE0..0xF3, 0xF8) - - undefined (0xF7) - -!!! warning "Object keys" - - CBOR allows map keys of any type, whereas JSON only allows strings as keys in object values. Therefore, CBOR maps with keys other than UTF-8 strings are rejected. - -!!! warning "Tagged items" - - Tagged items will throw a parse error by default. However, they can be ignored by passing `cbor_tag_handler_t::ignore` to function `from_cbor`. - -??? example - - ```cpp - --8<-- "examples/from_cbor.cpp" - ``` - - Output: - - ```json - --8<-- "examples/from_cbor.output" - ``` diff --git a/external_imported/json/doc/mkdocs/docs/features/binary_formats/index.md b/external_imported/json/doc/mkdocs/docs/features/binary_formats/index.md deleted file mode 100644 index 55f963c2d..000000000 --- a/external_imported/json/doc/mkdocs/docs/features/binary_formats/index.md +++ /dev/null @@ -1,45 +0,0 @@ -# Overview - -Though JSON is a ubiquitous data format, it is not a very compact format suitable for data exchange, for instance over a network. Hence, the library supports - -- [BSON](bson.md) (Binary JSON), -- [CBOR](cbor.md) (Concise Binary Object Representation), -- [MessagePack](messagepack.md), and -- [UBJSON](ubjson.md) (Universal Binary JSON) - -to efficiently encode JSON values to byte vectors and to decode such vectors. - -## Comparison - -### Completeness - -| Format | Serialization | Deserialization | -| ----------- |---------------------------------------------- | -------------------------------------------- | -| BSON | incomplete: top-level value must be an object | incomplete, but all JSON types are supported | -| CBOR | complete | incomplete, but all JSON types are supported | -| MessagePack | complete | complete | -| UBJSON | complete | complete | - -### Binary values - -| Format | Binary values | Binary subtypes | -| ----------- | ------------- | --------------- | -| BSON | supported | supported | -| CBOR | supported | not supported | -| MessagePack | supported | supported | -| UBJSON | not supported | not supported | - -See [binary values](../binary_values.md) for more information. - -### Sizes - -| Format | canada.json | twitter.json | citm_catalog.json | jeopardy.json | -| ------------------ | ----------- | ------------ | ----------------- | ------------- | -| BSON | 85,8 % | 95,2 % | 95,8 % | 106,7 % | -| CBOR | 50,5 % | 86,3 % | 68,4 % | 88,0 % | -| MessagePack | 50,6 % | 86,0 % | 68,5 % | 87,9 % | -| UBJSON | 53,2 % | 91,3 % | 78,2 % | 96,6 % | -| UBJSON (size) | 58,6 % | 92,3 % | 86,8 % | 97,4 % | -| UBJSON (size+type) | 55,9 % | 92,3 % | 85,0 % | 95,0 % | - -Sizes compared to minified JSON value. diff --git a/external_imported/json/doc/mkdocs/docs/features/binary_formats/messagepack.md b/external_imported/json/doc/mkdocs/docs/features/binary_formats/messagepack.md deleted file mode 100644 index 3e041bb70..000000000 --- a/external_imported/json/doc/mkdocs/docs/features/binary_formats/messagepack.md +++ /dev/null @@ -1,139 +0,0 @@ -# MessagePack - -MessagePack is an efficient binary serialization format. It lets you exchange data among multiple languages like JSON. But it's faster and smaller. Small integers are encoded into a single byte, and typical short strings require only one extra byte in addition to the strings themselves. - -!!! abstract "References" - - - [MessagePack website](https://msgpack.org) - - [MessagePack specification](https://github.com/msgpack/msgpack/blob/master/spec.md) - -## Serialization - -The library uses the following mapping from JSON values types to MessagePack types according to the MessagePack specification: - -JSON value type | value/range | MessagePack type | first byte ---------------- | --------------------------------- | ---------------- | ---------- -null | `null` | nil | 0xC0 -boolean | `true` | true | 0xC3 -boolean | `false` | false | 0xC2 -number_integer | -9223372036854775808..-2147483649 | int64 | 0xD3 -number_integer | -2147483648..-32769 | int32 | 0xD2 -number_integer | -32768..-129 | int16 | 0xD1 -number_integer | -128..-33 | int8 | 0xD0 -number_integer | -32..-1 | negative fixint | 0xE0..0xFF -number_integer | 0..127 | positive fixint | 0x00..0x7F -number_integer | 128..255 | uint 8 | 0xCC -number_integer | 256..65535 | uint 16 | 0xCD -number_integer | 65536..4294967295 | uint 32 | 0xCE -number_integer | 4294967296..18446744073709551615 | uint 64 | 0xCF -number_unsigned | 0..127 | positive fixint | 0x00..0x7F -number_unsigned | 128..255 | uint 8 | 0xCC -number_unsigned | 256..65535 | uint 16 | 0xCD -number_unsigned | 65536..4294967295 | uint 32 | 0xCE -number_unsigned | 4294967296..18446744073709551615 | uint 64 | 0xCF -number_float | *any value representable by a float* | float 32 | 0xCA -number_float | *any value NOT representable by a float* | float 64 | 0xCB -string | *length*: 0..31 | fixstr | 0xA0..0xBF -string | *length*: 32..255 | str 8 | 0xD9 -string | *length*: 256..65535 | str 16 | 0xDA -string | *length*: 65536..4294967295 | str 32 | 0xDB -array | *size*: 0..15 | fixarray | 0x90..0x9F -array | *size*: 16..65535 | array 16 | 0xDC -array | *size*: 65536..4294967295 | array 32 | 0xDD -object | *size*: 0..15 | fix map | 0x80..0x8F -object | *size*: 16..65535 | map 16 | 0xDE -object | *size*: 65536..4294967295 | map 32 | 0xDF -binary | *size*: 0..255 | bin 8 | 0xC4 -binary | *size*: 256..65535 | bin 16 | 0xC5 -binary | *size*: 65536..4294967295 | bin 32 | 0xC6 - -!!! success "Complete mapping" - - The mapping is **complete** in the sense that any JSON value type can be converted to a MessagePack value. - - Any MessagePack output created by `to_msgpack` can be successfully parsed by `from_msgpack`. - -!!! warning "Size constraints" - - The following values can **not** be converted to a MessagePack value: - - - strings with more than 4294967295 bytes - - byte strings with more than 4294967295 bytes - - arrays with more than 4294967295 elements - - objects with more than 4294967295 elements - -!!! info "NaN/infinity handling" - - If NaN or Infinity are stored inside a JSON number, they are serialized properly. function which serializes NaN or Infinity to `null`. - -??? example - - ```cpp - --8<-- "examples/to_msgpack.cpp" - ``` - - Output: - - ```c - --8<-- "examples/to_msgpack.output" - ``` - -## Deserialization - -The library maps MessagePack types to JSON value types as follows: - -MessagePack type | JSON value type | first byte ----------------- | --------------- | ---------- -positive fixint | number_unsigned | 0x00..0x7F -fixmap | object | 0x80..0x8F -fixarray | array | 0x90..0x9F -fixstr | string | 0xA0..0xBF -nil | `null` | 0xC0 -false | `false` | 0xC2 -true | `true` | 0xC3 -float 32 | number_float | 0xCA -float 64 | number_float | 0xCB -uint 8 | number_unsigned | 0xCC -uint 16 | number_unsigned | 0xCD -uint 32 | number_unsigned | 0xCE -uint 64 | number_unsigned | 0xCF -int 8 | number_integer | 0xD0 -int 16 | number_integer | 0xD1 -int 32 | number_integer | 0xD2 -int 64 | number_integer | 0xD3 -str 8 | string | 0xD9 -str 16 | string | 0xDA -str 32 | string | 0xDB -array 16 | array | 0xDC -array 32 | array | 0xDD -map 16 | object | 0xDE -map 32 | object | 0xDF -bin 8 | binary | 0xC4 -bin 16 | binary | 0xC5 -bin 32 | binary | 0xC6 -ext 8 | binary | 0xC7 -ext 16 | binary | 0xC8 -ext 32 | binary | 0xC9 -fixext 1 | binary | 0xD4 -fixext 2 | binary | 0xD5 -fixext 4 | binary | 0xD6 -fixext 8 | binary | 0xD7 -fixext 16 | binary | 0xD8 -negative fixint | number_integer | 0xE0-0xFF - -!!! info - - Any MessagePack output created by `to_msgpack` can be successfully parsed by `from_msgpack`. - - -??? example - - ```cpp - --8<-- "examples/from_msgpack.cpp" - ``` - - Output: - - ```json - --8<-- "examples/from_msgpack.output" - ``` diff --git a/external_imported/json/doc/mkdocs/docs/features/binary_formats/ubjson.md b/external_imported/json/doc/mkdocs/docs/features/binary_formats/ubjson.md deleted file mode 100644 index 050b4ec59..000000000 --- a/external_imported/json/doc/mkdocs/docs/features/binary_formats/ubjson.md +++ /dev/null @@ -1,133 +0,0 @@ -# UBJSON - -Universal Binary JSON (UBJSON) is a binary form directly imitating JSON, but requiring fewer bytes of data. It aims to achieve the generality of JSON, combined with being much easier to process than JSON. - -!!! abstract "References" - - - [UBJSON Website](http://ubjson.org) - -## Serialization - -The library uses the following mapping from JSON values types to UBJSON types according to the UBJSON specification: - -JSON value type | value/range | UBJSON type | marker ---------------- | --------------------------------- | ----------- | ------ -null | `null` | null | `Z` -boolean | `true` | true | `T` -boolean | `false` | false | `F` -number_integer | -9223372036854775808..-2147483649 | int64 | `L` -number_integer | -2147483648..-32769 | int32 | `l` -number_integer | -32768..-129 | int16 | `I` -number_integer | -128..127 | int8 | `i` -number_integer | 128..255 | uint8 | `U` -number_integer | 256..32767 | int16 | `I` -number_integer | 32768..2147483647 | int32 | `l` -number_integer | 2147483648..9223372036854775807 | int64 | `L` -number_unsigned | 0..127 | int8 | `i` -number_unsigned | 128..255 | uint8 | `U` -number_unsigned | 256..32767 | int16 | `I` -number_unsigned | 32768..2147483647 | int32 | `l` -number_unsigned | 2147483648..9223372036854775807 | int64 | `L` -number_unsigned | 2147483649..18446744073709551615 | high-precision | `H` -number_float | *any value* | float64 | `D` -string | *with shortest length indicator* | string | `S` -array | *see notes on optimized format* | array | `[` -object | *see notes on optimized format* | map | `{` - -!!! success "Complete mapping" - - The mapping is **complete** in the sense that any JSON value type can be converted to a UBJSON value. - - Any UBJSON output created by `to_ubjson` can be successfully parsed by `from_ubjson`. - -!!! warning "Size constraints" - - The following values can **not** be converted to a UBJSON value: - - - strings with more than 9223372036854775807 bytes (theoretical) - -!!! info "Unused UBJSON markers" - - The following markers are not used in the conversion: - - - `Z`: no-op values are not created. - - `C`: single-byte strings are serialized with `S` markers. - -!!! info "NaN/infinity handling" - - If NaN or Infinity are stored inside a JSON number, they are - serialized properly. This behavior differs from the `dump()` - function which serializes NaN or Infinity to `null`. - -!!! info "Optimized formats" - - The optimized formats for containers are supported: Parameter - `use_size` adds size information to the beginning of a container and - removes the closing marker. Parameter `use_type` further checks - whether all elements of a container have the same type and adds the - type marker to the beginning of the container. The `use_type` - parameter must only be used together with `use_size = true`. - - Note that `use_size = true` alone may result in larger representations - - the benefit of this parameter is that the receiving side is - immediately informed on the number of elements of the container. - -!!! info "Binary values" - - If the JSON data contains the binary type, the value stored is a list - of integers, as suggested by the UBJSON documentation. In particular, - this means that serialization and the deserialization of a JSON - containing binary values into UBJSON and back will result in a - different JSON object. - - -??? example - - ```cpp - --8<-- "examples/to_ubjson.cpp" - ``` - - Output: - - ```c - --8<-- "examples/to_ubjson.output" - ``` - -## Deserialization - -The library maps UBJSON types to JSON value types as follows: - -UBJSON type | JSON value type | marker ------------ | --------------------------------------- | ------ -no-op | *no value, next value is read* | `N` -null | `null` | `Z` -false | `false` | `F` -true | `true` | `T` -float32 | number_float | `d` -float64 | number_float | `D` -uint8 | number_unsigned | `U` -int8 | number_integer | `i` -int16 | number_integer | `I` -int32 | number_integer | `l` -int64 | number_integer | `L` -string | string | `S` -char | string | `C` -array | array (optimized values are supported) | `[` -object | object (optimized values are supported) | `{` - -!!! success "Complete mapping" - - The mapping is **complete** in the sense that any UBJSON value can be converted to a JSON value. - - -??? example - - ```cpp - --8<-- "examples/from_ubjson.cpp" - ``` - - Output: - - ```json - --8<-- "examples/from_ubjson.output" - ``` diff --git a/external_imported/json/doc/mkdocs/docs/features/binary_values.md b/external_imported/json/doc/mkdocs/docs/features/binary_values.md deleted file mode 100644 index 4716aac7e..000000000 --- a/external_imported/json/doc/mkdocs/docs/features/binary_values.md +++ /dev/null @@ -1,295 +0,0 @@ -# Binary Values - -The library implements several [binary formats](binary_formats/index.md) that encode JSON in an efficient way. Most of these formats support binary values; that is, values that have semantics define outside the library and only define a sequence of bytes to be stored. - -JSON itself does not have a binary value. As such, binary values are an extension that this library implements to store values received by a binary format. Binary values are never created by the JSON parser, and are only part of a serialized JSON text if they have been created manually or via a binary format. - -## API for binary values - -```plantuml -class json::binary_t { - -- setters -- - +void set_subtype(std::uint8_t subtype) - +void clear_subtype() - -- getters -- - +std::uint8_t subtype() const - +bool has_subtype() const -} - -"std::vector" <|-- json::binary_t -``` - -By default, binary values are stored as `std::vector`. This type can be changed by providing a template parameter to the `basic_json` type. To store binary subtypes, the storage type is extended and exposed as `json::binary_t`: - -```cpp -auto binary = json::binary_t({0xCA, 0xFE, 0xBA, 0xBE}); -auto binary_with_subtype = json::binary_t({0xCA, 0xFE, 0xBA, 0xBE}, 42); -``` - -There are several convenience functions to check and set the subtype: - -```cpp -binary.has_subtype(); // returns false -binary_with_subtype.has_subtype(); // returns true - -binary_with_subtype.clear_subtype(); -binary_with_subtype.has_subtype(); // returns true - -binary_with_subtype.set_subtype(42); -binary.set_subtype(23); - -binary.subtype(); // returns 23 -``` - -As `json::binary_t` is subclassing `std::vector`, all member functions are available: - -```cpp -binary.size(); // returns 4 -binary[1]; // returns 0xFE -``` - -JSON values can be constructed from `json::binary_t`: - -```cpp -json j = binary; -``` - -Binary values are primitive values just like numbers or strings: - -```cpp -j.is_binary(); // returns true -j.is_primitive(); // returns true -``` - -Given a binary JSON value, the `binary_t` can be accessed by reference as via `get_binary()`: - -```cpp -j.get_binary().has_subtype(); // returns true -j.get_binary().size(); // returns 4 -``` - -For convencience, binary JSON values can be constructed via `json::binary`: - -```cpp -auto j2 = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 23); -auto j3 = json::binary({0xCA, 0xFE, 0xBA, 0xBE}); - -j2 == j; // returns true -j3.get_binary().has_subtype(); // returns false -``` - - - -## Serialization - -Binary values are serialized differently according to the formats. - -### JSON - -JSON does not have a binary type, and this library does not introduce a new type as this would break conformance. Instead, binary values are serialized as an object with two keys: `bytes` holds an array of integers, and `subtype` is an integer or `null`. - -??? example - - Code: - - ```cpp - // create a binary value of subtype 42 - json j; - j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42); - - // serialize to standard output - std::cout << j.dump(2) << std::endl; - ``` - - Output: - - ```json - { - "binary": { - "bytes": [202, 254, 186, 190], - "subtype": 42 - } - } - ``` - -!!! warning "No roundtrip for binary values" - - The JSON parser will not parse the objects generated by binary values back to binary values. This is by design to remain standards compliant. Serializing binary values to JSON is only implemented for debugging purposes. - -### BSON - -[BSON](binary_formats/bson.md) supports binary values and subtypes. If a subtype is given, it is used and added as unsigned 8-bit integer. If no subtype is given, the generic binary subtype 0x00 is used. - -??? example - - Code: - - ```cpp - // create a binary value of subtype 42 - json j; - j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42); - - // convert to BSON - auto v = json::to_bson(j); - ``` - - `v` is a `std::vector` with the following 22 elements: - - ```c - 0x16 0x00 0x00 0x00 // number of bytes in the document - 0x05 // binary value - 0x62 0x69 0x6E 0x61 0x72 0x79 0x00 // key "binary" + null byte - 0x04 0x00 0x00 0x00 // number of bytes - 0x2a // subtype - 0xCA 0xFE 0xBA 0xBE // content - 0x00 // end of the document - ``` - - Note that the serialization preserves the subtype, and deserializing `v` would yield the following value: - - ```json - { - "binary": { - "bytes": [202, 254, 186, 190], - "subtype": 42 - } - } - ``` - -### CBOR - -[CBOR](binary_formats/cbor.md) supports binary values, but no subtypes. Subtypes will be serialized as tags. Any binary value will be serialized as byte strings. The library will choose the smallest representation using the length of the byte array. - -??? example - - Code: - - ```cpp - // create a binary value of subtype 42 - json j; - j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42); - - // convert to CBOR - auto v = json::to_cbor(j); - ``` - - `v` is a `std::vector` with the following 15 elements: - - ```c - 0xA1 // map(1) - 0x66 // text(6) - 0x62 0x69 0x6E 0x61 0x72 0x79 // "binary" - 0xD8 0x2A // tag(42) - 0x44 // bytes(4) - 0xCA 0xFE 0xBA 0xBE // content - ``` - - Note that the subtype is serialized as tag. However, parsing tagged values yield a parse error unless `json::cbor_tag_handler_t::ignore` is passed to `json::from_cbor`. - - ```json - { - "binary": { - "bytes": [202, 254, 186, 190], - "subtype": null - } - } - ``` - -### MessagePack - -[MessagePack](binary_formats/messagepack.md) supports binary values and subtypes. If a subtype is given, the ext family is used. The library will choose the smallest representation among fixext1, fixext2, fixext4, fixext8, ext8, ext16, and ext32. The subtype is then added as singed 8-bit integer. - -If no subtype is given, the bin family (bin8, bin16, bin32) is used. - -??? example - - Code: - - ```cpp - // create a binary value of subtype 42 - json j; - j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42); - - // convert to MessagePack - auto v = json::to_msgpack(j); - ``` - - `v` is a `std::vector` with the following 14 elements: - - ```c - 0x81 // fixmap1 - 0xA6 // fixstr6 - 0x62 0x69 0x6E 0x61 0x72 0x79 // "binary" - 0xD6 // fixext4 - 0x2A // subtype - 0xCA 0xFE 0xBA 0xBE // content - ``` - - Note that the serialization preserves the subtype, and deserializing `v` would yield the following value: - - ```json - { - "binary": { - "bytes": [202, 254, 186, 190], - "subtype": 42 - } - } - ``` - -### UBJSON - -[UBJSON](binary_formats/ubjson.md) neither supports binary values nor subtypes, and proposes to serialize binary values as array of uint8 values. This translation is implemented by the library. - -??? example - - Code: - - ```cpp - // create a binary value of subtype 42 (will be ignored in UBJSON) - json j; - j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42); - - // convert to UBJSON - auto v = json::to_msgpack(j); - ``` - - `v` is a `std::vector` with the following 20 elements: - - ```c - 0x7B // '{' - 0x69 0x06 // i 6 (length of the key) - 0x62 0x69 0x6E 0x61 0x72 0x79 // "binary" - 0x5B // '[' - 0x55 0xCA 0x55 0xFE 0x55 0xBA 0x55 0xBE // content (each byte prefixed with 'U') - 0x5D // ']' - 0x7D // '}' - ``` - - The following code uses the type and size optimization for UBJSON: - - ```cpp - // convert to UBJSON using the size and type optimization - auto v = json::to_ubjson(j, true, true); - ``` - - The resulting vector has 23 elements; the optimization is not effective for examples with few values: - - ```c - 0x7B // '{' - 0x24 // '$' type of the object elements - 0x5B // '[' array - 0x23 0x69 0x01 // '#' i 1 number of object elements - 0x69 0x06 // i 6 (length of the key) - 0x62 0x69 0x6E 0x61 0x72 0x79 // "binary" - 0x24 0x55 // '$' 'U' type of the array elements: unsinged integers - 0x23 0x69 0x04 // '#' i 4 number of array elements - 0xCA 0xFE 0xBA 0xBE // content - ``` - - Note that subtype (42) is **not** serialized and that UBJSON has **no binary type**, and deserializing `v` would yield the following value: - - ```json - { - "binary": [202, 254, 186, 190] - } - ``` diff --git a/external_imported/json/doc/mkdocs/docs/features/element_access/checked_access.md b/external_imported/json/doc/mkdocs/docs/features/element_access/checked_access.md deleted file mode 100644 index 19c75254d..000000000 --- a/external_imported/json/doc/mkdocs/docs/features/element_access/checked_access.md +++ /dev/null @@ -1,77 +0,0 @@ -# Checked access: at - -## Overview - -The `#!cpp at()` member function performs checked access; that is, it returns a reference to the desired value if it exists and throws a [`basic_json::out_of_range` exception](../../home/exceptions.md#out-of-range) otherwise. - -??? example - - Consider the following JSON value: - - ```json - { - "name": "Mary Smith", - "age": 42, - "hobbies": ["hiking", "reading"] - } - ``` - - Assume the value is parsed to a `json` variable `j`. - - | expression | value | - | ---------- | ----- | - | `#!cpp j` | `#!json {"name": "Mary Smith", "age": 42, "hobbies": ["hiking", "reading"]}` | - | `#!cpp j.at("name")` | `#!json "Mary Smith"` | - | `#!cpp j.at("age")` | `#!json 42` | - | `#!cpp j.at("hobbies")` | `#!json ["hiking", "reading"]` | - | `#!cpp j.at("hobbies").at(0)` | `#!json "hiking"` | - | `#!cpp j.at("hobbies").at(1)` | `#!json "reading"` | - -The return value is a reference, so it can be modify the original value. - -??? example - - ```cpp - j.at("name") = "John Smith"; - ``` - - This code produces the following JSON value: - - ```json - { - "name": "John Smith", - "age": 42, - "hobbies": ["hiking", "reading"] - } - ``` - -When accessing an invalid index (i.e., an index greater than or equal to the array size) or the passed object key is non-existing, an exception is thrown. - -??? example - - ```cpp - j.at("hobbies").at(3) = "cooking"; - ``` - - This code produces the following exception: - - ``` - [json.exception.out_of_range.401] array index 3 is out of range - ``` - -## Notes - - -!!! failure "Exceptions" - - - `at` can only be used with objects (with a string argument) or with arrays (with a numeric argument). For other types, a [`basic_json::type_error`](../../home/exceptions.md#jsonexceptiontype_error304) is thrown. - - [`basic_json::out_of_range` exception](../../home/exceptions.md#out-of-range) exceptions are thrown if the provided key is not found in an object or the provided index is invalid. - -## Summary - -| scenario | non-const value | const value | -| -------- | ------------- | ----------- | -| access to existing object key | reference to existing value is returned | const reference to existing value is returned | -| access to valid array index | reference to existing value is returned | const reference to existing value is returned | -| access to non-existing object key | `basic_json::out_of_range` exception is thrown | `basic_json::out_of_range` exception is thrown | -| access to invalid array index | `basic_json::out_of_range` exception is thrown | `basic_json::out_of_range` exception is thrown | diff --git a/external_imported/json/doc/mkdocs/docs/features/element_access/index.md b/external_imported/json/doc/mkdocs/docs/features/element_access/index.md deleted file mode 100644 index 1755fe8c6..000000000 --- a/external_imported/json/doc/mkdocs/docs/features/element_access/index.md +++ /dev/null @@ -1,9 +0,0 @@ -# Overview - -There are many ways elements in a JSON value can be accessed: - -- unchecked access via [`operator[]`](unchecked_access.md) -- checked access via [`at`](checked_access.md) -- access with default value via [`value`](default_value.md) -- iterators -- JSON pointers diff --git a/external_imported/json/doc/mkdocs/docs/features/element_access/unchecked_access.md b/external_imported/json/doc/mkdocs/docs/features/element_access/unchecked_access.md deleted file mode 100644 index fff7f2b32..000000000 --- a/external_imported/json/doc/mkdocs/docs/features/element_access/unchecked_access.md +++ /dev/null @@ -1,102 +0,0 @@ -# Unchecked access: operator[] - -## Overview - -Elements in a JSON object and a JSON array can be accessed via `#!cpp operator[]` similar to a `#!cpp std::map` and a `#!cpp std::vector`, respectively. - -??? example - - Consider the following JSON value: - - ```json - { - "name": "Mary Smith", - "age": 42, - "hobbies": ["hiking", "reading"] - } - ``` - - Assume the value is parsed to a `json` variable `j`. - - | expression | value | - | ---------- | ----- | - | `#!cpp j` | `#!json {"name": "Mary Smith", "age": 42, "hobbies": ["hiking", "reading"]}` | - | `#!cpp j["name"]` | `#!json "Mary Smith"` | - | `#!cpp j["age"]` | `#!json 42` | - | `#!cpp j["hobbies"]` | `#!json ["hiking", "reading"]` | - | `#!cpp j["hobbies"][0]` | `#!json "hiking"` | - | `#!cpp j["hobbies"][1]` | `#!json "reading"` | - -The return value is a reference, so it can be modify the original value. In case the passed object key is non-existing, a `#!json null` value is inserted which can be immediately be overwritten. - -??? example - - ```cpp - j["name"] = "John Smith"; - j["maidenName"] = "Jones"; - ``` - - This code produces the following JSON value: - - ```json - { - "name": "John Smith", - "maidenName": "Jones", - "age": 42, - "hobbies": ["hiking", "reading"] - } - ``` - -When accessing an invalid index (i.e., an index greater than or equal to the array size), the JSON array is resized such that the passed index is the new maximal index. Intermediate values are filled with `#!json null`. - -??? example - - ```cpp - j["hobbies"][0] = "running"; - j["hobbies"][3] = "cooking"; - ``` - - This code produces the following JSON value: - - ```json - { - "name": "John Smith", - "maidenName": "Jones", - "age": 42, - "hobbies": ["running", "reading", null, "cooking"] - } - ``` - -## Notes - -!!! info "Design rationale" - - The library behaves differently to `#!cpp std::vector` and `#!cpp std::map`: - - - `#!cpp std::vector::operator[]` never inserts a new element. - - `#!cpp std::map::operator[]` is not available for const values. - - The type `#!cpp json` wraps all JSON value types. It would be impossible to remove `operator[]` for const objects. At the same time, inserting elements for non-const objects is really convenient as it avoids awkward `insert` calls. To this end, we decided to have an inserting non-const behavior for both arrays and objects. - -!!! info - - The access is unchecked. In case the passed object key does not exist or the passed array index is invalid, no exception is thrown. - -!!! danger - - - It is **undefined behavior** to access a const object with a non-existing key. - - It is **undefined behavior** to access a const array with an invalid index. - - In debug mode, an **assertion** will fire in both cases. You can disable assertions by defining the preprocessor symbol `#!cpp NDEBUG` or redefine the macro [`JSON_ASSERT(x)`](../macros.md#json_assertx). - -!!! failure "Exceptions" - - `operator[]` can only be used with objects (with a string argument) or with arrays (with a numeric argument). For other types, a [`basic_json::type_error`](../../home/exceptions.md#jsonexceptiontype_error305) is thrown. - -## Summary - -| scenario | non-const value | const value | -| -------- | ------------- | ----------- | -| access to existing object key | reference to existing value is returned | const reference to existing value is returned | -| access to valid array index | reference to existing value is returned | const reference to existing value is returned | -| access to non-existing object key | reference to newly inserted `#!json null` value is returned | **undefined behavior**; assertion in debug mode | -| access to invalid array index | reference to newly inserted `#!json null` value is returned; any index between previous maximal index and passed index are filled with `#!json null` | **undefined behavior**; assertion in debug mode | diff --git a/external_imported/json/doc/mkdocs/docs/features/enum_conversion.md b/external_imported/json/doc/mkdocs/docs/features/enum_conversion.md deleted file mode 100644 index 1c1bb8032..000000000 --- a/external_imported/json/doc/mkdocs/docs/features/enum_conversion.md +++ /dev/null @@ -1,53 +0,0 @@ -# Specializing enum conversion - -By default, enum values are serialized to JSON as integers. In some cases this could result in undesired behavior. If an enum is modified or re-ordered after data has been serialized to JSON, the later de-serialized JSON data may be undefined or a different enum value than was originally intended. - -It is possible to more precisely specify how a given enum is mapped to and from JSON as shown below: - -```cpp -// example enum type declaration -enum TaskState { - TS_STOPPED, - TS_RUNNING, - TS_COMPLETED, - TS_INVALID=-1, -}; - -// map TaskState values to JSON as strings -NLOHMANN_JSON_SERIALIZE_ENUM( TaskState, { - {TS_INVALID, nullptr}, - {TS_STOPPED, "stopped"}, - {TS_RUNNING, "running"}, - {TS_COMPLETED, "completed"}, -}) -``` - -The `NLOHMANN_JSON_SERIALIZE_ENUM()` macro declares a set of `to_json()` / `from_json()` functions for type `TaskState` while avoiding repetition and boilerplate serialization code. - -## Usage - -```cpp -// enum to JSON as string -json j = TS_STOPPED; -assert(j == "stopped"); - -// json string to enum -json j3 = "running"; -assert(j3.get() == TS_RUNNING); - -// undefined json value to enum (where the first map entry above is the default) -json jPi = 3.14; -assert(jPi.get() == TS_INVALID ); -``` - -## Notes - -Just as in [Arbitrary Type Conversions](#arbitrary-types-conversions) above, - -- `NLOHMANN_JSON_SERIALIZE_ENUM()` MUST be declared in your enum type's namespace (which can be the global namespace), or the library will not be able to locate it and it will default to integer serialization. -- It MUST be available (e.g., proper headers must be included) everywhere you use the conversions. - -Other Important points: - -- When using `get()`, undefined JSON values will default to the first pair specified in your map. Select this default pair carefully. -- If an enum or JSON value is specified more than once in your map, the first matching occurrence from the top of the map will be returned when converting to or from JSON. diff --git a/external_imported/json/doc/mkdocs/docs/features/json_pointer.md b/external_imported/json/doc/mkdocs/docs/features/json_pointer.md deleted file mode 100644 index b95c5bc02..000000000 --- a/external_imported/json/doc/mkdocs/docs/features/json_pointer.md +++ /dev/null @@ -1,15 +0,0 @@ -# JSON Pointer - -The library supports **JSON Pointer** ([RFC 6901](https://tools.ietf.org/html/rfc6901)) as alternative means to address structured values. - -```cpp -// a JSON value -json j_original = R"({ - "baz": ["one", "two", "three"], - "foo": "bar" -})"_json; - -// access members with a JSON pointer (RFC 6901) -j_original["/baz/1"_json_pointer]; -// "two" -``` diff --git a/external_imported/json/doc/mkdocs/docs/features/macros.md b/external_imported/json/doc/mkdocs/docs/features/macros.md deleted file mode 100644 index b468c091a..000000000 --- a/external_imported/json/doc/mkdocs/docs/features/macros.md +++ /dev/null @@ -1,89 +0,0 @@ -# Supported Macros - -Some aspects of the library can be configured by defining preprocessor macros before including the `json.hpp` header. - -## `JSON_ASSERT(x)` - -The default value is `#!cpp assert(x)`. - -## `JSON_CATCH_USER(exception)` - -This macro overrides `#!cpp catch` calls inside the library. The argument is the type of the exception to catch. As of version 3.8.0, the library only catches `std::out_of_range` exceptions internally to rethrow them as [`json::out_of_range`](../home/exceptions.md#out-of-range) exceptions. The macro is always followed by a scope. - -See [Switch off exceptions](../home/exceptions.md#switch-off-exceptions) for an example. - -## `JSON_DIAGNOSTICS` - -This macro enables extended diagnostics for exception messages. Possible values are `1` to enable or `0` to disable (default). - -When enabled, exception messages contain a [JSON Pointer](json_pointer.md) to the JSON value that triggered the exception, see [Extended diagnostic messages](../home/exceptions.md#extended-diagnostic-messages) for an example. Note that enabling this macro increases the size of every JSON value by one pointer and adds some runtime overhead. - -The diagnostics messages can also be controlled with the CMake option `JSON_Diagnostics` (`OFF` by default) which sets `JSON_DIAGNOSTICS` accordingly. - -## `JSON_NOEXCEPTION` - -Exceptions can be switched off by defining the symbol `JSON_NOEXCEPTION`. -When defining `JSON_NOEXCEPTION`, `#!cpp try` is replaced by `#!cpp if (true)`, -`#!cpp catch` is replaced by `#!cpp if (false)`, and `#!cpp throw` is replaced by `#!cpp std::abort()`. - -The same effect is achieved by setting the compiler flag `-fno-exceptions`. - -## `JSON_SKIP_UNSUPPORTED_COMPILER_CHECK` - -When defined, the library will not create a compile error when a known unsupported compiler is detected. This allows to use the library with compilers that do not fully support C++11 and may only work if unsupported features are not used. - -## `JSON_THROW_USER(exception)` - -This macro overrides `#!cpp throw` calls inside the library. The argument is the exception to be thrown. Note that `JSON_THROW_USER` should leave the current scope (e.g., by throwing or aborting), as continuing after it may yield undefined behavior. - -See [Switch off exceptions](../home/exceptions.md#switch-off-exceptions) for an example. - -## `JSON_TRY_USER` - -This macro overrides `#!cpp try` calls inside the library. It has no arguments and is always followed by a scope. - -See [Switch off exceptions](../home/exceptions.md#switch-off-exceptions) for an example. - -## `JSON_USE_IMPLICIT_CONVERSIONS` - -When defined to `0`, implicit conversions are switched off. By default, implicit conversions are switched on. - -??? example - - This is an example for an implicit conversion: - - ```cpp - json j = "Hello, world!"; - std::string s = j; - ``` - - When `JSON_USE_IMPLICIT_CONVERSIONS` is defined to `0`, the code above does no longer compile. Instead, it must be written like this: - - ```cpp - json j = "Hello, world!"; - auto s = j.get(); - ``` - -Implicit conversions can also be controlled with the CMake option `JSON_ImplicitConversions` (`ON` by default) which sets `JSON_USE_IMPLICIT_CONVERSIONS` accordingly. - -## `NLOHMANN_DEFINE_TYPE_INTRUSIVE(type, member...)` - -This macro can be used to simplify the serialization/deserialization of types if (1) want to use a JSON object as serialization and (2) want to use the member variable names as object keys in that object. - -The macro is to be defined inside of the class/struct to create code for. Unlike [`NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`](#nlohmann_define_type_non_intrusivetype-member), it can access private members. -The first parameter is the name of the class/struct, and all remaining parameters name the members. - -See [Simplify your life with macros](arbitrary_types.md#simplify-your-life-with-macros) for an example. - -## `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(type, member...)` - -This macro can be used to simplify the serialization/deserialization of types if (1) want to use a JSON object as serialization and (2) want to use the member variable names as object keys in that object. - -The macro is to be defined inside of the namespace of the class/struct to create code for. Private members cannot be accessed. Use [`NLOHMANN_DEFINE_TYPE_INTRUSIVE`](#nlohmann_define_type_intrusivetype-member) in these scenarios. -The first parameter is the name of the class/struct, and all remaining parameters name the members. - -See [Simplify your life with macros](arbitrary_types.md#simplify-your-life-with-macros) for an example. - -## `NLOHMANN_JSON_SERIALIZE_ENUM(type, ...)` - -This macro simplifies the serialization/deserialization of enum types. See [Specializing enum conversion](enum_conversion.md) for more information. diff --git a/external_imported/json/doc/mkdocs/docs/features/object_order.md b/external_imported/json/doc/mkdocs/docs/features/object_order.md deleted file mode 100644 index 86bb253ba..000000000 --- a/external_imported/json/doc/mkdocs/docs/features/object_order.md +++ /dev/null @@ -1,67 +0,0 @@ -# Object Order - -The [JSON standard](https://tools.ietf.org/html/rfc8259.html) defines objects as "an unordered collection of zero or more name/value pairs". As such, an implementation does not need to preserve any specific order of object keys. - -The default type `nlohmann::json` uses a `std::map` to store JSON objects, and thus stores object keys **sorted alphabetically**. - -??? example - - ```cpp - #include - #include "json.hpp" - - using json = nlohmann::json; - - int main() - { - json j; - j["one"] = 1; - j["two"] = 2; - j["three"] = 3; - - std::cout << j.dump(2) << '\n'; - } - ``` - - Output: - - ```json - { - "one": 1, - "three": 3, - "two": 2 - } - ``` - -If you do want to preserve the **insertion order**, you can try the type [`nlohmann::ordered_json`](https://github.com/nlohmann/json/issues/2179). - -??? example - - ```cpp - #include - #include - - using ordered_json = nlohmann::ordered_json; - - int main() - { - ordered_json j; - j["one"] = 1; - j["two"] = 2; - j["three"] = 3; - - std::cout << j.dump(2) << '\n'; - } - ``` - - Output: - - ```json - { - "one": 1, - "two": 2, - "three": 3 - } - ``` - -Alternatively, you can use a more sophisticated ordered map like [`tsl::ordered_map`](https://github.com/Tessil/ordered-map) ([integration](https://github.com/nlohmann/json/issues/546#issuecomment-304447518)) or [`nlohmann::fifo_map`](https://github.com/nlohmann/fifo_map) ([integration](https://github.com/nlohmann/json/issues/485#issuecomment-333652309)). diff --git a/external_imported/json/doc/mkdocs/docs/features/parsing/index.md b/external_imported/json/doc/mkdocs/docs/features/parsing/index.md deleted file mode 100644 index 5cf59bfe9..000000000 --- a/external_imported/json/doc/mkdocs/docs/features/parsing/index.md +++ /dev/null @@ -1,13 +0,0 @@ -# Overview - -!!! note - - This page is under construction. - -## Input - -## SAX vs. DOM parsing - -## Exceptions - -See [parsing and exceptions](parse_exceptions.md). diff --git a/external_imported/json/doc/mkdocs/docs/features/parsing/parser_callbacks.md b/external_imported/json/doc/mkdocs/docs/features/parsing/parser_callbacks.md deleted file mode 100644 index dbf88849f..000000000 --- a/external_imported/json/doc/mkdocs/docs/features/parsing/parser_callbacks.md +++ /dev/null @@ -1,79 +0,0 @@ -# Parser Callbacks - -## Overview - -With a parser callback function, the result of parsing a JSON text can be influenced. When passed to `parse`, it is called on certain events -(passed as `parse_event_t` via parameter `event`) with a set recursion depth `depth` and context JSON value `parsed`. The return value of the -callback function is a boolean indicating whether the element that emitted the callback shall be kept or not. - -The type of the callback function is: - -```cpp -template -using parser_callback_t = - std::function; -``` - - -## Callback event types - -We distinguish six scenarios (determined by the event type) in which the callback function can be called. The following table describes the values -of the parameters `depth`, `event`, and `parsed`. - -parameter `event` | description | parameter `depth` | parameter `parsed` ------------------- | ----------- | ------------------ | ------------------- -`parse_event_t::object_start` | the parser read `{` and started to process a JSON object | depth of the parent of the JSON object | a JSON value with type discarded -`parse_event_t::key` | the parser read a key of a value in an object | depth of the currently parsed JSON object | a JSON string containing the key -`parse_event_t::object_end` | the parser read `}` and finished processing a JSON object | depth of the parent of the JSON object | the parsed JSON object -`parse_event_t::array_start` | the parser read `[` and started to process a JSON array | depth of the parent of the JSON array | a JSON value with type discarded -`parse_event_t::array_end` | the parser read `]` and finished processing a JSON array | depth of the parent of the JSON array | the parsed JSON array -`parse_event_t::value` | the parser finished reading a JSON value | depth of the value | the parsed JSON value - -??? example - - When parsing the following JSON text, - - ```json - { - "name": "Berlin", - "location": [ - 52.519444, - 13.406667 - ] - } - ``` - - these calls are made to the callback function: - - | event | depth | parsed | - | -------------- | ----- | ------ | - | `object_start` | 0 | *discarded* | - | `key` | 1 | `#!json "name"` | - | `value` | 1 | `#!json "Berlin"` | - | `key` | 1 | `#!json "location"` | - | `array_start` | 1 | *discarded* | - | `value` | 2 | `#!json 52.519444` | - | `value` | 2 | `#!json 13.406667` | - | `array_end` | 1 | `#!json [52.519444,13.406667]` | - | `object_end` | 0 | `#!json {"location":[52.519444,13.406667],"name":"Berlin"}` | - -## Return value - -Discarding a value (i.e., returning `#!c false`) has different effects depending on the context in which function was called: - -- Discarded values in structured types are skipped. That is, the parser will behave as if the discarded value was never read. -- In case a value outside a structured type is skipped, it is replaced with `#!json null`. This case happens if the top-level element is skipped. - -??? example - - The example below demonstrates the `parse()` function with and without callback function. - - ```cpp - --8<-- "examples/parse__string__parser_callback_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/parse__string__parser_callback_t.output" - ``` diff --git a/external_imported/json/doc/mkdocs/docs/features/types.md b/external_imported/json/doc/mkdocs/docs/features/types.md deleted file mode 100644 index 94e40cbaf..000000000 --- a/external_imported/json/doc/mkdocs/docs/features/types.md +++ /dev/null @@ -1,267 +0,0 @@ -# Types - -This page gives an overview how JSON values are stored and how this can be configured. - -## Overview - -By default, JSON values are stored as follows: - -| JSON type | C++ type | -| --------- | -------- | -| object | `std::map` | -| array | `std::vector` | -| null | `std::nullptr_t` | -| string | `std::string` | -| boolean | `bool` | -| number | `std::int64_t`, `std::uint64_t`, and `double` | - -Note there are three different types for numbers - when parsing JSON text, the best fitting type is chosen. - -## Storage - -```plantuml -enum value_t { - null - object - array - string - boolean - number_integer - number_unsigned - number_float - binary - discarded -} - -class json_value << (U,orchid) >> { - object_t* object - array_t* array - string_t* string - binary_t* binary - boolean_t boolean - number_integer_t number_integer - number_unsigned_t number_unsigned - number_float_t number_float -} - -class basic_json { - -- type and value -- - value_t m_type - json_value m_value - -- derived types -- - + typedef object_t - + typedef array_t - + typedef binary_t - + typedef boolean_t - + typedef number_integer_t - + typedef number_unsigned_t - + typedef number_float_t -} - -basic_json .. json_value -basic_json .. value_t -``` - -## Template arguments - -The data types to store a JSON value are derived from the template arguments passed to class `basic_json`: - -```cpp -template< - template class ObjectType = std::map, - template class ArrayType = std::vector, - class StringType = std::string, - class BooleanType = bool, - class NumberIntegerType = std::int64_t, - class NumberUnsignedType = std::uint64_t, - class NumberFloatType = double, - template class AllocatorType = std::allocator, - template class JSONSerializer = adl_serializer, - class BinaryType = std::vector -> -class basic_json; -``` - -Type `json` is an alias for `basic_json<>` and uses the default types. - -From the template arguments, the following types are derived: - -```cpp -using object_comparator_t = std::less<>; -using object_t = ObjectType>>; - -using array_t = ArrayType>; - -using string_t = StringType; - -using boolean_t = BooleanType; - -using number_integer_t = NumberIntegerType; -using number_unsigned_t = NumberUnsignedType; -using number_float_t = NumberFloatType; - -using binary_t = nlohmann::byte_container_with_subtype; -``` - - -## Objects - -[RFC 7159](http://rfc7159.net/rfc7159) describes JSON objects as follows: - -> An object is an unordered collection of zero or more name/value pairs, where a name is a string and a value is a string, number, boolean, null, object, or array. - -### Default type - -With the default values for *ObjectType* (`std::map`), *StringType* (`std::string`), and *AllocatorType* (`std::allocator`), the default value for `object_t` is: - -```cpp -std::map< - std::string, // key_type - basic_json, // value_type - std::less<>, // key_compare - std::allocator> // allocator_type -> -``` - -### Behavior - -The choice of `object_t` influences the behavior of the JSON class. With the default type, objects have the following behavior: - -- When all names are unique, objects will be interoperable in the sense that all software implementations receiving that object will agree on the name-value mappings. -- When the names within an object are not unique, it is unspecified which one of the values for a given key will be chosen. For instance, `#!json {"key": 2, "key": 1}` could be equal to either `#!json {"key": 1}` or `#!json {"key": 2}`. -- Internally, name/value pairs are stored in lexicographical order of the names. Objects will also be serialized (see `dump`) in this order. For instance, both `#!json {"b": 1, "a": 2}` and `#!json {"a": 2, "b": 1}` will be stored and serialized as `#!json {"a": 2, "b": 1}`. -- When comparing objects, the order of the name/value pairs is irrelevant. This makes objects interoperable in the sense that they will not be affected by these differences. For instance, `#!json {"b": 1, "a": 2}` and `#!json {"a": 2, "b": 1}` will be treated as equal. - -### Key order - -The order name/value pairs are added to the object is *not* preserved by the library. Therefore, iterating an object may return name/value pairs in a different order than they were originally stored. In fact, keys will be traversed in alphabetical order as `std::map` with `std::less` is used by default. Please note this behavior conforms to [RFC 7159](http://rfc7159.net/rfc7159), because any order implements the specified "unordered" nature of JSON objects. - -### Limits - -[RFC 7159](http://rfc7159.net/rfc7159) specifies: - -> An implementation may set limits on the maximum depth of nesting. - -In this class, the object's limit of nesting is not explicitly constrained. However, a maximum depth of nesting may be introduced by the compiler or runtime environment. A theoretical limit can be queried by calling the `max_size` function of a JSON object. - -### Storage - -Objects are stored as pointers in a `basic_json` type. That is, for any access to object values, a pointer of type `object_t*` must be dereferenced. - - -## Arrays - -[RFC 7159](http://rfc7159.net/rfc7159) describes JSON arrays as follows: - -> An array is an ordered sequence of zero or more values. - -### Default type - -With the default values for *ArrayType* (`std::vector`) and *AllocatorType* (`std::allocator`), the default value for `array_t` is: - -```cpp -std::vector< - basic_json, // value_type - std::allocator // allocator_type -> -``` - -### Limits - -[RFC 7159](http://rfc7159.net/rfc7159) specifies: - -> An implementation may set limits on the maximum depth of nesting. - -In this class, the array's limit of nesting is not explicitly constrained. However, a maximum depth of nesting may be introduced by the compiler or runtime environment. A theoretical limit can be queried by calling the `max_size` function of a JSON array. - -### Storage - -Arrays are stored as pointers in a `basic_json` type. That is, for any access to array values, a pointer of type `array_t*` must be dereferenced. - - -## Strings - -[RFC 7159](http://rfc7159.net/rfc7159) describes JSON strings as follows: - -> A string is a sequence of zero or more Unicode characters. - -Unicode values are split by the JSON class into byte-sized characters during deserialization. - -### Default type - -With the default values for *StringType* (`std::string`), the default value for `string_t` is `#!cpp std::string`. - -### Encoding - -Strings are stored in UTF-8 encoding. Therefore, functions like `std::string::size()` or `std::string::length()` return the number of **bytes** in the string rather than the number of characters or glyphs. - -### String comparison - -[RFC 7159](http://rfc7159.net/rfc7159) states: - -> Software implementations are typically required to test names of object members for equality. Implementations that transform the textual representation into sequences of Unicode code units and then perform the comparison numerically, code unit by code unit, are interoperable in the sense that implementations will agree in all cases on equality or inequality of two strings. For example, implementations that compare strings with escaped characters unconverted may incorrectly find that `"a\\b"` and `"a\u005Cb"` are not equal. - -This implementation is interoperable as it does compare strings code unit by code unit. - -### Storage - -String values are stored as pointers in a `basic_json` type. That is, for any access to string values, a pointer of type `string_t*` must be dereferenced. - - -## Booleans - -[RFC 7159](http://rfc7159.net/rfc7159) implicitly describes a boolean as a type which differentiates the two literals `true` and `false`. - -### Default type - -With the default values for *BooleanType* (`#!cpp bool`), the default value for `boolean_t` is `#!cpp bool`. - -### Storage - -Boolean values are stored directly inside a `basic_json` type. - -## Numbers - -[RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows: - -> The representation of numbers is similar to that used in most programming languages. A number is represented in base 10 using decimal digits. It contains an integer component that may be prefixed with an optional minus sign, which may be followed by a fraction part and/or an exponent part. Leading zeros are not allowed. (...) Numeric values that cannot be represented in the grammar below (such as Infinity and NaN) are not permitted. - -This description includes both integer and floating-point numbers. However, C++ allows more precise storage if it is known whether the number is a signed integer, an unsigned integer or a floating-point number. Therefore, three different types, `number_integer_t`, `number_unsigned_t`, and `number_float_t` are used. - -### Default types - -With the default values for *NumberIntegerType* (`std::int64_t`), the default value for `number_integer_t` is `std::int64_t`. -With the default values for *NumberUnsignedType* (`std::uint64_t`), the default value for `number_unsigned_t` is `std::uint64_t`. -With the default values for *NumberFloatType* (`#!cpp double`), the default value for `number_float_t` is `#!cpp double`. - -### Default behavior - -- The restrictions about leading zeros is not enforced in C++. Instead, leading zeros in integer literals lead to an interpretation as octal number. Internally, the value will be stored as decimal number. For instance, the C++ integer literal `#!c 010` will be serialized to `#!c 8`. During deserialization, leading zeros yield an error. -- Not-a-number (NaN) values will be serialized to `#!json null`. - -### Limits - -[RFC 7159](http://rfc7159.net/rfc7159) specifies: - -> An implementation may set limits on the range and precision of numbers. - -When the default type is used, the maximal integer number that can be stored is `#!c 9223372036854775807` (`INT64_MAX`) and the minimal integer number that can be stored is `#!c -9223372036854775808` (`INT64_MIN`). Integer numbers that are out of range will yield over/underflow when used in a constructor. During deserialization, too large or small integer numbers will be automatically be stored as `number_unsigned_t` or `number_float_t`. - -When the default type is used, the maximal unsigned integer number that can be stored is `#!c 18446744073709551615` (`UINT64_MAX`) and the minimal integer number that can be stored is `#!c 0`. Integer numbers that are out of range will yield over/underflow when used in a constructor. During deserialization, too large or small integer numbers will be automatically be stored as `number_integer_t` or `number_float_t`. - -[RFC 7159](http://rfc7159.net/rfc7159) further states: - -> Note that when such software is used, numbers that are integers and are in the range $[-2^{53}+1, 2^{53}-1]$ are interoperable in the sense that implementations will agree exactly on their numeric values. - -As this range is a subrange of the exactly supported range [`INT64_MIN`, `INT64_MAX`], this class's integer type is interoperable. - -[RFC 7159](http://rfc7159.net/rfc7159) states: - -> This specification allows implementations to set limits on the range and precision of numbers accepted. Since software that implements IEEE 754-2008 binary64 (double precision) numbers is generally available and widely used, good interoperability can be achieved by implementations that expect no more precision or range than these provide, in the sense that implementations will approximate JSON numbers within the expected precision. - -This implementation does exactly follow this approach, as it uses double precision floating-point numbers. Note values smaller than `#!c -1.79769313486232e+308` and values greater than `#!c 1.79769313486232e+308` will be stored as NaN internally and be serialized to `#!json null`. - -### Storage - -Integer number values, unsigned integer number values, and floating-point number values are stored directly inside a `basic_json` type. diff --git a/external_imported/json/doc/mkdocs/docs/home/faq.md b/external_imported/json/doc/mkdocs/docs/home/faq.md deleted file mode 100644 index af63cfb6a..000000000 --- a/external_imported/json/doc/mkdocs/docs/home/faq.md +++ /dev/null @@ -1,91 +0,0 @@ -# Frequently Asked Questions (FAQ) - -## Limitations - -### Relaxed parsing - -!!! question - - - Can you add an option to ignore trailing commas? - -For the same reason this library does not support [comments](#comments), this library also does not support any feature which would jeopardize interoperability. - - -### Parse errors reading non-ASCII characters - -!!! question "Questions" - - - Why is the parser complaining about a Chinese character? - - Does the library support Unicode? - - I get an exception `[json.exception.parse_error.101] parse error at line 1, column 53: syntax error while parsing value - invalid string: ill-formed UTF-8 byte; last read: '"Testé$')"` - -The library supports **Unicode input** as follows: - -- Only **UTF-8** encoded input is supported which is the default encoding for JSON according to [RFC 8259](https://tools.ietf.org/html/rfc8259.html#section-8.1). -- `std::u16string` and `std::u32string` can be parsed, assuming UTF-16 and UTF-32 encoding, respectively. These encodings are not supported when reading from files or other input containers. -- Other encodings such as Latin-1 or ISO 8859-1 are **not** supported and will yield parse or serialization errors. -- [Unicode noncharacters](http://www.unicode.org/faq/private_use.html#nonchar1) will not be replaced by the library. -- Invalid surrogates (e.g., incomplete pairs such as `\uDEAD`) will yield parse errors. -- The strings stored in the library are UTF-8 encoded. When using the default string type (`std::string`), note that its length/size functions return the number of stored bytes rather than the number of characters or glyphs. -- When you store strings with different encodings in the library, calling [`dump()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a50ec80b02d0f3f51130d4abb5d1cfdc5.html#a50ec80b02d0f3f51130d4abb5d1cfdc5) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers. - -In most cases, the parser is right to complain, because the input is not UTF-8 encoded. This is especially true for Microsoft Windows where Latin-1 or ISO 8859-1 is often the standard encoding. - - -### Key name in exceptions - -!!! question - - Can I get the key of the object item that caused an exception? - -No, this is not possible. See for a longer discussion. - - -## Serialization issues - - -### Number precision - -!!! question - - - It seems that precision is lost when serializing a double. - - Can I change the precision for floating-point serialization? - -The library uses `std::numeric_limits::digits10` (15 for IEEE `double`s) digits for serialization. This value is sufficient to guarantee roundtripping. If one uses more than this number of digits of precision, then string -> value -> string is not guaranteed to round-trip. - -!!! quote "[cppreference.com](https://en.cppreference.com/w/cpp/types/numeric_limits/digits10)" - - The value of `std::numeric_limits::digits10` is the number of base-10 digits that can be represented by the type T without change, that is, any number with this many significant decimal digits can be converted to a value of type T and back to decimal form, without change due to rounding or overflow. - -!!! tip - - The website https://float.exposed gives a good insight into the internal storage of floating-point numbers. - - -## Compilation issues - -### Android SDK - -!!! question - - Why does the code not compile with Android SDK? - -Android defaults to using very old compilers and C++ libraries. To fix this, add the following to your `Application.mk`. This will switch to the LLVM C++ library, the Clang compiler, and enable C++11 and other features disabled by default. - -```ini -APP_STL := c++_shared -NDK_TOOLCHAIN_VERSION := clang3.6 -APP_CPPFLAGS += -frtti -fexceptions -``` - -The code compiles successfully with [Android NDK](https://developer.android.com/ndk/index.html?hl=ml), Revision 9 - 11 (and possibly later) and [CrystaX's Android NDK](https://www.crystax.net/en/android/ndk) version 10. - - -### Missing STL function - -!!! question "Questions" - - - Why do I get a compilation error `'to_string' is not a member of 'std'` (or similarly, for `strtod` or `strtof`)? - - Why does the code not compile with MinGW or Android SDK? - -This is not an issue with the code, but rather with the compiler itself. On Android, see above to build with a newer environment. For MinGW, please refer to [this site](http://tehsausage.com/mingw-to-string) and [this discussion](https://github.com/nlohmann/json/issues/136) for information on how to fix this bug. For Android NDK using `APP_STL := gnustl_static`, please refer to [this discussion](https://github.com/nlohmann/json/issues/219). diff --git a/external_imported/json/doc/mkdocs/docs/home/sponsors.md b/external_imported/json/doc/mkdocs/docs/home/sponsors.md deleted file mode 100644 index e2c5d91f8..000000000 --- a/external_imported/json/doc/mkdocs/docs/home/sponsors.md +++ /dev/null @@ -1,11 +0,0 @@ -# Sponsors - -You can sponsor this library at [GitHub Sponsors](https://github.com/sponsors/nlohmann). - -## Named Sponsors - -- [Michael Hartmann](https://github.com/reFX-Mike) -- [Stefan Hagen](https://github.com/sthagen) -- [Steve Sperandeo](https://github.com/homer6) - -Thanks everyone! diff --git a/external_imported/json/doc/mkdocs/docs/hooks.py b/external_imported/json/doc/mkdocs/docs/hooks.py deleted file mode 100644 index 8fee83973..000000000 --- a/external_imported/json/doc/mkdocs/docs/hooks.py +++ /dev/null @@ -1,10 +0,0 @@ -import shutil -import os.path - - -def copy_doxygen(*args, **kwargs): - doxygen_dir = os.path.join(kwargs['config']['site_dir'], 'doxygen') - if not os.path.isdir(doxygen_dir) or not os.listdir(doxygen_dir): - print('Copy Doxygen files...') - shutil.copytree('../html', doxygen_dir) - print('Copy Doxygen complete') diff --git a/external_imported/json/doc/mkdocs/docs/index.md b/external_imported/json/doc/mkdocs/docs/index.md deleted file mode 100644 index 39c52d748..000000000 --- a/external_imported/json/doc/mkdocs/docs/index.md +++ /dev/null @@ -1,7 +0,0 @@ -# JSON for Modern C++ - -!!! note - - This page is under construction. - -![](images/json.gif) diff --git a/external_imported/json/doc/mkdocs/docs/integration/cmake.md b/external_imported/json/doc/mkdocs/docs/integration/cmake.md deleted file mode 100644 index 76f05dbe1..000000000 --- a/external_imported/json/doc/mkdocs/docs/integration/cmake.md +++ /dev/null @@ -1,103 +0,0 @@ -# CMake - -You can also use the `nlohmann_json::nlohmann_json` interface target in CMake. This target populates the appropriate usage requirements for `INTERFACE_INCLUDE_DIRECTORIES` to point to the appropriate include directories and `INTERFACE_COMPILE_FEATURES` for the necessary C++11 flags. - -## External - -To use this library from a CMake project, you can locate it directly with `find_package()` and use the namespaced imported target from the generated package configuration: - -```cmake -# CMakeLists.txt -find_package(nlohmann_json 3.2.0 REQUIRED) -... -add_library(foo ...) -... -target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json) -``` - -The package configuration file, `nlohmann_jsonConfig.cmake`, can be used either from an install tree or directly out of the build tree. - -## Embedded - -To embed the library directly into an existing CMake project, place the entire source tree in a subdirectory and call `add_subdirectory()` in your `CMakeLists.txt` file: - -```cmake -# Typically you don't care so much for a third party library's tests to be -# run from your own project's code. -set(JSON_BuildTests OFF CACHE INTERNAL "") - -# If you only include this third party in PRIVATE source files, you do not -# need to install it when your main project gets installed. -# set(JSON_Install OFF CACHE INTERNAL "") - -# Don't use include(nlohmann_json/CMakeLists.txt) since that carries with it -# unintended consequences that will break the build. It's generally -# discouraged (although not necessarily well documented as such) to use -# include(...) for pulling in other CMake projects anyways. -add_subdirectory(nlohmann_json) -... -add_library(foo ...) -... -target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json) -``` - -## Embedded (FetchContent) - -Since CMake v3.11, -[FetchContent](https://cmake.org/cmake/help/v3.11/module/FetchContent.html) can -be used to automatically download the repository as a dependency at configure type. - -Example: -```cmake -include(FetchContent) - -FetchContent_Declare(json - GIT_REPOSITORY https://github.com/nlohmann/json - GIT_TAG v3.7.3) - -FetchContent_GetProperties(json) -if(NOT json_POPULATED) - FetchContent_Populate(json) - add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL) -endif() - -target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json) -``` - -!!! Note - The repository download size is huge. - It contains all the dataset used for the benchmarks. You might want to depend on - a smaller repository. For instance, you might want to replace the URL above by - . - -## Supporting Both - -To allow your project to support either an externally supplied or an embedded JSON library, you can use a pattern akin to the following: - -``` cmake -# Top level CMakeLists.txt -project(FOO) -... -option(FOO_USE_EXTERNAL_JSON "Use an external JSON library" OFF) -... -add_subdirectory(thirdparty) -... -add_library(foo ...) -... -# Note that the namespaced target will always be available regardless of the -# import method -target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json) -``` -```cmake -# thirdparty/CMakeLists.txt -... -if(FOO_USE_EXTERNAL_JSON) - find_package(nlohmann_json 3.2.0 REQUIRED) -else() - set(JSON_BuildTests OFF CACHE INTERNAL "") - add_subdirectory(nlohmann_json) -endif() -... -``` - -`thirdparty/nlohmann_json` is then a complete copy of this source tree. diff --git a/external_imported/json/doc/mkdocs/docs/integration/index.md b/external_imported/json/doc/mkdocs/docs/integration/index.md deleted file mode 100644 index 5dd8cceb7..000000000 --- a/external_imported/json/doc/mkdocs/docs/integration/index.md +++ /dev/null @@ -1,14 +0,0 @@ -# Integration - -[`json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp) is the single required file in `single_include/nlohmann` or [released here](https://github.com/nlohmann/json/releases). You need to add - -```cpp -#include - -// for convenience -using json = nlohmann::json; -``` - -to the files you want to process JSON and set the necessary switches to enable C++11 (e.g., `-std=c++11` for GCC and Clang). - -You can further use file [`include/nlohmann/json_fwd.hpp`](https://github.com/nlohmann/json/blob/develop/include/nlohmann/json_fwd.hpp) for forward-declarations. The installation of json_fwd.hpp (as part of cmake's install step), can be achieved by setting `-DJSON_MultipleHeaders=ON`. diff --git a/external_imported/json/doc/mkdocs/docs/integration/package_managers.md b/external_imported/json/doc/mkdocs/docs/integration/package_managers.md deleted file mode 100644 index 58b3eab55..000000000 --- a/external_imported/json/doc/mkdocs/docs/integration/package_managers.md +++ /dev/null @@ -1,143 +0,0 @@ -# Package Managers - -Throughout this page, we will describe how to compile the example file `example.cpp` below. - -```cpp ---8<-- "integration/example.cpp" -``` - -## Homebrew - -If you are using OS X and [Homebrew](http://brew.sh), just type - -```sh -brew tap nlohmann/json -brew install nlohmann-json -``` - -and you're set. If you want the bleeding edge rather than the latest release, use - -```sh -brew tap nlohmann/json -brew install nlohmann-json --HEAD -``` - -instead. - -!!! example - - 1. Create the following file: - - === "example.cpp" - - ```cpp - --8<-- "integration/example.cpp" - ``` - - 2. Install the package - - ```sh - brew tap nlohmann/json - brew install nlohmann-json - ``` - - 3. Determine the include path, which defaults to `/usr/local/Cellar/nlohmann-json/$version/include`, where `$version` is the version of the library, e.g. `3.7.3`. The path of the library can be determined with - - ```sh - brew list nlohmann-json - ``` - - 4. Compile the code. For instance, the code can be compiled using Clang with - - ```sh - clang++ example.cpp -I/usr/local/Cellar/nlohmann-json/3.7.3/include -std=c++11 -o example - ``` - -## Meson - -If you are using the [Meson Build System](http://mesonbuild.com), add this source tree as a [meson subproject](https://mesonbuild.com/Subprojects.html#using-a-subproject). You may also use the `include.zip` published in this project's [Releases](https://github.com/nlohmann/json/releases) to reduce the size of the vendored source tree. Alternatively, you can get a wrap file by downloading it from [Meson WrapDB](https://wrapdb.mesonbuild.com/nlohmann_json), or simply use `meson wrap install nlohmann_json`. Please see the meson project for any issues regarding the packaging. - -The provided meson.build can also be used as an alternative to cmake for installing `nlohmann_json` system-wide in which case a pkg-config file is installed. To use it, simply have your build system require the `nlohmann_json` pkg-config dependency. In Meson, it is preferred to use the [`dependency()`](https://mesonbuild.com/Reference-manual.html#dependency) object with a subproject fallback, rather than using the subproject directly. - -## Conan - -If you are using [Conan](https://www.conan.io/) to manage your dependencies, merely add `nlohmann_json/x.y.z` to your `conanfile`'s requires, where `x.y.z` is the release version you want to use. Please file issues [here](https://github.com/conan-io/conan-center-index/issues) if you experience problems with the packages. - -!!! example - - 1. Create the following files: - - === "Conanfile.txt" - - ```ini - --8<-- "integration/conan/Conanfile.txt" - ``` - - === "CMakeLists.txt" - - ```cmake - --8<-- "integration/conan/CMakeLists.txt" - ``` - - === "example.cpp" - - ```cpp - --8<-- "integration/conan/example.cpp" - ``` - - - 2. Build: - - ```sh - mkdir build - cd build - conan install .. - cmake .. - cmake --build . - ``` - -## Spack - -If you are using [Spack](https://www.spack.io/) to manage your dependencies, you can use the [`nlohmann-json` package](https://spack.readthedocs.io/en/latest/package_list.html#nlohmann-json). Please see the [spack project](https://github.com/spack/spack) for any issues regarding the packaging. - -## Hunter - -If you are using [hunter](https://github.com/cpp-pm/hunter) on your project for external dependencies, then you can use the [nlohmann_json package](https://hunter.readthedocs.io/en/latest/packages/pkg/nlohmann_json.html). Please see the hunter project for any issues regarding the packaging. - -## Buckaroo - -If you are using [Buckaroo](https://buckaroo.pm), you can install this library's module with `buckaroo add github.com/buckaroo-pm/nlohmann-json`. Please file issues [here](https://github.com/buckaroo-pm/nlohmann-json). There is a demo repo [here](https://github.com/njlr/buckaroo-nholmann-json-example). - -## vcpkg - -If you are using [vcpkg](https://github.com/Microsoft/vcpkg/) on your project for external dependencies, then you can use the [nlohmann-json package](https://github.com/Microsoft/vcpkg/tree/master/ports/nlohmann-json). Please see the vcpkg project for any issues regarding the packaging. - -## cget - -If you are using [cget](http://cget.readthedocs.io/en/latest/), you can install the latest development version with `cget install nlohmann/json`. A specific version can be installed with `cget install nlohmann/json@v3.1.0`. Also, the multiple header version can be installed by adding the `-DJSON_MultipleHeaders=ON` flag (i.e., `cget install nlohmann/json -DJSON_MultipleHeaders=ON`). - - -## CocoaPods - -If you are using [CocoaPods](https://cocoapods.org), you can use the library by adding pod `"nlohmann_json", '~>3.1.2'` to your podfile (see [an example](https://bitbucket.org/benman/nlohmann_json-cocoapod/src/master/)). Please file issues [here](https://bitbucket.org/benman/nlohmann_json-cocoapod/issues?status=new&status=open). - -## NuGet - -If you are using [NuGet](https://www.nuget.org), you can use the package [nlohmann.json](https://www.nuget.org/packages/nlohmann.json/). Please check [this extensive description](https://github.com/nlohmann/json/issues/1132#issuecomment-452250255) on how to use the package. Please files issues [here](https://github.com/hnkb/nlohmann-json-nuget/issues). - -## Conda - -If you are using [conda](https://conda.io/), you can use the package [nlohmann_json](https://github.com/conda-forge/nlohmann_json-feedstock) from [conda-forge](https://conda-forge.org) executing `conda install -c conda-forge nlohmann_json`. Please file issues [here](https://github.com/conda-forge/nlohmann_json-feedstock/issues). - -## MSYS2 - -If you are using [MSYS2](http://www.msys2.org/), your can use the [mingw-w64-nlohmann-json](https://packages.msys2.org/base/mingw-w64-nlohmann-json) package, just type `pacman -S mingw-w64-i686-nlohmann-json` or `pacman -S mingw-w64-x86_64-nlohmann-json` for installation. Please file issues [here](https://github.com/msys2/MINGW-packages/issues/new?title=%5Bnlohmann-json%5D) if you experience problems with the packages. - -## build2 - -If you are using [`build2`](https://build2.org), you can use the [`nlohmann-json`](https://cppget.org/nlohmann-json) package from the public repository http://cppget.org or directly from the [package's sources repository](https://github.com/build2-packaging/nlohmann-json). In your project's `manifest` file, just add `depends: nlohmann-json` (probably with some [version constraints](https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml#guide-add-remove-deps)). If you are not familiar with using dependencies in `build2`, [please read this introduction](https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml). -Please file issues [here](https://github.com/build2-packaging/nlohmann-json) if you experience problems with the packages. - -## wsjcpp - -If you are using [`wsjcpp`](http://wsjcpp.org), you can use the command `wsjcpp install "https://github.com/nlohmann/json:develop"` to get the latest version. Note you can change the branch ":develop" to an existing tag or another branch. diff --git a/external_imported/json/doc/mkdocs/mkdocs.yml b/external_imported/json/doc/mkdocs/mkdocs.yml deleted file mode 100644 index e1552d39b..000000000 --- a/external_imported/json/doc/mkdocs/mkdocs.yml +++ /dev/null @@ -1,242 +0,0 @@ -# Project information -site_name: JSON for Modern C++ -site_author: Niels Lohmann -site_url: https://json.nlohmann.me/ - -# Repository -repo_name: nlohmann/json -repo_url: https://github.com/nlohmann/json -edit_uri: edit/develop/doc/mkdocs/docs - -# Copyright -copyright: Copyright © 2013 - 2020 Niels Lohmann - -# Configuration -theme: - name: material - language: en - palette: - primary: indigo - accent: indigo - font: - text: Roboto - code: Roboto Mono - features: - - tabs - - instant - -nav: - - Home: - - index.md - - home/license.md - - "Code of Conduct": home/code_of_conduct.md - - "FAQ": home/faq.md - - home/exceptions.md - - home/releases.md - - home/design_goals.md - - home/sponsors.md - - Features: - - features/arbitrary_types.md - - Binary Formats: - - features/binary_formats/index.md - - features/binary_formats/bson.md - - features/binary_formats/cbor.md - - features/binary_formats/messagepack.md - - features/binary_formats/ubjson.md - - features/binary_values.md - - features/comments.md - - Element Access: - - features/element_access/index.md - - features/element_access/unchecked_access.md - - features/element_access/checked_access.md - - features/element_access/default_value.md - - features/iterators.md - - features/json_pointer.md - - features/json_patch.md - - features/merge_patch.md - - features/object_order.md - - Parsing: - - features/parsing/index.md - - features/parsing/parse_exceptions.md - - features/parsing/parser_callbacks.md - - features/parsing/sax_interface.md - - features/enum_conversion.md - - features/macros.md - - features/types.md - - Integration: - - integration/index.md - - integration/cmake.md - - integration/package_managers.md - - Doxygen: - - doxygen/index.html - - API: - - basic_json: - - api/basic_json/index.md - - api/basic_json/accept.md - - api/basic_json/array.md - - api/basic_json/array_t.md - - api/basic_json/at.md - - api/basic_json/back.md - - api/basic_json/basic_json.md - - api/basic_json/~basic_json.md - - api/basic_json/begin.md - - api/basic_json/binary.md - - api/basic_json/binary_t.md - - api/basic_json/boolean_t.md - - api/basic_json/cbegin.md - - api/basic_json/cbor_tag_handler_t.md - - api/basic_json/cend.md - - api/basic_json/clear.md - - api/basic_json/contains.md - - api/basic_json/count.md - - api/basic_json/crbegin.md - - api/basic_json/crend.md - - api/basic_json/diff.md - - api/basic_json/dump.md - - api/basic_json/emplace.md - - api/basic_json/emplace_back.md - - api/basic_json/empty.md - - api/basic_json/end.md - - api/basic_json/erase.md - - api/basic_json/error_handler_t.md - - api/basic_json/exception.md - - api/basic_json/find.md - - api/basic_json/flatten.md - - api/basic_json/from_bson.md - - api/basic_json/from_cbor.md - - api/basic_json/from_msgpack.md - - api/basic_json/from_ubjson.md - - api/basic_json/front.md - - api/basic_json/get.md - - api/basic_json/get_allocator.md - - api/basic_json/get_binary.md - - api/basic_json/get_ptr.md - - api/basic_json/get_ref.md - - api/basic_json/get_to.md - - api/basic_json/input_format_t.md - - api/basic_json/insert.md - - api/basic_json/invalid_iterator.md - - api/basic_json/is_array.md - - api/basic_json/is_binary.md - - api/basic_json/is_boolean.md - - api/basic_json/is_discarded.md - - api/basic_json/is_null.md - - api/basic_json/is_number.md - - api/basic_json/is_number_float.md - - api/basic_json/is_number_integer.md - - api/basic_json/is_number_unsigned.md - - api/basic_json/is_object.md - - api/basic_json/is_primitive.md - - api/basic_json/is_string.md - - api/basic_json/is_structured.md - - api/basic_json/items.md - - api/basic_json/json_serializer.md - - api/basic_json/max_size.md - - api/basic_json/meta.md - - api/basic_json/merge_patch.md - - api/basic_json/number_float_t.md - - api/basic_json/number_integer_t.md - - api/basic_json/number_unsigned_t.md - - api/basic_json/object.md - - api/basic_json/object_comparator_t.md - - api/basic_json/object_t.md - - api/basic_json/operator_ValueType.md - - api/basic_json/operator_value_t.md - - api/basic_json/operator[].md - - api/basic_json/operator=.md - - api/basic_json/operator_eq.md - - api/basic_json/operator_ne.md - - api/basic_json/operator_lt.md - - api/basic_json/operator_le.md - - api/basic_json/operator_gt.md - - api/basic_json/operator_ge.md - - api/basic_json/operator+=.md - - api/basic_json/operator_literal_json.md - - api/basic_json/operator_literal_json_pointer.md - - api/basic_json/out_of_range.md - - api/basic_json/other_error.md - - api/basic_json/parse.md - - api/basic_json/parse_error.md - - api/basic_json/parse_event_t.md - - api/basic_json/parser_callback_t.md - - api/basic_json/patch.md - - api/basic_json/push_back.md - - api/basic_json/rbegin.md - - api/basic_json/rend.md - - api/basic_json/sax_parse.md - - api/basic_json/size.md - - api/basic_json/string_t.md - - api/basic_json/to_bson.md - - api/basic_json/to_cbor.md - - api/basic_json/to_msgpack.md - - api/basic_json/to_ubjson.md - - api/basic_json/type.md - - api/basic_json/type_error.md - - api/basic_json/type_name.md - - api/basic_json/unflatten.md - - api/basic_json/update.md - - api/basic_json/value.md - - api/basic_json/value_t.md - - api/adl_serializer.md - - api/json.md - - api/json_pointer.md - - api/ordered_map.md - - api/ordered_json.md - -# Extras -extra: - social: - - icon: fontawesome/brands/github - link: https://github.com/nlohmann - - icon: fontawesome/brands/twitter - link: https://twitter.com/nlohmann - - icon: fontawesome/brands/linkedin - link: https://www.linkedin.com/in/nielslohmann/ - - icon: fontawesome/brands/xing - link: https://www.xing.com/profile/Niels_Lohmann - - icon: fontawesome/brands/paypal - link: https://www.paypal.me/nlohmann - -# Extensions -markdown_extensions: - - admonition - - def_list - - codehilite: - guess_lang: false - - toc: - permalink: true - - pymdownx.arithmatex - - pymdownx.betterem: - smart_enable: all - - pymdownx.caret - - pymdownx.critic - - pymdownx.details - - pymdownx.emoji: - emoji_index: !!python/name:materialx.emoji.twemoji - emoji_generator: !!python/name:materialx.emoji.to_svg - - pymdownx.inlinehilite - - pymdownx.magiclink - - pymdownx.mark - #- pymdownx.smartsymbols - - pymdownx.superfences - - pymdownx.tasklist: - custom_checkbox: true - - pymdownx.tabbed - - pymdownx.tilde - - pymdownx.snippets: - base_path: docs - check_paths: true - - plantuml_markdown: - format: svg - -plugins: - - search: - separator: '[\s\-\.]+' - - mkdocs-simple-hooks: - hooks: - on_post_build: "docs.hooks:copy_doxygen" - - minify: - minify_html: true - -extra_javascript: - - https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML diff --git a/external_imported/json/doc/mkdocs/requirements.txt b/external_imported/json/doc/mkdocs/requirements.txt deleted file mode 100644 index b64e9b873..000000000 --- a/external_imported/json/doc/mkdocs/requirements.txt +++ /dev/null @@ -1,29 +0,0 @@ -click>=7.1.2 -future>=0.18.2 -htmlmin>=0.1.12 -httplib2>=0.18.1 -importlib-metadata>=1.6.0 -Jinja2>=2.11.2 -joblib>=0.15.1 -jsmin>=2.2.2 -livereload>=2.6.1 -lunr>=0.5.8 -Markdown>=3.2.2 -markdown-include>=0.5.1 -MarkupSafe>=1.1.1 -mkdocs>=1.1.2 -mkdocs-material>=5.2.1 -mkdocs-material-extensions>=1.0 -mkdocs-minify-plugin>=0.3.0 -mkdocs-simple-hooks>=0.1.1 -nltk>=3.5 -plantuml>=0.3.0 -plantuml-markdown>=3.2.2 -Pygments>=2.6.1 -pymdown-extensions>=7.1 -PyYAML>=5.3.1 -regex>=2020.5.14 -six>=1.15.0 -tornado>=6.0.4 -tqdm>=4.46.0 -zipp>=3.1.0 diff --git a/external_imported/json/doc/scripts/git-update-ghpages b/external_imported/json/doc/scripts/git-update-ghpages deleted file mode 100755 index 393650c1c..000000000 --- a/external_imported/json/doc/scripts/git-update-ghpages +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env bash -set -o errexit - -copy_contents() { - local source="$1" - status "Copying contents from $source" - if [[ ! "$dryrun" == "1" ]]; then - (cd "$source" >/dev/null && tar c .) | tar xv - else - _ "(cd \"$source\" >/dev/null && tar c .) | tar xv" - fi -} - -# Sets git config -set_config() { - if [ -n "$GIT_NAME" ]; then _ git config user.name "$GIT_NAME"; fi - if [ -n "$GIT_EMAIL" ]; then _ git config user.email "$GIT_EMAIL"; fi -} - -# Runs the deployment -run() { - if [ ! -d "$source" ]; then - echo "Source is not a directory: $source" - exit 1 - fi - - local tmpdir="$(mktemp -d)" - - if [[ "$force" == "1" ]]; then - _ cd "$tmpdir" - _ git init - _ git checkout -b "$branch" - copy_contents "$source" - if [[ "$useenv" == "1" ]]; then set_config; fi - _ git add -A . - git_commit - git_push --force - else - _ cd "$tmpdir" - _ git clone "$repo" . -b "$branch" || ( \ - _ git init && \ - _ git checkout -b "$branch") - if [[ "$keep" == "0" ]]; then _ rm -rf ./*; fi - copy_contents "$source" - if [[ "$useenv" == "1" ]]; then set_config; fi - _ git add -A . - git_commit || true - git_push - fi - _ rm -rf "$tmpdir" - status_ "Done" -} - -git_commit() { - if [ -z "$author" ]; then - _ git commit -m "$message" - else - _ git commit -m "$message" --author "$author" - fi -} - -git_push() { - if [ -z "$GITHUB_TOKEN" ]; then - _ git push "${repo}" "$branch" "$@" - else - status "Pushing via \$GITHUB_TOKEN $@" - _ git push "https://${GITHUB_TOKEN}@github.com/${repospec}.git" "$branch" "$@" \ - --quiet >/dev/null 2>&1 || \ - ( status_ "Failed to push"; exit 1 ) - fi -} - -status() { - echo -e "\n\033[34m==>\033[0;1m" "$@\033[0m" -} -status_() { - echo -e "\033[33;1m==>\033[0m" "$@" -} - -_() { - echo "" - status_ "$@" - if [[ ! "$dryrun" == "1" ]]; then "$@"; fi -} - -help() { - local cmd="$(basename $0)" - echo 'Usage:' - echo " $cmd " - echo '' - echo 'Parameters:' - echo " REPO repository to push to in 'user/repo' form" - echo " SOURCE path to upload to repository's gh-pages branch" - echo '' - echo 'Options:' - echo ' -h, --help show help screen' - echo ' -f, --force force push' - echo ' -n, --dry-run run in simulation mode' - echo ' -e, --use-env pick up arguments from environment variables' - echo ' -b, --branch use this branch name (default: gh-pages)' - echo ' -a, --author set the author' - echo ' -k, --keep keep existing files in the repo' - echo '' - echo 'Env var options:' - echo ' GITHUB_TOKEN if set, use this to push to the repo' - echo '' - echo 'Optional env vars:' - echo " Run with '-e' to enable the use of these variables." - echo " GIT_NAME set this as the repos user.name" - echo ' GIT_EMAIL set this as the repos user.email' - echo ' GITHUB_REPO substitute as the REPO (1st argument)' - echo ' GIT_SOURCE substitute as the SOURCE (2nd argument)' - echo ' GIT_BRANCH use this branch name (--branch)' - echo '' - echo 'Example:' - echo " $cmd rstacruz/myproject doc" - echo " # pushes './doc' into the gh-pages branch of rstacruz/myproject" - echo '' - echo " export GITHUB_REPO='xyz/abc'" - echo " export GIT_SOURCE='docs'" - echo " $cmd -e" - echo " # pushes './doc' into the gh-pages branch of xyz/abc" -} - -# -# Defaults -# - -force=0 -dryrun=0 -repospec= -source= -branch= -message="Update" -useenv=0 -author="" -keep=0 - -# -# Parse args -# - -while [[ "$1" =~ ^- && ! "$1" == '--' ]]; do case $1 in - -h | --help ) - help - exit - ;; - -b | --branch ) - shift - branch="$1" - ;; - -n | --dry-run ) - dryrun=1 - ;; - -e | --use-env ) - useenv=1 - ;; - -k | --keep ) - keep=1 - ;; - -a | --author) - shift - author="$1" - ;; - -f | --force ) - force=1 - ;; -esac; shift; done -if [[ "$1" == '--' ]]; then shift; fi - -if [[ "$useenv" == "1" ]] && [[ -n "$GIT_BRANCH" ]] && [[ -z "$branch" ]]; then - branch="$GIT_BRANCH" -fi - -if [[ "$useenv" == "1" ]] && [[ -n "$GITHUB_REPO" ]] && [[ -n "$GIT_SOURCE" ]] && [[ -z "$2" ]]; then - repospec="$GITHUB_REPO" - source="$GIT_SOURCE" -else - repospec="$1" - source="$2" -fi - -: ${branch:="gh-pages"} - -if [ -z "$source" ]; then - help - exit 1 -fi - -source="`pwd -LP`/$source" -repo="https://github.com/${repospec}.git" - -run diff --git a/external_imported/json/doc/scripts/send_to_wandbox.py b/external_imported/json/doc/scripts/send_to_wandbox.py deleted file mode 100755 index 112656694..000000000 --- a/external_imported/json/doc/scripts/send_to_wandbox.py +++ /dev/null @@ -1,120 +0,0 @@ -#! /usr/bin/env python - -# This script uploads a directory to Wandbox (http://melpon.org/wandbox), -# which is an online compiler environment, and prints a permalink to the -# uploaded code. We use this to provide a "Try it online" version of the -# library to make the barrier to entry as low as possible. -# -# This script was adapted from the script proposed in -# https://github.com/melpon/wandbox/issues/153. -# -# To know how to use this script: ./wandbox.py --help -# -# Copyright Louis Dionne 2015 -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - -import argparse -import fnmatch -import json -import os -import re -import urllib2 - - -# Strips C and C++ comments from the given string. -# -# Copied from https://stackoverflow.com/a/241506/627587. -def strip_comments(text): - def replacer(match): - s = match.group(0) - if s.startswith('/'): - return " " # note: a space and not an empty string - else: - return s - pattern = re.compile( - r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"', - re.DOTALL | re.MULTILINE - ) - return re.sub(pattern, replacer, text) - - -# Post the given JSON data to Wandbox's API, and return the result -# as a JSON object. -def upload(options): - request = urllib2.Request('https://melpon.org/wandbox/api/compile.json') - request.add_header('Content-Type', 'application/json') - response = urllib2.urlopen(request, json.dumps(options)) - return json.loads(response.read()) - - -# Returns a list of the '.hpp' headers in the given directory and in -# subdirectories. -# -# The path must be absolute, and the returned paths are all absolute too. -def headers(path): - return [ - os.path.join(dir, file) - for (dir, _, files) in os.walk(path) - for file in fnmatch.filter(files, "*.hpp") - ] - - -def main(): - parser = argparse.ArgumentParser(description= - """Upload a directory to Wandbox (http://melpon.org/wandbox). - - On success, the program prints a permalink to the uploaded - directory on Wandbox and returns 0. On error, it prints the - response from the Wandbox API and returns 1. - - Note that the comments are stripped from all the headers in the - uploaded directory. - """ - ) - parser.add_argument('directory', type=str, help= - """A directory to upload to Wandbox. - - The path may be either absolute or relative to the current directory. - However, the names of the files uploaded to Wandbox will all be - relative to this directory. This way, one can easily specify the - directory to be '/some/project/include', and the uploaded files - will be uploaded as-if they were rooted at '/some/project/include' - """) - parser.add_argument('main', type=str, help= - """The main source file. - - The path may be either absolute or relative to the current directory. - """ - ) - args = parser.parse_args() - directory = os.path.abspath(args.directory) - if not os.path.exists(directory): - raise Exception("'%s' is not a valid directory" % args.directory) - - cpp = os.path.abspath(args.main) - if not os.path.exists(cpp): - raise Exception("'%s' is not a valid file name" % args.main) - - response = upload({ - 'code': open(cpp).read(), - 'codes': [{ - 'file': os.path.relpath(header, directory), - #'code': strip_comments(open(header).read()) - 'code': open(header).read() - } for header in headers(directory)], - 'options': 'boost-nothing,c++11', - 'compiler': 'gcc-4.9.2', - 'save': True, - 'compiler-option-raw': '-I.' - }) - - if 'status' in response and response['status'] == '0': - print response['url'] - return 0 - else: - print response - return 1 - - -exit(main()) diff --git a/external_imported/json/docs/Makefile b/external_imported/json/docs/Makefile new file mode 100644 index 000000000..35c30daef --- /dev/null +++ b/external_imported/json/docs/Makefile @@ -0,0 +1,45 @@ +SRCDIR = ../single_include + +all: create_output + +########################################################################## +# example files +########################################################################## + +# where are the example cpp files +EXAMPLES = $(wildcard examples/*.cpp) + +cxx_standard = $(lastword c++11 $(filter c++%, $(subst ., ,$1))) + +# create output from a stand-alone example file +%.output: %.cpp + @echo "standard $(call cxx_standard $(<:.cpp=))" + $(MAKE) $(<:.cpp=) \ + CPPFLAGS="-I $(SRCDIR) -DJSON_USE_GLOBAL_UDLS=0" \ + CXXFLAGS="-std=$(call cxx_standard,$(<:.cpp=)) -Wno-deprecated-declarations" + ./$(<:.cpp=) > $@ + rm $(<:.cpp=) + +# compare created output with current output of the example files +%.test: %.cpp + $(MAKE) $(<:.cpp=) \ + CPPFLAGS="-I $(SRCDIR) -DJSON_USE_GLOBAL_UDLS=0" \ + CXXFLAGS="-std=$(call cxx_standard,$(<:.cpp=)) -Wno-deprecated-declarations" + ./$(<:.cpp=) > $@ + diff $@ $(<:.cpp=.output) + rm $(<:.cpp=) $@ + +# create output from all stand-alone example files +create_output: $(EXAMPLES:.cpp=.output) + +# check output of all stand-alone example files +check_output: $(EXAMPLES:.cpp=.test) + +# check output of all stand-alone example files (exclude files with platform-dependent output.) +# This target is used in the CI (ci_test_documentation). +check_output_portable: $(filter-out examples/meta.test examples/max_size.test examples/std_hash.test examples/basic_json__CompatibleType.test,$(EXAMPLES:.cpp=.test)) + +clean: + rm -fr $(EXAMPLES:.cpp=) + $(MAKE) clean -C docset + $(MAKE) clean -C mkdocs diff --git a/external_imported/json/docs/README.md b/external_imported/json/docs/README.md new file mode 100644 index 000000000..b39d54e05 --- /dev/null +++ b/external_imported/json/docs/README.md @@ -0,0 +1,20 @@ +# Documentation + +## Generate documentation + +Note on documentation: The source files contain links to the online documentation at https://json.nlohmann.me. This URL +contains the most recent documentation and should also be applicable to previous versions; documentation for deprecated +functions is not removed, but marked deprecated. + +If you want to see the documentation for a specific tag or commit hash, you can generate it as follows (here for tag +`v3.10.2`): + +```shell +git clone https://github.com/nlohmann/json.git +cd json +git checkout v3.10.2 +make install_venv serve -C docs/mkdocs +``` + +Open URL in your browser. Replace from any URL from the source code `https://json.nlohmann.me` +with `http://127.0.0.1:8000` to see the documentation for your tag or commit hash. diff --git a/external_imported/json/docs/avatars.png b/external_imported/json/docs/avatars.png new file mode 100644 index 000000000..25429f34a Binary files /dev/null and b/external_imported/json/docs/avatars.png differ diff --git a/external_imported/json/doc/docset/Info.plist b/external_imported/json/docs/docset/Info.plist similarity index 100% rename from external_imported/json/doc/docset/Info.plist rename to external_imported/json/docs/docset/Info.plist diff --git a/external_imported/json/docs/docset/Makefile b/external_imported/json/docs/docset/Makefile new file mode 100644 index 000000000..eb1cfd38c --- /dev/null +++ b/external_imported/json/docs/docset/Makefile @@ -0,0 +1,87 @@ +SHELL=/usr/bin/env bash +SED ?= $(shell which gsed 2>/dev/null || which sed) + +MKDOCS_PAGES=$(shell cd ../mkdocs/docs/ && find * -type f -name '*.md' | sort) + +.PHONY: all +all: JSON_for_Modern_C++.tgz + +docSet.dsidx: docSet.sql + # generate index + sqlite3 docSet.dsidx > "$$(ls JSON_for_Modern_C++.docset/Contents/Resources/Documents/assets/stylesheets/main.*.min.css)" + # fix spacing + echo -e "\n\ndiv.md-sidebar div.md-sidebar--secondary, div.md-main__inner { top: 0; margin-top: 0 }" >> "$$(ls JSON_for_Modern_C++.docset/Contents/Resources/Documents/assets/stylesheets/main.*.min.css)" + # remove "JSON for Modern C++" from page titles (fallback) + find JSON_for_Modern_C++.docset/Contents/Resources/Documents -type f -exec $(SED) -i 's| - JSON for Modern C++||' {} + + # replace page titles with name from index, if available + for page in $(MKDOCS_PAGES); do \ + case "$$page" in \ + */index.md) path=$${page/\/index.md/} ;; \ + *) path=$${page/.md/} ;; \ + esac; \ + title=$$(sqlite3 docSet.dsidx "SELECT name FROM searchIndex WHERE path='$$path/index.html'" | tr '\n' ',' | $(SED) -e 's/,/, /g' -e 's/, $$/\n/'); \ + if [ "x$$title" != "x" ]; then \ + $(SED) -i "s%.*%$$title%" "JSON_for_Modern_C++.docset/Contents/Resources/Documents/$$path/index.html"; \ + fi \ + done + # clean up + rm JSON_for_Modern_C++.docset/Contents/Resources/Documents/sitemap.* + # copy index + cp docSet.dsidx JSON_for_Modern_C++.docset/Contents/Resources/ + +JSON_for_Modern_C++.tgz: JSON_for_Modern_C++.docset + tar --exclude='.DS_Store' -cvzf JSON_for_Modern_C++.tgz JSON_for_Modern_C++.docset + +# install docset for Zeal documentation browser (https://zealdocs.org/) +.PHONY: install_docset_zeal +install_docset_zeal: JSON_for_Modern_C++.docset + docset_root=$${XDG_DATA_HOME:-$$HOME/.local/share}/Zeal/Zeal/docsets; \ + rm -rf $$docset_root/JSON_for_Modern_C++.docset; \ + mkdir -p $$docset_root; \ + cp -r JSON_for_Modern_C++.docset $$docset_root/ + +# list mkdocs pages missing from the docset index +.PHONY: list_missing_pages +list_missing_pages: docSet.dsidx + @for page in $(MKDOCS_PAGES); do \ + case "$$page" in \ + */index.md) path=$${page/\/index.md/} ;; \ + *) path=$${page/.md/} ;; \ + esac; \ + if [ "x$$page" != "xindex.md" -a "x$$(sqlite3 docSet.dsidx "SELECT COUNT(*) FROM searchIndex WHERE path='$$path/index.html'")" = "x0" ]; then \ + echo $$page; \ + fi \ + done + +# list paths in the docset index without a corresponding mkdocs page +.PHONY: list_removed_paths +list_removed_paths: docSet.dsidx + @for path in $$(sqlite3 docSet.dsidx "SELECT path FROM searchIndex"); do \ + page=$${path/\/index.html/.md}; \ + page_index=$${path/index.html/index.md}; \ + page_found=0; \ + for p in $(MKDOCS_PAGES); do \ + if [ "x$$p" = "x$$page" -o "x$$p" = "x$$page_index" ]; then \ + page_found=1; \ + fi \ + done; \ + if [ "x$$page_found" = "x0" ]; then \ + echo $$path; \ + fi \ + done + +.PHONY: clean +clean: + rm -f docSet.dsidx + rm -fr JSON_for_Modern_C++.docset JSON_for_Modern_C++.tgz diff --git a/external_imported/json/docs/docset/README.md b/external_imported/json/docs/docset/README.md new file mode 100644 index 000000000..79a778eb8 --- /dev/null +++ b/external_imported/json/docs/docset/README.md @@ -0,0 +1,19 @@ +# docset + +The folder contains the required files to create a [docset](https://kapeli.com/docsets) which can be used in +documentation browsers like [Dash](https://kapeli.com/dash), [Velocity](https://velocity.silverlakesoftware.com), or +[Zeal](https://zealdocs.org). + +The docset can be created with + +```sh +make nlohmann_json.docset +``` + +The generated folder `nlohmann_json.docset` can then be opened in the documentation browser. + +A recent version is also part of the [Dash user contributions](https://github.com/Kapeli/Dash-User-Contributions/tree/master/docsets/JSON_for_Modern_C%2B%2B). + +## Licenses + +The [JSON logo](https://commons.wikimedia.org/wiki/File:JSON_vector_logo.svg) is public domain. diff --git a/external_imported/json/docs/docset/docSet.sql b/external_imported/json/docs/docset/docSet.sql new file mode 100644 index 000000000..ea6b4f285 --- /dev/null +++ b/external_imported/json/docs/docset/docSet.sql @@ -0,0 +1,234 @@ +DROP TABLE IF EXISTS searchIndex; +CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT); +CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path); + +-- API +INSERT INTO searchIndex(name, type, path) VALUES ('adl_serializer', 'Class', 'api/adl_serializer/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('adl_serializer::from_json', 'Function', 'api/adl_serializer/from_json/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('adl_serializer::to_json', 'Function', 'api/adl_serializer/to_json/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('byte_container_with_subtype', 'Class', 'api/byte_container_with_subtype/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('byte_container_with_subtype::byte_container_with_subtype', 'Constructor', 'api/byte_container_with_subtype/byte_container_with_subtype/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('byte_container_with_subtype::clear_subtype', 'Method', 'api/byte_container_with_subtype/clear_subtype/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('byte_container_with_subtype::has_subtype', 'Method', 'api/byte_container_with_subtype/has_subtype/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('byte_container_with_subtype::set_subtype', 'Method', 'api/byte_container_with_subtype/set_subtype/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('byte_container_with_subtype::subtype', 'Method', 'api/byte_container_with_subtype/subtype/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json', 'Class', 'api/basic_json/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::accept', 'Function', 'api/basic_json/accept/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::array', 'Function', 'api/basic_json/array/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::array_t', 'Type', 'api/basic_json/array_t/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::at', 'Method', 'api/basic_json/at/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::back', 'Method', 'api/basic_json/back/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::basic_json', 'Constructor', 'api/basic_json/basic_json/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::begin', 'Method', 'api/basic_json/begin/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::binary', 'Function', 'api/basic_json/binary/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::binary_t', 'Type', 'api/basic_json/binary_t/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::boolean_t', 'Type', 'api/basic_json/boolean_t/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::cbegin', 'Method', 'api/basic_json/cbegin/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::cbor_tag_handler_t', 'Enum', 'api/basic_json/cbor_tag_handler_t/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::cend', 'Method', 'api/basic_json/cend/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::clear', 'Method', 'api/basic_json/clear/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::contains', 'Method', 'api/basic_json/contains/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::count', 'Method', 'api/basic_json/count/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::crbegin', 'Method', 'api/basic_json/crbegin/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::crend', 'Method', 'api/basic_json/crend/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::default_object_comparator_t', 'Type', 'api/basic_json/default_object_comparator_t/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::diff', 'Function', 'api/basic_json/diff/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::dump', 'Method', 'api/basic_json/dump/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::emplace', 'Method', 'api/basic_json/emplace/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::emplace_back', 'Method', 'api/basic_json/emplace_back/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::empty', 'Method', 'api/basic_json/empty/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::end', 'Method', 'api/basic_json/end/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::erase', 'Method', 'api/basic_json/erase/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::error_handler_t', 'Enum', 'api/basic_json/error_handler_t/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::exception', 'Class', 'api/basic_json/exception/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::find', 'Method', 'api/basic_json/find/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::flatten', 'Method', 'api/basic_json/flatten/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::from_bjdata', 'Function', 'api/basic_json/from_bjdata/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::from_bson', 'Function', 'api/basic_json/from_bson/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::from_cbor', 'Function', 'api/basic_json/from_cbor/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::from_msgpack', 'Function', 'api/basic_json/from_msgpack/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::from_ubjson', 'Function', 'api/basic_json/from_ubjson/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::front', 'Method', 'api/basic_json/front/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::get', 'Method', 'api/basic_json/get/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::get_allocator', 'Function', 'api/basic_json/get_allocator/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::get_binary', 'Method', 'api/basic_json/get_binary/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::get_ptr', 'Method', 'api/basic_json/get_ptr/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::get_ref', 'Method', 'api/basic_json/get_ref/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::get_to', 'Method', 'api/basic_json/get_to/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::input_format_t', 'Enum', 'api/basic_json/input_format_t/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::insert', 'Method', 'api/basic_json/insert/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::invalid_iterator', 'Class', 'api/basic_json/invalid_iterator/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_array', 'Method', 'api/basic_json/is_array/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_binary', 'Method', 'api/basic_json/is_binary/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_boolean', 'Method', 'api/basic_json/is_boolean/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_discarded', 'Method', 'api/basic_json/is_discarded/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_null', 'Method', 'api/basic_json/is_null/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_number', 'Method', 'api/basic_json/is_number/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_number_float', 'Method', 'api/basic_json/is_number_float/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_number_integer', 'Method', 'api/basic_json/is_number_integer/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_number_unsigned', 'Method', 'api/basic_json/is_number_unsigned/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_object', 'Method', 'api/basic_json/is_object/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_primitive', 'Method', 'api/basic_json/is_primitive/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_string', 'Method', 'api/basic_json/is_string/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_structured', 'Method', 'api/basic_json/is_structured/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::items', 'Method', 'api/basic_json/items/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::json_serializer', 'Class', 'api/basic_json/json_serializer/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::max_size', 'Method', 'api/basic_json/max_size/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::merge_patch', 'Method', 'api/basic_json/merge_patch/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::meta', 'Function', 'api/basic_json/meta/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::number_float_t', 'Type', 'api/basic_json/number_float_t/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::number_integer_t', 'Type', 'api/basic_json/number_integer_t/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::number_unsigned_t', 'Type', 'api/basic_json/number_unsigned_t/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::object', 'Function', 'api/basic_json/object/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::object_comparator_t', 'Type', 'api/basic_json/object_comparator_t/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::object_t', 'Type', 'api/basic_json/object_t/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator ValueType', 'Operator', 'api/basic_json/operator_ValueType/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator value_t', 'Operator', 'api/basic_json/operator_value_t/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator[]', 'Operator', 'api/basic_json/operator[]/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator=', 'Operator', 'api/basic_json/operator=/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator+=', 'Operator', 'api/basic_json/operator+=/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator==', 'Operator', 'api/basic_json/operator_eq/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator!=', 'Operator', 'api/basic_json/operator_ne/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator<', 'Operator', 'api/basic_json/operator_lt/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator<=', 'Operator', 'api/basic_json/operator_le/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator>', 'Operator', 'api/basic_json/operator_gt/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator>=', 'Operator', 'api/basic_json/operator_ge/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator<=>', 'Operator', 'api/basic_json/operator_spaceship/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::out_of_range', 'Class', 'api/basic_json/out_of_range/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::other_error', 'Class', 'api/basic_json/other_error/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::parse', 'Function', 'api/basic_json/parse/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::parse_error', 'Class', 'api/basic_json/parse_error/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::parse_event_t', 'Enum', 'api/basic_json/parse_event_t/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::parser_callback_t', 'Type', 'api/basic_json/parser_callback_t/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::patch', 'Method', 'api/basic_json/patch/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::patch_inplace', 'Method', 'api/basic_json/patch_inplace/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::push_back', 'Method', 'api/basic_json/push_back/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::rbegin', 'Method', 'api/basic_json/rbegin/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::rend', 'Method', 'api/basic_json/rend/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::sax_parse', 'Function', 'api/basic_json/sax_parse/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::size', 'Method', 'api/basic_json/size/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::string_t', 'Type', 'api/basic_json/string_t/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::swap', 'Method', 'api/basic_json/swap/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::type', 'Method', 'api/basic_json/type/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::type_error', 'Class', 'api/basic_json/type_error/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::type_name', 'Method', 'api/basic_json/type_name/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::unflatten', 'Method', 'api/basic_json/unflatten/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::update', 'Method', 'api/basic_json/update/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::to_bjdata', 'Function', 'api/basic_json/to_bjdata/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::to_bson', 'Function', 'api/basic_json/to_bson/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::to_cbor', 'Function', 'api/basic_json/to_cbor/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::to_msgpack', 'Function', 'api/basic_json/to_msgpack/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::to_string', 'Method', 'api/basic_json/to_string/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::to_ubjson', 'Function', 'api/basic_json/to_ubjson/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::value', 'Method', 'api/basic_json/value/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::value_t', 'Enum', 'api/basic_json/value_t/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::~basic_json', 'Method', 'api/basic_json/~basic_json/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json', 'Class', 'api/json/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer', 'Class', 'api/json_pointer/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::back', 'Method', 'api/json_pointer/back/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::empty', 'Method', 'api/json_pointer/empty/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::json_pointer', 'Constructor', 'api/json_pointer/json_pointer/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::operator==', 'Operator', 'api/json_pointer/operator_eq/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::operator!=', 'Operator', 'api/json_pointer/operator_ne/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::operator/', 'Operator', 'api/json_pointer/operator_slash/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::operator/=', 'Operator', 'api/json_pointer/operator_slasheq/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::operator string_t', 'Operator', 'api/json_pointer/operator_string_t/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::parent_pointer', 'Method', 'api/json_pointer/parent_pointer/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::pop_back', 'Method', 'api/json_pointer/pop_back/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::push_back', 'Method', 'api/json_pointer/push_back/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::string_t', 'Type', 'api/json_pointer/string_t/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::to_string', 'Method', 'api/json_pointer/to_string/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_sax', 'Class', 'api/json_sax/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::binary', 'Method', 'api/json_sax/binary/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::boolean', 'Method', 'api/json_sax/boolean/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::end_array', 'Method', 'api/json_sax/end_array/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::end_object', 'Method', 'api/json_sax/end_object/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::key', 'Method', 'api/json_sax/key/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::null', 'Method', 'api/json_sax/null/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::number_float', 'Method', 'api/json_sax/number_float/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::number_integer', 'Method', 'api/json_sax/number_integer/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::number_unsigned', 'Method', 'api/json_sax/number_unsigned/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::parse_error', 'Method', 'api/json_sax/parse_error/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::start_array', 'Method', 'api/json_sax/start_array/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::start_object', 'Method', 'api/json_sax/start_object/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::string', 'Method', 'api/json_sax/string/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('operator""_json', 'Literal', 'api/operator_literal_json/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('operator""_json_pointer', 'Literal', 'api/operator_literal_json_pointer/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('operator<<', 'Operator', 'api/operator_ltlt/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('operator>>', 'Operator', 'api/operator_gtgt/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('ordered_json', 'Class', 'api/ordered_json/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('ordered_map', 'Class', 'api/ordered_map/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('std::hash', 'Class', 'api/basic_json/std_hash/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('std::swap', 'Function', 'api/basic_json/std_swap/index.html'); + +-- Features +INSERT INTO searchIndex(name, type, path) VALUES ('Arbitrary Type Conversions', 'Guide', 'features/arbitrary_types/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Binary Formats', 'Guide', 'features/binary_formats/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Binary Formats: BJData', 'Guide', 'features/binary_formats/bjdata/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Binary Formats: BSON', 'Guide', 'features/binary_formats/bson/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Binary Formats: CBOR', 'Guide', 'features/binary_formats/cbor/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Binary Formats: MessagePack', 'Guide', 'features/binary_formats/messagepack/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Binary Formats: UBJSON', 'Guide', 'features/binary_formats/ubjson/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Binary Values', 'Guide', 'features/binary_values/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Comments', 'Guide', 'features/comments/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Element Access', 'Guide', 'features/element_access/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Element Access: Access with default value: value', 'Guide', 'features/element_access/default_value/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Element Access: Checked access: at', 'Guide', 'features/element_access/checked_access/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Element Access: Unchecked access: operator[]', 'Guide', 'features/element_access/unchecked_access/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Integration: Migration Guide', 'Guide', 'integration/migration_guide/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Integration: CMake', 'Guide', 'integration/cmake/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Integration: Header only', 'Guide', 'integration/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Integration: Package Managers', 'Guide', 'integration/package_managers/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Integration: Pkg-config', 'Guide', 'integration/pkg-config/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Iterators', 'Guide', 'features/iterators/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON Merge Patch', 'Guide', 'features/merge_patch/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON Patch and Diff', 'Guide', 'features/json_patch/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON Pointer', 'Guide', 'features/json_pointer/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('nlohmann Namespace', 'Guide', 'features/namespace/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Types', 'Guide', 'features/types/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Types: Number Handling', 'Guide', 'features/types/number_handling/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Object Order', 'Guide', 'features/object_order/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Parsing', 'Guide', 'features/parsing/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Parsing: JSON Lines', 'Guide', 'features/parsing/json_lines/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Parsing: Parser Callbacks', 'Guide', 'features/parsing/parser_callbacks/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Parsing: Parsing and Exceptions', 'Guide', 'features/parsing/parse_exceptions/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Parsing: SAX Interface', 'Guide', 'features/parsing/sax_interface/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Runtime Assertions', 'Guide', 'features/assertions/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Specializing enum conversion', 'Guide', 'features/enum_conversion/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Supported Macros', 'Guide', 'features/macros/index.html'); + +-- Macros +INSERT INTO searchIndex(name, type, path) VALUES ('JSON_ASSERT', 'Macro', 'api/macros/json_assert/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON_CATCH_USER', 'Macro', 'api/macros/json_throw_user/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON_DIAGNOSTICS', 'Macro', 'api/macros/json_diagnostics/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON_DISABLE_ENUM_SERIALIZATION', 'Macro', 'api/macros/json_disable_enum_serialization/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON_HAS_CPP_11', 'Macro', 'api/macros/json_has_cpp_11/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON_HAS_CPP_14', 'Macro', 'api/macros/json_has_cpp_11/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON_HAS_CPP_17', 'Macro', 'api/macros/json_has_cpp_11/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON_HAS_CPP_20', 'Macro', 'api/macros/json_has_cpp_11/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON_HAS_EXPERIMENTAL_FILESYSTEM', 'Macro', 'api/macros/json_has_filesystem/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON_HAS_FILESYSTEM', 'Macro', 'api/macros/json_has_filesystem/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON_HAS_RANGES', 'Macro', 'api/macros/json_has_ranges/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON_HAS_THREE_WAY_COMPARISON', 'Macro', 'api/macros/json_has_three_way_comparison/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON_NOEXCEPTION', 'Macro', 'api/macros/json_noexception/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON_NO_IO', 'Macro', 'api/macros/json_no_io/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON_SKIP_LIBRARY_VERSION_CHECK', 'Macro', 'api/macros/json_skip_library_version_check/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON_SKIP_UNSUPPORTED_COMPILER_CHECK', 'Macro', 'api/macros/json_skip_unsupported_compiler_check/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON_THROW_USER', 'Macro', 'api/macros/json_throw_user/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON_TRY_USER', 'Macro', 'api/macros/json_throw_user/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON_USE_GLOBAL_UDLS', 'Macro', 'api/macros/json_use_global_udls/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON_USE_IMPLICIT_CONVERSIONS', 'Macro', 'api/macros/json_use_implicit_conversions/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON', 'Macro', 'api/macros/json_use_legacy_discarded_value_comparison/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('Macros', 'Macro', 'api/macros/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_DEFINE_TYPE_INTRUSIVE', 'Macro', 'api/macros/nlohmann_define_type_intrusive/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT', 'Macro', 'api/macros/nlohmann_define_type_intrusive/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE', 'Macro', 'api/macros/nlohmann_define_type_non_intrusive/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT', 'Macro', 'api/macros/nlohmann_define_type_non_intrusive/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_NAMESPACE', 'Macro', 'api/macros/nlohmann_json_namespace/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_NAMESPACE_BEGIN', 'Macro', 'api/macros/nlohmann_json_namespace_begin/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_NAMESPACE_END', 'Macro', 'api/macros/nlohmann_json_namespace_begin/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_NAMESPACE_NO_VERSION', 'Macro', 'api/macros/nlohmann_json_namespace_no_version/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_SERIALIZE_ENUM', 'Macro', 'api/macros/nlohmann_json_serialize_enum/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_VERSION_MAJOR', 'Macro', 'api/macros/nlohmann_json_version_major/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_VERSION_MINOR', 'Macro', 'api/macros/nlohmann_json_version_major/index.html'); +INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_VERSION_PATCH', 'Macro', 'api/macros/nlohmann_json_version_major/index.html'); diff --git a/external_imported/json/docs/docset/docset.json b/external_imported/json/docs/docset/docset.json new file mode 100644 index 000000000..bc08d283d --- /dev/null +++ b/external_imported/json/docs/docset/docset.json @@ -0,0 +1,10 @@ +{ + "name": "JSON for Modern C++", + "version": "3.11.3", + "archive": "JSON_for_Modern_C++.tgz", + "author": { + "name": "Niels Lohmann", + "link": "https://twitter.com/nlohmann" + }, + "aliases": ["nlohmann/json"] +} diff --git a/external_imported/json/docs/docset/icon.png b/external_imported/json/docs/docset/icon.png new file mode 100644 index 000000000..7197d0a75 Binary files /dev/null and b/external_imported/json/docs/docset/icon.png differ diff --git a/external_imported/json/docs/docset/icon@2x.png b/external_imported/json/docs/docset/icon@2x.png new file mode 100644 index 000000000..5f2fac87a Binary files /dev/null and b/external_imported/json/docs/docset/icon@2x.png differ diff --git a/external_imported/json/doc/examples/README.cpp b/external_imported/json/docs/examples/README.cpp similarity index 100% rename from external_imported/json/doc/examples/README.cpp rename to external_imported/json/docs/examples/README.cpp diff --git a/external_imported/json/doc/examples/README.output b/external_imported/json/docs/examples/README.output similarity index 100% rename from external_imported/json/doc/examples/README.output rename to external_imported/json/docs/examples/README.output diff --git a/external_imported/json/doc/examples/accept__string.cpp b/external_imported/json/docs/examples/accept__string.cpp similarity index 100% rename from external_imported/json/doc/examples/accept__string.cpp rename to external_imported/json/docs/examples/accept__string.cpp diff --git a/external_imported/json/doc/examples/accept__string.output b/external_imported/json/docs/examples/accept__string.output similarity index 100% rename from external_imported/json/doc/examples/accept__string.output rename to external_imported/json/docs/examples/accept__string.output diff --git a/external_imported/json/doc/examples/array.cpp b/external_imported/json/docs/examples/array.cpp similarity index 100% rename from external_imported/json/doc/examples/array.cpp rename to external_imported/json/docs/examples/array.cpp diff --git a/external_imported/json/doc/examples/array.output b/external_imported/json/docs/examples/array.output similarity index 100% rename from external_imported/json/doc/examples/array.output rename to external_imported/json/docs/examples/array.output diff --git a/external_imported/json/docs/examples/array_t.cpp b/external_imported/json/docs/examples/array_t.cpp new file mode 100644 index 000000000..0964857b7 --- /dev/null +++ b/external_imported/json/docs/examples/array_t.cpp @@ -0,0 +1,10 @@ +#include +#include +#include + +using json = nlohmann::json; + +int main() +{ + std::cout << std::boolalpha << std::is_same, json::array_t>::value << std::endl; +} diff --git a/external_imported/json/docs/examples/array_t.output b/external_imported/json/docs/examples/array_t.output new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/external_imported/json/docs/examples/array_t.output @@ -0,0 +1 @@ +true diff --git a/external_imported/json/docs/examples/at__json_pointer.cpp b/external_imported/json/docs/examples/at__json_pointer.cpp new file mode 100644 index 000000000..15e91433d --- /dev/null +++ b/external_imported/json/docs/examples/at__json_pointer.cpp @@ -0,0 +1,103 @@ +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +int main() +{ + // create a JSON value + json j = + { + {"number", 1}, {"string", "foo"}, {"array", {1, 2}} + }; + + // read-only access + + // output element with JSON pointer "/number" + std::cout << j.at("/number"_json_pointer) << '\n'; + // output element with JSON pointer "/string" + std::cout << j.at("/string"_json_pointer) << '\n'; + // output element with JSON pointer "/array" + std::cout << j.at("/array"_json_pointer) << '\n'; + // output element with JSON pointer "/array/1" + std::cout << j.at("/array/1"_json_pointer) << '\n'; + + // writing access + + // change the string + j.at("/string"_json_pointer) = "bar"; + // output the changed string + std::cout << j["string"] << '\n'; + + // change an array element + j.at("/array/1"_json_pointer) = 21; + // output the changed array + std::cout << j["array"] << '\n'; + + // out_of_range.106 + try + { + // try to use an array index with leading '0' + json::reference ref = j.at("/array/01"_json_pointer); + } + catch (const json::parse_error& e) + { + std::cout << e.what() << '\n'; + } + + // out_of_range.109 + try + { + // try to use an array index that is not a number + json::reference ref = j.at("/array/one"_json_pointer); + } + catch (const json::parse_error& e) + { + std::cout << e.what() << '\n'; + } + + // out_of_range.401 + try + { + // try to use an invalid array index + json::reference ref = j.at("/array/4"_json_pointer); + } + catch (const json::out_of_range& e) + { + std::cout << e.what() << '\n'; + } + + // out_of_range.402 + try + { + // try to use the array index '-' + json::reference ref = j.at("/array/-"_json_pointer); + } + catch (const json::out_of_range& e) + { + std::cout << e.what() << '\n'; + } + + // out_of_range.403 + try + { + // try to use a JSON pointer to a nonexistent object key + json::const_reference ref = j.at("/foo"_json_pointer); + } + catch (const json::out_of_range& e) + { + std::cout << e.what() << '\n'; + } + + // out_of_range.404 + try + { + // try to use a JSON pointer that cannot be resolved + json::reference ref = j.at("/number/foo"_json_pointer); + } + catch (const json::out_of_range& e) + { + std::cout << e.what() << '\n'; + } +} diff --git a/external_imported/json/doc/examples/at_json_pointer.output b/external_imported/json/docs/examples/at__json_pointer.output similarity index 100% rename from external_imported/json/doc/examples/at_json_pointer.output rename to external_imported/json/docs/examples/at__json_pointer.output diff --git a/external_imported/json/docs/examples/at__json_pointer_const.cpp b/external_imported/json/docs/examples/at__json_pointer_const.cpp new file mode 100644 index 000000000..ab026e078 --- /dev/null +++ b/external_imported/json/docs/examples/at__json_pointer_const.cpp @@ -0,0 +1,80 @@ +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +int main() +{ + // create a JSON value + const json j = + { + {"number", 1}, {"string", "foo"}, {"array", {1, 2}} + }; + + // read-only access + + // output element with JSON pointer "/number" + std::cout << j.at("/number"_json_pointer) << '\n'; + // output element with JSON pointer "/string" + std::cout << j.at("/string"_json_pointer) << '\n'; + // output element with JSON pointer "/array" + std::cout << j.at("/array"_json_pointer) << '\n'; + // output element with JSON pointer "/array/1" + std::cout << j.at("/array/1"_json_pointer) << '\n'; + + // out_of_range.109 + try + { + // try to use an array index that is not a number + json::const_reference ref = j.at("/array/one"_json_pointer); + } + catch (const json::parse_error& e) + { + std::cout << e.what() << '\n'; + } + + // out_of_range.401 + try + { + // try to use an invalid array index + json::const_reference ref = j.at("/array/4"_json_pointer); + } + catch (const json::out_of_range& e) + { + std::cout << e.what() << '\n'; + } + + // out_of_range.402 + try + { + // try to use the array index '-' + json::const_reference ref = j.at("/array/-"_json_pointer); + } + catch (const json::out_of_range& e) + { + std::cout << e.what() << '\n'; + } + + // out_of_range.403 + try + { + // try to use a JSON pointer to a nonexistent object key + json::const_reference ref = j.at("/foo"_json_pointer); + } + catch (const json::out_of_range& e) + { + std::cout << e.what() << '\n'; + } + + // out_of_range.404 + try + { + // try to use a JSON pointer that cannot be resolved + json::const_reference ref = j.at("/number/foo"_json_pointer); + } + catch (const json::out_of_range& e) + { + std::cout << e.what() << '\n'; + } +} diff --git a/external_imported/json/doc/examples/at_json_pointer_const.output b/external_imported/json/docs/examples/at__json_pointer_const.output similarity index 100% rename from external_imported/json/doc/examples/at_json_pointer_const.output rename to external_imported/json/docs/examples/at__json_pointer_const.output diff --git a/external_imported/json/docs/examples/at__keytype.c++17.cpp b/external_imported/json/docs/examples/at__keytype.c++17.cpp new file mode 100644 index 000000000..032506acd --- /dev/null +++ b/external_imported/json/docs/examples/at__keytype.c++17.cpp @@ -0,0 +1,49 @@ +#include +#include +#include + +using namespace std::string_view_literals; +using json = nlohmann::json; + +int main() +{ + // create JSON object + json object = + { + {"the good", "il buono"}, + {"the bad", "il cattivo"}, + {"the ugly", "il brutto"} + }; + + // output element with key "the ugly" using string_view + std::cout << object.at("the ugly"sv) << '\n'; + + // change element with key "the bad" using string_view + object.at("the bad"sv) = "il cattivo"; + + // output changed array + std::cout << object << '\n'; + + // exception type_error.304 + try + { + // use at() with string_view on a non-object type + json str = "I am a string"; + str.at("the good"sv) = "Another string"; + } + catch (const json::type_error& e) + { + std::cout << e.what() << '\n'; + } + + // exception out_of_range.401 + try + { + // try to write at a nonexisting key using string_view + object.at("the fast"sv) = "il rapido"; + } + catch (const json::out_of_range& e) + { + std::cout << e.what() << '\n'; + } +} diff --git a/external_imported/json/doc/examples/at__object_t_key_type.output b/external_imported/json/docs/examples/at__keytype.c++17.output similarity index 100% rename from external_imported/json/doc/examples/at__object_t_key_type.output rename to external_imported/json/docs/examples/at__keytype.c++17.output diff --git a/external_imported/json/docs/examples/at__keytype_const.c++17.cpp b/external_imported/json/docs/examples/at__keytype_const.c++17.cpp new file mode 100644 index 000000000..b08cd17b5 --- /dev/null +++ b/external_imported/json/docs/examples/at__keytype_const.c++17.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +using namespace std::string_view_literals; +using json = nlohmann::json; + +int main() +{ + // create JSON object + const json object = + { + {"the good", "il buono"}, + {"the bad", "il cattivo"}, + {"the ugly", "il brutto"} + }; + + // output element with key "the ugly" using string_view + std::cout << object.at("the ugly"sv) << '\n'; + + // exception type_error.304 + try + { + // use at() with string_view on a non-object type + const json str = "I am a string"; + std::cout << str.at("the good"sv) << '\n'; + } + catch (const json::type_error& e) + { + std::cout << e.what() << '\n'; + } + + // exception out_of_range.401 + try + { + // try to read from a nonexisting key using string_view + std::cout << object.at("the fast"sv) << '\n'; + } + catch (const json::out_of_range) + { + std::cout << "out of range" << '\n'; + } +} diff --git a/external_imported/json/doc/examples/at__object_t_key_type_const.output b/external_imported/json/docs/examples/at__keytype_const.c++17.output similarity index 100% rename from external_imported/json/doc/examples/at__object_t_key_type_const.output rename to external_imported/json/docs/examples/at__keytype_const.c++17.output diff --git a/external_imported/json/doc/examples/at__object_t_key_type.cpp b/external_imported/json/docs/examples/at__object_t_key_type.cpp similarity index 92% rename from external_imported/json/doc/examples/at__object_t_key_type.cpp rename to external_imported/json/docs/examples/at__object_t_key_type.cpp index 202f8a2ee..e1f33ceca 100644 --- a/external_imported/json/doc/examples/at__object_t_key_type.cpp +++ b/external_imported/json/docs/examples/at__object_t_key_type.cpp @@ -22,7 +22,6 @@ int main() // output changed array std::cout << object << '\n'; - // exception type_error.304 try { @@ -30,7 +29,7 @@ int main() json str = "I am a string"; str.at("the good") = "Another string"; } - catch (json::type_error& e) + catch (const json::type_error& e) { std::cout << e.what() << '\n'; } @@ -41,7 +40,7 @@ int main() // try to write at a nonexisting key object.at("the fast") = "il rapido"; } - catch (json::out_of_range& e) + catch (const json::out_of_range& e) { std::cout << e.what() << '\n'; } diff --git a/external_imported/json/docs/examples/at__object_t_key_type.output b/external_imported/json/docs/examples/at__object_t_key_type.output new file mode 100644 index 000000000..b544b7299 --- /dev/null +++ b/external_imported/json/docs/examples/at__object_t_key_type.output @@ -0,0 +1,4 @@ +"il brutto" +{"the bad":"il cattivo","the good":"il buono","the ugly":"il brutto"} +[json.exception.type_error.304] cannot use at() with string +[json.exception.out_of_range.403] key 'the fast' not found diff --git a/external_imported/json/doc/examples/at__object_t_key_type_const.cpp b/external_imported/json/docs/examples/at__object_t_key_type_const.cpp similarity index 91% rename from external_imported/json/doc/examples/at__object_t_key_type_const.cpp rename to external_imported/json/docs/examples/at__object_t_key_type_const.cpp index e5244f3f7..b37bbd489 100644 --- a/external_imported/json/doc/examples/at__object_t_key_type_const.cpp +++ b/external_imported/json/docs/examples/at__object_t_key_type_const.cpp @@ -16,7 +16,6 @@ int main() // output element with key "the ugly" std::cout << object.at("the ugly") << '\n'; - // exception type_error.304 try { @@ -24,7 +23,7 @@ int main() const json str = "I am a string"; std::cout << str.at("the good") << '\n'; } - catch (json::type_error& e) + catch (const json::type_error& e) { std::cout << e.what() << '\n'; } @@ -35,7 +34,7 @@ int main() // try to read from a nonexisting key std::cout << object.at("the fast") << '\n'; } - catch (json::out_of_range) + catch (const json::out_of_range) { std::cout << "out of range" << '\n'; } diff --git a/external_imported/json/docs/examples/at__object_t_key_type_const.output b/external_imported/json/docs/examples/at__object_t_key_type_const.output new file mode 100644 index 000000000..40ca3f09f --- /dev/null +++ b/external_imported/json/docs/examples/at__object_t_key_type_const.output @@ -0,0 +1,3 @@ +"il brutto" +[json.exception.type_error.304] cannot use at() with string +out of range diff --git a/external_imported/json/doc/examples/at__size_type.cpp b/external_imported/json/docs/examples/at__size_type.cpp similarity index 91% rename from external_imported/json/doc/examples/at__size_type.cpp rename to external_imported/json/docs/examples/at__size_type.cpp index 65baeddcf..6527c6b16 100644 --- a/external_imported/json/doc/examples/at__size_type.cpp +++ b/external_imported/json/docs/examples/at__size_type.cpp @@ -17,7 +17,6 @@ int main() // output changed array std::cout << array << '\n'; - // exception type_error.304 try { @@ -25,7 +24,7 @@ int main() json str = "I am a string"; str.at(0) = "Another string"; } - catch (json::type_error& e) + catch (const json::type_error& e) { std::cout << e.what() << '\n'; } @@ -36,7 +35,7 @@ int main() // try to write beyond the array limit array.at(5) = "sixth"; } - catch (json::out_of_range& e) + catch (const json::out_of_range& e) { std::cout << e.what() << '\n'; } diff --git a/external_imported/json/doc/examples/at__size_type.output b/external_imported/json/docs/examples/at__size_type.output similarity index 100% rename from external_imported/json/doc/examples/at__size_type.output rename to external_imported/json/docs/examples/at__size_type.output diff --git a/external_imported/json/doc/examples/at__size_type_const.cpp b/external_imported/json/docs/examples/at__size_type_const.cpp similarity index 89% rename from external_imported/json/doc/examples/at__size_type_const.cpp rename to external_imported/json/docs/examples/at__size_type_const.cpp index faa4cffdd..2080387a3 100644 --- a/external_imported/json/doc/examples/at__size_type_const.cpp +++ b/external_imported/json/docs/examples/at__size_type_const.cpp @@ -11,7 +11,6 @@ int main() // output element at index 2 (third element) std::cout << array.at(2) << '\n'; - // exception type_error.304 try { @@ -19,7 +18,7 @@ int main() const json str = "I am a string"; std::cout << str.at(0) << '\n'; } - catch (json::type_error& e) + catch (const json::type_error& e) { std::cout << e.what() << '\n'; } @@ -30,7 +29,7 @@ int main() // try to read beyond the array limit std::cout << array.at(5) << '\n'; } - catch (json::out_of_range& e) + catch (const json::out_of_range& e) { std::cout << e.what() << '\n'; } diff --git a/external_imported/json/doc/examples/at__size_type_const.output b/external_imported/json/docs/examples/at__size_type_const.output similarity index 100% rename from external_imported/json/doc/examples/at__size_type_const.output rename to external_imported/json/docs/examples/at__size_type_const.output diff --git a/external_imported/json/doc/examples/back.cpp b/external_imported/json/docs/examples/back.cpp similarity index 95% rename from external_imported/json/doc/examples/back.cpp rename to external_imported/json/docs/examples/back.cpp index 1439a8218..45342db13 100644 --- a/external_imported/json/doc/examples/back.cpp +++ b/external_imported/json/docs/examples/back.cpp @@ -31,7 +31,7 @@ int main() json j_null; j_null.back(); } - catch (json::invalid_iterator& e) + catch (const json::invalid_iterator& e) { std::cout << e.what() << '\n'; } diff --git a/external_imported/json/doc/examples/back.output b/external_imported/json/docs/examples/back.output similarity index 100% rename from external_imported/json/doc/examples/back.output rename to external_imported/json/docs/examples/back.output diff --git a/external_imported/json/doc/examples/basic_json__CompatibleType.cpp b/external_imported/json/docs/examples/basic_json__CompatibleType.cpp similarity index 98% rename from external_imported/json/doc/examples/basic_json__CompatibleType.cpp rename to external_imported/json/docs/examples/basic_json__CompatibleType.cpp index d39fd7a43..f0d0cc1e7 100644 --- a/external_imported/json/doc/examples/basic_json__CompatibleType.cpp +++ b/external_imported/json/docs/examples/basic_json__CompatibleType.cpp @@ -55,7 +55,6 @@ int main() std::cout << j_mmap << '\n'; std::cout << j_ummap << "\n\n"; - // =========== // array types // =========== @@ -81,7 +80,7 @@ int main() json j_list(c_list); // create an array from std::forward_list - std::forward_list c_flist {12345678909876, 23456789098765, 34567890987654, 45678909876543}; + std::forward_list c_flist {12345678909876, 23456789098765, 34567890987654, 45678909876543}; json j_flist(c_flist); // create an array from std::array @@ -117,7 +116,6 @@ int main() std::cout << j_mset << '\n'; std::cout << j_umset << "\n\n"; - // ============ // string types // ============ @@ -138,7 +136,6 @@ int main() std::cout << j_string_literal << '\n'; std::cout << j_stdstring << "\n\n"; - // ============ // number types // ============ @@ -203,7 +200,6 @@ int main() std::cout << j_float_nan << '\n'; std::cout << j_double << "\n\n"; - // ============= // boolean types // ============= diff --git a/external_imported/json/doc/examples/basic_json__CompatibleType.output b/external_imported/json/docs/examples/basic_json__CompatibleType.output similarity index 100% rename from external_imported/json/doc/examples/basic_json__CompatibleType.output rename to external_imported/json/docs/examples/basic_json__CompatibleType.output diff --git a/external_imported/json/doc/examples/basic_json__InputIt_InputIt.cpp b/external_imported/json/docs/examples/basic_json__InputIt_InputIt.cpp similarity index 94% rename from external_imported/json/doc/examples/basic_json__InputIt_InputIt.cpp rename to external_imported/json/docs/examples/basic_json__InputIt_InputIt.cpp index ed5aff9a8..dec693c80 100644 --- a/external_imported/json/doc/examples/basic_json__InputIt_InputIt.cpp +++ b/external_imported/json/docs/examples/basic_json__InputIt_InputIt.cpp @@ -25,7 +25,7 @@ int main() { json j_invalid(j_number.begin() + 1, j_number.end()); } - catch (json::invalid_iterator& e) + catch (const json::invalid_iterator& e) { std::cout << e.what() << '\n'; } diff --git a/external_imported/json/doc/examples/basic_json__InputIt_InputIt.output b/external_imported/json/docs/examples/basic_json__InputIt_InputIt.output similarity index 100% rename from external_imported/json/doc/examples/basic_json__InputIt_InputIt.output rename to external_imported/json/docs/examples/basic_json__InputIt_InputIt.output diff --git a/external_imported/json/doc/examples/basic_json__basic_json.cpp b/external_imported/json/docs/examples/basic_json__basic_json.cpp similarity index 100% rename from external_imported/json/doc/examples/basic_json__basic_json.cpp rename to external_imported/json/docs/examples/basic_json__basic_json.cpp diff --git a/external_imported/json/doc/examples/basic_json__basic_json.output b/external_imported/json/docs/examples/basic_json__basic_json.output similarity index 100% rename from external_imported/json/doc/examples/basic_json__basic_json.output rename to external_imported/json/docs/examples/basic_json__basic_json.output diff --git a/external_imported/json/doc/examples/basic_json__copyassignment.cpp b/external_imported/json/docs/examples/basic_json__copyassignment.cpp similarity index 100% rename from external_imported/json/doc/examples/basic_json__copyassignment.cpp rename to external_imported/json/docs/examples/basic_json__copyassignment.cpp diff --git a/external_imported/json/doc/examples/basic_json__copyassignment.output b/external_imported/json/docs/examples/basic_json__copyassignment.output similarity index 100% rename from external_imported/json/doc/examples/basic_json__copyassignment.output rename to external_imported/json/docs/examples/basic_json__copyassignment.output diff --git a/external_imported/json/doc/examples/basic_json__list_init_t.cpp b/external_imported/json/docs/examples/basic_json__list_init_t.cpp similarity index 100% rename from external_imported/json/doc/examples/basic_json__list_init_t.cpp rename to external_imported/json/docs/examples/basic_json__list_init_t.cpp diff --git a/external_imported/json/doc/examples/basic_json__list_init_t.output b/external_imported/json/docs/examples/basic_json__list_init_t.output similarity index 100% rename from external_imported/json/doc/examples/basic_json__list_init_t.output rename to external_imported/json/docs/examples/basic_json__list_init_t.output diff --git a/external_imported/json/doc/examples/basic_json__moveconstructor.cpp b/external_imported/json/docs/examples/basic_json__moveconstructor.cpp similarity index 100% rename from external_imported/json/doc/examples/basic_json__moveconstructor.cpp rename to external_imported/json/docs/examples/basic_json__moveconstructor.cpp diff --git a/external_imported/json/doc/examples/basic_json__moveconstructor.output b/external_imported/json/docs/examples/basic_json__moveconstructor.output similarity index 100% rename from external_imported/json/doc/examples/basic_json__moveconstructor.output rename to external_imported/json/docs/examples/basic_json__moveconstructor.output diff --git a/external_imported/json/doc/examples/basic_json__nullptr_t.cpp b/external_imported/json/docs/examples/basic_json__nullptr_t.cpp similarity index 100% rename from external_imported/json/doc/examples/basic_json__nullptr_t.cpp rename to external_imported/json/docs/examples/basic_json__nullptr_t.cpp diff --git a/external_imported/json/doc/examples/basic_json__nullptr_t.output b/external_imported/json/docs/examples/basic_json__nullptr_t.output similarity index 100% rename from external_imported/json/doc/examples/basic_json__nullptr_t.output rename to external_imported/json/docs/examples/basic_json__nullptr_t.output diff --git a/external_imported/json/doc/examples/basic_json__size_type_basic_json.cpp b/external_imported/json/docs/examples/basic_json__size_type_basic_json.cpp similarity index 100% rename from external_imported/json/doc/examples/basic_json__size_type_basic_json.cpp rename to external_imported/json/docs/examples/basic_json__size_type_basic_json.cpp diff --git a/external_imported/json/doc/examples/basic_json__size_type_basic_json.output b/external_imported/json/docs/examples/basic_json__size_type_basic_json.output similarity index 100% rename from external_imported/json/doc/examples/basic_json__size_type_basic_json.output rename to external_imported/json/docs/examples/basic_json__size_type_basic_json.output diff --git a/external_imported/json/doc/examples/basic_json__value_t.cpp b/external_imported/json/docs/examples/basic_json__value_t.cpp similarity index 100% rename from external_imported/json/doc/examples/basic_json__value_t.cpp rename to external_imported/json/docs/examples/basic_json__value_t.cpp diff --git a/external_imported/json/doc/examples/basic_json__value_t.output b/external_imported/json/docs/examples/basic_json__value_t.output similarity index 100% rename from external_imported/json/doc/examples/basic_json__value_t.output rename to external_imported/json/docs/examples/basic_json__value_t.output diff --git a/external_imported/json/doc/examples/begin.cpp b/external_imported/json/docs/examples/begin.cpp similarity index 100% rename from external_imported/json/doc/examples/begin.cpp rename to external_imported/json/docs/examples/begin.cpp diff --git a/external_imported/json/doc/examples/begin.output b/external_imported/json/docs/examples/begin.output similarity index 100% rename from external_imported/json/doc/examples/begin.output rename to external_imported/json/docs/examples/begin.output diff --git a/external_imported/json/docs/examples/binary.cpp b/external_imported/json/docs/examples/binary.cpp new file mode 100644 index 000000000..617ce6096 --- /dev/null +++ b/external_imported/json/docs/examples/binary.cpp @@ -0,0 +1,16 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + // create a binary vector + std::vector vec = {0xCA, 0xFE, 0xBA, 0xBE}; + + // create a binary JSON value with subtype 42 + json j = json::binary(vec, 42); + + // output type and subtype + std::cout << "type: " << j.type_name() << ", subtype: " << j.get_binary().subtype() << std::endl; +} diff --git a/external_imported/json/docs/examples/binary.output b/external_imported/json/docs/examples/binary.output new file mode 100644 index 000000000..74b05d23f --- /dev/null +++ b/external_imported/json/docs/examples/binary.output @@ -0,0 +1 @@ +type: binary, subtype: 42 diff --git a/external_imported/json/docs/examples/binary_t.cpp b/external_imported/json/docs/examples/binary_t.cpp new file mode 100644 index 000000000..bfaee5ca8 --- /dev/null +++ b/external_imported/json/docs/examples/binary_t.cpp @@ -0,0 +1,10 @@ +#include +#include +#include + +using json = nlohmann::json; + +int main() +{ + std::cout << std::boolalpha << std::is_same>, json::binary_t>::value << std::endl; +} diff --git a/external_imported/json/docs/examples/binary_t.output b/external_imported/json/docs/examples/binary_t.output new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/external_imported/json/docs/examples/binary_t.output @@ -0,0 +1 @@ +true diff --git a/external_imported/json/docs/examples/boolean_t.cpp b/external_imported/json/docs/examples/boolean_t.cpp new file mode 100644 index 000000000..75b8c99f9 --- /dev/null +++ b/external_imported/json/docs/examples/boolean_t.cpp @@ -0,0 +1,10 @@ +#include +#include +#include + +using json = nlohmann::json; + +int main() +{ + std::cout << std::boolalpha << std::is_same::value << std::endl; +} diff --git a/external_imported/json/docs/examples/boolean_t.output b/external_imported/json/docs/examples/boolean_t.output new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/external_imported/json/docs/examples/boolean_t.output @@ -0,0 +1 @@ +true diff --git a/external_imported/json/docs/examples/byte_container_with_subtype__byte_container_with_subtype.cpp b/external_imported/json/docs/examples/byte_container_with_subtype__byte_container_with_subtype.cpp new file mode 100644 index 000000000..1c10be5c2 --- /dev/null +++ b/external_imported/json/docs/examples/byte_container_with_subtype__byte_container_with_subtype.cpp @@ -0,0 +1,23 @@ +#include +#include + +// define a byte container based on std::vector +using byte_container_with_subtype = nlohmann::byte_container_with_subtype>; + +using json = nlohmann::json; + +int main() +{ + // (1) create empty container + auto c1 = byte_container_with_subtype(); + + std::vector bytes = {{0xca, 0xfe, 0xba, 0xbe}}; + + // (2) create container + auto c2 = byte_container_with_subtype(bytes); + + // (3) create container with subtype + auto c3 = byte_container_with_subtype(bytes, 42); + + std::cout << json(c1) << "\n" << json(c2) << "\n" << json(c3) << std::endl; +} diff --git a/external_imported/json/docs/examples/byte_container_with_subtype__byte_container_with_subtype.output b/external_imported/json/docs/examples/byte_container_with_subtype__byte_container_with_subtype.output new file mode 100644 index 000000000..67ac1b2ef --- /dev/null +++ b/external_imported/json/docs/examples/byte_container_with_subtype__byte_container_with_subtype.output @@ -0,0 +1,3 @@ +{"bytes":[],"subtype":null} +{"bytes":[202,254,186,190],"subtype":null} +{"bytes":[202,254,186,190],"subtype":42} diff --git a/external_imported/json/docs/examples/byte_container_with_subtype__clear_subtype.cpp b/external_imported/json/docs/examples/byte_container_with_subtype__clear_subtype.cpp new file mode 100644 index 000000000..f9ce6842b --- /dev/null +++ b/external_imported/json/docs/examples/byte_container_with_subtype__clear_subtype.cpp @@ -0,0 +1,21 @@ +#include +#include + +// define a byte container based on std::vector +using byte_container_with_subtype = nlohmann::byte_container_with_subtype>; + +using json = nlohmann::json; + +int main() +{ + std::vector bytes = {{0xca, 0xfe, 0xba, 0xbe}}; + + // create container with subtype + auto c1 = byte_container_with_subtype(bytes, 42); + + std::cout << "before calling clear_subtype(): " << json(c1) << '\n'; + + c1.clear_subtype(); + + std::cout << "after calling clear_subtype(): " << json(c1) << '\n'; +} diff --git a/external_imported/json/docs/examples/byte_container_with_subtype__clear_subtype.output b/external_imported/json/docs/examples/byte_container_with_subtype__clear_subtype.output new file mode 100644 index 000000000..9d8212946 --- /dev/null +++ b/external_imported/json/docs/examples/byte_container_with_subtype__clear_subtype.output @@ -0,0 +1,2 @@ +before calling clear_subtype(): {"bytes":[202,254,186,190],"subtype":42} +after calling clear_subtype(): {"bytes":[202,254,186,190],"subtype":null} diff --git a/external_imported/json/docs/examples/byte_container_with_subtype__has_subtype.cpp b/external_imported/json/docs/examples/byte_container_with_subtype__has_subtype.cpp new file mode 100644 index 000000000..61c21eaae --- /dev/null +++ b/external_imported/json/docs/examples/byte_container_with_subtype__has_subtype.cpp @@ -0,0 +1,19 @@ +#include +#include + +// define a byte container based on std::vector +using byte_container_with_subtype = nlohmann::byte_container_with_subtype>; + +int main() +{ + std::vector bytes = {{0xca, 0xfe, 0xba, 0xbe}}; + + // create container + auto c1 = byte_container_with_subtype(bytes); + + // create container with subtype + auto c2 = byte_container_with_subtype(bytes, 42); + + std::cout << std::boolalpha << "c1.has_subtype() = " << c1.has_subtype() + << "\nc2.has_subtype() = " << c2.has_subtype() << std::endl; +} diff --git a/external_imported/json/docs/examples/byte_container_with_subtype__has_subtype.output b/external_imported/json/docs/examples/byte_container_with_subtype__has_subtype.output new file mode 100644 index 000000000..f4aade2a1 --- /dev/null +++ b/external_imported/json/docs/examples/byte_container_with_subtype__has_subtype.output @@ -0,0 +1,2 @@ +c1.has_subtype() = false +c2.has_subtype() = true diff --git a/external_imported/json/docs/examples/byte_container_with_subtype__set_subtype.cpp b/external_imported/json/docs/examples/byte_container_with_subtype__set_subtype.cpp new file mode 100644 index 000000000..b2694c54d --- /dev/null +++ b/external_imported/json/docs/examples/byte_container_with_subtype__set_subtype.cpp @@ -0,0 +1,22 @@ +#include +#include + +// define a byte container based on std::vector +using byte_container_with_subtype = nlohmann::byte_container_with_subtype>; + +using json = nlohmann::json; + +int main() +{ + std::vector bytes = {{0xca, 0xfe, 0xba, 0xbe}}; + + // create container without subtype + auto c = byte_container_with_subtype(bytes); + + std::cout << "before calling set_subtype(42): " << json(c) << '\n'; + + // set the subtype + c.set_subtype(42); + + std::cout << "after calling set_subtype(42): " << json(c) << '\n'; +} diff --git a/external_imported/json/docs/examples/byte_container_with_subtype__set_subtype.output b/external_imported/json/docs/examples/byte_container_with_subtype__set_subtype.output new file mode 100644 index 000000000..648b3ef24 --- /dev/null +++ b/external_imported/json/docs/examples/byte_container_with_subtype__set_subtype.output @@ -0,0 +1,2 @@ +before calling set_subtype(42): {"bytes":[202,254,186,190],"subtype":null} +after calling set_subtype(42): {"bytes":[202,254,186,190],"subtype":42} diff --git a/external_imported/json/docs/examples/byte_container_with_subtype__subtype.cpp b/external_imported/json/docs/examples/byte_container_with_subtype__subtype.cpp new file mode 100644 index 000000000..cd230ade1 --- /dev/null +++ b/external_imported/json/docs/examples/byte_container_with_subtype__subtype.cpp @@ -0,0 +1,22 @@ +#include +#include + +// define a byte container based on std::vector +using byte_container_with_subtype = nlohmann::byte_container_with_subtype>; + +int main() +{ + std::vector bytes = {{0xca, 0xfe, 0xba, 0xbe}}; + + // create container + auto c1 = byte_container_with_subtype(bytes); + + // create container with subtype + auto c2 = byte_container_with_subtype(bytes, 42); + + std::cout << "c1.subtype() = " << c1.subtype() + << "\nc2.subtype() = " << c2.subtype() << std::endl; + + // in case no subtype is set, return special value + assert(c1.subtype() == static_cast(-1)); +} diff --git a/external_imported/json/docs/examples/byte_container_with_subtype__subtype.output b/external_imported/json/docs/examples/byte_container_with_subtype__subtype.output new file mode 100644 index 000000000..47955277b --- /dev/null +++ b/external_imported/json/docs/examples/byte_container_with_subtype__subtype.output @@ -0,0 +1,2 @@ +c1.subtype() = 18446744073709551615 +c2.subtype() = 42 diff --git a/external_imported/json/doc/examples/cbegin.cpp b/external_imported/json/docs/examples/cbegin.cpp similarity index 100% rename from external_imported/json/doc/examples/cbegin.cpp rename to external_imported/json/docs/examples/cbegin.cpp diff --git a/external_imported/json/doc/examples/cbegin.output b/external_imported/json/docs/examples/cbegin.output similarity index 100% rename from external_imported/json/doc/examples/cbegin.output rename to external_imported/json/docs/examples/cbegin.output diff --git a/external_imported/json/docs/examples/cbor_tag_handler_t.cpp b/external_imported/json/docs/examples/cbor_tag_handler_t.cpp new file mode 100644 index 000000000..38d168ca8 --- /dev/null +++ b/external_imported/json/docs/examples/cbor_tag_handler_t.cpp @@ -0,0 +1,28 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + // tagged byte string + std::vector vec = {{0xd8, 0x42, 0x44, 0xcA, 0xfe, 0xba, 0xbe}}; + + // cbor_tag_handler_t::error throws + try + { + auto b_throw_on_tag = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::error); + } + catch (const json::parse_error& e) + { + std::cout << e.what() << std::endl; + } + + // cbor_tag_handler_t::ignore ignores the tag + auto b_ignore_tag = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::ignore); + std::cout << b_ignore_tag << std::endl; + + // cbor_tag_handler_t::store stores the tag as binary subtype + auto b_store_tag = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::store); + std::cout << b_store_tag << std::endl; +} diff --git a/external_imported/json/docs/examples/cbor_tag_handler_t.output b/external_imported/json/docs/examples/cbor_tag_handler_t.output new file mode 100644 index 000000000..18920b137 --- /dev/null +++ b/external_imported/json/docs/examples/cbor_tag_handler_t.output @@ -0,0 +1,3 @@ +[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing CBOR value: invalid byte: 0xD8 +{"bytes":[202,254,186,190],"subtype":null} +{"bytes":[202,254,186,190],"subtype":66} diff --git a/external_imported/json/doc/examples/cend.cpp b/external_imported/json/docs/examples/cend.cpp similarity index 100% rename from external_imported/json/doc/examples/cend.cpp rename to external_imported/json/docs/examples/cend.cpp diff --git a/external_imported/json/doc/examples/cend.output b/external_imported/json/docs/examples/cend.output similarity index 100% rename from external_imported/json/doc/examples/cend.output rename to external_imported/json/docs/examples/cend.output diff --git a/external_imported/json/doc/examples/clear.cpp b/external_imported/json/docs/examples/clear.cpp similarity index 100% rename from external_imported/json/doc/examples/clear.cpp rename to external_imported/json/docs/examples/clear.cpp diff --git a/external_imported/json/doc/examples/clear.output b/external_imported/json/docs/examples/clear.output similarity index 100% rename from external_imported/json/doc/examples/clear.output rename to external_imported/json/docs/examples/clear.output diff --git a/external_imported/json/docs/examples/contains__json_pointer.cpp b/external_imported/json/docs/examples/contains__json_pointer.cpp new file mode 100644 index 000000000..14d8514b4 --- /dev/null +++ b/external_imported/json/docs/examples/contains__json_pointer.cpp @@ -0,0 +1,43 @@ +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +int main() +{ + // create a JSON value + json j = + { + {"number", 1}, {"string", "foo"}, {"array", {1, 2}} + }; + + std::cout << std::boolalpha + << j.contains("/number"_json_pointer) << '\n' + << j.contains("/string"_json_pointer) << '\n' + << j.contains("/array"_json_pointer) << '\n' + << j.contains("/array/1"_json_pointer) << '\n' + << j.contains("/array/-"_json_pointer) << '\n' + << j.contains("/array/4"_json_pointer) << '\n' + << j.contains("/baz"_json_pointer) << std::endl; + + try + { + // try to use an array index with leading '0' + j.contains("/array/01"_json_pointer); + } + catch (const json::parse_error& e) + { + std::cout << e.what() << '\n'; + } + + try + { + // try to use an array index that is not a number + j.contains("/array/one"_json_pointer); + } + catch (const json::parse_error& e) + { + std::cout << e.what() << '\n'; + } +} diff --git a/external_imported/json/doc/examples/contains_json_pointer.output b/external_imported/json/docs/examples/contains__json_pointer.output similarity index 100% rename from external_imported/json/doc/examples/contains_json_pointer.output rename to external_imported/json/docs/examples/contains__json_pointer.output diff --git a/external_imported/json/docs/examples/contains__keytype.c++17.cpp b/external_imported/json/docs/examples/contains__keytype.c++17.cpp new file mode 100644 index 000000000..43b62fab1 --- /dev/null +++ b/external_imported/json/docs/examples/contains__keytype.c++17.cpp @@ -0,0 +1,20 @@ +#include +#include +#include + +using namespace std::string_view_literals; +using json = nlohmann::json; +using namespace nlohmann::literals; + +int main() +{ + // create some JSON values + json j_object = R"( {"key": "value"} )"_json; + json j_array = R"( [1, 2, 3] )"_json; + + // call contains + std::cout << std::boolalpha << + "j_object contains 'key': " << j_object.contains("key"sv) << '\n' << + "j_object contains 'another': " << j_object.contains("another"sv) << '\n' << + "j_array contains 'key': " << j_array.contains("key"sv) << std::endl; +} diff --git a/external_imported/json/doc/examples/contains.output b/external_imported/json/docs/examples/contains__keytype.c++17.output similarity index 100% rename from external_imported/json/doc/examples/contains.output rename to external_imported/json/docs/examples/contains__keytype.c++17.output diff --git a/external_imported/json/docs/examples/contains__object_t_key_type.cpp b/external_imported/json/docs/examples/contains__object_t_key_type.cpp new file mode 100644 index 000000000..a8bc8143d --- /dev/null +++ b/external_imported/json/docs/examples/contains__object_t_key_type.cpp @@ -0,0 +1,18 @@ +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +int main() +{ + // create some JSON values + json j_object = R"( {"key": "value"} )"_json; + json j_array = R"( [1, 2, 3] )"_json; + + // call contains + std::cout << std::boolalpha << + "j_object contains 'key': " << j_object.contains("key") << '\n' << + "j_object contains 'another': " << j_object.contains("another") << '\n' << + "j_array contains 'key': " << j_array.contains("key") << std::endl; +} diff --git a/external_imported/json/docs/examples/contains__object_t_key_type.output b/external_imported/json/docs/examples/contains__object_t_key_type.output new file mode 100644 index 000000000..14ad177b1 --- /dev/null +++ b/external_imported/json/docs/examples/contains__object_t_key_type.output @@ -0,0 +1,3 @@ +j_object contains 'key': true +j_object contains 'another': false +j_array contains 'key': false diff --git a/external_imported/json/docs/examples/count__keytype.c++17.cpp b/external_imported/json/docs/examples/count__keytype.c++17.cpp new file mode 100644 index 000000000..ec6de0607 --- /dev/null +++ b/external_imported/json/docs/examples/count__keytype.c++17.cpp @@ -0,0 +1,20 @@ +#include +#include +#include + +using namespace std::string_view_literals; +using json = nlohmann::json; + +int main() +{ + // create a JSON object + json j_object = {{"one", 1}, {"two", 2}}; + + // call count() + auto count_two = j_object.count("two"sv); + auto count_three = j_object.count("three"sv); + + // print values + std::cout << "number of elements with key \"two\": " << count_two << '\n'; + std::cout << "number of elements with key \"three\": " << count_three << '\n'; +} diff --git a/external_imported/json/doc/examples/count.output b/external_imported/json/docs/examples/count__keytype.c++17.output similarity index 100% rename from external_imported/json/doc/examples/count.output rename to external_imported/json/docs/examples/count__keytype.c++17.output diff --git a/external_imported/json/doc/examples/count.cpp b/external_imported/json/docs/examples/count__object_t_key_type.cpp similarity index 100% rename from external_imported/json/doc/examples/count.cpp rename to external_imported/json/docs/examples/count__object_t_key_type.cpp diff --git a/external_imported/json/docs/examples/count__object_t_key_type.output b/external_imported/json/docs/examples/count__object_t_key_type.output new file mode 100644 index 000000000..d816fcb24 --- /dev/null +++ b/external_imported/json/docs/examples/count__object_t_key_type.output @@ -0,0 +1,2 @@ +number of elements with key "two": 1 +number of elements with key "three": 0 diff --git a/external_imported/json/doc/examples/crbegin.cpp b/external_imported/json/docs/examples/crbegin.cpp similarity index 100% rename from external_imported/json/doc/examples/crbegin.cpp rename to external_imported/json/docs/examples/crbegin.cpp diff --git a/external_imported/json/doc/examples/crbegin.output b/external_imported/json/docs/examples/crbegin.output similarity index 100% rename from external_imported/json/doc/examples/crbegin.output rename to external_imported/json/docs/examples/crbegin.output diff --git a/external_imported/json/doc/examples/crend.cpp b/external_imported/json/docs/examples/crend.cpp similarity index 100% rename from external_imported/json/doc/examples/crend.cpp rename to external_imported/json/docs/examples/crend.cpp diff --git a/external_imported/json/doc/examples/crend.output b/external_imported/json/docs/examples/crend.output similarity index 100% rename from external_imported/json/doc/examples/crend.output rename to external_imported/json/docs/examples/crend.output diff --git a/external_imported/json/docs/examples/default_object_comparator_t.cpp b/external_imported/json/docs/examples/default_object_comparator_t.cpp new file mode 100644 index 000000000..9f200fe6b --- /dev/null +++ b/external_imported/json/docs/examples/default_object_comparator_t.cpp @@ -0,0 +1,11 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + std::cout << std::boolalpha + << "one < two : " << json::default_object_comparator_t{}("one", "two") << "\n" + << "three < four : " << json::default_object_comparator_t{}("three", "four") << std::endl; +} diff --git a/external_imported/json/docs/examples/default_object_comparator_t.output b/external_imported/json/docs/examples/default_object_comparator_t.output new file mode 100644 index 000000000..b1daf3b96 --- /dev/null +++ b/external_imported/json/docs/examples/default_object_comparator_t.output @@ -0,0 +1,2 @@ +one < two : true +three < four : false diff --git a/external_imported/json/doc/examples/diagnostics_extended.cpp b/external_imported/json/docs/examples/diagnostics_extended.cpp similarity index 90% rename from external_imported/json/doc/examples/diagnostics_extended.cpp rename to external_imported/json/docs/examples/diagnostics_extended.cpp index f4c43f05e..3b9f484b7 100644 --- a/external_imported/json/doc/examples/diagnostics_extended.cpp +++ b/external_imported/json/docs/examples/diagnostics_extended.cpp @@ -15,7 +15,7 @@ int main() { int housenumber = j["address"]["housenumber"]; } - catch (json::exception& e) + catch (const json::exception& e) { std::cout << e.what() << '\n'; } diff --git a/external_imported/json/doc/examples/diagnostics_extended.output b/external_imported/json/docs/examples/diagnostics_extended.output similarity index 100% rename from external_imported/json/doc/examples/diagnostics_extended.output rename to external_imported/json/docs/examples/diagnostics_extended.output diff --git a/external_imported/json/doc/examples/diagnostics_standard.cpp b/external_imported/json/docs/examples/diagnostics_standard.cpp similarity index 89% rename from external_imported/json/doc/examples/diagnostics_standard.cpp rename to external_imported/json/docs/examples/diagnostics_standard.cpp index 575c409eb..eae61a4a7 100644 --- a/external_imported/json/doc/examples/diagnostics_standard.cpp +++ b/external_imported/json/docs/examples/diagnostics_standard.cpp @@ -13,7 +13,7 @@ int main() { int housenumber = j["address"]["housenumber"]; } - catch (json::exception& e) + catch (const json::exception& e) { std::cout << e.what() << '\n'; } diff --git a/external_imported/json/doc/examples/diagnostics_standard.output b/external_imported/json/docs/examples/diagnostics_standard.output similarity index 100% rename from external_imported/json/doc/examples/diagnostics_standard.output rename to external_imported/json/docs/examples/diagnostics_standard.output diff --git a/external_imported/json/doc/examples/diff.cpp b/external_imported/json/docs/examples/diff.cpp similarity index 95% rename from external_imported/json/doc/examples/diff.cpp rename to external_imported/json/docs/examples/diff.cpp index 71b19be66..ef01332a1 100644 --- a/external_imported/json/doc/examples/diff.cpp +++ b/external_imported/json/docs/examples/diff.cpp @@ -3,6 +3,7 @@ #include using json = nlohmann::json; +using namespace nlohmann::literals; int main() { diff --git a/external_imported/json/doc/examples/diff.output b/external_imported/json/docs/examples/diff.output similarity index 100% rename from external_imported/json/doc/examples/diff.output rename to external_imported/json/docs/examples/diff.output diff --git a/external_imported/json/doc/examples/dump.cpp b/external_imported/json/docs/examples/dump.cpp similarity index 97% rename from external_imported/json/doc/examples/dump.cpp rename to external_imported/json/docs/examples/dump.cpp index eb2d71f0e..009c95fd7 100644 --- a/external_imported/json/doc/examples/dump.cpp +++ b/external_imported/json/docs/examples/dump.cpp @@ -35,7 +35,7 @@ int main() { std::cout << j_invalid.dump() << std::endl; } - catch (json::type_error& e) + catch (const json::type_error& e) { std::cout << e.what() << std::endl; } diff --git a/external_imported/json/doc/examples/dump.output b/external_imported/json/docs/examples/dump.output similarity index 100% rename from external_imported/json/doc/examples/dump.output rename to external_imported/json/docs/examples/dump.output diff --git a/external_imported/json/doc/examples/emplace.cpp b/external_imported/json/docs/examples/emplace.cpp similarity index 100% rename from external_imported/json/doc/examples/emplace.cpp rename to external_imported/json/docs/examples/emplace.cpp diff --git a/external_imported/json/doc/examples/emplace.output b/external_imported/json/docs/examples/emplace.output similarity index 100% rename from external_imported/json/doc/examples/emplace.output rename to external_imported/json/docs/examples/emplace.output diff --git a/external_imported/json/doc/examples/emplace_back.cpp b/external_imported/json/docs/examples/emplace_back.cpp similarity index 100% rename from external_imported/json/doc/examples/emplace_back.cpp rename to external_imported/json/docs/examples/emplace_back.cpp diff --git a/external_imported/json/doc/examples/emplace_back.output b/external_imported/json/docs/examples/emplace_back.output similarity index 100% rename from external_imported/json/doc/examples/emplace_back.output rename to external_imported/json/docs/examples/emplace_back.output diff --git a/external_imported/json/doc/examples/empty.cpp b/external_imported/json/docs/examples/empty.cpp similarity index 100% rename from external_imported/json/doc/examples/empty.cpp rename to external_imported/json/docs/examples/empty.cpp diff --git a/external_imported/json/doc/examples/empty.output b/external_imported/json/docs/examples/empty.output similarity index 100% rename from external_imported/json/doc/examples/empty.output rename to external_imported/json/docs/examples/empty.output diff --git a/external_imported/json/doc/examples/end.cpp b/external_imported/json/docs/examples/end.cpp similarity index 100% rename from external_imported/json/doc/examples/end.cpp rename to external_imported/json/docs/examples/end.cpp diff --git a/external_imported/json/doc/examples/end.output b/external_imported/json/docs/examples/end.output similarity index 100% rename from external_imported/json/doc/examples/end.output rename to external_imported/json/docs/examples/end.output diff --git a/external_imported/json/doc/examples/erase__IteratorType.cpp b/external_imported/json/docs/examples/erase__IteratorType.cpp similarity index 100% rename from external_imported/json/doc/examples/erase__IteratorType.cpp rename to external_imported/json/docs/examples/erase__IteratorType.cpp diff --git a/external_imported/json/doc/examples/erase__IteratorType.output b/external_imported/json/docs/examples/erase__IteratorType.output similarity index 100% rename from external_imported/json/doc/examples/erase__IteratorType.output rename to external_imported/json/docs/examples/erase__IteratorType.output diff --git a/external_imported/json/doc/examples/erase__IteratorType_IteratorType.cpp b/external_imported/json/docs/examples/erase__IteratorType_IteratorType.cpp similarity index 100% rename from external_imported/json/doc/examples/erase__IteratorType_IteratorType.cpp rename to external_imported/json/docs/examples/erase__IteratorType_IteratorType.cpp diff --git a/external_imported/json/doc/examples/erase__IteratorType_IteratorType.output b/external_imported/json/docs/examples/erase__IteratorType_IteratorType.output similarity index 100% rename from external_imported/json/doc/examples/erase__IteratorType_IteratorType.output rename to external_imported/json/docs/examples/erase__IteratorType_IteratorType.output diff --git a/external_imported/json/docs/examples/erase__keytype.c++17.cpp b/external_imported/json/docs/examples/erase__keytype.c++17.cpp new file mode 100644 index 000000000..c5e4bed5d --- /dev/null +++ b/external_imported/json/docs/examples/erase__keytype.c++17.cpp @@ -0,0 +1,20 @@ +#include +#include +#include + +using namespace std::string_view_literals; +using json = nlohmann::json; + +int main() +{ + // create a JSON object + json j_object = {{"one", 1}, {"two", 2}}; + + // call erase() + auto count_one = j_object.erase("one"sv); + auto count_three = j_object.erase("three"sv); + + // print values + std::cout << j_object << '\n'; + std::cout << count_one << " " << count_three << '\n'; +} diff --git a/external_imported/json/doc/examples/erase__key_type.output b/external_imported/json/docs/examples/erase__keytype.c++17.output similarity index 100% rename from external_imported/json/doc/examples/erase__key_type.output rename to external_imported/json/docs/examples/erase__keytype.c++17.output diff --git a/external_imported/json/doc/examples/erase__key_type.cpp b/external_imported/json/docs/examples/erase__object_t_key_type.cpp similarity index 100% rename from external_imported/json/doc/examples/erase__key_type.cpp rename to external_imported/json/docs/examples/erase__object_t_key_type.cpp diff --git a/external_imported/json/docs/examples/erase__object_t_key_type.output b/external_imported/json/docs/examples/erase__object_t_key_type.output new file mode 100644 index 000000000..28d79391a --- /dev/null +++ b/external_imported/json/docs/examples/erase__object_t_key_type.output @@ -0,0 +1,2 @@ +{"two":2} +1 0 diff --git a/external_imported/json/doc/examples/erase__size_type.cpp b/external_imported/json/docs/examples/erase__size_type.cpp similarity index 100% rename from external_imported/json/doc/examples/erase__size_type.cpp rename to external_imported/json/docs/examples/erase__size_type.cpp diff --git a/external_imported/json/doc/examples/erase__size_type.output b/external_imported/json/docs/examples/erase__size_type.output similarity index 100% rename from external_imported/json/doc/examples/erase__size_type.output rename to external_imported/json/docs/examples/erase__size_type.output diff --git a/external_imported/json/docs/examples/error_handler_t.cpp b/external_imported/json/docs/examples/error_handler_t.cpp new file mode 100644 index 000000000..b4718d7e6 --- /dev/null +++ b/external_imported/json/docs/examples/error_handler_t.cpp @@ -0,0 +1,24 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + // create JSON value with invalid UTF-8 byte sequence + json j_invalid = "ä\xA9ü"; + try + { + std::cout << j_invalid.dump() << std::endl; + } + catch (const json::type_error& e) + { + std::cout << e.what() << std::endl; + } + + std::cout << "string with replaced invalid characters: " + << j_invalid.dump(-1, ' ', false, json::error_handler_t::replace) + << "\nstring with ignored invalid characters: " + << j_invalid.dump(-1, ' ', false, json::error_handler_t::ignore) + << '\n'; +} diff --git a/external_imported/json/docs/examples/error_handler_t.output b/external_imported/json/docs/examples/error_handler_t.output new file mode 100644 index 000000000..718d62bee --- /dev/null +++ b/external_imported/json/docs/examples/error_handler_t.output @@ -0,0 +1,3 @@ +[json.exception.type_error.316] invalid UTF-8 byte at index 2: 0xA9 +string with replaced invalid characters: "ä�ü" +string with ignored invalid characters: "äü" diff --git a/external_imported/json/doc/examples/exception.cpp b/external_imported/json/docs/examples/exception.cpp similarity index 91% rename from external_imported/json/doc/examples/exception.cpp rename to external_imported/json/docs/examples/exception.cpp index 82696e614..3e5a23b3c 100644 --- a/external_imported/json/doc/examples/exception.cpp +++ b/external_imported/json/docs/examples/exception.cpp @@ -11,7 +11,7 @@ int main() json j = {{"foo", "bar"}}; json k = j.at("non-existing"); } - catch (json::exception& e) + catch (const json::exception& e) { // output exception information std::cout << "message: " << e.what() << '\n' diff --git a/external_imported/json/doc/examples/exception.output b/external_imported/json/docs/examples/exception.output similarity index 100% rename from external_imported/json/doc/examples/exception.output rename to external_imported/json/docs/examples/exception.output diff --git a/external_imported/json/docs/examples/find__keytype.c++17.cpp b/external_imported/json/docs/examples/find__keytype.c++17.cpp new file mode 100644 index 000000000..da94cf0ad --- /dev/null +++ b/external_imported/json/docs/examples/find__keytype.c++17.cpp @@ -0,0 +1,22 @@ +#include +#include +#include + +using namespace std::string_view_literals; +using json = nlohmann::json; + +int main() +{ + // create a JSON object + json j_object = {{"one", 1}, {"two", 2}}; + + // call find + auto it_two = j_object.find("two"sv); + auto it_three = j_object.find("three"sv); + + // print values + std::cout << std::boolalpha; + std::cout << "\"two\" was found: " << (it_two != j_object.end()) << '\n'; + std::cout << "value at key \"two\": " << *it_two << '\n'; + std::cout << "\"three\" was found: " << (it_three != j_object.end()) << '\n'; +} diff --git a/external_imported/json/doc/examples/find__key_type.output b/external_imported/json/docs/examples/find__keytype.c++17.output similarity index 100% rename from external_imported/json/doc/examples/find__key_type.output rename to external_imported/json/docs/examples/find__keytype.c++17.output diff --git a/external_imported/json/doc/examples/find__key_type.cpp b/external_imported/json/docs/examples/find__object_t_key_type.cpp similarity index 100% rename from external_imported/json/doc/examples/find__key_type.cpp rename to external_imported/json/docs/examples/find__object_t_key_type.cpp diff --git a/external_imported/json/docs/examples/find__object_t_key_type.output b/external_imported/json/docs/examples/find__object_t_key_type.output new file mode 100644 index 000000000..509bb42d5 --- /dev/null +++ b/external_imported/json/docs/examples/find__object_t_key_type.output @@ -0,0 +1,3 @@ +"two" was found: true +value at key "two": 2 +"three" was found: false diff --git a/external_imported/json/doc/examples/flatten.cpp b/external_imported/json/docs/examples/flatten.cpp similarity index 100% rename from external_imported/json/doc/examples/flatten.cpp rename to external_imported/json/docs/examples/flatten.cpp diff --git a/external_imported/json/doc/examples/flatten.output b/external_imported/json/docs/examples/flatten.output similarity index 100% rename from external_imported/json/doc/examples/flatten.output rename to external_imported/json/docs/examples/flatten.output diff --git a/external_imported/json/docs/examples/from_bjdata.cpp b/external_imported/json/docs/examples/from_bjdata.cpp new file mode 100644 index 000000000..961164c29 --- /dev/null +++ b/external_imported/json/docs/examples/from_bjdata.cpp @@ -0,0 +1,20 @@ +#include +#include +#include + +using json = nlohmann::json; + +int main() +{ + // create byte vector + std::vector v = {0x7B, 0x69, 0x07, 0x63, 0x6F, 0x6D, 0x70, 0x61, + 0x63, 0x74, 0x54, 0x69, 0x06, 0x73, 0x63, 0x68, + 0x65, 0x6D, 0x61, 0x69, 0x00, 0x7D + }; + + // deserialize it with BJData + json j = json::from_bjdata(v); + + // print the deserialized JSON value + std::cout << std::setw(2) << j << std::endl; +} diff --git a/external_imported/json/doc/examples/from_bson.output b/external_imported/json/docs/examples/from_bjdata.output similarity index 100% rename from external_imported/json/doc/examples/from_bson.output rename to external_imported/json/docs/examples/from_bjdata.output diff --git a/external_imported/json/docs/examples/from_bson.cpp b/external_imported/json/docs/examples/from_bson.cpp new file mode 100644 index 000000000..c9d9fdfa6 --- /dev/null +++ b/external_imported/json/docs/examples/from_bson.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +using json = nlohmann::json; + +int main() +{ + // create byte vector + std::vector v = {0x1b, 0x00, 0x00, 0x00, 0x08, 0x63, 0x6f, 0x6d, + 0x70, 0x61, 0x63, 0x74, 0x00, 0x01, 0x10, 0x73, + 0x63, 0x68, 0x65, 0x6d, 0x61, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00 + }; + + // deserialize it with BSON + json j = json::from_bson(v); + + // print the deserialized JSON value + std::cout << std::setw(2) << j << std::endl; +} diff --git a/external_imported/json/doc/examples/from_cbor.output b/external_imported/json/docs/examples/from_bson.output similarity index 100% rename from external_imported/json/doc/examples/from_cbor.output rename to external_imported/json/docs/examples/from_bson.output diff --git a/external_imported/json/docs/examples/from_cbor.cpp b/external_imported/json/docs/examples/from_cbor.cpp new file mode 100644 index 000000000..e685329ef --- /dev/null +++ b/external_imported/json/docs/examples/from_cbor.cpp @@ -0,0 +1,20 @@ +#include +#include +#include + +using json = nlohmann::json; + +int main() +{ + // create byte vector + std::vector v = {0xa2, 0x67, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, + 0x74, 0xf5, 0x66, 0x73, 0x63, 0x68, 0x65, 0x6d, + 0x61, 0x00 + }; + + // deserialize it with CBOR + json j = json::from_cbor(v); + + // print the deserialized JSON value + std::cout << std::setw(2) << j << std::endl; +} diff --git a/external_imported/json/doc/examples/from_msgpack.output b/external_imported/json/docs/examples/from_cbor.output similarity index 100% rename from external_imported/json/doc/examples/from_msgpack.output rename to external_imported/json/docs/examples/from_cbor.output diff --git a/external_imported/json/docs/examples/from_json__default_constructible.cpp b/external_imported/json/docs/examples/from_json__default_constructible.cpp new file mode 100644 index 000000000..07d71ac95 --- /dev/null +++ b/external_imported/json/docs/examples/from_json__default_constructible.cpp @@ -0,0 +1,37 @@ +#include +#include + +using json = nlohmann::json; + +namespace ns +{ +// a simple struct to model a person +struct person +{ + std::string name; + std::string address; + int age; +}; +} // namespace ns + +namespace ns +{ +void from_json(const json& j, person& p) +{ + j.at("name").get_to(p.name); + j.at("address").get_to(p.address); + j.at("age").get_to(p.age); +} +} // namespace ns + +int main() +{ + json j; + j["name"] = "Ned Flanders"; + j["address"] = "744 Evergreen Terrace"; + j["age"] = 60; + + auto p = j.template get(); + + std::cout << p.name << " (" << p.age << ") lives in " << p.address << std::endl; +} diff --git a/external_imported/json/docs/examples/from_json__default_constructible.output b/external_imported/json/docs/examples/from_json__default_constructible.output new file mode 100644 index 000000000..b92452326 --- /dev/null +++ b/external_imported/json/docs/examples/from_json__default_constructible.output @@ -0,0 +1 @@ +Ned Flanders (60) lives in 744 Evergreen Terrace diff --git a/external_imported/json/docs/examples/from_json__non_default_constructible.cpp b/external_imported/json/docs/examples/from_json__non_default_constructible.cpp new file mode 100644 index 000000000..ec8206ead --- /dev/null +++ b/external_imported/json/docs/examples/from_json__non_default_constructible.cpp @@ -0,0 +1,53 @@ +#include +#include + +using json = nlohmann::json; + +namespace ns +{ +// a simple struct to model a person (not default constructible) +struct person +{ + person(std::string n, std::string a, int aa) + : name(std::move(n)), address(std::move(a)), age(aa) + {} + + std::string name; + std::string address; + int age; +}; +} // namespace ns + +namespace nlohmann +{ +template <> +struct adl_serializer +{ + static ns::person from_json(const json& j) + { + return {j.at("name"), j.at("address"), j.at("age")}; + } + + // Here's the catch! You must provide a to_json method! Otherwise, you + // will not be able to convert person to json, since you fully + // specialized adl_serializer on that type + static void to_json(json& j, ns::person p) + { + j["name"] = p.name; + j["address"] = p.address; + j["age"] = p.age; + } +}; +} // namespace nlohmann + +int main() +{ + json j; + j["name"] = "Ned Flanders"; + j["address"] = "744 Evergreen Terrace"; + j["age"] = 60; + + auto p = j.template get(); + + std::cout << p.name << " (" << p.age << ") lives in " << p.address << std::endl; +} diff --git a/external_imported/json/docs/examples/from_json__non_default_constructible.output b/external_imported/json/docs/examples/from_json__non_default_constructible.output new file mode 100644 index 000000000..b92452326 --- /dev/null +++ b/external_imported/json/docs/examples/from_json__non_default_constructible.output @@ -0,0 +1 @@ +Ned Flanders (60) lives in 744 Evergreen Terrace diff --git a/external_imported/json/docs/examples/from_msgpack.cpp b/external_imported/json/docs/examples/from_msgpack.cpp new file mode 100644 index 000000000..5c2183f1e --- /dev/null +++ b/external_imported/json/docs/examples/from_msgpack.cpp @@ -0,0 +1,20 @@ +#include +#include +#include + +using json = nlohmann::json; + +int main() +{ + // create byte vector + std::vector v = {0x82, 0xa7, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, + 0x74, 0xc3, 0xa6, 0x73, 0x63, 0x68, 0x65, 0x6d, + 0x61, 0x00 + }; + + // deserialize it with MessagePack + json j = json::from_msgpack(v); + + // print the deserialized JSON value + std::cout << std::setw(2) << j << std::endl; +} diff --git a/external_imported/json/doc/examples/from_ubjson.output b/external_imported/json/docs/examples/from_msgpack.output similarity index 100% rename from external_imported/json/doc/examples/from_ubjson.output rename to external_imported/json/docs/examples/from_msgpack.output diff --git a/external_imported/json/docs/examples/from_ubjson.cpp b/external_imported/json/docs/examples/from_ubjson.cpp new file mode 100644 index 000000000..1e85e4e36 --- /dev/null +++ b/external_imported/json/docs/examples/from_ubjson.cpp @@ -0,0 +1,20 @@ +#include +#include +#include + +using json = nlohmann::json; + +int main() +{ + // create byte vector + std::vector v = {0x7B, 0x69, 0x07, 0x63, 0x6F, 0x6D, 0x70, 0x61, + 0x63, 0x74, 0x54, 0x69, 0x06, 0x73, 0x63, 0x68, + 0x65, 0x6D, 0x61, 0x69, 0x00, 0x7D + }; + + // deserialize it with UBJSON + json j = json::from_ubjson(v); + + // print the deserialized JSON value + std::cout << std::setw(2) << j << std::endl; +} diff --git a/external_imported/json/docs/examples/from_ubjson.output b/external_imported/json/docs/examples/from_ubjson.output new file mode 100644 index 000000000..259f63bd4 --- /dev/null +++ b/external_imported/json/docs/examples/from_ubjson.output @@ -0,0 +1,4 @@ +{ + "compact": true, + "schema": 0 +} diff --git a/external_imported/json/doc/examples/front.cpp b/external_imported/json/docs/examples/front.cpp similarity index 100% rename from external_imported/json/doc/examples/front.cpp rename to external_imported/json/docs/examples/front.cpp diff --git a/external_imported/json/doc/examples/front.output b/external_imported/json/docs/examples/front.output similarity index 100% rename from external_imported/json/doc/examples/front.output rename to external_imported/json/docs/examples/front.output diff --git a/external_imported/json/docs/examples/get__PointerType.cpp b/external_imported/json/docs/examples/get__PointerType.cpp new file mode 100644 index 000000000..309c8deeb --- /dev/null +++ b/external_imported/json/docs/examples/get__PointerType.cpp @@ -0,0 +1,21 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + // create a JSON number + json value = 17; + + // explicitly getting pointers + auto p1 = value.template get(); + auto p2 = value.template get(); + auto p3 = value.template get(); + auto p4 = value.template get(); + auto p5 = value.template get(); + + // print the pointees + std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n'; + std::cout << std::boolalpha << (p5 == nullptr) << '\n'; +} diff --git a/external_imported/json/doc/examples/get__PointerType.output b/external_imported/json/docs/examples/get__PointerType.output similarity index 100% rename from external_imported/json/doc/examples/get__PointerType.output rename to external_imported/json/docs/examples/get__PointerType.output diff --git a/external_imported/json/docs/examples/get__ValueType_const.cpp b/external_imported/json/docs/examples/get__ValueType_const.cpp new file mode 100644 index 000000000..db63791fc --- /dev/null +++ b/external_imported/json/docs/examples/get__ValueType_const.cpp @@ -0,0 +1,50 @@ +#include +#include +#include + +using json = nlohmann::json; + +int main() +{ + // create a JSON value with different types + json json_types = + { + {"boolean", true}, + { + "number", { + {"integer", 42}, + {"floating-point", 17.23} + } + }, + {"string", "Hello, world!"}, + {"array", {1, 2, 3, 4, 5}}, + {"null", nullptr} + }; + + // use explicit conversions + auto v1 = json_types["boolean"].template get(); + auto v2 = json_types["number"]["integer"].template get(); + auto v3 = json_types["number"]["integer"].template get(); + auto v4 = json_types["number"]["floating-point"].template get(); + auto v5 = json_types["number"]["floating-point"].template get(); + auto v6 = json_types["string"].template get(); + auto v7 = json_types["array"].template get>(); + auto v8 = json_types.template get>(); + + // print the conversion results + std::cout << v1 << '\n'; + std::cout << v2 << ' ' << v3 << '\n'; + std::cout << v4 << ' ' << v5 << '\n'; + std::cout << v6 << '\n'; + + for (auto i : v7) + { + std::cout << i << ' '; + } + std::cout << "\n\n"; + + for (auto i : v8) + { + std::cout << i.first << ": " << i.second << '\n'; + } +} diff --git a/external_imported/json/doc/examples/get__ValueType_const.output b/external_imported/json/docs/examples/get__ValueType_const.output similarity index 100% rename from external_imported/json/doc/examples/get__ValueType_const.output rename to external_imported/json/docs/examples/get__ValueType_const.output diff --git a/external_imported/json/docs/examples/get_allocator.cpp b/external_imported/json/docs/examples/get_allocator.cpp new file mode 100644 index 000000000..35079a10c --- /dev/null +++ b/external_imported/json/docs/examples/get_allocator.cpp @@ -0,0 +1,18 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + auto alloc = json::get_allocator(); + using traits_t = std::allocator_traits; + + json* j = traits_t::allocate(alloc, 1); + traits_t::construct(alloc, j, "Hello, world!"); + + std::cout << *j << std::endl; + + traits_t::destroy(alloc, j); + traits_t::deallocate(alloc, j, 1); +} diff --git a/external_imported/json/docs/examples/get_allocator.output b/external_imported/json/docs/examples/get_allocator.output new file mode 100644 index 000000000..8effb3e8c --- /dev/null +++ b/external_imported/json/docs/examples/get_allocator.output @@ -0,0 +1 @@ +"Hello, world!" diff --git a/external_imported/json/docs/examples/get_binary.cpp b/external_imported/json/docs/examples/get_binary.cpp new file mode 100644 index 000000000..617ce6096 --- /dev/null +++ b/external_imported/json/docs/examples/get_binary.cpp @@ -0,0 +1,16 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + // create a binary vector + std::vector vec = {0xCA, 0xFE, 0xBA, 0xBE}; + + // create a binary JSON value with subtype 42 + json j = json::binary(vec, 42); + + // output type and subtype + std::cout << "type: " << j.type_name() << ", subtype: " << j.get_binary().subtype() << std::endl; +} diff --git a/external_imported/json/docs/examples/get_binary.output b/external_imported/json/docs/examples/get_binary.output new file mode 100644 index 000000000..74b05d23f --- /dev/null +++ b/external_imported/json/docs/examples/get_binary.output @@ -0,0 +1 @@ +type: binary, subtype: 42 diff --git a/external_imported/json/doc/examples/get_ptr.cpp b/external_imported/json/docs/examples/get_ptr.cpp similarity index 100% rename from external_imported/json/doc/examples/get_ptr.cpp rename to external_imported/json/docs/examples/get_ptr.cpp diff --git a/external_imported/json/doc/examples/get_ptr.output b/external_imported/json/docs/examples/get_ptr.output similarity index 100% rename from external_imported/json/doc/examples/get_ptr.output rename to external_imported/json/docs/examples/get_ptr.output diff --git a/external_imported/json/doc/examples/get_ref.cpp b/external_imported/json/docs/examples/get_ref.cpp similarity index 93% rename from external_imported/json/doc/examples/get_ref.cpp rename to external_imported/json/docs/examples/get_ref.cpp index ab25946bb..0183a6537 100644 --- a/external_imported/json/doc/examples/get_ref.cpp +++ b/external_imported/json/docs/examples/get_ref.cpp @@ -20,7 +20,7 @@ int main() { auto r3 = value.get_ref(); } - catch (json::type_error& ex) + catch (const json::type_error& ex) { std::cout << ex.what() << '\n'; } diff --git a/external_imported/json/doc/examples/get_ref.output b/external_imported/json/docs/examples/get_ref.output similarity index 100% rename from external_imported/json/doc/examples/get_ref.output rename to external_imported/json/docs/examples/get_ref.output diff --git a/external_imported/json/doc/examples/get_to.cpp b/external_imported/json/docs/examples/get_to.cpp similarity index 99% rename from external_imported/json/doc/examples/get_to.cpp rename to external_imported/json/docs/examples/get_to.cpp index 4705b172f..358c8d43a 100644 --- a/external_imported/json/doc/examples/get_to.cpp +++ b/external_imported/json/docs/examples/get_to.cpp @@ -30,7 +30,6 @@ int main() std::vector v7; std::unordered_map v8; - // use explicit conversions json_types["boolean"].get_to(v1); json_types["number"]["integer"].get_to(v2); diff --git a/external_imported/json/doc/examples/get_to.output b/external_imported/json/docs/examples/get_to.output similarity index 100% rename from external_imported/json/doc/examples/get_to.output rename to external_imported/json/docs/examples/get_to.output diff --git a/external_imported/json/doc/examples/insert.cpp b/external_imported/json/docs/examples/insert.cpp similarity index 100% rename from external_imported/json/doc/examples/insert.cpp rename to external_imported/json/docs/examples/insert.cpp diff --git a/external_imported/json/doc/examples/insert.output b/external_imported/json/docs/examples/insert.output similarity index 100% rename from external_imported/json/doc/examples/insert.output rename to external_imported/json/docs/examples/insert.output diff --git a/external_imported/json/doc/examples/insert__count.cpp b/external_imported/json/docs/examples/insert__count.cpp similarity index 100% rename from external_imported/json/doc/examples/insert__count.cpp rename to external_imported/json/docs/examples/insert__count.cpp diff --git a/external_imported/json/doc/examples/insert__count.output b/external_imported/json/docs/examples/insert__count.output similarity index 100% rename from external_imported/json/doc/examples/insert__count.output rename to external_imported/json/docs/examples/insert__count.output diff --git a/external_imported/json/doc/examples/insert__ilist.cpp b/external_imported/json/docs/examples/insert__ilist.cpp similarity index 100% rename from external_imported/json/doc/examples/insert__ilist.cpp rename to external_imported/json/docs/examples/insert__ilist.cpp diff --git a/external_imported/json/doc/examples/insert__ilist.output b/external_imported/json/docs/examples/insert__ilist.output similarity index 100% rename from external_imported/json/doc/examples/insert__ilist.output rename to external_imported/json/docs/examples/insert__ilist.output diff --git a/external_imported/json/doc/examples/insert__range.cpp b/external_imported/json/docs/examples/insert__range.cpp similarity index 100% rename from external_imported/json/doc/examples/insert__range.cpp rename to external_imported/json/docs/examples/insert__range.cpp diff --git a/external_imported/json/doc/examples/insert__range.output b/external_imported/json/docs/examples/insert__range.output similarity index 100% rename from external_imported/json/doc/examples/insert__range.output rename to external_imported/json/docs/examples/insert__range.output diff --git a/external_imported/json/doc/examples/insert__range_object.cpp b/external_imported/json/docs/examples/insert__range_object.cpp similarity index 100% rename from external_imported/json/doc/examples/insert__range_object.cpp rename to external_imported/json/docs/examples/insert__range_object.cpp diff --git a/external_imported/json/doc/examples/insert__range_object.output b/external_imported/json/docs/examples/insert__range_object.output similarity index 100% rename from external_imported/json/doc/examples/insert__range_object.output rename to external_imported/json/docs/examples/insert__range_object.output diff --git a/external_imported/json/doc/examples/invalid_iterator.cpp b/external_imported/json/docs/examples/invalid_iterator.cpp similarity index 90% rename from external_imported/json/doc/examples/invalid_iterator.cpp rename to external_imported/json/docs/examples/invalid_iterator.cpp index 5d3e622e6..ecde12e62 100644 --- a/external_imported/json/doc/examples/invalid_iterator.cpp +++ b/external_imported/json/docs/examples/invalid_iterator.cpp @@ -12,7 +12,7 @@ int main() json::iterator it = j.begin(); auto k = it.key(); } - catch (json::invalid_iterator& e) + catch (const json::invalid_iterator& e) { // output exception information std::cout << "message: " << e.what() << '\n' diff --git a/external_imported/json/doc/examples/invalid_iterator.output b/external_imported/json/docs/examples/invalid_iterator.output similarity index 100% rename from external_imported/json/doc/examples/invalid_iterator.output rename to external_imported/json/docs/examples/invalid_iterator.output diff --git a/external_imported/json/doc/examples/is_array.cpp b/external_imported/json/docs/examples/is_array.cpp similarity index 100% rename from external_imported/json/doc/examples/is_array.cpp rename to external_imported/json/docs/examples/is_array.cpp diff --git a/external_imported/json/doc/examples/is_array.output b/external_imported/json/docs/examples/is_array.output similarity index 100% rename from external_imported/json/doc/examples/is_array.output rename to external_imported/json/docs/examples/is_array.output diff --git a/external_imported/json/doc/examples/is_binary.cpp b/external_imported/json/docs/examples/is_binary.cpp similarity index 100% rename from external_imported/json/doc/examples/is_binary.cpp rename to external_imported/json/docs/examples/is_binary.cpp diff --git a/external_imported/json/doc/examples/is_binary.output b/external_imported/json/docs/examples/is_binary.output similarity index 100% rename from external_imported/json/doc/examples/is_binary.output rename to external_imported/json/docs/examples/is_binary.output diff --git a/external_imported/json/doc/examples/is_boolean.cpp b/external_imported/json/docs/examples/is_boolean.cpp similarity index 100% rename from external_imported/json/doc/examples/is_boolean.cpp rename to external_imported/json/docs/examples/is_boolean.cpp diff --git a/external_imported/json/doc/examples/is_boolean.output b/external_imported/json/docs/examples/is_boolean.output similarity index 100% rename from external_imported/json/doc/examples/is_boolean.output rename to external_imported/json/docs/examples/is_boolean.output diff --git a/external_imported/json/doc/examples/is_discarded.cpp b/external_imported/json/docs/examples/is_discarded.cpp similarity index 100% rename from external_imported/json/doc/examples/is_discarded.cpp rename to external_imported/json/docs/examples/is_discarded.cpp diff --git a/external_imported/json/doc/examples/is_discarded.output b/external_imported/json/docs/examples/is_discarded.output similarity index 100% rename from external_imported/json/doc/examples/is_discarded.output rename to external_imported/json/docs/examples/is_discarded.output diff --git a/external_imported/json/doc/examples/is_null.cpp b/external_imported/json/docs/examples/is_null.cpp similarity index 100% rename from external_imported/json/doc/examples/is_null.cpp rename to external_imported/json/docs/examples/is_null.cpp diff --git a/external_imported/json/doc/examples/is_null.output b/external_imported/json/docs/examples/is_null.output similarity index 100% rename from external_imported/json/doc/examples/is_null.output rename to external_imported/json/docs/examples/is_null.output diff --git a/external_imported/json/doc/examples/is_number.cpp b/external_imported/json/docs/examples/is_number.cpp similarity index 100% rename from external_imported/json/doc/examples/is_number.cpp rename to external_imported/json/docs/examples/is_number.cpp diff --git a/external_imported/json/doc/examples/is_number.output b/external_imported/json/docs/examples/is_number.output similarity index 100% rename from external_imported/json/doc/examples/is_number.output rename to external_imported/json/docs/examples/is_number.output diff --git a/external_imported/json/doc/examples/is_number_float.cpp b/external_imported/json/docs/examples/is_number_float.cpp similarity index 100% rename from external_imported/json/doc/examples/is_number_float.cpp rename to external_imported/json/docs/examples/is_number_float.cpp diff --git a/external_imported/json/doc/examples/is_number_float.output b/external_imported/json/docs/examples/is_number_float.output similarity index 100% rename from external_imported/json/doc/examples/is_number_float.output rename to external_imported/json/docs/examples/is_number_float.output diff --git a/external_imported/json/doc/examples/is_number_integer.cpp b/external_imported/json/docs/examples/is_number_integer.cpp similarity index 100% rename from external_imported/json/doc/examples/is_number_integer.cpp rename to external_imported/json/docs/examples/is_number_integer.cpp diff --git a/external_imported/json/doc/examples/is_number_integer.output b/external_imported/json/docs/examples/is_number_integer.output similarity index 100% rename from external_imported/json/doc/examples/is_number_integer.output rename to external_imported/json/docs/examples/is_number_integer.output diff --git a/external_imported/json/doc/examples/is_number_unsigned.cpp b/external_imported/json/docs/examples/is_number_unsigned.cpp similarity index 100% rename from external_imported/json/doc/examples/is_number_unsigned.cpp rename to external_imported/json/docs/examples/is_number_unsigned.cpp diff --git a/external_imported/json/doc/examples/is_number_unsigned.output b/external_imported/json/docs/examples/is_number_unsigned.output similarity index 100% rename from external_imported/json/doc/examples/is_number_unsigned.output rename to external_imported/json/docs/examples/is_number_unsigned.output diff --git a/external_imported/json/doc/examples/is_object.cpp b/external_imported/json/docs/examples/is_object.cpp similarity index 100% rename from external_imported/json/doc/examples/is_object.cpp rename to external_imported/json/docs/examples/is_object.cpp diff --git a/external_imported/json/doc/examples/is_object.output b/external_imported/json/docs/examples/is_object.output similarity index 100% rename from external_imported/json/doc/examples/is_object.output rename to external_imported/json/docs/examples/is_object.output diff --git a/external_imported/json/doc/examples/is_primitive.cpp b/external_imported/json/docs/examples/is_primitive.cpp similarity index 100% rename from external_imported/json/doc/examples/is_primitive.cpp rename to external_imported/json/docs/examples/is_primitive.cpp diff --git a/external_imported/json/doc/examples/is_primitive.output b/external_imported/json/docs/examples/is_primitive.output similarity index 100% rename from external_imported/json/doc/examples/is_primitive.output rename to external_imported/json/docs/examples/is_primitive.output diff --git a/external_imported/json/doc/examples/is_string.cpp b/external_imported/json/docs/examples/is_string.cpp similarity index 100% rename from external_imported/json/doc/examples/is_string.cpp rename to external_imported/json/docs/examples/is_string.cpp diff --git a/external_imported/json/doc/examples/is_string.output b/external_imported/json/docs/examples/is_string.output similarity index 100% rename from external_imported/json/doc/examples/is_string.output rename to external_imported/json/docs/examples/is_string.output diff --git a/external_imported/json/doc/examples/is_structured.cpp b/external_imported/json/docs/examples/is_structured.cpp similarity index 100% rename from external_imported/json/doc/examples/is_structured.cpp rename to external_imported/json/docs/examples/is_structured.cpp diff --git a/external_imported/json/doc/examples/is_structured.output b/external_imported/json/docs/examples/is_structured.output similarity index 100% rename from external_imported/json/doc/examples/is_structured.output rename to external_imported/json/docs/examples/is_structured.output diff --git a/external_imported/json/doc/examples/items.cpp b/external_imported/json/docs/examples/items.cpp similarity index 100% rename from external_imported/json/doc/examples/items.cpp rename to external_imported/json/docs/examples/items.cpp diff --git a/external_imported/json/doc/examples/items.output b/external_imported/json/docs/examples/items.output similarity index 100% rename from external_imported/json/doc/examples/items.output rename to external_imported/json/docs/examples/items.output diff --git a/external_imported/json/docs/examples/json_base_class_t.cpp b/external_imported/json/docs/examples/json_base_class_t.cpp new file mode 100644 index 000000000..d993522a7 --- /dev/null +++ b/external_imported/json/docs/examples/json_base_class_t.cpp @@ -0,0 +1,88 @@ +#include +#include + +class visitor_adaptor_with_metadata +{ + public: + template + void visit(const Fnc& fnc) const; + + int metadata = 42; + private: + template + void do_visit(const Ptr& ptr, const Fnc& fnc) const; +}; + +using json = nlohmann::basic_json < + std::map, + std::vector, + std::string, + bool, + std::int64_t, + std::uint64_t, + double, + std::allocator, + nlohmann::adl_serializer, + std::vector, + visitor_adaptor_with_metadata + >; + +template +void visitor_adaptor_with_metadata::visit(const Fnc& fnc) const +{ + do_visit(json::json_pointer{}, fnc); +} + +template +void visitor_adaptor_with_metadata::do_visit(const Ptr& ptr, const Fnc& fnc) const +{ + using value_t = nlohmann::detail::value_t; + const json& j = *static_cast(this); + switch (j.type()) + { + case value_t::object: + fnc(ptr, j); + for (const auto& entry : j.items()) + { + entry.value().do_visit(ptr / entry.key(), fnc); + } + break; + case value_t::array: + fnc(ptr, j); + for (std::size_t i = 0; i < j.size(); ++i) + { + j.at(i).do_visit(ptr / std::to_string(i), fnc); + } + break; + case value_t::null: + case value_t::string: + case value_t::boolean: + case value_t::number_integer: + case value_t::number_unsigned: + case value_t::number_float: + case value_t::binary: + fnc(ptr, j); + break; + case value_t::discarded: + default: + break; + } +} + +int main() +{ + // create a json object + json j; + j["null"]; + j["object"]["uint"] = 1U; + j["object"].metadata = 21; + + // visit and output + j.visit( + [&](const json::json_pointer & p, + const json & j) + { + std::cout << (p.empty() ? std::string{"/"} : p.to_string()) + << " - metadata = " << j.metadata << " -> " << j.dump() << '\n'; + }); +} diff --git a/external_imported/json/docs/examples/json_base_class_t.output b/external_imported/json/docs/examples/json_base_class_t.output new file mode 100644 index 000000000..83ce1f693 --- /dev/null +++ b/external_imported/json/docs/examples/json_base_class_t.output @@ -0,0 +1,4 @@ +/ - metadata = 42 -> {"null":null,"object":{"uint":1}} +/null - metadata = 42 -> null +/object - metadata = 21 -> {"uint":1} +/object/uint - metadata = 42 -> 1 diff --git a/external_imported/json/docs/examples/json_lines.cpp b/external_imported/json/docs/examples/json_lines.cpp new file mode 100644 index 000000000..233c81a4a --- /dev/null +++ b/external_imported/json/docs/examples/json_lines.cpp @@ -0,0 +1,22 @@ +#include +#include +#include + +using json = nlohmann::json; + +int main() +{ + // JSON Lines (see https://jsonlines.org) + std::stringstream input; + input << R"({"name": "Gilbert", "wins": [["straight", "7♣"], ["one pair", "10♥"]]} +{"name": "Alexa", "wins": [["two pair", "4â™ "], ["two pair", "9â™ "]]} +{"name": "May", "wins": []} +{"name": "Deloise", "wins": [["three of a kind", "5♣"]]} +)"; + + std::string line; + while (std::getline(input, line)) + { + std::cout << json::parse(line) << std::endl; + } +} diff --git a/external_imported/json/docs/examples/json_lines.output b/external_imported/json/docs/examples/json_lines.output new file mode 100644 index 000000000..1b4122480 --- /dev/null +++ b/external_imported/json/docs/examples/json_lines.output @@ -0,0 +1,4 @@ +{"name":"Gilbert","wins":[["straight","7♣"],["one pair","10♥"]]} +{"name":"Alexa","wins":[["two pair","4â™ "],["two pair","9â™ "]]} +{"name":"May","wins":[]} +{"name":"Deloise","wins":[["three of a kind","5♣"]]} diff --git a/external_imported/json/doc/examples/json_pointer.cpp b/external_imported/json/docs/examples/json_pointer.cpp similarity index 88% rename from external_imported/json/doc/examples/json_pointer.cpp rename to external_imported/json/docs/examples/json_pointer.cpp index 75b971758..8705cf498 100644 --- a/external_imported/json/doc/examples/json_pointer.cpp +++ b/external_imported/json/docs/examples/json_pointer.cpp @@ -20,7 +20,7 @@ int main() { json::json_pointer p9("foo"); } - catch (json::parse_error& e) + catch (const json::parse_error& e) { std::cout << e.what() << '\n'; } @@ -30,7 +30,7 @@ int main() { json::json_pointer p10("/foo/~"); } - catch (json::parse_error& e) + catch (const json::parse_error& e) { std::cout << e.what() << '\n'; } @@ -40,7 +40,7 @@ int main() { json::json_pointer p11("/foo/~3"); } - catch (json::parse_error& e) + catch (const json::parse_error& e) { std::cout << e.what() << '\n'; } diff --git a/external_imported/json/doc/examples/json_pointer.output b/external_imported/json/docs/examples/json_pointer.output similarity index 100% rename from external_imported/json/doc/examples/json_pointer.output rename to external_imported/json/docs/examples/json_pointer.output diff --git a/external_imported/json/docs/examples/json_pointer__back.cpp b/external_imported/json/docs/examples/json_pointer__back.cpp new file mode 100644 index 000000000..dd3b210bf --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__back.cpp @@ -0,0 +1,15 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + // different JSON Pointers + json::json_pointer ptr1("/foo"); + json::json_pointer ptr2("/foo/0"); + + // call empty() + std::cout << "last reference token of \"" << ptr1 << "\" is \"" << ptr1.back() << "\"\n" + << "last reference token of \"" << ptr2 << "\" is \"" << ptr2.back() << "\"" << std::endl; +} diff --git a/external_imported/json/docs/examples/json_pointer__back.output b/external_imported/json/docs/examples/json_pointer__back.output new file mode 100644 index 000000000..a89357b49 --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__back.output @@ -0,0 +1,2 @@ +last reference token of "/foo" is "foo" +last reference token of "/foo/0" is "0" diff --git a/external_imported/json/docs/examples/json_pointer__empty.cpp b/external_imported/json/docs/examples/json_pointer__empty.cpp new file mode 100644 index 000000000..57257e8b1 --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__empty.cpp @@ -0,0 +1,20 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + // different JSON Pointers + json::json_pointer ptr0; + json::json_pointer ptr1(""); + json::json_pointer ptr2("/foo"); + json::json_pointer ptr3("/foo/0"); + + // call empty() + std::cout << std::boolalpha + << "\"" << ptr0 << "\": " << ptr0.empty() << '\n' + << "\"" << ptr1 << "\": " << ptr1.empty() << '\n' + << "\"" << ptr2 << "\": " << ptr2.empty() << '\n' + << "\"" << ptr3 << "\": " << ptr3.empty() << std::endl; +} diff --git a/external_imported/json/doc/examples/json_pointer__empty.output b/external_imported/json/docs/examples/json_pointer__empty.output similarity index 100% rename from external_imported/json/doc/examples/json_pointer__empty.output rename to external_imported/json/docs/examples/json_pointer__empty.output diff --git a/external_imported/json/docs/examples/json_pointer__operator__equal.cpp b/external_imported/json/docs/examples/json_pointer__operator__equal.cpp new file mode 100644 index 000000000..dce6df03c --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__operator__equal.cpp @@ -0,0 +1,19 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + // different JSON pointers + json::json_pointer ptr0; + json::json_pointer ptr1(""); + json::json_pointer ptr2("/foo"); + + // compare JSON pointers + std::cout << std::boolalpha + << "\"" << ptr0 << "\" == \"" << ptr0 << "\": " << (ptr0 == ptr0) << '\n' + << "\"" << ptr0 << "\" == \"" << ptr1 << "\": " << (ptr0 == ptr1) << '\n' + << "\"" << ptr1 << "\" == \"" << ptr2 << "\": " << (ptr1 == ptr2) << '\n' + << "\"" << ptr2 << "\" == \"" << ptr2 << "\": " << (ptr2 == ptr2) << std::endl; +} diff --git a/external_imported/json/docs/examples/json_pointer__operator__equal.output b/external_imported/json/docs/examples/json_pointer__operator__equal.output new file mode 100644 index 000000000..9a7612580 --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__operator__equal.output @@ -0,0 +1,4 @@ +"" == "": true +"" == "": true +"" == "/foo": false +"/foo" == "/foo": true diff --git a/external_imported/json/docs/examples/json_pointer__operator__equal_stringtype.cpp b/external_imported/json/docs/examples/json_pointer__operator__equal_stringtype.cpp new file mode 100644 index 000000000..af8ec5a29 --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__operator__equal_stringtype.cpp @@ -0,0 +1,33 @@ +#include +#include +#include + +using json = nlohmann::json; + +int main() +{ + // different JSON pointers + json::json_pointer ptr0; + json::json_pointer ptr1(""); + json::json_pointer ptr2("/foo"); + + // different strings + std::string str0(""); + std::string str1("/foo"); + std::string str2("bar"); + + // compare JSON pointers and strings + std::cout << std::boolalpha + << "\"" << ptr0 << "\" == \"" << str0 << "\": " << (ptr0 == str0) << '\n' + << "\"" << str0 << "\" == \"" << ptr1 << "\": " << (str0 == ptr1) << '\n' + << "\"" << ptr2 << "\" == \"" << str1 << "\": " << (ptr2 == str1) << std::endl; + + try + { + std::cout << "\"" << str2 << "\" == \"" << ptr2 << "\": " << (str2 == ptr2) << std::endl; + } + catch (const json::parse_error& ex) + { + std::cout << ex.what() << std::endl; + } +} diff --git a/external_imported/json/docs/examples/json_pointer__operator__equal_stringtype.output b/external_imported/json/docs/examples/json_pointer__operator__equal_stringtype.output new file mode 100644 index 000000000..7fb299d3d --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__operator__equal_stringtype.output @@ -0,0 +1,4 @@ +"" == "": true +"" == "": true +"/foo" == "/foo": true +"bar" == "/foo": [json.exception.parse_error.107] parse error at byte 1: JSON pointer must be empty or begin with '/' - was: 'bar' diff --git a/external_imported/json/docs/examples/json_pointer__operator__notequal.cpp b/external_imported/json/docs/examples/json_pointer__operator__notequal.cpp new file mode 100644 index 000000000..9bbdd5310 --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__operator__notequal.cpp @@ -0,0 +1,19 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + // different JSON pointers + json::json_pointer ptr0; + json::json_pointer ptr1(""); + json::json_pointer ptr2("/foo"); + + // compare JSON pointers + std::cout << std::boolalpha + << "\"" << ptr0 << "\" != \"" << ptr0 << "\": " << (ptr0 != ptr0) << '\n' + << "\"" << ptr0 << "\" != \"" << ptr1 << "\": " << (ptr0 != ptr1) << '\n' + << "\"" << ptr1 << "\" != \"" << ptr2 << "\": " << (ptr1 != ptr2) << '\n' + << "\"" << ptr2 << "\" != \"" << ptr2 << "\": " << (ptr2 != ptr2) << std::endl; +} diff --git a/external_imported/json/docs/examples/json_pointer__operator__notequal.output b/external_imported/json/docs/examples/json_pointer__operator__notequal.output new file mode 100644 index 000000000..de891f0c6 --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__operator__notequal.output @@ -0,0 +1,4 @@ +"" != "": false +"" != "": false +"" != "/foo": true +"/foo" != "/foo": false diff --git a/external_imported/json/docs/examples/json_pointer__operator__notequal_stringtype.cpp b/external_imported/json/docs/examples/json_pointer__operator__notequal_stringtype.cpp new file mode 100644 index 000000000..b9b898728 --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__operator__notequal_stringtype.cpp @@ -0,0 +1,32 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + // different JSON pointers + json::json_pointer ptr0; + json::json_pointer ptr1(""); + json::json_pointer ptr2("/foo"); + + // different strings + std::string str0(""); + std::string str1("/foo"); + std::string str2("bar"); + + // compare JSON pointers and strings + std::cout << std::boolalpha + << "\"" << ptr0 << "\" != \"" << str0 << "\": " << (ptr0 != str0) << '\n' + << "\"" << str0 << "\" != \"" << ptr1 << "\": " << (str0 != ptr1) << '\n' + << "\"" << ptr2 << "\" != \"" << str1 << "\": " << (ptr2 != str1) << std::endl; + + try + { + std::cout << "\"" << str2 << "\" != \"" << ptr2 << "\": " << (str2 != ptr2) << std::endl; + } + catch (const json::parse_error& ex) + { + std::cout << ex.what() << std::endl; + } +} diff --git a/external_imported/json/docs/examples/json_pointer__operator__notequal_stringtype.output b/external_imported/json/docs/examples/json_pointer__operator__notequal_stringtype.output new file mode 100644 index 000000000..61331b752 --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__operator__notequal_stringtype.output @@ -0,0 +1,4 @@ +"" != "": false +"" != "": false +"/foo" != "/foo": false +"bar" != "/foo": [json.exception.parse_error.107] parse error at byte 1: JSON pointer must be empty or begin with '/' - was: 'bar' diff --git a/external_imported/json/docs/examples/json_pointer__operator_add.cpp b/external_imported/json/docs/examples/json_pointer__operator_add.cpp new file mode 100644 index 000000000..14bd74561 --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__operator_add.cpp @@ -0,0 +1,23 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + // create a JSON pointer + json::json_pointer ptr("/foo"); + std::cout << "\"" << ptr << "\"\n"; + + // append a JSON Pointer + ptr /= json::json_pointer("/bar/baz"); + std::cout << "\"" << ptr << "\"\n"; + + // append a string + ptr /= "fob"; + std::cout << "\"" << ptr << "\"\n"; + + // append an array index + ptr /= 42; + std::cout << "\"" << ptr << "\"" << std::endl; +} diff --git a/external_imported/json/doc/examples/json_pointer__operator_add.output b/external_imported/json/docs/examples/json_pointer__operator_add.output similarity index 100% rename from external_imported/json/doc/examples/json_pointer__operator_add.output rename to external_imported/json/docs/examples/json_pointer__operator_add.output diff --git a/external_imported/json/docs/examples/json_pointer__operator_add_binary.cpp b/external_imported/json/docs/examples/json_pointer__operator_add_binary.cpp new file mode 100644 index 000000000..d26a0d171 --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__operator_add_binary.cpp @@ -0,0 +1,19 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + // create a JSON pointer + json::json_pointer ptr("/foo"); + + // append a JSON Pointer + std::cout << "\"" << ptr / json::json_pointer("/bar/baz") << "\"\n"; + + // append a string + std::cout << "\"" << ptr / "fob" << "\"\n"; + + // append an array index + std::cout << "\"" << ptr / 42 << "\"" << std::endl; +} diff --git a/external_imported/json/doc/examples/json_pointer__operator_add_binary.output b/external_imported/json/docs/examples/json_pointer__operator_add_binary.output similarity index 100% rename from external_imported/json/doc/examples/json_pointer__operator_add_binary.output rename to external_imported/json/docs/examples/json_pointer__operator_add_binary.output diff --git a/external_imported/json/docs/examples/json_pointer__operator_string_t.cpp b/external_imported/json/docs/examples/json_pointer__operator_string_t.cpp new file mode 100644 index 000000000..56f213020 --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__operator_string_t.cpp @@ -0,0 +1,19 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + // different JSON Pointers + json::json_pointer ptr1("/foo/0"); + json::json_pointer ptr2("/a~1b"); + + // implicit conversion to string + std::string s; + s += ptr1; + s += "\n"; + s += ptr2; + + std::cout << s << std::endl; +} diff --git a/external_imported/json/docs/examples/json_pointer__operator_string_t.output b/external_imported/json/docs/examples/json_pointer__operator_string_t.output new file mode 100644 index 000000000..ec6aba2c2 --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__operator_string_t.output @@ -0,0 +1,2 @@ +/foo/0 +/a~1b diff --git a/external_imported/json/docs/examples/json_pointer__parent_pointer.cpp b/external_imported/json/docs/examples/json_pointer__parent_pointer.cpp new file mode 100644 index 000000000..ef9df4534 --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__parent_pointer.cpp @@ -0,0 +1,18 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + // different JSON Pointers + json::json_pointer ptr1(""); + json::json_pointer ptr2("/foo"); + json::json_pointer ptr3("/foo/0"); + + // call parent_pointer() + std::cout << std::boolalpha + << "parent of \"" << ptr1 << "\" is \"" << ptr1.parent_pointer() << "\"\n" + << "parent of \"" << ptr2 << "\" is \"" << ptr2.parent_pointer() << "\"\n" + << "parent of \"" << ptr3 << "\" is \"" << ptr3.parent_pointer() << "\"" << std::endl; +} diff --git a/external_imported/json/doc/examples/json_pointer__parent_pointer.output b/external_imported/json/docs/examples/json_pointer__parent_pointer.output similarity index 100% rename from external_imported/json/doc/examples/json_pointer__parent_pointer.output rename to external_imported/json/docs/examples/json_pointer__parent_pointer.output diff --git a/external_imported/json/docs/examples/json_pointer__pop_back.cpp b/external_imported/json/docs/examples/json_pointer__pop_back.cpp new file mode 100644 index 000000000..fd077b7e9 --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__pop_back.cpp @@ -0,0 +1,21 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + // create empty JSON Pointer + json::json_pointer ptr("/foo/bar/baz"); + std::cout << "\"" << ptr << "\"\n"; + + // call pop_back() + ptr.pop_back(); + std::cout << "\"" << ptr << "\"\n"; + + ptr.pop_back(); + std::cout << "\"" << ptr << "\"\n"; + + ptr.pop_back(); + std::cout << "\"" << ptr << "\"\n"; +} diff --git a/external_imported/json/doc/examples/json_pointer__pop_back.output b/external_imported/json/docs/examples/json_pointer__pop_back.output similarity index 100% rename from external_imported/json/doc/examples/json_pointer__pop_back.output rename to external_imported/json/docs/examples/json_pointer__pop_back.output diff --git a/external_imported/json/docs/examples/json_pointer__push_back.cpp b/external_imported/json/docs/examples/json_pointer__push_back.cpp new file mode 100644 index 000000000..e6b59a125 --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__push_back.cpp @@ -0,0 +1,21 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + // create empty JSON Pointer + json::json_pointer ptr; + std::cout << "\"" << ptr << "\"\n"; + + // call push_back() + ptr.push_back("foo"); + std::cout << "\"" << ptr << "\"\n"; + + ptr.push_back("0"); + std::cout << "\"" << ptr << "\"\n"; + + ptr.push_back("bar"); + std::cout << "\"" << ptr << "\"\n"; +} diff --git a/external_imported/json/doc/examples/json_pointer__push_back.output b/external_imported/json/docs/examples/json_pointer__push_back.output similarity index 100% rename from external_imported/json/doc/examples/json_pointer__push_back.output rename to external_imported/json/docs/examples/json_pointer__push_back.output diff --git a/external_imported/json/docs/examples/json_pointer__string_t.cpp b/external_imported/json/docs/examples/json_pointer__string_t.cpp new file mode 100644 index 000000000..fbe0f179e --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__string_t.cpp @@ -0,0 +1,13 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + json::json_pointer::string_t s = "This is a string."; + + std::cout << s << std::endl; + + std::cout << std::boolalpha << std::is_same::value << std::endl; +} diff --git a/external_imported/json/docs/examples/json_pointer__string_t.output b/external_imported/json/docs/examples/json_pointer__string_t.output new file mode 100644 index 000000000..d87113724 --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__string_t.output @@ -0,0 +1,2 @@ +This is a string. +true diff --git a/external_imported/json/docs/examples/json_pointer__to_string.cpp b/external_imported/json/docs/examples/json_pointer__to_string.cpp new file mode 100644 index 000000000..31d35a724 --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__to_string.cpp @@ -0,0 +1,34 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + // different JSON Pointers + json::json_pointer ptr1(""); + json::json_pointer ptr2("/foo"); + json::json_pointer ptr3("/foo/0"); + json::json_pointer ptr4("/"); + json::json_pointer ptr5("/a~1b"); + json::json_pointer ptr6("/c%d"); + json::json_pointer ptr7("/e^f"); + json::json_pointer ptr8("/g|h"); + json::json_pointer ptr9("/i\\j"); + json::json_pointer ptr10("/k\"l"); + json::json_pointer ptr11("/ "); + json::json_pointer ptr12("/m~0n"); + + std::cout << "\"" << ptr1.to_string() << "\"\n" + << "\"" << ptr2.to_string() << "\"\n" + << "\"" << ptr3.to_string() << "\"\n" + << "\"" << ptr4.to_string() << "\"\n" + << "\"" << ptr5.to_string() << "\"\n" + << "\"" << ptr6.to_string() << "\"\n" + << "\"" << ptr7.to_string() << "\"\n" + << "\"" << ptr8.to_string() << "\"\n" + << "\"" << ptr9.to_string() << "\"\n" + << "\"" << ptr10.to_string() << "\"\n" + << "\"" << ptr11.to_string() << "\"\n" + << "\"" << ptr12.to_string() << "\"" << std::endl; +} diff --git a/external_imported/json/docs/examples/json_pointer__to_string.output b/external_imported/json/docs/examples/json_pointer__to_string.output new file mode 100644 index 000000000..3c441357e --- /dev/null +++ b/external_imported/json/docs/examples/json_pointer__to_string.output @@ -0,0 +1,12 @@ +"" +"/foo" +"/foo/0" +"/" +"/a~1b" +"/c%d" +"/e^f" +"/g|h" +"/i\j" +"/k"l" +"/ " +"/m~0n" diff --git a/external_imported/json/doc/examples/max_size.cpp b/external_imported/json/docs/examples/max_size.cpp similarity index 100% rename from external_imported/json/doc/examples/max_size.cpp rename to external_imported/json/docs/examples/max_size.cpp diff --git a/external_imported/json/docs/examples/max_size.output b/external_imported/json/docs/examples/max_size.output new file mode 100644 index 000000000..b8dcb4d0c --- /dev/null +++ b/external_imported/json/docs/examples/max_size.output @@ -0,0 +1,7 @@ +0 +1 +1 +1 +115292150460684697 +576460752303423487 +1 diff --git a/external_imported/json/doc/examples/merge_patch.cpp b/external_imported/json/docs/examples/merge_patch.cpp similarity index 96% rename from external_imported/json/doc/examples/merge_patch.cpp rename to external_imported/json/docs/examples/merge_patch.cpp index b8804d7c5..f3fee1ed1 100644 --- a/external_imported/json/doc/examples/merge_patch.cpp +++ b/external_imported/json/docs/examples/merge_patch.cpp @@ -3,6 +3,7 @@ #include // for std::setw using json = nlohmann::json; +using namespace nlohmann::literals; int main() { diff --git a/external_imported/json/doc/examples/merge_patch.output b/external_imported/json/docs/examples/merge_patch.output similarity index 100% rename from external_imported/json/doc/examples/merge_patch.output rename to external_imported/json/docs/examples/merge_patch.output diff --git a/external_imported/json/doc/examples/meta.cpp b/external_imported/json/docs/examples/meta.cpp similarity index 100% rename from external_imported/json/doc/examples/meta.cpp rename to external_imported/json/docs/examples/meta.cpp diff --git a/external_imported/json/docs/examples/meta.output b/external_imported/json/docs/examples/meta.output new file mode 100644 index 000000000..90390f96b --- /dev/null +++ b/external_imported/json/docs/examples/meta.output @@ -0,0 +1,17 @@ +{ + "compiler": { + "c++": "201103", + "family": "gcc", + "version": "12.3.0" + }, + "copyright": "(C) 2013-2022 Niels Lohmann", + "name": "JSON for Modern C++", + "platform": "apple", + "url": "https://github.com/nlohmann/json", + "version": { + "major": 3, + "minor": 11, + "patch": 3, + "string": "3.11.3" + } +} diff --git a/external_imported/json/docs/examples/nlohmann_define_type_intrusive_explicit.cpp b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_explicit.cpp new file mode 100644 index 000000000..de79bd37c --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_explicit.cpp @@ -0,0 +1,60 @@ +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +namespace ns +{ +class person +{ + private: + std::string name = "John Doe"; + std::string address = "123 Fake St"; + int age = -1; + + public: + person() = default; + person(std::string name_, std::string address_, int age_) + : name(std::move(name_)), address(std::move(address_)), age(age_) + {} + + friend void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t) + { + nlohmann_json_j["name"] = nlohmann_json_t.name; + nlohmann_json_j["address"] = nlohmann_json_t.address; + nlohmann_json_j["age"] = nlohmann_json_t.age; + } + + friend void from_json(const nlohmann::json& nlohmann_json_j, person& nlohmann_json_t) + { + nlohmann_json_t.name = nlohmann_json_j.at("name"); + nlohmann_json_t.address = nlohmann_json_j.at("address"); + nlohmann_json_t.age = nlohmann_json_j.at("age"); + } +}; +} // namespace ns + +int main() +{ + ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; + + // serialization: person -> json + json j = p; + std::cout << "serialization: " << j << std::endl; + + // deserialization: json -> person + json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; + auto p2 = j2.template get(); + + // incomplete deserialization: + json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; + try + { + auto p3 = j3.template get(); + } + catch (const json::exception& e) + { + std::cout << "deserialization failed: " << e.what() << std::endl; + } +} diff --git a/external_imported/json/docs/examples/nlohmann_define_type_intrusive_explicit.output b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_explicit.output new file mode 100644 index 000000000..37f4eb414 --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_explicit.output @@ -0,0 +1,2 @@ +serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} +deserialization failed: [json.exception.out_of_range.403] key 'age' not found diff --git a/external_imported/json/docs/examples/nlohmann_define_type_intrusive_macro.cpp b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_macro.cpp new file mode 100644 index 000000000..4ecd4294f --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_macro.cpp @@ -0,0 +1,48 @@ +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +namespace ns +{ +class person +{ + private: + std::string name = "John Doe"; + std::string address = "123 Fake St"; + int age = -1; + + public: + person() = default; + person(std::string name_, std::string address_, int age_) + : name(std::move(name_)), address(std::move(address_)), age(age_) + {} + + NLOHMANN_DEFINE_TYPE_INTRUSIVE(person, name, address, age) +}; +} // namespace ns + +int main() +{ + ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; + + // serialization: person -> json + json j = p; + std::cout << "serialization: " << j << std::endl; + + // deserialization: json -> person + json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; + auto p2 = j2.template get(); + + // incomplete deserialization: + json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; + try + { + auto p3 = j3.template get(); + } + catch (const json::exception& e) + { + std::cout << "deserialization failed: " << e.what() << std::endl; + } +} diff --git a/external_imported/json/docs/examples/nlohmann_define_type_intrusive_macro.output b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_macro.output new file mode 100644 index 000000000..37f4eb414 --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_macro.output @@ -0,0 +1,2 @@ +serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} +deserialization failed: [json.exception.out_of_range.403] key 'age' not found diff --git a/external_imported/json/docs/examples/nlohmann_define_type_intrusive_only_serialize_explicit.cpp b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_only_serialize_explicit.cpp new file mode 100644 index 000000000..ea422beb5 --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_only_serialize_explicit.cpp @@ -0,0 +1,38 @@ +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +namespace ns +{ +class person +{ + private: + std::string name = "John Doe"; + std::string address = "123 Fake St"; + int age = -1; + + public: + // No default constructor + person(std::string name_, std::string address_, int age_) + : name(std::move(name_)), address(std::move(address_)), age(age_) + {} + + friend void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t) + { + nlohmann_json_j["name"] = nlohmann_json_t.name; + nlohmann_json_j["address"] = nlohmann_json_t.address; + nlohmann_json_j["age"] = nlohmann_json_t.age; + } +}; +} // namespace ns + +int main() +{ + ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; + + // serialization: person -> json + json j = p; + std::cout << "serialization: " << j << std::endl; +} diff --git a/external_imported/json/docs/examples/nlohmann_define_type_intrusive_only_serialize_explicit.output b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_only_serialize_explicit.output new file mode 100644 index 000000000..12f503307 --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_only_serialize_explicit.output @@ -0,0 +1 @@ +serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} diff --git a/external_imported/json/docs/examples/nlohmann_define_type_intrusive_only_serialize_macro.cpp b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_only_serialize_macro.cpp new file mode 100644 index 000000000..8213f9063 --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_only_serialize_macro.cpp @@ -0,0 +1,33 @@ +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +namespace ns +{ +class person +{ + private: + std::string name = "John Doe"; + std::string address = "123 Fake St"; + int age = -1; + + public: + // No default constructor + person(std::string name_, std::string address_, int age_) + : name(std::move(name_)), address(std::move(address_)), age(age_) + {} + + NLOHMANN_DEFINE_TYPE_INTRUSIVE(person, name, address, age) +}; +} // namespace ns + +int main() +{ + ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; + + // serialization: person -> json + json j = p; + std::cout << "serialization: " << j << std::endl; +} diff --git a/external_imported/json/docs/examples/nlohmann_define_type_intrusive_only_serialize_macro.output b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_only_serialize_macro.output new file mode 100644 index 000000000..12f503307 --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_only_serialize_macro.output @@ -0,0 +1 @@ +serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} diff --git a/external_imported/json/docs/examples/nlohmann_define_type_intrusive_with_default_explicit.cpp b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_with_default_explicit.cpp new file mode 100644 index 000000000..0fb2e1cb2 --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_with_default_explicit.cpp @@ -0,0 +1,55 @@ +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +namespace ns +{ +class person +{ + private: + std::string name = "John Doe"; + std::string address = "123 Fake St"; + int age = -1; + + public: + person() = default; + person(std::string name_, std::string address_, int age_) + : name(std::move(name_)), address(std::move(address_)), age(age_) + {} + + friend void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t) + { + nlohmann_json_j["name"] = nlohmann_json_t.name; + nlohmann_json_j["address"] = nlohmann_json_t.address; + nlohmann_json_j["age"] = nlohmann_json_t.age; + } + + friend void from_json(const nlohmann::json& nlohmann_json_j, person& nlohmann_json_t) + { + person nlohmann_json_default_obj; + nlohmann_json_t.name = nlohmann_json_j.value("name", nlohmann_json_default_obj.name); + nlohmann_json_t.address = nlohmann_json_j.value("address", nlohmann_json_default_obj.address); + nlohmann_json_t.age = nlohmann_json_j.value("age", nlohmann_json_default_obj.age); + } +}; +} // namespace ns + +int main() +{ + ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; + + // serialization: person -> json + json j = p; + std::cout << "serialization: " << j << std::endl; + + // deserialization: json -> person + json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; + auto p2 = j2.template get(); + + // incomplete deserialization: + json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; + auto p3 = j3.template get(); + std::cout << "roundtrip: " << json(p3) << std::endl; +} diff --git a/external_imported/json/docs/examples/nlohmann_define_type_intrusive_with_default_explicit.output b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_with_default_explicit.output new file mode 100644 index 000000000..1a255f65c --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_with_default_explicit.output @@ -0,0 +1,2 @@ +serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} +roundtrip: {"address":"742 Evergreen Terrace","age":-1,"name":"Maggie Simpson"} diff --git a/external_imported/json/docs/examples/nlohmann_define_type_intrusive_with_default_macro.cpp b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_with_default_macro.cpp new file mode 100644 index 000000000..52668516b --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_with_default_macro.cpp @@ -0,0 +1,42 @@ +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +namespace ns +{ +class person +{ + private: + std::string name = "John Doe"; + std::string address = "123 Fake St"; + int age = -1; + + public: + person() = default; + person(std::string name_, std::string address_, int age_) + : name(std::move(name_)), address(std::move(address_)), age(age_) + {} + + NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(person, name, address, age) +}; +} // namespace ns + +int main() +{ + ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; + + // serialization: person -> json + json j = p; + std::cout << "serialization: " << j << std::endl; + + // deserialization: json -> person + json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; + auto p2 = j2.template get(); + + // incomplete deserialization: + json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; + auto p3 = j3.template get(); + std::cout << "roundtrip: " << json(p3) << std::endl; +} diff --git a/external_imported/json/docs/examples/nlohmann_define_type_intrusive_with_default_macro.output b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_with_default_macro.output new file mode 100644 index 000000000..1a255f65c --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_intrusive_with_default_macro.output @@ -0,0 +1,2 @@ +serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} +roundtrip: {"address":"742 Evergreen Terrace","age":-1,"name":"Maggie Simpson"} diff --git a/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_explicit.cpp b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_explicit.cpp new file mode 100644 index 000000000..a31a7eb8f --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_explicit.cpp @@ -0,0 +1,53 @@ +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +namespace ns +{ +struct person +{ + std::string name; + std::string address; + int age; +}; + +void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t) +{ + nlohmann_json_j["name"] = nlohmann_json_t.name; + nlohmann_json_j["address"] = nlohmann_json_t.address; + nlohmann_json_j["age"] = nlohmann_json_t.age; +} + +void from_json(const nlohmann::json& nlohmann_json_j, person& nlohmann_json_t) +{ + nlohmann_json_t.name = nlohmann_json_j.at("name"); + nlohmann_json_t.address = nlohmann_json_j.at("address"); + nlohmann_json_t.age = nlohmann_json_j.at("age"); +} +} // namespace ns + +int main() +{ + ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; + + // serialization: person -> json + json j = p; + std::cout << "serialization: " << j << std::endl; + + // deserialization: json -> person + json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; + auto p2 = j2.template get(); + + // incomplete deserialization: + json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; + try + { + auto p3 = j3.template get(); + } + catch (const json::exception& e) + { + std::cout << "deserialization failed: " << e.what() << std::endl; + } +} diff --git a/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_explicit.output b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_explicit.output new file mode 100644 index 000000000..37f4eb414 --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_explicit.output @@ -0,0 +1,2 @@ +serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} +deserialization failed: [json.exception.out_of_range.403] key 'age' not found diff --git a/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_macro.cpp b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_macro.cpp new file mode 100644 index 000000000..d11691b70 --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_macro.cpp @@ -0,0 +1,41 @@ +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +namespace ns +{ +struct person +{ + std::string name; + std::string address; + int age; +}; + +NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(person, name, address, age) +} // namespace ns + +int main() +{ + ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; + + // serialization: person -> json + json j = p; + std::cout << "serialization: " << j << std::endl; + + // deserialization: json -> person + json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; + auto p2 = j2.template get(); + + // incomplete deserialization: + json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; + try + { + auto p3 = j3.template get(); + } + catch (const json::exception& e) + { + std::cout << "deserialization failed: " << e.what() << std::endl; + } +} diff --git a/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_macro.output b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_macro.output new file mode 100644 index 000000000..37f4eb414 --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_macro.output @@ -0,0 +1,2 @@ +serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} +deserialization failed: [json.exception.out_of_range.403] key 'age' not found diff --git a/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_only_serialize_explicit.cpp b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_only_serialize_explicit.cpp new file mode 100644 index 000000000..8890e03af --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_only_serialize_explicit.cpp @@ -0,0 +1,31 @@ +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +namespace ns +{ +struct person +{ + std::string name; + std::string address; + int age; +}; + +void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t) +{ + nlohmann_json_j["name"] = nlohmann_json_t.name; + nlohmann_json_j["address"] = nlohmann_json_t.address; + nlohmann_json_j["age"] = nlohmann_json_t.age; +} +} // namespace ns + +int main() +{ + ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; + + // serialization: person -> json + json j = p; + std::cout << "serialization: " << j << std::endl; +} diff --git a/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_only_serialize_explicit.output b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_only_serialize_explicit.output new file mode 100644 index 000000000..12f503307 --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_only_serialize_explicit.output @@ -0,0 +1 @@ +serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} diff --git a/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_only_serialize_macro.cpp b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_only_serialize_macro.cpp new file mode 100644 index 000000000..7aef23af6 --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_only_serialize_macro.cpp @@ -0,0 +1,26 @@ +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +namespace ns +{ +struct person +{ + std::string name; + std::string address; + int age; +}; + +NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(person, name, address, age) +} // namespace ns + +int main() +{ + ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; + + // serialization: person -> json + json j = p; + std::cout << "serialization: " << j << std::endl; +} diff --git a/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_only_serialize_macro.output b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_only_serialize_macro.output new file mode 100644 index 000000000..12f503307 --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_only_serialize_macro.output @@ -0,0 +1 @@ +serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} diff --git a/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_with_default_explicit.cpp b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_with_default_explicit.cpp new file mode 100644 index 000000000..855ab52b8 --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_with_default_explicit.cpp @@ -0,0 +1,53 @@ +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +namespace ns +{ +struct person +{ + std::string name = "John Doe"; + std::string address = "123 Fake St"; + int age = -1; + + person() = default; + person(std::string name_, std::string address_, int age_) + : name(std::move(name_)), address(std::move(address_)), age(age_) + {} +}; + +void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t) +{ + nlohmann_json_j["name"] = nlohmann_json_t.name; + nlohmann_json_j["address"] = nlohmann_json_t.address; + nlohmann_json_j["age"] = nlohmann_json_t.age; +} + +void from_json(const nlohmann::json& nlohmann_json_j, person& nlohmann_json_t) +{ + person nlohmann_json_default_obj; + nlohmann_json_t.name = nlohmann_json_j.value("name", nlohmann_json_default_obj.name); + nlohmann_json_t.address = nlohmann_json_j.value("address", nlohmann_json_default_obj.address); + nlohmann_json_t.age = nlohmann_json_j.value("age", nlohmann_json_default_obj.age); +} +} // namespace ns + +int main() +{ + ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; + + // serialization: person -> json + json j = p; + std::cout << "serialization: " << j << std::endl; + + // deserialization: json -> person + json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; + auto p2 = j2.template get(); + + // incomplete deserialization: + json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; + auto p3 = j3.template get(); + std::cout << "roundtrip: " << json(p3) << std::endl; +} diff --git a/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_with_default_explicit.output b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_with_default_explicit.output new file mode 100644 index 000000000..1a255f65c --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_with_default_explicit.output @@ -0,0 +1,2 @@ +serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} +roundtrip: {"address":"742 Evergreen Terrace","age":-1,"name":"Maggie Simpson"} diff --git a/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_with_default_macro.cpp b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_with_default_macro.cpp new file mode 100644 index 000000000..8c41c65ec --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_with_default_macro.cpp @@ -0,0 +1,40 @@ +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +namespace ns +{ +struct person +{ + std::string name = "John Doe"; + std::string address = "123 Fake St"; + int age = -1; + + person() = default; + person(std::string name_, std::string address_, int age_) + : name(std::move(name_)), address(std::move(address_)), age(age_) + {} +}; + +NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(person, name, address, age) +} // namespace ns + +int main() +{ + ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; + + // serialization: person -> json + json j = p; + std::cout << "serialization: " << j << std::endl; + + // deserialization: json -> person + json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; + auto p2 = j2.template get(); + + // incomplete deserialization: + json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; + auto p3 = j3.template get(); + std::cout << "roundtrip: " << json(p3) << std::endl; +} diff --git a/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_with_default_macro.output b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_with_default_macro.output new file mode 100644 index 000000000..1a255f65c --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_define_type_non_intrusive_with_default_macro.output @@ -0,0 +1,2 @@ +serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} +roundtrip: {"address":"742 Evergreen Terrace","age":-1,"name":"Maggie Simpson"} diff --git a/external_imported/json/docs/examples/nlohmann_json_namespace.cpp b/external_imported/json/docs/examples/nlohmann_json_namespace.cpp new file mode 100644 index 000000000..4bad91f4b --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_json_namespace.cpp @@ -0,0 +1,14 @@ +#include +#include + +// possible use case: use NLOHMANN_JSON_NAMESPACE instead of nlohmann +using json = NLOHMANN_JSON_NAMESPACE::json; + +// macro needed to output the NLOHMANN_JSON_NAMESPACE as string literal +#define Q(x) #x +#define QUOTE(x) Q(x) + +int main() +{ + std::cout << QUOTE(NLOHMANN_JSON_NAMESPACE) << std::endl; +} diff --git a/external_imported/json/docs/examples/nlohmann_json_namespace.output b/external_imported/json/docs/examples/nlohmann_json_namespace.output new file mode 100644 index 000000000..5565deafd --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_json_namespace.output @@ -0,0 +1 @@ +nlohmann::json_abi_v3_11_3 diff --git a/external_imported/json/docs/examples/nlohmann_json_namespace_begin.c++17.cpp b/external_imported/json/docs/examples/nlohmann_json_namespace_begin.c++17.cpp new file mode 100644 index 000000000..9385d593d --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_json_namespace_begin.c++17.cpp @@ -0,0 +1,33 @@ +#include +#include +#include + +// partial specialization (see https://json.nlohmann.me/features/arbitrary_types/) +NLOHMANN_JSON_NAMESPACE_BEGIN +template +struct adl_serializer> +{ + static void to_json(json& j, const std::optional& opt) + { + if (opt == std::nullopt) + { + j = nullptr; + } + else + { + j = *opt; + } + } +}; +NLOHMANN_JSON_NAMESPACE_END + +int main() +{ + std::optional o1 = 1; + std::optional o2 = std::nullopt; + + NLOHMANN_JSON_NAMESPACE::json j; + j.push_back(o1); + j.push_back(o2); + std::cout << j << std::endl; +} diff --git a/external_imported/json/docs/examples/nlohmann_json_namespace_begin.c++17.output b/external_imported/json/docs/examples/nlohmann_json_namespace_begin.c++17.output new file mode 100644 index 000000000..b29d3b93c --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_json_namespace_begin.c++17.output @@ -0,0 +1 @@ +[1,null] diff --git a/external_imported/json/docs/examples/nlohmann_json_namespace_no_version.cpp b/external_imported/json/docs/examples/nlohmann_json_namespace_no_version.cpp new file mode 100644 index 000000000..97948dd7e --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_json_namespace_no_version.cpp @@ -0,0 +1,13 @@ +#include + +#define NLOHMANN_JSON_NAMESPACE_NO_VERSION 1 +#include + +// macro needed to output the NLOHMANN_JSON_NAMESPACE as string literal +#define Q(x) #x +#define QUOTE(x) Q(x) + +int main() +{ + std::cout << QUOTE(NLOHMANN_JSON_NAMESPACE) << std::endl; +} diff --git a/external_imported/json/docs/examples/nlohmann_json_namespace_no_version.output b/external_imported/json/docs/examples/nlohmann_json_namespace_no_version.output new file mode 100644 index 000000000..1c8f3132b --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_json_namespace_no_version.output @@ -0,0 +1 @@ +nlohmann::json_abi diff --git a/external_imported/json/docs/examples/nlohmann_json_serialize_enum.cpp b/external_imported/json/docs/examples/nlohmann_json_serialize_enum.cpp new file mode 100644 index 000000000..a40db49ea --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_json_serialize_enum.cpp @@ -0,0 +1,59 @@ +#include +#include + +using json = nlohmann::json; + +namespace ns +{ +enum TaskState +{ + TS_STOPPED, + TS_RUNNING, + TS_COMPLETED, + TS_INVALID = -1 +}; + +NLOHMANN_JSON_SERIALIZE_ENUM(TaskState, +{ + { TS_INVALID, nullptr }, + { TS_STOPPED, "stopped" }, + { TS_RUNNING, "running" }, + { TS_COMPLETED, "completed" } +}) + +enum class Color +{ + red, green, blue, unknown +}; + +NLOHMANN_JSON_SERIALIZE_ENUM(Color, +{ + { Color::unknown, "unknown" }, { Color::red, "red" }, + { Color::green, "green" }, { Color::blue, "blue" } +}) +} // namespace ns + +int main() +{ + // serialization + json j_stopped = ns::TS_STOPPED; + json j_red = ns::Color::red; + std::cout << "ns::TS_STOPPED -> " << j_stopped + << ", ns::Color::red -> " << j_red << std::endl; + + // deserialization + json j_running = "running"; + json j_blue = "blue"; + auto running = j_running.template get(); + auto blue = j_blue.template get(); + std::cout << j_running << " -> " << running + << ", " << j_blue << " -> " << static_cast(blue) << std::endl; + + // deserializing undefined JSON value to enum + // (where the first map entry above is the default) + json j_pi = 3.14; + auto invalid = j_pi.template get(); + auto unknown = j_pi.template get(); + std::cout << j_pi << " -> " << invalid << ", " + << j_pi << " -> " << static_cast(unknown) << std::endl; +} diff --git a/external_imported/json/docs/examples/nlohmann_json_serialize_enum.output b/external_imported/json/docs/examples/nlohmann_json_serialize_enum.output new file mode 100644 index 000000000..f512563dd --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_json_serialize_enum.output @@ -0,0 +1,3 @@ +ns::TS_STOPPED -> "stopped", ns::Color::red -> "red" +"running" -> 1, "blue" -> 2 +3.14 -> -1, 3.14 -> 3 diff --git a/external_imported/json/docs/examples/nlohmann_json_serialize_enum_2.cpp b/external_imported/json/docs/examples/nlohmann_json_serialize_enum_2.cpp new file mode 100644 index 000000000..b35e94cc5 --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_json_serialize_enum_2.cpp @@ -0,0 +1,33 @@ +#include +#include + +using json = nlohmann::json; + +namespace ns +{ +enum class Color +{ + red, green, blue, unknown +}; + +NLOHMANN_JSON_SERIALIZE_ENUM(Color, +{ + { Color::unknown, "unknown" }, { Color::red, "red" }, + { Color::green, "green" }, { Color::blue, "blue" }, + { Color::red, "rot" } // a second conversion for Color::red +}) +} + +int main() +{ + // serialization + json j_red = ns::Color::red; + std::cout << static_cast(ns::Color::red) << " -> " << j_red << std::endl; + + // deserialization + json j_rot = "rot"; + auto rot = j_rot.template get(); + auto red = j_red.template get(); + std::cout << j_rot << " -> " << static_cast(rot) << std::endl; + std::cout << j_red << " -> " << static_cast(red) << std::endl; +} diff --git a/external_imported/json/docs/examples/nlohmann_json_serialize_enum_2.output b/external_imported/json/docs/examples/nlohmann_json_serialize_enum_2.output new file mode 100644 index 000000000..5dec31b4a --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_json_serialize_enum_2.output @@ -0,0 +1,3 @@ +0 -> "red" +"rot" -> 0 +"red" -> 0 diff --git a/external_imported/json/docs/examples/nlohmann_json_version.cpp b/external_imported/json/docs/examples/nlohmann_json_version.cpp new file mode 100644 index 000000000..ca5f53728 --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_json_version.cpp @@ -0,0 +1,12 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + std::cout << "JSON for Modern C++ version " + << NLOHMANN_JSON_VERSION_MAJOR << "." + << NLOHMANN_JSON_VERSION_MINOR << "." + << NLOHMANN_JSON_VERSION_PATCH << std::endl; +} diff --git a/external_imported/json/docs/examples/nlohmann_json_version.output b/external_imported/json/docs/examples/nlohmann_json_version.output new file mode 100644 index 000000000..75dbe8478 --- /dev/null +++ b/external_imported/json/docs/examples/nlohmann_json_version.output @@ -0,0 +1 @@ +JSON for Modern C++ version 3.11.3 diff --git a/external_imported/json/docs/examples/number_float_t.cpp b/external_imported/json/docs/examples/number_float_t.cpp new file mode 100644 index 000000000..21211dc51 --- /dev/null +++ b/external_imported/json/docs/examples/number_float_t.cpp @@ -0,0 +1,10 @@ +#include +#include +#include + +using json = nlohmann::json; + +int main() +{ + std::cout << std::boolalpha << std::is_same::value << std::endl; +} diff --git a/external_imported/json/docs/examples/number_float_t.output b/external_imported/json/docs/examples/number_float_t.output new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/external_imported/json/docs/examples/number_float_t.output @@ -0,0 +1 @@ +true diff --git a/external_imported/json/docs/examples/number_integer_t.cpp b/external_imported/json/docs/examples/number_integer_t.cpp new file mode 100644 index 000000000..75ee57b63 --- /dev/null +++ b/external_imported/json/docs/examples/number_integer_t.cpp @@ -0,0 +1,10 @@ +#include +#include +#include + +using json = nlohmann::json; + +int main() +{ + std::cout << std::boolalpha << std::is_same::value << std::endl; +} diff --git a/external_imported/json/docs/examples/number_integer_t.output b/external_imported/json/docs/examples/number_integer_t.output new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/external_imported/json/docs/examples/number_integer_t.output @@ -0,0 +1 @@ +true diff --git a/external_imported/json/docs/examples/number_unsigned_t.cpp b/external_imported/json/docs/examples/number_unsigned_t.cpp new file mode 100644 index 000000000..ff3b86df8 --- /dev/null +++ b/external_imported/json/docs/examples/number_unsigned_t.cpp @@ -0,0 +1,10 @@ +#include +#include +#include + +using json = nlohmann::json; + +int main() +{ + std::cout << std::boolalpha << std::is_same::value << std::endl; +} diff --git a/external_imported/json/docs/examples/number_unsigned_t.output b/external_imported/json/docs/examples/number_unsigned_t.output new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/external_imported/json/docs/examples/number_unsigned_t.output @@ -0,0 +1 @@ +true diff --git a/external_imported/json/doc/examples/object.cpp b/external_imported/json/docs/examples/object.cpp similarity index 94% rename from external_imported/json/doc/examples/object.cpp rename to external_imported/json/docs/examples/object.cpp index 733b89b53..ad167d4af 100644 --- a/external_imported/json/doc/examples/object.cpp +++ b/external_imported/json/docs/examples/object.cpp @@ -21,7 +21,7 @@ int main() // can only create an object from a list of pairs json j_invalid_object = json::object({{ "one", 1, 2 }}); } - catch (json::type_error& e) + catch (const json::type_error& e) { std::cout << e.what() << '\n'; } diff --git a/external_imported/json/doc/examples/object.output b/external_imported/json/docs/examples/object.output similarity index 100% rename from external_imported/json/doc/examples/object.output rename to external_imported/json/docs/examples/object.output diff --git a/external_imported/json/docs/examples/object_comparator_t.cpp b/external_imported/json/docs/examples/object_comparator_t.cpp new file mode 100644 index 000000000..6b82c7ca6 --- /dev/null +++ b/external_imported/json/docs/examples/object_comparator_t.cpp @@ -0,0 +1,11 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + std::cout << std::boolalpha + << "json::object_comparator_t(\"one\", \"two\") = " << json::object_comparator_t{}("one", "two") << "\n" + << "json::object_comparator_t(\"three\", \"four\") = " << json::object_comparator_t{}("three", "four") << std::endl; +} diff --git a/external_imported/json/docs/examples/object_comparator_t.output b/external_imported/json/docs/examples/object_comparator_t.output new file mode 100644 index 000000000..63620edb4 --- /dev/null +++ b/external_imported/json/docs/examples/object_comparator_t.output @@ -0,0 +1,2 @@ +json::object_comparator_t("one", "two") = true +json::object_comparator_t("three", "four") = false diff --git a/external_imported/json/docs/examples/object_t.cpp b/external_imported/json/docs/examples/object_t.cpp new file mode 100644 index 000000000..85cfa3e33 --- /dev/null +++ b/external_imported/json/docs/examples/object_t.cpp @@ -0,0 +1,10 @@ +#include +#include +#include + +using json = nlohmann::json; + +int main() +{ + std::cout << std::boolalpha << std::is_same, json::object_t>::value << std::endl; +} diff --git a/external_imported/json/docs/examples/object_t.output b/external_imported/json/docs/examples/object_t.output new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/external_imported/json/docs/examples/object_t.output @@ -0,0 +1 @@ +true diff --git a/external_imported/json/doc/examples/operator__ValueType.cpp b/external_imported/json/docs/examples/operator__ValueType.cpp similarity index 97% rename from external_imported/json/doc/examples/operator__ValueType.cpp rename to external_imported/json/docs/examples/operator__ValueType.cpp index 66fcf310e..e8a1d349d 100644 --- a/external_imported/json/doc/examples/operator__ValueType.cpp +++ b/external_imported/json/docs/examples/operator__ValueType.cpp @@ -53,7 +53,7 @@ int main() { bool v1 = json_types["string"]; } - catch (json::type_error& e) + catch (const json::type_error& e) { std::cout << e.what() << '\n'; } diff --git a/external_imported/json/doc/examples/operator__ValueType.output b/external_imported/json/docs/examples/operator__ValueType.output similarity index 100% rename from external_imported/json/doc/examples/operator__ValueType.output rename to external_imported/json/docs/examples/operator__ValueType.output diff --git a/external_imported/json/doc/examples/operator__equal.cpp b/external_imported/json/docs/examples/operator__equal.cpp similarity index 100% rename from external_imported/json/doc/examples/operator__equal.cpp rename to external_imported/json/docs/examples/operator__equal.cpp diff --git a/external_imported/json/doc/examples/operator__equal.output b/external_imported/json/docs/examples/operator__equal.output similarity index 100% rename from external_imported/json/doc/examples/operator__equal.output rename to external_imported/json/docs/examples/operator__equal.output diff --git a/external_imported/json/doc/examples/operator__equal__nullptr_t.cpp b/external_imported/json/docs/examples/operator__equal__nullptr_t.cpp similarity index 100% rename from external_imported/json/doc/examples/operator__equal__nullptr_t.cpp rename to external_imported/json/docs/examples/operator__equal__nullptr_t.cpp diff --git a/external_imported/json/doc/examples/operator__equal__nullptr_t.output b/external_imported/json/docs/examples/operator__equal__nullptr_t.output similarity index 100% rename from external_imported/json/doc/examples/operator__equal__nullptr_t.output rename to external_imported/json/docs/examples/operator__equal__nullptr_t.output diff --git a/external_imported/json/docs/examples/operator__equal__specializations.cpp b/external_imported/json/docs/examples/operator__equal__specializations.cpp new file mode 100644 index 000000000..97d5ecead --- /dev/null +++ b/external_imported/json/docs/examples/operator__equal__specializations.cpp @@ -0,0 +1,16 @@ +#include +#include +#include + +using json = nlohmann::json; + +int main() +{ + nlohmann::json uj1 = {{"version", 1}, {"type", "integer"}}; + nlohmann::json uj2 = {{"type", "integer"}, {"version", 1}}; + + nlohmann::ordered_json oj1 = {{"version", 1}, {"type", "integer"}}; + nlohmann::ordered_json oj2 = {{"type", "integer"}, {"version", 1}}; + + std::cout << std::boolalpha << (uj1 == uj2) << '\n' << (oj1 == oj2) << std::endl; +} diff --git a/external_imported/json/docs/examples/operator__equal__specializations.output b/external_imported/json/docs/examples/operator__equal__specializations.output new file mode 100644 index 000000000..da29283aa --- /dev/null +++ b/external_imported/json/docs/examples/operator__equal__specializations.output @@ -0,0 +1,2 @@ +true +false diff --git a/external_imported/json/doc/examples/operator__greater.cpp b/external_imported/json/docs/examples/operator__greater.cpp similarity index 100% rename from external_imported/json/doc/examples/operator__greater.cpp rename to external_imported/json/docs/examples/operator__greater.cpp diff --git a/external_imported/json/doc/examples/operator__greater.output b/external_imported/json/docs/examples/operator__greater.output similarity index 100% rename from external_imported/json/doc/examples/operator__greater.output rename to external_imported/json/docs/examples/operator__greater.output diff --git a/external_imported/json/doc/examples/operator__greaterequal.cpp b/external_imported/json/docs/examples/operator__greaterequal.cpp similarity index 100% rename from external_imported/json/doc/examples/operator__greaterequal.cpp rename to external_imported/json/docs/examples/operator__greaterequal.cpp diff --git a/external_imported/json/doc/examples/operator__greaterequal.output b/external_imported/json/docs/examples/operator__greaterequal.output similarity index 100% rename from external_imported/json/doc/examples/operator__greaterequal.output rename to external_imported/json/docs/examples/operator__greaterequal.output diff --git a/external_imported/json/doc/examples/operator__less.cpp b/external_imported/json/docs/examples/operator__less.cpp similarity index 100% rename from external_imported/json/doc/examples/operator__less.cpp rename to external_imported/json/docs/examples/operator__less.cpp diff --git a/external_imported/json/doc/examples/operator__less.output b/external_imported/json/docs/examples/operator__less.output similarity index 100% rename from external_imported/json/doc/examples/operator__less.output rename to external_imported/json/docs/examples/operator__less.output diff --git a/external_imported/json/doc/examples/operator__lessequal.cpp b/external_imported/json/docs/examples/operator__lessequal.cpp similarity index 100% rename from external_imported/json/doc/examples/operator__lessequal.cpp rename to external_imported/json/docs/examples/operator__lessequal.cpp diff --git a/external_imported/json/doc/examples/operator__lessequal.output b/external_imported/json/docs/examples/operator__lessequal.output similarity index 100% rename from external_imported/json/doc/examples/operator__lessequal.output rename to external_imported/json/docs/examples/operator__lessequal.output diff --git a/external_imported/json/doc/examples/operator__notequal.cpp b/external_imported/json/docs/examples/operator__notequal.cpp similarity index 100% rename from external_imported/json/doc/examples/operator__notequal.cpp rename to external_imported/json/docs/examples/operator__notequal.cpp diff --git a/external_imported/json/doc/examples/operator__notequal.output b/external_imported/json/docs/examples/operator__notequal.output similarity index 100% rename from external_imported/json/doc/examples/operator__notequal.output rename to external_imported/json/docs/examples/operator__notequal.output diff --git a/external_imported/json/doc/examples/operator__notequal__nullptr_t.cpp b/external_imported/json/docs/examples/operator__notequal__nullptr_t.cpp similarity index 100% rename from external_imported/json/doc/examples/operator__notequal__nullptr_t.cpp rename to external_imported/json/docs/examples/operator__notequal__nullptr_t.cpp diff --git a/external_imported/json/doc/examples/operator__notequal__nullptr_t.output b/external_imported/json/docs/examples/operator__notequal__nullptr_t.output similarity index 100% rename from external_imported/json/doc/examples/operator__notequal__nullptr_t.output rename to external_imported/json/docs/examples/operator__notequal__nullptr_t.output diff --git a/external_imported/json/doc/examples/operator__value_t.cpp b/external_imported/json/docs/examples/operator__value_t.cpp similarity index 100% rename from external_imported/json/doc/examples/operator__value_t.cpp rename to external_imported/json/docs/examples/operator__value_t.cpp diff --git a/external_imported/json/doc/examples/operator__value_t.output b/external_imported/json/docs/examples/operator__value_t.output similarity index 100% rename from external_imported/json/doc/examples/operator__value_t.output rename to external_imported/json/docs/examples/operator__value_t.output diff --git a/external_imported/json/docs/examples/operator_array__json_pointer.cpp b/external_imported/json/docs/examples/operator_array__json_pointer.cpp new file mode 100644 index 000000000..0fa207f02 --- /dev/null +++ b/external_imported/json/docs/examples/operator_array__json_pointer.cpp @@ -0,0 +1,49 @@ +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +int main() +{ + // create a JSON value + json j = + { + {"number", 1}, {"string", "foo"}, {"array", {1, 2}} + }; + + // read-only access + + // output element with JSON pointer "/number" + std::cout << j["/number"_json_pointer] << '\n'; + // output element with JSON pointer "/string" + std::cout << j["/string"_json_pointer] << '\n'; + // output element with JSON pointer "/array" + std::cout << j["/array"_json_pointer] << '\n'; + // output element with JSON pointer "/array/1" + std::cout << j["/array/1"_json_pointer] << '\n'; + + // writing access + + // change the string + j["/string"_json_pointer] = "bar"; + // output the changed string + std::cout << j["string"] << '\n'; + + // "change" a nonexisting object entry + j["/boolean"_json_pointer] = true; + // output the changed object + std::cout << j << '\n'; + + // change an array element + j["/array/1"_json_pointer] = 21; + // "change" an array element with nonexisting index + j["/array/4"_json_pointer] = 44; + // output the changed array + std::cout << j["array"] << '\n'; + + // "change" the array element past the end + j["/array/-"_json_pointer] = 55; + // output the changed array + std::cout << j["array"] << '\n'; +} diff --git a/external_imported/json/doc/examples/operatorjson_pointer.output b/external_imported/json/docs/examples/operator_array__json_pointer.output similarity index 100% rename from external_imported/json/doc/examples/operatorjson_pointer.output rename to external_imported/json/docs/examples/operator_array__json_pointer.output diff --git a/external_imported/json/docs/examples/operator_array__json_pointer_const.cpp b/external_imported/json/docs/examples/operator_array__json_pointer_const.cpp new file mode 100644 index 000000000..f40e2494a --- /dev/null +++ b/external_imported/json/docs/examples/operator_array__json_pointer_const.cpp @@ -0,0 +1,25 @@ +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +int main() +{ + // create a JSON value + const json j = + { + {"number", 1}, {"string", "foo"}, {"array", {1, 2}} + }; + + // read-only access + + // output element with JSON pointer "/number" + std::cout << j["/number"_json_pointer] << '\n'; + // output element with JSON pointer "/string" + std::cout << j["/string"_json_pointer] << '\n'; + // output element with JSON pointer "/array" + std::cout << j["/array"_json_pointer] << '\n'; + // output element with JSON pointer "/array/1" + std::cout << j["/array/1"_json_pointer] << '\n'; +} diff --git a/external_imported/json/doc/examples/operatorjson_pointer_const.output b/external_imported/json/docs/examples/operator_array__json_pointer_const.output similarity index 100% rename from external_imported/json/doc/examples/operatorjson_pointer_const.output rename to external_imported/json/docs/examples/operator_array__json_pointer_const.output diff --git a/external_imported/json/docs/examples/operator_array__keytype.c++17.cpp b/external_imported/json/docs/examples/operator_array__keytype.c++17.cpp new file mode 100644 index 000000000..7f2b41dd8 --- /dev/null +++ b/external_imported/json/docs/examples/operator_array__keytype.c++17.cpp @@ -0,0 +1,34 @@ +#include +#include +#include +#include + +using namespace std::string_view_literals; +using json = nlohmann::json; + +int main() +{ + // create a JSON object + json object = + { + {"one", 1}, {"two", 2}, {"three", 2.9} + }; + + // output element with key "two" + std::cout << object["two"sv] << "\n\n"; + + // change element with key "three" + object["three"sv] = 3; + + // output changed array + std::cout << std::setw(4) << object << "\n\n"; + + // mention nonexisting key + object["four"sv]; + + // write to nonexisting key + object["five"sv]["really"sv]["nested"sv] = true; + + // output changed object + std::cout << std::setw(4) << object << '\n'; +} diff --git a/external_imported/json/doc/examples/operatorarray__key_type.output b/external_imported/json/docs/examples/operator_array__keytype.c++17.output similarity index 100% rename from external_imported/json/doc/examples/operatorarray__key_type.output rename to external_imported/json/docs/examples/operator_array__keytype.c++17.output diff --git a/external_imported/json/docs/examples/operator_array__keytype_const.c++17.cpp b/external_imported/json/docs/examples/operator_array__keytype_const.c++17.cpp new file mode 100644 index 000000000..2cf94f40f --- /dev/null +++ b/external_imported/json/docs/examples/operator_array__keytype_const.c++17.cpp @@ -0,0 +1,18 @@ +#include +#include +#include + +using namespace std::string_view_literals; +using json = nlohmann::json; + +int main() +{ + // create a JSON object + const json object = + { + {"one", 1}, {"two", 2}, {"three", 2.9} + }; + + // output element with key "two" + std::cout << object["two"sv] << '\n'; +} diff --git a/external_imported/json/doc/examples/operatorarray__key_type_const.output b/external_imported/json/docs/examples/operator_array__keytype_const.c++17.output similarity index 100% rename from external_imported/json/doc/examples/operatorarray__key_type_const.output rename to external_imported/json/docs/examples/operator_array__keytype_const.c++17.output diff --git a/external_imported/json/doc/examples/operatorarray__key_type.cpp b/external_imported/json/docs/examples/operator_array__object_t_key_type.cpp similarity index 100% rename from external_imported/json/doc/examples/operatorarray__key_type.cpp rename to external_imported/json/docs/examples/operator_array__object_t_key_type.cpp diff --git a/external_imported/json/docs/examples/operator_array__object_t_key_type.output b/external_imported/json/docs/examples/operator_array__object_t_key_type.output new file mode 100644 index 000000000..b643587f1 --- /dev/null +++ b/external_imported/json/docs/examples/operator_array__object_t_key_type.output @@ -0,0 +1,19 @@ +2 + +{ + "one": 1, + "three": 3, + "two": 2 +} + +{ + "five": { + "really": { + "nested": true + } + }, + "four": null, + "one": 1, + "three": 3, + "two": 2 +} diff --git a/external_imported/json/doc/examples/operatorarray__key_type_const.cpp b/external_imported/json/docs/examples/operator_array__object_t_key_type_const.cpp similarity index 100% rename from external_imported/json/doc/examples/operatorarray__key_type_const.cpp rename to external_imported/json/docs/examples/operator_array__object_t_key_type_const.cpp diff --git a/external_imported/json/docs/examples/operator_array__object_t_key_type_const.output b/external_imported/json/docs/examples/operator_array__object_t_key_type_const.output new file mode 100644 index 000000000..0cfbf0888 --- /dev/null +++ b/external_imported/json/docs/examples/operator_array__object_t_key_type_const.output @@ -0,0 +1 @@ +2 diff --git a/external_imported/json/doc/examples/operatorarray__size_type.cpp b/external_imported/json/docs/examples/operator_array__size_type.cpp similarity index 100% rename from external_imported/json/doc/examples/operatorarray__size_type.cpp rename to external_imported/json/docs/examples/operator_array__size_type.cpp diff --git a/external_imported/json/doc/examples/operatorarray__size_type.output b/external_imported/json/docs/examples/operator_array__size_type.output similarity index 100% rename from external_imported/json/doc/examples/operatorarray__size_type.output rename to external_imported/json/docs/examples/operator_array__size_type.output diff --git a/external_imported/json/doc/examples/operatorarray__size_type_const.cpp b/external_imported/json/docs/examples/operator_array__size_type_const.cpp similarity index 100% rename from external_imported/json/doc/examples/operatorarray__size_type_const.cpp rename to external_imported/json/docs/examples/operator_array__size_type_const.cpp diff --git a/external_imported/json/doc/examples/operatorarray__size_type_const.output b/external_imported/json/docs/examples/operator_array__size_type_const.output similarity index 100% rename from external_imported/json/doc/examples/operatorarray__size_type_const.output rename to external_imported/json/docs/examples/operator_array__size_type_const.output diff --git a/external_imported/json/doc/examples/operator_deserialize.cpp b/external_imported/json/docs/examples/operator_deserialize.cpp similarity index 100% rename from external_imported/json/doc/examples/operator_deserialize.cpp rename to external_imported/json/docs/examples/operator_deserialize.cpp diff --git a/external_imported/json/doc/examples/operator_deserialize.output b/external_imported/json/docs/examples/operator_deserialize.output similarity index 100% rename from external_imported/json/doc/examples/operator_deserialize.output rename to external_imported/json/docs/examples/operator_deserialize.output diff --git a/external_imported/json/docs/examples/operator_literal_json.cpp b/external_imported/json/docs/examples/operator_literal_json.cpp new file mode 100644 index 000000000..84ca6297d --- /dev/null +++ b/external_imported/json/docs/examples/operator_literal_json.cpp @@ -0,0 +1,13 @@ +#include +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +int main() +{ + json j = R"( {"hello": "world", "answer": 42} )"_json; + + std::cout << std::setw(2) << j << '\n'; +} diff --git a/external_imported/json/docs/examples/operator_literal_json.output b/external_imported/json/docs/examples/operator_literal_json.output new file mode 100644 index 000000000..6c0a7b34b --- /dev/null +++ b/external_imported/json/docs/examples/operator_literal_json.output @@ -0,0 +1,4 @@ +{ + "answer": 42, + "hello": "world" +} diff --git a/external_imported/json/docs/examples/operator_literal_json_pointer.cpp b/external_imported/json/docs/examples/operator_literal_json_pointer.cpp new file mode 100644 index 000000000..aba93e88e --- /dev/null +++ b/external_imported/json/docs/examples/operator_literal_json_pointer.cpp @@ -0,0 +1,14 @@ +#include +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +int main() +{ + json j = R"( {"hello": "world", "answer": 42} )"_json; + auto val = j["/hello"_json_pointer]; + + std::cout << std::setw(2) << val << '\n'; +} diff --git a/external_imported/json/docs/examples/operator_literal_json_pointer.output b/external_imported/json/docs/examples/operator_literal_json_pointer.output new file mode 100644 index 000000000..b0fcd3479 --- /dev/null +++ b/external_imported/json/docs/examples/operator_literal_json_pointer.output @@ -0,0 +1 @@ +"world" diff --git a/external_imported/json/doc/examples/operator_serialize.cpp b/external_imported/json/docs/examples/operator_ltlt__basic_json.cpp similarity index 100% rename from external_imported/json/doc/examples/operator_serialize.cpp rename to external_imported/json/docs/examples/operator_ltlt__basic_json.cpp diff --git a/external_imported/json/doc/examples/operator_serialize.output b/external_imported/json/docs/examples/operator_ltlt__basic_json.output similarity index 100% rename from external_imported/json/doc/examples/operator_serialize.output rename to external_imported/json/docs/examples/operator_ltlt__basic_json.output diff --git a/external_imported/json/docs/examples/operator_ltlt__json_pointer.cpp b/external_imported/json/docs/examples/operator_ltlt__json_pointer.cpp new file mode 100644 index 000000000..f4fac886d --- /dev/null +++ b/external_imported/json/docs/examples/operator_ltlt__json_pointer.cpp @@ -0,0 +1,13 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + // create JSON poiner + json::json_pointer ptr("/foo/bar/baz"); + + // write string representation to stream + std::cout << ptr << std::endl; +} diff --git a/external_imported/json/docs/examples/operator_ltlt__json_pointer.output b/external_imported/json/docs/examples/operator_ltlt__json_pointer.output new file mode 100644 index 000000000..ed359432d --- /dev/null +++ b/external_imported/json/docs/examples/operator_ltlt__json_pointer.output @@ -0,0 +1 @@ +/foo/bar/baz diff --git a/external_imported/json/docs/examples/operator_spaceship__const_reference.c++20.cpp b/external_imported/json/docs/examples/operator_spaceship__const_reference.c++20.cpp new file mode 100644 index 000000000..9e7c9e9be --- /dev/null +++ b/external_imported/json/docs/examples/operator_spaceship__const_reference.c++20.cpp @@ -0,0 +1,40 @@ +#include +#include +#include + +using json = nlohmann::json; + +const char* to_string(const std::partial_ordering& po) +{ + if (std::is_lt(po)) + { + return "less"; + } + else if (std::is_gt(po)) + { + return "greater"; + } + else if (std::is_eq(po)) + { + return "equivalent"; + } + return "unordered"; +} + +int main() +{ + // create several JSON values + json array_1 = {1, 2, 3}; + json array_2 = {1, 2, 4}; + json object_1 = {{"A", "a"}, {"B", "b"}}; + json object_2 = {{"B", "b"}, {"A", "a"}}; + json number = 17; + json string = "foo"; + json discarded = json(json::value_t::discarded); + + // output values and comparisons + std::cout << array_1 << " <=> " << array_2 << " := " << to_string(array_1 <=> array_2) << '\n'; // *NOPAD* + std::cout << object_1 << " <=> " << object_2 << " := " << to_string(object_1 <=> object_2) << '\n'; // *NOPAD* + std::cout << string << " <=> " << number << " := " << to_string(string <=> number) << '\n'; // *NOPAD* + std::cout << string << " <=> " << discarded << " := " << to_string(string <=> discarded) << '\n'; // *NOPAD* +} diff --git a/external_imported/json/docs/examples/operator_spaceship__const_reference.c++20.output b/external_imported/json/docs/examples/operator_spaceship__const_reference.c++20.output new file mode 100644 index 000000000..2e8bf9f64 --- /dev/null +++ b/external_imported/json/docs/examples/operator_spaceship__const_reference.c++20.output @@ -0,0 +1,4 @@ +[1,2,3] <=> [1,2,4] := less +{"A":"a","B":"b"} <=> {"A":"a","B":"b"} := equivalent +"foo" <=> 17 := greater +"foo" <=> := unordered diff --git a/external_imported/json/docs/examples/operator_spaceship__scalartype.c++20.cpp b/external_imported/json/docs/examples/operator_spaceship__scalartype.c++20.cpp new file mode 100644 index 000000000..ebb5b4349 --- /dev/null +++ b/external_imported/json/docs/examples/operator_spaceship__scalartype.c++20.cpp @@ -0,0 +1,40 @@ +#include +#include +#include + +using json = nlohmann::json; + +const char* to_string(const std::partial_ordering& po) +{ + if (std::is_lt(po)) + { + return "less"; + } + else if (std::is_gt(po)) + { + return "greater"; + } + else if (std::is_eq(po)) + { + return "equivalent"; + } + return "unordered"; +} + +int main() +{ + using float_limits = std::numeric_limits; + constexpr auto nan = float_limits::quiet_NaN(); + + // create several JSON values + json boolean = false; + json number = 17; + json string = "17"; + + // output values and comparisons + std::cout << std::boolalpha << std::fixed; + std::cout << boolean << " <=> " << true << " := " << to_string(boolean <=> true) << '\n'; // *NOPAD* + std::cout << number << " <=> " << 17.0 << " := " << to_string(number <=> 17.0) << '\n'; // *NOPAD* + std::cout << number << " <=> " << nan << " := " << to_string(number <=> nan) << '\n'; // *NOPAD* + std::cout << string << " <=> " << 17 << " := " << to_string(string <=> 17) << '\n'; // *NOPAD* +} diff --git a/external_imported/json/docs/examples/operator_spaceship__scalartype.c++20.output b/external_imported/json/docs/examples/operator_spaceship__scalartype.c++20.output new file mode 100644 index 000000000..b2939a5f5 --- /dev/null +++ b/external_imported/json/docs/examples/operator_spaceship__scalartype.c++20.output @@ -0,0 +1,4 @@ +false <=> true := less +17 <=> 17.000000 := equivalent +17 <=> nan := unordered +"17" <=> 17 := greater diff --git a/external_imported/json/docs/examples/ordered_json.cpp b/external_imported/json/docs/examples/ordered_json.cpp new file mode 100644 index 000000000..effad530c --- /dev/null +++ b/external_imported/json/docs/examples/ordered_json.cpp @@ -0,0 +1,14 @@ +#include +#include + +using ordered_json = nlohmann::ordered_json; + +int main() +{ + ordered_json j; + j["one"] = 1; + j["two"] = 2; + j["three"] = 3; + + std::cout << j.dump(2) << '\n'; +} diff --git a/external_imported/json/docs/examples/ordered_json.output b/external_imported/json/docs/examples/ordered_json.output new file mode 100644 index 000000000..120cbb284 --- /dev/null +++ b/external_imported/json/docs/examples/ordered_json.output @@ -0,0 +1,5 @@ +{ + "one": 1, + "two": 2, + "three": 3 +} diff --git a/external_imported/json/docs/examples/ordered_map.cpp b/external_imported/json/docs/examples/ordered_map.cpp new file mode 100644 index 000000000..dcc60cb52 --- /dev/null +++ b/external_imported/json/docs/examples/ordered_map.cpp @@ -0,0 +1,43 @@ +#include +#include + +// simple output function +template +void output(const char* prefix, const Map& m) +{ + std::cout << prefix << " = { "; + for (auto& element : m) + { + std::cout << element.first << ":" << element.second << ' '; + } + std::cout << "}" << std::endl; +} + +int main() +{ + // create and fill two maps + nlohmann::ordered_map m_ordered; + m_ordered["one"] = "eins"; + m_ordered["two"] = "zwei"; + m_ordered["three"] = "drei"; + + std::map m_std; + m_std["one"] = "eins"; + m_std["two"] = "zwei"; + m_std["three"] = "drei"; + + // output: m_ordered is ordered by insertion order, m_std is ordered by key + output("m_ordered", m_ordered); + output("m_std", m_std); + + // erase and re-add "one" key + m_ordered.erase("one"); + m_ordered["one"] = "eins"; + + m_std.erase("one"); + m_std["one"] = "eins"; + + // output: m_ordered shows newly added key at the end; m_std is again ordered by key + output("m_ordered", m_ordered); + output("m_std", m_std); +} diff --git a/external_imported/json/docs/examples/ordered_map.output b/external_imported/json/docs/examples/ordered_map.output new file mode 100644 index 000000000..a4ffc454a --- /dev/null +++ b/external_imported/json/docs/examples/ordered_map.output @@ -0,0 +1,4 @@ +m_ordered = { one:eins two:zwei three:drei } +m_std = { one:eins three:drei two:zwei } +m_ordered = { two:zwei three:drei one:eins } +m_std = { one:eins three:drei two:zwei } diff --git a/external_imported/json/doc/examples/other_error.cpp b/external_imported/json/docs/examples/other_error.cpp similarity index 89% rename from external_imported/json/doc/examples/other_error.cpp rename to external_imported/json/docs/examples/other_error.cpp index 2e7ccfbb8..56aa8ae6b 100644 --- a/external_imported/json/doc/examples/other_error.cpp +++ b/external_imported/json/docs/examples/other_error.cpp @@ -2,6 +2,7 @@ #include using json = nlohmann::json; +using namespace nlohmann::literals; int main() { @@ -20,7 +21,7 @@ int main() }])"_json; value.patch(patch); } - catch (json::other_error& e) + catch (const json::other_error& e) { // output exception information std::cout << "message: " << e.what() << '\n' diff --git a/external_imported/json/doc/examples/other_error.output b/external_imported/json/docs/examples/other_error.output similarity index 100% rename from external_imported/json/doc/examples/other_error.output rename to external_imported/json/docs/examples/other_error.output diff --git a/external_imported/json/doc/examples/out_of_range.cpp b/external_imported/json/docs/examples/out_of_range.cpp similarity index 90% rename from external_imported/json/doc/examples/out_of_range.cpp rename to external_imported/json/docs/examples/out_of_range.cpp index e7116408a..03282082d 100644 --- a/external_imported/json/doc/examples/out_of_range.cpp +++ b/external_imported/json/docs/examples/out_of_range.cpp @@ -11,7 +11,7 @@ int main() json j = {1, 2, 3, 4}; j.at(4) = 10; } - catch (json::out_of_range& e) + catch (const json::out_of_range& e) { // output exception information std::cout << "message: " << e.what() << '\n' diff --git a/external_imported/json/doc/examples/out_of_range.output b/external_imported/json/docs/examples/out_of_range.output similarity index 100% rename from external_imported/json/doc/examples/out_of_range.output rename to external_imported/json/docs/examples/out_of_range.output diff --git a/external_imported/json/doc/examples/parse__allow_exceptions.cpp b/external_imported/json/docs/examples/parse__allow_exceptions.cpp similarity index 94% rename from external_imported/json/doc/examples/parse__allow_exceptions.cpp rename to external_imported/json/docs/examples/parse__allow_exceptions.cpp index 82449a526..f396c347e 100644 --- a/external_imported/json/doc/examples/parse__allow_exceptions.cpp +++ b/external_imported/json/docs/examples/parse__allow_exceptions.cpp @@ -17,7 +17,7 @@ int main() { json j = json::parse(text); } - catch (json::parse_error& e) + catch (const json::parse_error& e) { std::cout << e.what() << std::endl; } diff --git a/external_imported/json/doc/examples/parse__allow_exceptions.output b/external_imported/json/docs/examples/parse__allow_exceptions.output similarity index 100% rename from external_imported/json/doc/examples/parse__allow_exceptions.output rename to external_imported/json/docs/examples/parse__allow_exceptions.output diff --git a/external_imported/json/doc/examples/parse__array__parser_callback_t.cpp b/external_imported/json/docs/examples/parse__array__parser_callback_t.cpp similarity index 100% rename from external_imported/json/doc/examples/parse__array__parser_callback_t.cpp rename to external_imported/json/docs/examples/parse__array__parser_callback_t.cpp diff --git a/external_imported/json/doc/examples/parse__array__parser_callback_t.output b/external_imported/json/docs/examples/parse__array__parser_callback_t.output similarity index 100% rename from external_imported/json/doc/examples/parse__array__parser_callback_t.output rename to external_imported/json/docs/examples/parse__array__parser_callback_t.output diff --git a/external_imported/json/doc/examples/parse__contiguouscontainer__parser_callback_t.cpp b/external_imported/json/docs/examples/parse__contiguouscontainer__parser_callback_t.cpp similarity index 77% rename from external_imported/json/doc/examples/parse__contiguouscontainer__parser_callback_t.cpp rename to external_imported/json/docs/examples/parse__contiguouscontainer__parser_callback_t.cpp index 14cfa2514..6eb409bba 100644 --- a/external_imported/json/doc/examples/parse__contiguouscontainer__parser_callback_t.cpp +++ b/external_imported/json/docs/examples/parse__contiguouscontainer__parser_callback_t.cpp @@ -7,7 +7,7 @@ using json = nlohmann::json; int main() { // a JSON text given as std::vector - std::vector text = {'[', '1', ',', '2', ',', '3', ']', '\0'}; + std::vector text = {'[', '1', ',', '2', ',', '3', ']', '\0'}; // parse and serialize JSON json j_complete = json::parse(text); diff --git a/external_imported/json/doc/examples/parse__contiguouscontainer__parser_callback_t.output b/external_imported/json/docs/examples/parse__contiguouscontainer__parser_callback_t.output similarity index 100% rename from external_imported/json/doc/examples/parse__contiguouscontainer__parser_callback_t.output rename to external_imported/json/docs/examples/parse__contiguouscontainer__parser_callback_t.output diff --git a/external_imported/json/doc/examples/parse__istream__parser_callback_t.cpp b/external_imported/json/docs/examples/parse__istream__parser_callback_t.cpp similarity index 99% rename from external_imported/json/doc/examples/parse__istream__parser_callback_t.cpp rename to external_imported/json/docs/examples/parse__istream__parser_callback_t.cpp index afcaa39d0..2ef14dab2 100644 --- a/external_imported/json/doc/examples/parse__istream__parser_callback_t.cpp +++ b/external_imported/json/docs/examples/parse__istream__parser_callback_t.cpp @@ -33,7 +33,6 @@ int main() json j_complete = json::parse(ss); std::cout << std::setw(4) << j_complete << "\n\n"; - // define parser callback json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed) { diff --git a/external_imported/json/doc/examples/parse__istream__parser_callback_t.output b/external_imported/json/docs/examples/parse__istream__parser_callback_t.output similarity index 100% rename from external_imported/json/doc/examples/parse__istream__parser_callback_t.output rename to external_imported/json/docs/examples/parse__istream__parser_callback_t.output diff --git a/external_imported/json/docs/examples/parse__iterator_pair.cpp b/external_imported/json/docs/examples/parse__iterator_pair.cpp new file mode 100644 index 000000000..d0c30c1a5 --- /dev/null +++ b/external_imported/json/docs/examples/parse__iterator_pair.cpp @@ -0,0 +1,15 @@ +#include +#include +#include + +using json = nlohmann::json; + +int main() +{ + // a JSON text given an input with other values + std::vector input = {'[', '1', ',', '2', ',', '3', ']', 'o', 't', 'h', 'e', 'r'}; + + // parse and serialize JSON + json j_complete = json::parse(input.begin(), input.begin() + 7); + std::cout << std::setw(4) << j_complete << "\n\n"; +} diff --git a/external_imported/json/docs/examples/parse__iterator_pair.link b/external_imported/json/docs/examples/parse__iterator_pair.link new file mode 100644 index 000000000..f464e54c8 --- /dev/null +++ b/external_imported/json/docs/examples/parse__iterator_pair.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/external_imported/json/doc/examples/parse__iteratortype__parser_callback_t.output b/external_imported/json/docs/examples/parse__iterator_pair.output similarity index 100% rename from external_imported/json/doc/examples/parse__iteratortype__parser_callback_t.output rename to external_imported/json/docs/examples/parse__iterator_pair.output diff --git a/external_imported/json/docs/examples/parse__pointers.cpp b/external_imported/json/docs/examples/parse__pointers.cpp new file mode 100644 index 000000000..a5a16eea9 --- /dev/null +++ b/external_imported/json/docs/examples/parse__pointers.cpp @@ -0,0 +1,15 @@ +#include +#include +#include + +using json = nlohmann::json; + +int main() +{ + // a JSON text given as string that is not null-terminated + const char* ptr = "[1,2,3]another value"; + + // parse and serialize JSON + json j_complete = json::parse(ptr, ptr + 7); + std::cout << std::setw(4) << j_complete << "\n\n"; +} diff --git a/external_imported/json/docs/examples/parse__pointers.link b/external_imported/json/docs/examples/parse__pointers.link new file mode 100644 index 000000000..9a93ef1c5 --- /dev/null +++ b/external_imported/json/docs/examples/parse__pointers.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/external_imported/json/docs/examples/parse__pointers.output b/external_imported/json/docs/examples/parse__pointers.output new file mode 100644 index 000000000..74633e808 --- /dev/null +++ b/external_imported/json/docs/examples/parse__pointers.output @@ -0,0 +1,6 @@ +[ + 1, + 2, + 3 +] + diff --git a/external_imported/json/doc/examples/parse__string__parser_callback_t.cpp b/external_imported/json/docs/examples/parse__string__parser_callback_t.cpp similarity index 99% rename from external_imported/json/doc/examples/parse__string__parser_callback_t.cpp rename to external_imported/json/docs/examples/parse__string__parser_callback_t.cpp index 2ae4410a8..19c6c448a 100644 --- a/external_imported/json/doc/examples/parse__string__parser_callback_t.cpp +++ b/external_imported/json/docs/examples/parse__string__parser_callback_t.cpp @@ -28,7 +28,6 @@ int main() json j_complete = json::parse(text); std::cout << std::setw(4) << j_complete << "\n\n"; - // define parser callback json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed) { diff --git a/external_imported/json/doc/examples/parse__string__parser_callback_t.output b/external_imported/json/docs/examples/parse__string__parser_callback_t.output similarity index 100% rename from external_imported/json/doc/examples/parse__string__parser_callback_t.output rename to external_imported/json/docs/examples/parse__string__parser_callback_t.output diff --git a/external_imported/json/doc/examples/parse_error.cpp b/external_imported/json/docs/examples/parse_error.cpp similarity index 91% rename from external_imported/json/doc/examples/parse_error.cpp rename to external_imported/json/docs/examples/parse_error.cpp index 9b27b58fa..ce15ebe22 100644 --- a/external_imported/json/doc/examples/parse_error.cpp +++ b/external_imported/json/docs/examples/parse_error.cpp @@ -10,7 +10,7 @@ int main() // parsing input with a syntax error json::parse("[1,2,3,]"); } - catch (json::parse_error& e) + catch (const json::parse_error& e) { // output exception information std::cout << "message: " << e.what() << '\n' diff --git a/external_imported/json/doc/examples/parse_error.output b/external_imported/json/docs/examples/parse_error.output similarity index 100% rename from external_imported/json/doc/examples/parse_error.output rename to external_imported/json/docs/examples/parse_error.output diff --git a/external_imported/json/doc/examples/patch.cpp b/external_imported/json/docs/examples/patch.cpp similarity index 95% rename from external_imported/json/doc/examples/patch.cpp rename to external_imported/json/docs/examples/patch.cpp index b0896c794..b7ecb8eee 100644 --- a/external_imported/json/doc/examples/patch.cpp +++ b/external_imported/json/docs/examples/patch.cpp @@ -3,6 +3,7 @@ #include using json = nlohmann::json; +using namespace nlohmann::literals; int main() { diff --git a/external_imported/json/doc/examples/patch.output b/external_imported/json/docs/examples/patch.output similarity index 100% rename from external_imported/json/doc/examples/patch.output rename to external_imported/json/docs/examples/patch.output diff --git a/external_imported/json/docs/examples/patch_inplace.cpp b/external_imported/json/docs/examples/patch_inplace.cpp new file mode 100644 index 000000000..061708a2d --- /dev/null +++ b/external_imported/json/docs/examples/patch_inplace.cpp @@ -0,0 +1,35 @@ +#include +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +int main() +{ + // the original document + json doc = R"( + { + "baz": "qux", + "foo": "bar" + } + )"_json; + + // the patch + json patch = R"( + [ + { "op": "replace", "path": "/baz", "value": "boo" }, + { "op": "add", "path": "/hello", "value": ["world"] }, + { "op": "remove", "path": "/foo"} + ] + )"_json; + + // output original document + std::cout << "Before\n" << std::setw(4) << doc << std::endl; + + // apply the patch + doc.patch_inplace(patch); + + // output patched document + std::cout << "\nAfter\n" << std::setw(4) << doc << std::endl; +} diff --git a/external_imported/json/docs/examples/patch_inplace.output b/external_imported/json/docs/examples/patch_inplace.output new file mode 100644 index 000000000..9d31b8ba4 --- /dev/null +++ b/external_imported/json/docs/examples/patch_inplace.output @@ -0,0 +1,13 @@ +Before +{ + "baz": "qux", + "foo": "bar" +} + +After +{ + "baz": "boo", + "hello": [ + "world" + ] +} diff --git a/external_imported/json/doc/examples/push_back.cpp b/external_imported/json/docs/examples/push_back.cpp similarity index 100% rename from external_imported/json/doc/examples/push_back.cpp rename to external_imported/json/docs/examples/push_back.cpp diff --git a/external_imported/json/doc/examples/push_back.output b/external_imported/json/docs/examples/push_back.output similarity index 100% rename from external_imported/json/doc/examples/push_back.output rename to external_imported/json/docs/examples/push_back.output diff --git a/external_imported/json/doc/examples/push_back__initializer_list.cpp b/external_imported/json/docs/examples/push_back__initializer_list.cpp similarity index 100% rename from external_imported/json/doc/examples/push_back__initializer_list.cpp rename to external_imported/json/docs/examples/push_back__initializer_list.cpp diff --git a/external_imported/json/doc/examples/push_back__initializer_list.output b/external_imported/json/docs/examples/push_back__initializer_list.output similarity index 100% rename from external_imported/json/doc/examples/push_back__initializer_list.output rename to external_imported/json/docs/examples/push_back__initializer_list.output diff --git a/external_imported/json/doc/examples/push_back__object_t__value.cpp b/external_imported/json/docs/examples/push_back__object_t__value.cpp similarity index 100% rename from external_imported/json/doc/examples/push_back__object_t__value.cpp rename to external_imported/json/docs/examples/push_back__object_t__value.cpp diff --git a/external_imported/json/doc/examples/push_back__object_t__value.output b/external_imported/json/docs/examples/push_back__object_t__value.output similarity index 100% rename from external_imported/json/doc/examples/push_back__object_t__value.output rename to external_imported/json/docs/examples/push_back__object_t__value.output diff --git a/external_imported/json/doc/examples/rbegin.cpp b/external_imported/json/docs/examples/rbegin.cpp similarity index 100% rename from external_imported/json/doc/examples/rbegin.cpp rename to external_imported/json/docs/examples/rbegin.cpp diff --git a/external_imported/json/doc/examples/rbegin.output b/external_imported/json/docs/examples/rbegin.output similarity index 100% rename from external_imported/json/doc/examples/rbegin.output rename to external_imported/json/docs/examples/rbegin.output diff --git a/external_imported/json/doc/examples/rend.cpp b/external_imported/json/docs/examples/rend.cpp similarity index 100% rename from external_imported/json/doc/examples/rend.cpp rename to external_imported/json/docs/examples/rend.cpp diff --git a/external_imported/json/doc/examples/rend.output b/external_imported/json/docs/examples/rend.output similarity index 100% rename from external_imported/json/doc/examples/rend.output rename to external_imported/json/docs/examples/rend.output diff --git a/external_imported/json/docs/examples/sax_parse.cpp b/external_imported/json/docs/examples/sax_parse.cpp new file mode 100644 index 000000000..8602687e3 --- /dev/null +++ b/external_imported/json/docs/examples/sax_parse.cpp @@ -0,0 +1,131 @@ +#include +#include +#include +#include + +using json = nlohmann::json; + +// a simple event consumer that collects string representations of the passed +// values; note inheriting from json::json_sax_t is not required, but can +// help not to forget a required function +class sax_event_consumer : public json::json_sax_t +{ + public: + std::vector events; + + bool null() override + { + events.push_back("null()"); + return true; + } + + bool boolean(bool val) override + { + events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")"); + return true; + } + + bool number_integer(number_integer_t val) override + { + events.push_back("number_integer(val=" + std::to_string(val) + ")"); + return true; + } + + bool number_unsigned(number_unsigned_t val) override + { + events.push_back("number_unsigned(val=" + std::to_string(val) + ")"); + return true; + } + + bool number_float(number_float_t val, const string_t& s) override + { + events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")"); + return true; + } + + bool string(string_t& val) override + { + events.push_back("string(val=" + val + ")"); + return true; + } + + bool start_object(std::size_t elements) override + { + events.push_back("start_object(elements=" + std::to_string(elements) + ")"); + return true; + } + + bool end_object() override + { + events.push_back("end_object()"); + return true; + } + + bool start_array(std::size_t elements) override + { + events.push_back("start_array(elements=" + std::to_string(elements) + ")"); + return true; + } + + bool end_array() override + { + events.push_back("end_array()"); + return true; + } + + bool key(string_t& val) override + { + events.push_back("key(val=" + val + ")"); + return true; + } + + bool binary(json::binary_t& val) override + { + events.push_back("binary(val=[...])"); + return true; + } + + bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override + { + events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n ex=" + std::string(ex.what()) + ")"); + return false; + } +}; + +int main() +{ + // a JSON text + auto text = R"( + { + "Image": { + "Width": 800, + "Height": 600, + "Title": "View from 15th Floor", + "Thumbnail": { + "Url": "http://www.example.com/image/481989943", + "Height": 125, + "Width": 100 + }, + "Animated" : false, + "IDs": [116, 943, 234, -38793], + "DeletionDate": null, + "Distance": 12.723374634 + } + }] + )"; + + // create a SAX event consumer object + sax_event_consumer sec; + + // parse JSON + bool result = json::sax_parse(text, &sec); + + // output the recorded events + for (auto& event : sec.events) + { + std::cout << event << "\n"; + } + + // output the result of sax_parse + std::cout << "\nresult: " << std::boolalpha << result << std::endl; +} diff --git a/external_imported/json/docs/examples/sax_parse.output b/external_imported/json/docs/examples/sax_parse.output new file mode 100644 index 000000000..dd2fc2f05 --- /dev/null +++ b/external_imported/json/docs/examples/sax_parse.output @@ -0,0 +1,37 @@ +start_object(elements=18446744073709551615) +key(val=Image) +start_object(elements=18446744073709551615) +key(val=Width) +number_unsigned(val=800) +key(val=Height) +number_unsigned(val=600) +key(val=Title) +string(val=View from 15th Floor) +key(val=Thumbnail) +start_object(elements=18446744073709551615) +key(val=Url) +string(val=http://www.example.com/image/481989943) +key(val=Height) +number_unsigned(val=125) +key(val=Width) +number_unsigned(val=100) +end_object() +key(val=Animated) +boolean(val=false) +key(val=IDs) +start_array(elements=18446744073709551615) +number_unsigned(val=116) +number_unsigned(val=943) +number_unsigned(val=234) +number_integer(val=-38793) +end_array() +key(val=DeletionDate) +null() +key(val=Distance) +number_float(val=12.723375, s=12.723374634) +end_object() +end_object() +parse_error(position=460, last_token=12.723374634 } }], + ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input) + +result: false diff --git a/external_imported/json/docs/examples/sax_parse__binary.cpp b/external_imported/json/docs/examples/sax_parse__binary.cpp new file mode 100644 index 000000000..08bc85df6 --- /dev/null +++ b/external_imported/json/docs/examples/sax_parse__binary.cpp @@ -0,0 +1,114 @@ +#include +#include +#include +#include + +using json = nlohmann::json; + +// a simple event consumer that collects string representations of the passed +// values; note inheriting from json::json_sax_t is not required, but can +// help not to forget a required function +class sax_event_consumer : public json::json_sax_t +{ + public: + std::vector events; + + bool null() override + { + events.push_back("null()"); + return true; + } + + bool boolean(bool val) override + { + events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")"); + return true; + } + + bool number_integer(number_integer_t val) override + { + events.push_back("number_integer(val=" + std::to_string(val) + ")"); + return true; + } + + bool number_unsigned(number_unsigned_t val) override + { + events.push_back("number_unsigned(val=" + std::to_string(val) + ")"); + return true; + } + + bool number_float(number_float_t val, const string_t& s) override + { + events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")"); + return true; + } + + bool string(string_t& val) override + { + events.push_back("string(val=" + val + ")"); + return true; + } + + bool start_object(std::size_t elements) override + { + events.push_back("start_object(elements=" + std::to_string(elements) + ")"); + return true; + } + + bool end_object() override + { + events.push_back("end_object()"); + return true; + } + + bool start_array(std::size_t elements) override + { + events.push_back("start_array(elements=" + std::to_string(elements) + ")"); + return true; + } + + bool end_array() override + { + events.push_back("end_array()"); + return true; + } + + bool key(string_t& val) override + { + events.push_back("key(val=" + val + ")"); + return true; + } + + bool binary(json::binary_t& val) override + { + events.push_back("binary(val=[...])"); + return true; + } + + bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override + { + events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n ex=" + std::string(ex.what()) + ")"); + return false; + } +}; + +int main() +{ + // CBOR byte string + std::vector vec = {{0x44, 0xcA, 0xfe, 0xba, 0xbe}}; + + // create a SAX event consumer object + sax_event_consumer sec; + + // parse CBOR + bool result = json::sax_parse(vec, &sec, json::input_format_t::cbor); + + // output the recorded events + for (auto& event : sec.events) + { + std::cout << event << "\n"; + } + + // output the result of sax_parse + std::cout << "\nresult: " << std::boolalpha << result << std::endl; +} diff --git a/external_imported/json/docs/examples/sax_parse__binary.output b/external_imported/json/docs/examples/sax_parse__binary.output new file mode 100644 index 000000000..f88089610 --- /dev/null +++ b/external_imported/json/docs/examples/sax_parse__binary.output @@ -0,0 +1,3 @@ +binary(val=[...]) + +result: true diff --git a/external_imported/json/doc/examples/size.cpp b/external_imported/json/docs/examples/size.cpp similarity index 100% rename from external_imported/json/doc/examples/size.cpp rename to external_imported/json/docs/examples/size.cpp diff --git a/external_imported/json/doc/examples/size.output b/external_imported/json/docs/examples/size.output similarity index 100% rename from external_imported/json/doc/examples/size.output rename to external_imported/json/docs/examples/size.output diff --git a/external_imported/json/docs/examples/std_hash.cpp b/external_imported/json/docs/examples/std_hash.cpp new file mode 100644 index 000000000..9721910eb --- /dev/null +++ b/external_imported/json/docs/examples/std_hash.cpp @@ -0,0 +1,19 @@ +#include +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +int main() +{ + std::cout << "hash(null) = " << std::hash {}(json(nullptr)) << '\n' + << "hash(false) = " << std::hash {}(json(false)) << '\n' + << "hash(0) = " << std::hash {}(json(0)) << '\n' + << "hash(0U) = " << std::hash {}(json(0U)) << '\n' + << "hash(\"\") = " << std::hash {}(json("")) << '\n' + << "hash({}) = " << std::hash {}(json::object()) << '\n' + << "hash([]) = " << std::hash {}(json::array()) << '\n' + << "hash({\"hello\": \"world\"}) = " << std::hash {}("{\"hello\": \"world\"}"_json) + << std::endl; +} diff --git a/external_imported/json/docs/examples/std_hash.output b/external_imported/json/docs/examples/std_hash.output new file mode 100644 index 000000000..521d2b4b8 --- /dev/null +++ b/external_imported/json/docs/examples/std_hash.output @@ -0,0 +1,8 @@ +hash(null) = 2654435769 +hash(false) = 2654436030 +hash(0) = 2654436095 +hash(0U) = 2654436156 +hash("") = 6142509191626859748 +hash({}) = 2654435832 +hash([]) = 2654435899 +hash({"hello": "world"}) = 4469488738203676328 diff --git a/external_imported/json/docs/examples/std_swap.cpp b/external_imported/json/docs/examples/std_swap.cpp new file mode 100644 index 000000000..36ab3ce6b --- /dev/null +++ b/external_imported/json/docs/examples/std_swap.cpp @@ -0,0 +1,19 @@ +#include +#include +#include + +using json = nlohmann::json; + +int main() +{ + // create JSON values + json j1 = {{"one", 1}, {"two", 2}}; + json j2 = {1, 2, 4, 8, 16}; + + std::cout << "j1 = " << j1 << " | j2 = " << j2 << '\n'; + + // swap values + std::swap(j1, j2); + + std::cout << "j1 = " << j1 << " | j2 = " << j2 << std::endl; +} diff --git a/external_imported/json/docs/examples/std_swap.output b/external_imported/json/docs/examples/std_swap.output new file mode 100644 index 000000000..5ae6db780 --- /dev/null +++ b/external_imported/json/docs/examples/std_swap.output @@ -0,0 +1,2 @@ +j1 = {"one":1,"two":2} | j2 = [1,2,4,8,16] +j1 = [1,2,4,8,16] | j2 = {"one":1,"two":2} diff --git a/external_imported/json/docs/examples/string_t.cpp b/external_imported/json/docs/examples/string_t.cpp new file mode 100644 index 000000000..77a9ea480 --- /dev/null +++ b/external_imported/json/docs/examples/string_t.cpp @@ -0,0 +1,10 @@ +#include +#include +#include + +using json = nlohmann::json; + +int main() +{ + std::cout << std::boolalpha << std::is_same::value << std::endl; +} diff --git a/external_imported/json/docs/examples/string_t.output b/external_imported/json/docs/examples/string_t.output new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/external_imported/json/docs/examples/string_t.output @@ -0,0 +1 @@ +true diff --git a/external_imported/json/doc/examples/swap__array_t.cpp b/external_imported/json/docs/examples/swap__array_t.cpp similarity index 100% rename from external_imported/json/doc/examples/swap__array_t.cpp rename to external_imported/json/docs/examples/swap__array_t.cpp diff --git a/external_imported/json/doc/examples/swap__array_t.output b/external_imported/json/docs/examples/swap__array_t.output similarity index 100% rename from external_imported/json/doc/examples/swap__array_t.output rename to external_imported/json/docs/examples/swap__array_t.output diff --git a/external_imported/json/doc/examples/swap__binary_t.cpp b/external_imported/json/docs/examples/swap__binary_t.cpp similarity index 100% rename from external_imported/json/doc/examples/swap__binary_t.cpp rename to external_imported/json/docs/examples/swap__binary_t.cpp diff --git a/external_imported/json/doc/examples/swap__binary_t.output b/external_imported/json/docs/examples/swap__binary_t.output similarity index 100% rename from external_imported/json/doc/examples/swap__binary_t.output rename to external_imported/json/docs/examples/swap__binary_t.output diff --git a/external_imported/json/doc/examples/swap__object_t.cpp b/external_imported/json/docs/examples/swap__object_t.cpp similarity index 100% rename from external_imported/json/doc/examples/swap__object_t.cpp rename to external_imported/json/docs/examples/swap__object_t.cpp diff --git a/external_imported/json/doc/examples/swap__object_t.output b/external_imported/json/docs/examples/swap__object_t.output similarity index 100% rename from external_imported/json/doc/examples/swap__object_t.output rename to external_imported/json/docs/examples/swap__object_t.output diff --git a/external_imported/json/doc/examples/swap__reference.cpp b/external_imported/json/docs/examples/swap__reference.cpp similarity index 100% rename from external_imported/json/doc/examples/swap__reference.cpp rename to external_imported/json/docs/examples/swap__reference.cpp diff --git a/external_imported/json/doc/examples/swap__reference.output b/external_imported/json/docs/examples/swap__reference.output similarity index 100% rename from external_imported/json/doc/examples/swap__reference.output rename to external_imported/json/docs/examples/swap__reference.output diff --git a/external_imported/json/doc/examples/swap__string_t.cpp b/external_imported/json/docs/examples/swap__string_t.cpp similarity index 100% rename from external_imported/json/doc/examples/swap__string_t.cpp rename to external_imported/json/docs/examples/swap__string_t.cpp diff --git a/external_imported/json/doc/examples/swap__string_t.output b/external_imported/json/docs/examples/swap__string_t.output similarity index 100% rename from external_imported/json/doc/examples/swap__string_t.output rename to external_imported/json/docs/examples/swap__string_t.output diff --git a/external_imported/json/docs/examples/to_bjdata.cpp b/external_imported/json/docs/examples/to_bjdata.cpp new file mode 100644 index 000000000..9b7abac4e --- /dev/null +++ b/external_imported/json/docs/examples/to_bjdata.cpp @@ -0,0 +1,64 @@ +#include +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +// function to print BJData's diagnostic format +void print_byte(uint8_t byte) +{ + if (32 < byte and byte < 128) + { + std::cout << (char)byte; + } + else + { + std::cout << (int)byte; + } +} + +int main() +{ + // create a JSON value + json j = R"({"compact": true, "schema": false})"_json; + + // serialize it to BJData + std::vector v = json::to_bjdata(j); + + // print the vector content + for (auto& byte : v) + { + print_byte(byte); + } + std::cout << std::endl; + + // create an array of numbers + json array = {1, 2, 3, 4, 5, 6, 7, 8}; + + // serialize it to BJData using default representation + std::vector v_array = json::to_bjdata(array); + // serialize it to BJData using size optimization + std::vector v_array_size = json::to_bjdata(array, true); + // serialize it to BJData using type optimization + std::vector v_array_size_and_type = json::to_bjdata(array, true, true); + + // print the vector contents + for (auto& byte : v_array) + { + print_byte(byte); + } + std::cout << std::endl; + + for (auto& byte : v_array_size) + { + print_byte(byte); + } + std::cout << std::endl; + + for (auto& byte : v_array_size_and_type) + { + print_byte(byte); + } + std::cout << std::endl; +} diff --git a/external_imported/json/doc/examples/to_ubjson.output b/external_imported/json/docs/examples/to_bjdata.output similarity index 100% rename from external_imported/json/doc/examples/to_ubjson.output rename to external_imported/json/docs/examples/to_bjdata.output diff --git a/external_imported/json/doc/examples/to_bson.cpp b/external_imported/json/docs/examples/to_bson.cpp similarity index 82% rename from external_imported/json/doc/examples/to_bson.cpp rename to external_imported/json/docs/examples/to_bson.cpp index fd2884f13..3484b0b76 100644 --- a/external_imported/json/doc/examples/to_bson.cpp +++ b/external_imported/json/docs/examples/to_bson.cpp @@ -3,6 +3,7 @@ #include using json = nlohmann::json; +using namespace nlohmann::literals; int main() { @@ -10,7 +11,7 @@ int main() json j = R"({"compact": true, "schema": 0})"_json; // serialize it to BSON - std::vector v = json::to_bson(j); + std::vector v = json::to_bson(j); // print the vector content for (auto& byte : v) diff --git a/external_imported/json/doc/examples/to_bson.output b/external_imported/json/docs/examples/to_bson.output similarity index 100% rename from external_imported/json/doc/examples/to_bson.output rename to external_imported/json/docs/examples/to_bson.output diff --git a/external_imported/json/doc/examples/to_cbor.cpp b/external_imported/json/docs/examples/to_cbor.cpp similarity index 82% rename from external_imported/json/doc/examples/to_cbor.cpp rename to external_imported/json/docs/examples/to_cbor.cpp index 1237ca86f..3d5e04150 100644 --- a/external_imported/json/doc/examples/to_cbor.cpp +++ b/external_imported/json/docs/examples/to_cbor.cpp @@ -3,6 +3,7 @@ #include using json = nlohmann::json; +using namespace nlohmann::literals; int main() { @@ -10,7 +11,7 @@ int main() json j = R"({"compact": true, "schema": 0})"_json; // serialize it to CBOR - std::vector v = json::to_cbor(j); + std::vector v = json::to_cbor(j); // print the vector content for (auto& byte : v) diff --git a/external_imported/json/doc/examples/to_cbor.output b/external_imported/json/docs/examples/to_cbor.output similarity index 100% rename from external_imported/json/doc/examples/to_cbor.output rename to external_imported/json/docs/examples/to_cbor.output diff --git a/external_imported/json/docs/examples/to_json.cpp b/external_imported/json/docs/examples/to_json.cpp new file mode 100644 index 000000000..1f82a4de4 --- /dev/null +++ b/external_imported/json/docs/examples/to_json.cpp @@ -0,0 +1,32 @@ +#include +#include + +using json = nlohmann::json; + +namespace ns +{ +// a simple struct to model a person +struct person +{ + std::string name; + std::string address; + int age; +}; +} // namespace ns + +namespace ns +{ +void to_json(json& j, const person& p) +{ + j = json{ {"name", p.name}, {"address", p.address}, {"age", p.age} }; +} +} // namespace ns + +int main() +{ + ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; + + json j = p; + + std::cout << j << std::endl; +} diff --git a/external_imported/json/docs/examples/to_json.output b/external_imported/json/docs/examples/to_json.output new file mode 100644 index 000000000..e9c5bf381 --- /dev/null +++ b/external_imported/json/docs/examples/to_json.output @@ -0,0 +1 @@ +{"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} diff --git a/external_imported/json/doc/examples/to_msgpack.cpp b/external_imported/json/docs/examples/to_msgpack.cpp similarity index 82% rename from external_imported/json/doc/examples/to_msgpack.cpp rename to external_imported/json/docs/examples/to_msgpack.cpp index 99cc9eda2..b29ae8c7c 100644 --- a/external_imported/json/doc/examples/to_msgpack.cpp +++ b/external_imported/json/docs/examples/to_msgpack.cpp @@ -3,6 +3,7 @@ #include using json = nlohmann::json; +using namespace nlohmann::literals; int main() { @@ -10,7 +11,7 @@ int main() json j = R"({"compact": true, "schema": 0})"_json; // serialize it to MessagePack - std::vector v = json::to_msgpack(j); + std::vector v = json::to_msgpack(j); // print the vector content for (auto& byte : v) diff --git a/external_imported/json/doc/examples/to_msgpack.output b/external_imported/json/docs/examples/to_msgpack.output similarity index 100% rename from external_imported/json/doc/examples/to_msgpack.output rename to external_imported/json/docs/examples/to_msgpack.output diff --git a/external_imported/json/docs/examples/to_string.cpp b/external_imported/json/docs/examples/to_string.cpp new file mode 100644 index 000000000..ee44283f3 --- /dev/null +++ b/external_imported/json/docs/examples/to_string.cpp @@ -0,0 +1,20 @@ +#include +#include + +using json = nlohmann::json; +using std::to_string; + +int main() +{ + // create values + json j = {{"one", 1}, {"two", 2}}; + int i = 42; + + // use ADL to select best to_string function + auto j_str = to_string(j); // calling nlohmann::to_string + auto i_str = to_string(i); // calling std::to_string + + // serialize without indentation + std::cout << j_str << "\n\n" + << i_str << std::endl; +} diff --git a/external_imported/json/docs/examples/to_string.output b/external_imported/json/docs/examples/to_string.output new file mode 100644 index 000000000..b261f35e3 --- /dev/null +++ b/external_imported/json/docs/examples/to_string.output @@ -0,0 +1,3 @@ +{"one":1,"two":2} + +42 diff --git a/external_imported/json/doc/examples/to_ubjson.cpp b/external_imported/json/docs/examples/to_ubjson.cpp similarity index 78% rename from external_imported/json/doc/examples/to_ubjson.cpp rename to external_imported/json/docs/examples/to_ubjson.cpp index 06b2abba8..fd267a85a 100644 --- a/external_imported/json/doc/examples/to_ubjson.cpp +++ b/external_imported/json/docs/examples/to_ubjson.cpp @@ -3,6 +3,7 @@ #include using json = nlohmann::json; +using namespace nlohmann::literals; // function to print UBJSON's diagnostic format void print_byte(uint8_t byte) @@ -23,7 +24,7 @@ int main() json j = R"({"compact": true, "schema": false})"_json; // serialize it to UBJSON - std::vector v = json::to_ubjson(j); + std::vector v = json::to_ubjson(j); // print the vector content for (auto& byte : v) @@ -36,11 +37,11 @@ int main() json array = {1, 2, 3, 4, 5, 6, 7, 8}; // serialize it to UBJSON using default representation - std::vector v_array = json::to_ubjson(array); + std::vector v_array = json::to_ubjson(array); // serialize it to UBJSON using size optimization - std::vector v_array_size = json::to_ubjson(array, true); + std::vector v_array_size = json::to_ubjson(array, true); // serialize it to UBJSON using type optimization - std::vector v_array_size_and_type = json::to_ubjson(array, true, true); + std::vector v_array_size_and_type = json::to_ubjson(array, true, true); // print the vector contents for (auto& byte : v_array) diff --git a/external_imported/json/docs/examples/to_ubjson.output b/external_imported/json/docs/examples/to_ubjson.output new file mode 100644 index 000000000..087980cb9 --- /dev/null +++ b/external_imported/json/docs/examples/to_ubjson.output @@ -0,0 +1,4 @@ +{i7compactTi6schemaF} +[i1i2i3i4i5i6i7i8] +[#i8i1i2i3i4i5i6i7i8 +[$i#i812345678 diff --git a/external_imported/json/doc/examples/type.cpp b/external_imported/json/docs/examples/type.cpp similarity index 100% rename from external_imported/json/doc/examples/type.cpp rename to external_imported/json/docs/examples/type.cpp diff --git a/external_imported/json/doc/examples/type.output b/external_imported/json/docs/examples/type.output similarity index 100% rename from external_imported/json/doc/examples/type.output rename to external_imported/json/docs/examples/type.output diff --git a/external_imported/json/doc/examples/type_error.cpp b/external_imported/json/docs/examples/type_error.cpp similarity index 91% rename from external_imported/json/doc/examples/type_error.cpp rename to external_imported/json/docs/examples/type_error.cpp index d4f18b180..f520f4013 100644 --- a/external_imported/json/doc/examples/type_error.cpp +++ b/external_imported/json/docs/examples/type_error.cpp @@ -11,7 +11,7 @@ int main() json j = "string"; j.push_back("another string"); } - catch (json::type_error& e) + catch (const json::type_error& e) { // output exception information std::cout << "message: " << e.what() << '\n' diff --git a/external_imported/json/doc/examples/type_error.output b/external_imported/json/docs/examples/type_error.output similarity index 100% rename from external_imported/json/doc/examples/type_error.output rename to external_imported/json/docs/examples/type_error.output diff --git a/external_imported/json/doc/examples/type_name.cpp b/external_imported/json/docs/examples/type_name.cpp similarity index 100% rename from external_imported/json/doc/examples/type_name.cpp rename to external_imported/json/docs/examples/type_name.cpp diff --git a/external_imported/json/doc/examples/type_name.output b/external_imported/json/docs/examples/type_name.output similarity index 100% rename from external_imported/json/doc/examples/type_name.output rename to external_imported/json/docs/examples/type_name.output diff --git a/external_imported/json/doc/examples/unflatten.cpp b/external_imported/json/docs/examples/unflatten.cpp similarity index 100% rename from external_imported/json/doc/examples/unflatten.cpp rename to external_imported/json/docs/examples/unflatten.cpp diff --git a/external_imported/json/doc/examples/unflatten.output b/external_imported/json/docs/examples/unflatten.output similarity index 100% rename from external_imported/json/doc/examples/unflatten.output rename to external_imported/json/docs/examples/unflatten.output diff --git a/external_imported/json/docs/examples/update.cpp b/external_imported/json/docs/examples/update.cpp new file mode 100644 index 000000000..ff94b67fa --- /dev/null +++ b/external_imported/json/docs/examples/update.cpp @@ -0,0 +1,24 @@ +#include +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +int main() +{ + // create two JSON objects + json o1 = R"( {"color": "red", "price": 17.99, "names": {"de": "Flugzeug"}} )"_json; + json o2 = R"( {"color": "blue", "speed": 100, "names": {"en": "plane"}} )"_json; + json o3 = o1; + + // add all keys from o2 to o1 (updating "color", replacing "names") + o1.update(o2); + + // add all keys from o2 to o1 (updating "color", merging "names") + o3.update(o2, true); + + // output updated object o1 and o3 + std::cout << std::setw(2) << o1 << '\n'; + std::cout << std::setw(2) << o3 << '\n'; +} diff --git a/external_imported/json/docs/examples/update.output b/external_imported/json/docs/examples/update.output new file mode 100644 index 000000000..c35a74513 --- /dev/null +++ b/external_imported/json/docs/examples/update.output @@ -0,0 +1,17 @@ +{ + "color": "blue", + "names": { + "en": "plane" + }, + "price": 17.99, + "speed": 100 +} +{ + "color": "blue", + "names": { + "de": "Flugzeug", + "en": "plane" + }, + "price": 17.99, + "speed": 100 +} diff --git a/external_imported/json/docs/examples/update__range.cpp b/external_imported/json/docs/examples/update__range.cpp new file mode 100644 index 000000000..5b4385046 --- /dev/null +++ b/external_imported/json/docs/examples/update__range.cpp @@ -0,0 +1,24 @@ +#include +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +int main() +{ + // create two JSON objects + json o1 = R"( {"color": "red", "price": 17.99, "names": {"de": "Flugzeug"}} )"_json; + json o2 = R"( {"color": "blue", "speed": 100, "names": {"en": "plane"}} )"_json; + json o3 = o1; + + // add all keys from o2 to o1 (updating "color", replacing "names") + o1.update(o2.begin(), o2.end()); + + // add all keys from o2 to o1 (updating "color", merging "names") + o3.update(o2.begin(), o2.end(), true); + + // output updated object o1 and o3 + std::cout << std::setw(2) << o1 << '\n'; + std::cout << std::setw(2) << o3 << '\n'; +} diff --git a/external_imported/json/docs/examples/update__range.output b/external_imported/json/docs/examples/update__range.output new file mode 100644 index 000000000..c35a74513 --- /dev/null +++ b/external_imported/json/docs/examples/update__range.output @@ -0,0 +1,17 @@ +{ + "color": "blue", + "names": { + "en": "plane" + }, + "price": 17.99, + "speed": 100 +} +{ + "color": "blue", + "names": { + "de": "Flugzeug", + "en": "plane" + }, + "price": 17.99, + "speed": 100 +} diff --git a/external_imported/json/docs/examples/value__json_ptr.cpp b/external_imported/json/docs/examples/value__json_ptr.cpp new file mode 100644 index 000000000..d866ef076 --- /dev/null +++ b/external_imported/json/docs/examples/value__json_ptr.cpp @@ -0,0 +1,31 @@ +#include +#include + +using json = nlohmann::json; +using namespace nlohmann::literals; + +int main() +{ + // create a JSON object with different entry types + json j = + { + {"integer", 1}, + {"floating", 42.23}, + {"string", "hello world"}, + {"boolean", true}, + {"object", {{"key1", 1}, {"key2", 2}}}, + {"array", {1, 2, 3}} + }; + + // access existing values + int v_integer = j.value("/integer"_json_pointer, 0); + double v_floating = j.value("/floating"_json_pointer, 47.11); + + // access nonexisting values and rely on default value + std::string v_string = j.value("/nonexisting"_json_pointer, "oops"); + bool v_boolean = j.value("/nonexisting"_json_pointer, false); + + // output values + std::cout << std::boolalpha << v_integer << " " << v_floating + << " " << v_string << " " << v_boolean << "\n"; +} diff --git a/external_imported/json/doc/examples/basic_json__value.output b/external_imported/json/docs/examples/value__json_ptr.output similarity index 100% rename from external_imported/json/doc/examples/basic_json__value.output rename to external_imported/json/docs/examples/value__json_ptr.output diff --git a/external_imported/json/docs/examples/value__keytype.c++17.cpp b/external_imported/json/docs/examples/value__keytype.c++17.cpp new file mode 100644 index 000000000..1f6ff5c30 --- /dev/null +++ b/external_imported/json/docs/examples/value__keytype.c++17.cpp @@ -0,0 +1,32 @@ +#include +#include +#include + +using namespace std::string_view_literals; +using json = nlohmann::json; + +int main() +{ + // create a JSON object with different entry types + json j = + { + {"integer", 1}, + {"floating", 42.23}, + {"string", "hello world"}, + {"boolean", true}, + {"object", {{"key1", 1}, {"key2", 2}}}, + {"array", {1, 2, 3}} + }; + + // access existing values + int v_integer = j.value("integer"sv, 0); + double v_floating = j.value("floating"sv, 47.11); + + // access nonexisting values and rely on default value + std::string v_string = j.value("nonexisting"sv, "oops"); + bool v_boolean = j.value("nonexisting"sv, false); + + // output values + std::cout << std::boolalpha << v_integer << " " << v_floating + << " " << v_string << " " << v_boolean << "\n"; +} diff --git a/external_imported/json/doc/examples/basic_json__value_ptr.output b/external_imported/json/docs/examples/value__keytype.c++17.output similarity index 100% rename from external_imported/json/doc/examples/basic_json__value_ptr.output rename to external_imported/json/docs/examples/value__keytype.c++17.output diff --git a/external_imported/json/doc/examples/basic_json__value.cpp b/external_imported/json/docs/examples/value__object_t_key_type.cpp similarity index 100% rename from external_imported/json/doc/examples/basic_json__value.cpp rename to external_imported/json/docs/examples/value__object_t_key_type.cpp diff --git a/external_imported/json/docs/examples/value__object_t_key_type.output b/external_imported/json/docs/examples/value__object_t_key_type.output new file mode 100644 index 000000000..dfc40e58c --- /dev/null +++ b/external_imported/json/docs/examples/value__object_t_key_type.output @@ -0,0 +1 @@ +1 42.23 oops false diff --git a/external_imported/json/docs/json.gif b/external_imported/json/docs/json.gif new file mode 100644 index 000000000..8b86b0375 Binary files /dev/null and b/external_imported/json/docs/json.gif differ diff --git a/external_imported/json/docs/mkdocs/Makefile b/external_imported/json/docs/mkdocs/Makefile new file mode 100644 index 000000000..d3356b820 --- /dev/null +++ b/external_imported/json/docs/mkdocs/Makefile @@ -0,0 +1,37 @@ +# serve the site locally +serve: prepare_files style_check + venv/bin/mkdocs serve + +serve_dirty: prepare_files style_check + venv/bin/mkdocs serve --dirtyreload + +build: prepare_files style_check + venv/bin/mkdocs build + +# create files that are not versioned inside the mkdocs folder (images, examples) +prepare_files: clean + mkdir docs/examples + cp -r ../json.gif docs/images + cp -r ../examples/*.cpp ../examples/*.output docs/examples + +style_check: + @cd docs ; python3 ../scripts/check_structure.py + +# clean subfolders +clean: + rm -fr docs/images/json.gif docs/examples + +# publish site to GitHub pages (not working in GitHub Actions; need special action) +publish: prepare_files + venv/bin/mkdocs gh-deploy --clean --force + +# install a Python virtual environment +install_venv: requirements.txt + python3 -mvenv venv + venv/bin/pip install --upgrade pip + venv/bin/pip install wheel + venv/bin/pip install -r requirements.txt + +# uninstall the virtual environment +uninstall_venv: clean + rm -fr venv diff --git a/external_imported/json/docs/mkdocs/docs/api/adl_serializer/from_json.md b/external_imported/json/docs/mkdocs/docs/api/adl_serializer/from_json.md new file mode 100644 index 000000000..176290e24 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/adl_serializer/from_json.md @@ -0,0 +1,73 @@ +# nlohmann::adl_serializer::from_json + +```cpp +// (1) +template +static auto from_json(BasicJsonType && j, TargetType& val) noexcept( + noexcept(::nlohmann::from_json(std::forward(j), val))) +-> decltype(::nlohmann::from_json(std::forward(j), val), void()) + +// (2) +template +static auto from_json(BasicJsonType && j) noexcept( +noexcept(::nlohmann::from_json(std::forward(j), detail::identity_tag {}))) +-> decltype(::nlohmann::from_json(std::forward(j), detail::identity_tag {})) +``` + +This function is usually called by the [`get()`](../basic_json/get.md) function of the [basic_json](../basic_json/index.md) +class (either explicitly or via the conversion operators). + +1. This function is chosen for default-constructible value types. +2. This function is chosen for value types which are not default-constructible. + +## Parameters + +`j` (in) +: JSON value to read from + +`val` (out) +: value to write to + +## Return value + +Copy of the JSON value, converted to `ValueType` + +## Examples + +??? example "Example: (1) Default-constructible type" + + The example below shows how a `from_json` function can be implemented for a user-defined type. This function is + called by the `adl_serializer` when `template get()` is called. + + ```cpp + --8<-- "examples/from_json__default_constructible.cpp" + ``` + + Output: + + ```json + --8<-- "examples/from_json__default_constructible.output" + ``` + +??? example "Example: (2) Non-default-constructible type" + + The example below shows how a `from_json` is implemented as part of a specialization of the `adl_serializer` to + realize the conversion of a non-default-constructible type. + + ```cpp + --8<-- "examples/from_json__non_default_constructible.cpp" + ``` + + Output: + + ```json + --8<-- "examples/from_json__non_default_constructible.output" + ``` + +## See also + +- [to_json](to_json.md) + +## Version history + +- Added in version 2.1.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/adl_serializer/index.md b/external_imported/json/docs/mkdocs/docs/api/adl_serializer/index.md new file mode 100644 index 000000000..95f35cddf --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/adl_serializer/index.md @@ -0,0 +1,35 @@ +# nlohmann::adl_serializer + +```cpp +template +struct adl_serializer; +``` + +Serializer that uses ADL ([Argument-Dependent Lookup](https://en.cppreference.com/w/cpp/language/adl)) to choose +`to_json`/`from_json` functions from the types' namespaces. + +It is implemented similar to + +```cpp +template +struct adl_serializer { + template + static void to_json(BasicJsonType& j, const T& value) { + // calls the "to_json" method in T's namespace + } + + template + static void from_json(const BasicJsonType& j, T& value) { + // same thing, but with the "from_json" method + } +}; +``` + +## Member functions + +- [**from_json**](from_json.md) - convert a JSON value to any value type +- [**to_json**](to_json.md) - convert any value type to a JSON value + +## Version history + +- Added in version 2.1.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/adl_serializer/to_json.md b/external_imported/json/docs/mkdocs/docs/api/adl_serializer/to_json.md new file mode 100644 index 000000000..da9765186 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/adl_serializer/to_json.md @@ -0,0 +1,43 @@ +# nlohmann::adl_serializer::to_json + +```cpp +template +static auto to_json(BasicJsonType& j, TargetType && val) noexcept( + noexcept(::nlohmann::to_json(j, std::forward(val)))) +-> decltype(::nlohmann::to_json(j, std::forward(val)), void()) +``` + +This function is usually called by the constructors of the [basic_json](../basic_json/index.md) class. + +## Parameters + +`j` (out) +: JSON value to write to + +`val` (in) +: value to read from + +## Examples + +??? example + + The example below shows how a `to_json` function can be implemented for a user-defined type. This function is called + by the `adl_serializer` when the constructor `basic_json(ns::person)` is called. + + ```cpp + --8<-- "examples/to_json.cpp" + ``` + + Output: + + ```json + --8<-- "examples/to_json.output" + ``` + +## See also + +- [from_json](from_json.md) + +## Version history + +- Added in version 2.1.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/accept.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/accept.md new file mode 100644 index 000000000..1c806e82f --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/accept.md @@ -0,0 +1,113 @@ +# nlohmann::basic_json::accept + +```cpp +// (1) +template +static bool accept(InputType&& i, + const bool ignore_comments = false); + +// (2) +template +static bool accept(IteratorType first, IteratorType last, + const bool ignore_comments = false); +``` + +Checks whether the input is valid JSON. + +1. Reads from a compatible input. +2. Reads from a pair of character iterators + + The value_type of the iterator must be an integral type with size of 1, 2 or 4 bytes, which will be interpreted + respectively as UTF-8, UTF-16 and UTF-32. + +Unlike the [`parse`](parse.md) function, this function neither throws an exception in case of invalid JSON input +(i.e., a parse error) nor creates diagnostic information. + +## Template parameters + +`InputType` +: A compatible input, for instance: + + - an `std::istream` object + - a `FILE` pointer (must not be null) + - a C-style array of characters + - a pointer to a null-terminated string of single byte characters + - a `std::string` + - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. + +`IteratorType` +: a compatible iterator type, for instance. + + - a pair of `std::string::iterator` or `std::vector::iterator` + - a pair of pointers such as `ptr` and `ptr + len` + +## Parameters + +`i` (in) +: Input to parse from. + +`ignore_comments` (in) +: whether comments should be ignored and treated like whitespace (`#!cpp true`) or yield a parse error + (`#!cpp false`); (optional, `#!cpp false` by default) + +`first` (in) +: iterator to start of character range + +`last` (in) +: iterator to end of character range + +## Return value + +Whether the input is valid JSON. + +## Exception safety + +Strong guarantee: if an exception is thrown, there are no changes in the JSON value. + +## Complexity + +Linear in the length of the input. The parser is a predictive LL(1) parser. + +## Notes + +(1) A UTF-8 byte order mark is silently ignored. + +!!! danger "Runtime assertion" + + The precondition that a passed `#!cpp FILE` pointer must not be null is enforced with a + [runtime assertion](../../features/assertions.md). + +## Examples + +??? example + + The example below demonstrates the `accept()` function reading from a string. + + ```cpp + --8<-- "examples/accept__string.cpp" + ``` + + Output: + + ```json + --8<-- "examples/accept__string.output" + ``` + +## See also + +- [parse](parse.md) - deserialize from a compatible input +- [operator>>](../operator_gtgt.md) - deserialize from stream + +## Version history + +- Added in version 3.0.0. +- Ignoring comments via `ignore_comments` added in version 3.9.0. + +!!! warning "Deprecation" + + Overload (2) replaces calls to `accept` with a pair of iterators as their first parameter which has been + deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like + `#!cpp accept({ptr, ptr+len}, ...);` with `#!cpp accept(ptr, ptr+len, ...);`. + + You should be warned by your compiler with a `-Wdeprecated-declarations` warning if you are using a deprecated + function. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/array.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/array.md similarity index 85% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/array.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/array.md index 89113026d..22b2ee1db 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/array.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/array.md @@ -1,4 +1,4 @@ -# basic_json::array +# nlohmann::basic_json::array ```cpp static basic_json array(initializer_list_t init = {}); @@ -50,6 +50,11 @@ This function is only needed to express two edge cases that cannot be realized w --8<-- "examples/array.output" ``` +## See also + +- [`basic_json(initializer_list_t)`](basic_json.md) - create a JSON value from an initializer list +- [`object`](object.md) - create a JSON object value from an initializer list + ## Version history - Added in version 1.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/array_t.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/array_t.md new file mode 100644 index 000000000..dd2b901d5 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/array_t.md @@ -0,0 +1,68 @@ +# nlohmann::basic_json::array_t + +```cpp +using array_t = ArrayType>; +``` + +The type used to store JSON arrays. + +[RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON arrays as follows: +> An array is an ordered sequence of zero or more values. + +To store objects in C++, a type is defined by the template parameters explained below. + +## Template parameters + +`ArrayType` +: container type to store arrays (e.g., `std::vector` or `std::list`) + +`AllocatorType` +: the allocator to use for objects (e.g., `std::allocator`) + +## Notes + +#### Default type + +With the default values for `ArrayType` (`std::vector`) and `AllocatorType` (`std::allocator`), the default value for +`array_t` is: + +```cpp +std::vector< + basic_json, // value_type + std::allocator // allocator_type +> +``` + +#### Limits + +[RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: +> An implementation may set limits on the maximum depth of nesting. + +In this class, the array's limit of nesting is not explicitly constrained. However, a maximum depth of nesting may be +introduced by the compiler or runtime environment. A theoretical limit can be queried by calling the +[`max_size`](max_size.md) function of a JSON array. + +#### Storage + +Arrays are stored as pointers in a `basic_json` type. That is, for any access to array values, a pointer of type +`#!cpp array_t*` must be dereferenced. + +## Examples + +??? example + + The following code shows that `array_t` is by default, a typedef to `#!cpp std::vector`. + + ```cpp + --8<-- "examples/array_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/array_t.output" + ``` + +## Version history + +- Added in version 1.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/at.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/at.md new file mode 100644 index 000000000..5e9504508 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/at.md @@ -0,0 +1,226 @@ +# nlohmann::basic_json::at + +```cpp +// (1) +reference at(size_type idx); +const_reference at(size_type idx) const; + +// (2) +reference at(const typename object_t::key_type& key); +const_reference at(const typename object_t::key_type& key) const; + +// (3) +template +reference at(KeyType&& key); +template +const_reference at(KeyType&& key) const; + +// (4) +reference at(const json_pointer& ptr); +const_reference at(const json_pointer& ptr) const; +``` + +1. Returns a reference to the array element at specified location `idx`, with bounds checking. +2. Returns a reference to the object element with specified key `key`, with bounds checking. +3. See 2. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and + `#!cpp typename object_comparator_t::is_transparent` denotes a type. +4. Returns a reference to the element at specified JSON pointer `ptr`, with bounds checking. + +## Template parameters + +`KeyType` +: A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with + [`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md). + This can also be a string view (C++17). + +## Parameters + +`idx` (in) +: index of the element to access + +`key` (in) +: object key of the elements to access + +`ptr` (in) +: JSON pointer to the desired element + +## Return value + +1. reference to the element at index `idx` +2. reference to the element at key `key` +3. reference to the element at key `key` +4. reference to the element pointed to by `ptr` + +## Exception safety + +Strong exception safety: if an exception occurs, the original value stays intact. + +## Exceptions + +1. The function can throw the following exceptions: + - Throws [`type_error.304`](../../home/exceptions.md#jsonexceptiontype_error304) if the JSON value is not an array; + in this case, calling `at` with an index makes no sense. See example below. + - Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) if the index `idx` is out of + range of the array; that is, `idx >= size()`. See example below. +2. The function can throw the following exceptions: + - Throws [`type_error.304`](../../home/exceptions.md#jsonexceptiontype_error304) if the JSON value is not an object; + in this case, calling `at` with a key makes no sense. See example below. + - Throws [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if the key `key` is not + stored in the object; that is, `find(key) == end()`. See example below. +3. See 2. +4. The function can throw the following exceptions: + - Throws [`parse_error.106`](../../home/exceptions.md#jsonexceptionparse_error106) if an array index in the passed + JSON pointer `ptr` begins with '0'. See example below. + - Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109) if an array index in the passed + JSON pointer `ptr` is not a number. See example below. + - Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) if an array index in the passed + JSON pointer `ptr` is out of range. See example below. + - Throws [`out_of_range.402`](../../home/exceptions.md#jsonexceptionout_of_range402) if the array index '-' is used + in the passed JSON pointer `ptr`. As `at` provides checked access (and no elements are implicitly inserted), the + index '-' is always invalid. See example below. + - Throws [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if the JSON pointer describes a + key of an object which cannot be found. See example below. + - Throws [`out_of_range.404`](../../home/exceptions.md#jsonexceptionout_of_range404) if the JSON pointer `ptr` can + not be resolved. See example below. + +## Complexity + +1. Constant. +2. Logarithmic in the size of the container. +3. Logarithmic in the size of the container. +4. Logarithmic in the size of the container. + +## Examples + +??? example "Example: (1) access specified array element with bounds checking" + + The example below shows how array elements can be read and written using `at()`. It also demonstrates the different + exceptions that can be thrown. + + ```cpp + --8<-- "examples/at__size_type.cpp" + ``` + + Output: + + ```json + --8<-- "examples/at__size_type.output" + ``` + +??? example "Example: (1) access specified array element with bounds checking" + + The example below shows how array elements can be read using `at()`. It also demonstrates the different exceptions + that can be thrown. + + ```cpp + --8<-- "examples/at__size_type_const.cpp" + ``` + + Output: + + ```json + --8<-- "examples/at__size_type_const.output" + ``` + +??? example "Example: (2) access specified object element with bounds checking" + + The example below shows how object elements can be read and written using `at()`. It also demonstrates the different + exceptions that can be thrown. + + ```cpp + --8<-- "examples/at__object_t_key_type.cpp" + ``` + + Output: + + ```json + --8<-- "examples/at__object_t_key_type.output" + ``` + +??? example "Example: (2) access specified object element with bounds checking" + + The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions + that can be thrown. + + ```cpp + --8<-- "examples/at__object_t_key_type_const.cpp" + ``` + + Output: + + ```json + --8<-- "examples/at__object_t_key_type_const.output" + ``` + +??? example "Example: (3) access specified object element using string_view with bounds checking" + + The example below shows how object elements can be read and written using `at()`. It also demonstrates the different + exceptions that can be thrown. + + ```cpp + --8<-- "examples/at__keytype.c++17.cpp" + ``` + + Output: + + ```json + --8<-- "examples/at__keytype.c++17.output" + ``` + +??? example "Example: (3) access specified object element using string_view with bounds checking" + + The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions + that can be thrown. + + ```cpp + --8<-- "examples/at__keytype_const.c++17.cpp" + ``` + + Output: + + ```json + --8<-- "examples/at__keytype_const.c++17.output" + ``` + +??? example "Example: (4) access specified element via JSON Pointer" + + The example below shows how object elements can be read and written using `at()`. It also demonstrates the different + exceptions that can be thrown. + + ```cpp + --8<-- "examples/at__json_pointer.cpp" + ``` + + Output: + + ```json + --8<-- "examples/at__json_pointer.output" + ``` + +??? example "Example: (4) access specified element via JSON Pointer" + + The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions + that can be thrown. + + ```cpp + --8<-- "examples/at__json_pointer_const.cpp" + ``` + + Output: + + ```json + --8<-- "examples/at__json_pointer_const.output" + ``` + +## See also + +- documentation on [checked access](../../features/element_access/checked_access.md) +- see [`operator[]`](operator%5B%5D.md) for unchecked access by reference +- see [`value`](value.md) for access with default value + +## Version history + +1. Added in version 1.0.0. +2. Added in version 1.0.0. +3. Added in version 3.11.0. +4. Added in version 2.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/back.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/back.md new file mode 100644 index 000000000..1a715284d --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/back.md @@ -0,0 +1,65 @@ +# nlohmann::basic_json::back + +```cpp +reference back(); + +const_reference back() const; +``` + +Returns a reference to the last element in the container. For a JSON container `c`, the expression `c.back()` is +equivalent to + +```cpp +auto tmp = c.end(); +--tmp; +return *tmp; +``` + +## Return value + +In case of a structured type (array or object), a reference to the last element is returned. In case of number, string, +boolean, or binary values, a reference to the value is returned. + +## Exception safety + +Strong guarantee: if an exception is thrown, there are no changes in the JSON value. + +## Exceptions + +If the JSON value is `#!json null`, exception +[`invalid_iterator.214`](../../home/exceptions.md#jsonexceptioninvalid_iterator214) is thrown. + +## Complexity + +Constant. + +## Notes + +!!! info "Precondition" + + The array or object must not be empty. Calling `back` on an empty array or object yields undefined behavior. + +## Examples + +??? example + + The following code shows an example for `back()`. + + ```cpp + --8<-- "examples/back.cpp" + ``` + + Output: + + ```json + --8<-- "examples/back.output" + ``` + +## See also + +- [front](front.md) to access the first element + +## Version history + +- Added in version 1.0.0. +- Adjusted code to return reference to binary values in version 3.8.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/basic_json.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/basic_json.md similarity index 88% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/basic_json.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/basic_json.md index 9ff6fbb8d..e2e73612c 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/basic_json.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/basic_json.md @@ -1,53 +1,55 @@ -# basic_json::basic_json +# nlohmann::basic_json::basic_json ```cpp -// 1 +// (1) basic_json(const value_t v); -// 2 +// (2) basic_json(std::nullptr_t = nullptr) noexcept; -// 3 +// (3) template basic_json(CompatibleType&& val) noexcept(noexcept( JSONSerializer::to_json(std::declval(), std::forward(val)))); -// 4 +// (4) template basic_json(const BasicJsonType& val); -// 5 +// (5) basic_json(initializer_list_t init, bool type_deduction = true, value_t manual_type = value_t::array); -// 6 +// (6) basic_json(size_type cnt, const basic_json& val); -// 7 +// (7) basic_json(iterator first, iterator last); basic_json(const_iterator first, const_iterator last); -// 8 +// (8) basic_json(const basic_json& other); -// 9 +// (9) basic_json(basic_json&& other) noexcept; ``` 1. Create an empty JSON value with a given type. The value will be default initialized with an empty value which depends on the type: - Value type | initial value - ----------- | ------------- - null | `#!json null` - boolean | `#!json false` - string | `#!json ""` - number | `#!json 0` - object | `#!json {}` - array | `#!json []` - binary | empty array + | Value type | initial value | + |------------|----------------| + | null | `#!json null` | + | boolean | `#!json false` | + | string | `#!json ""` | + | number | `#!json 0` | + | object | `#!json {}` | + | array | `#!json []` | + | binary | empty array | + + The postcondition of this constructor can be restored by calling [`clear()`](clear.md). 2. Create a `#!json null` JSON value. It either takes a null pointer as parameter (explicitly creating `#!json null`) or no parameter (implicitly creating `#!json null`). The passed null pointer itself is not read -- it is only used to @@ -104,6 +106,9 @@ basic_json(basic_json&& other) noexcept; - the empty array (`#!json []`): use `array(initializer_list_t)` with an empty initializer list in this case - arrays whose elements satisfy rule 2: use `array(initializer_list_t)` with the same initializer list in this case + + Function [`array()`](array.md) and [`object()`](object.md) force array and object creation from initializer lists, + respectively. 6. Constructs a JSON array value by creating `cnt` copies of a passed value. In case `cnt` is `0`, an empty array is created. @@ -142,6 +147,9 @@ basic_json(basic_json&& other) noexcept; - `BasicJsonType` is a `basic_json` type. - `BasicJsonType` has different template arguments than `basic_json_t`. +`U`: +: `uncvref_t` + ## Parameters `v` (in) @@ -175,46 +183,46 @@ basic_json(basic_json&& other) noexcept; `other` (in) : the JSON value to copy/move +## Exception safety + +1. Strong guarantee: if an exception is thrown, there are no changes to any JSON value. +2. No-throw guarantee: this constructor never throws exceptions. +3. Depends on the called constructor. For types directly supported by the library (i.e., all types for which no + `to_json()` function was provided), strong guarantee holds: if an exception is thrown, there are no changes to any + JSON value. +4. Depends on the called constructor. For types directly supported by the library (i.e., all types for which no + `to_json()` function was provided), strong guarantee holds: if an exception is thrown, there are no changes to any + JSON value. +5. Strong guarantee: if an exception is thrown, there are no changes to any JSON value. +6. Strong guarantee: if an exception is thrown, there are no changes to any JSON value. +7. Strong guarantee: if an exception is thrown, there are no changes to any JSON value. +8. Strong guarantee: if an exception is thrown, there are no changes to any JSON value. +9. No-throw guarantee: this constructor never throws exceptions. + ## Exceptions -1. / +1. (none) 2. The function does not throw exceptions. -3. / -4. / +3. (none) +4. (none) 5. The function can throw the following exceptions: - Throws [`type_error.301`](../../home/exceptions.md#jsonexceptiontype_error301) if `type_deduction` is `#!cpp false`, `manual_type` is `value_t::object`, but `init` contains an element which is not a pair whose first element is a string. In this case, the constructor could not create an object. If `type_deduction` would have been `#!cpp true`, an array would have been created. See `object(initializer_list_t)` for an example. -6. / +6. (none) 7. The function can throw the following exceptions: - Throws [`invalid_iterator.201`](../../home/exceptions.md#jsonexceptioninvalid_iterator201) if iterators `first` and `last` are not compatible (i.e., do not belong to the same JSON value). In this case, the range `[first, last)` is undefined. - Throws [`invalid_iterator.204`](../../home/exceptions.md#jsonexceptioninvalid_iterator204) if iterators `first` and `last` belong to a primitive type (number, boolean, or string), but `first` does not point to the first - element any more. In this case, the range `[first, last)` is undefined. See example code below. + element anymore. In this case, the range `[first, last)` is undefined. See example code below. - Throws [`invalid_iterator.206`](../../home/exceptions.md#jsonexceptioninvalid_iterator206) if iterators `first` and `last` belong to a `#!json null` value. In this case, the range `[first, last)` is undefined. -8. / +8. (none) 9. The function does not throw exceptions. -## Exception safety - -1. Strong guarantee: if an exception is thrown, there are no changes to any JSON value. -2. No-throw guarantee: this constructor never throws exceptions. -3. Depends on the called constructor. For types directly supported by the library (i.e., all types for which no - `to_json()` function was provided), strong guarantee holds: if an exception is thrown, there are no changes to any - JSON value. -4. Depends on the called constructor. For types directly supported by the library (i.e., all types for which no - `to_json()` function was provided), strong guarantee holds: if an exception is thrown, there are no changes to any - JSON value. -5. Strong guarantee: if an exception is thrown, there are no changes to any JSON value. -6. Strong guarantee: if an exception is thrown, there are no changes to any JSON value. -7. Strong guarantee: if an exception is thrown, there are no changes to any JSON value. -8. Strong guarantee: if an exception is thrown, there are no changes to any JSON value. -9. No-throw guarantee: this constructor never throws exceptions. - ## Complexity 1. Constant. @@ -233,7 +241,7 @@ basic_json(basic_json&& other) noexcept; - Overload 5: - !!! note + !!! note "Empty initializer list" When used without parentheses around an empty initializer list, `basic_json()` is called instead of this function, yielding the JSON `#!json null` value. @@ -242,17 +250,15 @@ basic_json(basic_json&& other) noexcept; !!! info "Preconditions" - - Iterators `first` and `last` must be initialized. **This precondition is enforced with an assertion (see - warning).** If assertions are switched off, a violation of this precondition yields undefined behavior. + - Iterators `first` and `last` must be initialized. **This precondition is enforced with a + [runtime assertion](../../features/assertions.md). - Range `[first, last)` is valid. Usually, this precondition cannot be checked efficiently. Only certain edge cases are detected; see the description of the exceptions above. A violation of this precondition yields undefined behavior. - !!! warning + !!! danger "Runtime assertion" - A precondition is enforced with a runtime assertion that will result in calling `std::abort` if this - precondition is not met. Assertions can be disabled by defining `NDEBUG` at compile time. See - for more information. + A precondition is enforced with a [runtime assertion](../../features/assertions.md). - Overload 8: @@ -267,9 +273,9 @@ basic_json(basic_json&& other) noexcept; - `#!cpp `*this` has the same value as `other` before the call. - `other` is a JSON `#!json null` value -## Example +## Examples -??? example +??? example "Example: (1) create an empty value with a given type" The following code shows the constructor for different `value_t` values. @@ -283,7 +289,7 @@ basic_json(basic_json&& other) noexcept; --8<-- "examples/basic_json__value_t.output" ``` -??? example +??? example "Example: (2) create a `#!json null` object" The following code shows the constructor with and without a null pointer parameter. @@ -297,7 +303,7 @@ basic_json(basic_json&& other) noexcept; --8<-- "examples/basic_json__nullptr_t.output" ``` -??? example +??? example "Example: (3) create a JSON value from compatible types" The following code shows the constructor with several compatible types. @@ -311,7 +317,9 @@ basic_json(basic_json&& other) noexcept; --8<-- "examples/basic_json__CompatibleType.output" ``` -??? example + Note the output is platform-dependent. + +??? example "Example: (5) create a container (array or object) from an initializer list" The example below shows how JSON values are created from initializer lists. @@ -325,7 +333,7 @@ basic_json(basic_json&& other) noexcept; --8<-- "examples/basic_json__list_init_t.output" ``` -??? example +??? example "Example: (6) construct an array with count copies of given value" The following code shows examples for creating arrays with several copies of a given value. @@ -339,7 +347,7 @@ basic_json(basic_json&& other) noexcept; --8<-- "examples/basic_json__size_type_basic_json.output" ``` -??? example +??? example "Example: (7) construct a JSON container given an iterator range" The example below shows several ways to create JSON values by specifying a subrange with iterators. @@ -353,7 +361,7 @@ basic_json(basic_json&& other) noexcept; --8<-- "examples/basic_json__InputIt_InputIt.output" ``` -??? example +??? example "Example: (8) copy constructor" The following code shows an example for the copy constructor. @@ -367,7 +375,7 @@ basic_json(basic_json&& other) noexcept; --8<-- "examples/basic_json__basic_json.output" ``` -??? example +??? example "Example: (9) move constructor" The code below shows the move constructor explicitly called via `std::move`. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/begin.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/begin.md similarity index 91% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/begin.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/begin.md index 25d93b8f8..ef623a5ff 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/begin.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/begin.md @@ -1,4 +1,4 @@ -# basic_json::begin +# nlohmann::basic_json::begin ```cpp iterator begin() noexcept; @@ -21,7 +21,7 @@ No-throw guarantee: this member function never throws exceptions. Constant. -## Example +## Examples ??? example diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/binary.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/binary.md new file mode 100644 index 000000000..ce45d8a0f --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/binary.md @@ -0,0 +1,66 @@ +# nlohmann::basic_json::binary + +```cpp +// (1) +static basic_json binary(const typename binary_t::container_type& init); +static basic_json binary(typename binary_t::container_type&& init); + +// (2) +static basic_json binary(const typename binary_t::container_type& init, + std::uint8_t subtype); +static basic_json binary(typename binary_t::container_type&& init, + std::uint8_t subtype); +``` + +1. Creates a JSON binary array value from a given binary container. +2. Creates a JSON binary array value from a given binary container with subtype. + +Binary values are part of various binary formats, such as CBOR, MessagePack, and BSON. This constructor is used to +create a value for serialization to those formats. + +## Parameters + +`init` (in) +: container containing bytes to use as binary type + +`subtype` (in) +: subtype to use in CBOR, MessagePack, and BSON + +## Return value + +JSON binary array value + +## Exception safety + +Strong guarantee: if an exception is thrown, there are no changes in the JSON value. + +## Complexity + +Linear in the size of `init`; constant for `typename binary_t::container_type&& init` versions. + +## Notes + +Note, this function exists because of the difficulty in correctly specifying the correct template overload in the +standard value ctor, as both JSON arrays and JSON binary arrays are backed with some form of a `std::vector`. Because +JSON binary arrays are a non-standard extension it was decided that it would be best to prevent automatic initialization +of a binary array type, for backwards compatibility and so it does not happen on accident. + +## Examples + +??? example + + The following code shows how to create a binary value. + + ```cpp + --8<-- "examples/binary.cpp" + ``` + + Output: + + ```json + --8<-- "examples/binary.output" + ``` + +## Version history + +- Added in version 3.8.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/binary_t.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/binary_t.md new file mode 100644 index 000000000..705c92cb5 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/binary_t.md @@ -0,0 +1,89 @@ +# nlohmann::basic_json::binary_t + +```cpp +using binary_t = byte_container_with_subtype; +``` + +This type is a type designed to carry binary data that appears in various serialized formats, such as CBOR's Major Type +2, MessagePack's bin, and BSON's generic binary subtype. This type is NOT a part of standard JSON and exists solely for +compatibility with these binary types. As such, it is simply defined as an ordered sequence of zero or more byte values. + +Additionally, as an implementation detail, the subtype of the binary data is carried around as a `std::uint64_t`, which +is compatible with both of the binary data formats that use binary subtyping, (though the specific numbering is +incompatible with each other, and it is up to the user to translate between them). The subtype is added to `BinaryType` +via the helper type [byte_container_with_subtype](../byte_container_with_subtype/index.md). + +[CBOR's RFC 7049](https://tools.ietf.org/html/rfc7049) describes this type as: +> Major type 2: a byte string. The string's length in bytes is represented following the rules for positive integers +> (major type 0). + +[MessagePack's documentation on the bin type +family](https://github.com/msgpack/msgpack/blob/master/spec.md#bin-format-family) describes this type as: +> Bin format family stores a byte array in 2, 3, or 5 bytes of extra bytes in addition to the size of the byte array. + +[BSON's specifications](http://bsonspec.org/spec.html) describe several binary types; however, this type is intended to +represent the generic binary type which has the description: +> Generic binary subtype - This is the most commonly used binary subtype and should be the 'default' for drivers and +> tools. + +None of these impose any limitations on the internal representation other than the basic unit of storage be some type of +array whose parts are decomposable into bytes. + +The default representation of this binary format is a `#!cpp std::vector`, which is a very common way to +represent a byte array in modern C++. + +## Template parameters + +`BinaryType` +: container type to store arrays + +## Notes + +#### Default type + +The default values for `BinaryType` is `#!cpp std::vector`. + +#### Storage + +Binary Arrays are stored as pointers in a `basic_json` type. That is, for any access to array values, a pointer of the +type `#!cpp binary_t*` must be dereferenced. + +#### Notes on subtypes + +- CBOR + - Binary values are represented as byte strings. Subtypes are written as tags. + +- MessagePack + - If a subtype is given and the binary array contains exactly 1, 2, 4, 8, or 16 elements, the fixext family (fixext1, + fixext2, fixext4, fixext8) is used. For other sizes, the ext family (ext8, ext16, ext32) is used. The subtype is + then added as signed 8-bit integer. + - If no subtype is given, the bin family (bin8, bin16, bin32) is used. + +- BSON + - If a subtype is given, it is used and added as unsigned 8-bit integer. + - If no subtype is given, the generic binary subtype 0x00 is used. + +## Examples + +??? example + + The following code shows that `binary_t` is by default, a typedef to + `#!cpp nlohmann::byte_container_with_subtype>`. + + ```cpp + --8<-- "examples/binary_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/binary_t.output" + ``` + +## See also + +- [byte_container_with_subtype](../byte_container_with_subtype/index.md) + +## Version history + +- Added in version 3.8.0. Changed type of subtype to `std::uint64_t` in version 3.10.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/boolean_t.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/boolean_t.md new file mode 100644 index 000000000..e3a783027 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/boolean_t.md @@ -0,0 +1,42 @@ +# nlohmann::basic_json::boolean_t + +```cpp +using boolean_t = BooleanType; +``` + +The type used to store JSON booleans. + +[RFC 8259](https://tools.ietf.org/html/rfc8259) implicitly describes a boolean as a type which differentiates the two +literals `#!json true` and `#!json false`. + +To store objects in C++, a type is defined by the template parameter `BooleanType` which chooses the type to use. + +## Notes + +#### Default type + +With the default values for `BooleanType` (`#!cpp bool`), the default value for `boolean_t` is `#!cpp bool`. + +#### Storage + +Boolean values are stored directly inside a `basic_json` type. + +## Examples + +??? example + + The following code shows that `boolean_t` is by default, a typedef to `#!cpp bool`. + + ```cpp + --8<-- "examples/boolean_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/boolean_t.output" + ``` + +## Version history + +- Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/cbegin.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/cbegin.md similarity index 90% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/cbegin.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/cbegin.md index 132934a8f..06504fee6 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/cbegin.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/cbegin.md @@ -1,4 +1,4 @@ -# basic_json::cbegin +# nlohmann::basic_json::cbegin ```cpp const_iterator cbegin() const noexcept; @@ -20,7 +20,7 @@ No-throw guarantee: this member function never throws exceptions. Constant. -## Example +## Examples ??? example diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/cbor_tag_handler_t.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/cbor_tag_handler_t.md new file mode 100644 index 000000000..e19c3edd9 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/cbor_tag_handler_t.md @@ -0,0 +1,42 @@ +# nlohmann::basic_json::cbor_tag_handler_t + +```cpp +enum class cbor_tag_handler_t +{ + error, + ignore, + store +}; +``` + +This enumeration is used in the [`from_cbor`](from_cbor.md) function to choose how to treat tags: + +error +: throw a `parse_error` exception in case of a tag + +ignore +: ignore tags + +store +: store tagged values as binary container with subtype (for bytes 0xd8..0xdb) + +## Examples + +??? example + + The example below shows how the different values of the `cbor_tag_handler_t` influence the behavior of + [`from_cbor`](from_cbor.md) when reading a tagged byte string. + + ```cpp + --8<-- "examples/cbor_tag_handler_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/cbor_tag_handler_t.output" + ``` + +## Version history + +- Added in version 3.9.0. Added value `store` in 3.10.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/cend.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/cend.md similarity index 91% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/cend.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/cend.md index e5de7e94e..3f3aa949d 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/cend.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/cend.md @@ -1,4 +1,4 @@ -# basic_json::cend +# nlohmann::basic_json::cend ```cpp const_iterator cend() const noexcept; @@ -20,7 +20,7 @@ No-throw guarantee: this member function never throws exceptions. Constant. -## Example +## Examples ??? example diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/clear.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/clear.md new file mode 100644 index 000000000..ff04b08e6 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/clear.md @@ -0,0 +1,58 @@ +# nlohmann::basic_json::clear + +```cpp +void clear() noexcept; +``` + +Clears the content of a JSON value and resets it to the default value as if [`basic_json(value_t)`](basic_json.md) would +have been called with the current value type from [`type()`](type.md): + +| Value type | initial value | +|------------|----------------------| +| null | `null` | +| boolean | `false` | +| string | `""` | +| number | `0` | +| binary | An empty byte vector | +| object | `{}` | +| array | `[]` | + +Has the same effect as calling + +```.cpp +*this = basic_json(type()); +``` + +## Exception safety + +No-throw guarantee: this function never throws exceptions. + +## Complexity + +Linear in the size of the JSON value. + +## Notes + +All iterators, pointers and references related to this container are invalidated. + +## Examples + +??? example + + The example below shows the effect of `clear()` to different + JSON types. + + ```cpp + --8<-- "examples/clear.cpp" + ``` + + Output: + + ```json + --8<-- "examples/clear.output" + ``` + +## Version history + +- Added in version 1.0.0. +- Added support for binary types in version 3.8.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/contains.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/contains.md new file mode 100644 index 000000000..ba2c3df2d --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/contains.md @@ -0,0 +1,118 @@ +# nlohmann::basic_json::contains + +```cpp +// (1) +bool contains(const typename object_t::key_type& key) const; + +// (2) +template +bool contains(KeyType&& key) const; + +// (3) +bool contains(const json_pointer& ptr) const; +``` + +1. Check whether an element exists in a JSON object with a key equivalent to `key`. If the element is not found or the + JSON value is not an object, `#!cpp false` is returned. +2. See 1. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and + `#!cpp typename object_comparator_t::is_transparent` denotes a type. +3. Check whether the given JSON pointer `ptr` can be resolved in the current JSON value. + +## Template parameters + +`KeyType` +: A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with + [`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md). + This can also be a string view (C++17). + +## Parameters + +`key` (in) +: key value to check its existence. + +`ptr` (in) +: JSON pointer to check its existence. + +## Return value + +1. `#!cpp true` if an element with specified `key` exists. If no such element with such key is found or the JSON value + is not an object, `#!cpp false` is returned. +2. See 1. +3. `#!cpp true` if the JSON pointer can be resolved to a stored value, `#!cpp false` otherwise. + +## Exception safety + +Strong exception safety: if an exception occurs, the original value stays intact. + +## Exceptions + +1. The function does not throw exceptions. +2. The function does not throw exceptions. +3. The function can throw the following exceptions: + - Throws [`parse_error.106`](../../home/exceptions.md#jsonexceptionparse_error106) if an array index begins with + `0`. + - Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109) if an array index was not a + number. + +## Complexity + +Logarithmic in the size of the JSON object. + +## Notes + +- This method always returns `#!cpp false` when executed on a JSON type that is not an object. +- This method can be executed on any JSON value type. + +!!! info "Postconditions" + + If `#!cpp j.contains(x)` returns `#!c true` for a key or JSON pointer `x`, then it is safe to call `j[x]`. + +## Examples + +??? example "Example: (1) check with key" + + The example shows how `contains()` is used. + + ```cpp + --8<-- "examples/contains__object_t_key_type.cpp" + ``` + + Output: + + ```json + --8<-- "examples/contains__object_t_key_type.output" + ``` + +??? example "Example: (2) check with key using string_view" + + The example shows how `contains()` is used. + + ```cpp + --8<-- "examples/contains__keytype.c++17.cpp" + ``` + + Output: + + ```json + --8<-- "examples/contains__keytype.c++17.output" + ``` + +??? example "Example: (3) check with JSON pointer" + + The example shows how `contains()` is used. + + ```cpp + --8<-- "examples/contains__json_pointer.cpp" + ``` + + Output: + + ```json + --8<-- "examples/contains__json_pointer.output" + ``` + +## Version history + +1. Added in version 3.11.0. +2. Added in version 3.6.0. Extended template `KeyType` to support comparable types in version 3.11.0. +3. Added in version 3.7.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/count.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/count.md new file mode 100644 index 000000000..4f3a31055 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/count.md @@ -0,0 +1,78 @@ +# nlohmann::basic_json::count + +```cpp +// (1) +size_type count(const typename object_t::key_type& key) const; + +// (2) +template +size_type count(KeyType&& key) const; +``` + +1. Returns the number of elements with key `key`. If `ObjectType` is the default `std::map` type, the return value will + always be `0` (`key` was not found) or `1` (`key` was found). +2. See 1. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and + `#!cpp typename object_comparator_t::is_transparent` denotes a type. + +## Template parameters + +`KeyType` +: A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with + [`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md). + This can also be a string view (C++17). + +## Parameters + +`key` (in) +: key value of the element to count. + +## Return value + +Number of elements with key `key`. If the JSON value is not an object, the return value will be `0`. + +## Exception safety + +Strong exception safety: if an exception occurs, the original value stays intact. + +## Complexity + +Logarithmic in the size of the JSON object. + +## Notes + +This method always returns `0` when executed on a JSON type that is not an object. + +## Examples + +??? example "Example: (1) count number of elements" + + The example shows how `count()` is used. + + ```cpp + --8<-- "examples/count__object_t_key_type.cpp" + ``` + + Output: + + ```json + --8<-- "examples/count__object_t_key_type.output" + ``` + +??? example "Example: (2) count number of elements using string_view" + + The example shows how `count()` is used. + + ```cpp + --8<-- "examples/count__keytype.c++17.cpp" + ``` + + Output: + + ```json + --8<-- "examples/count__keytype.c++17.output" + ``` + +## Version history + +1. Added in version 3.11.0. +2. Added in version 1.0.0. Changed parameter `key` type to `KeyType&&` in version 3.11.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/crbegin.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/crbegin.md similarity index 91% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/crbegin.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/crbegin.md index 14196627e..7af5ecae4 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/crbegin.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/crbegin.md @@ -1,4 +1,4 @@ -# basic_json::crbegin +# nlohmann::basic_json::crbegin ```cpp const_reverse_iterator crbegin() const noexcept; @@ -20,7 +20,7 @@ No-throw guarantee: this member function never throws exceptions. Constant. -## Example +## Examples ??? example diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/crend.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/crend.md similarity index 92% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/crend.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/crend.md index f98af7058..0e6bc8474 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/crend.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/crend.md @@ -1,4 +1,4 @@ -# basic_json::rend +# nlohmann::basic_json::crend ```cpp const_reverse_iterator crend() const noexcept; @@ -21,7 +21,7 @@ No-throw guarantee: this member function never throws exceptions. Constant. -## Example +## Examples ??? example diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/default_object_comparator_t.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/default_object_comparator_t.md new file mode 100644 index 000000000..8a237f662 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/default_object_comparator_t.md @@ -0,0 +1,35 @@ +# nlohmann::basic_json::default_object_comparator_t + +```cpp +using default_object_comparator_t = std::less; // until C++14 + +using default_object_comparator_t = std::less<>; // since C++14 +``` + +The default comparator used by [`object_t`](object_t.md). + +Since C++14 a transparent comparator is used which prevents unnecessary string construction +when looking up a key in an object. + +The actual comparator used depends on [`object_t`](object_t.md) and can be obtained via +[`object_comparator_t`](object_comparator_t.md). + +## Examples + +??? example + + The example below demonstrates the default comparator. + + ```cpp + --8<-- "examples/default_object_comparator_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/default_object_comparator_t.output" + ``` + +## Version history + +- Added in version 3.11.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/diff.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/diff.md similarity index 88% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/diff.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/diff.md index 736d5fb4b..4e840684e 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/diff.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/diff.md @@ -1,4 +1,4 @@ -# basic_json::diff +# nlohmann::basic_json::diff ```cpp static basic_json diff(const basic_json& source, @@ -33,11 +33,11 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va Linear in the lengths of `source` and `target`. -## Note +## Notes Currently, only `remove`, `add`, and `replace` operations are generated. -## Example +## Examples ??? example @@ -53,6 +53,10 @@ Currently, only `remove`, `add`, and `replace` operations are generated. --8<-- "examples/diff.output" ``` +## See also + +- [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) + ## Version history - Added in version 2.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/dump.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/dump.md new file mode 100644 index 000000000..41adb154d --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/dump.md @@ -0,0 +1,79 @@ +# nlohmann::basic_json::dump + +```cpp +string_t dump(const int indent = -1, + const char indent_char = ' ', + const bool ensure_ascii = false, + const error_handler_t error_handler = error_handler_t::strict) const; +``` + +Serialization function for JSON values. The function tries to mimic Python's +[`json.dumps()` function](https://docs.python.org/2/library/json.html#json.dump), and currently supports its `indent` +and `ensure_ascii` parameters. + +## Parameters + +`indent` (in) +: If `indent` is nonnegative, then array elements and object members will be pretty-printed with that indent level. An + indent level of `0` will only insert newlines. `-1` (the default) selects the most compact representation. + +`indent_char` (in) +: The character to use for indentation if `indent` is greater than `0`. The default is ` ` (space). + +`ensure_ascii` (in) +: If `ensure_ascii` is true, all non-ASCII characters in the output are escaped with `\uXXXX` sequences, and the + result consists of ASCII characters only. + +`error_handler` (in) +: how to react on decoding errors; there are three possible values (see [`error_handler_t`](error_handler_t.md): + `strict` (throws and exception in case a decoding error occurs; default), `replace` (replace invalid UTF-8 sequences + with U+FFFD), and `ignore` (ignore invalid UTF-8 sequences during serialization; all bytes are copied to the output + unchanged)). + +## Return value + +string containing the serialization of the JSON value + +## Exception safety + +Strong guarantee: if an exception is thrown, there are no changes to any JSON value. + +## Exceptions + +Throws [`type_error.316`](../../home/exceptions.md#jsonexceptiontype_error316) if a string stored inside the JSON value +is not UTF-8 encoded and `error_handler` is set to `strict` + +## Complexity + +Linear. + +## Notes + +Binary values are serialized as object containing two keys: + +- "bytes": an array of bytes as integers +- "subtype": the subtype as integer or `#!json null` if the binary has no subtype + +## Examples + +??? example + + The following example shows the effect of different `indent`, `indent_char`, and `ensure_ascii` parameters to the + result of the serialization. + + ```cpp + --8<-- "examples/dump.cpp" + ``` + + Output: + + ```json + --8<-- "examples/dump.output" + ``` + +## Version history + +- Added in version 1.0.0. +- Indentation character `indent_char`, option `ensure_ascii` and exceptions added in version 3.0.0. +- Error handlers added in version 3.4.0. +- Serialization of binary values added in version 3.8.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/emplace.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/emplace.md similarity index 96% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/emplace.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/emplace.md index 50a9c92e3..6cc2c98d7 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/emplace.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/emplace.md @@ -1,4 +1,4 @@ -# basic_json::emplace +# nlohmann::basic_json::emplace ```cpp template diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/emplace_back.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/emplace_back.md similarity index 95% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/emplace_back.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/emplace_back.md index 8a8af0c66..597ad41e4 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/emplace_back.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/emplace_back.md @@ -1,4 +1,4 @@ -# basic_json::emplace_back +# nlohmann::basic_json::emplace_back ```cpp template diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/empty.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/empty.md new file mode 100644 index 000000000..26bf6e9aa --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/empty.md @@ -0,0 +1,66 @@ +# nlohmann::basic_json::empty + +```cpp +bool empty() const noexcept; +``` + +Checks if a JSON value has no elements (i.e. whether its [`size()`](size.md) is `0`). + +## Return value + +The return value depends on the different types and is defined as follows: + +| Value type | return value | +|------------|----------------------------------------| +| null | `#!cpp true` | +| boolean | `#!cpp false` | +| string | `#!cpp false` | +| number | `#!cpp false` | +| binary | `#!cpp false` | +| object | result of function `object_t::empty()` | +| array | result of function `array_t::empty()` | + +## Exception safety + +No-throw guarantee: this function never throws exceptions. + +## Complexity + +Constant, as long as [`array_t`](array_t.md) and [`object_t`](object_t.md) satisfy the +[Container](https://en.cppreference.com/w/cpp/named_req/Container) concept; that is, their `empty()` functions have +constant complexity. + +## Possible implementation + +```cpp +bool empty() const noexcept +{ + return size() == 0; +} +``` + +## Notes + +This function does not return whether a string stored as JSON value is empty -- it returns whether the JSON container +itself is empty which is `#!cpp false` in the case of a string. + +## Examples + +??? example + + The following code uses `empty()` to check if a JSON object contains any elements. + + ```cpp + --8<-- "examples/empty.cpp" + ``` + + Output: + + ```json + --8<-- "examples/empty.output" + ``` + +## Version history + +- Added in version 1.0.0. +- Extended to return `#!cpp false` for binary types in version 3.8.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/end.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/end.md similarity index 91% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/end.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/end.md index 52bfec2e3..179ce9e67 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/end.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/end.md @@ -1,4 +1,4 @@ -# basic_json::end +# nlohmann::basic_json::end ```cpp iterator end() noexcept; @@ -21,7 +21,7 @@ No-throw guarantee: this member function never throws exceptions. Constant. -## Example +## Examples ??? example diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/erase.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/erase.md new file mode 100644 index 000000000..1187995b6 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/erase.md @@ -0,0 +1,211 @@ +# nlohmann::basic_json::erase + +```cpp +// (1) +iterator erase(iterator pos); +const_iterator erase(const_iterator pos); + +// (2) +iterator erase(iterator first, iterator last); +const_iterator erase(const_iterator first, const_iterator last); + +// (3) +size_type erase(const typename object_t::key_type& key); + +// (4) +template +size_type erase(KeyType&& key); + +// (5) +void erase(const size_type idx); +``` + +1. Removes an element from a JSON value specified by iterator `pos`. The iterator `pos` must be valid and + dereferenceable. Thus, the `end()` iterator (which is valid, but is not dereferenceable) cannot be used as a value for + `pos`. + + If called on a primitive type other than `#!json null`, the resulting JSON value will be `#!json null`. + +2. Remove an element range specified by `[first; last)` from a JSON value. The iterator `first` does not need to be + dereferenceable if `first == last`: erasing an empty range is a no-op. + + If called on a primitive type other than `#!json null`, the resulting JSON value will be `#!json null`. + +3. Removes an element from a JSON object by key. + +4. See 3. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and + `#!cpp typename object_comparator_t::is_transparent` denotes a type. + +5. Removes an element from a JSON array by index. + +## Template parameters + +`KeyType` +: A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with + [`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md). + This can also be a string view (C++17). + +## Parameters + +`pos` (in) +: iterator to the element to remove + +`first` (in) +: iterator to the beginning of the range to remove + +`last` (in) +: iterator past the end of the range to remove + +`key` (in) +: object key of the elements to remove + +`idx` (in) +: array index of the element to remove + +## Return value + +1. Iterator following the last removed element. If the iterator `pos` refers to the last element, the `end()` iterator + is returned. +2. Iterator following the last removed element. If the iterator `last` refers to the last element, the `end()` iterator + is returned. +3. Number of elements removed. If `ObjectType` is the default `std::map` type, the return value will always be `0` + (`key` was not found) or `1` (`key` was found). +4. See 3. +5. (none) + +## Exception safety + +Strong exception safety: if an exception occurs, the original value stays intact. + +## Exceptions + +1. The function can throw the following exceptions: + - Throws [`type_error.307`](../../home/exceptions.md#jsonexceptiontype_error307) if called on a `null` value; + example: `"cannot use erase() with null"` + - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an + iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"` + - Throws [`invalid_iterator.205`](../../home/exceptions.md#jsonexceptioninvalid_iterator205) if called on a + primitive type with invalid iterator (i.e., any iterator which is not `begin()`); example: `"iterator out of + range"` +2. The function can throw the following exceptions: + - Throws [`type_error.307`](../../home/exceptions.md#jsonexceptiontype_error307) if called on a `null` value; + example: `"cannot use erase() with null"` + - Throws [`invalid_iterator.203`](../../home/exceptions.md#jsonexceptioninvalid_iterator203) if called on iterators + which does not belong to the current JSON value; example: `"iterators do not fit current value"` + - Throws [`invalid_iterator.204`](../../home/exceptions.md#jsonexceptioninvalid_iterator204) if called on a + primitive type with invalid iterators (i.e., if `first != begin()` and `last != end()`); example: `"iterators out + of range"` +3. The function can throw the following exceptions: + - Throws [`type_error.307`](../../home/exceptions.md#jsonexceptiontype_error307) when called on a type other than + JSON object; example: `"cannot use erase() with null"` +4. See 3. +5. The function can throw the following exceptions: + - Throws [`type_error.307`](../../home/exceptions.md#jsonexceptiontype_error307) when called on a type other than + JSON object; example: `"cannot use erase() with null"` + - Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) when `idx >= size()`; example: + `"array index 17 is out of range"` + +## Complexity + +1. The complexity depends on the type: + - objects: amortized constant + - arrays: linear in distance between `pos` and the end of the container + - strings and binary: linear in the length of the member + - other types: constant +2. The complexity depends on the type: + - objects: `log(size()) + std::distance(first, last)` + - arrays: linear in the distance between `first` and `last`, plus linear + in the distance between `last` and end of the container + - strings and binary: linear in the length of the member + - other types: constant +3. `log(size()) + count(key)` +4. `log(size()) + count(key)` +5. Linear in distance between `idx` and the end of the container. + +## Notes + +1. Invalidates iterators and references at or after the point of the `erase`, including the `end()` iterator. +2. (none) +3. References and iterators to the erased elements are invalidated. Other references and iterators are not affected. +4. See 3. +5. (none) + +## Examples + +??? example "Example: (1) remove element given an iterator" + + The example shows the effect of `erase()` for different JSON types using an iterator. + + ```cpp + --8<-- "examples/erase__IteratorType.cpp" + ``` + + Output: + + ```json + --8<-- "examples/erase__IteratorType.output" + ``` + +??? example "Example: (2) remove elements given an iterator range" + + The example shows the effect of `erase()` for different JSON types using an iterator range. + + ```cpp + --8<-- "examples/erase__IteratorType_IteratorType.cpp" + ``` + + Output: + + ```json + --8<-- "examples/erase__IteratorType_IteratorType.output" + ``` + +??? example "Example: (3) remove element from a JSON object given a key" + + The example shows the effect of `erase()` for different JSON types using an object key. + + ```cpp + --8<-- "examples/erase__object_t_key_type.cpp" + ``` + + Output: + + ```json + --8<-- "examples/erase__object_t_key_type.output" + ``` + +??? example "Example: (4) remove element from a JSON object given a key using string_view" + + The example shows the effect of `erase()` for different JSON types using an object key. + + ```cpp + --8<-- "examples/erase__keytype.c++17.cpp" + ``` + + Output: + + ```json + --8<-- "examples/erase__keytype.c++17.output" + ``` + +??? example "Example: (5) remove element from a JSON array given an index" + + The example shows the effect of `erase()` using an array index. + + ```cpp + --8<-- "examples/erase__size_type.cpp" + ``` + + Output: + + ```json + --8<-- "examples/erase__size_type.output" + ``` + +## Version history + +1. Added in version 1.0.0. Added support for binary types in version 3.8.0. +2. Added in version 1.0.0. Added support for binary types in version 3.8.0. +3. Added in version 1.0.0. +4. Added in version 3.11.0. +5. Added in version 1.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/error_handler_t.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/error_handler_t.md new file mode 100644 index 000000000..dc32ced9b --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/error_handler_t.md @@ -0,0 +1,42 @@ +# nlohmann::basic_json::error_handler_t + +```cpp +enum class error_handler_t { + strict, + replace, + ignore +}; +``` + +This enumeration is used in the [`dump`](dump.md) function to choose how to treat decoding errors while serializing a +`basic_json` value. Three values are differentiated: + +strict +: throw a `type_error` exception in case of invalid UTF-8 + +replace +: replace invalid UTF-8 sequences with U+FFFD (� REPLACEMENT CHARACTER) + +ignore +: ignore invalid UTF-8 sequences; all bytes are copied to the output unchanged + +## Examples + +??? example + + The example below shows how the different values of the `error_handler_t` influence the behavior of + [`dump`](dump.md) when reading serializing an invalid UTF-8 sequence. + + ```cpp + --8<-- "examples/error_handler_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/error_handler_t.output" + ``` + +## Version history + +- Added in version 3.4.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/exception.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/exception.md similarity index 82% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/exception.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/exception.md index deedae5a6..794b7d1e2 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/exception.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/exception.md @@ -1,4 +1,4 @@ -# basic_json::exception +# nlohmann::basic_json::exception ```cpp class exception : public std::exception; @@ -44,7 +44,13 @@ Subclasses: - **id** - the id of the exception -## Example +## Notes + +To have nothrow-copy-constructible exceptions, we internally use `std::runtime_error` which can cope with +arbitrary-length error messages. Intermediate strings are built with static functions and then passed to the actual +constructor. + +## Examples ??? example @@ -60,6 +66,10 @@ Subclasses: --8<-- "examples/exception.output" ``` +## See also + +[List of exceptions](../../home/exceptions.md) + ## Version history - Since version 3.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/find.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/find.md new file mode 100644 index 000000000..c64350718 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/find.md @@ -0,0 +1,86 @@ +# nlohmann::basic_json::find + +```cpp +// (1) +iterator find(const typename object_t::key_type& key); +const_iterator find(const typename object_t::key_type& key) const; + +// (2) +template +iterator find(KeyType&& key); +template +const_iterator find(KeyType&& key) const; +``` + +1. Finds an element in a JSON object with a key equivalent to `key`. If the element is not found or the + JSON value is not an object, `end()` is returned. +2. See 1. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and + `#!cpp typename object_comparator_t::is_transparent` denotes a type. + +## Template parameters + +`KeyType` +: A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with + [`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md). + This can also be a string view (C++17). + +## Parameters + +`key` (in) +: key value of the element to search for. + +## Return value + +Iterator to an element with a key equivalent to `key`. If no such element is found or the JSON value is not an object, +a past-the-end iterator (see `end()`) is returned. + +## Exception safety + +Strong exception safety: if an exception occurs, the original value stays intact. + +## Complexity + +Logarithmic in the size of the JSON object. + +## Notes + +This method always returns `end()` when executed on a JSON type that is not an object. + +## Examples + +??? example "Example: (1) find object element by key" + + The example shows how `find()` is used. + + ```cpp + --8<-- "examples/find__object_t_key_type.cpp" + ``` + + Output: + + ```json + --8<-- "examples/find__object_t_key_type.output" + ``` + +??? example "Example: (2) find object element by key using string_view" + + The example shows how `find()` is used. + + ```cpp + --8<-- "examples/find__keytype.c++17.cpp" + ``` + + Output: + + ```json + --8<-- "examples/find__keytype.c++17.output" + ``` + +## See also + +- [contains](contains.md) checks whether a key exists + +## Version history + +1. Added in version 3.11.0. +2. Added in version 1.0.0. Changed to support comparable types in version 3.11.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/flatten.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/flatten.md similarity index 89% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/flatten.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/flatten.md index 1408f3809..8703e86d1 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/flatten.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/flatten.md @@ -1,4 +1,4 @@ -# basic_json::flatten +# nlohmann::basic_json::flatten ```cpp basic_json flatten() const; @@ -25,7 +25,7 @@ Linear in the size the JSON value. Empty objects and arrays are flattened to `#!json null` and will not be reconstructed correctly by the [`unflatten()`](unflatten.md) function. -## Example +## Examples ??? example @@ -41,6 +41,10 @@ Empty objects and arrays are flattened to `#!json null` and will not be reconstr --8<-- "examples/flatten.output" ``` +## See also + +- [unflatten](unflatten.md) the reverse function + ## Version history - Added in version 2.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/from_bjdata.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/from_bjdata.md new file mode 100644 index 000000000..3c5eeb351 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/from_bjdata.md @@ -0,0 +1,93 @@ +# nlohmann::basic_json::from_bjdata + +```cpp +// (1) +template +static basic_json from_bjdata(InputType&& i, + const bool strict = true, + const bool allow_exceptions = true); +// (2) +template +static basic_json from_bjdata(IteratorType first, IteratorType last, + const bool strict = true, + const bool allow_exceptions = true); +``` + +Deserializes a given input to a JSON value using the BJData (Binary JData) serialization format. + +1. Reads from a compatible input. +2. Reads from an iterator range. + +The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/bjdata.md). + +## Template parameters + +`InputType` +: A compatible input, for instance: + + - an `std::istream` object + - a `FILE` pointer + - a C-style array of characters + - a pointer to a null-terminated string of single byte characters + - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. + +`IteratorType` +: a compatible iterator type + +## Parameters + +`i` (in) +: an input in BJData format convertible to an input adapter + +`first` (in) +: iterator to start of the input + +`last` (in) +: iterator to end of the input + +`strict` (in) +: whether to expect the input to be consumed until EOF (`#!cpp true` by default) + +`allow_exceptions` (in) +: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) + +## Return value + +deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be +`value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). + +## Exception safety + +Strong guarantee: if an exception is thrown, there are no changes in the JSON value. + +## Exceptions + +- Throws [parse_error.110](../../home/exceptions.md#jsonexceptionparse_error110) if the given input ends prematurely or + the end of file was not reached when `strict` was set to true +- Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if a parse error occurs +- Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a string could not be parsed + successfully + +## Complexity + +Linear in the size of the input. + +## Examples + +??? example + + The example shows the deserialization of a byte vector in BJData format to a JSON value. + + ```cpp + --8<-- "examples/from_bjdata.cpp" + ``` + + Output: + + ```json + --8<-- "examples/from_bjdata.output" + ``` + +## Version history + +- Added in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/from_bson.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/from_bson.md new file mode 100644 index 000000000..77549370c --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/from_bson.md @@ -0,0 +1,110 @@ +# nlohmann::basic_json::from_bson + +```cpp +// (1) +template +static basic_json from_bson(InputType&& i, + const bool strict = true, + const bool allow_exceptions = true); +// (2) +template +static basic_json from_bson(IteratorType first, IteratorType last, + const bool strict = true, + const bool allow_exceptions = true); +``` + +Deserializes a given input to a JSON value using the BSON (Binary JSON) serialization format. + +1. Reads from a compatible input. +2. Reads from an iterator range. + +The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/bson.md). + +## Template parameters + +`InputType` +: A compatible input, for instance: + + - an `std::istream` object + - a `FILE` pointer + - a C-style array of characters + - a pointer to a null-terminated string of single byte characters + - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. + +`IteratorType` +: a compatible iterator type + +## Parameters + +`i` (in) +: an input in BSON format convertible to an input adapter + +`first` (in) +: iterator to start of the input + +`last` (in) +: iterator to end of the input + +`strict` (in) +: whether to expect the input to be consumed until EOF (`#!cpp true` by default) + +`allow_exceptions` (in) +: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) + +## Return value + +deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be +`value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). + +## Exception safety + +Strong guarantee: if an exception is thrown, there are no changes in the JSON value. + +## Exceptions + +Throws [`parse_error.114`](../../home/exceptions.md#jsonexceptionparse_error114) if an unsupported BSON record type is +encountered. + +## Complexity + +Linear in the size of the input. + +## Examples + +??? example + + The example shows the deserialization of a byte vector in BSON format to a JSON value. + + ```cpp + --8<-- "examples/from_bson.cpp" + ``` + + Output: + + ```json + --8<-- "examples/from_bson.output" + ``` + +## See also + +- [BSON specification](http://bsonspec.org/spec.html) +- [to_bson](to_bson.md) for the analogous serialization +- [from_cbor](from_cbor.md) for the related CBOR format +- [from_msgpack](from_msgpack.md) for the related MessagePack format +- [from_ubjson](from_ubjson.md) for the related UBJSON format + +## Version history + +- Added in version 3.4.0. + +!!! warning "Deprecation" + + - Overload (2) replaces calls to `from_bson` with a pointer and a length as first two parameters, which has been + deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like + `#!cpp from_bson(ptr, len, ...);` with `#!cpp from_bson(ptr, ptr+len, ...);`. + - Overload (2) replaces calls to `from_bson` with a pair of iterators as their first parameter, which has been + deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like + `#!cpp from_bson({ptr, ptr+len}, ...);` with `#!cpp from_bson(ptr, ptr+len, ...);`. + + You should be warned by your compiler with a `-Wdeprecated-declarations` warning if you are using a deprecated + function. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/from_cbor.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/from_cbor.md new file mode 100644 index 000000000..3aa57b9ec --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/from_cbor.md @@ -0,0 +1,117 @@ +# nlohmann::basic_json::from_cbor + +```cpp +// (1) +template +static basic_json from_cbor(InputType&& i, + const bool strict = true, + const bool allow_exceptions = true, + const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error); + +// (2) +template +static basic_json from_cbor(IteratorType first, IteratorType last, + const bool strict = true, + const bool allow_exceptions = true, + const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error); +``` + +Deserializes a given input to a JSON value using the CBOR (Concise Binary Object Representation) serialization format. + +1. Reads from a compatible input. +2. Reads from an iterator range. + +The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/cbor.md). + +## Template parameters + +`InputType` +: A compatible input, for instance: + + - an `std::istream` object + - a `FILE` pointer + - a C-style array of characters + - a pointer to a null-terminated string of single byte characters + - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. + +`IteratorType` +: a compatible iterator type + +## Parameters + +`i` (in) +: an input in CBOR format convertible to an input adapter + +`first` (in) +: iterator to start of the input + +`last` (in) +: iterator to end of the input + +`strict` (in) +: whether to expect the input to be consumed until EOF (`#!cpp true` by default) + +`allow_exceptions` (in) +: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) + +`tag_handler` (in) +: how to treat CBOR tags (optional, `error` by default); see [`cbor_tag_handler_t`](cbor_tag_handler_t.md) for more + information + +## Return value + +deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be +`value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). + +## Exception safety + +Strong guarantee: if an exception is thrown, there are no changes in the JSON value. + +## Exceptions + +- Throws [parse_error.110](../../home/exceptions.md#jsonexceptionparse_error110) if the given input ends prematurely or + the end of file was not reached when `strict` was set to true +- Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if unsupported features from CBOR were + used in the given input or if the input is not valid CBOR +- Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a string was expected as map key, + but not found + +## Complexity + +Linear in the size of the input. + +## Examples + +??? example + + The example shows the deserialization of a byte vector in CBOR format to a JSON value. + + ```cpp + --8<-- "examples/from_cbor.cpp" + ``` + + Output: + + ```json + --8<-- "examples/from_cbor.output" + ``` + +## Version history + +- Added in version 2.0.9. +- Parameter `start_index` since version 2.1.1. +- Changed to consume input adapters, removed `start_index` parameter, and added `strict` parameter in version 3.0.0. +- Added `allow_exceptions` parameter in version 3.2.0. +- Added `tag_handler` parameter in version 3.9.0. + +!!! warning "Deprecation" + + - Overload (2) replaces calls to `from_cbor` with a pointer and a length as first two parameters, which has been + deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like + `#!cpp from_cbor(ptr, len, ...);` with `#!cpp from_cbor(ptr, ptr+len, ...);`. + - Overload (2) replaces calls to `from_cbor` with a pair of iterators as their first parameter, which has been + deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like + `#!cpp from_cbor({ptr, ptr+len}, ...);` with `#!cpp from_cbor(ptr, ptr+len, ...);`. + + You should be warned by your compiler with a `-Wdeprecated-declarations` warning if you are using a deprecated + function. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/from_msgpack.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/from_msgpack.md new file mode 100644 index 000000000..117c3865f --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/from_msgpack.md @@ -0,0 +1,109 @@ +# nlohmann::basic_json::from_msgpack + +```cpp +// (1) +template +static basic_json from_msgpack(InputType&& i, + const bool strict = true, + const bool allow_exceptions = true); +// (2) +template +static basic_json from_msgpack(IteratorType first, IteratorType last, + const bool strict = true, + const bool allow_exceptions = true); +``` + +Deserializes a given input to a JSON value using the MessagePack serialization format. + +1. Reads from a compatible input. +2. Reads from an iterator range. + +The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/messagepack.md). + +## Template parameters + +`InputType` +: A compatible input, for instance: + + - an `std::istream` object + - a `FILE` pointer + - a C-style array of characters + - a pointer to a null-terminated string of single byte characters + - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. + +`IteratorType` +: a compatible iterator type + +## Parameters + +`i` (in) +: an input in MessagePack format convertible to an input adapter + +`first` (in) +: iterator to start of the input + +`last` (in) +: iterator to end of the input + +`strict` (in) +: whether to expect the input to be consumed until EOF (`#!cpp true` by default) + +`allow_exceptions` (in) +: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) + +## Return value + +deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be +`value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). + +## Exception safety + +Strong guarantee: if an exception is thrown, there are no changes in the JSON value. + +## Exceptions + +- Throws [parse_error.110](../../home/exceptions.md#jsonexceptionparse_error110) if the given input ends prematurely or + the end of file was not reached when `strict` was set to true +- Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if unsupported features from + MessagePack were used in the given input or if the input is not valid MessagePack +- Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a string was expected as map key, + but not found + +## Complexity + +Linear in the size of the input. + +## Examples + +??? example + + The example shows the deserialization of a byte vector in MessagePack format to a JSON value. + + ```cpp + --8<-- "examples/from_msgpack.cpp" + ``` + + Output: + + ```json + --8<-- "examples/from_msgpack.output" + ``` + +## Version history + +- Added in version 2.0.9. +- Parameter `start_index` since version 2.1.1. +- Changed to consume input adapters, removed `start_index` parameter, and added `strict` parameter in version 3.0.0. +- Added `allow_exceptions` parameter in version 3.2.0. + +!!! warning "Deprecation" + + - Overload (2) replaces calls to `from_msgpack` with a pointer and a length as first two parameters, which has been + deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like + `#!cpp from_msgpack(ptr, len, ...);` with `#!cpp from_msgpack(ptr, ptr+len, ...);`. + - Overload (2) replaces calls to `from_cbor` with a pair of iterators as their first parameter, which has been + deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like + `#!cpp from_msgpack({ptr, ptr+len}, ...);` with `#!cpp from_msgpack(ptr, ptr+len, ...);`. + + You should be warned by your compiler with a `-Wdeprecated-declarations` warning if you are using a deprecated + function. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/from_ubjson.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/from_ubjson.md new file mode 100644 index 000000000..08117e89b --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/from_ubjson.md @@ -0,0 +1,106 @@ +# nlohmann::basic_json::from_ubjson + +```cpp +// (1) +template +static basic_json from_ubjson(InputType&& i, + const bool strict = true, + const bool allow_exceptions = true); +// (2) +template +static basic_json from_ubjson(IteratorType first, IteratorType last, + const bool strict = true, + const bool allow_exceptions = true); +``` + +Deserializes a given input to a JSON value using the UBJSON (Universal Binary JSON) serialization format. + +1. Reads from a compatible input. +2. Reads from an iterator range. + +The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/ubjson.md). + +## Template parameters + +`InputType` +: A compatible input, for instance: + + - an `std::istream` object + - a `FILE` pointer + - a C-style array of characters + - a pointer to a null-terminated string of single byte characters + - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. + +`IteratorType` +: a compatible iterator type + +## Parameters + +`i` (in) +: an input in UBJSON format convertible to an input adapter + +`first` (in) +: iterator to start of the input + +`last` (in) +: iterator to end of the input + +`strict` (in) +: whether to expect the input to be consumed until EOF (`#!cpp true` by default) + +`allow_exceptions` (in) +: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) + +## Return value + +deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be +`value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). + +## Exception safety + +Strong guarantee: if an exception is thrown, there are no changes in the JSON value. + +## Exceptions + +- Throws [parse_error.110](../../home/exceptions.md#jsonexceptionparse_error110) if the given input ends prematurely or + the end of file was not reached when `strict` was set to true +- Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if a parse error occurs +- Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a string could not be parsed + successfully + +## Complexity + +Linear in the size of the input. + +## Examples + +??? example + + The example shows the deserialization of a byte vector in UBJSON format to a JSON value. + + ```cpp + --8<-- "examples/from_ubjson.cpp" + ``` + + Output: + + ```json + --8<-- "examples/from_ubjson.output" + ``` + +## Version history + +- Added in version 3.1.0. +- Added `allow_exceptions` parameter in version 3.2.0. + +!!! warning "Deprecation" + + - Overload (2) replaces calls to `from_ubjson` with a pointer and a length as first two parameters, which has been + deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like + `#!cpp from_ubjson(ptr, len, ...);` with `#!cpp from_ubjson(ptr, ptr+len, ...);`. + - Overload (2) replaces calls to `from_ubjson` with a pair of iterators as their first parameter, which has been + deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like + `#!cpp from_ubjson({ptr, ptr+len}, ...);` with `#!cpp from_ubjson(ptr, ptr+len, ...);`. + + You should be warned by your compiler with a `-Wdeprecated-declarations` warning if you are using a deprecated + function. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/front.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/front.md similarity index 79% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/front.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/front.md index 55010fb85..e258c36a0 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/front.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/front.md @@ -1,4 +1,4 @@ -# basic_json::front +# nlohmann::basic_json::front ```cpp reference front(); @@ -13,26 +13,26 @@ Returns a reference to the first element in the container. For a JSON container In case of a structured type (array or object), a reference to the first element is returned. In case of number, string, boolean, or binary values, a reference to the value is returned. +## Exception safety + +Strong guarantee: if an exception is thrown, there are no changes in the JSON value. + ## Exceptions If the JSON value is `#!json null`, exception [`invalid_iterator.214`](../../home/exceptions.md#jsonexceptioninvalid_iterator214) is thrown. -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - ## Complexity Constant. -## Note +## Notes -!!! danger +!!! info "Precondition" - Calling `front` on an empty array or object is undefined behavior and is **guarded by an assertion**! + The array or object must not be empty. Calling `front` on an empty array or object yields undefined behavior. -## Example +## Examples ??? example @@ -48,6 +48,10 @@ Constant. --8<-- "examples/front.output" ``` +## See also + +- [back](back.md) to access the last element + ## Version history - Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/get.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/get.md similarity index 96% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/get.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/get.md index 6cd663056..96fc221da 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/get.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/get.md @@ -1,4 +1,4 @@ -# basic_json::get +# nlohmann::basic_json::get ```cpp // (1) @@ -31,7 +31,7 @@ constexpr const PointerType get_ptr() const noexcept; return ret; ``` - This overloads is chosen if: + This overload is chosen if: - `ValueType` is not `basic_json`, - `json_serializer` has a `from_json()` method of the form @@ -48,7 +48,7 @@ constexpr const PointerType get_ptr() const noexcept; return JSONSerializer::from_json(*this); ``` - This overloads is chosen if: + This overload is chosen if: - `ValueType` is not `basic_json` and - `json_serializer` has a `from_json()` method of the form @@ -90,11 +90,11 @@ Depends on what `json_serializer` `from_json()` method throws ## Notes -!!! warning +!!! danger "Undefined behavior" Writing data to the pointee (overload 3) of the result yields an undefined state. -## Example +## Examples ??? example diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/get_allocator.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/get_allocator.md new file mode 100644 index 000000000..07a4d8456 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/get_allocator.md @@ -0,0 +1,31 @@ +# nlohmann::basic_json::get_allocator + +```cpp +static allocator_type get_allocator(); +``` + +Returns the allocator associated with the container. + +## Return value + +associated allocator + +## Examples + +??? example + + The example shows how `get_allocator()` is used to created `json` values. + + ```cpp + --8<-- "examples/get_allocator.cpp" + ``` + + Output: + + ```json + --8<-- "examples/get_allocator.output" + ``` + +## Version history + +- Added in version 1.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/get_binary.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/get_binary.md new file mode 100644 index 000000000..a910f3aa5 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/get_binary.md @@ -0,0 +1,45 @@ +# nlohmann::basic_json::get_binary + +```cpp +binary_t& get_binary(); + +const binary_t& get_binary() const; +``` + +Returns a reference to the stored binary value. + +## Return value + +Reference to binary value. + +## Exception safety + +Strong exception safety: if an exception occurs, the original value stays intact. + +## Exceptions + +Throws [`type_error.302`](../../home/exceptions.md#jsonexceptiontype_error302) if the value is not binary + +## Complexity + +Constant. + +## Examples + +??? example + + The following code shows how to query a binary value. + + ```cpp + --8<-- "examples/get_binary.cpp" + ``` + + Output: + + ```json + --8<-- "examples/get_binary.output" + ``` + +## Version history + +- Added in version 3.8.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/get_ptr.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/get_ptr.md similarity index 86% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/get_ptr.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/get_ptr.md index c5cee307a..2441e1156 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/get_ptr.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/get_ptr.md @@ -1,8 +1,8 @@ -# basic_json::get_ptr +# nlohmann::basic_json::get_ptr ```cpp template -PointerType get_ptr(); +PointerType get_ptr() noexcept; template constexpr const PointerType get_ptr() const noexcept; @@ -10,7 +10,7 @@ constexpr const PointerType get_ptr() const noexcept; Implicit pointer access to the internally stored JSON value. No copies are made. -## Template arguments +## Template parameters `PointerType` : pointer type; must be a pointer to [`array_t`](array_t.md), [`object_t`](object_t.md), [`string_t`](string_t.md), @@ -25,7 +25,7 @@ otherwise ## Exception safety -Strong exception safety: if an exception occurs, the original value stays intact. +No-throw guarantee: this function never throws exceptions. ## Complexity @@ -33,11 +33,11 @@ Constant. ## Notes -!!! warning +!!! danger "Undefined behavior" Writing data to the pointee of the result yields an undefined state. -## Example +## Examples ??? example diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/get_ref.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/get_ref.md similarity index 91% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/get_ref.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/get_ref.md index 102aff1ef..b1219742c 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/get_ref.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/get_ref.md @@ -1,4 +1,4 @@ -# basic_json::get_ref +# nlohmann::basic_json::get_ref ```cpp template @@ -10,13 +10,13 @@ const ReferenceType get_ref() const; Implicit reference access to the internally stored JSON value. No copies are made. -## Template arguments +## Template parameters `ReferenceType` : reference type; must be a reference to [`array_t`](array_t.md), [`object_t`](object_t.md), [`string_t`](string_t.md), [`boolean_t`](boolean_t.md), [`number_integer_t`](number_integer_t.md), or [`number_unsigned_t`](number_unsigned_t.md), [`number_float_t`](number_float_t.md), or [`binary_t`](binary_t.md). - Enforced by static assertion. + Enforced by a static assertion. ## Return value @@ -38,11 +38,11 @@ Constant. ## Notes -!!! warning +!!! danger "Undefined behavior" Writing data to the referee of the result yields an undefined state. -## Example +## Examples ??? example diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/get_to.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/get_to.md similarity index 90% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/get_to.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/get_to.md index 4a4395bc8..6af6d212c 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/get_to.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/get_to.md @@ -1,10 +1,10 @@ -# basic_json::get_to +# nlohmann::basic_json::get_to ```cpp template ValueType& get_to(ValueType& v) const noexcept( noexcept(JSONSerializer::from_json( - std::declval(), v))) + std::declval(), v))); ``` Explicit type conversion between the JSON value and a compatible value. The value is filled into the input parameter by @@ -16,7 +16,7 @@ ValueType v; JSONSerializer::from_json(*this, v); ``` -This overloads is chosen if: +This overload is chosen if: - `ValueType` is not `basic_json`, - `json_serializer` has a `from_json()` method of the form `void from_json(const basic_json&, ValueType&)` @@ -34,7 +34,7 @@ the input parameter, allowing chaining calls Depends on what `json_serializer` `from_json()` method throws -## Example +## Examples ??? example diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/index.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/index.md new file mode 100644 index 000000000..648670144 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/index.md @@ -0,0 +1,323 @@ +# nlohmann::basic_json + +Defined in header `` + +```cpp +template< + template class ObjectType = std::map, + template class ArrayType = std::vector, + class StringType = std::string, + class BooleanType = bool, + class NumberIntegerType = std::int64_t, + class NumberUnsignedType = std::uint64_t, + class NumberFloatType = double, + template class AllocatorType = std::allocator, + template class JSONSerializer = adl_serializer, + class BinaryType = std::vector, + class CustomBaseClass = void +> +class basic_json; +``` + +## Template parameters + +| Template parameter | Description | Derived type | +|----------------------|---------------------------------------------------------------------------|---------------------------------------------| +| `ObjectType` | type for JSON objects | [`object_t`](object_t.md) | +| `ArrayType` | type for JSON arrays | [`array_t`](array_t.md) | +| `StringType` | type for JSON strings and object keys | [`string_t`](string_t.md) | +| `BooleanType` | type for JSON booleans | [`boolean_t`](boolean_t.md) | +| `NumberIntegerType` | type for JSON integer numbers | [`number_integer_t`](number_integer_t.md) | +| `NumberUnsignedType` | type for JSON unsigned integer numbers | [`number_unsigned_t`](number_unsigned_t.md) | +| `NumberFloatType` | type for JSON floating-point numbers | [`number_float_t`](number_float_t.md) | +| `AllocatorType` | type of the allocator to use | | +| `JSONSerializer` | the serializer to resolve internal calls to `to_json()` and `from_json()` | [`json_serializer`](json_serializer.md) | +| `BinaryType` | type for binary arrays | [`binary_t`](binary_t.md) | +| `CustomBaseClass` | extension point for user code | [`json_base_class_t`](json_base_class_t.md) | + +## Specializations + +- [**json**](../json.md) - default specialization +- [**ordered_json**](../ordered_json.md) - specialization that maintains the insertion order of object keys + +## Iterator invalidation + +Todo + +## Requirements + +The class satisfies the following concept requirements: + +### Basic + +- [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible): JSON values can be default + constructed. The result will be a JSON null value. +- [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible): A JSON value can be constructed + from an rvalue argument. +- [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible): A JSON value can be + copy-constructed from an lvalue expression. +- [MoveAssignable](https://en.cppreference.com/w/cpp/named_req/MoveAssignable): A JSON value can be assigned from an + rvalue argument. +- [CopyAssignable](https://en.cppreference.com/w/cpp/named_req/CopyAssignable): A JSON value can be copy-assigned from + an lvalue expression. +- [Destructible](https://en.cppreference.com/w/cpp/named_req/Destructible): JSON values can be destructed. + +### Layout + +- [StandardLayoutType](https://en.cppreference.com/w/cpp/named_req/StandardLayoutType): JSON values have + [standard layout](https://en.cppreference.com/w/cpp/language/data_members#Standard_layout): All non-static data + members are private and standard layout types, the class has no virtual functions or (virtual) base classes. + +### Library-wide + +- [EqualityComparable](https://en.cppreference.com/w/cpp/named_req/EqualityComparable): JSON values can be compared with + `==`, see [`operator==`](operator_eq.md). +- [LessThanComparable](https://en.cppreference.com/w/cpp/named_req/LessThanComparable): JSON values can be compared with + `<`, see [`operator<`](operator_le.md). +- [Swappable](https://en.cppreference.com/w/cpp/named_req/Swappable): Any JSON lvalue or rvalue of can be swapped with + any lvalue or rvalue of other compatible types, using unqualified function `swap`. +- [NullablePointer](https://en.cppreference.com/w/cpp/named_req/NullablePointer): JSON values can be compared against + `std::nullptr_t` objects which are used to model the `null` value. + +### Container + +- [Container](https://en.cppreference.com/w/cpp/named_req/Container): JSON values can be used like STL containers and + provide iterator access. +- [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer): JSON values can be used like + STL containers and provide reverse iterator access. + +## Member types + +- [**adl_serializer**](../adl_serializer/index.md) - the default serializer +- [**value_t**](value_t.md) - the JSON type enumeration +- [**json_pointer**](../json_pointer/index.md) - JSON Pointer implementation +- [**json_serializer**](json_serializer.md) - type of the serializer to for conversions from/to JSON +- [**error_handler_t**](error_handler_t.md) - type to choose behavior on decoding errors +- [**cbor_tag_handler_t**](cbor_tag_handler_t.md) - type to choose how to handle CBOR tags +- **initializer_list_t** - type for initializer lists of `basic_json` values +- [**input_format_t**](input_format_t.md) - type to choose the format to parse +- [**json_sax_t**](../json_sax/index.md) - type for SAX events + +### Exceptions + +- [**exception**](exception.md) - general exception of the `basic_json` class + - [**parse_error**](parse_error.md) - exception indicating a parse error + - [**invalid_iterator**](invalid_iterator.md) - exception indicating errors with iterators + - [**type_error**](type_error.md) - exception indicating executing a member function with a wrong type + - [**out_of_range**](out_of_range.md) - exception indicating access out of the defined range + - [**other_error**](other_error.md) - exception indicating other library errors + +### Container types + +| Type | Definition | +|--------------------------|-----------------------------------------------------------------------------------------------------------| +| `value_type` | `#!cpp basic_json` | +| `reference` | `#!cpp value_type&` | +| `const_reference` | `#!cpp const value_type&` | +| `difference_type` | `#!cpp std::ptrdiff_t` | +| `size_type` | `#!cpp std::size_t` | +| `allocator_type` | `#!cpp AllocatorType` | +| `pointer` | `#!cpp std::allocator_traits::pointer` | +| `const_pointer` | `#!cpp std::allocator_traits::const_pointer` | +| `iterator` | [LegacyBidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator) | +| `const_iterator` | constant [LegacyBidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator) | +| `reverse_iterator` | reverse iterator, derived from `iterator` | +| `const_reverse_iterator` | reverse iterator, derived from `const_iterator` | +| `iteration_proxy` | helper type for [`items`](items.md) function | + +### JSON value data types + +- [**array_t**](array_t.md) - type for arrays +- [**binary_t**](binary_t.md) - type for binary arrays +- [**boolean_t**](boolean_t.md) - type for booleans +- [**default_object_comparator_t**](default_object_comparator_t.md) - default comparator for objects +- [**number_float_t**](number_float_t.md) - type for numbers (floating-point) +- [**number_integer_t**](number_integer_t.md) - type for numbers (integer) +- [**number_unsigned_t**](number_unsigned_t.md) - type for numbers (unsigned) +- [**object_comparator_t**](object_comparator_t.md) - comparator for objects +- [**object_t**](object_t.md) - type for objects +- [**string_t**](string_t.md) - type for strings + +### Parser callback + +- [**parse_event_t**](parse_event_t.md) - parser event types +- [**parser_callback_t**](parser_callback_t.md) - per-element parser callback type + +## Member functions + +- [(constructor)](basic_json.md) +- [(destructor)](~basic_json.md) +- [**operator=**](operator=.md) - copy assignment +- [**array**](array_t.md) (_static_) - explicitly create an array +- [**binary**](binary.md) (_static_) - explicitly create a binary array +- [**object**](object_t.md) (_static_) - explicitly create an object + +### Object inspection + +Functions to inspect the type of a JSON value. + +- [**type**](type.md) - return the type of the JSON value +- [**operator value_t**](operator_value_t.md) - return the type of the JSON value +- [**type_name**](type_name.md) - return the type as string +- [**is_primitive**](is_primitive.md) - return whether type is primitive +- [**is_structured**](is_structured.md) - return whether type is structured +- [**is_null**](is_null.md) - return whether value is null +- [**is_boolean**](is_boolean.md) - return whether value is a boolean +- [**is_number**](is_number.md) - return whether value is a number +- [**is_number_integer**](is_number_integer.md) - return whether value is an integer number +- [**is_number_unsigned**](is_number_unsigned.md) - return whether value is an unsigned integer number +- [**is_number_float**](is_number_float.md) - return whether value is a floating-point number +- [**is_object**](is_object.md) - return whether value is an object +- [**is_array**](is_array.md) - return whether value is an array +- [**is_string**](is_string.md) - return whether value is a string +- [**is_binary**](is_binary.md) - return whether value is a binary array +- [**is_discarded**](is_discarded.md) - return whether value is discarded + +### Value access + +Direct access to the stored value of a JSON value. + +- [**get**](get.md) - get a value +- [**get_to**](get_to.md) - get a value and write it to a destination +- [**get_ptr**](get_ptr.md) - get a pointer value +- [**get_ref**](get_ref.md) - get a reference value +- [**operator ValueType**](operator_ValueType.md) - get a value +- [**get_binary**](get_binary.md) - get a binary value + +### Element access + +Access to the JSON value + +- [**at**](at.md) - access specified element with bounds checking +- [**operator[]**](operator[].md) - access specified element +- [**value**](value.md) - access specified object element with default value +- [**front**](front.md) - access the first element +- [**back**](back.md) - access the last element + +### Lookup + +- [**find**](find.md) - find an element in a JSON object +- [**count**](count.md) - returns the number of occurrences of a key in a JSON object +- [**contains**](contains.md) - check the existence of an element in a JSON object + +### Iterators + +- [**begin**](begin.md) - returns an iterator to the first element +- [**cbegin**](cbegin.md) - returns a const iterator to the first element +- [**end**](end.md) - returns an iterator to one past the last element +- [**cend**](cend.md) - returns a const iterator to one past the last element +- [**rbegin**](rbegin.md) - returns an iterator to the reverse-beginning +- [**rend**](rend.md) - returns an iterator to the reverse-end +- [**crbegin**](crbegin.md) - returns a const iterator to the reverse-beginning +- [**crend**](crend.md) - returns a const iterator to the reverse-end +- [**items**](items.md) - wrapper to access iterator member functions in range-based for + +### Capacity + +- [**empty**](empty.md) - checks whether the container is empty +- [**size**](size.md) - returns the number of elements +- [**max_size**](max_size.md) - returns the maximum possible number of elements + +### Modifiers + +- [**clear**](clear.md) - clears the contents +- [**push_back**](push_back.md) - add a value to an array/object +- [**operator+=**](operator+=.md) - add a value to an array/object +- [**emplace_back**](emplace_back.md) - add a value to an array +- [**emplace**](emplace.md) - add a value to an object if key does not exist +- [**erase**](erase.md) - remove elements +- [**insert**](insert.md) - inserts elements +- [**update**](update.md) - updates a JSON object from another object, overwriting existing keys +- [**swap**](swap.md) - exchanges the values + +### Lexicographical comparison operators + +- [**operator==**](operator_eq.md) - comparison: equal +- [**operator!=**](operator_ne.md) - comparison: not equal +- [**operator<**](operator_lt.md) - comparison: less than +- [**operator>**](operator_gt.md) - comparison: greater than +- [**operator<=**](operator_le.md) - comparison: less than or equal +- [**operator>=**](operator_ge.md) - comparison: greater than or equal +- [**operator<=>**](operator_spaceship.md) - comparison: 3-way + +### Serialization / Dumping + +- [**dump**](dump.md) - serialization + +### Deserialization / Parsing + +- [**parse**](parse.md) (_static_) - deserialize from a compatible input +- [**accept**](accept.md) (_static_) - check if the input is valid JSON +- [**sax_parse**](sax_parse.md) (_static_) - generate SAX events + +### JSON Pointer functions + +- [**flatten**](flatten.md) - return flattened JSON value +- [**unflatten**](unflatten.md) - unflatten a previously flattened JSON value + +### JSON Patch functions + +- [**patch**](patch.md) - applies a JSON patch +- [**patch_inplace**](patch_inplace.md) - applies a JSON patch in place +- [**diff**](diff.md) (_static_) - creates a diff as a JSON patch + +### JSON Merge Patch functions + +- [**merge_patch**](merge_patch.md) - applies a JSON Merge Patch + +## Static functions + +- [**meta**](meta.md) - returns version information on the library +- [**get_allocator**](get_allocator.md) - returns the allocator associated with the container + +### Binary formats + +- [**from_bjdata**](from_bjdata.md) (_static_) - create a JSON value from an input in BJData format +- [**from_bson**](from_bson.md) (_static_) - create a JSON value from an input in BSON format +- [**from_cbor**](from_cbor.md) (_static_) - create a JSON value from an input in CBOR format +- [**from_msgpack**](from_msgpack.md) (_static_) - create a JSON value from an input in MessagePack format +- [**from_ubjson**](from_ubjson.md) (_static_) - create a JSON value from an input in UBJSON format +- [**to_bjdata**](to_bjdata.md) (_static_) - create a BJData serialization of a given JSON value +- [**to_bson**](to_bson.md) (_static_) - create a BSON serialization of a given JSON value +- [**to_cbor**](to_cbor.md) (_static_) - create a CBOR serialization of a given JSON value +- [**to_msgpack**](to_msgpack.md) (_static_) - create a MessagePack serialization of a given JSON value +- [**to_ubjson**](to_ubjson.md) (_static_) - create a UBJSON serialization of a given JSON value + +## Non-member functions + +- [**operator<<(std::ostream&)**](../operator_ltlt.md) - serialize to stream +- [**operator>>(std::istream&)**](../operator_gtgt.md) - deserialize from stream +- [**to_string**](to_string.md) - user-defined `to_string` function for JSON values + +## Literals + +- [**operator""_json**](../operator_literal_json.md) - user-defined string literal for JSON values + +## Helper classes + +- [**std::hash<basic_json>**](std_hash.md) - return a hash value for a JSON object +- [**std::swap<basic_json>**](std_swap.md) - exchanges the values of two JSON objects + +## Examples + +??? example + + The example shows how the library is used. + + ```cpp + --8<-- "examples/README.cpp" + ``` + + Output: + + ```json + --8<-- "examples/README.output" + ``` + +## See also + +- [RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format](https://tools.ietf.org/html/rfc8259) + +## Version history + +- Added in version 1.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/input_format_t.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/input_format_t.md new file mode 100644 index 000000000..a3baabab8 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/input_format_t.md @@ -0,0 +1,52 @@ +# nlohmann::basic_json::input_format_t + +```cpp +enum class input_format_t { + json, + cbor, + msgpack, + ubjson, + bson, + bjdata +}; +``` + +This enumeration is used in the [`sax_parse`](sax_parse.md) function to choose the input format to parse: + +json +: JSON (JavaScript Object Notation) + +cbor +: CBOR (Concise Binary Object Representation) + +msgpack +: MessagePack + +ubjson +: UBJSON (Universal Binary JSON) + +bson +: BSON (Binary JSON) + +bjdata +: BJData (Binary JData) + +## Examples + +??? example + + The example below shows how an `input_format_t` enum value is passed to `sax_parse` to set the input format to CBOR. + + ```cpp + --8<-- "examples/sax_parse__binary.cpp" + ``` + + Output: + + ```json + --8<-- "examples/sax_parse__binary.output" + ``` + +## Version history + +- Added in version 3.2.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/insert.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/insert.md similarity index 85% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/insert.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/insert.md index fbd466852..2e6b29301 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/insert.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/insert.md @@ -1,4 +1,4 @@ -# basic_json::insert +# nlohmann::basic_json::insert ```cpp // (1) @@ -18,11 +18,11 @@ iterator insert(const_iterator pos, initializer_list_t ilist); void insert(const_iterator first, const_iterator last); ``` -1. Inserts element `val` to array before iterator `pos`. -2. Inserts `cnt` copies of `val` to array before iterator `pos`. -3. Inserts elements from range `[first, last)` to array before iterator `pos`. -4. Inserts elements from initializer list `ilist` to array before iterator `pos`. -5. Inserts elements from range `[first, last)` to object. +1. Inserts element `val` into array before iterator `pos`. +2. Inserts `cnt` copies of `val` into array before iterator `pos`. +3. Inserts elements from range `[first, last)` into array before iterator `pos`. +4. Inserts elements from initializer list `ilist` into array before iterator `pos`. +5. Inserts elements from range `[first, last)` into object. ## Parameters @@ -50,7 +50,11 @@ void insert(const_iterator first, const_iterator last); 2. iterator pointing to the first element inserted, or `pos` if `#!cpp cnt==0` 3. iterator pointing to the first element inserted, or `pos` if `#!cpp first==last` 4. iterator pointing to the first element inserted, or `pos` if `ilist` is empty -5. / +5. (none) + +## Exception safety + +Strong exception safety: if an exception occurs, the original value stays intact. ## Exceptions @@ -59,12 +63,12 @@ void insert(const_iterator first, const_iterator last); arrays; example: `"cannot use insert() with string"` - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"` -2. The function can throw thw following exceptions: +2. The function can throw the following exceptions: - Throws [`type_error.309`](../../home/exceptions.md#jsonexceptiontype_error309) if called on JSON values other than arrays; example: `"cannot use insert() with string"` - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"` -3. The function can throw thw following exceptions: +3. The function can throw the following exceptions: - Throws [`type_error.309`](../../home/exceptions.md#jsonexceptiontype_error309) if called on JSON values other than arrays; example: `"cannot use insert() with string"` - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an @@ -73,12 +77,12 @@ void insert(const_iterator first, const_iterator last); do not belong to the same JSON value; example: `"iterators do not fit"` - Throws [`invalid_iterator.211`](../../home/exceptions.md#jsonexceptioninvalid_iterator211) if `first` or `last` are iterators into container for which insert is called; example: `"passed iterators may not belong to container"` -4. The function can throw thw following exceptions: +4. The function can throw the following exceptions: - Throws [`type_error.309`](../../home/exceptions.md#jsonexceptiontype_error309) if called on JSON values other than arrays; example: `"cannot use insert() with string"` - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"` -5. The function can throw thw following exceptions: +5. The function can throw the following exceptions: - Throws [`type_error.309`](../../home/exceptions.md#jsonexceptiontype_error309) if called on JSON values other than objects; example: `"cannot use insert() with string"` - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an @@ -86,10 +90,6 @@ void insert(const_iterator first, const_iterator last); - Throws [`invalid_iterator.210`](../../home/exceptions.md#jsonexceptioninvalid_iterator210) if `first` and `last` do not belong to the same JSON value; example: `"iterators do not fit"` -## Exception safety - -Strong exception safety: if an exception occurs, the original value stays intact. - ## Complexity 1. Constant plus linear in the distance between `pos` and end of the container. @@ -98,9 +98,9 @@ Strong exception safety: if an exception occurs, the original value stays intact 4. Linear in `ilist.size()` plus linear in the distance between `pos` and end of the container. 5. Logarithmic: `O(N*log(size() + N))`, where `N` is the number of elements to insert. -## Example +## Examples -??? example +??? example "Example (1): insert element into array" The example shows how `insert()` is used. @@ -114,7 +114,7 @@ Strong exception safety: if an exception occurs, the original value stays intact --8<-- "examples/insert.output" ``` -??? example +??? example "Example (2): insert copies of element into array" The example shows how `insert()` is used. @@ -128,7 +128,7 @@ Strong exception safety: if an exception occurs, the original value stays intact --8<-- "examples/insert__count.output" ``` -??? example +??? example "Example (3): insert range of elements into array" The example shows how `insert()` is used. @@ -142,7 +142,7 @@ Strong exception safety: if an exception occurs, the original value stays intact --8<-- "examples/insert__range.output" ``` -??? example +??? example "Example (4): insert elements from initializer list into array" The example shows how `insert()` is used. @@ -156,7 +156,7 @@ Strong exception safety: if an exception occurs, the original value stays intact --8<-- "examples/insert__ilist.output" ``` -??? example +??? example "Example (5): insert range of elements into object" The example shows how `insert()` is used. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/invalid_iterator.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/invalid_iterator.md new file mode 100644 index 000000000..f9fdce5b4 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/invalid_iterator.md @@ -0,0 +1,67 @@ +# nlohmann::basic_json::invalid_iterator + +```cpp +class invalid_iterator : public exception; +``` + +This exception is thrown if iterators passed to a library function do not match the expected semantics. + +Exceptions have ids 2xx (see [list of iterator errors](../../home/exceptions.md#iterator-errors)). + +```plantuml +std::exception <|-- basic_json::exception +basic_json::exception <|-- basic_json::parse_error +basic_json::exception <|-- basic_json::invalid_iterator +basic_json::exception <|-- basic_json::type_error +basic_json::exception <|-- basic_json::out_of_range +basic_json::exception <|-- basic_json::other_error + +interface std::exception {} + +class basic_json::exception { + + const int id + + const char* what() const +} + +class basic_json::parse_error { + + const std::size_t byte +} + +class basic_json::invalid_iterator #FFFF00 {} +``` + +## Member functions + +- **what** - returns explanatory string + +## Member variables + +- **id** - the id of the exception + +## Examples + +??? example + + The following code shows how a `invalid_iterator` exception can be caught. + + ```cpp + --8<-- "examples/invalid_iterator.cpp" + ``` + + Output: + + ```json + --8<-- "examples/invalid_iterator.output" + ``` + +## See also + +- [List of iterator errors](../../home/exceptions.md#iterator-errors) +- [`parse_error`](parse_error.md) for exceptions indicating a parse error +- [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type +- [`out_of_range`](out_of_range.md) for exceptions indicating access out of the defined range +- [`other_error`](other_error.md) for exceptions indicating other library errors + +## Version history + +- Since version 3.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_array.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_array.md similarity index 90% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/is_array.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/is_array.md index a30379561..64468c357 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_array.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_array.md @@ -1,4 +1,4 @@ -# basic_json::is_array +# nlohmann::basic_json::is_array ```cpp constexpr bool is_array() const noexcept; @@ -18,7 +18,7 @@ No-throw guarantee: this member function never throws exceptions. Constant. -## Example +## Examples ??? example diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_binary.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_binary.md similarity index 90% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/is_binary.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/is_binary.md index f2285bb59..ea48d745c 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_binary.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_binary.md @@ -1,4 +1,4 @@ -# basic_json::is_binary +# nlohmann::basic_json::is_binary ```cpp constexpr bool is_binary() const noexcept; @@ -18,7 +18,7 @@ No-throw guarantee: this member function never throws exceptions. Constant. -## Example +## Examples ??? example diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_boolean.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_boolean.md similarity index 91% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/is_boolean.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/is_boolean.md index 32bb8c458..dc41d84bd 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_boolean.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_boolean.md @@ -1,4 +1,4 @@ -# basic_json::is_boolean +# nlohmann::basic_json::is_boolean ```cpp constexpr bool is_boolean() const noexcept; @@ -18,7 +18,7 @@ No-throw guarantee: this member function never throws exceptions. Constant. -## Example +## Examples ??? example diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_discarded.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_discarded.md similarity index 89% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/is_discarded.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/is_discarded.md index b733f623c..663cbf889 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_discarded.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_discarded.md @@ -1,4 +1,4 @@ -# basic_json::is_discarded +# nlohmann::basic_json::is_discarded ```cpp constexpr bool is_discarded() const noexcept; @@ -24,7 +24,7 @@ Constant. ## Notes -!!! note +!!! note "Comparisons" Discarded values are never compared equal with [`operator==`](operator_eq.md). That is, checking whether a JSON value `j` is discarded will only work via: @@ -41,17 +41,17 @@ Constant. will always be `#!cpp false`. -!!! note +!!! note "Removal during parsing with callback functions" When a value is discarded by a callback function (see [`parser_callback_t`](parser_callback_t.md)) during parsing, - then it is removed when it is part of a structured value. For instance, if the second value of an array is discared, + then it is removed when it is part of a structured value. For instance, if the second value of an array is discarded, instead of `#!json [null, discarded, false]`, the array `#!json [null, false]` is returned. Only if the top-level value is discarded, the return value of the `parse` call is discarded. This function will always be `#!cpp false` for JSON values after parsing. That is, discarded values can only occur during parsing, but will be removed when inside a structured value or replaced by null in other cases. -## Example +## Examples ??? example diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_null.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_null.md similarity index 91% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/is_null.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/is_null.md index 8072642a9..d080ad32f 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_null.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_null.md @@ -1,4 +1,4 @@ -# basic_json::is_null +# nlohmann::basic_json::is_null ```cpp constexpr bool is_null() const noexcept; @@ -18,7 +18,7 @@ No-throw guarantee: this member function never throws exceptions. Constant. -## Example +## Examples ??? example diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/is_number.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_number.md new file mode 100644 index 000000000..9807911bc --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_number.md @@ -0,0 +1,56 @@ +# nlohmann::basic_json::is_number + +```cpp +constexpr bool is_number() const noexcept; +``` + +This function returns `#!cpp true` if and only if the JSON value is a number. This includes both integer (signed and +unsigned) and floating-point values. + +## Return value + +`#!cpp true` if type is number (regardless whether integer, unsigned integer or floating-type), `#!cpp false` otherwise. + +## Exception safety + +No-throw guarantee: this member function never throws exceptions. + +## Complexity + +Constant. + +## Possible implementation + +```cpp +constexpr bool is_number() const noexcept +{ + return is_number_integer() || is_number_float(); +} +``` + +## Examples + +??? example + + The following code exemplifies `is_number()` for all JSON types. + + ```cpp + --8<-- "examples/is_number.cpp" + ``` + + Output: + + ```json + --8<-- "examples/is_number.output" + ``` + +## See also + +- [is_number_integer()](is_number_integer.md) check if value is an integer or unsigned integer number +- [is_number_unsigned()](is_number_unsigned.md) check if value is an unsigned integer number +- [is_number_float()](is_number_float.md) check if value is a floating-point number + +## Version history + +- Added in version 1.0.0. +- Extended to also return `#!cpp true` for unsigned integers in 2.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/is_number_float.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_number_float.md new file mode 100644 index 000000000..68d0cfb01 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_number_float.md @@ -0,0 +1,46 @@ +# nlohmann::basic_json::is_number_float + +```cpp +constexpr bool is_number_float() const noexcept; +``` + +This function returns `#!cpp true` if and only if the JSON value is a floating-point number. This excludes signed and +unsigned integer values. + +## Return value + +`#!cpp true` if type is a floating-point number, `#!cpp false` otherwise. + +## Exception safety + +No-throw guarantee: this member function never throws exceptions. + +## Complexity + +Constant. + +## Examples + +??? example + + The following code exemplifies `is_number_float()` for all JSON types. + + ```cpp + --8<-- "examples/is_number_float.cpp" + ``` + + Output: + + ```json + --8<-- "examples/is_number_float.output" + ``` + +## See also + +- [is_number()](is_number.md) check if value is a number +- [is_number_integer()](is_number_integer.md) check if value is an integer or unsigned integer number +- [is_number_unsigned()](is_number_unsigned.md) check if value is an unsigned integer number + +## Version history + +- Added in version 1.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/is_number_integer.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_number_integer.md new file mode 100644 index 000000000..8ca214aed --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_number_integer.md @@ -0,0 +1,47 @@ +# nlohmann::basic_json::is_number_integer + +```cpp +constexpr bool is_number_integer() const noexcept; +``` + +This function returns `#!cpp true` if and only if the JSON value is a signed or unsigned integer number. This excludes +floating-point values. + +## Return value + +`#!cpp true` if type is an integer or unsigned integer number, `#!cpp false` otherwise. + +## Exception safety + +No-throw guarantee: this member function never throws exceptions. + +## Complexity + +Constant. + +## Examples + +??? example + + The following code exemplifies `is_number_integer()` for all JSON types. + + ```cpp + --8<-- "examples/is_number_integer.cpp" + ``` + + Output: + + ```json + --8<-- "examples/is_number_integer.output" + ``` + +## See also + +- [is_number()](is_number.md) check if value is a number +- [is_number_unsigned()](is_number_unsigned.md) check if value is an unsigned integer number +- [is_number_float()](is_number_float.md) check if value is a floating-point number + +## Version history + +- Added in version 1.0.0. +- Extended to also return `#!cpp true` for unsigned integers in 2.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/is_number_unsigned.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_number_unsigned.md new file mode 100644 index 000000000..2ac98a5f0 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_number_unsigned.md @@ -0,0 +1,46 @@ +# nlohmann::basic_json::is_number_unsigned + +```cpp +constexpr bool is_number_unsigned() const noexcept; +``` + +This function returns `#!cpp true` if and only if the JSON value is an unsigned integer number. This excludes +floating-point and signed integer values. + +## Return value + +`#!cpp true` if type is an unsigned integer number, `#!cpp false` otherwise. + +## Exception safety + +No-throw guarantee: this member function never throws exceptions. + +## Complexity + +Constant. + +## Examples + +??? example + + The following code exemplifies `is_number_unsigned()` for all JSON types. + + ```cpp + --8<-- "examples/is_number_unsigned.cpp" + ``` + + Output: + + ```json + --8<-- "examples/is_number_unsigned.output" + ``` + +## See also + +- [is_number()](is_number.md) check if value is a number +- [is_number_integer()](is_number_integer.md) check if value is an integer or unsigned integer number +- [is_number_float()](is_number_float.md) check if value is a floating-point number + +## Version history + +- Added in version 2.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_object.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_object.md similarity index 90% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/is_object.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/is_object.md index 22a15634c..04457013b 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_object.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_object.md @@ -1,4 +1,4 @@ -# basic_json::is_object +# nlohmann::basic_json::is_object ```cpp constexpr bool is_object() const noexcept; @@ -18,7 +18,7 @@ No-throw guarantee: this member function never throws exceptions. Constant. -## Example +## Examples ??? example diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/is_primitive.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_primitive.md new file mode 100644 index 000000000..cf6cbbd4c --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_primitive.md @@ -0,0 +1,69 @@ +# nlohmann::basic_json::is_primitive + +```cpp +constexpr bool is_primitive() const noexcept; +``` + +This function returns `#!cpp true` if and only if the JSON type is primitive (string, number, boolean, `#!json null`, +binary). + +## Return value + +`#!cpp true` if type is primitive (string, number, boolean, `#!json null`, or binary), `#!cpp false` otherwise. + +## Exception safety + +No-throw guarantee: this member function never throws exceptions. + +## Complexity + +Constant. + +## Possible implementation + +```cpp +constexpr bool is_primitive() const noexcept +{ + return is_null() || is_string() || is_boolean() || is_number() || is_binary(); +} +``` + +## Notes + +The term *primitive* stems from [RFC 8259](https://tools.ietf.org/html/rfc8259): + +> JSON can represent four primitive types (strings, numbers, booleans, and null) and two structured types (objects and +> arrays). + +This library extends primitive types to binary types, because binary types are roughly comparable to strings. Hence, +`is_primitive()` returns `#!cpp true` for binary values. + +## Examples + +??? example + + The following code exemplifies `is_primitive()` for all JSON types. + + ```cpp + --8<-- "examples/is_primitive.cpp" + ``` + + Output: + + ```json + --8<-- "examples/is_primitive.output" + ``` + +## See also + +- [is_structured()](is_structured.md) returns whether JSON value is structured +- [is_null()](is_null.md) returns whether JSON value is `null` +- [is_string()](is_string.md) returns whether JSON value is a string +- [is_boolean()](is_boolean.md) returns whether JSON value is a boolean +- [is_number()](is_number.md) returns whether JSON value is a number +- [is_binary()](is_binary.md) returns whether JSON value is a binary array + +## Version history + +- Added in version 1.0.0. +- Extended to return `#!cpp true` for binary types in version 3.8.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_string.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_string.md similarity index 90% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/is_string.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/is_string.md index af725fb87..b82c92465 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/is_string.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_string.md @@ -1,4 +1,4 @@ -# basic_json::is_string +# nlohmann::basic_json::is_string ```cpp constexpr bool is_string() const noexcept; @@ -18,7 +18,7 @@ No-throw guarantee: this member function never throws exceptions. Constant. -## Example +## Examples ??? example diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/is_structured.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_structured.md new file mode 100644 index 000000000..f8fe4dcba --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/is_structured.md @@ -0,0 +1,63 @@ +# nlohmann::basic_json::is_structured + +```cpp +constexpr bool is_structured() const noexcept; +``` + +This function returns `#!cpp true` if and only if the JSON type is structured (array or object). + +## Return value + +`#!cpp true` if type is structured (array or object), `#!cpp false` otherwise. + +## Exception safety + +No-throw guarantee: this member function never throws exceptions. + +## Complexity + +Constant. + +## Possible implementation + +```cpp +constexpr bool is_primitive() const noexcept +{ + return is_array() || is_object(); +} +``` + +## Notes + +The term *structured* stems from [RFC 8259](https://tools.ietf.org/html/rfc8259): + +> JSON can represent four primitive types (strings, numbers, booleans, and null) and two structured types (objects and +> arrays). + +Note that though strings are containers in C++, they are treated as primitive values in JSON. + +## Examples + +??? example + + The following code exemplifies `is_structured()` for all JSON types. + + ```cpp + --8<-- "examples/is_structured.cpp" + ``` + + Output: + + ```json + --8<-- "examples/is_structured.output" + ``` + +## See also + +- [is_primitive()](is_primitive.md) returns whether JSON value is primitive +- [is_array()](is_array.md) returns whether value is an array +- [is_object()](is_object.md) returns whether value is an object + +## Version history + +- Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/items.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/items.md similarity index 81% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/items.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/items.md index d5c711364..0b34ddcba 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/items.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/items.md @@ -1,11 +1,11 @@ -# basic_json::items +# nlohmann::basic_json::items ```cpp iteration_proxy items() noexcept; iteration_proxy items() const noexcept; ``` -This function allows to access `iterator::key()` and `iterator::value()` during range-based for loops. In these loops, a +This function allows accessing `iterator::key()` and `iterator::value()` during range-based for loops. In these loops, a reference to the JSON values is returned, so there is no access to the underlying iterator. For loop without `items()` function: @@ -36,7 +36,7 @@ for (auto& el : j_object.items()) } ``` -The `items()` function also allows to use +The `items()` function also allows using [structured bindings](https://en.cppreference.com/w/cpp/language/structured_binding) (C++17): ```cpp @@ -63,12 +63,12 @@ Constant. When iterating over an array, `key()` will return the index of the element as string (see example). For primitive types (e.g., numbers), `key()` returns an empty string. -!!! warning +!!! danger "Lifetime issues" - Using `items()` on temporary objects is dangerous. Make sure the object's lifetime exeeds the iteration. See + Using `items()` on temporary objects is dangerous. Make sure the object's lifetime exceeds the iteration. See for more information. -## Example +## Examples ??? example @@ -86,11 +86,15 @@ When iterating over an array, `key()` will return the index of the element as st ## Version history -- Added in version 3.0.0. +- Added `iterator_wrapper` in version 3.0.0. +- Added `items` and deprecated `iterator_wrapper` in version 3.1.0. - Added structured binding support in version 3.5.0. -!!! note +!!! warning "Deprecation" This function replaces the static function `iterator_wrapper` which was introduced in version 1.0.0, but has been deprecated in version 3.1.0. Function `iterator_wrapper` will be removed in version 4.0.0. Please replace all occurrences of `#!cpp iterator_wrapper(j)` with `#!cpp j.items()`. + + You should be warned by your compiler with a `-Wdeprecated-declarations` warning if you are using a deprecated + function. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/json_base_class_t.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/json_base_class_t.md new file mode 100644 index 000000000..75752049f --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/json_base_class_t.md @@ -0,0 +1,45 @@ +# nlohmann::basic_json::json_base_class_t + +```cpp +using json_base_class_t = detail::json_base_class; +``` + +The base class used to inject custom functionality into each instance of `basic_json`. +Examples of such functionality might be metadata, additional member functions (e.g., visitors), or other application-specific code. + +## Template parameters + +`CustomBaseClass` +: the base class to be added to `basic_json` + +## Notes + +#### Default type + +The default value for `CustomBaseClass` is `void`. In this case an +[empty base class](https://en.cppreference.com/w/cpp/language/ebo) is used and no additional functionality is injected. + +#### Limitations + +The type `CustomBaseClass` has to be a default-constructible class. +`basic_json` only supports copy/move construction/assignment if `CustomBaseClass` does so as well. + +## Examples + +??? example + + The following code shows how to inject custom data and methods for each node. + + ```cpp + --8<-- "examples/json_base_class_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/json_base_class_t.output" + ``` + +## Version history + +- Added in version 3.12.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/json_serializer.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/json_serializer.md new file mode 100644 index 000000000..24a37735c --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/json_serializer.md @@ -0,0 +1,41 @@ +# nlohmann::basic_json::json_serializer + +```cpp +template +using json_serializer = JSONSerializer; +``` + +## Template parameters + +`T` +: type to convert; will be used in the `to_json`/`from_json` functions + +`SFINAE` +: type to add compile type checks via SFINAE; usually `#!cpp void` + +## Notes + +#### Default type + +The default values for `json_serializer` is [`adl_serializer`](../adl_serializer/index.md). + +## Examples + +??? example + + The example below shows how a conversion of a non-default-constructible type is implemented via a specialization of + the `adl_serializer`. + + ```cpp + --8<-- "examples/from_json__non_default_constructible.cpp" + ``` + + Output: + + ```json + --8<-- "examples/from_json__non_default_constructible.output" + ``` + +## Version history + +- Since version 2.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/max_size.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/max_size.md new file mode 100644 index 000000000..4c0c57520 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/max_size.md @@ -0,0 +1,60 @@ +# nlohmann::basic_json::max_size + +```cpp +size_type max_size() const noexcept; +``` + +Returns the maximum number of elements a JSON value is able to hold due to system or library implementation limitations, +i.e. `std::distance(begin(), end())` for the JSON value. + +## Return value + +The return value depends on the different types and is defined as follows: + +| Value type | return value | +|------------|-------------------------------------------| +| null | `0` (same as [`size()`](size.md)) | +| boolean | `1` (same as [`size()`](size.md)) | +| string | `1` (same as [`size()`](size.md)) | +| number | `1` (same as [`size()`](size.md)) | +| binary | `1` (same as [`size()`](size.md)) | +| object | result of function `object_t::max_size()` | +| array | result of function `array_t::max_size()` | + +## Exception safety + +No-throw guarantee: this function never throws exceptions. + +## Complexity + +Constant, as long as [`array_t`](array_t.md) and [`object_t`](object_t.md) satisfy the +[Container](https://en.cppreference.com/w/cpp/named_req/Container) concept; that is, their `max_size()` functions have +constant complexity. + +## Notes + +This function does not return the maximal length of a string stored as JSON value -- it returns the maximal number of +string elements the JSON value can store which is `1`. + +## Examples + +??? example + + The following code calls `max_size()` on the different value types. + + ```cpp + --8<-- "examples/max_size.cpp" + ``` + + Output: + + ```json + --8<-- "examples/max_size.output" + ``` + + Note the output is platform-dependent. + +## Version history + +- Added in version 1.0.0. +- Extended to return `1` for binary types in version 3.8.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/merge_patch.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/merge_patch.md similarity index 87% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/merge_patch.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/merge_patch.md index e865e89d8..1718c9227 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/merge_patch.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/merge_patch.md @@ -1,4 +1,4 @@ -# basic_json::merge_patch +# nlohmann::basic_json::merge_patch ```cpp void merge_patch(const basic_json& apply_patch); @@ -37,7 +37,7 @@ Thereby, `Target` is the current object; that is, the patch is applied to the cu Linear in the lengths of `apply_patch`. -## Example +## Examples ??? example @@ -53,6 +53,11 @@ Linear in the lengths of `apply_patch`. --8<-- "examples/merge_patch.output" ``` +## See also + +- [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396) +- [patch](patch.md) apply a JSON patch + ## Version history - Added in version 3.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/meta.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/meta.md new file mode 100644 index 000000000..c584f9b6d --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/meta.md @@ -0,0 +1,56 @@ +# nlohmann::basic_json::meta + +```cpp +static basic_json meta(); +``` + +This function returns a JSON object with information about the library, including the version number and information on +the platform and compiler. + +## Return value + +JSON object holding version information + +| key | description | +|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `compiler` | Information on the used compiler. It is an object with the following keys: `c++` (the used C++ standard), `family` (the compiler family; possible values are `clang`, `icc`, `gcc`, `ilecpp`, `msvc`, `pgcpp`, `sunpro`, and `unknown`), and `version` (the compiler version). | +| `copyright` | The copyright line for the library as string. | +| `name` | The name of the library as string. | +| `platform` | The used platform as string. Possible values are `win32`, `linux`, `apple`, `unix`, and `unknown`. | +| `url` | The URL of the project as string. | +| `version` | The version of the library. It is an object with the following keys: `major`, `minor`, and `patch` as defined by [Semantic Versioning](http://semver.org), and `string` (the version string). | + +## Exception safety + +Strong guarantee: if an exception is thrown, there are no changes to any JSON value. + +## Complexity + +Constant. + +## Examples + +??? example + + The following code shows an example output of the `meta()` function. + + ```cpp + --8<-- "examples/meta.cpp" + ``` + + Output: + + ```json + --8<-- "examples/meta.output" + ``` + + Note the output is platform-dependent. + +## See also + +- [**NLOHMANN_JSON_VERSION_MAJOR**/**NLOHMANN_JSON_VERSION_MINOR**/**NLOHMANN_JSON_VERSION_PATCH**](../macros/nlohmann_json_version_major.md) + \- library version information + +## Version history + +- Added in version 2.1.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/number_float_t.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/number_float_t.md similarity index 84% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/number_float_t.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/number_float_t.md index c6785eb26..50aa43b48 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/number_float_t.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/number_float_t.md @@ -1,4 +1,4 @@ -# basic_json::number_float_t +# nlohmann::basic_json::number_float_t ```cpp using number_float_t = NumberFloatType; @@ -6,7 +6,7 @@ using number_float_t = NumberFloatType; The type used to store JSON numbers (floating-point). -[RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows: +[RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows: > The representation of numbers is similar to that used in most programming languages. A number is represented in base > 10 using decimal digits. It contains an integer component that may be prefixed with an optional minus sign, which may > be followed by a fraction part and/or an exponent part. Leading zeros are not allowed. (...) Numeric values that @@ -35,7 +35,7 @@ With the default values for `NumberFloatType` (`double`), the default value for #### Limits -[RFC 7159](http://rfc7159.net/rfc7159) states: +[RFC 8259](https://tools.ietf.org/html/rfc8259) states: > This specification allows implementations to set limits on the range and precision of numbers accepted. Since software > that implements IEEE 754-2008 binary64 (double precision) numbers is generally available and widely used, good > interoperability can be achieved by implementations that expect no more precision or range than these provide, in the @@ -49,6 +49,22 @@ and be serialized to `null`. Floating-point number values are stored directly inside a `basic_json` type. +## Examples + +??? example + + The following code shows that `number_float_t` is by default, a typedef to `#!cpp double`. + + ```cpp + --8<-- "examples/number_float_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/number_float_t.output" + ``` + ## Version history - Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/number_integer_t.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/number_integer_t.md similarity index 81% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/number_integer_t.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/number_integer_t.md index c10cb7803..9bb3835a0 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/number_integer_t.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/number_integer_t.md @@ -1,4 +1,4 @@ -# basic_json::number_integer_t +# nlohmann::basic_json::number_integer_t ```cpp using number_integer_t = NumberIntegerType; @@ -6,7 +6,7 @@ using number_integer_t = NumberIntegerType; The type used to store JSON numbers (integers). -[RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows: +[RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows: > The representation of numbers is similar to that used in most programming languages. A number is represented in base > 10 using decimal digits. It contains an integer component that may be prefixed with an optional minus sign, which may > be followed by a fraction part and/or an exponent part. Leading zeros are not allowed. (...) Numeric values that @@ -36,7 +36,7 @@ With the default values for `NumberIntegerType` (`std::int64_t`), the default va #### Limits -[RFC 7159](http://rfc7159.net/rfc7159) specifies: +[RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: > An implementation may set limits on the range and precision of numbers. When the default type is used, the maximal integer number that can be stored is `9223372036854775807` (INT64_MAX) and @@ -44,8 +44,8 @@ the minimal integer number that can be stored is `-9223372036854775808` (INT64_M range will yield over/underflow when used in a constructor. During deserialization, too large or small integer numbers will be automatically be stored as [`number_unsigned_t`](number_unsigned_t.md) or [`number_float_t`](number_float_t.md). -[RFC 7159](http://rfc7159.net/rfc7159) further states: -> Note that when such software is used, numbers that are integers and are in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are +[RFC 8259](https://tools.ietf.org/html/rfc8259) further states: +> Note that when such software is used, numbers that are integers and are in the range $[-2^{53}+1, 2^{53}-1]$ are > interoperable in the sense that implementations will agree exactly on their numeric values. As this range is a subrange of the exactly supported range [INT64_MIN, INT64_MAX], this class's integer type is @@ -55,6 +55,22 @@ interoperable. Integer number values are stored directly inside a `basic_json` type. +## Examples + +??? example + + The following code shows that `number_integer_t` is by default, a typedef to `#!cpp std::int64_t`. + + ```cpp + --8<-- "examples/number_integer_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/number_integer_t.output" + ``` + ## Version history - Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/number_unsigned_t.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/number_unsigned_t.md similarity index 83% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/number_unsigned_t.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/number_unsigned_t.md index a28e25351..8a1540a57 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/number_unsigned_t.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/number_unsigned_t.md @@ -1,4 +1,4 @@ -# basic_json::number_unsigned_t +# nlohmann::basic_json::number_unsigned_t ```cpp using number_unsigned_t = NumberUnsignedType; @@ -6,7 +6,7 @@ using number_unsigned_t = NumberUnsignedType; The type used to store JSON numbers (unsigned). -[RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows: +[RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows: > The representation of numbers is similar to that used in most programming languages. A number is represented in base > 10 using decimal digits. It contains an integer component that may be prefixed with an optional minus sign, which may > be followed by a fraction part and/or an exponent part. Leading zeros are not allowed. (...) Numeric values that @@ -36,7 +36,7 @@ With the default values for `NumberUnsignedType` (`std::uint64_t`), the default #### Limits -[RFC 7159](http://rfc7159.net/rfc7159) specifies: +[RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: > An implementation may set limits on the range and precision of numbers. When the default type is used, the maximal integer number that can be stored is `18446744073709551615` (UINT64_MAX) and @@ -44,7 +44,7 @@ the minimal integer number that can be stored is `0`. Integer numbers that are o when used in a constructor. During deserialization, too large or small integer numbers will be automatically be stored as [`number_integer_t`](number_integer_t.md) or [`number_float_t`](number_float_t.md). -[RFC 7159](http://rfc7159.net/rfc7159) further states: +[RFC 8259](https://tools.ietf.org/html/rfc8259) further states: > Note that when such software is used, numbers that are integers and are in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are > interoperable in the sense that implementations will agree exactly on their numeric values. @@ -55,6 +55,22 @@ range [0, UINT64_MAX], this class's integer type is interoperable. Integer number values are stored directly inside a `basic_json` type. +## Examples + +??? example + + The following code shows that `number_unsigned_t` is by default, a typedef to `#!cpp std::uint64_t`. + + ```cpp + --8<-- "examples/number_unsigned_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/number_unsigned_t.output" + ``` + ## Version history - Added in version 2.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/object.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/object.md similarity index 86% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/object.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/object.md index 4aae6fe2a..9bdbddb6a 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/object.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/object.md @@ -1,4 +1,4 @@ -# basic_json::object +# nlohmann::basic_json::object ```cpp static basic_json object(initializer_list_t init = {}); @@ -16,6 +16,10 @@ elements must be strings. If the initializer list is empty, the empty object `#! JSON object value +## Exception safety + +Strong guarantee: if an exception is thrown, there are no changes in the JSON value. + ## Exceptions Throws [`type_error.301`](../../home/exceptions.md#jsonexceptiontype_error301) if `init` is not a list of pairs whose @@ -23,10 +27,6 @@ first elements are strings. In this case, no object can be created. When such a `basic_json(initializer_list_t, bool, value_t)`, an array would have been created from the passed initializer list `init`. See example below. -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - ## Complexity Linear in the size of `init`. @@ -53,6 +53,11 @@ the initializer list constructor `basic_json(initializer_list_t, bool, value_t)` --8<-- "examples/object.output" ``` +## See also + +- [`basic_json(initializer_list_t)`](basic_json.md) - create a JSON value from an initializer list +- [`array`](array.md) - create a JSON array value from an initializer list + ## Version history - Added in version 1.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/object_comparator_t.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/object_comparator_t.md new file mode 100644 index 000000000..d41b98229 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/object_comparator_t.md @@ -0,0 +1,32 @@ +# nlohmann::basic_json::object_comparator_t + +```cpp +using object_comparator_t = typename object_t::key_compare; +// or +using object_comparator_t = default_object_comparator_t; +``` + +The comparator used by [`object_t`](object_t.md). Defined as `#!cpp typename object_t::key_compare` if available, +and [`default_object_comparator_t`](default_object_comparator_t.md) otherwise. + +## Examples + +??? example + + The example below demonstrates the used object comparator. + + ```cpp + --8<-- "examples/object_comparator_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/object_comparator_t.output" + ``` + +## Version history + +- Added in version 3.0.0. +- Changed to be conditionally defined as `#!cpp typename object_t::key_compare` or `default_object_comparator_t` in + version 3.11.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/object_t.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/object_t.md similarity index 82% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/object_t.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/object_t.md index efc18c41f..39f68b089 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/object_t.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/object_t.md @@ -1,15 +1,15 @@ -# basic_json::object_t +# nlohmann::basic_json::object_t ```cpp using object_t = ObjectType>>; ``` The type used to store JSON objects. -[RFC 7159](http://rfc7159.net/rfc7159) describes JSON objects as follows: +[RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON objects as follows: > An object is an unordered collection of zero or more name/value pairs, where a name is a string and a value is a > string, number, boolean, null, object, or array. @@ -52,7 +52,7 @@ std::map< > ``` -See [`object_comparator_t`](object_comparator_t.md) for more information. +See [`default_object_comparator_t`](default_object_comparator_t.md) for more information. #### Behavior @@ -73,7 +73,7 @@ behavior: #### Limits -[RFC 7159](http://rfc7159.net/rfc7159) specifies: +[RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: > An implementation may set limits on the maximum depth of nesting. In this class, the object's limit of nesting is not explicitly constrained. However, a maximum depth of nesting may be @@ -90,7 +90,24 @@ Objects are stored as pointers in a `basic_json` type. That is, for any access t The order name/value pairs are added to the object is *not* preserved by the library. Therefore, iterating an object may return name/value pairs in a different order than they were originally stored. In fact, keys will be traversed in alphabetical order as `std::map` with `std::less` is used by default. Please note this behavior conforms to -[RFC 7159](http://rfc7159.net/rfc7159), because any order implements the specified "unordered" nature of JSON objects. +[RFC 8259](https://tools.ietf.org/html/rfc8259), because any order implements the specified "unordered" nature of JSON +objects. + +## Examples + +??? example + + The following code shows that `object_t` is by default, a typedef to `#!cpp std::map`. + + ```cpp + --8<-- "examples/object_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/object_t.output" + ``` ## Version history diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator+=.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator+=.md similarity index 80% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/operator+=.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/operator+=.md index 59001a58f..dc5f2ecc4 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator+=.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator+=.md @@ -1,4 +1,4 @@ -# basic_json::operator+= +# nlohmann::basic_json::operator+= ```cpp // (1) @@ -18,7 +18,7 @@ reference operator+=(initializer_list_t init); 2. Inserts the given element `val` to the JSON object. If the function is called on a JSON null value, an empty object is created before inserting `val`. -3. This function allows to use `operator+=` with an initializer list. In case +3. This function allows using `operator+=` with an initializer list. In case 1. the current value is an object, 2. the initializer list `init` contains only two elements, and @@ -41,12 +41,9 @@ reference operator+=(initializer_list_t init); ## Exceptions -1. The function can throw the following exceptions: - - Throws [`type_error.308`](../../home/exceptions.md#jsonexceptiontype_error308) when called on a type other than - JSON array or null; example: `"cannot use operator+=() with number"` -2. The function can throw the following exceptions: - - Throws [`type_error.308`](../../home/exceptions.md#jsonexceptiontype_error308) when called on a type other than - JSON object or null; example: `"cannot use operator+=() with number"` +All functions can throw the following exception: + - Throws [`type_error.308`](../../home/exceptions.md#jsonexceptiontype_error308) when called on a type other than + JSON array or null; example: `"cannot use operator+=() with number"` ## Complexity @@ -62,7 +59,7 @@ interpreted as `object_t::value_type` or `std::initializer_list`, se ## Examples -??? example +??? example "Example: (1) add element to array" The example shows how `push_back()` and `+=` can be used to add elements to a JSON array. Note how the `null` value was silently converted to a JSON array. @@ -77,7 +74,7 @@ interpreted as `object_t::value_type` or `std::initializer_list`, se --8<-- "examples/push_back.output" ``` -??? example +??? example "Example: (2) add element to object" The example shows how `push_back()` and `+=` can be used to add elements to a JSON object. Note how the `null` value was silently converted to a JSON object. @@ -92,7 +89,7 @@ interpreted as `object_t::value_type` or `std::initializer_list`, se --8<-- "examples/push_back__object_t__value.output" ``` -??? example +??? example "Example: (3) add to object from initializer list" The example shows how initializer lists are treated as objects when possible. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator=.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator=.md similarity index 94% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/operator=.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/operator=.md index 340f8eaf3..4e0b91446 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/operator=.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator=.md @@ -1,4 +1,4 @@ -# basic_json::operator= +# nlohmann::basic_json::operator= ```cpp basic_json& operator=(basic_json other) noexcept ( @@ -21,7 +21,7 @@ constructor, destructor, and the `swap()` member function. Linear. -## Example +## Examples ??? example diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/operator[].md b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator[].md new file mode 100644 index 000000000..51dd8588c --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator[].md @@ -0,0 +1,241 @@ +# nlohmann::basic_json::operator[] + +```cpp +// (1) +reference operator[](size_type idx); +const_reference operator[](size_type idx) const; + +// (2) +reference operator[](typename object_t::key_type key); +const_reference operator[](const typename object_t::key_type& key) const; + +// (3) +template +reference operator[](KeyType&& key); +template +const_reference operator[](KeyType&& key) const; + +// (4) +reference operator[](const json_pointer& ptr); +const_reference operator[](const json_pointer& ptr) const; +``` + +1. Returns a reference to the array element at specified location `idx`. +2. Returns a reference to the object element with specified key `key`. The non-const qualified overload takes the key by + value. +3. See 2. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and + `#!cpp typename object_comparator_t::is_transparent` denotes a type. +4. Returns a reference to the element with specified JSON pointer `ptr`. + +## Template parameters + +`KeyType` +: A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with + [`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md). + This can also be a string view (C++17). + +## Parameters + +`idx` (in) +: index of the element to access + +`key` (in) +: object key of the element to access + +`ptr` (in) +: JSON pointer to the desired element + +## Return value + +1. (const) reference to the element at index `idx` +2. (const) reference to the element at key `key` +3. (const) reference to the element at key `key` +4. (const) reference to the element pointed to by `ptr` + +## Exception safety + +Strong exception safety: if an exception occurs, the original value stays intact. + +## Exceptions + +1. The function can throw the following exceptions: + - Throws [`type_error.305`](../../home/exceptions.md#jsonexceptiontype_error305) if the JSON value is not an array + or null; in that case, using the `[]` operator with an index makes no sense. +2. The function can throw the following exceptions: + - Throws [`type_error.305`](../../home/exceptions.md#jsonexceptiontype_error305) if the JSON value is not an object + or null; in that case, using the `[]` operator with a key makes no sense. +3. See 2. +4. The function can throw the following exceptions: + - Throws [`parse_error.106`](../../home/exceptions.md#jsonexceptionparse_error106) if an array index in the passed + JSON pointer `ptr` begins with '0'. + - Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109) if an array index in the passed + JSON pointer `ptr` is not a number. + - Throws [`out_of_range.402`](../../home/exceptions.md#jsonexceptionout_of_range402) if the array index '-' is used + in the passed JSON pointer `ptr` for the const version. + - Throws [`out_of_range.404`](../../home/exceptions.md#jsonexceptionout_of_range404) if the JSON pointer `ptr` can + not be resolved. + +## Complexity + +1. Constant if `idx` is in the range of the array. Otherwise, linear in `idx - size()`. +2. Logarithmic in the size of the container. +3. Logarithmic in the size of the container. +4. Logarithmic in the size of the container. + +## Notes + +!!! danger "Undefined behavior and runtime assertions" + + 1. If the element with key `idx` does not exist, the behavior is undefined. + 2. If the element with key `key` does not exist, the behavior is undefined and is **guarded by a + [runtime assertion](../../features/assertions.md)**! + +1. The non-const version may add values: If `idx` is beyond the range of the array (i.e., `idx >= size()`), then the + array is silently filled up with `#!json null` values to make `idx` a valid reference to the last stored element. In + case the value was `#!json null` before, it is converted to an array. + +2. If `key` is not found in the object, then it is silently added to the object and filled with a `#!json null` value to + make `key` a valid reference. In case the value was `#!json null` before, it is converted to an object. + +3. See 2. + +4. `null` values are created in arrays and objects if necessary. + + In particular: + + - If the JSON pointer points to an object key that does not exist, it is created and filled with a `#!json null` + value before a reference to it is returned. + - If the JSON pointer points to an array index that does not exist, it is created and filled with a `#!json null` + value before a reference to it is returned. All indices between the current maximum and the given index are also + filled with `#!json null`. + - The special value `-` is treated as a synonym for the index past the end. + +## Examples + +??? example "Example: (1) access specified array element" + + The example below shows how array elements can be read and written using `[]` operator. Note the addition of + `#!json null` values. + + ```cpp + --8<-- "examples/operator_array__size_type.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator_array__size_type.output" + ``` + +??? example "Example: (1) access specified array element (const)" + + The example below shows how array elements can be read using the `[]` operator. + + ```cpp + --8<-- "examples/operator_array__size_type_const.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator_array__size_type_const.output" + ``` + +??? example "Example: (2) access specified object element" + + The example below shows how object elements can be read and written using the `[]` operator. + + ```cpp + --8<-- "examples/operator_array__object_t_key_type.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator_array__object_t_key_type.output" + ``` + +??? example "Example: (2) access specified object element (const)" + + The example below shows how object elements can be read using the `[]` operator. + + ```cpp + --8<-- "examples/operator_array__object_t_key_type_const.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator_array__object_t_key_type_const.output" + ``` + +??? example "Example: (3) access specified object element using string_view" + + The example below shows how object elements can be read using the `[]` operator. + + ```cpp + --8<-- "examples/operator_array__keytype.c++17.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator_array__keytype.c++17.output" + ``` + +??? example "Example: (3) access specified object element using string_view (const)" + + The example below shows how object elements can be read using the `[]` operator. + + ```cpp + --8<-- "examples/operator_array__keytype_const.c++17.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator_array__keytype_const.c++17.output" + ``` + +??? example "Example: (4) access specified element via JSON Pointer" + + The example below shows how values can be read and written using JSON Pointers. + + ```cpp + --8<-- "examples/operator_array__json_pointer.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator_array__json_pointer.output" + ``` + +??? example "Example: (4) access specified element via JSON Pointer (const)" + + The example below shows how values can be read using JSON Pointers. + + ```cpp + --8<-- "examples/operator_array__json_pointer_const.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator_array__json_pointer_const.output" + ``` + +## See also + +- documentation on [unchecked access](../../features/element_access/unchecked_access.md) +- documentation on [runtime assertions](../../features/assertions.md) +- see [`at`](at.md) for access by reference with range checking +- see [`value`](value.md) for access with default value + +## Version history + +1. Added in version 1.0.0. +2. Added in version 1.0.0. Added overloads for `T* key` in version 1.1.0. Removed overloads for `T* key` (replaced by 3) + in version 3.11.0. +3. Added in version 3.11.0. +4. Added in version 2.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_ValueType.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_ValueType.md new file mode 100644 index 000000000..bf38a3d21 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_ValueType.md @@ -0,0 +1,82 @@ +# nlohmann::basic_json::operator ValueType + +```cpp +template +JSON_EXPLICIT operator ValueType() const; +``` + +Implicit type conversion between the JSON value and a compatible value. The call is realized by calling +[`get()`](get.md). See [Notes](#notes) for the meaning of `JSON_EXPLICIT`. + +## Template parameters + +`ValueType` +: the value type to return + +## Return value + +copy of the JSON value, converted to `ValueType` + +## Exceptions + +Depends on what `json_serializer` `from_json()` method throws + +## Complexity + +Linear in the size of the JSON value. + +## Notes + +!!! note "Definition of `JSON_EXPLICIT`" + + By default `JSON_EXPLICIT` is defined to the empty string, so the signature is: + + ```cpp + template + operator ValueType() const; + ``` + + If [`JSON_USE_IMPLICIT_CONVERSIONS`](../macros/json_use_implicit_conversions.md) is set to `0`, + `JSON_EXPLICIT` is defined to `#!cpp explicit`: + + ```cpp + template + explicit operator ValueType() const; + ``` + + That is, implicit conversions can be switched off by defining + [`JSON_USE_IMPLICIT_CONVERSIONS`](../macros/json_use_implicit_conversions.md) to `0`. + +!!! info "Future behavior change" + + Implicit conversions will be switched off by default in the next major release of the library. That is, + `JSON_EXPLICIT` will be set to `#!cpp explicit` by default. + + You can prepare existing code by already defining + [`JSON_USE_IMPLICIT_CONVERSIONS`](../macros/json_use_implicit_conversions.md) to `0` and replace any implicit + conversions with calls to [`get`](../basic_json/get.md). + +## Examples + +??? example + + The example below shows several conversions from JSON values to other types. There are a few things to note: (1) + Floating-point numbers can be converted to integers, (2) A JSON array can be converted to a standard + `std::vector`, (3) A JSON object can be converted to C++ associative containers such as + `std::unordered_map`. + + ```cpp + --8<-- "examples/operator__ValueType.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator__ValueType.output" + ``` + +## Version history + +- Since version 1.0.0. +- Macros `JSON_EXPLICIT`/[`JSON_USE_IMPLICIT_CONVERSIONS`](../macros/json_use_implicit_conversions.md) added + in version 3.9.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_eq.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_eq.md new file mode 100644 index 000000000..a2ce6155c --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_eq.md @@ -0,0 +1,168 @@ +# nlohmann::basic_json::operator== + +```cpp +// until C++20 +bool operator==(const_reference lhs, const_reference rhs) noexcept; // (1) + +template +bool operator==(const_reference lhs, const ScalarType rhs) noexcept; // (2) + +template +bool operator==(ScalarType lhs, const const_reference rhs) noexcept; // (2) + +// since C++20 +class basic_json { + bool operator==(const_reference rhs) const noexcept; // (1) + + template + bool operator==(ScalarType rhs) const noexcept; // (2) +}; +``` + +1. Compares two JSON values for equality according to the following rules: + - Two JSON values are equal if (1) neither value is discarded, or (2) they are of the same type and their stored + values are the same according to their respective `operator==`. + - Integer and floating-point numbers are automatically converted before comparison. + +2. Compares a JSON value and a scalar or a scalar and a JSON value for equality by converting the + scalar to a JSON value and comparing both JSON values according to 1. + +## Template parameters + +`ScalarType` +: a scalar type according to `std::is_scalar::value` + +## Parameters + +`lhs` (in) +: first value to consider + +`rhs` (in) +: second value to consider + +## Return value + +whether the values `lhs`/`*this` and `rhs` are equal + +## Exception safety + +No-throw guarantee: this function never throws exceptions. + +## Complexity + +Linear. + +## Notes + +!!! note "Comparing special values" + + - `NaN` values are unordered within the domain of numbers. + The following comparisons all yield `#!cpp false`: + 1. Comparing a `NaN` with itself. + 2. Comparing a `NaN` with another `NaN`. + 3. Comparing a `NaN` and any other number. + - JSON `#!cpp null` values are all equal. + - Discarded values never compare equal to themselves. + +!!! note "Comparing floating-point numbers" + + Floating-point numbers inside JSON values numbers are compared with `json::number_float_t::operator==` which is + `double::operator==` by default. To compare floating-point while respecting an epsilon, an alternative + [comparison function](https://github.com/mariokonrad/marnav/blob/master/include/marnav/math/floatingpoint.hpp#L34-#L39) + could be used, for instance + + ```cpp + template::value, T>::type> + inline bool is_same(T a, T b, T epsilon = std::numeric_limits::epsilon()) noexcept + { + return std::abs(a - b) <= epsilon; + } + ``` + + Or you can self-defined operator equal function like this: + + ```cpp + bool my_equal(const_reference lhs, const_reference rhs) + { + const auto lhs_type lhs.type(); + const auto rhs_type rhs.type(); + if (lhs_type == rhs_type) + { + switch(lhs_type) + // self_defined case + case value_t::number_float: + return std::abs(lhs - rhs) <= std::numeric_limits::epsilon(); + // other cases remain the same with the original + ... + } + ... + } + ``` + +!!! note "Comparing different `basic_json` specializations" + + Comparing different `basic_json` specializations can have surprising effects. For instance, the result of comparing + the JSON objects + + ```json + { + "version": 1, + "type": "integer" + } + ``` + + and + + ```json + { + "type": "integer", + "version": 1 + } + ``` + + depends on whether [`nlohmann::json`](../json.md) or [`nlohmann::ordered_json`](../ordered_json.md) is used: + + ```cpp + --8<-- "examples/operator__equal__specializations.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator__equal__specializations.output" + ``` + +## Examples + +??? example + + The example demonstrates comparing several JSON types. + + ```cpp + --8<-- "examples/operator__equal.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator__equal.output" + ``` + +??? example + + The example demonstrates comparing several JSON types against the null pointer (JSON `#!json null`). + + ```cpp + --8<-- "examples/operator__equal__nullptr_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator__equal__nullptr_t.output" + ``` + +## Version history + +1. Added in version 1.0.0. Added C++20 member functions in version 3.11.0. +2. Added in version 1.0.0. Added C++20 member functions in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_ge.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_ge.md new file mode 100644 index 000000000..d4e2fb4a5 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_ge.md @@ -0,0 +1,86 @@ +# nlohmann::basic_json::operator>= + +```cpp +// until C++20 +bool operator>=(const_reference lhs, const_reference rhs) noexcept; // (1) + +template +bool operator>=(const_reference lhs, const ScalarType rhs) noexcept; // (2) + +template +bool operator>=(ScalarType lhs, const const_reference rhs) noexcept; // (2) +``` + +1. Compares whether one JSON value `lhs` is greater than or equal to another JSON value `rhs` according to the following + rules: + - The comparison always yields `#!cpp false` if (1) either operand is discarded, or (2) either operand is `NaN` and + the other operand is either `NaN` or any other number. + - Otherwise, returns the result of `#!cpp !(lhs < rhs)` (see [**operator<**](operator_lt.md)). + +2. Compares whether a JSON value is greater than or equal to a scalar or a scalar is greater than or equal to a JSON + value by converting the scalar to a JSON value and comparing both JSON values according to 1. + +## Template parameters + +`ScalarType` +: a scalar type according to `std::is_scalar::value` + +## Parameters + +`lhs` (in) +: first value to consider + +`rhs` (in) +: second value to consider + +## Return value + +whether `lhs` is less than or equal to `rhs` + +## Exception safety + +No-throw guarantee: this function never throws exceptions. + +## Complexity + +Linear. + +## Notes + +!!! note "Comparing `NaN`" + + `NaN` values are unordered within the domain of numbers. + The following comparisons all yield `#!cpp false`: + 1. Comparing a `NaN` with itself. + 2. Comparing a `NaN` with another `NaN`. + 3. Comparing a `NaN` and any other number. + +!!! note "Operator overload resolution" + + Since C++20 overload resolution will consider the _rewritten candidate_ generated from + [`operator<=>`](operator_spaceship.md). + +## Examples + +??? example + + The example demonstrates comparing several JSON types. + + ```cpp + --8<-- "examples/operator__greaterequal.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator__greaterequal.output" + ``` + +## See also + +- [**operator<=>**](operator_spaceship.md) comparison: 3-way + +## Version history + +1. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0. +2. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_gt.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_gt.md new file mode 100644 index 000000000..9516656e0 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_gt.md @@ -0,0 +1,86 @@ +# nlohmann::basic_json::operator> + +```cpp +// until C++20 +bool operator>(const_reference lhs, const_reference rhs) noexcept; // (1) + +template +bool operator>(const_reference lhs, const ScalarType rhs) noexcept; // (2) + +template +bool operator>(ScalarType lhs, const const_reference rhs) noexcept; // (2) +``` + +1. Compares whether one JSON value `lhs` is greater than another JSON value `rhs` according to the + following rules: + - The comparison always yields `#!cpp false` if (1) either operand is discarded, or (2) either + operand is `NaN` and the other operand is either `NaN` or any other number. + - Otherwise, returns the result of `#!cpp !(lhs <= rhs)` (see [**operator<=**](operator_le.md)). + +2. Compares wether a JSON value is greater than a scalar or a scalar is greater than a JSON value by + converting the scalar to a JSON value and comparing both JSON values according to 1. + +## Template parameters + +`ScalarType` +: a scalar type according to `std::is_scalar::value` + +## Parameters + +`lhs` (in) +: first value to consider + +`rhs` (in) +: second value to consider + +## Return value + +whether `lhs` is greater than `rhs` + +## Exception safety + +No-throw guarantee: this function never throws exceptions. + +## Complexity + +Linear. + +## Notes + +!!! note "Comparing `NaN`" + + `NaN` values are unordered within the domain of numbers. + The following comparisons all yield `#!cpp false`: + 1. Comparing a `NaN` with itself. + 2. Comparing a `NaN` with another `NaN`. + 3. Comparing a `NaN` and any other number. + +!!! note "Operator overload resolution" + + Since C++20 overload resolution will consider the _rewritten candidate_ generated from + [`operator<=>`](operator_spaceship.md). + +## Examples + +??? example + + The example demonstrates comparing several JSON types. + + ```cpp + --8<-- "examples/operator__greater.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator__greater.output" + ``` + +## See also + +- [**operator<=>**](operator_spaceship.md) comparison: 3-way + +## Version history + +1. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0. +2. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_le.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_le.md new file mode 100644 index 000000000..7b648e035 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_le.md @@ -0,0 +1,87 @@ +# nlohmann::basic_json::operator<= + +```cpp +// until C++20 +bool operator<=(const_reference lhs, const_reference rhs) noexcept; // (1) + +template +bool operator<=(const_reference lhs, const ScalarType rhs) noexcept; // (2) + +template +bool operator<=(ScalarType lhs, const const_reference rhs) noexcept; // (2) +``` + +1. Compares whether one JSON value `lhs` is less than or equal to another JSON value `rhs` + according to the following rules: + - The comparison always yields `#!cpp false` if (1) either operand is discarded, or (2) either + operand is `NaN` and the other operand is either `NaN` or any other number. + - Otherwise, returns the result of `#!cpp !(rhs < lhs)` (see [**operator<**](operator_lt.md)). + +1. Compares wether a JSON value is less than or equal to a scalar or a scalar is less than or equal + to a JSON value by converting the scalar to a JSON value and comparing both JSON values according + to 1. + +## Template parameters + +`ScalarType` +: a scalar type according to `std::is_scalar::value` + +## Parameters + +`lhs` (in) +: first value to consider + +`rhs` (in) +: second value to consider + +## Return value + +whether `lhs` is less than or equal to `rhs` + +## Exception safety + +No-throw guarantee: this function never throws exceptions. + +## Complexity + +Linear. + +## Notes + +!!! note "Comparing `NaN`" + + `NaN` values are unordered within the domain of numbers. + The following comparisons all yield `#!cpp false`: + 1. Comparing a `NaN` with itself. + 2. Comparing a `NaN` with another `NaN`. + 3. Comparing a `NaN` and any other number. + +!!! note "Operator overload resolution" + + Since C++20 overload resolution will consider the _rewritten candidate_ generated from + [`operator<=>`](operator_spaceship.md). + +## Examples + +??? example + + The example demonstrates comparing several JSON types. + + ```cpp + --8<-- "examples/operator__lessequal.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator__lessequal.output" + ``` + +## See also + +- [**operator<=>**](operator_spaceship.md) comparison: 3-way + +## Version history + +1. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0. +2. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_lt.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_lt.md new file mode 100644 index 000000000..b5d191ec4 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_lt.md @@ -0,0 +1,96 @@ +# nlohmann::basic_json::operator< + +```cpp +// until C++20 +bool operator<(const_reference lhs, const_reference rhs) noexcept; // (1) + +template +bool operator<(const_reference lhs, const ScalarType rhs) noexcept; // (2) + +template +bool operator<(ScalarType lhs, const const_reference rhs) noexcept; // (2) +``` + +1. Compares whether one JSON value `lhs` is less than another JSON value `rhs` according to the + following rules: + - If either operand is discarded, the comparison yields `#!cpp false`. + - If both operands have the same type, the values are compared using their respective `operator<`. + - Integer and floating-point numbers are automatically converted before comparison. + - In case `lhs` and `rhs` have different types, the values are ignored and the order of the types + is considered, which is: + 1. null + 2. boolean + 3. number (all types) + 4. object + 5. array + 6. string + 7. binary + For instance, any boolean value is considered less than any string. + +2. Compares wether a JSON value is less than a scalar or a scalar is less than a JSON value by converting + the scalar to a JSON value and comparing both JSON values according to 1. + +## Template parameters + +`ScalarType` +: a scalar type according to `std::is_scalar::value` + +## Parameters + +`lhs` (in) +: first value to consider + +`rhs` (in) +: second value to consider + +## Return value + +whether `lhs` is less than `rhs` + +## Exception safety + +No-throw guarantee: this function never throws exceptions. + +## Complexity + +Linear. + +## Notes + +!!! note "Comparing `NaN`" + + `NaN` values are unordered within the domain of numbers. + The following comparisons all yield `#!cpp false`: + 1. Comparing a `NaN` with itself. + 2. Comparing a `NaN` with another `NaN`. + 3. Comparing a `NaN` and any other number. + +!!! note "Operator overload resolution" + + Since C++20 overload resolution will consider the _rewritten candidate_ generated from + [`operator<=>`](operator_spaceship.md). + +## Examples + +??? example + + The example demonstrates comparing several JSON types. + + ```cpp + --8<-- "examples/operator__less.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator__less.output" + ``` + +## See also + +- [**operator<=>**](operator_spaceship.md) comparison: 3-way + +## Version history + +1. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0. +2. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_ne.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_ne.md new file mode 100644 index 000000000..982a06764 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_ne.md @@ -0,0 +1,98 @@ +# nlohmann::basic_json::operator!= + +```cpp +// until C++20 +bool operator!=(const_reference lhs, const_reference rhs) noexcept; // (1) + +template +bool operator!=(const_reference lhs, const ScalarType rhs) noexcept; // (2) + +template +bool operator!=(ScalarType lhs, const const_reference rhs) noexcept; // (2) + +// since C++20 +class basic_json { + bool operator!=(const_reference rhs) const noexcept; // (1) + + template + bool operator!=(ScalarType rhs) const noexcept; // (2) +}; +``` + +1. Compares two JSON values for inequality according to the following rules: + - The comparison always yields `#!cpp false` if (1) either operand is discarded, or (2) either operand is `NaN` and + the other operand is either `NaN` or any other number. + - Otherwise, returns the result of `#!cpp !(lhs == rhs)` (until C++20) or `#!cpp !(*this == rhs)` (since C++20). + +2. Compares a JSON value and a scalar or a scalar and a JSON value for inequality by converting the scalar to a JSON + value and comparing both JSON values according to 1. + +## Template parameters + +`ScalarType` +: a scalar type according to `std::is_scalar::value` + +## Parameters + +`lhs` (in) +: first value to consider + +`rhs` (in) +: second value to consider + +## Return value + +whether the values `lhs`/`*this` and `rhs` are not equal + +## Exception safety + +No-throw guarantee: this function never throws exceptions. + +## Complexity + +Linear. + +## Notes + +!!! note "Comparing `NaN`" + + `NaN` values are unordered within the domain of numbers. + The following comparisons all yield `#!cpp false`: + 1. Comparing a `NaN` with itself. + 2. Comparing a `NaN` with another `NaN`. + 3. Comparing a `NaN` and any other number. + +## Examples + +??? example + + The example demonstrates comparing several JSON types. + + ```cpp + --8<-- "examples/operator__notequal.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator__notequal.output" + ``` + +??? example + + The example demonstrates comparing several JSON types against the null pointer (JSON `#!json null`). + + ```cpp + --8<-- "examples/operator__notequal__nullptr_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator__notequal__nullptr_t.output" + ``` + +## Version history + +1. Added in version 1.0.0. Added C++20 member functions in version 3.11.0. +2. Added in version 1.0.0. Added C++20 member functions in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_spaceship.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_spaceship.md new file mode 100644 index 000000000..9e91d0d2d --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_spaceship.md @@ -0,0 +1,100 @@ +# nlohmann::basic_json::operator<=> + +```cpp +// since C++20 +class basic_json { + std::partial_ordering operator<=>(const_reference rhs) const noexcept; // (1) + + template + std::partial_ordering operator<=>(const ScalarType rhs) const noexcept; // (2) +}; +``` + +1. 3-way compares two JSON values producing a result of type `std::partial_ordering` according to the following rules: + - Two JSON values compare with a result of `std::partial_ordering::unordered` if either value is discarded. + - If both JSON values are of the same type, the result is produced by 3-way comparing their stored values using + their respective `operator<=>`. + - Integer and floating-point numbers are converted to their common type and then 3-way compared using their + respective `operator<=>`. + For instance, comparing an integer and a floating-point value will 3-way compare the first value converted to + floating-point with the second value. + - Otherwise, yields a result by comparing the type (see [`value_t`](value_t.md)). + +2. 3-way compares a JSON value and a scalar or a scalar and a JSON value by converting the scalar to a JSON value and + 3-way comparing both JSON values (see 1). + +## Template parameters + +`ScalarType` +: a scalar type according to `std::is_scalar::value` + +## Parameters + +`rhs` (in) +: second value to consider + +## Return value + +the `std::partial_ordering` of the 3-way comparison of `*this` and `rhs` + +## Exception safety + +No-throw guarantee: this function never throws exceptions. + +## Complexity + +Linear. + +## Notes + +!!! note "Comparing `NaN`" + + - `NaN` values are unordered within the domain of numbers. + The following comparisons all yield `std::partial_ordering::unordered`: + 1. Comparing a `NaN` with itself. + 2. Comparing a `NaN` with another `NaN`. + 3. Comparing a `NaN` and any other number. + +## Examples + +??? example "Example: (1) comparing JSON values" + + The example demonstrates comparing several JSON values. + + ```cpp + --8<-- "examples/operator_spaceship__const_reference.c++20.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator_spaceship__const_reference.c++20.output" + ``` + +??? example "Example: (2) comparing JSON values and scalars" + + The example demonstrates comparing several JSON values and scalars. + + ```cpp + --8<-- "examples/operator_spaceship__scalartype.c++20.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator_spaceship__scalartype.c++20.output" + ``` + +## See also + +- [**operator==**](operator_eq.md) - comparison: equal +- [**operator!=**](operator_ne.md) - comparison: not equal +- [**operator<**](operator_lt.md) - comparison: less than +- [**operator<=**](operator_le.md) - comparison: less than or equal +- [**operator>**](operator_gt.md) - comparison: greater than +- [**operator>=**](operator_ge.md) - comparison: greater than or equal + +## Version history + +1. Added in version 3.11.0. +2. Added in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_value_t.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_value_t.md new file mode 100644 index 000000000..0f08f42b0 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/operator_value_t.md @@ -0,0 +1,54 @@ +# nlohmann::basic_json::operator value_t + +```cpp +constexpr operator value_t() const noexcept; +``` + +Return the type of the JSON value as a value from the [`value_t`](value_t.md) enumeration. + +## Return value + +the type of the JSON value + +| Value type | return value | +|---------------------------|----------------------------| +| `#!json null` | `value_t::null` | +| boolean | `value_t::boolean` | +| string | `value_t::string` | +| number (integer) | `value_t::number_integer` | +| number (unsigned integer) | `value_t::number_unsigned` | +| number (floating-point) | `value_t::number_float` | +| object | `value_t::object` | +| array | `value_t::array` | +| binary | `value_t::binary` | +| discarded | `value_t::discarded` | + +## Exception safety + +No-throw guarantee: this member function never throws exceptions. + +## Complexity + +Constant. + +## Examples + +??? example + + The following code exemplifies `operator value_t()` for all JSON types. + + ```cpp + --8<-- "examples/operator__value_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator__value_t.output" + ``` + +## Version history + +- Added in version 1.0.0. +- Added unsigned integer type in version 2.0.0. +- Added binary type in version 3.8.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/other_error.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/other_error.md new file mode 100644 index 000000000..9a83340a0 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/other_error.md @@ -0,0 +1,67 @@ +# nlohmann::basic_json::other_error + +```cpp +class other_error : public exception; +``` + +This exception is thrown in case of errors that cannot be classified with the other exception types. + +Exceptions have ids 5xx (see [list of other errors](../../home/exceptions.md#further-exceptions)). + +```plantuml +std::exception <|-- basic_json::exception +basic_json::exception <|-- basic_json::parse_error +basic_json::exception <|-- basic_json::invalid_iterator +basic_json::exception <|-- basic_json::type_error +basic_json::exception <|-- basic_json::out_of_range +basic_json::exception <|-- basic_json::other_error + +interface std::exception {} + +class basic_json::exception { + + const int id + + const char* what() const +} + +class basic_json::parse_error { + + const std::size_t byte +} + +class basic_json::other_error #FFFF00 {} +``` + +## Member functions + +- **what** - returns explanatory string + +## Member variables + +- **id** - the id of the exception + +## Examples + +??? example + + The following code shows how a `other_error` exception can be caught. + + ```cpp + --8<-- "examples/other_error.cpp" + ``` + + Output: + + ```json + --8<-- "examples/other_error.output" + ``` + +## See also + +- [List of other errors](../../home/exceptions.md#further-exceptions) +- [`parse_error`](parse_error.md) for exceptions indicating a parse error +- [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators +- [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type +- [`out_of_range`](out_of_range.md) for exceptions indicating access out of the defined range + +## Version history + +- Since version 3.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/out_of_range.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/out_of_range.md new file mode 100644 index 000000000..6c1f0dfba --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/out_of_range.md @@ -0,0 +1,68 @@ +# nlohmann::basic_json::out_of_range + +```cpp +class out_of_range : public exception; +``` + +This exception is thrown in case a library function is called on an input parameter that exceeds the expected range, for +instance in case of array indices or nonexisting object keys. + +Exceptions have ids 4xx (see [list of out-of-range errors](../../home/exceptions.md#out-of-range)). + +```plantuml +std::exception <|-- basic_json::exception +basic_json::exception <|-- basic_json::parse_error +basic_json::exception <|-- basic_json::invalid_iterator +basic_json::exception <|-- basic_json::type_error +basic_json::exception <|-- basic_json::out_of_range +basic_json::exception <|-- basic_json::other_error + +interface std::exception {} + +class basic_json::exception { + + const int id + + const char* what() const +} + +class basic_json::parse_error { + + const std::size_t byte +} + +class basic_json::out_of_range #FFFF00 {} +``` + +## Member functions + +- **what** - returns explanatory string + +## Member variables + +- **id** - the id of the exception + +## Examples + +??? example + + The following code shows how a `out_of_range` exception can be caught. + + ```cpp + --8<-- "examples/out_of_range.cpp" + ``` + + Output: + + ```json + --8<-- "examples/out_of_range.output" + ``` + +## See also + +- [List of out-of-range errors](../../home/exceptions.md#out-of-range) +- [`parse_error`](parse_error.md) for exceptions indicating a parse error +- [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators +- [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type +- [`other_error`](other_error.md) for exceptions indicating other library errors + +## Version history + +- Since version 3.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/parse.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/parse.md new file mode 100644 index 000000000..49838ad1d --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/parse.md @@ -0,0 +1,214 @@ +# nlohmann::basic_json::parse + +```cpp +// (1) +template +static basic_json parse(InputType&& i, + const parser_callback_t cb = nullptr, + const bool allow_exceptions = true, + const bool ignore_comments = false); + +// (2) +template +static basic_json parse(IteratorType first, IteratorType last, + const parser_callback_t cb = nullptr, + const bool allow_exceptions = true, + const bool ignore_comments = false); +``` + +1. Deserialize from a compatible input. +2. Deserialize from a pair of character iterators + + The `value_type` of the iterator must be an integral type with size of 1, 2 or 4 bytes, which will be interpreted + respectively as UTF-8, UTF-16 and UTF-32. + +## Template parameters + +`InputType` +: A compatible input, for instance: + + - an `std::istream` object + - a `FILE` pointer (must not be null) + - a C-style array of characters + - a pointer to a null-terminated string of single byte characters + - a `std::string` + - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. + +`IteratorType` +: a compatible iterator type, for instance. + + - a pair of `std::string::iterator` or `std::vector::iterator` + - a pair of pointers such as `ptr` and `ptr + len` + +## Parameters + +`i` (in) +: Input to parse from. + +`cb` (in) +: a parser callback function of type [`parser_callback_t`](parser_callback_t.md) which is used to control the + deserialization by filtering unwanted values (optional) + +`allow_exceptions` (in) +: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) + +`ignore_comments` (in) +: whether comments should be ignored and treated like whitespace (`#!cpp true`) or yield a parse error + (`#!cpp false`); (optional, `#!cpp false` by default) + +`first` (in) +: iterator to start of character range + +`last` (in) +: iterator to end of character range + +## Return value + +Deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be +`value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). + +## Exception safety + +Strong guarantee: if an exception is thrown, there are no changes in the JSON value. + +## Exceptions + +- Throws [`parse_error.101`](../../home/exceptions.md#jsonexceptionparse_error101) in case of an unexpected token. +- Throws [`parse_error.102`](../../home/exceptions.md#jsonexceptionparse_error102) if to_unicode fails or surrogate + error. +- Throws [`parse_error.103`](../../home/exceptions.md#jsonexceptionparse_error103) if to_unicode fails. + +## Complexity + +Linear in the length of the input. The parser is a predictive LL(1) parser. The complexity can be higher if the parser +callback function `cb` or reading from (1) the input `i` or (2) the iterator range [`first`, `last`] has a +super-linear complexity. + +## Notes + +(1) A UTF-8 byte order mark is silently ignored. + +!!! danger "Runtime assertion" + + The precondition that a passed `#!cpp FILE` pointer must not be null is enforced with a + [runtime assertion](../../features/assertions.md). + +## Examples + +??? example "Parsing from a character array" + + The example below demonstrates the `parse()` function reading from an array. + + ```cpp + --8<-- "examples/parse__array__parser_callback_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/parse__array__parser_callback_t.output" + ``` + +??? example "Parsing from a string" + + The example below demonstrates the `parse()` function with and without callback function. + + ```cpp + --8<-- "examples/parse__string__parser_callback_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/parse__string__parser_callback_t.output" + ``` + +??? example "Parsing from an input stream" + + The example below demonstrates the `parse()` function with and without callback function. + + ```cpp + --8<-- "examples/parse__istream__parser_callback_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/parse__istream__parser_callback_t.output" + ``` + +??? example "Parsing from a contiguous container" + + The example below demonstrates the `parse()` function reading from a contiguous container. + + ```cpp + --8<-- "examples/parse__contiguouscontainer__parser_callback_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/parse__contiguouscontainer__parser_callback_t.output" + ``` + +??? example "Parsing from a non null-terminated string" + + The example below demonstrates the `parse()` function reading from a string that is not null-terminated. + + ```cpp + --8<-- "examples/parse__pointers.cpp" + ``` + + Output: + + ```json + --8<-- "examples/parse__pointers.output" + ``` + +??? example "Parsing from an iterator pair" + + The example below demonstrates the `parse()` function reading from an iterator pair. + + ```cpp + --8<-- "examples/parse__iterator_pair.cpp" + ``` + + Output: + + ```json + --8<-- "examples/parse__iterator_pair.output" + ``` + +??? example "Effect of `allow_exceptions` parameter" + + The example below demonstrates the effect of the `allow_exceptions` parameter in the ´parse()` function. + + ```cpp + --8<-- "examples/parse__allow_exceptions.cpp" + ``` + + Output: + + ```json + --8<-- "examples/parse__allow_exceptions.output" + ``` + +## See also + +- [accept](accept.md) - check if the input is valid JSON +- [operator>>](../operator_gtgt.md) - deserialize from stream + +## Version history + +- Added in version 1.0.0. +- Overload for contiguous containers (1) added in version 2.0.3. +- Ignoring comments via `ignore_comments` added in version 3.9.0. + +!!! warning "Deprecation" + + Overload (2) replaces calls to `parse` with a pair of iterators as their first parameter which has been + deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like + `#!cpp parse({ptr, ptr+len}, ...);` with `#!cpp parse(ptr, ptr+len, ...);`. + + You should be warned by your compiler with a `-Wdeprecated-declarations` warning if you are using a deprecated + function. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/parse_error.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/parse_error.md new file mode 100644 index 000000000..af3e1f0b3 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/parse_error.md @@ -0,0 +1,74 @@ +# nlohmann::basic_json::parse_error + +```cpp +class parse_error : public exception; +``` + +This exception is thrown by the library when a parse error occurs. Parse errors can occur during the deserialization of +JSON text, BSON, CBOR, MessagePack, UBJSON, as well as when using JSON Patch. + +Member `byte` holds the byte index of the last read character in the input file (see note below). + +Exceptions have ids 1xx (see [list of parse errors](../../home/exceptions.md#parse-errors)). + +```plantuml +std::exception <|-- basic_json::exception +basic_json::exception <|-- basic_json::parse_error +basic_json::exception <|-- basic_json::invalid_iterator +basic_json::exception <|-- basic_json::type_error +basic_json::exception <|-- basic_json::out_of_range +basic_json::exception <|-- basic_json::other_error + +interface std::exception {} + +class basic_json::exception { + + const int id + + const char* what() const +} + +class basic_json::parse_error #FFFF00 { + + const std::size_t byte +} +``` + +## Member functions + +- **what** - returns explanatory string + +## Member variables + +- **id** - the id of the exception +- **byte** - byte index of the parse error + +## Notes + +For an input with $n$ bytes, 1 is the index of the first character and $n+1$ is the index of the terminating null byte +or the end of file. This also holds true when reading a byte vector for binary formats. + +## Examples + +??? example + + The following code shows how a `parse_error` exception can be caught. + + ```cpp + --8<-- "examples/parse_error.cpp" + ``` + + Output: + + ```json + --8<-- "examples/parse_error.output" + ``` + +## See also + +- [List of parse errors](../../home/exceptions.md#parse-errors) +- [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators +- [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type +- [`out_of_range`](out_of_range.md) for exceptions indicating access out of the defined range +- [`other_error`](other_error.md) for exceptions indicating other library errors + +## Version history + +- Since version 3.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/parse_event_t.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/parse_event_t.md similarity index 91% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/parse_event_t.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/parse_event_t.md index 867de48bd..1a7c39038 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/parse_event_t.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/parse_event_t.md @@ -1,4 +1,4 @@ -# basic_json::parse_event_t +# nlohmann::basic_json::parse_event_t ```cpp enum class parse_event_t : std::uint8_t { @@ -20,7 +20,7 @@ The parser callback distinguishes the following events: - `array_end`: the parser read `]` and finished processing a JSON array - `value`: the parser finished reading a JSON value -## Example +## Examples ![Example when certain parse events are triggered](../../images/callback_events.png) diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/parser_callback_t.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/parser_callback_t.md new file mode 100644 index 000000000..e10402ea9 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/parser_callback_t.md @@ -0,0 +1,73 @@ +# nlohmann::basic_json::parser_callback_t + +```cpp +template +using parser_callback_t = + std::function; +``` + +With a parser callback function, the result of parsing a JSON text can be influenced. When passed to +[`parse`](parse.md), it is called on certain events (passed as [`parse_event_t`](parse_event_t.md) via parameter +`event`) with a set recursion depth `depth` and context JSON value `parsed`. The return value of the callback function +is a boolean indicating whether the element that emitted the callback shall be kept or not. + +We distinguish six scenarios (determined by the event type) in which the callback function can be called. The following +table describes the values of the parameters `depth`, `event`, and `parsed`. + +| parameter `event` | description | parameter `depth` | parameter `parsed` | +|-------------------------------|-----------------------------------------------------------|-------------------------------------------|----------------------------------| +| `parse_event_t::object_start` | the parser read `{` and started to process a JSON object | depth of the parent of the JSON object | a JSON value with type discarded | +| `parse_event_t::key` | the parser read a key of a value in an object | depth of the currently parsed JSON object | a JSON string containing the key | +| `parse_event_t::object_end` | the parser read `}` and finished processing a JSON object | depth of the parent of the JSON object | the parsed JSON object | +| `parse_event_t::array_start` | the parser read `[` and started to process a JSON array | depth of the parent of the JSON array | a JSON value with type discarded | +| `parse_event_t::array_end` | the parser read `]` and finished processing a JSON array | depth of the parent of the JSON array | the parsed JSON array | +| `parse_event_t::value` | the parser finished reading a JSON value | depth of the value | the parsed JSON value | + +![Example when certain parse events are triggered](../../images/callback_events.png) + +Discarding a value (i.e., returning `#!cpp false`) has different effects depending on the context in which function was +called: + +- Discarded values in structured types are skipped. That is, the parser will behave as if the discarded value was never + read. +- In case a value outside a structured type is skipped, it is replaced with `null`. This case happens if the top-level + element is skipped. + +## Parameters + +`depth` (in) +: the depth of the recursion during parsing + +`event` (in) +: an event of type [`parse_event_t`](parse_event_t.md) indicating the context in + the callback function has been called + +`parsed` (in, out) +: the current intermediate parse result; note that + writing to this value has no effect for `parse_event_t::key` events + +## Return value + +Whether the JSON value which called the function during parsing should be kept (`#!cpp true`) or not (`#!cpp false`). In +the latter case, it is either skipped completely or replaced by an empty discarded object. + +## Examples + +??? example + + The example below demonstrates the `parse()` function with + and without callback function. + + ```cpp + --8<-- "examples/parse__string__parser_callback_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/parse__string__parser_callback_t.output" + ``` + +## Version history + +- Added in version 1.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/patch.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/patch.md similarity index 80% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/patch.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/patch.md index d73e9c0d3..deec47434 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/patch.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/patch.md @@ -1,11 +1,11 @@ -# basic_json::patch +# nlohmann::basic_json::patch ```cpp basic_json patch(const basic_json& json_patch) const; ``` [JSON Patch](http://jsonpatch.com) defines a JSON document structure for expressing a sequence of operations to apply to -a JSON) document. With this function, a JSON Patch is applied to the current JSON value by executing all operations from +a JSON document. With this function, a JSON Patch is applied to the current JSON value by executing all operations from the patch. ## Parameters @@ -17,6 +17,10 @@ the patch. patched document +## Exception safety + +Strong guarantee: if an exception is thrown, there are no changes in the JSON value. + ## Exceptions - Throws [`parse_error.104`](../../home/exceptions.md#jsonexceptionparse_error104) if the JSON patch does not consist of @@ -31,21 +35,17 @@ patched document - Throws [`out_of_range.501`](../../home/exceptions.md#jsonexceptionother_error501) if "test" operation was unsuccessful. -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - ## Complexity Linear in the size of the JSON value and the length of the JSON patch. As usually only a fraction of the JSON value is affected by the patch, the complexity can usually be neglected. -## Note +## Notes The application of a patch is atomic: Either all operations succeed and the patched document is returned or an exception is thrown. In any case, the original value is not changed: the patch is applied to a copy of the value. -## Example +## Examples ??? example @@ -61,6 +61,13 @@ is thrown. In any case, the original value is not changed: the patch is applied --8<-- "examples/patch.output" ``` +## See also + +- [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) +- [RFC 6901 (JSON Pointer)](https://tools.ietf.org/html/rfc6901) +- [patch_inplace](patch_inplace.md) applies a JSON Patch without creating a copy of the document +- [merge_patch](merge_patch.md) applies a JSON Merge Patch + ## Version history - Added in version 2.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/patch_inplace.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/patch_inplace.md new file mode 100644 index 000000000..e8fd176c3 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/patch_inplace.md @@ -0,0 +1,70 @@ +# nlohmann::basic_json::patch_inplace + +```cpp +void patch_inplace(const basic_json& json_patch) const; +``` + +[JSON Patch](http://jsonpatch.com) defines a JSON document structure for expressing a sequence of operations to apply to +a JSON document. With this function, a JSON Patch is applied to the current JSON value by executing all operations from +the patch. This function applies a JSON patch in place and returns void. + +## Parameters + +`json_patch` (in) +: JSON patch document + +## Exception safety + +No guarantees, value may be corrupted by an unsuccessful patch operation. + +## Exceptions + +- Throws [`parse_error.104`](../../home/exceptions.md#jsonexceptionparse_error104) if the JSON patch does not consist of + an array of objects. +- Throws [`parse_error.105`](../../home/exceptions.md#jsonexceptionparse_error105) if the JSON patch is malformed (e.g., + mandatory attributes are missing); example: `"operation add must have member path"`. +- Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) if an array index is out of range. +- Throws [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if a JSON pointer inside the patch + could not be resolved successfully in the current JSON value; example: `"key baz not found"`. +- Throws [`out_of_range.405`](../../home/exceptions.md#jsonexceptionout_of_range405) if JSON pointer has no parent + ("add", "remove", "move") +- Throws [`out_of_range.501`](../../home/exceptions.md#jsonexceptionother_error501) if "test" operation was + unsuccessful. + +## Complexity + +Linear in the size of the JSON value and the length of the JSON patch. As usually only a fraction of the JSON value is +affected by the patch, the complexity can usually be neglected. + +## Notes + +Unlike [`patch`](patch.md), `patch_inplace` applies the operation "in place" and no copy of the JSON value is created. +That makes it faster for large documents by avoiding the copy. However, the JSON value might be corrupted if the +function throws an exception. + +## Examples + +??? example + + The following code shows how a JSON patch is applied to a value. + + ```cpp + --8<-- "examples/patch_inplace.cpp" + ``` + + Output: + + ```json + --8<-- "examples/patch_inplace.output" + ``` + +## See also + +- [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) +- [RFC 6901 (JSON Pointer)](https://tools.ietf.org/html/rfc6901) +- [patch](patch.md) applies a JSON Merge Patch +- [merge_patch](merge_patch.md) applies a JSON Merge Patch + +## Version history + +- Added in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/push_back.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/push_back.md new file mode 100644 index 000000000..5c7d20dd6 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/push_back.md @@ -0,0 +1,106 @@ +# nlohmann::basic_json::push_back + +```cpp +// (1) +void push_back(basic_json&& val); +void push_back(const basic_json& val); + +// (2) +void push_back(const typename object_t::value_type& val); + +// (3) +void push_back(initializer_list_t init); +``` + +1. Appends the given element `val` to the end of the JSON array. If the function is called on a JSON null value, an + empty array is created before appending `val`. + +2. Inserts the given element `val` to the JSON object. If the function is called on a JSON null value, an empty object + is created before inserting `val`. + +3. This function allows using `push_back` with an initializer list. In case + + 1. the current value is an object, + 2. the initializer list `init` contains only two elements, and + 3. the first element of `init` is a string, + + `init` is converted into an object element and added using `push_back(const typename object_t::value_type&)`. + Otherwise, `init` is converted to a JSON value and added using `push_back(basic_json&&)`. + +## Parameters + +`val` (in) +: the value to add to the JSON array/object + +`init` (in) +: an initializer list + +## Exceptions + +All functions can throw the following exception: + - Throws [`type_error.308`](../../home/exceptions.md#jsonexceptiontype_error308) when called on a type other than + JSON array or null; example: `"cannot use push_back() with number"` + +## Complexity + +1. Amortized constant. +2. Logarithmic in the size of the container, O(log(`size()`)). +3. Linear in the size of the initializer list `init`. + +## Notes + +(3) This function is required to resolve an ambiguous overload error, because pairs like `{"key", "value"}` can be both + interpreted as `object_t::value_type` or `std::initializer_list`, see + [#235](https://github.com/nlohmann/json/issues/235) for more information. + +## Examples + +??? example "Example: (1) add element to array" + + The example shows how `push_back()` and `+=` can be used to add elements to a JSON array. Note how the `null` value + was silently converted to a JSON array. + + ```cpp + --8<-- "examples/push_back.cpp" + ``` + + Output: + + ```json + --8<-- "examples/push_back.output" + ``` + +??? example "Example: (2) add element to object" + + The example shows how `push_back()` and `+=` can be used to add elements to a JSON object. Note how the `null` value + was silently converted to a JSON object. + + ```cpp + --8<-- "examples/push_back__object_t__value.cpp" + ``` + + Output: + + ```json + --8<-- "examples/push_back__object_t__value.output" + ``` + +??? example "Example: (3) add to object from initializer list" + + The example shows how initializer lists are treated as objects when possible. + + ```cpp + --8<-- "examples/push_back__initializer_list.cpp" + ``` + + Output: + + ```json + --8<-- "examples/push_back__initializer_list.output" + ``` + +## Version history + +1. Since version 1.0.0. +2. Since version 1.0.0. +2. Since version 2.0.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/rbegin.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/rbegin.md similarity index 92% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/rbegin.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/rbegin.md index 57957b3b4..126c47127 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/rbegin.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/rbegin.md @@ -1,4 +1,4 @@ -# basic_json::rbegin +# nlohmann::basic_json::rbegin ```cpp reverse_iterator rbegin() noexcept; @@ -21,7 +21,7 @@ No-throw guarantee: this member function never throws exceptions. Constant. -## Example +## Examples ??? example diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/rend.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/rend.md similarity index 93% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/rend.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/rend.md index 5d5f21310..96da7a5f5 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/rend.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/rend.md @@ -1,4 +1,4 @@ -# basic_json::rend +# nlohmann::basic_json::rend ```cpp reverse_iterator rend() noexcept; @@ -22,7 +22,7 @@ No-throw guarantee: this member function never throws exceptions. Constant. -## Example +## Examples ??? example diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/sax_parse.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/sax_parse.md similarity index 81% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/sax_parse.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/sax_parse.md index 7a6dbad3c..e2ac1b41d 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/sax_parse.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/sax_parse.md @@ -1,4 +1,4 @@ -# basic_json::sax_parse +# nlohmann::basic_json::sax_parse ```cpp // (1) @@ -23,10 +23,10 @@ Read from input and generate SAX events 1. Read from a compatible input. 2. Read from a pair of character iterators - The value_type of the iterator must be a integral type with size of 1, 2 or 4 bytes, which will be interpreted + The value_type of the iterator must be an integral type with size of 1, 2 or 4 bytes, which will be interpreted respectively as UTF-8, UTF-16 and UTF-32. -The SAX event lister must follow the interface of `json_sax`. +The SAX event lister must follow the interface of [`json_sax`](../json_sax/index.md). ## Template parameters @@ -107,3 +107,9 @@ A UTF-8 byte order mark is silently ignored. - Added in version 3.2.0. - Ignoring comments via `ignore_comments` added in version 3.9.0. + +!!! warning "Deprecation" + + Overload (2) replaces calls to `sax_parse` with a pair of iterators as their first parameter which has been + deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like + `#!cpp sax_parse({ptr, ptr+len});` with `#!cpp sax_parse(ptr, ptr+len);`. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/size.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/size.md new file mode 100644 index 000000000..4ff582db2 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/size.md @@ -0,0 +1,57 @@ +# nlohmann::basic_json::size + +```cpp +size_type size() const noexcept; +``` + +Returns the number of elements in a JSON value. + +## Return value + +The return value depends on the different types and is defined as follows: + +| Value type | return value | +|------------|-------------------------------------| +| null | `0` | +| boolean | `1` | +| string | `1` | +| number | `1` | +| binary | `1` | +| object | result of function object_t::size() | +| array | result of function array_t::size() | + +## Exception safety + +No-throw guarantee: this function never throws exceptions. + +## Complexity + +Constant, as long as [`array_t`](array_t.md) and [`object_t`](object_t.md) satisfy the +[Container](https://en.cppreference.com/w/cpp/named_req/Container) concept; that is, their `size()` functions have +constant complexity. + +## Notes + +This function does not return the length of a string stored as JSON value -- it returns the number of elements in the +JSON value which is `1` in the case of a string. + +## Examples + +??? example + + The following code calls `size()` on the different value types. + + ```cpp + --8<-- "examples/size.cpp" + ``` + + Output: + + ```json + --8<-- "examples/size.output" + ``` + +## Version history + +- Added in version 1.0.0. +- Extended to return `1` for binary types in version 3.8.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/std_hash.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/std_hash.md new file mode 100644 index 000000000..b9de74f8c --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/std_hash.md @@ -0,0 +1,34 @@ +# std::hash + +```cpp +namespace std { + struct hash; +} +``` + +Return a hash value for a JSON object. The hash function tries to rely on `std::hash` where possible. Furthermore, the +type of the JSON value is taken into account to have different hash values for `#!json null`, `#!cpp 0`, `#!cpp 0U`, and +`#!cpp false`, etc. + +## Examples + +??? example + + The example shows how to calculate hash values for different JSON values. + + ```cpp + --8<-- "examples/std_hash.cpp" + ``` + + Output: + + ```json + --8<-- "examples/std_hash.output" + ``` + + Note the output is platform-dependent. + +## Version history + +- Added in version 1.0.0. +- Extended for arbitrary basic_json types in version 3.10.5. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/std_swap.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/std_swap.md new file mode 100644 index 000000000..d30f3bccd --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/std_swap.md @@ -0,0 +1,51 @@ +# std::swap + +```cpp +namespace std { + void swap(nlohmann::basic_json& j1, nlohmann::basic_json& j2); +} +``` + +Exchanges the values of two JSON objects. + +## Parameters + +`j1` (in, out) +: value to be replaced by `j2` + +`j2` (in, out) +: value to be replaced by `j1` + +## Possible implementation + +```cpp +void swap(nlohmann::basic_json& j1, nlohmann::basic_json& j2) +{ + j1.swap(j2); +} +``` + +## Examples + +??? example + + The following code shows how two values are swapped with `std::swap`. + + ```cpp + --8<-- "examples/std_swap.cpp" + ``` + + Output: + + ```json + --8<-- "examples/std_swap.output" + ``` + +## See also + +- [swap](swap.md) + +## Version history + +- Added in version 1.0.0. +- Extended for arbitrary basic_json types in version 3.10.5. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/string_t.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/string_t.md new file mode 100644 index 000000000..3ab4412dd --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/string_t.md @@ -0,0 +1,66 @@ +# nlohmann::basic_json::string_t + +```cpp +using string_t = StringType; +``` + +The type used to store JSON strings. + +[RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON strings as follows: +> A string is a sequence of zero or more Unicode characters. + +To store objects in C++, a type is defined by the template parameter described below. Unicode values are split by the +JSON class into byte-sized characters during deserialization. + +## Template parameters + +`StringType` +: the container to store strings (e.g., `std::string`). Note this container is used for keys/names in objects, see + [object_t](object_t.md). + +## Notes + +#### Default type + +With the default values for `StringType` (`std::string`), the default value for `string_t` is `#!cpp std::string`. + +#### Encoding + +Strings are stored in UTF-8 encoding. Therefore, functions like `std::string::size()` or `std::string::length()` return +the number of bytes in the string rather than the number of characters or glyphs. + +#### String comparison + +[RFC 8259](https://tools.ietf.org/html/rfc8259) states: +> Software implementations are typically required to test names of object members for equality. Implementations that +> transform the textual representation into sequences of Unicode code units and then perform the comparison numerically, +> code unit by code unit, are interoperable in the sense that implementations will agree in all cases on equality or +> inequality of two strings. For example, implementations that compare strings with escaped characters unconverted may +> incorrectly find that `"a\\b"` and `"a\u005Cb"` are not equal. + +This implementation is interoperable as it does compare strings code unit by code unit. + +#### Storage + +String values are stored as pointers in a `basic_json` type. That is, for any access to string values, a pointer of type +`string_t*` must be dereferenced. + +## Examples + +??? example + + The following code shows that `string_t` is by default, a typedef to `#!cpp std::string`. + + ```cpp + --8<-- "examples/string_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/string_t.output" + ``` + +## Version history + +- Added in version 1.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/swap.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/swap.md new file mode 100644 index 000000000..a5730ffa7 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/swap.md @@ -0,0 +1,157 @@ +# nlohmann::basic_json::swap + +```cpp +// (1) +void swap(reference other) noexcept; + +// (2) +void swap(reference left, reference right) noexcept; + +// (3) +void swap(array_t& other); + +// (4) +void swap(object_t& other); + +// (5) +void swap(string_t& other); + +// (6) +void swap(binary_t& other); + +// (7) +void swap(typename binary_t::container_type& other); +``` + +1. Exchanges the contents of the JSON value with those of `other`. Does not invoke any move, copy, or swap operations on + individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated. +2. Exchanges the contents of the JSON value from `left` with those of `right`. Does not invoke any move, copy, or swap + operations on individual elements. All iterators and references remain valid. The past-the-end iterator is + invalidated. Implemented as a friend function callable via ADL. +3. Exchanges the contents of a JSON array with those of `other`. Does not invoke any move, copy, or swap operations on + individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated. +4. Exchanges the contents of a JSON object with those of `other`. Does not invoke any move, copy, or swap operations on + individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated. +5. Exchanges the contents of a JSON string with those of `other`. Does not invoke any move, copy, or swap operations on + individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated. +6. Exchanges the contents of a binary value with those of `other`. Does not invoke any move, copy, or swap operations on + individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated. +7. Exchanges the contents of a binary value with those of `other`. Does not invoke any move, copy, or swap operations on + individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated. Unlike + version (6), no binary subtype is involved. + +## Parameters + +`other` (in, out) +: value to exchange the contents with + +`left` (in, out) +: value to exchange the contents with + +`right` (in, out) +: value to exchange the contents with + +## Exceptions + +1. No-throw guarantee: this function never throws exceptions. +2. No-throw guarantee: this function never throws exceptions. +3. Throws [`type_error.310`](../../home/exceptions.md#jsonexceptiontype_error310) if called on JSON values other than + arrays; example: `"cannot use swap() with boolean"` +4. Throws [`type_error.310`](../../home/exceptions.md#jsonexceptiontype_error310) if called on JSON values other than + objects; example: `"cannot use swap() with boolean"` +5. Throws [`type_error.310`](../../home/exceptions.md#jsonexceptiontype_error310) if called on JSON values other than + strings; example: `"cannot use swap() with boolean"` +6. Throws [`type_error.310`](../../home/exceptions.md#jsonexceptiontype_error310) if called on JSON values other than + binaries; example: `"cannot use swap() with boolean"` +7. Throws [`type_error.310`](../../home/exceptions.md#jsonexceptiontype_error310) if called on JSON values other than + binaries; example: `"cannot use swap() with boolean"` + +## Complexity + +Constant. + +## Examples + +??? example "Example: Swap JSON value (1, 2)" + + The example below shows how JSON values can be swapped with `swap()`. + + ```cpp + --8<-- "examples/swap__reference.cpp" + ``` + + Output: + + ```json + --8<-- "examples/swap__reference.output" + ``` + +??? example "Example: Swap array (3)" + + The example below shows how arrays can be swapped with `swap()`. + + ```cpp + --8<-- "examples/swap__array_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/swap__array_t.output" + ``` + +??? example "Example: Swap object (4)" + + The example below shows how objects can be swapped with `swap()`. + + ```cpp + --8<-- "examples/swap__object_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/swap__object_t.output" + ``` + +??? example "Example: Swap string (5)" + + The example below shows how strings can be swapped with `swap()`. + + ```cpp + --8<-- "examples/swap__string_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/swap__string_t.output" + ``` + +??? example "Example: Swap string (6)" + + The example below shows how binary values can be swapped with `swap()`. + + ```cpp + --8<-- "examples/swap__binary_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/swap__binary_t.output" + ``` + +## See also + +- [std::swap](std_swap.md) + +## Version history + +1. Since version 1.0.0. +2. Since version 1.0.0. +3. Since version 1.0.0. +4. Since version 1.0.0. +5. Since version 1.0.0. +6. Since version 3.8.0. +7. Since version 3.8.0. \ No newline at end of file diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/to_bjdata.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/to_bjdata.md new file mode 100644 index 000000000..48598a5e6 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/to_bjdata.md @@ -0,0 +1,70 @@ +# nlohmann::basic_json::to_bjdata + +```cpp +// (1) +static std::vector to_bjdata(const basic_json& j, + const bool use_size = false, + const bool use_type = false); + +// (2) +static void to_bjdata(const basic_json& j, detail::output_adapter o, + const bool use_size = false, const bool use_type = false); +static void to_bjdata(const basic_json& j, detail::output_adapter o, + const bool use_size = false, const bool use_type = false); +``` + +Serializes a given JSON value `j` to a byte vector using the BJData (Binary JData) serialization format. BJData aims to +be more compact than JSON itself, yet more efficient to parse. + +1. Returns a byte vector containing the BJData serialization. +2. Writes the BJData serialization to an output adapter. + +The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/bjdata.md). + +## Parameters + +`j` (in) +: JSON value to serialize + +`o` (in) +: output adapter to write serialization to + +`use_size` (in) +: whether to add size annotations to container types; optional, `#!cpp false` by default. + +`use_type` (in) +: whether to add type annotations to container types (must be combined with `#!cpp use_size = true`); optional, +`#!cpp false` by default. + +## Return value + +1. BJData serialization as byte vector +2. (none) + +## Exception safety + +Strong guarantee: if an exception is thrown, there are no changes in the JSON value. + +## Complexity + +Linear in the size of the JSON value `j`. + +## Examples + +??? example + + The example shows the serialization of a JSON value to a byte vector in BJData format. + + ```cpp + --8<-- "examples/to_bjdata.cpp" + ``` + + Output: + + ```json + --8<-- "examples/to_bjdata.output" + ``` + +## Version history + +- Added in version 3.11.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/to_bson.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/to_bson.md similarity index 85% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/to_bson.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/to_bson.md index 747a4aa31..5c4324a3f 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/to_bson.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/to_bson.md @@ -1,4 +1,4 @@ -# basic_json::to_bson +# nlohmann::basic_json::to_bson ```cpp // (1) @@ -15,6 +15,8 @@ so-called document). 1. Returns a byte vector containing the BSON serialization. 2. Writes the BSON serialization to an output adapter. +The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/bson.md). + ## Parameters `j` (in) @@ -26,7 +28,7 @@ so-called document). ## Return value 1. BSON serialization as byte vector -2. / +2. (none) ## Exception safety @@ -36,7 +38,7 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va Linear in the size of the JSON value `j`. -## Example +## Examples ??? example diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/to_cbor.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/to_cbor.md similarity index 87% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/to_cbor.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/to_cbor.md index fd0eaa1fe..0f944c481 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/to_cbor.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/to_cbor.md @@ -1,4 +1,4 @@ -# basic_json::to_cbor +# nlohmann::basic_json::to_cbor ```cpp // (1) @@ -16,6 +16,8 @@ parse. 1. Returns a byte vector containing the CBOR serialization. 2. Writes the CBOR serialization to an output adapter. +The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/cbor.md). + ## Parameters `j` (in) @@ -27,7 +29,7 @@ parse. ## Return value 1. CBOR serialization as byte vector -2. / +2. (none) ## Exception safety @@ -37,7 +39,7 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va Linear in the size of the JSON value `j`. -## Example +## Examples ??? example diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/to_msgpack.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/to_msgpack.md similarity index 86% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/to_msgpack.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/to_msgpack.md index 1d438d7cd..7d40981d5 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/to_msgpack.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/to_msgpack.md @@ -1,4 +1,4 @@ -# basic_json::to_msgpack +# nlohmann::basic_json::to_msgpack ```cpp // (1) @@ -15,6 +15,8 @@ serialization format which aims to be more compact than JSON itself, yet more ef 1. Returns a byte vector containing the MessagePack serialization. 2. Writes the MessagePack serialization to an output adapter. +The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/messagepack.md). + ## Parameters `j` (in) @@ -26,7 +28,7 @@ serialization format which aims to be more compact than JSON itself, yet more ef ## Return value 1. MessagePack serialization as byte vector -2. / +2. (none) ## Exception safety @@ -36,7 +38,7 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va Linear in the size of the JSON value `j`. -## Example +## Examples ??? example diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/to_string.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/to_string.md new file mode 100644 index 000000000..2b907e217 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/to_string.md @@ -0,0 +1,65 @@ +# to_string(basic_json) + +```cpp +template +std::string to_string(const BasicJsonType& j); +``` + +This function implements a user-defined to_string for JSON objects. + +## Template parameters + +`BasicJsonType` +: a specialization of [`basic_json`](index.md) + +## Return value + +string containing the serialization of the JSON value + +## Exception safety + +Strong guarantee: if an exception is thrown, there are no changes to any JSON value. + +## Exceptions + +Throws [`type_error.316`](../../home/exceptions.md#jsonexceptiontype_error316) if a string stored inside the JSON value +is not UTF-8 encoded + +## Complexity + +Linear. + +## Possible implementation + +```cpp +template +std::string to_string(const BasicJsonType& j) +{ + return j.dump(); +} +``` + +## Examples + +??? example + + The following code shows how the library's `to_string()` function integrates with others, allowing + argument-dependent lookup. + + ```cpp + --8<-- "examples/to_string.cpp" + ``` + + Output: + + ```json + --8<-- "examples/to_string.output" + ``` + +## See also + +- [dump](dump.md) + +## Version history + +Added in version 3.7.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/to_ubjson.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/to_ubjson.md similarity index 90% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/to_ubjson.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/to_ubjson.md index a12a62555..e3cd5d62b 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/to_ubjson.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/to_ubjson.md @@ -1,4 +1,4 @@ -# basic_json::to_ubjson +# nlohmann::basic_json::to_ubjson ```cpp // (1) @@ -19,6 +19,8 @@ aims to be more compact than JSON itself, yet more efficient to parse. 1. Returns a byte vector containing the UBJSON serialization. 2. Writes the UBJSON serialization to an output adapter. +The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/ubjson.md). + ## Parameters `j` (in) @@ -37,7 +39,7 @@ aims to be more compact than JSON itself, yet more efficient to parse. ## Return value 1. UBJSON serialization as byte vector -2. / +2. (none) ## Exception safety @@ -47,7 +49,7 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va Linear in the size of the JSON value `j`. -## Example +## Examples ??? example diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/type.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/type.md new file mode 100644 index 000000000..deedd6b69 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/type.md @@ -0,0 +1,54 @@ +# nlohmann::basic_json::type + +```cpp +constexpr value_t type() const noexcept; +``` + +Return the type of the JSON value as a value from the [`value_t`](value_t.md) enumeration. + +## Return value + +the type of the JSON value + +| Value type | return value | +|---------------------------|----------------------------| +| `#!json null` | `value_t::null` | +| boolean | `value_t::boolean` | +| string | `value_t::string` | +| number (integer) | `value_t::number_integer` | +| number (unsigned integer) | `value_t::number_unsigned` | +| number (floating-point) | `value_t::number_float` | +| object | `value_t::object` | +| array | `value_t::array` | +| binary | `value_t::binary` | +| discarded | `value_t::discarded` | + +## Exception safety + +No-throw guarantee: this member function never throws exceptions. + +## Complexity + +Constant. + +## Examples + +??? example + + The following code exemplifies `type()` for all JSON types. + + ```cpp + --8<-- "examples/type.cpp" + ``` + + Output: + + ```json + --8<-- "examples/type.output" + ``` + +## Version history + +- Added in version 1.0.0. +- Added unsigned integer type in version 2.0.0. +- Added binary type in version 3.8.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/type_error.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/type_error.md new file mode 100644 index 000000000..cda54c089 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/type_error.md @@ -0,0 +1,68 @@ +# nlohmann::basic_json::type_error + +```cpp +class type_error : public exception; +``` + +This exception is thrown in case of a type error; that is, a library function is executed on a JSON value whose type +does not match the expected semantics. + +Exceptions have ids 3xx (see [list of type errors](../../home/exceptions.md#type-errors)). + +```plantuml +std::exception <|-- basic_json::exception +basic_json::exception <|-- basic_json::parse_error +basic_json::exception <|-- basic_json::invalid_iterator +basic_json::exception <|-- basic_json::type_error +basic_json::exception <|-- basic_json::out_of_range +basic_json::exception <|-- basic_json::other_error + +interface std::exception {} + +class basic_json::exception { + + const int id + + const char* what() const +} + +class basic_json::parse_error { + + const std::size_t byte +} + +class basic_json::type_error #FFFF00 {} +``` + +## Member functions + +- **what** - returns explanatory string + +## Member variables + +- **id** - the id of the exception + +## Examples + +??? example + + The following code shows how a `type_error` exception can be caught. + + ```cpp + --8<-- "examples/type_error.cpp" + ``` + + Output: + + ```json + --8<-- "examples/type_error.output" + ``` + +## See also + +- [List of type errors](../../home/exceptions.md#type-errors) +- [`parse_error`](parse_error.md) for exceptions indicating a parse error +- [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators +- [`out_of_range`](out_of_range.md) for exceptions indicating access out of the defined range +- [`other_error`](other_error.md) for exceptions indicating other library errors + +## Version history + +- Since version 3.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/type_name.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/type_name.md new file mode 100644 index 000000000..389c2b1dd --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/type_name.md @@ -0,0 +1,54 @@ +# nlohmann::basic_json::type_name + +```cpp +const char* type_name() const noexcept; +``` + +Returns the type name as string to be used in error messages -- usually to indicate that a function was called on a +wrong JSON type. + +## Return value + +a string representation of the type ([`value_t`](value_t.md)): + +| Value type | return value | +|----------------------------------------------------|---------------| +| `#!json null` | `"null"` | +| boolean | `"boolean"` | +| string | `"string"` | +| number (integer, unsigned integer, floating-point) | `"number"` | +| object | `"object"` | +| array | `"array"` | +| binary | `"binary"` | +| discarded | `"discarded"` | + +## Exception safety + +No-throw guarantee: this member function never throws exceptions. + +## Complexity + +Constant. + +## Examples + +??? example + + The following code exemplifies `type_name()` for all JSON types. + + ```cpp + --8<-- "examples/type_name.cpp" + ``` + + Output: + + ```json + --8<-- "examples/type_name.output" + ``` + +## Version history + +- Added in version 1.0.0. +- Part of the public API version since 2.1.0. +- Changed return value to `const char*` and added `noexcept` in version 3.0.0. +- Added support for binary type in version 3.8.0. diff --git a/external_imported/json/doc/mkdocs/docs/api/basic_json/unflatten.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/unflatten.md similarity index 92% rename from external_imported/json/doc/mkdocs/docs/api/basic_json/unflatten.md rename to external_imported/json/docs/mkdocs/docs/api/basic_json/unflatten.md index 379428639..d9778036c 100644 --- a/external_imported/json/doc/mkdocs/docs/api/basic_json/unflatten.md +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/unflatten.md @@ -1,4 +1,4 @@ -# basic_json::unflatten +# nlohmann::basic_json::unflatten ```cpp basic_json unflatten() const; @@ -15,6 +15,10 @@ The function restores the arbitrary nesting of a JSON value that has been flatte the original JSON from a flattened version +## Exception safety + +Strong exception safety: if an exception occurs, the original value stays intact. + ## Exceptions The function can throw the following exceptions: @@ -22,10 +26,6 @@ The function can throw the following exceptions: - Throws [`type_error.314`](../../home/exceptions.md#jsonexceptiontype_error314) if value is not an object - Throws [`type_error.315`](../../home/exceptions.md#jsonexceptiontype_error315) if object values are not primitive -## Exception safety - -Strong exception safety: if an exception occurs, the original value stays intact. - ## Complexity Linear in the size the JSON value. @@ -36,7 +36,7 @@ Empty objects and arrays are flattened by [`flatten()`](flatten.md) to `#!json n their original type. Apart from this example, for a JSON value `j`, the following is always true: `#!cpp j == j.flatten().unflatten()`. -## Example +## Examples ??? example @@ -52,6 +52,10 @@ their original type. Apart from this example, for a JSON value `j`, the followin --8<-- "examples/unflatten.output" ``` +## See also + +- [flatten](flatten.md) the reverse function + ## Version history - Added in version 2.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/update.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/update.md new file mode 100644 index 000000000..a594cf9d0 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/update.md @@ -0,0 +1,142 @@ +# nlohmann::basic_json::update + +```cpp +// (1) +void update(const_reference j, bool merge_objects = false); + +// (2) +void update(const_iterator first, const_iterator last, bool merge_objects = false); +``` + +1. Inserts all values from JSON object `j`. +2. Inserts all values from range `[first, last)` + +When `merge_objects` is `#!c false` (default), existing keys are overwritten. When `merge_objects` is `#!c true`, +recursively merges objects with common keys. + +The function is motivated by Python's [dict.update](https://docs.python.org/3.6/library/stdtypes.html#dict.update) +function. + +## Parameters + +`j` (in) +: JSON object to read values from + +`merge_objects` (in) +: when `#!c true`, existing keys are not overwritten, but contents of objects are merged recursively (default: + `#!c false`) + +`first` (in) +: begin of the range of elements to insert + +`last` (in) +: end of the range of elements to insert + +## Exceptions + +1. The function can throw the following exceptions: + - Throws [`type_error.312`](../../home/exceptions.md#jsonexceptiontype_error312) if called on JSON values other than + objects; example: `"cannot use update() with string"` +2. The function can throw the following exceptions: + - Throws [`type_error.312`](../../home/exceptions.md#jsonexceptiontype_error312) if called on JSON values other than + objects; example: `"cannot use update() with string"` + - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an + iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"` + - Throws [`invalid_iterator.210`](../../home/exceptions.md#jsonexceptioninvalid_iterator210) if `first` and `last` + do not belong to the same JSON value; example: `"iterators do not fit"` + +## Complexity + +1. O(N*log(size() + N)), where N is the number of elements to insert. +2. O(N*log(size() + N)), where N is the number of elements to insert. + +## Examples + +??? example + + The example shows how `update()` is used. + + ```cpp + --8<-- "examples/update.cpp" + ``` + + Output: + + ```json + --8<-- "examples/update.output" + ``` + +??? example + + The example shows how `update()` is used. + + ```cpp + --8<-- "examples/update__range.cpp" + ``` + + Output: + + ```json + --8<-- "examples/update__range.output" + ``` + +??? example + + One common use case for this function is the handling of user settings. Assume your application can be configured in + some aspects: + + ```json + { + "color": "red", + "active": true, + "name": {"de": "Maus", "en": "mouse"} + } + ``` + + The user may override the default settings selectively: + + ```json + { + "color": "blue", + "name": {"es": "ratón"}, + } + ``` + + Then `update` manages the merging of default settings and user settings: + + ```cpp + auto user_settings = json::parse("config.json"); + auto effective_settings = get_default_settings(); + effective_settings.update(user_settings); + ``` + + Now `effective_settings` contains the default settings, but those keys set by the user are overwritten: + + ```json + { + "color": "blue", + "active": true, + "name": {"es": "ratón"} + } + ``` + + Note existing keys were just overwritten. To merge objects, `merge_objects` setting should be set to `#!c true`: + + ```cpp + auto user_settings = json::parse("config.json"); + auto effective_settings = get_default_settings(); + effective_settings.update(user_settings, true); + ``` + + ```json + { + "color": "blue", + "active": true, + "name": {"de": "Maus", "en": "mouse", "es": "ratón"} + } + ``` + +## Version history + +- Added in version 3.0.0. +- Added `merge_objects` parameter in 3.10.4. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/value.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/value.md new file mode 100644 index 000000000..edb5406ba --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/value.md @@ -0,0 +1,159 @@ +# nlohmann::basic_json::value + +```cpp +// (1) +template +ValueType value(const typename object_t::key_type& key, + ValueType&& default_value) const; + +// (2) +template +ValueType value(KeyType&& key, + ValueType&& default_value) const; + +// (3) +template +ValueType value(const json_pointer& ptr, + const ValueType& default_value) const; +``` + +1. Returns either a copy of an object's element at the specified key `key` or a given default value if no element with + key `key` exists. + + The function is basically equivalent to executing + ```cpp + try { + return at(key); + } catch(out_of_range) { + return default_value; + } + ``` + +2. See 1. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and + `#!cpp typename object_comparator_t::is_transparent` denotes a type. + +3. Returns either a copy of an object's element at the specified JSON pointer `ptr` or a given default value if no value + at `ptr` exists. + + The function is basically equivalent to executing + ```cpp + try { + return at(ptr); + } catch(out_of_range) { + return default_value; + } + ``` + +!!! note "Differences to `at` and `operator[]`" + + - Unlike [`at`](at.md), this function does not throw if the given `key`/`ptr` was not found. + - Unlike [`operator[]`](operator[].md), this function does not implicitly add an element to the position defined by + `key`/`ptr` key. This function is furthermore also applicable to const objects. + +## Template parameters + +`KeyType` +: A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with + [`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md). + This can also be a string view (C++17). +`ValueType` +: type compatible to JSON values, for instance `#!cpp int` for JSON integer numbers, `#!cpp bool` for JSON booleans, + or `#!cpp std::vector` types for JSON arrays. Note the type of the expected value at `key`/`ptr` and the default + value `default_value` must be compatible. + +## Parameters + +`key` (in) +: key of the element to access + +`default_value` (in) +: the value to return if `key`/`ptr` found no value + +`ptr` (in) +: a JSON pointer to the element to access + +## Return value + +1. copy of the element at key `key` or `default_value` if `key` is not found +2. copy of the element at key `key` or `default_value` if `key` is not found +3. copy of the element at JSON Pointer `ptr` or `default_value` if no value for `ptr` is found + +## Exception safety + +Strong guarantee: if an exception is thrown, there are no +changes to any JSON value. + +## Exceptions + +1. The function can throw the following exceptions: + - Throws [`type_error.302`](../../home/exceptions.md#jsonexceptiontype_error302) if `default_value` does not match + the type of the value at `key` + - Throws [`type_error.306`](../../home/exceptions.md#jsonexceptiontype_error306) if the JSON value is not an object; + in that case, using `value()` with a key makes no sense. +2. See 1. +3. The function can throw the following exceptions: + - Throws [`type_error.302`](../../home/exceptions.md#jsonexceptiontype_error302) if `default_value` does not match + the type of the value at `ptr` + - Throws [`type_error.306`](../../home/exceptions.md#jsonexceptiontype_error306) if the JSON value is not an object; + in that case, using `value()` with a key makes no sense. + +## Complexity + +1. Logarithmic in the size of the container. +2. Logarithmic in the size of the container. +3. Logarithmic in the size of the container. + +## Examples + +??? example "Example: (1) access specified object element with default value" + + The example below shows how object elements can be queried with a default value. + + ```cpp + --8<-- "examples/value__object_t_key_type.cpp" + ``` + + Output: + + ```json + --8<-- "examples/value__object_t_key_type.output" + ``` + +??? example "Example: (2) access specified object element using string_view with default value" + + The example below shows how object elements can be queried with a default value. + + ```cpp + --8<-- "examples/value__keytype.c++17.cpp" + ``` + + Output: + + ```json + --8<-- "examples/value__keytype.c++17.output" + ``` + +??? example "Example: (3) access specified object element via JSON Pointer with default value" + + The example below shows how object elements can be queried with a default value. + + ```cpp + --8<-- "examples/value__json_ptr.cpp" + ``` + + Output: + + ```json + --8<-- "examples/value__json_ptr.output" + ``` + +## See also + +- see [`at`](at.md) for access by reference with range checking +- see [`operator[]`](operator%5B%5D.md) for unchecked access by reference + +## Version history + +1. Added in version 1.0.0. Changed parameter `default_value` type from `const ValueType&` to `ValueType&&` in version 3.11.0. +2. Added in version 3.11.0. Made `ValueType` the first template parameter in version 3.11.2. +3. Added in version 2.0.2. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/value_t.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/value_t.md new file mode 100644 index 000000000..1505e02d0 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/value_t.md @@ -0,0 +1,81 @@ +# nlohmann::basic_json::value_t + +```cpp +enum class value_t : std::uint8_t { + null, + object, + array, + string, + boolean, + number_integer, + number_unsigned, + number_float, + binary, + discarded +}; +``` + +This enumeration collects the different JSON types. It is internally used to distinguish the stored values, and the +functions [`is_null`](is_null.md), [`is_object`](is_object.md), [`is_array`](is_array.md), [`is_string`](is_string.md), +[`is_boolean`](is_boolean.md), [`is_number`](is_number.md) (with [`is_number_integer`](is_number_integer.md), +[`is_number_unsigned`](is_number_unsigned.md), and [`is_number_float`](is_number_float.md)), +[`is_discarded`](is_discarded.md), [`is_binary`](is_binary.md), [`is_primitive`](is_primitive.md), and +[`is_structured`](is_structured.md) rely on it. + +## Notes + +!!! note "Ordering" + + The order of types is as follows: + + 1. `null` + 2. `boolean` + 3. `number_integer`, `number_unsigned`, `number_float` + 4. `object` + 5. `array` + 6. `string` + 7. `binary` + + `discarded` is unordered. + +!!! note "Types of numbers" + + There are three enumerators for numbers (`number_integer`, `number_unsigned`, and `number_float`) to distinguish + between different types of numbers: + + - [`number_unsigned_t`](number_unsigned_t.md) for unsigned integers + - [`number_integer_t`](number_integer_t.md) for signed integers + - [`number_float_t`](number_float_t.md) for floating-point numbers or to approximate integers which do not fit + into the limits of their respective type + +!!! warning "Comparison operators" + + `operator<` and `operator<=>` (since C++20) are overloaded and compare according to the ordering described above. + Until C++20 all other relational and equality operators yield results according to the integer value of each + enumerator. Since C++20 some compilers consider the _rewritten candidates_ generated from `operator<=>` during + overload resolution, while others do not. For predictable and portable behavior use: + + - `operator<` or `operator<=>` when wanting to compare according to the order described above + - `operator==` or `operator!=` when wanting to compare according to each enumerators integer value + +## Examples + +??? example + + The following code how `type()` queries the `value_t` for all JSON types. + + ```cpp + --8<-- "examples/type.cpp" + ``` + + Output: + + ```json + --8<-- "examples/type.output" + ``` + +## Version history + +- Added in version 1.0.0. +- Added unsigned integer type in version 2.0.0. +- Added binary type in version 3.8.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/basic_json/~basic_json.md b/external_imported/json/docs/mkdocs/docs/api/basic_json/~basic_json.md new file mode 100644 index 000000000..64e944006 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/basic_json/~basic_json.md @@ -0,0 +1,21 @@ +# nlohmann::basic_json::~basic_json + +```cpp +~basic_json() noexcept; +``` + +Destroys the JSON value and frees all allocated memory. + +## Exception safety + +No-throw guarantee: this member function never throws exceptions. + +## Complexity + +Linear. + + + +## Version history + +- Added in version 1.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/byte_container_with_subtype/byte_container_with_subtype.md b/external_imported/json/docs/mkdocs/docs/api/byte_container_with_subtype/byte_container_with_subtype.md new file mode 100644 index 000000000..9913a9b5c --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/byte_container_with_subtype/byte_container_with_subtype.md @@ -0,0 +1,46 @@ +# nlohmann::byte_container_with_subtype::byte_container_with_subtype + +```cpp +// (1) +byte_container_with_subtype(); + +// (2) +byte_container_with_subtype(const container_type& container); +byte_container_with_subtype(container_type&& container); + +// (3) +byte_container_with_subtype(const container_type& container, subtype_type subtype); +byte_container_with_subtype(container_type&& container, subtype_type subtype); +``` + +1. Create empty binary container without subtype. +2. Create binary container without subtype. +3. Create binary container with subtype. + +## Parameters + +`container` (in) +: binary container + +`subtype` (in) +: subtype + +## Examples + +??? example + + The example below demonstrates how byte containers can be created. + + ```cpp + --8<-- "examples/byte_container_with_subtype__byte_container_with_subtype.cpp" + ``` + + Output: + + ```json + --8<-- "examples/byte_container_with_subtype__byte_container_with_subtype.output" + ``` + +## Version history + +Since version 3.8.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/byte_container_with_subtype/clear_subtype.md b/external_imported/json/docs/mkdocs/docs/api/byte_container_with_subtype/clear_subtype.md new file mode 100644 index 000000000..c62dead36 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/byte_container_with_subtype/clear_subtype.md @@ -0,0 +1,36 @@ +# nlohmann::byte_container_with_subtype::clear_subtype + +```cpp +void clear_subtype() noexcept; +``` + +Clears the binary subtype and flags the value as not having a subtype, which has implications for serialization; for +instance MessagePack will prefer the bin family over the ext family. + +## Exception safety + +No-throw guarantee: this function never throws exceptions. + +## Complexity + +Constant. + +## Examples + +??? example + + The example below demonstrates how `clear_subtype` can remove subtypes. + + ```cpp + --8<-- "examples/byte_container_with_subtype__clear_subtype.cpp" + ``` + + Output: + + ```json + --8<-- "examples/byte_container_with_subtype__clear_subtype.output" + ``` + +## Version history + +Since version 3.8.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/byte_container_with_subtype/has_subtype.md b/external_imported/json/docs/mkdocs/docs/api/byte_container_with_subtype/has_subtype.md new file mode 100644 index 000000000..e06286e29 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/byte_container_with_subtype/has_subtype.md @@ -0,0 +1,39 @@ +# nlohmann::byte_container_with_subtype::has_subtype + +```cpp +constexpr bool has_subtype() const noexcept; +``` + +Returns whether the value has a subtype. + +## Return value + +whether the value has a subtype + +## Exception safety + +No-throw guarantee: this function never throws exceptions. + +## Complexity + +Constant. + +## Examples + +??? example + + The example below demonstrates how `has_subtype` can check whether a subtype was set. + + ```cpp + --8<-- "examples/byte_container_with_subtype__has_subtype.cpp" + ``` + + Output: + + ```json + --8<-- "examples/byte_container_with_subtype__has_subtype.output" + ``` + +## Version history + +Since version 3.8.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/byte_container_with_subtype/index.md b/external_imported/json/docs/mkdocs/docs/api/byte_container_with_subtype/index.md new file mode 100644 index 000000000..277fffa34 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/byte_container_with_subtype/index.md @@ -0,0 +1,35 @@ +# nlohmann::byte_container_with_subtype + +```cpp +template +class byte_container_with_subtype : public BinaryType; +``` + +This type extends the template parameter `BinaryType` provided to [`basic_json`](../basic_json/index.md) with a subtype +used by BSON and MessagePack. This type exists so that the user does not have to specify a type themselves with a +specific naming scheme in order to override the binary type. + +## Template parameters + +`BinaryType` +: container to store bytes (`#!cpp std::vector` by default) + +## Member types + +- **container_type** - the type of the underlying container (`BinaryType`) +- **subtype_type** - the type of the subtype (`#!cpp std::uint64_t`) + +## Member functions + +- [(constructor)](byte_container_with_subtype.md) +- **operator==** - comparison: equal +- **operator!=** - comparison: not equal +- [**set_subtype**](subtype.md) - sets the binary subtype +- [**subtype**](subtype.md) - return the binary subtype +- [**has_subtype**](has_subtype.md) - return whether the value has a subtype +- [**clear_subtype**](clear_subtype.md) - clears the binary subtype + +## Version history + +- Added in version 3.8.0. +- Changed type of subtypes to `#!cpp std::uint64_t` in 3.10.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/byte_container_with_subtype/set_subtype.md b/external_imported/json/docs/mkdocs/docs/api/byte_container_with_subtype/set_subtype.md new file mode 100644 index 000000000..cf21732b8 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/byte_container_with_subtype/set_subtype.md @@ -0,0 +1,41 @@ +# nlohmann::byte_container_with_subtype::set_subtype + +```cpp +void set_subtype(subtype_type subtype) noexcept; +``` + +Sets the binary subtype of the value, also flags a binary JSON value as having a subtype, which has implications for +serialization. + +## Parameters + +`subtype` (in) +: subtype to set + +## Exception safety + +No-throw guarantee: this function never throws exceptions. + +## Complexity + +Constant. + +## Examples + +??? example + + The example below demonstrates how a subtype can be set with `set_subtype`. + + ```cpp + --8<-- "examples/byte_container_with_subtype__set_subtype.cpp" + ``` + + Output: + + ```json + --8<-- "examples/byte_container_with_subtype__set_subtype.output" + ``` + +## Version history + +Since version 3.8.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/byte_container_with_subtype/subtype.md b/external_imported/json/docs/mkdocs/docs/api/byte_container_with_subtype/subtype.md new file mode 100644 index 000000000..389241a79 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/byte_container_with_subtype/subtype.md @@ -0,0 +1,42 @@ +# nlohmann::byte_container_with_subtype::subtype + +```cpp +constexpr subtype_type subtype() const noexcept; +``` + +Returns the numerical subtype of the value if it has a subtype. If it does not have a subtype, this function will return +`subtype_type(-1)` as a sentinel value. + +## Return value + +the numerical subtype of the binary value, or `subtype_type(-1)` if no subtype is set + +## Exception safety + +No-throw guarantee: this function never throws exceptions. + +## Complexity + +Constant. + +## Examples + +??? example + + The example below demonstrates how the subtype can be retrieved with `subtype`. Note how `subtype_type(-1)` is + returned for container `c1`. + + ```cpp + --8<-- "examples/byte_container_with_subtype__subtype.cpp" + ``` + + Output: + + ```json + --8<-- "examples/byte_container_with_subtype__subtype.output" + ``` + +## Version history + +- Added in version 3.8.0 +- Fixed return value to properly return `subtype_type(-1)` as documented in version 3.10.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json.md b/external_imported/json/docs/mkdocs/docs/api/json.md new file mode 100644 index 000000000..36edcc2c1 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json.md @@ -0,0 +1,28 @@ +# nlohmann::json + +```cpp +using json = basic_json<>; +``` + +This type is the default specialization of the [basic_json](basic_json/index.md) class which uses the standard template +types. + +## Examples + +??? example + + The example below demonstrates how to use the type `nlohmann::json`. + + ```cpp + --8<-- "examples/README.cpp" + ``` + + Output: + + ```json + --8<-- "examples/README.output" + ``` + +## Version history + +Since version 1.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_pointer/back.md b/external_imported/json/docs/mkdocs/docs/api/json_pointer/back.md new file mode 100644 index 000000000..240bc6e1e --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_pointer/back.md @@ -0,0 +1,40 @@ +# nlohmann::json_pointer::back + +```cpp +const string_t& back() const; +``` + +Return last reference token. + +## Return value + +Last reference token. + +## Exceptions + +Throws [out_of_range.405](../../home/exceptions.md#jsonexceptionout_of_range405) if JSON pointer has no parent. + +## Complexity + +Constant. + +## Examples + +??? example + + The example shows the usage of `back`. + + ```cpp + --8<-- "examples/json_pointer__back.cpp" + ``` + + Output: + + ```json + --8<-- "examples/json_pointer__back.output" + ``` + +## Version history + +- Added in version 3.6.0. +- Changed return type to `string_t` in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_pointer/empty.md b/external_imported/json/docs/mkdocs/docs/api/json_pointer/empty.md new file mode 100644 index 000000000..346364ad5 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_pointer/empty.md @@ -0,0 +1,39 @@ +# nlohmann::json_pointer::empty + +```cpp +bool empty() const noexcept; +``` + +Return whether pointer points to the root document. + +## Return value + +`#!cpp true` iff the JSON pointer points to the root document. + +## Exception safety + +No-throw guarantee: this function never throws exceptions. + +## Complexity + +Constant. + +## Examples + +??? example + + The example shows the result of `empty` for different JSON Pointers. + + ```cpp + --8<-- "examples/json_pointer__empty.cpp" + ``` + + Output: + + ```json + --8<-- "examples/json_pointer__empty.output" + ``` + +## Version history + +Added in version 3.6.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_pointer/index.md b/external_imported/json/docs/mkdocs/docs/api/json_pointer/index.md new file mode 100644 index 000000000..22e246405 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_pointer/index.md @@ -0,0 +1,52 @@ +# nlohmann::json_pointer + +```cpp +template +class json_pointer; +``` + +A JSON pointer defines a string syntax for identifying a specific value within a JSON document. It can be used with +functions [`at`](../basic_json/at.md) and [`operator[]`](../basic_json/operator%5B%5D.md). Furthermore, JSON pointers +are the base for JSON patches. + +## Template parameters + +`RefStringType` +: the string type used for the reference tokens making up the JSON pointer + +!!! warning "Deprecation" + + For backwards compatibility `RefStringType` may also be a specialization of [`basic_json`](../basic_json/index.md) + in which case `string_t` will be deduced as [`basic_json::string_t`](../basic_json/string_t.md). This feature is + deprecated and may be removed in a future major version. + +## Member types + +- [**string_t**](string_t.md) - the string type used for the reference tokens + +## Member functions + +- [(constructor)](json_pointer.md) +- [**to_string**](to_string.md) - return a string representation of the JSON pointer +- [**operator string_t**](operator_string_t.md) - return a string representation of the JSON pointer +- [**operator==**](operator_eq.md) - compare: equal +- [**operator!=**](operator_ne.md) - compare: not equal +- [**operator/=**](operator_slasheq.md) - append to the end of the JSON pointer +- [**operator/**](operator_slash.md) - create JSON Pointer by appending +- [**parent_pointer**](parent_pointer.md) - returns the parent of this JSON pointer +- [**pop_back**](pop_back.md) - remove last reference token +- [**back**](back.md) - return last reference token +- [**push_back**](push_back.md) - append an unescaped token at the end of the pointer +- [**empty**](empty.md) - return whether pointer points to the root document + +## Literals + +- [**operator""_json_pointer**](../operator_literal_json_pointer.md) - user-defined string literal for JSON pointers +## See also + +- [RFC 6901](https://datatracker.ietf.org/doc/html/rfc6901) + +## Version history + +- Added in version 2.0.0. +- Changed template parameter from `basic_json` to string type in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_pointer/json_pointer.md b/external_imported/json/docs/mkdocs/docs/api/json_pointer/json_pointer.md new file mode 100644 index 000000000..5e7057fc9 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_pointer/json_pointer.md @@ -0,0 +1,41 @@ +# nlohmann::json_pointer::json_pointer + +```cpp +explicit json_pointer(const string_t& s = ""); +``` + +Create a JSON pointer according to the syntax described in +[Section 3 of RFC6901](https://tools.ietf.org/html/rfc6901#section-3). + +## Parameters + +`s` (in) +: string representing the JSON pointer; if omitted, the empty string is assumed which references the whole JSON value + +## Exceptions + +- Throws [parse_error.107](../../home/exceptions.md#jsonexceptionparse_error107) if the given JSON pointer `s` is + nonempty and does not begin with a slash (`/`); see example below. +- Throws [parse_error.108](../../home/exceptions.md#jsonexceptionparse_error108) if a tilde (`~`) in the given JSON + pointer `s` is not followed by `0` (representing `~`) or `1` (representing `/`); see example below. + +## Examples + +??? example + + The example shows the construction several valid JSON pointers as well as the exceptional behavior. + + ```cpp + --8<-- "examples/json_pointer.cpp" + ``` + + Output: + + ```json + --8<-- "examples/json_pointer.output" + ``` + +## Version history + +- Added in version 2.0.0. +- Changed type of `s` to `string_t` in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_pointer/operator_eq.md b/external_imported/json/docs/mkdocs/docs/api/json_pointer/operator_eq.md new file mode 100644 index 000000000..807ae1d0c --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_pointer/operator_eq.md @@ -0,0 +1,113 @@ +# nlohmann::json_pointer::operator== + +```cpp +// until C++20 +template +bool operator==( + const json_pointer& lhs, + const json_pointer& rhs) noexcept; // (1) + +template +bool operator==( + const json_pointer& lhs, + const StringType& rhs); // (2) + +template +bool operator==( + const StringType& lhs, + const json_pointer& rhs); // (2) + +// since C++20 +class json_pointer { + template + bool operator==( + const json_pointer& rhs) const noexcept; // (1) + + bool operator==(const string_t& rhs) const; // (2) +}; +``` + +1. Compares two JSON pointers for equality by comparing their reference tokens. + +2. Compares a JSON pointer and a string or a string and a JSON pointer for equality by converting the string to a JSON + pointer and comparing the JSON pointers according to 1. + +## Template parameters + +`RefStringTypeLhs`, `RefStringTypeRhs` +: the string type of the left-hand side or right-hand side JSON pointer, respectively + +`StringType` +: the string type derived from the `json_pointer` operand ([`json_pointer::string_t`](string_t.md)) + +## Parameters + +`lhs` (in) +: first value to consider + +`rhs` (in) +: second value to consider + +## Return value + +whether the values `lhs`/`*this` and `rhs` are equal + +## Exception safety + +1. No-throw guarantee: this function never throws exceptions. +2. Strong exception safety: if an exception occurs, the original value stays intact. + +## Exceptions + +1. (none) +2. The function can throw the following exceptions: + - Throws [parse_error.107](../../home/exceptions.md#jsonexceptionparse_error107) if the given JSON pointer `s` is + nonempty and does not begin with a slash (`/`); see example below. + - Throws [parse_error.108](../../home/exceptions.md#jsonexceptionparse_error108) if a tilde (`~`) in the given JSON + pointer `s` is not followed by `0` (representing `~`) or `1` (representing `/`); see example below. + +## Complexity + +Constant if `lhs` and `rhs` differ in the number of reference tokens, otherwise linear in the number of reference +tokens. + +## Notes + +!!! warning "Deprecation" + + Overload 2 is deprecated and will be removed in a future major version release. + +## Examples + +??? example "Example: (1) Comparing JSON pointers" + + The example demonstrates comparing JSON pointers. + + ```cpp + --8<-- "examples/json_pointer__operator__equal.cpp" + ``` + + Output: + + ``` + --8<-- "examples/json_pointer__operator__equal.output" + ``` + +??? example "Example: (2) Comparing JSON pointers and strings" + + The example demonstrates comparing JSON pointers and strings, and when doing so may raise an exception. + + ```cpp + --8<-- "examples/json_pointer__operator__equal_stringtype.cpp" + ``` + + Output: + + ``` + --8<-- "examples/json_pointer__operator__equal_stringtype.output" + ``` + +## Version history + +1. Added in version 2.1.0. Added C++20 member functions in version 3.11.2. +2. Added for backward compatibility and deprecated in version 3.11.2. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_pointer/operator_ne.md b/external_imported/json/docs/mkdocs/docs/api/json_pointer/operator_ne.md new file mode 100644 index 000000000..1f3e3247e --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_pointer/operator_ne.md @@ -0,0 +1,109 @@ +# nlohmann::json_pointer::operator!= + +```cpp +// until C++20 +template +bool operator!=( + const json_pointer& lhs, + const json_pointer& rhs) noexcept; // (1) + +template +bool operator!=( + const json_pointer& lhs, + const StringType& rhs); // (2) + +template +bool operator!=( + const StringType& lhs, + const json_pointer& rhs); // (2) +``` + +1. Compares two JSON pointers for inequality by comparing their reference tokens. + +2. Compares a JSON pointer and a string or a string and a JSON pointer for inequality by converting the string to a + JSON pointer and comparing the JSON pointers according to 1. + +## Template parameters + +`RefStringTypeLhs`, `RefStringTypeRhs` +: the string type of the left-hand side or right-hand side JSON pointer, respectively + +`StringType` +: the string type derived from the `json_pointer` operand ([`json_pointer::string_t`](string_t.md)) + +## Parameters + +`lhs` (in) +: first value to consider + +`rhs` (in) +: second value to consider + +## Return value + +whether the values `lhs`/`*this` and `rhs` are not equal + +## Exception safety + +1. No-throw guarantee: this function never throws exceptions. +2. Strong exception safety: if an exception occurs, the original value stays intact. + +## Exceptions + +1. (none) +2. The function can throw the following exceptions: + - Throws [parse_error.107](../../home/exceptions.md#jsonexceptionparse_error107) if the given JSON pointer `s` is + nonempty and does not begin with a slash (`/`); see example below. + - Throws [parse_error.108](../../home/exceptions.md#jsonexceptionparse_error108) if a tilde (`~`) in the given JSON + pointer `s` is not followed by `0` (representing `~`) or `1` (representing `/`); see example below. + +## Complexity + +Constant if `lhs` and `rhs` differ in the number of reference tokens, otherwise linear in the number of reference +tokens. + +## Notes + +!!! note "Operator overload resolution" + + Since C++20 overload resolution will consider the _rewritten candidate_ generated from + [`operator==`](operator_eq.md). + +!!! warning "Deprecation" + + Overload 2 is deprecated and will be removed in a future major version release. + +## Examples + +??? example "Example: (1) Comparing JSON pointers" + + The example demonstrates comparing JSON pointers. + + ```cpp + --8<-- "examples/json_pointer__operator__notequal.cpp" + ``` + + Output: + + ``` + --8<-- "examples/json_pointer__operator__notequal.output" + ``` + +??? example "Example: (2) Comparing JSON pointers and strings" + + The example demonstrates comparing JSON pointers and strings, and when doing so may raise an exception. + + ```cpp + --8<-- "examples/json_pointer__operator__notequal_stringtype.cpp" + ``` + + Output: + + ``` + --8<-- "examples/json_pointer__operator__notequal_stringtype.output" + ``` + +## Version history + +1. Added in version 2.1.0. +2. Added for backward compatibility and deprecated in version 3.11.2. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_pointer/operator_slash.md b/external_imported/json/docs/mkdocs/docs/api/json_pointer/operator_slash.md new file mode 100644 index 000000000..ed77b504b --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_pointer/operator_slash.md @@ -0,0 +1,64 @@ +# nlohmann::json_pointer::operator/ + +```cpp +// (1) +json_pointer operator/(const json_pointer& lhs, const json_pointer& rhs); + +// (2) +json_pointer operator/(const json_pointer& lhs, string_t token); + +// (3) +json_pointer operator/(const json_pointer& lhs, std::size_t array_idx); +``` + +1. create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer +2. create a new JSON pointer by appending the unescaped token at the end of the JSON pointer +3. create a new JSON pointer by appending the array-index-token at the end of the JSON pointer + +## Parameters + +`lhs` (in) +: JSON pointer + +`rhs` (in) +: JSON pointer to append + +`token` (in) +: reference token to append + +`array_idx` (in) +: array index to append + +## Return value + +1. a new JSON pointer with `rhs` appended to `lhs` +2. a new JSON pointer with unescaped `token` appended to `lhs` +3. a new JSON pointer with `array_idx` appended to `lhs` + +## Complexity + +1. Linear in the length of `lhs` and `rhs`. +2. Linear in the length of `lhs`. +3. Linear in the length of `lhs`. + +## Examples + +??? example + + The example shows the usage of `operator/`. + + ```cpp + --8<-- "examples/json_pointer__operator_add_binary.cpp" + ``` + + Output: + + ```json + --8<-- "examples/json_pointer__operator_add_binary.output" + ``` + +## Version history + +1. Added in version 3.6.0. +2. Added in version 3.6.0. Changed type of `token` to `string_t` in version 3.11.0. +3. Added in version 3.6.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_pointer/operator_slasheq.md b/external_imported/json/docs/mkdocs/docs/api/json_pointer/operator_slasheq.md new file mode 100644 index 000000000..3518557d5 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_pointer/operator_slasheq.md @@ -0,0 +1,61 @@ +# nlohmann::json_pointer::operator/= + +```cpp +// (1) +json_pointer& operator/=(const json_pointer& ptr); + +// (2) +json_pointer& operator/=(string_t token); + +// (3) +json_pointer& operator/=(std::size_t array_idx) +``` + +1. append another JSON pointer at the end of this JSON pointer +2. append an unescaped reference token at the end of this JSON pointer +3. append an array index at the end of this JSON pointer + +## Parameters + +`ptr` (in) +: JSON pointer to append + +`token` (in) +: reference token to append + +`array_idx` (in) +: array index to append + +## Return value + +1. JSON pointer with `ptr` appended +2. JSON pointer with `token` appended without escaping `token` +3. JSON pointer with `array_idx` appended + +## Complexity + +1. Linear in the length of `ptr`. +2. Amortized constant. +3. Amortized constant. + +## Examples + +??? example + + The example shows the usage of `operator/=`. + + ```cpp + --8<-- "examples/json_pointer__operator_add.cpp" + ``` + + Output: + + ```json + --8<-- "examples/json_pointer__operator_add.output" + ``` + +## Version history + +1. Added in version 3.6.0. +2. Added in version 3.6.0. Changed type of `token` to `string_t` in version 3.11.0. +3. Added in version 3.6.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_pointer/operator_string_t.md b/external_imported/json/docs/mkdocs/docs/api/json_pointer/operator_string_t.md new file mode 100644 index 000000000..74105a4f1 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_pointer/operator_string_t.md @@ -0,0 +1,48 @@ +# nlohmann::json_pointer::operator string_t + +```cpp +operator string_t() const +``` + +Return a string representation of the JSON pointer. + +## Return value + +A string representation of the JSON pointer + +## Possible implementation + +```cpp +operator string_t() const +{ + return to_string(); +} +``` + +## Notes + +!!! warning "Deprecation" + + This function is deprecated in favor of [`to_string`](to_string.md) and will be removed in a future major version + release. + +## Examples + +??? example + + The example shows how JSON Pointers can be implicitly converted to strings. + + ```cpp + --8<-- "examples/json_pointer__operator_string_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/json_pointer__operator_string_t.output" + ``` + +## Version history + +- Since version 2.0.0. +- Changed type to `string_t` and deprecated in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_pointer/parent_pointer.md b/external_imported/json/docs/mkdocs/docs/api/json_pointer/parent_pointer.md new file mode 100644 index 000000000..139873072 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_pointer/parent_pointer.md @@ -0,0 +1,35 @@ +# nlohmann::json_pointer::parent_pointer + +```cpp +json_pointer parent_pointer() const; +``` + +Returns the parent of this JSON pointer. + +## Return value + +Parent of this JSON pointer; in case this JSON pointer is the root, the root itself is returned. + +## Complexity + +Linear in the length of the JSON pointer. + +## Examples + +??? example + + The example shows the result of `parent_pointer` for different JSON Pointers. + + ```cpp + --8<-- "examples/json_pointer__parent_pointer.cpp" + ``` + + Output: + + ```json + --8<-- "examples/json_pointer__parent_pointer.output" + ``` + +## Version history + +Added in version 3.6.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_pointer/pop_back.md b/external_imported/json/docs/mkdocs/docs/api/json_pointer/pop_back.md new file mode 100644 index 000000000..3c79f3638 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_pointer/pop_back.md @@ -0,0 +1,35 @@ +# nlohmann::json_pointer::pop_back + +```cpp +void pop_back(); +``` + +Remove last reference token. + +## Exceptions + +Throws [out_of_range.405](../../home/exceptions.md#jsonexceptionout_of_range405) if JSON pointer has no parent. + +## Complexity + +Constant. + +## Examples + +??? example + + The example shows the usage of `pop_back`. + + ```cpp + --8<-- "examples/json_pointer__pop_back.cpp" + ``` + + Output: + + ```json + --8<-- "examples/json_pointer__pop_back.output" + ``` + +## Version history + +Added in version 3.6.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_pointer/push_back.md b/external_imported/json/docs/mkdocs/docs/api/json_pointer/push_back.md new file mode 100644 index 000000000..c1c19cb8d --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_pointer/push_back.md @@ -0,0 +1,39 @@ +# nlohmann::json_pointer::push_back + +```cpp +void push_back(const string_t& token); + +void push_back(string_t&& token); +``` + +Append an unescaped token at the end of the reference pointer. + +## Parameters + +`token` (in) +: token to add + +## Complexity + +Amortized constant. + +## Examples + +??? example + + The example shows the result of `push_back` for different JSON Pointers. + + ```cpp + --8<-- "examples/json_pointer__push_back.cpp" + ``` + + Output: + + ```json + --8<-- "examples/json_pointer__push_back.output" + ``` + +## Version history + +- Added in version 3.6.0. +- Changed type of `token` to `string_t` in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_pointer/string_t.md b/external_imported/json/docs/mkdocs/docs/api/json_pointer/string_t.md new file mode 100644 index 000000000..c8527bc9c --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_pointer/string_t.md @@ -0,0 +1,28 @@ +# nlohmann::json_pointer::string_t +```cpp +using string_t = RefStringType; +``` + +The string type used for the reference tokens making up the JSON pointer. + +See [`basic_json::string_t`](../basic_json/string_t.md) for more information. + +## Examples + +??? example + + The example shows the type `string_t` and its relation to `basic_json::string_t`. + + ```cpp + --8<-- "examples/json_pointer__string_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/json_pointer__string_t.output" + ``` + +## Version history + +- Added in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_pointer/to_string.md b/external_imported/json/docs/mkdocs/docs/api/json_pointer/to_string.md new file mode 100644 index 000000000..fae3abe5f --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_pointer/to_string.md @@ -0,0 +1,40 @@ +# nlohmann::json_pointer::to_string + +```cpp +string_t to_string() const; +``` + +Return a string representation of the JSON pointer. + +## Return value + +A string representation of the JSON pointer + +## Notes + +For each JSON pointer `ptr`, it holds: + +```cpp +ptr == json_pointer(ptr.to_string()); +``` + +## Examples + +??? example + + The example shows the result of `to_string`. + + ```cpp + --8<-- "examples/json_pointer__to_string.cpp" + ``` + + Output: + + ```json + --8<-- "examples/json_pointer__to_string.output" + ``` + +## Version history + +- Since version 2.0.0. +- Changed return type to `string_t` in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_sax/binary.md b/external_imported/json/docs/mkdocs/docs/api/json_sax/binary.md new file mode 100644 index 000000000..fc0980e20 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_sax/binary.md @@ -0,0 +1,40 @@ +# nlohmann::json_sax::binary + +```cpp +virtual bool binary(binary_t& val) = 0; +``` + +A binary value was read. + +## Parameters + +`val` (in) +: binary value + +## Return value + +Whether parsing should proceed. + +## Notes + +It is safe to move the passed binary value. + +## Examples + +??? example + + The example below shows how the SAX interface is used. + + ```cpp + --8<-- "examples/sax_parse__binary.cpp" + ``` + + Output: + + ```json + --8<-- "examples/sax_parse__binary.output" + ``` + +## Version history + +- Added in version 3.8.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_sax/boolean.md b/external_imported/json/docs/mkdocs/docs/api/json_sax/boolean.md new file mode 100644 index 000000000..fdf294562 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_sax/boolean.md @@ -0,0 +1,36 @@ +# nlohmann::json_sax::boolean + +```cpp +virtual bool boolean(bool val) = 0; +``` + +A boolean value was read. + +## Parameters + +`val` (in) +: boolean value + +## Return value + +Whether parsing should proceed. + +## Examples + +??? example + + The example below shows how the SAX interface is used. + + ```cpp + --8<-- "examples/sax_parse.cpp" + ``` + + Output: + + ```json + --8<-- "examples/sax_parse.output" + ``` + +## Version history + +- Added in version 3.2.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_sax/end_array.md b/external_imported/json/docs/mkdocs/docs/api/json_sax/end_array.md new file mode 100644 index 000000000..9c12e40a5 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_sax/end_array.md @@ -0,0 +1,31 @@ +# nlohmann::json_sax::end_array + +```cpp +virtual bool end_array() = 0; +``` + +The end of an array was read. + +## Return value + +Whether parsing should proceed. + +## Examples + +??? example + + The example below shows how the SAX interface is used. + + ```cpp + --8<-- "examples/sax_parse.cpp" + ``` + + Output: + + ```json + --8<-- "examples/sax_parse.output" + ``` + +## Version history + +- Added in version 3.2.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_sax/end_object.md b/external_imported/json/docs/mkdocs/docs/api/json_sax/end_object.md new file mode 100644 index 000000000..601c94a4a --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_sax/end_object.md @@ -0,0 +1,31 @@ +# nlohmann::json_sax::end_object + +```cpp +virtual bool end_object() = 0; +``` + +The end of an object was read. + +## Return value + +Whether parsing should proceed. + +## Examples + +??? example + + The example below shows how the SAX interface is used. + + ```cpp + --8<-- "examples/sax_parse.cpp" + ``` + + Output: + + ```json + --8<-- "examples/sax_parse.output" + ``` + +## Version history + +- Added in version 3.2.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_sax/index.md b/external_imported/json/docs/mkdocs/docs/api/json_sax/index.md new file mode 100644 index 000000000..f63e85c9a --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_sax/index.md @@ -0,0 +1,44 @@ +# nlohmann::json_sax + +```cpp +template +struct json_sax; +``` + +This class describes the SAX interface used by [sax_parse](../basic_json/sax_parse.md). Each function is called in +different situations while the input is parsed. The boolean return value informs the parser whether to continue +processing the input. + +## Template parameters + +`BasicJsonType` +: a specialization of [`basic_json`](../basic_json/index.md) + +## Member types + +- [**number_integer_t**](../basic_json/number_integer_t.md) - `BasicJsonType`'s type for numbers (integer) +- [**number_unsigned_t**](../basic_json/number_unsigned_t.md) - `BasicJsonType`'s type for numbers (unsigned) +- [**number_float_t**](../basic_json/number_float_t.md) - `BasicJsonType`'s type for numbers (floating-point) +- [**string_t**](../basic_json/string_t.md) - `BasicJsonType`'s type for strings +- [**binary_t**](../basic_json/binary_t.md) - `BasicJsonType`'s type for binary arrays + +## Member functions + +- [**binary**](binary.md) (_virtual_) - a binary value was read +- [**boolean**](boolean.md) (_virtual_) - a boolean value was read +- [**end_array**](end_array.md) (_virtual_) - the end of an array was read +- [**end_object**](end_object.md) (_virtual_) - the end of an object was read +- [**key**](key.md) (_virtual_) - an object key was read +- [**null**](null.md) (_virtual_) - a null value was read +- [**number_float**](number_float.md) (_virtual_) - a floating-point number was read +- [**number_integer**](number_integer.md) (_virtual_) - an integer number was read +- [**number_unsigned**](number_unsigned.md) (_virtual_) - an unsigned integer number was read +- [**parse_error**](parse_error.md) (_virtual_) - a parse error occurred +- [**start_array**](start_array.md) (_virtual_) - the beginning of an array was read +- [**start_object**](start_object.md) (_virtual_) - the beginning of an object was read +- [**string**](string.md) (_virtual_) - a string value was read + +## Version history + +- Added in version 3.2.0. +- Support for binary values (`binary_t`, `binary`) added in version 3.8.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_sax/key.md b/external_imported/json/docs/mkdocs/docs/api/json_sax/key.md new file mode 100644 index 000000000..31fd6c1d1 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_sax/key.md @@ -0,0 +1,40 @@ +# nlohmann::json_sax::key + +```cpp +virtual bool key(string_t& val) = 0; +``` + +An object key was read. + +## Parameters + +`val` (in) +: object key + +## Return value + +Whether parsing should proceed. + +## Notes + +It is safe to move the passed object key value. + +## Examples + +??? example + + The example below shows how the SAX interface is used. + + ```cpp + --8<-- "examples/sax_parse.cpp" + ``` + + Output: + + ```json + --8<-- "examples/sax_parse.output" + ``` + +## Version history + +- Added in version 3.2.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_sax/null.md b/external_imported/json/docs/mkdocs/docs/api/json_sax/null.md new file mode 100644 index 000000000..9354ede6c --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_sax/null.md @@ -0,0 +1,31 @@ +# nlohmann::json_sax::null + +```cpp +virtual bool null() = 0; +``` + +A null value was read. + +## Return value + +Whether parsing should proceed. + +## Examples + +??? example + + The example below shows how the SAX interface is used. + + ```cpp + --8<-- "examples/sax_parse.cpp" + ``` + + Output: + + ```json + --8<-- "examples/sax_parse.output" + ``` + +## Version history + +- Added in version 3.2.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_sax/number_float.md b/external_imported/json/docs/mkdocs/docs/api/json_sax/number_float.md new file mode 100644 index 000000000..17799401e --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_sax/number_float.md @@ -0,0 +1,39 @@ +# nlohmann::json_sax::number_float + +```cpp +virtual bool number_float(number_float_t val, const string_t& s) = 0; +``` + +A floating-point number was read. + +## Parameters + +`val` (in) +: floating-point value + +`s` (in) +: string representation of the original input + +## Return value + +Whether parsing should proceed. + +## Examples + +??? example + + The example below shows how the SAX interface is used. + + ```cpp + --8<-- "examples/sax_parse.cpp" + ``` + + Output: + + ```json + --8<-- "examples/sax_parse.output" + ``` + +## Version history + +- Added in version 3.2.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_sax/number_integer.md b/external_imported/json/docs/mkdocs/docs/api/json_sax/number_integer.md new file mode 100644 index 000000000..5c3cb4f31 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_sax/number_integer.md @@ -0,0 +1,36 @@ +# nlohmann::json_sax::number_integer + +```cpp +virtual bool number_integer(number_integer_t val) = 0; +``` + +An integer number was read. + +## Parameters + +`val` (in) +: integer value + +## Return value + +Whether parsing should proceed. + +## Examples + +??? example + + The example below shows how the SAX interface is used. + + ```cpp + --8<-- "examples/sax_parse.cpp" + ``` + + Output: + + ```json + --8<-- "examples/sax_parse.output" + ``` + +## Version history + +- Added in version 3.2.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_sax/number_unsigned.md b/external_imported/json/docs/mkdocs/docs/api/json_sax/number_unsigned.md new file mode 100644 index 000000000..0ac250037 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_sax/number_unsigned.md @@ -0,0 +1,36 @@ +# nlohmann::json_sax::number_unsigned + +```cpp +virtual bool number_unsigned(number_unsigned_t val) = 0; +``` + +An unsigned integer number was read. + +## Parameters + +`val` (in) +: unsigned integer value + +## Return value + +Whether parsing should proceed. + +## Examples + +??? example + + The example below shows how the SAX interface is used. + + ```cpp + --8<-- "examples/sax_parse.cpp" + ``` + + Output: + + ```json + --8<-- "examples/sax_parse.output" + ``` + +## Version history + +- Added in version 3.2.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_sax/parse_error.md b/external_imported/json/docs/mkdocs/docs/api/json_sax/parse_error.md new file mode 100644 index 000000000..e41cb67ff --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_sax/parse_error.md @@ -0,0 +1,44 @@ +# nlohmann::json_sax::parse_error + +```cpp +virtual bool parse_error(std::size_t position, + const std::string& last_token, + const detail::exception& ex) = 0; +``` + +A parse error occurred. + +## Parameters + +`position` (in) +: the position in the input where the error occurs + +`last_token` (in) +: the last read token + +`ex` (in) +: an exception object describing the error + +## Return value + +Whether parsing should proceed (**must return `#!cpp false`**). + +## Examples + +??? example + + The example below shows how the SAX interface is used. + + ```cpp + --8<-- "examples/sax_parse.cpp" + ``` + + Output: + + ```json + --8<-- "examples/sax_parse.output" + ``` + +## Version history + +- Added in version 3.2.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_sax/start_array.md b/external_imported/json/docs/mkdocs/docs/api/json_sax/start_array.md new file mode 100644 index 000000000..cf2b8cf56 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_sax/start_array.md @@ -0,0 +1,40 @@ +# nlohmann::json_sax::start_array + +```cpp +virtual bool start_array(std::size_t elements) = 0; +``` + +The beginning of an array was read. + +## Parameters + +`elements` (in) +: number of object elements or `#!cpp -1` if unknown + +## Return value + +Whether parsing should proceed. + +## Notes + +Binary formats may report the number of elements. + +## Examples + +??? example + + The example below shows how the SAX interface is used. + + ```cpp + --8<-- "examples/sax_parse.cpp" + ``` + + Output: + + ```json + --8<-- "examples/sax_parse.output" + ``` + +## Version history + +- Added in version 3.2.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_sax/start_object.md b/external_imported/json/docs/mkdocs/docs/api/json_sax/start_object.md new file mode 100644 index 000000000..491815deb --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_sax/start_object.md @@ -0,0 +1,40 @@ +# nlohmann::json_sax::start_object + +```cpp +virtual bool start_object(std::size_t elements) = 0; +``` + +The beginning of an object was read. + +## Parameters + +`elements` (in) +: number of object elements or `#!cpp -1` if unknown + +## Return value + +Whether parsing should proceed. + +## Notes + +Binary formats may report the number of elements. + +## Examples + +??? example + + The example below shows how the SAX interface is used. + + ```cpp + --8<-- "examples/sax_parse.cpp" + ``` + + Output: + + ```json + --8<-- "examples/sax_parse.output" + ``` + +## Version history + +- Added in version 3.2.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/json_sax/string.md b/external_imported/json/docs/mkdocs/docs/api/json_sax/string.md new file mode 100644 index 000000000..dcffb5f61 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/json_sax/string.md @@ -0,0 +1,40 @@ +# nlohmann::json_sax::string + +```cpp +virtual bool string(string_t& val) = 0; +``` + +A string value was read. + +## Parameters + +`val` (in) +: string value + +## Return value + +Whether parsing should proceed. + +## Notes + +It is safe to move the passed string value. + +## Examples + +??? example + + The example below shows how the SAX interface is used. + + ```cpp + --8<-- "examples/sax_parse.cpp" + ``` + + Output: + + ```json + --8<-- "examples/sax_parse.output" + ``` + +## Version history + +- Added in version 3.2.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/index.md b/external_imported/json/docs/mkdocs/docs/api/macros/index.md new file mode 100644 index 000000000..ae9eb2044 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/index.md @@ -0,0 +1,62 @@ +# Macros + +Some aspects of the library can be configured by defining preprocessor macros **before** including the `json.hpp` +header. See also the [macro overview page](../../features/macros.md). + +## Runtime assertions + +- [**JSON_ASSERT(x)**](json_assert.md) - control behavior of runtime assertions + +## Exceptions + +- [**JSON_CATCH_USER(exception)**
**JSON_THROW_USER(exception)**
**JSON_TRY_USER**](json_throw_user.md) - control exceptions +- [**JSON_DIAGNOSTICS**](json_diagnostics.md) - control extended diagnostics +- [**JSON_NOEXCEPTION**](json_noexception.md) - switch off exceptions + +## Language support + +- [**JSON_HAS_CPP_11**
**JSON_HAS_CPP_14**
**JSON_HAS_CPP_17**
**JSON_HAS_CPP_20**](json_has_cpp_11.md) - set supported C++ standard +- [**JSON_HAS_FILESYSTEM**
**JSON_HAS_EXPERIMENTAL_FILESYSTEM**](json_has_filesystem.md) - control `std::filesystem` support +- [**JSON_HAS_RANGES**](json_has_ranges.md) - control `std::ranges` support +- [**JSON_HAS_THREE_WAY_COMPARISON**](json_has_three_way_comparison.md) - control 3-way comparison support +- [**JSON_NO_IO**](json_no_io.md) - switch off functions relying on certain C++ I/O headers +- [**JSON_SKIP_UNSUPPORTED_COMPILER_CHECK**](json_skip_unsupported_compiler_check.md) - do not warn about unsupported compilers +- [**JSON_USE_GLOBAL_UDLS**](json_use_global_udls.md) - place user-defined string literals (UDLs) into the global namespace + +## Library version + +- [**JSON_SKIP_LIBRARY_VERSION_CHECK**](json_skip_library_version_check.md) - skip library version check +- [**NLOHMANN_JSON_VERSION_MAJOR**
**NLOHMANN_JSON_VERSION_MINOR**
**NLOHMANN_JSON_VERSION_PATCH**](nlohmann_json_version_major.md) + \- library version information + +## Library namespace + +- [**NLOHMANN_JSON_NAMESPACE**](nlohmann_json_namespace.md) - full name of the `nlohmann` namespace +- [**NLOHMANN_JSON_NAMESPACE_BEGIN**
**NLOHMANN_JSON_NAMESPACE_END**](nlohmann_json_namespace_begin.md) - open and + close the library namespace +- [**NLOHMANN_JSON_NAMESPACE_NO_VERSION**](nlohmann_json_namespace_no_version.md) - disable the version component of + the inline namespace + +## Type conversions + +- [**JSON_DISABLE_ENUM_SERIALIZATION**](json_disable_enum_serialization.md) - switch off default serialization/deserialization functions for enums +- [**JSON_USE_IMPLICIT_CONVERSIONS**](json_use_implicit_conversions.md) - control implicit conversions + + +## Comparison behavior + +- [**JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON**](json_use_legacy_discarded_value_comparison.md) - + control comparison of discarded values + +## Serialization/deserialization macros + +- [**NLOHMANN_DEFINE_TYPE_INTRUSIVE(type, member...)**
**NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(type, member...)** +
**NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(type, member...)**][DefInt] + \- serialization/deserialization of types _with_ access to private variables +- [**NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(type, member...)**
**NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(type, member...)** +
**NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(type, member...)**][DefNonInt] + \- serialization/deserialization of types _without_ access to private variables +- [**NLOHMANN_JSON_SERIALIZE_ENUM(type, ...)**](nlohmann_json_serialize_enum.md) - serialization/deserialization of enum types + +[DefInt]: nlohmann_define_type_intrusive.md +[DefNonInt]: nlohmann_define_type_non_intrusive.md diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/json_assert.md b/external_imported/json/docs/mkdocs/docs/api/macros/json_assert.md new file mode 100644 index 000000000..a093341a1 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/json_assert.md @@ -0,0 +1,84 @@ +# JSON_ASSERT + +```cpp +#define JSON_ASSERT(x) /* value */ +``` + +This macro controls which code is executed for [runtime assertions](../../features/assertions.md) of the library. + +## Parameters + +`x` (in) +: expression of scalar type + +## Default definition + +The default value is [`#!cpp assert(x)`](https://en.cppreference.com/w/cpp/error/assert). + +```cpp +#define JSON_ASSERT(x) assert(x) +``` + +Therefore, assertions can be switched off by defining `NDEBUG`. + +## Notes + +- The library uses numerous assertions to guarantee invariants and to abort in case of otherwise undefined behavior + (e.g., when calling [operator[]](../basic_json/operator%5B%5D.md) with a missing object key on a `const` object). See + page [runtime assertions](../../features/assertions.md) for more information. +- Defining the macro to code that does not call `std::abort` may leave the library in an undefined state. +- The macro is undefined outside the library. + +## Examples + +??? example "Example 1: default behavior" + + The following code will trigger an assertion at runtime: + + ```cpp + #include + + using json = nlohmann::json; + + int main() + { + const json j = {{"key", "value"}}; + auto v = j["missing"]; + } + ``` + + Output: + + ``` + Assertion failed: (m_value.object->find(key) != m_value.object->end()), function operator[], file json.hpp, line 2144. + ``` + +??? example "Example 2: user-defined behavior" + + The assertion reporting can be changed by defining `JSON_ASSERT(x)` differently. + + ```cpp + #include + #include + #define JSON_ASSERT(x) if(!(x)){fprintf(stderr, "assertion error in %s\n", __FUNCTION__); std::abort();} + + #include + + using json = nlohmann::json; + + int main() + { + const json j = {{"key", "value"}}; + auto v = j["missing"]; + } + ``` + + Output: + + ``` + assertion error in operator[] + ``` + +## Version history + +- Added in version 3.9.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/json_diagnostics.md b/external_imported/json/docs/mkdocs/docs/api/macros/json_diagnostics.md new file mode 100644 index 000000000..4fc0fc38e --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/json_diagnostics.md @@ -0,0 +1,76 @@ +# JSON_DIAGNOSTICS + +```cpp +#define JSON_DIAGNOSTICS /* value */ +``` + +This macro enables [extended diagnostics for exception messages](../../home/exceptions.md#extended-diagnostic-messages). +Possible values are `1` to enable or `0` to disable (default). + +When enabled, exception messages contain a [JSON Pointer](../json_pointer/json_pointer.md) to the JSON value that +triggered the exception. Note that enabling this macro increases the size of every JSON value by one pointer and adds +some runtime overhead. + +## Default definition + +The default value is `0` (extended diagnostics are switched off). + +```cpp +#define JSON_DIAGNOSTICS 0 +``` + +When the macro is not defined, the library will define it to its default value. + +## Notes + +!!! note "ABI compatibility" + + As of version 3.11.0, this macro is no longer required to be defined consistently throughout a codebase to avoid + One Definition Rule (ODR) violations, as the value of this macro is encoded in the namespace, resulting in distinct + symbol names. + + This allows different parts of a codebase to use different versions or configurations of this library without + causing improper behavior. + + Where possible, it is still recommended that all code define this the same way for maximum interoperability. + +!!! hint "CMake option" + + Diagnostic messages can also be controlled with the CMake option + [`JSON_Diagnostics`](../../integration/cmake.md#json_diagnostics) (`OFF` by default) + which defines `JSON_DIAGNOSTICS` accordingly. + +## Examples + +??? example "Example 1: default behavior" + + ```cpp + --8<-- "examples/diagnostics_standard.cpp" + ``` + + Output: + + ``` + --8<-- "examples/diagnostics_standard.output" + ``` + + This exception can be hard to debug if storing the value `#!c "12"` and accessing it is further apart. + +??? example "Example 2: extended diagnostic messages" + + ```cpp + --8<-- "examples/diagnostics_extended.cpp" + ``` + + Output: + + ``` + --8<-- "examples/diagnostics_extended.output" + ``` + + Now the exception message contains a JSON Pointer `/address/housenumber` that indicates which value has the wrong type. + +## Version history + +- Added in version 3.10.0. +- As of version 3.11.0 the definition is allowed to vary between translation units. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/json_disable_enum_serialization.md b/external_imported/json/docs/mkdocs/docs/api/macros/json_disable_enum_serialization.md new file mode 100644 index 000000000..6440e34e3 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/json_disable_enum_serialization.md @@ -0,0 +1,152 @@ +# JSON_DISABLE_ENUM_SERIALIZATION + +```cpp +#define JSON_DISABLE_ENUM_SERIALIZATION /* value */ +``` + +When defined to `1`, default serialization and deserialization functions for enums are excluded and have to be provided +by the user, for example, using [`NLOHMANN_JSON_SERIALIZE_ENUM`](nlohmann_json_serialize_enum.md) (see +[arbitrary type conversions](../../features/arbitrary_types.md) for more details). + +Parsing or serializing an enum will result in a compiler error. + +This works for both unscoped and scoped enums. + +## Default definition + +The default value is `0`. + +```cpp +#define JSON_DISABLE_ENUM_SERIALIZATION 0 +``` + +## Notes + +!!! hint "CMake option" + + Enum serialization can also be controlled with the CMake option + [`JSON_DisableEnumSerialization`](../../integration/cmake.md#json_disableenumserialization) + (`OFF` by default) which defines `JSON_DISABLE_ENUM_SERIALIZATION` accordingly. + +## Examples + +??? example "Example 1: Disabled behavior" + + The code below forces the library **not** to create default serialization/deserialization functions `from_json` and `to_json`, meaning the code below + **does not** compile. + + ```cpp + #define JSON_DISABLE_ENUM_SERIALIZATION 1 + #include + + using json = nlohmann::json; + + enum class Choice + { + first, + second, + }; + + int main() + { + // normally invokes to_json serialization function but with JSON_DISABLE_ENUM_SERIALIZATION defined, it does not + const json j = Choice::first; + + // normally invokes from_json parse function but with JSON_DISABLE_ENUM_SERIALIZATION defined, it does not + Choice ch = j.template get(); + } + ``` + +??? example "Example 2: Serialize enum macro" + + The code below forces the library **not** to create default serialization/deserialization functions `from_json` and `to_json`, but uses + [`NLOHMANN_JSON_SERIALIZE_ENUM`](nlohmann_json_serialize_enum.md) to parse and serialize the enum. + + ```cpp + #define JSON_DISABLE_ENUM_SERIALIZATION 1 + #include + + using json = nlohmann::json; + + enum class Choice + { + first, + second, + }; + + NLOHMANN_JSON_SERIALIZE_ENUM(Choice, + { + { Choice::first, "first" }, + { Choice::second, "second" }, + }) + + int main() + { + // uses user-defined to_json function defined by macro + const json j = Choice::first; + + // uses user-defined from_json function defined by macro + Choice ch = j.template get(); + } + ``` + +??? example "Example 3: User-defined serialization/deserialization functions" + + The code below forces the library **not** to create default serialization/deserialization functions `from_json` and `to_json`, but uses user-defined + functions to parse and serialize the enum. + + ```cpp + #define JSON_DISABLE_ENUM_SERIALIZATION 1 + #include + + using json = nlohmann::json; + + enum class Choice + { + first, + second, + }; + + void from_json(const json& j, Choice& ch) + { + auto value = j.template get(); + if (value == "first") + { + ch = Choice::first; + } + else if (value == "second") + { + ch = Choice::second; + } + } + + void to_json(json& j, const Choice& ch) + { + auto value = j.template get(); + if (value == "first") + { + ch = Choice::first; + } + else if (value == "second") + { + ch = Choice::second; + } + } + + int main() + { + // uses user-defined to_json function + const json j = Choice::first; + + // uses user-defined from_json function + Choice ch = j.template get(); + } + ``` + +## See also + +- [`NLOHMANN_JSON_SERIALIZE_ENUM`](nlohmann_json_serialize_enum.md) + +## Version history + +- Added in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/json_has_cpp_11.md b/external_imported/json/docs/mkdocs/docs/api/macros/json_has_cpp_11.md new file mode 100644 index 000000000..f3eaa585c --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/json_has_cpp_11.md @@ -0,0 +1,41 @@ +# JSON_HAS_CPP_11, JSON_HAS_CPP_14, JSON_HAS_CPP_17, JSON_HAS_CPP_20 + +```cpp +#define JSON_HAS_CPP_11 +#define JSON_HAS_CPP_14 +#define JSON_HAS_CPP_17 +#define JSON_HAS_CPP_20 +``` + +The library targets C++11, but also supports some features introduced in later C++ versions (e.g., `std::string_view` +support for C++17). For these new features, the library implements some preprocessor checks to determine the C++ +standard. By defining any of these symbols, the internal check is overridden and the provided C++ version is +unconditionally assumed. This can be helpful for compilers that only implement parts of the standard and would be +detected incorrectly. + +## Default definition + +The default value is detected based on preprocessor macros such as `#!cpp __cplusplus`, `#!cpp _HAS_CXX17`, or +`#!cpp _MSVC_LANG`. + +## Notes + +- `#!cpp JSON_HAS_CPP_11` is always defined. +- All macros are undefined outside the library. + +## Examples + +??? example + + The code below forces the library to use the C++14 standard: + + ```cpp + #define JSON_HAS_CPP_14 1 + #include + + ... + ``` + +## Version history + +- Added in version 3.10.5. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/json_has_filesystem.md b/external_imported/json/docs/mkdocs/docs/api/macros/json_has_filesystem.md new file mode 100644 index 000000000..308aea2ac --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/json_has_filesystem.md @@ -0,0 +1,43 @@ +# JSON_HAS_FILESYSTEM / JSON_HAS_EXPERIMENTAL_FILESYSTEM + +```cpp +#define JSON_HAS_FILESYSTEM /* value */ +#define JSON_HAS_EXPERIMENTAL_FILESYSTEM /* value */ +``` + +When compiling with C++17, the library provides conversions from and to +[`std::filesystem::path`](https://en.cppreference.com/w/cpp/filesystem/path). As compiler support for filesystem is +limited, the library tries to detect whether +[``/`std::filesystem`](https://en.cppreference.com/w/cpp/header/filesystem) (`JSON_HAS_FILESYSTEM`) or +[``/`std::experimental::filesystem`](https://en.cppreference.com/w/cpp/header/experimental/filesystem) +(`JSON_HAS_EXPERIMENTAL_FILESYSTEM`) should be used. To override the built-in check, define `JSON_HAS_FILESYSTEM` or +`JSON_HAS_EXPERIMENTAL_FILESYSTEM` to `1`. + +## Default definition + +The default value is detected based on the preprocessor macros `#!cpp __cpp_lib_filesystem`, +`#!cpp __cpp_lib_experimental_filesystem`, `#!cpp __has_include()`, or +`#!cpp __has_include()`. + +## Notes + +- Note that older compilers or older versions of libstd++ also require the library `stdc++fs` to be linked to for + filesystem support. +- Both macros are undefined outside the library. + +## Examples + +??? example + + The code below forces the library to use the header ``. + + ```cpp + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #include + + ... + ``` + +## Version history + +- Added in version 3.10.5. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/json_has_ranges.md b/external_imported/json/docs/mkdocs/docs/api/macros/json_has_ranges.md new file mode 100644 index 000000000..96d51052d --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/json_has_ranges.md @@ -0,0 +1,31 @@ +# JSON_HAS_RANGES + +```cpp +#define JSON_HAS_RANGES /* value */ +``` + +This macro indicates whether the standard library has any support for ranges. Implies support for concepts. +Possible values are `1` when supported or `0` when unsupported. + +## Default definition + +The default value is detected based on the preprocessor macro `#!cpp __cpp_lib_ranges`. + +When the macro is not defined, the library will define it to its default value. + +## Examples + +??? example + + The code below forces the library to enable support for ranges: + + ```cpp + #define JSON_HAS_RANGES 1 + #include + + ... + ``` + +## Version history + +- Added in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/json_has_static_rtti.md b/external_imported/json/docs/mkdocs/docs/api/macros/json_has_static_rtti.md new file mode 100644 index 000000000..780878319 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/json_has_static_rtti.md @@ -0,0 +1,31 @@ +# JSON_HAS_STATIC_RTTI + +```cpp +#define JSON_HAS_STATIC_RTTI /* value */ +``` + +This macro indicates whether the standard library has any support for RTTI (run time type information). +Possible values are `1` when supported or `0` when unsupported. + +## Default definition + +The default value is detected based on the preprocessor macro `#!cpp _HAS_STATIC_RTTI`. + +When the macro is not defined, the library will define it to its default value. + +## Examples + +??? example + + The code below forces the library to enable support for libraries with RTTI dependence: + + ```cpp + #define JSON_HAS_STATIC_RTTI 1 + #include + + ... + ``` + +## Version history + +- Added in version ?. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/json_has_three_way_comparison.md b/external_imported/json/docs/mkdocs/docs/api/macros/json_has_three_way_comparison.md new file mode 100644 index 000000000..f52070ebf --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/json_has_three_way_comparison.md @@ -0,0 +1,32 @@ +# JSON_HAS_THREE_WAY_COMPARISON + +```cpp +#define JSON_HAS_THREE_WAY_COMPARISON /* value */ +``` + +This macro indicates whether the compiler and standard library support 3-way comparison. +Possible values are `1` when supported or `0` when unsupported. + +## Default definition + +The default value is detected based on the preprocessor macros `#!cpp __cpp_impl_three_way_comparison` +and `#!cpp __cpp_lib_three_way_comparison`. + +When the macro is not defined, the library will define it to its default value. + +## Examples + +??? example + + The code below forces the library to use 3-way comparison: + + ```cpp + #define JSON_HAS_THREE_WAY_COMPARISON 1 + #include + + ... + ``` + +## Version history + +- Added in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/json_no_io.md b/external_imported/json/docs/mkdocs/docs/api/macros/json_no_io.md new file mode 100644 index 000000000..ef37384a5 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/json_no_io.md @@ -0,0 +1,35 @@ +# JSON_NO_IO + +```cpp +#define JSON_NO_IO +``` + +When defined, headers ``, ``, ``, ``, and `` are not included and parse functions +relying on these headers are excluded. This is relevant for environments where these I/O functions are disallowed for +security reasons (e.g., Intel Software Guard Extensions (SGX)). + +## Default definition + +By default, `#!cpp JSON_NO_IO` is not defined. + +```cpp +#undef JSON_NO_IO +``` + +## Examples + +??? example + + The code below forces the library not to use the headers ``, ``, ``, ``, and + ``. + + ```cpp + #define JSON_NO_IO 1 + #include + + ... + ``` + +## Version history + +- Added in version 3.10.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/json_noexception.md b/external_imported/json/docs/mkdocs/docs/api/macros/json_noexception.md new file mode 100644 index 000000000..c801b8567 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/json_noexception.md @@ -0,0 +1,45 @@ +# JSON_NOEXCEPTION + +```cpp +#define JSON_NOEXCEPTION +``` + +Exceptions can be switched off by defining the symbol `JSON_NOEXCEPTION`. When defining `JSON_NOEXCEPTION`, `#!cpp try` +is replaced by `#!cpp if (true)`, `#!cpp catch` is replaced by `#!cpp if (false)`, and `#!cpp throw` is replaced by +`#!cpp std::abort()`. + +The same effect is achieved by setting the compiler flag `-fno-exceptions`. + +## Default definition + +By default, the macro is not defined. + +```cpp +#undef JSON_NOEXCEPTION +``` + +## Notes + +The explanatory [`what()`](https://en.cppreference.com/w/cpp/error/exception/what) string of exceptions is not +available for MSVC if exceptions are disabled, see [#2824](https://github.com/nlohmann/json/discussions/2824). + +## Examples + +??? example + + The code below switches off exceptions in the library. + + ```cpp + #define JSON_NOEXCEPTION 1 + #include + + ... + ``` + +## See also + +- [Switch off exceptions](../../home/exceptions.md#switch-off-exceptions) for more information how to switch off exceptions + +## Version history + +Added in version 2.1.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/json_skip_library_version_check.md b/external_imported/json/docs/mkdocs/docs/api/macros/json_skip_library_version_check.md new file mode 100644 index 000000000..c9a743c18 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/json_skip_library_version_check.md @@ -0,0 +1,37 @@ +# JSON_SKIP_LIBRARY_VERSION_CHECK + +```cpp +#define JSON_SKIP_LIBRARY_VERSION_CHECK +``` + +When defined, the library will not create a compiler warning when a different version of the library was already +included. + +## Default definition + +By default, the macro is not defined. + +```cpp +#undef JSON_SKIP_LIBRARY_VERSION_CHECK +``` + +## Notes + +!!! danger "ABI compatibility" + + Mixing different library versions in the same code can be a problem as the different versions may not be ABI + compatible. + +## Examples + +!!! example + + The following warning will be shown in case a different version of the library was already included: + + ``` + Already included a different version of the library! + ``` + +## Version history + +Added in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/json_skip_unsupported_compiler_check.md b/external_imported/json/docs/mkdocs/docs/api/macros/json_skip_unsupported_compiler_check.md new file mode 100644 index 000000000..374fa4c27 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/json_skip_unsupported_compiler_check.md @@ -0,0 +1,33 @@ +# JSON_SKIP_UNSUPPORTED_COMPILER_CHECK + +```cpp +#define JSON_SKIP_UNSUPPORTED_COMPILER_CHECK +``` + +When defined, the library will not create a compile error when a known unsupported compiler is detected. This allows to +use the library with compilers that do not fully support C++11 and may only work if unsupported features are not used. + +## Default definition + +By default, the macro is not defined. + +```cpp +#undef JSON_SKIP_UNSUPPORTED_COMPILER_CHECK +``` + +## Examples + +??? example + + The code below switches off the check whether the compiler is supported. + + ```cpp + #define JSON_SKIP_UNSUPPORTED_COMPILER_CHECK 1 + #include + + ... + ``` + +## Version history + +Added in version 3.2.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/json_throw_user.md b/external_imported/json/docs/mkdocs/docs/api/macros/json_throw_user.md new file mode 100644 index 000000000..b02918cf8 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/json_throw_user.md @@ -0,0 +1,75 @@ +# JSON_CATCH_USER, JSON_THROW_USER, JSON_TRY_USER + +```cpp +// (1) +#define JSON_CATCH_USER(exception) /* value */ +// (2) +#define JSON_THROW_USER(exception) /* value */ +// (3) +#define JSON_TRY_USER /* value */ +``` + +Controls how exceptions are handled by the library. + +1. This macro overrides [`#!cpp catch`](https://en.cppreference.com/w/cpp/language/try_catch) calls inside the library. + The argument is the type of the exception to catch. As of version 3.8.0, the library only catches `std::out_of_range` + exceptions internally to rethrow them as [`json::out_of_range`](../../home/exceptions.md#out-of-range) exceptions. + The macro is always followed by a scope. +2. This macro overrides `#!cpp throw` calls inside the library. The argument is the exception to be thrown. Note that + `JSON_THROW_USER` should leave the current scope (e.g., by throwing or aborting), as continuing after it may yield + undefined behavior. +3. This macro overrides `#!cpp try` calls inside the library. It has no arguments and is always followed by a scope. + +## Parameters + +`exception` (in) +: an exception type + +## Default definition + +By default, the macros map to their respective C++ keywords: + +```cpp +#define JSON_CATCH_USER(exception) catch(exception) +#define JSON_THROW_USER(exception) throw exception +#define JSON_TRY_USER try +``` + +When exceptions are switched off, the `#!cpp try` block is executed unconditionally, and throwing exceptions is +replaced by calling [`std::abort`](https://en.cppreference.com/w/cpp/utility/program/abort) to make reaching the +`#!cpp throw` branch abort the process. + +```cpp +#define JSON_THROW_USER(exception) std::abort() +#define JSON_TRY_USER if (true) +#define JSON_CATCH_USER(exception) if (false) +``` + +## Examples + +??? example + + The code below switches off exceptions and creates a log entry with a detailed error message in case of errors. + + ```cpp + #include + + #define JSON_TRY_USER if(true) + #define JSON_CATCH_USER(exception) if(false) + #define JSON_THROW_USER(exception) \ + {std::clog << "Error in " << __FILE__ << ":" << __LINE__ \ + << " (function " << __FUNCTION__ << ") - " \ + << (exception).what() << std::endl; \ + std::abort();} + + #include + ``` + +## See also + +- [Switch off exceptions](../../home/exceptions.md#switch-off-exceptions) for more information how to switch off exceptions +- [JSON_NOEXCEPTION](json_noexception.md) - switch off exceptions + +## Version history + +- Added in version 3.1.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/json_use_global_udls.md b/external_imported/json/docs/mkdocs/docs/api/macros/json_use_global_udls.md new file mode 100644 index 000000000..69db9e77c --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/json_use_global_udls.md @@ -0,0 +1,98 @@ +# JSON_USE_GLOBAL_UDLS + +```cpp +#define JSON_USE_GLOBAL_UDLS /* value */ +``` + +When defined to `1`, the user-defined string literals (UDLs) are placed into the global namespace instead of +`nlohmann::literals::json_literals`. + +## Default definition + +The default value is `1`. + +```cpp +#define JSON_USE_GLOBAL_UDLS 1 +``` + +When the macro is not defined, the library will define it to its default value. + +## Notes + +!!! info "Future behavior change" + + The user-defined string literals will be removed from the global namespace in the next major release of the library. + + To prepare existing code, define `JSON_USE_GLOBAL_UDLS` to `0` and bring the string literals into scope where + needed. Refer to any of the [string literals](#see-also) for details. + +!!! hint "CMake option" + + The placement of user-defined string literals can also be controlled with the CMake option + [`JSON_GlobalUDLs`](../../integration/cmake.md#json_globaludls) (`ON` by default) which defines + `JSON_USE_GLOBAL_UDLS` accordingly. + +## Examples + +??? example "Example 1: Default behavior" + + The code below shows the default behavior using the `_json` UDL. + + ```cpp + #include + + #include + + int main() + { + auto j = "42"_json; + + std::cout << j << std::endl; + } + ``` + + Output: + + ```json + 42 + ``` + +??? example "Example 2: Namespaced UDLs" + + The code below shows how UDLs need to be brought into scope before using `_json` when `JSON_USE_GLOBAL_UDLS` is + defined to `0`. + + ```cpp + #define JSON_USE_GLOBAL_UDLS 0 + #include + + #include + + int main() + { + // auto j = "42"_json; // This line would fail to compile, + // because the UDLs are not in the global namespace + + // Bring the UDLs into scope + using namespace nlohmann::json_literals; + + auto j = "42"_json; + + std::cout << j << std::endl; + } + ``` + + Output: + + ```json + 42 + ``` + +## See also + +- [`operator""_json`](../operator_literal_json.md) +- [`operator""_json_pointer`](../operator_literal_json_pointer.md) + +## Version history + +- Added in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/json_use_implicit_conversions.md b/external_imported/json/docs/mkdocs/docs/api/macros/json_use_implicit_conversions.md new file mode 100644 index 000000000..557dfa299 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/json_use_implicit_conversions.md @@ -0,0 +1,59 @@ +# JSON_USE_IMPLICIT_CONVERSIONS + +```cpp +#define JSON_USE_IMPLICIT_CONVERSIONS /* value */ +``` + +When defined to `0`, implicit conversions are switched off. By default, implicit conversions are switched on. The +value directly affects [`operator ValueType`](../basic_json/operator_ValueType.md). + +## Default definition + +By default, implicit conversions are enabled. + +```cpp +#define JSON_USE_IMPLICIT_CONVERSIONS 1 +``` + +## Notes + +!!! info "Future behavior change" + + Implicit conversions will be switched off by default in the next major release of the library. + + You can prepare existing code by already defining `JSON_USE_IMPLICIT_CONVERSIONS` to `0` and replace any implicit + conversions with calls to [`get`](../basic_json/get.md). + +!!! hint "CMake option" + + Implicit conversions can also be controlled with the CMake option + [`JSON_ImplicitConversions`](../../integration/cmake.md#json_legacydiscardedvaluecomparison) + (`ON` by default) which defines `JSON_USE_IMPLICIT_CONVERSIONS` accordingly. + +## Examples + +??? example + + This is an example for an implicit conversion: + + ```cpp + json j = "Hello, world!"; + std::string s = j; + ``` + + When `JSON_USE_IMPLICIT_CONVERSIONS` is defined to `0`, the code above does no longer compile. Instead, it must be + written like this: + + ```cpp + json j = "Hello, world!"; + auto s = j.template get(); + ``` + +## See also + +- [**operator ValueType**](../basic_json/operator_ValueType.md) - get a value (implicit) +- [**get**](../basic_json/get.md) - get a value (explicit) + +## Version history + +- Added in version 3.9.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/json_use_legacy_discarded_value_comparison.md b/external_imported/json/docs/mkdocs/docs/api/macros/json_use_legacy_discarded_value_comparison.md new file mode 100644 index 000000000..bc1d1434a --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/json_use_legacy_discarded_value_comparison.md @@ -0,0 +1,77 @@ +# JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON + +```cpp +#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON /* value */ +``` + +This macro enables the (incorrect) legacy comparison behavior of discarded JSON values. Possible values are `1` to +enable or `0` to disable (default). + +When enabled, comparisons involving at least one discarded JSON value yield results as follows: + +| **Operator** | **Result** | +|--------------|---------------| +| `==` | `#!cpp false` | +| `!=` | `#!cpp true` | +| `<` | `#!cpp false` | +| `<=` | `#!cpp true` | +| `>=` | `#!cpp true` | +| `>` | `#!cpp false` | + +Otherwise, comparisons involving at least one discarded JSON value always yield `#!cpp false`. + +## Default definition + +The default value is `0`. + +```cpp +#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0 +``` + +When the macro is not defined, the library will define it to its default value. + +## Notes + +!!! warning "Inconsistent behavior in C++20 and beyond" + + When targeting C++20 or above, enabling the legacy comparison behavior is _strongly_ + discouraged. + + - The 3-way comparison operator (`<=>`) will always give the correct result + (`#!cpp std::partial_ordering::unordered`) regardless of the value of + `JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON`. + - Overloads for the equality and relational operators emulate the legacy behavior. + + Code outside your control may use either 3-way comparison or the equality and relational operators, resulting in + inconsistent and unpredictable behavior. + + See [`operator<=>`](../basic_json/operator_spaceship.md) for more information on 3-way comparison. + +!!! warning "Deprecation" + + The legacy comparison behavior is deprecated and may be removed in a future major version release. + + New code should not depend on it and existing code should try to remove or rewrite expressions relying on it. + +!!! hint "CMake option" + + Legacy comparison can also be controlled with the CMake option + [`JSON_LegacyDiscardedValueComparison`](../../integration/cmake.md#json_legacydiscardedvaluecomparison) + (`OFF` by default) which defines `JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON` accordingly. + +## Examples + +??? example + + The code below switches on the legacy discarded value comparison behavior in the library. + + ```cpp + #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 1 + #include + + ... + ``` + +## Version history + +- Added in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/nlohmann_define_type_intrusive.md b/external_imported/json/docs/mkdocs/docs/api/macros/nlohmann_define_type_intrusive.md new file mode 100644 index 000000000..ad425810a --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/nlohmann_define_type_intrusive.md @@ -0,0 +1,156 @@ +# NLOHMANN_DEFINE_TYPE_INTRUSIVE, NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT, NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE + +```cpp +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(type, member...) // (1) +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(type, member...) // (2) +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(type, member...) // (3) +``` + +These macros can be used to simplify the serialization/deserialization of types if you want to use a JSON object as +serialization and want to use the member variable names as object keys in that object. The macro is to be defined +**inside** the class/struct to create code for. Unlike +[`NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`](nlohmann_define_type_non_intrusive.md), it can access private members. The first +parameter is the name of the class/struct, and all remaining parameters name the members. + +1. Will use [`at`](../basic_json/at.md) during deserialization and will throw + [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if a key is missing in the JSON object. +2. Will use [`value`](../basic_json/value.md) during deserialization and fall back to the default value for the + respective type of the member variable if a key in the JSON object is missing. The generated `from_json()` function + default constructs an object and uses its values as the defaults when calling the `value` function. +3. Only defines the serialization. Useful in cases when the type does not have a default constructor and only serialization in required. + +## Parameters + +`type` (in) +: name of the type (class, struct) to serialize/deserialize + +`member` (in) +: name of the member variable to serialize/deserialize; up to 64 members can be given as comma-separated list + +## Default definition + +The macros add two friend functions to the class which take care of the serialization and deserialization: + +```cpp +friend void to_json(nlohmann::json&, const type&); +friend void from_json(const nlohmann::json&, type&); // except (3) +``` + +See examples below for the concrete generated code. + +## Notes + +!!! info "Prerequisites" + + 1. The type `type` must be default constructible (except (3)). See [How can I use `get()` for non-default + constructible/non-copyable types?][GetNonDefNonCopy] for how to overcome this limitation. + 2. The macro must be used inside the type (class/struct). + +[GetNonDefNonCopy]: ../../features/arbitrary_types.md#how-can-i-use-get-for-non-default-constructiblenon-copyable-types + +!!! warning "Implementation limits" + + - The current implementation is limited to at most 64 member variables. If you want to serialize/deserialize types + with more than 64 member variables, you need to define the `to_json`/`from_json` functions manually. + - The macros only work for the [`nlohmann::json`](../json.md) type; other specializations such as + [`nlohmann::ordered_json`](../ordered_json.md) are currently unsupported. + +## Examples + +??? example "Example (1): NLOHMANN_DEFINE_TYPE_INTRUSIVE" + + Consider the following complete example: + + ```cpp hl_lines="22" + --8<-- "examples/nlohmann_define_type_intrusive_macro.cpp" + ``` + + Output: + + ```json + --8<-- "examples/nlohmann_define_type_intrusive_macro.output" + ``` + + Notes: + + - `ns::person` is default-constructible. This is a requirement for using the macro. + - `ns::person` has private member variables. This makes `NLOHMANN_DEFINE_TYPE_INTRUSIVE` applicable, but not + `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`. + - The macro `NLOHMANN_DEFINE_TYPE_INTRUSIVE` is used _inside_ the class. + - A missing key "age" in the deserialization yields an exception. To fall back to the default value, + `NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT` can be used. + + The macro is equivalent to: + + ```cpp hl_lines="22 23 24 25 26 27 28 29 30 31 32 33 34" + --8<-- "examples/nlohmann_define_type_intrusive_explicit.cpp" + ``` + +??? example "Example (2): NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT" + + Consider the following complete example: + + ```cpp hl_lines="22" + --8<-- "examples/nlohmann_define_type_intrusive_with_default_macro.cpp" + ``` + + Output: + + ```json + --8<-- "examples/nlohmann_define_type_intrusive_with_default_macro.output" + ``` + + Notes: + + - `ns::person` is default-constructible. This is a requirement for using the macro. + - `ns::person` has private member variables. This makes `NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT` applicable, + but not `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT`. + - The macro `NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT` is used _inside_ the class. + - A missing key "age" in the deserialization does not yield an exception. Instead, the default value `-1` is used. + + The macro is equivalent to: + + ```cpp hl_lines="22 23 24 25 26 27 28 29 30 31 32 33 34 35" + --8<-- "examples/nlohmann_define_type_intrusive_with_default_explicit.cpp" + ``` + + Note how a default-initialized `person` object is used in the `from_json` to fill missing values. + +??? example "Example (3): NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE" + Consider the following complete example: + + ```cpp hl_lines="22" + --8<-- "examples/nlohmann_define_type_intrusive_only_serialize_macro.cpp" + ``` + + Output: + + ```json + --8<-- "examples/nlohmann_define_type_intrusive_only_serialize_macro.output" + ``` + + Notes: + + - `ns::person` is non-default-constructible. This allows this macro to be used instead of + `NLOHMANN_DEFINE_TYPE_INTRUSIVE` and `NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT`. + - `ns::person` has private member variables. This makes `NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE` applicable, but not + `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE`. + - The macro `NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE` is used _inside_ the class. + + The macro is equivalent to: + + ```cpp hl_lines="22 22 23 24 25 26 27" + --8<-- "examples/nlohmann_define_type_intrusive_only_serialize_explicit.cpp" + ``` + +## See also + +- [NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE{_WITH_DEFAULT, _ONLY_SERIALIZE}](nlohmann_define_type_non_intrusive.md) + for a similar macro that can be defined _outside_ the type. +- [Arbitrary Type Conversions](../../features/arbitrary_types.md) for an overview. + +## Version history + +1. Added in version 3.9.0. +2. Added in version 3.11.0. +3. Added in version TODO. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/nlohmann_define_type_non_intrusive.md b/external_imported/json/docs/mkdocs/docs/api/macros/nlohmann_define_type_non_intrusive.md new file mode 100644 index 000000000..5830f8ca9 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/nlohmann_define_type_non_intrusive.md @@ -0,0 +1,157 @@ +# NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE, NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT, NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE + +```cpp +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(type, member...) // (1) +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(type, member...) // (2) +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(type, member...) // (3) +``` + +These macros can be used to simplify the serialization/deserialization of types if you want to use a JSON object as +serialization and want to use the member variable names as object keys in that object. The macro is to be defined +**outside** the class/struct to create code for, but **inside** its namespace. Unlike +[`NLOHMANN_DEFINE_TYPE_INTRUSIVE`](nlohmann_define_type_intrusive.md), it **cannot** access private members. The first +parameter is the name of the class/struct, and all remaining parameters name the members. + +1. Will use [`at`](../basic_json/at.md) during deserialization and will throw + [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if a key is missing in the JSON object. +2. Will use [`value`](../basic_json/value.md) during deserialization and fall back to the default value for the + respective type of the member variable if a key in the JSON object is missing. The generated `from_json()` function + default constructs an object and uses its values as the defaults when calling the `value` function. +3. Only defines the serialization. Useful in cases when the type does not have a default constructor and only serialization in required. + +## Parameters + +`type` (in) +: name of the type (class, struct) to serialize/deserialize + +`member` (in) +: name of the (public) member variable to serialize/deserialize; up to 64 members can be given as comma-separated list + +## Default definition + +The macros add two functions to the namespace which take care of the serialization and deserialization: + +```cpp +void to_json(nlohmann::json&, const type&); +void from_json(const nlohmann::json&, type&); // except (3) +``` + +See examples below for the concrete generated code. + +## Notes + +!!! info "Prerequisites" + + 1. The type `type` must be default constructible (except (3). See [How can I use `get()` for non-default constructible/non-copyable types?][GetNonDefNonCopy] + for how to overcome this limitation. + 2. The macro must be used outside the type (class/struct). + 3. The passed members must be public. + +[GetNonDefNonCopy]: ../../features/arbitrary_types.md#how-can-i-use-get-for-non-default-constructiblenon-copyable-types + +!!! warning "Implementation limits" + + - The current implementation is limited to at most 64 member variables. If you want to serialize/deserialize types + with more than 64 member variables, you need to define the `to_json`/`from_json` functions manually. + - The macros only work for the [`nlohmann::json`](../json.md) type; other specializations such as + [`nlohmann::ordered_json`](../ordered_json.md) are currently unsupported. + +## Examples + +??? example "Example (1): NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE" + + Consider the following complete example: + + ```cpp hl_lines="16" + --8<-- "examples/nlohmann_define_type_non_intrusive_macro.cpp" + ``` + + Output: + + ```json + --8<-- "examples/nlohmann_define_type_non_intrusive_macro.output" + ``` + + Notes: + + - `ns::person` is default-constructible. This is a requirement for using the macro. + - `ns::person` has only public member variables. This makes `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE` applicable. + - The macro `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE` is used _outside_ the class, but _inside_ its namespace `ns`. + - A missing key "age" in the deserialization yields an exception. To fall back to the default value, + `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT` can be used. + + The macro is equivalent to: + + ```cpp hl_lines="16 17 18 19 20 21 22 23 24 25 26 27 28" + --8<-- "examples/nlohmann_define_type_non_intrusive_explicit.cpp" + ``` + +??? example "Example (2): NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT" + + Consider the following complete example: + + ```cpp hl_lines="22" + --8<-- "examples/nlohmann_define_type_non_intrusive_with_default_macro.cpp" + ``` + + Output: + + ```json + --8<-- "examples/nlohmann_define_type_non_intrusive_with_default_macro.output" + ``` + + Notes: + + - `ns::person` is default-constructible. This is a requirement for using the macro. + - `ns::person` has only public member variables. This makes `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT` + applicable. + - The macro `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT` is used _outside_ the class, but _inside_ its + namespace `ns`. + - A missing key "age" in the deserialization does not yield an exception. Instead, the default value `-1` is used. + + The macro is equivalent to: + + ```cpp hl_lines="22 23 24 25 26 27 28 29 30 31 32 33 34 35" + --8<-- "examples/nlohmann_define_type_non_intrusive_with_default_explicit.cpp" + ``` + + Note how a default-initialized `person` object is used in the `from_json` to fill missing values. + +??? example "Example (3): NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE" + + Consider the following complete example: + + ```cpp hl_lines="16" + --8<-- "examples/nlohmann_define_type_non_intrusive_only_serialize_macro.cpp" + ``` + + Output: + + ```json + --8<-- "examples/nlohmann_define_type_non_intrusive_only_serialize_macro.output" + ``` + + Notes: + + - `ns::person` is non-default-constructible. This allows this macro to be used instead of + `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE` and `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT`. + - `ns::person` has only public member variables. This makes `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE` applicable. + - The macro `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE` is used _outside_ the class, but _inside_ its namespace `ns`. + + The macro is equivalent to: + + ```cpp hl_lines="16 17 18 19 20 21" + --8<-- "examples/nlohmann_define_type_non_intrusive_only_serialize_explicit.cpp" + ``` + +## See also + +- [NLOHMANN_DEFINE_TYPE_INTRUSIVE{_WITH_DEFAULT, _ONLY_SERIALIZE}](nlohmann_define_type_intrusive.md) + for a similar macro that can be defined _inside_ the type. +- [Arbitrary Type Conversions](../../features/arbitrary_types.md) for an overview. + +## Version history + +1. Added in version 3.9.0. +2. Added in version 3.11.0. +3. Added in version TODO. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/nlohmann_json_namespace.md b/external_imported/json/docs/mkdocs/docs/api/macros/nlohmann_json_namespace.md new file mode 100644 index 000000000..5c54dba52 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/nlohmann_json_namespace.md @@ -0,0 +1,41 @@ +# NLOHMANN_JSON_NAMESPACE + +```cpp +#define NLOHMANN_JSON_NAMESPACE /* value */ +``` + +This macro evaluates to the full name of the `nlohmann` namespace. + +## Default definition + +The default value consists of the root namespace (`nlohmann`) and an inline ABI namespace. See +[`nlohmann` Namespace](../../features/namespace.md#structure) for details. + +When the macro is not defined, the library will define it to its default value. Overriding this value has no effect on +the library. + +## Examples + +??? example + + The example shows how to use `NLOHMANN_JSON_NAMESPACE` instead of just `nlohmann`, as well as how to output the value + of `NLOHMANN_JSON_NAMESPACE`. + + ```cpp + --8<-- "examples/nlohmann_json_namespace.cpp" + ``` + + Output: + + ```json + --8<-- "examples/nlohmann_json_namespace.output" + ``` + +## See also + +- [`NLOHMANN_JSON_NAMESPACE_BEGIN, NLOHMANN_JSON_NAMESPACE_END`](nlohmann_json_namespace_begin.md) +- [`NLOHMANN_JSON_NAMESPACE_NO_VERSION`](nlohmann_json_namespace_no_version.md) + +## Version history + +- Added in version 3.11.0. Changed inline namespace name in version 3.11.2. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/nlohmann_json_namespace_begin.md b/external_imported/json/docs/mkdocs/docs/api/macros/nlohmann_json_namespace_begin.md new file mode 100644 index 000000000..1374264a3 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/nlohmann_json_namespace_begin.md @@ -0,0 +1,61 @@ +# NLOHMANN_JSON_NAMESPACE_BEGIN, NLOHMANN_JSON_NAMESPACE_END + +```cpp +#define NLOHMANN_JSON_NAMESPACE_BEGIN /* value */ // (1) +#define NLOHMANN_JSON_NAMESPACE_END /* value */ // (2) +``` + +These macros can be used to open and close the `nlohmann` namespace. See +[`nlohmann` Namespace](../../features/namespace.md#structure) for details. + +1. Opens the namespace. +2. Closes the namespace. + +## Default definition + +The default definitions open and close the `nlohmann` namespace. The precise definition of +[`NLOHMANN_JSON_NAMESPACE_BEGIN`] varies as described [here](../../features/namespace.md#structure). + +1. Default definition of `NLOHMANN_JSON_NAMESPACE_BEGIN`: + + ```cpp + namespace nlohmann + { + inline namespace json_abi_v3_11_2 + { + ``` + +2. Default definition of `NLOHMANN_JSON_NAMESPACE_END`: + ```cpp + } // namespace json_abi_v3_11_2 + } // namespace nlohmann + ``` + +When these macros are not defined, the library will define them to their default definitions. + +## Examples + +??? example + + The example shows how to use `NLOHMANN_JSON_NAMESPACE_BEGIN`/`NLOHMANN_JSON_NAMESPACE_END` from the + [How do I convert third-party types?](../../features/arbitrary_types.md#how-do-i-convert-third-party-types) page. + + ```cpp + --8<-- "examples/nlohmann_json_namespace_begin.c++17.cpp" + ``` + + Output: + + ```json + --8<-- "examples/nlohmann_json_namespace_begin.c++17.output" + ``` + +## See also + +- [`nlohmann` Namespace](../../features/namespace.md) +- [NLOHMANN_JSON_NAMESPACE](nlohmann_json_namespace.md) +- [`NLOHMANN_JSON_NAMESPACE_NO_VERSION`](nlohmann_json_namespace_no_version.md) + +## Version history + +- Added in version 3.11.0. Changed inline namespace name in version 3.11.2. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/nlohmann_json_namespace_no_version.md b/external_imported/json/docs/mkdocs/docs/api/macros/nlohmann_json_namespace_no_version.md new file mode 100644 index 000000000..9e2a52d04 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/nlohmann_json_namespace_no_version.md @@ -0,0 +1,45 @@ +# NLOHMANN_JSON_NAMESPACE_NO_VERSION + +```cpp +#define NLOHMANN_JSON_NAMESPACE_NO_VERSION /* value */ +``` + +If defined to `1`, the version component is omitted from the inline namespace. See +[`nlohmann` Namespace](../../features/namespace.md#structure) for details. + +## Default definition + +The default value is `0`. + +```cpp +#define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0 +``` + +When the macro is not defined, the library will define it to its default value. + +## Examples + +??? example + + The example shows how to use `NLOHMANN_JSON_NAMESPACE_NO_VERSION` to disable the version component of the inline + namespace. + + ```cpp + --8<-- "examples/nlohmann_json_namespace_no_version.cpp" + ``` + + Output: + + ```json + --8<-- "examples/nlohmann_json_namespace_no_version.output" + ``` + +## See also + +- [`nlohmann` Namespace](../../features/namespace.md) +- [`NLOHMANN_JSON_NAMESPACE`](nlohmann_json_namespace.md) +- [`NLOHMANN_JSON_NAMESPACE_BEGIN, NLOHMANN_JSON_NAMESPACE_END`](nlohmann_json_namespace_begin.md) + +## Version history + +- Added in version 3.11.2. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/nlohmann_json_serialize_enum.md b/external_imported/json/docs/mkdocs/docs/api/macros/nlohmann_json_serialize_enum.md new file mode 100644 index 000000000..dc2cc8ecb --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/nlohmann_json_serialize_enum.md @@ -0,0 +1,85 @@ +# NLOHMANN_JSON_SERIALIZE_ENUM + +```cpp +#define NLOHMANN_JSON_SERIALIZE_ENUM(type, conversion...) +``` + +By default, enum values are serialized to JSON as integers. In some cases this could result in undesired behavior. If an +enum is modified or re-ordered after data has been serialized to JSON, the later de-serialized JSON data may be +undefined or a different enum value than was originally intended. + +The `NLOHMANN_JSON_SERIALIZE_ENUM` allows to define a user-defined serialization for every enumerator. + +## Parameters + +`type` (in) +: name of the enum to serialize/deserialize + +`conversion` (in) +: a pair of an enumerator and a JSON serialization; arbitrary pairs can be given as a comma-separated list + +## Default definition + +The macros add two friend functions to the class which take care of the serialization and deserialization: + +```cpp +template +inline void to_json(BasicJsonType& j, const type& e); +template +inline void from_json(const BasicJsonType& j, type& e); +``` + +## Notes + +!!! info "Prerequisites" + + The macro must be used inside the namespace of the enum. + +!!! important "Important notes" + + - When using [`template get()`](../basic_json/get.md), undefined JSON values will default to the first specified + conversion. Select this default pair carefully. See example 1 below. + - If an enum or JSON value is specified in multiple conversions, the first matching conversion from the top of the + list will be returned when converting to or from JSON. See example 2 below. + +## Examples + +??? example "Example 1: Basic usage" + + The example shows how `NLOHMANN_JSON_SERIALIZE_ENUM` can be used to serialize/deserialize both classical enums and + C++11 enum classes: + + ```cpp hl_lines="16 17 18 19 20 21 22 29 30 31 32 33" + --8<-- "examples/nlohmann_json_serialize_enum.cpp" + ``` + + Output: + + ```json + --8<-- "examples/nlohmann_json_serialize_enum.output" + ``` + +??? example "Example 2: Multiple conversions for one enumerator" + + The example shows how to use multiple conversions for a single enumerator. In the example, `Color::red` will always + be *serialized* to `"red"`, because the first occurring conversion. The second conversion, however, offers an + alternative *deserialization* from `"rot"` to `Color::red`. + + ```cpp hl_lines="17" + --8<-- "examples/nlohmann_json_serialize_enum_2.cpp" + ``` + + Output: + + ```json + --8<-- "examples/nlohmann_json_serialize_enum_2.output" + ``` + +## See also + +- [Specializing enum conversion](../../features/enum_conversion.md) +- [`JSON_DISABLE_ENUM_SERIALIZATION`](json_disable_enum_serialization.md) + +## Version history + +Added in version 3.4.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/macros/nlohmann_json_version_major.md b/external_imported/json/docs/mkdocs/docs/api/macros/nlohmann_json_version_major.md new file mode 100644 index 000000000..d7a314276 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/macros/nlohmann_json_version_major.md @@ -0,0 +1,40 @@ +# NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, NLOHMANN_JSON_VERSION_PATCH + +```cpp +#define NLOHMANN_JSON_VERSION_MAJOR /* value */ +#define NLOHMANN_JSON_VERSION_MINOR /* value */ +#define NLOHMANN_JSON_VERSION_PATCH /* value */ +``` + +These macros are defined by the library and contain the version numbers according to +[Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html). + +## Default definition + +The macros are defined according to the current library version. + +## Examples + +??? example + + The example below shows how `NLOHMANN_JSON_VERSION_MAJOR`, `NLOHMANN_JSON_VERSION_MINOR`, and + `NLOHMANN_JSON_VERSION_PATCH` are defined by the library. + + ```cpp + --8<-- "examples/nlohmann_json_version.cpp" + ``` + + Output: + + ```json + --8<-- "examples/nlohmann_json_version.output" + ``` + +## See also + +- [meta](../basic_json/meta.md) - returns version information on the library +- [JSON_SKIP_LIBRARY_VERSION_CHECK](json_skip_library_version_check.md) - skip library version check + +## Version history + +- Added in version 3.1.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/operator_gtgt.md b/external_imported/json/docs/mkdocs/docs/api/operator_gtgt.md new file mode 100644 index 000000000..e76cc0db7 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/operator_gtgt.md @@ -0,0 +1,64 @@ +# nlohmann::operator>>(basic_json) + +```cpp +std::istream& operator>>(std::istream& i, basic_json& j); +``` + +Deserializes an input stream to a JSON value. + +## Parameters + +`i` (in, out) +: input stream to read a serialized JSON value from + +`j` (in, out) +: JSON value to write the deserialized input to + +## Return value + +the stream `i` + +## Exceptions + +- Throws [`parse_error.101`](../home/exceptions.md#jsonexceptionparse_error101) in case of an unexpected token. +- Throws [`parse_error.102`](../home/exceptions.md#jsonexceptionparse_error102) if to_unicode fails or surrogate error. +- Throws [`parse_error.103`](../home/exceptions.md#jsonexceptionparse_error103) if to_unicode fails. + +## Complexity + +Linear in the length of the input. The parser is a predictive LL(1) parser. + +## Notes + +A UTF-8 byte order mark is silently ignored. + +!!! warning "Deprecation" + + This function replaces function `#!cpp std::istream& operator<<(basic_json& j, std::istream& i)` which has + been deprecated in version 3.0.0. It will be removed in version 4.0.0. Please replace calls like `#!cpp j << i;` + with `#!cpp i >> j;`. + +## Examples + +??? example + + The example below shows how a JSON value is constructed by reading a serialization from a stream. + + ```cpp + --8<-- "examples/operator_deserialize.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator_deserialize.output" + ``` + +## See also + +- [accept](basic_json/accept.md) - check if the input is valid JSON +- [parse](basic_json/parse.md) - deserialize from a compatible input + +## Version history + +- Added in version 1.0.0. Deprecated in version 3.0.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/operator_literal_json.md b/external_imported/json/docs/mkdocs/docs/api/operator_literal_json.md new file mode 100644 index 000000000..bc2b2cfc5 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/operator_literal_json.md @@ -0,0 +1,61 @@ +# nlohmann::operator""_json + +```cpp +json operator ""_json(const char* s, std::size_t n); +``` + +This operator implements a user-defined string literal for JSON objects. It can be used by adding `#!cpp _json` to a +string literal and returns a [`json`](json.md) object if no parse error occurred. + +It is recommended to bring the operator into scope using any of the following lines: +```cpp +using nlohmann::literals::operator ""_json; +using namespace nlohmann::literals; +using namespace nlohmann::json_literals; +using namespace nlohmann::literals::json_literals; +using namespace nlohmann; +``` + +This is suggested to ease migration to the next major version release of the library. See +['JSON_USE_GLOBAL_UDLS`](macros/json_use_global_udls.md#notes) for details. + +## Parameters + +`s` (in) +: a string representation of a JSON object + +`n` (in) +: length of string `s` + +## Return value + +[`json`](json.md) value parsed from `s` + +## Exceptions + +The function can throw anything that [`parse(s, s+n)`](basic_json/parse.md) would throw. + +## Complexity + +Linear. + +## Examples + +??? example + + The following code shows how to create JSON values from string literals. + + ```cpp + --8<-- "examples/operator_literal_json.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator_literal_json.output" + ``` + +## Version history + +- Added in version 1.0.0. +- Moved to namespace `nlohmann::literals::json_literals` in 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/operator_literal_json_pointer.md b/external_imported/json/docs/mkdocs/docs/api/operator_literal_json_pointer.md new file mode 100644 index 000000000..0e12440e1 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/operator_literal_json_pointer.md @@ -0,0 +1,64 @@ +# nlohmann::operator""_json_pointer + +```cpp +json_pointer operator ""_json_pointer(const char* s, std::size_t n); +``` + +This operator implements a user-defined string literal for JSON Pointers. It can be used by adding `#!cpp _json_pointer` +to a string literal and returns a [`json_pointer`](json_pointer/index.md) object if no parse error occurred. + +It is recommended to bring the operator into scope using any of the following lines: +```cpp +using nlohmann::literals::operator ""_json_pointer; +using namespace nlohmann::literals; +using namespace nlohmann::json_literals; +using namespace nlohmann::literals::json_literals; +using namespace nlohmann; +``` +This is suggested to ease migration to the next major version release of the library. See +['JSON_USE_GLOBAL_UDLS`](macros/json_use_global_udls.md#notes) for details. + +## Parameters + +`s` (in) +: a string representation of a JSON Pointer + +`n` (in) +: length of string `s` + +## Return value + +[`json_pointer`](json_pointer/index.md) value parsed from `s` + +## Exceptions + +The function can throw anything that [`json_pointer::json_pointer`](json_pointer/index.md) would throw. + +## Complexity + +Linear. + +## Examples + +??? example + + The following code shows how to create JSON Pointers from string literals. + + ```cpp + --8<-- "examples/operator_literal_json_pointer.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator_literal_json_pointer.output" + ``` + +## See also + +- [json_pointer](json_pointer/index.md) - type to represent JSON Pointers + +## Version history + +- Added in version 2.0.0. +- Moved to namespace `nlohmann::literals::json_literals` in 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/operator_ltlt.md b/external_imported/json/docs/mkdocs/docs/api/operator_ltlt.md new file mode 100644 index 000000000..1718b3c9e --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/operator_ltlt.md @@ -0,0 +1,87 @@ +# nlohmann::operator<<(basic_json), nlohmann::operator<<(json_pointer) + +```cpp +std::ostream& operator<<(std::ostream& o, const basic_json& j); // (1) + +std::ostream& operator<<(std::ostream& o, const json_pointer& ptr); // (2) +``` + +1. Serialize the given JSON value `j` to the output stream `o`. The JSON value will be serialized using the + [`dump`](basic_json/dump.md) member function. + - The indentation of the output can be controlled with the member variable `width` of the output stream `o`. For + instance, using the manipulator `std::setw(4)` on `o` sets the indentation level to `4` and the serialization + result is the same as calling `dump(4)`. + - The indentation character can be controlled with the member variable `fill` of the output stream `o`. + For instance, the manipulator `std::setfill('\\t')` sets indentation to use a tab character rather than the + default space character. +2. Write a string representation of the given JSON pointer `ptr` to the output stream `o`. The string representation is + obtained using the [`to_string`](json_pointer/to_string.md) member function. + +## Parameters + +`o` (in, out) +: stream to write to + +`j` (in) +: JSON value to serialize + +`ptr` (in) +: JSON pointer to write + +## Return value + +the stream `o` + +## Exceptions + +1. Throws [`type_error.316`](../home/exceptions.md#jsonexceptiontype_error316) if a string stored inside the JSON + value is not UTF-8 encoded. Note that unlike the [`dump`](basic_json/dump.md) member functions, no `error_handler` + can be set. +2. None. + +## Complexity + +Linear. + +## Notes + +!!! warning "Deprecation" + + Function `#!cpp std::ostream& operator<<(std::ostream& o, const basic_json& j)` replaces function + `#!cpp std::ostream& operator>>(const basic_json& j, std::ostream& o)` which has been deprecated in version 3.0.0. + It will be removed in version 4.0.0. Please replace calls like `#!cpp j >> o;` with `#!cpp o << j;`. + +## Examples + +??? example "Example: (1) serialize JSON value to stream" + + The example below shows the serialization with different parameters to `width` to adjust the indentation level. + + ```cpp + --8<-- "examples/operator_ltlt__basic_json.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator_ltlt__basic_json.output" + ``` + +??? example "Example: (2) write JSON pointer to stream" + + The example below shows how to write a JSON pointer to a stream. + + ```cpp + --8<-- "examples/operator_ltlt__json_pointer.cpp" + ``` + + Output: + + ```json + --8<-- "examples/operator_ltlt__json_pointer.output" + ``` +## Version history + +1. Added in version 1.0.0. Added support for indentation character and deprecated + `#!cpp std::ostream& operator>>(const basic_json& j, std::ostream& o)` in version 3.0.0. +3. Added in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/ordered_json.md b/external_imported/json/docs/mkdocs/docs/api/ordered_json.md new file mode 100644 index 000000000..7cfd9f4dd --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/ordered_json.md @@ -0,0 +1,32 @@ +# nlohmann::ordered_json + +```cpp +using ordered_json = basic_json; +``` + +This type preserves the insertion order of object keys. + +## Examples + +??? example + + The example below demonstrates how `ordered_json` preserves the insertion order of object keys. + + ```cpp + --8<-- "examples/ordered_json.cpp" + ``` + + Output: + + ```json + --8<-- "examples/ordered_json.output" + ``` + +## See also + +- [ordered_map](ordered_map.md) +- [Object Order](../features/object_order.md) + +## Version history + +Since version 3.9.0. diff --git a/external_imported/json/docs/mkdocs/docs/api/ordered_map.md b/external_imported/json/docs/mkdocs/docs/api/ordered_map.md new file mode 100644 index 000000000..160b85c28 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/api/ordered_map.md @@ -0,0 +1,77 @@ +# nlohmann::ordered_map + +```cpp +template, + class Allocator = std::allocator>> +struct ordered_map : std::vector, Allocator>; +``` + +A minimal map-like container that preserves insertion order for use within [`nlohmann::ordered_json`](ordered_json.md) +(`nlohmann::basic_json`). + +## Template parameters + +`Key` +: key type + +`T` +: mapped type + +`IgnoredLess` +: comparison function (ignored and only added to ensure compatibility with `#!cpp std::map`) + +`Allocator` +: allocator type + +## Member types + +- **key_type** - key type (`Key`) +- **mapped_type** - mapped type (`T`) +- **Container** - base container type (`#!cpp std::vector, Allocator>`) +- **iterator** +- **const_iterator** +- **size_type** +- **value_type** +- **key_compare** - key comparison function +```cpp +std::equal_to // until C++14 + +std::equal_to<> // since C++14 +``` + +## Member functions + +- (constructor) +- (destructor) +- **emplace** +- **operator\[\]** +- **at** +- **erase** +- **count** +- **find** +- **insert** + +## Examples + +??? example + + The example shows the different behavior of `std::map` and `nlohmann::ordered_map`. + + ```cpp + --8<-- "examples/ordered_map.cpp" + ``` + + Output: + + ```json + --8<-- "examples/ordered_map.output" + ``` + +## See also + +- [ordered_json](ordered_json.md) + +## Version history + +- Added in version 3.9.0 to implement [`nlohmann::ordered_json`](ordered_json.md). +- Added **key_compare** member in version 3.11.0. diff --git a/external_imported/json/docs/mkdocs/docs/css/custom.css b/external_imported/json/docs/mkdocs/docs/css/custom.css new file mode 100644 index 000000000..7a1008b0b --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/css/custom.css @@ -0,0 +1,4 @@ +/* disable ligatures in code and preformatted blocks */ +code, pre { + font-variant-ligatures: none; +} diff --git a/external_imported/json/docs/mkdocs/docs/features/arbitrary_types.md b/external_imported/json/docs/mkdocs/docs/features/arbitrary_types.md new file mode 100644 index 000000000..9b54fcb3e --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/arbitrary_types.md @@ -0,0 +1,274 @@ +# Arbitrary Type Conversions + +Every type can be serialized in JSON, not just STL containers and scalar types. Usually, you would do something along those lines: + +```cpp +namespace ns { + // a simple struct to model a person + struct person { + std::string name; + std::string address; + int age; + }; +} // namespace ns + +ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; + +// convert to JSON: copy each value into the JSON object +json j; +j["name"] = p.name; +j["address"] = p.address; +j["age"] = p.age; + +// ... + +// convert from JSON: copy each value from the JSON object +ns::person p { + j["name"].template get(), + j["address"].template get(), + j["age"].template get() +}; +``` + +It works, but that's quite a lot of boilerplate... Fortunately, there's a better way: + +```cpp +// create a person +ns::person p {"Ned Flanders", "744 Evergreen Terrace", 60}; + +// conversion: person -> json +json j = p; + +std::cout << j << std::endl; +// {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} + +// conversion: json -> person +auto p2 = j.template get(); + +// that's it +assert(p == p2); +``` + +## Basic usage + +To make this work with one of your types, you only need to provide two functions: + +```cpp +using json = nlohmann::json; + +namespace ns { + void to_json(json& j, const person& p) { + j = json{ {"name", p.name}, {"address", p.address}, {"age", p.age} }; + } + + void from_json(const json& j, person& p) { + j.at("name").get_to(p.name); + j.at("address").get_to(p.address); + j.at("age").get_to(p.age); + } +} // namespace ns +``` + +That's all! When calling the `json` constructor with your type, your custom `to_json` method will be automatically called. +Likewise, when calling `template get()` or `get_to(your_type&)`, the `from_json` method will be called. + +Some important things: + +* Those methods **MUST** be in your type's namespace (which can be the global namespace), or the library will not be able to locate them (in this example, they are in namespace `ns`, where `person` is defined). +* Those methods **MUST** be available (e.g., proper headers must be included) everywhere you use these conversions. Look at [issue 1108](https://github.com/nlohmann/json/issues/1108) for errors that may occur otherwise. +* When using `template get()`, `your_type` **MUST** be [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). (There is a way to bypass this requirement described later.) +* In function `from_json`, use function [`at()`](../api/basic_json/at.md) to access the object values rather than `operator[]`. In case a key does not exist, `at` throws an exception that you can handle, whereas `operator[]` exhibits undefined behavior. +* You do not need to add serializers or deserializers for STL types like `std::vector`: the library already implements these. + + +## Simplify your life with macros + +If you just want to serialize/deserialize some structs, the `to_json`/`from_json` functions can be a lot of boilerplate. + +There are four macros to make your life easier as long as you (1) want to use a JSON object as serialization and (2) want to use the member variable names as object keys in that object: + +- [`NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(name, member1, member2, ...)`](../api/macros/nlohmann_define_type_non_intrusive.md) is to be defined inside the namespace of the class/struct to create code for. It will throw an exception in `from_json()` due to a missing value in the JSON object. +- [`NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(name, member1, member2, ...)`](../api/macros/nlohmann_define_type_non_intrusive.md) is to be defined inside the namespace of the class/struct to create code for. It will not throw an exception in `from_json()` due to a missing value in the JSON object, but fills in values from object which is default-constructed by the type. +- [`NLOHMANN_DEFINE_TYPE_INTRUSIVE(name, member1, member2, ...)`](../api/macros/nlohmann_define_type_intrusive.md) is to be defined inside the class/struct to create code for. This macro can also access private members. It will throw an exception in `from_json()` due to a missing value in the JSON object. +- [`NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(name, member1, member2, ...)`](../api/macros/nlohmann_define_type_intrusive.md) is to be defined inside the class/struct to create code for. This macro can also access private members. It will not throw an exception in `from_json()` due to a missing value in the JSON object, but fills in values from object which is default-constructed by the type. + +In all macros, the first parameter is the name of the class/struct, and all remaining parameters name the members. You can read more docs about them starting from [here](macros.md#nlohmann_define_type_intrusivetype-member). + +!!! info "Implementation limits" + + - The current macro implementations are limited to at most 64 member variables. If you want to serialize/deserialize + types with more than 64 member variables, you need to define the `to_json`/`from_json` functions manually. + - The macros only work for the [`nlohmann::json`](../api/json.md) type; other specializations such as + [`nlohmann::ordered_json`](../api/ordered_json.md) are currently unsupported. + +??? example + + The `to_json`/`from_json` functions for the `person` struct above can be created with: + + ```cpp + namespace ns { + NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(person, name, address, age) + } + ``` + + Here is an example with private members, where `NLOHMANN_DEFINE_TYPE_INTRUSIVE` is needed: + + ```cpp + namespace ns { + class address { + private: + std::string street; + int housenumber; + int postcode; + + public: + NLOHMANN_DEFINE_TYPE_INTRUSIVE(address, street, housenumber, postcode) + }; + } + ``` + +## How do I convert third-party types? + +This requires a bit more advanced technique. But first, let's see how this conversion mechanism works: + +The library uses **JSON Serializers** to convert types to json. +The default serializer for `nlohmann::json` is `nlohmann::adl_serializer` (ADL means [Argument-Dependent Lookup](https://en.cppreference.com/w/cpp/language/adl)). + +It is implemented like this (simplified): + +```cpp +template +struct adl_serializer { + static void to_json(json& j, const T& value) { + // calls the "to_json" method in T's namespace + } + + static void from_json(const json& j, T& value) { + // same thing, but with the "from_json" method + } +}; +``` + +This serializer works fine when you have control over the type's namespace. However, what about `boost::optional` or `std::filesystem::path` (C++17)? Hijacking the `boost` namespace is pretty bad, and it's illegal to add something other than template specializations to `std`... + +To solve this, you need to add a specialization of `adl_serializer` to the `nlohmann` namespace, here's an example: + +```cpp +// partial specialization (full specialization works too) +NLOHMANN_JSON_NAMESPACE_BEGIN +template +struct adl_serializer> { + static void to_json(json& j, const boost::optional& opt) { + if (opt == boost::none) { + j = nullptr; + } else { + j = *opt; // this will call adl_serializer::to_json which will + // find the free function to_json in T's namespace! + } + } + + static void from_json(const json& j, boost::optional& opt) { + if (j.is_null()) { + opt = boost::none; + } else { + opt = j.template get(); // same as above, but with + // adl_serializer::from_json + } + } +}; +NLOHMANN_JSON_NAMESPACE_END +``` + +!!! note "ABI compatibility" + + Use [`NLOHMANN_JSON_NAMESPACE_BEGIN`](../api/macros/nlohmann_json_namespace_begin.md) and `NLOHMANN_JSON_NAMESPACE_END` + instead of `#!cpp namespace nlohmann { }` in code which may be linked with different versions of this library. + +## How can I use `get()` for non-default constructible/non-copyable types? + +There is a way, if your type is [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible). You will need to specialize the `adl_serializer` as well, but with a special `from_json` overload: + +```cpp +struct move_only_type { + move_only_type() = delete; + move_only_type(int ii): i(ii) {} + move_only_type(const move_only_type&) = delete; + move_only_type(move_only_type&&) = default; + + int i; +}; + +namespace nlohmann { + template <> + struct adl_serializer { + // note: the return type is no longer 'void', and the method only takes + // one argument + static move_only_type from_json(const json& j) { + return {j.template get()}; + } + + // Here's the catch! You must provide a to_json method! Otherwise, you + // will not be able to convert move_only_type to json, since you fully + // specialized adl_serializer on that type + static void to_json(json& j, move_only_type t) { + j = t.i; + } + }; +} +``` + +## Can I write my own serializer? (Advanced use) + +Yes. You might want to take a look at [`unit-udt.cpp`](https://github.com/nlohmann/json/blob/develop/tests/src/unit-udt.cpp) in the test suite, to see a few examples. + +If you write your own serializer, you'll need to do a few things: + +- use a different `basic_json` alias than `nlohmann::json` (the last template parameter of `basic_json` is the `JSONSerializer`) +- use your `basic_json` alias (or a template parameter) in all your `to_json`/`from_json` methods +- use `nlohmann::to_json` and `nlohmann::from_json` when you need ADL + +Here is an example, without simplifications, that only accepts types with a size <= 32, and uses ADL. + +```cpp +// You should use void as a second template argument +// if you don't need compile-time checks on T +template::type> +struct less_than_32_serializer { + template + static void to_json(BasicJsonType& j, T value) { + // we want to use ADL, and call the correct to_json overload + using nlohmann::to_json; // this method is called by adl_serializer, + // this is where the magic happens + to_json(j, value); + } + + template + static void from_json(const BasicJsonType& j, T& value) { + // same thing here + using nlohmann::from_json; + from_json(j, value); + } +}; +``` + +Be **very** careful when reimplementing your serializer, you can stack overflow if you don't pay attention: + +```cpp +template +struct bad_serializer +{ + template + static void to_json(BasicJsonType& j, const T& value) { + // this calls BasicJsonType::json_serializer::to_json(j, value); + // if BasicJsonType::json_serializer == bad_serializer ... oops! + j = value; + } + + template + static void to_json(const BasicJsonType& j, T& value) { + // this calls BasicJsonType::json_serializer::from_json(j, value); + // if BasicJsonType::json_serializer == bad_serializer ... oops! + value = j.template template get(); // oops! + } +}; +``` diff --git a/external_imported/json/docs/mkdocs/docs/features/assertions.md b/external_imported/json/docs/mkdocs/docs/features/assertions.md new file mode 100644 index 000000000..2bad62e81 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/assertions.md @@ -0,0 +1,131 @@ +# Runtime Assertions + +The code contains numerous debug assertions to ensure class invariants are valid or to detect undefined behavior. +Whereas the former class invariants are nothing to be concerned of, the latter checks for undefined behavior are to +detect bugs in client code. + +## Switch off runtime assertions + +Runtime assertions can be switched off by defining the preprocessor macro `NDEBUG` (see the +[documentation of assert](https://en.cppreference.com/w/cpp/error/assert)) which is the default for release builds. + +## Change assertion behavior + +The behavior of runtime assertions can be changes by defining macro [`JSON_ASSERT(x)`](../api/macros/json_assert.md) +before including the `json.hpp` header. + +## Function with runtime assertions + +### Unchecked object access to a const value + +Function [`operator[]`](../api/basic_json/operator%5B%5D.md) implements unchecked access for objects. Whereas a missing +key is added in case of non-const objects, accessing a const object with a missing key is undefined behavior (think of a +dereferenced null pointer) and yields a runtime assertion. + +If you are not sure whether an element in an object exists, use checked access with the +[`at` function](../api/basic_json/at.md) or call the [`contains` function](../api/basic_json/contains.md) before. + +See also the documentation on [element access](element_access/index.md). + +??? example "Example 1: Missing object key" + + The following code will trigger an assertion at runtime: + + ```cpp + #include + + using json = nlohmann::json; + + int main() + { + const json j = {{"key", "value"}}; + auto v = j["missing"]; + } + ``` + + Output: + + ``` + Assertion failed: (m_value.object->find(key) != m_value.object->end()), function operator[], file json.hpp, line 2144. + ``` + +### Constructing from an uninitialized iterator range + +Constructing a JSON value from an iterator range (see [constructor](../api/basic_json/basic_json.md)) with an +uninitialized iterator is undefined behavior and yields a runtime assertion. + +??? example "Example 2: Uninitialized iterator range" + + The following code will trigger an assertion at runtime: + + ```cpp + #include + + using json = nlohmann::json; + + int main() + { + json::iterator it1, it2; + json j(it1, it2); + } + ``` + + Output: + + ``` + Assertion failed: (m_object != nullptr), function operator++, file iter_impl.hpp, line 368. + ``` + +### Operations on uninitialized iterators + +Any operation on uninitialized iterators (i.e., iterators that are not associated with any JSON value) is undefined +behavior and yields a runtime assertion. + +??? example "Example 3: Uninitialized iterator" + + The following code will trigger an assertion at runtime: + + ```cpp + #include + + using json = nlohmann::json; + + int main() + { + json::iterator it; + ++it; + } + ``` + + Output: + + ``` + Assertion failed: (m_object != nullptr), function operator++, file iter_impl.hpp, line 368. + ``` + +### Reading from a null `FILE` pointer + +Reading from a null `#!cpp FILE` pointer is undefined behavior and yields a runtime assertion. This can happen when +calling `#!cpp std::fopen` on a nonexistent file. + +??? example "Example 4: Uninitialized iterator" + + The following code will trigger an assertion at runtime: + + ```cpp + #include + + using json = nlohmann::json; + + int main() + { + std::FILE* f = std::fopen("nonexistent_file.json", "r"); + json j = json::parse(f); + } + ``` + + Output: + + ``` + Assertion failed: (m_file != nullptr), function file_input_adapter, file input_adapters.hpp, line 55. + ``` diff --git a/external_imported/json/docs/mkdocs/docs/features/binary_formats/bjdata.md b/external_imported/json/docs/mkdocs/docs/features/binary_formats/bjdata.md new file mode 100644 index 000000000..a89a22885 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/binary_formats/bjdata.md @@ -0,0 +1,194 @@ +# BJData + +The [BJData format](https://neurojson.org) was derived from and improved upon +[Universal Binary JSON(UBJSON)](https://ubjson.org) specification (Draft 12). Specifically, it introduces an optimized +array container for efficient storage of N-dimensional packed arrays (**ND-arrays**); it also adds 4 new type markers - +`[u] - uint16`, `[m] - uint32`, `[M] - uint64` and `[h] - float16` - to unambiguously map common binary numeric types; +furthermore, it uses little-endian (LE) to store all numerics instead of big-endian (BE) as in UBJSON to avoid +unnecessary conversions on commonly available platforms. + +Compared to other binary JSON-like formats such as MessagePack and CBOR, both BJData and UBJSON demonstrate a rare +combination of being both binary and **quasi-human-readable**. This is because all semantic elements in BJData and +UBJSON, including the data-type markers and name/string types are directly human-readable. Data stored in the +BJData/UBJSON format are not only compact in size, fast to read/write, but also can be directly searched or read using +simple processing. + +!!! abstract "References" + + - [BJData Specification](https://neurojson.org/bjdata/draft2) + +## Serialization + +The library uses the following mapping from JSON values types to BJData types according to the BJData specification: + +| JSON value type | value/range | BJData type | marker | +|-----------------|-------------------------------------------|----------------|--------| +| null | `null` | null | `Z` | +| boolean | `true` | true | `T` | +| boolean | `false` | false | `F` | +| number_integer | -9223372036854775808..-2147483649 | int64 | `L` | +| number_integer | -2147483648..-32769 | int32 | `l` | +| number_integer | -32768..-129 | int16 | `I` | +| number_integer | -128..127 | int8 | `i` | +| number_integer | 128..255 | uint8 | `U` | +| number_integer | 256..32767 | int16 | `I` | +| number_integer | 32768..65535 | uint16 | `u` | +| number_integer | 65536..2147483647 | int32 | `l` | +| number_integer | 2147483648..4294967295 | uint32 | `m` | +| number_integer | 4294967296..9223372036854775807 | int64 | `L` | +| number_integer | 9223372036854775808..18446744073709551615 | uint64 | `M` | +| number_unsigned | 0..127 | int8 | `i` | +| number_unsigned | 128..255 | uint8 | `U` | +| number_unsigned | 256..32767 | int16 | `I` | +| number_unsigned | 32768..65535 | uint16 | `u` | +| number_unsigned | 65536..2147483647 | int32 | `l` | +| number_unsigned | 2147483648..4294967295 | uint32 | `m` | +| number_unsigned | 4294967296..9223372036854775807 | int64 | `L` | +| number_unsigned | 9223372036854775808..18446744073709551615 | uint64 | `M` | +| number_float | *any value* | float64 | `D` | +| string | *with shortest length indicator* | string | `S` | +| array | *see notes on optimized format/ND-array* | array | `[` | +| object | *see notes on optimized format* | map | `{` | + +!!! success "Complete mapping" + + The mapping is **complete** in the sense that any JSON value type can be converted to a BJData value. + + Any BJData output created by `to_bjdata` can be successfully parsed by `from_bjdata`. + +!!! warning "Size constraints" + + The following values can **not** be converted to a BJData value: + + - strings with more than 18446744073709551615 bytes, i.e., $2^{64}-1$ bytes (theoretical) + +!!! info "Unused BJData markers" + + The following markers are not used in the conversion: + + - `Z`: no-op values are not created. + - `C`: single-byte strings are serialized with `S` markers. + +!!! info "NaN/infinity handling" + + If NaN or Infinity are stored inside a JSON number, they are serialized properly. This behavior differs from the + `dump()` function which serializes NaN or Infinity to `#!json null`. + +!!! info "Endianness" + + A breaking difference between BJData and UBJSON is the endianness of numerical values. In BJData, all numerical data + types (integers `UiuImlML` and floating-point values `hdD`) are stored in the little-endian (LE) byte order as + opposed to big-endian as used by UBJSON. Adopting LE to store numeric records avoids unnecessary byte swapping on + most modern computers where LE is used as the default byte order. + +!!! info "Optimized formats" + + Optimized formats for containers are supported via two parameters of + [`to_bjdata`](../../api/basic_json/to_bjdata.md): + + - Parameter `use_size` adds size information to the beginning of a container and removes the closing marker. + - Parameter `use_type` further checks whether all elements of a container have the same type and adds the type + marker to the beginning of the container. The `use_type` parameter must only be used together with + `use_size = true`. + + Note that `use_size = true` alone may result in larger representations - the benefit of this parameter is that the + receiving side is immediately informed of the number of elements in the container. + +!!! info "ND-array optimized format" + + BJData extends UBJSON's optimized array **size** marker to support ND-arrays of uniform numerical data types + (referred to as *packed arrays*). For example, the 2-D `uint8` integer array `[[1,2],[3,4],[5,6]]`, stored as nested + optimized array in UBJSON `[ [$U#i2 1 2 [$U#i2 3 4 [$U#i2 5 6 ]`, can be further compressed in BJData to + `[$U#[$i#i2 2 3 1 2 3 4 5 6` or `[$U#[i2 i3] 1 2 3 4 5 6`. + + To maintain type and size information, ND-arrays are converted to JSON objects following the **annotated array + format** (defined in the [JData specification (Draft 3)][JDataAAFmt]), when parsed using + [`from_bjdata`](../../api/basic_json/from_bjdata.md). For example, the above 2-D `uint8` array can be parsed and + accessed as + + ```json + { + "_ArrayType_": "uint8", + "_ArraySize_": [2,3], + "_ArrayData_": [1,2,3,4,5,6] + } + ``` + + Likewise, when a JSON object in the above form is serialzed using + [`to_bjdata`](../../api/basic_json/to_bjdata.md), it is automatically converted into a compact BJData ND-array. The + only exception is, that when the 1-dimensional vector stored in `"_ArraySize_"` contains a single integer or two + integers with one being 1, a regular 1-D optimized array is generated. + + The current version of this library does not yet support automatic detection of and conversion from a nested JSON + array input to a BJData ND-array. + + [JDataAAFmt]: https://github.com/NeuroJSON/jdata/blob/master/JData_specification.md#annotated-storage-of-n-d-arrays) + +!!! info "Restrictions in optimized data types for arrays and objects" + + Due to diminished space saving, hampered readability, and increased security risks, in BJData, the allowed data + types following the `$` marker in an optimized array and object container are restricted to + **non-zero-fixed-length** data types. Therefore, the valid optimized type markers can only be one of `UiuImlMLhdDC`. + This also means other variable (`[{SH`) or zero-length types (`TFN`) can not be used in an optimized array or object + in BJData. + +!!! info "Binary values" + + If the JSON data contains the binary type, the value stored is a list of integers, as suggested by the BJData + documentation. In particular, this means that the serialization and the deserialization of JSON containing binary + values into BJData and back will result in a different JSON object. + +??? example + + ```cpp + --8<-- "examples/to_bjdata.cpp" + ``` + + Output: + + ```c + --8<-- "examples/to_bjdata.output" + ``` + +## Deserialization + +The library maps BJData types to JSON value types as follows: + +| BJData type | JSON value type | marker | +|-------------|-----------------------------------------|--------| +| no-op | *no value, next value is read* | `N` | +| null | `null` | `Z` | +| false | `false` | `F` | +| true | `true` | `T` | +| float16 | number_float | `h` | +| float32 | number_float | `d` | +| float64 | number_float | `D` | +| uint8 | number_unsigned | `U` | +| int8 | number_integer | `i` | +| uint16 | number_unsigned | `u` | +| int16 | number_integer | `I` | +| uint32 | number_unsigned | `m` | +| int32 | number_integer | `l` | +| uint64 | number_unsigned | `M` | +| int64 | number_integer | `L` | +| string | string | `S` | +| char | string | `C` | +| array | array (optimized values are supported) | `[` | +| ND-array | object (in JData annotated array format)|`[$.#[.`| +| object | object (optimized values are supported) | `{` | + +!!! success "Complete mapping" + + The mapping is **complete** in the sense that any BJData value can be converted to a JSON value. + +??? example + + ```cpp + --8<-- "examples/from_bjdata.cpp" + ``` + + Output: + + ```json + --8<-- "examples/from_bjdata.output" + ``` diff --git a/external_imported/json/docs/mkdocs/docs/features/binary_formats/bson.md b/external_imported/json/docs/mkdocs/docs/features/binary_formats/bson.md new file mode 100644 index 000000000..f3b8cf18d --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/binary_formats/bson.md @@ -0,0 +1,96 @@ +# BSON + +BSON, short for Binary JSON, is a binary-encoded serialization of JSON-like documents. Like JSON, BSON supports the +embedding of documents and arrays within other documents and arrays. BSON also contains extensions that allow +representation of data types that are not part of the JSON spec. For example, BSON has a Date type and a BinData type. + +!!! abstract "References" + + - [BSON Website](http://bsonspec.org) - the main source on BSON + - [BSON Specification](http://bsonspec.org/spec.html) - the specification + + +## Serialization + +The library uses the following mapping from JSON values types to BSON types: + +| JSON value type | value/range | BSON type | marker | +|-----------------|-------------------------------------------|-----------|--------| +| null | `null` | null | 0x0A | +| boolean | `true`, `false` | boolean | 0x08 | +| number_integer | -9223372036854775808..-2147483649 | int64 | 0x12 | +| number_integer | -2147483648..2147483647 | int32 | 0x10 | +| number_integer | 2147483648..9223372036854775807 | int64 | 0x12 | +| number_unsigned | 0..2147483647 | int32 | 0x10 | +| number_unsigned | 2147483648..9223372036854775807 | int64 | 0x12 | +| number_unsigned | 9223372036854775808..18446744073709551615 | -- | -- | +| number_float | *any value* | double | 0x01 | +| string | *any value* | string | 0x02 | +| array | *any value* | document | 0x04 | +| object | *any value* | document | 0x03 | +| binary | *any value* | binary | 0x05 | + +!!! warning "Incomplete mapping" + + The mapping is **incomplete**, since only JSON-objects (and things + contained therein) can be serialized to BSON. + Also, integers larger than 9223372036854775807 cannot be serialized to BSON, + and the keys may not contain U+0000, since they are serialized a + zero-terminated c-strings. + +??? example + + ```cpp + --8<-- "examples/to_bson.cpp" + ``` + + Output: + + ```c + --8<-- "examples/to_bson.output" + ``` + + +## Deserialization + +The library maps BSON record types to JSON value types as follows: + +| BSON type | BSON marker byte | JSON value type | +|-----------------------|------------------|-----------------| +| double | 0x01 | number_float | +| string | 0x02 | string | +| document | 0x03 | object | +| array | 0x04 | array | +| binary | 0x05 | binary | +| undefined | 0x06 | *unsupported* | +| ObjectId | 0x07 | *unsupported* | +| boolean | 0x08 | boolean | +| UTC Date-Time | 0x09 | *unsupported* | +| null | 0x0A | null | +| Regular Expr. | 0x0B | *unsupported* | +| DB Pointer | 0x0C | *unsupported* | +| JavaScript Code | 0x0D | *unsupported* | +| Symbol | 0x0E | *unsupported* | +| JavaScript Code | 0x0F | *unsupported* | +| int32 | 0x10 | number_integer | +| Timestamp | 0x11 | *unsupported* | +| 128-bit decimal float | 0x13 | *unsupported* | +| Max Key | 0x7F | *unsupported* | +| Min Key | 0xFF | *unsupported* | + +!!! warning "Incomplete mapping" + + The mapping is **incomplete**. The unsupported mappings are indicated in the table above. + + +??? example + + ```cpp + --8<-- "examples/from_bson.cpp" + ``` + + Output: + + ```json + --8<-- "examples/from_bson.output" + ``` diff --git a/external_imported/json/docs/mkdocs/docs/features/binary_formats/cbor.md b/external_imported/json/docs/mkdocs/docs/features/binary_formats/cbor.md new file mode 100644 index 000000000..2d0a1dae1 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/binary_formats/cbor.md @@ -0,0 +1,181 @@ +# CBOR + +The Concise Binary Object Representation (CBOR) is a data format whose design goals include the possibility of extremely +small code size, fairly small message size, and extensibility without the need for version negotiation. + +!!! abstract "References" + + - [CBOR Website](http://cbor.io) - the main source on CBOR + - [CBOR Playground](http://cbor.me) - an interactive webpage to translate between JSON and CBOR + - [RFC 7049](https://tools.ietf.org/html/rfc7049) - the CBOR specification + +## Serialization + +The library uses the following mapping from JSON values types to CBOR types according to the CBOR specification +([RFC 7049](https://www.rfc-editor.org/rfc/rfc7049.html)): + +| JSON value type | value/range | CBOR type | first byte | +|-----------------|--------------------------------------------|-----------------------------------|------------| +| null | `null` | Null | 0xF6 | +| boolean | `true` | True | 0xF5 | +| boolean | `false` | False | 0xF4 | +| number_integer | -9223372036854775808..-2147483649 | Negative integer (8 bytes follow) | 0x3B | +| number_integer | -2147483648..-32769 | Negative integer (4 bytes follow) | 0x3A | +| number_integer | -32768..-129 | Negative integer (2 bytes follow) | 0x39 | +| number_integer | -128..-25 | Negative integer (1 byte follow) | 0x38 | +| number_integer | -24..-1 | Negative integer | 0x20..0x37 | +| number_integer | 0..23 | Integer | 0x00..0x17 | +| number_integer | 24..255 | Unsigned integer (1 byte follow) | 0x18 | +| number_integer | 256..65535 | Unsigned integer (2 bytes follow) | 0x19 | +| number_integer | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A | +| number_integer | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B | +| number_unsigned | 0..23 | Integer | 0x00..0x17 | +| number_unsigned | 24..255 | Unsigned integer (1 byte follow) | 0x18 | +| number_unsigned | 256..65535 | Unsigned integer (2 bytes follow) | 0x19 | +| number_unsigned | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A | +| number_unsigned | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B | +| number_float | *any value representable by a float* | Single-Precision Float | 0xFA | +| number_float | *any value NOT representable by a float* | Double-Precision Float | 0xFB | +| string | *length*: 0..23 | UTF-8 string | 0x60..0x77 | +| string | *length*: 23..255 | UTF-8 string (1 byte follow) | 0x78 | +| string | *length*: 256..65535 | UTF-8 string (2 bytes follow) | 0x79 | +| string | *length*: 65536..4294967295 | UTF-8 string (4 bytes follow) | 0x7A | +| string | *length*: 4294967296..18446744073709551615 | UTF-8 string (8 bytes follow) | 0x7B | +| array | *size*: 0..23 | array | 0x80..0x97 | +| array | *size*: 23..255 | array (1 byte follow) | 0x98 | +| array | *size*: 256..65535 | array (2 bytes follow) | 0x99 | +| array | *size*: 65536..4294967295 | array (4 bytes follow) | 0x9A | +| array | *size*: 4294967296..18446744073709551615 | array (8 bytes follow) | 0x9B | +| object | *size*: 0..23 | map | 0xA0..0xB7 | +| object | *size*: 23..255 | map (1 byte follow) | 0xB8 | +| object | *size*: 256..65535 | map (2 bytes follow) | 0xB9 | +| object | *size*: 65536..4294967295 | map (4 bytes follow) | 0xBA | +| object | *size*: 4294967296..18446744073709551615 | map (8 bytes follow) | 0xBB | +| binary | *size*: 0..23 | byte string | 0x40..0x57 | +| binary | *size*: 23..255 | byte string (1 byte follow) | 0x58 | +| binary | *size*: 256..65535 | byte string (2 bytes follow) | 0x59 | +| binary | *size*: 65536..4294967295 | byte string (4 bytes follow) | 0x5A | +| binary | *size*: 4294967296..18446744073709551615 | byte string (8 bytes follow) | 0x5B | + +Binary values with subtype are mapped to tagged values (0xD8..0xDB) depending on the subtype, followed by a byte string, +see "binary" cells in the table above. + +!!! success "Complete mapping" + + The mapping is **complete** in the sense that any JSON value type can be converted to a CBOR value. + +!!! info "NaN/infinity handling" + + If NaN or Infinity are stored inside a JSON number, they are serialized properly. This behavior differs from the normal JSON serialization which serializes NaN or Infinity to `null`. + +!!! info "Unused CBOR types" + + The following CBOR types are not used in the conversion: + + - UTF-8 strings terminated by "break" (0x7F) + - arrays terminated by "break" (0x9F) + - maps terminated by "break" (0xBF) + - byte strings terminated by "break" (0x5F) + - date/time (0xC0..0xC1) + - bignum (0xC2..0xC3) + - decimal fraction (0xC4) + - bigfloat (0xC5) + - expected conversions (0xD5..0xD7) + - simple values (0xE0..0xF3, 0xF8) + - undefined (0xF7) + - half-precision floats (0xF9) + - break (0xFF) + +!!! info "Tagged items" + + Binary subtypes will be serialized as tagged items. See [binary values](../binary_values.md#cbor) for an example. + +??? example + + ```cpp + --8<-- "examples/to_cbor.cpp" + ``` + + Output: + + ```c + --8<-- "examples/to_cbor.output" + ``` + +## Deserialization + +The library maps CBOR types to JSON value types as follows: + +| CBOR type | JSON value type | first byte | +|------------------------|-----------------|------------| +| Integer | number_unsigned | 0x00..0x17 | +| Unsigned integer | number_unsigned | 0x18 | +| Unsigned integer | number_unsigned | 0x19 | +| Unsigned integer | number_unsigned | 0x1A | +| Unsigned integer | number_unsigned | 0x1B | +| Negative integer | number_integer | 0x20..0x37 | +| Negative integer | number_integer | 0x38 | +| Negative integer | number_integer | 0x39 | +| Negative integer | number_integer | 0x3A | +| Negative integer | number_integer | 0x3B | +| Byte string | binary | 0x40..0x57 | +| Byte string | binary | 0x58 | +| Byte string | binary | 0x59 | +| Byte string | binary | 0x5A | +| Byte string | binary | 0x5B | +| UTF-8 string | string | 0x60..0x77 | +| UTF-8 string | string | 0x78 | +| UTF-8 string | string | 0x79 | +| UTF-8 string | string | 0x7A | +| UTF-8 string | string | 0x7B | +| UTF-8 string | string | 0x7F | +| array | array | 0x80..0x97 | +| array | array | 0x98 | +| array | array | 0x99 | +| array | array | 0x9A | +| array | array | 0x9B | +| array | array | 0x9F | +| map | object | 0xA0..0xB7 | +| map | object | 0xB8 | +| map | object | 0xB9 | +| map | object | 0xBA | +| map | object | 0xBB | +| map | object | 0xBF | +| False | `false` | 0xF4 | +| True | `true` | 0xF5 | +| Null | `null` | 0xF6 | +| Half-Precision Float | number_float | 0xF9 | +| Single-Precision Float | number_float | 0xFA | +| Double-Precision Float | number_float | 0xFB | + +!!! warning "Incomplete mapping" + + The mapping is **incomplete** in the sense that not all CBOR types can be converted to a JSON value. The following CBOR types are not supported and will yield parse errors: + + - date/time (0xC0..0xC1) + - bignum (0xC2..0xC3) + - decimal fraction (0xC4) + - bigfloat (0xC5) + - expected conversions (0xD5..0xD7) + - simple values (0xE0..0xF3, 0xF8) + - undefined (0xF7) + +!!! warning "Object keys" + + CBOR allows map keys of any type, whereas JSON only allows strings as keys in object values. Therefore, CBOR maps with keys other than UTF-8 strings are rejected. + +!!! warning "Tagged items" + + Tagged items will throw a parse error by default. They can be ignored by passing `cbor_tag_handler_t::ignore` to function `from_cbor`. They can be stored by passing `cbor_tag_handler_t::store` to function `from_cbor`. + +??? example + + ```cpp + --8<-- "examples/from_cbor.cpp" + ``` + + Output: + + ```json + --8<-- "examples/from_cbor.output" + ``` diff --git a/external_imported/json/docs/mkdocs/docs/features/binary_formats/index.md b/external_imported/json/docs/mkdocs/docs/features/binary_formats/index.md new file mode 100644 index 000000000..e74290b09 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/binary_formats/index.md @@ -0,0 +1,52 @@ +# Binary Formats + +Though JSON is a ubiquitous data format, it is not a very compact format suitable for data exchange, for instance over +a network. Hence, the library supports + +- [BJData](bjdata.md) (Binary JData), +- [BSON](bson.md) (Binary JSON), +- [CBOR](cbor.md) (Concise Binary Object Representation), +- [MessagePack](messagepack.md), and +- [UBJSON](ubjson.md) (Universal Binary JSON) + +to efficiently encode JSON values to byte vectors and to decode such vectors. + +## Comparison + +### Completeness + +| Format | Serialization | Deserialization | +|-------------|-----------------------------------------------|----------------------------------------------| +| BJData | complete | complete | +| BSON | incomplete: top-level value must be an object | incomplete, but all JSON types are supported | +| CBOR | complete | incomplete, but all JSON types are supported | +| MessagePack | complete | complete | +| UBJSON | complete | complete | + +### Binary values + +| Format | Binary values | Binary subtypes | +|-------------|---------------|-----------------| +| BJData | not supported | not supported | +| BSON | supported | supported | +| CBOR | supported | supported | +| MessagePack | supported | supported | +| UBJSON | not supported | not supported | + +See [binary values](../binary_values.md) for more information. + +### Sizes + +| Format | canada.json | twitter.json | citm_catalog.json | jeopardy.json | +|--------------------|-------------|--------------|-------------------|---------------| +| BJData | 53.2 % | 91.1 % | 78.1 % | 96.6 % | +| BJData (size) | 58.6 % | 92.1 % | 86.7 % | 97.4 % | +| BJData (size+tyoe) | 58.6 % | 92.1 % | 86.5 % | 97.4 % | +| BSON | 85.8 % | 95.2 % | 95.8 % | 106.7 % | +| CBOR | 50.5 % | 86.3 % | 68.4 % | 88.0 % | +| MessagePack | 50.5 % | 86.0 % | 68.5 % | 87.9 % | +| UBJSON | 53.2 % | 91.3 % | 78.2 % | 96.6 % | +| UBJSON (size) | 58.6 % | 92.3 % | 86.8 % | 97.4 % | +| UBJSON (size+type) | 55.9 % | 92.3 % | 85.0 % | 95.0 % | + +Sizes compared to minified JSON value. diff --git a/external_imported/json/docs/mkdocs/docs/features/binary_formats/messagepack.md b/external_imported/json/docs/mkdocs/docs/features/binary_formats/messagepack.md new file mode 100644 index 000000000..b2f69f174 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/binary_formats/messagepack.md @@ -0,0 +1,143 @@ +# MessagePack + +MessagePack is an efficient binary serialization format. It lets you exchange data among multiple languages like JSON. +But it's faster and smaller. Small integers are encoded into a single byte, and typical short strings require only one +extra byte in addition to the strings themselves. + +!!! abstract "References" + + - [MessagePack website](https://msgpack.org) + - [MessagePack specification](https://github.com/msgpack/msgpack/blob/master/spec.md) + +## Serialization + +The library uses the following mapping from JSON values types to MessagePack types according to the MessagePack +specification: + +| JSON value type | value/range | MessagePack type | first byte | +|-----------------|------------------------------------------|------------------|------------| +| null | `null` | nil | 0xC0 | +| boolean | `true` | true | 0xC3 | +| boolean | `false` | false | 0xC2 | +| number_integer | -9223372036854775808..-2147483649 | int64 | 0xD3 | +| number_integer | -2147483648..-32769 | int32 | 0xD2 | +| number_integer | -32768..-129 | int16 | 0xD1 | +| number_integer | -128..-33 | int8 | 0xD0 | +| number_integer | -32..-1 | negative fixint | 0xE0..0xFF | +| number_integer | 0..127 | positive fixint | 0x00..0x7F | +| number_integer | 128..255 | uint 8 | 0xCC | +| number_integer | 256..65535 | uint 16 | 0xCD | +| number_integer | 65536..4294967295 | uint 32 | 0xCE | +| number_integer | 4294967296..18446744073709551615 | uint 64 | 0xCF | +| number_unsigned | 0..127 | positive fixint | 0x00..0x7F | +| number_unsigned | 128..255 | uint 8 | 0xCC | +| number_unsigned | 256..65535 | uint 16 | 0xCD | +| number_unsigned | 65536..4294967295 | uint 32 | 0xCE | +| number_unsigned | 4294967296..18446744073709551615 | uint 64 | 0xCF | +| number_float | *any value representable by a float* | float 32 | 0xCA | +| number_float | *any value NOT representable by a float* | float 64 | 0xCB | +| string | *length*: 0..31 | fixstr | 0xA0..0xBF | +| string | *length*: 32..255 | str 8 | 0xD9 | +| string | *length*: 256..65535 | str 16 | 0xDA | +| string | *length*: 65536..4294967295 | str 32 | 0xDB | +| array | *size*: 0..15 | fixarray | 0x90..0x9F | +| array | *size*: 16..65535 | array 16 | 0xDC | +| array | *size*: 65536..4294967295 | array 32 | 0xDD | +| object | *size*: 0..15 | fix map | 0x80..0x8F | +| object | *size*: 16..65535 | map 16 | 0xDE | +| object | *size*: 65536..4294967295 | map 32 | 0xDF | +| binary | *size*: 0..255 | bin 8 | 0xC4 | +| binary | *size*: 256..65535 | bin 16 | 0xC5 | +| binary | *size*: 65536..4294967295 | bin 32 | 0xC6 | + +!!! success "Complete mapping" + + The mapping is **complete** in the sense that any JSON value type can be converted to a MessagePack value. + + Any MessagePack output created by `to_msgpack` can be successfully parsed by `from_msgpack`. + +!!! warning "Size constraints" + + The following values can **not** be converted to a MessagePack value: + + - strings with more than 4294967295 bytes + - byte strings with more than 4294967295 bytes + - arrays with more than 4294967295 elements + - objects with more than 4294967295 elements + +!!! info "NaN/infinity handling" + + If NaN or Infinity are stored inside a JSON number, they are serialized properly in contrast to the + [dump](../../api/basic_json/dump.md) function which serializes NaN or Infinity to `null`. + +??? example + + ```cpp + --8<-- "examples/to_msgpack.cpp" + ``` + + Output: + + ```c + --8<-- "examples/to_msgpack.output" + ``` + +## Deserialization + +The library maps MessagePack types to JSON value types as follows: + +| MessagePack type | JSON value type | first byte | +|------------------|-----------------|------------| +| positive fixint | number_unsigned | 0x00..0x7F | +| fixmap | object | 0x80..0x8F | +| fixarray | array | 0x90..0x9F | +| fixstr | string | 0xA0..0xBF | +| nil | `null` | 0xC0 | +| false | `false` | 0xC2 | +| true | `true` | 0xC3 | +| float 32 | number_float | 0xCA | +| float 64 | number_float | 0xCB | +| uint 8 | number_unsigned | 0xCC | +| uint 16 | number_unsigned | 0xCD | +| uint 32 | number_unsigned | 0xCE | +| uint 64 | number_unsigned | 0xCF | +| int 8 | number_integer | 0xD0 | +| int 16 | number_integer | 0xD1 | +| int 32 | number_integer | 0xD2 | +| int 64 | number_integer | 0xD3 | +| str 8 | string | 0xD9 | +| str 16 | string | 0xDA | +| str 32 | string | 0xDB | +| array 16 | array | 0xDC | +| array 32 | array | 0xDD | +| map 16 | object | 0xDE | +| map 32 | object | 0xDF | +| bin 8 | binary | 0xC4 | +| bin 16 | binary | 0xC5 | +| bin 32 | binary | 0xC6 | +| ext 8 | binary | 0xC7 | +| ext 16 | binary | 0xC8 | +| ext 32 | binary | 0xC9 | +| fixext 1 | binary | 0xD4 | +| fixext 2 | binary | 0xD5 | +| fixext 4 | binary | 0xD6 | +| fixext 8 | binary | 0xD7 | +| fixext 16 | binary | 0xD8 | +| negative fixint | number_integer | 0xE0-0xFF | + +!!! info + + Any MessagePack output created by `to_msgpack` can be successfully parsed by `from_msgpack`. + + +??? example + + ```cpp + --8<-- "examples/from_msgpack.cpp" + ``` + + Output: + + ```json + --8<-- "examples/from_msgpack.output" + ``` diff --git a/external_imported/json/docs/mkdocs/docs/features/binary_formats/ubjson.md b/external_imported/json/docs/mkdocs/docs/features/binary_formats/ubjson.md new file mode 100644 index 000000000..76956d60a --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/binary_formats/ubjson.md @@ -0,0 +1,126 @@ +# UBJSON + +Universal Binary JSON (UBJSON) is a binary form directly imitating JSON, but requiring fewer bytes of data. It aims to +achieve the generality of JSON, combined with being much easier to process than JSON. + +!!! abstract "References" + + - [UBJSON Website](http://ubjson.org) + +## Serialization + +The library uses the following mapping from JSON values types to UBJSON types according to the UBJSON specification: + +| JSON value type | value/range | UBJSON type | marker | +|-----------------|-----------------------------------|----------------|--------| +| null | `null` | null | `Z` | +| boolean | `true` | true | `T` | +| boolean | `false` | false | `F` | +| number_integer | -9223372036854775808..-2147483649 | int64 | `L` | +| number_integer | -2147483648..-32769 | int32 | `l` | +| number_integer | -32768..-129 | int16 | `I` | +| number_integer | -128..127 | int8 | `i` | +| number_integer | 128..255 | uint8 | `U` | +| number_integer | 256..32767 | int16 | `I` | +| number_integer | 32768..2147483647 | int32 | `l` | +| number_integer | 2147483648..9223372036854775807 | int64 | `L` | +| number_unsigned | 0..127 | int8 | `i` | +| number_unsigned | 128..255 | uint8 | `U` | +| number_unsigned | 256..32767 | int16 | `I` | +| number_unsigned | 32768..2147483647 | int32 | `l` | +| number_unsigned | 2147483648..9223372036854775807 | int64 | `L` | +| number_unsigned | 2147483649..18446744073709551615 | high-precision | `H` | +| number_float | *any value* | float64 | `D` | +| string | *with shortest length indicator* | string | `S` | +| array | *see notes on optimized format* | array | `[` | +| object | *see notes on optimized format* | map | `{` | + +!!! success "Complete mapping" + + The mapping is **complete** in the sense that any JSON value type can be converted to a UBJSON value. + + Any UBJSON output created by `to_ubjson` can be successfully parsed by `from_ubjson`. + +!!! warning "Size constraints" + + The following values can **not** be converted to a UBJSON value: + + - strings with more than 9223372036854775807 bytes (theoretical) + +!!! info "Unused UBJSON markers" + + The following markers are not used in the conversion: + + - `Z`: no-op values are not created. + - `C`: single-byte strings are serialized with `S` markers. + +!!! info "NaN/infinity handling" + + If NaN or Infinity are stored inside a JSON number, they are serialized properly. This behavior differs from the + `dump()` function which serializes NaN or Infinity to `null`. + +!!! info "Optimized formats" + + The optimized formats for containers are supported: Parameter `use_size` adds size information to the beginning of a + container and removes the closing marker. Parameter `use_type` further checks whether all elements of a container + have the same type and adds the type marker to the beginning of the container. The `use_type` parameter must only be + used together with `use_size = true`. + + Note that `use_size = true` alone may result in larger representations - the benefit of this parameter is that the + receiving side is immediately informed on the number of elements of the container. + +!!! info "Binary values" + + If the JSON data contains the binary type, the value stored is a list of integers, as suggested by the UBJSON + documentation. In particular, this means that serialization and the deserialization of a JSON containing binary + values into UBJSON and back will result in a different JSON object. + +??? example + + ```cpp + --8<-- "examples/to_ubjson.cpp" + ``` + + Output: + + ```c + --8<-- "examples/to_ubjson.output" + ``` + +## Deserialization + +The library maps UBJSON types to JSON value types as follows: + +| UBJSON type | JSON value type | marker | +|-------------|-----------------------------------------|--------| +| no-op | *no value, next value is read* | `N` | +| null | `null` | `Z` | +| false | `false` | `F` | +| true | `true` | `T` | +| float32 | number_float | `d` | +| float64 | number_float | `D` | +| uint8 | number_unsigned | `U` | +| int8 | number_integer | `i` | +| int16 | number_integer | `I` | +| int32 | number_integer | `l` | +| int64 | number_integer | `L` | +| string | string | `S` | +| char | string | `C` | +| array | array (optimized values are supported) | `[` | +| object | object (optimized values are supported) | `{` | + +!!! success "Complete mapping" + + The mapping is **complete** in the sense that any UBJSON value can be converted to a JSON value. + +??? example + + ```cpp + --8<-- "examples/from_ubjson.cpp" + ``` + + Output: + + ```json + --8<-- "examples/from_ubjson.output" + ``` diff --git a/external_imported/json/docs/mkdocs/docs/features/binary_values.md b/external_imported/json/docs/mkdocs/docs/features/binary_values.md new file mode 100644 index 000000000..5ad6433cf --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/binary_values.md @@ -0,0 +1,372 @@ +# Binary Values + +The library implements several [binary formats](binary_formats/index.md) that encode JSON in an efficient way. Most of +these formats support binary values; that is, values that have semantics define outside the library and only define a +sequence of bytes to be stored. + +JSON itself does not have a binary value. As such, binary values are an extension that this library implements to store +values received by a binary format. Binary values are never created by the JSON parser, and are only part of a +serialized JSON text if they have been created manually or via a binary format. + +## API for binary values + +```plantuml +class json::binary_t { + -- setters -- + +void set_subtype(std::uint64_t subtype) + +void clear_subtype() + -- getters -- + +std::uint64_t subtype() const + +bool has_subtype() const +} + +"std::vector" <|-- json::binary_t +``` + +By default, binary values are stored as `std::vector`. This type can be changed by providing a template +parameter to the `basic_json` type. To store binary subtypes, the storage type is extended and exposed as +`json::binary_t`: + +```cpp +auto binary = json::binary_t({0xCA, 0xFE, 0xBA, 0xBE}); +auto binary_with_subtype = json::binary_t({0xCA, 0xFE, 0xBA, 0xBE}, 42); +``` + +There are several convenience functions to check and set the subtype: + +```cpp +binary.has_subtype(); // returns false +binary_with_subtype.has_subtype(); // returns true + +binary_with_subtype.clear_subtype(); +binary_with_subtype.has_subtype(); // returns true + +binary_with_subtype.set_subtype(42); +binary.set_subtype(23); + +binary.subtype(); // returns 23 +``` + +As `json::binary_t` is subclassing `std::vector`, all member functions are available: + +```cpp +binary.size(); // returns 4 +binary[1]; // returns 0xFE +``` + +JSON values can be constructed from `json::binary_t`: + +```cpp +json j = binary; +``` + +Binary values are primitive values just like numbers or strings: + +```cpp +j.is_binary(); // returns true +j.is_primitive(); // returns true +``` + +Given a binary JSON value, the `binary_t` can be accessed by reference as via `get_binary()`: + +```cpp +j.get_binary().has_subtype(); // returns true +j.get_binary().size(); // returns 4 +``` + +For convenience, binary JSON values can be constructed via `json::binary`: + +```cpp +auto j2 = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 23); +auto j3 = json::binary({0xCA, 0xFE, 0xBA, 0xBE}); + +j2 == j; // returns true +j3.get_binary().has_subtype(); // returns false +j3.get_binary().subtype(); // returns std::uint64_t(-1) as j3 has no subtype +``` + + + +## Serialization + +Binary values are serialized differently according to the formats. + +### JSON + +JSON does not have a binary type, and this library does not introduce a new type as this would break conformance. +Instead, binary values are serialized as an object with two keys: `bytes` holds an array of integers, and `subtype` +is an integer or `null`. + +??? example + + Code: + + ```cpp + // create a binary value of subtype 42 + json j; + j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42); + + // serialize to standard output + std::cout << j.dump(2) << std::endl; + ``` + + Output: + + ```json + { + "binary": { + "bytes": [202, 254, 186, 190], + "subtype": 42 + } + } + ``` + +!!! warning "No roundtrip for binary values" + + The JSON parser will not parse the objects generated by binary values back to binary values. This is by design to + remain standards compliant. Serializing binary values to JSON is only implemented for debugging purposes. + +### BJData + +[BJData](binary_formats/bjdata.md) neither supports binary values nor subtypes, and proposes to serialize binary values +as array of uint8 values. This translation is implemented by the library. + +??? example + + Code: + + ```cpp + // create a binary value of subtype 42 (will be ignored in BJData) + json j; + j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42); + + // convert to BJData + auto v = json::to_bjdata(j); + ``` + + `v` is a `std::vector` with the following 20 elements: + + ```c + 0x7B // '{' + 0x69 0x06 // i 6 (length of the key) + 0x62 0x69 0x6E 0x61 0x72 0x79 // "binary" + 0x5B // '[' + 0x55 0xCA 0x55 0xFE 0x55 0xBA 0x55 0xBE // content (each byte prefixed with 'U') + 0x5D // ']' + 0x7D // '}' + ``` + + The following code uses the type and size optimization for UBJSON: + + ```cpp + // convert to UBJSON using the size and type optimization + auto v = json::to_bjdata(j, true, true); + ``` + + The resulting vector has 22 elements; the optimization is not effective for examples with few values: + + ```c + 0x7B // '{' + 0x23 0x69 0x01 // '#' 'i' type of the array elements: unsigned integers + 0x69 0x06 // i 6 (length of the key) + 0x62 0x69 0x6E 0x61 0x72 0x79 // "binary" + 0x5B // '[' array + 0x24 0x55 // '$' 'U' type of the array elements: unsigned integers + 0x23 0x69 0x04 // '#' i 4 number of array elements + 0xCA 0xFE 0xBA 0xBE // content + ``` + + Note that subtype (42) is **not** serialized and that UBJSON has **no binary type**, and deserializing `v` would + yield the following value: + + ```json + { + "binary": [202, 254, 186, 190] + } + ``` + +### BSON + +[BSON](binary_formats/bson.md) supports binary values and subtypes. If a subtype is given, it is used and added as +unsigned 8-bit integer. If no subtype is given, the generic binary subtype 0x00 is used. + +??? example + + Code: + + ```cpp + // create a binary value of subtype 42 + json j; + j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42); + + // convert to BSON + auto v = json::to_bson(j); + ``` + + `v` is a `std::vector` with the following 22 elements: + + ```c + 0x16 0x00 0x00 0x00 // number of bytes in the document + 0x05 // binary value + 0x62 0x69 0x6E 0x61 0x72 0x79 0x00 // key "binary" + null byte + 0x04 0x00 0x00 0x00 // number of bytes + 0x2a // subtype + 0xCA 0xFE 0xBA 0xBE // content + 0x00 // end of the document + ``` + + Note that the serialization preserves the subtype, and deserializing `v` would yield the following value: + + ```json + { + "binary": { + "bytes": [202, 254, 186, 190], + "subtype": 42 + } + } + ``` + +### CBOR + +[CBOR](binary_formats/cbor.md) supports binary values, but no subtypes. Subtypes will be serialized as tags. Any binary +value will be serialized as byte strings. The library will choose the smallest representation using the length of the +byte array. + +??? example + + Code: + + ```cpp + // create a binary value of subtype 42 + json j; + j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42); + + // convert to CBOR + auto v = json::to_cbor(j); + ``` + + `v` is a `std::vector` with the following 15 elements: + + ```c + 0xA1 // map(1) + 0x66 // text(6) + 0x62 0x69 0x6E 0x61 0x72 0x79 // "binary" + 0xD8 0x2A // tag(42) + 0x44 // bytes(4) + 0xCA 0xFE 0xBA 0xBE // content + ``` + + Note that the subtype is serialized as tag. However, parsing tagged values yield a parse error unless + `json::cbor_tag_handler_t::ignore` or `json::cbor_tag_handler_t::store` is passed to `json::from_cbor`. + + ```json + { + "binary": { + "bytes": [202, 254, 186, 190], + "subtype": null + } + } + ``` + +### MessagePack + +[MessagePack](binary_formats/messagepack.md) supports binary values and subtypes. If a subtype is given, the ext family +is used. The library will choose the smallest representation among fixext1, fixext2, fixext4, fixext8, ext8, ext16, and +ext32. The subtype is then added as signed 8-bit integer. + +If no subtype is given, the bin family (bin8, bin16, bin32) is used. + +??? example + + Code: + + ```cpp + // create a binary value of subtype 42 + json j; + j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42); + + // convert to MessagePack + auto v = json::to_msgpack(j); + ``` + + `v` is a `std::vector` with the following 14 elements: + + ```c + 0x81 // fixmap1 + 0xA6 // fixstr6 + 0x62 0x69 0x6E 0x61 0x72 0x79 // "binary" + 0xD6 // fixext4 + 0x2A // subtype + 0xCA 0xFE 0xBA 0xBE // content + ``` + + Note that the serialization preserves the subtype, and deserializing `v` would yield the following value: + + ```json + { + "binary": { + "bytes": [202, 254, 186, 190], + "subtype": 42 + } + } + ``` + +### UBJSON + +[UBJSON](binary_formats/ubjson.md) neither supports binary values nor subtypes, and proposes to serialize binary values +as array of uint8 values. This translation is implemented by the library. + +??? example + + Code: + + ```cpp + // create a binary value of subtype 42 (will be ignored in UBJSON) + json j; + j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42); + + // convert to UBJSON + auto v = json::to_ubjson(j); + ``` + + `v` is a `std::vector` with the following 20 elements: + + ```c + 0x7B // '{' + 0x69 0x06 // i 6 (length of the key) + 0x62 0x69 0x6E 0x61 0x72 0x79 // "binary" + 0x5B // '[' + 0x55 0xCA 0x55 0xFE 0x55 0xBA 0x55 0xBE // content (each byte prefixed with 'U') + 0x5D // ']' + 0x7D // '}' + ``` + + The following code uses the type and size optimization for UBJSON: + + ```cpp + // convert to UBJSON using the size and type optimization + auto v = json::to_ubjson(j, true, true); + ``` + + The resulting vector has 23 elements; the optimization is not effective for examples with few values: + + ```c + 0x7B // '{' + 0x24 // '$' type of the object elements + 0x5B // '[' array + 0x23 0x69 0x01 // '#' i 1 number of object elements + 0x69 0x06 // i 6 (length of the key) + 0x62 0x69 0x6E 0x61 0x72 0x79 // "binary" + 0x24 0x55 // '$' 'U' type of the array elements: unsigned integers + 0x23 0x69 0x04 // '#' i 4 number of array elements + 0xCA 0xFE 0xBA 0xBE // content + ``` + + Note that subtype (42) is **not** serialized and that UBJSON has **no binary type**, and deserializing `v` would + yield the following value: + + ```json + { + "binary": [202, 254, 186, 190] + } + ``` diff --git a/external_imported/json/doc/mkdocs/docs/features/comments.md b/external_imported/json/docs/mkdocs/docs/features/comments.md similarity index 78% rename from external_imported/json/doc/mkdocs/docs/features/comments.md rename to external_imported/json/docs/mkdocs/docs/features/comments.md index f82029eee..61266d9ca 100644 --- a/external_imported/json/doc/mkdocs/docs/features/comments.md +++ b/external_imported/json/docs/mkdocs/docs/features/comments.md @@ -5,9 +5,9 @@ This library does not support comments *by default*. It does so for three reason 1. Comments are not part of the [JSON specification](https://tools.ietf.org/html/rfc8259). You may argue that `//` or `/* */` are allowed in JavaScript, but JSON is not JavaScript. 2. This was not an oversight: Douglas Crockford [wrote on this](https://plus.google.com/118095276221607585885/posts/RK8qyGVaGSr) in May 2012: - > I removed comments from JSON because I saw people were using them to hold parsing directives, a practice which would have destroyed interoperability. I know that the lack of comments makes some people sad, but it shouldn't. + > I removed comments from JSON because I saw people were using them to hold parsing directives, a practice which would have destroyed interoperability. I know that the lack of comments makes some people sad, but it shouldn't. - > Suppose you are using JSON to keep configuration files, which you would like to annotate. Go ahead and insert all the comments you like. Then pipe it through JSMin before handing it to your JSON parser. + > Suppose you are using JSON to keep configuration files, which you would like to annotate. Go ahead and insert all the comments you like. Then pipe it through JSMin before handing it to your JSON parser. 3. It is dangerous for interoperability if some libraries would add comment support while others don't. Please check [The Harmful Consequences of the Robustness Principle](https://tools.ietf.org/html/draft-iab-protocol-maintenance-01) on this. @@ -25,7 +25,7 @@ However, you can pass set parameter `ignore_comments` to `#!c true` in the parse } ``` - When calling `parse` without additional argument, a parse error exception is thrown. If `skip_comments` is set to `#! true`, the comments are skipped during parsing: + When calling `parse` without additional argument, a parse error exception is thrown. If `ignore_comments` is set to `#! true`, the comments are ignored during parsing: ```cpp #include @@ -55,7 +55,7 @@ However, you can pass set parameter `ignore_comments` to `#!c true` in the parse json j = json::parse(s, /* callback */ nullptr, /* allow exceptions */ true, - /* skip_comments */ true); + /* ignore_comments */ true); std::cout << j.dump(2) << '\n'; } ``` @@ -80,4 +80,4 @@ However, you can pass set parameter `ignore_comments` to `#!c true` in the parse "Neptune" ] } - ``` \ No newline at end of file + ``` diff --git a/external_imported/json/docs/mkdocs/docs/features/element_access/checked_access.md b/external_imported/json/docs/mkdocs/docs/features/element_access/checked_access.md new file mode 100644 index 000000000..c4023cce5 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/element_access/checked_access.md @@ -0,0 +1,91 @@ +# Checked access: at + +## Overview + +The [`at`](../../api/basic_json/at.md) member function performs checked access; that is, it returns a reference to the +desired value if it exists and throws a [`basic_json::out_of_range` exception](../../home/exceptions.md#out-of-range) +otherwise. + +??? example "Read access" + + Consider the following JSON value: + + ```json + { + "name": "Mary Smith", + "age": 42, + "hobbies": ["hiking", "reading"] + } + ``` + + Assume the value is parsed to a `json` variable `j`. + + | expression | value | + |-------------------------------|------------------------------------------------------------------------------| + | `#!cpp j` | `#!json {"name": "Mary Smith", "age": 42, "hobbies": ["hiking", "reading"]}` | + | `#!cpp j.at("name")` | `#!json "Mary Smith"` | + | `#!cpp j.at("age")` | `#!json 42` | + | `#!cpp j.at("hobbies")` | `#!json ["hiking", "reading"]` | + | `#!cpp j.at("hobbies").at(0)` | `#!json "hiking"` | + | `#!cpp j.at("hobbies").at(1)` | `#!json "reading"` | + +The return value is a reference, so it can be modified by the original value. + +??? example "Write access" + + ```cpp + j.at("name") = "John Smith"; + ``` + + This code produces the following JSON value: + + ```json + { + "name": "John Smith", + "age": 42, + "hobbies": ["hiking", "reading"] + } + ``` + +When accessing an invalid index (i.e., an index greater than or equal to the array size) or the passed object key is +non-existing, an exception is thrown. + +??? example "Accessing via invalid index or missing key" + + ```cpp + j.at("hobbies").at(3) = "cooking"; + ``` + + This code produces the following exception: + + ``` + [json.exception.out_of_range.401] array index 3 is out of range + ``` + + When you [extended diagnostic messages](../../home/exceptions.md#extended-diagnostic-messages) are enabled by + defining [`JSON_DIAGNOSTICS`](../../api/macros/json_diagnostics.md), the exception further gives information where + the key or index is missing or out of range. + + ``` + [json.exception.out_of_range.401] (/hobbies) array index 3 is out of range + ``` + +## Notes + + +!!! failure "Exceptions" + + - [`at`](../../api/basic_json/at.md) can only be used with objects (with a string argument) or with arrays (with a + numeric argument). For other types, a [`basic_json::type_error`](../../home/exceptions.md#jsonexceptiontype_error304) + is thrown. + - [`basic_json::out_of_range` exception](../../home/exceptions.md#out-of-range) exceptions are thrown if the + provided key is not found in an object or the provided index is invalid. + +## Summary + +| scenario | non-const value | const value | +|-----------------------------------|------------------------------------------------|------------------------------------------------| +| access to existing object key | reference to existing value is returned | const reference to existing value is returned | +| access to valid array index | reference to existing value is returned | const reference to existing value is returned | +| access to non-existing object key | `basic_json::out_of_range` exception is thrown | `basic_json::out_of_range` exception is thrown | +| access to invalid array index | `basic_json::out_of_range` exception is thrown | `basic_json::out_of_range` exception is thrown | diff --git a/external_imported/json/doc/mkdocs/docs/features/element_access/default_value.md b/external_imported/json/docs/mkdocs/docs/features/element_access/default_value.md similarity index 100% rename from external_imported/json/doc/mkdocs/docs/features/element_access/default_value.md rename to external_imported/json/docs/mkdocs/docs/features/element_access/default_value.md diff --git a/external_imported/json/docs/mkdocs/docs/features/element_access/index.md b/external_imported/json/docs/mkdocs/docs/features/element_access/index.md new file mode 100644 index 000000000..0b39547ec --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/element_access/index.md @@ -0,0 +1,9 @@ +# Element Access + +There are many ways elements in a JSON value can be accessed: + +- unchecked access via [`operator[]`](unchecked_access.md) +- checked access via [`at`](checked_access.md) +- access with default value via [`value`](default_value.md) +- iterators +- JSON pointers diff --git a/external_imported/json/docs/mkdocs/docs/features/element_access/unchecked_access.md b/external_imported/json/docs/mkdocs/docs/features/element_access/unchecked_access.md new file mode 100644 index 000000000..39f06dc9f --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/element_access/unchecked_access.md @@ -0,0 +1,112 @@ +# Unchecked access: operator[] + +## Overview + +Elements in a JSON object and a JSON array can be accessed via [`operator[]`](../../api/basic_json/operator%5B%5D.md) +similar to a `#!cpp std::map` and a `#!cpp std::vector`, respectively. + +??? example "Read access" + + Consider the following JSON value: + + ```json + { + "name": "Mary Smith", + "age": 42, + "hobbies": ["hiking", "reading"] + } + ``` + + Assume the value is parsed to a `json` variable `j`. + + | expression | value | + |-------------------------|------------------------------------------------------------------------------| + | `#!cpp j` | `#!json {"name": "Mary Smith", "age": 42, "hobbies": ["hiking", "reading"]}` | + | `#!cpp j["name"]` | `#!json "Mary Smith"` | + | `#!cpp j["age"]` | `#!json 42` | + | `#!cpp j["hobbies"]` | `#!json ["hiking", "reading"]` | + | `#!cpp j["hobbies"][0]` | `#!json "hiking"` | + | `#!cpp j["hobbies"][1]` | `#!json "reading"` | + +The return value is a reference, so it can modify the original value. In case the passed object key is non-existing, a +`#!json null` value is inserted which can be immediately be overwritten. + +??? example "Write access" + + ```cpp + j["name"] = "John Smith"; + j["maidenName"] = "Jones"; + ``` + + This code produces the following JSON value: + + ```json + { + "name": "John Smith", + "maidenName": "Jones", + "age": 42, + "hobbies": ["hiking", "reading"] + } + ``` + +When accessing an invalid index (i.e., an index greater than or equal to the array size), the JSON array is resized such +that the passed index is the new maximal index. Intermediate values are filled with `#!json null`. + +??? example "Filling up arrays with `#!json null` values" + + ```cpp + j["hobbies"][0] = "running"; + j["hobbies"][3] = "cooking"; + ``` + + This code produces the following JSON value: + + ```json + { + "name": "John Smith", + "maidenName": "Jones", + "age": 42, + "hobbies": ["running", "reading", null, "cooking"] + } + ``` + +## Notes + +!!! info "Design rationale" + + The library behaves differently to `#!cpp std::vector` and `#!cpp std::map`: + + - `#!cpp std::vector::operator[]` never inserts a new element. + - `#!cpp std::map::operator[]` is not available for const values. + + The type `#!cpp json` wraps all JSON value types. It would be impossible to remove + [`operator[]`](../../api/basic_json/operator%5B%5D.md) for const objects. At the same time, inserting elements for + non-const objects is really convenient as it avoids awkward `insert` calls. To this end, we decided to have an + inserting non-const behavior for both arrays and objects. + +!!! info + + The access is unchecked. In case the passed object key does not exist or the passed array index is invalid, no + exception is thrown. + +!!! danger + + - It is **undefined behavior** to access a const object with a non-existing key. + - It is **undefined behavior** to access a const array with an invalid index. + - In debug mode, an **assertion** will fire in both cases. You can disable assertions by defining the preprocessor + symbol `#!cpp NDEBUG` or redefine the macro [`JSON_ASSERT(x)`](../macros.md#json_assertx). See the documentation + on [runtime assertions](../assertions.md) for more information. + +!!! failure "Exceptions" + + `operator[]` can only be used with objects (with a string argument) or with arrays (with a numeric argument). For + other types, a [`basic_json::type_error`](../../home/exceptions.md#jsonexceptiontype_error305) is thrown. + +## Summary + +| scenario | non-const value | const value | +|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------| +| access to existing object key | reference to existing value is returned | const reference to existing value is returned | +| access to valid array index | reference to existing value is returned | const reference to existing value is returned | +| access to non-existing object key | reference to newly inserted `#!json null` value is returned | **undefined behavior**; [runtime assertion](../assertions.md) in debug mode | +| access to invalid array index | reference to newly inserted `#!json null` value is returned; any index between previous maximal index and passed index are filled with `#!json null` | **undefined behavior**; [runtime assertion](../assertions.md) in debug mode | diff --git a/external_imported/json/docs/mkdocs/docs/features/enum_conversion.md b/external_imported/json/docs/mkdocs/docs/features/enum_conversion.md new file mode 100644 index 000000000..1755bca2a --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/enum_conversion.md @@ -0,0 +1,61 @@ +# Specializing enum conversion + +By default, enum values are serialized to JSON as integers. In some cases this could result in undesired behavior. If an +enum is modified or re-ordered after data has been serialized to JSON, the later de-serialized JSON data may be +undefined or a different enum value than was originally intended. + +It is possible to more precisely specify how a given enum is mapped to and from JSON as shown below: + +```cpp +// example enum type declaration +enum TaskState { + TS_STOPPED, + TS_RUNNING, + TS_COMPLETED, + TS_INVALID=-1, +}; + +// map TaskState values to JSON as strings +NLOHMANN_JSON_SERIALIZE_ENUM( TaskState, { + {TS_INVALID, nullptr}, + {TS_STOPPED, "stopped"}, + {TS_RUNNING, "running"}, + {TS_COMPLETED, "completed"}, +}) +``` + +The [`NLOHMANN_JSON_SERIALIZE_ENUM()` macro](../api/macros/nlohmann_json_serialize_enum.md) declares a set of +`to_json()` / `from_json()` functions for type `TaskState` while avoiding repetition and boilerplate serialization code. + +## Usage + +```cpp +// enum to JSON as string +json j = TS_STOPPED; +assert(j == "stopped"); + +// json string to enum +json j3 = "running"; +assert(j3.template get() == TS_RUNNING); + +// undefined json value to enum (where the first map entry above is the default) +json jPi = 3.14; +assert(jPi.template get() == TS_INVALID ); +``` + +## Notes + +Just as in [Arbitrary Type Conversions](arbitrary_types.md) above, + +- [`NLOHMANN_JSON_SERIALIZE_ENUM()`](../api/macros/nlohmann_json_serialize_enum.md) MUST be declared in your enum type's + namespace (which can be the global namespace), or the library will not be able to locate it, and it will default to + integer serialization. +- It MUST be available (e.g., proper headers must be included) everywhere you use the conversions. + +Other Important points: + +- When using `template get()`, undefined JSON values will default to the first pair specified in your map. Select this + default pair carefully. +- If an enum or JSON value is specified more than once in your map, the first matching occurrence from the top of the + map will be returned when converting to or from JSON. +- To disable the default serialization of enumerators as integers and force a compiler error instead, see [`JSON_DISABLE_ENUM_SERIALIZATION`](../api/macros/json_disable_enum_serialization.md). diff --git a/external_imported/json/doc/mkdocs/docs/features/iterators.md b/external_imported/json/docs/mkdocs/docs/features/iterators.md similarity index 88% rename from external_imported/json/doc/mkdocs/docs/features/iterators.md rename to external_imported/json/docs/mkdocs/docs/features/iterators.md index a8b88e2d8..ce627e012 100644 --- a/external_imported/json/doc/mkdocs/docs/features/iterators.md +++ b/external_imported/json/docs/mkdocs/docs/features/iterators.md @@ -10,7 +10,7 @@ As for other containers, `begin()` returns an iterator to the first value and `e ### Iteration order for objects -When iterating over objects, values are ordered with respect to the `object_comparator_t` type which defaults to `std::less`. See the [types documentation](types.md#key-order) for more information. +When iterating over objects, values are ordered with respect to the `object_comparator_t` type which defaults to `std::less`. See the [types documentation](types/index.md#key-order) for more information. ??? example @@ -66,7 +66,7 @@ The JSON iterators have two member functions, `key()` and `value()` to access th ### Range-based for loops -C++11 allows to use range-based for loops to iterate over a container. +C++11 allows using range-based for loops to iterate over a container. ```cpp for (auto it : j_object) @@ -76,7 +76,7 @@ for (auto it : j_object) } ``` -For this reason, the `items()` function allows to access `iterator::key()` and `iterator::value()` during range-based for loops. In these loops, a reference to the JSON values is returned, so there is no access to the underlying iterator. +For this reason, the `items()` function allows accessing `iterator::key()` and `iterator::value()` during range-based for loops. In these loops, a reference to the JSON values is returned, so there is no access to the underlying iterator. ```cpp for (auto& el : j_object.items()) @@ -85,7 +85,7 @@ for (auto& el : j_object.items()) } ``` -The items() function also allows to use structured bindings (C++17): +The items() function also allows using structured bindings (C++17): ```cpp for (auto& [key, val] : j_object.items()) @@ -100,7 +100,7 @@ for (auto& [key, val] : j_object.items()) !!! warning - Using `items()` on temporary objects is dangerous. Make sure the object's lifetime exeeds the iteration. See for more information. + Using `items()` on temporary objects is dangerous. Make sure the object's lifetime exceeds the iteration. See for more information. ### Reverse iteration order @@ -113,7 +113,7 @@ for (auto& [key, val] : j_object.items()) ```cpp json j = {1, 2, 3, 4}; - for (auto it = j.begin(); it != j.end(); ++it) + for (auto it = j.rbegin(); it != j.rend(); ++it) { std::cout << *it << std::endl; } @@ -151,5 +151,5 @@ Note that "value" means a JSON value in this setting, not values stored in the u ## Iterator invalidation | Operations | invalidated iterators | -| ---------- | --------------------- | +|------------|-----------------------| | `clear` | all | diff --git a/external_imported/json/doc/mkdocs/docs/features/json_patch.md b/external_imported/json/docs/mkdocs/docs/features/json_patch.md similarity index 78% rename from external_imported/json/doc/mkdocs/docs/features/json_patch.md rename to external_imported/json/docs/mkdocs/docs/features/json_patch.md index 24cebdd98..88c731a2c 100644 --- a/external_imported/json/doc/mkdocs/docs/features/json_patch.md +++ b/external_imported/json/docs/mkdocs/docs/features/json_patch.md @@ -2,7 +2,9 @@ ## Patches -JSON Patch ([RFC 6902](https://tools.ietf.org/html/rfc6902)) defines a JSON document structure for expressing a sequence of operations to apply to a JSON) document. With the `patch` function, a JSON Patch is applied to the current JSON value by executing all operations from the patch. +JSON Patch ([RFC 6902](https://tools.ietf.org/html/rfc6902)) defines a JSON document structure for expressing a sequence +of operations to apply to a JSON document. With the `patch` function, a JSON Patch is applied to the current JSON value +by executing all operations from the patch. ??? example diff --git a/external_imported/json/docs/mkdocs/docs/features/json_pointer.md b/external_imported/json/docs/mkdocs/docs/features/json_pointer.md new file mode 100644 index 000000000..04aeca504 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/json_pointer.md @@ -0,0 +1,126 @@ +# JSON Pointer + +## Introduction + +The library supports **JSON Pointer** ([RFC 6901](https://tools.ietf.org/html/rfc6901)) as alternative means to address +structured values. A JSON Pointer is a string that identifies a specific value within a JSON document. + +Consider the following JSON document + +```json +{ + "array": ["A", "B", "C"], + "nested": { + "one": 1, + "two": 2, + "three": [true, false] + } +} +``` + +Then every value inside the JSON document can be identified as follows: + +| JSON Pointer | JSON value | +|-------------------|----------------------------------------------------------------------------------| +| `` | `#!json {"array":["A","B","C"],"nested":{"one":1,"two":2,"three":[true,false]}}` | +| `/array` | `#!json ["A","B","C"]` | +| `/array/0` | `#!json A` | +| `/array/1` | `#!json B` | +| `/array/2` | `#!json C` | +| `/nested` | `#!json {"one":1,"two":2,"three":[true,false]}` | +| `/nested/one` | `#!json 1` | +| `/nested/two` | `#!json 2` | +| `/nested/three` | `#!json [true,false]` | +| `/nested/three/0` | `#!json true` | +| `/nested/three/1` | `#!json false` | + +Note `/` does not identify the root (i.e., the whole document), but an object entry with empty key `""`. See +[RFC 6901](https://tools.ietf.org/html/rfc6901) for more information. + +## JSON Pointer creation + +JSON Pointers can be created from a string: + +```cpp +json::json_pointer p = "/nested/one"; +``` + +Furthermore, a user-defined string literal can be used to achieve the same result: + +```cpp +auto p = "/nested/one"_json_pointer; +``` + +The escaping rules of [RFC 6901](https://tools.ietf.org/html/rfc6901) are implemented. See the +[constructor documentation](../api/json_pointer/json_pointer.md) for more information. + +## Value access + +JSON Pointers can be used in the [`at`](../api/basic_json/at.md), [`operator[]`](../api/basic_json/operator%5B%5D.md), +and [`value`](../api/basic_json/value.md) functions just like object keys or array indices. + +```cpp +// the JSON value from above +auto j = json::parse(R"({ + "array": ["A", "B", "C"], + "nested": { + "one": 1, + "two": 2, + "three": [true, false] + } +})"); + +// access values +auto val = j["/"_json_pointer]; // {"array":["A","B","C"],...} +auto val1 = j["/nested/one"_json_pointer]; // 1 +auto val2 = j.at[json::json_pointer("/nested/three/1")]; // false +auto val3 = j.value[json::json_pointer("/nested/four", 0)]; // 0 +``` + +## Flatten / unflatten + +The library implements a function [`flatten`](../api/basic_json/flatten.md) to convert any JSON document into a JSON +object where each key is a JSON Pointer and each value is a primitive JSON value (i.e., a string, boolean, number, or +null). + +```cpp +// the JSON value from above +auto j = json::parse(R"({ + "array": ["A", "B", "C"], + "nested": { + "one": 1, + "two": 2, + "three": [true, false] + } +})"); + +// create flattened value +auto j_flat = j.flatten(); +``` + +The resulting value `j_flat` is: + +```json +{ + "/array/0": "A", + "/array/1": "B", + "/array/2": "C", + "/nested/one": 1, + "/nested/two": 2, + "/nested/three/0": true, + "/nested/three/1": false +} +``` + +The reverse function, [`unflatten`](../api/basic_json/unflatten.md) recreates the original value. + +```cpp +auto j_original = j_flat.unflatten(); +``` + +## See also + +- Class [`json_pointer`](../api/json_pointer/index.md) +- Function [`flatten`](../api/basic_json/flatten.md) +- Function [`unflatten`](../api/basic_json/unflatten.md) +- [JSON Patch](json_patch.md) diff --git a/external_imported/json/docs/mkdocs/docs/features/macros.md b/external_imported/json/docs/mkdocs/docs/features/macros.md new file mode 100644 index 000000000..926741b09 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/macros.md @@ -0,0 +1,167 @@ +# Supported Macros + +Some aspects of the library can be configured by defining preprocessor macros before including the `json.hpp` header. +See also the [API documentation for macros](../api/macros/index.md) for examples and more information. + +## `JSON_ASSERT(x)` + +This macro controls which code is executed for [runtime assertions](assertions.md) of the library. + +See [full documentation of `JSON_ASSERT(x)`](../api/macros/json_assert.md). + +## `JSON_CATCH_USER(exception)` + +This macro overrides [`#!cpp catch`](https://en.cppreference.com/w/cpp/language/try_catch) calls inside the library. + +See [full documentation of `JSON_CATCH_USER(exception)`](../api/macros/json_throw_user.md). + +## `JSON_DIAGNOSTICS` + +This macro enables extended diagnostics for exception messages. Possible values are `1` to enable or `0` to disable +(default). + +When enabled, exception messages contain a [JSON Pointer](json_pointer.md) to the JSON value that triggered the +exception, see [Extended diagnostic messages](../home/exceptions.md#extended-diagnostic-messages) for an example. Note +that enabling this macro increases the size of every JSON value by one pointer and adds some runtime overhead. + +The diagnostics messages can also be controlled with the CMake option `JSON_Diagnostics` (`OFF` by default) which sets +`JSON_DIAGNOSTICS` accordingly. + +See [full documentation of `JSON_DIAGNOSTICS`](../api/macros/json_diagnostics.md). + +## `JSON_HAS_CPP_11`, `JSON_HAS_CPP_14`, `JSON_HAS_CPP_17`, `JSON_HAS_CPP_20` + +The library targets C++11, but also supports some features introduced in later C++ versions (e.g., `std::string_view` +support for C++17). For these new features, the library implements some preprocessor checks to determine the C++ +standard. By defining any of these symbols, the internal check is overridden and the provided C++ version is +unconditionally assumed. This can be helpful for compilers that only implement parts of the standard and would be +detected incorrectly. + +See [full documentation of `JSON_HAS_CPP_11`, `JSON_HAS_CPP_14`, `JSON_HAS_CPP_17`, and `JSON_HAS_CPP_20`](../api/macros/json_has_cpp_11.md). + +## `JSON_HAS_FILESYSTEM`, `JSON_HAS_EXPERIMENTAL_FILESYSTEM` + +When compiling with C++17, the library provides conversions from and to `std::filesystem::path`. As compiler support +for filesystem is limited, the library tries to detect whether ``/`std::filesystem` (`JSON_HAS_FILESYSTEM`) +or ``/`std::experimental::filesystem` (`JSON_HAS_EXPERIMENTAL_FILESYSTEM`) should be used. +To override the built-in check, define `JSON_HAS_FILESYSTEM` or `JSON_HAS_EXPERIMENTAL_FILESYSTEM` to `1`. + +See [full documentation of `JSON_HAS_FILESYSTEM` and `JSON_HAS_EXPERIMENTAL_FILESYSTEM`](../api/macros/json_has_filesystem.md). + +## `JSON_NOEXCEPTION` + +Exceptions can be switched off by defining the symbol `JSON_NOEXCEPTION`. + +See [full documentation of `JSON_NOEXCEPTION`](../api/macros/json_noexception.md). + +## `JSON_DISABLE_ENUM_SERIALIZATION` + +When defined, default parse and serialize functions for enums are excluded and have to be provided by the user, for example, using [`NLOHMANN_JSON_SERIALIZE_ENUM`](../api/macros/nlohmann_json_serialize_enum.md). + +See [full documentation of `JSON_DISABLE_ENUM_SERIALIZATION`](../api/macros/json_disable_enum_serialization.md). + +## `JSON_NO_IO` + +When defined, headers ``, ``, ``, ``, and `` are not included and parse functions +relying on these headers are excluded. This is relevant for environment where these I/O functions are disallowed for +security reasons (e.g., Intel Software Guard Extensions (SGX)). + +See [full documentation of `JSON_NO_IO`](../api/macros/json_no_io.md). + +## `JSON_SKIP_LIBRARY_VERSION_CHECK` + +When defined, the library will not create a compiler warning when a different version of the library was already +included. + +See [full documentation of `JSON_SKIP_LIBRARY_VERSION_CHECK`](../api/macros/json_skip_library_version_check.md). + +## `JSON_SKIP_UNSUPPORTED_COMPILER_CHECK` + +When defined, the library will not create a compile error when a known unsupported compiler is detected. This allows to +use the library with compilers that do not fully support C++11 and may only work if unsupported features are not used. + +See [full documentation of `JSON_SKIP_UNSUPPORTED_COMPILER_CHECK`](../api/macros/json_skip_unsupported_compiler_check.md). + +## `JSON_THROW_USER(exception)` + +This macro overrides `#!cpp throw` calls inside the library. The argument is the exception to be thrown. + +See [full documentation of `JSON_THROW_USER(exception)`](../api/macros/json_throw_user.md). + +## `JSON_TRY_USER` + +This macro overrides `#!cpp try` calls inside the library. + +See [full documentation of `JSON_TRY_USER`](../api/macros/json_throw_user.md). + +## `JSON_USE_IMPLICIT_CONVERSIONS` + +When defined to `0`, implicit conversions are switched off. By default, implicit conversions are switched on. + +See [full documentation of `JSON_USE_IMPLICIT_CONVERSIONS`](../api/macros/json_use_implicit_conversions.md). + +## `NLOHMANN_DEFINE_TYPE_INTRUSIVE(type, member...)` + +This macro can be used to simplify the serialization/deserialization of types if (1) want to use a JSON object as +serialization and (2) want to use the member variable names as object keys in that object. + +The macro is to be defined inside the class/struct to create code for. Unlike +[`NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`](#nlohmann_define_type_non_intrusivetype-member), it can access private members. +The first parameter is the name of the class/struct, and all remaining parameters name the members. + +See [full documentation of `NLOHMANN_DEFINE_TYPE_INTRUSIVE`](../api/macros/nlohmann_define_type_intrusive.md). + +## `NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(type, member...)` + +This macro is similar to `NLOHMANN_DEFINE_TYPE_INTRUSIVE`. It will not throw an exception in `from_json()` due to a +missing value in the JSON object, but can throw due to a mismatched type. The `from_json()` function default constructs +an object and uses its values as the defaults when calling the [`value`](../api/basic_json/value.md) function. + +See [full documentation of `NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT`](../api/macros/nlohmann_define_type_intrusive.md). + +## `NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(type, member...)` + +This macro is similar to `NLOHMANN_DEFINE_TYPE_INTRUSIVE` except that it defines only the serialization code. This is +useful when the user type does not have a default constructor and only the serialization is required. + +See [full documentation of `NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE`](../api/macros//nlohmann_define_type_intrusive.md). + +## `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(type, member...)` + +This macro can be used to simplify the serialization/deserialization of types if (1) want to use a JSON object as +serialization and (2) want to use the member variable names as object keys in that object. + +The macro is to be defined inside the namespace of the class/struct to create code for. Private members cannot be +accessed. Use [`NLOHMANN_DEFINE_TYPE_INTRUSIVE`](#nlohmann_define_type_intrusivetype-member) in these scenarios. The +first parameter is the name of the class/struct, and all remaining parameters name the members. + +See [full documentation of `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`](../api/macros/nlohmann_define_type_non_intrusive.md). + +## `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(type, member...)` + +This macro is similar to `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`. It will not throw an exception in `from_json()` due to a +missing value in the JSON object, but can throw due to a mismatched type. The `from_json()` function default constructs +an object and uses its values as the defaults when calling the [`value`](../api/basic_json/value.md) function. + +See [full documentation of `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT`](../api/macros/nlohmann_define_type_non_intrusive.md). + +## `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(type, member...)` + +This macro is similar to `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE` except that it defines only the serialization code. This is +useful when the user type does not have a default constructor and only the serialization is required. + +See [full documentation of `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE`](../api/macros//nlohmann_define_type_non_intrusive.md). + +## `NLOHMANN_JSON_SERIALIZE_ENUM(type, ...)` + +This macro simplifies the serialization/deserialization of enum types. See +[Specializing enum conversion](enum_conversion.md) for more information. + +See [full documentation of `NLOHMANN_JSON_SERIALIZE_ENUM`](../api/macros/nlohmann_json_serialize_enum.md). + +## `NLOHMANN_JSON_VERSION_MAJOR`, `NLOHMANN_JSON_VERSION_MINOR`, `NLOHMANN_JSON_VERSION_PATCH` + +These macros are defined by the library and contain the version numbers according to +[Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html). + +See [full documentation of `NLOHMANN_JSON_VERSION_MAJOR`, `NLOHMANN_JSON_VERSION_MINOR`, and `NLOHMANN_JSON_VERSION_PATCH`](../api/macros/nlohmann_json_version_major.md). diff --git a/external_imported/json/doc/mkdocs/docs/features/merge_patch.md b/external_imported/json/docs/mkdocs/docs/features/merge_patch.md similarity index 100% rename from external_imported/json/doc/mkdocs/docs/features/merge_patch.md rename to external_imported/json/docs/mkdocs/docs/features/merge_patch.md diff --git a/external_imported/json/docs/mkdocs/docs/features/namespace.md b/external_imported/json/docs/mkdocs/docs/features/namespace.md new file mode 100644 index 000000000..8cee2ccfe --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/namespace.md @@ -0,0 +1,93 @@ +# `nlohmann` Namespace + +The 3.11.0 release introduced an +[inline namespace](https://en.cppreference.com/w/cpp/language/namespace#Inline_namespaces) to allow different parts of +a codebase to safely use different versions of the JSON library as long as they never exchange instances of library +types. + +## Structure + +The complete default namespace name is derived as follows: + +- The root namespace is always `nlohmann`. +- The inline namespace starts with `json_abi` and is followed by serveral optional ABI tags according to the value of + these ABI-affecting macros, in order: + - [`JSON_DIAGNOSTICS`](../api/macros/json_diagnostics.md) defined non-zero appends `_diag`. + - [`JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON`](../api/macros/json_use_legacy_discarded_value_comparison.md) + defined non-zero appends `_ldvcmp`. +- The inline namespace ends with the suffix `_v` followed by the 3 components of the version number separated by + underscores. To omit the version component, see [Disabling the version component](#disabling-the-version-component) + below. + +For example, the namespace name for version 3.11.2 with `JSON_DIAGNOSTICS` defined to `1` is: + +```cpp +nlohmann::json_abi_diag_v3_11_2 +``` + +## Purpose + +Several incompatibilities have been observed. Amongst the most common ones is linking code compiled with different +definitions of [`JSON_DIAGNOSTICS`](../api/macros/json_diagnostics.md). This is illustrated in the diagram below. + +```plantuml +[**nlohmann_json (v3.10.5)**\nJSON_DIAGNOSTICS=0] as [json] +[**nlohmann_json (v3.10.5)**\nJSON_DIAGNOSTICS=1] as [json_diag] +[**some_library**] as [library] +[**application**] as [app] + +[library] ..|> [json] +[app] ..|> [json_diag] +[app] ..|>[library] +``` + +In releases prior to 3.11.0, mixing any version of the JSON library with different `JSON_DIAGNOSTICS` settings would +result in a crashing application. If `some_library` never passes instances of JSON library types to the application, +this scenario became safe in version 3.11.0 and above due to the inline namespace yielding distinct symbol names. + +## Limitations + +Neither the compiler nor the linker will issue as much as a warning when translation units – intended to be linked +together and that include different versions and/or configurations of the JSON library – exchange and use library +types. + +There is an exception when forward declarations are used (i.e., when including `json_fwd.hpp`) in which case the linker +may complain about undefined references. + +## Disabling the version component + +Different versions are not necessarily ABI-incompatible, but the project does not actively track changes in the ABI and +recommends that all parts of a codebase exchanging library types be built with the same version. Users can, **at their +own risk**, disable the version component of the linline namespace, allowing different versions – but not +configurations – to be used in cases where the linker would otherwise output undefined reference errors. + +To do so, define [`NLOHMANN_JSON_NAMESPACE_NO_VERSION`](../api/macros/nlohmann_json_namespace_no_version.md) to `1`. + +This applies to version 3.11.2 and above only, versions 3.11.0 and 3.11.1 can apply the technique described in the next +section to emulate the effect of the `NLOHMANN_JSON_NAMESPACE_NO_VERSION` macro. + +!!! danger "Use at your own risk" + + Disabling the namespace version component and mixing ABI-incompatible versions will result in crashes or incorrect + behavior. You have been warned! +## Disabling the inline namespace completely + +When interoperability with code using a pre-3.11.0 version of the library is required, users can, **at their own risk** +restore the old namespace layout by redefining +[`NLOHMANN_JSON_NAMESPACE_BEGIN, NLOHMANN_JSON_NAMESPACE_END`](../api/macros/nlohmann_json_namespace_begin.md) as +follows: + +```cpp +#define NLOHMANN_JSON_NAMESPACE_BEGIN namespace nlohmann { +#define NLOHMANN_JSON_NAMESPACE_END } +``` + +!!! danger "Use at your own risk" + + Overriding the namespace and mixing ABI-incompatible versions will result in crashes or incorrect behavior. You + have been warned! + +## Version history + +- Introduced inline namespace (`json_v3_11_0[_abi-tag]*`) in version 3.11.0. +- Changed structure of inline namespace in version 3.11.2. diff --git a/external_imported/json/docs/mkdocs/docs/features/object_order.md b/external_imported/json/docs/mkdocs/docs/features/object_order.md new file mode 100644 index 000000000..3ee16a90e --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/object_order.md @@ -0,0 +1,109 @@ +# Object Order + +The [JSON standard](https://tools.ietf.org/html/rfc8259.html) defines objects as "an unordered collection of zero or more name/value pairs". As such, an implementation does not need to preserve any specific order of object keys. + +## Default behavior: sort keys + +The default type `nlohmann::json` uses a `std::map` to store JSON objects, and thus stores object keys **sorted alphabetically**. + +??? example + + ```cpp + #include + #include "json.hpp" + + using json = nlohmann::json; + + int main() + { + json j; + j["one"] = 1; + j["two"] = 2; + j["three"] = 3; + + std::cout << j.dump(2) << '\n'; + } + ``` + + Output: + + ```json + { + "one": 1, + "three": 3, + "two": 2 + } + ``` + +## Alternative behavior: preserve insertion order + +If you do want to preserve the **insertion order**, you can try the type [`nlohmann::ordered_json`](https://github.com/nlohmann/json/issues/2179). + +??? example + + ```cpp + --8<-- "examples/ordered_json.cpp" + ``` + + Output: + + ```json + --8<-- "examples/ordered_json.output" + ``` + +Alternatively, you can use a more sophisticated ordered map like [`tsl::ordered_map`](https://github.com/Tessil/ordered-map) ([integration](https://github.com/nlohmann/json/issues/546#issuecomment-304447518)) or [`nlohmann::fifo_map`](https://github.com/nlohmann/fifo_map) ([integration](https://github.com/nlohmann/json/issues/485#issuecomment-333652309)). + +### Notes on parsing + +Note that you also need to call the right [`parse`](../api/basic_json/parse.md) function when reading from a file. +Assume file `input.json` contains the JSON object above: + +```json +{ + "one": 1, + "two": 2, + "three": 3 +} +``` + +!!! success "Right way" + + The following code correctly calls the `parse` function from `nlohmann::ordered_json`: + + ```cpp + std::ifstream i("input.json"); + auto j = nlohmann::ordered_json::parse(i); + std::cout << j.dump(2) << std::endl; + ``` + + The output will be: + + ```json + { + "one": 1, + "two": 2, + "three": 3 + } + ``` + +??? failure "Wrong way" + + The following code incorrectly calls the `parse` function from `nlohmann::json` which does not preserve the + insertion order, but sorts object keys. Assigning the result to `nlohmann::ordered_json` compiles, but does not + restore the order from the input file. + + ```cpp + std::ifstream i("input.json"); + nlohmann::ordered_json j = nlohmann::json::parse(i); + std::cout << j.dump(2) << std::endl; + ``` + + The output will be: + + ```json + { + "one": 1, + "three": 3 + "two": 2, + } + ``` diff --git a/external_imported/json/docs/mkdocs/docs/features/parsing/index.md b/external_imported/json/docs/mkdocs/docs/features/parsing/index.md new file mode 100644 index 000000000..29493520e --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/parsing/index.md @@ -0,0 +1,13 @@ +# Parsing + +!!! note + + This page is under construction. + +## Input + +## SAX vs. DOM parsing + +## Exceptions + +See [parsing and exceptions](parse_exceptions.md). diff --git a/external_imported/json/docs/mkdocs/docs/features/parsing/json_lines.md b/external_imported/json/docs/mkdocs/docs/features/parsing/json_lines.md new file mode 100644 index 000000000..659d31792 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/parsing/json_lines.md @@ -0,0 +1,49 @@ +# JSON Lines + +The [JSON Lines](https://jsonlines.org) format is a text format of newline-delimited JSON. In particular: + +1. The input must be UTF-8 encoded. +2. Every line must be a valid JSON value. +3. The line separator must be `\n`. As `\r` is silently ignored, `\r\n` is also supported. +4. The final character may be `\n`, but is not required to be one. + +!!! example "JSON Text example" + + ```json + {"name": "Gilbert", "wins": [["straight", "7♣"], ["one pair", "10♥"]]} + {"name": "Alexa", "wins": [["two pair", "4â™ "], ["two pair", "9â™ "]]} + {"name": "May", "wins": []} + {"name": "Deloise", "wins": [["three of a kind", "5♣"]]} + ``` + +JSON Lines input with more than one value is treated as invalid JSON by the [`parse`](../../api/basic_json/parse.md) or +[`accept`](../../api/basic_json/accept.md) functions. To process it line by line, functions like +[`std::getline`](https://en.cppreference.com/w/cpp/string/basic_string/getline) can be used: + +!!! example "Example: Parse JSON Text input line by line" + + The example below demonstrates how JSON Lines can be processed. + + ```cpp + --8<-- "examples/json_lines.cpp" + ``` + + Output: + + ```json + --8<-- "examples/json_lines.output" + ``` + +!!! warning "Note" + + Using [`operator>>`](../../api/operator_gtgt.md) like + + ```cpp + json j; + while (input >> j) + { + std::cout << j << std::endl; + } + ``` + + with a JSON Lines input does not work, because the parser will try to parse one value after the last one. diff --git a/external_imported/json/doc/mkdocs/docs/features/parsing/parse_exceptions.md b/external_imported/json/docs/mkdocs/docs/features/parsing/parse_exceptions.md similarity index 76% rename from external_imported/json/doc/mkdocs/docs/features/parsing/parse_exceptions.md rename to external_imported/json/docs/mkdocs/docs/features/parsing/parse_exceptions.md index b882e0b5c..61c0ff290 100644 --- a/external_imported/json/doc/mkdocs/docs/features/parsing/parse_exceptions.md +++ b/external_imported/json/docs/mkdocs/docs/features/parsing/parse_exceptions.md @@ -1,6 +1,10 @@ -# Parsing and exceptions +# Parsing and Exceptions -When the input is not valid JSON, an exception of type [`parse_error`](../../home/exceptions.md#parse-errors) is thrown. This exception contains the position in the input where the error occurred, together with a diagnostic message and the last read input token. The exceptions page contains a [list of examples for parse error exceptions](../../home/exceptions.md#parse-errors). In case you process untrusted input, always enclose your code with a `#!cpp try`/`#!cpp catch` block, like +When the input is not valid JSON, an exception of type [`parse_error`](../../home/exceptions.md#parse-errors) is thrown. +This exception contains the position in the input where the error occurred, together with a diagnostic message and the +last read input token. The exceptions page contains a +[list of examples for parse error exceptions](../../home/exceptions.md#parse-errors). In case you process untrusted +input, always enclose your code with a `#!cpp try`/`#!cpp catch` block, like ```cpp json j; @@ -8,7 +12,7 @@ try { j = json::parse(my_input); } -catch (json::exception::parse_error& ex) +catch (json::parse_error& ex) { std::cerr << "parse error at byte " << ex.byte << std::endl; } @@ -19,7 +23,9 @@ In case exceptions are undesired or not supported by the environment, there are ## Switch off exceptions -The `parse()` function accepts as last parameter a `#!cpp bool` variable `allow_exceptions` which controls whether an exception is thrown when a parse error occurs (`#!cpp true`, default) or whether a discarded value should be returned (`#!cpp false`). +The `parse()` function accepts a `#!cpp bool` parameter `allow_exceptions` which controls whether an exception is +thrown when a parse error occurs (`#!cpp true`, default) or whether a discarded value should be returned +(`#!cpp false`). ```cpp json j = json::parse(my_input, nullptr, false); @@ -33,7 +39,8 @@ Note there is no diagnostic information available in this scenario. ## Use accept() function -Alternatively, function `accept()` can be used which does not return a `json` value, but a `#!cpp bool` indicating whether the input is valid JSON. +Alternatively, function `accept()` can be used which does not return a `json` value, but a `#!cpp bool` indicating +whether the input is valid JSON. ```cpp if (!json::accept(my_input)) diff --git a/external_imported/json/docs/mkdocs/docs/features/parsing/parser_callbacks.md b/external_imported/json/docs/mkdocs/docs/features/parsing/parser_callbacks.md new file mode 100644 index 000000000..ef076d126 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/parsing/parser_callbacks.md @@ -0,0 +1,83 @@ +# Parser Callbacks + +## Overview + +With a parser callback function, the result of parsing a JSON text can be influenced. When passed to `parse`, it is +called on certain events (passed as `parse_event_t` via parameter `event`) with a set recursion depth `depth` and +context JSON value `parsed`. The return value of the callback function is a boolean indicating whether the element that +emitted the callback shall be kept or not. + +The type of the callback function is: + +```cpp +template +using parser_callback_t = + std::function; +``` + + +## Callback event types + +We distinguish six scenarios (determined by the event type) in which the callback function can be called. The following +table describes the values of the parameters `depth`, `event`, and `parsed`. + +| parameter `event` | description | parameter `depth` | parameter `parsed` | +|-------------------------------|-----------------------------------------------------------|-------------------------------------------|----------------------------------| +| `parse_event_t::object_start` | the parser read `{` and started to process a JSON object | depth of the parent of the JSON object | a JSON value with type discarded | +| `parse_event_t::key` | the parser read a key of a value in an object | depth of the currently parsed JSON object | a JSON string containing the key | +| `parse_event_t::object_end` | the parser read `}` and finished processing a JSON object | depth of the parent of the JSON object | the parsed JSON object | +| `parse_event_t::array_start` | the parser read `[` and started to process a JSON array | depth of the parent of the JSON array | a JSON value with type discarded | +| `parse_event_t::array_end` | the parser read `]` and finished processing a JSON array | depth of the parent of the JSON array | the parsed JSON array | +| `parse_event_t::value` | the parser finished reading a JSON value | depth of the value | the parsed JSON value | + +??? example + + When parsing the following JSON text, + + ```json + { + "name": "Berlin", + "location": [ + 52.519444, + 13.406667 + ] + } + ``` + + these calls are made to the callback function: + + | event | depth | parsed | + | -------------- | ----- | ------ | + | `object_start` | 0 | *discarded* | + | `key` | 1 | `#!json "name"` | + | `value` | 1 | `#!json "Berlin"` | + | `key` | 1 | `#!json "location"` | + | `array_start` | 1 | *discarded* | + | `value` | 2 | `#!json 52.519444` | + | `value` | 2 | `#!json 13.406667` | + | `array_end` | 1 | `#!json [52.519444,13.406667]` | + | `object_end` | 0 | `#!json {"location":[52.519444,13.406667],"name":"Berlin"}` | + +## Return value + +Discarding a value (i.e., returning `#!c false`) has different effects depending on the context in which the function +was called: + +- Discarded values in structured types are skipped. That is, the parser will behave as if the discarded value was never + read. +- In case a value outside a structured type is skipped, it is replaced with `#!json null`. This case happens if the + top-level element is skipped. + +??? example + + The example below demonstrates the `parse()` function with and without callback function. + + ```cpp + --8<-- "examples/parse__string__parser_callback_t.cpp" + ``` + + Output: + + ```json + --8<-- "examples/parse__string__parser_callback_t.output" + ``` diff --git a/external_imported/json/doc/mkdocs/docs/features/parsing/sax_interface.md b/external_imported/json/docs/mkdocs/docs/features/parsing/sax_interface.md similarity index 95% rename from external_imported/json/doc/mkdocs/docs/features/parsing/sax_interface.md rename to external_imported/json/docs/mkdocs/docs/features/parsing/sax_interface.md index 731534826..0796a55f5 100644 --- a/external_imported/json/doc/mkdocs/docs/features/parsing/sax_interface.md +++ b/external_imported/json/docs/mkdocs/docs/features/parsing/sax_interface.md @@ -66,3 +66,8 @@ To implement your own SAX handler, proceed as follows: 3. Call `#!cpp bool json::sax_parse(input, &my_sax);` where the first parameter can be any input like a string or an input stream and the second parameter is a pointer to your SAX interface. Note the `sax_parse` function only returns a `#!cpp bool` indicating the result of the last executed SAX event. It does not return `json` value - it is up to you to decide what to do with the SAX events. Furthermore, no exceptions are thrown in case of a parse error - it is up to you what to do with the exception object passed to your `parse_error` implementation. Internally, the SAX interface is used for the DOM parser (class `json_sax_dom_parser`) as well as the acceptor (`json_sax_acceptor`), see file `json_sax.hpp`. + +## See also + +- [json_sax](../../api/json_sax/index.md) - documentation of the SAX interface +- [sax_parse](../../api/basic_json/sax_parse.md) - SAX parser diff --git a/external_imported/json/docs/mkdocs/docs/features/types/index.md b/external_imported/json/docs/mkdocs/docs/features/types/index.md new file mode 100644 index 000000000..d9dfcc29a --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/types/index.md @@ -0,0 +1,269 @@ +# Types + +This page gives an overview how JSON values are stored and how this can be configured. + +## Overview + +By default, JSON values are stored as follows: + +| JSON type | C++ type | +|-----------|-----------------------------------------------| +| object | `std::map` | +| array | `std::vector` | +| null | `std::nullptr_t` | +| string | `std::string` | +| boolean | `bool` | +| number | `std::int64_t`, `std::uint64_t`, and `double` | + +Note there are three different types for numbers - when parsing JSON text, the best fitting type is chosen. + +## Storage + +```plantuml +enum value_t { + null + object + array + string + boolean + number_integer + number_unsigned + number_float + binary + discarded +} + +class json_value << (U,orchid) >> { + object_t* object + array_t* array + string_t* string + binary_t* binary + boolean_t boolean + number_integer_t number_integer + number_unsigned_t number_unsigned + number_float_t number_float +} + +class basic_json { + -- type and value -- + value_t m_type + json_value m_value + -- derived types -- + + typedef object_t + + typedef array_t + + typedef binary_t + + typedef boolean_t + + typedef number_integer_t + + typedef number_unsigned_t + + typedef number_float_t +} + +basic_json .. json_value +basic_json .. value_t +``` + +## Template arguments + +The data types to store a JSON value are derived from the template arguments passed to class `basic_json`: + +```cpp +template< + template class ObjectType = std::map, + template class ArrayType = std::vector, + class StringType = std::string, + class BooleanType = bool, + class NumberIntegerType = std::int64_t, + class NumberUnsignedType = std::uint64_t, + class NumberFloatType = double, + template class AllocatorType = std::allocator, + template class JSONSerializer = adl_serializer, + class BinaryType = std::vector +> +class basic_json; +``` + +Type `json` is an alias for `basic_json<>` and uses the default types. + +From the template arguments, the following types are derived: + +```cpp +using object_comparator_t = std::less<>; +using object_t = ObjectType>>; + +using array_t = ArrayType>; + +using string_t = StringType; + +using boolean_t = BooleanType; + +using number_integer_t = NumberIntegerType; +using number_unsigned_t = NumberUnsignedType; +using number_float_t = NumberFloatType; + +using binary_t = nlohmann::byte_container_with_subtype; +``` + + +## Objects + +[RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON objects as follows: + +> An object is an unordered collection of zero or more name/value pairs, where a name is a string and a value is a string, number, boolean, null, object, or array. + +### Default type + +With the default values for *ObjectType* (`std::map`), *StringType* (`std::string`), and *AllocatorType* (`std::allocator`), the default value for `object_t` is: + +```cpp +std::map< + std::string, // key_type + basic_json, // value_type + std::less<>, // key_compare + std::allocator> // allocator_type +> +``` + +### Behavior + +The choice of `object_t` influences the behavior of the JSON class. With the default type, objects have the following behavior: + +- When all names are unique, objects will be interoperable in the sense that all software implementations receiving that object will agree on the name-value mappings. +- When the names within an object are not unique, it is unspecified which one of the values for a given key will be chosen. For instance, `#!json {"key": 2, "key": 1}` could be equal to either `#!json {"key": 1}` or `#!json {"key": 2}`. +- Internally, name/value pairs are stored in lexicographical order of the names. Objects will also be serialized (see `dump`) in this order. For instance, both `#!json {"b": 1, "a": 2}` and `#!json {"a": 2, "b": 1}` will be stored and serialized as `#!json {"a": 2, "b": 1}`. +- When comparing objects, the order of the name/value pairs is irrelevant. This makes objects interoperable in the sense that they will not be affected by these differences. For instance, `#!json {"b": 1, "a": 2}` and `#!json {"a": 2, "b": 1}` will be treated as equal. + +### Key order + +The order name/value pairs are added to the object is *not* preserved by the library. Therefore, iterating an object may return name/value pairs in a different order than they were originally stored. In fact, keys will be traversed in alphabetical order as `std::map` with `std::less` is used by default. Please note this behavior conforms to [RFC 8259](https://tools.ietf.org/html/rfc8259), because any order implements the specified "unordered" nature of JSON objects. + +### Limits + +[RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: + +> An implementation may set limits on the maximum depth of nesting. + +In this class, the object's limit of nesting is not explicitly constrained. However, a maximum depth of nesting may be introduced by the compiler or runtime environment. A theoretical limit can be queried by calling the `max_size` function of a JSON object. + +### Storage + +Objects are stored as pointers in a `basic_json` type. That is, for any access to object values, a pointer of type `object_t*` must be dereferenced. + + +## Arrays + +[RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON arrays as follows: + +> An array is an ordered sequence of zero or more values. + +### Default type + +With the default values for *ArrayType* (`std::vector`) and *AllocatorType* (`std::allocator`), the default value for `array_t` is: + +```cpp +std::vector< + basic_json, // value_type + std::allocator // allocator_type +> +``` + +### Limits + +[RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: + +> An implementation may set limits on the maximum depth of nesting. + +In this class, the array's limit of nesting is not explicitly constrained. However, a maximum depth of nesting may be introduced by the compiler or runtime environment. A theoretical limit can be queried by calling the `max_size` function of a JSON array. + +### Storage + +Arrays are stored as pointers in a `basic_json` type. That is, for any access to array values, a pointer of type `array_t*` must be dereferenced. + + +## Strings + +[RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON strings as follows: + +> A string is a sequence of zero or more Unicode characters. + +Unicode values are split by the JSON class into byte-sized characters during deserialization. + +### Default type + +With the default values for *StringType* (`std::string`), the default value for `string_t` is `#!cpp std::string`. + +### Encoding + +Strings are stored in UTF-8 encoding. Therefore, functions like `std::string::size()` or `std::string::length()` return the number of **bytes** in the string rather than the number of characters or glyphs. + +### String comparison + +[RFC 8259](https://tools.ietf.org/html/rfc8259) states: + +> Software implementations are typically required to test names of object members for equality. Implementations that transform the textual representation into sequences of Unicode code units and then perform the comparison numerically, code unit by code unit, are interoperable in the sense that implementations will agree in all cases on equality or inequality of two strings. For example, implementations that compare strings with escaped characters unconverted may incorrectly find that `"a\\b"` and `"a\u005Cb"` are not equal. + +This implementation is interoperable as it does compare strings code unit by code unit. + +### Storage + +String values are stored as pointers in a `basic_json` type. That is, for any access to string values, a pointer of type `string_t*` must be dereferenced. + + +## Booleans + +[RFC 8259](https://tools.ietf.org/html/rfc8259) implicitly describes a boolean as a type which differentiates the two literals `true` and `false`. + +### Default type + +With the default values for *BooleanType* (`#!cpp bool`), the default value for `boolean_t` is `#!cpp bool`. + +### Storage + +Boolean values are stored directly inside a `basic_json` type. + +## Numbers + +See the [number handling](number_handling.md) article for a detailed discussion on how numbers are handled by this library. + +[RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows: + +> The representation of numbers is similar to that used in most programming languages. A number is represented in base 10 using decimal digits. It contains an integer component that may be prefixed with an optional minus sign, which may be followed by a fraction part and/or an exponent part. Leading zeros are not allowed. (...) Numeric values that cannot be represented in the grammar below (such as Infinity and NaN) are not permitted. + +This description includes both integer and floating-point numbers. However, C++ allows more precise storage if it is known whether the number is a signed integer, an unsigned integer or a floating-point number. Therefore, three different types, `number_integer_t`, `number_unsigned_t`, and `number_float_t` are used. + +### Default types + +With the default values for *NumberIntegerType* (`std::int64_t`), the default value for `number_integer_t` is `std::int64_t`. +With the default values for *NumberUnsignedType* (`std::uint64_t`), the default value for `number_unsigned_t` is `std::uint64_t`. +With the default values for *NumberFloatType* (`#!cpp double`), the default value for `number_float_t` is `#!cpp double`. + +### Default behavior + +- The restrictions about leading zeros is not enforced in C++. Instead, leading zeros in integer literals lead to an interpretation as octal number. Internally, the value will be stored as decimal number. For instance, the C++ integer literal `#!c 010` will be serialized to `#!c 8`. During deserialization, leading zeros yield an error. +- Not-a-number (NaN) values will be serialized to `#!json null`. + +### Limits + +[RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: + +> An implementation may set limits on the range and precision of numbers. + +When the default type is used, the maximal integer number that can be stored is `#!c 9223372036854775807` (`INT64_MAX`) and the minimal integer number that can be stored is `#!c -9223372036854775808` (`INT64_MIN`). Integer numbers that are out of range will yield over/underflow when used in a constructor. During deserialization, too large or small integer numbers will be automatically be stored as `number_unsigned_t` or `number_float_t`. + +When the default type is used, the maximal unsigned integer number that can be stored is `#!c 18446744073709551615` (`UINT64_MAX`) and the minimal integer number that can be stored is `#!c 0`. Integer numbers that are out of range will yield over/underflow when used in a constructor. During deserialization, too large or small integer numbers will be automatically be stored as `number_integer_t` or `number_float_t`. + +[RFC 8259](https://tools.ietf.org/html/rfc8259) further states: + +> Note that when such software is used, numbers that are integers and are in the range $[-2^{53}+1, 2^{53}-1]$ are interoperable in the sense that implementations will agree exactly on their numeric values. + +As this range is a subrange of the exactly supported range [`INT64_MIN`, `INT64_MAX`], this class's integer type is interoperable. + +[RFC 8259](https://tools.ietf.org/html/rfc8259) states: + +> This specification allows implementations to set limits on the range and precision of numbers accepted. Since software that implements IEEE 754-2008 binary64 (double precision) numbers is generally available and widely used, good interoperability can be achieved by implementations that expect no more precision or range than these provide, in the sense that implementations will approximate JSON numbers within the expected precision. + +This implementation does exactly follow this approach, as it uses double precision floating-point numbers. Note values smaller than `#!c -1.79769313486232e+308` and values greater than `#!c 1.79769313486232e+308` will be stored as NaN internally and be serialized to `#!json null`. + +### Storage + +Integer number values, unsigned integer number values, and floating-point number values are stored directly inside a `basic_json` type. diff --git a/external_imported/json/docs/mkdocs/docs/features/types/number_handling.md b/external_imported/json/docs/mkdocs/docs/features/types/number_handling.md new file mode 100644 index 000000000..3dcca76a4 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/features/types/number_handling.md @@ -0,0 +1,328 @@ +# Number Handling + +This document describes how the library is handling numbers. + +## Background + +This section briefly summarizes how the JSON specification describes how numbers should be handled. + +### JSON number syntax + +JSON defines the syntax of numbers as follows: + +!!! quote "[RFC 8259](https://tools.ietf.org/html/rfc8259#section-6), Section 6" + + The representation of numbers is similar to that used in most + programming languages. A number is represented in base 10 using + decimal digits. It contains an integer component that may be + prefixed with an optional minus sign, which may be followed by a + fraction part and/or an exponent part. Leading zeros are not + allowed. + + A fraction part is a decimal point followed by one or more digits. + + An exponent part begins with the letter E in uppercase or lowercase, + which may be followed by a plus or minus sign. The E and optional + sign are followed by one or more digits. + +The following railroad diagram from [json.org](https://json.org) visualizes the number syntax: + +![Syntax for JSON numbers](../../images/json_syntax_number.png) + +### Number interoperability + +On number interoperability, the following remarks are made: + +!!! quote "[RFC 8259](https://tools.ietf.org/html/rfc8259#section-6), Section 6" + + This specification allows implementations to set limits on the range + and precision of numbers accepted. Since software that implements + IEEE 754 binary64 (double precision) numbers [IEEE754] is generally + available and widely used, good interoperability can be achieved by + implementations that expect no more precision or range than these + provide, in the sense that implementations will approximate JSON + numbers within the expected precision. A JSON number such as 1E400 + or 3.141592653589793238462643383279 may indicate potential + interoperability problems, since it suggests that the software that + created it expects receiving software to have greater capabilities + for numeric magnitude and precision than is widely available. + + Note that when such software is used, numbers that are integers and + are in the range $[-2^{53}+1, 2^{53}-1]$ are interoperable in the + sense that implementations will agree exactly on their numeric + values. + +## Library implementation + +This section describes how the above number specification is implemented by this library. + +### Number storage + +In the default [`json`](../../api/json.md) type, numbers are stored as `#!c std::uint64_t`, `#!c std::int64_t`, and +`#!c double`, respectively. Thereby, `#!c std::uint64_t` and `#!c std::int64_t` are used only if they can store the +number without loss of precision. If this is impossible (e.g., if the number is too large), the number is stored as +`#!c double`. + +!!! info "Notes" + + - Numbers with a decimal digit or scientific notation are always stored as `#!c double`. + - The number types can be changed, see [Template number types](#template-number-types). + - As of version 3.9.1, the conversion is realized by + [`std::strtoull`](https://en.cppreference.com/w/cpp/string/byte/strtoul), + [`std::strtoll`](https://en.cppreference.com/w/cpp/string/byte/strtol), and + [`std::strtod`](https://en.cppreference.com/w/cpp/string/byte/strtof), respectively. + +!!! example "Examples" + + - Integer `#!c -12345678912345789123456789` is smaller than `#!c INT64_MIN` and will be stored as floating-point + number `#!c -1.2345678912345788e+25`. + - Integer `#!c 1E3` will be stored as floating-point number `#!c 1000.0`. + +### Number limits + +- Any 64-bit signed or unsigned integer can be stored without loss of precision. +- Numbers exceeding the limits of `#!c double` (i.e., numbers that after conversion via +[`std::strtod`](https://en.cppreference.com/w/cpp/string/byte/strtof) are not satisfying +[`std::isfinite`](https://en.cppreference.com/w/cpp/numeric/math/isfinite) such as `#!c 1E400`) will throw exception +[`json.exception.out_of_range.406`](../../home/exceptions.md#jsonexceptionout_of_range406) during parsing. +- Floating-point numbers are rounded to the next number representable as `double`. For instance +`#!c 3.141592653589793238462643383279` is stored as [`0x400921fb54442d18`](https://float.exposed/0x400921fb54442d18). +This is the same behavior as the code `#!c double x = 3.141592653589793238462643383279;`. + +!!! success "Interoperability" + + - The library interoperable with respect to the specification, because its supported range $[-2^{63}, 2^{64}-1]$ is + larger than the described range $[-2^{53}+1, 2^{53}-1]$. + - All integers outside the range $[-2^{63}, 2^{64}-1]$, as well as floating-point numbers are stored as `double`. + This also concurs with the specification above. + +### Zeros + +The JSON number grammar allows for different ways to express zero, and this library will store zeros differently: + +| Literal | Stored value and type | Serialization | +|---------|------------------------|---------------| +| `0` | `#!c std::uint64_t(0)` | `0` | +| `-0` | `#!c std::int64_t(0)` | `0` | +| `0.0` | `#!c double(0.0)` | `0.0` | +| `-0.0` | `#!c double(-0.0)` | `-0.0` | +| `0E0` | `#!c double(0.0)` | `0.0` | +| `-0E0` | `#!c double(-0.0)` | `-0.0` | + +That is, `-0` is stored as a signed integer, but the serialization does not reproduce the `-`. + +### Number serialization + +- Integer numbers are serialized as is; that is, no scientific notation is used. +- Floating-point numbers are serialized as specified by the `#!c %g` printf modifier with + [`std::numeric_limits::max_digits10`](https://en.cppreference.com/w/cpp/types/numeric_limits/max_digits10) + significant digits. The rationale is to use the shortest representation while still allow round-tripping. + +!!! hint "Notes regarding precision of floating-point numbers" + + As described above, floating-point numbers are rounded to the nearest double and serialized with the shortest + representation to allow round-tripping. This can yield confusing examples: + + - The serialization can have fewer decimal places than the input: `#!c 2555.5599999999999` will be serialized as + `#!c 2555.56`. The reverse can also be true. + - The serialization can be in scientific notation even if the input is not: `#!c 0.0000972439793401814` will be + serialized as `#!c 9.72439793401814e-05`. The reverse can also be true: `#!c 12345E-5` will be serialized as + `#!c 0.12345`. + - Conversions from `#!c float` to `#!c double` can also introduce rounding errors: + ```cpp + float f = 0.3; + json j = f; + std::cout << j << '\n'; + ``` + yields `#!c 0.30000001192092896`. + + All examples here can be reproduced by passing the original double value to + + ```cpp + std::printf("%.*g\n", std::numeric_limits::max_digits10, double_value); + ``` + +#### NaN handling + +NaN (not-a-number) cannot be expressed with the number syntax described above and are in fact explicitly excluded: + +!!! quote "[RFC 8259](https://tools.ietf.org/html/rfc8259#section-6), Section 6" + + Numeric values that cannot be represented in the grammar below (such + as Infinity and NaN) are not permitted. + +That is, there is no way to *parse* a NaN value. However, NaN values can be stored in a JSON value by assignment. + +This library serializes NaN values as `#!js null`. This corresponds to the behavior of JavaScript's +[`JSON.stringify`](https://www.w3schools.com/js/js_json_stringify.asp) function. + +!!! example + + The following example shows how a NaN value is stored in a `json` value. + + ```cpp + int main() + { + double val = std::numeric_limits::quiet_NaN(); + std::cout << "val=" << val << std::endl; + json j = val; + std::cout << "j=" << j.dump() << std::endl; + val = j; + std::cout << "val=" << val << std::endl; + } + ``` + + output: + + ``` + val=nan + j=null + val=nan + ``` + +### Number comparison + +Floating-point inside JSON values numbers are compared with `#!c json::number_float_t::operator==` which is +`#!c double::operator==` by default. + +!!! example "Alternative comparison functions" + + To compare floating-point while respecting an epsilon, an alternative + [comparison function](https://github.com/mariokonrad/marnav/blob/master/include/marnav/math/floatingpoint.hpp#L34-#L39) + could be used, for instance + + ```cpp + template::value, T>::type> + inline bool is_same(T a, T b, T epsilon = std::numeric_limits::epsilon()) noexcept + { + return std::abs(a - b) <= epsilon; + } + ``` + Or you can self-define an operator equal function like this: + + ```cpp + bool my_equal(const_reference lhs, const_reference rhs) + { + const auto lhs_type lhs.type(); + const auto rhs_type rhs.type(); + if (lhs_type == rhs_type) + { + switch(lhs_type) + { + // self_defined case + case value_t::number_float: + return std::abs(lhs - rhs) <= std::numeric_limits::epsilon(); + + // other cases remain the same with the original + ... + } + } + ... + } + ``` + + (see [#703](https://github.com/nlohmann/json/issues/703) for more information.) + +!!! note + + NaN values never compare equal to themselves or to other NaN values. See [#514](https://github.com/nlohmann/json/issues/514). + +### Number conversion + +Just like the C++ language itself, the `get` family of functions allows conversions between unsigned and signed +integers, and between integers and floating-point values to integers. This behavior may be surprising. + +!!! warning "Unconditional number conversions" + + ```cpp hl_lines="3" + double d = 42.3; // non-integer double value 42.3 + json jd = d; // stores double value 42.3 + std::int64_t i = jd.template get(); // now i==42; no warning or error is produced + ``` + + Note the last line with throw a [`json.exception.type_error.302`](../../home/exceptions.md#jsonexceptiontype_error302) + exception if `jd` is not a numerical type, for instance a string. + +The rationale is twofold: + +1. JSON does not define a number type or precision (see above). +2. C++ also allows to silently convert between number types. + +!!! success "Conditional number conversion" + + The code above can be solved by explicitly checking the nature of the value with members such as + [`is_number_integer()`](../../api/basic_json/is_number_integer.md) or + [`is_number_unsigned()`](../../api/basic_json/is_number_unsigned.md): + + ```cpp hl_lines="2" + // check if jd is really integer-valued + if (jd.is_number_integer()) + { + // if so, do the conversion and use i + std::int64_t i = jd.template get(); + // ... + } + else + { + // otherwise, take appropriate action + // ... + } + ``` + + Note this approach also has the advantage that it can react on non-numerical JSON value types such as strings. + + (Example taken from [#777](https://github.com/nlohmann/json/issues/777#issuecomment-459968458).) + +### Determine number types + +As the example in [Number conversion](#number-conversion) shows, there are different functions to determine the type of +the stored number: + +- [`is_number()`](../../api/basic_json/is_number.md) returns `#!c true` for any number type +- [`is_number_integer()`](../../api/basic_json/is_number_integer.md) returns `#!c true` for signed and unsigned integers +- [`is_number_unsigned()`](../../api/basic_json/is_number_unsigned.md) returns `#!c true` for unsigned integers only +- [`is_number_float()`](../../api/basic_json/is_number_float.md) returns `#!c true` for floating-point numbers +- [`type_name()`](../../api/basic_json/type_name.md) returns `#!c "number"` for any number type +- [`type()`](../../api/basic_json/type.md) returns a different enumerator of + [`value_t`](../../api/basic_json/value_t.md) for all number types + +| function | unsigned integer | signed integer | floating-point | string | +|----------------------------------------------------------------------|-------------------|------------------|----------------|----------------| +| [`is_number()`](../../api/basic_json/is_number.md) | `#!c true` | `#!c true` | `#!c true` | `#!c false` | +| [`is_number_integer()`](../../api/basic_json/is_number_integer.md) | `#!c true` | `#!c true` | `#!c false` | `#!c false` | +| [`is_number_unsigned()`](../../api/basic_json/is_number_unsigned.md) | `#!c true` | `#!c false` | `#!c false` | `#!c false` | +| [`is_number_float()`](../../api/basic_json/is_number_float.md) | `#!c false` | `#!c false` | `#!c true` | `#!c false` | +| [`type_name()`](../../api/basic_json/type_name.md) | `#!c "number"` | `#!c "number"` | `#!c "number"` | `#!c "string"` | +| [`type()`](../../api/basic_json/type.md) | `number_unsigned` | `number_integer` | `number_float` | `string` | + +### Template number types + +The number types can be changed with template parameters. + +| position | number type | default type | possible values | +|----------|-------------------|---------------------|------------------------------------------------| +| 5 | signed integers | `#!c std::int64_t` | `#!c std::int32_t`, `#!c std::int16_t`, etc. | +| 6 | unsigned integers | `#!c std::uint64_t` | `#!c std::uint32_t`, `#!c std::uint16_t`, etc. | +| 7 | floating-point | `#!c double` | `#!c float`, `#!c long double` | + +!!! info "Constraints on number types" + + - The type for signed integers must be convertible from `#!c long long`. The type for floating-point numbers is used + in case of overflow. + - The type for unsigned integers must be convertible from `#!c unsigned long long`. The type for floating-point + numbers is used in case of overflow. + - The types for signed and unsigned integers must be distinct, see + [#2573](https://github.com/nlohmann/json/issues/2573). + - Only `#!c double`, `#!c float`, and `#!c long double` are supported for floating-point numbers. + +!!! example + + A `basic_json` type that uses `#!c long double` as floating-point type. + + ```cpp hl_lines="2" + using json_ld = nlohmann::basic_json; + ``` + + Note values should then be parsed with `json_ld::parse` rather than `json::parse` as the latter would parse + floating-point values to `#!c double` before then converting them to `#!c long double`. diff --git a/external_imported/json/doc/mkdocs/docs/home/code_of_conduct.md b/external_imported/json/docs/mkdocs/docs/home/code_of_conduct.md similarity index 100% rename from external_imported/json/doc/mkdocs/docs/home/code_of_conduct.md rename to external_imported/json/docs/mkdocs/docs/home/code_of_conduct.md diff --git a/external_imported/json/doc/mkdocs/docs/home/design_goals.md b/external_imported/json/docs/mkdocs/docs/home/design_goals.md similarity index 97% rename from external_imported/json/doc/mkdocs/docs/home/design_goals.md rename to external_imported/json/docs/mkdocs/docs/home/design_goals.md index 91b387528..b80551fe9 100644 --- a/external_imported/json/doc/mkdocs/docs/home/design_goals.md +++ b/external_imported/json/docs/mkdocs/docs/home/design_goals.md @@ -2,7 +2,7 @@ There are myriads of [JSON](https://json.org) libraries out there, and each may even have its reason to exist. Our class had these design goals: -- **Intuitive syntax**. In languages such as Python, JSON feels like a first class data type. We used all the operator magic of modern C++ to achieve the same feeling in your code. Check out the [examples below](#examples) and you'll know what I mean. +- **Intuitive syntax**. In languages such as Python, JSON feels like a first class data type. We used all the operator magic of modern C++ to achieve the same feeling in your code. Check out the [examples below](#examples), and you'll know what I mean. - **Trivial integration**. Our whole code consists of a single header file [`json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp). That's it. No library, no subproject, no dependencies, no complex build system. The class is written in vanilla C++11. All in all, everything should require no adjustment of your compiler flags or project settings. diff --git a/external_imported/json/doc/mkdocs/docs/home/exceptions.md b/external_imported/json/docs/mkdocs/docs/home/exceptions.md similarity index 88% rename from external_imported/json/doc/mkdocs/docs/home/exceptions.md rename to external_imported/json/docs/mkdocs/docs/home/exceptions.md index da68f2149..a0fee9e33 100644 --- a/external_imported/json/doc/mkdocs/docs/home/exceptions.md +++ b/external_imported/json/docs/mkdocs/docs/home/exceptions.md @@ -28,9 +28,9 @@ class json::parse_error { ### Switch off exceptions -Exceptions are used widely within the library. They can, however, be switched off with either using the compiler flag `-fno-exceptions` or by defining the symbol `JSON_NOEXCEPTION`. In this case, exceptions are replaced by `abort()` calls. You can further control this behavior by defining `JSON_THROW_USER` (overriding `#!cpp throw`), `JSON_TRY_USER` (overriding `#!cpp try`), and `JSON_CATCH_USER` (overriding `#!cpp catch`). +Exceptions are used widely within the library. They can, however, be switched off with either using the compiler flag `-fno-exceptions` or by defining the symbol [`JSON_NOEXCEPTION`](../api/macros/json_noexception.md). In this case, exceptions are replaced by `abort()` calls. You can further control this behavior by defining `JSON_THROW_USER` (overriding `#!cpp throw`), `JSON_TRY_USER` (overriding `#!cpp try`), and `JSON_CATCH_USER` (overriding `#!cpp catch`). -Note that `JSON_THROW_USER` should leave the current scope (e.g., by throwing or aborting), as continuing after it may yield undefined behavior. +Note that [`JSON_THROW_USER`](../api/macros/json_throw_user.md) should leave the current scope (e.g., by throwing or aborting), as continuing after it may yield undefined behavior. ??? example @@ -50,6 +50,10 @@ Note that `JSON_THROW_USER` should leave the current scope (e.g., by throwing or #include ``` +Note the explanatory [`what()`](https://en.cppreference.com/w/cpp/error/exception/what) string of exceptions is not available for MSVC if exceptions are disabled, see [#2824](https://github.com/nlohmann/json/discussions/2824). + +See [documentation of `JSON_TRY_USER`, `JSON_CATCH_USER` and `JSON_THROW_USER`](../api/macros/json_throw_user.md) for more information. + ### Extended diagnostic messages Exceptions in the library are thrown in the local context of the JSON value they are detected. This makes detailed diagnostics messages, and hence debugging, difficult. @@ -70,7 +74,7 @@ Exceptions in the library are thrown in the local context of the JSON value they To create better diagnostics messages, each JSON value needs a pointer to its parent value such that a global context (i.e., a path from the root value to the value that lead to the exception) can be created. That global context is provided as [JSON Pointer](../features/json_pointer.md). -As this global context comes at the price of storing one additional pointer per JSON value and runtime overhead to maintain the parent relation, extended diagnostics are disabled by default. They can, however, be enabled by defining the preprocessor symbol [`JSON_DIAGNOSTICS`](../features/macros.md#json_diagnostics) to `1` before including `json.hpp`. +As this global context comes at the price of storing one additional pointer per JSON value and runtime overhead to maintain the parent relation, extended diagnostics are disabled by default. They can, however, be enabled by defining the preprocessor symbol [`JSON_DIAGNOSTICS`](../api/macros/json_diagnostics.md) to `1` before including `json.hpp`. ??? example @@ -86,6 +90,7 @@ As this global context comes at the price of storing one additional pointer per Now the exception message contains a JSON Pointer `/address/housenumber` that indicates which value has the wrong type. +See [documentation of `JSON_DIAGNOSTICS`](../api/macros/json_diagnostics.md) for more information. ## Parse errors @@ -134,7 +139,7 @@ This error indicates a syntax error while deserializing a JSON text. The error m No input: ``` - [json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal + [json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON ``` Control character was not escaped: @@ -175,12 +180,12 @@ This error indicates a syntax error while deserializing a JSON text. The error m !!! tip - - Make sure the input is correctly read. Try to write the input to standard output to check if, for instance, the input file was successfully openened. + - Make sure the input is correctly read. Try to write the input to standard output to check if, for instance, the input file was successfully opened. - Paste the input to a JSON validator like or a tool like [jq](https://stedolan.github.io/jq/). ### json.exception.parse_error.102 -JSON uses the `\uxxxx` format to describe Unicode characters. Code points above above 0xFFFF are split into two `\uxxxx` entries ("surrogate pairs"). This error indicates that the surrogate pair is incomplete or contains an invalid code point. +JSON uses the `\uxxxx` format to describe Unicode characters. Code points above 0xFFFF are split into two `\uxxxx` entries ("surrogate pairs"). This error indicates that the surrogate pair is incomplete or contains an invalid code point. !!! failure "Example message" @@ -188,6 +193,10 @@ JSON uses the `\uxxxx` format to describe Unicode characters. Code points above parse error at 14: missing or wrong low surrogate ``` +!!! note + + This exception is not used any more. Instead [json.exception.parse_error.101](#jsonexceptionparse_error101) with a more detailed description is used. + ### json.exception.parse_error.103 Unicode supports code points up to 0x10FFFF. Code points above 0x10FFFF are invalid. @@ -198,6 +207,10 @@ Unicode supports code points up to 0x10FFFF. Code points above 0x10FFFF are inva parse error: code points above 0x10FFFF are invalid ``` +!!! note + + This exception is not used any more. Instead [json.exception.parse_error.101](#jsonexceptionparse_error101) with a more detailed description is used. + ### json.exception.parse_error.104 [RFC 6902](https://tools.ietf.org/html/rfc6902) requires a JSON Patch document to be a JSON document that represents an array of objects. @@ -258,7 +271,7 @@ In a JSON Pointer, only `~0` and `~1` are valid escape sequences. A JSON Pointer array index must be a number. -!!! failure "Example message" +!!! failure "Example messages" ``` [json.exception.parse_error.109] parse error: array index 'one' is not a number @@ -282,19 +295,34 @@ When parsing CBOR or MessagePack, the byte vector ends before the complete value ### json.exception.parse_error.112 -Not all types of CBOR or MessagePack are supported. This exception occurs if an unsupported byte was read. +An unexpected byte was read in a [binary format](../features/binary_formats/index.md) or length information is invalid ([BSON](../features/binary_formats/bson.md)). -!!! failure "Example message" +!!! failure "Example messages" ``` [json.exception.parse_error.112] parse error at byte 1: syntax error while parsing CBOR value: invalid byte: 0x1C ``` + ``` + [json.exception.parse_error.112] parse error at byte 1: syntax error while parsing MessagePack value: invalid byte: 0xC1 + ``` + ``` + [json.exception.parse_error.112] parse error at byte 4: syntax error while parsing BJData size: expected '#' after type information; last byte: 0x02 + ``` + ``` + [json.exception.parse_error.112] parse error at byte 4: syntax error while parsing UBJSON size: expected '#' after type information; last byte: 0x02 + ``` + ``` + [json.exception.parse_error.112] parse error at byte 10: syntax error while parsing BSON string: string length must be at least 1, is -2147483648 + ``` + ``` + [json.exception.parse_error.112] parse error at byte 15: syntax error while parsing BSON binary: byte array length cannot be negative, is -1 + ``` ### json.exception.parse_error.113 While parsing a map key, a value that is not a string has been read. -!!! failure "Example message" +!!! failure "Example messages" ``` [json.exception.parse_error.113] parse error at byte 2: syntax error while parsing CBOR string: expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0xFF @@ -359,9 +387,9 @@ The iterators passed to constructor `basic_json(InputIT first, InputIT last)` ar ### json.exception.invalid_iterator.202 -In an [erase](../api/basic_json/erase.md) or insert function, the passed iterator `pos` does not belong to the JSON value for which the function was called. It hence does not define a valid position for the deletion/insertion. +In the [erase](../api/basic_json/erase.md) or insert function, the passed iterator `pos` does not belong to the JSON value for which the function was called. It hence does not define a valid position for the deletion/insertion. -!!! failure "Example message" +!!! failure "Example messages" ``` [json.exception.invalid_iterator.202] iterator does not fit current value @@ -525,7 +553,7 @@ To create an object from an initializer list, the initializer list must consist During implicit or explicit value conversion, the JSON type must be compatible to the target type. For instance, a JSON string can only be converted into string types, but not into numbers or boolean types. -!!! failure "Example message" +!!! failure "Example messages" ``` [json.exception.type_error.302] type must be object, but is null @@ -538,7 +566,7 @@ During implicit or explicit value conversion, the JSON type must be compatible t To retrieve a reference to a value stored in a `basic_json` object with `get_ref`, the type of the reference must match the value type. For instance, for a JSON array, the `ReferenceType` must be `array_t &`. -!!! failure "Example message" +!!! failure "Example messages" ``` [json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object @@ -551,7 +579,7 @@ To retrieve a reference to a value stored in a `basic_json` object with `get_ref The `at()` member functions can only be executed for certain JSON types. -!!! failure "Example message" +!!! failure "Example messages" ``` [json.exception.type_error.304] cannot use at() with string @@ -564,7 +592,7 @@ The `at()` member functions can only be executed for certain JSON types. The `operator[]` member functions can only be executed for certain JSON types. -!!! failure "Example message" +!!! failure "Example messages" ``` [json.exception.type_error.305] cannot use operator[] with a string argument with array @@ -607,7 +635,7 @@ The `push_back()` and `operator+=` member functions can only be executed for cer The `insert()` member functions can only be executed for certain JSON types. -!!! failure "Example message" +!!! failure "Example messages" ``` [json.exception.type_error.309] cannot use insert() with array @@ -630,7 +658,7 @@ The `swap()` member functions can only be executed for certain JSON types. The `emplace()` and `emplace_back()` member functions can only be executed for certain JSON types. -!!! failure "Example message" +!!! failure "Example messages" ``` [json.exception.type_error.311] cannot use emplace() with number @@ -651,7 +679,7 @@ The `update()` member functions can only be executed for certain JSON types. ### json.exception.type_error.313 -The `unflatten` function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well defined. +The `unflatten` function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well-defined. !!! failure "Example message" @@ -705,7 +733,7 @@ The `dump()` function only works with UTF-8 encoded strings; that is, if you ass The dynamic type of the object cannot be represented in the requested serialization format (e.g. a raw `true` or `null` JSON object cannot be serialized to BSON) -!!! failure "Example message" +!!! failure "Example messages" Serializing `#!json null` to BSON: ``` diff --git a/external_imported/json/docs/mkdocs/docs/home/faq.md b/external_imported/json/docs/mkdocs/docs/home/faq.md new file mode 100644 index 000000000..dd426e073 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/home/faq.md @@ -0,0 +1,180 @@ +# Frequently Asked Questions (FAQ) + +## Known bugs + +### Brace initialization yields arrays + +!!! question + + Why does + + ```cpp + json j{true}; + ``` + + and + + ```cpp + json j(true); + ``` + + yield different results (`#!json [true]` vs. `#!json true`)? + +This is a known issue, and -- even worse -- the behavior differs between GCC and Clang. The "culprit" for this is the library's constructor overloads for initializer lists to allow syntax like + +```cpp +json array = {1, 2, 3, 4}; +``` + +for arrays and + +```cpp +json object = {{"one", 1}, {"two", 2}}; +``` + +for objects. + +!!! tip + + To avoid any confusion and ensure portable code, **do not** use brace initialization with the types `basic_json`, `json`, or `ordered_json` unless you want to create an object or array as shown in the examples above. + +## Limitations + +### Relaxed parsing + +!!! question + + Can you add an option to ignore trailing commas? + +This library does not support any feature which would jeopardize interoperability. + + +### Parse errors reading non-ASCII characters + +!!! question "Questions" + + - Why is the parser complaining about a Chinese character? + - Does the library support Unicode? + - I get an exception `[json.exception.parse_error.101] parse error at line 1, column 53: syntax error while parsing value - invalid string: ill-formed UTF-8 byte; last read: '"Testé$')"` + +The library supports **Unicode input** as follows: + +- Only **UTF-8** encoded input is supported which is the default encoding for JSON according to [RFC 8259](https://tools.ietf.org/html/rfc8259.html#section-8.1). +- `std::u16string` and `std::u32string` can be parsed, assuming UTF-16 and UTF-32 encoding, respectively. These encodings are not supported when reading from files or other input containers. +- Other encodings such as Latin-1 or ISO 8859-1 are **not** supported and will yield parse or serialization errors. +- [Unicode noncharacters](http://www.unicode.org/faq/private_use.html#nonchar1) will not be replaced by the library. +- Invalid surrogates (e.g., incomplete pairs such as `\uDEAD`) will yield parse errors. +- The strings stored in the library are UTF-8 encoded. When using the default string type (`std::string`), note that its length/size functions return the number of stored bytes rather than the number of characters or glyphs. +- When you store strings with different encodings in the library, calling [`dump()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a50ec80b02d0f3f51130d4abb5d1cfdc5.html#a50ec80b02d0f3f51130d4abb5d1cfdc5) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers. + +In most cases, the parser is right to complain, because the input is not UTF-8 encoded. This is especially true for Microsoft Windows where Latin-1 or ISO 8859-1 is often the standard encoding. + + +### Wide string handling + +!!! question + + Why are wide strings (e.g., `std::wstring`) dumped as arrays of numbers? + +As described [above](#parse-errors-reading-non-ascii-characters), the library assumes UTF-8 as encoding. To store a wide string, you need to change the encoding. + +!!! example + + ```cpp + #include // codecvt_utf8 + #include // wstring_convert + + // encoding function + std::string to_utf8(std::wstring& wide_string) + { + static std::wstring_convert> utf8_conv; + return utf8_conv.to_bytes(wide_string); + } + + json j; + std::wstring ws = L"車B1234 ã“ã‚“ã«ã¡ã¯"; + + j["original"] = ws; + j["encoded"] = to_utf8(ws); + + std::cout << j << std::endl; + ``` + + The result is: + + ```json + { + "encoded": "車B1234 ã“ã‚“ã«ã¡ã¯", + "original": [36554, 66, 49, 50, 51, 52, 32, 12371, 12435, 12395, 12385, 12399] + } + ``` + +## Exceptions + +### Parsing without exceptions + +!!! question + + Is it possible to indicate a parse error without throwing an exception? + +Yes, see [Parsing and exceptions](../features/parsing/parse_exceptions.md). + + +### Key name in exceptions + +!!! question + + Can I get the key of the object item that caused an exception? + +Yes, you can. Please define the symbol [`JSON_DIAGNOSTICS`](../api/macros/json_diagnostics.md) to get [extended diagnostics messages](exceptions.md#extended-diagnostic-messages). + + +## Serialization issues + + +### Number precision + +!!! question + + - It seems that precision is lost when serializing a double. + - Can I change the precision for floating-point serialization? + +The library uses `std::numeric_limits::digits10` (15 for IEEE `double`s) digits for serialization. This value is sufficient to guarantee roundtripping. If one uses more than this number of digits of precision, then string -> value -> string is not guaranteed to round-trip. + +!!! quote "[cppreference.com](https://en.cppreference.com/w/cpp/types/numeric_limits/digits10)" + + The value of `std::numeric_limits::digits10` is the number of base-10 digits that can be represented by the type T without change, that is, any number with this many significant decimal digits can be converted to a value of type T and back to decimal form, without change due to rounding or overflow. + +!!! tip + + The website https://float.exposed gives a good insight into the internal storage of floating-point numbers. + +See [this section](../features/types/number_handling.md#number-serialization) on the library's number handling for more information. + +## Compilation issues + +### Android SDK + +!!! question + + Why does the code not compile with Android SDK? + +Android defaults to using very old compilers and C++ libraries. To fix this, add the following to your `Application.mk`. This will switch to the LLVM C++ library, the Clang compiler, and enable C++11 and other features disabled by default. + +```ini +APP_STL := c++_shared +NDK_TOOLCHAIN_VERSION := clang3.6 +APP_CPPFLAGS += -frtti -fexceptions +``` + +The code compiles successfully with [Android NDK](https://developer.android.com/ndk/index.html?hl=ml), Revision 9 - 11 (and possibly later) and [CrystaX's Android NDK](https://www.crystax.net/en/android/ndk) version 10. + + +### Missing STL function + +!!! question "Questions" + + - Why do I get a compilation error `'to_string' is not a member of 'std'` (or similarly, for `strtod` or `strtof`)? + - Why does the code not compile with MinGW or Android SDK? + +This is not an issue with the code, but rather with the compiler itself. On Android, see above to build with a newer environment. For MinGW, please refer to [this site](http://tehsausage.com/mingw-to-string) and [this discussion](https://github.com/nlohmann/json/issues/136) for information on how to fix this bug. For Android NDK using `APP_STL := gnustl_static`, please refer to [this discussion](https://github.com/nlohmann/json/issues/219). diff --git a/external_imported/json/doc/mkdocs/docs/home/license.md b/external_imported/json/docs/mkdocs/docs/home/license.md similarity index 96% rename from external_imported/json/doc/mkdocs/docs/home/license.md rename to external_imported/json/docs/mkdocs/docs/home/license.md index d359468e0..baef2f51b 100644 --- a/external_imported/json/doc/mkdocs/docs/home/license.md +++ b/external_imported/json/docs/mkdocs/docs/home/license.md @@ -4,7 +4,7 @@ The class is licensed under the [MIT License](https://opensource.org/licenses/MIT): -Copyright © 2013-2021 [Niels Lohmann](https://nlohmann.me) +Copyright © 2013-2022 [Niels Lohmann](https://nlohmann.me) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Softwareâ€), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/external_imported/json/doc/mkdocs/docs/home/releases.md b/external_imported/json/docs/mkdocs/docs/home/releases.md similarity index 99% rename from external_imported/json/doc/mkdocs/docs/home/releases.md rename to external_imported/json/docs/mkdocs/docs/home/releases.md index 0cb890b0a..5237c4259 100644 --- a/external_imported/json/doc/mkdocs/docs/home/releases.md +++ b/external_imported/json/docs/mkdocs/docs/home/releases.md @@ -252,18 +252,18 @@ http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a0a45fc74063 - Fixed documentation of parse function. #1473 - Suppressed warning that cannot be fixed inside the library. #1401 #1468 - Imroved package manager suppert: - - Updated Buckaroo instructions. #1495 - - Improved Meson support. #1463 - - Added Conda package manager documentation. #1430 - - Added NuGet package manager documentation. #1132 + - Updated Buckaroo instructions. #1495 + - Improved Meson support. #1463 + - Added Conda package manager documentation. #1430 + - Added NuGet package manager documentation. #1132 - Continuous Integration - - Removed unstable or deprecated Travis builders (Xcode 6.4 - 8.2) and added Xcode 10.1 builder. - - Added Clang 7 to Travis CI. - - Fixed AppVeyor x64 builds. #1374 #1414 + - Removed unstable or deprecated Travis builders (Xcode 6.4 - 8.2) and added Xcode 10.1 builder. + - Added Clang 7 to Travis CI. + - Fixed AppVeyor x64 builds. #1374 #1414 - Updated thirdparty libraries: - - Catch 1.12.0 -> 1.12.2 - - Google Benchmark 1.3.0 -> 1.4.1 - - Doxygen 1.8.15 -> 1.8.16 + - Catch 1.12.0 -> 1.12.2 + - Google Benchmark 1.3.0 -> 1.4.1 + - Doxygen 1.8.15 -> 1.8.16 ### :fire: Deprecated functions @@ -468,7 +468,7 @@ This release further fixes several bugs in the library. All changes are backward - allow compare user-defined string types (#1130) - better support for algorithms using iterators from `items()` (#1045, #1134) - added parameter to avoid compilation error with MSVC 2015 debug builds (#1114) -- re-added accidentially skipped unit tests (#1176) +- re-added accidentally skipped unit tests (#1176) - fixed MSVC issue with `std::swap` (#1168) ### :zap: Improvements @@ -1008,7 +1008,7 @@ This release fixes a few bugs in the JSON parser found in the [Parsing JSON is a This release fixes the semantics of `operator[]` for JSON Pointers (see below). This fix is backwards compatible. ### Changes -- **`operator[]` for JSON Pointers** now behaves like the other versions of `operator[]` and transforms `null` values into objects or arrays if required. This allows to created nested structues like `j["/foo/bar/2"] = 17` (yielding `{"foo": "bar": [null, null, 17]}`) without problems. +- **`operator[]` for JSON Pointers** now behaves like the other versions of `operator[]` and transforms `null` values into objects or arrays if required. This allows to created nested structures like `j["/foo/bar/2"] = 17` (yielding `{"foo": "bar": [null, null, 17]}`) without problems. - overworked a helper SFINAE function - fixed some documentation issues - fixed the CMake files to allow to run the test suite outside the main project directory @@ -1093,7 +1093,7 @@ This release combines a lot of small fixes and improvements. The release is back ### Changes - The **parser** has been overworked, and a lot of small issues have been fixed: - Improved parser performance by avoiding recursion and using move semantics for the return value. - - Unescaped control charaters `\x10`-`\x1f` are not accepted any more. + - Unescaped control characters `\x10`-`\x1f` are not accepted any more. - Fixed a bug in the parser when reading from an input stream. - Improved test case coverage for UTF-8 parsing: now, all valid Unicode code points are tested both escaped and unescaped. - The precision of output streams is now preserved by the parser. @@ -1167,7 +1167,7 @@ As `noexcept` and `constexpr` specifier have been added to several functions, th - Parser error messages are still very vague and contain no information on the error location. - The implemented `diff` function is rather primitive and does not create minimal diffs. - The name of function `iteration_wrapper` may change in the future and the function will be deprecated in the next release. -- Roundtripping (i.e., parsing a JSON value from a string, serializing it, and comparing the strings) of floating-point numbers is not 100% accurate. Note that [RFC 7159](https://tools.ietf.org/html/rfc7159) defines no format to internally represent numbers and states not requirement for roundtripping. Nevertheless, benchmarks like [Native JSON Benchmark](https://github.com/miloyip/nativejson-benchmark) treat roundtripping deviations as conformance errors. +- Roundtripping (i.e., parsing a JSON value from a string, serializing it, and comparing the strings) of floating-point numbers is not 100% accurate. Note that [RFC 8259](https://tools.ietf.org/html/rfc8259) defines no format to internally represent numbers and states not requirement for roundtripping. Nevertheless, benchmarks like [Native JSON Benchmark](https://github.com/miloyip/nativejson-benchmark) treat roundtripping deviations as conformance errors. ## v1.1.0 diff --git a/external_imported/json/docs/mkdocs/docs/home/sponsors.md b/external_imported/json/docs/mkdocs/docs/home/sponsors.md new file mode 100644 index 000000000..9097049d4 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/home/sponsors.md @@ -0,0 +1,13 @@ +# Sponsors + +You can sponsor this library at [GitHub Sponsors](https://github.com/sponsors/nlohmann). + +## Named Sponsors + +- [Michael Hartmann](https://github.com/reFX-Mike) +- [Stefan Hagen](https://github.com/sthagen) +- [Steve Sperandeo](https://github.com/homer6) +- [Robert Jefe Lindstädt](https://github.com/eljefedelrodeodeljefe) +- [Steve Wagner](https://github.com/ciroque) + +Thanks everyone! diff --git a/external_imported/json/doc/images/callback_events.png b/external_imported/json/docs/mkdocs/docs/images/callback_events.png similarity index 100% rename from external_imported/json/doc/images/callback_events.png rename to external_imported/json/docs/mkdocs/docs/images/callback_events.png diff --git a/external_imported/json/docs/mkdocs/docs/images/json_syntax_number.png b/external_imported/json/docs/mkdocs/docs/images/json_syntax_number.png new file mode 100644 index 000000000..be23ffa69 Binary files /dev/null and b/external_imported/json/docs/mkdocs/docs/images/json_syntax_number.png differ diff --git a/external_imported/json/doc/images/range-begin-end.svg b/external_imported/json/docs/mkdocs/docs/images/range-begin-end.svg similarity index 100% rename from external_imported/json/doc/images/range-begin-end.svg rename to external_imported/json/docs/mkdocs/docs/images/range-begin-end.svg diff --git a/external_imported/json/doc/images/range-rbegin-rend.svg b/external_imported/json/docs/mkdocs/docs/images/range-rbegin-rend.svg similarity index 100% rename from external_imported/json/doc/images/range-rbegin-rend.svg rename to external_imported/json/docs/mkdocs/docs/images/range-rbegin-rend.svg diff --git a/external_imported/json/docs/mkdocs/docs/index.md b/external_imported/json/docs/mkdocs/docs/index.md new file mode 100644 index 000000000..0e49c836c --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/index.md @@ -0,0 +1,3 @@ +# JSON for Modern C++ + +![](images/json.gif) diff --git a/external_imported/json/docs/mkdocs/docs/integration/cmake.md b/external_imported/json/docs/mkdocs/docs/integration/cmake.md new file mode 100644 index 000000000..545f53f30 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/integration/cmake.md @@ -0,0 +1,172 @@ +# CMake + +## Integration + +You can use the `nlohmann_json::nlohmann_json` interface target in CMake. This target populates the appropriate usage +requirements for [`INTERFACE_INCLUDE_DIRECTORIES`](https://cmake.org/cmake/help/latest/prop_tgt/INTERFACE_INCLUDE_DIRECTORIES.html) +to point to the appropriate include directories and [`INTERFACE_COMPILE_FEATURES`](https://cmake.org/cmake/help/latest/prop_tgt/INTERFACE_COMPILE_FEATURES.html) +for the necessary C++11 flags. + +### External + +To use this library from a CMake project, you can locate it directly with [`find_package()`](https://cmake.org/cmake/help/latest/command/find_package.html) +and use the namespaced imported target from the generated package configuration: + +!!! example + + ```cmake title="CMakeLists.txt" + cmake_minimum_required(VERSION 3.1) + project(ExampleProject LANGUAGES CXX) + + find_package(nlohmann_json 3.11.3 REQUIRED) + + add_executable(example example.cpp) + target_link_libraries(example PRIVATE nlohmann_json::nlohmann_json) + ``` + +The package configuration file, `nlohmann_jsonConfig.cmake`, can be used either from an install tree or directly out of +the build tree. + +### Embedded + +To embed the library directly into an existing CMake project, place the entire source tree in a subdirectory and call +`add_subdirectory()` in your `CMakeLists.txt` file. + +!!! example + + ```cmake title="CMakeLists.txt" + cmake_minimum_required(VERSION 3.1) + project(ExampleProject LANGUAGES CXX) + + # If you only include this third party in PRIVATE source files, you do not need to install it + # when your main project gets installed. + set(JSON_Install OFF CACHE INTERNAL "") + + add_subdirectory(nlohmann_json) + + add_executable(example example.cpp) + target_link_libraries(example PRIVATE nlohmann_json::nlohmann_json) + ``` + +!!! note + + Do not use `#!cmake include(nlohmann_json/CMakeLists.txt)`, since that carries with it unintended consequences that + will break the build. It is generally discouraged (although not necessarily well documented as such) to use + `#!cmake include(...)` for pulling in other CMake projects anyways. + + +### Supporting Both + +To allow your project to support either an externally supplied or an embedded JSON library, you can use a pattern akin +to the following. + +!!! example + + ```cmake title="CMakeLists.txt" + project(ExampleProject LANGUAGES CXX) + + option(EXAMPLE_USE_EXTERNAL_JSON "Use an external JSON library" OFF) + + add_subdirectory(thirdparty) + + add_executable(example example.cpp) + + # Note that the namespaced target will always be available regardless of the import method + target_link_libraries(example PRIVATE nlohmann_json::nlohmann_json) + ``` + + ```cmake title="thirdparty/CMakeLists.txt" + if(EXAMPLE_USE_EXTERNAL_JSON) + find_package(nlohmann_json 3.11.3 REQUIRED) + else() + set(JSON_BuildTests OFF CACHE INTERNAL "") + add_subdirectory(nlohmann_json) + endif() + ``` + + `thirdparty/nlohmann_json` is then a complete copy of this source tree. + + +### FetchContent + +Since CMake v3.11, [FetchContent](https://cmake.org/cmake/help/v3.11/module/FetchContent.html) can be used to +automatically download a release as a dependency at configure type. + +!!! example + + ```cmake title="CMakeLists.txt" + cmake_minimum_required(VERSION 3.11) + project(ExampleProject LANGUAGES CXX) + + include(FetchContent) + + FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz) + FetchContent_MakeAvailable(json) + + add_executable(example example.cpp) + target_link_libraries(example PRIVATE nlohmann_json::nlohmann_json) + ``` + +!!! Note + + It is recommended to use the URL approach described above which is supported as of version 3.10.0. It is also + possible to pass the Git repository like + + ```cmake + FetchContent_Declare(json + GIT_REPOSITORY https://github.com/nlohmann/json + GIT_TAG v3.11.3 + ) + ``` + + However, the repository download size is quite large. You might want to depend on + a smaller repository. For instance, you might want to replace the URL in the example by + . + +## CMake Options + +### `JSON_BuildTests` + +Build the unit tests when [`BUILD_TESTING`](https://cmake.org/cmake/help/latest/command/enable_testing.html) is enabled. This option is `ON` by default if the library's CMake project is the top project. That is, when integrating the library as described above, the test suite is not built unless explicitly switched on with this option. + +### `JSON_CI` + +Enable CI build targets. The exact targets are used during the several CI steps and are subject to change without notice. This option is `OFF` by default. + +### `JSON_Diagnostics` + +Enable [extended diagnostic messages](../home/exceptions.md#extended-diagnostic-messages) by defining macro [`JSON_DIAGNOSTICS`](../api/macros/json_diagnostics.md). This option is `OFF` by default. + +### `JSON_DisableEnumSerialization` + +Disable default `enum` serialization by defining the macro +[`JSON_DISABLE_ENUM_SERIALIZATION`](../api/macros/json_disable_enum_serialization.md). This option is `OFF` by default. + +### `JSON_FastTests` + +Skip expensive/slow test suites. This option is `OFF` by default. Depends on `JSON_BuildTests`. + +### `JSON_GlobalUDLs` + +Place user-defined string literals in the global namespace by defining the macro +[`JSON_USE_GLOBAL_UDLS`](../api/macros/json_use_global_udls.md). This option is `OFF` by default. + +### `JSON_ImplicitConversions` + +Enable implicit conversions by defining macro [`JSON_USE_IMPLICIT_CONVERSIONS`](../api/macros/json_use_implicit_conversions.md). This option is `ON` by default. + +### `JSON_Install` + +Install CMake targets during install step. This option is `ON` by default if the library's CMake project is the top project. + +### `JSON_MultipleHeaders` + +Use non-amalgamated version of the library. This option is `OFF` by default. + +### `JSON_SystemInclude` + +Treat the library headers like system headers (i.e., adding `SYSTEM` to the [`target_include_directories`](https://cmake.org/cmake/help/latest/command/target_include_directories.html) call) to checks for this library by tools like Clang-Tidy. This option is `OFF` by default. + +### `JSON_Valgrind` + +Execute test suite with [Valgrind](https://valgrind.org). This option is `OFF` by default. Depends on `JSON_BuildTests`. diff --git a/external_imported/json/doc/mkdocs/docs/integration/conan/CMakeLists.txt b/external_imported/json/docs/mkdocs/docs/integration/conan/CMakeLists.txt similarity index 100% rename from external_imported/json/doc/mkdocs/docs/integration/conan/CMakeLists.txt rename to external_imported/json/docs/mkdocs/docs/integration/conan/CMakeLists.txt diff --git a/external_imported/json/doc/mkdocs/docs/integration/conan/Conanfile.txt b/external_imported/json/docs/mkdocs/docs/integration/conan/Conanfile.txt similarity index 100% rename from external_imported/json/doc/mkdocs/docs/integration/conan/Conanfile.txt rename to external_imported/json/docs/mkdocs/docs/integration/conan/Conanfile.txt diff --git a/external_imported/json/doc/mkdocs/docs/integration/conan/example.cpp b/external_imported/json/docs/mkdocs/docs/integration/conan/example.cpp similarity index 100% rename from external_imported/json/doc/mkdocs/docs/integration/conan/example.cpp rename to external_imported/json/docs/mkdocs/docs/integration/conan/example.cpp diff --git a/external_imported/json/docs/mkdocs/docs/integration/example.cpp b/external_imported/json/docs/mkdocs/docs/integration/example.cpp new file mode 100644 index 000000000..1a7ac4de2 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/integration/example.cpp @@ -0,0 +1,10 @@ +#include +#include +#include + +using json = nlohmann::json; + +int main() +{ + std::cout << std::setw(4) << json::meta() << std::endl; +} diff --git a/external_imported/json/docs/mkdocs/docs/integration/index.md b/external_imported/json/docs/mkdocs/docs/integration/index.md new file mode 100644 index 000000000..2bbaa8604 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/integration/index.md @@ -0,0 +1,18 @@ +# Header only + +[`json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp) is the single required +file in `single_include/nlohmann` or [released here](https://github.com/nlohmann/json/releases). You need to add + +```cpp +#include + +// for convenience +using json = nlohmann::json; +``` + +to the files you want to process JSON and set the necessary switches to enable C++11 (e.g., `-std=c++11` for GCC and +Clang). + +You can further use file +[`single_include/nlohmann/json_fwd.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json_fwd.hpp) +for forward declarations. diff --git a/external_imported/json/docs/mkdocs/docs/integration/migration_guide.md b/external_imported/json/docs/mkdocs/docs/integration/migration_guide.md new file mode 100644 index 000000000..d250f5b20 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/integration/migration_guide.md @@ -0,0 +1,264 @@ +# Migration Guide + +This page collects some guidelines on how to future-proof your code for future versions of this library. + +## Replace deprecated functions + +The following functions have been deprecated and will be removed in the next major version (i.e., 4.0.0). All +deprecations are annotated with +[`HEDLEY_DEPRECATED_FOR`](https://nemequ.github.io/hedley/api-reference.html#HEDLEY_DEPRECATED_FOR) to report which +function to use instead. + +#### Parsing + +- Function `friend std::istream& operator<<(basic_json&, std::istream&)` is deprecated since 3.0.0. Please use + [`friend std::istream& operator>>(std::istream&, basic_json&)`](../api/operator_gtgt.md) instead. + + === "Deprecated" + + ```cpp + nlohmann::json j; + std::stringstream ss("[1,2,3]"); + j << ss; + ``` + + === "Future-proof" + + ```cpp + nlohmann::json j; + std::stringstream ss("[1,2,3]"); + ss >> j; + ``` + +- Passing iterator pairs or pointer/length pairs to parsing functions ([`parse`](../api/basic_json/parse.md), + [`accept`](../api/basic_json/accept.md), [`sax_parse`](../api/basic_json/sax_parse.md), + [`from_cbor`](../api/basic_json/from_cbor.md), [`from_msgpack`](../api/basic_json/from_msgpack.md), + [`from_ubjson`](../api/basic_json/from_ubjson.md), and [`from_bson`](../api/basic_json/from_bson.md) via initializer + lists is deprecated since 3.8.0. Instead, pass two iterators; for instance, call `from_cbor(ptr, ptr+len)` instead of + `from_cbor({ptr, len})`. + + === "Deprecated" + + ```cpp + const char* s = "[1,2,3]"; + bool ok = nlohmann::json::accept({s, s + std::strlen(s)}); + ``` + + === "Future-proof" + + ```cpp + const char* s = "[1,2,3]"; + bool ok = nlohmann::json::accept(s, s + std::strlen(s)); + ``` + +#### JSON Pointers + +- Comparing JSON Pointers with strings via [`operator==`](../api/json_pointer/operator_eq.md) and + [`operator!=`](../api/json_pointer/operator_ne.md) is deprecated since 3.11.2. To compare a + [`json_pointer`](../api/json_pointer/index.md) `p` with a string `s`, convert `s` to a `json_pointer` first and use + [`json_pointer::operator==`](../api/json_pointer/operator_eq.md) or + [`json_pointer::operator!=`](../api/json_pointer/operator_ne.md). + + === "Deprecated" + + ```cpp + nlohmann::json::json_pointer lhs("/foo/bar/1"); + assert(lhs == "/foo/bar/1"); + ``` + + === "Future-proof" + + ```cpp + nlohmann::json::json_pointer lhs("/foo/bar/1"); + assert(lhs == nlohmann::json::json_pointer("/foo/bar/1")); + ``` + +- The implicit conversion from JSON Pointers to string + ([`json_pointer::operator string_t`](../api/json_pointer/operator_string_t.md)) is deprecated since 3.11.0. Use + [`json_pointer::to_string`](../api/json_pointer/to_string.md) instead. + + === "Deprecated" + + ```cpp + nlohmann::json::json_pointer ptr("/foo/bar/1"); + std::string s = ptr; + ``` + + === "Future-proof" + + ```cpp + nlohmann::json::json_pointer ptr("/foo/bar/1"); + std::string s = ptr.to_string(); + ``` + +- Passing a `basic_json` specialization as template parameter `RefStringType` to + [`json_pointer`](../api/json_pointer/index.md) is deprecated since 3.11.0. The string type can now be directly + provided. + + === "Deprecated" + + ```cpp + using my_json = nlohmann::basic_json; + nlohmann::json_pointer ptr("/foo/bar/1"); + ``` + + === "Future-proof" + + ```cpp + nlohmann::json_pointer ptr("/foo/bar/1"); + ``` + + Thereby, `nlohmann::my_json::json_pointer` is an alias for `nlohmann::json_pointer` and is always an + alias to the `json_pointer` with the appropriate string type for all specializations of `basic_json`. + +#### Miscellaneous functions + +- The function `iterator_wrapper` is deprecated since 3.1.0. Please use the member function + [`items`](../api/basic_json/items.md) instead. + + === "Deprecated" + + ```cpp + for (auto &x : nlohmann::json::iterator_wrapper(j)) + { + std::cout << x.key() << ":" << x.value() << std::endl; + } + ``` + + === "Future-proof" + + ```cpp + for (auto &x : j.items()) + { + std::cout << x.key() << ":" << x.value() << std::endl; + } + ``` + +- Function `friend std::ostream& operator>>(const basic_json&, std::ostream&)` is deprecated since 3.0.0. Please use + [`friend operator<<(std::ostream&, const basic_json&)`](../api/operator_ltlt.md) instead. + + === "Deprecated" + + ```cpp + j >> std::cout; + ``` + + === "Future-proof" + + ```cpp + std::cout << j; + ``` + +- The legacy comparison behavior for discarded values is deprecated since 3.11.0. It is already disabled by default and + can still be enabled by defining + [`JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON`](../api/macros/json_use_legacy_discarded_value_comparison.md) to `1`. + + === "Deprecated" + + ```cpp + #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 1 + #include + ``` + + === "Future-proof" + + ```cpp + #include + ``` + +## Replace implicit conversions + +Implicit conversions via [`operator ValueType`](../api/basic_json/operator_ValueType.md) will be switched off by default +in the next major release of the library. + +You can prepare existing code by already defining +[`JSON_USE_IMPLICIT_CONVERSIONS`](../api/macros/json_use_implicit_conversions.md) to `0` and replace any implicit +conversions with calls to [`get`](../api/basic_json/get.md), [`get_to`](../api/basic_json/get_to.md), +[`get_ref`](../api/basic_json/get_ref.md), or [`get_ptr`](../api/basic_json/get_ptr.md). + +=== "Deprecated" + + ```cpp + nlohmann::json j = "Hello, world!"; + std::string s = j; + ``` + +=== "Future-proof" + + ```cpp + nlohmann::json j = "Hello, world!"; + auto s = j.template get(); + ``` + +=== "Future-proof (alternative)" + + ```cpp + nlohmann::json j = "Hello, world!"; + std::string s; + j.get_to(s); + ``` + +You can prepare existing code by already defining +[`JSON_USE_IMPLICIT_CONVERSIONS`](../api/macros/json_use_implicit_conversions.md) to `0` and replace any implicit +conversions with calls to [`get`](../api/basic_json/get.md). + +## Import namespace `literals` for UDLs + +The user-defined string literals [`operator""_json`](../api/operator_literal_json.md) and +[`operator""_json_pointer`](../api/operator_literal_json_pointer.md) will be removed from the global namespace in the +next major release of the library. + +=== "Deprecated" + + ```cpp + nlohmann::json j = "[1,2,3]"_json; + ``` + +=== "Future-proof" + + ```cpp + using namespace nlohmann::literals; + nlohmann::json j = "[1,2,3]"_json; + ``` + +To prepare existing code, define [`JSON_USE_GLOBAL_UDLS`](../api/macros/json_use_global_udls.md) to `0` and bring the +string literals into scope where needed. + +## Do not hard-code the complete library namespace + +The [`nlohmann` namespace](../features/namespace.md) contains a sub-namespace to avoid problems when different +versions or configurations of the library are used in the same project. Always use `nlohmann` as namespace or, when the +exact version and configuration is relevant, use macro +[`NLOHMANN_JSON_NAMESPACE`](../api/macros/nlohmann_json_namespace.md) to denote the namespace. + +=== "Dangerous" + + ```cpp + void to_json(nlohmann::json_abi_v3_11_2::json& j, const person& p) + { + j["age"] = p.age; + } + ``` + +=== "Future-proof" + + ```cpp + void to_json(nlohmann::json& j, const person& p) + { + j["age"] = p.age; + } + ``` + +=== "Future-proof (alternative)" + + ```cpp + void to_json(NLOHMANN_JSON_NAMESPACE::json& j, const person& p) + { + j["age"] = p.age; + } + ``` + +## Do not use the `details` namespace + +The `details` namespace is not part of the public API of the library and can change in any version without announcement. +Do not rely on any function or type in the `details` namespace. diff --git a/external_imported/json/docs/mkdocs/docs/integration/package_managers.md b/external_imported/json/docs/mkdocs/docs/integration/package_managers.md new file mode 100644 index 000000000..c9a273a50 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/integration/package_managers.md @@ -0,0 +1,198 @@ +# Package Managers + +Throughout this page, we will describe how to compile the example file `example.cpp` below. + +```cpp +--8<-- "integration/example.cpp" +``` + +When executed, this program should create output similar to + +```json +--8<-- "examples/meta.output" +``` + +## Homebrew + +If you are using OS X and [Homebrew](http://brew.sh), just type + +```sh +brew install nlohmann-json +``` + +and you're set. If you want the bleeding edge rather than the latest release, use + +```sh +brew install nlohmann-json --HEAD +``` + +instead. See [nlohmann-json](https://formulae.brew.sh/formula/nlohmann-json) for more information. + +??? example + + 1. Create the following file: + + ```cpp title="example.cpp" + --8<-- "integration/example.cpp" + ``` + + 2. Install the package + + ```sh + brew install nlohmann-json + ``` + + 3. Determine the include path, which defaults to `/usr/local/Cellar/nlohmann-json/$version/include`, where `$version` is the version of the library, e.g. `3.7.3`. The path of the library can be determined with + + ```sh + brew list nlohmann-json + ``` + + 4. Compile the code. For instance, the code can be compiled using Clang with + + ```sh + clang++ example.cpp -I/usr/local/Cellar/nlohmann-json/3.7.3/include -std=c++11 -o example + ``` + +:material-update: The [formula](https://formulae.brew.sh/formula/nlohmann-json) is updated automatically. + +## Meson + +If you are using the [Meson Build System](http://mesonbuild.com), add this source tree as a [meson subproject](https://mesonbuild.com/Subprojects.html#using-a-subproject). You may also use the `include.zip` published in this project's [Releases](https://github.com/nlohmann/json/releases) to reduce the size of the vendored source tree. Alternatively, you can get a wrap file by downloading it from [Meson WrapDB](https://wrapdb.mesonbuild.com/nlohmann_json), or simply use `meson wrap install nlohmann_json`. Please see the meson project for any issues regarding the packaging. + +The provided `meson.build` can also be used as an alternative to cmake for installing `nlohmann_json` system-wide in which case a pkg-config file is installed. To use it, simply have your build system require the `nlohmann_json` pkg-config dependency. In Meson, it is preferred to use the [`dependency()`](https://mesonbuild.com/Reference-manual.html#dependency) object with a subproject fallback, rather than using the subproject directly. + +## Bazel + +This repository provides a [Bazel](https://bazel.build/) `WORKSPACE.bazel` and a corresponding `BUILD.bazel` file. Therefore, this repository can be referenced by workspace rules such as `http_archive`, `git_repository`, or `local_repository` from other Bazel workspaces. To use the library you only need to depend on the target `@nlohmann_json//:json` (e.g. via `deps` attribute). + +## Conan + +If you are using [Conan](https://www.conan.io/) to manage your dependencies, merely add `nlohmann_json/x.y.z` to your `conanfile`'s requires, where `x.y.z` is the release version you want to use. Please file issues [here](https://github.com/conan-io/conan-center-index/issues) if you experience problems with the packages. + +??? example + + 1. Create the following files: + + ```ini title="Conanfile.txt" + --8<-- "integration/conan/Conanfile.txt" + ``` + + ```cmake title="CMakeLists.txt" + --8<-- "integration/conan/CMakeLists.txt" + ``` + + ```cpp title="example.cpp" + --8<-- "integration/conan/example.cpp" + ``` + + 2. Build: + + ```sh + mkdir build + cd build + conan install .. + cmake .. + cmake --build . + ``` + +:material-update: The [package](https://conan.io/center/nlohmann_json) is updated automatically. + +## Spack + +If you are using [Spack](https://www.spack.io/) to manage your dependencies, you can use the [`nlohmann-json` package](https://spack.readthedocs.io/en/latest/package_list.html#nlohmann-json). Please see the [spack project](https://github.com/spack/spack) for any issues regarding the packaging. + +## Hunter + +If you are using [hunter](https://github.com/cpp-pm/hunter) on your project for external dependencies, then you can use the [nlohmann_json package](https://hunter.readthedocs.io/en/latest/packages/pkg/nlohmann_json.html). Please see the hunter project for any issues regarding the packaging. + +## Buckaroo + +If you are using [Buckaroo](https://buckaroo.pm), you can install this library's module with `buckaroo add github.com/buckaroo-pm/nlohmann-json`. Please file issues [here](https://github.com/buckaroo-pm/nlohmann-json). There is a demo repo [here](https://github.com/njlr/buckaroo-nholmann-json-example). + +## vcpkg + +If you are using [vcpkg](https://github.com/Microsoft/vcpkg/) on your project for external dependencies, then you can install the [nlohmann-json package](https://github.com/Microsoft/vcpkg/tree/master/ports/nlohmann-json) with `vcpkg install nlohmann-json` and follow the then displayed descriptions. Please see the vcpkg project for any issues regarding the packaging. + +??? example + + 1. Create the following files: + + ```cmake title="CMakeLists.txt" + --8<-- "integration/vcpkg/CMakeLists.txt" + ``` + + ```cpp title="example.cpp" + --8<-- "integration/vcpkg/example.cpp" + ``` + + 2. Install package: + + ```sh + vcpkg install nlohmann-json + ``` + + 3. Build: + + ```sh + mkdir build + cd build + cmake .. -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake + cmake --build . + ``` + + Note you need to adjust `/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake` to your system. + +## cget + +If you are using [cget](http://cget.readthedocs.io/en/latest/), you can install the latest development version with `cget install nlohmann/json`. A specific version can be installed with `cget install nlohmann/json@v3.1.0`. Also, the multiple header version can be installed by adding the `-DJSON_MultipleHeaders=ON` flag (i.e., `cget install nlohmann/json -DJSON_MultipleHeaders=ON`). + +:material-update: cget reads directly from the [GitHub repository](https://github.com/nlohmann/json) and is always up-to-date. + +## CocoaPods + +If you are using [CocoaPods](https://cocoapods.org), you can use the library by adding pod `"nlohmann_json", '~>3.1.2'` to your podfile (see [an example](https://bitbucket.org/benman/nlohmann_json-cocoapod/src/master/)). Please file issues [here](https://bitbucket.org/benman/nlohmann_json-cocoapod/issues?status=new&status=open). + +## NuGet + +If you are using [NuGet](https://www.nuget.org), you can use the package [nlohmann.json](https://www.nuget.org/packages/nlohmann.json/). Please check [this extensive description](https://github.com/nlohmann/json/issues/1132#issuecomment-452250255) on how to use the package. Please file issues [here](https://github.com/hnkb/nlohmann-json-nuget/issues). + +## Conda + +If you are using [conda](https://conda.io/), you can use the package [nlohmann_json](https://github.com/conda-forge/nlohmann_json-feedstock) from [conda-forge](https://conda-forge.org) executing `conda install -c conda-forge nlohmann_json`. Please file issues [here](https://github.com/conda-forge/nlohmann_json-feedstock/issues). + +## MSYS2 + +If you are using [MSYS2](http://www.msys2.org/), you can use the [mingw-w64-nlohmann-json](https://packages.msys2.org/base/mingw-w64-nlohmann-json) package, just type `pacman -S mingw-w64-i686-nlohmann-json` or `pacman -S mingw-w64-x86_64-nlohmann-json` for installation. Please file issues [here](https://github.com/msys2/MINGW-packages/issues/new?title=%5Bnlohmann-json%5D) if you experience problems with the packages. + +:material-update: The [package](https://packages.msys2.org/base/mingw-w64-nlohmann-json) is updated automatically. + +## MacPorts + +If you are using [MacPorts](https://ports.macports.org), execute `sudo port install nlohmann-json` to install the [nlohmann-json](https://ports.macports.org/port/nlohmann-json/) package. + +:material-update: The [package](https://ports.macports.org/port/nlohmann-json/) is updated automatically. + +## build2 + +If you are using [`build2`](https://build2.org), you can use the [`nlohmann-json`](https://cppget.org/nlohmann-json) package from the public repository or directly from the [package's sources repository](https://github.com/build2-packaging/nlohmann-json). In your project's `manifest` file, just add `depends: nlohmann-json` (probably with some [version constraints](https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml#guide-add-remove-deps)). If you are not familiar with using dependencies in `build2`, [please read this introduction](https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml). +Please file issues [here](https://github.com/build2-packaging/nlohmann-json) if you experience problems with the packages. + +:material-update: The [package](https://cppget.org/nlohmann-json) is updated automatically. + +## wsjcpp + +If you are using [`wsjcpp`](http://wsjcpp.org), you can use the command `wsjcpp install "https://github.com/nlohmann/json:develop"` to get the latest version. Note you can change the branch ":develop" to an existing tag or another branch. + +:material-update: wsjcpp reads directly from the [GitHub repository](https://github.com/nlohmann/json) and is always up-to-date. + +## CPM.cmake + +If you are using [`CPM.cmake`](https://github.com/TheLartians/CPM.cmake), you can check this [`example`](https://github.com/TheLartians/CPM.cmake/tree/master/examples/json). After [adding CPM script](https://github.com/TheLartians/CPM.cmake#adding-cpm) to your project, implement the following snippet to your CMake: + +```cmake +CPMAddPackage( + NAME nlohmann_json + GITHUB_REPOSITORY nlohmann/json + VERSION 3.9.1) +``` diff --git a/external_imported/json/docs/mkdocs/docs/integration/pkg-config.md b/external_imported/json/docs/mkdocs/docs/integration/pkg-config.md new file mode 100644 index 000000000..429d0dea9 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/integration/pkg-config.md @@ -0,0 +1,13 @@ +# Pkg-config + +If you are using bare Makefiles, you can use `pkg-config` to generate the include flags that point to where the library is installed: + +```sh +pkg-config nlohmann_json --cflags +``` + +Users of the [Meson build system](package_managers.md#meson) will also be able to use a system-wide library, which will be found by `pkg-config`: + +```meson +json = dependency('nlohmann_json', required: true) +``` diff --git a/external_imported/json/docs/mkdocs/docs/integration/vcpkg/CMakeLists.txt b/external_imported/json/docs/mkdocs/docs/integration/vcpkg/CMakeLists.txt new file mode 100644 index 000000000..d31f4e835 --- /dev/null +++ b/external_imported/json/docs/mkdocs/docs/integration/vcpkg/CMakeLists.txt @@ -0,0 +1,7 @@ +project(json_example) +cmake_minimum_required(VERSION 2.8.12) + +find_package(nlohmann_json CONFIG REQUIRED) + +add_executable(json_example example.cpp) +target_link_libraries(json_example PRIVATE nlohmann_json::nlohmann_json) diff --git a/external_imported/json/doc/mkdocs/docs/integration/example.cpp b/external_imported/json/docs/mkdocs/docs/integration/vcpkg/example.cpp similarity index 100% rename from external_imported/json/doc/mkdocs/docs/integration/example.cpp rename to external_imported/json/docs/mkdocs/docs/integration/vcpkg/example.cpp diff --git a/external_imported/json/docs/mkdocs/mkdocs.yml b/external_imported/json/docs/mkdocs/mkdocs.yml new file mode 100644 index 000000000..5e66db596 --- /dev/null +++ b/external_imported/json/docs/mkdocs/mkdocs.yml @@ -0,0 +1,366 @@ +# Project information +site_name: JSON for Modern C++ +site_author: Niels Lohmann +site_url: https://json.nlohmann.me/ + +# Repository +repo_name: nlohmann/json +repo_url: https://github.com/nlohmann/json +edit_uri: edit/develop/docs/mkdocs/docs + +# Copyright +copyright: Copyright © 2013 - 2023 Niels Lohmann + +# Configuration +theme: + name: material + language: en + palette: + - media: '(prefers-color-scheme: light)' + scheme: default + primary: indigo + accent: indigo + toggle: + icon: material/brightness-7 + name: Switch to dark mode + - media: '(prefers-color-scheme: dark)' + scheme: slate + primary: indigo + accent: indigo + toggle: + icon: material/brightness-4 + name: Switch to light mode + + font: + text: Roboto + code: JetBrains Mono + features: + - navigation.instant + - navigation.tracking + - navigation.tabs + - navigation.indexes + - navigation.top + - content.tabs.link + +nav: + - Home: + - index.md + - home/license.md + - "Code of Conduct": home/code_of_conduct.md + - "FAQ": home/faq.md + - home/exceptions.md + - home/releases.md + - home/design_goals.md + - home/sponsors.md + - Features: + - features/arbitrary_types.md + - Binary Formats: + - features/binary_formats/index.md + - features/binary_formats/bjdata.md + - features/binary_formats/bson.md + - features/binary_formats/cbor.md + - features/binary_formats/messagepack.md + - features/binary_formats/ubjson.md + - features/binary_values.md + - features/comments.md + - Element Access: + - features/element_access/index.md + - features/element_access/unchecked_access.md + - features/element_access/checked_access.md + - features/element_access/default_value.md + - features/iterators.md + - features/json_pointer.md + - features/json_patch.md + - features/merge_patch.md + - 'nlohmann Namespace': features/namespace.md + - features/object_order.md + - Parsing: + - features/parsing/index.md + - features/parsing/json_lines.md + - features/parsing/parse_exceptions.md + - features/parsing/parser_callbacks.md + - features/parsing/sax_interface.md + - features/assertions.md + - features/enum_conversion.md + - features/macros.md + - Types: + - features/types/index.md + - features/types/number_handling.md + - Integration: + - integration/index.md + - integration/migration_guide.md + - integration/cmake.md + - integration/package_managers.md + - integration/pkg-config.md + - API Documentation: + - basic_json: + - 'Overview': api/basic_json/index.md + - '(Constructor)': api/basic_json/basic_json.md + - '(Destructor)': api/basic_json/~basic_json.md + - 'accept': api/basic_json/accept.md + - 'array': api/basic_json/array.md + - 'array_t': api/basic_json/array_t.md + - 'at': api/basic_json/at.md + - 'back': api/basic_json/back.md + - 'begin': api/basic_json/begin.md + - 'binary': api/basic_json/binary.md + - 'binary_t': api/basic_json/binary_t.md + - 'boolean_t': api/basic_json/boolean_t.md + - 'cbegin': api/basic_json/cbegin.md + - 'cbor_tag_handler_t': api/basic_json/cbor_tag_handler_t.md + - 'cend': api/basic_json/cend.md + - 'clear': api/basic_json/clear.md + - 'contains': api/basic_json/contains.md + - 'count': api/basic_json/count.md + - 'crbegin': api/basic_json/crbegin.md + - 'crend': api/basic_json/crend.md + - 'default_object_comparator_t': api/basic_json/default_object_comparator_t.md + - 'diff': api/basic_json/diff.md + - 'dump': api/basic_json/dump.md + - 'emplace': api/basic_json/emplace.md + - 'emplace_back': api/basic_json/emplace_back.md + - 'empty': api/basic_json/empty.md + - 'end': api/basic_json/end.md + - 'erase': api/basic_json/erase.md + - 'error_handler_t': api/basic_json/error_handler_t.md + - 'exception': api/basic_json/exception.md + - 'find': api/basic_json/find.md + - 'flatten': api/basic_json/flatten.md + - 'from_bjdata': api/basic_json/from_bjdata.md + - 'from_bson': api/basic_json/from_bson.md + - 'from_cbor': api/basic_json/from_cbor.md + - 'from_msgpack': api/basic_json/from_msgpack.md + - 'from_ubjson': api/basic_json/from_ubjson.md + - 'front': api/basic_json/front.md + - 'get': api/basic_json/get.md + - 'get_allocator': api/basic_json/get_allocator.md + - 'get_binary': api/basic_json/get_binary.md + - 'get_ptr': api/basic_json/get_ptr.md + - 'get_ref': api/basic_json/get_ref.md + - 'get_to': api/basic_json/get_to.md + - 'std::hash<basic_json>': api/basic_json/std_hash.md + - 'input_format_t': api/basic_json/input_format_t.md + - 'insert': api/basic_json/insert.md + - 'invalid_iterator': api/basic_json/invalid_iterator.md + - 'is_array': api/basic_json/is_array.md + - 'is_binary': api/basic_json/is_binary.md + - 'is_boolean': api/basic_json/is_boolean.md + - 'is_discarded': api/basic_json/is_discarded.md + - 'is_null': api/basic_json/is_null.md + - 'is_number': api/basic_json/is_number.md + - 'is_number_float': api/basic_json/is_number_float.md + - 'is_number_integer': api/basic_json/is_number_integer.md + - 'is_number_unsigned': api/basic_json/is_number_unsigned.md + - 'is_object': api/basic_json/is_object.md + - 'is_primitive': api/basic_json/is_primitive.md + - 'is_string': api/basic_json/is_string.md + - 'is_structured': api/basic_json/is_structured.md + - 'items': api/basic_json/items.md + - 'json_base_class_t': api/basic_json/json_base_class_t.md + - 'json_serializer': api/basic_json/json_serializer.md + - 'max_size': api/basic_json/max_size.md + - 'meta': api/basic_json/meta.md + - 'merge_patch': api/basic_json/merge_patch.md + - 'number_float_t': api/basic_json/number_float_t.md + - 'number_integer_t': api/basic_json/number_integer_t.md + - 'number_unsigned_t': api/basic_json/number_unsigned_t.md + - 'object': api/basic_json/object.md + - 'object_comparator_t': api/basic_json/object_comparator_t.md + - 'object_t': api/basic_json/object_t.md + - 'operator ValueType': api/basic_json/operator_ValueType.md + - 'operator value_t': api/basic_json/operator_value_t.md + - 'operator[]': api/basic_json/operator[].md + - 'operator=': api/basic_json/operator=.md + - 'operator+=': api/basic_json/operator+=.md + - 'operator==': api/basic_json/operator_eq.md + - 'operator!=': api/basic_json/operator_ne.md + - 'operator<': api/basic_json/operator_lt.md + - 'operator>': api/basic_json/operator_gt.md + - 'operator<=': api/basic_json/operator_le.md + - 'operator>=': api/basic_json/operator_ge.md + - 'operator<=>': api/basic_json/operator_spaceship.md + - 'out_of_range': api/basic_json/out_of_range.md + - 'other_error': api/basic_json/other_error.md + - 'parse': api/basic_json/parse.md + - 'parse_error': api/basic_json/parse_error.md + - 'parse_event_t': api/basic_json/parse_event_t.md + - 'parser_callback_t': api/basic_json/parser_callback_t.md + - 'patch': api/basic_json/patch.md + - 'patch_inplace': api/basic_json/patch_inplace.md + - 'push_back': api/basic_json/push_back.md + - 'rbegin': api/basic_json/rbegin.md + - 'rend': api/basic_json/rend.md + - 'sax_parse': api/basic_json/sax_parse.md + - 'size': api/basic_json/size.md + - 'string_t': api/basic_json/string_t.md + - 'swap': api/basic_json/swap.md + - 'std::swap<basic_json>': api/basic_json/std_swap.md + - 'to_bjdata': api/basic_json/to_bjdata.md + - 'to_bson': api/basic_json/to_bson.md + - 'to_cbor': api/basic_json/to_cbor.md + - 'to_msgpack': api/basic_json/to_msgpack.md + - 'to_string': api/basic_json/to_string.md + - 'to_ubjson': api/basic_json/to_ubjson.md + - 'type': api/basic_json/type.md + - 'type_error': api/basic_json/type_error.md + - 'type_name': api/basic_json/type_name.md + - 'unflatten': api/basic_json/unflatten.md + - 'update': api/basic_json/update.md + - 'value': api/basic_json/value.md + - 'value_t': api/basic_json/value_t.md + - byte_container_with_subtype: + - 'Overview': api/byte_container_with_subtype/index.md + - '(constructor)': api/byte_container_with_subtype/byte_container_with_subtype.md + - 'clear_subtype': api/byte_container_with_subtype/clear_subtype.md + - 'has_subtype': api/byte_container_with_subtype/has_subtype.md + - 'set_subtype': api/byte_container_with_subtype/set_subtype.md + - 'subtype': api/byte_container_with_subtype/subtype.md + - adl_serializer: + - 'Overview': api/adl_serializer/index.md + - 'from_json': api/adl_serializer/from_json.md + - 'to_json': api/adl_serializer/to_json.md + - 'json': api/json.md + - json_pointer: + - 'Overview': api/json_pointer/index.md + - '(Constructor)': api/json_pointer/json_pointer.md + - 'back': api/json_pointer/back.md + - 'empty': api/json_pointer/empty.md + - 'operator string_t': api/json_pointer/operator_string_t.md + - 'operator==': api/json_pointer/operator_eq.md + - 'operator!=': api/json_pointer/operator_ne.md + - 'operator/': api/json_pointer/operator_slash.md + - 'operator/=': api/json_pointer/operator_slasheq.md + - 'parent_pointer': api/json_pointer/parent_pointer.md + - 'pop_back': api/json_pointer/pop_back.md + - 'push_back': api/json_pointer/push_back.md + - 'string_t': api/json_pointer/string_t.md + - 'to_string': api/json_pointer/to_string.md + - json_sax: + - 'Overview': api/json_sax/index.md + - 'binary': api/json_sax/binary.md + - 'boolean': api/json_sax/boolean.md + - 'end_array': api/json_sax/end_array.md + - 'end_object': api/json_sax/end_object.md + - 'key': api/json_sax/key.md + - 'null': api/json_sax/null.md + - 'number_float': api/json_sax/number_float.md + - 'number_integer': api/json_sax/number_integer.md + - 'number_unsigned': api/json_sax/number_unsigned.md + - 'parse_error': api/json_sax/parse_error.md + - 'start_array': api/json_sax/start_array.md + - 'start_object': api/json_sax/start_object.md + - 'string': api/json_sax/string.md + - 'operator<<(basic_json)': api/operator_ltlt.md + - 'operator<<(json_pointer)': api/operator_ltlt.md + - 'operator>>(basic_json)': api/operator_gtgt.md + - 'operator""_json': api/operator_literal_json.md + - 'operator""_json_pointer': api/operator_literal_json_pointer.md + - 'ordered_json': api/ordered_json.md + - 'ordered_map': api/ordered_map.md + - macros: + - 'Overview': api/macros/index.md + - 'JSON_ASSERT': api/macros/json_assert.md + - 'JSON_CATCH_USER': api/macros/json_throw_user.md + - 'JSON_DIAGNOSTICS': api/macros/json_diagnostics.md + - 'JSON_DISABLE_ENUM_SERIALIZATION': api/macros/json_disable_enum_serialization.md + - 'JSON_HAS_CPP_11': api/macros/json_has_cpp_11.md + - 'JSON_HAS_CPP_14': api/macros/json_has_cpp_11.md + - 'JSON_HAS_CPP_17': api/macros/json_has_cpp_11.md + - 'JSON_HAS_CPP_20': api/macros/json_has_cpp_11.md + - 'JSON_HAS_EXPERIMENTAL_FILESYSTEM': api/macros/json_has_filesystem.md + - 'JSON_HAS_FILESYSTEM': api/macros/json_has_filesystem.md + - 'JSON_HAS_RANGES': api/macros/json_has_ranges.md + - 'JSON_HAS_STATIC_RTTI': api/macros/json_has_static_rtti.md + - 'JSON_HAS_THREE_WAY_COMPARISON': api/macros/json_has_three_way_comparison.md + - 'JSON_NOEXCEPTION': api/macros/json_noexception.md + - 'JSON_NO_IO': api/macros/json_no_io.md + - 'JSON_SKIP_LIBRARY_VERSION_CHECK': api/macros/json_skip_library_version_check.md + - 'JSON_SKIP_UNSUPPORTED_COMPILER_CHECK': api/macros/json_skip_unsupported_compiler_check.md + - 'JSON_THROW_USER': api/macros/json_throw_user.md + - 'JSON_TRY_USER': api/macros/json_throw_user.md + - 'JSON_USE_GLOBAL_UDLS': api/macros/json_use_global_udls.md + - 'JSON_USE_IMPLICIT_CONVERSIONS': api/macros/json_use_implicit_conversions.md + - 'JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON': api/macros/json_use_legacy_discarded_value_comparison.md + - 'NLOHMANN_DEFINE_TYPE_INTRUSIVE': api/macros/nlohmann_define_type_intrusive.md + - 'NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT': api/macros/nlohmann_define_type_intrusive.md + - 'NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE': api/macros/nlohmann_define_type_non_intrusive.md + - 'NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT': api/macros/nlohmann_define_type_non_intrusive.md + - 'NLOHMANN_JSON_NAMESPACE': api/macros/nlohmann_json_namespace.md + - 'NLOHMANN_JSON_NAMESPACE_BEGIN': api/macros/nlohmann_json_namespace_begin.md + - 'NLOHMANN_JSON_NAMESPACE_END': api/macros/nlohmann_json_namespace_begin.md + - 'NLOHMANN_JSON_NAMESPACE_NO_VERSION': api/macros/nlohmann_json_namespace_no_version.md + - 'NLOHMANN_JSON_SERIALIZE_ENUM': api/macros/nlohmann_json_serialize_enum.md + - 'NLOHMANN_JSON_VERSION_MAJOR': api/macros/nlohmann_json_version_major.md + - 'NLOHMANN_JSON_VERSION_MINOR': api/macros/nlohmann_json_version_major.md + - 'NLOHMANN_JSON_VERSION_PATCH': api/macros/nlohmann_json_version_major.md + +# Extras +extra: + social: + - icon: fontawesome/brands/github + link: https://github.com/nlohmann + - icon: fontawesome/brands/twitter + link: https://twitter.com/nlohmann + - icon: fontawesome/brands/linkedin + link: https://www.linkedin.com/in/nielslohmann/ + - icon: fontawesome/brands/xing + link: https://www.xing.com/profile/Niels_Lohmann + - icon: fontawesome/brands/paypal + link: https://www.paypal.me/nlohmann + generator: false + +# Extensions +markdown_extensions: + - abbr + - admonition + - attr_list + - def_list + - codehilite: + guess_lang: false + - toc: + permalink: true + - pymdownx.arithmatex + - pymdownx.betterem: + smart_enable: all + - pymdownx.caret + - pymdownx.critic + - pymdownx.details + - pymdownx.emoji: + emoji_index: !!python/name:material.extensions.emoji.twemoji + emoji_generator: !!python/name:material.extensions.emoji.to_svg + - pymdownx.inlinehilite + - pymdownx.magiclink + - pymdownx.mark + #- pymdownx.smartsymbols + - pymdownx.superfences + - pymdownx.tasklist: + custom_checkbox: true + - pymdownx.tabbed: + alternate_style: true + - pymdownx.tilde + - pymdownx.snippets: + base_path: docs + check_paths: true + - plantuml_markdown: + format: svg + +plugins: + - search: + separator: '[\s\-\.]' + lang: en + - minify: + minify_html: true + - git-revision-date-localized + - redirects: + redirect_maps: + 'api/basic_json/operator_gtgt.md': api/operator_gtgt.md + 'api/basic_json/operator_ltlt.md': api/operator_ltlt.md + 'api/basic_json/operator_literal_json.md': api/operator_literal_json.md + 'api/basic_json/operator_literal_json_pointer.md': api/operator_literal_json_pointer.md + 'api/json_pointer/operator_string.md': api/json_pointer/operator_string_t.md + +extra_css: + - css/custom.css + +extra_javascript: + - https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML diff --git a/external_imported/json/docs/mkdocs/requirements.txt b/external_imported/json/docs/mkdocs/requirements.txt new file mode 100644 index 000000000..b397d545d --- /dev/null +++ b/external_imported/json/docs/mkdocs/requirements.txt @@ -0,0 +1,49 @@ +Babel==2.13.1 +certifi==2023.7.22 +charset-normalizer==3.3.1 +click==8.1.7 +csscompressor==0.9.5 +future==0.18.3 +ghp-import==2.1.0 +gitdb==4.0.11 +GitPython==3.1.40 +htmlmin==0.1.12 +httplib2==0.22.0 +idna==3.4 +importlib-metadata==6.8.0 +Jinja2==3.1.2 +joblib==1.3.2 +jsmin==3.0.1 +livereload==2.6.3 +lunr==0.7.0.post1 +Markdown==3.5 +markdown-include==0.8.1 +MarkupSafe==2.1.3 +mergedeep==1.3.4 +mkdocs==1.5.3 +mkdocs-git-revision-date-localized-plugin==1.2.1 +mkdocs-material==9.4.7 +mkdocs-material-extensions==1.3 +mkdocs-minify-plugin==0.7.1 +mkdocs-redirects==1.2.1 +mkdocs-simple-hooks==0.1.5 +nltk==3.8.1 +packaging==23.2 +plantuml==0.3.0 +plantuml-markdown==3.9.2 +Pygments==2.16.1 +pymdown-extensions==10.3.1 +pyparsing==3.1.1 +python-dateutil==2.8.2 +pytz==2023.3.post1 +PyYAML==6.0.1 +pyyaml_env_tag==0.1 +regex==2023.10.3 +requests==2.31.0 +six==1.16.0 +smmap==5.0.1 +tornado==6.3.3 +tqdm==4.66.1 +urllib3==2.0.7 +watchdog==3.0.0 +zipp==3.17.0 diff --git a/external_imported/json/docs/mkdocs/scripts/check_structure.py b/external_imported/json/docs/mkdocs/scripts/check_structure.py new file mode 100755 index 000000000..643482af2 --- /dev/null +++ b/external_imported/json/docs/mkdocs/scripts/check_structure.py @@ -0,0 +1,179 @@ +#!/usr/bin/env python + +import glob +import os.path +import re +import sys + +warnings = 0 + + +def report(rule, location, description): + global warnings + warnings += 1 + print(f'{warnings:3}. {location}: {description} [{rule}]') + + +def check_structure(): + expected_sections = [ + 'Template parameters', + 'Specializations', + 'Iterator invalidation', + 'Requirements', + 'Member types', + 'Member functions', + 'Member variables', + 'Static functions', + 'Non-member functions', + 'Literals', + 'Helper classes', + 'Parameters', + 'Return value', + 'Exception safety', + 'Exceptions', + 'Complexity', + 'Possible implementation', + 'Default definition', + 'Notes', + 'Examples', + 'See also', + 'Version history' + ] + + required_sections = [ + 'Examples', + 'Version history' + ] + + files = sorted(glob.glob('api/**/*.md', recursive=True)) + for file in files: + with open(file) as file_content: + section_idx = -1 # the index of the current h2 section + existing_sections = [] # the list of h2 sections in the file + in_initial_code_example = False # whether we are inside the first code example block + previous_line = None # the previous read line + h1sections = 0 # the number of h1 sections in the file + last_overload = 0 # the last seen overload number in the code example + documented_overloads = {} # the overloads that have been documented in the current block + current_section = None # the name of the current section + + for lineno, original_line in enumerate(file_content.readlines()): + line = original_line.strip() + + if line.startswith('# '): + h1sections += 1 + + # there should only be one top-level title + if h1sections > 1: + report('structure/unexpected_section', f'{file}:{lineno+1}', f'unexpected top-level title "{line}"') + h1sections = 1 + + # Overview pages should have a better title + if line == '# Overview': + report('style/title', f'{file}:{lineno+1}', 'overview pages should have a better title than "Overview"') + + # lines longer than 160 characters are bad (unless they are tables) + if len(line) > 160 and '|' not in line: + report('whitespace/line_length', f'{file}:{lineno+1} ({current_section})', f'line is too long ({len(line)} vs. 160 chars)') + + # sections in `` comments are treated as present + if line.startswith('') + existing_sections.append(current_section) + + # check if sections are correct + if line.startswith('## '): + # before starting a new section, check if the previous one documented all overloads + if current_section in documented_overloads and last_overload != 0: + if len(documented_overloads[current_section]) > 0 and len(documented_overloads[current_section]) != last_overload: + expected = list(range(1, last_overload+1)) + undocumented = [x for x in expected if x not in documented_overloads[current_section]] + unexpected = [x for x in documented_overloads[current_section] if x not in expected] + if len(undocumented): + report('style/numbering', f'{file}:{lineno} ({current_section})', f'undocumented overloads: {", ".join([f"({x})" for x in undocumented])}') + if len(unexpected): + report('style/numbering', f'{file}:{lineno} ({current_section})', f'unexpected overloads: {", ".join([f"({x})" for x in unexpected])}') + + current_section = line.strip('## ') + existing_sections.append(current_section) + + if current_section in expected_sections: + idx = expected_sections.index(current_section) + if idx <= section_idx: + report('structure/section_order', f'{file}:{lineno+1}', f'section "{current_section}" is in an unexpected order (should be before "{expected_sections[section_idx]}")') + section_idx = idx + else: + if 'index.md' not in file: # index.md files may have a different structure + report('structure/unknown_section', f'{file}:{lineno+1}', f'section "{current_section}" is not part of the expected sections') + + # collect the numbered items of the current section to later check if they match the number of overloads + if last_overload != 0 and not in_initial_code_example: + if len(original_line) and original_line[0].isdigit(): + number = int(re.findall(r"^(\d+).", original_line)[0]) + if current_section not in documented_overloads: + documented_overloads[current_section] = [] + documented_overloads[current_section].append(number) + + # code example + if line == '```cpp' and section_idx == -1: + in_initial_code_example = True + + if in_initial_code_example and line.startswith('//') and line not in ['// since C++20', '// until C++20']: + # check numbering of overloads + if any(map(str.isdigit, line)): + number = int(re.findall(r'\d+', line)[0]) + if number != last_overload + 1: + report('style/numbering', f'{file}:{lineno+1}', f'expected number ({number}) to be ({last_overload +1 })') + last_overload = number + + if any(map(str.isdigit, line)) and '(' not in line: + report('style/numbering', f'{file}:{lineno+1}', f'number should be in parentheses: {line}') + + if line == '```' and in_initial_code_example: + in_initial_code_example = False + + # consecutive blank lines are bad + if line == '' and previous_line == '': + report('whitespace/blank_lines', f'{file}:{lineno}-{lineno+1} ({current_section})', 'consecutive blank lines') + + # check that non-example admonitions have titles + untitled_admonition = re.match(r'^(\?\?\?|!!!) ([^ ]+)$', line) + if untitled_admonition and untitled_admonition.group(2) != 'example': + report('style/admonition_title', f'{file}:{lineno} ({current_section})', f'"{untitled_admonition.group(2)}" admonitions should have a title') + + previous_line = line + + if 'index.md' not in file: # index.md files may have a different structure + for required_section in required_sections: + if required_section not in existing_sections: + report('structure/missing_section', f'{file}:{lineno+1}', f'required section "{required_section}" was not found') + + +def check_examples(): + example_files = sorted(glob.glob('../../examples/*.cpp')) + markdown_files = sorted(glob.glob('**/*.md', recursive=True)) + + # check if every example file is used in at least one markdown file + for example_file in example_files: + example_file = os.path.join('examples', os.path.basename(example_file)) + + found = False + for markdown_file in markdown_files: + content = ' '.join(open(markdown_file).readlines()) + if example_file in content: + found = True + break + + if not found: + report('examples/missing', f'{example_file}', 'example file is not used in any documentation file') + + +if __name__ == '__main__': + print(120 * '-') + check_structure() + check_examples() + print(120 * '-') + + if warnings > 0: + sys.exit(1) diff --git a/external_imported/json/doc/usages/ios.png b/external_imported/json/docs/usages/ios.png similarity index 100% rename from external_imported/json/doc/usages/ios.png rename to external_imported/json/docs/usages/ios.png diff --git a/external_imported/json/doc/usages/macos.png b/external_imported/json/docs/usages/macos.png similarity index 100% rename from external_imported/json/doc/usages/macos.png rename to external_imported/json/docs/usages/macos.png diff --git a/external_imported/json/include/nlohmann/adl_serializer.hpp b/external_imported/json/include/nlohmann/adl_serializer.hpp index 4af1c4bb1..56a606c0f 100644 --- a/external_imported/json/include/nlohmann/adl_serializer.hpp +++ b/external_imported/json/include/nlohmann/adl_serializer.hpp @@ -1,49 +1,55 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once #include +#include #include #include +#include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN -template +/// @sa https://json.nlohmann.me/api/adl_serializer/ +template struct adl_serializer { - /*! - @brief convert a JSON value to any value type - - This function is usually called by the `get()` function of the - @ref basic_json class (either explicit or via conversion operators). - - @param[in] j JSON value to read from - @param[in,out] val value to write to - */ - template - static auto from_json(BasicJsonType&& j, ValueType& val) noexcept( + /// @brief convert a JSON value to any value type + /// @sa https://json.nlohmann.me/api/adl_serializer/from_json/ + template + static auto from_json(BasicJsonType && j, TargetType& val) noexcept( noexcept(::nlohmann::from_json(std::forward(j), val))) -> decltype(::nlohmann::from_json(std::forward(j), val), void()) { ::nlohmann::from_json(std::forward(j), val); } - /*! - @brief convert any value type to a JSON value - - This function is usually called by the constructors of the @ref basic_json - class. + /// @brief convert a JSON value to any value type + /// @sa https://json.nlohmann.me/api/adl_serializer/from_json/ + template + static auto from_json(BasicJsonType && j) noexcept( + noexcept(::nlohmann::from_json(std::forward(j), detail::identity_tag {}))) + -> decltype(::nlohmann::from_json(std::forward(j), detail::identity_tag {})) + { + return ::nlohmann::from_json(std::forward(j), detail::identity_tag {}); + } - @param[in,out] j JSON value to write to - @param[in] val value to read from - */ - template - static auto to_json(BasicJsonType& j, ValueType&& val) noexcept( - noexcept(::nlohmann::to_json(j, std::forward(val)))) - -> decltype(::nlohmann::to_json(j, std::forward(val)), void()) + /// @brief convert any value type to a JSON value + /// @sa https://json.nlohmann.me/api/adl_serializer/to_json/ + template + static auto to_json(BasicJsonType& j, TargetType && val) noexcept( + noexcept(::nlohmann::to_json(j, std::forward(val)))) + -> decltype(::nlohmann::to_json(j, std::forward(val)), void()) { - ::nlohmann::to_json(j, std::forward(val)); + ::nlohmann::to_json(j, std::forward(val)); } }; -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/byte_container_with_subtype.hpp b/external_imported/json/include/nlohmann/byte_container_with_subtype.hpp index ee3ab4011..91382cd68 100644 --- a/external_imported/json/include/nlohmann/byte_container_with_subtype.hpp +++ b/external_imported/json/include/nlohmann/byte_container_with_subtype.hpp @@ -1,51 +1,54 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once -#include // uint8_t +#include // uint8_t, uint64_t #include // tie #include // move -namespace nlohmann -{ - -/*! -@brief an internal type for a backed binary type - -This type extends the template parameter @a BinaryType provided to `basic_json` -with a subtype used by BSON and MessagePack. This type exists so that the user -does not have to specify a type themselves with a specific naming scheme in -order to override the binary type. +#include -@tparam BinaryType container to store bytes (`std::vector` by - default) +NLOHMANN_JSON_NAMESPACE_BEGIN -@since version 3.8.0 -*/ +/// @brief an internal type for a backed binary type +/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/ template class byte_container_with_subtype : public BinaryType { public: - /// the type of the underlying container using container_type = BinaryType; + using subtype_type = std::uint64_t; + /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/ byte_container_with_subtype() noexcept(noexcept(container_type())) : container_type() {} + /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/ byte_container_with_subtype(const container_type& b) noexcept(noexcept(container_type(b))) : container_type(b) {} + /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/ byte_container_with_subtype(container_type&& b) noexcept(noexcept(container_type(std::move(b)))) : container_type(std::move(b)) {} - byte_container_with_subtype(const container_type& b, std::uint8_t subtype_) noexcept(noexcept(container_type(b))) + /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/ + byte_container_with_subtype(const container_type& b, subtype_type subtype_) noexcept(noexcept(container_type(b))) : container_type(b) , m_subtype(subtype_) , m_has_subtype(true) {} - byte_container_with_subtype(container_type&& b, std::uint8_t subtype_) noexcept(noexcept(container_type(std::move(b)))) + /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/ + byte_container_with_subtype(container_type&& b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b)))) : container_type(std::move(b)) , m_subtype(subtype_) , m_has_subtype(true) @@ -62,96 +65,30 @@ class byte_container_with_subtype : public BinaryType return !(rhs == *this); } - /*! - @brief sets the binary subtype - - Sets the binary subtype of the value, also flags a binary JSON value as - having a subtype, which has implications for serialization. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @sa @ref subtype() -- return the binary subtype - @sa @ref clear_subtype() -- clears the binary subtype - @sa @ref has_subtype() -- returns whether or not the binary value has a - subtype - - @since version 3.8.0 - */ - void set_subtype(std::uint8_t subtype_) noexcept + /// @brief sets the binary subtype + /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/set_subtype/ + void set_subtype(subtype_type subtype_) noexcept { m_subtype = subtype_; m_has_subtype = true; } - /*! - @brief return the binary subtype - - Returns the numerical subtype of the value if it has a subtype. If it does - not have a subtype, this function will return size_t(-1) as a sentinel - value. - - @return the numerical subtype of the binary value - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @sa @ref set_subtype() -- sets the binary subtype - @sa @ref clear_subtype() -- clears the binary subtype - @sa @ref has_subtype() -- returns whether or not the binary value has a - subtype - - @since version 3.8.0 - */ - constexpr std::uint8_t subtype() const noexcept + /// @brief return the binary subtype + /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/subtype/ + constexpr subtype_type subtype() const noexcept { - return m_subtype; + return m_has_subtype ? m_subtype : static_cast(-1); } - /*! - @brief return whether the value has a subtype - - @return whether the value has a subtype - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @sa @ref subtype() -- return the binary subtype - @sa @ref set_subtype() -- sets the binary subtype - @sa @ref clear_subtype() -- clears the binary subtype - - @since version 3.8.0 - */ + /// @brief return whether the value has a subtype + /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/has_subtype/ constexpr bool has_subtype() const noexcept { return m_has_subtype; } - /*! - @brief clears the binary subtype - - Clears the binary subtype and flags the value as not having a subtype, which - has implications for serialization; for instance MessagePack will prefer the - bin family over the ext family. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @sa @ref subtype() -- return the binary subtype - @sa @ref set_subtype() -- sets the binary subtype - @sa @ref has_subtype() -- returns whether or not the binary value has a - subtype - - @since version 3.8.0 - */ + /// @brief clears the binary subtype + /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/clear_subtype/ void clear_subtype() noexcept { m_subtype = 0; @@ -159,8 +96,8 @@ class byte_container_with_subtype : public BinaryType } private: - std::uint8_t m_subtype = 0; + subtype_type m_subtype = 0; bool m_has_subtype = false; }; -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/abi_macros.hpp b/external_imported/json/include/nlohmann/detail/abi_macros.hpp new file mode 100644 index 000000000..f48b9eb1d --- /dev/null +++ b/external_imported/json/include/nlohmann/detail/abi_macros.hpp @@ -0,0 +1,100 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + +#pragma once + +// This file contains all macro definitions affecting or depending on the ABI + +#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK + #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH) + #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 3 + #warning "Already included a different version of the library!" + #endif + #endif +#endif + +#define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum) +#define NLOHMANN_JSON_VERSION_MINOR 11 // NOLINT(modernize-macro-to-enum) +#define NLOHMANN_JSON_VERSION_PATCH 3 // NOLINT(modernize-macro-to-enum) + +#ifndef JSON_DIAGNOSTICS + #define JSON_DIAGNOSTICS 0 +#endif + +#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON + #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0 +#endif + +#if JSON_DIAGNOSTICS + #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag +#else + #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS +#endif + +#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON + #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp +#else + #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON +#endif + +#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION + #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0 +#endif + +// Construct the namespace ABI tags component +#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b +#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \ + NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) + +#define NLOHMANN_JSON_ABI_TAGS \ + NLOHMANN_JSON_ABI_TAGS_CONCAT( \ + NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \ + NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON) + +// Construct the namespace version component +#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \ + _v ## major ## _ ## minor ## _ ## patch +#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \ + NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) + +#if NLOHMANN_JSON_NAMESPACE_NO_VERSION +#define NLOHMANN_JSON_NAMESPACE_VERSION +#else +#define NLOHMANN_JSON_NAMESPACE_VERSION \ + NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \ + NLOHMANN_JSON_VERSION_MINOR, \ + NLOHMANN_JSON_VERSION_PATCH) +#endif + +// Combine namespace components +#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b +#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \ + NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) + +#ifndef NLOHMANN_JSON_NAMESPACE +#define NLOHMANN_JSON_NAMESPACE \ + nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \ + NLOHMANN_JSON_ABI_TAGS, \ + NLOHMANN_JSON_NAMESPACE_VERSION) +#endif + +#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN +#define NLOHMANN_JSON_NAMESPACE_BEGIN \ + namespace nlohmann \ + { \ + inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \ + NLOHMANN_JSON_ABI_TAGS, \ + NLOHMANN_JSON_NAMESPACE_VERSION) \ + { +#endif + +#ifndef NLOHMANN_JSON_NAMESPACE_END +#define NLOHMANN_JSON_NAMESPACE_END \ + } /* namespace (inline namespace) NOLINT(readability/namespace) */ \ + } // namespace nlohmann +#endif diff --git a/external_imported/json/include/nlohmann/detail/conversions/from_json.hpp b/external_imported/json/include/nlohmann/detail/conversions/from_json.hpp index f03c01815..aa2f0cbf4 100644 --- a/external_imported/json/include/nlohmann/detail/conversions/from_json.hpp +++ b/external_imported/json/include/nlohmann/detail/conversions/from_json.hpp @@ -1,3 +1,11 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once #include // transform @@ -15,19 +23,22 @@ #include #include #include +#include +#include #include +#include #include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + template -void from_json(const BasicJsonType& j, typename std::nullptr_t& n) +inline void from_json(const BasicJsonType& j, typename std::nullptr_t& n) { if (JSON_HEDLEY_UNLIKELY(!j.is_null())) { - JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name()), j)); + JSON_THROW(type_error::create(302, concat("type must be null, but is ", j.type_name()), &j)); } n = nullptr; } @@ -57,83 +68,92 @@ void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) break; } + case value_t::null: + case value_t::object: + case value_t::array: + case value_t::string: + case value_t::boolean: + case value_t::binary: + case value_t::discarded: default: - JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()), j)); + JSON_THROW(type_error::create(302, concat("type must be number, but is ", j.type_name()), &j)); } } template -void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) +inline void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) { if (JSON_HEDLEY_UNLIKELY(!j.is_boolean())) { - JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name()), j)); + JSON_THROW(type_error::create(302, concat("type must be boolean, but is ", j.type_name()), &j)); } b = *j.template get_ptr(); } template -void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s) +inline void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s) { if (JSON_HEDLEY_UNLIKELY(!j.is_string())) { - JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j)); + JSON_THROW(type_error::create(302, concat("type must be string, but is ", j.type_name()), &j)); } s = *j.template get_ptr(); } template < - typename BasicJsonType, typename ConstructibleStringType, + typename BasicJsonType, typename StringType, enable_if_t < - is_constructible_string_type::value&& - !std::is_same::value, - int > = 0 > -void from_json(const BasicJsonType& j, ConstructibleStringType& s) + std::is_assignable::value + && is_detected_exact::value + && !std::is_same::value + && !is_json_ref::value, int > = 0 > +inline void from_json(const BasicJsonType& j, StringType& s) { if (JSON_HEDLEY_UNLIKELY(!j.is_string())) { - JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j)); + JSON_THROW(type_error::create(302, concat("type must be string, but is ", j.type_name()), &j)); } s = *j.template get_ptr(); } template -void from_json(const BasicJsonType& j, typename BasicJsonType::number_float_t& val) +inline void from_json(const BasicJsonType& j, typename BasicJsonType::number_float_t& val) { get_arithmetic_value(j, val); } template -void from_json(const BasicJsonType& j, typename BasicJsonType::number_unsigned_t& val) +inline void from_json(const BasicJsonType& j, typename BasicJsonType::number_unsigned_t& val) { get_arithmetic_value(j, val); } template -void from_json(const BasicJsonType& j, typename BasicJsonType::number_integer_t& val) +inline void from_json(const BasicJsonType& j, typename BasicJsonType::number_integer_t& val) { get_arithmetic_value(j, val); } +#if !JSON_DISABLE_ENUM_SERIALIZATION template::value, int> = 0> -void from_json(const BasicJsonType& j, EnumType& e) +inline void from_json(const BasicJsonType& j, EnumType& e) { typename std::underlying_type::type val; get_arithmetic_value(j, val); e = static_cast(val); } +#endif // JSON_DISABLE_ENUM_SERIALIZATION // forward_list doesn't have an insert method template::value, int> = 0> -void from_json(const BasicJsonType& j, std::forward_list& l) +inline void from_json(const BasicJsonType& j, std::forward_list& l) { if (JSON_HEDLEY_UNLIKELY(!j.is_array())) { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); + JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); } l.clear(); std::transform(j.rbegin(), j.rend(), @@ -146,11 +166,11 @@ void from_json(const BasicJsonType& j, std::forward_list& l) // valarray doesn't have an insert method template::value, int> = 0> -void from_json(const BasicJsonType& j, std::valarray& l) +inline void from_json(const BasicJsonType& j, std::valarray& l) { if (JSON_HEDLEY_UNLIKELY(!j.is_array())) { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); + JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); } l.resize(j.size()); std::transform(j.begin(), j.end(), std::begin(l), @@ -161,7 +181,7 @@ void from_json(const BasicJsonType& j, std::valarray& l) } template -auto from_json(const BasicJsonType& j, T (&arr)[N]) +auto from_json(const BasicJsonType& j, T (&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) -> decltype(j.template get(), void()) { for (std::size_t i = 0; i < N; ++i) @@ -171,7 +191,7 @@ auto from_json(const BasicJsonType& j, T (&arr)[N]) } template -void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType::array_t& arr, priority_tag<3> /*unused*/) +inline void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType::array_t& arr, priority_tag<3> /*unused*/) { arr = *j.template get_ptr(); } @@ -187,7 +207,10 @@ auto from_json_array_impl(const BasicJsonType& j, std::array& arr, } } -template +template::value, + int> = 0> auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> /*unused*/) -> decltype( arr.reserve(std::declval()), @@ -208,9 +231,12 @@ auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, p arr = std::move(ret); } -template -void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, - priority_tag<0> /*unused*/) +template::value, + int> = 0> +inline void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, + priority_tag<0> /*unused*/) { using std::end; @@ -241,18 +267,37 @@ void()) { if (JSON_HEDLEY_UNLIKELY(!j.is_array())) { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); + JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); } from_json_array_impl(j, arr, priority_tag<3> {}); } +template < typename BasicJsonType, typename T, std::size_t... Idx > +std::array from_json_inplace_array_impl(BasicJsonType&& j, + identity_tag> /*unused*/, index_sequence /*unused*/) +{ + return { { std::forward(j).at(Idx).template get()... } }; +} + +template < typename BasicJsonType, typename T, std::size_t N > +auto from_json(BasicJsonType&& j, identity_tag> tag) +-> decltype(from_json_inplace_array_impl(std::forward(j), tag, make_index_sequence {})) +{ + if (JSON_HEDLEY_UNLIKELY(!j.is_array())) + { + JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); + } + + return from_json_inplace_array_impl(std::forward(j), tag, make_index_sequence {}); +} + template -void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin) +inline void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin) { if (JSON_HEDLEY_UNLIKELY(!j.is_binary())) { - JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(j.type_name()), j)); + JSON_THROW(type_error::create(302, concat("type must be binary, but is ", j.type_name()), &j)); } bin = *j.template get_ptr(); @@ -260,15 +305,15 @@ void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin) template::value, int> = 0> -void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) +inline void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) { if (JSON_HEDLEY_UNLIKELY(!j.is_object())) { - JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name()), j)); + JSON_THROW(type_error::create(302, concat("type must be object, but is ", j.type_name()), &j)); } ConstructibleObjectType ret; - auto inner_object = j.template get_ptr(); + const auto* inner_object = j.template get_ptr(); using value_type = typename ConstructibleObjectType::value_type; std::transform( inner_object->begin(), inner_object->end(), @@ -292,7 +337,7 @@ template < typename BasicJsonType, typename ArithmeticType, !std::is_same::value&& !std::is_same::value, int > = 0 > -void from_json(const BasicJsonType& j, ArithmeticType& val) +inline void from_json(const BasicJsonType& j, ArithmeticType& val) { switch (static_cast(j)) { @@ -317,44 +362,75 @@ void from_json(const BasicJsonType& j, ArithmeticType& val) break; } + case value_t::null: + case value_t::object: + case value_t::array: + case value_t::string: + case value_t::binary: + case value_t::discarded: default: - JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()), j)); + JSON_THROW(type_error::create(302, concat("type must be number, but is ", j.type_name()), &j)); } } +template +std::tuple from_json_tuple_impl_base(BasicJsonType&& j, index_sequence /*unused*/) +{ + return std::make_tuple(std::forward(j).at(Idx).template get()...); +} + +template < typename BasicJsonType, class A1, class A2 > +std::pair from_json_tuple_impl(BasicJsonType&& j, identity_tag> /*unused*/, priority_tag<0> /*unused*/) +{ + return {std::forward(j).at(0).template get(), + std::forward(j).at(1).template get()}; +} + template -void from_json(const BasicJsonType& j, std::pair& p) +inline void from_json_tuple_impl(BasicJsonType&& j, std::pair& p, priority_tag<1> /*unused*/) { - p = {j.at(0).template get(), j.at(1).template get()}; + p = from_json_tuple_impl(std::forward(j), identity_tag> {}, priority_tag<0> {}); } -template -void from_json_tuple_impl(const BasicJsonType& j, Tuple& t, index_sequence /*unused*/) +template +std::tuple from_json_tuple_impl(BasicJsonType&& j, identity_tag> /*unused*/, priority_tag<2> /*unused*/) { - t = std::make_tuple(j.at(Idx).template get::type>()...); + return from_json_tuple_impl_base(std::forward(j), index_sequence_for {}); } template -void from_json(const BasicJsonType& j, std::tuple& t) +inline void from_json_tuple_impl(BasicJsonType&& j, std::tuple& t, priority_tag<3> /*unused*/) { - from_json_tuple_impl(j, t, index_sequence_for {}); + t = from_json_tuple_impl_base(std::forward(j), index_sequence_for {}); +} + +template +auto from_json(BasicJsonType&& j, TupleRelated&& t) +-> decltype(from_json_tuple_impl(std::forward(j), std::forward(t), priority_tag<3> {})) +{ + if (JSON_HEDLEY_UNLIKELY(!j.is_array())) + { + JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); + } + + return from_json_tuple_impl(std::forward(j), std::forward(t), priority_tag<3> {}); } template < typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator, typename = enable_if_t < !std::is_constructible < typename BasicJsonType::string_t, Key >::value >> -void from_json(const BasicJsonType& j, std::map& m) +inline void from_json(const BasicJsonType& j, std::map& m) { if (JSON_HEDLEY_UNLIKELY(!j.is_array())) { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); + JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); } m.clear(); for (const auto& p : j) { if (JSON_HEDLEY_UNLIKELY(!p.is_array())) { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()), j)); + JSON_THROW(type_error::create(302, concat("type must be array, but is ", p.type_name()), &j)); } m.emplace(p.at(0).template get(), p.at(1).template get()); } @@ -363,40 +439,59 @@ void from_json(const BasicJsonType& j, std::map& template < typename BasicJsonType, typename Key, typename Value, typename Hash, typename KeyEqual, typename Allocator, typename = enable_if_t < !std::is_constructible < typename BasicJsonType::string_t, Key >::value >> -void from_json(const BasicJsonType& j, std::unordered_map& m) +inline void from_json(const BasicJsonType& j, std::unordered_map& m) { if (JSON_HEDLEY_UNLIKELY(!j.is_array())) { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); + JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); } m.clear(); for (const auto& p : j) { if (JSON_HEDLEY_UNLIKELY(!p.is_array())) { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()), j)); + JSON_THROW(type_error::create(302, concat("type must be array, but is ", p.type_name()), &j)); } m.emplace(p.at(0).template get(), p.at(1).template get()); } } +#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM +template +inline void from_json(const BasicJsonType& j, std_fs::path& p) +{ + if (JSON_HEDLEY_UNLIKELY(!j.is_string())) + { + JSON_THROW(type_error::create(302, concat("type must be string, but is ", j.type_name()), &j)); + } + p = *j.template get_ptr(); +} +#endif + struct from_json_fn { template - auto operator()(const BasicJsonType& j, T& val) const - noexcept(noexcept(from_json(j, val))) - -> decltype(from_json(j, val), void()) + auto operator()(const BasicJsonType& j, T&& val) const + noexcept(noexcept(from_json(j, std::forward(val)))) + -> decltype(from_json(j, std::forward(val))) { - return from_json(j, val); + return from_json(j, std::forward(val)); } }; + } // namespace detail +#ifndef JSON_HAS_CPP_17 /// namespace to hold default `from_json` function /// to see why this is required: /// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html -namespace +namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces) { -constexpr const auto& from_json = detail::static_const::value; -} // namespace -} // namespace nlohmann +#endif +JSON_INLINE_VARIABLE constexpr const auto& from_json = // NOLINT(misc-definitions-in-headers) + detail::static_const::value; +#ifndef JSON_HAS_CPP_17 +} // namespace +#endif + +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/conversions/to_chars.hpp b/external_imported/json/include/nlohmann/detail/conversions/to_chars.hpp index 49ed0f913..e10741c92 100644 --- a/external_imported/json/include/nlohmann/detail/conversions/to_chars.hpp +++ b/external_imported/json/include/nlohmann/detail/conversions/to_chars.hpp @@ -1,3 +1,12 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2009 Florian Loitsch +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once #include // array @@ -9,8 +18,7 @@ #include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { @@ -200,7 +208,7 @@ boundaries compute_boundaries(FloatType value) using bits_type = typename std::conditional::type; - const std::uint64_t bits = reinterpret_bits(value); + const auto bits = static_cast(reinterpret_bits(value)); const std::uint64_t E = bits >> (kPrecision - 1); const std::uint64_t F = bits & (kHiddenBit - 1); @@ -618,7 +626,7 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, JSON_ASSERT(p1 > 0); - std::uint32_t pow10; + std::uint32_t pow10{}; const int k = find_largest_pow10(p1, pow10); // 10^(k-1) <= p1 < 10^k, pow10 = 10^(k-1) @@ -891,7 +899,7 @@ void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) // // The documentation for 'std::to_chars' (https://en.cppreference.com/w/cpp/utility/to_chars) // says "value is converted to a string as if by std::sprintf in the default ("C") locale" - // and since sprintf promotes float's to double's, I think this is exactly what 'std::to_chars' + // and since sprintf promotes floats to doubles, I think this is exactly what 'std::to_chars' // does. // On the other hand, the documentation for 'std::to_chars' requires that "parsing the // representation using the corresponding std::from_chars function recovers value exactly". That @@ -901,7 +909,7 @@ void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) // NB: If the neighbors are computed for single-precision numbers, there is a single float // (7.0385307e-26f) which can't be recovered using strtod. The resulting double precision // value is off by 1 ulp. -#if 0 +#if 0 // NOLINT(readability-avoid-unconditional-preprocessor-if) const boundaries w = compute_boundaries(static_cast(value)); #else const boundaries w = compute_boundaries(value); @@ -1039,7 +1047,7 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent, return append_exponent(buf, n - 1); } -} // namespace dtoa_impl +} // namespace dtoa_impl /*! @brief generates a decimal representation of the floating-point number value in [first, last). @@ -1066,6 +1074,10 @@ char* to_chars(char* first, const char* last, FloatType value) *first++ = '-'; } +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wfloat-equal" +#endif if (value == 0) // +-0 { *first++ = '0'; @@ -1074,6 +1086,9 @@ char* to_chars(char* first, const char* last, FloatType value) *first++ = '0'; return first; } +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif JSON_ASSERT(last - first >= std::numeric_limits::max_digits10); @@ -1099,5 +1114,5 @@ char* to_chars(char* first, const char* last, FloatType value) return dtoa_impl::format_buffer(first, len, decimal_exponent, kMinExp, kMaxExp); } -} // namespace detail -} // namespace nlohmann +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/conversions/to_json.hpp b/external_imported/json/include/nlohmann/detail/conversions/to_json.hpp index 228e81879..e39b7797d 100644 --- a/external_imported/json/include/nlohmann/detail/conversions/to_json.hpp +++ b/external_imported/json/include/nlohmann/detail/conversions/to_json.hpp @@ -1,3 +1,11 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once #include // copy @@ -10,18 +18,27 @@ #include // vector #include +#include #include +#include #include #include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + ////////////////// // constructors // ////////////////// +/* + * Note all external_constructor<>::construct functions need to call + * j.m_data.m_value.destroy(j.m_data.m_type) to avoid a memory leak in case j contains an + * allocated value (e.g., a string). See bug issue + * https://github.com/nlohmann/json/issues/2865 for more information. + */ + template struct external_constructor; template<> @@ -30,8 +47,9 @@ struct external_constructor template static void construct(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept { - j.m_type = value_t::boolean; - j.m_value = b; + j.m_data.m_value.destroy(j.m_data.m_type); + j.m_data.m_type = value_t::boolean; + j.m_data.m_value = b; j.assert_invariant(); } }; @@ -42,16 +60,18 @@ struct external_constructor template static void construct(BasicJsonType& j, const typename BasicJsonType::string_t& s) { - j.m_type = value_t::string; - j.m_value = s; + j.m_data.m_value.destroy(j.m_data.m_type); + j.m_data.m_type = value_t::string; + j.m_data.m_value = s; j.assert_invariant(); } template static void construct(BasicJsonType& j, typename BasicJsonType::string_t&& s) { - j.m_type = value_t::string; - j.m_value = std::move(s); + j.m_data.m_value.destroy(j.m_data.m_type); + j.m_data.m_type = value_t::string; + j.m_data.m_value = std::move(s); j.assert_invariant(); } @@ -60,8 +80,9 @@ struct external_constructor int > = 0 > static void construct(BasicJsonType& j, const CompatibleStringType& str) { - j.m_type = value_t::string; - j.m_value.string = j.template create(str); + j.m_data.m_value.destroy(j.m_data.m_type); + j.m_data.m_type = value_t::string; + j.m_data.m_value.string = j.template create(str); j.assert_invariant(); } }; @@ -72,18 +93,18 @@ struct external_constructor template static void construct(BasicJsonType& j, const typename BasicJsonType::binary_t& b) { - j.m_type = value_t::binary; - typename BasicJsonType::binary_t value{b}; - j.m_value = value; + j.m_data.m_value.destroy(j.m_data.m_type); + j.m_data.m_type = value_t::binary; + j.m_data.m_value = typename BasicJsonType::binary_t(b); j.assert_invariant(); } template static void construct(BasicJsonType& j, typename BasicJsonType::binary_t&& b) { - j.m_type = value_t::binary; - typename BasicJsonType::binary_t value{std::move(b)}; - j.m_value = value; + j.m_data.m_value.destroy(j.m_data.m_type); + j.m_data.m_type = value_t::binary; + j.m_data.m_value = typename BasicJsonType::binary_t(std::move(b)); j.assert_invariant(); } }; @@ -94,8 +115,9 @@ struct external_constructor template static void construct(BasicJsonType& j, typename BasicJsonType::number_float_t val) noexcept { - j.m_type = value_t::number_float; - j.m_value = val; + j.m_data.m_value.destroy(j.m_data.m_type); + j.m_data.m_type = value_t::number_float; + j.m_data.m_value = val; j.assert_invariant(); } }; @@ -106,8 +128,9 @@ struct external_constructor template static void construct(BasicJsonType& j, typename BasicJsonType::number_unsigned_t val) noexcept { - j.m_type = value_t::number_unsigned; - j.m_value = val; + j.m_data.m_value.destroy(j.m_data.m_type); + j.m_data.m_type = value_t::number_unsigned; + j.m_data.m_value = val; j.assert_invariant(); } }; @@ -118,8 +141,9 @@ struct external_constructor template static void construct(BasicJsonType& j, typename BasicJsonType::number_integer_t val) noexcept { - j.m_type = value_t::number_integer; - j.m_value = val; + j.m_data.m_value.destroy(j.m_data.m_type); + j.m_data.m_type = value_t::number_integer; + j.m_data.m_value = val; j.assert_invariant(); } }; @@ -130,8 +154,9 @@ struct external_constructor template static void construct(BasicJsonType& j, const typename BasicJsonType::array_t& arr) { - j.m_type = value_t::array; - j.m_value = arr; + j.m_data.m_value.destroy(j.m_data.m_type); + j.m_data.m_type = value_t::array; + j.m_data.m_value = arr; j.set_parents(); j.assert_invariant(); } @@ -139,8 +164,9 @@ struct external_constructor template static void construct(BasicJsonType& j, typename BasicJsonType::array_t&& arr) { - j.m_type = value_t::array; - j.m_value = std::move(arr); + j.m_data.m_value.destroy(j.m_data.m_type); + j.m_data.m_type = value_t::array; + j.m_data.m_value = std::move(arr); j.set_parents(); j.assert_invariant(); } @@ -152,8 +178,10 @@ struct external_constructor { using std::begin; using std::end; - j.m_type = value_t::array; - j.m_value.array = j.template create(begin(arr), end(arr)); + + j.m_data.m_value.destroy(j.m_data.m_type); + j.m_data.m_type = value_t::array; + j.m_data.m_value.array = j.template create(begin(arr), end(arr)); j.set_parents(); j.assert_invariant(); } @@ -161,13 +189,14 @@ struct external_constructor template static void construct(BasicJsonType& j, const std::vector& arr) { - j.m_type = value_t::array; - j.m_value = value_t::array; - j.m_value.array->reserve(arr.size()); + j.m_data.m_value.destroy(j.m_data.m_type); + j.m_data.m_type = value_t::array; + j.m_data.m_value = value_t::array; + j.m_data.m_value.array->reserve(arr.size()); for (const bool x : arr) { - j.m_value.array->push_back(x); - j.set_parent(j.m_value.array->back()); + j.m_data.m_value.array->push_back(x); + j.set_parent(j.m_data.m_value.array->back()); } j.assert_invariant(); } @@ -176,12 +205,13 @@ struct external_constructor enable_if_t::value, int> = 0> static void construct(BasicJsonType& j, const std::valarray& arr) { - j.m_type = value_t::array; - j.m_value = value_t::array; - j.m_value.array->resize(arr.size()); + j.m_data.m_value.destroy(j.m_data.m_type); + j.m_data.m_type = value_t::array; + j.m_data.m_value = value_t::array; + j.m_data.m_value.array->resize(arr.size()); if (arr.size() > 0) { - std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin()); + std::copy(std::begin(arr), std::end(arr), j.m_data.m_value.array->begin()); } j.set_parents(); j.assert_invariant(); @@ -194,8 +224,9 @@ struct external_constructor template static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj) { - j.m_type = value_t::object; - j.m_value = obj; + j.m_data.m_value.destroy(j.m_data.m_type); + j.m_data.m_type = value_t::object; + j.m_data.m_value = obj; j.set_parents(); j.assert_invariant(); } @@ -203,8 +234,9 @@ struct external_constructor template static void construct(BasicJsonType& j, typename BasicJsonType::object_t&& obj) { - j.m_type = value_t::object; - j.m_value = std::move(obj); + j.m_data.m_value.destroy(j.m_data.m_type); + j.m_data.m_type = value_t::object; + j.m_data.m_value = std::move(obj); j.set_parents(); j.assert_invariant(); } @@ -216,8 +248,9 @@ struct external_constructor using std::begin; using std::end; - j.m_type = value_t::object; - j.m_value.object = j.template create(begin(obj), end(obj)); + j.m_data.m_value.destroy(j.m_data.m_type); + j.m_data.m_type = value_t::object; + j.m_data.m_value.object = j.template create(begin(obj), end(obj)); j.set_parents(); j.assert_invariant(); } @@ -229,55 +262,70 @@ struct external_constructor template::value, int> = 0> -void to_json(BasicJsonType& j, T b) noexcept +inline void to_json(BasicJsonType& j, T b) noexcept { external_constructor::construct(j, b); } +template < typename BasicJsonType, typename BoolRef, + enable_if_t < + ((std::is_same::reference, BoolRef>::value + && !std::is_same ::reference, typename BasicJsonType::boolean_t&>::value) + || (std::is_same::const_reference, BoolRef>::value + && !std::is_same ::const_reference>, + typename BasicJsonType::boolean_t >::value)) + && std::is_convertible::value, int > = 0 > +inline void to_json(BasicJsonType& j, const BoolRef& b) noexcept +{ + external_constructor::construct(j, static_cast(b)); +} + template::value, int> = 0> -void to_json(BasicJsonType& j, const CompatibleString& s) +inline void to_json(BasicJsonType& j, const CompatibleString& s) { external_constructor::construct(j, s); } template -void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s) +inline void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s) { external_constructor::construct(j, std::move(s)); } template::value, int> = 0> -void to_json(BasicJsonType& j, FloatType val) noexcept +inline void to_json(BasicJsonType& j, FloatType val) noexcept { external_constructor::construct(j, static_cast(val)); } template::value, int> = 0> -void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept +inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept { external_constructor::construct(j, static_cast(val)); } template::value, int> = 0> -void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept +inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept { external_constructor::construct(j, static_cast(val)); } +#if !JSON_DISABLE_ENUM_SERIALIZATION template::value, int> = 0> -void to_json(BasicJsonType& j, EnumType e) noexcept +inline void to_json(BasicJsonType& j, EnumType e) noexcept { using underlying_type = typename std::underlying_type::type; external_constructor::construct(j, static_cast(e)); } +#endif // JSON_DISABLE_ENUM_SERIALIZATION template -void to_json(BasicJsonType& j, const std::vector& e) +inline void to_json(BasicJsonType& j, const std::vector& e) { external_constructor::construct(j, e); } @@ -290,39 +338,39 @@ template < typename BasicJsonType, typename CompatibleArrayType, !std::is_same::value&& !is_basic_json::value, int > = 0 > -void to_json(BasicJsonType& j, const CompatibleArrayType& arr) +inline void to_json(BasicJsonType& j, const CompatibleArrayType& arr) { external_constructor::construct(j, arr); } template -void to_json(BasicJsonType& j, const typename BasicJsonType::binary_t& bin) +inline void to_json(BasicJsonType& j, const typename BasicJsonType::binary_t& bin) { external_constructor::construct(j, bin); } template::value, int> = 0> -void to_json(BasicJsonType& j, const std::valarray& arr) +inline void to_json(BasicJsonType& j, const std::valarray& arr) { external_constructor::construct(j, std::move(arr)); } template -void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr) +inline void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr) { external_constructor::construct(j, std::move(arr)); } template < typename BasicJsonType, typename CompatibleObjectType, enable_if_t < is_compatible_object_type::value&& !is_basic_json::value, int > = 0 > -void to_json(BasicJsonType& j, const CompatibleObjectType& obj) +inline void to_json(BasicJsonType& j, const CompatibleObjectType& obj) { external_constructor::construct(j, obj); } template -void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj) +inline void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj) { external_constructor::construct(j, std::move(obj)); } @@ -330,15 +378,15 @@ void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj) template < typename BasicJsonType, typename T, std::size_t N, enable_if_t < !std::is_constructible::value, + const T(&)[N]>::value, // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) int > = 0 > -void to_json(BasicJsonType& j, const T(&arr)[N]) +inline void to_json(BasicJsonType& j, const T(&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) { external_constructor::construct(j, arr); } template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible::value&& std::is_constructible::value, int > = 0 > -void to_json(BasicJsonType& j, const std::pair& p) +inline void to_json(BasicJsonType& j, const std::pair& p) { j = { p.first, p.second }; } @@ -346,23 +394,31 @@ void to_json(BasicJsonType& j, const std::pair& p) // for https://github.com/nlohmann/json/pull/1134 template>::value, int> = 0> -void to_json(BasicJsonType& j, const T& b) +inline void to_json(BasicJsonType& j, const T& b) { j = { {b.key(), b.value()} }; } template -void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence /*unused*/) +inline void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence /*unused*/) { j = { std::get(t)... }; } template::value, int > = 0> -void to_json(BasicJsonType& j, const T& t) +inline void to_json(BasicJsonType& j, const T& t) { to_json_tuple_impl(j, t, make_index_sequence::value> {}); } +#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM +template +inline void to_json(BasicJsonType& j, const std_fs::path& p) +{ + j = p.string(); +} +#endif + struct to_json_fn { template @@ -374,9 +430,17 @@ struct to_json_fn }; } // namespace detail +#ifndef JSON_HAS_CPP_17 /// namespace to hold default `to_json` function -namespace +/// to see why this is required: +/// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html +namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces) { -constexpr const auto& to_json = detail::static_const::value; -} // namespace -} // namespace nlohmann +#endif +JSON_INLINE_VARIABLE constexpr const auto& to_json = // NOLINT(misc-definitions-in-headers) + detail::static_const::value; +#ifndef JSON_HAS_CPP_17 +} // namespace +#endif + +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/exceptions.hpp b/external_imported/json/include/nlohmann/detail/exceptions.hpp index 5c9dce3c5..5974d7be2 100644 --- a/external_imported/json/include/nlohmann/detail/exceptions.hpp +++ b/external_imported/json/include/nlohmann/detail/exceptions.hpp @@ -1,86 +1,80 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once +#include // nullptr_t #include // exception +#if JSON_DIAGNOSTICS + #include // accumulate +#endif #include // runtime_error #include // to_string +#include // vector #include #include #include #include +#include +#include +#include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + //////////////// // exceptions // //////////////// -/*! -@brief general exception of the @ref basic_json class - -This class is an extension of `std::exception` objects with a member @a id for -exception ids. It is used as the base class for all exceptions thrown by the -@ref basic_json class. This class can hence be used as "wildcard" to catch -exceptions. - -Subclasses: -- @ref parse_error for exceptions indicating a parse error -- @ref invalid_iterator for exceptions indicating errors with iterators -- @ref type_error for exceptions indicating executing a member function with - a wrong type -- @ref out_of_range for exceptions indicating access out of the defined range -- @ref other_error for exceptions indicating other library errors - -@internal -@note To have nothrow-copy-constructible exceptions, we internally use - `std::runtime_error` which can cope with arbitrary-length error messages. - Intermediate strings are built with static functions and then passed to - the actual constructor. -@endinternal - -@liveexample{The following code shows how arbitrary library exceptions can be -caught.,exception} - -@since version 3.0.0 -*/ +/// @brief general exception of the @ref basic_json class +/// @sa https://json.nlohmann.me/api/basic_json/exception/ class exception : public std::exception { public: /// returns the explanatory string - JSON_HEDLEY_RETURNS_NON_NULL const char* what() const noexcept override { return m.what(); } /// the id of the exception - const int id; + const int id; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes) protected: JSON_HEDLEY_NON_NULL(3) - exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} + exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} // NOLINT(bugprone-throw-keyword-missing) static std::string name(const std::string& ename, int id_) { - return "[json.exception." + ename + "." + std::to_string(id_) + "] "; + return concat("[json.exception.", ename, '.', std::to_string(id_), "] "); + } + + static std::string diagnostics(std::nullptr_t /*leaf_element*/) + { + return ""; } template - static std::string diagnostics(const BasicJsonType& leaf_element) + static std::string diagnostics(const BasicJsonType* leaf_element) { #if JSON_DIAGNOSTICS std::vector tokens; - for (const auto* current = &leaf_element; current->m_parent != nullptr; current = current->m_parent) + for (const auto* current = leaf_element; current != nullptr && current->m_parent != nullptr; current = current->m_parent) { switch (current->m_parent->type()) { case value_t::array: { - for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i) + for (std::size_t i = 0; i < current->m_parent->m_data.m_value.array->size(); ++i) { - if (¤t->m_parent->m_value.array->operator[](i) == current) + if (¤t->m_parent->m_data.m_value.array->operator[](i) == current) { tokens.emplace_back(std::to_string(i)); break; @@ -91,7 +85,7 @@ class exception : public std::exception case value_t::object: { - for (const auto& element : *current->m_parent->m_value.object) + for (const auto& element : *current->m_parent->m_data.m_value.object) { if (&element.second == current) { @@ -102,6 +96,14 @@ class exception : public std::exception break; } + case value_t::null: // LCOV_EXCL_LINE + case value_t::string: // LCOV_EXCL_LINE + case value_t::boolean: // LCOV_EXCL_LINE + case value_t::number_integer: // LCOV_EXCL_LINE + case value_t::number_unsigned: // LCOV_EXCL_LINE + case value_t::number_float: // LCOV_EXCL_LINE + case value_t::binary: // LCOV_EXCL_LINE + case value_t::discarded: // LCOV_EXCL_LINE default: // LCOV_EXCL_LINE break; // LCOV_EXCL_LINE } @@ -112,12 +114,14 @@ class exception : public std::exception return ""; } - return "(" + std::accumulate(tokens.rbegin(), tokens.rend(), std::string{}, - [](const std::string & a, const std::string & b) + auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{}, + [](const std::string & a, const std::string & b) { - return a + "/" + detail::escape(b); - }) + ") "; + return concat(a, '/', detail::escape(b)); + }); + return concat('(', str, ") "); #else + static_cast(leaf_element); return ""; #endif } @@ -127,51 +131,8 @@ class exception : public std::exception std::runtime_error m; }; -/*! -@brief exception indicating a parse error - -This exception is thrown by the library when a parse error occurs. Parse errors -can occur during the deserialization of JSON text, CBOR, MessagePack, as well -as when using JSON Patch. - -Member @a byte holds the byte index of the last read character in the input -file. - -Exceptions have ids 1xx. - -name / id | example message | description ------------------------------- | --------------- | ------------------------- -json.exception.parse_error.101 | parse error at 2: unexpected end of input; expected string literal | This error indicates a syntax error while deserializing a JSON text. The error message describes that an unexpected token (character) was encountered, and the member @a byte indicates the error position. -json.exception.parse_error.102 | parse error at 14: missing or wrong low surrogate | JSON uses the `\uxxxx` format to describe Unicode characters. Code points above above 0xFFFF are split into two `\uxxxx` entries ("surrogate pairs"). This error indicates that the surrogate pair is incomplete or contains an invalid code point. -json.exception.parse_error.103 | parse error: code points above 0x10FFFF are invalid | Unicode supports code points up to 0x10FFFF. Code points above 0x10FFFF are invalid. -json.exception.parse_error.104 | parse error: JSON patch must be an array of objects | [RFC 6902](https://tools.ietf.org/html/rfc6902) requires a JSON Patch document to be a JSON document that represents an array of objects. -json.exception.parse_error.105 | parse error: operation must have string member 'op' | An operation of a JSON Patch document must contain exactly one "op" member, whose value indicates the operation to perform. Its value must be one of "add", "remove", "replace", "move", "copy", or "test"; other values are errors. -json.exception.parse_error.106 | parse error: array index '01' must not begin with '0' | An array index in a JSON Pointer ([RFC 6901](https://tools.ietf.org/html/rfc6901)) may be `0` or any number without a leading `0`. -json.exception.parse_error.107 | parse error: JSON pointer must be empty or begin with '/' - was: 'foo' | A JSON Pointer must be a Unicode string containing a sequence of zero or more reference tokens, each prefixed by a `/` character. -json.exception.parse_error.108 | parse error: escape character '~' must be followed with '0' or '1' | In a JSON Pointer, only `~0` and `~1` are valid escape sequences. -json.exception.parse_error.109 | parse error: array index 'one' is not a number | A JSON Pointer array index must be a number. -json.exception.parse_error.110 | parse error at 1: cannot read 2 bytes from vector | When parsing CBOR or MessagePack, the byte vector ends before the complete value has been read. -json.exception.parse_error.112 | parse error at 1: error reading CBOR; last byte: 0xF8 | Not all types of CBOR or MessagePack are supported. This exception occurs if an unsupported byte was read. -json.exception.parse_error.113 | parse error at 2: expected a CBOR string; last byte: 0x98 | While parsing a map key, a value that is not a string has been read. -json.exception.parse_error.114 | parse error: Unsupported BSON record type 0x0F | The parsing of the corresponding BSON record type is not implemented (yet). -json.exception.parse_error.115 | parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1A | A UBJSON high-precision number could not be parsed. - -@note For an input with n bytes, 1 is the index of the first character and n+1 - is the index of the terminating null byte or the end of file. This also - holds true when reading a byte vector (CBOR or MessagePack). - -@liveexample{The following code shows how a `parse_error` exception can be -caught.,parse_error} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref out_of_range for exceptions indicating access out of the defined range -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ +/// @brief exception indicating a parse error +/// @sa https://json.nlohmann.me/api/basic_json/parse_error/ class parse_error : public exception { public: @@ -184,21 +145,21 @@ class parse_error : public exception @param[in] what_arg the explanatory string @return parse_error object */ - template - static parse_error create(int id_, const position_t& pos, const std::string& what_arg, const BasicJsonType& context) + template::value, int> = 0> + static parse_error create(int id_, const position_t& pos, const std::string& what_arg, BasicJsonContext context) { - std::string w = exception::name("parse_error", id_) + "parse error" + - position_string(pos) + ": " + exception::diagnostics(context) + what_arg; - return parse_error(id_, pos.chars_read_total, w.c_str()); + const std::string w = concat(exception::name("parse_error", id_), "parse error", + position_string(pos), ": ", exception::diagnostics(context), what_arg); + return {id_, pos.chars_read_total, w.c_str()}; } - template - static parse_error create(int id_, std::size_t byte_, const std::string& what_arg, const BasicJsonType& context) + template::value, int> = 0> + static parse_error create(int id_, std::size_t byte_, const std::string& what_arg, BasicJsonContext context) { - std::string w = exception::name("parse_error", id_) + "parse error" + - (byte_ != 0 ? (" at byte " + std::to_string(byte_)) : "") + - ": " + exception::diagnostics(context) + what_arg; - return parse_error(id_, byte_, w.c_str()); + const std::string w = concat(exception::name("parse_error", id_), "parse error", + (byte_ != 0 ? (concat(" at byte ", std::to_string(byte_))) : ""), + ": ", exception::diagnostics(context), what_arg); + return {id_, byte_, w.c_str()}; } /*! @@ -218,56 +179,21 @@ class parse_error : public exception static std::string position_string(const position_t& pos) { - return " at line " + std::to_string(pos.lines_read + 1) + - ", column " + std::to_string(pos.chars_read_current_line); + return concat(" at line ", std::to_string(pos.lines_read + 1), + ", column ", std::to_string(pos.chars_read_current_line)); } }; -/*! -@brief exception indicating errors with iterators - -This exception is thrown if iterators passed to a library function do not match -the expected semantics. - -Exceptions have ids 2xx. - -name / id | example message | description ------------------------------------ | --------------- | ------------------------- -json.exception.invalid_iterator.201 | iterators are not compatible | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid. -json.exception.invalid_iterator.202 | iterator does not fit current value | In an erase or insert function, the passed iterator @a pos does not belong to the JSON value for which the function was called. It hence does not define a valid position for the deletion/insertion. -json.exception.invalid_iterator.203 | iterators do not fit current value | Either iterator passed to function @ref erase(IteratorType first, IteratorType last) does not belong to the JSON value from which values shall be erased. It hence does not define a valid range to delete values from. -json.exception.invalid_iterator.204 | iterators out of range | When an iterator range for a primitive type (number, boolean, or string) is passed to a constructor or an erase function, this range has to be exactly (@ref begin(), @ref end()), because this is the only way the single stored value is expressed. All other ranges are invalid. -json.exception.invalid_iterator.205 | iterator out of range | When an iterator for a primitive type (number, boolean, or string) is passed to an erase function, the iterator has to be the @ref begin() iterator, because it is the only way to address the stored value. All other iterators are invalid. -json.exception.invalid_iterator.206 | cannot construct with iterators from null | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) belong to a JSON null value and hence to not define a valid range. -json.exception.invalid_iterator.207 | cannot use key() for non-object iterators | The key() member function can only be used on iterators belonging to a JSON object, because other types do not have a concept of a key. -json.exception.invalid_iterator.208 | cannot use operator[] for object iterators | The operator[] to specify a concrete offset cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. -json.exception.invalid_iterator.209 | cannot use offsets with object iterators | The offset operators (+, -, +=, -=) cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. -json.exception.invalid_iterator.210 | iterators do not fit | The iterator range passed to the insert function are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid. -json.exception.invalid_iterator.211 | passed iterators may not belong to container | The iterator range passed to the insert function must not be a subrange of the container to insert to. -json.exception.invalid_iterator.212 | cannot compare iterators of different containers | When two iterators are compared, they must belong to the same container. -json.exception.invalid_iterator.213 | cannot compare order of object iterators | The order of object iterators cannot be compared, because JSON objects are unordered. -json.exception.invalid_iterator.214 | cannot get value | Cannot get value for iterator: Either the iterator belongs to a null value or it is an iterator to a primitive type (number, boolean, or string), but the iterator is different to @ref begin(). - -@liveexample{The following code shows how an `invalid_iterator` exception can be -caught.,invalid_iterator} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref out_of_range for exceptions indicating access out of the defined range -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ +/// @brief exception indicating errors with iterators +/// @sa https://json.nlohmann.me/api/basic_json/invalid_iterator/ class invalid_iterator : public exception { public: - template - static invalid_iterator create(int id_, const std::string& what_arg, const BasicJsonType& context) + template::value, int> = 0> + static invalid_iterator create(int id_, const std::string& what_arg, BasicJsonContext context) { - std::string w = exception::name("invalid_iterator", id_) + exception::diagnostics(context) + what_arg; - return invalid_iterator(id_, w.c_str()); + const std::string w = concat(exception::name("invalid_iterator", id_), exception::diagnostics(context), what_arg); + return {id_, w.c_str()}; } private: @@ -276,53 +202,16 @@ class invalid_iterator : public exception : exception(id_, what_arg) {} }; -/*! -@brief exception indicating executing a member function with a wrong type - -This exception is thrown in case of a type error; that is, a library function is -executed on a JSON value whose type does not match the expected semantics. - -Exceptions have ids 3xx. - -name / id | example message | description ------------------------------ | --------------- | ------------------------- -json.exception.type_error.301 | cannot create object from initializer list | To create an object from an initializer list, the initializer list must consist only of a list of pairs whose first element is a string. When this constraint is violated, an array is created instead. -json.exception.type_error.302 | type must be object, but is array | During implicit or explicit value conversion, the JSON type must be compatible to the target type. For instance, a JSON string can only be converted into string types, but not into numbers or boolean types. -json.exception.type_error.303 | incompatible ReferenceType for get_ref, actual type is object | To retrieve a reference to a value stored in a @ref basic_json object with @ref get_ref, the type of the reference must match the value type. For instance, for a JSON array, the @a ReferenceType must be @ref array_t &. -json.exception.type_error.304 | cannot use at() with string | The @ref at() member functions can only be executed for certain JSON types. -json.exception.type_error.305 | cannot use operator[] with string | The @ref operator[] member functions can only be executed for certain JSON types. -json.exception.type_error.306 | cannot use value() with string | The @ref value() member functions can only be executed for certain JSON types. -json.exception.type_error.307 | cannot use erase() with string | The @ref erase() member functions can only be executed for certain JSON types. -json.exception.type_error.308 | cannot use push_back() with string | The @ref push_back() and @ref operator+= member functions can only be executed for certain JSON types. -json.exception.type_error.309 | cannot use insert() with | The @ref insert() member functions can only be executed for certain JSON types. -json.exception.type_error.310 | cannot use swap() with number | The @ref swap() member functions can only be executed for certain JSON types. -json.exception.type_error.311 | cannot use emplace_back() with string | The @ref emplace_back() member function can only be executed for certain JSON types. -json.exception.type_error.312 | cannot use update() with string | The @ref update() member functions can only be executed for certain JSON types. -json.exception.type_error.313 | invalid value to unflatten | The @ref unflatten function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well defined. -json.exception.type_error.314 | only objects can be unflattened | The @ref unflatten function only works for an object whose keys are JSON Pointers. -json.exception.type_error.315 | values in object must be primitive | The @ref unflatten function only works for an object whose keys are JSON Pointers and whose values are primitive. -json.exception.type_error.316 | invalid UTF-8 byte at index 10: 0x7E | The @ref dump function only works with UTF-8 encoded strings; that is, if you assign a `std::string` to a JSON value, make sure it is UTF-8 encoded. | -json.exception.type_error.317 | JSON value cannot be serialized to requested format | The dynamic type of the object cannot be represented in the requested serialization format (e.g. a raw `true` or `null` JSON object cannot be serialized to BSON) | - -@liveexample{The following code shows how a `type_error` exception can be -caught.,type_error} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref out_of_range for exceptions indicating access out of the defined range -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ +/// @brief exception indicating executing a member function with a wrong type +/// @sa https://json.nlohmann.me/api/basic_json/type_error/ class type_error : public exception { public: - template - static type_error create(int id_, const std::string& what_arg, const BasicJsonType& context) + template::value, int> = 0> + static type_error create(int id_, const std::string& what_arg, BasicJsonContext context) { - std::string w = exception::name("type_error", id_) + exception::diagnostics(context) + what_arg; - return type_error(id_, w.c_str()); + const std::string w = concat(exception::name("type_error", id_), exception::diagnostics(context), what_arg); + return {id_, w.c_str()}; } private: @@ -330,47 +219,16 @@ class type_error : public exception type_error(int id_, const char* what_arg) : exception(id_, what_arg) {} }; -/*! -@brief exception indicating access out of the defined range - -This exception is thrown in case a library function is called on an input -parameter that exceeds the expected range, for instance in case of array -indices or nonexisting object keys. - -Exceptions have ids 4xx. - -name / id | example message | description -------------------------------- | --------------- | ------------------------- -json.exception.out_of_range.401 | array index 3 is out of range | The provided array index @a i is larger than @a size-1. -json.exception.out_of_range.402 | array index '-' (3) is out of range | The special array index `-` in a JSON Pointer never describes a valid element of the array, but the index past the end. That is, it can only be used to add elements at this position, but not to read it. -json.exception.out_of_range.403 | key 'foo' not found | The provided key was not found in the JSON object. -json.exception.out_of_range.404 | unresolved reference token 'foo' | A reference token in a JSON Pointer could not be resolved. -json.exception.out_of_range.405 | JSON pointer has no parent | The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value. -json.exception.out_of_range.406 | number overflow parsing '10E1000' | A parsed number could not be stored as without changing it to NaN or INF. -json.exception.out_of_range.407 | number overflow serializing '9223372036854775808' | UBJSON and BSON only support integer numbers up to 9223372036854775807. (until version 3.8.0) | -json.exception.out_of_range.408 | excessive array size: 8658170730974374167 | The size (following `#`) of an UBJSON array or object exceeds the maximal capacity. | -json.exception.out_of_range.409 | BSON key cannot contain code point U+0000 (at byte 2) | Key identifiers to be serialized to BSON cannot contain code point U+0000, since the key is stored as zero-terminated c-string | - -@liveexample{The following code shows how an `out_of_range` exception can be -caught.,out_of_range} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ +/// @brief exception indicating access out of the defined range +/// @sa https://json.nlohmann.me/api/basic_json/out_of_range/ class out_of_range : public exception { public: - template - static out_of_range create(int id_, const std::string& what_arg, const BasicJsonType& context) + template::value, int> = 0> + static out_of_range create(int id_, const std::string& what_arg, BasicJsonContext context) { - std::string w = exception::name("out_of_range", id_) + exception::diagnostics(context) + what_arg; - return out_of_range(id_, w.c_str()); + const std::string w = concat(exception::name("out_of_range", id_), exception::diagnostics(context), what_arg); + return {id_, w.c_str()}; } private: @@ -378,43 +236,22 @@ class out_of_range : public exception out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {} }; -/*! -@brief exception indicating other library errors - -This exception is thrown in case of errors that cannot be classified with the -other exception types. - -Exceptions have ids 5xx. - -name / id | example message | description ------------------------------- | --------------- | ------------------------- -json.exception.other_error.501 | unsuccessful: {"op":"test","path":"/baz", "value":"bar"} | A JSON Patch operation 'test' failed. The unsuccessful operation is also printed. - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref out_of_range for exceptions indicating access out of the defined range - -@liveexample{The following code shows how an `other_error` exception can be -caught.,other_error} - -@since version 3.0.0 -*/ +/// @brief exception indicating other library errors +/// @sa https://json.nlohmann.me/api/basic_json/other_error/ class other_error : public exception { public: - template - static other_error create(int id_, const std::string& what_arg, const BasicJsonType& context) + template::value, int> = 0> + static other_error create(int id_, const std::string& what_arg, BasicJsonContext context) { - std::string w = exception::name("other_error", id_) + exception::diagnostics(context) + what_arg; - return other_error(id_, w.c_str()); + const std::string w = concat(exception::name("other_error", id_), exception::diagnostics(context), what_arg); + return {id_, w.c_str()}; } private: JSON_HEDLEY_NON_NULL(3) other_error(int id_, const char* what_arg) : exception(id_, what_arg) {} }; + } // namespace detail -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/hash.hpp b/external_imported/json/include/nlohmann/detail/hash.hpp index c32d5535c..4464e8e67 100644 --- a/external_imported/json/include/nlohmann/detail/hash.hpp +++ b/external_imported/json/include/nlohmann/detail/hash.hpp @@ -1,12 +1,21 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once -#include // size_t, uint8_t +#include // uint8_t +#include // size_t #include // hash -#include +#include +#include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { @@ -102,7 +111,7 @@ std::size_t hash(const BasicJsonType& j) auto seed = combine(type, j.get_binary().size()); const auto h = std::hash {}(j.get_binary().has_subtype()); seed = combine(seed, h); - seed = combine(seed, j.get_binary().subtype()); + seed = combine(seed, static_cast(j.get_binary().subtype())); for (const auto byte : j.get_binary()) { seed = combine(seed, std::hash {}(byte)); @@ -111,10 +120,10 @@ std::size_t hash(const BasicJsonType& j) } default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // LCOV_EXCL_LINE + JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE return 0; // LCOV_EXCL_LINE } } } // namespace detail -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/input/binary_reader.hpp b/external_imported/json/include/nlohmann/detail/input/binary_reader.hpp index ad7359da3..a6e100e76 100644 --- a/external_imported/json/include/nlohmann/detail/input/binary_reader.hpp +++ b/external_imported/json/include/nlohmann/detail/input/binary_reader.hpp @@ -1,3 +1,11 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once #include // generate_n @@ -19,18 +27,20 @@ #include #include #include +#include +#include #include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { /// how to treat CBOR tags enum class cbor_tag_handler_t { - error, ///< throw a parse_error exception in case of a tag - ignore ///< ignore tags + error, ///< throw a parse_error exception in case of a tag + ignore, ///< ignore tags + store ///< store tags as binary type }; /*! @@ -40,12 +50,11 @@ enum class cbor_tag_handler_t @note from https://stackoverflow.com/a/1001328/266378 */ -static inline bool little_endianess(int num = 1) noexcept +static inline bool little_endianness(int num = 1) noexcept { return *reinterpret_cast(&num) == 1; } - /////////////////// // binary reader // /////////////////// @@ -63,7 +72,7 @@ class binary_reader using binary_t = typename BasicJsonType::binary_t; using json_sax_t = SAX; using char_type = typename InputAdapterType::char_type; - using char_int_type = typename std::char_traits::int_type; + using char_int_type = typename char_traits::int_type; public: /*! @@ -71,16 +80,16 @@ class binary_reader @param[in] adapter input adapter to read from */ - explicit binary_reader(InputAdapterType&& adapter) : ia(std::move(adapter)) + explicit binary_reader(InputAdapterType&& adapter, const input_format_t format = input_format_t::json) noexcept : ia(std::move(adapter)), input_format(format) { (void)detail::is_sax_static_asserts {}; } // make class move-only binary_reader(const binary_reader&) = delete; - binary_reader(binary_reader&&) = default; + binary_reader(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) binary_reader& operator=(const binary_reader&) = delete; - binary_reader& operator=(binary_reader&&) = default; + binary_reader& operator=(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) ~binary_reader() = default; /*! @@ -89,7 +98,7 @@ class binary_reader @param[in] strict whether to expect the input to be consumed completed @param[in] tag_handler how to treat CBOR tags - @return + @return whether parsing was successful */ JSON_HEDLEY_NON_NULL(3) bool sax_parse(const input_format_t format, @@ -115,17 +124,19 @@ class binary_reader break; case input_format_t::ubjson: + case input_format_t::bjdata: result = parse_ubjson_internal(); break; + case input_format_t::json: // LCOV_EXCL_LINE default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // LCOV_EXCL_LINE + JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE } // strict mode: next byte must be EOF if (result && strict) { - if (format == input_format_t::ubjson) + if (input_format == input_format_t::ubjson || input_format == input_format_t::bjdata) { get_ignore_noop(); } @@ -134,10 +145,10 @@ class binary_reader get(); } - if (JSON_HEDLEY_UNLIKELY(current != std::char_traits::eof())) + if (JSON_HEDLEY_UNLIKELY(current != char_traits::eof())) { - return sax->parse_error(chars_read, get_token_string(), - parse_error::create(110, chars_read, exception_message(format, "expected end of input; last byte: 0x" + get_token_string(), "value"), BasicJsonType())); + return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read, + exception_message(input_format, concat("expected end of input; last byte: 0x", get_token_string()), "value"), nullptr)); } } @@ -158,7 +169,7 @@ class binary_reader std::int32_t document_size{}; get_number(input_format_t::bson, document_size); - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(static_cast(-1)))) { return false; } @@ -173,7 +184,7 @@ class binary_reader /*! @brief Parses a C-style string from the BSON input. - @param[in, out] result A reference to the string variable where the read + @param[in,out] result A reference to the string variable where the read string is to be stored. @return `true` if the \x00-byte indicating the end of the string was encountered before the EOF; false` indicates an unexpected EOF. @@ -201,7 +212,7 @@ class binary_reader input. @param[in] len The length (including the zero-byte at the end) of the string to be read. - @param[in, out] result A reference to the string variable where the read + @param[in,out] result A reference to the string variable where the read string is to be stored. @tparam NumberType The type of the length @a len @pre len >= 1 @@ -213,16 +224,17 @@ class binary_reader if (JSON_HEDLEY_UNLIKELY(len < 1)) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "string length must be at least 1, is " + std::to_string(len), "string"), BasicJsonType())); + return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, + exception_message(input_format_t::bson, concat("string length must be at least 1, is ", std::to_string(len)), "string"), nullptr)); } - return get_string(input_format_t::bson, len - static_cast(1), result) && get() != std::char_traits::eof(); + return get_string(input_format_t::bson, len - static_cast(1), result) && get() != char_traits::eof(); } /*! @brief Parses a byte array input of length @a len from the BSON input. @param[in] len The length of the byte array to be read. - @param[in, out] result A reference to the binary variable where the read + @param[in,out] result A reference to the binary variable where the read array is to be stored. @tparam NumberType The type of the length @a len @pre len >= 0 @@ -234,7 +246,8 @@ class binary_reader if (JSON_HEDLEY_UNLIKELY(len < 0)) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "byte array length cannot be negative, is " + std::to_string(len), "binary"), BasicJsonType())); + return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, + exception_message(input_format_t::bson, concat("byte array length cannot be negative, is ", std::to_string(len)), "binary"), nullptr)); } // All BSON binary values have a subtype @@ -315,8 +328,10 @@ class binary_reader default: // anything else not supported (yet) { std::array cr{{}}; - (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(element_type)); - return sax->parse_error(element_type_parse_position, std::string(cr.data()), parse_error::create(114, element_type_parse_position, "Unsupported BSON record type 0x" + std::string(cr.data()), BasicJsonType())); + static_cast((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(element_type))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + const std::string cr_str{cr.data()}; + return sax->parse_error(element_type_parse_position, cr_str, + parse_error::create(114, element_type_parse_position, concat("Unsupported BSON record type 0x", cr_str), nullptr)); } } } @@ -376,7 +391,7 @@ class binary_reader std::int32_t document_size{}; get_number(input_format_t::bson, document_size); - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_array(static_cast(-1)))) { return false; } @@ -407,7 +422,7 @@ class binary_reader switch (get_char ? get() : current) { // EOF - case std::char_traits::eof(): + case char_traits::eof(): return unexpect_eof(input_format_t::cbor, "value"); // Integer 0x00..0x17 (0..23) @@ -608,7 +623,8 @@ class binary_reader case 0x95: case 0x96: case 0x97: - return get_cbor_array(static_cast(static_cast(current) & 0x1Fu), tag_handler); + return get_cbor_array( + conditional_static_cast(static_cast(current) & 0x1Fu), tag_handler); case 0x98: // array (one-byte uint8_t for n follows) { @@ -625,17 +641,17 @@ class binary_reader case 0x9A: // array (four-byte uint32_t for n follow) { std::uint32_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); + return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast(len), tag_handler); } case 0x9B: // array (eight-byte uint64_t for n follow) { std::uint64_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); + return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast(len), tag_handler); } case 0x9F: // array (indefinite length) - return get_cbor_array(std::size_t(-1), tag_handler); + return get_cbor_array(static_cast(-1), tag_handler); // map (0x00..0x17 pairs of data items follow) case 0xA0: @@ -662,7 +678,7 @@ class binary_reader case 0xB5: case 0xB6: case 0xB7: - return get_cbor_object(static_cast(static_cast(current) & 0x1Fu), tag_handler); + return get_cbor_object(conditional_static_cast(static_cast(current) & 0x1Fu), tag_handler); case 0xB8: // map (one-byte uint8_t for n follows) { @@ -679,17 +695,17 @@ class binary_reader case 0xBA: // map (four-byte uint32_t for n follow) { std::uint32_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); + return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast(len), tag_handler); } case 0xBB: // map (eight-byte uint64_t for n follow) { std::uint64_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); + return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast(len), tag_handler); } case 0xBF: // map (indefinite length) - return get_cbor_object(std::size_t(-1), tag_handler); + return get_cbor_object(static_cast(-1), tag_handler); case 0xC6: // tagged item case 0xC7: @@ -716,35 +732,37 @@ class binary_reader case cbor_tag_handler_t::error: { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, "invalid byte: 0x" + last_token, "value"), BasicJsonType())); + return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, + exception_message(input_format_t::cbor, concat("invalid byte: 0x", last_token), "value"), nullptr)); } case cbor_tag_handler_t::ignore: { + // ignore binary subtype switch (current) { case 0xD8: { - std::uint8_t len{}; - get_number(input_format_t::cbor, len); + std::uint8_t subtype_to_ignore{}; + get_number(input_format_t::cbor, subtype_to_ignore); break; } case 0xD9: { - std::uint16_t len{}; - get_number(input_format_t::cbor, len); + std::uint16_t subtype_to_ignore{}; + get_number(input_format_t::cbor, subtype_to_ignore); break; } case 0xDA: { - std::uint32_t len{}; - get_number(input_format_t::cbor, len); + std::uint32_t subtype_to_ignore{}; + get_number(input_format_t::cbor, subtype_to_ignore); break; } case 0xDB: { - std::uint64_t len{}; - get_number(input_format_t::cbor, len); + std::uint64_t subtype_to_ignore{}; + get_number(input_format_t::cbor, subtype_to_ignore); break; } default: @@ -753,8 +771,49 @@ class binary_reader return parse_cbor_internal(true, tag_handler); } + case cbor_tag_handler_t::store: + { + binary_t b; + // use binary subtype and store in binary container + switch (current) + { + case 0xD8: + { + std::uint8_t subtype{}; + get_number(input_format_t::cbor, subtype); + b.set_subtype(detail::conditional_static_cast(subtype)); + break; + } + case 0xD9: + { + std::uint16_t subtype{}; + get_number(input_format_t::cbor, subtype); + b.set_subtype(detail::conditional_static_cast(subtype)); + break; + } + case 0xDA: + { + std::uint32_t subtype{}; + get_number(input_format_t::cbor, subtype); + b.set_subtype(detail::conditional_static_cast(subtype)); + break; + } + case 0xDB: + { + std::uint64_t subtype{}; + get_number(input_format_t::cbor, subtype); + b.set_subtype(detail::conditional_static_cast(subtype)); + break; + } + default: + return parse_cbor_internal(true, tag_handler); + } + get(); + return get_cbor_binary(b) && sax->binary(b); + } + default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // LCOV_EXCL_LINE + JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE return false; // LCOV_EXCL_LINE } } @@ -831,7 +890,8 @@ class binary_reader default: // anything else (0xFF is handled inside the other types) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, "invalid byte: 0x" + last_token, "value"), BasicJsonType())); + return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, + exception_message(input_format_t::cbor, concat("invalid byte: 0x", last_token), "value"), nullptr)); } } } @@ -926,7 +986,8 @@ class binary_reader default: { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, "expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x" + last_token, "string"), BasicJsonType())); + return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, + exception_message(input_format_t::cbor, concat("expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token), "string"), nullptr)); } } } @@ -1025,13 +1086,14 @@ class binary_reader default: { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, "expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x" + last_token, "binary"), BasicJsonType())); + return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, + exception_message(input_format_t::cbor, concat("expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x", last_token), "binary"), nullptr)); } } } /*! - @param[in] len the length of the array or std::size_t(-1) for an + @param[in] len the length of the array or static_cast(-1) for an array of indefinite size @param[in] tag_handler how CBOR tags should be treated @return whether array creation completed @@ -1044,7 +1106,7 @@ class binary_reader return false; } - if (len != std::size_t(-1)) + if (len != static_cast(-1)) { for (std::size_t i = 0; i < len; ++i) { @@ -1069,7 +1131,7 @@ class binary_reader } /*! - @param[in] len the length of the object or std::size_t(-1) for an + @param[in] len the length of the object or static_cast(-1) for an object of indefinite size @param[in] tag_handler how CBOR tags should be treated @return whether object creation completed @@ -1082,38 +1144,41 @@ class binary_reader return false; } - string_t key; - if (len != std::size_t(-1)) + if (len != 0) { - for (std::size_t i = 0; i < len; ++i) + string_t key; + if (len != static_cast(-1)) { - get(); - if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key))) + for (std::size_t i = 0; i < len; ++i) { - return false; - } + get(); + if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key))) + { + return false; + } - if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) - { - return false; + if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) + { + return false; + } + key.clear(); } - key.clear(); } - } - else - { - while (get() != 0xFF) + else { - if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key))) + while (get() != 0xFF) { - return false; - } + if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key))) + { + return false; + } - if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) - { - return false; + if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) + { + return false; + } + key.clear(); } - key.clear(); } } @@ -1132,7 +1197,7 @@ class binary_reader switch (get()) { // EOF - case std::char_traits::eof(): + case char_traits::eof(): return unexpect_eof(input_format_t::msgpack, "value"); // positive fixint @@ -1283,7 +1348,7 @@ class binary_reader case 0x8D: case 0x8E: case 0x8F: - return get_msgpack_object(static_cast(static_cast(current) & 0x0Fu)); + return get_msgpack_object(conditional_static_cast(static_cast(current) & 0x0Fu)); // fixarray case 0x90: @@ -1302,7 +1367,7 @@ class binary_reader case 0x9D: case 0x9E: case 0x9F: - return get_msgpack_array(static_cast(static_cast(current) & 0x0Fu)); + return get_msgpack_array(conditional_static_cast(static_cast(current) & 0x0Fu)); // fixstr case 0xA0: @@ -1439,7 +1504,7 @@ class binary_reader case 0xDD: // array 32 { std::uint32_t len{}; - return get_number(input_format_t::msgpack, len) && get_msgpack_array(static_cast(len)); + return get_number(input_format_t::msgpack, len) && get_msgpack_array(conditional_static_cast(len)); } case 0xDE: // map 16 @@ -1451,7 +1516,7 @@ class binary_reader case 0xDF: // map 32 { std::uint32_t len{}; - return get_number(input_format_t::msgpack, len) && get_msgpack_object(static_cast(len)); + return get_number(input_format_t::msgpack, len) && get_msgpack_object(conditional_static_cast(len)); } // negative fixint @@ -1492,7 +1557,8 @@ class binary_reader default: // anything else { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::msgpack, "invalid byte: 0x" + last_token, "value"), BasicJsonType())); + return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, + exception_message(input_format_t::msgpack, concat("invalid byte: 0x", last_token), "value"), nullptr)); } } } @@ -1574,7 +1640,8 @@ class binary_reader default: { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::msgpack, "expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x" + last_token, "string"), BasicJsonType())); + return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, + exception_message(input_format_t::msgpack, concat("expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token), "string"), nullptr)); } } } @@ -1785,7 +1852,7 @@ class binary_reader get(); // TODO(niels): may we ignore N here? } - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "value"))) + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "value"))) { return false; } @@ -1795,51 +1862,162 @@ class binary_reader case 'U': { std::uint8_t len{}; - return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); + return get_number(input_format, len) && get_string(input_format, len, result); } case 'i': { std::int8_t len{}; - return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); + return get_number(input_format, len) && get_string(input_format, len, result); } case 'I': { std::int16_t len{}; - return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); + return get_number(input_format, len) && get_string(input_format, len, result); } case 'l': { std::int32_t len{}; - return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); + return get_number(input_format, len) && get_string(input_format, len, result); } case 'L': { std::int64_t len{}; - return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); + return get_number(input_format, len) && get_string(input_format, len, result); + } + + case 'u': + { + if (input_format != input_format_t::bjdata) + { + break; + } + std::uint16_t len{}; + return get_number(input_format, len) && get_string(input_format, len, result); + } + + case 'm': + { + if (input_format != input_format_t::bjdata) + { + break; + } + std::uint32_t len{}; + return get_number(input_format, len) && get_string(input_format, len, result); + } + + case 'M': + { + if (input_format != input_format_t::bjdata) + { + break; + } + std::uint64_t len{}; + return get_number(input_format, len) && get_string(input_format, len, result); } default: - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L); last byte: 0x" + last_token, "string"), BasicJsonType())); + break; + } + auto last_token = get_token_string(); + std::string message; + + if (input_format != input_format_t::bjdata) + { + message = "expected length type specification (U, i, I, l, L); last byte: 0x" + last_token; } + else + { + message = "expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token; + } + return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message, "string"), nullptr)); + } + + /*! + @param[out] dim an integer vector storing the ND array dimensions + @return whether reading ND array size vector is successful + */ + bool get_ubjson_ndarray_size(std::vector& dim) + { + std::pair size_and_type; + size_t dimlen = 0; + bool no_ndarray = true; + + if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type, no_ndarray))) + { + return false; + } + + if (size_and_type.first != npos) + { + if (size_and_type.second != 0) + { + if (size_and_type.second != 'N') + { + for (std::size_t i = 0; i < size_and_type.first; ++i) + { + if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_value(dimlen, no_ndarray, size_and_type.second))) + { + return false; + } + dim.push_back(dimlen); + } + } + } + else + { + for (std::size_t i = 0; i < size_and_type.first; ++i) + { + if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_value(dimlen, no_ndarray))) + { + return false; + } + dim.push_back(dimlen); + } + } + } + else + { + while (current != ']') + { + if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_value(dimlen, no_ndarray, current))) + { + return false; + } + dim.push_back(dimlen); + get_ignore_noop(); + } + } + return true; } /*! @param[out] result determined size + @param[in,out] is_ndarray for input, `true` means already inside an ndarray vector + or ndarray dimension is not allowed; `false` means ndarray + is allowed; for output, `true` means an ndarray is found; + is_ndarray can only return `true` when its initial value + is `false` + @param[in] prefix type marker if already read, otherwise set to 0 + @return whether size determination completed */ - bool get_ubjson_size_value(std::size_t& result) + bool get_ubjson_size_value(std::size_t& result, bool& is_ndarray, char_int_type prefix = 0) { - switch (get_ignore_noop()) + if (prefix == 0) + { + prefix = get_ignore_noop(); + } + + switch (prefix) { case 'U': { std::uint8_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) + if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) { return false; } @@ -1850,21 +2028,31 @@ class binary_reader case 'i': { std::int8_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) + if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) { return false; } - result = static_cast(number); + if (number < 0) + { + return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, + exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); + } + result = static_cast(number); // NOLINT(bugprone-signed-char-misuse,cert-str34-c): number is not a char return true; } case 'I': { std::int16_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) + if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) { return false; } + if (number < 0) + { + return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, + exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); + } result = static_cast(number); return true; } @@ -1872,10 +2060,15 @@ class binary_reader case 'l': { std::int32_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) + if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) { return false; } + if (number < 0) + { + return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, + exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); + } result = static_cast(number); return true; } @@ -1883,20 +2076,145 @@ class binary_reader case 'L': { std::int64_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) + if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) { return false; } + if (number < 0) + { + return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, + exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); + } + if (!value_in_range_of(number)) + { + return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, + exception_message(input_format, "integer value overflow", "size"), nullptr)); + } result = static_cast(number); return true; } - default: + case 'u': { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token, "size"), BasicJsonType())); + if (input_format != input_format_t::bjdata) + { + break; + } + std::uint16_t number{}; + if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) + { + return false; + } + result = static_cast(number); + return true; + } + + case 'm': + { + if (input_format != input_format_t::bjdata) + { + break; + } + std::uint32_t number{}; + if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) + { + return false; + } + result = conditional_static_cast(number); + return true; + } + + case 'M': + { + if (input_format != input_format_t::bjdata) + { + break; + } + std::uint64_t number{}; + if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) + { + return false; + } + if (!value_in_range_of(number)) + { + return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, + exception_message(input_format, "integer value overflow", "size"), nullptr)); + } + result = detail::conditional_static_cast(number); + return true; } + + case '[': + { + if (input_format != input_format_t::bjdata) + { + break; + } + if (is_ndarray) // ndarray dimensional vector can only contain integers, and can not embed another array + { + return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "ndarray dimensional vector is not allowed", "size"), nullptr)); + } + std::vector dim; + if (JSON_HEDLEY_UNLIKELY(!get_ubjson_ndarray_size(dim))) + { + return false; + } + if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1)) // return normal array size if 1D row vector + { + result = dim.at(dim.size() - 1); + return true; + } + if (!dim.empty()) // if ndarray, convert to an object in JData annotated array format + { + for (auto i : dim) // test if any dimension in an ndarray is 0, if so, return a 1D empty container + { + if ( i == 0 ) + { + result = 0; + return true; + } + } + + string_t key = "_ArraySize_"; + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(3) || !sax->key(key) || !sax->start_array(dim.size()))) + { + return false; + } + result = 1; + for (auto i : dim) + { + result *= i; + if (result == 0 || result == npos) // because dim elements shall not have zeros, result = 0 means overflow happened; it also can't be npos as it is used to initialize size in get_ubjson_size_type() + { + return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format, "excessive ndarray size caused overflow", "size"), nullptr)); + } + if (JSON_HEDLEY_UNLIKELY(!sax->number_unsigned(static_cast(i)))) + { + return false; + } + } + is_ndarray = true; + return sax->end_array(); + } + result = 0; + return true; + } + + default: + break; } + auto last_token = get_token_string(); + std::string message; + + if (input_format != input_format_t::bjdata) + { + message = "expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token; + } + else + { + message = "expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token; + } + return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message, "size"), nullptr)); } /*! @@ -1906,20 +2224,30 @@ class binary_reader for a more compact representation. @param[out] result pair of the size and the type + @param[in] inside_ndarray whether the parser is parsing an ND array dimensional vector @return whether pair creation completed */ - bool get_ubjson_size_type(std::pair& result) + bool get_ubjson_size_type(std::pair& result, bool inside_ndarray = false) { - result.first = string_t::npos; // size + result.first = npos; // size result.second = 0; // type + bool is_ndarray = false; get_ignore_noop(); if (current == '$') { result.second = get(); // must not ignore 'N', because 'N' maybe the type - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "type"))) + if (input_format == input_format_t::bjdata + && JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second))) + { + auto last_token = get_token_string(); + return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, + exception_message(input_format, concat("marker 0x", last_token, " is not a permitted optimized array type"), "type"), nullptr)); + } + + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "type"))) { return false; } @@ -1927,20 +2255,37 @@ class binary_reader get_ignore_noop(); if (JSON_HEDLEY_UNLIKELY(current != '#')) { - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "value"))) + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "value"))) { return false; } auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::ubjson, "expected '#' after type information; last byte: 0x" + last_token, "size"), BasicJsonType())); + return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, + exception_message(input_format, concat("expected '#' after type information; last byte: 0x", last_token), "size"), nullptr)); } - return get_ubjson_size_value(result.first); + const bool is_error = get_ubjson_size_value(result.first, is_ndarray); + if (input_format == input_format_t::bjdata && is_ndarray) + { + if (inside_ndarray) + { + return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read, + exception_message(input_format, "ndarray can not be recursive", "size"), nullptr)); + } + result.second |= (1 << 8); // use bit 8 to indicate ndarray, all UBJSON and BJData markers should be ASCII letters + } + return is_error; } if (current == '#') { - return get_ubjson_size_value(result.first); + const bool is_error = get_ubjson_size_value(result.first, is_ndarray); + if (input_format == input_format_t::bjdata && is_ndarray) + { + return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read, + exception_message(input_format, "ndarray requires both type and size", "size"), nullptr)); + } + return is_error; } return true; @@ -1954,8 +2299,8 @@ class binary_reader { switch (prefix) { - case std::char_traits::eof(): // EOF - return unexpect_eof(input_format_t::ubjson, "value"); + case char_traits::eof(): // EOF + return unexpect_eof(input_format, "value"); case 'T': // true return sax->boolean(true); @@ -1968,43 +2313,125 @@ class binary_reader case 'U': { std::uint8_t number{}; - return get_number(input_format_t::ubjson, number) && sax->number_unsigned(number); + return get_number(input_format, number) && sax->number_unsigned(number); } case 'i': { std::int8_t number{}; - return get_number(input_format_t::ubjson, number) && sax->number_integer(number); + return get_number(input_format, number) && sax->number_integer(number); } case 'I': { std::int16_t number{}; - return get_number(input_format_t::ubjson, number) && sax->number_integer(number); + return get_number(input_format, number) && sax->number_integer(number); } case 'l': { std::int32_t number{}; - return get_number(input_format_t::ubjson, number) && sax->number_integer(number); + return get_number(input_format, number) && sax->number_integer(number); } case 'L': { std::int64_t number{}; - return get_number(input_format_t::ubjson, number) && sax->number_integer(number); + return get_number(input_format, number) && sax->number_integer(number); + } + + case 'u': + { + if (input_format != input_format_t::bjdata) + { + break; + } + std::uint16_t number{}; + return get_number(input_format, number) && sax->number_unsigned(number); + } + + case 'm': + { + if (input_format != input_format_t::bjdata) + { + break; + } + std::uint32_t number{}; + return get_number(input_format, number) && sax->number_unsigned(number); + } + + case 'M': + { + if (input_format != input_format_t::bjdata) + { + break; + } + std::uint64_t number{}; + return get_number(input_format, number) && sax->number_unsigned(number); + } + + case 'h': + { + if (input_format != input_format_t::bjdata) + { + break; + } + const auto byte1_raw = get(); + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "number"))) + { + return false; + } + const auto byte2_raw = get(); + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "number"))) + { + return false; + } + + const auto byte1 = static_cast(byte1_raw); + const auto byte2 = static_cast(byte2_raw); + + // code from RFC 7049, Appendix D, Figure 3: + // As half-precision floating-point numbers were only added + // to IEEE 754 in 2008, today's programming platforms often + // still only have limited support for them. It is very + // easy to include at least decoding support for them even + // without such support. An example of a small decoder for + // half-precision floating-point numbers in the C language + // is shown in Fig. 3. + const auto half = static_cast((byte2 << 8u) + byte1); + const double val = [&half] + { + const int exp = (half >> 10u) & 0x1Fu; + const unsigned int mant = half & 0x3FFu; + JSON_ASSERT(0 <= exp&& exp <= 32); + JSON_ASSERT(mant <= 1024); + switch (exp) + { + case 0: + return std::ldexp(mant, -24); + case 31: + return (mant == 0) + ? std::numeric_limits::infinity() + : std::numeric_limits::quiet_NaN(); + default: + return std::ldexp(mant + 1024, exp - 25); + } + }(); + return sax->number_float((half & 0x8000u) != 0 + ? static_cast(-val) + : static_cast(val), ""); } case 'd': { float number{}; - return get_number(input_format_t::ubjson, number) && sax->number_float(static_cast(number), ""); + return get_number(input_format, number) && sax->number_float(static_cast(number), ""); } case 'D': { double number{}; - return get_number(input_format_t::ubjson, number) && sax->number_float(static_cast(number), ""); + return get_number(input_format, number) && sax->number_float(static_cast(number), ""); } case 'H': @@ -2015,14 +2442,15 @@ class binary_reader case 'C': // char { get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "char"))) + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "char"))) { return false; } if (JSON_HEDLEY_UNLIKELY(current > 127)) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token, "char"), BasicJsonType())); + return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, + exception_message(input_format, concat("byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token), "char"), nullptr)); } string_t s(1, static_cast(current)); return sax->string(s); @@ -2041,11 +2469,10 @@ class binary_reader return get_ubjson_object(); default: // anything else - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::ubjson, "invalid byte: 0x" + last_token, "value"), BasicJsonType())); - } + break; } + auto last_token = get_token_string(); + return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format, "invalid byte: 0x" + last_token, "value"), nullptr)); } /*! @@ -2059,7 +2486,53 @@ class binary_reader return false; } - if (size_and_type.first != string_t::npos) + // if bit-8 of size_and_type.second is set to 1, encode bjdata ndarray as an object in JData annotated array format (https://github.com/NeuroJSON/jdata): + // {"_ArrayType_" : "typeid", "_ArraySize_" : [n1, n2, ...], "_ArrayData_" : [v1, v2, ...]} + + if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0) + { + size_and_type.second &= ~(static_cast(1) << 8); // use bit 8 to indicate ndarray, here we remove the bit to restore the type marker + auto it = std::lower_bound(bjd_types_map.begin(), bjd_types_map.end(), size_and_type.second, [](const bjd_type & p, char_int_type t) + { + return p.first < t; + }); + string_t key = "_ArrayType_"; + if (JSON_HEDLEY_UNLIKELY(it == bjd_types_map.end() || it->first != size_and_type.second)) + { + auto last_token = get_token_string(); + return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, + exception_message(input_format, "invalid byte: 0x" + last_token, "type"), nullptr)); + } + + string_t type = it->second; // sax->string() takes a reference + if (JSON_HEDLEY_UNLIKELY(!sax->key(key) || !sax->string(type))) + { + return false; + } + + if (size_and_type.second == 'C') + { + size_and_type.second = 'U'; + } + + key = "_ArrayData_"; + if (JSON_HEDLEY_UNLIKELY(!sax->key(key) || !sax->start_array(size_and_type.first) )) + { + return false; + } + + for (std::size_t i = 0; i < size_and_type.first; ++i) + { + if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second))) + { + return false; + } + } + + return (sax->end_array() && sax->end_object()); + } + + if (size_and_type.first != npos) { if (JSON_HEDLEY_UNLIKELY(!sax->start_array(size_and_type.first))) { @@ -2092,7 +2565,7 @@ class binary_reader } else { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_array(static_cast(-1)))) { return false; } @@ -2121,8 +2594,16 @@ class binary_reader return false; } + // do not accept ND-array size in objects in BJData + if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0) + { + auto last_token = get_token_string(); + return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, + exception_message(input_format, "BJData object does not support ND-array size in optimized format", "object"), nullptr)); + } + string_t key; - if (size_and_type.first != string_t::npos) + if (size_and_type.first != npos) { if (JSON_HEDLEY_UNLIKELY(!sax->start_object(size_and_type.first))) { @@ -2162,7 +2643,7 @@ class binary_reader } else { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(static_cast(-1)))) { return false; } @@ -2192,7 +2673,8 @@ class binary_reader { // get size of following number string std::size_t size{}; - auto res = get_ubjson_size_value(size); + bool no_ndarray = true; + auto res = get_ubjson_size_value(size, no_ndarray); if (JSON_HEDLEY_UNLIKELY(!res)) { return res; @@ -2203,7 +2685,7 @@ class binary_reader for (std::size_t i = 0; i < size; ++i) { get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "number"))) + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "number"))) { return false; } @@ -2211,8 +2693,8 @@ class binary_reader } // parse number string - auto number_ia = detail::input_adapter(std::forward(number_vector)); - auto number_lexer = detail::lexer(std::move(number_ia), false); + using ia_type = decltype(detail::input_adapter(number_vector)); + auto number_lexer = detail::lexer(detail::input_adapter(number_vector), false); const auto result_number = number_lexer.scan(); const auto number_string = number_lexer.get_token_string(); const auto result_remainder = number_lexer.scan(); @@ -2221,7 +2703,8 @@ class binary_reader if (JSON_HEDLEY_UNLIKELY(result_remainder != token_type::end_of_input)) { - return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format_t::ubjson, "invalid number text: " + number_lexer.get_token_string(), "high-precision number"), BasicJsonType())); + return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, + exception_message(input_format, concat("invalid number text: ", number_lexer.get_token_string()), "high-precision number"), nullptr)); } switch (result_number) @@ -2232,8 +2715,23 @@ class binary_reader return sax->number_unsigned(number_lexer.get_number_unsigned()); case token_type::value_float: return sax->number_float(number_lexer.get_number_float(), std::move(number_string)); + case token_type::uninitialized: + case token_type::literal_true: + case token_type::literal_false: + case token_type::literal_null: + case token_type::value_string: + case token_type::begin_array: + case token_type::begin_object: + case token_type::end_array: + case token_type::end_object: + case token_type::name_separator: + case token_type::value_separator: + case token_type::parse_error: + case token_type::end_of_input: + case token_type::literal_or_value: default: - return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format_t::ubjson, "invalid number text: " + number_lexer.get_token_string(), "high-precision number"), BasicJsonType())); + return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, + exception_message(input_format, concat("invalid number text: ", number_lexer.get_token_string()), "high-precision number"), nullptr)); } } @@ -2246,7 +2744,7 @@ class binary_reader This function provides the interface to the used input adapter. It does not throw in case the input reached EOF, but returns a -'ve valued - `std::char_traits::eof()` in that case. + `char_traits::eof()` in that case. @return character read from the input */ @@ -2279,15 +2777,17 @@ class binary_reader @return whether conversion completed - @note This function needs to respect the system's endianess, because + @note This function needs to respect the system's endianness, because bytes in CBOR, MessagePack, and UBJSON are stored in network order (big endian) and therefore need reordering on little endian systems. + On the other hand, BSON and BJData use little endian and should reorder + on big endian systems. */ template bool get_number(const input_format_t format, NumberType& result) { // step 1: read input into array with system's byte order - std::array vec; + std::array vec{}; for (std::size_t i = 0; i < sizeof(NumberType); ++i) { get(); @@ -2297,7 +2797,7 @@ class binary_reader } // reverse byte order prior to conversion if necessary - if (is_little_endian != InputIsLittleEndian) + if (is_little_endian != (InputIsLittleEndian || format == input_format_t::bjdata)) { vec[sizeof(NumberType) - i - 1] = static_cast(current); } @@ -2386,10 +2886,10 @@ class binary_reader JSON_HEDLEY_NON_NULL(3) bool unexpect_eof(const input_format_t format, const char* context) const { - if (JSON_HEDLEY_UNLIKELY(current == std::char_traits::eof())) + if (JSON_HEDLEY_UNLIKELY(current == char_traits::eof())) { return sax->parse_error(chars_read, "", - parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context), BasicJsonType())); + parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context), nullptr)); } return true; } @@ -2400,7 +2900,7 @@ class binary_reader std::string get_token_string() const { std::array cr{{}}; - (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(current)); + static_cast((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(current))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) return std::string{cr.data()}; } @@ -2434,28 +2934,76 @@ class binary_reader error_msg += "BSON"; break; + case input_format_t::bjdata: + error_msg += "BJData"; + break; + + case input_format_t::json: // LCOV_EXCL_LINE default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // LCOV_EXCL_LINE + JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE } - return error_msg + " " + context + ": " + detail; + return concat(error_msg, ' ', context, ": ", detail); } private: + static JSON_INLINE_VARIABLE constexpr std::size_t npos = static_cast(-1); + /// input adapter InputAdapterType ia; /// the current character - char_int_type current = std::char_traits::eof(); + char_int_type current = char_traits::eof(); /// the number of characters read std::size_t chars_read = 0; - /// whether we can assume little endianess - const bool is_little_endian = little_endianess(); + /// whether we can assume little endianness + const bool is_little_endian = little_endianness(); + + /// input format + const input_format_t input_format = input_format_t::json; /// the SAX parser json_sax_t* sax = nullptr; + + // excluded markers in bjdata optimized type +#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \ + make_array('F', 'H', 'N', 'S', 'T', 'Z', '[', '{') + +#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \ + make_array( \ + bjd_type{'C', "char"}, \ + bjd_type{'D', "double"}, \ + bjd_type{'I', "int16"}, \ + bjd_type{'L', "int64"}, \ + bjd_type{'M', "uint64"}, \ + bjd_type{'U', "uint8"}, \ + bjd_type{'d', "single"}, \ + bjd_type{'i', "int8"}, \ + bjd_type{'l', "int32"}, \ + bjd_type{'m', "uint32"}, \ + bjd_type{'u', "uint16"}) + + JSON_PRIVATE_UNLESS_TESTED: + // lookup tables + // NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes) + const decltype(JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_) bjd_optimized_type_markers = + JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_; + + using bjd_type = std::pair; + // NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes) + const decltype(JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_) bjd_types_map = + JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_; + +#undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ +#undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ }; + +#ifndef JSON_HAS_CPP_17 + template + constexpr std::size_t binary_reader::npos; +#endif + } // namespace detail -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/input/input_adapters.hpp b/external_imported/json/include/nlohmann/detail/input/input_adapters.hpp index c437564fd..33fca3e4b 100644 --- a/external_imported/json/include/nlohmann/detail/input/input_adapters.hpp +++ b/external_imported/json/include/nlohmann/detail/input/input_adapters.hpp @@ -1,10 +1,16 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once #include // array #include // size_t -#include //FILE * #include // strlen -#include // istream #include // begin, end, iterator_traits, random_access_iterator_tag, distance, next #include // shared_ptr, make_shared, addressof #include // accumulate @@ -12,20 +18,27 @@ #include // enable_if, is_base_of, is_pointer, is_integral, remove_pointer #include // pair, declval +#ifndef JSON_NO_IO + #include // FILE * + #include // istream +#endif // JSON_NO_IO + #include #include +#include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /// the supported input formats -enum class input_format_t { json, cbor, msgpack, ubjson, bson }; +enum class input_format_t { json, cbor, msgpack, ubjson, bson, bjdata }; //////////////////// // input adapters // //////////////////// +#ifndef JSON_NO_IO /*! Input adapter for stdio file access. This adapter read only 1 byte and do not use any buffer. This adapter is a very low level adapter. @@ -38,13 +51,16 @@ class file_input_adapter JSON_HEDLEY_NON_NULL(2) explicit file_input_adapter(std::FILE* f) noexcept : m_file(f) - {} + { + JSON_ASSERT(m_file != nullptr); + } // make class move-only file_input_adapter(const file_input_adapter&) = delete; - file_input_adapter(file_input_adapter&&) = default; + file_input_adapter(file_input_adapter&&) noexcept = default; file_input_adapter& operator=(const file_input_adapter&) = delete; file_input_adapter& operator=(file_input_adapter&&) = delete; + ~file_input_adapter() = default; std::char_traits::int_type get_character() noexcept { @@ -56,7 +72,6 @@ class file_input_adapter std::FILE* m_file; }; - /*! Input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at beginning of input. Does not support changing the underlying std::streambuf @@ -88,9 +103,10 @@ class input_stream_adapter // delete because of pointer members input_stream_adapter(const input_stream_adapter&) = delete; input_stream_adapter& operator=(input_stream_adapter&) = delete; - input_stream_adapter& operator=(input_stream_adapter&& rhs) = delete; + input_stream_adapter& operator=(input_stream_adapter&&) = delete; - input_stream_adapter(input_stream_adapter&& rhs) noexcept : is(rhs.is), sb(rhs.sb) + input_stream_adapter(input_stream_adapter&& rhs) noexcept + : is(rhs.is), sb(rhs.sb) { rhs.is = nullptr; rhs.sb = nullptr; @@ -98,12 +114,12 @@ class input_stream_adapter // std::istream/std::streambuf use std::char_traits::to_int_type, to // ensure that std::char_traits::eof() and the character 0xFF do not - // end up as the same value, eg. 0xFFFFFFFF. + // end up as the same value, e.g. 0xFFFFFFFF. std::char_traits::int_type get_character() { auto res = sb->sbumpc(); // set eof manually, as we don't use the istream interface. - if (JSON_HEDLEY_UNLIKELY(res == EOF)) + if (JSON_HEDLEY_UNLIKELY(res == std::char_traits::eof())) { is->clear(is->rdstate() | std::ios::eofbit); } @@ -115,6 +131,7 @@ class input_stream_adapter std::istream* is = nullptr; std::streambuf* sb = nullptr; }; +#endif // JSON_NO_IO // General-purpose iterator-based adapter. It might not be as fast as // theoretically possible for some containers, but it is extremely versatile. @@ -125,18 +142,19 @@ class iterator_input_adapter using char_type = typename std::iterator_traits::value_type; iterator_input_adapter(IteratorType first, IteratorType last) - : current(std::move(first)), end(std::move(last)) {} + : current(std::move(first)), end(std::move(last)) + {} - typename std::char_traits::int_type get_character() + typename char_traits::int_type get_character() { if (JSON_HEDLEY_LIKELY(current != end)) { - auto result = std::char_traits::to_int_type(*current); + auto result = char_traits::to_int_type(*current); std::advance(current, 1); return result; } - return std::char_traits::eof(); + return char_traits::eof(); } private: @@ -150,10 +168,8 @@ class iterator_input_adapter { return current == end; } - }; - template struct wide_string_input_helper; @@ -277,7 +293,7 @@ struct wide_string_input_helper } }; -// Wraps another input apdater to convert wide character types into individual bytes. +// Wraps another input adapter to convert wide character types into individual bytes. template class wide_string_input_adapter { @@ -322,7 +338,6 @@ class wide_string_input_adapter std::size_t utf8_bytes_filled = 0; }; - template struct iterator_input_adapter_factory { @@ -393,7 +408,7 @@ struct container_input_adapter_factory< ContainerType, } }; -} +} // namespace container_input_adapter_factory_impl template typename container_input_adapter_factory_impl::container_input_adapter_factory::adapter_type input_adapter(const ContainerType& container) @@ -401,6 +416,7 @@ typename container_input_adapter_factory_impl::container_input_adapter_factory::create(container); } +#ifndef JSON_NO_IO // Special cases with fast paths inline file_input_adapter input_adapter(std::FILE* file) { @@ -416,6 +432,7 @@ inline input_stream_adapter input_adapter(std::istream&& stream) { return input_stream_adapter(stream); } +#endif // JSON_NO_IO using contiguous_bytes_input_adapter = decltype(input_adapter(std::declval(), std::declval())); @@ -435,13 +452,13 @@ contiguous_bytes_input_adapter input_adapter(CharT b) } template -auto input_adapter(T (&array)[N]) -> decltype(input_adapter(array, array + N)) +auto input_adapter(T (&array)[N]) -> decltype(input_adapter(array, array + N)) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) { return input_adapter(array, array + N); } // This class only handles inputs of input_buffer_adapter type. -// It's required so that expressions like {ptr, len} can be implicitely casted +// It's required so that expressions like {ptr, len} can be implicitly cast // to the correct adapter. class span_input_adapter { @@ -464,11 +481,12 @@ class span_input_adapter contiguous_bytes_input_adapter&& get() { - return std::move(ia); + return std::move(ia); // NOLINT(hicpp-move-const-arg,performance-move-const-arg) } private: contiguous_bytes_input_adapter ia; }; + } // namespace detail -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/input/json_sax.hpp b/external_imported/json/include/nlohmann/detail/input/json_sax.hpp index a4b7e6d08..c772521cd 100644 --- a/external_imported/json/include/nlohmann/detail/input/json_sax.hpp +++ b/external_imported/json/include/nlohmann/detail/input/json_sax.hpp @@ -1,3 +1,11 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once #include @@ -7,9 +15,9 @@ #include #include +#include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN /*! @brief SAX interface @@ -56,7 +64,7 @@ struct json_sax virtual bool number_unsigned(number_unsigned_t val) = 0; /*! - @brief an floating-point number was read + @brief a floating-point number was read @param[in] val floating-point value @param[in] s raw token value @return whether parsing should proceed @@ -64,18 +72,18 @@ struct json_sax virtual bool number_float(number_float_t val, const string_t& s) = 0; /*! - @brief a string was read + @brief a string value was read @param[in] val string value @return whether parsing should proceed - @note It is safe to move the passed string. + @note It is safe to move the passed string value. */ virtual bool string(string_t& val) = 0; /*! - @brief a binary string was read + @brief a binary value was read @param[in] val binary value @return whether parsing should proceed - @note It is safe to move the passed binary. + @note It is safe to move the passed binary value. */ virtual bool binary(binary_t& val) = 0; @@ -126,10 +134,14 @@ struct json_sax const std::string& last_token, const detail::exception& ex) = 0; + json_sax() = default; + json_sax(const json_sax&) = default; + json_sax(json_sax&&) noexcept = default; + json_sax& operator=(const json_sax&) = default; + json_sax& operator=(json_sax&&) noexcept = default; virtual ~json_sax() = default; }; - namespace detail { /*! @@ -156,7 +168,7 @@ class json_sax_dom_parser using binary_t = typename BasicJsonType::binary_t; /*! - @param[in, out] r reference to a JSON value that is manipulated while + @param[in,out] r reference to a JSON value that is manipulated while parsing @param[in] allow_exceptions_ whether parse errors yield exceptions */ @@ -166,9 +178,9 @@ class json_sax_dom_parser // make class move-only json_sax_dom_parser(const json_sax_dom_parser&) = delete; - json_sax_dom_parser(json_sax_dom_parser&&) = default; + json_sax_dom_parser(json_sax_dom_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) json_sax_dom_parser& operator=(const json_sax_dom_parser&) = delete; - json_sax_dom_parser& operator=(json_sax_dom_parser&&) = default; + json_sax_dom_parser& operator=(json_sax_dom_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) ~json_sax_dom_parser() = default; bool null() @@ -217,9 +229,9 @@ class json_sax_dom_parser { ref_stack.push_back(handle_value(BasicJsonType::value_t::object)); - if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) + if (JSON_HEDLEY_UNLIKELY(len != static_cast(-1) && len > ref_stack.back()->max_size())) { - JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len), *ref_stack.back())); + JSON_THROW(out_of_range::create(408, concat("excessive object size: ", std::to_string(len)), ref_stack.back())); } return true; @@ -227,13 +239,19 @@ class json_sax_dom_parser bool key(string_t& val) { + JSON_ASSERT(!ref_stack.empty()); + JSON_ASSERT(ref_stack.back()->is_object()); + // add null at given key and store the reference for later - object_element = &(ref_stack.back()->m_value.object->operator[](val)); + object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val)); return true; } bool end_object() { + JSON_ASSERT(!ref_stack.empty()); + JSON_ASSERT(ref_stack.back()->is_object()); + ref_stack.back()->set_parents(); ref_stack.pop_back(); return true; @@ -243,9 +261,9 @@ class json_sax_dom_parser { ref_stack.push_back(handle_value(BasicJsonType::value_t::array)); - if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) + if (JSON_HEDLEY_UNLIKELY(len != static_cast(-1) && len > ref_stack.back()->max_size())) { - JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len), *ref_stack.back())); + JSON_THROW(out_of_range::create(408, concat("excessive array size: ", std::to_string(len)), ref_stack.back())); } return true; @@ -253,6 +271,9 @@ class json_sax_dom_parser bool end_array() { + JSON_ASSERT(!ref_stack.empty()); + JSON_ASSERT(ref_stack.back()->is_array()); + ref_stack.back()->set_parents(); ref_stack.pop_back(); return true; @@ -297,8 +318,8 @@ class json_sax_dom_parser if (ref_stack.back()->is_array()) { - ref_stack.back()->m_value.array->emplace_back(std::forward(v)); - return &(ref_stack.back()->m_value.array->back()); + ref_stack.back()->m_data.m_value.array->emplace_back(std::forward(v)); + return &(ref_stack.back()->m_data.m_value.array->back()); } JSON_ASSERT(ref_stack.back()->is_object()); @@ -341,9 +362,9 @@ class json_sax_dom_callback_parser // make class move-only json_sax_dom_callback_parser(const json_sax_dom_callback_parser&) = delete; - json_sax_dom_callback_parser(json_sax_dom_callback_parser&&) = default; + json_sax_dom_callback_parser(json_sax_dom_callback_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) json_sax_dom_callback_parser& operator=(const json_sax_dom_callback_parser&) = delete; - json_sax_dom_callback_parser& operator=(json_sax_dom_callback_parser&&) = default; + json_sax_dom_callback_parser& operator=(json_sax_dom_callback_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) ~json_sax_dom_callback_parser() = default; bool null() @@ -398,9 +419,9 @@ class json_sax_dom_callback_parser ref_stack.push_back(val.second); // check object limit - if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) + if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != static_cast(-1) && len > ref_stack.back()->max_size())) { - JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len), *ref_stack.back())); + JSON_THROW(out_of_range::create(408, concat("excessive object size: ", std::to_string(len)), ref_stack.back())); } return true; @@ -417,7 +438,7 @@ class json_sax_dom_callback_parser // add discarded value at given key and store the reference for later if (keep && ref_stack.back()) { - object_element = &(ref_stack.back()->m_value.object->operator[](val) = discarded); + object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val) = discarded); } return true; @@ -468,9 +489,9 @@ class json_sax_dom_callback_parser ref_stack.push_back(val.second); // check array limit - if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) + if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != static_cast(-1) && len > ref_stack.back()->max_size())) { - JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len), *ref_stack.back())); + JSON_THROW(out_of_range::create(408, concat("excessive array size: ", std::to_string(len)), ref_stack.back())); } return true; @@ -502,7 +523,7 @@ class json_sax_dom_callback_parser // remove discarded value if (!keep && !ref_stack.empty() && ref_stack.back()->is_array()) { - ref_stack.back()->m_value.array->pop_back(); + ref_stack.back()->m_data.m_value.array->pop_back(); } return true; @@ -569,7 +590,7 @@ class json_sax_dom_callback_parser if (ref_stack.empty()) { root = std::move(value); - return {true, &root}; + return {true, & root}; } // skip this value if we already decided to skip the parent @@ -585,8 +606,8 @@ class json_sax_dom_callback_parser // array if (ref_stack.back()->is_array()) { - ref_stack.back()->m_value.array->emplace_back(std::move(value)); - return {true, &(ref_stack.back()->m_value.array->back())}; + ref_stack.back()->m_data.m_value.array->emplace_back(std::move(value)); + return {true, & (ref_stack.back()->m_data.m_value.array->back())}; } // object @@ -671,7 +692,7 @@ class json_sax_acceptor return true; } - bool start_object(std::size_t /*unused*/ = std::size_t(-1)) + bool start_object(std::size_t /*unused*/ = static_cast(-1)) { return true; } @@ -686,7 +707,7 @@ class json_sax_acceptor return true; } - bool start_array(std::size_t /*unused*/ = std::size_t(-1)) + bool start_array(std::size_t /*unused*/ = static_cast(-1)) { return true; } @@ -701,6 +722,6 @@ class json_sax_acceptor return false; } }; -} // namespace detail -} // namespace nlohmann +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/input/lexer.hpp b/external_imported/json/include/nlohmann/detail/input/lexer.hpp index eae82eaa3..4b3bf77d6 100644 --- a/external_imported/json/include/nlohmann/detail/input/lexer.hpp +++ b/external_imported/json/include/nlohmann/detail/input/lexer.hpp @@ -1,3 +1,11 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once #include // array @@ -13,11 +21,12 @@ #include #include #include +#include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /////////// // lexer // /////////// @@ -107,12 +116,12 @@ class lexer : public lexer_base using number_float_t = typename BasicJsonType::number_float_t; using string_t = typename BasicJsonType::string_t; using char_type = typename InputAdapterType::char_type; - using char_int_type = typename std::char_traits::int_type; + using char_int_type = typename char_traits::int_type; public: using token_type = typename lexer_base::token_type; - explicit lexer(InputAdapterType&& adapter, bool ignore_comments_ = false) + explicit lexer(InputAdapterType&& adapter, bool ignore_comments_ = false) noexcept : ia(std::move(adapter)) , ignore_comments(ignore_comments_) , decimal_point_char(static_cast(get_decimal_point())) @@ -120,9 +129,9 @@ class lexer : public lexer_base // delete because of pointer members lexer(const lexer&) = delete; - lexer(lexer&&) = default; + lexer(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) lexer& operator=(lexer&) = delete; - lexer& operator=(lexer&&) = default; + lexer& operator=(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) ~lexer() = default; private: @@ -214,7 +223,7 @@ class lexer : public lexer_base for (auto range = ranges.begin(); range != ranges.end(); ++range) { get(); - if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) + if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) // NOLINT(bugprone-inc-dec-in-conditions) { add(current); } @@ -231,7 +240,7 @@ class lexer : public lexer_base /*! @brief scan a string literal - This function scans a string according to Sect. 7 of RFC 7159. While + This function scans a string according to Sect. 7 of RFC 8259. While scanning, bytes are escaped and copied into buffer token_buffer. Then the function returns successfully, token_buffer is *not* null-terminated (as it may contain \0 bytes), and token_buffer.size() is the number of bytes in the @@ -257,7 +266,7 @@ class lexer : public lexer_base switch (get()) { // end of file while parsing string - case std::char_traits::eof(): + case char_traits::eof(): { error_message = "invalid string: missing closing quote"; return token_type::parse_error; @@ -343,7 +352,7 @@ class lexer : public lexer_base // low surrogate occupies the least significant 15 bits + static_cast(codepoint2) // there is still the 0xD800, 0xDC00 and 0x10000 noise - // in the result so we have to subtract with: + // in the result, so we have to subtract with: // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00 - 0x35FDC00u); } @@ -846,7 +855,7 @@ class lexer : public lexer_base { case '\n': case '\r': - case std::char_traits::eof(): + case char_traits::eof(): case '\0': return true; @@ -863,7 +872,7 @@ class lexer : public lexer_base { switch (get()) { - case std::char_traits::eof(): + case char_traits::eof(): case '\0': { error_message = "invalid comment; missing closing '*/'"; @@ -921,10 +930,10 @@ class lexer : public lexer_base /*! @brief scan a number literal - This function scans a string according to Sect. 6 of RFC 7159. + This function scans a string according to Sect. 6 of RFC 8259. The function is realized with a deterministic finite state machine derived - from the grammar described in RFC 7159. Starting in state "init", the + from the grammar described in RFC 8259. Starting in state "init", the input is read and used to determined the next state. Only state "done" accepts the number. State "error" is a trap state to model errors. In the table below, "anything" means any character but the ones listed before. @@ -998,7 +1007,7 @@ class lexer : public lexer_base // all other characters are rejected outside scan_number() default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // LCOV_EXCL_LINE + JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE } scan_number_minus: @@ -1236,7 +1245,7 @@ class lexer : public lexer_base // we are done scanning a number) unget(); - char* endptr = nullptr; + char* endptr = nullptr; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) errno = 0; // try to parse integers first and fall back to floats @@ -1292,10 +1301,10 @@ class lexer : public lexer_base token_type scan_literal(const char_type* literal_text, const std::size_t length, token_type return_type) { - JSON_ASSERT(std::char_traits::to_char_type(current) == literal_text[0]); + JSON_ASSERT(char_traits::to_char_type(current) == literal_text[0]); for (std::size_t i = 1; i < length; ++i) { - if (JSON_HEDLEY_UNLIKELY(std::char_traits::to_char_type(get()) != literal_text[i])) + if (JSON_HEDLEY_UNLIKELY(char_traits::to_char_type(get()) != literal_text[i])) { error_message = "invalid literal"; return token_type::parse_error; @@ -1313,7 +1322,7 @@ class lexer : public lexer_base { token_buffer.clear(); token_string.clear(); - token_string.push_back(std::char_traits::to_char_type(current)); + token_string.push_back(char_traits::to_char_type(current)); } /* @@ -1321,7 +1330,7 @@ class lexer : public lexer_base This function provides the interface to the used input adapter. It does not throw in case the input reached EOF, but returns a - `std::char_traits::eof()` in that case. Stores the scanned characters + `char_traits::eof()` in that case. Stores the scanned characters for use in error messages. @return character read from the input @@ -1341,9 +1350,9 @@ class lexer : public lexer_base current = ia.get_character(); } - if (JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) + if (JSON_HEDLEY_LIKELY(current != char_traits::eof())) { - token_string.push_back(std::char_traits::to_char_type(current)); + token_string.push_back(char_traits::to_char_type(current)); } if (current == '\n') @@ -1382,7 +1391,7 @@ class lexer : public lexer_base --position.chars_read_current_line; } - if (JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) + if (JSON_HEDLEY_LIKELY(current != char_traits::eof())) { JSON_ASSERT(!token_string.empty()); token_string.pop_back(); @@ -1447,7 +1456,7 @@ class lexer : public lexer_base { // escape control characters std::array cs{{}}; - (std::snprintf)(cs.data(), cs.size(), "", static_cast(c)); + static_cast((std::snprintf)(cs.data(), cs.size(), "", static_cast(c))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) result += cs.data(); } else @@ -1541,17 +1550,17 @@ class lexer : public lexer_base // literals case 't': { - std::array true_literal = {{char_type('t'), char_type('r'), char_type('u'), char_type('e')}}; + std::array true_literal = {{static_cast('t'), static_cast('r'), static_cast('u'), static_cast('e')}}; return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true); } case 'f': { - std::array false_literal = {{char_type('f'), char_type('a'), char_type('l'), char_type('s'), char_type('e')}}; + std::array false_literal = {{static_cast('f'), static_cast('a'), static_cast('l'), static_cast('s'), static_cast('e')}}; return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false); } case 'n': { - std::array null_literal = {{char_type('n'), char_type('u'), char_type('l'), char_type('l')}}; + std::array null_literal = {{static_cast('n'), static_cast('u'), static_cast('l'), static_cast('l')}}; return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null); } @@ -1576,7 +1585,7 @@ class lexer : public lexer_base // end of input (the null byte is needed when parsing from // string literals) case '\0': - case std::char_traits::eof(): + case char_traits::eof(): return token_type::end_of_input; // error @@ -1594,7 +1603,7 @@ class lexer : public lexer_base const bool ignore_comments = false; /// the current character - char_int_type current = std::char_traits::eof(); + char_int_type current = char_traits::eof(); /// whether the next get() call should just return current bool next_unget = false; @@ -1619,5 +1628,6 @@ class lexer : public lexer_base /// the decimal point const char_int_type decimal_point_char = '.'; }; + } // namespace detail -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/input/parser.hpp b/external_imported/json/include/nlohmann/detail/input/parser.hpp index 7b5d494f8..bdf85ba29 100644 --- a/external_imported/json/include/nlohmann/detail/input/parser.hpp +++ b/external_imported/json/include/nlohmann/detail/input/parser.hpp @@ -1,3 +1,11 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once #include // isfinite @@ -13,17 +21,17 @@ #include #include #include +#include #include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { //////////// // parser // //////////// -enum class parse_event_t : uint8_t +enum class parse_event_t : std::uint8_t { /// the parser read `{` and started to process a JSON object object_start, @@ -41,7 +49,7 @@ enum class parse_event_t : uint8_t template using parser_callback_t = - std::function; + std::function; /*! @brief syntax analysis @@ -95,7 +103,7 @@ class parser sdp.parse_error(m_lexer.get_position(), m_lexer.get_token_string(), parse_error::create(101, m_lexer.get_position(), - exception_message(token_type::end_of_input, "value"), BasicJsonType())); + exception_message(token_type::end_of_input, "value"), nullptr)); } // in case of an error, return discarded value @@ -122,7 +130,7 @@ class parser { sdp.parse_error(m_lexer.get_position(), m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), BasicJsonType())); + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), nullptr)); } // in case of an error, return discarded value @@ -160,7 +168,7 @@ class parser { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), BasicJsonType())); + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), nullptr)); } return result; @@ -186,7 +194,7 @@ class parser { case token_type::begin_object: { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(static_cast(-1)))) { return false; } @@ -206,7 +214,7 @@ class parser { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), BasicJsonType())); + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), nullptr)); } if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) { @@ -218,7 +226,7 @@ class parser { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), BasicJsonType())); + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), nullptr)); } // remember we are now inside an object @@ -231,7 +239,7 @@ class parser case token_type::begin_array: { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_array(static_cast(-1)))) { return false; } @@ -261,7 +269,7 @@ class parser { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), - out_of_range::create(406, "number overflow parsing '" + m_lexer.get_token_string() + "'", BasicJsonType())); + out_of_range::create(406, concat("number overflow parsing '", m_lexer.get_token_string(), '\''), nullptr)); } if (JSON_HEDLEY_UNLIKELY(!sax->number_float(res, m_lexer.get_string()))) @@ -331,14 +339,33 @@ class parser // using "uninitialized" to avoid "expected" message return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), BasicJsonType())); + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), nullptr)); } + case token_type::end_of_input: + { + if (JSON_HEDLEY_UNLIKELY(m_lexer.get_position().chars_read_total == 1)) + { + return sax->parse_error(m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), + "attempting to parse an empty input; check that your input string or stream contains the expected JSON", nullptr)); + } + return sax->parse_error(m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr)); + } + case token_type::uninitialized: + case token_type::end_array: + case token_type::end_object: + case token_type::name_separator: + case token_type::value_separator: + case token_type::literal_or_value: default: // the last token was unexpected { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), BasicJsonType())); + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr)); } } } @@ -384,7 +411,7 @@ class parser return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array, "array"), BasicJsonType())); + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array, "array"), nullptr)); } // states.back() is false -> object @@ -397,7 +424,7 @@ class parser { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), BasicJsonType())); + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), nullptr)); } if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) @@ -410,7 +437,7 @@ class parser { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), BasicJsonType())); + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), nullptr)); } // parse values @@ -438,7 +465,7 @@ class parser return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object, "object"), BasicJsonType())); + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object, "object"), nullptr)); } } @@ -454,24 +481,24 @@ class parser if (!context.empty()) { - error_msg += "while parsing " + context + " "; + error_msg += concat("while parsing ", context, ' '); } error_msg += "- "; if (last_token == token_type::parse_error) { - error_msg += std::string(m_lexer.get_error_message()) + "; last read: '" + - m_lexer.get_token_string() + "'"; + error_msg += concat(m_lexer.get_error_message(), "; last read: '", + m_lexer.get_token_string(), '\''); } else { - error_msg += "unexpected " + std::string(lexer_t::token_type_name(last_token)); + error_msg += concat("unexpected ", lexer_t::token_type_name(last_token)); } if (expected != token_type::uninitialized) { - error_msg += "; expected " + std::string(lexer_t::token_type_name(expected)); + error_msg += concat("; expected ", lexer_t::token_type_name(expected)); } return error_msg; @@ -487,5 +514,6 @@ class parser /// whether to throw exceptions in case of errors const bool allow_exceptions = true; }; + } // namespace detail -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/input/position_t.hpp b/external_imported/json/include/nlohmann/detail/input/position_t.hpp index 14e9649fb..8ac7c78cf 100644 --- a/external_imported/json/include/nlohmann/detail/input/position_t.hpp +++ b/external_imported/json/include/nlohmann/detail/input/position_t.hpp @@ -1,11 +1,21 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once #include // size_t -namespace nlohmann -{ +#include + +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /// struct to capture the start position of the current token struct position_t { @@ -23,5 +33,5 @@ struct position_t } }; -} // namespace detail -} // namespace nlohmann +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/iterators/internal_iterator.hpp b/external_imported/json/include/nlohmann/detail/iterators/internal_iterator.hpp index 2c81f723f..2991ee693 100644 --- a/external_imported/json/include/nlohmann/detail/iterators/internal_iterator.hpp +++ b/external_imported/json/include/nlohmann/detail/iterators/internal_iterator.hpp @@ -1,11 +1,20 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once +#include #include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /*! @brief an iterator value @@ -21,5 +30,6 @@ template struct internal_iterator /// generic iterator for all other types primitive_iterator_t primitive_iterator {}; }; + } // namespace detail -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/iterators/iter_impl.hpp b/external_imported/json/include/nlohmann/detail/iterators/iter_impl.hpp index 118fef3f5..444709134 100644 --- a/external_imported/json/include/nlohmann/detail/iterators/iter_impl.hpp +++ b/external_imported/json/include/nlohmann/detail/iterators/iter_impl.hpp @@ -1,3 +1,11 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once #include // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next @@ -11,10 +19,10 @@ #include #include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + // forward declare, to be able to friend it later on template class iteration_proxy; template class iteration_proxy_value; @@ -36,7 +44,7 @@ This class implements a both iterators (iterator and const_iterator) for the iterators in version 3.0.0 (see https://github.com/nlohmann/json/issues/593) */ template -class iter_impl +class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions) { /// the iterator with BasicJsonType of different const-ness using other_iter_impl = iter_impl::value, typename std::remove_const::type, const BasicJsonType>::type>; @@ -51,9 +59,12 @@ class iter_impl // make sure BasicJsonType is basic_json or const basic_json static_assert(is_basic_json::type>::value, "iter_impl only accepts (const) basic_json"); + // superficial check for the LegacyBidirectionalIterator named requirement + static_assert(std::is_base_of::value + && std::is_base_of::iterator_category>::value, + "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement."); public: - /// The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17. /// The C++ Standard has never required user-defined iterators to derive from std::iterator. /// A user-defined iterator should provide publicly accessible typedefs named @@ -75,8 +86,10 @@ class iter_impl typename BasicJsonType::const_reference, typename BasicJsonType::reference>::type; - /// default constructor iter_impl() = default; + ~iter_impl() = default; + iter_impl(iter_impl&&) noexcept = default; + iter_impl& operator=(iter_impl&&) noexcept = default; /*! @brief constructor for a given JSON instance @@ -88,7 +101,7 @@ class iter_impl { JSON_ASSERT(m_object != nullptr); - switch (m_object->m_type) + switch (m_object->m_data.m_type) { case value_t::object: { @@ -102,6 +115,14 @@ class iter_impl break; } + case value_t::null: + case value_t::string: + case value_t::boolean: + case value_t::number_integer: + case value_t::number_unsigned: + case value_t::number_float: + case value_t::binary: + case value_t::discarded: default: { m_it.primitive_iterator = primitive_iterator_t(); @@ -138,8 +159,11 @@ class iter_impl */ iter_impl& operator=(const iter_impl& other) noexcept { - m_object = other.m_object; - m_it = other.m_it; + if (&other != this) + { + m_object = other.m_object; + m_it = other.m_it; + } return *this; } @@ -158,7 +182,7 @@ class iter_impl @return const/non-const iterator @note It is not checked whether @a other is initialized. */ - iter_impl& operator=(const iter_impl::type>& other) noexcept + iter_impl& operator=(const iter_impl::type>& other) noexcept // NOLINT(cert-oop54-cpp) { m_object = other.m_object; m_it = other.m_it; @@ -174,17 +198,17 @@ class iter_impl { JSON_ASSERT(m_object != nullptr); - switch (m_object->m_type) + switch (m_object->m_data.m_type) { case value_t::object: { - m_it.object_iterator = m_object->m_value.object->begin(); + m_it.object_iterator = m_object->m_data.m_value.object->begin(); break; } case value_t::array: { - m_it.array_iterator = m_object->m_value.array->begin(); + m_it.array_iterator = m_object->m_data.m_value.array->begin(); break; } @@ -195,6 +219,13 @@ class iter_impl break; } + case value_t::string: + case value_t::boolean: + case value_t::number_integer: + case value_t::number_unsigned: + case value_t::number_float: + case value_t::binary: + case value_t::discarded: default: { m_it.primitive_iterator.set_begin(); @@ -211,20 +242,28 @@ class iter_impl { JSON_ASSERT(m_object != nullptr); - switch (m_object->m_type) + switch (m_object->m_data.m_type) { case value_t::object: { - m_it.object_iterator = m_object->m_value.object->end(); + m_it.object_iterator = m_object->m_data.m_value.object->end(); break; } case value_t::array: { - m_it.array_iterator = m_object->m_value.array->end(); + m_it.array_iterator = m_object->m_data.m_value.array->end(); break; } + case value_t::null: + case value_t::string: + case value_t::boolean: + case value_t::number_integer: + case value_t::number_unsigned: + case value_t::number_float: + case value_t::binary: + case value_t::discarded: default: { m_it.primitive_iterator.set_end(); @@ -242,23 +281,30 @@ class iter_impl { JSON_ASSERT(m_object != nullptr); - switch (m_object->m_type) + switch (m_object->m_data.m_type) { case value_t::object: { - JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end()); + JSON_ASSERT(m_it.object_iterator != m_object->m_data.m_value.object->end()); return m_it.object_iterator->second; } case value_t::array: { - JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end()); + JSON_ASSERT(m_it.array_iterator != m_object->m_data.m_value.array->end()); return *m_it.array_iterator; } case value_t::null: - JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); - + JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object)); + + case value_t::string: + case value_t::boolean: + case value_t::number_integer: + case value_t::number_unsigned: + case value_t::number_float: + case value_t::binary: + case value_t::discarded: default: { if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) @@ -266,7 +312,7 @@ class iter_impl return *m_object; } - JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); + JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object)); } } } @@ -279,20 +325,28 @@ class iter_impl { JSON_ASSERT(m_object != nullptr); - switch (m_object->m_type) + switch (m_object->m_data.m_type) { case value_t::object: { - JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end()); + JSON_ASSERT(m_it.object_iterator != m_object->m_data.m_value.object->end()); return &(m_it.object_iterator->second); } case value_t::array: { - JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end()); + JSON_ASSERT(m_it.array_iterator != m_object->m_data.m_value.array->end()); return &*m_it.array_iterator; } + case value_t::null: + case value_t::string: + case value_t::boolean: + case value_t::number_integer: + case value_t::number_unsigned: + case value_t::number_float: + case value_t::binary: + case value_t::discarded: default: { if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) @@ -300,7 +354,7 @@ class iter_impl return m_object; } - JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); + JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object)); } } } @@ -309,7 +363,7 @@ class iter_impl @brief post-increment (it++) @pre The iterator is initialized; i.e. `m_object != nullptr`. */ - iter_impl const operator++(int) + iter_impl operator++(int)& // NOLINT(cert-dcl21-cpp) { auto result = *this; ++(*this); @@ -324,7 +378,7 @@ class iter_impl { JSON_ASSERT(m_object != nullptr); - switch (m_object->m_type) + switch (m_object->m_data.m_type) { case value_t::object: { @@ -338,6 +392,14 @@ class iter_impl break; } + case value_t::null: + case value_t::string: + case value_t::boolean: + case value_t::number_integer: + case value_t::number_unsigned: + case value_t::number_float: + case value_t::binary: + case value_t::discarded: default: { ++m_it.primitive_iterator; @@ -352,7 +414,7 @@ class iter_impl @brief post-decrement (it--) @pre The iterator is initialized; i.e. `m_object != nullptr`. */ - iter_impl const operator--(int) + iter_impl operator--(int)& // NOLINT(cert-dcl21-cpp) { auto result = *this; --(*this); @@ -367,7 +429,7 @@ class iter_impl { JSON_ASSERT(m_object != nullptr); - switch (m_object->m_type) + switch (m_object->m_data.m_type) { case value_t::object: { @@ -381,6 +443,14 @@ class iter_impl break; } + case value_t::null: + case value_t::string: + case value_t::boolean: + case value_t::number_integer: + case value_t::number_unsigned: + case value_t::number_float: + case value_t::binary: + case value_t::discarded: default: { --m_it.primitive_iterator; @@ -401,12 +471,12 @@ class iter_impl // if objects are not the same, the comparison is undefined if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) { - JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", *m_object)); + JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", m_object)); } JSON_ASSERT(m_object != nullptr); - switch (m_object->m_type) + switch (m_object->m_data.m_type) { case value_t::object: return (m_it.object_iterator == other.m_it.object_iterator); @@ -414,6 +484,14 @@ class iter_impl case value_t::array: return (m_it.array_iterator == other.m_it.array_iterator); + case value_t::null: + case value_t::string: + case value_t::boolean: + case value_t::number_integer: + case value_t::number_unsigned: + case value_t::number_float: + case value_t::binary: + case value_t::discarded: default: return (m_it.primitive_iterator == other.m_it.primitive_iterator); } @@ -438,19 +516,27 @@ class iter_impl // if objects are not the same, the comparison is undefined if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) { - JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", *m_object)); + JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", m_object)); } JSON_ASSERT(m_object != nullptr); - switch (m_object->m_type) + switch (m_object->m_data.m_type) { case value_t::object: - JSON_THROW(invalid_iterator::create(213, "cannot compare order of object iterators", *m_object)); + JSON_THROW(invalid_iterator::create(213, "cannot compare order of object iterators", m_object)); case value_t::array: return (m_it.array_iterator < other.m_it.array_iterator); + case value_t::null: + case value_t::string: + case value_t::boolean: + case value_t::number_integer: + case value_t::number_unsigned: + case value_t::number_float: + case value_t::binary: + case value_t::discarded: default: return (m_it.primitive_iterator < other.m_it.primitive_iterator); } @@ -491,10 +577,10 @@ class iter_impl { JSON_ASSERT(m_object != nullptr); - switch (m_object->m_type) + switch (m_object->m_data.m_type) { case value_t::object: - JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", *m_object)); + JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", m_object)); case value_t::array: { @@ -502,6 +588,14 @@ class iter_impl break; } + case value_t::null: + case value_t::string: + case value_t::boolean: + case value_t::number_integer: + case value_t::number_unsigned: + case value_t::number_float: + case value_t::binary: + case value_t::discarded: default: { m_it.primitive_iterator += i; @@ -562,14 +656,22 @@ class iter_impl { JSON_ASSERT(m_object != nullptr); - switch (m_object->m_type) + switch (m_object->m_data.m_type) { case value_t::object: - JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", *m_object)); + JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", m_object)); case value_t::array: return m_it.array_iterator - other.m_it.array_iterator; + case value_t::null: + case value_t::string: + case value_t::boolean: + case value_t::number_integer: + case value_t::number_unsigned: + case value_t::number_float: + case value_t::binary: + case value_t::discarded: default: return m_it.primitive_iterator - other.m_it.primitive_iterator; } @@ -583,17 +685,24 @@ class iter_impl { JSON_ASSERT(m_object != nullptr); - switch (m_object->m_type) + switch (m_object->m_data.m_type) { case value_t::object: - JSON_THROW(invalid_iterator::create(208, "cannot use operator[] for object iterators", *m_object)); + JSON_THROW(invalid_iterator::create(208, "cannot use operator[] for object iterators", m_object)); case value_t::array: return *std::next(m_it.array_iterator, n); case value_t::null: - JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); - + JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object)); + + case value_t::string: + case value_t::boolean: + case value_t::number_integer: + case value_t::number_unsigned: + case value_t::number_float: + case value_t::binary: + case value_t::discarded: default: { if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.get_value() == -n)) @@ -601,7 +710,7 @@ class iter_impl return *m_object; } - JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); + JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object)); } } } @@ -619,7 +728,7 @@ class iter_impl return m_it.object_iterator->first; } - JSON_THROW(invalid_iterator::create(207, "cannot use key() for non-object iterators", *m_object)); + JSON_THROW(invalid_iterator::create(207, "cannot use key() for non-object iterators", m_object)); } /*! @@ -637,5 +746,6 @@ class iter_impl /// the actual iterator of the associated instance internal_iterator::type> m_it {}; }; -} // namespace detail -} // namespace nlohmann + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/iterators/iteration_proxy.hpp b/external_imported/json/include/nlohmann/detail/iterators/iteration_proxy.hpp index 1b47faeb3..76293de22 100644 --- a/external_imported/json/include/nlohmann/detail/iterators/iteration_proxy.hpp +++ b/external_imported/json/include/nlohmann/detail/iterators/iteration_proxy.hpp @@ -1,17 +1,31 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once #include // size_t #include // input_iterator_tag #include // string, to_string #include // tuple_size, get, tuple_element +#include // move + +#if JSON_HAS_RANGES + #include // enable_borrowed_range +#endif +#include #include #include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + template void int_to_string( string_type& target, std::size_t value ) { @@ -24,14 +38,14 @@ template class iteration_proxy_value public: using difference_type = std::ptrdiff_t; using value_type = iteration_proxy_value; - using pointer = value_type * ; - using reference = value_type & ; + using pointer = value_type *; + using reference = value_type &; using iterator_category = std::input_iterator_tag; using string_type = typename std::remove_cv< typename std::remove_reference().key() ) >::type >::type; private: /// the iterator - IteratorType anchor; + IteratorType anchor{}; /// an index for arrays (used to create key names) std::size_t array_index = 0; /// last stringified array index @@ -39,13 +53,30 @@ template class iteration_proxy_value /// a string representation of the array index mutable string_type array_index_str = "0"; /// an empty string (to return a reference for primitive values) - const string_type empty_str{}; + string_type empty_str{}; public: - explicit iteration_proxy_value(IteratorType it) noexcept : anchor(it) {} + explicit iteration_proxy_value() = default; + explicit iteration_proxy_value(IteratorType it, std::size_t array_index_ = 0) + noexcept(std::is_nothrow_move_constructible::value + && std::is_nothrow_default_constructible::value) + : anchor(std::move(it)) + , array_index(array_index_) + {} + + iteration_proxy_value(iteration_proxy_value const&) = default; + iteration_proxy_value& operator=(iteration_proxy_value const&) = default; + // older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions + iteration_proxy_value(iteration_proxy_value&&) + noexcept(std::is_nothrow_move_constructible::value + && std::is_nothrow_move_constructible::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations) + iteration_proxy_value& operator=(iteration_proxy_value&&) + noexcept(std::is_nothrow_move_assignable::value + && std::is_nothrow_move_assignable::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations) + ~iteration_proxy_value() = default; /// dereference operator (needed for range-based for) - iteration_proxy_value& operator*() + const iteration_proxy_value& operator*() const { return *this; } @@ -59,6 +90,14 @@ template class iteration_proxy_value return *this; } + iteration_proxy_value operator++(int)& // NOLINT(cert-dcl21-cpp) + { + auto tmp = iteration_proxy_value(anchor, array_index); + ++anchor; + ++array_index; + return tmp; + } + /// equality operator (needed for InputIterator) bool operator==(const iteration_proxy_value& o) const { @@ -94,6 +133,14 @@ template class iteration_proxy_value return anchor.key(); // use an empty key for all primitive types + case value_t::null: + case value_t::string: + case value_t::boolean: + case value_t::number_integer: + case value_t::number_unsigned: + case value_t::number_float: + case value_t::binary: + case value_t::discarded: default: return empty_str; } @@ -111,25 +158,34 @@ template class iteration_proxy { private: /// the container to iterate - typename IteratorType::reference container; + typename IteratorType::pointer container = nullptr; public: + explicit iteration_proxy() = default; + /// construct iteration proxy from a container explicit iteration_proxy(typename IteratorType::reference cont) noexcept - : container(cont) {} + : container(&cont) {} + + iteration_proxy(iteration_proxy const&) = default; + iteration_proxy& operator=(iteration_proxy const&) = default; + iteration_proxy(iteration_proxy&&) noexcept = default; + iteration_proxy& operator=(iteration_proxy&&) noexcept = default; + ~iteration_proxy() = default; /// return iterator begin (needed for range-based for) - iteration_proxy_value begin() noexcept + iteration_proxy_value begin() const noexcept { - return iteration_proxy_value(container.begin()); + return iteration_proxy_value(container->begin()); } /// return iterator end (needed for range-based for) - iteration_proxy_value end() noexcept + iteration_proxy_value end() const noexcept { - return iteration_proxy_value(container.end()); + return iteration_proxy_value(container->end()); } }; + // Structured Bindings Support // For further reference see https://blog.tartanllama.xyz/structured-bindings/ // And see https://github.com/nlohmann/json/pull/1391 @@ -146,8 +202,9 @@ auto get(const nlohmann::detail::iteration_proxy_value& i) -> decl { return i.value(); } + } // namespace detail -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // The Addition to the STD Namespace is required to add // Structured Bindings Support to the iteration_proxy_value class @@ -155,17 +212,18 @@ auto get(const nlohmann::detail::iteration_proxy_value& i) -> decl // And see https://github.com/nlohmann/json/pull/1391 namespace std { + #if defined(__clang__) // Fix: https://github.com/nlohmann/json/issues/1401 #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wmismatched-tags" #endif template -class tuple_size<::nlohmann::detail::iteration_proxy_value> +class tuple_size<::nlohmann::detail::iteration_proxy_value> // NOLINT(cert-dcl58-cpp) : public std::integral_constant {}; template -class tuple_element> +class tuple_element> // NOLINT(cert-dcl58-cpp) { public: using type = decltype( @@ -175,4 +233,10 @@ class tuple_element> #if defined(__clang__) #pragma clang diagnostic pop #endif -} // namespace std + +} // namespace std + +#if JSON_HAS_RANGES + template + inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy> = true; +#endif diff --git a/external_imported/json/include/nlohmann/detail/iterators/iterator_traits.hpp b/external_imported/json/include/nlohmann/detail/iterators/iterator_traits.hpp index da5636188..84cc27a85 100644 --- a/external_imported/json/include/nlohmann/detail/iterators/iterator_traits.hpp +++ b/external_imported/json/include/nlohmann/detail/iterators/iterator_traits.hpp @@ -1,14 +1,23 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once #include // random_access_iterator_tag +#include #include #include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + template struct iterator_types {}; @@ -47,5 +56,6 @@ struct iterator_traits::value>> using pointer = T*; using reference = T&; }; -} // namespace detail -} // namespace nlohmann + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/iterators/json_reverse_iterator.hpp b/external_imported/json/include/nlohmann/detail/iterators/json_reverse_iterator.hpp index f3b5b5db6..006d5499a 100644 --- a/external_imported/json/include/nlohmann/detail/iterators/json_reverse_iterator.hpp +++ b/external_imported/json/include/nlohmann/detail/iterators/json_reverse_iterator.hpp @@ -1,13 +1,23 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once #include // ptrdiff_t #include // reverse_iterator #include // declval -namespace nlohmann -{ +#include + +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + ////////////////////// // reverse_iterator // ////////////////////// @@ -48,7 +58,7 @@ class json_reverse_iterator : public std::reverse_iterator explicit json_reverse_iterator(const base_iterator& it) noexcept : base_iterator(it) {} /// post-increment (it++) - json_reverse_iterator const operator++(int) + json_reverse_iterator operator++(int)& // NOLINT(cert-dcl21-cpp) { return static_cast(base_iterator::operator++(1)); } @@ -60,7 +70,7 @@ class json_reverse_iterator : public std::reverse_iterator } /// post-decrement (it--) - json_reverse_iterator const operator--(int) + json_reverse_iterator operator--(int)& // NOLINT(cert-dcl21-cpp) { return static_cast(base_iterator::operator--(1)); } @@ -115,5 +125,6 @@ class json_reverse_iterator : public std::reverse_iterator return it.operator * (); } }; + } // namespace detail -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/iterators/primitive_iterator.hpp b/external_imported/json/include/nlohmann/detail/iterators/primitive_iterator.hpp index ae7471ef5..0b6e8499e 100644 --- a/external_imported/json/include/nlohmann/detail/iterators/primitive_iterator.hpp +++ b/external_imported/json/include/nlohmann/detail/iterators/primitive_iterator.hpp @@ -1,3 +1,11 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once #include // ptrdiff_t @@ -5,10 +13,10 @@ #include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /* @brief an iterator for primitive JSON types @@ -87,7 +95,7 @@ class primitive_iterator_t return *this; } - primitive_iterator_t const operator++(int) noexcept + primitive_iterator_t operator++(int)& noexcept // NOLINT(cert-dcl21-cpp) { auto result = *this; ++m_it; @@ -100,7 +108,7 @@ class primitive_iterator_t return *this; } - primitive_iterator_t const operator--(int) noexcept + primitive_iterator_t operator--(int)& noexcept // NOLINT(cert-dcl21-cpp) { auto result = *this; --m_it; @@ -119,5 +127,6 @@ class primitive_iterator_t return *this; } }; + } // namespace detail -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/json_custom_base_class.hpp b/external_imported/json/include/nlohmann/detail/json_custom_base_class.hpp new file mode 100644 index 000000000..d1e29162a --- /dev/null +++ b/external_imported/json/include/nlohmann/detail/json_custom_base_class.hpp @@ -0,0 +1,39 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + +#pragma once + +#include // conditional, is_same + +#include + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +/*! +@brief Default base class of the @ref basic_json class. + +So that the correct implementations of the copy / move ctors / assign operators +of @ref basic_json do not require complex case distinctions +(no base class / custom base class used as customization point), +@ref basic_json always has a base class. +By default, this class is used because it is empty and thus has no effect +on the behavior of @ref basic_json. +*/ +struct json_default_base {}; + +template +using json_base_class = typename std::conditional < + std::is_same::value, + json_default_base, + T + >::type; + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/json_pointer.hpp b/external_imported/json/include/nlohmann/detail/json_pointer.hpp index cb2ec8560..4fdcd9ad2 100644 --- a/external_imported/json/include/nlohmann/detail/json_pointer.hpp +++ b/external_imported/json/include/nlohmann/detail/json_pointer.hpp @@ -1,7 +1,20 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once #include // all_of #include // isdigit +#include // errno, ERANGE +#include // strtoull +#ifndef JSON_NO_IO + #include // ostream +#endif // JSON_NO_IO #include // max #include // accumulate #include // string @@ -10,90 +23,78 @@ #include #include +#include #include #include -namespace nlohmann -{ -template +NLOHMANN_JSON_NAMESPACE_BEGIN + +/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document +/// @sa https://json.nlohmann.me/api/json_pointer/ +template class json_pointer { // allow basic_json to access private members NLOHMANN_BASIC_JSON_TPL_DECLARATION friend class basic_json; - public: - /*! - @brief create JSON pointer + template + friend class json_pointer; - Create a JSON pointer according to the syntax described in - [Section 3 of RFC6901](https://tools.ietf.org/html/rfc6901#section-3). - - @param[in] s string representing the JSON pointer; if omitted, the empty - string is assumed which references the whole JSON value - - @throw parse_error.107 if the given JSON pointer @a s is nonempty and does - not begin with a slash (`/`); see example below + template + struct string_t_helper + { + using type = T; + }; - @throw parse_error.108 if a tilde (`~`) in the given JSON pointer @a s is - not followed by `0` (representing `~`) or `1` (representing `/`); see - example below + NLOHMANN_BASIC_JSON_TPL_DECLARATION + struct string_t_helper + { + using type = StringType; + }; - @liveexample{The example shows the construction several valid JSON pointers - as well as the exceptional behavior.,json_pointer} + public: + // for backwards compatibility accept BasicJsonType + using string_t = typename string_t_helper::type; - @since version 2.0.0 - */ - explicit json_pointer(const std::string& s = "") + /// @brief create JSON pointer + /// @sa https://json.nlohmann.me/api/json_pointer/json_pointer/ + explicit json_pointer(const string_t& s = "") : reference_tokens(split(s)) {} - /*! - @brief return a string representation of the JSON pointer - - @invariant For each JSON pointer `ptr`, it holds: - @code {.cpp} - ptr == json_pointer(ptr.to_string()); - @endcode - - @return a string representation of the JSON pointer - - @liveexample{The example shows the result of `to_string`.,json_pointer__to_string} - - @since version 2.0.0 - */ - std::string to_string() const + /// @brief return a string representation of the JSON pointer + /// @sa https://json.nlohmann.me/api/json_pointer/to_string/ + string_t to_string() const { return std::accumulate(reference_tokens.begin(), reference_tokens.end(), - std::string{}, - [](const std::string & a, const std::string & b) + string_t{}, + [](const string_t& a, const string_t& b) { - return a + "/" + detail::escape(b); + return detail::concat(a, '/', detail::escape(b)); }); } - /// @copydoc to_string() - operator std::string() const + /// @brief return a string representation of the JSON pointer + /// @sa https://json.nlohmann.me/api/json_pointer/operator_string/ + JSON_HEDLEY_DEPRECATED_FOR(3.11.0, to_string()) + operator string_t() const { return to_string(); } - /*! - @brief append another JSON pointer at the end of this JSON pointer - - @param[in] ptr JSON pointer to append - @return JSON pointer with @a ptr appended - - @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add} - - @complexity Linear in the length of @a ptr. - - @sa @ref operator/=(std::string) to append a reference token - @sa @ref operator/=(std::size_t) to append an array index - @sa @ref operator/(const json_pointer&, const json_pointer&) for a binary operator +#ifndef JSON_NO_IO + /// @brief write string representation of the JSON pointer to stream + /// @sa https://json.nlohmann.me/api/basic_json/operator_ltlt/ + friend std::ostream& operator<<(std::ostream& o, const json_pointer& ptr) + { + o << ptr.to_string(); + return o; + } +#endif - @since version 3.6.0 - */ + /// @brief append another JSON pointer at the end of this JSON pointer + /// @sa https://json.nlohmann.me/api/json_pointer/operator_slasheq/ json_pointer& operator/=(const json_pointer& ptr) { reference_tokens.insert(reference_tokens.end(), @@ -102,123 +103,45 @@ class json_pointer return *this; } - /*! - @brief append an unescaped reference token at the end of this JSON pointer - - @param[in] token reference token to append - @return JSON pointer with @a token appended without escaping @a token - - @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add} - - @complexity Amortized constant. - - @sa @ref operator/=(const json_pointer&) to append a JSON pointer - @sa @ref operator/=(std::size_t) to append an array index - @sa @ref operator/(const json_pointer&, std::size_t) for a binary operator - - @since version 3.6.0 - */ - json_pointer& operator/=(std::string token) + /// @brief append an unescaped reference token at the end of this JSON pointer + /// @sa https://json.nlohmann.me/api/json_pointer/operator_slasheq/ + json_pointer& operator/=(string_t token) { push_back(std::move(token)); return *this; } - /*! - @brief append an array index at the end of this JSON pointer - - @param[in] array_idx array index to append - @return JSON pointer with @a array_idx appended - - @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add} - - @complexity Amortized constant. - - @sa @ref operator/=(const json_pointer&) to append a JSON pointer - @sa @ref operator/=(std::string) to append a reference token - @sa @ref operator/(const json_pointer&, std::string) for a binary operator - - @since version 3.6.0 - */ + /// @brief append an array index at the end of this JSON pointer + /// @sa https://json.nlohmann.me/api/json_pointer/operator_slasheq/ json_pointer& operator/=(std::size_t array_idx) { return *this /= std::to_string(array_idx); } - /*! - @brief create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer - - @param[in] lhs JSON pointer - @param[in] rhs JSON pointer - @return a new JSON pointer with @a rhs appended to @a lhs - - @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary} - - @complexity Linear in the length of @a lhs and @a rhs. - - @sa @ref operator/=(const json_pointer&) to append a JSON pointer - - @since version 3.6.0 - */ + /// @brief create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer + /// @sa https://json.nlohmann.me/api/json_pointer/operator_slash/ friend json_pointer operator/(const json_pointer& lhs, const json_pointer& rhs) { return json_pointer(lhs) /= rhs; } - /*! - @brief create a new JSON pointer by appending the unescaped token at the end of the JSON pointer - - @param[in] ptr JSON pointer - @param[in] token reference token - @return a new JSON pointer with unescaped @a token appended to @a ptr - - @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary} - - @complexity Linear in the length of @a ptr. - - @sa @ref operator/=(std::string) to append a reference token - - @since version 3.6.0 - */ - friend json_pointer operator/(const json_pointer& ptr, std::string token) + /// @brief create a new JSON pointer by appending the unescaped token at the end of the JSON pointer + /// @sa https://json.nlohmann.me/api/json_pointer/operator_slash/ + friend json_pointer operator/(const json_pointer& lhs, string_t token) // NOLINT(performance-unnecessary-value-param) { - return json_pointer(ptr) /= std::move(token); + return json_pointer(lhs) /= std::move(token); } - /*! - @brief create a new JSON pointer by appending the array-index-token at the end of the JSON pointer - - @param[in] ptr JSON pointer - @param[in] array_idx array index - @return a new JSON pointer with @a array_idx appended to @a ptr - - @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary} - - @complexity Linear in the length of @a ptr. - - @sa @ref operator/=(std::size_t) to append an array index - - @since version 3.6.0 - */ - friend json_pointer operator/(const json_pointer& ptr, std::size_t array_idx) + /// @brief create a new JSON pointer by appending the array-index-token at the end of the JSON pointer + /// @sa https://json.nlohmann.me/api/json_pointer/operator_slash/ + friend json_pointer operator/(const json_pointer& lhs, std::size_t array_idx) { - return json_pointer(ptr) /= array_idx; + return json_pointer(lhs) /= array_idx; } - /*! - @brief returns the parent of this JSON pointer - - @return parent of this JSON pointer; in case this JSON pointer is the root, - the root itself is returned - - @complexity Linear in the length of the JSON pointer. - - @liveexample{The example shows the result of `parent_pointer` for different - JSON Pointers.,json_pointer__parent_pointer} - - @since version 3.6.0 - */ + /// @brief returns the parent of this JSON pointer + /// @sa https://json.nlohmann.me/api/json_pointer/parent_pointer/ json_pointer parent_pointer() const { if (empty()) @@ -231,90 +154,46 @@ class json_pointer return res; } - /*! - @brief remove last reference token - - @pre not `empty()` - - @liveexample{The example shows the usage of `pop_back`.,json_pointer__pop_back} - - @complexity Constant. - - @throw out_of_range.405 if JSON pointer has no parent - - @since version 3.6.0 - */ + /// @brief remove last reference token + /// @sa https://json.nlohmann.me/api/json_pointer/pop_back/ void pop_back() { if (JSON_HEDLEY_UNLIKELY(empty())) { - JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", BasicJsonType())); + JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", nullptr)); } reference_tokens.pop_back(); } - /*! - @brief return last reference token - - @pre not `empty()` - @return last reference token - - @liveexample{The example shows the usage of `back`.,json_pointer__back} - - @complexity Constant. - - @throw out_of_range.405 if JSON pointer has no parent - - @since version 3.6.0 - */ - const std::string& back() const + /// @brief return last reference token + /// @sa https://json.nlohmann.me/api/json_pointer/back/ + const string_t& back() const { if (JSON_HEDLEY_UNLIKELY(empty())) { - JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", BasicJsonType())); + JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", nullptr)); } return reference_tokens.back(); } - /*! - @brief append an unescaped token at the end of the reference pointer - - @param[in] token token to add - - @complexity Amortized constant. - - @liveexample{The example shows the result of `push_back` for different - JSON Pointers.,json_pointer__push_back} - - @since version 3.6.0 - */ - void push_back(const std::string& token) + /// @brief append an unescaped token at the end of the reference pointer + /// @sa https://json.nlohmann.me/api/json_pointer/push_back/ + void push_back(const string_t& token) { reference_tokens.push_back(token); } - /// @copydoc push_back(const std::string&) - void push_back(std::string&& token) + /// @brief append an unescaped token at the end of the reference pointer + /// @sa https://json.nlohmann.me/api/json_pointer/push_back/ + void push_back(string_t&& token) { reference_tokens.push_back(std::move(token)); } - /*! - @brief return whether pointer points to the root document - - @return true iff the JSON pointer points to the root document - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @liveexample{The example shows the result of `empty` for different JSON - Pointers.,json_pointer__empty} - - @since version 3.6.0 - */ + /// @brief return whether pointer points to the root document + /// @sa https://json.nlohmann.me/api/json_pointer/empty/ bool empty() const noexcept { return reference_tokens.empty(); @@ -331,44 +210,39 @@ class json_pointer @throw out_of_range.404 if string @a s could not be converted to an integer @throw out_of_range.410 if an array index exceeds size_type */ - static typename BasicJsonType::size_type array_index(const std::string& s) + template + static typename BasicJsonType::size_type array_index(const string_t& s) { using size_type = typename BasicJsonType::size_type; // error condition (cf. RFC 6901, Sect. 4) if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && s[0] == '0')) { - JSON_THROW(detail::parse_error::create(106, 0, "array index '" + s + "' must not begin with '0'", BasicJsonType())); + JSON_THROW(detail::parse_error::create(106, 0, detail::concat("array index '", s, "' must not begin with '0'"), nullptr)); } // error condition (cf. RFC 6901, Sect. 4) if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && !(s[0] >= '1' && s[0] <= '9'))) { - JSON_THROW(detail::parse_error::create(109, 0, "array index '" + s + "' is not a number", BasicJsonType())); - } - - std::size_t processed_chars = 0; - unsigned long long res = 0; - JSON_TRY - { - res = std::stoull(s, &processed_chars); - } - JSON_CATCH(std::out_of_range&) - { - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'", BasicJsonType())); + JSON_THROW(detail::parse_error::create(109, 0, detail::concat("array index '", s, "' is not a number"), nullptr)); } - // check if the string was completely read - if (JSON_HEDLEY_UNLIKELY(processed_chars != s.size())) + const char* p = s.c_str(); + char* p_end = nullptr; + errno = 0; // strtoull doesn't reset errno + const unsigned long long res = std::strtoull(p, &p_end, 10); // NOLINT(runtime/int) + if (p == p_end // invalid input or empty string + || errno == ERANGE // out of range + || JSON_HEDLEY_UNLIKELY(static_cast(p_end - p) != s.size())) // incomplete read { - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'", BasicJsonType())); + JSON_THROW(detail::out_of_range::create(404, detail::concat("unresolved reference token '", s, "'"), nullptr)); } // only triggered on special platforms (like 32bit), see also // https://github.com/nlohmann/json/pull/2203 - if (res >= static_cast((std::numeric_limits::max)())) + if (res >= static_cast((std::numeric_limits::max)())) // NOLINT(runtime/int) { - JSON_THROW(detail::out_of_range::create(410, "array index " + s + " exceeds size_type", BasicJsonType())); // LCOV_EXCL_LINE + JSON_THROW(detail::out_of_range::create(410, detail::concat("array index ", s, " exceeds size_type"), nullptr)); // LCOV_EXCL_LINE } return static_cast(res); @@ -379,7 +253,7 @@ class json_pointer { if (JSON_HEDLEY_UNLIKELY(empty())) { - JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", BasicJsonType())); + JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", nullptr)); } json_pointer result = *this; @@ -396,9 +270,10 @@ class json_pointer @throw parse_error.109 if array index is not a number @throw type_error.313 if value cannot be unflattened */ + template BasicJsonType& get_and_create(BasicJsonType& j) const { - auto result = &j; + auto* result = &j; // in case no reference tokens exist, return a reference to the JSON value // j which will be overwritten by a primitive value @@ -431,7 +306,7 @@ class json_pointer case detail::value_t::array: { // create an entry in the array - result = &result->operator[](array_index(reference_token)); + result = &result->operator[](array_index(reference_token)); break; } @@ -441,8 +316,15 @@ class json_pointer an error situation, because primitive values may only occur as single value; that is, with an empty list of reference tokens. */ + case detail::value_t::string: + case detail::value_t::boolean: + case detail::value_t::number_integer: + case detail::value_t::number_unsigned: + case detail::value_t::number_float: + case detail::value_t::binary: + case detail::value_t::discarded: default: - JSON_THROW(detail::type_error::create(313, "invalid value to unflatten", j)); + JSON_THROW(detail::type_error::create(313, "invalid value to unflatten", &j)); } } @@ -468,6 +350,7 @@ class json_pointer @throw parse_error.109 if an array index was not a number @throw out_of_range.404 if the JSON pointer can not be resolved */ + template BasicJsonType& get_unchecked(BasicJsonType* ptr) const { for (const auto& reference_token : reference_tokens) @@ -503,18 +386,26 @@ class json_pointer if (reference_token == "-") { // explicitly treat "-" as index beyond the end - ptr = &ptr->operator[](ptr->m_value.array->size()); + ptr = &ptr->operator[](ptr->m_data.m_value.array->size()); } else { // convert array index to number; unchecked access - ptr = &ptr->operator[](array_index(reference_token)); + ptr = &ptr->operator[](array_index(reference_token)); } break; } + case detail::value_t::null: + case detail::value_t::string: + case detail::value_t::boolean: + case detail::value_t::number_integer: + case detail::value_t::number_unsigned: + case detail::value_t::number_float: + case detail::value_t::binary: + case detail::value_t::discarded: default: - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr)); + JSON_THROW(detail::out_of_range::create(404, detail::concat("unresolved reference token '", reference_token, "'"), ptr)); } } @@ -527,6 +418,7 @@ class json_pointer @throw out_of_range.402 if the array index '-' is used @throw out_of_range.404 if the JSON pointer can not be resolved */ + template BasicJsonType& get_checked(BasicJsonType* ptr) const { for (const auto& reference_token : reference_tokens) @@ -545,18 +437,26 @@ class json_pointer if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check - JSON_THROW(detail::out_of_range::create(402, - "array index '-' (" + std::to_string(ptr->m_value.array->size()) + - ") is out of range", *ptr)); + JSON_THROW(detail::out_of_range::create(402, detail::concat( + "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), + ") is out of range"), ptr)); } // note: at performs range check - ptr = &ptr->at(array_index(reference_token)); + ptr = &ptr->at(array_index(reference_token)); break; } + case detail::value_t::null: + case detail::value_t::string: + case detail::value_t::boolean: + case detail::value_t::number_integer: + case detail::value_t::number_unsigned: + case detail::value_t::number_float: + case detail::value_t::binary: + case detail::value_t::discarded: default: - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr)); + JSON_THROW(detail::out_of_range::create(404, detail::concat("unresolved reference token '", reference_token, "'"), ptr)); } } @@ -576,6 +476,7 @@ class json_pointer @throw out_of_range.402 if the array index '-' is used @throw out_of_range.404 if the JSON pointer can not be resolved */ + template const BasicJsonType& get_unchecked(const BasicJsonType* ptr) const { for (const auto& reference_token : reference_tokens) @@ -594,16 +495,24 @@ class json_pointer if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" cannot be used for const access - JSON_THROW(detail::out_of_range::create(402, "array index '-' (" + std::to_string(ptr->m_value.array->size()) + ") is out of range", *ptr)); + JSON_THROW(detail::out_of_range::create(402, detail::concat("array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), ") is out of range"), ptr)); } // use unchecked array access - ptr = &ptr->operator[](array_index(reference_token)); + ptr = &ptr->operator[](array_index(reference_token)); break; } + case detail::value_t::null: + case detail::value_t::string: + case detail::value_t::boolean: + case detail::value_t::number_integer: + case detail::value_t::number_unsigned: + case detail::value_t::number_float: + case detail::value_t::binary: + case detail::value_t::discarded: default: - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr)); + JSON_THROW(detail::out_of_range::create(404, detail::concat("unresolved reference token '", reference_token, "'"), ptr)); } } @@ -616,6 +525,7 @@ class json_pointer @throw out_of_range.402 if the array index '-' is used @throw out_of_range.404 if the JSON pointer can not be resolved */ + template const BasicJsonType& get_checked(const BasicJsonType* ptr) const { for (const auto& reference_token : reference_tokens) @@ -634,18 +544,26 @@ class json_pointer if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check - JSON_THROW(detail::out_of_range::create(402, - "array index '-' (" + std::to_string(ptr->m_value.array->size()) + - ") is out of range", *ptr)); + JSON_THROW(detail::out_of_range::create(402, detail::concat( + "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), + ") is out of range"), ptr)); } // note: at performs range check - ptr = &ptr->at(array_index(reference_token)); + ptr = &ptr->at(array_index(reference_token)); break; } + case detail::value_t::null: + case detail::value_t::string: + case detail::value_t::boolean: + case detail::value_t::number_integer: + case detail::value_t::number_unsigned: + case detail::value_t::number_float: + case detail::value_t::binary: + case detail::value_t::discarded: default: - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr)); + JSON_THROW(detail::out_of_range::create(404, detail::concat("unresolved reference token '", reference_token, "'"), ptr)); } } @@ -656,6 +574,7 @@ class json_pointer @throw parse_error.106 if an array index begins with '0' @throw parse_error.109 if an array index was not a number */ + template bool contains(const BasicJsonType* ptr) const { for (const auto& reference_token : reference_tokens) @@ -703,7 +622,7 @@ class json_pointer } } - const auto idx = array_index(reference_token); + const auto idx = array_index(reference_token); if (idx >= ptr->size()) { // index out of range @@ -714,6 +633,14 @@ class json_pointer break; } + case detail::value_t::null: + case detail::value_t::string: + case detail::value_t::boolean: + case detail::value_t::number_integer: + case detail::value_t::number_unsigned: + case detail::value_t::number_float: + case detail::value_t::binary: + case detail::value_t::discarded: default: { // we do not expect primitive values if there is still a @@ -736,9 +663,9 @@ class json_pointer @throw parse_error.107 if the pointer is not empty or begins with '/' @throw parse_error.108 if character '~' is not followed by '0' or '1' */ - static std::vector split(const std::string& reference_string) + static std::vector split(const string_t& reference_string) { - std::vector result; + std::vector result; // special case: empty reference string -> no reference tokens if (reference_string.empty()) @@ -749,7 +676,7 @@ class json_pointer // check if nonempty reference string begins with slash if (JSON_HEDLEY_UNLIKELY(reference_string[0] != '/')) { - JSON_THROW(detail::parse_error::create(107, 1, "JSON pointer must be empty or begin with '/' - was: '" + reference_string + "'", BasicJsonType())); + JSON_THROW(detail::parse_error::create(107, 1, detail::concat("JSON pointer must be empty or begin with '/' - was: '", reference_string, "'"), nullptr)); } // extract the reference tokens: @@ -760,11 +687,11 @@ class json_pointer std::size_t slash = reference_string.find_first_of('/', 1), // set the beginning of the first reference token start = 1; - // we can stop if start == 0 (if slash == std::string::npos) + // we can stop if start == 0 (if slash == string_t::npos) start != 0; // set the beginning of the next reference token - // (will eventually be 0 if slash == std::string::npos) - start = (slash == std::string::npos) ? 0 : slash + 1, + // (will eventually be 0 if slash == string_t::npos) + start = (slash == string_t::npos) ? 0 : slash + 1, // find next slash slash = reference_string.find_first_of('/', start)) { @@ -774,7 +701,7 @@ class json_pointer // check reference tokens are properly escaped for (std::size_t pos = reference_token.find_first_of('~'); - pos != std::string::npos; + pos != string_t::npos; pos = reference_token.find_first_of('~', pos + 1)) { JSON_ASSERT(reference_token[pos] == '~'); @@ -784,7 +711,7 @@ class json_pointer (reference_token[pos + 1] != '0' && reference_token[pos + 1] != '1'))) { - JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'", BasicJsonType())); + JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'", nullptr)); } } @@ -804,7 +731,8 @@ class json_pointer @note Empty objects or arrays are flattened to `null`. */ - static void flatten(const std::string& reference_string, + template + static void flatten(const string_t& reference_string, const BasicJsonType& value, BasicJsonType& result) { @@ -812,7 +740,7 @@ class json_pointer { case detail::value_t::array: { - if (value.m_value.array->empty()) + if (value.m_data.m_value.array->empty()) { // flatten empty array as null result[reference_string] = nullptr; @@ -820,10 +748,10 @@ class json_pointer else { // iterate array and use index as reference string - for (std::size_t i = 0; i < value.m_value.array->size(); ++i) + for (std::size_t i = 0; i < value.m_data.m_value.array->size(); ++i) { - flatten(reference_string + "/" + std::to_string(i), - value.m_value.array->operator[](i), result); + flatten(detail::concat(reference_string, '/', std::to_string(i)), + value.m_data.m_value.array->operator[](i), result); } } break; @@ -831,7 +759,7 @@ class json_pointer case detail::value_t::object: { - if (value.m_value.object->empty()) + if (value.m_data.m_value.object->empty()) { // flatten empty object as null result[reference_string] = nullptr; @@ -839,14 +767,22 @@ class json_pointer else { // iterate object and use keys as reference string - for (const auto& element : *value.m_value.object) + for (const auto& element : *value.m_data.m_value.object) { - flatten(reference_string + "/" + detail::escape(element.first), element.second, result); + flatten(detail::concat(reference_string, '/', detail::escape(element.first)), element.second, result); } } break; } + case detail::value_t::null: + case detail::value_t::string: + case detail::value_t::boolean: + case detail::value_t::number_integer: + case detail::value_t::number_unsigned: + case detail::value_t::number_float: + case detail::value_t::binary: + case detail::value_t::discarded: default: { // add primitive value with its reference string @@ -866,22 +802,23 @@ class json_pointer @throw type_error.315 if object values are not primitive @throw type_error.313 if value cannot be unflattened */ + template static BasicJsonType unflatten(const BasicJsonType& value) { if (JSON_HEDLEY_UNLIKELY(!value.is_object())) { - JSON_THROW(detail::type_error::create(314, "only objects can be unflattened", value)); + JSON_THROW(detail::type_error::create(314, "only objects can be unflattened", &value)); } BasicJsonType result; // iterate the JSON object values - for (const auto& element : *value.m_value.object) + for (const auto& element : *value.m_data.m_value.object) { if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive())) { - JSON_THROW(detail::type_error::create(315, "values in object must be primitive", element.second)); + JSON_THROW(detail::type_error::create(315, "values in object must be primitive", &element.second)); } // assign value to reference pointed to by JSON pointer; Note that if @@ -894,41 +831,158 @@ class json_pointer return result; } - /*! - @brief compares two JSON pointers for equality - - @param[in] lhs JSON pointer to compare - @param[in] rhs JSON pointer to compare - @return whether @a lhs is equal to @a rhs - - @complexity Linear in the length of the JSON pointer - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - */ - friend bool operator==(json_pointer const& lhs, - json_pointer const& rhs) noexcept + // can't use conversion operator because of ambiguity + json_pointer convert() const& { - return lhs.reference_tokens == rhs.reference_tokens; + json_pointer result; + result.reference_tokens = reference_tokens; + return result; } - /*! - @brief compares two JSON pointers for inequality + json_pointer convert()&& + { + json_pointer result; + result.reference_tokens = std::move(reference_tokens); + return result; + } - @param[in] lhs JSON pointer to compare - @param[in] rhs JSON pointer to compare - @return whether @a lhs is not equal @a rhs + public: +#if JSON_HAS_THREE_WAY_COMPARISON + /// @brief compares two JSON pointers for equality + /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ + template + bool operator==(const json_pointer& rhs) const noexcept + { + return reference_tokens == rhs.reference_tokens; + } - @complexity Linear in the length of the JSON pointer + /// @brief compares JSON pointer and string for equality + /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ + JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer)) + bool operator==(const string_t& rhs) const + { + return *this == json_pointer(rhs); + } - @exceptionsafety No-throw guarantee: this function never throws exceptions. - */ - friend bool operator!=(json_pointer const& lhs, - json_pointer const& rhs) noexcept + /// @brief 3-way compares two JSON pointers + template + std::strong_ordering operator<=>(const json_pointer& rhs) const noexcept // *NOPAD* { - return !(lhs == rhs); + return reference_tokens <=> rhs.reference_tokens; // *NOPAD* } +#else + /// @brief compares two JSON pointers for equality + /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ + template + // NOLINTNEXTLINE(readability-redundant-declaration) + friend bool operator==(const json_pointer& lhs, + const json_pointer& rhs) noexcept; + + /// @brief compares JSON pointer and string for equality + /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ + template + // NOLINTNEXTLINE(readability-redundant-declaration) + friend bool operator==(const json_pointer& lhs, + const StringType& rhs); + + /// @brief compares string and JSON pointer for equality + /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ + template + // NOLINTNEXTLINE(readability-redundant-declaration) + friend bool operator==(const StringType& lhs, + const json_pointer& rhs); + + /// @brief compares two JSON pointers for inequality + /// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/ + template + // NOLINTNEXTLINE(readability-redundant-declaration) + friend bool operator!=(const json_pointer& lhs, + const json_pointer& rhs) noexcept; + + /// @brief compares JSON pointer and string for inequality + /// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/ + template + // NOLINTNEXTLINE(readability-redundant-declaration) + friend bool operator!=(const json_pointer& lhs, + const StringType& rhs); + + /// @brief compares string and JSON pointer for inequality + /// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/ + template + // NOLINTNEXTLINE(readability-redundant-declaration) + friend bool operator!=(const StringType& lhs, + const json_pointer& rhs); + + /// @brief compares two JSON pointer for less-than + template + // NOLINTNEXTLINE(readability-redundant-declaration) + friend bool operator<(const json_pointer& lhs, + const json_pointer& rhs) noexcept; +#endif + private: /// the reference tokens - std::vector reference_tokens; + std::vector reference_tokens; }; -} // namespace nlohmann + +#if !JSON_HAS_THREE_WAY_COMPARISON +// functions cannot be defined inside class due to ODR violations +template +inline bool operator==(const json_pointer& lhs, + const json_pointer& rhs) noexcept +{ + return lhs.reference_tokens == rhs.reference_tokens; +} + +template::string_t> +JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer)) +inline bool operator==(const json_pointer& lhs, + const StringType& rhs) +{ + return lhs == json_pointer(rhs); +} + +template::string_t> +JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer)) +inline bool operator==(const StringType& lhs, + const json_pointer& rhs) +{ + return json_pointer(lhs) == rhs; +} + +template +inline bool operator!=(const json_pointer& lhs, + const json_pointer& rhs) noexcept +{ + return !(lhs == rhs); +} + +template::string_t> +JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator!=(json_pointer, json_pointer)) +inline bool operator!=(const json_pointer& lhs, + const StringType& rhs) +{ + return !(lhs == rhs); +} + +template::string_t> +JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator!=(json_pointer, json_pointer)) +inline bool operator!=(const StringType& lhs, + const json_pointer& rhs) +{ + return !(lhs == rhs); +} + +template +inline bool operator<(const json_pointer& lhs, + const json_pointer& rhs) noexcept +{ + return lhs.reference_tokens < rhs.reference_tokens; +} +#endif + +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/json_ref.hpp b/external_imported/json/include/nlohmann/detail/json_ref.hpp index 26a490382..b8bb6a76b 100644 --- a/external_imported/json/include/nlohmann/detail/json_ref.hpp +++ b/external_imported/json/include/nlohmann/detail/json_ref.hpp @@ -1,14 +1,23 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once #include #include +#include #include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + template class json_ref { @@ -35,7 +44,7 @@ class json_ref {} // class should be movable only - json_ref(json_ref&&) = default; + json_ref(json_ref&&) noexcept = default; json_ref(const json_ref&) = delete; json_ref& operator=(const json_ref&) = delete; json_ref& operator=(json_ref&&) = delete; @@ -64,5 +73,6 @@ class json_ref mutable value_type owned_value = nullptr; value_type const* value_ref = nullptr; }; + } // namespace detail -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/macro_scope.hpp b/external_imported/json/include/nlohmann/detail/macro_scope.hpp index 77acf04c7..97127a646 100644 --- a/external_imported/json/include/nlohmann/detail/macro_scope.hpp +++ b/external_imported/json/include/nlohmann/detail/macro_scope.hpp @@ -1,11 +1,22 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once -#include // pair +#include // declval, pair +#include #include -// This file contains all internal macro definitions +// This file contains all internal macro definitions (except those affecting ABI) // You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them +#include + // exclude unsupported compilers #if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) #if defined(__clang__) @@ -20,30 +31,136 @@ #endif // C++ language standard detection -#if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) - #define JSON_HAS_CPP_20 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 -#elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 -#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) - #define JSON_HAS_CPP_14 +// if the user manually specified the used c++ version this is skipped +#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11) + #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) + #define JSON_HAS_CPP_20 + #define JSON_HAS_CPP_17 + #define JSON_HAS_CPP_14 + #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 + #define JSON_HAS_CPP_17 + #define JSON_HAS_CPP_14 + #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) + #define JSON_HAS_CPP_14 + #endif + // the cpp 11 flag is always specified because it is the minimal required version + #define JSON_HAS_CPP_11 +#endif + +#ifdef __has_include + #if __has_include() + #include + #endif +#endif + +#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM) + #ifdef JSON_HAS_CPP_17 + #if defined(__cpp_lib_filesystem) + #define JSON_HAS_FILESYSTEM 1 + #elif defined(__cpp_lib_experimental_filesystem) + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #elif !defined(__has_include) + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #elif __has_include() + #define JSON_HAS_FILESYSTEM 1 + #elif __has_include() + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #endif + + // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ + #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before GCC 8: https://en.cppreference.com/w/cpp/compiler_support + #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before Clang 7: https://en.cppreference.com/w/cpp/compiler_support + #if defined(__clang_major__) && __clang_major__ < 7 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before MSVC 19.14: https://en.cppreference.com/w/cpp/compiler_support + #if defined(_MSC_VER) && _MSC_VER < 1914 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before iOS 13 + #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before macOS Catalina + #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + #endif +#endif + +#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0 #endif -// disable float-equal warnings on GCC/clang -#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wfloat-equal" +#ifndef JSON_HAS_FILESYSTEM + #define JSON_HAS_FILESYSTEM 0 +#endif + +#ifndef JSON_HAS_THREE_WAY_COMPARISON + #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \ + && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L + #define JSON_HAS_THREE_WAY_COMPARISON 1 + #else + #define JSON_HAS_THREE_WAY_COMPARISON 0 + #endif +#endif + +#ifndef JSON_HAS_RANGES + // ranges header shipping in GCC 11.1.0 (released 2021-04-27) has syntax error + #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427 + #define JSON_HAS_RANGES 0 + #elif defined(__cpp_lib_ranges) + #define JSON_HAS_RANGES 1 + #else + #define JSON_HAS_RANGES 0 + #endif +#endif + +#ifndef JSON_HAS_STATIC_RTTI + #if !defined(_HAS_STATIC_RTTI) || _HAS_STATIC_RTTI != 0 + #define JSON_HAS_STATIC_RTTI 1 + #else + #define JSON_HAS_STATIC_RTTI 0 + #endif +#endif + +#ifdef JSON_HAS_CPP_17 + #define JSON_INLINE_VARIABLE inline +#else + #define JSON_INLINE_VARIABLE +#endif + +#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address) + #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]] +#else + #define JSON_NO_UNIQUE_ADDRESS #endif // disable documentation warnings on clang #if defined(__clang__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdocumentation" + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdocumentation" + #pragma clang diagnostic ignored "-Wdocumentation-unknown-command" #endif -// allow to disable exceptions +// allow disabling exceptions #if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) #define JSON_THROW(exception) throw exception #define JSON_TRY try @@ -77,7 +194,7 @@ #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER #endif -// allow to override assert +// allow overriding assert #if !defined(JSON_ASSERT) #include // assert #define JSON_ASSERT(x) assert(x) @@ -131,12 +248,13 @@ class NumberUnsignedType, class NumberFloatType, \ template class AllocatorType, \ template class JSONSerializer, \ - class BinaryType> + class BinaryType, \ + class CustomBaseClass> #define NLOHMANN_BASIC_JSON_TPL \ basic_json + AllocatorType, JSONSerializer, BinaryType, CustomBaseClass> // Macros to simplify conversion from/to types @@ -273,6 +391,7 @@ #define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1; #define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1); +#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1); /*! @brief macro @@ -283,6 +402,13 @@ friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \ + friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } + +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \ + friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } + /*! @brief macro @def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE @@ -292,6 +418,51 @@ inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \ + inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } + +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \ + inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } + +// inspired from https://stackoverflow.com/a/26745591 +// allows to call any std function as if (e.g. with begin): +// using std::begin; begin(x); +// +// it allows using the detected idiom to retrieve the return type +// of such an expression +#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \ + namespace detail { \ + using std::std_name; \ + \ + template \ + using result_of_##std_name = decltype(std_name(std::declval()...)); \ + } \ + \ + namespace detail2 { \ + struct std_name##_tag \ + { \ + }; \ + \ + template \ + std_name##_tag std_name(T&&...); \ + \ + template \ + using result_of_##std_name = decltype(std_name(std::declval()...)); \ + \ + template \ + struct would_call_std_##std_name \ + { \ + static constexpr auto const value = ::nlohmann::detail:: \ + is_detected_exact::value; \ + }; \ + } /* namespace detail2 */ \ + \ + template \ + struct would_call_std_##std_name : detail2::would_call_std_##std_name \ + { \ + } + #ifndef JSON_USE_IMPLICIT_CONVERSIONS #define JSON_USE_IMPLICIT_CONVERSIONS 1 #endif @@ -301,3 +472,11 @@ #else #define JSON_EXPLICIT explicit #endif + +#ifndef JSON_DISABLE_ENUM_SERIALIZATION + #define JSON_DISABLE_ENUM_SERIALIZATION 0 +#endif + +#ifndef JSON_USE_GLOBAL_UDLS + #define JSON_USE_GLOBAL_UDLS 1 +#endif diff --git a/external_imported/json/include/nlohmann/detail/macro_unscope.hpp b/external_imported/json/include/nlohmann/detail/macro_unscope.hpp index 5ac66f5af..c6620d1e2 100644 --- a/external_imported/json/include/nlohmann/detail/macro_unscope.hpp +++ b/external_imported/json/include/nlohmann/detail/macro_unscope.hpp @@ -1,24 +1,45 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once -// restore GCC/clang diagnostic settings -#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) - #pragma GCC diagnostic pop -#endif +// restore clang diagnostic settings #if defined(__clang__) - #pragma GCC diagnostic pop + #pragma clang diagnostic pop #endif // clean up #undef JSON_ASSERT #undef JSON_INTERNAL_CATCH -#undef JSON_CATCH #undef JSON_THROW -#undef JSON_TRY #undef JSON_PRIVATE_UNLESS_TESTED -#undef JSON_HAS_CPP_14 -#undef JSON_HAS_CPP_17 #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION #undef NLOHMANN_BASIC_JSON_TPL #undef JSON_EXPLICIT +#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL +#undef JSON_INLINE_VARIABLE +#undef JSON_NO_UNIQUE_ADDRESS +#undef JSON_DISABLE_ENUM_SERIALIZATION +#undef JSON_USE_GLOBAL_UDLS + +#ifndef JSON_TEST_KEEP_MACROS + #undef JSON_CATCH + #undef JSON_TRY + #undef JSON_HAS_CPP_11 + #undef JSON_HAS_CPP_14 + #undef JSON_HAS_CPP_17 + #undef JSON_HAS_CPP_20 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #undef JSON_HAS_THREE_WAY_COMPARISON + #undef JSON_HAS_RANGES + #undef JSON_HAS_STATIC_RTTI + #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON +#endif #include diff --git a/external_imported/json/include/nlohmann/detail/meta/call_std/begin.hpp b/external_imported/json/include/nlohmann/detail/meta/call_std/begin.hpp new file mode 100644 index 000000000..364cc89d8 --- /dev/null +++ b/external_imported/json/include/nlohmann/detail/meta/call_std/begin.hpp @@ -0,0 +1,17 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + +#pragma once + +#include + +NLOHMANN_JSON_NAMESPACE_BEGIN + +NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin); + +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/meta/call_std/end.hpp b/external_imported/json/include/nlohmann/detail/meta/call_std/end.hpp new file mode 100644 index 000000000..463f07061 --- /dev/null +++ b/external_imported/json/include/nlohmann/detail/meta/call_std/end.hpp @@ -0,0 +1,17 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + +#pragma once + +#include + +NLOHMANN_JSON_NAMESPACE_BEGIN + +NLOHMANN_CAN_CALL_STD_FUNC_IMPL(end); + +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/meta/cpp_future.hpp b/external_imported/json/include/nlohmann/detail/meta/cpp_future.hpp index 4ba1a5571..412b5aa74 100644 --- a/external_imported/json/include/nlohmann/detail/meta/cpp_future.hpp +++ b/external_imported/json/include/nlohmann/detail/meta/cpp_future.hpp @@ -1,13 +1,22 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-FileCopyrightText: 2018 The Abseil Authors +// SPDX-License-Identifier: MIT + #pragma once +#include // array #include // size_t #include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type #include // index_sequence, make_index_sequence, index_sequence_for #include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { @@ -28,36 +37,112 @@ using std::index_sequence_for; template using enable_if_t = typename std::enable_if::type; -// source: https://stackoverflow.com/a/32223343 -template -struct index_sequence +// The following code is taken from https://github.com/abseil/abseil-cpp/blob/10cb35e459f5ecca5b2ff107635da0bfa41011b4/absl/utility/utility.h +// which is part of Google Abseil (https://github.com/abseil/abseil-cpp), licensed under the Apache License 2.0. + +//// START OF CODE FROM GOOGLE ABSEIL + +// integer_sequence +// +// Class template representing a compile-time integer sequence. An instantiation +// of `integer_sequence` has a sequence of integers encoded in its +// type through its template arguments (which is a common need when +// working with C++11 variadic templates). `absl::integer_sequence` is designed +// to be a drop-in replacement for C++14's `std::integer_sequence`. +// +// Example: +// +// template< class T, T... Ints > +// void user_function(integer_sequence); +// +// int main() +// { +// // user_function's `T` will be deduced to `int` and `Ints...` +// // will be deduced to `0, 1, 2, 3, 4`. +// user_function(make_integer_sequence()); +// } +template +struct integer_sequence { - using type = index_sequence; - using value_type = std::size_t; + using value_type = T; static constexpr std::size_t size() noexcept { return sizeof...(Ints); } }; -template -struct merge_and_renumber; +// index_sequence +// +// A helper template for an `integer_sequence` of `size_t`, +// `absl::index_sequence` is designed to be a drop-in replacement for C++14's +// `std::index_sequence`. +template +using index_sequence = integer_sequence; -template -struct merge_and_renumber, index_sequence> - : index_sequence < I1..., (sizeof...(I1) + I2)... > {}; +namespace utility_internal +{ -template -struct make_index_sequence - : merge_and_renumber < typename make_index_sequence < N / 2 >::type, - typename make_index_sequence < N - N / 2 >::type > {}; +template +struct Extend; + +// Note that SeqSize == sizeof...(Ints). It's passed explicitly for efficiency. +template +struct Extend, SeqSize, 0> +{ + using type = integer_sequence < T, Ints..., (Ints + SeqSize)... >; +}; -template<> struct make_index_sequence<0> : index_sequence<> {}; -template<> struct make_index_sequence<1> : index_sequence<0> {}; +template +struct Extend, SeqSize, 1> +{ + using type = integer_sequence < T, Ints..., (Ints + SeqSize)..., 2 * SeqSize >; +}; -template +// Recursion helper for 'make_integer_sequence'. +// 'Gen::type' is an alias for 'integer_sequence'. +template +struct Gen +{ + using type = + typename Extend < typename Gen < T, N / 2 >::type, N / 2, N % 2 >::type; +}; + +template +struct Gen +{ + using type = integer_sequence; +}; + +} // namespace utility_internal + +// Compile-time sequences of integers + +// make_integer_sequence +// +// This template alias is equivalent to +// `integer_sequence`, and is designed to be a drop-in +// replacement for C++14's `std::make_integer_sequence`. +template +using make_integer_sequence = typename utility_internal::Gen::type; + +// make_index_sequence +// +// This template alias is equivalent to `index_sequence<0, 1, ..., N-1>`, +// and is designed to be a drop-in replacement for C++14's +// `std::make_index_sequence`. +template +using make_index_sequence = make_integer_sequence; + +// index_sequence_for +// +// Converts a typename pack into an index sequence of the same length, and +// is designed to be a drop-in replacement for C++14's +// `std::index_sequence_for()` +template using index_sequence_for = make_index_sequence; +//// END OF CODE FROM GOOGLE ABSEIL + #endif // dispatch utility (taken from ranges-v3) @@ -68,11 +153,19 @@ template<> struct priority_tag<0> {}; template struct static_const { - static constexpr T value{}; + static JSON_INLINE_VARIABLE constexpr T value{}; }; -template -constexpr T static_const::value; +#ifndef JSON_HAS_CPP_17 + template + constexpr T static_const::value; +#endif + +template +inline constexpr std::array make_array(Args&& ... args) +{ + return std::array {{static_cast(std::forward(args))...}}; +} } // namespace detail -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/meta/detected.hpp b/external_imported/json/include/nlohmann/detail/meta/detected.hpp index 7b5a00353..1db9bf9ca 100644 --- a/external_imported/json/include/nlohmann/detail/meta/detected.hpp +++ b/external_imported/json/include/nlohmann/detail/meta/detected.hpp @@ -1,14 +1,22 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once #include #include -// https://en.cppreference.com/w/cpp/experimental/is_detected -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + +// https://en.cppreference.com/w/cpp/experimental/is_detected struct nonesuch { nonesuch() = delete; @@ -39,6 +47,9 @@ struct detector>, Op, Args...> template class Op, class... Args> using is_detected = typename detector::value_t; +template class Op, class... Args> +struct is_detected_lazy : is_detected { }; + template class Op, class... Args> using detected_t = typename detector::type; @@ -54,5 +65,6 @@ using is_detected_exact = std::is_same>; template class Op, class... Args> using is_detected_convertible = std::is_convertible, To>; + } // namespace detail -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/meta/identity_tag.hpp b/external_imported/json/include/nlohmann/detail/meta/identity_tag.hpp new file mode 100644 index 000000000..269deffb2 --- /dev/null +++ b/external_imported/json/include/nlohmann/detail/meta/identity_tag.hpp @@ -0,0 +1,21 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + +#pragma once + +#include + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +// dispatching helper struct +template struct identity_tag {}; + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/meta/is_sax.hpp b/external_imported/json/include/nlohmann/detail/meta/is_sax.hpp index e1e48a0ba..4e02bc148 100644 --- a/external_imported/json/include/nlohmann/detail/meta/is_sax.hpp +++ b/external_imported/json/include/nlohmann/detail/meta/is_sax.hpp @@ -1,16 +1,25 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once #include // size_t #include // declval #include // string +#include #include #include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + template using null_function_t = decltype(std::declval().null()); @@ -145,5 +154,6 @@ struct is_sax_static_asserts "Missing/invalid function: bool parse_error(std::size_t, const " "std::string&, const exception&)"); }; + } // namespace detail -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/external_imported/json/include/nlohmann/detail/meta/std_fs.hpp b/external_imported/json/include/nlohmann/detail/meta/std_fs.hpp new file mode 100644 index 000000000..fd1803964 --- /dev/null +++ b/external_imported/json/include/nlohmann/detail/meta/std_fs.hpp @@ -0,0 +1,29 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + +#pragma once + +#include + +#if JSON_HAS_EXPERIMENTAL_FILESYSTEM +#include +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ +namespace std_fs = std::experimental::filesystem; +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END +#elif JSON_HAS_FILESYSTEM +#include +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ +namespace std_fs = std::filesystem; +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END +#endif diff --git a/external_imported/json/include/nlohmann/detail/meta/type_traits.hpp b/external_imported/json/include/nlohmann/detail/meta/type_traits.hpp index 1706cbdc6..e1b000dcc 100644 --- a/external_imported/json/include/nlohmann/detail/meta/type_traits.hpp +++ b/external_imported/json/include/nlohmann/detail/meta/type_traits.hpp @@ -1,18 +1,28 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + #pragma once #include // numeric_limits #include // false_type, is_constructible, is_integral, is_same, true_type #include // declval #include // tuple +#include // char_traits #include #include +#include +#include #include #include #include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN /*! @brief detail namespace with internal helper functions @@ -23,6 +33,7 @@ implementations of some @ref basic_json methods, and meta-programming helpers. */ namespace detail { + ///////////// // helpers // ///////////// @@ -41,6 +52,16 @@ template struct is_basic_json : std::false_type {}; NLOHMANN_BASIC_JSON_TPL_DECLARATION struct is_basic_json : std::true_type {}; +// used by exceptions create() member functions +// true_type for pointer to possibly cv-qualified basic_json or std::nullptr_t +// false_type otherwise +template +struct is_basic_json_context : + std::integral_constant < bool, + is_basic_json::type>::type>::value + || std::is_same::value > +{}; + ////////////////////// // json_ref helpers // ////////////////////// @@ -79,9 +100,6 @@ using reference_t = typename T::reference; template using iterator_category_t = typename T::iterator_category; -template -using iterator_t = typename T::iterator; - template using to_json_function = decltype(T::to_json(std::declval()...)); @@ -106,8 +124,7 @@ struct is_getable }; template -struct has_from_json < BasicJsonType, T, - enable_if_t < !is_basic_json::value >> +struct has_from_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> { using serializer = typename BasicJsonType::template json_serializer; @@ -146,11 +163,133 @@ struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> T>::value; }; +template +using detect_key_compare = typename T::key_compare; + +template +struct has_key_compare : std::integral_constant::value> {}; + +// obtains the actual object key comparator +template +struct actual_object_comparator +{ + using object_t = typename BasicJsonType::object_t; + using object_comparator_t = typename BasicJsonType::default_object_comparator_t; + using type = typename std::conditional < has_key_compare::value, + typename object_t::key_compare, object_comparator_t>::type; +}; + +template +using actual_object_comparator_t = typename actual_object_comparator::type; + +///////////////// +// char_traits // +///////////////// + +// Primary template of char_traits calls std char_traits +template +struct char_traits : std::char_traits +{}; + +// Explicitly define char traits for unsigned char since it is not standard +template<> +struct char_traits : std::char_traits +{ + using char_type = unsigned char; + using int_type = uint64_t; + + // Redefine to_int_type function + static int_type to_int_type(char_type c) noexcept + { + return static_cast(c); + } + + static char_type to_char_type(int_type i) noexcept + { + return static_cast(i); + } + + static constexpr int_type eof() noexcept + { + return static_cast(EOF); + } +}; + +// Explicitly define char traits for signed char since it is not standard +template<> +struct char_traits : std::char_traits +{ + using char_type = signed char; + using int_type = uint64_t; + + // Redefine to_int_type function + static int_type to_int_type(char_type c) noexcept + { + return static_cast(c); + } + + static char_type to_char_type(int_type i) noexcept + { + return static_cast(i); + } + + static constexpr int_type eof() noexcept + { + return static_cast(EOF); + } +}; /////////////////// // is_ functions // /////////////////// +// https://en.cppreference.com/w/cpp/types/conjunction +template struct conjunction : std::true_type { }; +template struct conjunction : B { }; +template +struct conjunction +: std::conditional(B::value), conjunction, B>::type {}; + +// https://en.cppreference.com/w/cpp/types/negation +template struct negation : std::integral_constant < bool, !B::value > { }; + +// Reimplementation of is_constructible and is_default_constructible, due to them being broken for +// std::pair and std::tuple until LWG 2367 fix (see https://cplusplus.github.io/LWG/lwg-defects.html#2367). +// This causes compile errors in e.g. clang 3.5 or gcc 4.9. +template +struct is_default_constructible : std::is_default_constructible {}; + +template +struct is_default_constructible> + : conjunction, is_default_constructible> {}; + +template +struct is_default_constructible> + : conjunction, is_default_constructible> {}; + +template +struct is_default_constructible> + : conjunction...> {}; + +template +struct is_default_constructible> + : conjunction...> {}; + +template +struct is_constructible : std::is_constructible {}; + +template +struct is_constructible> : is_default_constructible> {}; + +template +struct is_constructible> : is_default_constructible> {}; + +template +struct is_constructible> : is_default_constructible> {}; + +template +struct is_constructible> : is_default_constructible> {}; + template struct is_iterator_traits : std::false_type {}; @@ -169,6 +308,31 @@ struct is_iterator_traits> is_detected::value; }; +template +struct is_range +{ + private: + using t_ref = typename std::add_lvalue_reference::type; + + using iterator = detected_t; + using sentinel = detected_t; + + // to be 100% correct, it should use https://en.cppreference.com/w/cpp/iterator/input_or_output_iterator + // and https://en.cppreference.com/w/cpp/iterator/sentinel_for + // but reimplementing these would be too much work, as a lot of other concepts are used underneath + static constexpr auto is_iterator_begin = + is_iterator_traits>::value; + + public: + static constexpr bool value = !std::is_same::value && !std::is_same::value && is_iterator_begin; +}; + +template +using iterator_t = enable_if_t::value, result_of_begin())>>; + +template +using range_value_t = value_type_t>>; + // The following implementation of is_complete_type is taken from // https://blogs.msdn.microsoft.com/vcblog/2015/12/02/partial-support-for-expression-sfinae-in-vs-2015-update-1/ // and is written by Xiang Fan who agreed to using it in this library. @@ -193,9 +357,9 @@ struct is_compatible_object_type_impl < // macOS's is_constructible does not play well with nonesuch... static constexpr bool value = - std::is_constructible::value && - std::is_constructible::value; }; @@ -216,10 +380,10 @@ struct is_constructible_object_type_impl < using object_t = typename BasicJsonType::object_t; static constexpr bool value = - (std::is_default_constructible::value && + (is_default_constructible::value && (std::is_move_assignable::value || std::is_copy_assignable::value) && - (std::is_constructible::value && std::is_same < typename object_t::mapped_type, @@ -236,60 +400,46 @@ struct is_constructible_object_type : is_constructible_object_type_impl {}; -template -struct is_compatible_string_type_impl : std::false_type {}; - template -struct is_compatible_string_type_impl < - BasicJsonType, CompatibleStringType, - enable_if_t::value >> +struct is_compatible_string_type { static constexpr auto value = - std::is_constructible::value; + is_constructible::value; }; template -struct is_compatible_string_type - : is_compatible_string_type_impl {}; - -template -struct is_constructible_string_type_impl : std::false_type {}; - -template -struct is_constructible_string_type_impl < - BasicJsonType, ConstructibleStringType, - enable_if_t::value >> +struct is_constructible_string_type { + // launder type through decltype() to fix compilation failure on ICPC +#ifdef __INTEL_COMPILER + using laundered_type = decltype(std::declval()); +#else + using laundered_type = ConstructibleStringType; +#endif + static constexpr auto value = - std::is_constructible::value; + conjunction < + is_constructible, + is_detected_exact>::value; }; -template -struct is_constructible_string_type - : is_constructible_string_type_impl {}; - template struct is_compatible_array_type_impl : std::false_type {}; template struct is_compatible_array_type_impl < BasicJsonType, CompatibleArrayType, - enable_if_t < is_detected::value&& + enable_if_t < is_detected::value&& -// This is needed because json_reverse_iterator has a ::iterator type... -// Therefore it is detected as a CompatibleArrayType. -// The real fix would be to have an Iterable concept. - !is_iterator_traits < - iterator_traits>::value >> + is_iterator_traits>>::value&& +// special case for types like std::filesystem::path whose iterator's value_type are themselves +// c.f. https://github.com/nlohmann/json/pull/3073 + !std::is_same>::value >> { static constexpr bool value = - std::is_constructible::value; + is_constructible>::value; }; template @@ -311,28 +461,29 @@ struct is_constructible_array_type_impl < BasicJsonType, ConstructibleArrayType, enable_if_t < !std::is_same::value&& - std::is_default_constructible::value&& + !is_compatible_string_type::value&& + is_default_constructible::value&& (std::is_move_assignable::value || std::is_copy_assignable::value)&& -is_detected::value&& is_detected::value&& -is_complete_type < -detected_t>::value >> +is_iterator_traits>>::value&& +is_detected::value&& +// special case for types like std::filesystem::path whose iterator's value_type are themselves +// c.f. https://github.com/nlohmann/json/pull/3073 +!std::is_same>::value&& + is_complete_type < + detected_t>::value >> { + using value_type = range_value_t; + static constexpr bool value = - // This is needed because json_reverse_iterator has a ::iterator type, - // furthermore, std::back_insert_iterator (and other iterators) have a - // base class `iterator`... Therefore it is detected as a - // ConstructibleArrayType. The real fix would be to have an Iterable - // concept. - !is_iterator_traits>::value && - - (std::is_same::value || - has_from_json::value || - has_non_default_from_json < - BasicJsonType, typename ConstructibleArrayType::value_type >::value); + std::is_same::value || + has_from_json::value || + has_non_default_from_json < + BasicJsonType, + value_type >::value; }; template @@ -355,7 +506,7 @@ struct is_compatible_integer_type_impl < using CompatibleLimits = std::numeric_limits; static constexpr auto value = - std::is_constructible::value && CompatibleLimits::is_integer && RealLimits::is_signed == CompatibleLimits::is_signed; @@ -382,17 +533,263 @@ template struct is_compatible_type : is_compatible_type_impl {}; -// https://en.cppreference.com/w/cpp/types/conjunction -template struct conjunction : std::true_type { }; -template struct conjunction : B1 { }; -template -struct conjunction -: std::conditional, B1>::type {}; - template struct is_constructible_tuple : std::false_type {}; template -struct is_constructible_tuple> : conjunction...> {}; +struct is_constructible_tuple> : conjunction...> {}; + +template +struct is_json_iterator_of : std::false_type {}; + +template +struct is_json_iterator_of : std::true_type {}; + +template +struct is_json_iterator_of : std::true_type +{}; + +// checks if a given type T is a template specialization of Primary +template