mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2025-07-13 04:26:47 +02:00
Compare commits
75 Commits
v0.6
...
vulkan_hea
Author | SHA1 | Date | |
---|---|---|---|
e4d99ad455 | |||
82faf448f4 | |||
76161df6cd | |||
a0024b34e9 | |||
525db7fe6b | |||
cab146ac45 | |||
695e2e5486 | |||
808822e70b | |||
e55808b32f | |||
95b9a17af4 | |||
aa81118c40 | |||
62c8b10131 | |||
c1f87aceda | |||
2ee17a63ea | |||
9aa6618e0f | |||
0f361f6505 | |||
6b06d5cb99 | |||
052bdb45ec | |||
a6950b9de7 | |||
5023a658e7 | |||
5cc6aa8c74 | |||
563dd80a52 | |||
1ae43457ed | |||
5f066faa28 | |||
bbbbc655e7 | |||
410b373fda | |||
72add20751 | |||
4dd5a69dee | |||
e0f503728d | |||
b520811e72 | |||
69a04cbd7e | |||
ab169927fe | |||
a98098af91 | |||
631b9433c2 | |||
15ab73909f | |||
3dc66de3bc | |||
5e58a61c93 | |||
8f44e09f32 | |||
0408f771b7 | |||
4029dcd50c | |||
338fbf70d0 | |||
e39b23ac72 | |||
c48ae81238 | |||
7a461111e1 | |||
9ff0b17a5e | |||
60aca24ec6 | |||
4304701e5e | |||
601e1ca99d | |||
f5eb0e0dfa | |||
49ed05dfd6 | |||
71486b2550 | |||
5089fd91aa | |||
bfe09374bb | |||
a2b056f385 | |||
a8b3b25e7d | |||
170b21089f | |||
cec80fd492 | |||
b3d700e910 | |||
592138845c | |||
6aa7e3899e | |||
e64c68d942 | |||
513ac12e30 | |||
597a98c3b5 | |||
12b0a90ad0 | |||
c36fa30cbc | |||
0dbe049a00 | |||
81043264d2 | |||
494912ce8a | |||
edcecba2eb | |||
edec5e51d3 | |||
2091d3f97c | |||
c046bd7663 | |||
42ff7c8099 | |||
4a1dde26ce | |||
0ad504e5d4 |
112
.github/workflows/cmake.yml
vendored
Normal file
112
.github/workflows/cmake.yml
vendored
Normal file
@ -0,0 +1,112 @@
|
||||
name: CMake
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
env:
|
||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||
BUILD_TYPE: Debug
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
timeout-minutes: 10
|
||||
|
||||
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
|
||||
# You can convert this to a matrix build if you need cross-platform coverage.
|
||||
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
# TODO: cache
|
||||
|
||||
- name: Install Dependencies
|
||||
run: sudo apt update && sudo apt -y install libsdl2-dev
|
||||
|
||||
- name: Configure CMake
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||
|
||||
#- name: Test
|
||||
#working-directory: ${{github.workspace}}/build
|
||||
## Execute tests defined by the CMake configuration.
|
||||
## See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
|
||||
#run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure
|
||||
|
||||
linux_gles:
|
||||
timeout-minutes: 10
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
# TODO: cache
|
||||
|
||||
- name: Install Dependencies
|
||||
run: sudo apt update && sudo apt -y install libsdl2-dev
|
||||
|
||||
- name: Configure CMake
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DMM_OPENGL_3_GLES=ON
|
||||
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||
|
||||
macos:
|
||||
timeout-minutes: 10
|
||||
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
# TODO: cache
|
||||
|
||||
- name: Install Dependencies
|
||||
run: brew install sdl2
|
||||
|
||||
- name: Configure CMake
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||
|
||||
# TODO: for some reason vcpkg find sdl does not work, despite the find_package REQUIRE not failing
|
||||
#windows:
|
||||
#timeout-minutes: 10
|
||||
|
||||
#runs-on: windows-latest
|
||||
|
||||
#steps:
|
||||
#- uses: actions/checkout@v2
|
||||
#with:
|
||||
#submodules: recursive
|
||||
|
||||
## TODO: cache
|
||||
|
||||
#- name: Install Dependencies
|
||||
#run: vcpkg install sdl2:x64-windows
|
||||
|
||||
## setup vs env
|
||||
#- uses: ilammy/msvc-dev-cmd@v1
|
||||
#with:
|
||||
#arch: amd64
|
||||
|
||||
#- name: Configure CMake
|
||||
#run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
|
||||
|
||||
#- name: Build
|
||||
#run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||
|
12
.gitmodules
vendored
12
.gitmodules
vendored
@ -19,10 +19,6 @@
|
||||
[submodule "external/ImGuiColorTextEdit"]
|
||||
path = external/ImGuiColorTextEdit
|
||||
url = https://github.com/BalazsJako/ImGuiColorTextEdit.git
|
||||
[submodule "external/physfs"]
|
||||
path = external/physfs
|
||||
url = https://github.com/Green-Sky/physfs.git
|
||||
shallow = true
|
||||
[submodule "external/soloud/soloud"]
|
||||
path = external/soloud/soloud
|
||||
url = https://github.com/jarikomppa/soloud.git
|
||||
@ -37,3 +33,11 @@
|
||||
path = external/tracy/tracy
|
||||
url = https://github.com/wolfpld/tracy.git
|
||||
shallow = true
|
||||
[submodule "external/physfs/physfs"]
|
||||
path = external/physfs/physfs
|
||||
url = https://github.com/icculus/physfs.git
|
||||
branch = main
|
||||
[submodule "external/Vulkan-Headers"]
|
||||
path = external/Vulkan-Headers
|
||||
url = https://github.com/KhronosGroup/Vulkan-Headers.git
|
||||
shallow = true
|
||||
|
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
|
||||
# cmake setup begin
|
||||
project(MushMachine C CXX)
|
||||
@ -19,6 +19,11 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||
|
||||
# add this to your projects cmake to enable ipo
|
||||
#include(CheckIPOSupported)
|
||||
#check_ipo_supported()
|
||||
#set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
|
||||
|
||||
# enable test
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||
include(CTest)
|
||||
|
2
LICENSE
2
LICENSE
@ -3,7 +3,7 @@ The Code is under the following License, if not stated otherwise:
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018-2019 Felix Richter
|
||||
Copyright (c) 2018-2021 Erik Scholz
|
||||
Copyright (c) 2018-2022 Erik Scholz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
16
README.md
16
README.md
@ -1,7 +1,7 @@
|
||||

|
||||
|
||||
# MushMachine
|
||||
This is a Game Engine/Framework, originally developed for GH**deducted** (a 2D game), but has since expanded its scope to be more generic. For example it also includes 3D stuff, instead of just 2D. Furthermore it got stripped of some dependency heavy dependencies (yea that's a thing).
|
||||
This is a Game Engine/Framework, originally developed for GH**deducted** (a 2D game), but has since expanded it's scope to be more generic. For example it also includes 3D stuff, instead of just 2D. Furthermore it got stripped of some dependency heavy dependencies (yea that's a thing).
|
||||
|
||||
The initial Developers are Erik Scholz and Felix Richter.
|
||||
Currently developed and maintained by Erik Scholz.
|
||||
@ -13,10 +13,18 @@ The private repo had over 900 commits, before the first public release.
|
||||
- [Github](https://github.com/MadeOfJelly/MushMachine)
|
||||
- [Setup](docs/setup.md)
|
||||
- [Example Game Setup](docs/basic_game.md)
|
||||
- The [Docs Directory](docs/) contains Documentation loosly based on the Source structure.
|
||||
- [mm_template](https://github.com/MadeOfJelly/mm_template) (a GitHub Template for quick starting MM game dev)
|
||||
- The [Docs Directory](docs/) contains Documentation loosely based on the Source structure.
|
||||
- Engine Extensions:
|
||||
- [Box2D integration](https://github.com/Green-Sky/mushmachine_box2d)
|
||||
- [fx_draw (simple line drawing rendertask)](https://github.com/Green-Sky/fx_draw)
|
||||
- Projects using the Engine:
|
||||
- [miniTD](https://github.com/Green-Sky/miniTD)
|
||||
- [LiteParticles2DDemo](https://github.com/MadeOfJelly/mm_lite_particles2d_demo)
|
||||
- [mm_fireworks](https://github.com/Green-Sky/mm_fireworks)
|
||||
|
||||
## Platforms
|
||||
- PC (Linux, Windows and maybe APPLE(untested))
|
||||
- PC (Linux, Windows and maybe APPLE(compiles))
|
||||
- Android (untested)
|
||||
- Web (huh? yea! via Emscripten, wasm and WebGL2)
|
||||
- anything if you put your mind to it....
|
||||
@ -24,7 +32,7 @@ The private repo had over 900 commits, before the first public release.
|
||||
|
||||
## Roadmap
|
||||
- Rewrite the Input service (the code was ported in and is older than the Engine (2017))
|
||||
- Extend the SDL service with Vulkan support (it's 2020 so yea)
|
||||
- Extend the SDL service with Vulkan support (it's 2020 so yea)(man it's 2022 and not done)
|
||||
- Filesystem refactor (like a proper file type, with destructor and stuff)
|
||||
- l10n support
|
||||
- ImGui integration refactor (for making it usable as a game ui, not just for debugging)
|
||||
|
5
external/CMakeLists.txt
vendored
5
external/CMakeLists.txt
vendored
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
|
||||
# external libs
|
||||
|
||||
@ -38,6 +38,9 @@ if(NOT MM_HEADLESS)
|
||||
add_subdirectory("glad-debug")
|
||||
endif()
|
||||
|
||||
add_subdirectory("Vulkan-Headers")
|
||||
target_compile_definitions(Vulkan-Headers INTERFACE VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1)
|
||||
|
||||
# stb utilies
|
||||
add_subdirectory("stb")
|
||||
|
||||
|
3
external/ImGuiColorTextEdit.cmake
vendored
3
external/ImGuiColorTextEdit.cmake
vendored
@ -1,9 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
|
||||
add_library(imgui_color_text_edit
|
||||
"${CMAKE_CURRENT_LIST_DIR}/ImGuiColorTextEdit/TextEditor.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/ImGuiColorTextEdit/TextEditor.cpp"
|
||||
)
|
||||
target_compile_features(imgui_color_text_edit PUBLIC cxx_std_11)
|
||||
target_include_directories(imgui_color_text_edit PUBLIC "${CMAKE_CURRENT_LIST_DIR}/ImGuiColorTextEdit")
|
||||
target_link_libraries(imgui_color_text_edit
|
||||
imgui
|
||||
|
3
external/SquirrelNoise/CMakeLists.txt
vendored
3
external/SquirrelNoise/CMakeLists.txt
vendored
@ -1,4 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
|
||||
project(SquirrelNoise)
|
||||
|
||||
add_library(squirrel_noise
|
||||
|
1
external/Vulkan-Headers
vendored
Submodule
1
external/Vulkan-Headers
vendored
Submodule
Submodule external/Vulkan-Headers added at 245d25ce8c
2
external/entt
vendored
2
external/entt
vendored
Submodule external/entt updated: dd6863f71d...e4ccb878f4
2
external/entt.cmake
vendored
2
external/entt.cmake
vendored
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
add_library(entt INTERFACE)
|
||||
target_include_directories(entt INTERFACE "${CMAKE_CURRENT_LIST_DIR}/entt/src")
|
||||
target_compile_features(entt INTERFACE cxx_std_17)
|
||||
|
7
external/glad-debug/CMakeLists.txt
vendored
7
external/glad-debug/CMakeLists.txt
vendored
@ -1,4 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
|
||||
project(glad C)
|
||||
|
||||
set(C_FILES
|
||||
@ -15,8 +16,6 @@ add_library(glad ${C_FILES} ${H_FILES})
|
||||
target_include_directories(glad PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
|
||||
if(UNIX)
|
||||
target_link_libraries(glad
|
||||
dl
|
||||
)
|
||||
target_link_libraries(glad dl)
|
||||
endif()
|
||||
|
||||
|
2
external/glm.cmake
vendored
2
external/glm.cmake
vendored
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
|
||||
add_library(glm INTERFACE)
|
||||
target_include_directories(glm INTERFACE "${CMAKE_CURRENT_LIST_DIR}/glm")
|
||||
|
2
external/icon_font_cpp_headers.cmake
vendored
2
external/icon_font_cpp_headers.cmake
vendored
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
add_library(icon_font_cpp_headers INTERFACE)
|
||||
target_include_directories(icon_font_cpp_headers INTERFACE "${CMAKE_CURRENT_LIST_DIR}/IconFontCppHeaders/")
|
||||
|
||||
|
2
external/imgui/imgui
vendored
2
external/imgui/imgui
vendored
Submodule external/imgui/imgui updated: ad5d1a8429...c71a50deb5
4
external/json/CMakeLists.txt
vendored
4
external/json/CMakeLists.txt
vendored
@ -1,10 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
|
||||
##
|
||||
## PROJECT
|
||||
## name and version
|
||||
##
|
||||
project(nlohmann_json VERSION 3.8.0 LANGUAGES CXX)
|
||||
project(nlohmann_json VERSION 3.10.4 LANGUAGES CXX)
|
||||
|
||||
|
||||
##
|
||||
|
21
external/json/LICENSE.MIT
vendored
Normal file
21
external/json/LICENSE.MIT
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
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
|
||||
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.
|
@ -1,49 +1,55 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <nlohmann/detail/abi_macros.hpp>
|
||||
#include <nlohmann/detail/conversions/from_json.hpp>
|
||||
#include <nlohmann/detail/conversions/to_json.hpp>
|
||||
#include <nlohmann/detail/meta/identity_tag.hpp>
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
|
||||
template<typename, typename>
|
||||
/// @sa https://json.nlohmann.me/api/adl_serializer/
|
||||
template<typename ValueType, typename>
|
||||
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<typename BasicJsonType, typename ValueType>
|
||||
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<typename BasicJsonType, typename TargetType = ValueType>
|
||||
static auto from_json(BasicJsonType && j, TargetType& val) noexcept(
|
||||
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
|
||||
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
|
||||
{
|
||||
::nlohmann::from_json(std::forward<BasicJsonType>(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.
|
||||
|
||||
@param[in,out] j JSON value to write to
|
||||
@param[in] val value to read from
|
||||
*/
|
||||
template<typename BasicJsonType, typename ValueType>
|
||||
static auto to_json(BasicJsonType& j, ValueType&& val) noexcept(
|
||||
noexcept(::nlohmann::to_json(j, std::forward<ValueType>(val))))
|
||||
-> decltype(::nlohmann::to_json(j, std::forward<ValueType>(val)), void())
|
||||
/// @brief convert a JSON value to any value type
|
||||
/// @sa https://json.nlohmann.me/api/adl_serializer/from_json/
|
||||
template<typename BasicJsonType, typename TargetType = ValueType>
|
||||
static auto from_json(BasicJsonType && j) noexcept(
|
||||
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {})))
|
||||
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}))
|
||||
{
|
||||
::nlohmann::to_json(j, std::forward<ValueType>(val));
|
||||
return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {});
|
||||
}
|
||||
|
||||
/// @brief convert any value type to a JSON value
|
||||
/// @sa https://json.nlohmann.me/api/adl_serializer/to_json/
|
||||
template<typename BasicJsonType, typename TargetType = ValueType>
|
||||
static auto to_json(BasicJsonType& j, TargetType && val) noexcept(
|
||||
noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
|
||||
-> decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
|
||||
{
|
||||
::nlohmann::to_json(j, std::forward<TargetType>(val));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace nlohmann
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
@ -1,53 +1,56 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint> // uint8_t
|
||||
#include <cstdint> // uint8_t, uint64_t
|
||||
#include <tuple> // tie
|
||||
#include <utility> // move
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
#include <nlohmann/detail/abi_macros.hpp>
|
||||
|
||||
/*!
|
||||
@brief an internal type for a backed binary type
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
|
||||
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.
|
||||
|
||||
@tparam BinaryType container to store bytes (`std::vector<std::uint8_t>` by
|
||||
default)
|
||||
|
||||
@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<typename BinaryType>
|
||||
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_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_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_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<subtype_type>(-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
|
||||
|
79
external/json/include/nlohmann/detail/abi_macros.hpp
vendored
Normal file
79
external/json/include/nlohmann/detail/abi_macros.hpp
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// 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 != 1
|
||||
#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 1 // 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
|
||||
|
||||
#define NLOHMANN_JSON_ABI_PREFIX_EX(major, minor, patch) \
|
||||
json_v ## major ## _ ## minor ## _ ## patch
|
||||
#define NLOHMANN_JSON_ABI_PREFIX(major, minor, patch) \
|
||||
NLOHMANN_JSON_ABI_PREFIX_EX(major, minor, patch)
|
||||
|
||||
#define NLOHMANN_JSON_ABI_CONCAT_EX(a, b, c) a ## b ## c
|
||||
#define NLOHMANN_JSON_ABI_CONCAT(a, b, c) \
|
||||
NLOHMANN_JSON_ABI_CONCAT_EX(a, b, c)
|
||||
|
||||
#define NLOHMANN_JSON_ABI_STRING \
|
||||
NLOHMANN_JSON_ABI_CONCAT( \
|
||||
NLOHMANN_JSON_ABI_PREFIX( \
|
||||
NLOHMANN_JSON_VERSION_MAJOR, \
|
||||
NLOHMANN_JSON_VERSION_MINOR, \
|
||||
NLOHMANN_JSON_VERSION_PATCH), \
|
||||
NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
|
||||
NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON)
|
||||
|
||||
#ifndef NLOHMANN_JSON_NAMESPACE
|
||||
#define NLOHMANN_JSON_NAMESPACE nlohmann::NLOHMANN_JSON_ABI_STRING
|
||||
#endif
|
||||
|
||||
#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
#define NLOHMANN_JSON_NAMESPACE_BEGIN \
|
||||
namespace nlohmann \
|
||||
{ \
|
||||
inline namespace NLOHMANN_JSON_ABI_STRING \
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifndef NLOHMANN_JSON_NAMESPACE_END
|
||||
#define NLOHMANN_JSON_NAMESPACE_END \
|
||||
} /* namespace (abi_string) */ \
|
||||
} /* namespace nlohmann */
|
||||
#endif
|
@ -1,3 +1,11 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm> // transform
|
||||
@ -15,19 +23,22 @@
|
||||
#include <nlohmann/detail/exceptions.hpp>
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
#include <nlohmann/detail/meta/cpp_future.hpp>
|
||||
#include <nlohmann/detail/meta/identity_tag.hpp>
|
||||
#include <nlohmann/detail/meta/std_fs.hpp>
|
||||
#include <nlohmann/detail/meta/type_traits.hpp>
|
||||
#include <nlohmann/detail/string_concat.hpp>
|
||||
#include <nlohmann/detail/value_t.hpp>
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<typename BasicJsonType>
|
||||
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())));
|
||||
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())));
|
||||
JSON_THROW(type_error::create(302, concat("type must be number, but is ", j.type_name()), &j));
|
||||
}
|
||||
}
|
||||
|
||||
template<typename BasicJsonType>
|
||||
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())));
|
||||
JSON_THROW(type_error::create(302, concat("type must be boolean, but is ", j.type_name()), &j));
|
||||
}
|
||||
b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
|
||||
}
|
||||
|
||||
template<typename BasicJsonType>
|
||||
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())));
|
||||
JSON_THROW(type_error::create(302, concat("type must be string, but is ", j.type_name()), &j));
|
||||
}
|
||||
s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
|
||||
}
|
||||
|
||||
template <
|
||||
typename BasicJsonType, typename ConstructibleStringType,
|
||||
typename BasicJsonType, typename StringType,
|
||||
enable_if_t <
|
||||
is_constructible_string_type<BasicJsonType, ConstructibleStringType>::value&&
|
||||
!std::is_same<typename BasicJsonType::string_t,
|
||||
ConstructibleStringType>::value,
|
||||
int > = 0 >
|
||||
void from_json(const BasicJsonType& j, ConstructibleStringType& s)
|
||||
std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
|
||||
&& is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value
|
||||
&& !std::is_same<typename BasicJsonType::string_t, StringType>::value
|
||||
&& !is_json_ref<StringType>::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())));
|
||||
JSON_THROW(type_error::create(302, concat("type must be string, but is ", j.type_name()), &j));
|
||||
}
|
||||
|
||||
s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
|
||||
}
|
||||
|
||||
template<typename BasicJsonType>
|
||||
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<typename BasicJsonType>
|
||||
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<typename BasicJsonType>
|
||||
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<typename BasicJsonType, typename EnumType,
|
||||
enable_if_t<std::is_enum<EnumType>::value, int> = 0>
|
||||
void from_json(const BasicJsonType& j, EnumType& e)
|
||||
inline void from_json(const BasicJsonType& j, EnumType& e)
|
||||
{
|
||||
typename std::underlying_type<EnumType>::type val;
|
||||
get_arithmetic_value(j, val);
|
||||
e = static_cast<EnumType>(val);
|
||||
}
|
||||
#endif // JSON_DISABLE_ENUM_SERIALIZATION
|
||||
|
||||
// forward_list doesn't have an insert method
|
||||
template<typename BasicJsonType, typename T, typename Allocator,
|
||||
enable_if_t<is_getable<BasicJsonType, T>::value, int> = 0>
|
||||
void from_json(const BasicJsonType& j, std::forward_list<T, Allocator>& l)
|
||||
inline void from_json(const BasicJsonType& j, std::forward_list<T, Allocator>& 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())));
|
||||
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<T, Allocator>& l)
|
||||
// valarray doesn't have an insert method
|
||||
template<typename BasicJsonType, typename T,
|
||||
enable_if_t<is_getable<BasicJsonType, T>::value, int> = 0>
|
||||
void from_json(const BasicJsonType& j, std::valarray<T>& l)
|
||||
inline void from_json(const BasicJsonType& j, std::valarray<T>& 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())));
|
||||
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<T>& l)
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename T, std::size_t N>
|
||||
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<T>(), void())
|
||||
{
|
||||
for (std::size_t i = 0; i < N; ++i)
|
||||
@ -171,7 +191,7 @@ auto from_json(const BasicJsonType& j, T (&arr)[N])
|
||||
}
|
||||
|
||||
template<typename BasicJsonType>
|
||||
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<const typename BasicJsonType::array_t*>();
|
||||
}
|
||||
@ -187,7 +207,10 @@ auto from_json_array_impl(const BasicJsonType& j, std::array<T, N>& arr,
|
||||
}
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename ConstructibleArrayType>
|
||||
template<typename BasicJsonType, typename ConstructibleArrayType,
|
||||
enable_if_t<
|
||||
std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
|
||||
int> = 0>
|
||||
auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> /*unused*/)
|
||||
-> decltype(
|
||||
arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
|
||||
@ -208,9 +231,12 @@ auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, p
|
||||
arr = std::move(ret);
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename ConstructibleArrayType>
|
||||
void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr,
|
||||
priority_tag<0> /*unused*/)
|
||||
template<typename BasicJsonType, typename ConstructibleArrayType,
|
||||
enable_if_t<
|
||||
std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
|
||||
int> = 0>
|
||||
inline void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr,
|
||||
priority_tag<0> /*unused*/)
|
||||
{
|
||||
using std::end;
|
||||
|
||||
@ -241,19 +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())));
|
||||
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<T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType&& j,
|
||||
identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/)
|
||||
{
|
||||
return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
|
||||
}
|
||||
|
||||
template < typename BasicJsonType, typename T, std::size_t N >
|
||||
auto from_json(BasicJsonType&& j, identity_tag<std::array<T, N>> tag)
|
||||
-> decltype(from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N> {}))
|
||||
{
|
||||
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<BasicJsonType>(j), tag, make_index_sequence<N> {});
|
||||
}
|
||||
|
||||
template<typename BasicJsonType>
|
||||
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())));
|
||||
JSON_THROW(type_error::create(302, concat("type must be binary, but is ", j.type_name()), &j));
|
||||
}
|
||||
|
||||
bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
|
||||
@ -261,15 +305,15 @@ void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin)
|
||||
|
||||
template<typename BasicJsonType, typename ConstructibleObjectType,
|
||||
enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::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())));
|
||||
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 typename BasicJsonType::object_t*>();
|
||||
const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
|
||||
using value_type = typename ConstructibleObjectType::value_type;
|
||||
std::transform(
|
||||
inner_object->begin(), inner_object->end(),
|
||||
@ -293,7 +337,7 @@ template < typename BasicJsonType, typename ArithmeticType,
|
||||
!std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
|
||||
!std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
|
||||
int > = 0 >
|
||||
void from_json(const BasicJsonType& j, ArithmeticType& val)
|
||||
inline void from_json(const BasicJsonType& j, ArithmeticType& val)
|
||||
{
|
||||
switch (static_cast<value_t>(j))
|
||||
{
|
||||
@ -318,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())));
|
||||
JSON_THROW(type_error::create(302, concat("type must be number, but is ", j.type_name()), &j));
|
||||
}
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename A1, typename A2>
|
||||
void from_json(const BasicJsonType& j, std::pair<A1, A2>& p)
|
||||
template<typename BasicJsonType, typename... Args, std::size_t... Idx>
|
||||
std::tuple<Args...> from_json_tuple_impl_base(BasicJsonType&& j, index_sequence<Idx...> /*unused*/)
|
||||
{
|
||||
p = {j.at(0).template get<A1>(), j.at(1).template get<A2>()};
|
||||
return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).template get<Args>()...);
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename Tuple, std::size_t... Idx>
|
||||
void from_json_tuple_impl(const BasicJsonType& j, Tuple& t, index_sequence<Idx...> /*unused*/)
|
||||
template < typename BasicJsonType, class A1, class A2 >
|
||||
std::pair<A1, A2> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::pair<A1, A2>> /*unused*/, priority_tag<0> /*unused*/)
|
||||
{
|
||||
t = std::make_tuple(j.at(Idx).template get<typename std::tuple_element<Idx, Tuple>::type>()...);
|
||||
return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
|
||||
std::forward<BasicJsonType>(j).at(1).template get<A2>()};
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename A1, typename A2>
|
||||
inline void from_json_tuple_impl(BasicJsonType&& j, std::pair<A1, A2>& p, priority_tag<1> /*unused*/)
|
||||
{
|
||||
p = from_json_tuple_impl(std::forward<BasicJsonType>(j), identity_tag<std::pair<A1, A2>> {}, priority_tag<0> {});
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename... Args>
|
||||
void from_json(const BasicJsonType& j, std::tuple<Args...>& t)
|
||||
std::tuple<Args...> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::tuple<Args...>> /*unused*/, priority_tag<2> /*unused*/)
|
||||
{
|
||||
from_json_tuple_impl(j, t, index_sequence_for<Args...> {});
|
||||
return from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j), index_sequence_for<Args...> {});
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename... Args>
|
||||
inline void from_json_tuple_impl(BasicJsonType&& j, std::tuple<Args...>& t, priority_tag<3> /*unused*/)
|
||||
{
|
||||
t = from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j), index_sequence_for<Args...> {});
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename TupleRelated>
|
||||
auto from_json(BasicJsonType&& j, TupleRelated&& t)
|
||||
-> decltype(from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(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<BasicJsonType>(j), std::forward<TupleRelated>(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<Key, Value, Compare, Allocator>& m)
|
||||
inline void from_json(const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& 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())));
|
||||
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())));
|
||||
JSON_THROW(type_error::create(302, concat("type must be array, but is ", p.type_name()), &j));
|
||||
}
|
||||
m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
|
||||
}
|
||||
@ -364,40 +439,59 @@ void from_json(const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>&
|
||||
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<Key, Value, Hash, KeyEqual, Allocator>& m)
|
||||
inline void from_json(const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& 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())));
|
||||
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())));
|
||||
JSON_THROW(type_error::create(302, concat("type must be array, but is ", p.type_name()), &j));
|
||||
}
|
||||
m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
|
||||
}
|
||||
}
|
||||
|
||||
#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
|
||||
template<typename BasicJsonType>
|
||||
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<const typename BasicJsonType::string_t*>();
|
||||
}
|
||||
#endif
|
||||
|
||||
struct from_json_fn
|
||||
{
|
||||
template<typename BasicJsonType, typename T>
|
||||
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<T>(val))))
|
||||
-> decltype(from_json(j, std::forward<T>(val)))
|
||||
{
|
||||
return from_json(j, val);
|
||||
return from_json(j, std::forward<T>(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<detail::from_json_fn>::value;
|
||||
} // namespace
|
||||
} // namespace nlohmann
|
||||
#endif
|
||||
JSON_INLINE_VARIABLE constexpr const auto& from_json = // NOLINT(misc-definitions-in-headers)
|
||||
detail::static_const<detail::from_json_fn>::value;
|
||||
#ifndef JSON_HAS_CPP_17
|
||||
} // namespace
|
||||
#endif
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
@ -1,3 +1,12 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2009 Florian Loitsch <https://florian.loitsch.com/>
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array> // array
|
||||
@ -9,8 +18,7 @@
|
||||
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
@ -200,7 +208,7 @@ boundaries compute_boundaries(FloatType value)
|
||||
|
||||
using bits_type = typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
|
||||
|
||||
const std::uint64_t bits = reinterpret_bits<bits_type>(value);
|
||||
const auto bits = static_cast<std::uint64_t>(reinterpret_bits<bits_type>(value));
|
||||
const std::uint64_t E = bits >> (kPrecision - 1);
|
||||
const std::uint64_t F = bits & (kHiddenBit - 1);
|
||||
|
||||
@ -490,51 +498,49 @@ inline int find_largest_pow10(const std::uint32_t n, std::uint32_t& pow10)
|
||||
return 10;
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
else if (n >= 100000000)
|
||||
if (n >= 100000000)
|
||||
{
|
||||
pow10 = 100000000;
|
||||
return 9;
|
||||
}
|
||||
else if (n >= 10000000)
|
||||
if (n >= 10000000)
|
||||
{
|
||||
pow10 = 10000000;
|
||||
return 8;
|
||||
}
|
||||
else if (n >= 1000000)
|
||||
if (n >= 1000000)
|
||||
{
|
||||
pow10 = 1000000;
|
||||
return 7;
|
||||
}
|
||||
else if (n >= 100000)
|
||||
if (n >= 100000)
|
||||
{
|
||||
pow10 = 100000;
|
||||
return 6;
|
||||
}
|
||||
else if (n >= 10000)
|
||||
if (n >= 10000)
|
||||
{
|
||||
pow10 = 10000;
|
||||
return 5;
|
||||
}
|
||||
else if (n >= 1000)
|
||||
if (n >= 1000)
|
||||
{
|
||||
pow10 = 1000;
|
||||
return 4;
|
||||
}
|
||||
else if (n >= 100)
|
||||
if (n >= 100)
|
||||
{
|
||||
pow10 = 100;
|
||||
return 3;
|
||||
}
|
||||
else if (n >= 10)
|
||||
if (n >= 10)
|
||||
{
|
||||
pow10 = 10;
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
pow10 = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
pow10 = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t delta,
|
||||
@ -620,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)
|
||||
@ -893,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
|
||||
@ -1041,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).
|
||||
@ -1068,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';
|
||||
@ -1076,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<FloatType>::max_digits10);
|
||||
|
||||
@ -1101,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
|
||||
|
@ -1,3 +1,11 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm> // copy
|
||||
@ -10,18 +18,27 @@
|
||||
#include <vector> // vector
|
||||
|
||||
#include <nlohmann/detail/iterators/iteration_proxy.hpp>
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
#include <nlohmann/detail/meta/cpp_future.hpp>
|
||||
#include <nlohmann/detail/meta/std_fs.hpp>
|
||||
#include <nlohmann/detail/meta/type_traits.hpp>
|
||||
#include <nlohmann/detail/value_t.hpp>
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
//////////////////
|
||||
// constructors //
|
||||
//////////////////
|
||||
|
||||
/*
|
||||
* Note all external_constructor<>::construct functions need to call
|
||||
* j.m_value.destroy(j.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<value_t> struct external_constructor;
|
||||
|
||||
template<>
|
||||
@ -30,6 +47,7 @@ struct external_constructor<value_t::boolean>
|
||||
template<typename BasicJsonType>
|
||||
static void construct(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept
|
||||
{
|
||||
j.m_value.destroy(j.m_type);
|
||||
j.m_type = value_t::boolean;
|
||||
j.m_value = b;
|
||||
j.assert_invariant();
|
||||
@ -42,6 +60,7 @@ struct external_constructor<value_t::string>
|
||||
template<typename BasicJsonType>
|
||||
static void construct(BasicJsonType& j, const typename BasicJsonType::string_t& s)
|
||||
{
|
||||
j.m_value.destroy(j.m_type);
|
||||
j.m_type = value_t::string;
|
||||
j.m_value = s;
|
||||
j.assert_invariant();
|
||||
@ -50,6 +69,7 @@ struct external_constructor<value_t::string>
|
||||
template<typename BasicJsonType>
|
||||
static void construct(BasicJsonType& j, typename BasicJsonType::string_t&& s)
|
||||
{
|
||||
j.m_value.destroy(j.m_type);
|
||||
j.m_type = value_t::string;
|
||||
j.m_value = std::move(s);
|
||||
j.assert_invariant();
|
||||
@ -60,6 +80,7 @@ struct external_constructor<value_t::string>
|
||||
int > = 0 >
|
||||
static void construct(BasicJsonType& j, const CompatibleStringType& str)
|
||||
{
|
||||
j.m_value.destroy(j.m_type);
|
||||
j.m_type = value_t::string;
|
||||
j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
|
||||
j.assert_invariant();
|
||||
@ -72,18 +93,18 @@ struct external_constructor<value_t::binary>
|
||||
template<typename BasicJsonType>
|
||||
static void construct(BasicJsonType& j, const typename BasicJsonType::binary_t& b)
|
||||
{
|
||||
j.m_value.destroy(j.m_type);
|
||||
j.m_type = value_t::binary;
|
||||
typename BasicJsonType::binary_t value{b};
|
||||
j.m_value = value;
|
||||
j.m_value = typename BasicJsonType::binary_t(b);
|
||||
j.assert_invariant();
|
||||
}
|
||||
|
||||
template<typename BasicJsonType>
|
||||
static void construct(BasicJsonType& j, typename BasicJsonType::binary_t&& b)
|
||||
{
|
||||
j.m_value.destroy(j.m_type);
|
||||
j.m_type = value_t::binary;
|
||||
typename BasicJsonType::binary_t value{std::move(b)};
|
||||
j.m_value = value;
|
||||
j.m_value = typename BasicJsonType::binary_t(std::move(b));
|
||||
j.assert_invariant();
|
||||
}
|
||||
};
|
||||
@ -94,6 +115,7 @@ struct external_constructor<value_t::number_float>
|
||||
template<typename BasicJsonType>
|
||||
static void construct(BasicJsonType& j, typename BasicJsonType::number_float_t val) noexcept
|
||||
{
|
||||
j.m_value.destroy(j.m_type);
|
||||
j.m_type = value_t::number_float;
|
||||
j.m_value = val;
|
||||
j.assert_invariant();
|
||||
@ -106,6 +128,7 @@ struct external_constructor<value_t::number_unsigned>
|
||||
template<typename BasicJsonType>
|
||||
static void construct(BasicJsonType& j, typename BasicJsonType::number_unsigned_t val) noexcept
|
||||
{
|
||||
j.m_value.destroy(j.m_type);
|
||||
j.m_type = value_t::number_unsigned;
|
||||
j.m_value = val;
|
||||
j.assert_invariant();
|
||||
@ -118,6 +141,7 @@ struct external_constructor<value_t::number_integer>
|
||||
template<typename BasicJsonType>
|
||||
static void construct(BasicJsonType& j, typename BasicJsonType::number_integer_t val) noexcept
|
||||
{
|
||||
j.m_value.destroy(j.m_type);
|
||||
j.m_type = value_t::number_integer;
|
||||
j.m_value = val;
|
||||
j.assert_invariant();
|
||||
@ -130,16 +154,20 @@ struct external_constructor<value_t::array>
|
||||
template<typename BasicJsonType>
|
||||
static void construct(BasicJsonType& j, const typename BasicJsonType::array_t& arr)
|
||||
{
|
||||
j.m_value.destroy(j.m_type);
|
||||
j.m_type = value_t::array;
|
||||
j.m_value = arr;
|
||||
j.set_parents();
|
||||
j.assert_invariant();
|
||||
}
|
||||
|
||||
template<typename BasicJsonType>
|
||||
static void construct(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
|
||||
{
|
||||
j.m_value.destroy(j.m_type);
|
||||
j.m_type = value_t::array;
|
||||
j.m_value = std::move(arr);
|
||||
j.set_parents();
|
||||
j.assert_invariant();
|
||||
}
|
||||
|
||||
@ -150,20 +178,25 @@ struct external_constructor<value_t::array>
|
||||
{
|
||||
using std::begin;
|
||||
using std::end;
|
||||
|
||||
j.m_value.destroy(j.m_type);
|
||||
j.m_type = value_t::array;
|
||||
j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
|
||||
j.set_parents();
|
||||
j.assert_invariant();
|
||||
}
|
||||
|
||||
template<typename BasicJsonType>
|
||||
static void construct(BasicJsonType& j, const std::vector<bool>& arr)
|
||||
{
|
||||
j.m_value.destroy(j.m_type);
|
||||
j.m_type = value_t::array;
|
||||
j.m_value = value_t::array;
|
||||
j.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.assert_invariant();
|
||||
}
|
||||
@ -172,6 +205,7 @@ struct external_constructor<value_t::array>
|
||||
enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0>
|
||||
static void construct(BasicJsonType& j, const std::valarray<T>& arr)
|
||||
{
|
||||
j.m_value.destroy(j.m_type);
|
||||
j.m_type = value_t::array;
|
||||
j.m_value = value_t::array;
|
||||
j.m_value.array->resize(arr.size());
|
||||
@ -179,6 +213,7 @@ struct external_constructor<value_t::array>
|
||||
{
|
||||
std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
|
||||
}
|
||||
j.set_parents();
|
||||
j.assert_invariant();
|
||||
}
|
||||
};
|
||||
@ -189,16 +224,20 @@ struct external_constructor<value_t::object>
|
||||
template<typename BasicJsonType>
|
||||
static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj)
|
||||
{
|
||||
j.m_value.destroy(j.m_type);
|
||||
j.m_type = value_t::object;
|
||||
j.m_value = obj;
|
||||
j.set_parents();
|
||||
j.assert_invariant();
|
||||
}
|
||||
|
||||
template<typename BasicJsonType>
|
||||
static void construct(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
|
||||
{
|
||||
j.m_value.destroy(j.m_type);
|
||||
j.m_type = value_t::object;
|
||||
j.m_value = std::move(obj);
|
||||
j.set_parents();
|
||||
j.assert_invariant();
|
||||
}
|
||||
|
||||
@ -209,8 +248,10 @@ struct external_constructor<value_t::object>
|
||||
using std::begin;
|
||||
using std::end;
|
||||
|
||||
j.m_value.destroy(j.m_type);
|
||||
j.m_type = value_t::object;
|
||||
j.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
|
||||
j.set_parents();
|
||||
j.assert_invariant();
|
||||
}
|
||||
};
|
||||
@ -221,55 +262,64 @@ struct external_constructor<value_t::object>
|
||||
|
||||
template<typename BasicJsonType, typename T,
|
||||
enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value, int> = 0>
|
||||
void to_json(BasicJsonType& j, T b) noexcept
|
||||
inline void to_json(BasicJsonType& j, T b) noexcept
|
||||
{
|
||||
external_constructor<value_t::boolean>::construct(j, b);
|
||||
}
|
||||
|
||||
template<typename BasicJsonType,
|
||||
enable_if_t<std::is_convertible<const std::vector<bool>::reference&, typename BasicJsonType::boolean_t>::value, int> = 0>
|
||||
inline void to_json(BasicJsonType& j, const std::vector<bool>::reference& b) noexcept
|
||||
{
|
||||
external_constructor<value_t::boolean>::construct(j, static_cast<typename BasicJsonType::boolean_t>(b));
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename CompatibleString,
|
||||
enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value, int> = 0>
|
||||
void to_json(BasicJsonType& j, const CompatibleString& s)
|
||||
inline void to_json(BasicJsonType& j, const CompatibleString& s)
|
||||
{
|
||||
external_constructor<value_t::string>::construct(j, s);
|
||||
}
|
||||
|
||||
template<typename BasicJsonType>
|
||||
void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s)
|
||||
inline void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s)
|
||||
{
|
||||
external_constructor<value_t::string>::construct(j, std::move(s));
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename FloatType,
|
||||
enable_if_t<std::is_floating_point<FloatType>::value, int> = 0>
|
||||
void to_json(BasicJsonType& j, FloatType val) noexcept
|
||||
inline void to_json(BasicJsonType& j, FloatType val) noexcept
|
||||
{
|
||||
external_constructor<value_t::number_float>::construct(j, static_cast<typename BasicJsonType::number_float_t>(val));
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename CompatibleNumberUnsignedType,
|
||||
enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value, int> = 0>
|
||||
void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept
|
||||
inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept
|
||||
{
|
||||
external_constructor<value_t::number_unsigned>::construct(j, static_cast<typename BasicJsonType::number_unsigned_t>(val));
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename CompatibleNumberIntegerType,
|
||||
enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value, int> = 0>
|
||||
void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept
|
||||
inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept
|
||||
{
|
||||
external_constructor<value_t::number_integer>::construct(j, static_cast<typename BasicJsonType::number_integer_t>(val));
|
||||
}
|
||||
|
||||
#if !JSON_DISABLE_ENUM_SERIALIZATION
|
||||
template<typename BasicJsonType, typename EnumType,
|
||||
enable_if_t<std::is_enum<EnumType>::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<EnumType>::type;
|
||||
external_constructor<value_t::number_integer>::construct(j, static_cast<underlying_type>(e));
|
||||
}
|
||||
#endif // JSON_DISABLE_ENUM_SERIALIZATION
|
||||
|
||||
template<typename BasicJsonType>
|
||||
void to_json(BasicJsonType& j, const std::vector<bool>& e)
|
||||
inline void to_json(BasicJsonType& j, const std::vector<bool>& e)
|
||||
{
|
||||
external_constructor<value_t::array>::construct(j, e);
|
||||
}
|
||||
@ -282,39 +332,39 @@ template < typename BasicJsonType, typename CompatibleArrayType,
|
||||
!std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
|
||||
!is_basic_json<CompatibleArrayType>::value,
|
||||
int > = 0 >
|
||||
void to_json(BasicJsonType& j, const CompatibleArrayType& arr)
|
||||
inline void to_json(BasicJsonType& j, const CompatibleArrayType& arr)
|
||||
{
|
||||
external_constructor<value_t::array>::construct(j, arr);
|
||||
}
|
||||
|
||||
template<typename BasicJsonType>
|
||||
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<value_t::binary>::construct(j, bin);
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename T,
|
||||
enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0>
|
||||
void to_json(BasicJsonType& j, const std::valarray<T>& arr)
|
||||
inline void to_json(BasicJsonType& j, const std::valarray<T>& arr)
|
||||
{
|
||||
external_constructor<value_t::array>::construct(j, std::move(arr));
|
||||
}
|
||||
|
||||
template<typename BasicJsonType>
|
||||
void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
|
||||
inline void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
|
||||
{
|
||||
external_constructor<value_t::array>::construct(j, std::move(arr));
|
||||
}
|
||||
|
||||
template < typename BasicJsonType, typename CompatibleObjectType,
|
||||
enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value, int > = 0 >
|
||||
void to_json(BasicJsonType& j, const CompatibleObjectType& obj)
|
||||
inline void to_json(BasicJsonType& j, const CompatibleObjectType& obj)
|
||||
{
|
||||
external_constructor<value_t::object>::construct(j, obj);
|
||||
}
|
||||
|
||||
template<typename BasicJsonType>
|
||||
void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
|
||||
inline void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
|
||||
{
|
||||
external_constructor<value_t::object>::construct(j, std::move(obj));
|
||||
}
|
||||
@ -322,15 +372,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<typename BasicJsonType::string_t,
|
||||
const T(&)[N]>::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<value_t::array>::construct(j, arr);
|
||||
}
|
||||
|
||||
template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value, int > = 0 >
|
||||
void to_json(BasicJsonType& j, const std::pair<T1, T2>& p)
|
||||
inline void to_json(BasicJsonType& j, const std::pair<T1, T2>& p)
|
||||
{
|
||||
j = { p.first, p.second };
|
||||
}
|
||||
@ -338,23 +388,31 @@ void to_json(BasicJsonType& j, const std::pair<T1, T2>& p)
|
||||
// for https://github.com/nlohmann/json/pull/1134
|
||||
template<typename BasicJsonType, typename T,
|
||||
enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::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<typename BasicJsonType, typename Tuple, std::size_t... Idx>
|
||||
void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence<Idx...> /*unused*/)
|
||||
inline void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence<Idx...> /*unused*/)
|
||||
{
|
||||
j = { std::get<Idx>(t)... };
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::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<std::tuple_size<T>::value> {});
|
||||
}
|
||||
|
||||
#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
|
||||
template<typename BasicJsonType>
|
||||
inline void to_json(BasicJsonType& j, const std_fs::path& p)
|
||||
{
|
||||
j = p.string();
|
||||
}
|
||||
#endif
|
||||
|
||||
struct to_json_fn
|
||||
{
|
||||
template<typename BasicJsonType, typename T>
|
||||
@ -366,9 +424,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<detail::to_json_fn>::value;
|
||||
} // namespace
|
||||
} // namespace nlohmann
|
||||
#endif
|
||||
JSON_INLINE_VARIABLE constexpr const auto& to_json = // NOLINT(misc-definitions-in-headers)
|
||||
detail::static_const<detail::to_json_fn>::value;
|
||||
#ifndef JSON_HAS_CPP_17
|
||||
} // namespace
|
||||
#endif
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
370
external/json/include/nlohmann/detail/exceptions.hpp
vendored
370
external/json/include/nlohmann/detail/exceptions.hpp
vendored
@ -1,68 +1,127 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef> // nullptr_t
|
||||
#include <exception> // exception
|
||||
#include <stdexcept> // runtime_error
|
||||
#include <string> // to_string
|
||||
#include <vector> // vector
|
||||
|
||||
#include <nlohmann/detail/value_t.hpp>
|
||||
#include <nlohmann/detail/string_escape.hpp>
|
||||
#include <nlohmann/detail/input/position_t.hpp>
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
#include <nlohmann/detail/meta/cpp_future.hpp>
|
||||
#include <nlohmann/detail/meta/type_traits.hpp>
|
||||
#include <nlohmann/detail/string_concat.hpp>
|
||||
|
||||
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<typename BasicJsonType>
|
||||
static std::string diagnostics(const BasicJsonType* leaf_element)
|
||||
{
|
||||
#if JSON_DIAGNOSTICS
|
||||
std::vector<std::string> tokens;
|
||||
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)
|
||||
{
|
||||
if (¤t->m_parent->m_value.array->operator[](i) == current)
|
||||
{
|
||||
tokens.emplace_back(std::to_string(i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case value_t::object:
|
||||
{
|
||||
for (const auto& element : *current->m_parent->m_value.object)
|
||||
{
|
||||
if (&element.second == current)
|
||||
{
|
||||
tokens.emplace_back(element.first.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
if (tokens.empty())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
|
||||
[](const std::string & a, const std::string & b)
|
||||
{
|
||||
return concat(a, '/', detail::escape(b));
|
||||
});
|
||||
return concat('(', str, ") ");
|
||||
#else
|
||||
static_cast<void>(leaf_element);
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
@ -70,51 +129,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:
|
||||
@ -127,19 +143,21 @@ class parse_error : public exception
|
||||
@param[in] what_arg the explanatory string
|
||||
@return parse_error object
|
||||
*/
|
||||
static parse_error create(int id_, const position_t& pos, const std::string& what_arg)
|
||||
template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::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) + ": " + what_arg;
|
||||
return parse_error(id_, pos.chars_read_total, w.c_str());
|
||||
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()};
|
||||
}
|
||||
|
||||
static parse_error create(int id_, std::size_t byte_, const std::string& what_arg)
|
||||
template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::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_)) : "") +
|
||||
": " + what_arg;
|
||||
return parse_error(id_, byte_, w.c_str());
|
||||
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()};
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -159,55 +177,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:
|
||||
static invalid_iterator create(int id_, const std::string& what_arg)
|
||||
template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0>
|
||||
static invalid_iterator create(int id_, const std::string& what_arg, BasicJsonContext context)
|
||||
{
|
||||
std::string w = exception::name("invalid_iterator", id_) + what_arg;
|
||||
return invalid_iterator(id_, w.c_str());
|
||||
std::string w = concat(exception::name("invalid_iterator", id_), exception::diagnostics(context), what_arg);
|
||||
return {id_, w.c_str()};
|
||||
}
|
||||
|
||||
private:
|
||||
@ -216,52 +200,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:
|
||||
static type_error create(int id_, const std::string& what_arg)
|
||||
template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0>
|
||||
static type_error create(int id_, const std::string& what_arg, BasicJsonContext context)
|
||||
{
|
||||
std::string w = exception::name("type_error", id_) + what_arg;
|
||||
return type_error(id_, w.c_str());
|
||||
std::string w = concat(exception::name("type_error", id_), exception::diagnostics(context), what_arg);
|
||||
return {id_, w.c_str()};
|
||||
}
|
||||
|
||||
private:
|
||||
@ -269,46 +217,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:
|
||||
static out_of_range create(int id_, const std::string& what_arg)
|
||||
template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::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_) + what_arg;
|
||||
return out_of_range(id_, w.c_str());
|
||||
std::string w = concat(exception::name("out_of_range", id_), exception::diagnostics(context), what_arg);
|
||||
return {id_, w.c_str()};
|
||||
}
|
||||
|
||||
private:
|
||||
@ -316,42 +234,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:
|
||||
static other_error create(int id_, const std::string& what_arg)
|
||||
template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0>
|
||||
static other_error create(int id_, const std::string& what_arg, BasicJsonContext context)
|
||||
{
|
||||
std::string w = exception::name("other_error", id_) + what_arg;
|
||||
return other_error(id_, w.c_str());
|
||||
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
|
||||
|
32
external/json/include/nlohmann/detail/hash.hpp
vendored
32
external/json/include/nlohmann/detail/hash.hpp
vendored
@ -1,10 +1,21 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef> // size_t, uint8_t
|
||||
#include <cstdint> // uint8_t
|
||||
#include <cstddef> // size_t
|
||||
#include <functional> // hash
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
#include <nlohmann/detail/abi_macros.hpp>
|
||||
#include <nlohmann/detail/value_t.hpp>
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
@ -83,24 +94,24 @@ std::size_t hash(const BasicJsonType& j)
|
||||
return combine(type, h);
|
||||
}
|
||||
|
||||
case nlohmann::detail::value_t::number_unsigned:
|
||||
case BasicJsonType::value_t::number_unsigned:
|
||||
{
|
||||
const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
|
||||
return combine(type, h);
|
||||
}
|
||||
|
||||
case nlohmann::detail::value_t::number_float:
|
||||
case BasicJsonType::value_t::number_float:
|
||||
{
|
||||
const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
|
||||
return combine(type, h);
|
||||
}
|
||||
|
||||
case nlohmann::detail::value_t::binary:
|
||||
case BasicJsonType::value_t::binary:
|
||||
{
|
||||
auto seed = combine(type, j.get_binary().size());
|
||||
const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
|
||||
seed = combine(seed, h);
|
||||
seed = combine(seed, j.get_binary().subtype());
|
||||
seed = combine(seed, static_cast<std::size_t>(j.get_binary().subtype()));
|
||||
for (const auto byte : j.get_binary())
|
||||
{
|
||||
seed = combine(seed, std::hash<std::uint8_t> {}(byte));
|
||||
@ -108,10 +119,11 @@ std::size_t hash(const BasicJsonType& j)
|
||||
return seed;
|
||||
}
|
||||
|
||||
default: // LCOV_EXCL_LINE
|
||||
JSON_ASSERT(false); // LCOV_EXCL_LINE
|
||||
default: // 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
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,16 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array> // array
|
||||
#include <cstddef> // size_t
|
||||
#include <cstdio> //FILE *
|
||||
#include <cstring> // strlen
|
||||
#include <istream> // istream
|
||||
#include <iterator> // begin, end, iterator_traits, random_access_iterator_tag, distance, next
|
||||
#include <memory> // shared_ptr, make_shared, addressof
|
||||
#include <numeric> // accumulate
|
||||
@ -12,20 +18,26 @@
|
||||
#include <type_traits> // enable_if, is_base_of, is_pointer, is_integral, remove_pointer
|
||||
#include <utility> // pair, declval
|
||||
|
||||
#ifndef JSON_NO_IO
|
||||
#include <cstdio> // FILE *
|
||||
#include <istream> // istream
|
||||
#endif // JSON_NO_IO
|
||||
|
||||
#include <nlohmann/detail/iterators/iterator_traits.hpp>
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
|
||||
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 +50,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<char>::int_type get_character() noexcept
|
||||
{
|
||||
@ -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<char>::to_int_type, to
|
||||
// ensure that std::char_traits<char>::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<char>::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<char>::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,7 +142,8 @@ class iterator_input_adapter
|
||||
using char_type = typename std::iterator_traits<IteratorType>::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<char_type>::int_type get_character()
|
||||
{
|
||||
@ -135,10 +153,8 @@ class iterator_input_adapter
|
||||
std::advance(current, 1);
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::char_traits<char_type>::eof();
|
||||
}
|
||||
|
||||
return std::char_traits<char_type>::eof();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -152,7 +168,6 @@ class iterator_input_adapter
|
||||
{
|
||||
return current == end;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -371,16 +386,39 @@ typename iterator_input_adapter_factory<IteratorType>::adapter_type input_adapte
|
||||
}
|
||||
|
||||
// Convenience shorthand from container to iterator
|
||||
template<typename ContainerType>
|
||||
auto input_adapter(const ContainerType& container) -> decltype(input_adapter(begin(container), end(container)))
|
||||
{
|
||||
// Enable ADL
|
||||
using std::begin;
|
||||
using std::end;
|
||||
// Enables ADL on begin(container) and end(container)
|
||||
// Encloses the using declarations in namespace for not to leak them to outside scope
|
||||
|
||||
namespace container_input_adapter_factory_impl
|
||||
{
|
||||
|
||||
using std::begin;
|
||||
using std::end;
|
||||
|
||||
template<typename ContainerType, typename Enable = void>
|
||||
struct container_input_adapter_factory {};
|
||||
|
||||
template<typename ContainerType>
|
||||
struct container_input_adapter_factory< ContainerType,
|
||||
void_t<decltype(begin(std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
|
||||
{
|
||||
using adapter_type = decltype(input_adapter(begin(std::declval<ContainerType>()), end(std::declval<ContainerType>())));
|
||||
|
||||
static adapter_type create(const ContainerType& container)
|
||||
{
|
||||
return input_adapter(begin(container), end(container));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace container_input_adapter_factory_impl
|
||||
|
||||
template<typename ContainerType>
|
||||
typename container_input_adapter_factory_impl::container_input_adapter_factory<ContainerType>::adapter_type input_adapter(const ContainerType& container)
|
||||
{
|
||||
return container_input_adapter_factory_impl::container_input_adapter_factory<ContainerType>::create(container);
|
||||
}
|
||||
|
||||
#ifndef JSON_NO_IO
|
||||
// Special cases with fast paths
|
||||
inline file_input_adapter input_adapter(std::FILE* file)
|
||||
{
|
||||
@ -396,6 +434,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<const char*>(), std::declval<const char*>()));
|
||||
|
||||
@ -415,13 +454,13 @@ contiguous_bytes_input_adapter input_adapter(CharT b)
|
||||
}
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
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
|
||||
{
|
||||
@ -444,11 +483,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
|
||||
|
@ -1,3 +1,11 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
@ -7,9 +15,9 @@
|
||||
|
||||
#include <nlohmann/detail/exceptions.hpp>
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
#include <nlohmann/detail/string_concat.hpp>
|
||||
|
||||
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,6 +134,11 @@ 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;
|
||||
};
|
||||
|
||||
@ -156,7 +169,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 +179,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,10 +230,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<std::size_t>(-1) && len > ref_stack.back()->max_size()))
|
||||
{
|
||||
JSON_THROW(out_of_range::create(408,
|
||||
"excessive object size: " + std::to_string(len)));
|
||||
JSON_THROW(out_of_range::create(408, concat("excessive object size: ", std::to_string(len)), ref_stack.back()));
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -228,6 +240,9 @@ 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));
|
||||
return true;
|
||||
@ -235,6 +250,10 @@ class json_sax_dom_parser
|
||||
|
||||
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,10 +262,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<std::size_t>(-1) && len > ref_stack.back()->max_size()))
|
||||
{
|
||||
JSON_THROW(out_of_range::create(408,
|
||||
"excessive array size: " + std::to_string(len)));
|
||||
JSON_THROW(out_of_range::create(408, concat("excessive array size: ", std::to_string(len)), ref_stack.back()));
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -254,6 +272,10 @@ 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;
|
||||
}
|
||||
@ -341,9 +363,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 +420,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<std::size_t>(-1) && len > ref_stack.back()->max_size()))
|
||||
{
|
||||
JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len)));
|
||||
JSON_THROW(out_of_range::create(408, concat("excessive object size: ", std::to_string(len)), ref_stack.back()));
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -425,10 +447,17 @@ class json_sax_dom_callback_parser
|
||||
|
||||
bool end_object()
|
||||
{
|
||||
if (ref_stack.back() && !callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
|
||||
if (ref_stack.back())
|
||||
{
|
||||
// discard object
|
||||
*ref_stack.back() = discarded;
|
||||
if (!callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
|
||||
{
|
||||
// discard object
|
||||
*ref_stack.back() = discarded;
|
||||
}
|
||||
else
|
||||
{
|
||||
ref_stack.back()->set_parents();
|
||||
}
|
||||
}
|
||||
|
||||
JSON_ASSERT(!ref_stack.empty());
|
||||
@ -461,9 +490,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<std::size_t>(-1) && len > ref_stack.back()->max_size()))
|
||||
{
|
||||
JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len)));
|
||||
JSON_THROW(out_of_range::create(408, concat("excessive array size: ", std::to_string(len)), ref_stack.back()));
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -476,7 +505,11 @@ class json_sax_dom_callback_parser
|
||||
if (ref_stack.back())
|
||||
{
|
||||
keep = callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
|
||||
if (!keep)
|
||||
if (keep)
|
||||
{
|
||||
ref_stack.back()->set_parents();
|
||||
}
|
||||
else
|
||||
{
|
||||
// discard array
|
||||
*ref_stack.back() = discarded;
|
||||
@ -574,7 +607,7 @@ class json_sax_dom_callback_parser
|
||||
// array
|
||||
if (ref_stack.back()->is_array())
|
||||
{
|
||||
ref_stack.back()->m_value.array->push_back(std::move(value));
|
||||
ref_stack.back()->m_value.array->emplace_back(std::move(value));
|
||||
return {true, &(ref_stack.back()->m_value.array->back())};
|
||||
}
|
||||
|
||||
@ -660,7 +693,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<std::size_t>(-1))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -675,7 +708,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<std::size_t>(-1))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -690,6 +723,6 @@ class json_sax_acceptor
|
||||
return false;
|
||||
}
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
} // namespace nlohmann
|
||||
} // namespace detail
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
@ -1,3 +1,11 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array> // array
|
||||
@ -14,10 +22,10 @@
|
||||
#include <nlohmann/detail/input/position_t.hpp>
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
///////////
|
||||
// lexer //
|
||||
///////////
|
||||
@ -112,7 +120,7 @@ class lexer : public lexer_base<BasicJsonType>
|
||||
public:
|
||||
using token_type = typename lexer_base<BasicJsonType>::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<char_int_type>(get_decimal_point()))
|
||||
@ -120,9 +128,9 @@ class lexer : public lexer_base<BasicJsonType>
|
||||
|
||||
// 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:
|
||||
@ -231,7 +239,7 @@ class lexer : public lexer_base<BasicJsonType>
|
||||
/*!
|
||||
@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
|
||||
@ -343,7 +351,7 @@ class lexer : public lexer_base<BasicJsonType>
|
||||
// low surrogate occupies the least significant 15 bits
|
||||
+ static_cast<unsigned int>(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);
|
||||
}
|
||||
@ -921,10 +929,10 @@ class lexer : public lexer_base<BasicJsonType>
|
||||
/*!
|
||||
@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 +1006,7 @@ class lexer : public lexer_base<BasicJsonType>
|
||||
|
||||
// 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 +1244,7 @@ scan_number_done:
|
||||
// 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
|
||||
@ -1447,7 +1455,7 @@ scan_number_done:
|
||||
{
|
||||
// escape control characters
|
||||
std::array<char, 9> cs{{}};
|
||||
(std::snprintf)(cs.data(), cs.size(), "<U+%.4X>", static_cast<unsigned char>(c));
|
||||
static_cast<void>((std::snprintf)(cs.data(), cs.size(), "<U+%.4X>", static_cast<unsigned char>(c))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
||||
result += cs.data();
|
||||
}
|
||||
else
|
||||
@ -1541,17 +1549,17 @@ scan_number_done:
|
||||
// literals
|
||||
case 't':
|
||||
{
|
||||
std::array<char_type, 4> true_literal = {{'t', 'r', 'u', 'e'}};
|
||||
std::array<char_type, 4> true_literal = {{static_cast<char_type>('t'), static_cast<char_type>('r'), static_cast<char_type>('u'), static_cast<char_type>('e')}};
|
||||
return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
|
||||
}
|
||||
case 'f':
|
||||
{
|
||||
std::array<char_type, 5> false_literal = {{'f', 'a', 'l', 's', 'e'}};
|
||||
std::array<char_type, 5> false_literal = {{static_cast<char_type>('f'), static_cast<char_type>('a'), static_cast<char_type>('l'), static_cast<char_type>('s'), static_cast<char_type>('e')}};
|
||||
return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
|
||||
}
|
||||
case 'n':
|
||||
{
|
||||
std::array<char_type, 4> null_literal = {{'n', 'u', 'l', 'l'}};
|
||||
std::array<char_type, 4> null_literal = {{static_cast<char_type>('n'), static_cast<char_type>('u'), static_cast<char_type>('l'), static_cast<char_type>('l')}};
|
||||
return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
|
||||
}
|
||||
|
||||
@ -1619,5 +1627,6 @@ scan_number_done:
|
||||
/// the decimal point
|
||||
const char_int_type decimal_point_char = '.';
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace nlohmann
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
@ -1,3 +1,11 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cmath> // isfinite
|
||||
@ -13,17 +21,17 @@
|
||||
#include <nlohmann/detail/input/lexer.hpp>
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
#include <nlohmann/detail/meta/is_sax.hpp>
|
||||
#include <nlohmann/detail/string_concat.hpp>
|
||||
#include <nlohmann/detail/value_t.hpp>
|
||||
|
||||
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<typename BasicJsonType>
|
||||
using parser_callback_t =
|
||||
std::function<bool(int depth, parse_event_t event, BasicJsonType& parsed)>;
|
||||
std::function<bool(int /*depth*/, parse_event_t /*event*/, BasicJsonType& /*parsed*/)>;
|
||||
|
||||
/*!
|
||||
@brief syntax analysis
|
||||
@ -88,7 +96,6 @@ class parser
|
||||
{
|
||||
json_sax_dom_callback_parser<BasicJsonType> sdp(result, callback, allow_exceptions);
|
||||
sax_parse_internal(&sdp);
|
||||
result.assert_invariant();
|
||||
|
||||
// in strict mode, input must be completely read
|
||||
if (strict && (get_token() != token_type::end_of_input))
|
||||
@ -96,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")));
|
||||
exception_message(token_type::end_of_input, "value"), nullptr));
|
||||
}
|
||||
|
||||
// in case of an error, return discarded value
|
||||
@ -117,15 +124,13 @@ class parser
|
||||
{
|
||||
json_sax_dom_parser<BasicJsonType> sdp(result, allow_exceptions);
|
||||
sax_parse_internal(&sdp);
|
||||
result.assert_invariant();
|
||||
|
||||
// in strict mode, input must be completely read
|
||||
if (strict && (get_token() != token_type::end_of_input))
|
||||
{
|
||||
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")));
|
||||
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
|
||||
@ -135,6 +140,8 @@ class parser
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
result.assert_invariant();
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -161,8 +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")));
|
||||
parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), nullptr));
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -188,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<std::size_t>(-1))))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -208,8 +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")));
|
||||
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())))
|
||||
{
|
||||
@ -221,8 +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")));
|
||||
parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), nullptr));
|
||||
}
|
||||
|
||||
// remember we are now inside an object
|
||||
@ -235,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<std::size_t>(-1))))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -265,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() + "'"));
|
||||
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())))
|
||||
@ -335,16 +339,21 @@ 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")));
|
||||
parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "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::end_of_input:
|
||||
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")));
|
||||
parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -390,65 +399,61 @@ 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")));
|
||||
parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array, "array"), nullptr));
|
||||
}
|
||||
else // object
|
||||
|
||||
// states.back() is false -> object
|
||||
|
||||
// comma -> next value
|
||||
if (get_token() == token_type::value_separator)
|
||||
{
|
||||
// comma -> next value
|
||||
if (get_token() == token_type::value_separator)
|
||||
// parse key
|
||||
if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::value_string))
|
||||
{
|
||||
// parse key
|
||||
if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::value_string))
|
||||
{
|
||||
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")));
|
||||
}
|
||||
|
||||
if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string())))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// parse separator (:)
|
||||
if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator))
|
||||
{
|
||||
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")));
|
||||
}
|
||||
|
||||
// parse values
|
||||
get_token();
|
||||
continue;
|
||||
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"), nullptr));
|
||||
}
|
||||
|
||||
// closing }
|
||||
if (JSON_HEDLEY_LIKELY(last_token == token_type::end_object))
|
||||
if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string())))
|
||||
{
|
||||
if (JSON_HEDLEY_UNLIKELY(!sax->end_object()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// We are done with this object. Before we can parse a
|
||||
// new value, we need to evaluate the new state first.
|
||||
// By setting skip_to_state_evaluation to false, we
|
||||
// are effectively jumping to the beginning of this if.
|
||||
JSON_ASSERT(!states.empty());
|
||||
states.pop_back();
|
||||
skip_to_state_evaluation = true;
|
||||
continue;
|
||||
return false;
|
||||
}
|
||||
|
||||
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")));
|
||||
// parse separator (:)
|
||||
if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator))
|
||||
{
|
||||
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"), nullptr));
|
||||
}
|
||||
|
||||
// parse values
|
||||
get_token();
|
||||
continue;
|
||||
}
|
||||
|
||||
// closing }
|
||||
if (JSON_HEDLEY_LIKELY(last_token == token_type::end_object))
|
||||
{
|
||||
if (JSON_HEDLEY_UNLIKELY(!sax->end_object()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// We are done with this object. Before we can parse a
|
||||
// new value, we need to evaluate the new state first.
|
||||
// By setting skip_to_state_evaluation to false, we
|
||||
// are effectively jumping to the beginning of this if.
|
||||
JSON_ASSERT(!states.empty());
|
||||
states.pop_back();
|
||||
skip_to_state_evaluation = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
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"), nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -464,24 +469,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;
|
||||
@ -497,5 +502,6 @@ class parser
|
||||
/// whether to throw exceptions in case of errors
|
||||
const bool allow_exceptions = true;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace nlohmann
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
@ -1,11 +1,21 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef> // size_t
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
#include <nlohmann/detail/abi_macros.hpp>
|
||||
|
||||
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
|
||||
|
@ -1,11 +1,20 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/detail/abi_macros.hpp>
|
||||
#include <nlohmann/detail/iterators/primitive_iterator.hpp>
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
/*!
|
||||
@brief an iterator value
|
||||
|
||||
@ -21,5 +30,6 @@ template<typename BasicJsonType> struct internal_iterator
|
||||
/// generic iterator for all other types
|
||||
primitive_iterator_t primitive_iterator {};
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace nlohmann
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
@ -1,3 +1,11 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <iterator> // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next
|
||||
@ -11,10 +19,10 @@
|
||||
#include <nlohmann/detail/meta/type_traits.hpp>
|
||||
#include <nlohmann/detail/value_t.hpp>
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// forward declare, to be able to friend it later on
|
||||
template<typename IteratorType> class iteration_proxy;
|
||||
template<typename IteratorType> class iteration_proxy_value;
|
||||
@ -36,10 +44,12 @@ 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<typename BasicJsonType>
|
||||
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<typename std::conditional<std::is_const<BasicJsonType>::value, typename std::remove_const<BasicJsonType>::type, const BasicJsonType>::type>;
|
||||
/// allow basic_json to access private members
|
||||
friend iter_impl<typename std::conditional<std::is_const<BasicJsonType>::value, typename std::remove_const<BasicJsonType>::type, const BasicJsonType>::type>;
|
||||
friend other_iter_impl;
|
||||
friend BasicJsonType;
|
||||
friend iteration_proxy<iter_impl>;
|
||||
friend iteration_proxy_value<iter_impl>;
|
||||
@ -49,9 +59,12 @@ class iter_impl
|
||||
// make sure BasicJsonType is basic_json or const basic_json
|
||||
static_assert(is_basic_json<typename std::remove_const<BasicJsonType>::type>::value,
|
||||
"iter_impl only accepts (const) basic_json");
|
||||
// superficial check for the LegacyBidirectionalIterator named requirement
|
||||
static_assert(std::is_base_of<std::bidirectional_iterator_tag, std::bidirectional_iterator_tag>::value
|
||||
&& std::is_base_of<std::bidirectional_iterator_tag, typename std::iterator_traits<typename array_t::iterator>::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
|
||||
@ -73,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
|
||||
@ -100,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();
|
||||
@ -136,8 +159,11 @@ class iter_impl
|
||||
*/
|
||||
iter_impl& operator=(const iter_impl<const BasicJsonType>& 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;
|
||||
}
|
||||
|
||||
@ -156,14 +182,14 @@ class iter_impl
|
||||
@return const/non-const iterator
|
||||
@note It is not checked whether @a other is initialized.
|
||||
*/
|
||||
iter_impl& operator=(const iter_impl<typename std::remove_const<BasicJsonType>::type>& other) noexcept
|
||||
iter_impl& operator=(const iter_impl<typename std::remove_const<BasicJsonType>::type>& other) noexcept // NOLINT(cert-oop54-cpp)
|
||||
{
|
||||
m_object = other.m_object;
|
||||
m_it = other.m_it;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
JSON_PRIVATE_UNLESS_TESTED:
|
||||
/*!
|
||||
@brief set the iterator to the first value
|
||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
||||
@ -193,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();
|
||||
@ -223,6 +256,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.set_end();
|
||||
@ -255,8 +296,15 @@ class iter_impl
|
||||
}
|
||||
|
||||
case value_t::null:
|
||||
JSON_THROW(invalid_iterator::create(214, "cannot get value"));
|
||||
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()))
|
||||
@ -264,7 +312,7 @@ class iter_impl
|
||||
return *m_object;
|
||||
}
|
||||
|
||||
JSON_THROW(invalid_iterator::create(214, "cannot get value"));
|
||||
JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -291,6 +339,14 @@ class iter_impl
|
||||
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()))
|
||||
@ -298,7 +354,7 @@ class iter_impl
|
||||
return m_object;
|
||||
}
|
||||
|
||||
JSON_THROW(invalid_iterator::create(214, "cannot get value"));
|
||||
JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -307,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);
|
||||
@ -336,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;
|
||||
@ -350,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);
|
||||
@ -379,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;
|
||||
@ -390,15 +462,16 @@ class iter_impl
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief comparison: equal
|
||||
@brief comparison: equal
|
||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
||||
*/
|
||||
bool operator==(const iter_impl& other) const
|
||||
template < typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::nullptr_t > = nullptr >
|
||||
bool operator==(const IterImpl& other) const
|
||||
{
|
||||
// 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"));
|
||||
JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", m_object));
|
||||
}
|
||||
|
||||
JSON_ASSERT(m_object != nullptr);
|
||||
@ -411,22 +484,31 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief comparison: not equal
|
||||
@brief comparison: not equal
|
||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
||||
*/
|
||||
bool operator!=(const iter_impl& other) const
|
||||
template < typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::nullptr_t > = nullptr >
|
||||
bool operator!=(const IterImpl& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief comparison: smaller
|
||||
@brief comparison: smaller
|
||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
||||
*/
|
||||
bool operator<(const iter_impl& other) const
|
||||
@ -434,7 +516,7 @@ 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"));
|
||||
JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", m_object));
|
||||
}
|
||||
|
||||
JSON_ASSERT(m_object != nullptr);
|
||||
@ -442,18 +524,26 @@ class iter_impl
|
||||
switch (m_object->m_type)
|
||||
{
|
||||
case value_t::object:
|
||||
JSON_THROW(invalid_iterator::create(213, "cannot compare order of object iterators"));
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief comparison: less than or equal
|
||||
@brief comparison: less than or equal
|
||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
||||
*/
|
||||
bool operator<=(const iter_impl& other) const
|
||||
@ -462,7 +552,7 @@ class iter_impl
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief comparison: greater than
|
||||
@brief comparison: greater than
|
||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
||||
*/
|
||||
bool operator>(const iter_impl& other) const
|
||||
@ -471,7 +561,7 @@ class iter_impl
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief comparison: greater than or equal
|
||||
@brief comparison: greater than or equal
|
||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
||||
*/
|
||||
bool operator>=(const iter_impl& other) const
|
||||
@ -480,7 +570,7 @@ class iter_impl
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief add to iterator
|
||||
@brief add to iterator
|
||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
||||
*/
|
||||
iter_impl& operator+=(difference_type i)
|
||||
@ -490,7 +580,7 @@ class iter_impl
|
||||
switch (m_object->m_type)
|
||||
{
|
||||
case value_t::object:
|
||||
JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators"));
|
||||
JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", m_object));
|
||||
|
||||
case value_t::array:
|
||||
{
|
||||
@ -498,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;
|
||||
@ -509,7 +607,7 @@ class iter_impl
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief subtract from iterator
|
||||
@brief subtract from iterator
|
||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
||||
*/
|
||||
iter_impl& operator-=(difference_type i)
|
||||
@ -518,7 +616,7 @@ class iter_impl
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief add to iterator
|
||||
@brief add to iterator
|
||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
||||
*/
|
||||
iter_impl operator+(difference_type i) const
|
||||
@ -529,7 +627,7 @@ class iter_impl
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief addition of distance and iterator
|
||||
@brief addition of distance and iterator
|
||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
||||
*/
|
||||
friend iter_impl operator+(difference_type i, const iter_impl& it)
|
||||
@ -540,7 +638,7 @@ class iter_impl
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief subtract from iterator
|
||||
@brief subtract from iterator
|
||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
||||
*/
|
||||
iter_impl operator-(difference_type i) const
|
||||
@ -551,7 +649,7 @@ class iter_impl
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief return difference
|
||||
@brief return difference
|
||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
||||
*/
|
||||
difference_type operator-(const iter_impl& other) const
|
||||
@ -561,18 +659,26 @@ class iter_impl
|
||||
switch (m_object->m_type)
|
||||
{
|
||||
case value_t::object:
|
||||
JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators"));
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief access to successor
|
||||
@brief access to successor
|
||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
||||
*/
|
||||
reference operator[](difference_type n) const
|
||||
@ -582,14 +688,21 @@ class iter_impl
|
||||
switch (m_object->m_type)
|
||||
{
|
||||
case value_t::object:
|
||||
JSON_THROW(invalid_iterator::create(208, "cannot use operator[] for object iterators"));
|
||||
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"));
|
||||
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))
|
||||
@ -597,13 +710,13 @@ class iter_impl
|
||||
return *m_object;
|
||||
}
|
||||
|
||||
JSON_THROW(invalid_iterator::create(214, "cannot get value"));
|
||||
JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief return the key of an object iterator
|
||||
@brief return the key of an object iterator
|
||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
||||
*/
|
||||
const typename object_t::key_type& key() const
|
||||
@ -615,11 +728,11 @@ class iter_impl
|
||||
return m_it.object_iterator->first;
|
||||
}
|
||||
|
||||
JSON_THROW(invalid_iterator::create(207, "cannot use key() for non-object iterators"));
|
||||
JSON_THROW(invalid_iterator::create(207, "cannot use key() for non-object iterators", m_object));
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief return the value of an iterator
|
||||
@brief return the value of an iterator
|
||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
||||
*/
|
||||
reference value() const
|
||||
@ -627,11 +740,12 @@ class iter_impl
|
||||
return operator*();
|
||||
}
|
||||
|
||||
private:
|
||||
JSON_PRIVATE_UNLESS_TESTED:
|
||||
/// associated JSON instance
|
||||
pointer m_object = nullptr;
|
||||
/// the actual iterator of the associated instance
|
||||
internal_iterator<typename std::remove_const<BasicJsonType>::type> m_it {};
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace nlohmann
|
||||
|
||||
} // namespace detail
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
@ -1,17 +1,31 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef> // size_t
|
||||
#include <iterator> // input_iterator_tag
|
||||
#include <string> // string, to_string
|
||||
#include <tuple> // tuple_size, get, tuple_element
|
||||
#include <utility> // move
|
||||
|
||||
#if JSON_HAS_RANGES
|
||||
#include <ranges> // enable_borrowed_range
|
||||
#endif
|
||||
|
||||
#include <nlohmann/detail/abi_macros.hpp>
|
||||
#include <nlohmann/detail/meta/type_traits.hpp>
|
||||
#include <nlohmann/detail/value_t.hpp>
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<typename string_type>
|
||||
void int_to_string( string_type& target, std::size_t value )
|
||||
{
|
||||
@ -24,14 +38,14 @@ template<typename IteratorType> 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<decltype( std::declval<IteratorType>().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<typename IteratorType> 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<IteratorType>::value
|
||||
&& std::is_nothrow_default_constructible<string_type>::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<IteratorType>::value
|
||||
&& std::is_nothrow_move_constructible<string_type>::value) = default;
|
||||
iteration_proxy_value& operator=(iteration_proxy_value&&)
|
||||
noexcept(std::is_nothrow_move_assignable<IteratorType>::value
|
||||
&& std::is_nothrow_move_assignable<string_type>::value) = default;
|
||||
~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<typename IteratorType> 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<typename IteratorType> 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<typename IteratorType> 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<IteratorType> begin() noexcept
|
||||
iteration_proxy_value<IteratorType> begin() const noexcept
|
||||
{
|
||||
return iteration_proxy_value<IteratorType>(container.begin());
|
||||
return iteration_proxy_value<IteratorType>(container->begin());
|
||||
}
|
||||
|
||||
/// return iterator end (needed for range-based for)
|
||||
iteration_proxy_value<IteratorType> end() noexcept
|
||||
iteration_proxy_value<IteratorType> end() const noexcept
|
||||
{
|
||||
return iteration_proxy_value<IteratorType>(container.end());
|
||||
return iteration_proxy_value<IteratorType>(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<IteratorType>& 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,6 +212,7 @@ auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& 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
|
||||
@ -175,4 +233,10 @@ class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
} // namespace std
|
||||
|
||||
} // namespace std
|
||||
|
||||
#if JSON_HAS_RANGES
|
||||
template <typename IteratorType>
|
||||
inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy<IteratorType>> = true;
|
||||
#endif
|
||||
|
@ -1,14 +1,23 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <iterator> // random_access_iterator_tag
|
||||
|
||||
#include <nlohmann/detail/abi_macros.hpp>
|
||||
#include <nlohmann/detail/meta/void_t.hpp>
|
||||
#include <nlohmann/detail/meta/cpp_future.hpp>
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<typename It, typename = void>
|
||||
struct iterator_types {};
|
||||
|
||||
@ -47,5 +56,6 @@ struct iterator_traits<T*, enable_if_t<std::is_object<T>::value>>
|
||||
using pointer = T*;
|
||||
using reference = T&;
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace nlohmann
|
||||
|
||||
} // namespace detail
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
@ -1,13 +1,23 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef> // ptrdiff_t
|
||||
#include <iterator> // reverse_iterator
|
||||
#include <utility> // declval
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
#include <nlohmann/detail/abi_macros.hpp>
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
//////////////////////
|
||||
// reverse_iterator //
|
||||
//////////////////////
|
||||
@ -48,7 +58,7 @@ class json_reverse_iterator : public std::reverse_iterator<Base>
|
||||
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<json_reverse_iterator>(base_iterator::operator++(1));
|
||||
}
|
||||
@ -60,7 +70,7 @@ class json_reverse_iterator : public std::reverse_iterator<Base>
|
||||
}
|
||||
|
||||
/// post-decrement (it--)
|
||||
json_reverse_iterator const operator--(int)
|
||||
json_reverse_iterator operator--(int)& // NOLINT(cert-dcl21-cpp)
|
||||
{
|
||||
return static_cast<json_reverse_iterator>(base_iterator::operator--(1));
|
||||
}
|
||||
@ -115,5 +125,6 @@ class json_reverse_iterator : public std::reverse_iterator<Base>
|
||||
return it.operator * ();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace nlohmann
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
@ -1,12 +1,22 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef> // ptrdiff_t
|
||||
#include <limits> // numeric_limits
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
/*
|
||||
@brief an iterator for primitive JSON types
|
||||
|
||||
@ -23,6 +33,7 @@ class primitive_iterator_t
|
||||
static constexpr difference_type begin_value = 0;
|
||||
static constexpr difference_type end_value = begin_value + 1;
|
||||
|
||||
JSON_PRIVATE_UNLESS_TESTED:
|
||||
/// iterator as signed integer type
|
||||
difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
|
||||
|
||||
@ -84,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;
|
||||
@ -97,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;
|
||||
@ -116,5 +127,6 @@ class primitive_iterator_t
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace nlohmann
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
@ -1,7 +1,20 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm> // all_of
|
||||
#include <cctype> // isdigit
|
||||
#include <cerrno> // errno, ERANGE
|
||||
#include <cstdlib> // strtoull
|
||||
#ifndef JSON_NO_IO
|
||||
#include <iosfwd> // ostream
|
||||
#endif // JSON_NO_IO
|
||||
#include <limits> // max
|
||||
#include <numeric> // accumulate
|
||||
#include <string> // string
|
||||
@ -10,89 +23,78 @@
|
||||
|
||||
#include <nlohmann/detail/exceptions.hpp>
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
#include <nlohmann/detail/string_concat.hpp>
|
||||
#include <nlohmann/detail/string_escape.hpp>
|
||||
#include <nlohmann/detail/value_t.hpp>
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
template<typename BasicJsonType>
|
||||
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<typename RefStringType>
|
||||
class json_pointer
|
||||
{
|
||||
// allow basic_json to access private members
|
||||
NLOHMANN_BASIC_JSON_TPL_DECLARATION
|
||||
friend class basic_json;
|
||||
|
||||
template<typename>
|
||||
friend class json_pointer;
|
||||
|
||||
template<typename T>
|
||||
struct string_t_helper
|
||||
{
|
||||
using type = T;
|
||||
};
|
||||
|
||||
NLOHMANN_BASIC_JSON_TPL_DECLARATION
|
||||
struct string_t_helper<NLOHMANN_BASIC_JSON_TPL>
|
||||
{
|
||||
using type = StringType;
|
||||
};
|
||||
|
||||
public:
|
||||
/*!
|
||||
@brief create JSON pointer
|
||||
// for backwards compatibility accept BasicJsonType
|
||||
using string_t = typename string_t_helper<RefStringType>::type;
|
||||
|
||||
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
|
||||
|
||||
@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
|
||||
|
||||
@liveexample{The example shows the construction several valid JSON pointers
|
||||
as well as the exceptional behavior.,json_pointer}
|
||||
|
||||
@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 + "/" + 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
|
||||
#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
|
||||
|
||||
@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
|
||||
|
||||
@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(),
|
||||
@ -101,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())
|
||||
@ -230,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"));
|
||||
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"));
|
||||
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();
|
||||
@ -330,56 +210,50 @@ 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<typename BasicJsonType>
|
||||
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'"));
|
||||
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"));
|
||||
JSON_THROW(detail::parse_error::create(109, 0, detail::concat("array index '", s, "' is not a number"), nullptr));
|
||||
}
|
||||
|
||||
std::size_t processed_chars = 0;
|
||||
unsigned long long res = 0;
|
||||
JSON_TRY
|
||||
const char* p = s.c_str();
|
||||
char* p_end = nullptr;
|
||||
errno = 0; // strtoull doesn't reset errno
|
||||
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<std::size_t>(p_end - p) != s.size())) // incomplete read
|
||||
{
|
||||
res = std::stoull(s, &processed_chars);
|
||||
}
|
||||
JSON_CATCH(std::out_of_range&)
|
||||
{
|
||||
JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'"));
|
||||
}
|
||||
|
||||
// check if the string was completely read
|
||||
if (JSON_HEDLEY_UNLIKELY(processed_chars != s.size()))
|
||||
{
|
||||
JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'"));
|
||||
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<unsigned long long>((std::numeric_limits<size_type>::max)()))
|
||||
if (res >= static_cast<unsigned long long>((std::numeric_limits<size_type>::max)())) // NOLINT(runtime/int)
|
||||
{
|
||||
JSON_THROW(detail::out_of_range::create(410, "array index " + s + " exceeds size_type")); // 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<size_type>(res);
|
||||
}
|
||||
|
||||
JSON_PRIVATE_UNLESS_TESTED:
|
||||
json_pointer top() const
|
||||
{
|
||||
if (JSON_HEDLEY_UNLIKELY(empty()))
|
||||
{
|
||||
JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent"));
|
||||
JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", nullptr));
|
||||
}
|
||||
|
||||
json_pointer result = *this;
|
||||
@ -387,6 +261,7 @@ class json_pointer
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
/*!
|
||||
@brief create and return a reference to the pointed to value
|
||||
|
||||
@ -395,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<typename BasicJsonType>
|
||||
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
|
||||
@ -430,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<BasicJsonType>(reference_token));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -440,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"));
|
||||
JSON_THROW(detail::type_error::create(313, "invalid value to unflatten", &j));
|
||||
}
|
||||
}
|
||||
|
||||
@ -467,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<typename BasicJsonType>
|
||||
BasicJsonType& get_unchecked(BasicJsonType* ptr) const
|
||||
{
|
||||
for (const auto& reference_token : reference_tokens)
|
||||
@ -507,13 +391,21 @@ class json_pointer
|
||||
else
|
||||
{
|
||||
// convert array index to number; unchecked access
|
||||
ptr = &ptr->operator[](array_index(reference_token));
|
||||
ptr = &ptr->operator[](array_index<BasicJsonType>(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 + "'"));
|
||||
JSON_THROW(detail::out_of_range::create(404, detail::concat("unresolved reference token '", reference_token, "'"), ptr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -526,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<typename BasicJsonType>
|
||||
BasicJsonType& get_checked(BasicJsonType* ptr) const
|
||||
{
|
||||
for (const auto& reference_token : reference_tokens)
|
||||
@ -544,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"));
|
||||
JSON_THROW(detail::out_of_range::create(402, detail::concat(
|
||||
"array index '-' (", std::to_string(ptr->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<BasicJsonType>(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 + "'"));
|
||||
JSON_THROW(detail::out_of_range::create(404, detail::concat("unresolved reference token '", reference_token, "'"), ptr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -575,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<typename BasicJsonType>
|
||||
const BasicJsonType& get_unchecked(const BasicJsonType* ptr) const
|
||||
{
|
||||
for (const auto& reference_token : reference_tokens)
|
||||
@ -593,18 +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"));
|
||||
JSON_THROW(detail::out_of_range::create(402, detail::concat("array index '-' (", std::to_string(ptr->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<BasicJsonType>(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 + "'"));
|
||||
JSON_THROW(detail::out_of_range::create(404, detail::concat("unresolved reference token '", reference_token, "'"), ptr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -617,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<typename BasicJsonType>
|
||||
const BasicJsonType& get_checked(const BasicJsonType* ptr) const
|
||||
{
|
||||
for (const auto& reference_token : reference_tokens)
|
||||
@ -635,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"));
|
||||
JSON_THROW(detail::out_of_range::create(402, detail::concat(
|
||||
"array index '-' (", std::to_string(ptr->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<BasicJsonType>(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 + "'"));
|
||||
JSON_THROW(detail::out_of_range::create(404, detail::concat("unresolved reference token '", reference_token, "'"), ptr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -657,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<typename BasicJsonType>
|
||||
bool contains(const BasicJsonType* ptr) const
|
||||
{
|
||||
for (const auto& reference_token : reference_tokens)
|
||||
@ -704,7 +622,7 @@ class json_pointer
|
||||
}
|
||||
}
|
||||
|
||||
const auto idx = array_index(reference_token);
|
||||
const auto idx = array_index<BasicJsonType>(reference_token);
|
||||
if (idx >= ptr->size())
|
||||
{
|
||||
// index out of range
|
||||
@ -715,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
|
||||
@ -737,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<std::string> split(const std::string& reference_string)
|
||||
static std::vector<string_t> split(const string_t& reference_string)
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
std::vector<string_t> result;
|
||||
|
||||
// special case: empty reference string -> no reference tokens
|
||||
if (reference_string.empty())
|
||||
@ -750,9 +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 + "'"));
|
||||
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:
|
||||
@ -763,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))
|
||||
{
|
||||
@ -777,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] == '~');
|
||||
@ -787,57 +711,19 @@ 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'"));
|
||||
JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'", nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
// finally, store the reference token
|
||||
unescape(reference_token);
|
||||
detail::unescape(reference_token);
|
||||
result.push_back(reference_token);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief replace all occurrences of a substring by another string
|
||||
|
||||
@param[in,out] s the string to manipulate; changed so that all
|
||||
occurrences of @a f are replaced with @a t
|
||||
@param[in] f the substring to replace with @a t
|
||||
@param[in] t the string to replace @a f
|
||||
|
||||
@pre The search string @a f must not be empty. **This precondition is
|
||||
enforced with an assertion.**
|
||||
|
||||
@since version 2.0.0
|
||||
*/
|
||||
static void replace_substring(std::string& s, const std::string& f,
|
||||
const std::string& t)
|
||||
{
|
||||
JSON_ASSERT(!f.empty());
|
||||
for (auto pos = s.find(f); // find first occurrence of f
|
||||
pos != std::string::npos; // make sure f was found
|
||||
s.replace(pos, f.size(), t), // replace with t, and
|
||||
pos = s.find(f, pos + t.size())) // find next occurrence of f
|
||||
{}
|
||||
}
|
||||
|
||||
/// escape "~" to "~0" and "/" to "~1"
|
||||
static std::string escape(std::string s)
|
||||
{
|
||||
replace_substring(s, "~", "~0");
|
||||
replace_substring(s, "/", "~1");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// unescape "~1" to tilde and "~0" to slash (order is important!)
|
||||
static void unescape(std::string& s)
|
||||
{
|
||||
replace_substring(s, "~1", "/");
|
||||
replace_substring(s, "~0", "~");
|
||||
}
|
||||
|
||||
private:
|
||||
/*!
|
||||
@param[in] reference_string the reference string to the current value
|
||||
@param[in] value the value to consider
|
||||
@ -845,7 +731,8 @@ class json_pointer
|
||||
|
||||
@note Empty objects or arrays are flattened to `null`.
|
||||
*/
|
||||
static void flatten(const std::string& reference_string,
|
||||
template<typename BasicJsonType>
|
||||
static void flatten(const string_t& reference_string,
|
||||
const BasicJsonType& value,
|
||||
BasicJsonType& result)
|
||||
{
|
||||
@ -863,7 +750,7 @@ class json_pointer
|
||||
// iterate array and use index as reference string
|
||||
for (std::size_t i = 0; i < value.m_value.array->size(); ++i)
|
||||
{
|
||||
flatten(reference_string + "/" + std::to_string(i),
|
||||
flatten(detail::concat(reference_string, '/', std::to_string(i)),
|
||||
value.m_value.array->operator[](i), result);
|
||||
}
|
||||
}
|
||||
@ -882,12 +769,20 @@ class json_pointer
|
||||
// iterate object and use keys as reference string
|
||||
for (const auto& element : *value.m_value.object)
|
||||
{
|
||||
flatten(reference_string + "/" + 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
|
||||
@ -907,12 +802,13 @@ class json_pointer
|
||||
@throw type_error.315 if object values are not primitive
|
||||
@throw type_error.313 if value cannot be unflattened
|
||||
*/
|
||||
template<typename BasicJsonType>
|
||||
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"));
|
||||
JSON_THROW(detail::type_error::create(314, "only objects can be unflattened", &value));
|
||||
}
|
||||
|
||||
BasicJsonType result;
|
||||
@ -922,7 +818,7 @@ class json_pointer
|
||||
{
|
||||
if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive()))
|
||||
{
|
||||
JSON_THROW(detail::type_error::create(315, "values in object must be primitive"));
|
||||
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
|
||||
@ -935,6 +831,21 @@ class json_pointer
|
||||
return result;
|
||||
}
|
||||
|
||||
// can't use conversion operator because of ambiguity
|
||||
json_pointer<string_t> convert() const&
|
||||
{
|
||||
json_pointer<string_t> result;
|
||||
result.reference_tokens = reference_tokens;
|
||||
return result;
|
||||
}
|
||||
|
||||
json_pointer<string_t> convert()&&
|
||||
{
|
||||
json_pointer<string_t> result;
|
||||
result.reference_tokens = std::move(reference_tokens);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief compares two JSON pointers for equality
|
||||
|
||||
@ -946,11 +857,10 @@ class json_pointer
|
||||
|
||||
@exceptionsafety No-throw guarantee: this function never throws exceptions.
|
||||
*/
|
||||
friend bool operator==(json_pointer const& lhs,
|
||||
json_pointer const& rhs) noexcept
|
||||
{
|
||||
return lhs.reference_tokens == rhs.reference_tokens;
|
||||
}
|
||||
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
|
||||
// NOLINTNEXTLINE(readability-redundant-declaration)
|
||||
friend bool operator==(json_pointer<RefStringTypeLhs> const& lhs,
|
||||
json_pointer<RefStringTypeRhs> const& rhs) noexcept;
|
||||
|
||||
/*!
|
||||
@brief compares two JSON pointers for inequality
|
||||
@ -963,13 +873,28 @@ class json_pointer
|
||||
|
||||
@exceptionsafety No-throw guarantee: this function never throws exceptions.
|
||||
*/
|
||||
friend bool operator!=(json_pointer const& lhs,
|
||||
json_pointer const& rhs) noexcept
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
|
||||
// NOLINTNEXTLINE(readability-redundant-declaration)
|
||||
friend bool operator!=(json_pointer<RefStringTypeLhs> const& lhs,
|
||||
json_pointer<RefStringTypeRhs> const& rhs) noexcept;
|
||||
|
||||
/// the reference tokens
|
||||
std::vector<std::string> reference_tokens;
|
||||
std::vector<string_t> reference_tokens;
|
||||
};
|
||||
} // namespace nlohmann
|
||||
|
||||
// functions cannot be defined inside class due to ODR violations
|
||||
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
|
||||
inline bool operator==(json_pointer<RefStringTypeLhs> const& lhs,
|
||||
json_pointer<RefStringTypeRhs> const& rhs) noexcept
|
||||
{
|
||||
return lhs.reference_tokens == rhs.reference_tokens;
|
||||
}
|
||||
|
||||
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
|
||||
inline bool operator!=(json_pointer<RefStringTypeLhs> const& lhs,
|
||||
json_pointer<RefStringTypeRhs> const& rhs) noexcept
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
@ -1,14 +1,23 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <initializer_list>
|
||||
#include <utility>
|
||||
|
||||
#include <nlohmann/detail/abi_macros.hpp>
|
||||
#include <nlohmann/detail/meta/type_traits.hpp>
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<typename BasicJsonType>
|
||||
class json_ref
|
||||
{
|
||||
@ -17,19 +26,14 @@ class json_ref
|
||||
|
||||
json_ref(value_type&& value)
|
||||
: owned_value(std::move(value))
|
||||
, value_ref(&owned_value)
|
||||
, is_rvalue(true)
|
||||
{}
|
||||
|
||||
json_ref(const value_type& value)
|
||||
: value_ref(const_cast<value_type*>(&value))
|
||||
, is_rvalue(false)
|
||||
: value_ref(&value)
|
||||
{}
|
||||
|
||||
json_ref(std::initializer_list<json_ref> init)
|
||||
: owned_value(init)
|
||||
, value_ref(&owned_value)
|
||||
, is_rvalue(true)
|
||||
{}
|
||||
|
||||
template <
|
||||
@ -37,12 +41,10 @@ class json_ref
|
||||
enable_if_t<std::is_constructible<value_type, Args...>::value, int> = 0 >
|
||||
json_ref(Args && ... args)
|
||||
: owned_value(std::forward<Args>(args)...)
|
||||
, value_ref(&owned_value)
|
||||
, is_rvalue(true)
|
||||
{}
|
||||
|
||||
// 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;
|
||||
@ -50,27 +52,27 @@ class json_ref
|
||||
|
||||
value_type moved_or_copied() const
|
||||
{
|
||||
if (is_rvalue)
|
||||
if (value_ref == nullptr)
|
||||
{
|
||||
return std::move(*value_ref);
|
||||
return std::move(owned_value);
|
||||
}
|
||||
return *value_ref;
|
||||
}
|
||||
|
||||
value_type const& operator*() const
|
||||
{
|
||||
return *static_cast<value_type const*>(value_ref);
|
||||
return value_ref ? *value_ref : owned_value;
|
||||
}
|
||||
|
||||
value_type const* operator->() const
|
||||
{
|
||||
return static_cast<value_type const*>(value_ref);
|
||||
return &** this;
|
||||
}
|
||||
|
||||
private:
|
||||
mutable value_type owned_value = nullptr;
|
||||
value_type* value_ref = nullptr;
|
||||
const bool is_rvalue = true;
|
||||
value_type const* value_ref = nullptr;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace nlohmann
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
@ -1,11 +1,22 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utility> // pair
|
||||
#include <utility> // declval, pair
|
||||
#include <nlohmann/detail/meta/detected.hpp>
|
||||
#include <nlohmann/thirdparty/hedley/hedley.hpp>
|
||||
|
||||
// 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 <nlohmann/detail/abi_macros.hpp>
|
||||
|
||||
// exclude unsupported compilers
|
||||
#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
|
||||
#if defined(__clang__)
|
||||
@ -20,30 +31,128 @@
|
||||
#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
|
||||
|
||||
// disable float-equal warnings on GCC/clang
|
||||
#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
#ifdef __has_include
|
||||
#if __has_include(<version>)
|
||||
#include <version>
|
||||
#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(<filesystem>)
|
||||
#define JSON_HAS_FILESYSTEM 1
|
||||
#elif __has_include(<experimental/filesystem>)
|
||||
#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
|
||||
|
||||
#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
|
||||
|
||||
#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,12 +186,19 @@
|
||||
#define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
|
||||
#endif
|
||||
|
||||
// allow to override assert
|
||||
// allow overriding assert
|
||||
#if !defined(JSON_ASSERT)
|
||||
#include <cassert> // assert
|
||||
#define JSON_ASSERT(x) assert(x)
|
||||
#endif
|
||||
|
||||
// allow to access some private functions (needed by the test suite)
|
||||
#if defined(JSON_TESTS_PRIVATE)
|
||||
#define JSON_PRIVATE_UNLESS_TESTED public
|
||||
#else
|
||||
#define JSON_PRIVATE_UNLESS_TESTED private
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@brief macro to briefly define a mapping between an enum and JSON
|
||||
@def NLOHMANN_JSON_SERIALIZE_ENUM
|
||||
@ -266,6 +382,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
|
||||
@ -276,6 +393,10 @@
|
||||
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) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
|
||||
|
||||
/*!
|
||||
@brief macro
|
||||
@def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE
|
||||
@ -285,6 +406,49 @@
|
||||
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_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) { 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<typename... T> \
|
||||
using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
|
||||
} \
|
||||
\
|
||||
namespace detail2 { \
|
||||
struct std_name##_tag \
|
||||
{ \
|
||||
}; \
|
||||
\
|
||||
template<typename... T> \
|
||||
std_name##_tag std_name(T&&...); \
|
||||
\
|
||||
template<typename... T> \
|
||||
using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
|
||||
\
|
||||
template<typename... T> \
|
||||
struct would_call_std_##std_name \
|
||||
{ \
|
||||
static constexpr auto const value = ::nlohmann::detail:: \
|
||||
is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
|
||||
}; \
|
||||
} /* namespace detail2 */ \
|
||||
\
|
||||
template<typename... T> \
|
||||
struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
|
||||
{ \
|
||||
}
|
||||
|
||||
#ifndef JSON_USE_IMPLICIT_CONVERSIONS
|
||||
#define JSON_USE_IMPLICIT_CONVERSIONS 1
|
||||
#endif
|
||||
@ -294,3 +458,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
|
||||
|
@ -1,23 +1,44 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// 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_HAS_CPP_14
|
||||
#undef JSON_HAS_CPP_17
|
||||
#undef JSON_PRIVATE_UNLESS_TESTED
|
||||
#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_USE_LEGACY_DISCARDED_VALUE_COMPARISON
|
||||
#endif
|
||||
|
||||
#include <nlohmann/thirdparty/hedley/hedley_undef.hpp>
|
||||
|
17
external/json/include/nlohmann/detail/meta/call_std/begin.hpp
vendored
Normal file
17
external/json/include/nlohmann/detail/meta/call_std/begin.hpp
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
|
||||
NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin);
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
17
external/json/include/nlohmann/detail/meta/call_std/end.hpp
vendored
Normal file
17
external/json/include/nlohmann/detail/meta/call_std/end.hpp
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
|
||||
NLOHMANN_CAN_CALL_STD_FUNC_IMPL(end);
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
@ -1,50 +1,149 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-FileCopyrightText: 2018 The Abseil Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef> // size_t
|
||||
#include <type_traits> // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type
|
||||
#include <utility> // index_sequence, make_index_sequence, index_sequence_for
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
// alias templates to reduce boilerplate
|
||||
template<bool B, typename T = void>
|
||||
using enable_if_t = typename std::enable_if<B, T>::type;
|
||||
|
||||
template<typename T>
|
||||
using uncvref_t = typename std::remove_cv<typename std::remove_reference<T>::type>::type;
|
||||
|
||||
// implementation of C++14 index_sequence and affiliates
|
||||
// source: https://stackoverflow.com/a/32223343
|
||||
template<std::size_t... Ints>
|
||||
struct index_sequence
|
||||
#ifdef JSON_HAS_CPP_14
|
||||
|
||||
// the following utilities are natively available in C++14
|
||||
using std::enable_if_t;
|
||||
using std::index_sequence;
|
||||
using std::make_index_sequence;
|
||||
using std::index_sequence_for;
|
||||
|
||||
#else
|
||||
|
||||
// alias templates to reduce boilerplate
|
||||
template<bool B, typename T = void>
|
||||
using enable_if_t = typename std::enable_if<B, T>::type;
|
||||
|
||||
// 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<T, Ints...>` 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<T, Ints...>);
|
||||
//
|
||||
// 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<int, 5>());
|
||||
// }
|
||||
template <typename T, T... Ints>
|
||||
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<class Sequence1, class Sequence2>
|
||||
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 <size_t... Ints>
|
||||
using index_sequence = integer_sequence<size_t, Ints...>;
|
||||
|
||||
template<std::size_t... I1, std::size_t... I2>
|
||||
struct merge_and_renumber<index_sequence<I1...>, index_sequence<I2...>>
|
||||
: index_sequence < I1..., (sizeof...(I1) + I2)... > {};
|
||||
namespace utility_internal
|
||||
{
|
||||
|
||||
template<std::size_t N>
|
||||
struct make_index_sequence
|
||||
: merge_and_renumber < typename make_index_sequence < N / 2 >::type,
|
||||
typename make_index_sequence < N - N / 2 >::type > {};
|
||||
template <typename Seq, size_t SeqSize, size_t Rem>
|
||||
struct Extend;
|
||||
|
||||
template<> struct make_index_sequence<0> : index_sequence<> {};
|
||||
template<> struct make_index_sequence<1> : index_sequence<0> {};
|
||||
// Note that SeqSize == sizeof...(Ints). It's passed explicitly for efficiency.
|
||||
template <typename T, T... Ints, size_t SeqSize>
|
||||
struct Extend<integer_sequence<T, Ints...>, SeqSize, 0>
|
||||
{
|
||||
using type = integer_sequence < T, Ints..., (Ints + SeqSize)... >;
|
||||
};
|
||||
|
||||
template<typename... Ts>
|
||||
template <typename T, T... Ints, size_t SeqSize>
|
||||
struct Extend<integer_sequence<T, Ints...>, SeqSize, 1>
|
||||
{
|
||||
using type = integer_sequence < T, Ints..., (Ints + SeqSize)..., 2 * SeqSize >;
|
||||
};
|
||||
|
||||
// Recursion helper for 'make_integer_sequence<T, N>'.
|
||||
// 'Gen<T, N>::type' is an alias for 'integer_sequence<T, 0, 1, ... N-1>'.
|
||||
template <typename T, size_t N>
|
||||
struct Gen
|
||||
{
|
||||
using type =
|
||||
typename Extend < typename Gen < T, N / 2 >::type, N / 2, N % 2 >::type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct Gen<T, 0>
|
||||
{
|
||||
using type = integer_sequence<T>;
|
||||
};
|
||||
|
||||
} // namespace utility_internal
|
||||
|
||||
// Compile-time sequences of integers
|
||||
|
||||
// make_integer_sequence
|
||||
//
|
||||
// This template alias is equivalent to
|
||||
// `integer_sequence<int, 0, 1, ..., N-1>`, and is designed to be a drop-in
|
||||
// replacement for C++14's `std::make_integer_sequence`.
|
||||
template <typename T, T N>
|
||||
using make_integer_sequence = typename utility_internal::Gen<T, N>::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 <size_t N>
|
||||
using make_index_sequence = make_integer_sequence<size_t, N>;
|
||||
|
||||
// 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 <typename... Ts>
|
||||
using index_sequence_for = make_index_sequence<sizeof...(Ts)>;
|
||||
|
||||
//// END OF CODE FROM GOOGLE ABSEIL
|
||||
|
||||
#endif
|
||||
|
||||
// dispatch utility (taken from ranges-v3)
|
||||
template<unsigned N> struct priority_tag : priority_tag < N - 1 > {};
|
||||
template<> struct priority_tag<0> {};
|
||||
@ -56,7 +155,12 @@ struct static_const
|
||||
static constexpr T value{};
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
constexpr T static_const<T>::value;
|
||||
#ifndef JSON_HAS_CPP_17
|
||||
|
||||
template<typename T>
|
||||
constexpr T static_const<T>::value; // NOLINT(readability-redundant-declaration)
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
} // namespace nlohmann
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
@ -1,14 +1,22 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include <nlohmann/detail/meta/void_t.hpp>
|
||||
|
||||
// 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<Default, void_t<Op<Args...>>, Op, Args...>
|
||||
template<template<class...> class Op, class... Args>
|
||||
using is_detected = typename detector<nonesuch, void, Op, Args...>::value_t;
|
||||
|
||||
template<template<class...> class Op, class... Args>
|
||||
struct is_detected_lazy : is_detected<Op, Args...> { };
|
||||
|
||||
template<template<class...> class Op, class... Args>
|
||||
using detected_t = typename detector<nonesuch, void, Op, Args...>::type;
|
||||
|
||||
@ -54,5 +65,6 @@ using is_detected_exact = std::is_same<Expected, detected_t<Op, Args...>>;
|
||||
template<class To, template<class...> class Op, class... Args>
|
||||
using is_detected_convertible =
|
||||
std::is_convertible<detected_t<Op, Args...>, To>;
|
||||
|
||||
} // namespace detail
|
||||
} // namespace nlohmann
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
21
external/json/include/nlohmann/detail/meta/identity_tag.hpp
vendored
Normal file
21
external/json/include/nlohmann/detail/meta/identity_tag.hpp
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/detail/abi_macros.hpp>
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// dispatching helper struct
|
||||
template <class T> struct identity_tag {};
|
||||
|
||||
} // namespace detail
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
@ -1,16 +1,25 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint> // size_t
|
||||
#include <utility> // declval
|
||||
#include <string> // string
|
||||
|
||||
#include <nlohmann/detail/abi_macros.hpp>
|
||||
#include <nlohmann/detail/meta/detected.hpp>
|
||||
#include <nlohmann/detail/meta/type_traits.hpp>
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
using null_function_t = decltype(std::declval<T&>().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
|
||||
|
29
external/json/include/nlohmann/detail/meta/std_fs.hpp
vendored
Normal file
29
external/json/include/nlohmann/detail/meta/std_fs.hpp
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
|
||||
#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
|
||||
#include <experimental/filesystem>
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
namespace std_fs = std::experimental::filesystem;
|
||||
} // namespace detail
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
#elif JSON_HAS_FILESYSTEM
|
||||
#include <filesystem>
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
namespace std_fs = std::filesystem;
|
||||
} // namespace detail
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
#endif
|
@ -1,17 +1,27 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <limits> // numeric_limits
|
||||
#include <type_traits> // false_type, is_constructible, is_integral, is_same, true_type
|
||||
#include <utility> // declval
|
||||
#include <tuple> // tuple
|
||||
|
||||
#include <nlohmann/detail/iterators/iterator_traits.hpp>
|
||||
#include <nlohmann/detail/macro_scope.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/json_fwd.hpp>
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
/*!
|
||||
@brief detail namespace with internal helper functions
|
||||
|
||||
@ -22,6 +32,7 @@ implementations of some @ref basic_json methods, and meta-programming helpers.
|
||||
*/
|
||||
namespace detail
|
||||
{
|
||||
|
||||
/////////////
|
||||
// helpers //
|
||||
/////////////
|
||||
@ -40,6 +51,16 @@ template<typename> struct is_basic_json : std::false_type {};
|
||||
NLOHMANN_BASIC_JSON_TPL_DECLARATION
|
||||
struct is_basic_json<NLOHMANN_BASIC_JSON_TPL> : 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<typename BasicJsonContext>
|
||||
struct is_basic_json_context :
|
||||
std::integral_constant < bool,
|
||||
is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
|
||||
|| std::is_same<BasicJsonContext, std::nullptr_t>::value >
|
||||
{};
|
||||
|
||||
//////////////////////
|
||||
// json_ref helpers //
|
||||
//////////////////////
|
||||
@ -78,9 +99,6 @@ using reference_t = typename T::reference;
|
||||
template<typename T>
|
||||
using iterator_category_t = typename T::iterator_category;
|
||||
|
||||
template<typename T>
|
||||
using iterator_t = typename T::iterator;
|
||||
|
||||
template<typename T, typename... Args>
|
||||
using to_json_function = decltype(T::to_json(std::declval<Args>()...));
|
||||
|
||||
@ -105,8 +123,7 @@ struct is_getable
|
||||
};
|
||||
|
||||
template<typename BasicJsonType, typename T>
|
||||
struct has_from_json < BasicJsonType, T,
|
||||
enable_if_t < !is_basic_json<T>::value >>
|
||||
struct has_from_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >>
|
||||
{
|
||||
using serializer = typename BasicJsonType::template json_serializer<T, void>;
|
||||
|
||||
@ -145,11 +162,78 @@ struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >>
|
||||
T>::value;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
using detect_key_compare = typename T::key_compare;
|
||||
|
||||
template<typename T>
|
||||
struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
|
||||
|
||||
// obtains the actual object key comparator
|
||||
template<typename BasicJsonType>
|
||||
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<object_t>::value,
|
||||
typename object_t::key_compare, object_comparator_t>::type;
|
||||
};
|
||||
|
||||
template<typename BasicJsonType>
|
||||
using actual_object_comparator_t = typename actual_object_comparator<BasicJsonType>::type;
|
||||
|
||||
///////////////////
|
||||
// is_ functions //
|
||||
///////////////////
|
||||
|
||||
// https://en.cppreference.com/w/cpp/types/conjunction
|
||||
template<class...> struct conjunction : std::true_type { };
|
||||
template<class B> struct conjunction<B> : B { };
|
||||
template<class B, class... Bn>
|
||||
struct conjunction<B, Bn...>
|
||||
: std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>::type {};
|
||||
|
||||
// https://en.cppreference.com/w/cpp/types/negation
|
||||
template<class B> 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 <typename T>
|
||||
struct is_default_constructible : std::is_default_constructible<T> {};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct is_default_constructible<std::pair<T1, T2>>
|
||||
: conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct is_default_constructible<const std::pair<T1, T2>>
|
||||
: conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
|
||||
|
||||
template <typename... Ts>
|
||||
struct is_default_constructible<std::tuple<Ts...>>
|
||||
: conjunction<is_default_constructible<Ts>...> {};
|
||||
|
||||
template <typename... Ts>
|
||||
struct is_default_constructible<const std::tuple<Ts...>>
|
||||
: conjunction<is_default_constructible<Ts>...> {};
|
||||
|
||||
|
||||
template <typename T, typename... Args>
|
||||
struct is_constructible : std::is_constructible<T, Args...> {};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct is_constructible<std::pair<T1, T2>> : is_default_constructible<std::pair<T1, T2>> {};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct is_constructible<const std::pair<T1, T2>> : is_default_constructible<const std::pair<T1, T2>> {};
|
||||
|
||||
template <typename... Ts>
|
||||
struct is_constructible<std::tuple<Ts...>> : is_default_constructible<std::tuple<Ts...>> {};
|
||||
|
||||
template <typename... Ts>
|
||||
struct is_constructible<const std::tuple<Ts...>> : is_default_constructible<const std::tuple<Ts...>> {};
|
||||
|
||||
|
||||
template<typename T, typename = void>
|
||||
struct is_iterator_traits : std::false_type {};
|
||||
|
||||
@ -168,7 +252,34 @@ struct is_iterator_traits<iterator_traits<T>>
|
||||
is_detected<reference_t, traits>::value;
|
||||
};
|
||||
|
||||
// source: https://stackoverflow.com/a/37193089/4116453
|
||||
template<typename T>
|
||||
struct is_range
|
||||
{
|
||||
private:
|
||||
using t_ref = typename std::add_lvalue_reference<T>::type;
|
||||
|
||||
using iterator = detected_t<result_of_begin, t_ref>;
|
||||
using sentinel = detected_t<result_of_end, t_ref>;
|
||||
|
||||
// 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<iterator_traits<iterator>>::value;
|
||||
|
||||
public:
|
||||
static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value && is_iterator_begin;
|
||||
};
|
||||
|
||||
template<typename R>
|
||||
using iterator_t = enable_if_t<is_range<R>::value, result_of_begin<decltype(std::declval<R&>())>>;
|
||||
|
||||
template<typename T>
|
||||
using range_value_t = value_type_t<iterator_traits<iterator_t<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.
|
||||
|
||||
template<typename T, typename = void>
|
||||
struct is_complete_type : std::false_type {};
|
||||
@ -186,14 +297,13 @@ struct is_compatible_object_type_impl <
|
||||
enable_if_t < is_detected<mapped_type_t, CompatibleObjectType>::value&&
|
||||
is_detected<key_type_t, CompatibleObjectType>::value >>
|
||||
{
|
||||
|
||||
using object_t = typename BasicJsonType::object_t;
|
||||
|
||||
// macOS's is_constructible does not play well with nonesuch...
|
||||
static constexpr bool value =
|
||||
std::is_constructible<typename object_t::key_type,
|
||||
is_constructible<typename object_t::key_type,
|
||||
typename CompatibleObjectType::key_type>::value &&
|
||||
std::is_constructible<typename object_t::mapped_type,
|
||||
is_constructible<typename object_t::mapped_type,
|
||||
typename CompatibleObjectType::mapped_type>::value;
|
||||
};
|
||||
|
||||
@ -214,10 +324,10 @@ struct is_constructible_object_type_impl <
|
||||
using object_t = typename BasicJsonType::object_t;
|
||||
|
||||
static constexpr bool value =
|
||||
(std::is_default_constructible<ConstructibleObjectType>::value &&
|
||||
(is_default_constructible<ConstructibleObjectType>::value &&
|
||||
(std::is_move_assignable<ConstructibleObjectType>::value ||
|
||||
std::is_copy_assignable<ConstructibleObjectType>::value) &&
|
||||
(std::is_constructible<typename ConstructibleObjectType::key_type,
|
||||
(is_constructible<typename ConstructibleObjectType::key_type,
|
||||
typename object_t::key_type>::value &&
|
||||
std::is_same <
|
||||
typename object_t::mapped_type,
|
||||
@ -234,42 +344,29 @@ struct is_constructible_object_type
|
||||
: is_constructible_object_type_impl<BasicJsonType,
|
||||
ConstructibleObjectType> {};
|
||||
|
||||
template<typename BasicJsonType, typename CompatibleStringType,
|
||||
typename = void>
|
||||
struct is_compatible_string_type_impl : std::false_type {};
|
||||
|
||||
template<typename BasicJsonType, typename CompatibleStringType>
|
||||
struct is_compatible_string_type_impl <
|
||||
BasicJsonType, CompatibleStringType,
|
||||
enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
|
||||
value_type_t, CompatibleStringType>::value >>
|
||||
{
|
||||
static constexpr auto value =
|
||||
std::is_constructible<typename BasicJsonType::string_t, CompatibleStringType>::value;
|
||||
};
|
||||
|
||||
template<typename BasicJsonType, typename ConstructibleStringType>
|
||||
struct is_compatible_string_type
|
||||
: is_compatible_string_type_impl<BasicJsonType, ConstructibleStringType> {};
|
||||
|
||||
template<typename BasicJsonType, typename ConstructibleStringType,
|
||||
typename = void>
|
||||
struct is_constructible_string_type_impl : std::false_type {};
|
||||
|
||||
template<typename BasicJsonType, typename ConstructibleStringType>
|
||||
struct is_constructible_string_type_impl <
|
||||
BasicJsonType, ConstructibleStringType,
|
||||
enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
|
||||
value_type_t, ConstructibleStringType>::value >>
|
||||
{
|
||||
static constexpr auto value =
|
||||
std::is_constructible<ConstructibleStringType,
|
||||
typename BasicJsonType::string_t>::value;
|
||||
is_constructible<typename BasicJsonType::string_t, CompatibleStringType>::value;
|
||||
};
|
||||
|
||||
template<typename BasicJsonType, typename ConstructibleStringType>
|
||||
struct is_constructible_string_type
|
||||
: is_constructible_string_type_impl<BasicJsonType, ConstructibleStringType> {};
|
||||
{
|
||||
// launder type through decltype() to fix compilation failure on ICPC
|
||||
#ifdef __INTEL_COMPILER
|
||||
using laundered_type = decltype(std::declval<ConstructibleStringType>());
|
||||
#else
|
||||
using laundered_type = ConstructibleStringType;
|
||||
#endif
|
||||
|
||||
static constexpr auto value =
|
||||
conjunction <
|
||||
is_constructible<laundered_type, typename BasicJsonType::string_t>,
|
||||
is_detected_exact<typename BasicJsonType::string_t::value_type,
|
||||
value_type_t, laundered_type >>::value;
|
||||
};
|
||||
|
||||
template<typename BasicJsonType, typename CompatibleArrayType, typename = void>
|
||||
struct is_compatible_array_type_impl : std::false_type {};
|
||||
@ -277,17 +374,16 @@ struct is_compatible_array_type_impl : std::false_type {};
|
||||
template<typename BasicJsonType, typename CompatibleArrayType>
|
||||
struct is_compatible_array_type_impl <
|
||||
BasicJsonType, CompatibleArrayType,
|
||||
enable_if_t < is_detected<value_type_t, CompatibleArrayType>::value&&
|
||||
enable_if_t <
|
||||
is_detected<iterator_t, CompatibleArrayType>::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<CompatibleArrayType >>::value >>
|
||||
is_iterator_traits<iterator_traits<detected_t<iterator_t, CompatibleArrayType>>>::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<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>::value >>
|
||||
{
|
||||
static constexpr bool value =
|
||||
std::is_constructible<BasicJsonType,
|
||||
typename CompatibleArrayType::value_type>::value;
|
||||
is_constructible<BasicJsonType,
|
||||
range_value_t<CompatibleArrayType>>::value;
|
||||
};
|
||||
|
||||
template<typename BasicJsonType, typename CompatibleArrayType>
|
||||
@ -309,28 +405,29 @@ struct is_constructible_array_type_impl <
|
||||
BasicJsonType, ConstructibleArrayType,
|
||||
enable_if_t < !std::is_same<ConstructibleArrayType,
|
||||
typename BasicJsonType::value_type>::value&&
|
||||
std::is_default_constructible<ConstructibleArrayType>::value&&
|
||||
!is_compatible_string_type<BasicJsonType, ConstructibleArrayType>::value&&
|
||||
is_default_constructible<ConstructibleArrayType>::value&&
|
||||
(std::is_move_assignable<ConstructibleArrayType>::value ||
|
||||
std::is_copy_assignable<ConstructibleArrayType>::value)&&
|
||||
is_detected<value_type_t, ConstructibleArrayType>::value&&
|
||||
is_detected<iterator_t, ConstructibleArrayType>::value&&
|
||||
is_complete_type <
|
||||
detected_t<value_type_t, ConstructibleArrayType >>::value >>
|
||||
is_iterator_traits<iterator_traits<detected_t<iterator_t, ConstructibleArrayType>>>::value&&
|
||||
is_detected<range_value_t, ConstructibleArrayType>::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<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>::value&&
|
||||
is_complete_type <
|
||||
detected_t<range_value_t, ConstructibleArrayType >>::value >>
|
||||
{
|
||||
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<iterator_traits<ConstructibleArrayType>>::value &&
|
||||
using value_type = range_value_t<ConstructibleArrayType>;
|
||||
|
||||
(std::is_same<typename ConstructibleArrayType::value_type,
|
||||
typename BasicJsonType::array_t::value_type>::value ||
|
||||
has_from_json<BasicJsonType,
|
||||
typename ConstructibleArrayType::value_type>::value ||
|
||||
has_non_default_from_json <
|
||||
BasicJsonType, typename ConstructibleArrayType::value_type >::value);
|
||||
static constexpr bool value =
|
||||
std::is_same<value_type,
|
||||
typename BasicJsonType::array_t::value_type>::value ||
|
||||
has_from_json<BasicJsonType,
|
||||
value_type>::value ||
|
||||
has_non_default_from_json <
|
||||
BasicJsonType,
|
||||
value_type >::value;
|
||||
};
|
||||
|
||||
template<typename BasicJsonType, typename ConstructibleArrayType>
|
||||
@ -353,7 +450,7 @@ struct is_compatible_integer_type_impl <
|
||||
using CompatibleLimits = std::numeric_limits<CompatibleNumberIntegerType>;
|
||||
|
||||
static constexpr auto value =
|
||||
std::is_constructible<RealIntegerType,
|
||||
is_constructible<RealIntegerType,
|
||||
CompatibleNumberIntegerType>::value &&
|
||||
CompatibleLimits::is_integer &&
|
||||
RealLimits::is_signed == CompatibleLimits::is_signed;
|
||||
@ -380,17 +477,212 @@ template<typename BasicJsonType, typename CompatibleType>
|
||||
struct is_compatible_type
|
||||
: is_compatible_type_impl<BasicJsonType, CompatibleType> {};
|
||||
|
||||
// https://en.cppreference.com/w/cpp/types/conjunction
|
||||
template<class...> struct conjunction : std::true_type { };
|
||||
template<class B1> struct conjunction<B1> : B1 { };
|
||||
template<class B1, class... Bn>
|
||||
struct conjunction<B1, Bn...>
|
||||
: std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};
|
||||
|
||||
template<typename T1, typename T2>
|
||||
struct is_constructible_tuple : std::false_type {};
|
||||
|
||||
template<typename T1, typename... Args>
|
||||
struct is_constructible_tuple<T1, std::tuple<Args...>> : conjunction<std::is_constructible<T1, Args>...> {};
|
||||
struct is_constructible_tuple<T1, std::tuple<Args...>> : conjunction<is_constructible<T1, Args>...> {};
|
||||
|
||||
template<typename BasicJsonType, typename T>
|
||||
struct is_json_iterator_of : std::false_type {};
|
||||
|
||||
template<typename BasicJsonType>
|
||||
struct is_json_iterator_of<BasicJsonType, typename BasicJsonType::iterator> : std::true_type {};
|
||||
|
||||
template<typename BasicJsonType>
|
||||
struct is_json_iterator_of<BasicJsonType, typename BasicJsonType::const_iterator> : std::true_type
|
||||
{};
|
||||
|
||||
// checks if a given type T is a template specialization of Primary
|
||||
template<template <typename...> class Primary, typename T>
|
||||
struct is_specialization_of : std::false_type {};
|
||||
|
||||
template<template <typename...> class Primary, typename... Args>
|
||||
struct is_specialization_of<Primary, Primary<Args...>> : std::true_type {};
|
||||
|
||||
template<typename T>
|
||||
using is_json_pointer = is_specialization_of<::nlohmann::json_pointer, uncvref_t<T>>;
|
||||
|
||||
// checks if A and B are comparable using Compare functor
|
||||
template<typename Compare, typename A, typename B, typename = void>
|
||||
struct is_comparable : std::false_type {};
|
||||
|
||||
template<typename Compare, typename A, typename B>
|
||||
struct is_comparable<Compare, A, B, void_t<
|
||||
decltype(std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
|
||||
decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
|
||||
>> : std::true_type {};
|
||||
|
||||
template<typename T>
|
||||
using detect_is_transparent = typename T::is_transparent;
|
||||
|
||||
// type trait to check if KeyType can be used as object key (without a BasicJsonType)
|
||||
// see is_usable_as_basic_json_key_type below
|
||||
template<typename Comparator, typename ObjectKeyType, typename KeyTypeCVRef, bool RequireTransparentComparator = true,
|
||||
bool ExcludeObjectKeyType = RequireTransparentComparator, typename KeyType = uncvref_t<KeyTypeCVRef>>
|
||||
using is_usable_as_key_type = typename std::conditional <
|
||||
is_comparable<Comparator, ObjectKeyType, KeyTypeCVRef>::value
|
||||
&& !(ExcludeObjectKeyType && std::is_same<KeyType,
|
||||
ObjectKeyType>::value)
|
||||
&& (!RequireTransparentComparator
|
||||
|| is_detected <detect_is_transparent, Comparator>::value)
|
||||
&& !is_json_pointer<KeyType>::value,
|
||||
std::true_type,
|
||||
std::false_type >::type;
|
||||
|
||||
// type trait to check if KeyType can be used as object key
|
||||
// true if:
|
||||
// - KeyType is comparable with BasicJsonType::object_t::key_type
|
||||
// - if ExcludeObjectKeyType is true, KeyType is not BasicJsonType::object_t::key_type
|
||||
// - the comparator is transparent or RequireTransparentComparator is false
|
||||
// - KeyType is not a JSON iterator or json_pointer
|
||||
template<typename BasicJsonType, typename KeyTypeCVRef, bool RequireTransparentComparator = true,
|
||||
bool ExcludeObjectKeyType = RequireTransparentComparator, typename KeyType = uncvref_t<KeyTypeCVRef>>
|
||||
using is_usable_as_basic_json_key_type = typename std::conditional <
|
||||
is_usable_as_key_type<typename BasicJsonType::object_comparator_t,
|
||||
typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
|
||||
RequireTransparentComparator, ExcludeObjectKeyType>::value
|
||||
&& !is_json_iterator_of<BasicJsonType, KeyType>::value,
|
||||
std::true_type,
|
||||
std::false_type >::type;
|
||||
|
||||
template<typename ObjectType, typename KeyType>
|
||||
using detect_erase_with_key_type = decltype(std::declval<ObjectType&>().erase(std::declval<KeyType>()));
|
||||
|
||||
// type trait to check if object_t has an erase() member functions accepting KeyType
|
||||
template<typename BasicJsonType, typename KeyType>
|
||||
using has_erase_with_key_type = typename std::conditional <
|
||||
is_detected <
|
||||
detect_erase_with_key_type,
|
||||
typename BasicJsonType::object_t, KeyType >::value,
|
||||
std::true_type,
|
||||
std::false_type >::type;
|
||||
|
||||
// a naive helper to check if a type is an ordered_map (exploits the fact that
|
||||
// ordered_map inherits capacity() from std::vector)
|
||||
template <typename T>
|
||||
struct is_ordered_map
|
||||
{
|
||||
using one = char;
|
||||
|
||||
struct two
|
||||
{
|
||||
char x[2]; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
};
|
||||
|
||||
template <typename C> static one test( decltype(&C::capacity) ) ;
|
||||
template <typename C> static two test(...);
|
||||
|
||||
enum { value = sizeof(test<T>(nullptr)) == sizeof(char) }; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
||||
};
|
||||
|
||||
// to avoid useless casts (see https://github.com/nlohmann/json/issues/2893#issuecomment-889152324)
|
||||
template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value, int > = 0 >
|
||||
T conditional_static_cast(U value)
|
||||
{
|
||||
return static_cast<T>(value);
|
||||
}
|
||||
|
||||
template<typename T, typename U, enable_if_t<std::is_same<T, U>::value, int> = 0>
|
||||
T conditional_static_cast(U value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
template<typename... Types>
|
||||
using all_integral = conjunction<std::is_integral<Types>...>;
|
||||
|
||||
template<typename... Types>
|
||||
using all_signed = conjunction<std::is_signed<Types>...>;
|
||||
|
||||
template<typename... Types>
|
||||
using all_unsigned = conjunction<std::is_unsigned<Types>...>;
|
||||
|
||||
// there's a disjunction trait in another PR; replace when merged
|
||||
template<typename... Types>
|
||||
using same_sign = std::integral_constant < bool,
|
||||
all_signed<Types...>::value || all_unsigned<Types...>::value >;
|
||||
|
||||
template<typename OfType, typename T>
|
||||
using never_out_of_range = std::integral_constant < bool,
|
||||
(std::is_signed<OfType>::value && (sizeof(T) < sizeof(OfType)))
|
||||
|| (same_sign<OfType, T>::value && sizeof(OfType) == sizeof(T)) >;
|
||||
|
||||
template<typename OfType, typename T,
|
||||
bool OfTypeSigned = std::is_signed<OfType>::value,
|
||||
bool TSigned = std::is_signed<T>::value>
|
||||
struct value_in_range_of_impl2;
|
||||
|
||||
template<typename OfType, typename T>
|
||||
struct value_in_range_of_impl2<OfType, T, false, false>
|
||||
{
|
||||
static constexpr bool test(T val)
|
||||
{
|
||||
using CommonType = typename std::common_type<OfType, T>::type;
|
||||
return static_cast<CommonType>(val) <= static_cast<CommonType>((std::numeric_limits<OfType>::max)());
|
||||
}
|
||||
};
|
||||
|
||||
template<typename OfType, typename T>
|
||||
struct value_in_range_of_impl2<OfType, T, true, false>
|
||||
{
|
||||
static constexpr bool test(T val)
|
||||
{
|
||||
using CommonType = typename std::common_type<OfType, T>::type;
|
||||
return static_cast<CommonType>(val) <= static_cast<CommonType>((std::numeric_limits<OfType>::max)());
|
||||
}
|
||||
};
|
||||
|
||||
template<typename OfType, typename T>
|
||||
struct value_in_range_of_impl2<OfType, T, false, true>
|
||||
{
|
||||
static constexpr bool test(T val)
|
||||
{
|
||||
using CommonType = typename std::common_type<OfType, T>::type;
|
||||
return val >= 0 && static_cast<CommonType>(val) <= static_cast<CommonType>((std::numeric_limits<OfType>::max)());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename OfType, typename T>
|
||||
struct value_in_range_of_impl2<OfType, T, true, true>
|
||||
{
|
||||
static constexpr bool test(T val)
|
||||
{
|
||||
using CommonType = typename std::common_type<OfType, T>::type;
|
||||
return static_cast<CommonType>(val) >= static_cast<CommonType>((std::numeric_limits<OfType>::min)())
|
||||
&& static_cast<CommonType>(val) <= static_cast<CommonType>((std::numeric_limits<OfType>::max)());
|
||||
}
|
||||
};
|
||||
|
||||
template<typename OfType, typename T,
|
||||
bool NeverOutOfRange = never_out_of_range<OfType, T>::value,
|
||||
typename = detail::enable_if_t<all_integral<OfType, T>::value>>
|
||||
struct value_in_range_of_impl1;
|
||||
|
||||
template<typename OfType, typename T>
|
||||
struct value_in_range_of_impl1<OfType, T, false>
|
||||
{
|
||||
static constexpr bool test(T val)
|
||||
{
|
||||
return value_in_range_of_impl2<OfType, T>::test(val);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename OfType, typename T>
|
||||
struct value_in_range_of_impl1<OfType, T, true>
|
||||
{
|
||||
static constexpr bool test(T /*val*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename OfType, typename T>
|
||||
inline constexpr bool value_in_range_of(T val)
|
||||
{
|
||||
return value_in_range_of_impl1<OfType, T>::test(val);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace nlohmann
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
@ -1,13 +1,24 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
#include <nlohmann/detail/abi_macros.hpp>
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<typename ...Ts> struct make_void
|
||||
{
|
||||
using type = void;
|
||||
};
|
||||
template<typename ...Ts> using void_t = typename make_void<Ts...>::type;
|
||||
} // namespace detail
|
||||
} // namespace nlohmann
|
||||
|
||||
} // namespace detail
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
@ -1,21 +1,33 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm> // reverse
|
||||
#include <array> // array
|
||||
#include <map> // map
|
||||
#include <cmath> // isnan, isinf
|
||||
#include <cstdint> // uint8_t, uint16_t, uint32_t, uint64_t
|
||||
#include <cstring> // memcpy
|
||||
#include <limits> // numeric_limits
|
||||
#include <string> // string
|
||||
#include <cmath> // isnan, isinf
|
||||
#include <utility> // move
|
||||
#include <vector> // vector
|
||||
|
||||
#include <nlohmann/detail/input/binary_reader.hpp>
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
#include <nlohmann/detail/output/output_adapters.hpp>
|
||||
#include <nlohmann/detail/string_concat.hpp>
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
///////////////////
|
||||
// binary writer //
|
||||
///////////////////
|
||||
@ -36,7 +48,7 @@ class binary_writer
|
||||
|
||||
@param[in] adapter output adapter to write to
|
||||
*/
|
||||
explicit binary_writer(output_adapter_t<CharType> adapter) : oa(adapter)
|
||||
explicit binary_writer(output_adapter_t<CharType> adapter) : oa(std::move(adapter))
|
||||
{
|
||||
JSON_ASSERT(oa);
|
||||
}
|
||||
@ -55,9 +67,18 @@ class binary_writer
|
||||
break;
|
||||
}
|
||||
|
||||
case value_t::null:
|
||||
case value_t::array:
|
||||
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:
|
||||
{
|
||||
JSON_THROW(type_error::create(317, "to serialize to BSON, top-level type must be object, but is " + std::string(j.type_name())));
|
||||
JSON_THROW(type_error::create(317, concat("to serialize to BSON, top-level type must be object, but is ", j.type_name()), &j));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -281,8 +302,26 @@ class binary_writer
|
||||
{
|
||||
if (j.m_value.binary->has_subtype())
|
||||
{
|
||||
write_number(static_cast<std::uint8_t>(0xd8));
|
||||
write_number(j.m_value.binary->subtype());
|
||||
if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
|
||||
{
|
||||
write_number(static_cast<std::uint8_t>(0xd8));
|
||||
write_number(static_cast<std::uint8_t>(j.m_value.binary->subtype()));
|
||||
}
|
||||
else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
|
||||
{
|
||||
write_number(static_cast<std::uint8_t>(0xd9));
|
||||
write_number(static_cast<std::uint16_t>(j.m_value.binary->subtype()));
|
||||
}
|
||||
else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
|
||||
{
|
||||
write_number(static_cast<std::uint8_t>(0xda));
|
||||
write_number(static_cast<std::uint32_t>(j.m_value.binary->subtype()));
|
||||
}
|
||||
else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
|
||||
{
|
||||
write_number(static_cast<std::uint8_t>(0xdb));
|
||||
write_number(static_cast<std::uint64_t>(j.m_value.binary->subtype()));
|
||||
}
|
||||
}
|
||||
|
||||
// step 1: write control byte and the binary array size
|
||||
@ -362,6 +401,7 @@ class binary_writer
|
||||
break;
|
||||
}
|
||||
|
||||
case value_t::discarded:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -683,6 +723,7 @@ class binary_writer
|
||||
break;
|
||||
}
|
||||
|
||||
case value_t::discarded:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -693,9 +734,11 @@ class binary_writer
|
||||
@param[in] use_count whether to use '#' prefixes (optimized format)
|
||||
@param[in] use_type whether to use '$' prefixes (optimized format)
|
||||
@param[in] add_prefix whether prefixes need to be used for this value
|
||||
@param[in] use_bjdata whether write in BJData format, default is false
|
||||
*/
|
||||
void write_ubjson(const BasicJsonType& j, const bool use_count,
|
||||
const bool use_type, const bool add_prefix = true)
|
||||
const bool use_type, const bool add_prefix = true,
|
||||
const bool use_bjdata = false)
|
||||
{
|
||||
switch (j.type())
|
||||
{
|
||||
@ -721,19 +764,19 @@ class binary_writer
|
||||
|
||||
case value_t::number_integer:
|
||||
{
|
||||
write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix);
|
||||
write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix, use_bjdata);
|
||||
break;
|
||||
}
|
||||
|
||||
case value_t::number_unsigned:
|
||||
{
|
||||
write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix);
|
||||
write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix, use_bjdata);
|
||||
break;
|
||||
}
|
||||
|
||||
case value_t::number_float:
|
||||
{
|
||||
write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix);
|
||||
write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix, use_bjdata);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -743,7 +786,7 @@ class binary_writer
|
||||
{
|
||||
oa->write_character(to_char_type('S'));
|
||||
}
|
||||
write_number_with_ubjson_prefix(j.m_value.string->size(), true);
|
||||
write_number_with_ubjson_prefix(j.m_value.string->size(), true, use_bjdata);
|
||||
oa->write_characters(
|
||||
reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
|
||||
j.m_value.string->size());
|
||||
@ -761,14 +804,16 @@ class binary_writer
|
||||
if (use_type && !j.m_value.array->empty())
|
||||
{
|
||||
JSON_ASSERT(use_count);
|
||||
const CharType first_prefix = ubjson_prefix(j.front());
|
||||
const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
|
||||
const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
|
||||
[this, first_prefix](const BasicJsonType & v)
|
||||
[this, first_prefix, use_bjdata](const BasicJsonType & v)
|
||||
{
|
||||
return ubjson_prefix(v) == first_prefix;
|
||||
return ubjson_prefix(v, use_bjdata) == first_prefix;
|
||||
});
|
||||
|
||||
if (same_prefix)
|
||||
std::vector<CharType> bjdx = {'[', '{', 'S', 'H', 'T', 'F', 'N', 'Z'}; // excluded markers in bjdata optimized type
|
||||
|
||||
if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
|
||||
{
|
||||
prefix_required = false;
|
||||
oa->write_character(to_char_type('$'));
|
||||
@ -779,12 +824,12 @@ class binary_writer
|
||||
if (use_count)
|
||||
{
|
||||
oa->write_character(to_char_type('#'));
|
||||
write_number_with_ubjson_prefix(j.m_value.array->size(), true);
|
||||
write_number_with_ubjson_prefix(j.m_value.array->size(), true, use_bjdata);
|
||||
}
|
||||
|
||||
for (const auto& el : *j.m_value.array)
|
||||
{
|
||||
write_ubjson(el, use_count, use_type, prefix_required);
|
||||
write_ubjson(el, use_count, use_type, prefix_required, use_bjdata);
|
||||
}
|
||||
|
||||
if (!use_count)
|
||||
@ -812,7 +857,7 @@ class binary_writer
|
||||
if (use_count)
|
||||
{
|
||||
oa->write_character(to_char_type('#'));
|
||||
write_number_with_ubjson_prefix(j.m_value.binary->size(), true);
|
||||
write_number_with_ubjson_prefix(j.m_value.binary->size(), true, use_bjdata);
|
||||
}
|
||||
|
||||
if (use_type)
|
||||
@ -840,6 +885,14 @@ class binary_writer
|
||||
|
||||
case value_t::object:
|
||||
{
|
||||
if (use_bjdata && j.m_value.object->size() == 3 && j.m_value.object->find("_ArrayType_") != j.m_value.object->end() && j.m_value.object->find("_ArraySize_") != j.m_value.object->end() && j.m_value.object->find("_ArrayData_") != j.m_value.object->end())
|
||||
{
|
||||
if (!write_bjdata_ndarray(*j.m_value.object, use_count, use_type)) // decode bjdata ndarray in the JData format (https://github.com/NeuroJSON/jdata)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (add_prefix)
|
||||
{
|
||||
oa->write_character(to_char_type('{'));
|
||||
@ -849,14 +902,16 @@ class binary_writer
|
||||
if (use_type && !j.m_value.object->empty())
|
||||
{
|
||||
JSON_ASSERT(use_count);
|
||||
const CharType first_prefix = ubjson_prefix(j.front());
|
||||
const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
|
||||
const bool same_prefix = std::all_of(j.begin(), j.end(),
|
||||
[this, first_prefix](const BasicJsonType & v)
|
||||
[this, first_prefix, use_bjdata](const BasicJsonType & v)
|
||||
{
|
||||
return ubjson_prefix(v) == first_prefix;
|
||||
return ubjson_prefix(v, use_bjdata) == first_prefix;
|
||||
});
|
||||
|
||||
if (same_prefix)
|
||||
std::vector<CharType> bjdx = {'[', '{', 'S', 'H', 'T', 'F', 'N', 'Z'}; // excluded markers in bjdata optimized type
|
||||
|
||||
if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
|
||||
{
|
||||
prefix_required = false;
|
||||
oa->write_character(to_char_type('$'));
|
||||
@ -867,16 +922,16 @@ class binary_writer
|
||||
if (use_count)
|
||||
{
|
||||
oa->write_character(to_char_type('#'));
|
||||
write_number_with_ubjson_prefix(j.m_value.object->size(), true);
|
||||
write_number_with_ubjson_prefix(j.m_value.object->size(), true, use_bjdata);
|
||||
}
|
||||
|
||||
for (const auto& el : *j.m_value.object)
|
||||
{
|
||||
write_number_with_ubjson_prefix(el.first.size(), true);
|
||||
write_number_with_ubjson_prefix(el.first.size(), true, use_bjdata);
|
||||
oa->write_characters(
|
||||
reinterpret_cast<const CharType*>(el.first.c_str()),
|
||||
el.first.size());
|
||||
write_ubjson(el.second, use_count, use_type, prefix_required);
|
||||
write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata);
|
||||
}
|
||||
|
||||
if (!use_count)
|
||||
@ -887,6 +942,7 @@ class binary_writer
|
||||
break;
|
||||
}
|
||||
|
||||
case value_t::discarded:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -901,13 +957,13 @@ class binary_writer
|
||||
@return The size of a BSON document entry header, including the id marker
|
||||
and the entry name size (and its null-terminator).
|
||||
*/
|
||||
static std::size_t calc_bson_entry_header_size(const string_t& name)
|
||||
static std::size_t calc_bson_entry_header_size(const string_t& name, const BasicJsonType& j)
|
||||
{
|
||||
const auto it = name.find(static_cast<typename string_t::value_type>(0));
|
||||
if (JSON_HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos))
|
||||
{
|
||||
JSON_THROW(out_of_range::create(409,
|
||||
"BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) + ")"));
|
||||
JSON_THROW(out_of_range::create(409, concat("BSON key cannot contain code point U+0000 (at byte ", std::to_string(it), ")"), &j));
|
||||
static_cast<void>(j);
|
||||
}
|
||||
|
||||
return /*id*/ 1ul + name.size() + /*zero-terminator*/1u;
|
||||
@ -942,7 +998,7 @@ class binary_writer
|
||||
const double value)
|
||||
{
|
||||
write_bson_entry_header(name, 0x01);
|
||||
write_number<double, true>(value);
|
||||
write_number<double>(value, true);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -961,7 +1017,7 @@ class binary_writer
|
||||
{
|
||||
write_bson_entry_header(name, 0x02);
|
||||
|
||||
write_number<std::int32_t, true>(static_cast<std::int32_t>(value.size() + 1ul));
|
||||
write_number<std::int32_t>(static_cast<std::int32_t>(value.size() + 1ul), true);
|
||||
oa->write_characters(
|
||||
reinterpret_cast<const CharType*>(value.c_str()),
|
||||
value.size() + 1);
|
||||
@ -994,12 +1050,12 @@ class binary_writer
|
||||
if ((std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)())
|
||||
{
|
||||
write_bson_entry_header(name, 0x10); // int32
|
||||
write_number<std::int32_t, true>(static_cast<std::int32_t>(value));
|
||||
write_number<std::int32_t>(static_cast<std::int32_t>(value), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
write_bson_entry_header(name, 0x12); // int64
|
||||
write_number<std::int64_t, true>(static_cast<std::int64_t>(value));
|
||||
write_number<std::int64_t>(static_cast<std::int64_t>(value), true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1017,21 +1073,21 @@ class binary_writer
|
||||
@brief Writes a BSON element with key @a name and unsigned @a value
|
||||
*/
|
||||
void write_bson_unsigned(const string_t& name,
|
||||
const std::uint64_t value)
|
||||
const BasicJsonType& j)
|
||||
{
|
||||
if (value <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
|
||||
if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
|
||||
{
|
||||
write_bson_entry_header(name, 0x10 /* int32 */);
|
||||
write_number<std::int32_t, true>(static_cast<std::int32_t>(value));
|
||||
write_number<std::int32_t>(static_cast<std::int32_t>(j.m_value.number_unsigned), true);
|
||||
}
|
||||
else if (value <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
|
||||
else if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
|
||||
{
|
||||
write_bson_entry_header(name, 0x12 /* int64 */);
|
||||
write_number<std::int64_t, true>(static_cast<std::int64_t>(value));
|
||||
write_number<std::int64_t>(static_cast<std::int64_t>(j.m_value.number_unsigned), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
JSON_THROW(out_of_range::create(407, "integer number " + std::to_string(value) + " cannot be represented by BSON as it does not fit int64"));
|
||||
JSON_THROW(out_of_range::create(407, concat("integer number ", std::to_string(j.m_value.number_unsigned), " cannot be represented by BSON as it does not fit int64"), &j));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1052,7 +1108,7 @@ class binary_writer
|
||||
{
|
||||
std::size_t array_index = 0ul;
|
||||
|
||||
const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), std::size_t(0), [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type & el)
|
||||
const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), static_cast<std::size_t>(0), [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type & el)
|
||||
{
|
||||
return result + calc_bson_element_size(std::to_string(array_index++), el);
|
||||
});
|
||||
@ -1075,7 +1131,7 @@ class binary_writer
|
||||
const typename BasicJsonType::array_t& value)
|
||||
{
|
||||
write_bson_entry_header(name, 0x04); // array
|
||||
write_number<std::int32_t, true>(static_cast<std::int32_t>(calc_bson_array_size(value)));
|
||||
write_number<std::int32_t>(static_cast<std::int32_t>(calc_bson_array_size(value)), true);
|
||||
|
||||
std::size_t array_index = 0ul;
|
||||
|
||||
@ -1095,8 +1151,8 @@ class binary_writer
|
||||
{
|
||||
write_bson_entry_header(name, 0x05);
|
||||
|
||||
write_number<std::int32_t, true>(static_cast<std::int32_t>(value.size()));
|
||||
write_number(value.has_subtype() ? value.subtype() : std::uint8_t(0x00));
|
||||
write_number<std::int32_t>(static_cast<std::int32_t>(value.size()), true);
|
||||
write_number(value.has_subtype() ? static_cast<std::uint8_t>(value.subtype()) : static_cast<std::uint8_t>(0x00));
|
||||
|
||||
oa->write_characters(reinterpret_cast<const CharType*>(value.data()), value.size());
|
||||
}
|
||||
@ -1108,7 +1164,7 @@ class binary_writer
|
||||
static std::size_t calc_bson_element_size(const string_t& name,
|
||||
const BasicJsonType& j)
|
||||
{
|
||||
const auto header_size = calc_bson_entry_header_size(name);
|
||||
const auto header_size = calc_bson_entry_header_size(name, j);
|
||||
switch (j.type())
|
||||
{
|
||||
case value_t::object:
|
||||
@ -1139,8 +1195,9 @@ class binary_writer
|
||||
return header_size + 0ul;
|
||||
|
||||
// LCOV_EXCL_START
|
||||
case value_t::discarded:
|
||||
default:
|
||||
JSON_ASSERT(false);
|
||||
JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert)
|
||||
return 0ul;
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
@ -1151,7 +1208,6 @@ class binary_writer
|
||||
key @a name.
|
||||
@param name The name to associate with the JSON entity @a j within the
|
||||
current BSON document
|
||||
@return The size of the BSON entry
|
||||
*/
|
||||
void write_bson_element(const string_t& name,
|
||||
const BasicJsonType& j)
|
||||
@ -1177,7 +1233,7 @@ class binary_writer
|
||||
return write_bson_integer(name, j.m_value.number_integer);
|
||||
|
||||
case value_t::number_unsigned:
|
||||
return write_bson_unsigned(name, j.m_value.number_unsigned);
|
||||
return write_bson_unsigned(name, j);
|
||||
|
||||
case value_t::string:
|
||||
return write_bson_string(name, *j.m_value.string);
|
||||
@ -1186,8 +1242,9 @@ class binary_writer
|
||||
return write_bson_null(name);
|
||||
|
||||
// LCOV_EXCL_START
|
||||
case value_t::discarded:
|
||||
default:
|
||||
JSON_ASSERT(false);
|
||||
JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert)
|
||||
return;
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
@ -1196,12 +1253,12 @@ class binary_writer
|
||||
/*!
|
||||
@brief Calculates the size of the BSON serialization of the given
|
||||
JSON-object @a j.
|
||||
@param[in] j JSON value to serialize
|
||||
@pre j.type() == value_t::object
|
||||
@param[in] value JSON value to serialize
|
||||
@pre value.type() == value_t::object
|
||||
*/
|
||||
static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t& value)
|
||||
{
|
||||
std::size_t document_size = std::accumulate(value.begin(), value.end(), std::size_t(0),
|
||||
std::size_t document_size = std::accumulate(value.begin(), value.end(), static_cast<std::size_t>(0),
|
||||
[](size_t result, const typename BasicJsonType::object_t::value_type & el)
|
||||
{
|
||||
return result += calc_bson_element_size(el.first, el.second);
|
||||
@ -1211,12 +1268,12 @@ class binary_writer
|
||||
}
|
||||
|
||||
/*!
|
||||
@param[in] j JSON value to serialize
|
||||
@pre j.type() == value_t::object
|
||||
@param[in] value JSON value to serialize
|
||||
@pre value.type() == value_t::object
|
||||
*/
|
||||
void write_bson_object(const typename BasicJsonType::object_t& value)
|
||||
{
|
||||
write_number<std::int32_t, true>(static_cast<std::int32_t>(calc_bson_object_size(value)));
|
||||
write_number<std::int32_t>(static_cast<std::int32_t>(calc_bson_object_size(value)), true);
|
||||
|
||||
for (const auto& el : value)
|
||||
{
|
||||
@ -1262,20 +1319,22 @@ class binary_writer
|
||||
template<typename NumberType, typename std::enable_if<
|
||||
std::is_floating_point<NumberType>::value, int>::type = 0>
|
||||
void write_number_with_ubjson_prefix(const NumberType n,
|
||||
const bool add_prefix)
|
||||
const bool add_prefix,
|
||||
const bool use_bjdata)
|
||||
{
|
||||
if (add_prefix)
|
||||
{
|
||||
oa->write_character(get_ubjson_float_prefix(n));
|
||||
}
|
||||
write_number(n);
|
||||
write_number(n, use_bjdata);
|
||||
}
|
||||
|
||||
// UBJSON: write number (unsigned integer)
|
||||
template<typename NumberType, typename std::enable_if<
|
||||
std::is_unsigned<NumberType>::value, int>::type = 0>
|
||||
void write_number_with_ubjson_prefix(const NumberType n,
|
||||
const bool add_prefix)
|
||||
const bool add_prefix,
|
||||
const bool use_bjdata)
|
||||
{
|
||||
if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)()))
|
||||
{
|
||||
@ -1283,7 +1342,7 @@ class binary_writer
|
||||
{
|
||||
oa->write_character(to_char_type('i')); // int8
|
||||
}
|
||||
write_number(static_cast<std::uint8_t>(n));
|
||||
write_number(static_cast<std::uint8_t>(n), use_bjdata);
|
||||
}
|
||||
else if (n <= (std::numeric_limits<std::uint8_t>::max)())
|
||||
{
|
||||
@ -1291,7 +1350,7 @@ class binary_writer
|
||||
{
|
||||
oa->write_character(to_char_type('U')); // uint8
|
||||
}
|
||||
write_number(static_cast<std::uint8_t>(n));
|
||||
write_number(static_cast<std::uint8_t>(n), use_bjdata);
|
||||
}
|
||||
else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)()))
|
||||
{
|
||||
@ -1299,7 +1358,15 @@ class binary_writer
|
||||
{
|
||||
oa->write_character(to_char_type('I')); // int16
|
||||
}
|
||||
write_number(static_cast<std::int16_t>(n));
|
||||
write_number(static_cast<std::int16_t>(n), use_bjdata);
|
||||
}
|
||||
else if (use_bjdata && n <= static_cast<uint64_t>((std::numeric_limits<uint16_t>::max)()))
|
||||
{
|
||||
if (add_prefix)
|
||||
{
|
||||
oa->write_character(to_char_type('u')); // uint16 - bjdata only
|
||||
}
|
||||
write_number(static_cast<std::uint16_t>(n), use_bjdata);
|
||||
}
|
||||
else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
|
||||
{
|
||||
@ -1307,7 +1374,15 @@ class binary_writer
|
||||
{
|
||||
oa->write_character(to_char_type('l')); // int32
|
||||
}
|
||||
write_number(static_cast<std::int32_t>(n));
|
||||
write_number(static_cast<std::int32_t>(n), use_bjdata);
|
||||
}
|
||||
else if (use_bjdata && n <= static_cast<uint64_t>((std::numeric_limits<uint32_t>::max)()))
|
||||
{
|
||||
if (add_prefix)
|
||||
{
|
||||
oa->write_character(to_char_type('m')); // uint32 - bjdata only
|
||||
}
|
||||
write_number(static_cast<std::uint32_t>(n), use_bjdata);
|
||||
}
|
||||
else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
|
||||
{
|
||||
@ -1315,7 +1390,15 @@ class binary_writer
|
||||
{
|
||||
oa->write_character(to_char_type('L')); // int64
|
||||
}
|
||||
write_number(static_cast<std::int64_t>(n));
|
||||
write_number(static_cast<std::int64_t>(n), use_bjdata);
|
||||
}
|
||||
else if (use_bjdata && n <= (std::numeric_limits<uint64_t>::max)())
|
||||
{
|
||||
if (add_prefix)
|
||||
{
|
||||
oa->write_character(to_char_type('M')); // uint64 - bjdata only
|
||||
}
|
||||
write_number(static_cast<std::uint64_t>(n), use_bjdata);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1325,7 +1408,7 @@ class binary_writer
|
||||
}
|
||||
|
||||
const auto number = BasicJsonType(n).dump();
|
||||
write_number_with_ubjson_prefix(number.size(), true);
|
||||
write_number_with_ubjson_prefix(number.size(), true, use_bjdata);
|
||||
for (std::size_t i = 0; i < number.size(); ++i)
|
||||
{
|
||||
oa->write_character(to_char_type(static_cast<std::uint8_t>(number[i])));
|
||||
@ -1338,7 +1421,8 @@ class binary_writer
|
||||
std::is_signed<NumberType>::value&&
|
||||
!std::is_floating_point<NumberType>::value, int >::type = 0 >
|
||||
void write_number_with_ubjson_prefix(const NumberType n,
|
||||
const bool add_prefix)
|
||||
const bool add_prefix,
|
||||
const bool use_bjdata)
|
||||
{
|
||||
if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
|
||||
{
|
||||
@ -1346,7 +1430,7 @@ class binary_writer
|
||||
{
|
||||
oa->write_character(to_char_type('i')); // int8
|
||||
}
|
||||
write_number(static_cast<std::int8_t>(n));
|
||||
write_number(static_cast<std::int8_t>(n), use_bjdata);
|
||||
}
|
||||
else if (static_cast<std::int64_t>((std::numeric_limits<std::uint8_t>::min)()) <= n && n <= static_cast<std::int64_t>((std::numeric_limits<std::uint8_t>::max)()))
|
||||
{
|
||||
@ -1354,7 +1438,7 @@ class binary_writer
|
||||
{
|
||||
oa->write_character(to_char_type('U')); // uint8
|
||||
}
|
||||
write_number(static_cast<std::uint8_t>(n));
|
||||
write_number(static_cast<std::uint8_t>(n), use_bjdata);
|
||||
}
|
||||
else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
|
||||
{
|
||||
@ -1362,7 +1446,15 @@ class binary_writer
|
||||
{
|
||||
oa->write_character(to_char_type('I')); // int16
|
||||
}
|
||||
write_number(static_cast<std::int16_t>(n));
|
||||
write_number(static_cast<std::int16_t>(n), use_bjdata);
|
||||
}
|
||||
else if (use_bjdata && (static_cast<std::int64_t>((std::numeric_limits<std::uint16_t>::min)()) <= n && n <= static_cast<std::int64_t>((std::numeric_limits<std::uint16_t>::max)())))
|
||||
{
|
||||
if (add_prefix)
|
||||
{
|
||||
oa->write_character(to_char_type('u')); // uint16 - bjdata only
|
||||
}
|
||||
write_number(static_cast<uint16_t>(n), use_bjdata);
|
||||
}
|
||||
else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
|
||||
{
|
||||
@ -1370,7 +1462,15 @@ class binary_writer
|
||||
{
|
||||
oa->write_character(to_char_type('l')); // int32
|
||||
}
|
||||
write_number(static_cast<std::int32_t>(n));
|
||||
write_number(static_cast<std::int32_t>(n), use_bjdata);
|
||||
}
|
||||
else if (use_bjdata && (static_cast<std::int64_t>((std::numeric_limits<std::uint32_t>::min)()) <= n && n <= static_cast<std::int64_t>((std::numeric_limits<std::uint32_t>::max)())))
|
||||
{
|
||||
if (add_prefix)
|
||||
{
|
||||
oa->write_character(to_char_type('m')); // uint32 - bjdata only
|
||||
}
|
||||
write_number(static_cast<uint32_t>(n), use_bjdata);
|
||||
}
|
||||
else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
|
||||
{
|
||||
@ -1378,7 +1478,7 @@ class binary_writer
|
||||
{
|
||||
oa->write_character(to_char_type('L')); // int64
|
||||
}
|
||||
write_number(static_cast<std::int64_t>(n));
|
||||
write_number(static_cast<std::int64_t>(n), use_bjdata);
|
||||
}
|
||||
// LCOV_EXCL_START
|
||||
else
|
||||
@ -1389,7 +1489,7 @@ class binary_writer
|
||||
}
|
||||
|
||||
const auto number = BasicJsonType(n).dump();
|
||||
write_number_with_ubjson_prefix(number.size(), true);
|
||||
write_number_with_ubjson_prefix(number.size(), true, use_bjdata);
|
||||
for (std::size_t i = 0; i < number.size(); ++i)
|
||||
{
|
||||
oa->write_character(to_char_type(static_cast<std::uint8_t>(number[i])));
|
||||
@ -1401,7 +1501,7 @@ class binary_writer
|
||||
/*!
|
||||
@brief determine the type prefix of container values
|
||||
*/
|
||||
CharType ubjson_prefix(const BasicJsonType& j) const noexcept
|
||||
CharType ubjson_prefix(const BasicJsonType& j, const bool use_bjdata) const noexcept
|
||||
{
|
||||
switch (j.type())
|
||||
{
|
||||
@ -1425,10 +1525,18 @@ class binary_writer
|
||||
{
|
||||
return 'I';
|
||||
}
|
||||
if (use_bjdata && ((std::numeric_limits<std::uint16_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)()))
|
||||
{
|
||||
return 'u';
|
||||
}
|
||||
if ((std::numeric_limits<std::int32_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
|
||||
{
|
||||
return 'l';
|
||||
}
|
||||
if (use_bjdata && ((std::numeric_limits<std::uint32_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)()))
|
||||
{
|
||||
return 'm';
|
||||
}
|
||||
if ((std::numeric_limits<std::int64_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
|
||||
{
|
||||
return 'L';
|
||||
@ -1451,14 +1559,26 @@ class binary_writer
|
||||
{
|
||||
return 'I';
|
||||
}
|
||||
if (use_bjdata && j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::uint16_t>::max)()))
|
||||
{
|
||||
return 'u';
|
||||
}
|
||||
if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
|
||||
{
|
||||
return 'l';
|
||||
}
|
||||
if (use_bjdata && j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::uint32_t>::max)()))
|
||||
{
|
||||
return 'm';
|
||||
}
|
||||
if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
|
||||
{
|
||||
return 'L';
|
||||
}
|
||||
if (use_bjdata && j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
|
||||
{
|
||||
return 'M';
|
||||
}
|
||||
// anything else is treated as high-precision number
|
||||
return 'H'; // LCOV_EXCL_LINE
|
||||
}
|
||||
@ -1476,6 +1596,7 @@ class binary_writer
|
||||
case value_t::object:
|
||||
return '{';
|
||||
|
||||
case value_t::discarded:
|
||||
default: // discarded values
|
||||
return 'N';
|
||||
}
|
||||
@ -1491,6 +1612,118 @@ class binary_writer
|
||||
return 'D'; // float 64
|
||||
}
|
||||
|
||||
/*!
|
||||
@return false if the object is successfully converted to a bjdata ndarray, true if the type or size is invalid
|
||||
*/
|
||||
bool write_bjdata_ndarray(const typename BasicJsonType::object_t& value, const bool use_count, const bool use_type)
|
||||
{
|
||||
std::map<string_t, CharType> bjdtype = {{"uint8", 'U'}, {"int8", 'i'}, {"uint16", 'u'}, {"int16", 'I'},
|
||||
{"uint32", 'm'}, {"int32", 'l'}, {"uint64", 'M'}, {"int64", 'L'}, {"single", 'd'}, {"double", 'D'}, {"char", 'C'}
|
||||
};
|
||||
|
||||
string_t key = "_ArrayType_";
|
||||
auto it = bjdtype.find(static_cast<string_t>(value.at(key)));
|
||||
if (it == bjdtype.end())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
CharType dtype = it->second;
|
||||
|
||||
key = "_ArraySize_";
|
||||
std::size_t len = (value.at(key).empty() ? 0 : 1);
|
||||
for (const auto& el : value.at(key))
|
||||
{
|
||||
len *= static_cast<std::size_t>(el.m_value.number_unsigned);
|
||||
}
|
||||
|
||||
key = "_ArrayData_";
|
||||
if (value.at(key).size() != len)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
oa->write_character('[');
|
||||
oa->write_character('$');
|
||||
oa->write_character(dtype);
|
||||
oa->write_character('#');
|
||||
|
||||
key = "_ArraySize_";
|
||||
write_ubjson(value.at(key), use_count, use_type, true, true);
|
||||
|
||||
key = "_ArrayData_";
|
||||
if (dtype == 'U' || dtype == 'C')
|
||||
{
|
||||
for (const auto& el : value.at(key))
|
||||
{
|
||||
write_number(static_cast<std::uint8_t>(el.m_value.number_unsigned), true);
|
||||
}
|
||||
}
|
||||
else if (dtype == 'i')
|
||||
{
|
||||
for (const auto& el : value.at(key))
|
||||
{
|
||||
write_number(static_cast<std::int8_t>(el.m_value.number_integer), true);
|
||||
}
|
||||
}
|
||||
else if (dtype == 'u')
|
||||
{
|
||||
for (const auto& el : value.at(key))
|
||||
{
|
||||
write_number(static_cast<std::uint16_t>(el.m_value.number_unsigned), true);
|
||||
}
|
||||
}
|
||||
else if (dtype == 'I')
|
||||
{
|
||||
for (const auto& el : value.at(key))
|
||||
{
|
||||
write_number(static_cast<std::int16_t>(el.m_value.number_integer), true);
|
||||
}
|
||||
}
|
||||
else if (dtype == 'm')
|
||||
{
|
||||
for (const auto& el : value.at(key))
|
||||
{
|
||||
write_number(static_cast<std::uint32_t>(el.m_value.number_unsigned), true);
|
||||
}
|
||||
}
|
||||
else if (dtype == 'l')
|
||||
{
|
||||
for (const auto& el : value.at(key))
|
||||
{
|
||||
write_number(static_cast<std::int32_t>(el.m_value.number_integer), true);
|
||||
}
|
||||
}
|
||||
else if (dtype == 'M')
|
||||
{
|
||||
for (const auto& el : value.at(key))
|
||||
{
|
||||
write_number(static_cast<std::uint64_t>(el.m_value.number_unsigned), true);
|
||||
}
|
||||
}
|
||||
else if (dtype == 'L')
|
||||
{
|
||||
for (const auto& el : value.at(key))
|
||||
{
|
||||
write_number(static_cast<std::int64_t>(el.m_value.number_integer), true);
|
||||
}
|
||||
}
|
||||
else if (dtype == 'd')
|
||||
{
|
||||
for (const auto& el : value.at(key))
|
||||
{
|
||||
write_number(static_cast<float>(el.m_value.number_float), true);
|
||||
}
|
||||
}
|
||||
else if (dtype == 'D')
|
||||
{
|
||||
for (const auto& el : value.at(key))
|
||||
{
|
||||
write_number(static_cast<double>(el.m_value.number_float), true);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
///////////////////////
|
||||
// Utility functions //
|
||||
///////////////////////
|
||||
@ -1498,19 +1731,21 @@ class binary_writer
|
||||
/*
|
||||
@brief write a number to output input
|
||||
@param[in] n number of type @a NumberType
|
||||
@tparam NumberType the type of the number
|
||||
@tparam OutputIsLittleEndian Set to true if output data is
|
||||
@param[in] OutputIsLittleEndian Set to true if output data is
|
||||
required to be little endian
|
||||
@tparam NumberType the type of the number
|
||||
|
||||
@note This function needs to respect the system's endianess, because bytes
|
||||
@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<typename NumberType, bool OutputIsLittleEndian = false>
|
||||
void write_number(const NumberType n)
|
||||
template<typename NumberType>
|
||||
void write_number(const NumberType n, const bool OutputIsLittleEndian = false)
|
||||
{
|
||||
// step 1: write number to array of length NumberType
|
||||
std::array<CharType, sizeof(NumberType)> vec;
|
||||
std::array<CharType, sizeof(NumberType)> vec{};
|
||||
std::memcpy(vec.data(), &n, sizeof(NumberType));
|
||||
|
||||
// step 2: write array to output (with possible reordering)
|
||||
@ -1525,6 +1760,10 @@ class binary_writer
|
||||
|
||||
void write_compact_float(const number_float_t n, detail::input_format_t format)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
#endif
|
||||
if (static_cast<double>(n) >= static_cast<double>(std::numeric_limits<float>::lowest()) &&
|
||||
static_cast<double>(n) <= static_cast<double>((std::numeric_limits<float>::max)()) &&
|
||||
static_cast<double>(static_cast<float>(n)) == static_cast<double>(n))
|
||||
@ -1541,6 +1780,9 @@ class binary_writer
|
||||
: get_msgpack_float_prefix(n));
|
||||
write_number(n);
|
||||
}
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
}
|
||||
|
||||
public:
|
||||
@ -1585,11 +1827,12 @@ class binary_writer
|
||||
}
|
||||
|
||||
private:
|
||||
/// 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();
|
||||
|
||||
/// the output
|
||||
output_adapter_t<CharType> oa = nullptr;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace nlohmann
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
@ -1,25 +1,43 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm> // copy
|
||||
#include <cstddef> // size_t
|
||||
#include <ios> // streamsize
|
||||
#include <iterator> // back_inserter
|
||||
#include <memory> // shared_ptr, make_shared
|
||||
#include <ostream> // basic_ostream
|
||||
#include <string> // basic_string
|
||||
#include <vector> // vector
|
||||
|
||||
#ifndef JSON_NO_IO
|
||||
#include <ios> // streamsize
|
||||
#include <ostream> // basic_ostream
|
||||
#endif // JSON_NO_IO
|
||||
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
/// abstract output adapter interface
|
||||
template<typename CharType> struct output_adapter_protocol
|
||||
{
|
||||
virtual void write_character(CharType c) = 0;
|
||||
virtual void write_characters(const CharType* s, std::size_t length) = 0;
|
||||
virtual ~output_adapter_protocol() = default;
|
||||
|
||||
output_adapter_protocol() = default;
|
||||
output_adapter_protocol(const output_adapter_protocol&) = default;
|
||||
output_adapter_protocol(output_adapter_protocol&&) noexcept = default;
|
||||
output_adapter_protocol& operator=(const output_adapter_protocol&) = default;
|
||||
output_adapter_protocol& operator=(output_adapter_protocol&&) noexcept = default;
|
||||
};
|
||||
|
||||
/// a type to simplify interfaces
|
||||
@ -27,11 +45,11 @@ template<typename CharType>
|
||||
using output_adapter_t = std::shared_ptr<output_adapter_protocol<CharType>>;
|
||||
|
||||
/// output adapter for byte vectors
|
||||
template<typename CharType>
|
||||
template<typename CharType, typename AllocatorType = std::allocator<CharType>>
|
||||
class output_vector_adapter : public output_adapter_protocol<CharType>
|
||||
{
|
||||
public:
|
||||
explicit output_vector_adapter(std::vector<CharType>& vec) noexcept
|
||||
explicit output_vector_adapter(std::vector<CharType, AllocatorType>& vec) noexcept
|
||||
: v(vec)
|
||||
{}
|
||||
|
||||
@ -43,13 +61,14 @@ class output_vector_adapter : public output_adapter_protocol<CharType>
|
||||
JSON_HEDLEY_NON_NULL(2)
|
||||
void write_characters(const CharType* s, std::size_t length) override
|
||||
{
|
||||
std::copy(s, s + length, std::back_inserter(v));
|
||||
v.insert(v.end(), s, s + length);
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<CharType>& v;
|
||||
std::vector<CharType, AllocatorType>& v;
|
||||
};
|
||||
|
||||
#ifndef JSON_NO_IO
|
||||
/// output adapter for output streams
|
||||
template<typename CharType>
|
||||
class output_stream_adapter : public output_adapter_protocol<CharType>
|
||||
@ -73,6 +92,7 @@ class output_stream_adapter : public output_adapter_protocol<CharType>
|
||||
private:
|
||||
std::basic_ostream<CharType>& stream;
|
||||
};
|
||||
#endif // JSON_NO_IO
|
||||
|
||||
/// output adapter for basic_string
|
||||
template<typename CharType, typename StringType = std::basic_string<CharType>>
|
||||
@ -102,11 +122,14 @@ template<typename CharType, typename StringType = std::basic_string<CharType>>
|
||||
class output_adapter
|
||||
{
|
||||
public:
|
||||
output_adapter(std::vector<CharType>& vec)
|
||||
: oa(std::make_shared<output_vector_adapter<CharType>>(vec)) {}
|
||||
template<typename AllocatorType = std::allocator<CharType>>
|
||||
output_adapter(std::vector<CharType, AllocatorType>& vec)
|
||||
: oa(std::make_shared<output_vector_adapter<CharType, AllocatorType>>(vec)) {}
|
||||
|
||||
#ifndef JSON_NO_IO
|
||||
output_adapter(std::basic_ostream<CharType>& s)
|
||||
: oa(std::make_shared<output_stream_adapter<CharType>>(s)) {}
|
||||
#endif // JSON_NO_IO
|
||||
|
||||
output_adapter(StringType& s)
|
||||
: oa(std::make_shared<output_string_adapter<CharType, StringType>>(s)) {}
|
||||
@ -119,5 +142,6 @@ class output_adapter
|
||||
private:
|
||||
output_adapter_t<CharType> oa = nullptr;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace nlohmann
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
@ -1,3 +1,12 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2008-2009 Björn Hoehrmann <bjoern@hoehrmann.de>
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm> // reverse, remove, fill, find, none_of
|
||||
@ -9,6 +18,7 @@
|
||||
#include <cstdio> // snprintf
|
||||
#include <limits> // numeric_limits
|
||||
#include <string> // string, char_traits
|
||||
#include <iomanip> // setfill, setw
|
||||
#include <type_traits> // is_same
|
||||
#include <utility> // move
|
||||
|
||||
@ -18,12 +28,13 @@
|
||||
#include <nlohmann/detail/meta/cpp_future.hpp>
|
||||
#include <nlohmann/detail/output/binary_writer.hpp>
|
||||
#include <nlohmann/detail/output/output_adapters.hpp>
|
||||
#include <nlohmann/detail/string_concat.hpp>
|
||||
#include <nlohmann/detail/value_t.hpp>
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
///////////////////
|
||||
// serialization //
|
||||
///////////////////
|
||||
@ -358,11 +369,11 @@ class serializer
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
JSON_PRIVATE_UNLESS_TESTED:
|
||||
/*!
|
||||
@brief dump escaped string
|
||||
|
||||
@ -379,7 +390,7 @@ class serializer
|
||||
*/
|
||||
void dump_escaped(const string_t& s, const bool ensure_ascii)
|
||||
{
|
||||
std::uint32_t codepoint;
|
||||
std::uint32_t codepoint{};
|
||||
std::uint8_t state = UTF8_ACCEPT;
|
||||
std::size_t bytes = 0; // number of bytes written to string_buffer
|
||||
|
||||
@ -389,7 +400,7 @@ class serializer
|
||||
|
||||
for (std::size_t i = 0; i < s.size(); ++i)
|
||||
{
|
||||
const auto byte = static_cast<uint8_t>(s[i]);
|
||||
const auto byte = static_cast<std::uint8_t>(s[i]);
|
||||
|
||||
switch (decode(state, codepoint, byte))
|
||||
{
|
||||
@ -454,15 +465,17 @@ class serializer
|
||||
{
|
||||
if (codepoint <= 0xFFFF)
|
||||
{
|
||||
(std::snprintf)(string_buffer.data() + bytes, 7, "\\u%04x",
|
||||
static_cast<std::uint16_t>(codepoint));
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
||||
static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 7, "\\u%04x",
|
||||
static_cast<std::uint16_t>(codepoint)));
|
||||
bytes += 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
(std::snprintf)(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x",
|
||||
static_cast<std::uint16_t>(0xD7C0u + (codepoint >> 10u)),
|
||||
static_cast<std::uint16_t>(0xDC00u + (codepoint & 0x3FFu)));
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
||||
static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x",
|
||||
static_cast<std::uint16_t>(0xD7C0u + (codepoint >> 10u)),
|
||||
static_cast<std::uint16_t>(0xDC00u + (codepoint & 0x3FFu))));
|
||||
bytes += 12;
|
||||
}
|
||||
}
|
||||
@ -497,9 +510,7 @@ class serializer
|
||||
{
|
||||
case error_handler_t::strict:
|
||||
{
|
||||
std::string sn(3, '\0');
|
||||
(std::snprintf)(&sn[0], sn.size(), "%.2X", byte);
|
||||
JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + sn));
|
||||
JSON_THROW(type_error::create(316, concat("invalid UTF-8 byte at index ", std::to_string(i), ": 0x", hex_bytes(byte | 0)), nullptr));
|
||||
}
|
||||
|
||||
case error_handler_t::ignore:
|
||||
@ -557,7 +568,7 @@ class serializer
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -591,9 +602,7 @@ class serializer
|
||||
{
|
||||
case error_handler_t::strict:
|
||||
{
|
||||
std::string sn(3, '\0');
|
||||
(std::snprintf)(&sn[0], sn.size(), "%.2X", static_cast<std::uint8_t>(s.back()));
|
||||
JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + sn));
|
||||
JSON_THROW(type_error::create(316, concat("incomplete UTF-8 string; last byte: 0x", hex_bytes(static_cast<std::uint8_t>(s.back() | 0))), nullptr));
|
||||
}
|
||||
|
||||
case error_handler_t::ignore:
|
||||
@ -620,11 +629,12 @@ class serializer
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
/*!
|
||||
@brief count digits
|
||||
|
||||
@ -659,6 +669,33 @@ class serializer
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief convert a byte to a uppercase hex representation
|
||||
* @param[in] byte byte to represent
|
||||
* @return representation ("00".."FF")
|
||||
*/
|
||||
static std::string hex_bytes(std::uint8_t byte)
|
||||
{
|
||||
std::string result = "FF";
|
||||
constexpr const char* nibble_to_hex = "0123456789ABCDEF";
|
||||
result[0] = nibble_to_hex[byte / 16];
|
||||
result[1] = nibble_to_hex[byte % 16];
|
||||
return result;
|
||||
}
|
||||
|
||||
// templates to avoid warnings about useless casts
|
||||
template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value, int> = 0>
|
||||
bool is_negative_number(NumberType x)
|
||||
{
|
||||
return x < 0;
|
||||
}
|
||||
|
||||
template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value, int > = 0 >
|
||||
bool is_negative_number(NumberType /*unused*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief dump an integer
|
||||
|
||||
@ -669,6 +706,7 @@ class serializer
|
||||
@tparam NumberType either @a number_integer_t or @a number_unsigned_t
|
||||
*/
|
||||
template < typename NumberType, detail::enable_if_t <
|
||||
std::is_integral<NumberType>::value ||
|
||||
std::is_same<NumberType, number_unsigned_t>::value ||
|
||||
std::is_same<NumberType, number_integer_t>::value ||
|
||||
std::is_same<NumberType, binary_char_t>::value,
|
||||
@ -699,14 +737,13 @@ class serializer
|
||||
}
|
||||
|
||||
// use a pointer to fill the buffer
|
||||
auto buffer_ptr = number_buffer.begin();
|
||||
auto buffer_ptr = number_buffer.begin(); // NOLINT(llvm-qualified-auto,readability-qualified-auto,cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
||||
|
||||
const bool is_negative = std::is_same<NumberType, number_integer_t>::value && !(x >= 0); // see issue #755
|
||||
number_unsigned_t abs_value;
|
||||
|
||||
unsigned int n_chars;
|
||||
unsigned int n_chars{};
|
||||
|
||||
if (is_negative)
|
||||
if (is_negative_number(x))
|
||||
{
|
||||
*buffer_ptr = '-';
|
||||
abs_value = remove_sign(static_cast<number_integer_t>(x));
|
||||
@ -723,7 +760,7 @@ class serializer
|
||||
// spare 1 byte for '\0'
|
||||
JSON_ASSERT(n_chars < number_buffer.size() - 1);
|
||||
|
||||
// jump to the end to generate the string from backward
|
||||
// jump to the end to generate the string from backward,
|
||||
// so we later avoid reversing the result
|
||||
buffer_ptr += n_chars;
|
||||
|
||||
@ -782,8 +819,8 @@ class serializer
|
||||
|
||||
void dump_float(number_float_t x, std::true_type /*is_ieee_single_or_double*/)
|
||||
{
|
||||
char* begin = number_buffer.data();
|
||||
char* end = ::nlohmann::detail::to_chars(begin, begin + number_buffer.size(), x);
|
||||
auto* begin = number_buffer.data();
|
||||
auto* end = ::nlohmann::detail::to_chars(begin, begin + number_buffer.size(), x);
|
||||
|
||||
o->write_characters(begin, static_cast<size_t>(end - begin));
|
||||
}
|
||||
@ -794,6 +831,7 @@ class serializer
|
||||
static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
|
||||
|
||||
// the actual conversion
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
||||
std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(), "%.*g", d, x);
|
||||
|
||||
// negative value indicates an error
|
||||
@ -804,8 +842,8 @@ class serializer
|
||||
// erase thousands separator
|
||||
if (thousands_sep != '\0')
|
||||
{
|
||||
const auto end = std::remove(number_buffer.begin(),
|
||||
number_buffer.begin() + len, thousands_sep);
|
||||
// NOLINTNEXTLINE(readability-qualified-auto,llvm-qualified-auto): std::remove returns an iterator, see https://github.com/nlohmann/json/issues/3081
|
||||
const auto end = std::remove(number_buffer.begin(), number_buffer.begin() + len, thousands_sep);
|
||||
std::fill(end, number_buffer.end(), '\0');
|
||||
JSON_ASSERT((end - number_buffer.begin()) <= len);
|
||||
len = (end - number_buffer.begin());
|
||||
@ -814,6 +852,7 @@ class serializer
|
||||
// convert decimal point to '.'
|
||||
if (decimal_point != '\0' && decimal_point != '.')
|
||||
{
|
||||
// NOLINTNEXTLINE(readability-qualified-auto,llvm-qualified-auto): std::find returns an iterator, see https://github.com/nlohmann/json/issues/3081
|
||||
const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
|
||||
if (dec_pos != number_buffer.end())
|
||||
{
|
||||
@ -823,7 +862,7 @@ class serializer
|
||||
|
||||
o->write_characters(number_buffer.data(), static_cast<std::size_t>(len));
|
||||
|
||||
// determine if need to append ".0"
|
||||
// determine if we need to append ".0"
|
||||
const bool value_is_int_like =
|
||||
std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
|
||||
[](char c)
|
||||
@ -880,6 +919,7 @@ class serializer
|
||||
}
|
||||
};
|
||||
|
||||
JSON_ASSERT(byte < utf8d.size());
|
||||
const std::uint8_t type = utf8d[byte];
|
||||
|
||||
codep = (state != UTF8_ACCEPT)
|
||||
@ -899,7 +939,7 @@ class serializer
|
||||
*/
|
||||
number_unsigned_t remove_sign(number_unsigned_t x)
|
||||
{
|
||||
JSON_ASSERT(false); // LCOV_EXCL_LINE
|
||||
JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
|
||||
return x; // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
@ -914,7 +954,7 @@ class serializer
|
||||
*/
|
||||
inline number_unsigned_t remove_sign(number_integer_t x) noexcept
|
||||
{
|
||||
JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
|
||||
JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)()); // NOLINT(misc-redundant-expression)
|
||||
return static_cast<number_unsigned_t>(-(x + 1)) + 1;
|
||||
}
|
||||
|
||||
@ -943,5 +983,6 @@ class serializer
|
||||
/// error_handler how to react on decoding errors
|
||||
const error_handler_t error_handler;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace nlohmann
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
146
external/json/include/nlohmann/detail/string_concat.hpp
vendored
Normal file
146
external/json/include/nlohmann/detail/string_concat.hpp
vendored
Normal file
@ -0,0 +1,146 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstring> // strlen
|
||||
#include <string> // string
|
||||
#include <utility> // forward
|
||||
|
||||
#include <nlohmann/detail/meta/cpp_future.hpp>
|
||||
#include <nlohmann/detail/meta/detected.hpp>
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
inline std::size_t concat_length()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline std::size_t concat_length(const char* cstr, Args&& ... rest);
|
||||
|
||||
template<typename StringType, typename... Args>
|
||||
inline std::size_t concat_length(const StringType& str, Args&& ... rest);
|
||||
|
||||
template<typename... Args>
|
||||
inline std::size_t concat_length(const char /*c*/, Args&& ... rest)
|
||||
{
|
||||
return 1 + concat_length(std::forward<Args>(rest)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline std::size_t concat_length(const char* cstr, Args&& ... rest)
|
||||
{
|
||||
// cppcheck-suppress ignoredReturnValue
|
||||
return ::strlen(cstr) + concat_length(std::forward<Args>(rest)...);
|
||||
}
|
||||
|
||||
template<typename StringType, typename... Args>
|
||||
inline std::size_t concat_length(const StringType& str, Args&& ... rest)
|
||||
{
|
||||
return str.size() + concat_length(std::forward<Args>(rest)...);
|
||||
}
|
||||
|
||||
template<typename OutStringType>
|
||||
inline void concat_into(OutStringType& /*out*/)
|
||||
{}
|
||||
|
||||
template<typename StringType, typename Arg>
|
||||
using string_can_append = decltype(std::declval<StringType&>().append(std::declval < Arg && > ()));
|
||||
|
||||
template<typename StringType, typename Arg>
|
||||
using detect_string_can_append = is_detected<string_can_append, StringType, Arg>;
|
||||
|
||||
template<typename StringType, typename Arg>
|
||||
using string_can_append_op = decltype(std::declval<StringType&>() += std::declval < Arg && > ());
|
||||
|
||||
template<typename StringType, typename Arg>
|
||||
using detect_string_can_append_op = is_detected<string_can_append_op, StringType, Arg>;
|
||||
|
||||
template<typename StringType, typename Arg>
|
||||
using string_can_append_iter = decltype(std::declval<StringType&>().append(std::declval<const Arg&>().begin(), std::declval<const Arg&>().end()));
|
||||
|
||||
template<typename StringType, typename Arg>
|
||||
using detect_string_can_append_iter = is_detected<string_can_append_iter, StringType, Arg>;
|
||||
|
||||
template<typename StringType, typename Arg>
|
||||
using string_can_append_data = decltype(std::declval<StringType&>().append(std::declval<const Arg&>().data(), std::declval<const Arg&>().size()));
|
||||
|
||||
template<typename StringType, typename Arg>
|
||||
using detect_string_can_append_data = is_detected<string_can_append_data, StringType, Arg>;
|
||||
|
||||
template < typename OutStringType, typename Arg, typename... Args,
|
||||
enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
|
||||
&& detect_string_can_append_op<OutStringType, Arg>::value, int > = 0 >
|
||||
inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest);
|
||||
|
||||
template < typename OutStringType, typename Arg, typename... Args,
|
||||
enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
|
||||
&& !detect_string_can_append_op<OutStringType, Arg>::value
|
||||
&& detect_string_can_append_iter<OutStringType, Arg>::value, int > = 0 >
|
||||
inline void concat_into(OutStringType& out, const Arg& arg, Args && ... rest);
|
||||
|
||||
template < typename OutStringType, typename Arg, typename... Args,
|
||||
enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
|
||||
&& !detect_string_can_append_op<OutStringType, Arg>::value
|
||||
&& !detect_string_can_append_iter<OutStringType, Arg>::value
|
||||
&& detect_string_can_append_data<OutStringType, Arg>::value, int > = 0 >
|
||||
inline void concat_into(OutStringType& out, const Arg& arg, Args && ... rest);
|
||||
|
||||
template<typename OutStringType, typename Arg, typename... Args,
|
||||
enable_if_t<detect_string_can_append<OutStringType, Arg>::value, int> = 0>
|
||||
inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest)
|
||||
{
|
||||
out.append(std::forward<Arg>(arg));
|
||||
concat_into(out, std::forward<Args>(rest)...);
|
||||
}
|
||||
|
||||
template < typename OutStringType, typename Arg, typename... Args,
|
||||
enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
|
||||
&& detect_string_can_append_op<OutStringType, Arg>::value, int > >
|
||||
inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
|
||||
{
|
||||
out += std::forward<Arg>(arg);
|
||||
concat_into(out, std::forward<Args>(rest)...);
|
||||
}
|
||||
|
||||
template < typename OutStringType, typename Arg, typename... Args,
|
||||
enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
|
||||
&& !detect_string_can_append_op<OutStringType, Arg>::value
|
||||
&& detect_string_can_append_iter<OutStringType, Arg>::value, int > >
|
||||
inline void concat_into(OutStringType& out, const Arg& arg, Args&& ... rest)
|
||||
{
|
||||
out.append(arg.begin(), arg.end());
|
||||
concat_into(out, std::forward<Args>(rest)...);
|
||||
}
|
||||
|
||||
template < typename OutStringType, typename Arg, typename... Args,
|
||||
enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
|
||||
&& !detect_string_can_append_op<OutStringType, Arg>::value
|
||||
&& !detect_string_can_append_iter<OutStringType, Arg>::value
|
||||
&& detect_string_can_append_data<OutStringType, Arg>::value, int > >
|
||||
inline void concat_into(OutStringType& out, const Arg& arg, Args&& ... rest)
|
||||
{
|
||||
out.append(arg.data(), arg.size());
|
||||
concat_into(out, std::forward<Args>(rest)...);
|
||||
}
|
||||
|
||||
template<typename OutStringType = std::string, typename... Args>
|
||||
inline OutStringType concat(Args && ... args)
|
||||
{
|
||||
OutStringType str;
|
||||
str.reserve(concat_length(std::forward<Args>(args)...));
|
||||
concat_into(str, std::forward<Args>(args)...);
|
||||
return str;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
72
external/json/include/nlohmann/detail/string_escape.hpp
vendored
Normal file
72
external/json/include/nlohmann/detail/string_escape.hpp
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/detail/abi_macros.hpp>
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
/*!
|
||||
@brief replace all occurrences of a substring by another string
|
||||
|
||||
@param[in,out] s the string to manipulate; changed so that all
|
||||
occurrences of @a f are replaced with @a t
|
||||
@param[in] f the substring to replace with @a t
|
||||
@param[in] t the string to replace @a f
|
||||
|
||||
@pre The search string @a f must not be empty. **This precondition is
|
||||
enforced with an assertion.**
|
||||
|
||||
@since version 2.0.0
|
||||
*/
|
||||
template<typename StringType>
|
||||
inline void replace_substring(StringType& s, const StringType& f,
|
||||
const StringType& t)
|
||||
{
|
||||
JSON_ASSERT(!f.empty());
|
||||
for (auto pos = s.find(f); // find first occurrence of f
|
||||
pos != StringType::npos; // make sure f was found
|
||||
s.replace(pos, f.size(), t), // replace with t, and
|
||||
pos = s.find(f, pos + t.size())) // find next occurrence of f
|
||||
{}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief string escaping as described in RFC 6901 (Sect. 4)
|
||||
* @param[in] s string to escape
|
||||
* @return escaped string
|
||||
*
|
||||
* Note the order of escaping "~" to "~0" and "/" to "~1" is important.
|
||||
*/
|
||||
template<typename StringType>
|
||||
inline StringType escape(StringType s)
|
||||
{
|
||||
replace_substring(s, StringType{"~"}, StringType{"~0"});
|
||||
replace_substring(s, StringType{"/"}, StringType{"~1"});
|
||||
return s;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief string unescaping as described in RFC 6901 (Sect. 4)
|
||||
* @param[in] s string to unescape
|
||||
* @return unescaped string
|
||||
*
|
||||
* Note the order of escaping "~1" to "/" and "~0" to "~" is important.
|
||||
*/
|
||||
template<typename StringType>
|
||||
static void unescape(StringType& s)
|
||||
{
|
||||
replace_substring(s, StringType{"~1"}, StringType{"/"});
|
||||
replace_substring(s, StringType{"~0"}, StringType{"~"});
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
@ -1,3 +1,11 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array> // array
|
||||
@ -5,10 +13,15 @@
|
||||
#include <cstdint> // uint8_t
|
||||
#include <string> // string
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
#if JSON_HAS_THREE_WAY_COMPARISON
|
||||
#include <compare> // partial_ordering
|
||||
#endif
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
///////////////////////////
|
||||
// JSON type enumeration //
|
||||
///////////////////////////
|
||||
@ -32,7 +45,7 @@ number_float), because the library distinguishes these three types for numbers:
|
||||
@ref basic_json::number_float_t is used for floating-point numbers or to
|
||||
approximate integers which do not fit in the limits of their respective type.
|
||||
|
||||
@sa @ref basic_json::basic_json(const value_t value_type) -- create a JSON
|
||||
@sa see @ref basic_json::basic_json(const value_t value_type) -- create a JSON
|
||||
value with the default value for a given type
|
||||
|
||||
@since version 1.0.0
|
||||
@ -64,7 +77,11 @@ Returns an ordering that is similar to Python:
|
||||
|
||||
@since version 1.0.0
|
||||
*/
|
||||
inline bool operator<(const value_t lhs, const value_t rhs) noexcept
|
||||
#if JSON_HAS_THREE_WAY_COMPARISON
|
||||
inline std::partial_ordering operator<=>(const value_t lhs, const value_t rhs) noexcept // *NOPAD*
|
||||
#else
|
||||
inline bool operator<(const value_t lhs, const value_t rhs) noexcept
|
||||
#endif
|
||||
{
|
||||
static constexpr std::array<std::uint8_t, 9> order = {{
|
||||
0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */,
|
||||
@ -75,7 +92,27 @@ inline bool operator<(const value_t lhs, const value_t rhs) noexcept
|
||||
|
||||
const auto l_index = static_cast<std::size_t>(lhs);
|
||||
const auto r_index = static_cast<std::size_t>(rhs);
|
||||
#if JSON_HAS_THREE_WAY_COMPARISON
|
||||
if (l_index < order.size() && r_index < order.size())
|
||||
{
|
||||
return order[l_index] <=> order[r_index]; // *NOPAD*
|
||||
}
|
||||
return std::partial_ordering::unordered;
|
||||
#else
|
||||
return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
|
||||
#endif
|
||||
}
|
||||
|
||||
// GCC selects the built-in operator< over an operator rewritten from
|
||||
// a user-defined spaceship operator
|
||||
// Clang, MSVC, and ICC select the rewritten candidate
|
||||
// (see GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105200)
|
||||
#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__)
|
||||
inline bool operator<(const value_t lhs, const value_t rhs) noexcept
|
||||
{
|
||||
return std::is_lt(lhs <=> rhs); // *NOPAD*
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
} // namespace nlohmann
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
7066
external/json/include/nlohmann/json.hpp
vendored
7066
external/json/include/nlohmann/json.hpp
vendored
File diff suppressed because it is too large
Load Diff
50
external/json/include/nlohmann/json_fwd.hpp
vendored
50
external/json/include/nlohmann/json_fwd.hpp
vendored
@ -1,3 +1,11 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
|
||||
#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
|
||||
|
||||
@ -7,13 +15,15 @@
|
||||
#include <string> // string
|
||||
#include <vector> // vector
|
||||
|
||||
#include <nlohmann/detail/abi_macros.hpp>
|
||||
|
||||
/*!
|
||||
@brief namespace for Niels Lohmann
|
||||
@see https://github.com/nlohmann
|
||||
@since version 1.0.0
|
||||
*/
|
||||
namespace nlohmann
|
||||
{
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
|
||||
/*!
|
||||
@brief default JSONSerializer template argument
|
||||
|
||||
@ -24,6 +34,8 @@ for serialization.
|
||||
template<typename T = void, typename SFINAE = void>
|
||||
struct adl_serializer;
|
||||
|
||||
/// a class to store JSON values
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/
|
||||
template<template<typename U, typename V, typename... Args> class ObjectType =
|
||||
std::map,
|
||||
template<typename U, typename... Args> class ArrayType = std::vector,
|
||||
@ -37,42 +49,26 @@ template<template<typename U, typename V, typename... Args> class ObjectType =
|
||||
class BinaryType = std::vector<std::uint8_t>>
|
||||
class basic_json;
|
||||
|
||||
/*!
|
||||
@brief 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` and
|
||||
`operator[]`. Furthermore, JSON pointers are the base for JSON patches.
|
||||
|
||||
@sa [RFC 6901](https://tools.ietf.org/html/rfc6901)
|
||||
|
||||
@since version 2.0.0
|
||||
*/
|
||||
/// @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<typename BasicJsonType>
|
||||
class json_pointer;
|
||||
|
||||
/*!
|
||||
@brief default JSON class
|
||||
|
||||
This type is the default specialization of the @ref basic_json class which
|
||||
uses the standard template types.
|
||||
|
||||
@since version 1.0.0
|
||||
@brief default specialization
|
||||
@sa https://json.nlohmann.me/api/json/
|
||||
*/
|
||||
using json = basic_json<>;
|
||||
|
||||
/// @brief a minimal map-like container that preserves insertion order
|
||||
/// @sa https://json.nlohmann.me/api/ordered_map/
|
||||
template<class Key, class T, class IgnoredLess, class Allocator>
|
||||
struct ordered_map;
|
||||
|
||||
/*!
|
||||
@brief ordered JSON class
|
||||
|
||||
This type preserves the insertion order of object keys.
|
||||
|
||||
@since version 3.9.0
|
||||
*/
|
||||
/// @brief specialization that maintains the insertion order of object keys
|
||||
/// @sa https://json.nlohmann.me/api/ordered_json/
|
||||
using ordered_json = basic_json<nlohmann::ordered_map>;
|
||||
|
||||
} // namespace nlohmann
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
||||
#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_
|
||||
|
268
external/json/include/nlohmann/ordered_map.hpp
vendored
268
external/json/include/nlohmann/ordered_map.hpp
vendored
@ -1,12 +1,26 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <functional> // less
|
||||
#include <functional> // equal_to, less
|
||||
#include <initializer_list> // initializer_list
|
||||
#include <iterator> // input_iterator_tag, iterator_traits
|
||||
#include <memory> // allocator
|
||||
#include <stdexcept> // for out_of_range
|
||||
#include <type_traits> // enable_if, is_convertible
|
||||
#include <utility> // pair
|
||||
#include <vector> // vector
|
||||
|
||||
namespace nlohmann
|
||||
{
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
#include <nlohmann/detail/meta/type_traits.hpp>
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
|
||||
/// ordered_map: a minimal map-like container that preserves insertion order
|
||||
/// for use within nlohmann::basic_json<ordered_map>
|
||||
@ -17,74 +31,160 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
||||
using key_type = Key;
|
||||
using mapped_type = T;
|
||||
using Container = std::vector<std::pair<const Key, T>, Allocator>;
|
||||
using typename Container::iterator;
|
||||
using typename Container::const_iterator;
|
||||
using typename Container::size_type;
|
||||
using typename Container::value_type;
|
||||
using iterator = typename Container::iterator;
|
||||
using const_iterator = typename Container::const_iterator;
|
||||
using size_type = typename Container::size_type;
|
||||
using value_type = typename Container::value_type;
|
||||
#ifdef JSON_HAS_CPP_14
|
||||
using key_compare = std::equal_to<>;
|
||||
#else
|
||||
using key_compare = std::equal_to<Key>;
|
||||
#endif
|
||||
|
||||
// Explicit constructors instead of `using Container::Container`
|
||||
// otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4)
|
||||
ordered_map(const Allocator& alloc = Allocator()) : Container{alloc} {}
|
||||
ordered_map() noexcept(noexcept(Container())) : Container{} {}
|
||||
explicit ordered_map(const Allocator& alloc) noexcept(noexcept(Container(alloc))) : Container{alloc} {}
|
||||
template <class It>
|
||||
ordered_map(It first, It last, const Allocator& alloc = Allocator())
|
||||
: Container{first, last, alloc} {}
|
||||
ordered_map(std::initializer_list<T> init, const Allocator& alloc = Allocator() )
|
||||
ordered_map(std::initializer_list<value_type> init, const Allocator& alloc = Allocator() )
|
||||
: Container{init, alloc} {}
|
||||
|
||||
std::pair<iterator, bool> emplace(const key_type& key, T&& t)
|
||||
{
|
||||
for (auto it = this->begin(); it != this->end(); ++it)
|
||||
{
|
||||
if (it->first == key)
|
||||
if (m_compare(it->first, key))
|
||||
{
|
||||
return {it, false};
|
||||
}
|
||||
}
|
||||
Container::emplace_back(key, t);
|
||||
return {--this->end(), true};
|
||||
Container::emplace_back(key, std::forward<T>(t));
|
||||
return {std::prev(this->end()), true};
|
||||
}
|
||||
|
||||
T& operator[](const Key& key)
|
||||
template<class KeyType, detail::enable_if_t<
|
||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||
std::pair<iterator, bool> emplace(KeyType && key, T && t)
|
||||
{
|
||||
for (auto it = this->begin(); it != this->end(); ++it)
|
||||
{
|
||||
if (m_compare(it->first, key))
|
||||
{
|
||||
return {it, false};
|
||||
}
|
||||
}
|
||||
Container::emplace_back(std::forward<KeyType>(key), std::forward<T>(t));
|
||||
return {std::prev(this->end()), true};
|
||||
}
|
||||
|
||||
T& operator[](const key_type& key)
|
||||
{
|
||||
return emplace(key, T{}).first->second;
|
||||
}
|
||||
|
||||
const T& operator[](const Key& key) const
|
||||
template<class KeyType, detail::enable_if_t<
|
||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||
T & operator[](KeyType && key)
|
||||
{
|
||||
return emplace(std::forward<KeyType>(key), T{}).first->second;
|
||||
}
|
||||
|
||||
const T& operator[](const key_type& key) const
|
||||
{
|
||||
return at(key);
|
||||
}
|
||||
|
||||
T& at(const Key& key)
|
||||
template<class KeyType, detail::enable_if_t<
|
||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||
const T & operator[](KeyType && key) const
|
||||
{
|
||||
return at(std::forward<KeyType>(key));
|
||||
}
|
||||
|
||||
T& at(const key_type& key)
|
||||
{
|
||||
for (auto it = this->begin(); it != this->end(); ++it)
|
||||
{
|
||||
if (it->first == key)
|
||||
if (m_compare(it->first, key))
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
|
||||
throw std::out_of_range("key not found");
|
||||
JSON_THROW(std::out_of_range("key not found"));
|
||||
}
|
||||
|
||||
const T& at(const Key& key) const
|
||||
template<class KeyType, detail::enable_if_t<
|
||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||
T & at(KeyType && key)
|
||||
{
|
||||
for (auto it = this->begin(); it != this->end(); ++it)
|
||||
{
|
||||
if (it->first == key)
|
||||
if (m_compare(it->first, key))
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
|
||||
throw std::out_of_range("key not found");
|
||||
JSON_THROW(std::out_of_range("key not found"));
|
||||
}
|
||||
|
||||
size_type erase(const Key& key)
|
||||
const T& at(const key_type& key) const
|
||||
{
|
||||
for (auto it = this->begin(); it != this->end(); ++it)
|
||||
{
|
||||
if (it->first == key)
|
||||
if (m_compare(it->first, key))
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
|
||||
JSON_THROW(std::out_of_range("key not found"));
|
||||
}
|
||||
|
||||
template<class KeyType, detail::enable_if_t<
|
||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||
const T & at(KeyType && key) const
|
||||
{
|
||||
for (auto it = this->begin(); it != this->end(); ++it)
|
||||
{
|
||||
if (m_compare(it->first, key))
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
|
||||
JSON_THROW(std::out_of_range("key not found"));
|
||||
}
|
||||
|
||||
size_type erase(const key_type& key)
|
||||
{
|
||||
for (auto it = this->begin(); it != this->end(); ++it)
|
||||
{
|
||||
if (m_compare(it->first, key))
|
||||
{
|
||||
// Since we cannot move const Keys, re-construct them in place
|
||||
for (auto next = it; ++next != this->end(); ++it)
|
||||
{
|
||||
it->~value_type(); // Destroy but keep allocation
|
||||
new (&*it) value_type{std::move(*next)};
|
||||
}
|
||||
Container::pop_back();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class KeyType, detail::enable_if_t<
|
||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||
size_type erase(KeyType && key)
|
||||
{
|
||||
for (auto it = this->begin(); it != this->end(); ++it)
|
||||
{
|
||||
if (m_compare(it->first, key))
|
||||
{
|
||||
// Since we cannot move const Keys, re-construct them in place
|
||||
for (auto next = it; ++next != this->end(); ++it)
|
||||
@ -101,23 +201,67 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
||||
|
||||
iterator erase(iterator pos)
|
||||
{
|
||||
auto it = pos;
|
||||
|
||||
// Since we cannot move const Keys, re-construct them in place
|
||||
for (auto next = it; ++next != this->end(); ++it)
|
||||
{
|
||||
it->~value_type(); // Destroy but keep allocation
|
||||
new (&*it) value_type{std::move(*next)};
|
||||
}
|
||||
Container::pop_back();
|
||||
return pos;
|
||||
return erase(pos, std::next(pos));
|
||||
}
|
||||
|
||||
size_type count(const Key& key) const
|
||||
iterator erase(iterator first, iterator last)
|
||||
{
|
||||
if (first == last)
|
||||
{
|
||||
return first;
|
||||
}
|
||||
|
||||
const auto elements_affected = std::distance(first, last);
|
||||
const auto offset = std::distance(Container::begin(), first);
|
||||
|
||||
// This is the start situation. We need to delete elements_affected
|
||||
// elements (3 in this example: e, f, g), and need to return an
|
||||
// iterator past the last deleted element (h in this example).
|
||||
// Note that offset is the distance from the start of the vector
|
||||
// to first. We will need this later.
|
||||
|
||||
// [ a, b, c, d, e, f, g, h, i, j ]
|
||||
// ^ ^
|
||||
// first last
|
||||
|
||||
// Since we cannot move const Keys, we re-construct them in place.
|
||||
// We start at first and re-construct (viz. copy) the elements from
|
||||
// the back of the vector. Example for first iteration:
|
||||
|
||||
// ,--------.
|
||||
// v | destroy e and re-construct with h
|
||||
// [ a, b, c, d, e, f, g, h, i, j ]
|
||||
// ^ ^
|
||||
// it it + elements_affected
|
||||
|
||||
for (auto it = first; std::next(it, elements_affected) != Container::end(); ++it)
|
||||
{
|
||||
it->~value_type(); // destroy but keep allocation
|
||||
new (&*it) value_type{std::move(*std::next(it, elements_affected))}; // "move" next element to it
|
||||
}
|
||||
|
||||
// [ a, b, c, d, h, i, j, h, i, j ]
|
||||
// ^ ^
|
||||
// first last
|
||||
|
||||
// remove the unneeded elements at the end of the vector
|
||||
Container::resize(this->size() - static_cast<size_type>(elements_affected));
|
||||
|
||||
// [ a, b, c, d, h, i, j ]
|
||||
// ^ ^
|
||||
// first last
|
||||
|
||||
// first is now pointing past the last deleted element, but we cannot
|
||||
// use this iterator, because it may have been invalidated by the
|
||||
// resize call. Instead, we can return begin() + offset.
|
||||
return Container::begin() + offset;
|
||||
}
|
||||
|
||||
size_type count(const key_type& key) const
|
||||
{
|
||||
for (auto it = this->begin(); it != this->end(); ++it)
|
||||
{
|
||||
if (it->first == key)
|
||||
if (m_compare(it->first, key))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@ -125,11 +269,25 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
||||
return 0;
|
||||
}
|
||||
|
||||
iterator find(const Key& key)
|
||||
template<class KeyType, detail::enable_if_t<
|
||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||
size_type count(KeyType && key) const
|
||||
{
|
||||
for (auto it = this->begin(); it != this->end(); ++it)
|
||||
{
|
||||
if (it->first == key)
|
||||
if (m_compare(it->first, key))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
iterator find(const key_type& key)
|
||||
{
|
||||
for (auto it = this->begin(); it != this->end(); ++it)
|
||||
{
|
||||
if (m_compare(it->first, key))
|
||||
{
|
||||
return it;
|
||||
}
|
||||
@ -137,11 +295,25 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
||||
return Container::end();
|
||||
}
|
||||
|
||||
const_iterator find(const Key& key) const
|
||||
template<class KeyType, detail::enable_if_t<
|
||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||
iterator find(KeyType && key)
|
||||
{
|
||||
for (auto it = this->begin(); it != this->end(); ++it)
|
||||
{
|
||||
if (it->first == key)
|
||||
if (m_compare(it->first, key))
|
||||
{
|
||||
return it;
|
||||
}
|
||||
}
|
||||
return Container::end();
|
||||
}
|
||||
|
||||
const_iterator find(const key_type& key) const
|
||||
{
|
||||
for (auto it = this->begin(); it != this->end(); ++it)
|
||||
{
|
||||
if (m_compare(it->first, key))
|
||||
{
|
||||
return it;
|
||||
}
|
||||
@ -158,7 +330,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
||||
{
|
||||
for (auto it = this->begin(); it != this->end(); ++it)
|
||||
{
|
||||
if (it->first == value.first)
|
||||
if (m_compare(it->first, value.first))
|
||||
{
|
||||
return {it, false};
|
||||
}
|
||||
@ -166,6 +338,22 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
||||
Container::push_back(value);
|
||||
return {--this->end(), true};
|
||||
}
|
||||
|
||||
template<typename InputIt>
|
||||
using require_input_iter = typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
|
||||
std::input_iterator_tag>::value>::type;
|
||||
|
||||
template<typename InputIt, typename = require_input_iter<InputIt>>
|
||||
void insert(InputIt first, InputIt last)
|
||||
{
|
||||
for (auto it = first; it != last; ++it)
|
||||
{
|
||||
insert(*it);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
JSON_NO_UNIQUE_ADDRESS key_compare m_compare = key_compare();
|
||||
};
|
||||
|
||||
} // namespace nlohmann
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
@ -1,20 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-FileCopyrightText: 2016-2021 Evan Nemerson <evan@nemerson.com>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/* Hedley - https://nemequ.github.io/hedley
|
||||
* Created by Evan Nemerson <evan@nemerson.com>
|
||||
*
|
||||
* To the extent possible under law, the author(s) have dedicated all
|
||||
* copyright and related and neighboring rights to this software to
|
||||
* the public domain worldwide. This software is distributed without
|
||||
* any warranty.
|
||||
*
|
||||
* For details, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
* SPDX-License-Identifier: CC0-1.0
|
||||
*/
|
||||
|
||||
#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 13)
|
||||
#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
|
||||
#if defined(JSON_HEDLEY_VERSION)
|
||||
#undef JSON_HEDLEY_VERSION
|
||||
#endif
|
||||
#define JSON_HEDLEY_VERSION 13
|
||||
#define JSON_HEDLEY_VERSION 15
|
||||
|
||||
#if defined(JSON_HEDLEY_STRINGIFY_EX)
|
||||
#undef JSON_HEDLEY_STRINGIFY_EX
|
||||
@ -87,18 +90,18 @@
|
||||
#if defined(JSON_HEDLEY_MSVC_VERSION)
|
||||
#undef JSON_HEDLEY_MSVC_VERSION
|
||||
#endif
|
||||
#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000)
|
||||
#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
|
||||
#define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
|
||||
#elif defined(_MSC_FULL_VER)
|
||||
#elif defined(_MSC_FULL_VER) && !defined(__ICL)
|
||||
#define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
|
||||
#elif defined(_MSC_VER)
|
||||
#elif defined(_MSC_VER) && !defined(__ICL)
|
||||
#define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
|
||||
#undef JSON_HEDLEY_MSVC_VERSION_CHECK
|
||||
#endif
|
||||
#if !defined(_MSC_VER)
|
||||
#if !defined(JSON_HEDLEY_MSVC_VERSION)
|
||||
#define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
|
||||
#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||
#define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
|
||||
@ -111,9 +114,9 @@
|
||||
#if defined(JSON_HEDLEY_INTEL_VERSION)
|
||||
#undef JSON_HEDLEY_INTEL_VERSION
|
||||
#endif
|
||||
#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE)
|
||||
#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
|
||||
#define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
|
||||
#elif defined(__INTEL_COMPILER)
|
||||
#elif defined(__INTEL_COMPILER) && !defined(__ICL)
|
||||
#define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
|
||||
#endif
|
||||
|
||||
@ -126,6 +129,22 @@
|
||||
#define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
|
||||
#undef JSON_HEDLEY_INTEL_CL_VERSION
|
||||
#endif
|
||||
#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
|
||||
#define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
|
||||
#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
|
||||
#endif
|
||||
#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
|
||||
#define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
|
||||
#else
|
||||
#define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_PGI_VERSION)
|
||||
#undef JSON_HEDLEY_PGI_VERSION
|
||||
#endif
|
||||
@ -365,7 +384,7 @@
|
||||
#if __VER__ > 1000
|
||||
#define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
|
||||
#else
|
||||
#define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(VER / 100, __VER__ % 100, 0)
|
||||
#define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -442,6 +461,22 @@
|
||||
#define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
|
||||
#undef JSON_HEDLEY_MCST_LCC_VERSION
|
||||
#endif
|
||||
#if defined(__LCC__) && defined(__LCC_MINOR__)
|
||||
#define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
|
||||
#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
|
||||
#endif
|
||||
#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
|
||||
#define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
|
||||
#else
|
||||
#define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_GCC_VERSION)
|
||||
#undef JSON_HEDLEY_GCC_VERSION
|
||||
#endif
|
||||
@ -451,6 +486,7 @@
|
||||
!defined(JSON_HEDLEY_INTEL_VERSION) && \
|
||||
!defined(JSON_HEDLEY_PGI_VERSION) && \
|
||||
!defined(JSON_HEDLEY_ARM_VERSION) && \
|
||||
!defined(JSON_HEDLEY_CRAY_VERSION) && \
|
||||
!defined(JSON_HEDLEY_TI_VERSION) && \
|
||||
!defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
|
||||
!defined(JSON_HEDLEY_TI_CL430_VERSION) && \
|
||||
@ -458,7 +494,8 @@
|
||||
!defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
|
||||
!defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
|
||||
!defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
|
||||
!defined(__COMPCERT__)
|
||||
!defined(__COMPCERT__) && \
|
||||
!defined(JSON_HEDLEY_MCST_LCC_VERSION)
|
||||
#define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
|
||||
#endif
|
||||
|
||||
@ -474,17 +511,21 @@
|
||||
#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
|
||||
#undef JSON_HEDLEY_HAS_ATTRIBUTE
|
||||
#endif
|
||||
#if defined(__has_attribute)
|
||||
#define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
|
||||
#if \
|
||||
defined(__has_attribute) && \
|
||||
( \
|
||||
(!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
|
||||
)
|
||||
# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
|
||||
#else
|
||||
#define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
|
||||
# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
|
||||
#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
|
||||
#endif
|
||||
#if defined(__has_attribute)
|
||||
#define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute)
|
||||
#define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
|
||||
#else
|
||||
#define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
|
||||
#endif
|
||||
@ -493,7 +534,7 @@
|
||||
#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
|
||||
#endif
|
||||
#if defined(__has_attribute)
|
||||
#define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute)
|
||||
#define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
|
||||
#else
|
||||
#define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
|
||||
#endif
|
||||
@ -678,6 +719,72 @@
|
||||
#define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
|
||||
#endif
|
||||
|
||||
#if \
|
||||
(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
|
||||
defined(__clang__) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
|
||||
JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
|
||||
JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
|
||||
JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
|
||||
(JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
|
||||
#define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
|
||||
#define JSON_HEDLEY_PRAGMA(value) __pragma(value)
|
||||
#else
|
||||
#define JSON_HEDLEY_PRAGMA(value)
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
|
||||
#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
|
||||
#endif
|
||||
#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
|
||||
#undef JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#endif
|
||||
#if defined(__clang__)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
|
||||
#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
|
||||
#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
|
||||
#elif \
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
|
||||
#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
|
||||
#elif \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
|
||||
#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
|
||||
#else
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#endif
|
||||
|
||||
/* JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ is for
|
||||
HEDLEY INTERNAL USE ONLY. API subject to change without notice. */
|
||||
#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
|
||||
@ -686,12 +793,22 @@
|
||||
#if defined(__cplusplus)
|
||||
# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
|
||||
# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
|
||||
# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
|
||||
# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
|
||||
# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
|
||||
JSON_HEDLEY_DIAGNOSTIC_PUSH \
|
||||
_Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
|
||||
_Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
|
||||
_Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
|
||||
xpr \
|
||||
JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
# else
|
||||
# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
|
||||
JSON_HEDLEY_DIAGNOSTIC_PUSH \
|
||||
_Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
|
||||
_Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
|
||||
xpr \
|
||||
JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
# endif
|
||||
# else
|
||||
# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
|
||||
JSON_HEDLEY_DIAGNOSTIC_PUSH \
|
||||
@ -756,7 +873,7 @@
|
||||
# define JSON_HEDLEY_CPP_CAST(T, expr) \
|
||||
JSON_HEDLEY_DIAGNOSTIC_PUSH \
|
||||
_Pragma("diag_suppress=Pe137") \
|
||||
JSON_HEDLEY_DIAGNOSTIC_POP \
|
||||
JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
# else
|
||||
# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
|
||||
# endif
|
||||
@ -764,70 +881,6 @@
|
||||
# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
|
||||
#endif
|
||||
|
||||
#if \
|
||||
(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
|
||||
defined(__clang__) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
|
||||
JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
|
||||
JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
|
||||
JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
|
||||
(JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
|
||||
#define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
|
||||
#define JSON_HEDLEY_PRAGMA(value) __pragma(value)
|
||||
#else
|
||||
#define JSON_HEDLEY_PRAGMA(value)
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
|
||||
#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
|
||||
#endif
|
||||
#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
|
||||
#undef JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#endif
|
||||
#if defined(__clang__)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
|
||||
#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
|
||||
#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
|
||||
#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
|
||||
#elif \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
|
||||
#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
|
||||
#else
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
|
||||
#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
|
||||
#endif
|
||||
@ -835,12 +888,18 @@
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
|
||||
#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
|
||||
#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
|
||||
#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
|
||||
#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
|
||||
#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
|
||||
#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
|
||||
#elif \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
|
||||
(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
@ -873,6 +932,8 @@
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
|
||||
#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
|
||||
#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
|
||||
#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
|
||||
#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
|
||||
@ -889,6 +950,8 @@
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
|
||||
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
|
||||
#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
|
||||
#else
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
|
||||
#endif
|
||||
@ -902,8 +965,12 @@
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
|
||||
#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
|
||||
#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
|
||||
#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
|
||||
#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
|
||||
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
|
||||
@ -915,6 +982,8 @@
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
|
||||
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
|
||||
#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
|
||||
#else
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
|
||||
#endif
|
||||
@ -932,20 +1001,34 @@
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
|
||||
#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
|
||||
#endif
|
||||
#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
|
||||
#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
|
||||
#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
|
||||
#else
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_DEPRECATED)
|
||||
#undef JSON_HEDLEY_DEPRECATED
|
||||
#endif
|
||||
#if defined(JSON_HEDLEY_DEPRECATED_FOR)
|
||||
#undef JSON_HEDLEY_DEPRECATED_FOR
|
||||
#endif
|
||||
#if JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0)
|
||||
#if \
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
|
||||
#define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
|
||||
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
|
||||
#elif defined(__cplusplus) && (__cplusplus >= 201402L)
|
||||
#define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
|
||||
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
|
||||
#elif \
|
||||
JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \
|
||||
(JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
|
||||
@ -955,9 +1038,13 @@
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
|
||||
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
|
||||
#elif defined(__cplusplus) && (__cplusplus >= 201402L)
|
||||
#define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
|
||||
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
|
||||
#elif \
|
||||
JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
|
||||
@ -972,12 +1059,15 @@
|
||||
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
|
||||
JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
|
||||
#define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
|
||||
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
|
||||
#elif \
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
|
||||
JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0)
|
||||
JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
|
||||
#define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
|
||||
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
|
||||
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
|
||||
@ -994,7 +1084,8 @@
|
||||
#if \
|
||||
JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
|
||||
#else
|
||||
#define JSON_HEDLEY_UNAVAILABLE(available_since)
|
||||
@ -1006,13 +1097,7 @@
|
||||
#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
|
||||
#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
|
||||
#endif
|
||||
#if (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
|
||||
#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
|
||||
#elif \
|
||||
#if \
|
||||
JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
@ -1028,9 +1113,16 @@
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
|
||||
(JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
|
||||
#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
|
||||
#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
|
||||
#elif defined(_Check_return_) /* SAL */
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
|
||||
@ -1046,7 +1138,8 @@
|
||||
JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0)
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
|
||||
#else
|
||||
#define JSON_HEDLEY_SENTINEL(position)
|
||||
@ -1057,7 +1150,9 @@
|
||||
#endif
|
||||
#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
|
||||
#define JSON_HEDLEY_NO_RETURN __noreturn
|
||||
#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
|
||||
#elif \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
|
||||
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
|
||||
#define JSON_HEDLEY_NO_RETURN _Noreturn
|
||||
@ -1079,11 +1174,14 @@
|
||||
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
|
||||
JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
|
||||
#define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
|
||||
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
|
||||
#define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0)
|
||||
#elif \
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
|
||||
#define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
|
||||
#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
|
||||
#define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
|
||||
@ -1115,7 +1213,8 @@
|
||||
#endif
|
||||
#if \
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
|
||||
#define JSON_HEDLEY_ASSUME(expr) __assume(expr)
|
||||
#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
|
||||
#define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
|
||||
@ -1133,7 +1232,9 @@
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5)
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
|
||||
JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
|
||||
#elif defined(JSON_HEDLEY_ASSUME)
|
||||
#define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
|
||||
@ -1211,7 +1312,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
|
||||
#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
|
||||
#define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
|
||||
@ -1247,15 +1349,16 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
|
||||
#endif
|
||||
#if \
|
||||
JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0)
|
||||
(JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
|
||||
# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
|
||||
# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
|
||||
# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
|
||||
# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
|
||||
#elif \
|
||||
JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) || \
|
||||
(JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
(JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
|
||||
@ -1269,7 +1372,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
|
||||
JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
|
||||
JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0)
|
||||
JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
|
||||
(((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
|
||||
# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
|
||||
@ -1315,11 +1419,14 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
|
||||
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
|
||||
#define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0)
|
||||
#elif \
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
|
||||
#define JSON_HEDLEY_MALLOC __declspec(restrict)
|
||||
#else
|
||||
#define JSON_HEDLEY_MALLOC
|
||||
@ -1346,7 +1453,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
# define JSON_HEDLEY_PURE __attribute__((__pure__))
|
||||
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
|
||||
# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
|
||||
@ -1382,7 +1490,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#define JSON_HEDLEY_CONST __attribute__((__const__))
|
||||
#elif \
|
||||
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
|
||||
@ -1400,6 +1509,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
|
||||
@ -1409,7 +1519,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
(JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
|
||||
JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
|
||||
defined(__clang__)
|
||||
defined(__clang__) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#define JSON_HEDLEY_RESTRICT __restrict
|
||||
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
|
||||
#define JSON_HEDLEY_RESTRICT _Restrict
|
||||
@ -1430,13 +1541,15 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#define JSON_HEDLEY_INLINE __inline__
|
||||
#elif \
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#define JSON_HEDLEY_INLINE __inline
|
||||
#else
|
||||
#define JSON_HEDLEY_INLINE
|
||||
@ -1462,9 +1575,13 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
|
||||
JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
|
||||
# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0)
|
||||
#elif \
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
|
||||
# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
|
||||
#elif defined(__cplusplus) && \
|
||||
( \
|
||||
@ -1502,9 +1619,13 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
|
||||
JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
|
||||
#define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0)
|
||||
#elif \
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
|
||||
#define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
|
||||
#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
|
||||
#define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
|
||||
@ -1547,7 +1668,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
|
||||
) \
|
||||
)
|
||||
) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
|
||||
# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
|
||||
# else
|
||||
@ -1563,10 +1685,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#if \
|
||||
JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
|
||||
#elif \
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
|
||||
#define JSON_HEDLEY_NO_THROW __declspec(nothrow)
|
||||
#else
|
||||
@ -1578,7 +1702,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#endif
|
||||
#if \
|
||||
JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0)
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
|
||||
#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
|
||||
#define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
|
||||
@ -1595,7 +1720,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#endif
|
||||
#if \
|
||||
JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
|
||||
#elif defined(_Ret_notnull_) /* SAL */
|
||||
#define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
|
||||
@ -1637,7 +1763,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
|
||||
(JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
|
||||
JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0)
|
||||
JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
|
||||
#endif
|
||||
#if !defined(__cplusplus)
|
||||
@ -1661,7 +1788,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
!defined(JSON_HEDLEY_SUNPRO_VERSION) && \
|
||||
!defined(JSON_HEDLEY_PGI_VERSION) && \
|
||||
!defined(JSON_HEDLEY_IAR_VERSION)) || \
|
||||
JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) || \
|
||||
(JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
|
||||
@ -1731,7 +1858,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#if \
|
||||
!defined(__cplusplus) && ( \
|
||||
(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
|
||||
JSON_HEDLEY_HAS_FEATURE(c_static_assert) || \
|
||||
(JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
defined(_Static_assert) \
|
||||
@ -1739,7 +1866,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
|
||||
#elif \
|
||||
(defined(__cplusplus) && (__cplusplus >= 201103L)) || \
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0)
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
|
||||
# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
|
||||
#else
|
||||
# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
|
||||
@ -1799,7 +1927,9 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
|
||||
# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
|
||||
#elif \
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
|
||||
# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
|
||||
#else
|
||||
# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
|
||||
@ -1835,8 +1965,10 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#if defined(JSON_HEDLEY_FLAGS)
|
||||
#undef JSON_HEDLEY_FLAGS
|
||||
#endif
|
||||
#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum)
|
||||
#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
|
||||
#define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
|
||||
#else
|
||||
#define JSON_HEDLEY_FLAGS
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_FLAGS_CAST)
|
||||
@ -1856,7 +1988,9 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#if defined(JSON_HEDLEY_EMPTY_BASES)
|
||||
#undef JSON_HEDLEY_EMPTY_BASES
|
||||
#endif
|
||||
#if JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)
|
||||
#if \
|
||||
(JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
|
||||
#define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
|
||||
#else
|
||||
#define JSON_HEDLEY_EMPTY_BASES
|
||||
|
@ -1,3 +1,13 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.1
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#undef JSON_HEDLEY_ALWAYS_INLINE
|
||||
#undef JSON_HEDLEY_ARM_VERSION
|
||||
#undef JSON_HEDLEY_ARM_VERSION_CHECK
|
||||
@ -31,6 +41,7 @@
|
||||
#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
|
||||
#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
|
||||
#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
|
||||
#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
|
||||
#undef JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
|
||||
#undef JSON_HEDLEY_DMC_VERSION
|
||||
@ -74,12 +85,16 @@
|
||||
#undef JSON_HEDLEY_IBM_VERSION_CHECK
|
||||
#undef JSON_HEDLEY_IMPORT
|
||||
#undef JSON_HEDLEY_INLINE
|
||||
#undef JSON_HEDLEY_INTEL_CL_VERSION
|
||||
#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
|
||||
#undef JSON_HEDLEY_INTEL_VERSION
|
||||
#undef JSON_HEDLEY_INTEL_VERSION_CHECK
|
||||
#undef JSON_HEDLEY_IS_CONSTANT
|
||||
#undef JSON_HEDLEY_IS_CONSTEXPR_
|
||||
#undef JSON_HEDLEY_LIKELY
|
||||
#undef JSON_HEDLEY_MALLOC
|
||||
#undef JSON_HEDLEY_MCST_LCC_VERSION
|
||||
#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
|
||||
#undef JSON_HEDLEY_MESSAGE
|
||||
#undef JSON_HEDLEY_MSVC_VERSION
|
||||
#undef JSON_HEDLEY_MSVC_VERSION_CHECK
|
||||
|
2
external/json/meson.build
vendored
2
external/json/meson.build
vendored
@ -1,6 +1,6 @@
|
||||
project('nlohmann_json',
|
||||
'cpp',
|
||||
version : '3.9.1',
|
||||
version : '3.11.1',
|
||||
license : 'MIT',
|
||||
)
|
||||
|
||||
|
13487
external/json/single_include/nlohmann/json.hpp
vendored
13487
external/json/single_include/nlohmann/json.hpp
vendored
File diff suppressed because it is too large
Load Diff
1
external/physfs
vendored
1
external/physfs
vendored
Submodule external/physfs deleted from 2ba973b677
235
external/physfs/CMakeLists.txt
vendored
Normal file
235
external/physfs/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,235 @@
|
||||
# file taken from offical physfs repo and modified
|
||||
|
||||
|
||||
|
||||
# PhysicsFS; a portable, flexible file i/o abstraction.
|
||||
#
|
||||
# Please see the file LICENSE.txt in the source's root directory.
|
||||
|
||||
# The CMake project file is meant to get this compiling on all sorts of
|
||||
# platforms quickly, and serve as the way Unix platforms and Linux distros
|
||||
# package up official builds, but you don't _need_ to use this; we have
|
||||
# built PhysicsFS to (hopefully) be able to drop into your project and
|
||||
# compile, using preprocessor checks for platform-specific bits instead of
|
||||
# testing in here.
|
||||
|
||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
|
||||
project(PhysicsFS)
|
||||
set(PHYSFS_VERSION 3.1.0)
|
||||
|
||||
# Increment this if/when we break backwards compatibility.
|
||||
set(PHYSFS_SOVERSION 1)
|
||||
|
||||
# I hate that they define "WIN32" ... we're about to move to Win64...I hope!
|
||||
if(WIN32 AND NOT WINDOWS)
|
||||
set(WINDOWS TRUE)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set(PHYSFS_M_SRCS physfs/src/physfs_platform_apple.m)
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
# Don't use -rpath.
|
||||
set(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE)
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "SunPro")
|
||||
add_definitions(-erroff=E_EMPTY_TRANSLATION_UNIT)
|
||||
add_definitions(-xldscope=hidden)
|
||||
endif()
|
||||
|
||||
if(HAIKU)
|
||||
# We add this explicitly, since we don't want CMake to think this
|
||||
# is a C++ project unless we're on Haiku.
|
||||
set(PHYSFS_CPP_SRCS physfs/src/physfs_platform_haiku.cpp)
|
||||
find_library(BE_LIBRARY be)
|
||||
find_library(ROOT_LIBRARY root)
|
||||
set(OPTIONAL_LIBRARY_LIBS ${OPTIONAL_LIBRARY_LIBS} ${BE_LIBRARY} ${ROOT_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" OR CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
|
||||
set(WINRT TRUE)
|
||||
endif()
|
||||
|
||||
if(WINRT)
|
||||
set(PHYSFS_CPP_SRCS physfs/src/physfs_platform_winrt.cpp)
|
||||
endif()
|
||||
|
||||
if(UNIX AND NOT WINDOWS AND NOT APPLE) # (MingW and such might be UNIX _and_ WINDOWS!)
|
||||
find_library(PTHREAD_LIBRARY pthread)
|
||||
if(PTHREAD_LIBRARY)
|
||||
set(OPTIONAL_LIBRARY_LIBS ${OPTIONAL_LIBRARY_LIBS} ${PTHREAD_LIBRARY})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Almost everything is "compiled" here, but things that don't apply to the
|
||||
# build are #ifdef'd out. This is to make it easy to embed PhysicsFS into
|
||||
# another project or bring up a new build system: just compile all the source
|
||||
# code and #define the things you want.
|
||||
set(PHYSFS_SRCS
|
||||
physfs/src/physfs.c
|
||||
physfs/src/physfs_byteorder.c
|
||||
physfs/src/physfs_unicode.c
|
||||
physfs/src/physfs_platform_posix.c
|
||||
physfs/src/physfs_platform_unix.c
|
||||
physfs/src/physfs_platform_windows.c
|
||||
physfs/src/physfs_platform_os2.c
|
||||
physfs/src/physfs_platform_qnx.c
|
||||
physfs/src/physfs_platform_android.c
|
||||
physfs/src/physfs_archiver_dir.c
|
||||
physfs/src/physfs_archiver_unpacked.c
|
||||
physfs/src/physfs_archiver_grp.c
|
||||
physfs/src/physfs_archiver_hog.c
|
||||
physfs/src/physfs_archiver_7z.c
|
||||
physfs/src/physfs_archiver_mvl.c
|
||||
physfs/src/physfs_archiver_qpak.c
|
||||
physfs/src/physfs_archiver_wad.c
|
||||
physfs/src/physfs_archiver_zip.c
|
||||
physfs/src/physfs_archiver_slb.c
|
||||
physfs/src/physfs_archiver_iso9660.c
|
||||
physfs/src/physfs_archiver_vdf.c
|
||||
|
||||
physfs/src/physfs.h
|
||||
physfs/src/physfs_casefolding.h
|
||||
physfs/src/physfs_internal.h
|
||||
physfs/src/physfs_lzmasdk.h
|
||||
physfs/src/physfs_miniz.h
|
||||
physfs/src/physfs_platforms.h
|
||||
|
||||
${PHYSFS_CPP_SRCS}
|
||||
${PHYSFS_M_SRCS}
|
||||
)
|
||||
|
||||
|
||||
# Archivers ...
|
||||
# These are (mostly) on by default now, so these options are only useful for
|
||||
# disabling them.
|
||||
|
||||
option(PHYSFS_ARCHIVE_ZIP "Enable ZIP support" TRUE)
|
||||
if(NOT PHYSFS_ARCHIVE_ZIP)
|
||||
add_definitions(-DPHYSFS_SUPPORTS_ZIP=0)
|
||||
endif()
|
||||
|
||||
option(PHYSFS_ARCHIVE_7Z "Enable 7zip support" TRUE)
|
||||
if(NOT PHYSFS_ARCHIVE_7Z)
|
||||
add_definitions(-DPHYSFS_SUPPORTS_7Z=0)
|
||||
endif()
|
||||
|
||||
option(PHYSFS_ARCHIVE_GRP "Enable Build Engine GRP support" TRUE)
|
||||
if(NOT PHYSFS_ARCHIVE_GRP)
|
||||
add_definitions(-DPHYSFS_SUPPORTS_GRP=0)
|
||||
endif()
|
||||
|
||||
option(PHYSFS_ARCHIVE_WAD "Enable Doom WAD support" TRUE)
|
||||
if(NOT PHYSFS_ARCHIVE_WAD)
|
||||
add_definitions(-DPHYSFS_SUPPORTS_WAD=0)
|
||||
endif()
|
||||
|
||||
option(PHYSFS_ARCHIVE_HOG "Enable Descent I/II HOG support" TRUE)
|
||||
if(NOT PHYSFS_ARCHIVE_HOG)
|
||||
add_definitions(-DPHYSFS_SUPPORTS_HOG=0)
|
||||
endif()
|
||||
|
||||
option(PHYSFS_ARCHIVE_MVL "Enable Descent I/II MVL support" TRUE)
|
||||
if(NOT PHYSFS_ARCHIVE_MVL)
|
||||
add_definitions(-DPHYSFS_SUPPORTS_MVL=0)
|
||||
endif()
|
||||
|
||||
option(PHYSFS_ARCHIVE_QPAK "Enable Quake I/II QPAK support" TRUE)
|
||||
if(NOT PHYSFS_ARCHIVE_QPAK)
|
||||
add_definitions(-DPHYSFS_SUPPORTS_QPAK=0)
|
||||
endif()
|
||||
|
||||
option(PHYSFS_ARCHIVE_SLB "Enable I-War / Independence War SLB support" TRUE)
|
||||
if(NOT PHYSFS_ARCHIVE_SLB)
|
||||
add_definitions(-DPHYSFS_SUPPORTS_SLB=0)
|
||||
endif()
|
||||
|
||||
option(PHYSFS_ARCHIVE_ISO9660 "Enable ISO9660 support" TRUE)
|
||||
if(NOT PHYSFS_ARCHIVE_ISO9660)
|
||||
add_definitions(-DPHYSFS_SUPPORTS_ISO9660=0)
|
||||
endif()
|
||||
|
||||
option(PHYSFS_ARCHIVE_VDF "Enable Gothic I/II VDF archive support" TRUE)
|
||||
if(NOT PHYSFS_ARCHIVE_VDF)
|
||||
add_definitions(-DPHYSFS_SUPPORTS_VDF=0)
|
||||
endif()
|
||||
|
||||
|
||||
option(PHYSFS_BUILD_STATIC "Build static library" TRUE)
|
||||
if(PHYSFS_BUILD_STATIC)
|
||||
add_library(physfs-static STATIC ${PHYSFS_SRCS})
|
||||
# Don't rename this on Windows, since DLLs will also produce an import
|
||||
# library named "physfs.lib" which would conflict; Unix tend to like the
|
||||
# same library name with a different extension for static libs, but
|
||||
# Windows can just have a separate name.
|
||||
if(NOT MSVC)
|
||||
set_target_properties(physfs-static PROPERTIES OUTPUT_NAME "physfs")
|
||||
endif()
|
||||
if(WINRT)
|
||||
# Ignore LNK4264 warnings; we don't author any WinRT components, just consume them, so we're okay in a static library.
|
||||
set_target_properties(physfs-static PROPERTIES VS_WINRT_COMPONENT True)
|
||||
set_target_properties(physfs-static PROPERTIES STATIC_LIBRARY_FLAGS "/ignore:4264")
|
||||
endif()
|
||||
if(APPLE)
|
||||
target_link_libraries(physfs-static PUBLIC "-framework IOKit")
|
||||
target_link_libraries(physfs-static PUBLIC "-framework Foundation") # do i need this?
|
||||
endif()
|
||||
|
||||
target_include_directories(physfs-static PUBLIC "physfs/src")
|
||||
|
||||
set(PHYSFS_LIB_TARGET physfs-static)
|
||||
set(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";physfs-static")
|
||||
endif()
|
||||
|
||||
if(NOT PHYSFS_BUILD_STATIC)
|
||||
message(FATAL "static libraries are disabled!")
|
||||
endif()
|
||||
|
||||
# CMake FAQ says I need this...
|
||||
if(PHYSFS_BUILD_STATIC AND NOT WINDOWS)
|
||||
set_target_properties(physfs-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
|
||||
endif()
|
||||
|
||||
if(NOT MSVC)
|
||||
configure_file(
|
||||
"physfs/extras/physfs.pc.in"
|
||||
"physfs/extras/physfs.pc"
|
||||
@ONLY
|
||||
)
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/extras/physfs.pc"
|
||||
DESTINATION "lib${LIB_SUFFIX}/pkgconfig"
|
||||
)
|
||||
endif()
|
||||
|
||||
macro(message_bool_option _NAME _VALUE)
|
||||
if(${_VALUE})
|
||||
message(STATUS " ${_NAME}: enabled")
|
||||
else()
|
||||
message(STATUS " ${_NAME}: disabled")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
message(STATUS "PhysicsFS will build with the following options:")
|
||||
message_bool_option("ZIP support" PHYSFS_ARCHIVE_ZIP)
|
||||
message_bool_option("7zip support" PHYSFS_ARCHIVE_7Z)
|
||||
message_bool_option("GRP support" PHYSFS_ARCHIVE_GRP)
|
||||
message_bool_option("WAD support" PHYSFS_ARCHIVE_WAD)
|
||||
message_bool_option("HOG support" PHYSFS_ARCHIVE_HOG)
|
||||
message_bool_option("MVL support" PHYSFS_ARCHIVE_MVL)
|
||||
message_bool_option("QPAK support" PHYSFS_ARCHIVE_QPAK)
|
||||
message_bool_option("SLB support" PHYSFS_ARCHIVE_SLB)
|
||||
message_bool_option("VDF support" PHYSFS_ARCHIVE_VDF)
|
||||
message_bool_option("ISO9660 support" PHYSFS_ARCHIVE_ISO9660)
|
||||
message_bool_option("Build static library" PHYSFS_BUILD_STATIC)
|
||||
message_bool_option("Build shared library" PHYSFS_BUILD_SHARED)
|
||||
message_bool_option("Build stdio test program" PHYSFS_BUILD_TEST)
|
||||
if(PHYSFS_BUILD_TEST)
|
||||
message_bool_option(" Use readline in test program" HAVE_SYSTEM_READLINE)
|
||||
endif()
|
||||
|
||||
# end of CMakeLists.txt ...
|
||||
|
1
external/physfs/physfs
vendored
Submodule
1
external/physfs/physfs
vendored
Submodule
Submodule external/physfs/physfs added at a0dfe220ff
9
external/soloud/CMakeLists.txt
vendored
9
external/soloud/CMakeLists.txt
vendored
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
|
||||
project(soloud CXX)
|
||||
|
||||
@ -32,9 +32,9 @@ set(CPP_FILES
|
||||
#soloud/src/backend/openal/soloud_openal.cpp
|
||||
#soloud/src/backend/openal/soloud_openal_dll.c
|
||||
soloud/src/backend/opensles/soloud_opensles.cpp
|
||||
soloud/src/backend/oss/soloud_oss.cpp
|
||||
soloud/src/backend/portaudio/soloud_portaudio.cpp
|
||||
soloud/src/backend/portaudio/soloud_portaudio_dll.c
|
||||
#soloud/src/backend/oss/soloud_oss.cpp
|
||||
#soloud/src/backend/portaudio/soloud_portaudio.cpp
|
||||
#soloud/src/backend/portaudio/soloud_portaudio_dll.c
|
||||
#soloud/src/backend/sdl/soloud_sdl1.cpp
|
||||
#soloud/src/backend/sdl/soloud_sdl1_dll.c
|
||||
#soloud/src/backend/sdl/soloud_sdl2.cpp
|
||||
@ -160,7 +160,6 @@ target_compile_definitions(soloud PRIVATE WITH_NULL)
|
||||
target_compile_definitions(soloud PRIVATE WITH_SDL2_STATIC)
|
||||
|
||||
target_include_directories(soloud SYSTEM PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/soloud/include")
|
||||
#target_include_directories(soloud PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/imgui")
|
||||
|
||||
#if not android or emscripten
|
||||
if(VCPKG_TARGET_TRIPLET)
|
||||
|
2
external/spdlog
vendored
2
external/spdlog
vendored
Submodule external/spdlog updated: de0dbfa359...76fb40d954
7
external/stb/CMakeLists.txt
vendored
7
external/stb/CMakeLists.txt
vendored
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
|
||||
project(stb CXX)
|
||||
|
||||
@ -11,8 +11,9 @@ target_link_libraries(stb_image stb)
|
||||
add_library(stb_image_write "stb/stb_image_write.h" "stb_image_write.cpp")
|
||||
target_link_libraries(stb_image_write stb)
|
||||
|
||||
add_library(stb_perlin "stb/stb_perlin.h" "stb_perlin.cpp")
|
||||
target_link_libraries(stb_perlin stb)
|
||||
# lel TODO: add back in when patent expires
|
||||
#add_library(stb_perlin "stb/stb_perlin.h" "stb_perlin.cpp")
|
||||
#target_link_libraries(stb_perlin stb)
|
||||
|
||||
add_library(stb_rect_pack "stb/stb_rect_pack.h" "stb_rect_pack.cpp")
|
||||
target_link_libraries(stb_rect_pack stb)
|
||||
|
2
external/stb/stb
vendored
2
external/stb/stb
vendored
Submodule external/stb/stb updated: 3a1174060a...af1a5bc352
53
external/tracy/CMakeLists.txt
vendored
53
external/tracy/CMakeLists.txt
vendored
@ -1,29 +1,38 @@
|
||||
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
|
||||
add_library(tracy_client
|
||||
"${CMAKE_CURRENT_LIST_DIR}/tracy/Tracy.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/tracy/TracyLua.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/tracy/TracyVulkan.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/tracy/TracyOpenGL.hpp"
|
||||
if(NOT EMSCRIPTEN)
|
||||
add_library(tracy_client
|
||||
"${CMAKE_CURRENT_LIST_DIR}/tracy/Tracy.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/tracy/TracyLua.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/tracy/TracyVulkan.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/tracy/TracyOpenGL.hpp"
|
||||
|
||||
"${CMAKE_CURRENT_LIST_DIR}/tracy/TracyClient.cpp"
|
||||
)
|
||||
"${CMAKE_CURRENT_LIST_DIR}/tracy/TracyClient.cpp"
|
||||
)
|
||||
|
||||
target_compile_features(tracy_client PUBLIC cxx_std_17)
|
||||
if(TRACY_ENABLE)
|
||||
target_compile_definitions(tracy_client PUBLIC TRACY_ENABLE)
|
||||
#target_compile_definitions(tracy_client PUBLIC TRACY_NO_SYSTEM_TRACING)
|
||||
message("Enabled TRACY")
|
||||
endif()
|
||||
|
||||
if(TRACY_ENABLE)
|
||||
target_compile_definitions(tracy_client PUBLIC TRACY_ENABLE)
|
||||
#target_compile_definitions(tracy_client PUBLIC TRACY_NO_SYSTEM_TRACING)
|
||||
message("Enabled TRACY")
|
||||
target_compile_features(tracy_client PUBLIC cxx_std_17)
|
||||
|
||||
target_include_directories(tracy_client PUBLIC "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
if(UNIX)
|
||||
target_link_libraries(tracy_client dl)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(tracy_client ws2_32 dbghelp)
|
||||
endif()
|
||||
else() # EMSCRIPTEN
|
||||
add_library(tracy_client INTERFACE)
|
||||
|
||||
target_compile_features(tracy_client INTERFACE cxx_std_17)
|
||||
|
||||
target_include_directories(tracy_client INTERFACE "${CMAKE_CURRENT_LIST_DIR}")
|
||||
endif()
|
||||
|
||||
target_include_directories(tracy_client PUBLIC "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
if(UNIX)
|
||||
target_link_libraries(tracy_client dl)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(tracy_client ws2_32 dbghelp)
|
||||
endif()
|
||||
|
||||
|
2
external/tracy/tracy
vendored
2
external/tracy/tracy
vendored
Submodule external/tracy/tracy updated: f4186d51d4...9ba7171c3d
@ -1,5 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(framework CXX)
|
||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
|
||||
project(framework)
|
||||
|
||||
add_subdirectory(engine)
|
||||
add_subdirectory(logger)
|
||||
@ -9,7 +10,6 @@ add_subdirectory(std_utils)
|
||||
add_subdirectory(random)
|
||||
add_subdirectory(screen_director)
|
||||
add_subdirectory(filesystem)
|
||||
add_subdirectory(simple_scene)
|
||||
add_subdirectory(organizer_scene)
|
||||
|
||||
if(NOT MM_HEADLESS)
|
||||
@ -17,6 +17,7 @@ if(NOT MM_HEADLESS)
|
||||
add_subdirectory(simple_sdl_renderer)
|
||||
add_subdirectory(opengl_primitives)
|
||||
add_subdirectory(opengl_renderer)
|
||||
add_subdirectory(vulkan_renderer)
|
||||
add_subdirectory(imgui)
|
||||
add_subdirectory(input)
|
||||
add_subdirectory(sound)
|
||||
|
@ -1,4 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
|
||||
project(common_components CXX)
|
||||
|
||||
add_library(common_components INTERFACE)
|
||||
|
12
framework/common_components/src/mm/components/position2d.hpp
Normal file
12
framework/common_components/src/mm/components/position2d.hpp
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <glm/vec2.hpp>
|
||||
|
||||
namespace MM::Components {
|
||||
|
||||
struct Position2D {
|
||||
glm::vec2 pos {0.f, 0.f};
|
||||
};
|
||||
|
||||
} // MM::Components
|
||||
|
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
namespace MM::Components {
|
||||
|
||||
// used to lift 2D into 3D space. like a z-index in css/svg
|
||||
struct Position2D_ZOffset {
|
||||
float z_offset = 500.f; // default camera allows values to be between 0 and 1000
|
||||
};
|
||||
|
||||
} // MM::Components
|
||||
|
12
framework/common_components/src/mm/components/position3d.hpp
Normal file
12
framework/common_components/src/mm/components/position3d.hpp
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
namespace MM::Components {
|
||||
|
||||
struct Position3D {
|
||||
glm::vec3 pos {0.f, 0.f, 0.f};
|
||||
};
|
||||
|
||||
} // MM::Components
|
||||
|
10
framework/common_components/src/mm/components/rotation2d.hpp
Normal file
10
framework/common_components/src/mm/components/rotation2d.hpp
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
namespace MM::Components {
|
||||
|
||||
struct Rotation2D {
|
||||
float rot {0.f};
|
||||
};
|
||||
|
||||
} // MM::Components
|
||||
|
12
framework/common_components/src/mm/components/scale2d.hpp
Normal file
12
framework/common_components/src/mm/components/scale2d.hpp
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <glm/vec2.hpp>
|
||||
|
||||
namespace MM::Components {
|
||||
|
||||
struct Scale2D {
|
||||
glm::vec2 scale {1.f, 1.f};
|
||||
};
|
||||
|
||||
} // MM::Components
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/vec4.hpp>
|
||||
#include <glm/mat4x4.hpp>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
@ -12,5 +13,26 @@ namespace glm {
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(vec3, x, y, z)
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(vec4, x, y, z, w)
|
||||
|
||||
//NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(mat4x4, [0], y, z, w)
|
||||
inline void to_json(nlohmann::json& nlohmann_json_j, const mat4x4& nlohmann_json_t) {
|
||||
// TODO: make 2d array?
|
||||
nlohmann_json_j = nlohmann::json::array_t{};
|
||||
nlohmann_json_j[0] = nlohmann_json_t[0];
|
||||
nlohmann_json_j[1] = nlohmann_json_t[1];
|
||||
nlohmann_json_j[2] = nlohmann_json_t[2];
|
||||
nlohmann_json_j[3] = nlohmann_json_t[3];
|
||||
}
|
||||
inline void from_json(const nlohmann::json& nlohmann_json_j, mat4x4& nlohmann_json_t) {
|
||||
if (!nlohmann_json_j.is_array()) {
|
||||
//throw nlohmann::json::type_error::create(0, "", nlohmann_json_j);
|
||||
assert(false && "expected array");
|
||||
return; // TODO: dont fail silently
|
||||
}
|
||||
|
||||
nlohmann_json_j.at(0).get_to(nlohmann_json_t[0]);
|
||||
nlohmann_json_j.at(1).get_to(nlohmann_json_t[1]);
|
||||
nlohmann_json_j.at(2).get_to(nlohmann_json_t[2]);
|
||||
nlohmann_json_j.at(3).get_to(nlohmann_json_t[3]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <mm/components/velocity3d.hpp>
|
||||
#include <mm/components/position2d.hpp>
|
||||
|
||||
#include "./json_glm.hpp"
|
||||
|
||||
namespace MM::Components {
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity3D, velocity, rotation)
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Position2D, pos)
|
||||
} // MM::Components
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <mm/components/transform2d.hpp>
|
||||
#include <mm/components/position2d_zoffset.hpp>
|
||||
|
||||
#include "./json_glm.hpp"
|
||||
|
||||
namespace MM::Components {
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Transform2D, position, scale, rotation)
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Position2D_ZOffset, z_offset)
|
||||
} // MM::Components
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <mm/components/velocity2d.hpp>
|
||||
#include <mm/components/position3d.hpp>
|
||||
|
||||
#include "./json_glm.hpp"
|
||||
|
||||
namespace MM::Components {
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity2D, velocity, rotation)
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Position3D, pos)
|
||||
} // MM::Components
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <mm/components/transform3d.hpp>
|
||||
#include <mm/components/rotation2d.hpp>
|
||||
|
||||
#include "./json_glm.hpp"
|
||||
|
||||
namespace MM::Components {
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Transform3D, position, scale, rotation)
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Rotation2D, rot)
|
||||
} // MM::Components
|
||||
|
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <mm/components/scale2d.hpp>
|
||||
|
||||
#include "./json_glm.hpp"
|
||||
|
||||
namespace MM::Components {
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Scale2D, scale)
|
||||
} // MM::Components
|
||||
|
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <mm/components/transform4x4.hpp>
|
||||
|
||||
#include "./json_glm.hpp"
|
||||
|
||||
namespace MM::Components {
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Transform4x4, trans)
|
||||
} // MM::Components
|
||||
|
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <mm/components/velocity2d_position.hpp>
|
||||
|
||||
#include "./json_glm.hpp"
|
||||
|
||||
namespace MM::Components {
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity2DPosition, pos_vel)
|
||||
} // MM::Components
|
||||
|
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <mm/components/velocity2d_position_intent.hpp>
|
||||
|
||||
#include "./json_glm.hpp"
|
||||
|
||||
namespace MM::Components {
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity2DPositionIntent, intent)
|
||||
} // MM::Components
|
||||
|
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <mm/components/velocity2d_rotation.hpp>
|
||||
|
||||
#include "./json_glm.hpp"
|
||||
|
||||
namespace MM::Components {
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity2DRotation, rot_vel)
|
||||
} // MM::Components
|
||||
|
@ -1,55 +0,0 @@
|
||||
//
|
||||
// Created by FlaXxy on 29.07.2018.
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/mat3x3.hpp>
|
||||
#include <glm/mat4x4.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
namespace MM::Components {
|
||||
|
||||
struct Transform2D {
|
||||
glm::vec2 position {0.0f,0.0f};
|
||||
glm::vec2 scale {1.0f,1.0f};
|
||||
float rotation {0.0f};
|
||||
|
||||
glm::mat3x3 getTransform3(void) const {
|
||||
//return transformationMatrix(scale, rotation, position);
|
||||
glm::mat3x3 res(1);
|
||||
res[2][0] = position.x;
|
||||
res[2][1] = position.y;
|
||||
float const s = sinf(rotation);
|
||||
float const c = cosf(rotation);
|
||||
res[0][0] = scale.x * c;
|
||||
res[0][1] = scale.x * s;
|
||||
res[1][0] = scale.y * -s;
|
||||
res[1][1] = scale.y * c;
|
||||
return res;
|
||||
}
|
||||
|
||||
glm::mat4x4 getTransform4(float z = 500.f) const {
|
||||
//return transformationMatrix(scale, rotation, position);
|
||||
glm::mat4x4 res{1};
|
||||
|
||||
//res[2][0] = position.x;
|
||||
//res[2][1] = position.y;
|
||||
res = glm::translate(res, glm::vec3(position, z));
|
||||
|
||||
//float const s = sinf(rotation);
|
||||
//float const c = cosf(rotation);
|
||||
//res[0][0] = scale.x * c;
|
||||
//res[0][1] = scale.x * s;
|
||||
//res[1][0] = scale.y * -s;
|
||||
//res[1][1] = scale.y * c;
|
||||
res = glm::rotate(res, rotation, glm::vec3(0.f, 0.f, 1.f));
|
||||
|
||||
res = glm::scale(res, glm::vec3(scale, 1.f));
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
} // MM::Components
|
||||
|
@ -1,37 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
//#include <glm/mat3x3.hpp>
|
||||
#include <glm/mat4x4.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
//#include <entt/core/type_traits.hpp>
|
||||
|
||||
namespace MM::Components {
|
||||
struct Transform3D {
|
||||
glm::vec3 position {0.0f,0.0f,0.0f};
|
||||
glm::vec3 scale {1.0f,1.0f,1.0f};
|
||||
float rotation {0.0f};
|
||||
|
||||
glm::mat4x4 getTransform4(void) const {
|
||||
//return transformationMatrix(scale, rotation, position);
|
||||
glm::mat4x4 res{1};
|
||||
|
||||
//res[2][0] = position.x;
|
||||
//res[2][1] = position.y;
|
||||
res = glm::translate(res, position);
|
||||
|
||||
//float const s = sinf(rotation);
|
||||
//float const c = cosf(rotation);
|
||||
//res[0][0] = scale.x * c;
|
||||
//res[0][1] = scale.x * s;
|
||||
//res[1][0] = scale.y * -s;
|
||||
//res[1][1] = scale.y * c;
|
||||
res = glm::rotate(res, rotation, glm::vec3(0.f, 0.f, 1.f));
|
||||
|
||||
res = glm::scale(res, scale);
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
} // MM::Components
|
||||
|
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <glm/mat4x4.hpp>
|
||||
|
||||
namespace MM::Components {
|
||||
|
||||
// tag/flag to track dirty positional data, to reduce computation.
|
||||
struct DirtyTransformTag {};
|
||||
|
||||
struct Transform4x4 {
|
||||
glm::mat4x4 trans {1.f};
|
||||
};
|
||||
|
||||
} // MM::Components
|
||||
|
@ -1,16 +0,0 @@
|
||||
//
|
||||
// Created by FlaXxy on 29.07.2018.
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include <glm/vec2.hpp>
|
||||
|
||||
namespace MM::Components {
|
||||
|
||||
struct Velocity2D {
|
||||
glm::vec2 velocity;
|
||||
float rotation {0.f};
|
||||
};
|
||||
|
||||
} // MM::Components
|
||||
|
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <glm/vec2.hpp>
|
||||
|
||||
namespace MM::Components {
|
||||
|
||||
struct Velocity2DPosition {
|
||||
glm::vec2 pos_vel {0.f, 0.f};
|
||||
};
|
||||
|
||||
} // MM::Components
|
||||
|
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <glm/vec2.hpp>
|
||||
|
||||
namespace MM::Components {
|
||||
|
||||
struct Velocity2DPositionIntent {
|
||||
glm::vec2 intent {0.f, 0.f};
|
||||
};
|
||||
|
||||
} // MM::Components
|
||||
|
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
namespace MM::Components {
|
||||
|
||||
struct Velocity2DRotation {
|
||||
float rot_vel {0.f};
|
||||
};
|
||||
|
||||
} // MM::Components
|
||||
|
@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
namespace MM::Components {
|
||||
|
||||
struct Velocity3D {
|
||||
glm::vec3 velocity {0.f, 0.f, 0.f};
|
||||
glm::vec3 rotation {0.f, 0.f, 0.f};
|
||||
};
|
||||
|
||||
} // MM::Components
|
||||
|
@ -1,33 +1,37 @@
|
||||
#include "mm/components/position2d.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <mm/components/serialize/json_name.hpp>
|
||||
#include <mm/components/serialize/json_color.hpp>
|
||||
#include <mm/components/serialize/json_transform2d.hpp>
|
||||
#include <mm/components/serialize/json_transform3d.hpp>
|
||||
#include <mm/components/serialize/json_velocity2d.hpp>
|
||||
|
||||
#include <mm/components/serialize/json_position2d.hpp>
|
||||
#include <mm/components/serialize/json_position2d_zoffset.hpp>
|
||||
#include <mm/components/serialize/json_position3d.hpp>
|
||||
#include <mm/components/serialize/json_rotation2d.hpp>
|
||||
#include <mm/components/serialize/json_scale2d.hpp>
|
||||
#include <mm/components/serialize/json_transform4x4.hpp>
|
||||
#include <mm/components/serialize/json_velocity2d_position.hpp>
|
||||
#include <mm/components/serialize/json_velocity2d_position_intent.hpp>
|
||||
#include <mm/components/serialize/json_velocity2d_rotation.hpp>
|
||||
#include <mm/components/serialize/json_view_dir2d.hpp>
|
||||
#include <mm/components/serialize/json_view_dir3d.hpp>
|
||||
|
||||
/*#define PARSE_TEST_MACRO(type, json_string, comp_val) \
|
||||
TEST(common_components_json_serialization, type) { \
|
||||
MM::Components::type comp; \
|
||||
{ \
|
||||
auto j = nlohmann::json::parse(json_string); \
|
||||
EXPECT_NO_THROW({ comp = j; }); \
|
||||
ASSERT_EQ(comp, (comp_val)); \
|
||||
#define TEST_JSON_SERL_EXPAND(x) x
|
||||
#define TEST_JSON_SERL_IN_OUT(TYPE, JSON_STR, TEST_CORPUS) \
|
||||
TEST(common_components_json_serialization, in_out_##TYPE) { \
|
||||
MM::Components::TYPE comp; \
|
||||
{ /* in */ \
|
||||
auto j = nlohmann::json::parse(JSON_STR); \
|
||||
comp = j; \
|
||||
TEST_CORPUS \
|
||||
} \
|
||||
{ \
|
||||
{ /* out */ \
|
||||
nlohmann::json j; \
|
||||
[>EXPECT_NO_THROW({ j = comp; });<] \
|
||||
ASSERT_EQ(json_string, j.dump()); \
|
||||
j = comp; \
|
||||
ASSERT_EQ(JSON_STR, j.dump()); \
|
||||
} \
|
||||
}
|
||||
|
||||
PARSE_TEST_MACRO(
|
||||
Name,
|
||||
"{\"str\":\"test_name\"}",
|
||||
MM::Components::Name{"test_name"}
|
||||
); */
|
||||
|
||||
TEST(common_components_json_serialization, in_out_name) {
|
||||
MM::Components::Name comp;
|
||||
@ -72,137 +76,113 @@ TEST(common_components_json_serialization, in_out_name_fail) {
|
||||
|
||||
// ##############################################################
|
||||
|
||||
TEST(common_components_json_serialization, in_out_color) {
|
||||
MM::Components::Color comp;
|
||||
|
||||
const char* json_test_file = R"({"color":{"w":1337.0,"x":0.0,"y":1.0,"z":3.0}})";
|
||||
|
||||
{ // in
|
||||
auto j = nlohmann::json::parse(json_test_file);
|
||||
|
||||
EXPECT_NO_THROW({
|
||||
comp = j;
|
||||
});
|
||||
|
||||
glm::vec4 comp_val{0.f, 1.f, 3.f, 1337.f};
|
||||
TEST_JSON_SERL_IN_OUT(
|
||||
Color,
|
||||
R"({"color":{"w":1337.0,"x":0.0,"y":1.0,"z":3.0}})",
|
||||
TEST_JSON_SERL_EXPAND({
|
||||
glm::vec4 comp_val(0.f, 1.f, 3.f, 1337.f);
|
||||
ASSERT_EQ(comp.color.x, comp_val.x);
|
||||
ASSERT_EQ(comp.color.y, comp_val.y);
|
||||
ASSERT_EQ(comp.color.z, comp_val.z);
|
||||
ASSERT_EQ(comp.color.w, comp_val.w);
|
||||
}
|
||||
|
||||
{ // out
|
||||
nlohmann::json j;
|
||||
|
||||
EXPECT_NO_THROW({
|
||||
j = comp;
|
||||
});
|
||||
|
||||
ASSERT_EQ(json_test_file, j.dump());
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
// ##############################################################
|
||||
|
||||
TEST(common_components_json_serialization, in_out_transform2d) {
|
||||
MM::Components::Transform2D comp;
|
||||
|
||||
const char* json_test_file = R"({"position":{"x":42.0,"y":6.0},"rotation":99.0,"scale":{"x":1337.0,"y":68.0}})";
|
||||
|
||||
{ // in
|
||||
auto j = nlohmann::json::parse(json_test_file);
|
||||
|
||||
EXPECT_NO_THROW({
|
||||
comp = j;
|
||||
});
|
||||
|
||||
ASSERT_EQ(comp.position.x, 42.f);
|
||||
ASSERT_EQ(comp.position.y, 6.f);
|
||||
|
||||
ASSERT_EQ(comp.scale.x, 1337.f);
|
||||
ASSERT_EQ(comp.scale.y, 68.f);
|
||||
|
||||
ASSERT_EQ(comp.rotation, 99.f);
|
||||
}
|
||||
|
||||
{ // out
|
||||
nlohmann::json j;
|
||||
|
||||
EXPECT_NO_THROW({
|
||||
j = comp;
|
||||
});
|
||||
|
||||
ASSERT_EQ(json_test_file, j.dump());
|
||||
}
|
||||
}
|
||||
TEST_JSON_SERL_IN_OUT(
|
||||
Position2D,
|
||||
R"({"pos":{"x":42.0,"y":6.0}})",
|
||||
TEST_JSON_SERL_EXPAND(
|
||||
ASSERT_EQ(comp.pos.x, 42.f);
|
||||
ASSERT_EQ(comp.pos.y, 6.f);
|
||||
)
|
||||
)
|
||||
|
||||
// ##############################################################
|
||||
|
||||
TEST(common_components_json_serialization, in_out_transform3d) {
|
||||
MM::Components::Transform3D comp;
|
||||
|
||||
const char* json_test_file = R"({"position":{"x":42.0,"y":6.0,"z":66.0},"rotation":99.0,"scale":{"x":1337.0,"y":68.0,"z":60.0}})";
|
||||
|
||||
{ // in
|
||||
auto j = nlohmann::json::parse(json_test_file);
|
||||
|
||||
EXPECT_NO_THROW({
|
||||
comp = j;
|
||||
});
|
||||
|
||||
ASSERT_EQ(comp.position.x, 42.f);
|
||||
ASSERT_EQ(comp.position.y, 6.f);
|
||||
ASSERT_EQ(comp.position.z, 66.f);
|
||||
|
||||
ASSERT_EQ(comp.scale.x, 1337.f);
|
||||
ASSERT_EQ(comp.scale.y, 68.f);
|
||||
ASSERT_EQ(comp.scale.z, 60.f);
|
||||
|
||||
// TODO: prob needs 3 rotations...
|
||||
ASSERT_EQ(comp.rotation, 99.f);
|
||||
}
|
||||
|
||||
{ // out
|
||||
nlohmann::json j;
|
||||
|
||||
EXPECT_NO_THROW({
|
||||
j = comp;
|
||||
});
|
||||
|
||||
ASSERT_EQ(json_test_file, j.dump());
|
||||
}
|
||||
}
|
||||
TEST_JSON_SERL_IN_OUT(
|
||||
Position2D_ZOffset,
|
||||
R"({"z_offset":3.0})",
|
||||
TEST_JSON_SERL_EXPAND(
|
||||
ASSERT_EQ(comp.z_offset, 3.f);
|
||||
)
|
||||
)
|
||||
|
||||
// ##############################################################
|
||||
|
||||
TEST(common_components_json_serialization, in_out_velocity2d) {
|
||||
MM::Components::Velocity2D comp;
|
||||
TEST_JSON_SERL_IN_OUT(
|
||||
Position3D,
|
||||
R"({"pos":{"x":42.0,"y":6.0,"z":44.0}})",
|
||||
TEST_JSON_SERL_EXPAND(
|
||||
ASSERT_EQ(comp.pos.x, 42.f);
|
||||
ASSERT_EQ(comp.pos.y, 6.f);
|
||||
ASSERT_EQ(comp.pos.z, 44.f);
|
||||
)
|
||||
)
|
||||
|
||||
const char* json_test_file = R"({"rotation":99.0,"velocity":{"x":42.0,"y":6.0}})";
|
||||
// ##############################################################
|
||||
|
||||
{ // in
|
||||
auto j = nlohmann::json::parse(json_test_file);
|
||||
TEST_JSON_SERL_IN_OUT(
|
||||
Rotation2D,
|
||||
R"({"rot":42.0})",
|
||||
TEST_JSON_SERL_EXPAND(
|
||||
ASSERT_EQ(comp.rot, 42.f);
|
||||
)
|
||||
)
|
||||
|
||||
EXPECT_NO_THROW({
|
||||
comp = j;
|
||||
});
|
||||
// ##############################################################
|
||||
|
||||
ASSERT_EQ(comp.velocity.x, 42.f);
|
||||
ASSERT_EQ(comp.velocity.y, 6.f);
|
||||
TEST_JSON_SERL_IN_OUT(
|
||||
Scale2D,
|
||||
R"({"scale":{"x":42.0,"y":6.0}})",
|
||||
TEST_JSON_SERL_EXPAND(
|
||||
ASSERT_EQ(comp.scale.x, 42.f);
|
||||
ASSERT_EQ(comp.scale.y, 6.f);
|
||||
)
|
||||
)
|
||||
|
||||
ASSERT_EQ(comp.rotation, 99.f);
|
||||
}
|
||||
// ##############################################################
|
||||
|
||||
{ // out
|
||||
nlohmann::json j;
|
||||
TEST_JSON_SERL_IN_OUT(
|
||||
Transform4x4,
|
||||
R"({"trans":[{"w":0.0,"x":1.0,"y":0.0,"z":0.0},{"w":0.0,"x":0.0,"y":1.0,"z":0.0},{"w":0.0,"x":0.0,"y":0.0,"z":1.0},{"w":1.0,"x":0.0,"y":0.0,"z":0.0}]})",
|
||||
TEST_JSON_SERL_EXPAND(
|
||||
ASSERT_EQ(comp.trans, glm::mat4x4{1.f});
|
||||
)
|
||||
)
|
||||
|
||||
EXPECT_NO_THROW({
|
||||
j = comp;
|
||||
});
|
||||
// ##############################################################
|
||||
|
||||
ASSERT_EQ(json_test_file, j.dump());
|
||||
}
|
||||
}
|
||||
TEST_JSON_SERL_IN_OUT(
|
||||
Velocity2DPosition,
|
||||
R"({"pos_vel":{"x":42.0,"y":6.0}})",
|
||||
TEST_JSON_SERL_EXPAND(
|
||||
ASSERT_EQ(comp.pos_vel.x, 42.f);
|
||||
ASSERT_EQ(comp.pos_vel.y, 6.f);
|
||||
)
|
||||
)
|
||||
|
||||
// ##############################################################
|
||||
|
||||
TEST_JSON_SERL_IN_OUT(
|
||||
Velocity2DPositionIntent,
|
||||
R"({"intent":{"x":42.0,"y":6.0}})",
|
||||
TEST_JSON_SERL_EXPAND(
|
||||
ASSERT_EQ(comp.intent.x, 42.f);
|
||||
ASSERT_EQ(comp.intent.y, 6.f);
|
||||
)
|
||||
)
|
||||
|
||||
// ##############################################################
|
||||
|
||||
TEST_JSON_SERL_IN_OUT(
|
||||
Velocity2DRotation,
|
||||
R"({"rot_vel":42.0})",
|
||||
TEST_JSON_SERL_EXPAND(
|
||||
ASSERT_EQ(comp.rot_vel, 42.f);
|
||||
)
|
||||
)
|
||||
|
||||
// ##############################################################
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
|
||||
project(engine CXX)
|
||||
|
||||
add_library(engine
|
||||
@ -15,7 +16,6 @@ add_library(engine
|
||||
src/mm/update_strategies/sequential_strategy.cpp
|
||||
|
||||
src/mm/services/scene_service_interface.hpp
|
||||
src/mm/services/scene_service_interface.cpp
|
||||
|
||||
src/mm/services/net_channeled_interface.hpp
|
||||
)
|
||||
|
@ -30,6 +30,14 @@ void Engine::setup(void) {
|
||||
Engine::Engine(void) {
|
||||
setup();
|
||||
|
||||
LOG_INFO(R"text(
|
||||
__ __ _ __ __ _ _
|
||||
| \/ | | | | \/ | | | (_)
|
||||
| \ / |_ _ ___| |__ | \ / | __ _ ___| |__ _ _ __ ___
|
||||
| |\/| | | | / __| '_ \| |\/| |/ _` |/ __| '_ \| | '_ \ / _ \
|
||||
| | | | |_| \__ \ | | | | | | (_| | (__| | | | | | | | __/
|
||||
|_| |_|\__,_|___/_| |_|_| |_|\__,_|\___|_| |_|_|_| |_|\___|)text");
|
||||
|
||||
_update_strategy = std::make_unique<MM::UpdateStrategies::Sequential>();
|
||||
LOG_INFO("defaulting to Sequential (single threaded) UpdateStrategy");
|
||||
//_update_strategy = std::make_unique<MM::UpdateStrategies::Dummy>();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user