mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2025-07-13 20:46:46 +02:00
Compare commits
72 Commits
vulkan_hea
...
master
Author | SHA1 | Date | |
---|---|---|---|
4ec8f98ab0 | |||
8801d5cde5 | |||
09074c1ab5 | |||
5494dda227 | |||
a5e89b5aa6 | |||
69803783cc | |||
339ab514dd | |||
7237cb265d | |||
ff30cb54f5 | |||
31e24b9c04 | |||
c6191d2cdc | |||
7e76d6116f | |||
2ea7a1529a | |||
e6403f0582 | |||
e64354e824 | |||
cd0b35b465 | |||
c051d36a64 | |||
202ba31d79 | |||
df949a5afc | |||
9b173c64a6 | |||
3a885ee250 | |||
00e48f9967 | |||
c791f4c6a1 | |||
7a3823db78 | |||
1722f61250 | |||
0abb860185 | |||
22dc949cc5 | |||
196ea7b93b | |||
f655da82d5 | |||
d672f8a52c | |||
6df865de3e | |||
e9c62f9201 | |||
7bce78167b | |||
a45da5c2b0 | |||
4ab1d99529 | |||
f27300a8fa | |||
8d24976a13 | |||
8036fdf2a9 | |||
5148ea7217 | |||
ab0e5afb94 | |||
191e9f6b44 | |||
86c52c4fac | |||
0c1a98cfd5 | |||
a9e56b9e25 | |||
eeb8be6a8e | |||
c4bd4fd678 | |||
9f6e9defb0 | |||
5ed71690c7 | |||
e108d14e1d | |||
20dd451cd0 | |||
3f03bbbd49 | |||
9af3df5550 | |||
8e5471480c | |||
8ace6e51f9 | |||
2b6a6b3e0c | |||
dffbad65d2 | |||
4d0f731d8d | |||
c13dff8eb3 | |||
8cc473b9fc | |||
53c7bc1477 | |||
7d983244b2 | |||
26a1f4b101 | |||
5004e30e18 | |||
cc40740cf1 | |||
3d03881002 | |||
3b2cd5c62b | |||
ee16ca5356 | |||
4b707a7adb | |||
e1bf5fefc0 | |||
e65878509e | |||
5ed74d956d | |||
989e3f7dda |
124
.github/workflows/cmake.yml
vendored
124
.github/workflows/cmake.yml
vendored
@ -9,10 +9,12 @@ on:
|
|||||||
env:
|
env:
|
||||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||||
BUILD_TYPE: Debug
|
BUILD_TYPE: Debug
|
||||||
|
EM_VERSION: 3.1.32
|
||||||
|
EM_CACHE_FOLDER: 'emsdk-cache'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
linux:
|
linux:
|
||||||
timeout-minutes: 10
|
timeout-minutes: 15
|
||||||
|
|
||||||
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
|
# 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.
|
# You can convert this to a matrix build if you need cross-platform coverage.
|
||||||
@ -20,14 +22,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
# TODO: cache
|
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: sudo apt update && sudo apt -y install libsdl2-dev
|
run: sudo apt update && sudo apt -y install libsdl2-dev xserver-xorg-video-dummy
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||||
@ -35,11 +35,20 @@ jobs:
|
|||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||||
|
|
||||||
#- name: Test
|
- name: Test
|
||||||
#working-directory: ${{github.workspace}}/build
|
working-directory: ${{github.workspace}}/build
|
||||||
## Execute tests defined by the CMake configuration.
|
# Execute tests defined by the CMake configuration.
|
||||||
## See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
|
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
|
||||||
#run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure
|
#run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure
|
||||||
|
# TODO: look into xinit
|
||||||
|
env:
|
||||||
|
DISPLAY: :0
|
||||||
|
run: |
|
||||||
|
sudo Xorg :0 -config ${{github.workspace}}/.github/workflows/x/dummy-1920x1080.conf -noautoBindGPU &
|
||||||
|
sleep 20s
|
||||||
|
ctest --output-on-failure --timeout 20
|
||||||
|
sudo pkill -15 Xorg
|
||||||
|
|
||||||
|
|
||||||
linux_gles:
|
linux_gles:
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
@ -47,12 +56,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
# TODO: cache
|
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: sudo apt update && sudo apt -y install libsdl2-dev
|
run: sudo apt update && sudo apt -y install libsdl2-dev
|
||||||
|
|
||||||
@ -62,18 +69,67 @@ jobs:
|
|||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||||
|
|
||||||
|
linux_tracy:
|
||||||
|
timeout-minutes: 10
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- 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}} -DTRACY_ENABLE=ON
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||||
|
|
||||||
|
emscripten:
|
||||||
|
timeout-minutes: 10
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Setup em cache
|
||||||
|
id: em-cache-system-libraries
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ${{env.EM_CACHE_FOLDER}}
|
||||||
|
key: ${{env.EM_VERSION}}-${{ runner.os }}
|
||||||
|
|
||||||
|
- name: Setup emsdk
|
||||||
|
uses: mymindstorm/setup-emsdk@v14
|
||||||
|
with:
|
||||||
|
version: ${{env.EM_VERSION}}
|
||||||
|
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}
|
||||||
|
|
||||||
|
- name: Verify
|
||||||
|
run: emcc --check
|
||||||
|
|
||||||
|
- name: Configure CMake
|
||||||
|
run: emcmake 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:
|
macos:
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
|
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
# TODO: cache
|
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: brew install sdl2
|
run: brew install sdl2
|
||||||
|
|
||||||
@ -83,30 +139,28 @@ jobs:
|
|||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
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:
|
||||||
#windows:
|
timeout-minutes: 15 # TODO: caching
|
||||||
#timeout-minutes: 10
|
|
||||||
|
|
||||||
#runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
|
||||||
#steps:
|
steps:
|
||||||
#- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
#with:
|
with:
|
||||||
#submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
## TODO: cache
|
# TODO: cache
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: vcpkg install sdl2[core,vulkan]:x64-windows
|
||||||
|
|
||||||
#- name: Install Dependencies
|
# setup vs env
|
||||||
#run: vcpkg install sdl2:x64-windows
|
- uses: ilammy/msvc-dev-cmd@v1
|
||||||
|
with:
|
||||||
|
arch: amd64
|
||||||
|
|
||||||
## setup vs env
|
- name: Configure CMake
|
||||||
#- uses: ilammy/msvc-dev-cmd@v1
|
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
|
||||||
#with:
|
|
||||||
#arch: amd64
|
|
||||||
|
|
||||||
#- name: Configure CMake
|
- name: Build
|
||||||
#run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||||
|
|
||||||
#- name: Build
|
|
||||||
#run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
|
||||||
|
|
||||||
|
21
.github/workflows/x/dummy-1920x1080.conf
vendored
Normal file
21
.github/workflows/x/dummy-1920x1080.conf
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# https://wiki.archlinux.org/title/Xorg
|
||||||
|
Section "Monitor"
|
||||||
|
Identifier "dummy_monitor"
|
||||||
|
HorizSync 28.0-80.0
|
||||||
|
VertRefresh 48.0-75.0
|
||||||
|
Modeline "1920x1080" 172.80 1920 2040 2248 2576 1080 1081 1084 1118
|
||||||
|
EndSection
|
||||||
|
|
||||||
|
Section "Device"
|
||||||
|
Identifier "dummy_card"
|
||||||
|
VideoRam 256000
|
||||||
|
Driver "dummy"
|
||||||
|
EndSection
|
||||||
|
|
||||||
|
Section "Screen"
|
||||||
|
Identifier "dummy_screen"
|
||||||
|
Device "dummy_card"
|
||||||
|
Monitor "dummy_monitor"
|
||||||
|
SubSection "Display"
|
||||||
|
EndSubSection
|
||||||
|
EndSection
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -16,9 +16,6 @@
|
|||||||
path = external/imgui/imgui
|
path = external/imgui/imgui
|
||||||
url = https://github.com/ocornut/imgui.git
|
url = https://github.com/ocornut/imgui.git
|
||||||
shallow = true
|
shallow = true
|
||||||
[submodule "external/ImGuiColorTextEdit"]
|
|
||||||
path = external/ImGuiColorTextEdit
|
|
||||||
url = https://github.com/BalazsJako/ImGuiColorTextEdit.git
|
|
||||||
[submodule "external/soloud/soloud"]
|
[submodule "external/soloud/soloud"]
|
||||||
path = external/soloud/soloud
|
path = external/soloud/soloud
|
||||||
url = https://github.com/jarikomppa/soloud.git
|
url = https://github.com/jarikomppa/soloud.git
|
||||||
|
28
.vimspector.json
Normal file
28
.vimspector.json
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"configurations": {
|
||||||
|
"run_ctest_native": {
|
||||||
|
"default": true,
|
||||||
|
"adapter": "CodeLLDB",
|
||||||
|
"configuration": {
|
||||||
|
"request": "launch",
|
||||||
|
"stopOnEntry": true,
|
||||||
|
"console": "integratedTerminal",
|
||||||
|
"program": "ctest",
|
||||||
|
"cwd": "${workspaceRoot}/build"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"run_native": {
|
||||||
|
"adapter": "CodeLLDB",
|
||||||
|
"variables": {
|
||||||
|
"Executable": "s6zer_test"
|
||||||
|
},
|
||||||
|
"configuration": {
|
||||||
|
"request": "launch",
|
||||||
|
"stopOnEntry": true,
|
||||||
|
"console": "integratedTerminal",
|
||||||
|
"program": "${workspaceRoot}/build/bin/${Executable}",
|
||||||
|
"cwd": "${workspaceRoot}/build"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.9...3.16 FATAL_ERROR)
|
||||||
|
|
||||||
# cmake setup begin
|
# cmake setup begin
|
||||||
project(MushMachine C CXX)
|
project(MushMachine C CXX)
|
||||||
@ -20,9 +20,16 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
|||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||||
|
|
||||||
# add this to your projects cmake to enable ipo
|
# add this to your projects cmake to enable ipo
|
||||||
#include(CheckIPOSupported)
|
#if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
||||||
#check_ipo_supported()
|
#include(CheckIPOSupported)
|
||||||
#set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
|
#check_ipo_supported(RESULT HAVE_LTO)
|
||||||
|
#if(HAVE_LTO)
|
||||||
|
#set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
|
||||||
|
#message(STATUS "Enabled LTO")
|
||||||
|
#else()
|
||||||
|
#message(STATUS "LTO not supported")
|
||||||
|
#endif()
|
||||||
|
#endif()
|
||||||
|
|
||||||
# enable test
|
# enable test
|
||||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||||
|
@ -105,7 +105,7 @@
|
|||||||
|
|
||||||
if(NOT EMSCRIPTEN)
|
if(NOT EMSCRIPTEN)
|
||||||
|
|
||||||
FIND_PATH(SDL2_INCLUDE_DIR SDL.h
|
FIND_PATH(SDL2_INCLUDE_DIR_TEMP SDL.h
|
||||||
HINTS
|
HINTS
|
||||||
$ENV{SDL2}
|
$ENV{SDL2}
|
||||||
PATH_SUFFIXES include/SDL2 include SDL2
|
PATH_SUFFIXES include/SDL2 include SDL2
|
||||||
@ -153,7 +153,7 @@ ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|||||||
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
|
||||||
IF(NOT SDL2_BUILDING_LIBRARY)
|
IF(NOT SDL2_BUILDING_LIBRARY)
|
||||||
IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
|
IF(NOT "${SDL2_INCLUDE_DIR_TEMP}" MATCHES ".framework")
|
||||||
# Non-OS X framework versions expect you to also dynamically link to
|
# Non-OS X framework versions expect you to also dynamically link to
|
||||||
# SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
|
# SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
|
||||||
# seem to provide SDL2main for compatibility even though they don't
|
# seem to provide SDL2main for compatibility even though they don't
|
||||||
@ -189,7 +189,7 @@ IF(NOT SDL2_BUILDING_LIBRARY)
|
|||||||
/opt
|
/opt
|
||||||
)
|
)
|
||||||
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
|
ENDIF(NOT "${SDL2_INCLUDE_DIR_TEMP}" MATCHES ".framework")
|
||||||
ENDIF(NOT SDL2_BUILDING_LIBRARY)
|
ENDIF(NOT SDL2_BUILDING_LIBRARY)
|
||||||
|
|
||||||
# SDL2 may require threads on your system.
|
# SDL2 may require threads on your system.
|
||||||
@ -208,58 +208,67 @@ IF(MINGW)
|
|||||||
ENDIF(MINGW)
|
ENDIF(MINGW)
|
||||||
|
|
||||||
SET(SDL2_FOUND "NO")
|
SET(SDL2_FOUND "NO")
|
||||||
IF(SDL2_LIBRARY_TEMP)
|
IF(SDL2_LIBRARY_TEMP)
|
||||||
# For SDL2main
|
# For SDL2main
|
||||||
IF(NOT SDL2_BUILDING_LIBRARY)
|
IF(NOT SDL2_BUILDING_LIBRARY)
|
||||||
IF(SDL2MAIN_LIBRARY)
|
IF(SDL2MAIN_LIBRARY)
|
||||||
SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP})
|
SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP})
|
||||||
ENDIF(SDL2MAIN_LIBRARY)
|
ENDIF(SDL2MAIN_LIBRARY)
|
||||||
ENDIF(NOT SDL2_BUILDING_LIBRARY)
|
ENDIF(NOT SDL2_BUILDING_LIBRARY)
|
||||||
|
|
||||||
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
|
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
|
||||||
# CMake doesn't display the -framework Cocoa string in the UI even
|
# CMake doesn't display the -framework Cocoa string in the UI even
|
||||||
# though it actually is there if I modify a pre-used variable.
|
# though it actually is there if I modify a pre-used variable.
|
||||||
# I think it has something to do with the CACHE STRING.
|
# I think it has something to do with the CACHE STRING.
|
||||||
# So I use a temporary variable until the end so I can set the
|
# So I use a temporary variable until the end so I can set the
|
||||||
# "real" variable in one-shot.
|
# "real" variable in one-shot.
|
||||||
IF(APPLE)
|
IF(APPLE)
|
||||||
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
|
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
|
||||||
ENDIF(APPLE)
|
ENDIF(APPLE)
|
||||||
|
|
||||||
# For threads, as mentioned Apple doesn't need this.
|
# For threads, as mentioned Apple doesn't need this.
|
||||||
# In fact, there seems to be a problem if I used the Threads package
|
# In fact, there seems to be a problem if I used the Threads package
|
||||||
# and try using this line, so I'm just skipping it entirely for OS X.
|
# and try using this line, so I'm just skipping it entirely for OS X.
|
||||||
IF(NOT APPLE)
|
IF(NOT APPLE)
|
||||||
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
|
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
|
||||||
ENDIF(NOT APPLE)
|
ENDIF(NOT APPLE)
|
||||||
|
|
||||||
# For MinGW library
|
# For MinGW library
|
||||||
IF(MINGW)
|
IF(MINGW)
|
||||||
SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
|
SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
|
||||||
ENDIF(MINGW)
|
ENDIF(MINGW)
|
||||||
|
|
||||||
# Set the final string here so the GUI reflects the final state.
|
# Set the final string here so the GUI reflects the final state.
|
||||||
SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
|
SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
|
||||||
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
|
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
|
||||||
SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
|
SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
|
||||||
|
|
||||||
############add_library(SDL UNKNOWN IMPORTED)
|
set(SDL2_INCLUDE_DIR ${SDL2_INCLUDE_DIR_TEMP} CACHE STRING "Where the SDL2 Headers can be found")
|
||||||
#target_link_libraries(SDL INTERFACE ${SDL2_LIBRARY})
|
SET(SDL2_INCLUDE_DIR_TEMP "${SDL2_INCLUDE_DIR_TEMP}" CACHE INTERNAL "")
|
||||||
#target_include_directories(SDL INTERFACE ${SDL2_INCLUDE_DIR})
|
|
||||||
#set_target_properties(SDL PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES "${SDL2_LIBRARY}")
|
|
||||||
|
|
||||||
#set_target_properties(SDL PROPERTIES
|
SET(SDL2_FOUND "YES")
|
||||||
#INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}")
|
else() # SDL2_LIBRARY_TEMP
|
||||||
|
# try to pkg-config fallback
|
||||||
|
find_package(PkgConfig)
|
||||||
|
if (PKG_CONFIG_FOUND)
|
||||||
|
pkg_check_modules(PKG_C_SDL2 QUIET sdl2)
|
||||||
|
if (PKG_C_SDL2_FOUND)
|
||||||
|
SET(SDL2_LIBRARY_TEMP ${PKG_C_SDL2_LIBRARIES})
|
||||||
|
SET(SDL2_INCLUDE_DIR_TEMP ${PKG_C_SDL2_INCLUDE_DIRS})
|
||||||
|
|
||||||
#set_target_properties(SDL PROPERTIES
|
# Set the final string here so the GUI reflects the final state.
|
||||||
#IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
|
||||||
#IMPORTED_LINK_INTERFACE_LIBRARIES "${SDL2_LIBRARY}"
|
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
|
||||||
#LINK_INTERFACE_LIBRARIES "${SDL2_LIBRARY}")
|
SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
|
||||||
|
|
||||||
#IMPORTED_LOCATION "${SDL2_LIBRARY}")
|
set(SDL2_INCLUDE_DIR ${SDL2_INCLUDE_DIR_TEMP} CACHE STRING "Where the SDL2 Headers can be found")
|
||||||
|
SET(SDL2_INCLUDE_DIR_TEMP "${SDL2_INCLUDE_DIR_TEMP}" CACHE INTERNAL "")
|
||||||
|
|
||||||
|
#message("II set include dir to ${SDL2_INCLUDE_DIR}")
|
||||||
|
|
||||||
SET(SDL2_FOUND "YES")
|
SET(SDL2_FOUND "YES")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
ENDIF(SDL2_LIBRARY_TEMP)
|
ENDIF(SDL2_LIBRARY_TEMP)
|
||||||
|
|
||||||
else() #emsripten
|
else() #emsripten
|
||||||
@ -288,4 +297,11 @@ INCLUDE(FindPackageHandleStandardArgs)
|
|||||||
|
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)
|
||||||
|
|
||||||
|
if (SDL2_FOUND)
|
||||||
|
if (NOT TARGET SDL2::SDL2)
|
||||||
|
add_library(SDL2::SDL2 INTERFACE IMPORTED)
|
||||||
|
target_include_directories(SDL2::SDL2 INTERFACE ${SDL2_INCLUDE_DIR})
|
||||||
|
target_link_libraries(SDL2::SDL2 INTERFACE ${SDL2_LIBRARY})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
7
external/CMakeLists.txt
vendored
7
external/CMakeLists.txt
vendored
@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.9...3.16 FATAL_ERROR)
|
||||||
|
|
||||||
# external libs
|
# external libs
|
||||||
|
|
||||||
@ -21,11 +21,11 @@ set(JSON_BuildTests OFF CACHE INTERNAL "")
|
|||||||
set(JSON_MultipleHeaders ON CACHE INTERNAL "")
|
set(JSON_MultipleHeaders ON CACHE INTERNAL "")
|
||||||
add_subdirectory("json") # link with "nlohmann_json::nlohmann_json"
|
add_subdirectory("json") # link with "nlohmann_json::nlohmann_json"
|
||||||
|
|
||||||
set(PHYSFS_BUILD_SHARED FALSE CACHE INTERNAL "")
|
|
||||||
add_subdirectory("physfs")
|
add_subdirectory("physfs")
|
||||||
|
|
||||||
if(NOT MM_HEADLESS)
|
if(NOT MM_HEADLESS)
|
||||||
if(NOT EMSCRIPTEN)
|
if(NOT EMSCRIPTEN)
|
||||||
|
# TODO: move into imgui and soload, since they are the one requireing this
|
||||||
if(VCPKG_TARGET_TRIPLET)
|
if(VCPKG_TARGET_TRIPLET)
|
||||||
find_package(SDL2 CONFIG REQUIRED)
|
find_package(SDL2 CONFIG REQUIRED)
|
||||||
else() # HACK: fix sdl find module
|
else() # HACK: fix sdl find module
|
||||||
@ -47,9 +47,6 @@ if(NOT MM_HEADLESS)
|
|||||||
# (debug) gui
|
# (debug) gui
|
||||||
add_subdirectory("imgui")
|
add_subdirectory("imgui")
|
||||||
|
|
||||||
# (debug) text editor
|
|
||||||
include("${CMAKE_CURRENT_SOURCE_DIR}/ImGuiColorTextEdit.cmake")
|
|
||||||
|
|
||||||
# sound, uses sdl2-static backend
|
# sound, uses sdl2-static backend
|
||||||
add_subdirectory("soloud")
|
add_subdirectory("soloud")
|
||||||
endif()
|
endif()
|
||||||
|
1
external/ImGuiColorTextEdit
vendored
1
external/ImGuiColorTextEdit
vendored
Submodule external/ImGuiColorTextEdit deleted from 0a88824f7d
12
external/ImGuiColorTextEdit.cmake
vendored
12
external/ImGuiColorTextEdit.cmake
vendored
@ -1,12 +0,0 @@
|
|||||||
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
|
|
||||||
)
|
|
||||||
|
|
2
external/SquirrelNoise/CMakeLists.txt
vendored
2
external/SquirrelNoise/CMakeLists.txt
vendored
@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.9...3.16 FATAL_ERROR)
|
||||||
|
|
||||||
project(SquirrelNoise)
|
project(SquirrelNoise)
|
||||||
|
|
||||||
|
2
external/entt
vendored
2
external/entt
vendored
Submodule external/entt updated: e4ccb878f4...d4014c74dc
2
external/entt.cmake
vendored
2
external/entt.cmake
vendored
@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.9...3.16 FATAL_ERROR)
|
||||||
add_library(entt INTERFACE)
|
add_library(entt INTERFACE)
|
||||||
target_include_directories(entt INTERFACE "${CMAKE_CURRENT_LIST_DIR}/entt/src")
|
target_include_directories(entt INTERFACE "${CMAKE_CURRENT_LIST_DIR}/entt/src")
|
||||||
target_compile_features(entt INTERFACE cxx_std_17)
|
target_compile_features(entt INTERFACE cxx_std_17)
|
||||||
|
2
external/glm
vendored
2
external/glm
vendored
Submodule external/glm updated: bf71a83494...0af55ccecd
3
external/glm.cmake
vendored
3
external/glm.cmake
vendored
@ -1,5 +1,6 @@
|
|||||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.9...3.16 FATAL_ERROR)
|
||||||
|
|
||||||
add_library(glm INTERFACE)
|
add_library(glm INTERFACE)
|
||||||
target_include_directories(glm INTERFACE "${CMAKE_CURRENT_LIST_DIR}/glm")
|
target_include_directories(glm INTERFACE "${CMAKE_CURRENT_LIST_DIR}/glm")
|
||||||
|
target_compile_definitions(glm INTERFACE GLM_ENABLE_EXPERIMENTAL)
|
||||||
|
|
||||||
|
2
external/googletest
vendored
2
external/googletest
vendored
Submodule external/googletest updated: 705b9c1af2...52eb8108c5
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.9 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.9...3.16 FATAL_ERROR)
|
||||||
add_library(icon_font_cpp_headers INTERFACE)
|
add_library(icon_font_cpp_headers INTERFACE)
|
||||||
target_include_directories(icon_font_cpp_headers INTERFACE "${CMAKE_CURRENT_LIST_DIR}/IconFontCppHeaders/")
|
target_include_directories(icon_font_cpp_headers INTERFACE "${CMAKE_CURRENT_LIST_DIR}/IconFontCppHeaders/")
|
||||||
|
|
||||||
|
50
external/imgui/CMakeLists.txt
vendored
50
external/imgui/CMakeLists.txt
vendored
@ -1,68 +1,64 @@
|
|||||||
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.9...3.16 FATAL_ERROR)
|
||||||
|
|
||||||
project(imgui C CXX)
|
project(imgui C CXX)
|
||||||
|
|
||||||
set(CPP_FILES
|
add_library(imgui
|
||||||
|
"imgui/imgui.h"
|
||||||
"imgui/imgui.cpp"
|
"imgui/imgui.cpp"
|
||||||
"imgui/imgui_draw.cpp"
|
"imgui/imgui_draw.cpp"
|
||||||
"imgui/imgui_widgets.cpp"
|
"imgui/imgui_widgets.cpp"
|
||||||
"imgui/imgui_tables.cpp"
|
"imgui/imgui_tables.cpp"
|
||||||
"imgui/imgui_demo.cpp"
|
"imgui/imgui_demo.cpp"
|
||||||
|
|
||||||
"imgui/misc/cpp/imgui_stdlib.cpp"
|
|
||||||
|
|
||||||
"imgui_plot_var.cpp"
|
|
||||||
|
|
||||||
#"imgui_impl_sdl_gl3.cpp" # very old
|
|
||||||
#"imgui_impl_sdl.cpp" # old
|
|
||||||
#"imgui_impl_opengl3.cpp" # old
|
|
||||||
"imgui/backends/imgui_impl_sdl.cpp"
|
|
||||||
"imgui/backends/imgui_impl_opengl3.cpp"
|
|
||||||
)
|
|
||||||
|
|
||||||
set(HPP_FILES
|
|
||||||
"imgui/imgui.h"
|
|
||||||
"imgui/imstb_rectpack.h"
|
"imgui/imstb_rectpack.h"
|
||||||
"imgui/imstb_textedit.h"
|
"imgui/imstb_textedit.h"
|
||||||
"imgui/imstb_truetype.h"
|
"imgui/imstb_truetype.h"
|
||||||
|
|
||||||
"imgui/misc/cpp/imgui_stdlib.h"
|
"imgui/misc/cpp/imgui_stdlib.h"
|
||||||
|
"imgui/misc/cpp/imgui_stdlib.cpp"
|
||||||
|
|
||||||
"imgui_plot_var.hpp"
|
"imgui_plot_var.hpp"
|
||||||
|
"imgui_plot_var.cpp"
|
||||||
|
|
||||||
#"imgui_impl_sdl_gl3.h" # very old
|
# TODO: seperate backends into libs
|
||||||
#"imgui_impl_sdl.h" # old
|
"imgui/backends/imgui_impl_sdl2.h"
|
||||||
#"imgui_impl_opengl3.h" # old
|
"imgui/backends/imgui_impl_sdl2.cpp"
|
||||||
"imgui/backends/imgui_impl_sdl.h"
|
|
||||||
"imgui/backends/imgui_impl_opengl3.h"
|
"imgui/backends/imgui_impl_opengl3.h"
|
||||||
|
"imgui/backends/imgui_impl_opengl3.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(imgui ${CPP_FILES} ${HPP_FILES})
|
target_compile_features(imgui PUBLIC cxx_std_11)
|
||||||
|
|
||||||
if(MM_OPENGL_3_GLES)
|
if(MM_OPENGL_3_GLES)
|
||||||
target_compile_definitions(imgui PUBLIC IMGUI_IMPL_OPENGL_ES3)
|
target_compile_definitions(imgui PUBLIC IMGUI_IMPL_OPENGL_ES3)
|
||||||
target_compile_definitions(imgui PUBLIC IMGUI_IMPL_OPENGL_LOADER_CUSTOM) # bug?
|
target_compile_definitions(imgui PUBLIC IMGUI_IMPL_OPENGL_LOADER_CUSTOM) # bug?
|
||||||
else()
|
else()
|
||||||
target_compile_definitions(imgui PUBLIC IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
target_compile_definitions(imgui PUBLIC IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||||
target_link_libraries(imgui glad)
|
target_link_libraries(imgui PUBLIC glad)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
#target_include_directories(imgui PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/imgui")
|
#target_include_directories(imgui PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/imgui")
|
||||||
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/imgui") # im sad
|
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/imgui") # im sad
|
||||||
|
|
||||||
target_compile_definitions(imgui PUBLIC IMGUI_DISABLE_OBSOLETE_FUNCTIONS=1)
|
#target_compile_definitions(imgui PUBLIC IMGUI_DISABLE_OBSOLETE_FUNCTIONS=1) # more sad
|
||||||
|
|
||||||
if(EMSCRIPTEN)
|
if(EMSCRIPTEN)
|
||||||
set_target_properties(imgui PROPERTIES COMPILE_FLAGS "-s USE_SDL=2 -s USE_WEBGL2=1 -s FULL_ES2=1 -s FULL_ES3=1")
|
target_compile_options(imgui PUBLIC -sUSE_SDL=2)
|
||||||
set_target_properties(imgui PROPERTIES LINK_FLAGS "-s USE_SDL=2 -s USE_WEBGL2=1 -s FULL_ES2=1 -s FULL_ES3=1")
|
target_link_libraries(imgui PUBLIC -sUSE_SDL=2 -sUSE_WEBGL2=1 -sFULL_ES3=1)
|
||||||
elseif(ANDROID)
|
elseif(ANDROID)
|
||||||
target_link_libraries(imgui SDL)
|
target_link_libraries(imgui PUBLIC SDL)
|
||||||
elseif(VCPKG_TARGET_TRIPLET)
|
elseif(VCPKG_TARGET_TRIPLET)
|
||||||
target_link_libraries(imgui SDL2::SDL2 SDL2::SDL2main SDL2::SDL2-static)
|
target_link_libraries(imgui
|
||||||
|
PUBLIC
|
||||||
|
SDL2::SDL2
|
||||||
|
#PRIVATE
|
||||||
|
#SDL2::SDL2main
|
||||||
|
#SDL2::SDL2-static
|
||||||
|
)
|
||||||
else()
|
else()
|
||||||
target_include_directories(imgui PUBLIC "${SDL2_INCLUDE_DIR}")
|
target_include_directories(imgui PUBLIC "${SDL2_INCLUDE_DIR}")
|
||||||
target_link_libraries(imgui ${SDL2_LIBRARY})
|
target_link_libraries(imgui PUBLIC ${SDL2_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_compile_definitions(imgui PUBLIC ImTextureID=unsigned\ long)
|
target_compile_definitions(imgui PUBLIC ImTextureID=unsigned\ long)
|
||||||
|
2
external/imgui/imgui
vendored
2
external/imgui/imgui
vendored
Submodule external/imgui/imgui updated: c71a50deb5...f5befd2d29
194
external/json/CMakeLists.txt
vendored
194
external/json/CMakeLists.txt
vendored
@ -1,21 +1,77 @@
|
|||||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.5...4.0)
|
||||||
|
|
||||||
##
|
##
|
||||||
## PROJECT
|
## PROJECT
|
||||||
## name and version
|
## name and version
|
||||||
##
|
##
|
||||||
project(nlohmann_json VERSION 3.10.4 LANGUAGES CXX)
|
project(nlohmann_json VERSION 3.12.0 LANGUAGES CXX)
|
||||||
|
|
||||||
|
##
|
||||||
|
## MAIN_PROJECT CHECK
|
||||||
|
## determine if nlohmann_json is built as a subproject (using add_subdirectory) or if it is the main project
|
||||||
|
##
|
||||||
|
set(MAIN_PROJECT OFF)
|
||||||
|
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||||
|
set(MAIN_PROJECT ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
##
|
||||||
|
## INCLUDE
|
||||||
|
##
|
||||||
|
##
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
|
||||||
|
include(ExternalProject)
|
||||||
|
|
||||||
##
|
##
|
||||||
## OPTIONS
|
## OPTIONS
|
||||||
##
|
##
|
||||||
option(JSON_MultipleHeaders "Use non-amalgamated version of the library." ON)
|
|
||||||
|
if (POLICY CMP0077)
|
||||||
|
# Allow CMake 3.13+ to override options when using FetchContent / add_subdirectory.
|
||||||
|
cmake_policy(SET CMP0077 NEW)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# VERSION_GREATER_EQUAL is not available in CMake 3.1
|
||||||
|
if(${MAIN_PROJECT} AND (${CMAKE_VERSION} VERSION_EQUAL 3.13 OR ${CMAKE_VERSION} VERSION_GREATER 3.13))
|
||||||
|
set(JSON_BuildTests_INIT ON)
|
||||||
|
else()
|
||||||
|
set(JSON_BuildTests_INIT OFF)
|
||||||
|
endif()
|
||||||
|
option(JSON_BuildTests "Build the unit tests when BUILD_TESTING is enabled." ${JSON_BuildTests_INIT})
|
||||||
|
option(JSON_CI "Enable CI build targets." OFF)
|
||||||
|
option(JSON_Diagnostics "Use extended diagnostic messages." OFF)
|
||||||
|
option(JSON_Diagnostic_Positions "Enable diagnostic positions." OFF)
|
||||||
|
option(JSON_GlobalUDLs "Place user-defined string literals in the global namespace." ON)
|
||||||
|
option(JSON_ImplicitConversions "Enable implicit conversions." ON)
|
||||||
|
option(JSON_DisableEnumSerialization "Disable default integer enum serialization." OFF)
|
||||||
|
option(JSON_LegacyDiscardedValueComparison "Enable legacy discarded value comparison." OFF)
|
||||||
|
option(JSON_Install "Install CMake targets during install step." ${MAIN_PROJECT})
|
||||||
|
option(JSON_MultipleHeaders "Use non-amalgamated version of the library." ON)
|
||||||
|
option(JSON_SystemInclude "Include as system headers (skip for clang-tidy)." OFF)
|
||||||
|
|
||||||
|
if (JSON_CI)
|
||||||
|
include(ci)
|
||||||
|
endif ()
|
||||||
|
|
||||||
##
|
##
|
||||||
## CONFIGURATION
|
## CONFIGURATION
|
||||||
##
|
##
|
||||||
set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME})
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
if (NOT DEFINED NLOHMANN_JSON_TARGET_NAME)
|
||||||
|
# Allow overriding the target name when using FetchContent / add_subdirectory.
|
||||||
|
set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}" CACHE INTERNAL "")
|
||||||
|
set(NLOHMANN_JSON_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||||
|
set(NLOHMANN_JSON_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
|
||||||
|
set(NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE "cmake/config.cmake.in")
|
||||||
|
set(NLOHMANN_JSON_CMAKE_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
|
set(NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
|
||||||
|
set(NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Config.cmake")
|
||||||
|
set(NLOHMANN_JSON_CMAKE_PROJECT_TARGETS_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Targets.cmake")
|
||||||
|
set(NLOHMANN_JSON_PKGCONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/pkgconfig")
|
||||||
|
|
||||||
if (JSON_MultipleHeaders)
|
if (JSON_MultipleHeaders)
|
||||||
set(NLOHMANN_JSON_INCLUDE_BUILD_DIR "${PROJECT_SOURCE_DIR}/include/")
|
set(NLOHMANN_JSON_INCLUDE_BUILD_DIR "${PROJECT_SOURCE_DIR}/include/")
|
||||||
@ -25,6 +81,34 @@ else()
|
|||||||
message(STATUS "Using the single-header code from ${NLOHMANN_JSON_INCLUDE_BUILD_DIR}")
|
message(STATUS "Using the single-header code from ${NLOHMANN_JSON_INCLUDE_BUILD_DIR}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (NOT JSON_ImplicitConversions)
|
||||||
|
message(STATUS "Implicit conversions are disabled (JSON_USE_IMPLICIT_CONVERSIONS=0)")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (JSON_DisableEnumSerialization)
|
||||||
|
message(STATUS "Enum integer serialization is disabled (JSON_DISABLE_ENUM_SERIALIZATION=0)")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (JSON_LegacyDiscardedValueComparison)
|
||||||
|
message(STATUS "Legacy discarded value comparison enabled (JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON=1)")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (JSON_Diagnostics)
|
||||||
|
message(STATUS "Diagnostics enabled (JSON_DIAGNOSTICS=1)")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (JSON_Diagnostic_Positions)
|
||||||
|
message(STATUS "Diagnostic positions enabled (JSON_DIAGNOSTIC_POSITIONS=1)")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT JSON_GlobalUDLs)
|
||||||
|
message(STATUS "User-defined string literals are not put in the global namespace (JSON_USE_GLOBAL_UDLS=0)")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (JSON_SystemInclude)
|
||||||
|
set(NLOHMANN_JSON_SYSTEM_INCLUDE "SYSTEM")
|
||||||
|
endif()
|
||||||
|
|
||||||
##
|
##
|
||||||
## TARGET
|
## TARGET
|
||||||
## create target and add include path
|
## create target and add include path
|
||||||
@ -37,5 +121,105 @@ else()
|
|||||||
target_compile_features(${NLOHMANN_JSON_TARGET_NAME} INTERFACE cxx_std_11)
|
target_compile_features(${NLOHMANN_JSON_TARGET_NAME} INTERFACE cxx_std_11)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(${NLOHMANN_JSON_TARGET_NAME} INTERFACE ${NLOHMANN_JSON_INCLUDE_BUILD_DIR})
|
target_compile_definitions(
|
||||||
|
${NLOHMANN_JSON_TARGET_NAME}
|
||||||
|
INTERFACE
|
||||||
|
$<$<NOT:$<BOOL:${JSON_GlobalUDLs}>>:JSON_USE_GLOBAL_UDLS=0>
|
||||||
|
$<$<NOT:$<BOOL:${JSON_ImplicitConversions}>>:JSON_USE_IMPLICIT_CONVERSIONS=0>
|
||||||
|
$<$<BOOL:${JSON_DisableEnumSerialization}>:JSON_DISABLE_ENUM_SERIALIZATION=1>
|
||||||
|
$<$<BOOL:${JSON_Diagnostics}>:JSON_DIAGNOSTICS=1>
|
||||||
|
$<$<BOOL:${JSON_Diagnostic_Positions}>:JSON_DIAGNOSTIC_POSITIONS=1>
|
||||||
|
$<$<BOOL:${JSON_LegacyDiscardedValueComparison}>:JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON=1>
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(
|
||||||
|
${NLOHMANN_JSON_TARGET_NAME}
|
||||||
|
${NLOHMANN_JSON_SYSTEM_INCLUDE} INTERFACE
|
||||||
|
$<BUILD_INTERFACE:${NLOHMANN_JSON_INCLUDE_BUILD_DIR}>
|
||||||
|
$<INSTALL_INTERFACE:${NLOHMANN_JSON_INCLUDE_INSTALL_DIR}>
|
||||||
|
)
|
||||||
|
|
||||||
|
## add debug view definition file for msvc (natvis)
|
||||||
|
if (MSVC)
|
||||||
|
set(NLOHMANN_ADD_NATVIS TRUE)
|
||||||
|
set(NLOHMANN_NATVIS_FILE "nlohmann_json.natvis")
|
||||||
|
target_sources(
|
||||||
|
${NLOHMANN_JSON_TARGET_NAME}
|
||||||
|
INTERFACE
|
||||||
|
$<INSTALL_INTERFACE:${NLOHMANN_NATVIS_FILE}>
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${NLOHMANN_NATVIS_FILE}>
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Install a pkg-config file, so other tools can find this.
|
||||||
|
CONFIGURE_FILE(
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkg-config.pc.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
|
||||||
|
##
|
||||||
|
## TESTS
|
||||||
|
## create and configure the unit test target
|
||||||
|
##
|
||||||
|
if (JSON_BuildTests)
|
||||||
|
include(CTest)
|
||||||
|
enable_testing()
|
||||||
|
add_subdirectory(tests)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
##
|
||||||
|
## INSTALL
|
||||||
|
## install header files, generate and install cmake config files for find_package()
|
||||||
|
##
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
# use a custom package version config file instead of
|
||||||
|
# write_basic_package_version_file to ensure that it's architecture-independent
|
||||||
|
# https://github.com/nlohmann/json/issues/1697
|
||||||
|
configure_file(
|
||||||
|
"cmake/nlohmann_jsonConfigVersion.cmake.in"
|
||||||
|
${NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE}
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
configure_file(
|
||||||
|
${NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE}
|
||||||
|
${NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE}
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
|
||||||
|
if(JSON_Install)
|
||||||
|
install(
|
||||||
|
DIRECTORY ${NLOHMANN_JSON_INCLUDE_BUILD_DIR}
|
||||||
|
DESTINATION ${NLOHMANN_JSON_INCLUDE_INSTALL_DIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
FILES ${NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE} ${NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE}
|
||||||
|
DESTINATION ${NLOHMANN_JSON_CONFIG_INSTALL_DIR}
|
||||||
|
)
|
||||||
|
if (NLOHMANN_ADD_NATVIS)
|
||||||
|
install(
|
||||||
|
FILES ${NLOHMANN_NATVIS_FILE}
|
||||||
|
DESTINATION .
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
export(
|
||||||
|
TARGETS ${NLOHMANN_JSON_TARGET_NAME}
|
||||||
|
NAMESPACE ${PROJECT_NAME}::
|
||||||
|
FILE ${NLOHMANN_JSON_CMAKE_PROJECT_TARGETS_FILE}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
TARGETS ${NLOHMANN_JSON_TARGET_NAME}
|
||||||
|
EXPORT ${NLOHMANN_JSON_TARGETS_EXPORT_NAME}
|
||||||
|
INCLUDES DESTINATION ${NLOHMANN_JSON_INCLUDE_INSTALL_DIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
EXPORT ${NLOHMANN_JSON_TARGETS_EXPORT_NAME}
|
||||||
|
NAMESPACE ${PROJECT_NAME}::
|
||||||
|
DESTINATION ${NLOHMANN_JSON_CONFIG_INSTALL_DIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
|
||||||
|
DESTINATION ${NLOHMANN_JSON_PKGCONFIG_INSTALL_DIR}
|
||||||
|
)
|
||||||
|
include(CPack)
|
||||||
|
endif()
|
||||||
|
2
external/json/LICENSE.MIT
vendored
2
external/json/LICENSE.MIT
vendored
@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2013-2022 Niels Lohmann
|
Copyright (c) 2013-2025 Niels Lohmann
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
15
external/json/cmake/config.cmake.in
vendored
Normal file
15
external/json/cmake/config.cmake.in
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
set(${CMAKE_FIND_PACKAGE_NAME}_CONFIG ${CMAKE_CURRENT_LIST_FILE})
|
||||||
|
find_package_handle_standard_args(@PROJECT_NAME@ CONFIG_MODE)
|
||||||
|
|
||||||
|
if(NOT TARGET @PROJECT_NAME@::@NLOHMANN_JSON_TARGET_NAME@)
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/@NLOHMANN_JSON_TARGETS_EXPORT_NAME@.cmake")
|
||||||
|
if((NOT TARGET @NLOHMANN_JSON_TARGET_NAME@) AND
|
||||||
|
(NOT @PROJECT_NAME@_FIND_VERSION OR
|
||||||
|
@PROJECT_NAME@_FIND_VERSION VERSION_LESS 3.2.0))
|
||||||
|
add_library(@NLOHMANN_JSON_TARGET_NAME@ INTERFACE IMPORTED)
|
||||||
|
set_target_properties(@NLOHMANN_JSON_TARGET_NAME@ PROPERTIES
|
||||||
|
INTERFACE_LINK_LIBRARIES @PROJECT_NAME@::@NLOHMANN_JSON_TARGET_NAME@
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
20
external/json/cmake/nlohmann_jsonConfigVersion.cmake.in
vendored
Normal file
20
external/json/cmake/nlohmann_jsonConfigVersion.cmake.in
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# This is essentially cmake's BasicConfigVersion-SameMajorVersion.cmake.in but
|
||||||
|
# without the 32/64-bit check. Since json is a header-only library, it doesn't
|
||||||
|
# matter if it was built on a different platform than what it is used on (see
|
||||||
|
# https://github.com/nlohmann/json/issues/1697).
|
||||||
|
set(PACKAGE_VERSION "@PROJECT_VERSION@")
|
||||||
|
|
||||||
|
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
|
||||||
|
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||||
|
else()
|
||||||
|
|
||||||
|
if(PACKAGE_FIND_VERSION_MAJOR STREQUAL "@PROJECT_VERSION_MAJOR@")
|
||||||
|
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||||
|
else()
|
||||||
|
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
|
||||||
|
set(PACKAGE_VERSION_EXACT TRUE)
|
||||||
|
endif()
|
||||||
|
endif()
|
7
external/json/cmake/pkg-config.pc.in
vendored
Normal file
7
external/json/cmake/pkg-config.pc.in
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
prefix=@CMAKE_INSTALL_PREFIX@
|
||||||
|
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
||||||
|
|
||||||
|
Name: @PROJECT_NAME@
|
||||||
|
Description: JSON for Modern C++
|
||||||
|
Version: @PROJECT_VERSION@
|
||||||
|
Cflags: -I${includedir}
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -12,20 +12,24 @@
|
|||||||
|
|
||||||
#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
|
#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
|
||||||
#if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
|
#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
|
#if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 12 || NLOHMANN_JSON_VERSION_PATCH != 0
|
||||||
#warning "Already included a different version of the library!"
|
#warning "Already included a different version of the library!"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum)
|
#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_MINOR 12 // NOLINT(modernize-macro-to-enum)
|
||||||
#define NLOHMANN_JSON_VERSION_PATCH 1 // NOLINT(modernize-macro-to-enum)
|
#define NLOHMANN_JSON_VERSION_PATCH 0 // NOLINT(modernize-macro-to-enum)
|
||||||
|
|
||||||
#ifndef JSON_DIAGNOSTICS
|
#ifndef JSON_DIAGNOSTICS
|
||||||
#define JSON_DIAGNOSTICS 0
|
#define JSON_DIAGNOSTICS 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef JSON_DIAGNOSTIC_POSITIONS
|
||||||
|
#define JSON_DIAGNOSTIC_POSITIONS 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
|
#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
|
||||||
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
|
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
|
||||||
#endif
|
#endif
|
||||||
@ -36,44 +40,72 @@
|
|||||||
#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
|
#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if JSON_DIAGNOSTIC_POSITIONS
|
||||||
|
#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS _dp
|
||||||
|
#else
|
||||||
|
#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS
|
||||||
|
#endif
|
||||||
|
|
||||||
#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
|
#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
|
||||||
#define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
|
#define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
|
||||||
#else
|
#else
|
||||||
#define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
|
#define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NLOHMANN_JSON_ABI_PREFIX_EX(major, minor, patch) \
|
#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
|
||||||
json_v ## major ## _ ## minor ## _ ## patch
|
#define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
|
||||||
#define NLOHMANN_JSON_ABI_PREFIX(major, minor, patch) \
|
#endif
|
||||||
NLOHMANN_JSON_ABI_PREFIX_EX(major, minor, patch)
|
|
||||||
|
|
||||||
#define NLOHMANN_JSON_ABI_CONCAT_EX(a, b, c) a ## b ## c
|
// Construct the namespace ABI tags component
|
||||||
#define NLOHMANN_JSON_ABI_CONCAT(a, b, c) \
|
#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c) json_abi ## a ## b ## c
|
||||||
NLOHMANN_JSON_ABI_CONCAT_EX(a, b, c)
|
#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b, c) \
|
||||||
|
NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c)
|
||||||
|
|
||||||
#define NLOHMANN_JSON_ABI_STRING \
|
#define NLOHMANN_JSON_ABI_TAGS \
|
||||||
NLOHMANN_JSON_ABI_CONCAT( \
|
NLOHMANN_JSON_ABI_TAGS_CONCAT( \
|
||||||
NLOHMANN_JSON_ABI_PREFIX( \
|
NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
|
||||||
NLOHMANN_JSON_VERSION_MAJOR, \
|
NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON, \
|
||||||
NLOHMANN_JSON_VERSION_MINOR, \
|
NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS)
|
||||||
NLOHMANN_JSON_VERSION_PATCH), \
|
|
||||||
NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
|
// Construct the namespace version component
|
||||||
NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON)
|
#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
|
||||||
|
_v ## major ## _ ## minor ## _ ## patch
|
||||||
|
#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
|
||||||
|
NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
|
||||||
|
|
||||||
|
#if NLOHMANN_JSON_NAMESPACE_NO_VERSION
|
||||||
|
#define NLOHMANN_JSON_NAMESPACE_VERSION
|
||||||
|
#else
|
||||||
|
#define NLOHMANN_JSON_NAMESPACE_VERSION \
|
||||||
|
NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
|
||||||
|
NLOHMANN_JSON_VERSION_MINOR, \
|
||||||
|
NLOHMANN_JSON_VERSION_PATCH)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Combine namespace components
|
||||||
|
#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
|
||||||
|
#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
|
||||||
|
NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
|
||||||
|
|
||||||
#ifndef NLOHMANN_JSON_NAMESPACE
|
#ifndef NLOHMANN_JSON_NAMESPACE
|
||||||
#define NLOHMANN_JSON_NAMESPACE nlohmann::NLOHMANN_JSON_ABI_STRING
|
#define NLOHMANN_JSON_NAMESPACE \
|
||||||
|
nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
|
||||||
|
NLOHMANN_JSON_ABI_TAGS, \
|
||||||
|
NLOHMANN_JSON_NAMESPACE_VERSION)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
|
#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
#define NLOHMANN_JSON_NAMESPACE_BEGIN \
|
#define NLOHMANN_JSON_NAMESPACE_BEGIN \
|
||||||
namespace nlohmann \
|
namespace nlohmann \
|
||||||
{ \
|
{ \
|
||||||
inline namespace NLOHMANN_JSON_ABI_STRING \
|
inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
|
||||||
|
NLOHMANN_JSON_ABI_TAGS, \
|
||||||
|
NLOHMANN_JSON_NAMESPACE_VERSION) \
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NLOHMANN_JSON_NAMESPACE_END
|
#ifndef NLOHMANN_JSON_NAMESPACE_END
|
||||||
#define NLOHMANN_JSON_NAMESPACE_END \
|
#define NLOHMANN_JSON_NAMESPACE_END \
|
||||||
} /* namespace (abi_string) */ \
|
} /* namespace (inline namespace) NOLINT(readability/namespace) */ \
|
||||||
} /* namespace nlohmann */
|
} // namespace nlohmann
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -13,6 +13,9 @@
|
|||||||
#include <forward_list> // forward_list
|
#include <forward_list> // forward_list
|
||||||
#include <iterator> // inserter, front_inserter, end
|
#include <iterator> // inserter, front_inserter, end
|
||||||
#include <map> // map
|
#include <map> // map
|
||||||
|
#ifdef JSON_HAS_CPP_17
|
||||||
|
#include <optional> // optional
|
||||||
|
#endif
|
||||||
#include <string> // string
|
#include <string> // string
|
||||||
#include <tuple> // tuple, make_tuple
|
#include <tuple> // tuple, make_tuple
|
||||||
#include <type_traits> // is_arithmetic, is_same, is_enum, underlying_type, is_convertible
|
#include <type_traits> // is_arithmetic, is_same, is_enum, underlying_type, is_convertible
|
||||||
@ -43,6 +46,24 @@ inline void from_json(const BasicJsonType& j, typename std::nullptr_t& n)
|
|||||||
n = nullptr;
|
n = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef JSON_HAS_CPP_17
|
||||||
|
#ifndef JSON_USE_IMPLICIT_CONVERSIONS
|
||||||
|
template<typename BasicJsonType, typename T>
|
||||||
|
void from_json(const BasicJsonType& j, std::optional<T>& opt)
|
||||||
|
{
|
||||||
|
if (j.is_null())
|
||||||
|
{
|
||||||
|
opt = std::nullopt;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
opt.emplace(j.template get<T>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // JSON_USE_IMPLICIT_CONVERSIONS
|
||||||
|
#endif // JSON_HAS_CPP_17
|
||||||
|
|
||||||
// overloads for basic_json template parameters
|
// overloads for basic_json template parameters
|
||||||
template < typename BasicJsonType, typename ArithmeticType,
|
template < typename BasicJsonType, typename ArithmeticType,
|
||||||
enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
|
enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
|
||||||
@ -190,6 +211,54 @@ auto from_json(const BasicJsonType& j, T (&arr)[N]) // NOLINT(cppcoreguidelines
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BasicJsonType, typename T, std::size_t N1, std::size_t N2>
|
||||||
|
auto from_json(const BasicJsonType& j, T (&arr)[N1][N2]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||||
|
-> decltype(j.template get<T>(), void())
|
||||||
|
{
|
||||||
|
for (std::size_t i1 = 0; i1 < N1; ++i1)
|
||||||
|
{
|
||||||
|
for (std::size_t i2 = 0; i2 < N2; ++i2)
|
||||||
|
{
|
||||||
|
arr[i1][i2] = j.at(i1).at(i2).template get<T>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename BasicJsonType, typename T, std::size_t N1, std::size_t N2, std::size_t N3>
|
||||||
|
auto from_json(const BasicJsonType& j, T (&arr)[N1][N2][N3]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||||
|
-> decltype(j.template get<T>(), void())
|
||||||
|
{
|
||||||
|
for (std::size_t i1 = 0; i1 < N1; ++i1)
|
||||||
|
{
|
||||||
|
for (std::size_t i2 = 0; i2 < N2; ++i2)
|
||||||
|
{
|
||||||
|
for (std::size_t i3 = 0; i3 < N3; ++i3)
|
||||||
|
{
|
||||||
|
arr[i1][i2][i3] = j.at(i1).at(i2).at(i3).template get<T>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename BasicJsonType, typename T, std::size_t N1, std::size_t N2, std::size_t N3, std::size_t N4>
|
||||||
|
auto from_json(const BasicJsonType& j, T (&arr)[N1][N2][N3][N4]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||||
|
-> decltype(j.template get<T>(), void())
|
||||||
|
{
|
||||||
|
for (std::size_t i1 = 0; i1 < N1; ++i1)
|
||||||
|
{
|
||||||
|
for (std::size_t i2 = 0; i2 < N2; ++i2)
|
||||||
|
{
|
||||||
|
for (std::size_t i3 = 0; i3 < N3; ++i3)
|
||||||
|
{
|
||||||
|
for (std::size_t i4 = 0; i4 < N4; ++i4)
|
||||||
|
{
|
||||||
|
arr[i1][i2][i3][i4] = j.at(i1).at(i2).at(i3).at(i4).template get<T>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
inline 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*/)
|
||||||
{
|
{
|
||||||
@ -275,7 +344,7 @@ void())
|
|||||||
|
|
||||||
template < typename BasicJsonType, typename T, std::size_t... Idx >
|
template < typename BasicJsonType, typename T, std::size_t... Idx >
|
||||||
std::array<T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType&& j,
|
std::array<T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType&& j,
|
||||||
identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/)
|
identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/)
|
||||||
{
|
{
|
||||||
return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
|
return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
|
||||||
}
|
}
|
||||||
@ -379,6 +448,12 @@ std::tuple<Args...> from_json_tuple_impl_base(BasicJsonType&& j, index_sequence<
|
|||||||
return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).template get<Args>()...);
|
return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).template get<Args>()...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BasicJsonType>
|
||||||
|
std::tuple<> from_json_tuple_impl_base(BasicJsonType& /*unused*/, index_sequence<> /*unused*/)
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
template < typename BasicJsonType, class A1, class A2 >
|
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*/)
|
std::pair<A1, A2> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::pair<A1, A2>> /*unused*/, priority_tag<0> /*unused*/)
|
||||||
{
|
{
|
||||||
@ -464,7 +539,12 @@ inline void from_json(const BasicJsonType& j, std_fs::path& p)
|
|||||||
{
|
{
|
||||||
JSON_THROW(type_error::create(302, concat("type must be string, but is ", j.type_name()), &j));
|
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*>();
|
const auto& s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
|
||||||
|
#ifdef JSON_HAS_CPP_20
|
||||||
|
p = std_fs::path(std::u8string_view(reinterpret_cast<const char8_t*>(s.data()), s.size()));
|
||||||
|
#else
|
||||||
|
p = std_fs::u8path(s); // accepts UTF-8 encoded std::string in C++17, deprecated in C++20
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2009 Florian Loitsch <https://florian.loitsch.com/>
|
// SPDX-FileCopyrightText: 2009 Florian Loitsch <https://florian.loitsch.com/>
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -239,10 +239,10 @@ boundaries compute_boundaries(FloatType value)
|
|||||||
// v- m- v m+ v+
|
// v- m- v m+ v+
|
||||||
|
|
||||||
const bool lower_boundary_is_closer = F == 0 && E > 1;
|
const bool lower_boundary_is_closer = F == 0 && E > 1;
|
||||||
const diyfp m_plus = diyfp(2 * v.f + 1, v.e - 1);
|
const diyfp m_plus = diyfp((2 * v.f) + 1, v.e - 1);
|
||||||
const diyfp m_minus = lower_boundary_is_closer
|
const diyfp m_minus = lower_boundary_is_closer
|
||||||
? diyfp(4 * v.f - 1, v.e - 2) // (B)
|
? diyfp((4 * v.f) - 1, v.e - 2) // (B)
|
||||||
: diyfp(2 * v.f - 1, v.e - 1); // (A)
|
: diyfp((2 * v.f) - 1, v.e - 1); // (A)
|
||||||
|
|
||||||
// Determine the normalized w+ = m+.
|
// Determine the normalized w+ = m+.
|
||||||
const diyfp w_plus = diyfp::normalize(m_plus);
|
const diyfp w_plus = diyfp::normalize(m_plus);
|
||||||
@ -472,7 +472,7 @@ inline cached_power get_cached_power_for_binary_exponent(int e)
|
|||||||
JSON_ASSERT(e >= -1500);
|
JSON_ASSERT(e >= -1500);
|
||||||
JSON_ASSERT(e <= 1500);
|
JSON_ASSERT(e <= 1500);
|
||||||
const int f = kAlpha - e - 1;
|
const int f = kAlpha - e - 1;
|
||||||
const int k = (f * 78913) / (1 << 18) + static_cast<int>(f > 0);
|
const int k = ((f * 78913) / (1 << 18)) + static_cast<int>(f > 0);
|
||||||
|
|
||||||
const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
|
const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
|
||||||
JSON_ASSERT(index >= 0);
|
JSON_ASSERT(index >= 0);
|
||||||
@ -909,7 +909,7 @@ void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value)
|
|||||||
// NB: If the neighbors are computed for single-precision numbers, there is a single float
|
// NB: If the neighbors are computed for single-precision numbers, there is a single float
|
||||||
// (7.0385307e-26f) which can't be recovered using strtod. The resulting double precision
|
// (7.0385307e-26f) which can't be recovered using strtod. The resulting double precision
|
||||||
// value is off by 1 ulp.
|
// value is off by 1 ulp.
|
||||||
#if 0
|
#if 0 // NOLINT(readability-avoid-unconditional-preprocessor-if)
|
||||||
const boundaries w = compute_boundaries(static_cast<double>(value));
|
const boundaries w = compute_boundaries(static_cast<double>(value));
|
||||||
#else
|
#else
|
||||||
const boundaries w = compute_boundaries(value);
|
const boundaries w = compute_boundaries(value);
|
||||||
@ -950,15 +950,15 @@ inline char* append_exponent(char* buf, int e)
|
|||||||
}
|
}
|
||||||
else if (k < 100)
|
else if (k < 100)
|
||||||
{
|
{
|
||||||
*buf++ = static_cast<char>('0' + k / 10);
|
*buf++ = static_cast<char>('0' + (k / 10));
|
||||||
k %= 10;
|
k %= 10;
|
||||||
*buf++ = static_cast<char>('0' + k);
|
*buf++ = static_cast<char>('0' + k);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*buf++ = static_cast<char>('0' + k / 100);
|
*buf++ = static_cast<char>('0' + (k / 100));
|
||||||
k %= 100;
|
k %= 100;
|
||||||
*buf++ = static_cast<char>('0' + k / 10);
|
*buf++ = static_cast<char>('0' + (k / 10));
|
||||||
k %= 10;
|
k %= 10;
|
||||||
*buf++ = static_cast<char>('0' + k);
|
*buf++ = static_cast<char>('0' + k);
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <nlohmann/detail/macro_scope.hpp> // JSON_HAS_CPP_17
|
||||||
|
#ifdef JSON_HAS_CPP_17
|
||||||
|
#include <optional> // optional
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <algorithm> // copy
|
#include <algorithm> // copy
|
||||||
#include <iterator> // begin, end
|
#include <iterator> // begin, end
|
||||||
#include <string> // string
|
#include <string> // string
|
||||||
@ -18,7 +23,6 @@
|
|||||||
#include <vector> // vector
|
#include <vector> // vector
|
||||||
|
|
||||||
#include <nlohmann/detail/iterators/iteration_proxy.hpp>
|
#include <nlohmann/detail/iterators/iteration_proxy.hpp>
|
||||||
#include <nlohmann/detail/macro_scope.hpp>
|
|
||||||
#include <nlohmann/detail/meta/cpp_future.hpp>
|
#include <nlohmann/detail/meta/cpp_future.hpp>
|
||||||
#include <nlohmann/detail/meta/std_fs.hpp>
|
#include <nlohmann/detail/meta/std_fs.hpp>
|
||||||
#include <nlohmann/detail/meta/type_traits.hpp>
|
#include <nlohmann/detail/meta/type_traits.hpp>
|
||||||
@ -34,7 +38,7 @@ namespace detail
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Note all external_constructor<>::construct functions need to call
|
* 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
|
* j.m_data.m_value.destroy(j.m_data.m_type) to avoid a memory leak in case j contains an
|
||||||
* allocated value (e.g., a string). See bug issue
|
* allocated value (e.g., a string). See bug issue
|
||||||
* https://github.com/nlohmann/json/issues/2865 for more information.
|
* https://github.com/nlohmann/json/issues/2865 for more information.
|
||||||
*/
|
*/
|
||||||
@ -47,9 +51,9 @@ struct external_constructor<value_t::boolean>
|
|||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
static void construct(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept
|
static void construct(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept
|
||||||
{
|
{
|
||||||
j.m_value.destroy(j.m_type);
|
j.m_data.m_value.destroy(j.m_data.m_type);
|
||||||
j.m_type = value_t::boolean;
|
j.m_data.m_type = value_t::boolean;
|
||||||
j.m_value = b;
|
j.m_data.m_value = b;
|
||||||
j.assert_invariant();
|
j.assert_invariant();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -60,18 +64,18 @@ struct external_constructor<value_t::string>
|
|||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
static void construct(BasicJsonType& j, const typename BasicJsonType::string_t& s)
|
static void construct(BasicJsonType& j, const typename BasicJsonType::string_t& s)
|
||||||
{
|
{
|
||||||
j.m_value.destroy(j.m_type);
|
j.m_data.m_value.destroy(j.m_data.m_type);
|
||||||
j.m_type = value_t::string;
|
j.m_data.m_type = value_t::string;
|
||||||
j.m_value = s;
|
j.m_data.m_value = s;
|
||||||
j.assert_invariant();
|
j.assert_invariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
static void construct(BasicJsonType& j, typename BasicJsonType::string_t&& s)
|
static void construct(BasicJsonType& j, typename BasicJsonType::string_t&& s)
|
||||||
{
|
{
|
||||||
j.m_value.destroy(j.m_type);
|
j.m_data.m_value.destroy(j.m_data.m_type);
|
||||||
j.m_type = value_t::string;
|
j.m_data.m_type = value_t::string;
|
||||||
j.m_value = std::move(s);
|
j.m_data.m_value = std::move(s);
|
||||||
j.assert_invariant();
|
j.assert_invariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,9 +84,9 @@ struct external_constructor<value_t::string>
|
|||||||
int > = 0 >
|
int > = 0 >
|
||||||
static void construct(BasicJsonType& j, const CompatibleStringType& str)
|
static void construct(BasicJsonType& j, const CompatibleStringType& str)
|
||||||
{
|
{
|
||||||
j.m_value.destroy(j.m_type);
|
j.m_data.m_value.destroy(j.m_data.m_type);
|
||||||
j.m_type = value_t::string;
|
j.m_data.m_type = value_t::string;
|
||||||
j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
|
j.m_data.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
|
||||||
j.assert_invariant();
|
j.assert_invariant();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -93,18 +97,18 @@ struct external_constructor<value_t::binary>
|
|||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
static void construct(BasicJsonType& j, const typename BasicJsonType::binary_t& b)
|
static void construct(BasicJsonType& j, const typename BasicJsonType::binary_t& b)
|
||||||
{
|
{
|
||||||
j.m_value.destroy(j.m_type);
|
j.m_data.m_value.destroy(j.m_data.m_type);
|
||||||
j.m_type = value_t::binary;
|
j.m_data.m_type = value_t::binary;
|
||||||
j.m_value = typename BasicJsonType::binary_t(b);
|
j.m_data.m_value = typename BasicJsonType::binary_t(b);
|
||||||
j.assert_invariant();
|
j.assert_invariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
static void construct(BasicJsonType& j, typename BasicJsonType::binary_t&& b)
|
static void construct(BasicJsonType& j, typename BasicJsonType::binary_t&& b)
|
||||||
{
|
{
|
||||||
j.m_value.destroy(j.m_type);
|
j.m_data.m_value.destroy(j.m_data.m_type);
|
||||||
j.m_type = value_t::binary;
|
j.m_data.m_type = value_t::binary;
|
||||||
j.m_value = typename BasicJsonType::binary_t(std::move(b));
|
j.m_data.m_value = typename BasicJsonType::binary_t(std::move(b));
|
||||||
j.assert_invariant();
|
j.assert_invariant();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -115,9 +119,9 @@ struct external_constructor<value_t::number_float>
|
|||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
static void construct(BasicJsonType& j, typename BasicJsonType::number_float_t val) noexcept
|
static void construct(BasicJsonType& j, typename BasicJsonType::number_float_t val) noexcept
|
||||||
{
|
{
|
||||||
j.m_value.destroy(j.m_type);
|
j.m_data.m_value.destroy(j.m_data.m_type);
|
||||||
j.m_type = value_t::number_float;
|
j.m_data.m_type = value_t::number_float;
|
||||||
j.m_value = val;
|
j.m_data.m_value = val;
|
||||||
j.assert_invariant();
|
j.assert_invariant();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -128,9 +132,9 @@ struct external_constructor<value_t::number_unsigned>
|
|||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
static void construct(BasicJsonType& j, typename BasicJsonType::number_unsigned_t val) noexcept
|
static void construct(BasicJsonType& j, typename BasicJsonType::number_unsigned_t val) noexcept
|
||||||
{
|
{
|
||||||
j.m_value.destroy(j.m_type);
|
j.m_data.m_value.destroy(j.m_data.m_type);
|
||||||
j.m_type = value_t::number_unsigned;
|
j.m_data.m_type = value_t::number_unsigned;
|
||||||
j.m_value = val;
|
j.m_data.m_value = val;
|
||||||
j.assert_invariant();
|
j.assert_invariant();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -141,9 +145,9 @@ struct external_constructor<value_t::number_integer>
|
|||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
static void construct(BasicJsonType& j, typename BasicJsonType::number_integer_t val) noexcept
|
static void construct(BasicJsonType& j, typename BasicJsonType::number_integer_t val) noexcept
|
||||||
{
|
{
|
||||||
j.m_value.destroy(j.m_type);
|
j.m_data.m_value.destroy(j.m_data.m_type);
|
||||||
j.m_type = value_t::number_integer;
|
j.m_data.m_type = value_t::number_integer;
|
||||||
j.m_value = val;
|
j.m_data.m_value = val;
|
||||||
j.assert_invariant();
|
j.assert_invariant();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -154,9 +158,9 @@ struct external_constructor<value_t::array>
|
|||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
static void construct(BasicJsonType& j, const typename BasicJsonType::array_t& arr)
|
static void construct(BasicJsonType& j, const typename BasicJsonType::array_t& arr)
|
||||||
{
|
{
|
||||||
j.m_value.destroy(j.m_type);
|
j.m_data.m_value.destroy(j.m_data.m_type);
|
||||||
j.m_type = value_t::array;
|
j.m_data.m_type = value_t::array;
|
||||||
j.m_value = arr;
|
j.m_data.m_value = arr;
|
||||||
j.set_parents();
|
j.set_parents();
|
||||||
j.assert_invariant();
|
j.assert_invariant();
|
||||||
}
|
}
|
||||||
@ -164,9 +168,9 @@ struct external_constructor<value_t::array>
|
|||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
static void construct(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
|
static void construct(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
|
||||||
{
|
{
|
||||||
j.m_value.destroy(j.m_type);
|
j.m_data.m_value.destroy(j.m_data.m_type);
|
||||||
j.m_type = value_t::array;
|
j.m_data.m_type = value_t::array;
|
||||||
j.m_value = std::move(arr);
|
j.m_data.m_value = std::move(arr);
|
||||||
j.set_parents();
|
j.set_parents();
|
||||||
j.assert_invariant();
|
j.assert_invariant();
|
||||||
}
|
}
|
||||||
@ -179,9 +183,9 @@ struct external_constructor<value_t::array>
|
|||||||
using std::begin;
|
using std::begin;
|
||||||
using std::end;
|
using std::end;
|
||||||
|
|
||||||
j.m_value.destroy(j.m_type);
|
j.m_data.m_value.destroy(j.m_data.m_type);
|
||||||
j.m_type = value_t::array;
|
j.m_data.m_type = value_t::array;
|
||||||
j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
|
j.m_data.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
|
||||||
j.set_parents();
|
j.set_parents();
|
||||||
j.assert_invariant();
|
j.assert_invariant();
|
||||||
}
|
}
|
||||||
@ -189,14 +193,14 @@ struct external_constructor<value_t::array>
|
|||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
static void construct(BasicJsonType& j, const std::vector<bool>& arr)
|
static void construct(BasicJsonType& j, const std::vector<bool>& arr)
|
||||||
{
|
{
|
||||||
j.m_value.destroy(j.m_type);
|
j.m_data.m_value.destroy(j.m_data.m_type);
|
||||||
j.m_type = value_t::array;
|
j.m_data.m_type = value_t::array;
|
||||||
j.m_value = value_t::array;
|
j.m_data.m_value = value_t::array;
|
||||||
j.m_value.array->reserve(arr.size());
|
j.m_data.m_value.array->reserve(arr.size());
|
||||||
for (const bool x : arr)
|
for (const bool x : arr)
|
||||||
{
|
{
|
||||||
j.m_value.array->push_back(x);
|
j.m_data.m_value.array->push_back(x);
|
||||||
j.set_parent(j.m_value.array->back());
|
j.set_parent(j.m_data.m_value.array->back());
|
||||||
}
|
}
|
||||||
j.assert_invariant();
|
j.assert_invariant();
|
||||||
}
|
}
|
||||||
@ -205,13 +209,13 @@ struct external_constructor<value_t::array>
|
|||||||
enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0>
|
enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0>
|
||||||
static void construct(BasicJsonType& j, const std::valarray<T>& arr)
|
static void construct(BasicJsonType& j, const std::valarray<T>& arr)
|
||||||
{
|
{
|
||||||
j.m_value.destroy(j.m_type);
|
j.m_data.m_value.destroy(j.m_data.m_type);
|
||||||
j.m_type = value_t::array;
|
j.m_data.m_type = value_t::array;
|
||||||
j.m_value = value_t::array;
|
j.m_data.m_value = value_t::array;
|
||||||
j.m_value.array->resize(arr.size());
|
j.m_data.m_value.array->resize(arr.size());
|
||||||
if (arr.size() > 0)
|
if (arr.size() > 0)
|
||||||
{
|
{
|
||||||
std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
|
std::copy(std::begin(arr), std::end(arr), j.m_data.m_value.array->begin());
|
||||||
}
|
}
|
||||||
j.set_parents();
|
j.set_parents();
|
||||||
j.assert_invariant();
|
j.assert_invariant();
|
||||||
@ -224,9 +228,9 @@ struct external_constructor<value_t::object>
|
|||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj)
|
static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj)
|
||||||
{
|
{
|
||||||
j.m_value.destroy(j.m_type);
|
j.m_data.m_value.destroy(j.m_data.m_type);
|
||||||
j.m_type = value_t::object;
|
j.m_data.m_type = value_t::object;
|
||||||
j.m_value = obj;
|
j.m_data.m_value = obj;
|
||||||
j.set_parents();
|
j.set_parents();
|
||||||
j.assert_invariant();
|
j.assert_invariant();
|
||||||
}
|
}
|
||||||
@ -234,9 +238,9 @@ struct external_constructor<value_t::object>
|
|||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
static void construct(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
|
static void construct(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
|
||||||
{
|
{
|
||||||
j.m_value.destroy(j.m_type);
|
j.m_data.m_value.destroy(j.m_data.m_type);
|
||||||
j.m_type = value_t::object;
|
j.m_data.m_type = value_t::object;
|
||||||
j.m_value = std::move(obj);
|
j.m_data.m_value = std::move(obj);
|
||||||
j.set_parents();
|
j.set_parents();
|
||||||
j.assert_invariant();
|
j.assert_invariant();
|
||||||
}
|
}
|
||||||
@ -248,9 +252,9 @@ struct external_constructor<value_t::object>
|
|||||||
using std::begin;
|
using std::begin;
|
||||||
using std::end;
|
using std::end;
|
||||||
|
|
||||||
j.m_value.destroy(j.m_type);
|
j.m_data.m_value.destroy(j.m_data.m_type);
|
||||||
j.m_type = value_t::object;
|
j.m_data.m_type = value_t::object;
|
||||||
j.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
|
j.m_data.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
|
||||||
j.set_parents();
|
j.set_parents();
|
||||||
j.assert_invariant();
|
j.assert_invariant();
|
||||||
}
|
}
|
||||||
@ -260,6 +264,22 @@ struct external_constructor<value_t::object>
|
|||||||
// to_json //
|
// to_json //
|
||||||
/////////////
|
/////////////
|
||||||
|
|
||||||
|
#ifdef JSON_HAS_CPP_17
|
||||||
|
template<typename BasicJsonType, typename T,
|
||||||
|
enable_if_t<std::is_constructible<BasicJsonType, T>::value, int> = 0>
|
||||||
|
void to_json(BasicJsonType& j, const std::optional<T>& opt)
|
||||||
|
{
|
||||||
|
if (opt.has_value())
|
||||||
|
{
|
||||||
|
j = *opt;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
j = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<typename BasicJsonType, typename T,
|
template<typename BasicJsonType, typename T,
|
||||||
enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value, int> = 0>
|
enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value, int> = 0>
|
||||||
inline void to_json(BasicJsonType& j, T b) noexcept
|
inline void to_json(BasicJsonType& j, T b) noexcept
|
||||||
@ -267,9 +287,15 @@ inline void to_json(BasicJsonType& j, T b) noexcept
|
|||||||
external_constructor<value_t::boolean>::construct(j, b);
|
external_constructor<value_t::boolean>::construct(j, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename BasicJsonType,
|
template < typename BasicJsonType, typename BoolRef,
|
||||||
enable_if_t<std::is_convertible<const std::vector<bool>::reference&, typename BasicJsonType::boolean_t>::value, int> = 0>
|
enable_if_t <
|
||||||
inline void to_json(BasicJsonType& j, const std::vector<bool>::reference& b) noexcept
|
((std::is_same<std::vector<bool>::reference, BoolRef>::value
|
||||||
|
&& !std::is_same <std::vector<bool>::reference, typename BasicJsonType::boolean_t&>::value)
|
||||||
|
|| (std::is_same<std::vector<bool>::const_reference, BoolRef>::value
|
||||||
|
&& !std::is_same <detail::uncvref_t<std::vector<bool>::const_reference>,
|
||||||
|
typename BasicJsonType::boolean_t >::value))
|
||||||
|
&& std::is_convertible<const BoolRef&, typename BasicJsonType::boolean_t>::value, int > = 0 >
|
||||||
|
inline void to_json(BasicJsonType& j, const BoolRef& b) noexcept
|
||||||
{
|
{
|
||||||
external_constructor<value_t::boolean>::construct(j, static_cast<typename BasicJsonType::boolean_t>(b));
|
external_constructor<value_t::boolean>::construct(j, static_cast<typename BasicJsonType::boolean_t>(b));
|
||||||
}
|
}
|
||||||
@ -314,7 +340,8 @@ template<typename BasicJsonType, typename EnumType,
|
|||||||
inline 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;
|
using underlying_type = typename std::underlying_type<EnumType>::type;
|
||||||
external_constructor<value_t::number_integer>::construct(j, static_cast<underlying_type>(e));
|
static constexpr value_t integral_value_t = std::is_unsigned<underlying_type>::value ? value_t::number_unsigned : value_t::number_integer;
|
||||||
|
external_constructor<integral_value_t>::construct(j, static_cast<underlying_type>(e));
|
||||||
}
|
}
|
||||||
#endif // JSON_DISABLE_ENUM_SERIALIZATION
|
#endif // JSON_DISABLE_ENUM_SERIALIZATION
|
||||||
|
|
||||||
@ -399,6 +426,13 @@ inline void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence<
|
|||||||
j = { std::get<Idx>(t)... };
|
j = { std::get<Idx>(t)... };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BasicJsonType, typename Tuple>
|
||||||
|
inline void to_json_tuple_impl(BasicJsonType& j, const Tuple& /*unused*/, index_sequence<> /*unused*/)
|
||||||
|
{
|
||||||
|
using array_t = typename BasicJsonType::array_t;
|
||||||
|
j = array_t();
|
||||||
|
}
|
||||||
|
|
||||||
template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value, int > = 0>
|
template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value, int > = 0>
|
||||||
inline void to_json(BasicJsonType& j, const T& t)
|
inline void to_json(BasicJsonType& j, const T& t)
|
||||||
{
|
{
|
||||||
@ -409,7 +443,12 @@ inline void to_json(BasicJsonType& j, const T& t)
|
|||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
inline void to_json(BasicJsonType& j, const std_fs::path& p)
|
inline void to_json(BasicJsonType& j, const std_fs::path& p)
|
||||||
{
|
{
|
||||||
j = p.string();
|
#ifdef JSON_HAS_CPP_20
|
||||||
|
const std::u8string s = p.u8string();
|
||||||
|
j = std::string(s.begin(), s.end());
|
||||||
|
#else
|
||||||
|
j = p.u8string(); // returns std::string in C++17
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstddef> // nullptr_t
|
#include <cstddef> // nullptr_t
|
||||||
#include <exception> // exception
|
#include <exception> // exception
|
||||||
|
#if JSON_DIAGNOSTICS
|
||||||
|
#include <numeric> // accumulate
|
||||||
|
#endif
|
||||||
#include <stdexcept> // runtime_error
|
#include <stdexcept> // runtime_error
|
||||||
#include <string> // to_string
|
#include <string> // to_string
|
||||||
#include <vector> // vector
|
#include <vector> // vector
|
||||||
@ -22,6 +25,17 @@
|
|||||||
#include <nlohmann/detail/meta/type_traits.hpp>
|
#include <nlohmann/detail/meta/type_traits.hpp>
|
||||||
#include <nlohmann/detail/string_concat.hpp>
|
#include <nlohmann/detail/string_concat.hpp>
|
||||||
|
|
||||||
|
// With -Wweak-vtables, Clang will complain about the exception classes as they
|
||||||
|
// have no out-of-line virtual method definitions and their vtable will be
|
||||||
|
// emitted in every translation unit. This issue cannot be fixed with a
|
||||||
|
// header-only library as there is no implementation file to move these
|
||||||
|
// functions to. As a result, we suppress this warning here to avoid client
|
||||||
|
// code to stumble over this. See https://github.com/nlohmann/json/issues/4087
|
||||||
|
// for a discussion.
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wweak-vtables"
|
||||||
|
#endif
|
||||||
|
|
||||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
namespace detail
|
namespace detail
|
||||||
@ -70,9 +84,9 @@ class exception : public std::exception
|
|||||||
{
|
{
|
||||||
case value_t::array:
|
case value_t::array:
|
||||||
{
|
{
|
||||||
for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i)
|
for (std::size_t i = 0; i < current->m_parent->m_data.m_value.array->size(); ++i)
|
||||||
{
|
{
|
||||||
if (¤t->m_parent->m_value.array->operator[](i) == current)
|
if (¤t->m_parent->m_data.m_value.array->operator[](i) == current)
|
||||||
{
|
{
|
||||||
tokens.emplace_back(std::to_string(i));
|
tokens.emplace_back(std::to_string(i));
|
||||||
break;
|
break;
|
||||||
@ -83,7 +97,7 @@ class exception : public std::exception
|
|||||||
|
|
||||||
case value_t::object:
|
case value_t::object:
|
||||||
{
|
{
|
||||||
for (const auto& element : *current->m_parent->m_value.object)
|
for (const auto& element : *current->m_parent->m_data.m_value.object)
|
||||||
{
|
{
|
||||||
if (&element.second == current)
|
if (&element.second == current)
|
||||||
{
|
{
|
||||||
@ -117,16 +131,34 @@ class exception : public std::exception
|
|||||||
{
|
{
|
||||||
return concat(a, '/', detail::escape(b));
|
return concat(a, '/', detail::escape(b));
|
||||||
});
|
});
|
||||||
return concat('(', str, ") ");
|
|
||||||
|
return concat('(', str, ") ", get_byte_positions(leaf_element));
|
||||||
#else
|
#else
|
||||||
static_cast<void>(leaf_element);
|
return get_byte_positions(leaf_element);
|
||||||
return "";
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// an exception object as storage for error messages
|
/// an exception object as storage for error messages
|
||||||
std::runtime_error m;
|
std::runtime_error m;
|
||||||
|
#if JSON_DIAGNOSTIC_POSITIONS
|
||||||
|
template<typename BasicJsonType>
|
||||||
|
static std::string get_byte_positions(const BasicJsonType* leaf_element)
|
||||||
|
{
|
||||||
|
if ((leaf_element->start_pos() != std::string::npos) && (leaf_element->end_pos() != std::string::npos))
|
||||||
|
{
|
||||||
|
return concat("(bytes ", std::to_string(leaf_element->start_pos()), "-", std::to_string(leaf_element->end_pos()), ") ");
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
template<typename BasicJsonType>
|
||||||
|
static std::string get_byte_positions(const BasicJsonType* leaf_element)
|
||||||
|
{
|
||||||
|
static_cast<void>(leaf_element);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @brief exception indicating a parse error
|
/// @brief exception indicating a parse error
|
||||||
@ -146,17 +178,17 @@ class parse_error : public exception
|
|||||||
template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0>
|
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)
|
static parse_error create(int id_, const position_t& pos, const std::string& what_arg, BasicJsonContext context)
|
||||||
{
|
{
|
||||||
std::string w = concat(exception::name("parse_error", id_), "parse error",
|
const std::string w = concat(exception::name("parse_error", id_), "parse error",
|
||||||
position_string(pos), ": ", exception::diagnostics(context), what_arg);
|
position_string(pos), ": ", exception::diagnostics(context), what_arg);
|
||||||
return {id_, pos.chars_read_total, w.c_str()};
|
return {id_, pos.chars_read_total, w.c_str()};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0>
|
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)
|
static parse_error create(int id_, std::size_t byte_, const std::string& what_arg, BasicJsonContext context)
|
||||||
{
|
{
|
||||||
std::string w = concat(exception::name("parse_error", id_), "parse error",
|
const std::string w = concat(exception::name("parse_error", id_), "parse error",
|
||||||
(byte_ != 0 ? (concat(" at byte ", std::to_string(byte_))) : ""),
|
(byte_ != 0 ? (concat(" at byte ", std::to_string(byte_))) : ""),
|
||||||
": ", exception::diagnostics(context), what_arg);
|
": ", exception::diagnostics(context), what_arg);
|
||||||
return {id_, byte_, w.c_str()};
|
return {id_, byte_, w.c_str()};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +222,7 @@ class invalid_iterator : public exception
|
|||||||
template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0>
|
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)
|
static invalid_iterator create(int id_, const std::string& what_arg, BasicJsonContext context)
|
||||||
{
|
{
|
||||||
std::string w = concat(exception::name("invalid_iterator", id_), exception::diagnostics(context), what_arg);
|
const std::string w = concat(exception::name("invalid_iterator", id_), exception::diagnostics(context), what_arg);
|
||||||
return {id_, w.c_str()};
|
return {id_, w.c_str()};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +240,7 @@ class type_error : public exception
|
|||||||
template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0>
|
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)
|
static type_error create(int id_, const std::string& what_arg, BasicJsonContext context)
|
||||||
{
|
{
|
||||||
std::string w = concat(exception::name("type_error", id_), exception::diagnostics(context), what_arg);
|
const std::string w = concat(exception::name("type_error", id_), exception::diagnostics(context), what_arg);
|
||||||
return {id_, w.c_str()};
|
return {id_, w.c_str()};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +257,7 @@ class out_of_range : public exception
|
|||||||
template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0>
|
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)
|
static out_of_range create(int id_, const std::string& what_arg, BasicJsonContext context)
|
||||||
{
|
{
|
||||||
std::string w = concat(exception::name("out_of_range", id_), exception::diagnostics(context), what_arg);
|
const std::string w = concat(exception::name("out_of_range", id_), exception::diagnostics(context), what_arg);
|
||||||
return {id_, w.c_str()};
|
return {id_, w.c_str()};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +274,7 @@ class other_error : public exception
|
|||||||
template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0>
|
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)
|
static other_error create(int id_, const std::string& what_arg, BasicJsonContext context)
|
||||||
{
|
{
|
||||||
std::string w = concat(exception::name("other_error", id_), exception::diagnostics(context), what_arg);
|
const std::string w = concat(exception::name("other_error", id_), exception::diagnostics(context), what_arg);
|
||||||
return {id_, w.c_str()};
|
return {id_, w.c_str()};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,3 +285,7 @@ class other_error : public exception
|
|||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
NLOHMANN_JSON_NAMESPACE_END
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -20,7 +20,9 @@
|
|||||||
#include <string> // char_traits, string
|
#include <string> // char_traits, string
|
||||||
#include <utility> // make_pair, move
|
#include <utility> // make_pair, move
|
||||||
#include <vector> // vector
|
#include <vector> // vector
|
||||||
#include <map> // map
|
#ifdef __cpp_lib_byteswap
|
||||||
|
#include <bit> //byteswap
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <nlohmann/detail/exceptions.hpp>
|
#include <nlohmann/detail/exceptions.hpp>
|
||||||
#include <nlohmann/detail/input/input_adapters.hpp>
|
#include <nlohmann/detail/input/input_adapters.hpp>
|
||||||
@ -56,7 +58,6 @@ static inline bool little_endianness(int num = 1) noexcept
|
|||||||
return *reinterpret_cast<char*>(&num) == 1;
|
return *reinterpret_cast<char*>(&num) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
// binary reader //
|
// binary reader //
|
||||||
///////////////////
|
///////////////////
|
||||||
@ -64,7 +65,7 @@ static inline bool little_endianness(int num = 1) noexcept
|
|||||||
/*!
|
/*!
|
||||||
@brief deserialization of CBOR, MessagePack, and UBJSON values
|
@brief deserialization of CBOR, MessagePack, and UBJSON values
|
||||||
*/
|
*/
|
||||||
template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType>>
|
template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
|
||||||
class binary_reader
|
class binary_reader
|
||||||
{
|
{
|
||||||
using number_integer_t = typename BasicJsonType::number_integer_t;
|
using number_integer_t = typename BasicJsonType::number_integer_t;
|
||||||
@ -74,7 +75,7 @@ class binary_reader
|
|||||||
using binary_t = typename BasicJsonType::binary_t;
|
using binary_t = typename BasicJsonType::binary_t;
|
||||||
using json_sax_t = SAX;
|
using json_sax_t = SAX;
|
||||||
using char_type = typename InputAdapterType::char_type;
|
using char_type = typename InputAdapterType::char_type;
|
||||||
using char_int_type = typename std::char_traits<char_type>::int_type;
|
using char_int_type = typename char_traits<char_type>::int_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
@ -147,7 +148,7 @@ class binary_reader
|
|||||||
get();
|
get();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JSON_HEDLEY_UNLIKELY(current != std::char_traits<char_type>::eof()))
|
if (JSON_HEDLEY_UNLIKELY(current != char_traits<char_type>::eof()))
|
||||||
{
|
{
|
||||||
return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read,
|
return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read,
|
||||||
exception_message(input_format, concat("expected end of input; last byte: 0x", get_token_string()), "value"), nullptr));
|
exception_message(input_format, concat("expected end of input; last byte: 0x", get_token_string()), "value"), nullptr));
|
||||||
@ -171,7 +172,7 @@ class binary_reader
|
|||||||
std::int32_t document_size{};
|
std::int32_t document_size{};
|
||||||
get_number<std::int32_t, true>(input_format_t::bson, document_size);
|
get_number<std::int32_t, true>(input_format_t::bson, document_size);
|
||||||
|
|
||||||
if (JSON_HEDLEY_UNLIKELY(!sax->start_object(static_cast<std::size_t>(-1))))
|
if (JSON_HEDLEY_UNLIKELY(!sax->start_object(detail::unknown_size())))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -230,7 +231,7 @@ class binary_reader
|
|||||||
exception_message(input_format_t::bson, concat("string length must be at least 1, is ", std::to_string(len)), "string"), nullptr));
|
exception_message(input_format_t::bson, concat("string length must be at least 1, is ", std::to_string(len)), "string"), nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
return get_string(input_format_t::bson, len - static_cast<NumberType>(1), result) && get() != std::char_traits<char_type>::eof();
|
return get_string(input_format_t::bson, len - static_cast<NumberType>(1), result) && get() != char_traits<char_type>::eof();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -327,11 +328,17 @@ class binary_reader
|
|||||||
return get_number<std::int64_t, true>(input_format_t::bson, value) && sax->number_integer(value);
|
return get_number<std::int64_t, true>(input_format_t::bson, value) && sax->number_integer(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 0x11: // uint64
|
||||||
|
{
|
||||||
|
std::uint64_t value{};
|
||||||
|
return get_number<std::uint64_t, true>(input_format_t::bson, value) && sax->number_unsigned(value);
|
||||||
|
}
|
||||||
|
|
||||||
default: // anything else not supported (yet)
|
default: // anything else not supported (yet)
|
||||||
{
|
{
|
||||||
std::array<char, 3> cr{{}};
|
std::array<char, 3> cr{{}};
|
||||||
static_cast<void>((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(element_type))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
static_cast<void>((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(element_type))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
||||||
std::string cr_str{cr.data()};
|
const std::string cr_str{cr.data()};
|
||||||
return sax->parse_error(element_type_parse_position, cr_str,
|
return sax->parse_error(element_type_parse_position, cr_str,
|
||||||
parse_error::create(114, element_type_parse_position, concat("Unsupported BSON record type 0x", cr_str), nullptr));
|
parse_error::create(114, element_type_parse_position, concat("Unsupported BSON record type 0x", cr_str), nullptr));
|
||||||
}
|
}
|
||||||
@ -393,7 +400,7 @@ class binary_reader
|
|||||||
std::int32_t document_size{};
|
std::int32_t document_size{};
|
||||||
get_number<std::int32_t, true>(input_format_t::bson, document_size);
|
get_number<std::int32_t, true>(input_format_t::bson, document_size);
|
||||||
|
|
||||||
if (JSON_HEDLEY_UNLIKELY(!sax->start_array(static_cast<std::size_t>(-1))))
|
if (JSON_HEDLEY_UNLIKELY(!sax->start_array(detail::unknown_size())))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -424,7 +431,7 @@ class binary_reader
|
|||||||
switch (get_char ? get() : current)
|
switch (get_char ? get() : current)
|
||||||
{
|
{
|
||||||
// EOF
|
// EOF
|
||||||
case std::char_traits<char_type>::eof():
|
case char_traits<char_type>::eof():
|
||||||
return unexpect_eof(input_format_t::cbor, "value");
|
return unexpect_eof(input_format_t::cbor, "value");
|
||||||
|
|
||||||
// Integer 0x00..0x17 (0..23)
|
// Integer 0x00..0x17 (0..23)
|
||||||
@ -653,7 +660,7 @@ class binary_reader
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 0x9F: // array (indefinite length)
|
case 0x9F: // array (indefinite length)
|
||||||
return get_cbor_array(static_cast<std::size_t>(-1), tag_handler);
|
return get_cbor_array(detail::unknown_size(), tag_handler);
|
||||||
|
|
||||||
// map (0x00..0x17 pairs of data items follow)
|
// map (0x00..0x17 pairs of data items follow)
|
||||||
case 0xA0:
|
case 0xA0:
|
||||||
@ -707,7 +714,7 @@ class binary_reader
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 0xBF: // map (indefinite length)
|
case 0xBF: // map (indefinite length)
|
||||||
return get_cbor_object(static_cast<std::size_t>(-1), tag_handler);
|
return get_cbor_object(detail::unknown_size(), tag_handler);
|
||||||
|
|
||||||
case 0xC6: // tagged item
|
case 0xC6: // tagged item
|
||||||
case 0xC7:
|
case 0xC7:
|
||||||
@ -1095,7 +1102,7 @@ class binary_reader
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@param[in] len the length of the array or static_cast<std::size_t>(-1) for an
|
@param[in] len the length of the array or detail::unknown_size() for an
|
||||||
array of indefinite size
|
array of indefinite size
|
||||||
@param[in] tag_handler how CBOR tags should be treated
|
@param[in] tag_handler how CBOR tags should be treated
|
||||||
@return whether array creation completed
|
@return whether array creation completed
|
||||||
@ -1108,7 +1115,7 @@ class binary_reader
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len != static_cast<std::size_t>(-1))
|
if (len != detail::unknown_size())
|
||||||
{
|
{
|
||||||
for (std::size_t i = 0; i < len; ++i)
|
for (std::size_t i = 0; i < len; ++i)
|
||||||
{
|
{
|
||||||
@ -1133,7 +1140,7 @@ class binary_reader
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@param[in] len the length of the object or static_cast<std::size_t>(-1) for an
|
@param[in] len the length of the object or detail::unknown_size() for an
|
||||||
object of indefinite size
|
object of indefinite size
|
||||||
@param[in] tag_handler how CBOR tags should be treated
|
@param[in] tag_handler how CBOR tags should be treated
|
||||||
@return whether object creation completed
|
@return whether object creation completed
|
||||||
@ -1149,7 +1156,7 @@ class binary_reader
|
|||||||
if (len != 0)
|
if (len != 0)
|
||||||
{
|
{
|
||||||
string_t key;
|
string_t key;
|
||||||
if (len != static_cast<std::size_t>(-1))
|
if (len != detail::unknown_size())
|
||||||
{
|
{
|
||||||
for (std::size_t i = 0; i < len; ++i)
|
for (std::size_t i = 0; i < len; ++i)
|
||||||
{
|
{
|
||||||
@ -1199,7 +1206,7 @@ class binary_reader
|
|||||||
switch (get())
|
switch (get())
|
||||||
{
|
{
|
||||||
// EOF
|
// EOF
|
||||||
case std::char_traits<char_type>::eof():
|
case char_traits<char_type>::eof():
|
||||||
return unexpect_eof(input_format_t::msgpack, "value");
|
return unexpect_eof(input_format_t::msgpack, "value");
|
||||||
|
|
||||||
// positive fixint
|
// positive fixint
|
||||||
@ -1953,7 +1960,7 @@ class binary_reader
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size_and_type.first != string_t::npos)
|
if (size_and_type.first != npos)
|
||||||
{
|
{
|
||||||
if (size_and_type.second != 0)
|
if (size_and_type.second != 0)
|
||||||
{
|
{
|
||||||
@ -2154,7 +2161,7 @@ class binary_reader
|
|||||||
}
|
}
|
||||||
if (is_ndarray) // ndarray dimensional vector can only contain integers, and can not embed another array
|
if (is_ndarray) // ndarray dimensional vector can only contain integers, and can not embed another array
|
||||||
{
|
{
|
||||||
return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "ndarray dimentional vector is not allowed", "size"), nullptr));
|
return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "ndarray dimensional vector is not allowed", "size"), nullptr));
|
||||||
}
|
}
|
||||||
std::vector<size_t> dim;
|
std::vector<size_t> dim;
|
||||||
if (JSON_HEDLEY_UNLIKELY(!get_ubjson_ndarray_size(dim)))
|
if (JSON_HEDLEY_UNLIKELY(!get_ubjson_ndarray_size(dim)))
|
||||||
@ -2186,7 +2193,7 @@ class binary_reader
|
|||||||
for (auto i : dim)
|
for (auto i : dim)
|
||||||
{
|
{
|
||||||
result *= i;
|
result *= i;
|
||||||
if (result == 0 || result == string_t::npos) // because dim elements shall not have zeros, result = 0 means overflow happened; it also can't be string_t::npos as it is used to initialize size in get_ubjson_size_type()
|
if (result == 0 || result == npos) // because dim elements shall not have zeros, result = 0 means overflow happened; it also can't be npos as it is used to initialize size in get_ubjson_size_type()
|
||||||
{
|
{
|
||||||
return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format, "excessive ndarray size caused overflow", "size"), nullptr));
|
return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format, "excessive ndarray size caused overflow", "size"), nullptr));
|
||||||
}
|
}
|
||||||
@ -2232,7 +2239,7 @@ class binary_reader
|
|||||||
*/
|
*/
|
||||||
bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>& result, bool inside_ndarray = false)
|
bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>& result, bool inside_ndarray = false)
|
||||||
{
|
{
|
||||||
result.first = string_t::npos; // size
|
result.first = npos; // size
|
||||||
result.second = 0; // type
|
result.second = 0; // type
|
||||||
bool is_ndarray = false;
|
bool is_ndarray = false;
|
||||||
|
|
||||||
@ -2240,10 +2247,9 @@ class binary_reader
|
|||||||
|
|
||||||
if (current == '$')
|
if (current == '$')
|
||||||
{
|
{
|
||||||
std::vector<char_int_type> bjdx = {'[', '{', 'S', 'H', 'T', 'F', 'N', 'Z'}; // excluded markers in bjdata optimized type
|
|
||||||
|
|
||||||
result.second = get(); // must not ignore 'N', because 'N' maybe the type
|
result.second = get(); // must not ignore 'N', because 'N' maybe the type
|
||||||
if (JSON_HEDLEY_UNLIKELY( input_format == input_format_t::bjdata && std::find(bjdx.begin(), bjdx.end(), result.second) != bjdx.end() ))
|
if (input_format == input_format_t::bjdata
|
||||||
|
&& JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second)))
|
||||||
{
|
{
|
||||||
auto last_token = get_token_string();
|
auto last_token = get_token_string();
|
||||||
return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
|
return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
|
||||||
@ -2267,7 +2273,7 @@ class binary_reader
|
|||||||
exception_message(input_format, concat("expected '#' after type information; last byte: 0x", last_token), "size"), nullptr));
|
exception_message(input_format, concat("expected '#' after type information; last byte: 0x", last_token), "size"), nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_error = get_ubjson_size_value(result.first, is_ndarray);
|
const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
|
||||||
if (input_format == input_format_t::bjdata && is_ndarray)
|
if (input_format == input_format_t::bjdata && is_ndarray)
|
||||||
{
|
{
|
||||||
if (inside_ndarray)
|
if (inside_ndarray)
|
||||||
@ -2282,7 +2288,7 @@ class binary_reader
|
|||||||
|
|
||||||
if (current == '#')
|
if (current == '#')
|
||||||
{
|
{
|
||||||
bool is_error = get_ubjson_size_value(result.first, is_ndarray);
|
const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
|
||||||
if (input_format == input_format_t::bjdata && is_ndarray)
|
if (input_format == input_format_t::bjdata && is_ndarray)
|
||||||
{
|
{
|
||||||
return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
|
return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
|
||||||
@ -2302,7 +2308,7 @@ class binary_reader
|
|||||||
{
|
{
|
||||||
switch (prefix)
|
switch (prefix)
|
||||||
{
|
{
|
||||||
case std::char_traits<char_type>::eof(): // EOF
|
case char_traits<char_type>::eof(): // EOF
|
||||||
return unexpect_eof(input_format, "value");
|
return unexpect_eof(input_format, "value");
|
||||||
|
|
||||||
case 'T': // true
|
case 'T': // true
|
||||||
@ -2313,6 +2319,16 @@ class binary_reader
|
|||||||
case 'Z': // null
|
case 'Z': // null
|
||||||
return sax->null();
|
return sax->null();
|
||||||
|
|
||||||
|
case 'B': // byte
|
||||||
|
{
|
||||||
|
if (input_format != input_format_t::bjdata)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
std::uint8_t number{};
|
||||||
|
return get_number(input_format, number) && sax->number_unsigned(number);
|
||||||
|
}
|
||||||
|
|
||||||
case 'U':
|
case 'U':
|
||||||
{
|
{
|
||||||
std::uint8_t number{};
|
std::uint8_t number{};
|
||||||
@ -2492,28 +2508,28 @@ class binary_reader
|
|||||||
// if bit-8 of size_and_type.second is set to 1, encode bjdata ndarray as an object in JData annotated array format (https://github.com/NeuroJSON/jdata):
|
// if bit-8 of size_and_type.second is set to 1, encode bjdata ndarray as an object in JData annotated array format (https://github.com/NeuroJSON/jdata):
|
||||||
// {"_ArrayType_" : "typeid", "_ArraySize_" : [n1, n2, ...], "_ArrayData_" : [v1, v2, ...]}
|
// {"_ArrayType_" : "typeid", "_ArraySize_" : [n1, n2, ...], "_ArrayData_" : [v1, v2, ...]}
|
||||||
|
|
||||||
if (input_format == input_format_t::bjdata && size_and_type.first != string_t::npos && (size_and_type.second & (1 << 8)) != 0)
|
if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
|
||||||
{
|
{
|
||||||
std::map<char_int_type, string_t> bjdtype = {{'U', "uint8"}, {'i', "int8"}, {'u', "uint16"}, {'I', "int16"},
|
|
||||||
{'m', "uint32"}, {'l', "int32"}, {'M', "uint64"}, {'L', "int64"}, {'d', "single"}, {'D', "double"}, {'C', "char"}
|
|
||||||
};
|
|
||||||
|
|
||||||
size_and_type.second &= ~(static_cast<char_int_type>(1) << 8); // use bit 8 to indicate ndarray, here we remove the bit to restore the type marker
|
size_and_type.second &= ~(static_cast<char_int_type>(1) << 8); // use bit 8 to indicate ndarray, here we remove the bit to restore the type marker
|
||||||
|
auto it = std::lower_bound(bjd_types_map.begin(), bjd_types_map.end(), size_and_type.second, [](const bjd_type & p, char_int_type t)
|
||||||
|
{
|
||||||
|
return p.first < t;
|
||||||
|
});
|
||||||
string_t key = "_ArrayType_";
|
string_t key = "_ArrayType_";
|
||||||
if (JSON_HEDLEY_UNLIKELY(bjdtype.count(size_and_type.second) == 0))
|
if (JSON_HEDLEY_UNLIKELY(it == bjd_types_map.end() || it->first != size_and_type.second))
|
||||||
{
|
{
|
||||||
auto last_token = get_token_string();
|
auto last_token = get_token_string();
|
||||||
return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
|
return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
|
||||||
exception_message(input_format, "invalid byte: 0x" + last_token, "type"), nullptr));
|
exception_message(input_format, "invalid byte: 0x" + last_token, "type"), nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JSON_HEDLEY_UNLIKELY(!sax->key(key) || !sax->string(bjdtype[size_and_type.second]) ))
|
string_t type = it->second; // sax->string() takes a reference
|
||||||
|
if (JSON_HEDLEY_UNLIKELY(!sax->key(key) || !sax->string(type)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size_and_type.second == 'C')
|
if (size_and_type.second == 'C' || size_and_type.second == 'B')
|
||||||
{
|
{
|
||||||
size_and_type.second = 'U';
|
size_and_type.second = 'U';
|
||||||
}
|
}
|
||||||
@ -2535,7 +2551,14 @@ class binary_reader
|
|||||||
return (sax->end_array() && sax->end_object());
|
return (sax->end_array() && sax->end_object());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size_and_type.first != string_t::npos)
|
// If BJData type marker is 'B' decode as binary
|
||||||
|
if (input_format == input_format_t::bjdata && size_and_type.first != npos && size_and_type.second == 'B')
|
||||||
|
{
|
||||||
|
binary_t result;
|
||||||
|
return get_binary(input_format, size_and_type.first, result) && sax->binary(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size_and_type.first != npos)
|
||||||
{
|
{
|
||||||
if (JSON_HEDLEY_UNLIKELY(!sax->start_array(size_and_type.first)))
|
if (JSON_HEDLEY_UNLIKELY(!sax->start_array(size_and_type.first)))
|
||||||
{
|
{
|
||||||
@ -2568,7 +2591,7 @@ class binary_reader
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (JSON_HEDLEY_UNLIKELY(!sax->start_array(static_cast<std::size_t>(-1))))
|
if (JSON_HEDLEY_UNLIKELY(!sax->start_array(detail::unknown_size())))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2598,7 +2621,7 @@ class binary_reader
|
|||||||
}
|
}
|
||||||
|
|
||||||
// do not accept ND-array size in objects in BJData
|
// do not accept ND-array size in objects in BJData
|
||||||
if (input_format == input_format_t::bjdata && size_and_type.first != string_t::npos && (size_and_type.second & (1 << 8)) != 0)
|
if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
|
||||||
{
|
{
|
||||||
auto last_token = get_token_string();
|
auto last_token = get_token_string();
|
||||||
return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
|
return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
|
||||||
@ -2606,7 +2629,7 @@ class binary_reader
|
|||||||
}
|
}
|
||||||
|
|
||||||
string_t key;
|
string_t key;
|
||||||
if (size_and_type.first != string_t::npos)
|
if (size_and_type.first != npos)
|
||||||
{
|
{
|
||||||
if (JSON_HEDLEY_UNLIKELY(!sax->start_object(size_and_type.first)))
|
if (JSON_HEDLEY_UNLIKELY(!sax->start_object(size_and_type.first)))
|
||||||
{
|
{
|
||||||
@ -2646,7 +2669,7 @@ class binary_reader
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (JSON_HEDLEY_UNLIKELY(!sax->start_object(static_cast<std::size_t>(-1))))
|
if (JSON_HEDLEY_UNLIKELY(!sax->start_object(detail::unknown_size())))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2747,7 +2770,7 @@ class binary_reader
|
|||||||
|
|
||||||
This function provides the interface to the used input adapter. It does
|
This function provides the interface to the used input adapter. It does
|
||||||
not throw in case the input reached EOF, but returns a -'ve valued
|
not throw in case the input reached EOF, but returns a -'ve valued
|
||||||
`std::char_traits<char_type>::eof()` in that case.
|
`char_traits<char_type>::eof()` in that case.
|
||||||
|
|
||||||
@return character read from the input
|
@return character read from the input
|
||||||
*/
|
*/
|
||||||
@ -2757,6 +2780,29 @@ class binary_reader
|
|||||||
return current = ia.get_character();
|
return current = ia.get_character();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief get_to read into a primitive type
|
||||||
|
|
||||||
|
This function provides the interface to the used input adapter. It does
|
||||||
|
not throw in case the input reached EOF, but returns false instead
|
||||||
|
|
||||||
|
@return bool, whether the read was successful
|
||||||
|
*/
|
||||||
|
template<class T>
|
||||||
|
bool get_to(T& dest, const input_format_t format, const char* context)
|
||||||
|
{
|
||||||
|
auto new_chars_read = ia.get_elements(&dest);
|
||||||
|
chars_read += new_chars_read;
|
||||||
|
if (JSON_HEDLEY_UNLIKELY(new_chars_read < sizeof(T)))
|
||||||
|
{
|
||||||
|
// in case of failure, advance position by 1 to report failing location
|
||||||
|
++chars_read;
|
||||||
|
sax->parse_error(chars_read, "<end of file>", parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context), nullptr));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@return character read from the input after ignoring all 'N' entries
|
@return character read from the input after ignoring all 'N' entries
|
||||||
*/
|
*/
|
||||||
@ -2771,6 +2817,28 @@ class binary_reader
|
|||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class NumberType>
|
||||||
|
static void byte_swap(NumberType& number)
|
||||||
|
{
|
||||||
|
constexpr std::size_t sz = sizeof(number);
|
||||||
|
#ifdef __cpp_lib_byteswap
|
||||||
|
if constexpr (sz == 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if constexpr(std::is_integral_v<NumberType>)
|
||||||
|
{
|
||||||
|
number = std::byteswap(number);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
auto* ptr = reinterpret_cast<std::uint8_t*>(&number);
|
||||||
|
for (std::size_t i = 0; i < sz / 2; ++i)
|
||||||
|
{
|
||||||
|
std::swap(ptr[i], ptr[sz - i - 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@brief read a number from the input
|
@brief read a number from the input
|
||||||
|
|
||||||
@ -2789,29 +2857,16 @@ class binary_reader
|
|||||||
template<typename NumberType, bool InputIsLittleEndian = false>
|
template<typename NumberType, bool InputIsLittleEndian = false>
|
||||||
bool get_number(const input_format_t format, NumberType& result)
|
bool get_number(const input_format_t format, NumberType& result)
|
||||||
{
|
{
|
||||||
// step 1: read input into array with system's byte order
|
// read in the original format
|
||||||
std::array<std::uint8_t, sizeof(NumberType)> vec{};
|
|
||||||
for (std::size_t i = 0; i < sizeof(NumberType); ++i)
|
if (JSON_HEDLEY_UNLIKELY(!get_to(result, format, "number")))
|
||||||
{
|
{
|
||||||
get();
|
return false;
|
||||||
if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "number")))
|
}
|
||||||
{
|
if (is_little_endian != (InputIsLittleEndian || format == input_format_t::bjdata))
|
||||||
return false;
|
{
|
||||||
}
|
byte_swap(result);
|
||||||
|
|
||||||
// reverse byte order prior to conversion if necessary
|
|
||||||
if (is_little_endian != (InputIsLittleEndian || format == input_format_t::bjdata))
|
|
||||||
{
|
|
||||||
vec[sizeof(NumberType) - i - 1] = static_cast<std::uint8_t>(current);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vec[i] = static_cast<std::uint8_t>(current); // LCOV_EXCL_LINE
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// step 2: convert array into number of type T and return
|
|
||||||
std::memcpy(&result, vec.data(), sizeof(NumberType));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2889,7 +2944,7 @@ class binary_reader
|
|||||||
JSON_HEDLEY_NON_NULL(3)
|
JSON_HEDLEY_NON_NULL(3)
|
||||||
bool unexpect_eof(const input_format_t format, const char* context) const
|
bool unexpect_eof(const input_format_t format, const char* context) const
|
||||||
{
|
{
|
||||||
if (JSON_HEDLEY_UNLIKELY(current == std::char_traits<char_type>::eof()))
|
if (JSON_HEDLEY_UNLIKELY(current == char_traits<char_type>::eof()))
|
||||||
{
|
{
|
||||||
return sax->parse_error(chars_read, "<end of file>",
|
return sax->parse_error(chars_read, "<end of file>",
|
||||||
parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context), nullptr));
|
parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context), nullptr));
|
||||||
@ -2950,11 +3005,13 @@ class binary_reader
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static JSON_INLINE_VARIABLE constexpr std::size_t npos = detail::unknown_size();
|
||||||
|
|
||||||
/// input adapter
|
/// input adapter
|
||||||
InputAdapterType ia;
|
InputAdapterType ia;
|
||||||
|
|
||||||
/// the current character
|
/// the current character
|
||||||
char_int_type current = std::char_traits<char_type>::eof();
|
char_int_type current = char_traits<char_type>::eof();
|
||||||
|
|
||||||
/// the number of characters read
|
/// the number of characters read
|
||||||
std::size_t chars_read = 0;
|
std::size_t chars_read = 0;
|
||||||
@ -2967,7 +3024,45 @@ class binary_reader
|
|||||||
|
|
||||||
/// the SAX parser
|
/// the SAX parser
|
||||||
json_sax_t* sax = nullptr;
|
json_sax_t* sax = nullptr;
|
||||||
|
|
||||||
|
// excluded markers in bjdata optimized type
|
||||||
|
#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \
|
||||||
|
make_array<char_int_type>('F', 'H', 'N', 'S', 'T', 'Z', '[', '{')
|
||||||
|
|
||||||
|
#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \
|
||||||
|
make_array<bjd_type>( \
|
||||||
|
bjd_type{'B', "byte"}, \
|
||||||
|
bjd_type{'C', "char"}, \
|
||||||
|
bjd_type{'D', "double"}, \
|
||||||
|
bjd_type{'I', "int16"}, \
|
||||||
|
bjd_type{'L', "int64"}, \
|
||||||
|
bjd_type{'M', "uint64"}, \
|
||||||
|
bjd_type{'U', "uint8"}, \
|
||||||
|
bjd_type{'d', "single"}, \
|
||||||
|
bjd_type{'i', "int8"}, \
|
||||||
|
bjd_type{'l', "int32"}, \
|
||||||
|
bjd_type{'m', "uint32"}, \
|
||||||
|
bjd_type{'u', "uint16"})
|
||||||
|
|
||||||
|
JSON_PRIVATE_UNLESS_TESTED:
|
||||||
|
// lookup tables
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes)
|
||||||
|
const decltype(JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_) bjd_optimized_type_markers =
|
||||||
|
JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_;
|
||||||
|
|
||||||
|
using bjd_type = std::pair<char_int_type, string_t>;
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes)
|
||||||
|
const decltype(JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_) bjd_types_map =
|
||||||
|
JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_;
|
||||||
|
|
||||||
|
#undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
|
||||||
|
#undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef JSON_HAS_CPP_17
|
||||||
|
template<typename BasicJsonType, typename InputAdapterType, typename SAX>
|
||||||
|
constexpr std::size_t binary_reader<BasicJsonType, InputAdapterType, SAX>::npos;
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
NLOHMANN_JSON_NAMESPACE_END
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -23,8 +23,10 @@
|
|||||||
#include <istream> // istream
|
#include <istream> // istream
|
||||||
#endif // JSON_NO_IO
|
#endif // JSON_NO_IO
|
||||||
|
|
||||||
|
#include <nlohmann/detail/exceptions.hpp>
|
||||||
#include <nlohmann/detail/iterators/iterator_traits.hpp>
|
#include <nlohmann/detail/iterators/iterator_traits.hpp>
|
||||||
#include <nlohmann/detail/macro_scope.hpp>
|
#include <nlohmann/detail/macro_scope.hpp>
|
||||||
|
#include <nlohmann/detail/meta/type_traits.hpp>
|
||||||
|
|
||||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
namespace detail
|
namespace detail
|
||||||
@ -66,12 +68,18 @@ class file_input_adapter
|
|||||||
return std::fgetc(m_file);
|
return std::fgetc(m_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// returns the number of characters successfully read
|
||||||
|
template<class T>
|
||||||
|
std::size_t get_elements(T* dest, std::size_t count = 1)
|
||||||
|
{
|
||||||
|
return fread(dest, 1, sizeof(T) * count, m_file);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// the file pointer to read from
|
/// the file pointer to read from
|
||||||
std::FILE* m_file;
|
std::FILE* m_file;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at
|
Input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at
|
||||||
beginning of input. Does not support changing the underlying std::streambuf
|
beginning of input. Does not support changing the underlying std::streambuf
|
||||||
@ -126,6 +134,17 @@ class input_stream_adapter
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
std::size_t get_elements(T* dest, std::size_t count = 1)
|
||||||
|
{
|
||||||
|
auto res = static_cast<std::size_t>(sb->sgetn(reinterpret_cast<char*>(dest), static_cast<std::streamsize>(count * sizeof(T))));
|
||||||
|
if (JSON_HEDLEY_UNLIKELY(res < count * sizeof(T)))
|
||||||
|
{
|
||||||
|
is->clear(is->rdstate() | std::ios::eofbit);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// the associated input stream
|
/// the associated input stream
|
||||||
std::istream* is = nullptr;
|
std::istream* is = nullptr;
|
||||||
@ -145,16 +164,36 @@ class iterator_input_adapter
|
|||||||
: 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()
|
typename char_traits<char_type>::int_type get_character()
|
||||||
{
|
{
|
||||||
if (JSON_HEDLEY_LIKELY(current != end))
|
if (JSON_HEDLEY_LIKELY(current != end))
|
||||||
{
|
{
|
||||||
auto result = std::char_traits<char_type>::to_int_type(*current);
|
auto result = char_traits<char_type>::to_int_type(*current);
|
||||||
std::advance(current, 1);
|
std::advance(current, 1);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::char_traits<char_type>::eof();
|
return char_traits<char_type>::eof();
|
||||||
|
}
|
||||||
|
|
||||||
|
// for general iterators, we cannot really do something better than falling back to processing the range one-by-one
|
||||||
|
template<class T>
|
||||||
|
std::size_t get_elements(T* dest, std::size_t count = 1)
|
||||||
|
{
|
||||||
|
auto* ptr = reinterpret_cast<char*>(dest);
|
||||||
|
for (std::size_t read_index = 0; read_index < count * sizeof(T); ++read_index)
|
||||||
|
{
|
||||||
|
if (JSON_HEDLEY_LIKELY(current != end))
|
||||||
|
{
|
||||||
|
ptr[read_index] = static_cast<char>(*current);
|
||||||
|
std::advance(current, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return read_index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count * sizeof(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -170,7 +209,6 @@ class iterator_input_adapter
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template<typename BaseInputAdapter, size_t T>
|
template<typename BaseInputAdapter, size_t T>
|
||||||
struct wide_string_input_helper;
|
struct wide_string_input_helper;
|
||||||
|
|
||||||
@ -294,7 +332,7 @@ struct wide_string_input_helper<BaseInputAdapter, 2>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Wraps another input apdater to convert wide character types into individual bytes.
|
// Wraps another input adapter to convert wide character types into individual bytes.
|
||||||
template<typename BaseInputAdapter, typename WideCharType>
|
template<typename BaseInputAdapter, typename WideCharType>
|
||||||
class wide_string_input_adapter
|
class wide_string_input_adapter
|
||||||
{
|
{
|
||||||
@ -321,6 +359,13 @@ class wide_string_input_adapter
|
|||||||
return utf8_bytes[utf8_bytes_index++];
|
return utf8_bytes[utf8_bytes_index++];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parsing binary with wchar doesn't make sense, but since the parsing mode can be runtime, we need something here
|
||||||
|
template<class T>
|
||||||
|
std::size_t get_elements(T* /*dest*/, std::size_t /*count*/ = 1)
|
||||||
|
{
|
||||||
|
JSON_THROW(parse_error::create(112, 1, "wide string type cannot be interpreted as binary data", nullptr));
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BaseInputAdapter base_adapter;
|
BaseInputAdapter base_adapter;
|
||||||
|
|
||||||
@ -339,7 +384,6 @@ class wide_string_input_adapter
|
|||||||
std::size_t utf8_bytes_filled = 0;
|
std::size_t utf8_bytes_filled = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template<typename IteratorType, typename Enable = void>
|
template<typename IteratorType, typename Enable = void>
|
||||||
struct iterator_input_adapter_factory
|
struct iterator_input_adapter_factory
|
||||||
{
|
{
|
||||||
@ -418,10 +462,17 @@ typename container_input_adapter_factory_impl::container_input_adapter_factory<C
|
|||||||
return container_input_adapter_factory_impl::container_input_adapter_factory<ContainerType>::create(container);
|
return container_input_adapter_factory_impl::container_input_adapter_factory<ContainerType>::create(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// specialization for std::string
|
||||||
|
using string_input_adapter_type = decltype(input_adapter(std::declval<std::string>()));
|
||||||
|
|
||||||
#ifndef JSON_NO_IO
|
#ifndef JSON_NO_IO
|
||||||
// Special cases with fast paths
|
// Special cases with fast paths
|
||||||
inline file_input_adapter input_adapter(std::FILE* file)
|
inline file_input_adapter input_adapter(std::FILE* file)
|
||||||
{
|
{
|
||||||
|
if (file == nullptr)
|
||||||
|
{
|
||||||
|
JSON_THROW(parse_error::create(101, 0, "attempting to parse an empty input; check that your input string or stream contains the expected JSON", nullptr));
|
||||||
|
}
|
||||||
return file_input_adapter(file);
|
return file_input_adapter(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,9 +499,13 @@ template < typename CharT,
|
|||||||
int >::type = 0 >
|
int >::type = 0 >
|
||||||
contiguous_bytes_input_adapter input_adapter(CharT b)
|
contiguous_bytes_input_adapter input_adapter(CharT b)
|
||||||
{
|
{
|
||||||
|
if (b == nullptr)
|
||||||
|
{
|
||||||
|
JSON_THROW(parse_error::create(101, 0, "attempting to parse an empty input; check that your input string or stream contains the expected JSON", nullptr));
|
||||||
|
}
|
||||||
auto length = std::strlen(reinterpret_cast<const char*>(b));
|
auto length = std::strlen(reinterpret_cast<const char*>(b));
|
||||||
const auto* ptr = reinterpret_cast<const char*>(b);
|
const auto* ptr = reinterpret_cast<const char*>(b);
|
||||||
return input_adapter(ptr, ptr + length);
|
return input_adapter(ptr, ptr + length); // cppcheck-suppress[nullPointerArithmeticRedundantCheck]
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, std::size_t N>
|
template<typename T, std::size_t N>
|
||||||
|
@ -1,22 +1,23 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <string> // string
|
#include <string> // string
|
||||||
|
#include <type_traits> // enable_if_t
|
||||||
#include <utility> // move
|
#include <utility> // move
|
||||||
#include <vector> // vector
|
#include <vector> // vector
|
||||||
|
|
||||||
#include <nlohmann/detail/exceptions.hpp>
|
#include <nlohmann/detail/exceptions.hpp>
|
||||||
|
#include <nlohmann/detail/input/lexer.hpp>
|
||||||
#include <nlohmann/detail/macro_scope.hpp>
|
#include <nlohmann/detail/macro_scope.hpp>
|
||||||
#include <nlohmann/detail/string_concat.hpp>
|
#include <nlohmann/detail/string_concat.hpp>
|
||||||
|
|
||||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -142,9 +143,13 @@ struct json_sax
|
|||||||
virtual ~json_sax() = default;
|
virtual ~json_sax() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
constexpr std::size_t unknown_size()
|
||||||
|
{
|
||||||
|
return (std::numeric_limits<std::size_t>::max)();
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief SAX implementation to create a JSON value from SAX events
|
@brief SAX implementation to create a JSON value from SAX events
|
||||||
|
|
||||||
@ -158,7 +163,7 @@ constructor contains the parsed value.
|
|||||||
|
|
||||||
@tparam BasicJsonType the JSON type
|
@tparam BasicJsonType the JSON type
|
||||||
*/
|
*/
|
||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType, typename InputAdapterType>
|
||||||
class json_sax_dom_parser
|
class json_sax_dom_parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -167,14 +172,15 @@ class json_sax_dom_parser
|
|||||||
using number_float_t = typename BasicJsonType::number_float_t;
|
using number_float_t = typename BasicJsonType::number_float_t;
|
||||||
using string_t = typename BasicJsonType::string_t;
|
using string_t = typename BasicJsonType::string_t;
|
||||||
using binary_t = typename BasicJsonType::binary_t;
|
using binary_t = typename BasicJsonType::binary_t;
|
||||||
|
using lexer_t = lexer<BasicJsonType, InputAdapterType>;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@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
|
parsing
|
||||||
@param[in] allow_exceptions_ whether parse errors yield exceptions
|
@param[in] allow_exceptions_ whether parse errors yield exceptions
|
||||||
*/
|
*/
|
||||||
explicit json_sax_dom_parser(BasicJsonType& r, const bool allow_exceptions_ = true)
|
explicit json_sax_dom_parser(BasicJsonType& r, const bool allow_exceptions_ = true, lexer_t* lexer_ = nullptr)
|
||||||
: root(r), allow_exceptions(allow_exceptions_)
|
: root(r), allow_exceptions(allow_exceptions_), m_lexer_ref(lexer_)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// make class move-only
|
// make class move-only
|
||||||
@ -230,7 +236,18 @@ class json_sax_dom_parser
|
|||||||
{
|
{
|
||||||
ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
|
ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
|
||||||
|
|
||||||
if (JSON_HEDLEY_UNLIKELY(len != static_cast<std::size_t>(-1) && len > ref_stack.back()->max_size()))
|
#if JSON_DIAGNOSTIC_POSITIONS
|
||||||
|
// Manually set the start position of the object here.
|
||||||
|
// Ensure this is after the call to handle_value to ensure correct start position.
|
||||||
|
if (m_lexer_ref)
|
||||||
|
{
|
||||||
|
// Lexer has read the first character of the object, so
|
||||||
|
// subtract 1 from the position to get the correct start position.
|
||||||
|
ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (JSON_HEDLEY_UNLIKELY(len != detail::unknown_size() && len > ref_stack.back()->max_size()))
|
||||||
{
|
{
|
||||||
JSON_THROW(out_of_range::create(408, concat("excessive object size: ", std::to_string(len)), ref_stack.back()));
|
JSON_THROW(out_of_range::create(408, concat("excessive object size: ", std::to_string(len)), ref_stack.back()));
|
||||||
}
|
}
|
||||||
@ -244,7 +261,7 @@ class json_sax_dom_parser
|
|||||||
JSON_ASSERT(ref_stack.back()->is_object());
|
JSON_ASSERT(ref_stack.back()->is_object());
|
||||||
|
|
||||||
// add null at given key and store the reference for later
|
// add null at given key and store the reference for later
|
||||||
object_element = &(ref_stack.back()->m_value.object->operator[](val));
|
object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,6 +270,14 @@ class json_sax_dom_parser
|
|||||||
JSON_ASSERT(!ref_stack.empty());
|
JSON_ASSERT(!ref_stack.empty());
|
||||||
JSON_ASSERT(ref_stack.back()->is_object());
|
JSON_ASSERT(ref_stack.back()->is_object());
|
||||||
|
|
||||||
|
#if JSON_DIAGNOSTIC_POSITIONS
|
||||||
|
if (m_lexer_ref)
|
||||||
|
{
|
||||||
|
// Lexer's position is past the closing brace, so set that as the end position.
|
||||||
|
ref_stack.back()->end_position = m_lexer_ref->get_position();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ref_stack.back()->set_parents();
|
ref_stack.back()->set_parents();
|
||||||
ref_stack.pop_back();
|
ref_stack.pop_back();
|
||||||
return true;
|
return true;
|
||||||
@ -262,7 +287,16 @@ class json_sax_dom_parser
|
|||||||
{
|
{
|
||||||
ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
|
ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
|
||||||
|
|
||||||
if (JSON_HEDLEY_UNLIKELY(len != static_cast<std::size_t>(-1) && len > ref_stack.back()->max_size()))
|
#if JSON_DIAGNOSTIC_POSITIONS
|
||||||
|
// Manually set the start position of the array here.
|
||||||
|
// Ensure this is after the call to handle_value to ensure correct start position.
|
||||||
|
if (m_lexer_ref)
|
||||||
|
{
|
||||||
|
ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (JSON_HEDLEY_UNLIKELY(len != detail::unknown_size() && len > ref_stack.back()->max_size()))
|
||||||
{
|
{
|
||||||
JSON_THROW(out_of_range::create(408, concat("excessive array size: ", std::to_string(len)), ref_stack.back()));
|
JSON_THROW(out_of_range::create(408, concat("excessive array size: ", std::to_string(len)), ref_stack.back()));
|
||||||
}
|
}
|
||||||
@ -275,6 +309,14 @@ class json_sax_dom_parser
|
|||||||
JSON_ASSERT(!ref_stack.empty());
|
JSON_ASSERT(!ref_stack.empty());
|
||||||
JSON_ASSERT(ref_stack.back()->is_array());
|
JSON_ASSERT(ref_stack.back()->is_array());
|
||||||
|
|
||||||
|
#if JSON_DIAGNOSTIC_POSITIONS
|
||||||
|
if (m_lexer_ref)
|
||||||
|
{
|
||||||
|
// Lexer's position is past the closing bracket, so set that as the end position.
|
||||||
|
ref_stack.back()->end_position = m_lexer_ref->get_position();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ref_stack.back()->set_parents();
|
ref_stack.back()->set_parents();
|
||||||
ref_stack.pop_back();
|
ref_stack.pop_back();
|
||||||
return true;
|
return true;
|
||||||
@ -299,6 +341,75 @@ class json_sax_dom_parser
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
#if JSON_DIAGNOSTIC_POSITIONS
|
||||||
|
void handle_diagnostic_positions_for_json_value(BasicJsonType& v)
|
||||||
|
{
|
||||||
|
if (m_lexer_ref)
|
||||||
|
{
|
||||||
|
// Lexer has read past the current field value, so set the end position to the current position.
|
||||||
|
// The start position will be set below based on the length of the string representation
|
||||||
|
// of the value.
|
||||||
|
v.end_position = m_lexer_ref->get_position();
|
||||||
|
|
||||||
|
switch (v.type())
|
||||||
|
{
|
||||||
|
case value_t::boolean:
|
||||||
|
{
|
||||||
|
// 4 and 5 are the string length of "true" and "false"
|
||||||
|
v.start_position = v.end_position - (v.m_data.m_value.boolean ? 4 : 5);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case value_t::null:
|
||||||
|
{
|
||||||
|
// 4 is the string length of "null"
|
||||||
|
v.start_position = v.end_position - 4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case value_t::string:
|
||||||
|
{
|
||||||
|
// include the length of the quotes, which is 2
|
||||||
|
v.start_position = v.end_position - v.m_data.m_value.string->size() - 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// As we handle the start and end positions for values created during parsing,
|
||||||
|
// we do not expect the following value type to be called. Regardless, set the positions
|
||||||
|
// in case this is created manually or through a different constructor. Exclude from lcov
|
||||||
|
// since the exact condition of this switch is esoteric.
|
||||||
|
// LCOV_EXCL_START
|
||||||
|
case value_t::discarded:
|
||||||
|
{
|
||||||
|
v.end_position = std::string::npos;
|
||||||
|
v.start_position = v.end_position;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
|
case value_t::binary:
|
||||||
|
case value_t::number_integer:
|
||||||
|
case value_t::number_unsigned:
|
||||||
|
case value_t::number_float:
|
||||||
|
{
|
||||||
|
v.start_position = v.end_position - m_lexer_ref->get_string().size();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case value_t::object:
|
||||||
|
case value_t::array:
|
||||||
|
{
|
||||||
|
// object and array are handled in start_object() and start_array() handlers
|
||||||
|
// skip setting the values here.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: // LCOV_EXCL_LINE
|
||||||
|
// Handle all possible types discretely, default handler should never be reached.
|
||||||
|
JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert,-warnings-as-errors) LCOV_EXCL_LINE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@invariant If the ref stack is empty, then the passed value will be the new
|
@invariant If the ref stack is empty, then the passed value will be the new
|
||||||
root.
|
root.
|
||||||
@ -312,6 +423,11 @@ class json_sax_dom_parser
|
|||||||
if (ref_stack.empty())
|
if (ref_stack.empty())
|
||||||
{
|
{
|
||||||
root = BasicJsonType(std::forward<Value>(v));
|
root = BasicJsonType(std::forward<Value>(v));
|
||||||
|
|
||||||
|
#if JSON_DIAGNOSTIC_POSITIONS
|
||||||
|
handle_diagnostic_positions_for_json_value(root);
|
||||||
|
#endif
|
||||||
|
|
||||||
return &root;
|
return &root;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,13 +435,23 @@ class json_sax_dom_parser
|
|||||||
|
|
||||||
if (ref_stack.back()->is_array())
|
if (ref_stack.back()->is_array())
|
||||||
{
|
{
|
||||||
ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
|
ref_stack.back()->m_data.m_value.array->emplace_back(std::forward<Value>(v));
|
||||||
return &(ref_stack.back()->m_value.array->back());
|
|
||||||
|
#if JSON_DIAGNOSTIC_POSITIONS
|
||||||
|
handle_diagnostic_positions_for_json_value(ref_stack.back()->m_data.m_value.array->back());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return &(ref_stack.back()->m_data.m_value.array->back());
|
||||||
}
|
}
|
||||||
|
|
||||||
JSON_ASSERT(ref_stack.back()->is_object());
|
JSON_ASSERT(ref_stack.back()->is_object());
|
||||||
JSON_ASSERT(object_element);
|
JSON_ASSERT(object_element);
|
||||||
*object_element = BasicJsonType(std::forward<Value>(v));
|
*object_element = BasicJsonType(std::forward<Value>(v));
|
||||||
|
|
||||||
|
#if JSON_DIAGNOSTIC_POSITIONS
|
||||||
|
handle_diagnostic_positions_for_json_value(*object_element);
|
||||||
|
#endif
|
||||||
|
|
||||||
return object_element;
|
return object_element;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,9 +465,11 @@ class json_sax_dom_parser
|
|||||||
bool errored = false;
|
bool errored = false;
|
||||||
/// whether to throw exceptions in case of errors
|
/// whether to throw exceptions in case of errors
|
||||||
const bool allow_exceptions = true;
|
const bool allow_exceptions = true;
|
||||||
|
/// the lexer reference to obtain the current position
|
||||||
|
lexer_t* m_lexer_ref = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType, typename InputAdapterType>
|
||||||
class json_sax_dom_callback_parser
|
class json_sax_dom_callback_parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -352,11 +480,13 @@ class json_sax_dom_callback_parser
|
|||||||
using binary_t = typename BasicJsonType::binary_t;
|
using binary_t = typename BasicJsonType::binary_t;
|
||||||
using parser_callback_t = typename BasicJsonType::parser_callback_t;
|
using parser_callback_t = typename BasicJsonType::parser_callback_t;
|
||||||
using parse_event_t = typename BasicJsonType::parse_event_t;
|
using parse_event_t = typename BasicJsonType::parse_event_t;
|
||||||
|
using lexer_t = lexer<BasicJsonType, InputAdapterType>;
|
||||||
|
|
||||||
json_sax_dom_callback_parser(BasicJsonType& r,
|
json_sax_dom_callback_parser(BasicJsonType& r,
|
||||||
const parser_callback_t cb,
|
parser_callback_t cb,
|
||||||
const bool allow_exceptions_ = true)
|
const bool allow_exceptions_ = true,
|
||||||
: root(r), callback(cb), allow_exceptions(allow_exceptions_)
|
lexer_t* lexer_ = nullptr)
|
||||||
|
: root(r), callback(std::move(cb)), allow_exceptions(allow_exceptions_), m_lexer_ref(lexer_)
|
||||||
{
|
{
|
||||||
keep_stack.push_back(true);
|
keep_stack.push_back(true);
|
||||||
}
|
}
|
||||||
@ -419,12 +549,26 @@ class json_sax_dom_callback_parser
|
|||||||
auto val = handle_value(BasicJsonType::value_t::object, true);
|
auto val = handle_value(BasicJsonType::value_t::object, true);
|
||||||
ref_stack.push_back(val.second);
|
ref_stack.push_back(val.second);
|
||||||
|
|
||||||
// check object limit
|
if (ref_stack.back())
|
||||||
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, concat("excessive object size: ", std::to_string(len)), ref_stack.back()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
#if JSON_DIAGNOSTIC_POSITIONS
|
||||||
|
// Manually set the start position of the object here.
|
||||||
|
// Ensure this is after the call to handle_value to ensure correct start position.
|
||||||
|
if (m_lexer_ref)
|
||||||
|
{
|
||||||
|
// Lexer has read the first character of the object, so
|
||||||
|
// subtract 1 from the position to get the correct start position.
|
||||||
|
ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// check object limit
|
||||||
|
if (JSON_HEDLEY_UNLIKELY(len != detail::unknown_size() && len > ref_stack.back()->max_size()))
|
||||||
|
{
|
||||||
|
JSON_THROW(out_of_range::create(408, concat("excessive object size: ", std::to_string(len)), ref_stack.back()));
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,7 +583,7 @@ class json_sax_dom_callback_parser
|
|||||||
// add discarded value at given key and store the reference for later
|
// add discarded value at given key and store the reference for later
|
||||||
if (keep && ref_stack.back())
|
if (keep && ref_stack.back())
|
||||||
{
|
{
|
||||||
object_element = &(ref_stack.back()->m_value.object->operator[](val) = discarded);
|
object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val) = discarded);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -453,9 +597,23 @@ class json_sax_dom_callback_parser
|
|||||||
{
|
{
|
||||||
// discard object
|
// discard object
|
||||||
*ref_stack.back() = discarded;
|
*ref_stack.back() = discarded;
|
||||||
|
|
||||||
|
#if JSON_DIAGNOSTIC_POSITIONS
|
||||||
|
// Set start/end positions for discarded object.
|
||||||
|
handle_diagnostic_positions_for_json_value(*ref_stack.back());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#if JSON_DIAGNOSTIC_POSITIONS
|
||||||
|
if (m_lexer_ref)
|
||||||
|
{
|
||||||
|
// Lexer's position is past the closing brace, so set that as the end position.
|
||||||
|
ref_stack.back()->end_position = m_lexer_ref->get_position();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ref_stack.back()->set_parents();
|
ref_stack.back()->set_parents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -489,10 +647,25 @@ class json_sax_dom_callback_parser
|
|||||||
auto val = handle_value(BasicJsonType::value_t::array, true);
|
auto val = handle_value(BasicJsonType::value_t::array, true);
|
||||||
ref_stack.push_back(val.second);
|
ref_stack.push_back(val.second);
|
||||||
|
|
||||||
// check array limit
|
if (ref_stack.back())
|
||||||
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, concat("excessive array size: ", std::to_string(len)), ref_stack.back()));
|
|
||||||
|
#if JSON_DIAGNOSTIC_POSITIONS
|
||||||
|
// Manually set the start position of the array here.
|
||||||
|
// Ensure this is after the call to handle_value to ensure correct start position.
|
||||||
|
if (m_lexer_ref)
|
||||||
|
{
|
||||||
|
// Lexer has read the first character of the array, so
|
||||||
|
// subtract 1 from the position to get the correct start position.
|
||||||
|
ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// check array limit
|
||||||
|
if (JSON_HEDLEY_UNLIKELY(len != detail::unknown_size() && len > ref_stack.back()->max_size()))
|
||||||
|
{
|
||||||
|
JSON_THROW(out_of_range::create(408, concat("excessive array size: ", std::to_string(len)), ref_stack.back()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -507,12 +680,26 @@ class json_sax_dom_callback_parser
|
|||||||
keep = callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
|
keep = callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
|
||||||
if (keep)
|
if (keep)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#if JSON_DIAGNOSTIC_POSITIONS
|
||||||
|
if (m_lexer_ref)
|
||||||
|
{
|
||||||
|
// Lexer's position is past the closing bracket, so set that as the end position.
|
||||||
|
ref_stack.back()->end_position = m_lexer_ref->get_position();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ref_stack.back()->set_parents();
|
ref_stack.back()->set_parents();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// discard array
|
// discard array
|
||||||
*ref_stack.back() = discarded;
|
*ref_stack.back() = discarded;
|
||||||
|
|
||||||
|
#if JSON_DIAGNOSTIC_POSITIONS
|
||||||
|
// Set start/end positions for discarded array.
|
||||||
|
handle_diagnostic_positions_for_json_value(*ref_stack.back());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,7 +711,7 @@ class json_sax_dom_callback_parser
|
|||||||
// remove discarded value
|
// remove discarded value
|
||||||
if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
|
if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
|
||||||
{
|
{
|
||||||
ref_stack.back()->m_value.array->pop_back();
|
ref_stack.back()->m_data.m_value.array->pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -549,6 +736,71 @@ class json_sax_dom_callback_parser
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
#if JSON_DIAGNOSTIC_POSITIONS
|
||||||
|
void handle_diagnostic_positions_for_json_value(BasicJsonType& v)
|
||||||
|
{
|
||||||
|
if (m_lexer_ref)
|
||||||
|
{
|
||||||
|
// Lexer has read past the current field value, so set the end position to the current position.
|
||||||
|
// The start position will be set below based on the length of the string representation
|
||||||
|
// of the value.
|
||||||
|
v.end_position = m_lexer_ref->get_position();
|
||||||
|
|
||||||
|
switch (v.type())
|
||||||
|
{
|
||||||
|
case value_t::boolean:
|
||||||
|
{
|
||||||
|
// 4 and 5 are the string length of "true" and "false"
|
||||||
|
v.start_position = v.end_position - (v.m_data.m_value.boolean ? 4 : 5);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case value_t::null:
|
||||||
|
{
|
||||||
|
// 4 is the string length of "null"
|
||||||
|
v.start_position = v.end_position - 4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case value_t::string:
|
||||||
|
{
|
||||||
|
// include the length of the quotes, which is 2
|
||||||
|
v.start_position = v.end_position - v.m_data.m_value.string->size() - 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case value_t::discarded:
|
||||||
|
{
|
||||||
|
v.end_position = std::string::npos;
|
||||||
|
v.start_position = v.end_position;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case value_t::binary:
|
||||||
|
case value_t::number_integer:
|
||||||
|
case value_t::number_unsigned:
|
||||||
|
case value_t::number_float:
|
||||||
|
{
|
||||||
|
v.start_position = v.end_position - m_lexer_ref->get_string().size();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case value_t::object:
|
||||||
|
case value_t::array:
|
||||||
|
{
|
||||||
|
// object and array are handled in start_object() and start_array() handlers
|
||||||
|
// skip setting the values here.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: // LCOV_EXCL_LINE
|
||||||
|
// Handle all possible types discretely, default handler should never be reached.
|
||||||
|
JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert,-warnings-as-errors) LCOV_EXCL_LINE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@param[in] v value to add to the JSON value we build during parsing
|
@param[in] v value to add to the JSON value we build during parsing
|
||||||
@param[in] skip_callback whether we should skip calling the callback
|
@param[in] skip_callback whether we should skip calling the callback
|
||||||
@ -579,6 +831,10 @@ class json_sax_dom_callback_parser
|
|||||||
// create value
|
// create value
|
||||||
auto value = BasicJsonType(std::forward<Value>(v));
|
auto value = BasicJsonType(std::forward<Value>(v));
|
||||||
|
|
||||||
|
#if JSON_DIAGNOSTIC_POSITIONS
|
||||||
|
handle_diagnostic_positions_for_json_value(value);
|
||||||
|
#endif
|
||||||
|
|
||||||
// check callback
|
// check callback
|
||||||
const bool keep = skip_callback || callback(static_cast<int>(ref_stack.size()), parse_event_t::value, value);
|
const bool keep = skip_callback || callback(static_cast<int>(ref_stack.size()), parse_event_t::value, value);
|
||||||
|
|
||||||
@ -591,7 +847,7 @@ class json_sax_dom_callback_parser
|
|||||||
if (ref_stack.empty())
|
if (ref_stack.empty())
|
||||||
{
|
{
|
||||||
root = std::move(value);
|
root = std::move(value);
|
||||||
return {true, &root};
|
return {true, & root};
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip this value if we already decided to skip the parent
|
// skip this value if we already decided to skip the parent
|
||||||
@ -607,8 +863,8 @@ class json_sax_dom_callback_parser
|
|||||||
// array
|
// array
|
||||||
if (ref_stack.back()->is_array())
|
if (ref_stack.back()->is_array())
|
||||||
{
|
{
|
||||||
ref_stack.back()->m_value.array->emplace_back(std::move(value));
|
ref_stack.back()->m_data.m_value.array->emplace_back(std::move(value));
|
||||||
return {true, &(ref_stack.back()->m_value.array->back())};
|
return {true, & (ref_stack.back()->m_data.m_value.array->back())};
|
||||||
}
|
}
|
||||||
|
|
||||||
// object
|
// object
|
||||||
@ -633,9 +889,9 @@ class json_sax_dom_callback_parser
|
|||||||
/// stack to model hierarchy of values
|
/// stack to model hierarchy of values
|
||||||
std::vector<BasicJsonType*> ref_stack {};
|
std::vector<BasicJsonType*> ref_stack {};
|
||||||
/// stack to manage which values to keep
|
/// stack to manage which values to keep
|
||||||
std::vector<bool> keep_stack {};
|
std::vector<bool> keep_stack {}; // NOLINT(readability-redundant-member-init)
|
||||||
/// stack to manage which object keys to keep
|
/// stack to manage which object keys to keep
|
||||||
std::vector<bool> key_keep_stack {};
|
std::vector<bool> key_keep_stack {}; // NOLINT(readability-redundant-member-init)
|
||||||
/// helper to hold the reference for the next object element
|
/// helper to hold the reference for the next object element
|
||||||
BasicJsonType* object_element = nullptr;
|
BasicJsonType* object_element = nullptr;
|
||||||
/// whether a syntax error occurred
|
/// whether a syntax error occurred
|
||||||
@ -646,6 +902,8 @@ class json_sax_dom_callback_parser
|
|||||||
const bool allow_exceptions = true;
|
const bool allow_exceptions = true;
|
||||||
/// a discarded value for the callback
|
/// a discarded value for the callback
|
||||||
BasicJsonType discarded = BasicJsonType::value_t::discarded;
|
BasicJsonType discarded = BasicJsonType::value_t::discarded;
|
||||||
|
/// the lexer reference to obtain the current position
|
||||||
|
lexer_t* m_lexer_ref = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
@ -693,7 +951,7 @@ class json_sax_acceptor
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool start_object(std::size_t /*unused*/ = static_cast<std::size_t>(-1))
|
bool start_object(std::size_t /*unused*/ = detail::unknown_size())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -708,7 +966,7 @@ class json_sax_acceptor
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool start_array(std::size_t /*unused*/ = static_cast<std::size_t>(-1))
|
bool start_array(std::size_t /*unused*/ = detail::unknown_size())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -21,6 +21,7 @@
|
|||||||
#include <nlohmann/detail/input/input_adapters.hpp>
|
#include <nlohmann/detail/input/input_adapters.hpp>
|
||||||
#include <nlohmann/detail/input/position_t.hpp>
|
#include <nlohmann/detail/input/position_t.hpp>
|
||||||
#include <nlohmann/detail/macro_scope.hpp>
|
#include <nlohmann/detail/macro_scope.hpp>
|
||||||
|
#include <nlohmann/detail/meta/type_traits.hpp>
|
||||||
|
|
||||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
namespace detail
|
namespace detail
|
||||||
@ -115,7 +116,7 @@ class lexer : public lexer_base<BasicJsonType>
|
|||||||
using number_float_t = typename BasicJsonType::number_float_t;
|
using number_float_t = typename BasicJsonType::number_float_t;
|
||||||
using string_t = typename BasicJsonType::string_t;
|
using string_t = typename BasicJsonType::string_t;
|
||||||
using char_type = typename InputAdapterType::char_type;
|
using char_type = typename InputAdapterType::char_type;
|
||||||
using char_int_type = typename std::char_traits<char_type>::int_type;
|
using char_int_type = typename char_traits<char_type>::int_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using token_type = typename lexer_base<BasicJsonType>::token_type;
|
using token_type = typename lexer_base<BasicJsonType>::token_type;
|
||||||
@ -222,7 +223,7 @@ class lexer : public lexer_base<BasicJsonType>
|
|||||||
for (auto range = ranges.begin(); range != ranges.end(); ++range)
|
for (auto range = ranges.begin(); range != ranges.end(); ++range)
|
||||||
{
|
{
|
||||||
get();
|
get();
|
||||||
if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range)))
|
if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) // NOLINT(bugprone-inc-dec-in-conditions)
|
||||||
{
|
{
|
||||||
add(current);
|
add(current);
|
||||||
}
|
}
|
||||||
@ -265,7 +266,7 @@ class lexer : public lexer_base<BasicJsonType>
|
|||||||
switch (get())
|
switch (get())
|
||||||
{
|
{
|
||||||
// end of file while parsing string
|
// end of file while parsing string
|
||||||
case std::char_traits<char_type>::eof():
|
case char_traits<char_type>::eof():
|
||||||
{
|
{
|
||||||
error_message = "invalid string: missing closing quote";
|
error_message = "invalid string: missing closing quote";
|
||||||
return token_type::parse_error;
|
return token_type::parse_error;
|
||||||
@ -854,7 +855,7 @@ class lexer : public lexer_base<BasicJsonType>
|
|||||||
{
|
{
|
||||||
case '\n':
|
case '\n':
|
||||||
case '\r':
|
case '\r':
|
||||||
case std::char_traits<char_type>::eof():
|
case char_traits<char_type>::eof():
|
||||||
case '\0':
|
case '\0':
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -871,7 +872,7 @@ class lexer : public lexer_base<BasicJsonType>
|
|||||||
{
|
{
|
||||||
switch (get())
|
switch (get())
|
||||||
{
|
{
|
||||||
case std::char_traits<char_type>::eof():
|
case char_traits<char_type>::eof():
|
||||||
case '\0':
|
case '\0':
|
||||||
{
|
{
|
||||||
error_message = "invalid comment; missing closing '*/'";
|
error_message = "invalid comment; missing closing '*/'";
|
||||||
@ -966,7 +967,7 @@ class lexer : public lexer_base<BasicJsonType>
|
|||||||
locale's decimal point is used instead of `.` to work with the
|
locale's decimal point is used instead of `.` to work with the
|
||||||
locale-dependent converters.
|
locale-dependent converters.
|
||||||
*/
|
*/
|
||||||
token_type scan_number() // lgtm [cpp/use-of-goto]
|
token_type scan_number() // lgtm [cpp/use-of-goto] `goto` is used in this function to implement the number-parsing state machine described above. By design, any finite input will eventually reach the "done" state or return token_type::parse_error. In each intermediate state, 1 byte of the input is appended to the token_buffer vector, and only the already initialized variables token_buffer, number_type, and error_message are manipulated.
|
||||||
{
|
{
|
||||||
// reset token_buffer to store the number's bytes
|
// reset token_buffer to store the number's bytes
|
||||||
reset();
|
reset();
|
||||||
@ -1048,6 +1049,7 @@ scan_number_zero:
|
|||||||
case '.':
|
case '.':
|
||||||
{
|
{
|
||||||
add(decimal_point_char);
|
add(decimal_point_char);
|
||||||
|
decimal_point_position = token_buffer.size() - 1;
|
||||||
goto scan_number_decimal1;
|
goto scan_number_decimal1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1084,6 +1086,7 @@ scan_number_any1:
|
|||||||
case '.':
|
case '.':
|
||||||
{
|
{
|
||||||
add(decimal_point_char);
|
add(decimal_point_char);
|
||||||
|
decimal_point_position = token_buffer.size() - 1;
|
||||||
goto scan_number_decimal1;
|
goto scan_number_decimal1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1244,7 +1247,7 @@ scan_number_done:
|
|||||||
// we are done scanning a number)
|
// we are done scanning a number)
|
||||||
unget();
|
unget();
|
||||||
|
|
||||||
char* endptr = nullptr; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
char* endptr = nullptr; // NOLINT(misc-const-correctness,cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
// try to parse integers first and fall back to floats
|
// try to parse integers first and fall back to floats
|
||||||
@ -1255,7 +1258,7 @@ scan_number_done:
|
|||||||
// we checked the number format before
|
// we checked the number format before
|
||||||
JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
|
JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
|
||||||
|
|
||||||
if (errno == 0)
|
if (errno != ERANGE)
|
||||||
{
|
{
|
||||||
value_unsigned = static_cast<number_unsigned_t>(x);
|
value_unsigned = static_cast<number_unsigned_t>(x);
|
||||||
if (value_unsigned == x)
|
if (value_unsigned == x)
|
||||||
@ -1271,7 +1274,7 @@ scan_number_done:
|
|||||||
// we checked the number format before
|
// we checked the number format before
|
||||||
JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
|
JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
|
||||||
|
|
||||||
if (errno == 0)
|
if (errno != ERANGE)
|
||||||
{
|
{
|
||||||
value_integer = static_cast<number_integer_t>(x);
|
value_integer = static_cast<number_integer_t>(x);
|
||||||
if (value_integer == x)
|
if (value_integer == x)
|
||||||
@ -1300,10 +1303,10 @@ scan_number_done:
|
|||||||
token_type scan_literal(const char_type* literal_text, const std::size_t length,
|
token_type scan_literal(const char_type* literal_text, const std::size_t length,
|
||||||
token_type return_type)
|
token_type return_type)
|
||||||
{
|
{
|
||||||
JSON_ASSERT(std::char_traits<char_type>::to_char_type(current) == literal_text[0]);
|
JSON_ASSERT(char_traits<char_type>::to_char_type(current) == literal_text[0]);
|
||||||
for (std::size_t i = 1; i < length; ++i)
|
for (std::size_t i = 1; i < length; ++i)
|
||||||
{
|
{
|
||||||
if (JSON_HEDLEY_UNLIKELY(std::char_traits<char_type>::to_char_type(get()) != literal_text[i]))
|
if (JSON_HEDLEY_UNLIKELY(char_traits<char_type>::to_char_type(get()) != literal_text[i]))
|
||||||
{
|
{
|
||||||
error_message = "invalid literal";
|
error_message = "invalid literal";
|
||||||
return token_type::parse_error;
|
return token_type::parse_error;
|
||||||
@ -1321,7 +1324,8 @@ scan_number_done:
|
|||||||
{
|
{
|
||||||
token_buffer.clear();
|
token_buffer.clear();
|
||||||
token_string.clear();
|
token_string.clear();
|
||||||
token_string.push_back(std::char_traits<char_type>::to_char_type(current));
|
decimal_point_position = std::string::npos;
|
||||||
|
token_string.push_back(char_traits<char_type>::to_char_type(current));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1329,7 +1333,7 @@ scan_number_done:
|
|||||||
|
|
||||||
This function provides the interface to the used input adapter. It does
|
This function provides the interface to the used input adapter. It does
|
||||||
not throw in case the input reached EOF, but returns a
|
not throw in case the input reached EOF, but returns a
|
||||||
`std::char_traits<char>::eof()` in that case. Stores the scanned characters
|
`char_traits<char>::eof()` in that case. Stores the scanned characters
|
||||||
for use in error messages.
|
for use in error messages.
|
||||||
|
|
||||||
@return character read from the input
|
@return character read from the input
|
||||||
@ -1349,9 +1353,9 @@ scan_number_done:
|
|||||||
current = ia.get_character();
|
current = ia.get_character();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JSON_HEDLEY_LIKELY(current != std::char_traits<char_type>::eof()))
|
if (JSON_HEDLEY_LIKELY(current != char_traits<char_type>::eof()))
|
||||||
{
|
{
|
||||||
token_string.push_back(std::char_traits<char_type>::to_char_type(current));
|
token_string.push_back(char_traits<char_type>::to_char_type(current));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current == '\n')
|
if (current == '\n')
|
||||||
@ -1390,7 +1394,7 @@ scan_number_done:
|
|||||||
--position.chars_read_current_line;
|
--position.chars_read_current_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JSON_HEDLEY_LIKELY(current != std::char_traits<char_type>::eof()))
|
if (JSON_HEDLEY_LIKELY(current != char_traits<char_type>::eof()))
|
||||||
{
|
{
|
||||||
JSON_ASSERT(!token_string.empty());
|
JSON_ASSERT(!token_string.empty());
|
||||||
token_string.pop_back();
|
token_string.pop_back();
|
||||||
@ -1429,6 +1433,11 @@ scan_number_done:
|
|||||||
/// return current string value (implicitly resets the token; useful only once)
|
/// return current string value (implicitly resets the token; useful only once)
|
||||||
string_t& get_string()
|
string_t& get_string()
|
||||||
{
|
{
|
||||||
|
// translate decimal points from locale back to '.' (#4084)
|
||||||
|
if (decimal_point_char != '.' && decimal_point_position != std::string::npos)
|
||||||
|
{
|
||||||
|
token_buffer[decimal_point_position] = '.';
|
||||||
|
}
|
||||||
return token_buffer;
|
return token_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1584,7 +1593,7 @@ scan_number_done:
|
|||||||
// end of input (the null byte is needed when parsing from
|
// end of input (the null byte is needed when parsing from
|
||||||
// string literals)
|
// string literals)
|
||||||
case '\0':
|
case '\0':
|
||||||
case std::char_traits<char_type>::eof():
|
case char_traits<char_type>::eof():
|
||||||
return token_type::end_of_input;
|
return token_type::end_of_input;
|
||||||
|
|
||||||
// error
|
// error
|
||||||
@ -1602,7 +1611,7 @@ scan_number_done:
|
|||||||
const bool ignore_comments = false;
|
const bool ignore_comments = false;
|
||||||
|
|
||||||
/// the current character
|
/// the current character
|
||||||
char_int_type current = std::char_traits<char_type>::eof();
|
char_int_type current = char_traits<char_type>::eof();
|
||||||
|
|
||||||
/// whether the next get() call should just return current
|
/// whether the next get() call should just return current
|
||||||
bool next_unget = false;
|
bool next_unget = false;
|
||||||
@ -1626,6 +1635,8 @@ scan_number_done:
|
|||||||
|
|
||||||
/// the decimal point
|
/// the decimal point
|
||||||
const char_int_type decimal_point_char = '.';
|
const char_int_type decimal_point_char = '.';
|
||||||
|
/// the position of the decimal point in the input
|
||||||
|
std::size_t decimal_point_position = std::string::npos;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -69,10 +69,10 @@ class parser
|
|||||||
public:
|
public:
|
||||||
/// a parser reading from an input adapter
|
/// a parser reading from an input adapter
|
||||||
explicit parser(InputAdapterType&& adapter,
|
explicit parser(InputAdapterType&& adapter,
|
||||||
const parser_callback_t<BasicJsonType> cb = nullptr,
|
parser_callback_t<BasicJsonType> cb = nullptr,
|
||||||
const bool allow_exceptions_ = true,
|
const bool allow_exceptions_ = true,
|
||||||
const bool skip_comments = false)
|
const bool skip_comments = false)
|
||||||
: callback(cb)
|
: callback(std::move(cb))
|
||||||
, m_lexer(std::move(adapter), skip_comments)
|
, m_lexer(std::move(adapter), skip_comments)
|
||||||
, allow_exceptions(allow_exceptions_)
|
, allow_exceptions(allow_exceptions_)
|
||||||
{
|
{
|
||||||
@ -94,7 +94,7 @@ class parser
|
|||||||
{
|
{
|
||||||
if (callback)
|
if (callback)
|
||||||
{
|
{
|
||||||
json_sax_dom_callback_parser<BasicJsonType> sdp(result, callback, allow_exceptions);
|
json_sax_dom_callback_parser<BasicJsonType, InputAdapterType> sdp(result, callback, allow_exceptions, &m_lexer);
|
||||||
sax_parse_internal(&sdp);
|
sax_parse_internal(&sdp);
|
||||||
|
|
||||||
// in strict mode, input must be completely read
|
// in strict mode, input must be completely read
|
||||||
@ -122,7 +122,7 @@ class parser
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
json_sax_dom_parser<BasicJsonType> sdp(result, allow_exceptions);
|
json_sax_dom_parser<BasicJsonType, InputAdapterType> sdp(result, allow_exceptions, &m_lexer);
|
||||||
sax_parse_internal(&sdp);
|
sax_parse_internal(&sdp);
|
||||||
|
|
||||||
// in strict mode, input must be completely read
|
// in strict mode, input must be completely read
|
||||||
@ -194,7 +194,7 @@ class parser
|
|||||||
{
|
{
|
||||||
case token_type::begin_object:
|
case token_type::begin_object:
|
||||||
{
|
{
|
||||||
if (JSON_HEDLEY_UNLIKELY(!sax->start_object(static_cast<std::size_t>(-1))))
|
if (JSON_HEDLEY_UNLIKELY(!sax->start_object(detail::unknown_size())))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -239,7 +239,7 @@ class parser
|
|||||||
|
|
||||||
case token_type::begin_array:
|
case token_type::begin_array:
|
||||||
{
|
{
|
||||||
if (JSON_HEDLEY_UNLIKELY(!sax->start_array(static_cast<std::size_t>(-1))))
|
if (JSON_HEDLEY_UNLIKELY(!sax->start_array(detail::unknown_size())))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -341,13 +341,25 @@ class parser
|
|||||||
m_lexer.get_token_string(),
|
m_lexer.get_token_string(),
|
||||||
parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), nullptr));
|
parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), nullptr));
|
||||||
}
|
}
|
||||||
|
case token_type::end_of_input:
|
||||||
|
{
|
||||||
|
if (JSON_HEDLEY_UNLIKELY(m_lexer.get_position().chars_read_total == 1))
|
||||||
|
{
|
||||||
|
return sax->parse_error(m_lexer.get_position(),
|
||||||
|
m_lexer.get_token_string(),
|
||||||
|
parse_error::create(101, m_lexer.get_position(),
|
||||||
|
"attempting to parse an empty input; check that your input string or stream contains the expected JSON", nullptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
return sax->parse_error(m_lexer.get_position(),
|
||||||
|
m_lexer.get_token_string(),
|
||||||
|
parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr));
|
||||||
|
}
|
||||||
case token_type::uninitialized:
|
case token_type::uninitialized:
|
||||||
case token_type::end_array:
|
case token_type::end_array:
|
||||||
case token_type::end_object:
|
case token_type::end_object:
|
||||||
case token_type::name_separator:
|
case token_type::name_separator:
|
||||||
case token_type::value_separator:
|
case token_type::value_separator:
|
||||||
case token_type::end_of_input:
|
|
||||||
case token_type::literal_or_value:
|
case token_type::literal_or_value:
|
||||||
default: // the last token was unexpected
|
default: // the last token was unexpected
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -101,7 +101,7 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci
|
|||||||
{
|
{
|
||||||
JSON_ASSERT(m_object != nullptr);
|
JSON_ASSERT(m_object != nullptr);
|
||||||
|
|
||||||
switch (m_object->m_type)
|
switch (m_object->m_data.m_type)
|
||||||
{
|
{
|
||||||
case value_t::object:
|
case value_t::object:
|
||||||
{
|
{
|
||||||
@ -198,17 +198,17 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci
|
|||||||
{
|
{
|
||||||
JSON_ASSERT(m_object != nullptr);
|
JSON_ASSERT(m_object != nullptr);
|
||||||
|
|
||||||
switch (m_object->m_type)
|
switch (m_object->m_data.m_type)
|
||||||
{
|
{
|
||||||
case value_t::object:
|
case value_t::object:
|
||||||
{
|
{
|
||||||
m_it.object_iterator = m_object->m_value.object->begin();
|
m_it.object_iterator = m_object->m_data.m_value.object->begin();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case value_t::array:
|
case value_t::array:
|
||||||
{
|
{
|
||||||
m_it.array_iterator = m_object->m_value.array->begin();
|
m_it.array_iterator = m_object->m_data.m_value.array->begin();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,17 +242,17 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci
|
|||||||
{
|
{
|
||||||
JSON_ASSERT(m_object != nullptr);
|
JSON_ASSERT(m_object != nullptr);
|
||||||
|
|
||||||
switch (m_object->m_type)
|
switch (m_object->m_data.m_type)
|
||||||
{
|
{
|
||||||
case value_t::object:
|
case value_t::object:
|
||||||
{
|
{
|
||||||
m_it.object_iterator = m_object->m_value.object->end();
|
m_it.object_iterator = m_object->m_data.m_value.object->end();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case value_t::array:
|
case value_t::array:
|
||||||
{
|
{
|
||||||
m_it.array_iterator = m_object->m_value.array->end();
|
m_it.array_iterator = m_object->m_data.m_value.array->end();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,17 +281,17 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci
|
|||||||
{
|
{
|
||||||
JSON_ASSERT(m_object != nullptr);
|
JSON_ASSERT(m_object != nullptr);
|
||||||
|
|
||||||
switch (m_object->m_type)
|
switch (m_object->m_data.m_type)
|
||||||
{
|
{
|
||||||
case value_t::object:
|
case value_t::object:
|
||||||
{
|
{
|
||||||
JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end());
|
JSON_ASSERT(m_it.object_iterator != m_object->m_data.m_value.object->end());
|
||||||
return m_it.object_iterator->second;
|
return m_it.object_iterator->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
case value_t::array:
|
case value_t::array:
|
||||||
{
|
{
|
||||||
JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end());
|
JSON_ASSERT(m_it.array_iterator != m_object->m_data.m_value.array->end());
|
||||||
return *m_it.array_iterator;
|
return *m_it.array_iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,17 +325,17 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci
|
|||||||
{
|
{
|
||||||
JSON_ASSERT(m_object != nullptr);
|
JSON_ASSERT(m_object != nullptr);
|
||||||
|
|
||||||
switch (m_object->m_type)
|
switch (m_object->m_data.m_type)
|
||||||
{
|
{
|
||||||
case value_t::object:
|
case value_t::object:
|
||||||
{
|
{
|
||||||
JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end());
|
JSON_ASSERT(m_it.object_iterator != m_object->m_data.m_value.object->end());
|
||||||
return &(m_it.object_iterator->second);
|
return &(m_it.object_iterator->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
case value_t::array:
|
case value_t::array:
|
||||||
{
|
{
|
||||||
JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end());
|
JSON_ASSERT(m_it.array_iterator != m_object->m_data.m_value.array->end());
|
||||||
return &*m_it.array_iterator;
|
return &*m_it.array_iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,7 +378,7 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci
|
|||||||
{
|
{
|
||||||
JSON_ASSERT(m_object != nullptr);
|
JSON_ASSERT(m_object != nullptr);
|
||||||
|
|
||||||
switch (m_object->m_type)
|
switch (m_object->m_data.m_type)
|
||||||
{
|
{
|
||||||
case value_t::object:
|
case value_t::object:
|
||||||
{
|
{
|
||||||
@ -429,7 +429,7 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci
|
|||||||
{
|
{
|
||||||
JSON_ASSERT(m_object != nullptr);
|
JSON_ASSERT(m_object != nullptr);
|
||||||
|
|
||||||
switch (m_object->m_type)
|
switch (m_object->m_data.m_type)
|
||||||
{
|
{
|
||||||
case value_t::object:
|
case value_t::object:
|
||||||
{
|
{
|
||||||
@ -463,7 +463,7 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief comparison: equal
|
@brief comparison: equal
|
||||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
@pre (1) Both iterators are initialized to point to the same object, or (2) both iterators are value-initialized.
|
||||||
*/
|
*/
|
||||||
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 >
|
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
|
bool operator==(const IterImpl& other) const
|
||||||
@ -474,9 +474,13 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci
|
|||||||
JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", m_object));
|
JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", m_object));
|
||||||
}
|
}
|
||||||
|
|
||||||
JSON_ASSERT(m_object != nullptr);
|
// value-initialized forward iterators can be compared, and must compare equal to other value-initialized iterators of the same type #4493
|
||||||
|
if (m_object == nullptr)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
switch (m_object->m_type)
|
switch (m_object->m_data.m_type)
|
||||||
{
|
{
|
||||||
case value_t::object:
|
case value_t::object:
|
||||||
return (m_it.object_iterator == other.m_it.object_iterator);
|
return (m_it.object_iterator == other.m_it.object_iterator);
|
||||||
@ -499,7 +503,7 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief comparison: not equal
|
@brief comparison: not equal
|
||||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
@pre (1) Both iterators are initialized to point to the same object, or (2) both iterators are value-initialized.
|
||||||
*/
|
*/
|
||||||
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 >
|
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
|
bool operator!=(const IterImpl& other) const
|
||||||
@ -509,7 +513,7 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief comparison: smaller
|
@brief comparison: smaller
|
||||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
@pre (1) Both iterators are initialized to point to the same object, or (2) both iterators are value-initialized.
|
||||||
*/
|
*/
|
||||||
bool operator<(const iter_impl& other) const
|
bool operator<(const iter_impl& other) const
|
||||||
{
|
{
|
||||||
@ -519,9 +523,14 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci
|
|||||||
JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", m_object));
|
JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", m_object));
|
||||||
}
|
}
|
||||||
|
|
||||||
JSON_ASSERT(m_object != nullptr);
|
// value-initialized forward iterators can be compared, and must compare equal to other value-initialized iterators of the same type #4493
|
||||||
|
if (m_object == nullptr)
|
||||||
|
{
|
||||||
|
// the iterators are both value-initialized and are to be considered equal, but this function checks for smaller, so we return false
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
switch (m_object->m_type)
|
switch (m_object->m_data.m_type)
|
||||||
{
|
{
|
||||||
case value_t::object:
|
case value_t::object:
|
||||||
JSON_THROW(invalid_iterator::create(213, "cannot compare order of object iterators", m_object));
|
JSON_THROW(invalid_iterator::create(213, "cannot compare order of object iterators", m_object));
|
||||||
@ -544,7 +553,7 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief comparison: less than or equal
|
@brief comparison: less than or equal
|
||||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
@pre (1) Both iterators are initialized to point to the same object, or (2) both iterators are value-initialized.
|
||||||
*/
|
*/
|
||||||
bool operator<=(const iter_impl& other) const
|
bool operator<=(const iter_impl& other) const
|
||||||
{
|
{
|
||||||
@ -553,7 +562,7 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief comparison: greater than
|
@brief comparison: greater than
|
||||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
@pre (1) Both iterators are initialized to point to the same object, or (2) both iterators are value-initialized.
|
||||||
*/
|
*/
|
||||||
bool operator>(const iter_impl& other) const
|
bool operator>(const iter_impl& other) const
|
||||||
{
|
{
|
||||||
@ -562,7 +571,7 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief comparison: greater than or equal
|
@brief comparison: greater than or equal
|
||||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
@pre (1) The iterator is initialized; i.e. `m_object != nullptr`, or (2) both iterators are value-initialized.
|
||||||
*/
|
*/
|
||||||
bool operator>=(const iter_impl& other) const
|
bool operator>=(const iter_impl& other) const
|
||||||
{
|
{
|
||||||
@ -577,7 +586,7 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci
|
|||||||
{
|
{
|
||||||
JSON_ASSERT(m_object != nullptr);
|
JSON_ASSERT(m_object != nullptr);
|
||||||
|
|
||||||
switch (m_object->m_type)
|
switch (m_object->m_data.m_type)
|
||||||
{
|
{
|
||||||
case value_t::object:
|
case value_t::object:
|
||||||
JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", m_object));
|
JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", m_object));
|
||||||
@ -656,7 +665,7 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci
|
|||||||
{
|
{
|
||||||
JSON_ASSERT(m_object != nullptr);
|
JSON_ASSERT(m_object != nullptr);
|
||||||
|
|
||||||
switch (m_object->m_type)
|
switch (m_object->m_data.m_type)
|
||||||
{
|
{
|
||||||
case value_t::object:
|
case value_t::object:
|
||||||
JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", m_object));
|
JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", m_object));
|
||||||
@ -685,7 +694,7 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci
|
|||||||
{
|
{
|
||||||
JSON_ASSERT(m_object != nullptr);
|
JSON_ASSERT(m_object != nullptr);
|
||||||
|
|
||||||
switch (m_object->m_type)
|
switch (m_object->m_data.m_type)
|
||||||
{
|
{
|
||||||
case value_t::object:
|
case value_t::object:
|
||||||
JSON_THROW(invalid_iterator::create(208, "cannot use operator[] for object iterators", m_object));
|
JSON_THROW(invalid_iterator::create(208, "cannot use operator[] for object iterators", m_object));
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstddef> // size_t
|
#include <cstddef> // size_t
|
||||||
#include <iterator> // input_iterator_tag
|
#include <iterator> // forward_iterator_tag
|
||||||
#include <string> // string, to_string
|
|
||||||
#include <tuple> // tuple_size, get, tuple_element
|
#include <tuple> // tuple_size, get, tuple_element
|
||||||
#include <utility> // move
|
#include <utility> // move
|
||||||
|
|
||||||
@ -20,19 +19,13 @@
|
|||||||
|
|
||||||
#include <nlohmann/detail/abi_macros.hpp>
|
#include <nlohmann/detail/abi_macros.hpp>
|
||||||
#include <nlohmann/detail/meta/type_traits.hpp>
|
#include <nlohmann/detail/meta/type_traits.hpp>
|
||||||
|
#include <nlohmann/detail/string_utils.hpp>
|
||||||
#include <nlohmann/detail/value_t.hpp>
|
#include <nlohmann/detail/value_t.hpp>
|
||||||
|
|
||||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
template<typename string_type>
|
|
||||||
void int_to_string( string_type& target, std::size_t value )
|
|
||||||
{
|
|
||||||
// For ADL
|
|
||||||
using std::to_string;
|
|
||||||
target = to_string(value);
|
|
||||||
}
|
|
||||||
template<typename IteratorType> class iteration_proxy_value
|
template<typename IteratorType> class iteration_proxy_value
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -40,7 +33,7 @@ template<typename IteratorType> class iteration_proxy_value
|
|||||||
using value_type = iteration_proxy_value;
|
using value_type = iteration_proxy_value;
|
||||||
using pointer = value_type *;
|
using pointer = value_type *;
|
||||||
using reference = value_type &;
|
using reference = value_type &;
|
||||||
using iterator_category = std::input_iterator_tag;
|
using iterator_category = std::forward_iterator_tag;
|
||||||
using string_type = typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().key() ) >::type >::type;
|
using string_type = typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().key() ) >::type >::type;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -69,10 +62,10 @@ template<typename IteratorType> class iteration_proxy_value
|
|||||||
// older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions
|
// older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions
|
||||||
iteration_proxy_value(iteration_proxy_value&&)
|
iteration_proxy_value(iteration_proxy_value&&)
|
||||||
noexcept(std::is_nothrow_move_constructible<IteratorType>::value
|
noexcept(std::is_nothrow_move_constructible<IteratorType>::value
|
||||||
&& std::is_nothrow_move_constructible<string_type>::value) = default;
|
&& std::is_nothrow_move_constructible<string_type>::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations)
|
||||||
iteration_proxy_value& operator=(iteration_proxy_value&&)
|
iteration_proxy_value& operator=(iteration_proxy_value&&)
|
||||||
noexcept(std::is_nothrow_move_assignable<IteratorType>::value
|
noexcept(std::is_nothrow_move_assignable<IteratorType>::value
|
||||||
&& std::is_nothrow_move_assignable<string_type>::value) = default;
|
&& std::is_nothrow_move_assignable<string_type>::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations)
|
||||||
~iteration_proxy_value() = default;
|
~iteration_proxy_value() = default;
|
||||||
|
|
||||||
/// dereference operator (needed for range-based for)
|
/// dereference operator (needed for range-based for)
|
||||||
@ -219,11 +212,11 @@ namespace std
|
|||||||
#pragma clang diagnostic ignored "-Wmismatched-tags"
|
#pragma clang diagnostic ignored "-Wmismatched-tags"
|
||||||
#endif
|
#endif
|
||||||
template<typename IteratorType>
|
template<typename IteratorType>
|
||||||
class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
|
class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>> // NOLINT(cert-dcl58-cpp)
|
||||||
: public std::integral_constant<std::size_t, 2> {};
|
: public std::integral_constant<std::size_t, 2> {};
|
||||||
|
|
||||||
template<std::size_t N, typename IteratorType>
|
template<std::size_t N, typename IteratorType>
|
||||||
class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
|
class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >> // NOLINT(cert-dcl58-cpp)
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using type = decltype(
|
using type = decltype(
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -43,7 +43,7 @@ struct iterator_traits
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >>
|
struct iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >>
|
||||||
: iterator_types<T>
|
: iterator_types<T>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
39
external/json/include/nlohmann/detail/json_custom_base_class.hpp
vendored
Normal file
39
external/json/include/nlohmann/detail/json_custom_base_class.hpp
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// __ _____ _____ _____
|
||||||
|
// __| | __| | | | JSON for Modern C++
|
||||||
|
// | | |__ | | | | | | version 3.12.0
|
||||||
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
|
//
|
||||||
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <type_traits> // conditional, is_same
|
||||||
|
|
||||||
|
#include <nlohmann/detail/abi_macros.hpp>
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief Default base class of the @ref basic_json class.
|
||||||
|
|
||||||
|
So that the correct implementations of the copy / move ctors / assign operators
|
||||||
|
of @ref basic_json do not require complex case distinctions
|
||||||
|
(no base class / custom base class used as customization point),
|
||||||
|
@ref basic_json always has a base class.
|
||||||
|
By default, this class is used because it is empty and thus has no effect
|
||||||
|
on the behavior of @ref basic_json.
|
||||||
|
*/
|
||||||
|
struct json_default_base {};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
using json_base_class = typename std::conditional <
|
||||||
|
std::is_same<T, void>::value,
|
||||||
|
json_default_base,
|
||||||
|
T
|
||||||
|
>::type;
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -228,9 +228,9 @@ class json_pointer
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char* p = s.c_str();
|
const char* p = s.c_str();
|
||||||
char* p_end = nullptr;
|
char* p_end = nullptr; // NOLINT(misc-const-correctness)
|
||||||
errno = 0; // strtoull doesn't reset errno
|
errno = 0; // strtoull doesn't reset errno
|
||||||
unsigned long long res = std::strtoull(p, &p_end, 10); // NOLINT(runtime/int)
|
const unsigned long long res = std::strtoull(p, &p_end, 10); // NOLINT(runtime/int)
|
||||||
if (p == p_end // invalid input or empty string
|
if (p == p_end // invalid input or empty string
|
||||||
|| errno == ERANGE // out of range
|
|| errno == ERANGE // out of range
|
||||||
|| JSON_HEDLEY_UNLIKELY(static_cast<std::size_t>(p_end - p) != s.size())) // incomplete read
|
|| JSON_HEDLEY_UNLIKELY(static_cast<std::size_t>(p_end - p) != s.size())) // incomplete read
|
||||||
@ -386,7 +386,7 @@ class json_pointer
|
|||||||
if (reference_token == "-")
|
if (reference_token == "-")
|
||||||
{
|
{
|
||||||
// explicitly treat "-" as index beyond the end
|
// explicitly treat "-" as index beyond the end
|
||||||
ptr = &ptr->operator[](ptr->m_value.array->size());
|
ptr = &ptr->operator[](ptr->m_data.m_value.array->size());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -438,7 +438,7 @@ class json_pointer
|
|||||||
{
|
{
|
||||||
// "-" always fails the range check
|
// "-" always fails the range check
|
||||||
JSON_THROW(detail::out_of_range::create(402, detail::concat(
|
JSON_THROW(detail::out_of_range::create(402, detail::concat(
|
||||||
"array index '-' (", std::to_string(ptr->m_value.array->size()),
|
"array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
|
||||||
") is out of range"), ptr));
|
") is out of range"), ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,7 +495,7 @@ class json_pointer
|
|||||||
if (JSON_HEDLEY_UNLIKELY(reference_token == "-"))
|
if (JSON_HEDLEY_UNLIKELY(reference_token == "-"))
|
||||||
{
|
{
|
||||||
// "-" cannot be used for const access
|
// "-" cannot be used for const access
|
||||||
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));
|
JSON_THROW(detail::out_of_range::create(402, detail::concat("array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), ") is out of range"), ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
// use unchecked array access
|
// use unchecked array access
|
||||||
@ -545,7 +545,7 @@ class json_pointer
|
|||||||
{
|
{
|
||||||
// "-" always fails the range check
|
// "-" always fails the range check
|
||||||
JSON_THROW(detail::out_of_range::create(402, detail::concat(
|
JSON_THROW(detail::out_of_range::create(402, detail::concat(
|
||||||
"array index '-' (", std::to_string(ptr->m_value.array->size()),
|
"array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
|
||||||
") is out of range"), ptr));
|
") is out of range"), ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -740,7 +740,7 @@ class json_pointer
|
|||||||
{
|
{
|
||||||
case detail::value_t::array:
|
case detail::value_t::array:
|
||||||
{
|
{
|
||||||
if (value.m_value.array->empty())
|
if (value.m_data.m_value.array->empty())
|
||||||
{
|
{
|
||||||
// flatten empty array as null
|
// flatten empty array as null
|
||||||
result[reference_string] = nullptr;
|
result[reference_string] = nullptr;
|
||||||
@ -748,10 +748,10 @@ class json_pointer
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// iterate array and use index as reference string
|
// iterate array and use index as reference string
|
||||||
for (std::size_t i = 0; i < value.m_value.array->size(); ++i)
|
for (std::size_t i = 0; i < value.m_data.m_value.array->size(); ++i)
|
||||||
{
|
{
|
||||||
flatten(detail::concat(reference_string, '/', std::to_string(i)),
|
flatten(detail::concat<string_t>(reference_string, '/', std::to_string(i)),
|
||||||
value.m_value.array->operator[](i), result);
|
value.m_data.m_value.array->operator[](i), result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -759,7 +759,7 @@ class json_pointer
|
|||||||
|
|
||||||
case detail::value_t::object:
|
case detail::value_t::object:
|
||||||
{
|
{
|
||||||
if (value.m_value.object->empty())
|
if (value.m_data.m_value.object->empty())
|
||||||
{
|
{
|
||||||
// flatten empty object as null
|
// flatten empty object as null
|
||||||
result[reference_string] = nullptr;
|
result[reference_string] = nullptr;
|
||||||
@ -767,9 +767,9 @@ class json_pointer
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// iterate object and use keys as reference string
|
// iterate object and use keys as reference string
|
||||||
for (const auto& element : *value.m_value.object)
|
for (const auto& element : *value.m_data.m_value.object)
|
||||||
{
|
{
|
||||||
flatten(detail::concat(reference_string, '/', detail::escape(element.first)), element.second, result);
|
flatten(detail::concat<string_t>(reference_string, '/', detail::escape(element.first)), element.second, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -814,7 +814,7 @@ class json_pointer
|
|||||||
BasicJsonType result;
|
BasicJsonType result;
|
||||||
|
|
||||||
// iterate the JSON object values
|
// iterate the JSON object values
|
||||||
for (const auto& element : *value.m_value.object)
|
for (const auto& element : *value.m_data.m_value.object)
|
||||||
{
|
{
|
||||||
if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive()))
|
if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive()))
|
||||||
{
|
{
|
||||||
@ -846,55 +846,143 @@ class json_pointer
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
public:
|
||||||
@brief compares two JSON pointers for equality
|
#if JSON_HAS_THREE_WAY_COMPARISON
|
||||||
|
/// @brief compares two JSON pointers for equality
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/
|
||||||
|
template<typename RefStringTypeRhs>
|
||||||
|
bool operator==(const json_pointer<RefStringTypeRhs>& rhs) const noexcept
|
||||||
|
{
|
||||||
|
return reference_tokens == rhs.reference_tokens;
|
||||||
|
}
|
||||||
|
|
||||||
@param[in] lhs JSON pointer to compare
|
/// @brief compares JSON pointer and string for equality
|
||||||
@param[in] rhs JSON pointer to compare
|
/// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/
|
||||||
@return whether @a lhs is equal to @a rhs
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer))
|
||||||
|
bool operator==(const string_t& rhs) const
|
||||||
|
{
|
||||||
|
return *this == json_pointer(rhs);
|
||||||
|
}
|
||||||
|
|
||||||
@complexity Linear in the length of the JSON pointer
|
/// @brief 3-way compares two JSON pointers
|
||||||
|
template<typename RefStringTypeRhs>
|
||||||
@exceptionsafety No-throw guarantee: this function never throws exceptions.
|
std::strong_ordering operator<=>(const json_pointer<RefStringTypeRhs>& rhs) const noexcept // *NOPAD*
|
||||||
*/
|
{
|
||||||
|
return reference_tokens <=> rhs.reference_tokens; // *NOPAD*
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/// @brief compares two JSON pointers for equality
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/
|
||||||
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
|
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
|
||||||
// NOLINTNEXTLINE(readability-redundant-declaration)
|
// NOLINTNEXTLINE(readability-redundant-declaration)
|
||||||
friend bool operator==(json_pointer<RefStringTypeLhs> const& lhs,
|
friend bool operator==(const json_pointer<RefStringTypeLhs>& lhs,
|
||||||
json_pointer<RefStringTypeRhs> const& rhs) noexcept;
|
const json_pointer<RefStringTypeRhs>& rhs) noexcept;
|
||||||
|
|
||||||
/*!
|
/// @brief compares JSON pointer and string for equality
|
||||||
@brief compares two JSON pointers for inequality
|
/// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/
|
||||||
|
template<typename RefStringTypeLhs, typename StringType>
|
||||||
|
// NOLINTNEXTLINE(readability-redundant-declaration)
|
||||||
|
friend bool operator==(const json_pointer<RefStringTypeLhs>& lhs,
|
||||||
|
const StringType& rhs);
|
||||||
|
|
||||||
@param[in] lhs JSON pointer to compare
|
/// @brief compares string and JSON pointer for equality
|
||||||
@param[in] rhs JSON pointer to compare
|
/// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/
|
||||||
@return whether @a lhs is not equal @a rhs
|
template<typename RefStringTypeRhs, typename StringType>
|
||||||
|
// NOLINTNEXTLINE(readability-redundant-declaration)
|
||||||
|
friend bool operator==(const StringType& lhs,
|
||||||
|
const json_pointer<RefStringTypeRhs>& rhs);
|
||||||
|
|
||||||
@complexity Linear in the length of the JSON pointer
|
/// @brief compares two JSON pointers for inequality
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/
|
||||||
@exceptionsafety No-throw guarantee: this function never throws exceptions.
|
|
||||||
*/
|
|
||||||
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
|
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
|
||||||
// NOLINTNEXTLINE(readability-redundant-declaration)
|
// NOLINTNEXTLINE(readability-redundant-declaration)
|
||||||
friend bool operator!=(json_pointer<RefStringTypeLhs> const& lhs,
|
friend bool operator!=(const json_pointer<RefStringTypeLhs>& lhs,
|
||||||
json_pointer<RefStringTypeRhs> const& rhs) noexcept;
|
const json_pointer<RefStringTypeRhs>& rhs) noexcept;
|
||||||
|
|
||||||
|
/// @brief compares JSON pointer and string for inequality
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/
|
||||||
|
template<typename RefStringTypeLhs, typename StringType>
|
||||||
|
// NOLINTNEXTLINE(readability-redundant-declaration)
|
||||||
|
friend bool operator!=(const json_pointer<RefStringTypeLhs>& lhs,
|
||||||
|
const StringType& rhs);
|
||||||
|
|
||||||
|
/// @brief compares string and JSON pointer for inequality
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/
|
||||||
|
template<typename RefStringTypeRhs, typename StringType>
|
||||||
|
// NOLINTNEXTLINE(readability-redundant-declaration)
|
||||||
|
friend bool operator!=(const StringType& lhs,
|
||||||
|
const json_pointer<RefStringTypeRhs>& rhs);
|
||||||
|
|
||||||
|
/// @brief compares two JSON pointer for less-than
|
||||||
|
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
|
||||||
|
// NOLINTNEXTLINE(readability-redundant-declaration)
|
||||||
|
friend bool operator<(const json_pointer<RefStringTypeLhs>& lhs,
|
||||||
|
const json_pointer<RefStringTypeRhs>& rhs) noexcept;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
/// the reference tokens
|
/// the reference tokens
|
||||||
std::vector<string_t> reference_tokens;
|
std::vector<string_t> reference_tokens;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if !JSON_HAS_THREE_WAY_COMPARISON
|
||||||
// functions cannot be defined inside class due to ODR violations
|
// functions cannot be defined inside class due to ODR violations
|
||||||
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
|
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
|
||||||
inline bool operator==(json_pointer<RefStringTypeLhs> const& lhs,
|
inline bool operator==(const json_pointer<RefStringTypeLhs>& lhs,
|
||||||
json_pointer<RefStringTypeRhs> const& rhs) noexcept
|
const json_pointer<RefStringTypeRhs>& rhs) noexcept
|
||||||
{
|
{
|
||||||
return lhs.reference_tokens == rhs.reference_tokens;
|
return lhs.reference_tokens == rhs.reference_tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename RefStringTypeLhs,
|
||||||
|
typename StringType = typename json_pointer<RefStringTypeLhs>::string_t>
|
||||||
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer))
|
||||||
|
inline bool operator==(const json_pointer<RefStringTypeLhs>& lhs,
|
||||||
|
const StringType& rhs)
|
||||||
|
{
|
||||||
|
return lhs == json_pointer<RefStringTypeLhs>(rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename RefStringTypeRhs,
|
||||||
|
typename StringType = typename json_pointer<RefStringTypeRhs>::string_t>
|
||||||
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer))
|
||||||
|
inline bool operator==(const StringType& lhs,
|
||||||
|
const json_pointer<RefStringTypeRhs>& rhs)
|
||||||
|
{
|
||||||
|
return json_pointer<RefStringTypeRhs>(lhs) == rhs;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
|
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
|
||||||
inline bool operator!=(json_pointer<RefStringTypeLhs> const& lhs,
|
inline bool operator!=(const json_pointer<RefStringTypeLhs>& lhs,
|
||||||
json_pointer<RefStringTypeRhs> const& rhs) noexcept
|
const json_pointer<RefStringTypeRhs>& rhs) noexcept
|
||||||
{
|
{
|
||||||
return !(lhs == rhs);
|
return !(lhs == rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename RefStringTypeLhs,
|
||||||
|
typename StringType = typename json_pointer<RefStringTypeLhs>::string_t>
|
||||||
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator!=(json_pointer, json_pointer))
|
||||||
|
inline bool operator!=(const json_pointer<RefStringTypeLhs>& lhs,
|
||||||
|
const StringType& rhs)
|
||||||
|
{
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename RefStringTypeRhs,
|
||||||
|
typename StringType = typename json_pointer<RefStringTypeRhs>::string_t>
|
||||||
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator!=(json_pointer, json_pointer))
|
||||||
|
inline bool operator!=(const StringType& lhs,
|
||||||
|
const json_pointer<RefStringTypeRhs>& rhs)
|
||||||
|
{
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
|
||||||
|
inline bool operator<(const json_pointer<RefStringTypeLhs>& lhs,
|
||||||
|
const json_pointer<RefStringTypeRhs>& rhs) noexcept
|
||||||
|
{
|
||||||
|
return lhs.reference_tokens < rhs.reference_tokens;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
NLOHMANN_JSON_NAMESPACE_END
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -32,15 +32,20 @@
|
|||||||
|
|
||||||
// C++ language standard detection
|
// C++ language standard detection
|
||||||
// if the user manually specified the used c++ version this is skipped
|
// 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(JSON_HAS_CPP_23) && !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)
|
#if (defined(__cplusplus) && __cplusplus > 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG > 202002L)
|
||||||
|
#define JSON_HAS_CPP_23
|
||||||
#define JSON_HAS_CPP_20
|
#define JSON_HAS_CPP_20
|
||||||
#define JSON_HAS_CPP_17
|
#define JSON_HAS_CPP_17
|
||||||
#define JSON_HAS_CPP_14
|
#define JSON_HAS_CPP_14
|
||||||
#elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
|
#elif (defined(__cplusplus) && __cplusplus > 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG > 201703L)
|
||||||
|
#define JSON_HAS_CPP_20
|
||||||
#define JSON_HAS_CPP_17
|
#define JSON_HAS_CPP_17
|
||||||
#define JSON_HAS_CPP_14
|
#define JSON_HAS_CPP_14
|
||||||
#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
|
#elif (defined(__cplusplus) && __cplusplus > 201402L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
|
||||||
|
#define JSON_HAS_CPP_17
|
||||||
|
#define JSON_HAS_CPP_14
|
||||||
|
#elif (defined(__cplusplus) && __cplusplus > 201103L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
|
||||||
#define JSON_HAS_CPP_14
|
#define JSON_HAS_CPP_14
|
||||||
#endif
|
#endif
|
||||||
// the cpp 11 flag is always specified because it is the minimal required version
|
// the cpp 11 flag is always specified because it is the minimal required version
|
||||||
@ -133,6 +138,14 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef JSON_HAS_STATIC_RTTI
|
||||||
|
#if !defined(_HAS_STATIC_RTTI) || _HAS_STATIC_RTTI != 0
|
||||||
|
#define JSON_HAS_STATIC_RTTI 1
|
||||||
|
#else
|
||||||
|
#define JSON_HAS_STATIC_RTTI 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef JSON_HAS_CPP_17
|
#ifdef JSON_HAS_CPP_17
|
||||||
#define JSON_INLINE_VARIABLE inline
|
#define JSON_INLINE_VARIABLE inline
|
||||||
#else
|
#else
|
||||||
@ -208,7 +221,9 @@
|
|||||||
template<typename BasicJsonType> \
|
template<typename BasicJsonType> \
|
||||||
inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
|
inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
|
||||||
{ \
|
{ \
|
||||||
|
/* NOLINTNEXTLINE(modernize-type-traits) we use C++11 */ \
|
||||||
static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
|
static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
|
||||||
|
/* NOLINTNEXTLINE(modernize-avoid-c-arrays) we don't want to depend on <array> */ \
|
||||||
static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
|
static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
|
||||||
auto it = std::find_if(std::begin(m), std::end(m), \
|
auto it = std::find_if(std::begin(m), std::end(m), \
|
||||||
[e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
|
[e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
|
||||||
@ -220,7 +235,9 @@
|
|||||||
template<typename BasicJsonType> \
|
template<typename BasicJsonType> \
|
||||||
inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
|
inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
|
||||||
{ \
|
{ \
|
||||||
|
/* NOLINTNEXTLINE(modernize-type-traits) we use C++11 */ \
|
||||||
static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
|
static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
|
||||||
|
/* NOLINTNEXTLINE(modernize-avoid-c-arrays) we don't want to depend on <array> */ \
|
||||||
static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
|
static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
|
||||||
auto it = std::find_if(std::begin(m), std::end(m), \
|
auto it = std::find_if(std::begin(m), std::end(m), \
|
||||||
[&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
|
[&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
|
||||||
@ -240,12 +257,13 @@
|
|||||||
class NumberUnsignedType, class NumberFloatType, \
|
class NumberUnsignedType, class NumberFloatType, \
|
||||||
template<typename> class AllocatorType, \
|
template<typename> class AllocatorType, \
|
||||||
template<typename, typename = void> class JSONSerializer, \
|
template<typename, typename = void> class JSONSerializer, \
|
||||||
class BinaryType>
|
class BinaryType, \
|
||||||
|
class CustomBaseClass>
|
||||||
|
|
||||||
#define NLOHMANN_BASIC_JSON_TPL \
|
#define NLOHMANN_BASIC_JSON_TPL \
|
||||||
basic_json<ObjectType, ArrayType, StringType, BooleanType, \
|
basic_json<ObjectType, ArrayType, StringType, BooleanType, \
|
||||||
NumberIntegerType, NumberUnsignedType, NumberFloatType, \
|
NumberIntegerType, NumberUnsignedType, NumberFloatType, \
|
||||||
AllocatorType, JSONSerializer, BinaryType>
|
AllocatorType, JSONSerializer, BinaryType, CustomBaseClass>
|
||||||
|
|
||||||
// Macros to simplify conversion from/to types
|
// Macros to simplify conversion from/to types
|
||||||
|
|
||||||
@ -382,37 +400,146 @@
|
|||||||
|
|
||||||
#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
|
#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(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);
|
#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = !nlohmann_json_j.is_null() ? nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1) : nlohmann_json_default_obj.v1;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@def NLOHMANN_DEFINE_TYPE_INTRUSIVE
|
@def NLOHMANN_DEFINE_TYPE_INTRUSIVE
|
||||||
@since version 3.9.0
|
@since version 3.9.0
|
||||||
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
|
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(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__)) } \
|
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
||||||
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__)) }
|
friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
||||||
|
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
||||||
|
friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief macro
|
||||||
|
@def NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT
|
||||||
|
@since version 3.11.0
|
||||||
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/
|
||||||
|
*/
|
||||||
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
|
#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__)) } \
|
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
||||||
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__)) }
|
friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
||||||
|
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
||||||
|
friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief macro
|
||||||
|
@def NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE
|
||||||
|
@since version 3.11.3
|
||||||
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/
|
||||||
|
*/
|
||||||
|
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
|
||||||
|
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
||||||
|
friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE
|
@def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE
|
||||||
@since version 3.9.0
|
@since version 3.9.0
|
||||||
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
|
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(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__)) } \
|
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
||||||
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__)) }
|
void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
||||||
|
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
||||||
|
void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief macro
|
||||||
|
@def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT
|
||||||
|
@since version 3.11.0
|
||||||
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/
|
||||||
|
*/
|
||||||
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
|
#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__)) } \
|
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
||||||
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__)) }
|
void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
||||||
|
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
||||||
|
void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief macro
|
||||||
|
@def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE
|
||||||
|
@since version 3.11.3
|
||||||
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/
|
||||||
|
*/
|
||||||
|
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
|
||||||
|
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
||||||
|
void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief macro
|
||||||
|
@def NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE
|
||||||
|
@since version 3.12.0
|
||||||
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
||||||
|
*/
|
||||||
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(Type, BaseType, ...) \
|
||||||
|
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
||||||
|
friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
||||||
|
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
||||||
|
friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief macro
|
||||||
|
@def NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT
|
||||||
|
@since version 3.12.0
|
||||||
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
||||||
|
*/
|
||||||
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
|
||||||
|
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
||||||
|
friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
||||||
|
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
||||||
|
friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief macro
|
||||||
|
@def NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE
|
||||||
|
@since version 3.12.0
|
||||||
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
||||||
|
*/
|
||||||
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
|
||||||
|
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
||||||
|
friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief macro
|
||||||
|
@def NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE
|
||||||
|
@since version 3.12.0
|
||||||
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
||||||
|
*/
|
||||||
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE(Type, BaseType, ...) \
|
||||||
|
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
||||||
|
void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
||||||
|
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
||||||
|
void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief macro
|
||||||
|
@def NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT
|
||||||
|
@since version 3.12.0
|
||||||
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
||||||
|
*/
|
||||||
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
|
||||||
|
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
||||||
|
void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
||||||
|
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
||||||
|
void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief macro
|
||||||
|
@def NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE
|
||||||
|
@since version 3.12.0
|
||||||
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
||||||
|
*/
|
||||||
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
|
||||||
|
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
||||||
|
void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
|
||||||
|
|
||||||
// inspired from https://stackoverflow.com/a/26745591
|
// inspired from https://stackoverflow.com/a/26745591
|
||||||
// allows to call any std function as if (e.g. with begin):
|
// allows calling any std function as if (e.g., with begin):
|
||||||
// using std::begin; begin(x);
|
// using std::begin; begin(x);
|
||||||
//
|
//
|
||||||
// it allows using the detected idiom to retrieve the return type
|
// it allows using the detected idiom to retrieve the return type
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -34,10 +34,12 @@
|
|||||||
#undef JSON_HAS_CPP_14
|
#undef JSON_HAS_CPP_14
|
||||||
#undef JSON_HAS_CPP_17
|
#undef JSON_HAS_CPP_17
|
||||||
#undef JSON_HAS_CPP_20
|
#undef JSON_HAS_CPP_20
|
||||||
|
#undef JSON_HAS_CPP_23
|
||||||
#undef JSON_HAS_FILESYSTEM
|
#undef JSON_HAS_FILESYSTEM
|
||||||
#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
|
#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
|
||||||
#undef JSON_HAS_THREE_WAY_COMPARISON
|
#undef JSON_HAS_THREE_WAY_COMPARISON
|
||||||
#undef JSON_HAS_RANGES
|
#undef JSON_HAS_RANGES
|
||||||
|
#undef JSON_HAS_STATIC_RTTI
|
||||||
#undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
|
#undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-FileCopyrightText: 2018 The Abseil Authors
|
// SPDX-FileCopyrightText: 2018 The Abseil Authors
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array> // array
|
||||||
#include <cstddef> // size_t
|
#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 <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
|
#include <utility> // index_sequence, make_index_sequence, index_sequence_for
|
||||||
@ -152,15 +153,19 @@ template<> struct priority_tag<0> {};
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
struct static_const
|
struct static_const
|
||||||
{
|
{
|
||||||
static constexpr T value{};
|
static JSON_INLINE_VARIABLE constexpr T value{};
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef JSON_HAS_CPP_17
|
#ifndef JSON_HAS_CPP_17
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr T static_const<T>::value; // NOLINT(readability-redundant-declaration)
|
constexpr T static_const<T>::value;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
template<typename T, typename... Args>
|
||||||
|
constexpr std::array<T, sizeof...(Args)> make_array(Args&& ... args)
|
||||||
|
{
|
||||||
|
return std::array<T, sizeof...(Args)> {{static_cast<T>(std::forward<Args>(args))...}};
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
NLOHMANN_JSON_NAMESPACE_END
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -19,7 +19,7 @@ namespace std_fs = std::experimental::filesystem;
|
|||||||
} // namespace detail
|
} // namespace detail
|
||||||
NLOHMANN_JSON_NAMESPACE_END
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
#elif JSON_HAS_FILESYSTEM
|
#elif JSON_HAS_FILESYSTEM
|
||||||
#include <filesystem>
|
#include <filesystem> // NOLINT(build/c++17)
|
||||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <limits> // numeric_limits
|
#include <limits> // numeric_limits
|
||||||
|
#include <string> // char_traits
|
||||||
|
#include <tuple> // tuple
|
||||||
#include <type_traits> // false_type, is_constructible, is_integral, is_same, true_type
|
#include <type_traits> // false_type, is_constructible, is_integral, is_same, true_type
|
||||||
#include <utility> // declval
|
#include <utility> // declval
|
||||||
#include <tuple> // tuple
|
|
||||||
|
|
||||||
#include <nlohmann/detail/iterators/iterator_traits.hpp>
|
#include <nlohmann/detail/iterators/iterator_traits.hpp>
|
||||||
#include <nlohmann/detail/macro_scope.hpp>
|
#include <nlohmann/detail/macro_scope.hpp>
|
||||||
@ -181,6 +182,63 @@ struct actual_object_comparator
|
|||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
using actual_object_comparator_t = typename actual_object_comparator<BasicJsonType>::type;
|
using actual_object_comparator_t = typename actual_object_comparator<BasicJsonType>::type;
|
||||||
|
|
||||||
|
/////////////////
|
||||||
|
// char_traits //
|
||||||
|
/////////////////
|
||||||
|
|
||||||
|
// Primary template of char_traits calls std char_traits
|
||||||
|
template<typename T>
|
||||||
|
struct char_traits : std::char_traits<T>
|
||||||
|
{};
|
||||||
|
|
||||||
|
// Explicitly define char traits for unsigned char since it is not standard
|
||||||
|
template<>
|
||||||
|
struct char_traits<unsigned char> : std::char_traits<char>
|
||||||
|
{
|
||||||
|
using char_type = unsigned char;
|
||||||
|
using int_type = uint64_t;
|
||||||
|
|
||||||
|
// Redefine to_int_type function
|
||||||
|
static int_type to_int_type(char_type c) noexcept
|
||||||
|
{
|
||||||
|
return static_cast<int_type>(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char_type to_char_type(int_type i) noexcept
|
||||||
|
{
|
||||||
|
return static_cast<char_type>(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
static constexpr int_type eof() noexcept
|
||||||
|
{
|
||||||
|
return static_cast<int_type>(std::char_traits<char>::eof());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Explicitly define char traits for signed char since it is not standard
|
||||||
|
template<>
|
||||||
|
struct char_traits<signed char> : std::char_traits<char>
|
||||||
|
{
|
||||||
|
using char_type = signed char;
|
||||||
|
using int_type = uint64_t;
|
||||||
|
|
||||||
|
// Redefine to_int_type function
|
||||||
|
static int_type to_int_type(char_type c) noexcept
|
||||||
|
{
|
||||||
|
return static_cast<int_type>(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char_type to_char_type(int_type i) noexcept
|
||||||
|
{
|
||||||
|
return static_cast<char_type>(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
static constexpr int_type eof() noexcept
|
||||||
|
{
|
||||||
|
return static_cast<int_type>(std::char_traits<char>::eof());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
// is_ functions //
|
// is_ functions //
|
||||||
///////////////////
|
///////////////////
|
||||||
@ -203,20 +261,19 @@ struct is_default_constructible : std::is_default_constructible<T> {};
|
|||||||
|
|
||||||
template <typename T1, typename T2>
|
template <typename T1, typename T2>
|
||||||
struct is_default_constructible<std::pair<T1, T2>>
|
struct is_default_constructible<std::pair<T1, T2>>
|
||||||
: conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
|
: conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
|
||||||
|
|
||||||
template <typename T1, typename T2>
|
template <typename T1, typename T2>
|
||||||
struct is_default_constructible<const std::pair<T1, T2>>
|
struct is_default_constructible<const std::pair<T1, T2>>
|
||||||
: conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
|
: conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
struct is_default_constructible<std::tuple<Ts...>>
|
struct is_default_constructible<std::tuple<Ts...>>
|
||||||
: conjunction<is_default_constructible<Ts>...> {};
|
: conjunction<is_default_constructible<Ts>...> {};
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
struct is_default_constructible<const std::tuple<Ts...>>
|
struct is_default_constructible<const std::tuple<Ts...>>
|
||||||
: conjunction<is_default_constructible<Ts>...> {};
|
: conjunction<is_default_constructible<Ts>...> {};
|
||||||
|
|
||||||
|
|
||||||
template <typename T, typename... Args>
|
template <typename T, typename... Args>
|
||||||
struct is_constructible : std::is_constructible<T, Args...> {};
|
struct is_constructible : std::is_constructible<T, Args...> {};
|
||||||
@ -233,7 +290,6 @@ struct is_constructible<std::tuple<Ts...>> : is_default_constructible<std::tuple
|
|||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
struct is_constructible<const std::tuple<Ts...>> : is_default_constructible<const std::tuple<Ts...>> {};
|
struct is_constructible<const std::tuple<Ts...>> : is_default_constructible<const std::tuple<Ts...>> {};
|
||||||
|
|
||||||
|
|
||||||
template<typename T, typename = void>
|
template<typename T, typename = void>
|
||||||
struct is_iterator_traits : std::false_type {};
|
struct is_iterator_traits : std::false_type {};
|
||||||
|
|
||||||
@ -415,8 +471,8 @@ is_detected<range_value_t, ConstructibleArrayType>::value&&
|
|||||||
// special case for types like std::filesystem::path whose iterator's value_type are themselves
|
// special case for types like std::filesystem::path whose iterator's value_type are themselves
|
||||||
// c.f. https://github.com/nlohmann/json/pull/3073
|
// c.f. https://github.com/nlohmann/json/pull/3073
|
||||||
!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>::value&&
|
!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>::value&&
|
||||||
is_complete_type <
|
is_complete_type <
|
||||||
detected_t<range_value_t, ConstructibleArrayType >>::value >>
|
detected_t<range_value_t, ConstructibleArrayType >>::value >>
|
||||||
{
|
{
|
||||||
using value_type = range_value_t<ConstructibleArrayType>;
|
using value_type = range_value_t<ConstructibleArrayType>;
|
||||||
|
|
||||||
@ -539,12 +595,12 @@ using is_usable_as_key_type = typename std::conditional <
|
|||||||
template<typename BasicJsonType, typename KeyTypeCVRef, bool RequireTransparentComparator = true,
|
template<typename BasicJsonType, typename KeyTypeCVRef, bool RequireTransparentComparator = true,
|
||||||
bool ExcludeObjectKeyType = RequireTransparentComparator, typename KeyType = uncvref_t<KeyTypeCVRef>>
|
bool ExcludeObjectKeyType = RequireTransparentComparator, typename KeyType = uncvref_t<KeyTypeCVRef>>
|
||||||
using is_usable_as_basic_json_key_type = typename std::conditional <
|
using is_usable_as_basic_json_key_type = typename std::conditional <
|
||||||
is_usable_as_key_type<typename BasicJsonType::object_comparator_t,
|
is_usable_as_key_type<typename BasicJsonType::object_comparator_t,
|
||||||
typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
|
typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
|
||||||
RequireTransparentComparator, ExcludeObjectKeyType>::value
|
RequireTransparentComparator, ExcludeObjectKeyType>::value
|
||||||
&& !is_json_iterator_of<BasicJsonType, KeyType>::value,
|
&& !is_json_iterator_of<BasicJsonType, KeyType>::value,
|
||||||
std::true_type,
|
std::true_type,
|
||||||
std::false_type >::type;
|
std::false_type >::type;
|
||||||
|
|
||||||
template<typename ObjectType, typename KeyType>
|
template<typename ObjectType, typename KeyType>
|
||||||
using detect_erase_with_key_type = decltype(std::declval<ObjectType&>().erase(std::declval<KeyType>()));
|
using detect_erase_with_key_type = decltype(std::declval<ObjectType&>().erase(std::declval<KeyType>()));
|
||||||
@ -643,7 +699,6 @@ struct value_in_range_of_impl2<OfType, T, false, true>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template<typename OfType, typename T>
|
template<typename OfType, typename T>
|
||||||
struct value_in_range_of_impl2<OfType, T, true, true>
|
struct value_in_range_of_impl2<OfType, T, true, true>
|
||||||
{
|
{
|
||||||
@ -679,10 +734,62 @@ struct value_in_range_of_impl1<OfType, T, true>
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename OfType, typename T>
|
template<typename OfType, typename T>
|
||||||
inline constexpr bool value_in_range_of(T val)
|
constexpr bool value_in_range_of(T val)
|
||||||
{
|
{
|
||||||
return value_in_range_of_impl1<OfType, T>::test(val);
|
return value_in_range_of_impl1<OfType, T>::test(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<bool Value>
|
||||||
|
using bool_constant = std::integral_constant<bool, Value>;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// is_c_string
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
constexpr bool is_c_string()
|
||||||
|
{
|
||||||
|
using TUnExt = typename std::remove_extent<T>::type;
|
||||||
|
using TUnCVExt = typename std::remove_cv<TUnExt>::type;
|
||||||
|
using TUnPtr = typename std::remove_pointer<T>::type;
|
||||||
|
using TUnCVPtr = typename std::remove_cv<TUnPtr>::type;
|
||||||
|
return
|
||||||
|
(std::is_array<T>::value && std::is_same<TUnCVExt, char>::value)
|
||||||
|
|| (std::is_pointer<T>::value && std::is_same<TUnCVPtr, char>::value);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace impl
|
||||||
|
|
||||||
|
// checks whether T is a [cv] char */[cv] char[] C string
|
||||||
|
template<typename T>
|
||||||
|
struct is_c_string : bool_constant<impl::is_c_string<T>()> {};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
using is_c_string_uncvref = is_c_string<uncvref_t<T>>;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// is_transparent
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
constexpr bool is_transparent()
|
||||||
|
{
|
||||||
|
return is_detected<detect_is_transparent, T>::value;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace impl
|
||||||
|
|
||||||
|
// checks whether T has a member named is_transparent
|
||||||
|
template<typename T>
|
||||||
|
struct is_transparent : bool_constant<impl::is_transparent<T>()> {};
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
NLOHMANN_JSON_NAMESPACE_END
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -28,6 +28,13 @@ NLOHMANN_JSON_NAMESPACE_BEGIN
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/// how to encode BJData
|
||||||
|
enum class bjdata_version_t
|
||||||
|
{
|
||||||
|
draft2,
|
||||||
|
draft3,
|
||||||
|
};
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
// binary writer //
|
// binary writer //
|
||||||
///////////////////
|
///////////////////
|
||||||
@ -63,7 +70,7 @@ class binary_writer
|
|||||||
{
|
{
|
||||||
case value_t::object:
|
case value_t::object:
|
||||||
{
|
{
|
||||||
write_bson_object(*j.m_value.object);
|
write_bson_object(*j.m_data.m_value.object);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +105,7 @@ class binary_writer
|
|||||||
|
|
||||||
case value_t::boolean:
|
case value_t::boolean:
|
||||||
{
|
{
|
||||||
oa->write_character(j.m_value.boolean
|
oa->write_character(j.m_data.m_value.boolean
|
||||||
? to_char_type(0xF5)
|
? to_char_type(0xF5)
|
||||||
: to_char_type(0xF4));
|
: to_char_type(0xF4));
|
||||||
break;
|
break;
|
||||||
@ -106,42 +113,42 @@ class binary_writer
|
|||||||
|
|
||||||
case value_t::number_integer:
|
case value_t::number_integer:
|
||||||
{
|
{
|
||||||
if (j.m_value.number_integer >= 0)
|
if (j.m_data.m_value.number_integer >= 0)
|
||||||
{
|
{
|
||||||
// CBOR does not differentiate between positive signed
|
// CBOR does not differentiate between positive signed
|
||||||
// integers and unsigned integers. Therefore, we used the
|
// integers and unsigned integers. Therefore, we used the
|
||||||
// code from the value_t::number_unsigned case here.
|
// code from the value_t::number_unsigned case here.
|
||||||
if (j.m_value.number_integer <= 0x17)
|
if (j.m_data.m_value.number_integer <= 0x17)
|
||||||
{
|
{
|
||||||
write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
|
write_number(static_cast<std::uint8_t>(j.m_data.m_value.number_integer));
|
||||||
}
|
}
|
||||||
else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
|
else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
|
||||||
{
|
{
|
||||||
oa->write_character(to_char_type(0x18));
|
oa->write_character(to_char_type(0x18));
|
||||||
write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
|
write_number(static_cast<std::uint8_t>(j.m_data.m_value.number_integer));
|
||||||
}
|
}
|
||||||
else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
|
else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
|
||||||
{
|
{
|
||||||
oa->write_character(to_char_type(0x19));
|
oa->write_character(to_char_type(0x19));
|
||||||
write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
|
write_number(static_cast<std::uint16_t>(j.m_data.m_value.number_integer));
|
||||||
}
|
}
|
||||||
else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
|
else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
|
||||||
{
|
{
|
||||||
oa->write_character(to_char_type(0x1A));
|
oa->write_character(to_char_type(0x1A));
|
||||||
write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
|
write_number(static_cast<std::uint32_t>(j.m_data.m_value.number_integer));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
oa->write_character(to_char_type(0x1B));
|
oa->write_character(to_char_type(0x1B));
|
||||||
write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
|
write_number(static_cast<std::uint64_t>(j.m_data.m_value.number_integer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// The conversions below encode the sign in the first
|
// The conversions below encode the sign in the first
|
||||||
// byte, and the value is converted to a positive number.
|
// byte, and the value is converted to a positive number.
|
||||||
const auto positive_number = -1 - j.m_value.number_integer;
|
const auto positive_number = -1 - j.m_data.m_value.number_integer;
|
||||||
if (j.m_value.number_integer >= -24)
|
if (j.m_data.m_value.number_integer >= -24)
|
||||||
{
|
{
|
||||||
write_number(static_cast<std::uint8_t>(0x20 + positive_number));
|
write_number(static_cast<std::uint8_t>(0x20 + positive_number));
|
||||||
}
|
}
|
||||||
@ -171,52 +178,52 @@ class binary_writer
|
|||||||
|
|
||||||
case value_t::number_unsigned:
|
case value_t::number_unsigned:
|
||||||
{
|
{
|
||||||
if (j.m_value.number_unsigned <= 0x17)
|
if (j.m_data.m_value.number_unsigned <= 0x17)
|
||||||
{
|
{
|
||||||
write_number(static_cast<std::uint8_t>(j.m_value.number_unsigned));
|
write_number(static_cast<std::uint8_t>(j.m_data.m_value.number_unsigned));
|
||||||
}
|
}
|
||||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
|
else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
|
||||||
{
|
{
|
||||||
oa->write_character(to_char_type(0x18));
|
oa->write_character(to_char_type(0x18));
|
||||||
write_number(static_cast<std::uint8_t>(j.m_value.number_unsigned));
|
write_number(static_cast<std::uint8_t>(j.m_data.m_value.number_unsigned));
|
||||||
}
|
}
|
||||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
|
else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
|
||||||
{
|
{
|
||||||
oa->write_character(to_char_type(0x19));
|
oa->write_character(to_char_type(0x19));
|
||||||
write_number(static_cast<std::uint16_t>(j.m_value.number_unsigned));
|
write_number(static_cast<std::uint16_t>(j.m_data.m_value.number_unsigned));
|
||||||
}
|
}
|
||||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
|
else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
|
||||||
{
|
{
|
||||||
oa->write_character(to_char_type(0x1A));
|
oa->write_character(to_char_type(0x1A));
|
||||||
write_number(static_cast<std::uint32_t>(j.m_value.number_unsigned));
|
write_number(static_cast<std::uint32_t>(j.m_data.m_value.number_unsigned));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
oa->write_character(to_char_type(0x1B));
|
oa->write_character(to_char_type(0x1B));
|
||||||
write_number(static_cast<std::uint64_t>(j.m_value.number_unsigned));
|
write_number(static_cast<std::uint64_t>(j.m_data.m_value.number_unsigned));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case value_t::number_float:
|
case value_t::number_float:
|
||||||
{
|
{
|
||||||
if (std::isnan(j.m_value.number_float))
|
if (std::isnan(j.m_data.m_value.number_float))
|
||||||
{
|
{
|
||||||
// NaN is 0xf97e00 in CBOR
|
// NaN is 0xf97e00 in CBOR
|
||||||
oa->write_character(to_char_type(0xF9));
|
oa->write_character(to_char_type(0xF9));
|
||||||
oa->write_character(to_char_type(0x7E));
|
oa->write_character(to_char_type(0x7E));
|
||||||
oa->write_character(to_char_type(0x00));
|
oa->write_character(to_char_type(0x00));
|
||||||
}
|
}
|
||||||
else if (std::isinf(j.m_value.number_float))
|
else if (std::isinf(j.m_data.m_value.number_float))
|
||||||
{
|
{
|
||||||
// Infinity is 0xf97c00, -Infinity is 0xf9fc00
|
// Infinity is 0xf97c00, -Infinity is 0xf9fc00
|
||||||
oa->write_character(to_char_type(0xf9));
|
oa->write_character(to_char_type(0xf9));
|
||||||
oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
|
oa->write_character(j.m_data.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
|
||||||
oa->write_character(to_char_type(0x00));
|
oa->write_character(to_char_type(0x00));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
write_compact_float(j.m_value.number_float, detail::input_format_t::cbor);
|
write_compact_float(j.m_data.m_value.number_float, detail::input_format_t::cbor);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -224,7 +231,7 @@ class binary_writer
|
|||||||
case value_t::string:
|
case value_t::string:
|
||||||
{
|
{
|
||||||
// step 1: write control byte and the string length
|
// step 1: write control byte and the string length
|
||||||
const auto N = j.m_value.string->size();
|
const auto N = j.m_data.m_value.string->size();
|
||||||
if (N <= 0x17)
|
if (N <= 0x17)
|
||||||
{
|
{
|
||||||
write_number(static_cast<std::uint8_t>(0x60 + N));
|
write_number(static_cast<std::uint8_t>(0x60 + N));
|
||||||
@ -254,15 +261,15 @@ class binary_writer
|
|||||||
|
|
||||||
// step 2: write the string
|
// step 2: write the string
|
||||||
oa->write_characters(
|
oa->write_characters(
|
||||||
reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
|
reinterpret_cast<const CharType*>(j.m_data.m_value.string->c_str()),
|
||||||
j.m_value.string->size());
|
j.m_data.m_value.string->size());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case value_t::array:
|
case value_t::array:
|
||||||
{
|
{
|
||||||
// step 1: write control byte and the array size
|
// step 1: write control byte and the array size
|
||||||
const auto N = j.m_value.array->size();
|
const auto N = j.m_data.m_value.array->size();
|
||||||
if (N <= 0x17)
|
if (N <= 0x17)
|
||||||
{
|
{
|
||||||
write_number(static_cast<std::uint8_t>(0x80 + N));
|
write_number(static_cast<std::uint8_t>(0x80 + N));
|
||||||
@ -291,7 +298,7 @@ class binary_writer
|
|||||||
// LCOV_EXCL_STOP
|
// LCOV_EXCL_STOP
|
||||||
|
|
||||||
// step 2: write each element
|
// step 2: write each element
|
||||||
for (const auto& el : *j.m_value.array)
|
for (const auto& el : *j.m_data.m_value.array)
|
||||||
{
|
{
|
||||||
write_cbor(el);
|
write_cbor(el);
|
||||||
}
|
}
|
||||||
@ -300,32 +307,32 @@ class binary_writer
|
|||||||
|
|
||||||
case value_t::binary:
|
case value_t::binary:
|
||||||
{
|
{
|
||||||
if (j.m_value.binary->has_subtype())
|
if (j.m_data.m_value.binary->has_subtype())
|
||||||
{
|
{
|
||||||
if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
|
if (j.m_data.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>(0xd8));
|
||||||
write_number(static_cast<std::uint8_t>(j.m_value.binary->subtype()));
|
write_number(static_cast<std::uint8_t>(j.m_data.m_value.binary->subtype()));
|
||||||
}
|
}
|
||||||
else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
|
else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
|
||||||
{
|
{
|
||||||
write_number(static_cast<std::uint8_t>(0xd9));
|
write_number(static_cast<std::uint8_t>(0xd9));
|
||||||
write_number(static_cast<std::uint16_t>(j.m_value.binary->subtype()));
|
write_number(static_cast<std::uint16_t>(j.m_data.m_value.binary->subtype()));
|
||||||
}
|
}
|
||||||
else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
|
else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
|
||||||
{
|
{
|
||||||
write_number(static_cast<std::uint8_t>(0xda));
|
write_number(static_cast<std::uint8_t>(0xda));
|
||||||
write_number(static_cast<std::uint32_t>(j.m_value.binary->subtype()));
|
write_number(static_cast<std::uint32_t>(j.m_data.m_value.binary->subtype()));
|
||||||
}
|
}
|
||||||
else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
|
else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
|
||||||
{
|
{
|
||||||
write_number(static_cast<std::uint8_t>(0xdb));
|
write_number(static_cast<std::uint8_t>(0xdb));
|
||||||
write_number(static_cast<std::uint64_t>(j.m_value.binary->subtype()));
|
write_number(static_cast<std::uint64_t>(j.m_data.m_value.binary->subtype()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// step 1: write control byte and the binary array size
|
// step 1: write control byte and the binary array size
|
||||||
const auto N = j.m_value.binary->size();
|
const auto N = j.m_data.m_value.binary->size();
|
||||||
if (N <= 0x17)
|
if (N <= 0x17)
|
||||||
{
|
{
|
||||||
write_number(static_cast<std::uint8_t>(0x40 + N));
|
write_number(static_cast<std::uint8_t>(0x40 + N));
|
||||||
@ -355,7 +362,7 @@ class binary_writer
|
|||||||
|
|
||||||
// step 2: write each element
|
// step 2: write each element
|
||||||
oa->write_characters(
|
oa->write_characters(
|
||||||
reinterpret_cast<const CharType*>(j.m_value.binary->data()),
|
reinterpret_cast<const CharType*>(j.m_data.m_value.binary->data()),
|
||||||
N);
|
N);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -364,7 +371,7 @@ class binary_writer
|
|||||||
case value_t::object:
|
case value_t::object:
|
||||||
{
|
{
|
||||||
// step 1: write control byte and the object size
|
// step 1: write control byte and the object size
|
||||||
const auto N = j.m_value.object->size();
|
const auto N = j.m_data.m_value.object->size();
|
||||||
if (N <= 0x17)
|
if (N <= 0x17)
|
||||||
{
|
{
|
||||||
write_number(static_cast<std::uint8_t>(0xA0 + N));
|
write_number(static_cast<std::uint8_t>(0xA0 + N));
|
||||||
@ -393,7 +400,7 @@ class binary_writer
|
|||||||
// LCOV_EXCL_STOP
|
// LCOV_EXCL_STOP
|
||||||
|
|
||||||
// step 2: write each element
|
// step 2: write each element
|
||||||
for (const auto& el : *j.m_value.object)
|
for (const auto& el : *j.m_data.m_value.object)
|
||||||
{
|
{
|
||||||
write_cbor(el.first);
|
write_cbor(el.first);
|
||||||
write_cbor(el.second);
|
write_cbor(el.second);
|
||||||
@ -422,7 +429,7 @@ class binary_writer
|
|||||||
|
|
||||||
case value_t::boolean: // true and false
|
case value_t::boolean: // true and false
|
||||||
{
|
{
|
||||||
oa->write_character(j.m_value.boolean
|
oa->write_character(j.m_data.m_value.boolean
|
||||||
? to_char_type(0xC3)
|
? to_char_type(0xC3)
|
||||||
: to_char_type(0xC2));
|
: to_char_type(0xC2));
|
||||||
break;
|
break;
|
||||||
@ -430,75 +437,75 @@ class binary_writer
|
|||||||
|
|
||||||
case value_t::number_integer:
|
case value_t::number_integer:
|
||||||
{
|
{
|
||||||
if (j.m_value.number_integer >= 0)
|
if (j.m_data.m_value.number_integer >= 0)
|
||||||
{
|
{
|
||||||
// MessagePack does not differentiate between positive
|
// MessagePack does not differentiate between positive
|
||||||
// signed integers and unsigned integers. Therefore, we used
|
// signed integers and unsigned integers. Therefore, we used
|
||||||
// the code from the value_t::number_unsigned case here.
|
// the code from the value_t::number_unsigned case here.
|
||||||
if (j.m_value.number_unsigned < 128)
|
if (j.m_data.m_value.number_unsigned < 128)
|
||||||
{
|
{
|
||||||
// positive fixnum
|
// positive fixnum
|
||||||
write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
|
write_number(static_cast<std::uint8_t>(j.m_data.m_value.number_integer));
|
||||||
}
|
}
|
||||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
|
else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
|
||||||
{
|
{
|
||||||
// uint 8
|
// uint 8
|
||||||
oa->write_character(to_char_type(0xCC));
|
oa->write_character(to_char_type(0xCC));
|
||||||
write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
|
write_number(static_cast<std::uint8_t>(j.m_data.m_value.number_integer));
|
||||||
}
|
}
|
||||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
|
else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
|
||||||
{
|
{
|
||||||
// uint 16
|
// uint 16
|
||||||
oa->write_character(to_char_type(0xCD));
|
oa->write_character(to_char_type(0xCD));
|
||||||
write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
|
write_number(static_cast<std::uint16_t>(j.m_data.m_value.number_integer));
|
||||||
}
|
}
|
||||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
|
else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
|
||||||
{
|
{
|
||||||
// uint 32
|
// uint 32
|
||||||
oa->write_character(to_char_type(0xCE));
|
oa->write_character(to_char_type(0xCE));
|
||||||
write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
|
write_number(static_cast<std::uint32_t>(j.m_data.m_value.number_integer));
|
||||||
}
|
}
|
||||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
|
else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
|
||||||
{
|
{
|
||||||
// uint 64
|
// uint 64
|
||||||
oa->write_character(to_char_type(0xCF));
|
oa->write_character(to_char_type(0xCF));
|
||||||
write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
|
write_number(static_cast<std::uint64_t>(j.m_data.m_value.number_integer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (j.m_value.number_integer >= -32)
|
if (j.m_data.m_value.number_integer >= -32)
|
||||||
{
|
{
|
||||||
// negative fixnum
|
// negative fixnum
|
||||||
write_number(static_cast<std::int8_t>(j.m_value.number_integer));
|
write_number(static_cast<std::int8_t>(j.m_data.m_value.number_integer));
|
||||||
}
|
}
|
||||||
else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
|
else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
|
||||||
j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
|
j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
|
||||||
{
|
{
|
||||||
// int 8
|
// int 8
|
||||||
oa->write_character(to_char_type(0xD0));
|
oa->write_character(to_char_type(0xD0));
|
||||||
write_number(static_cast<std::int8_t>(j.m_value.number_integer));
|
write_number(static_cast<std::int8_t>(j.m_data.m_value.number_integer));
|
||||||
}
|
}
|
||||||
else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
|
else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
|
||||||
j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
|
j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
|
||||||
{
|
{
|
||||||
// int 16
|
// int 16
|
||||||
oa->write_character(to_char_type(0xD1));
|
oa->write_character(to_char_type(0xD1));
|
||||||
write_number(static_cast<std::int16_t>(j.m_value.number_integer));
|
write_number(static_cast<std::int16_t>(j.m_data.m_value.number_integer));
|
||||||
}
|
}
|
||||||
else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
|
else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
|
||||||
j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
|
j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
|
||||||
{
|
{
|
||||||
// int 32
|
// int 32
|
||||||
oa->write_character(to_char_type(0xD2));
|
oa->write_character(to_char_type(0xD2));
|
||||||
write_number(static_cast<std::int32_t>(j.m_value.number_integer));
|
write_number(static_cast<std::int32_t>(j.m_data.m_value.number_integer));
|
||||||
}
|
}
|
||||||
else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
|
else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
|
||||||
j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
|
j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
|
||||||
{
|
{
|
||||||
// int 64
|
// int 64
|
||||||
oa->write_character(to_char_type(0xD3));
|
oa->write_character(to_char_type(0xD3));
|
||||||
write_number(static_cast<std::int64_t>(j.m_value.number_integer));
|
write_number(static_cast<std::int64_t>(j.m_data.m_value.number_integer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -506,48 +513,48 @@ class binary_writer
|
|||||||
|
|
||||||
case value_t::number_unsigned:
|
case value_t::number_unsigned:
|
||||||
{
|
{
|
||||||
if (j.m_value.number_unsigned < 128)
|
if (j.m_data.m_value.number_unsigned < 128)
|
||||||
{
|
{
|
||||||
// positive fixnum
|
// positive fixnum
|
||||||
write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
|
write_number(static_cast<std::uint8_t>(j.m_data.m_value.number_integer));
|
||||||
}
|
}
|
||||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
|
else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
|
||||||
{
|
{
|
||||||
// uint 8
|
// uint 8
|
||||||
oa->write_character(to_char_type(0xCC));
|
oa->write_character(to_char_type(0xCC));
|
||||||
write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
|
write_number(static_cast<std::uint8_t>(j.m_data.m_value.number_integer));
|
||||||
}
|
}
|
||||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
|
else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
|
||||||
{
|
{
|
||||||
// uint 16
|
// uint 16
|
||||||
oa->write_character(to_char_type(0xCD));
|
oa->write_character(to_char_type(0xCD));
|
||||||
write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
|
write_number(static_cast<std::uint16_t>(j.m_data.m_value.number_integer));
|
||||||
}
|
}
|
||||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
|
else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
|
||||||
{
|
{
|
||||||
// uint 32
|
// uint 32
|
||||||
oa->write_character(to_char_type(0xCE));
|
oa->write_character(to_char_type(0xCE));
|
||||||
write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
|
write_number(static_cast<std::uint32_t>(j.m_data.m_value.number_integer));
|
||||||
}
|
}
|
||||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
|
else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
|
||||||
{
|
{
|
||||||
// uint 64
|
// uint 64
|
||||||
oa->write_character(to_char_type(0xCF));
|
oa->write_character(to_char_type(0xCF));
|
||||||
write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
|
write_number(static_cast<std::uint64_t>(j.m_data.m_value.number_integer));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case value_t::number_float:
|
case value_t::number_float:
|
||||||
{
|
{
|
||||||
write_compact_float(j.m_value.number_float, detail::input_format_t::msgpack);
|
write_compact_float(j.m_data.m_value.number_float, detail::input_format_t::msgpack);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case value_t::string:
|
case value_t::string:
|
||||||
{
|
{
|
||||||
// step 1: write control byte and the string length
|
// step 1: write control byte and the string length
|
||||||
const auto N = j.m_value.string->size();
|
const auto N = j.m_data.m_value.string->size();
|
||||||
if (N <= 31)
|
if (N <= 31)
|
||||||
{
|
{
|
||||||
// fixstr
|
// fixstr
|
||||||
@ -574,15 +581,15 @@ class binary_writer
|
|||||||
|
|
||||||
// step 2: write the string
|
// step 2: write the string
|
||||||
oa->write_characters(
|
oa->write_characters(
|
||||||
reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
|
reinterpret_cast<const CharType*>(j.m_data.m_value.string->c_str()),
|
||||||
j.m_value.string->size());
|
j.m_data.m_value.string->size());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case value_t::array:
|
case value_t::array:
|
||||||
{
|
{
|
||||||
// step 1: write control byte and the array size
|
// step 1: write control byte and the array size
|
||||||
const auto N = j.m_value.array->size();
|
const auto N = j.m_data.m_value.array->size();
|
||||||
if (N <= 15)
|
if (N <= 15)
|
||||||
{
|
{
|
||||||
// fixarray
|
// fixarray
|
||||||
@ -602,7 +609,7 @@ class binary_writer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// step 2: write each element
|
// step 2: write each element
|
||||||
for (const auto& el : *j.m_value.array)
|
for (const auto& el : *j.m_data.m_value.array)
|
||||||
{
|
{
|
||||||
write_msgpack(el);
|
write_msgpack(el);
|
||||||
}
|
}
|
||||||
@ -612,11 +619,11 @@ class binary_writer
|
|||||||
case value_t::binary:
|
case value_t::binary:
|
||||||
{
|
{
|
||||||
// step 0: determine if the binary type has a set subtype to
|
// step 0: determine if the binary type has a set subtype to
|
||||||
// determine whether or not to use the ext or fixext types
|
// determine whether to use the ext or fixext types
|
||||||
const bool use_ext = j.m_value.binary->has_subtype();
|
const bool use_ext = j.m_data.m_value.binary->has_subtype();
|
||||||
|
|
||||||
// step 1: write control byte and the byte string length
|
// step 1: write control byte and the byte string length
|
||||||
const auto N = j.m_value.binary->size();
|
const auto N = j.m_data.m_value.binary->size();
|
||||||
if (N <= (std::numeric_limits<std::uint8_t>::max)())
|
if (N <= (std::numeric_limits<std::uint8_t>::max)())
|
||||||
{
|
{
|
||||||
std::uint8_t output_type{};
|
std::uint8_t output_type{};
|
||||||
@ -661,18 +668,18 @@ class binary_writer
|
|||||||
}
|
}
|
||||||
else if (N <= (std::numeric_limits<std::uint16_t>::max)())
|
else if (N <= (std::numeric_limits<std::uint16_t>::max)())
|
||||||
{
|
{
|
||||||
std::uint8_t output_type = use_ext
|
const std::uint8_t output_type = use_ext
|
||||||
? 0xC8 // ext 16
|
? 0xC8 // ext 16
|
||||||
: 0xC5; // bin 16
|
: 0xC5; // bin 16
|
||||||
|
|
||||||
oa->write_character(to_char_type(output_type));
|
oa->write_character(to_char_type(output_type));
|
||||||
write_number(static_cast<std::uint16_t>(N));
|
write_number(static_cast<std::uint16_t>(N));
|
||||||
}
|
}
|
||||||
else if (N <= (std::numeric_limits<std::uint32_t>::max)())
|
else if (N <= (std::numeric_limits<std::uint32_t>::max)())
|
||||||
{
|
{
|
||||||
std::uint8_t output_type = use_ext
|
const std::uint8_t output_type = use_ext
|
||||||
? 0xC9 // ext 32
|
? 0xC9 // ext 32
|
||||||
: 0xC6; // bin 32
|
: 0xC6; // bin 32
|
||||||
|
|
||||||
oa->write_character(to_char_type(output_type));
|
oa->write_character(to_char_type(output_type));
|
||||||
write_number(static_cast<std::uint32_t>(N));
|
write_number(static_cast<std::uint32_t>(N));
|
||||||
@ -681,12 +688,12 @@ class binary_writer
|
|||||||
// step 1.5: if this is an ext type, write the subtype
|
// step 1.5: if this is an ext type, write the subtype
|
||||||
if (use_ext)
|
if (use_ext)
|
||||||
{
|
{
|
||||||
write_number(static_cast<std::int8_t>(j.m_value.binary->subtype()));
|
write_number(static_cast<std::int8_t>(j.m_data.m_value.binary->subtype()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// step 2: write the byte string
|
// step 2: write the byte string
|
||||||
oa->write_characters(
|
oa->write_characters(
|
||||||
reinterpret_cast<const CharType*>(j.m_value.binary->data()),
|
reinterpret_cast<const CharType*>(j.m_data.m_value.binary->data()),
|
||||||
N);
|
N);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -695,7 +702,7 @@ class binary_writer
|
|||||||
case value_t::object:
|
case value_t::object:
|
||||||
{
|
{
|
||||||
// step 1: write control byte and the object size
|
// step 1: write control byte and the object size
|
||||||
const auto N = j.m_value.object->size();
|
const auto N = j.m_data.m_value.object->size();
|
||||||
if (N <= 15)
|
if (N <= 15)
|
||||||
{
|
{
|
||||||
// fixmap
|
// fixmap
|
||||||
@ -715,7 +722,7 @@ class binary_writer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// step 2: write each element
|
// step 2: write each element
|
||||||
for (const auto& el : *j.m_value.object)
|
for (const auto& el : *j.m_data.m_value.object)
|
||||||
{
|
{
|
||||||
write_msgpack(el.first);
|
write_msgpack(el.first);
|
||||||
write_msgpack(el.second);
|
write_msgpack(el.second);
|
||||||
@ -735,11 +742,14 @@ class binary_writer
|
|||||||
@param[in] use_type 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] add_prefix whether prefixes need to be used for this value
|
||||||
@param[in] use_bjdata whether write in BJData format, default is false
|
@param[in] use_bjdata whether write in BJData format, default is false
|
||||||
|
@param[in] bjdata_version which BJData version to use, default is draft2
|
||||||
*/
|
*/
|
||||||
void write_ubjson(const BasicJsonType& j, const bool use_count,
|
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)
|
const bool use_bjdata = false, const bjdata_version_t bjdata_version = bjdata_version_t::draft2)
|
||||||
{
|
{
|
||||||
|
const bool bjdata_draft3 = use_bjdata && bjdata_version == bjdata_version_t::draft3;
|
||||||
|
|
||||||
switch (j.type())
|
switch (j.type())
|
||||||
{
|
{
|
||||||
case value_t::null:
|
case value_t::null:
|
||||||
@ -755,7 +765,7 @@ class binary_writer
|
|||||||
{
|
{
|
||||||
if (add_prefix)
|
if (add_prefix)
|
||||||
{
|
{
|
||||||
oa->write_character(j.m_value.boolean
|
oa->write_character(j.m_data.m_value.boolean
|
||||||
? to_char_type('T')
|
? to_char_type('T')
|
||||||
: to_char_type('F'));
|
: to_char_type('F'));
|
||||||
}
|
}
|
||||||
@ -764,19 +774,19 @@ class binary_writer
|
|||||||
|
|
||||||
case value_t::number_integer:
|
case value_t::number_integer:
|
||||||
{
|
{
|
||||||
write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix, use_bjdata);
|
write_number_with_ubjson_prefix(j.m_data.m_value.number_integer, add_prefix, use_bjdata);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case value_t::number_unsigned:
|
case value_t::number_unsigned:
|
||||||
{
|
{
|
||||||
write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix, use_bjdata);
|
write_number_with_ubjson_prefix(j.m_data.m_value.number_unsigned, add_prefix, use_bjdata);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case value_t::number_float:
|
case value_t::number_float:
|
||||||
{
|
{
|
||||||
write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix, use_bjdata);
|
write_number_with_ubjson_prefix(j.m_data.m_value.number_float, add_prefix, use_bjdata);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -786,10 +796,10 @@ class binary_writer
|
|||||||
{
|
{
|
||||||
oa->write_character(to_char_type('S'));
|
oa->write_character(to_char_type('S'));
|
||||||
}
|
}
|
||||||
write_number_with_ubjson_prefix(j.m_value.string->size(), true, use_bjdata);
|
write_number_with_ubjson_prefix(j.m_data.m_value.string->size(), true, use_bjdata);
|
||||||
oa->write_characters(
|
oa->write_characters(
|
||||||
reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
|
reinterpret_cast<const CharType*>(j.m_data.m_value.string->c_str()),
|
||||||
j.m_value.string->size());
|
j.m_data.m_value.string->size());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -801,7 +811,7 @@ class binary_writer
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool prefix_required = true;
|
bool prefix_required = true;
|
||||||
if (use_type && !j.m_value.array->empty())
|
if (use_type && !j.m_data.m_value.array->empty())
|
||||||
{
|
{
|
||||||
JSON_ASSERT(use_count);
|
JSON_ASSERT(use_count);
|
||||||
const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
|
const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
|
||||||
@ -824,12 +834,12 @@ class binary_writer
|
|||||||
if (use_count)
|
if (use_count)
|
||||||
{
|
{
|
||||||
oa->write_character(to_char_type('#'));
|
oa->write_character(to_char_type('#'));
|
||||||
write_number_with_ubjson_prefix(j.m_value.array->size(), true, use_bjdata);
|
write_number_with_ubjson_prefix(j.m_data.m_value.array->size(), true, use_bjdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& el : *j.m_value.array)
|
for (const auto& el : *j.m_data.m_value.array)
|
||||||
{
|
{
|
||||||
write_ubjson(el, use_count, use_type, prefix_required, use_bjdata);
|
write_ubjson(el, use_count, use_type, prefix_required, use_bjdata, bjdata_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!use_count)
|
if (!use_count)
|
||||||
@ -847,31 +857,31 @@ class binary_writer
|
|||||||
oa->write_character(to_char_type('['));
|
oa->write_character(to_char_type('['));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_type && !j.m_value.binary->empty())
|
if (use_type && (bjdata_draft3 || !j.m_data.m_value.binary->empty()))
|
||||||
{
|
{
|
||||||
JSON_ASSERT(use_count);
|
JSON_ASSERT(use_count);
|
||||||
oa->write_character(to_char_type('$'));
|
oa->write_character(to_char_type('$'));
|
||||||
oa->write_character('U');
|
oa->write_character(bjdata_draft3 ? 'B' : 'U');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_count)
|
if (use_count)
|
||||||
{
|
{
|
||||||
oa->write_character(to_char_type('#'));
|
oa->write_character(to_char_type('#'));
|
||||||
write_number_with_ubjson_prefix(j.m_value.binary->size(), true, use_bjdata);
|
write_number_with_ubjson_prefix(j.m_data.m_value.binary->size(), true, use_bjdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_type)
|
if (use_type)
|
||||||
{
|
{
|
||||||
oa->write_characters(
|
oa->write_characters(
|
||||||
reinterpret_cast<const CharType*>(j.m_value.binary->data()),
|
reinterpret_cast<const CharType*>(j.m_data.m_value.binary->data()),
|
||||||
j.m_value.binary->size());
|
j.m_data.m_value.binary->size());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < j.m_value.binary->size(); ++i)
|
for (size_t i = 0; i < j.m_data.m_value.binary->size(); ++i)
|
||||||
{
|
{
|
||||||
oa->write_character(to_char_type('U'));
|
oa->write_character(to_char_type(bjdata_draft3 ? 'B' : 'U'));
|
||||||
oa->write_character(j.m_value.binary->data()[i]);
|
oa->write_character(j.m_data.m_value.binary->data()[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -885,9 +895,9 @@ class binary_writer
|
|||||||
|
|
||||||
case value_t::object:
|
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 (use_bjdata && j.m_data.m_value.object->size() == 3 && j.m_data.m_value.object->find("_ArrayType_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find("_ArraySize_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find("_ArrayData_") != j.m_data.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)
|
if (!write_bjdata_ndarray(*j.m_data.m_value.object, use_count, use_type, bjdata_version)) // decode bjdata ndarray in the JData format (https://github.com/NeuroJSON/jdata)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -899,7 +909,7 @@ class binary_writer
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool prefix_required = true;
|
bool prefix_required = true;
|
||||||
if (use_type && !j.m_value.object->empty())
|
if (use_type && !j.m_data.m_value.object->empty())
|
||||||
{
|
{
|
||||||
JSON_ASSERT(use_count);
|
JSON_ASSERT(use_count);
|
||||||
const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
|
const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
|
||||||
@ -922,16 +932,16 @@ class binary_writer
|
|||||||
if (use_count)
|
if (use_count)
|
||||||
{
|
{
|
||||||
oa->write_character(to_char_type('#'));
|
oa->write_character(to_char_type('#'));
|
||||||
write_number_with_ubjson_prefix(j.m_value.object->size(), true, use_bjdata);
|
write_number_with_ubjson_prefix(j.m_data.m_value.object->size(), true, use_bjdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& el : *j.m_value.object)
|
for (const auto& el : *j.m_data.m_value.object)
|
||||||
{
|
{
|
||||||
write_number_with_ubjson_prefix(el.first.size(), true, use_bjdata);
|
write_number_with_ubjson_prefix(el.first.size(), true, use_bjdata);
|
||||||
oa->write_characters(
|
oa->write_characters(
|
||||||
reinterpret_cast<const CharType*>(el.first.c_str()),
|
reinterpret_cast<const CharType*>(el.first.c_str()),
|
||||||
el.first.size());
|
el.first.size());
|
||||||
write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata);
|
write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata, bjdata_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!use_count)
|
if (!use_count)
|
||||||
@ -1075,19 +1085,20 @@ class binary_writer
|
|||||||
void write_bson_unsigned(const string_t& name,
|
void write_bson_unsigned(const string_t& name,
|
||||||
const BasicJsonType& j)
|
const BasicJsonType& j)
|
||||||
{
|
{
|
||||||
if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
|
if (j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
|
||||||
{
|
{
|
||||||
write_bson_entry_header(name, 0x10 /* int32 */);
|
write_bson_entry_header(name, 0x10 /* int32 */);
|
||||||
write_number<std::int32_t>(static_cast<std::int32_t>(j.m_value.number_unsigned), true);
|
write_number<std::int32_t>(static_cast<std::int32_t>(j.m_data.m_value.number_unsigned), true);
|
||||||
}
|
}
|
||||||
else if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
|
else if (j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
|
||||||
{
|
{
|
||||||
write_bson_entry_header(name, 0x12 /* int64 */);
|
write_bson_entry_header(name, 0x12 /* int64 */);
|
||||||
write_number<std::int64_t>(static_cast<std::int64_t>(j.m_value.number_unsigned), true);
|
write_number<std::int64_t>(static_cast<std::int64_t>(j.m_data.m_value.number_unsigned), true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
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));
|
write_bson_entry_header(name, 0x11 /* uint64 */);
|
||||||
|
write_number<std::uint64_t>(static_cast<std::uint64_t>(j.m_data.m_value.number_unsigned), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1168,13 +1179,13 @@ class binary_writer
|
|||||||
switch (j.type())
|
switch (j.type())
|
||||||
{
|
{
|
||||||
case value_t::object:
|
case value_t::object:
|
||||||
return header_size + calc_bson_object_size(*j.m_value.object);
|
return header_size + calc_bson_object_size(*j.m_data.m_value.object);
|
||||||
|
|
||||||
case value_t::array:
|
case value_t::array:
|
||||||
return header_size + calc_bson_array_size(*j.m_value.array);
|
return header_size + calc_bson_array_size(*j.m_data.m_value.array);
|
||||||
|
|
||||||
case value_t::binary:
|
case value_t::binary:
|
||||||
return header_size + calc_bson_binary_size(*j.m_value.binary);
|
return header_size + calc_bson_binary_size(*j.m_data.m_value.binary);
|
||||||
|
|
||||||
case value_t::boolean:
|
case value_t::boolean:
|
||||||
return header_size + 1ul;
|
return header_size + 1ul;
|
||||||
@ -1183,13 +1194,13 @@ class binary_writer
|
|||||||
return header_size + 8ul;
|
return header_size + 8ul;
|
||||||
|
|
||||||
case value_t::number_integer:
|
case value_t::number_integer:
|
||||||
return header_size + calc_bson_integer_size(j.m_value.number_integer);
|
return header_size + calc_bson_integer_size(j.m_data.m_value.number_integer);
|
||||||
|
|
||||||
case value_t::number_unsigned:
|
case value_t::number_unsigned:
|
||||||
return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned);
|
return header_size + calc_bson_unsigned_size(j.m_data.m_value.number_unsigned);
|
||||||
|
|
||||||
case value_t::string:
|
case value_t::string:
|
||||||
return header_size + calc_bson_string_size(*j.m_value.string);
|
return header_size + calc_bson_string_size(*j.m_data.m_value.string);
|
||||||
|
|
||||||
case value_t::null:
|
case value_t::null:
|
||||||
return header_size + 0ul;
|
return header_size + 0ul;
|
||||||
@ -1215,28 +1226,28 @@ class binary_writer
|
|||||||
switch (j.type())
|
switch (j.type())
|
||||||
{
|
{
|
||||||
case value_t::object:
|
case value_t::object:
|
||||||
return write_bson_object_entry(name, *j.m_value.object);
|
return write_bson_object_entry(name, *j.m_data.m_value.object);
|
||||||
|
|
||||||
case value_t::array:
|
case value_t::array:
|
||||||
return write_bson_array(name, *j.m_value.array);
|
return write_bson_array(name, *j.m_data.m_value.array);
|
||||||
|
|
||||||
case value_t::binary:
|
case value_t::binary:
|
||||||
return write_bson_binary(name, *j.m_value.binary);
|
return write_bson_binary(name, *j.m_data.m_value.binary);
|
||||||
|
|
||||||
case value_t::boolean:
|
case value_t::boolean:
|
||||||
return write_bson_boolean(name, j.m_value.boolean);
|
return write_bson_boolean(name, j.m_data.m_value.boolean);
|
||||||
|
|
||||||
case value_t::number_float:
|
case value_t::number_float:
|
||||||
return write_bson_double(name, j.m_value.number_float);
|
return write_bson_double(name, j.m_data.m_value.number_float);
|
||||||
|
|
||||||
case value_t::number_integer:
|
case value_t::number_integer:
|
||||||
return write_bson_integer(name, j.m_value.number_integer);
|
return write_bson_integer(name, j.m_data.m_value.number_integer);
|
||||||
|
|
||||||
case value_t::number_unsigned:
|
case value_t::number_unsigned:
|
||||||
return write_bson_unsigned(name, j);
|
return write_bson_unsigned(name, j);
|
||||||
|
|
||||||
case value_t::string:
|
case value_t::string:
|
||||||
return write_bson_string(name, *j.m_value.string);
|
return write_bson_string(name, *j.m_data.m_value.string);
|
||||||
|
|
||||||
case value_t::null:
|
case value_t::null:
|
||||||
return write_bson_null(name);
|
return write_bson_null(name);
|
||||||
@ -1258,8 +1269,8 @@ class binary_writer
|
|||||||
*/
|
*/
|
||||||
static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t& value)
|
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(), static_cast<std::size_t>(0),
|
const 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)
|
[](size_t result, const typename BasicJsonType::object_t::value_type & el)
|
||||||
{
|
{
|
||||||
return result += calc_bson_element_size(el.first, el.second);
|
return result += calc_bson_element_size(el.first, el.second);
|
||||||
});
|
});
|
||||||
@ -1509,35 +1520,35 @@ class binary_writer
|
|||||||
return 'Z';
|
return 'Z';
|
||||||
|
|
||||||
case value_t::boolean:
|
case value_t::boolean:
|
||||||
return j.m_value.boolean ? 'T' : 'F';
|
return j.m_data.m_value.boolean ? 'T' : 'F';
|
||||||
|
|
||||||
case value_t::number_integer:
|
case value_t::number_integer:
|
||||||
{
|
{
|
||||||
if ((std::numeric_limits<std::int8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
|
if ((std::numeric_limits<std::int8_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
|
||||||
{
|
{
|
||||||
return 'i';
|
return 'i';
|
||||||
}
|
}
|
||||||
if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
|
if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
|
||||||
{
|
{
|
||||||
return 'U';
|
return 'U';
|
||||||
}
|
}
|
||||||
if ((std::numeric_limits<std::int16_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
|
if ((std::numeric_limits<std::int16_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
|
||||||
{
|
{
|
||||||
return 'I';
|
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)()))
|
if (use_bjdata && ((std::numeric_limits<std::uint16_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)()))
|
||||||
{
|
{
|
||||||
return 'u';
|
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)())
|
if ((std::numeric_limits<std::int32_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
|
||||||
{
|
{
|
||||||
return 'l';
|
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)()))
|
if (use_bjdata && ((std::numeric_limits<std::uint32_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)()))
|
||||||
{
|
{
|
||||||
return 'm';
|
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)())
|
if ((std::numeric_limits<std::int64_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
|
||||||
{
|
{
|
||||||
return 'L';
|
return 'L';
|
||||||
}
|
}
|
||||||
@ -1547,35 +1558,35 @@ class binary_writer
|
|||||||
|
|
||||||
case value_t::number_unsigned:
|
case value_t::number_unsigned:
|
||||||
{
|
{
|
||||||
if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)()))
|
if (j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)()))
|
||||||
{
|
{
|
||||||
return 'i';
|
return 'i';
|
||||||
}
|
}
|
||||||
if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::uint8_t>::max)()))
|
if (j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::uint8_t>::max)()))
|
||||||
{
|
{
|
||||||
return 'U';
|
return 'U';
|
||||||
}
|
}
|
||||||
if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)()))
|
if (j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)()))
|
||||||
{
|
{
|
||||||
return 'I';
|
return 'I';
|
||||||
}
|
}
|
||||||
if (use_bjdata && j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::uint16_t>::max)()))
|
if (use_bjdata && j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::uint16_t>::max)()))
|
||||||
{
|
{
|
||||||
return 'u';
|
return 'u';
|
||||||
}
|
}
|
||||||
if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
|
if (j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
|
||||||
{
|
{
|
||||||
return 'l';
|
return 'l';
|
||||||
}
|
}
|
||||||
if (use_bjdata && j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::uint32_t>::max)()))
|
if (use_bjdata && j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::uint32_t>::max)()))
|
||||||
{
|
{
|
||||||
return 'm';
|
return 'm';
|
||||||
}
|
}
|
||||||
if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
|
if (j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
|
||||||
{
|
{
|
||||||
return 'L';
|
return 'L';
|
||||||
}
|
}
|
||||||
if (use_bjdata && j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
|
if (use_bjdata && j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
|
||||||
{
|
{
|
||||||
return 'M';
|
return 'M';
|
||||||
}
|
}
|
||||||
@ -1584,7 +1595,7 @@ class binary_writer
|
|||||||
}
|
}
|
||||||
|
|
||||||
case value_t::number_float:
|
case value_t::number_float:
|
||||||
return get_ubjson_float_prefix(j.m_value.number_float);
|
return get_ubjson_float_prefix(j.m_data.m_value.number_float);
|
||||||
|
|
||||||
case value_t::string:
|
case value_t::string:
|
||||||
return 'S';
|
return 'S';
|
||||||
@ -1615,10 +1626,11 @@ class binary_writer
|
|||||||
/*!
|
/*!
|
||||||
@return false if the object is successfully converted to a bjdata ndarray, true if the type or size is invalid
|
@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)
|
bool write_bjdata_ndarray(const typename BasicJsonType::object_t& value, const bool use_count, const bool use_type, const bjdata_version_t bjdata_version)
|
||||||
{
|
{
|
||||||
std::map<string_t, CharType> bjdtype = {{"uint8", 'U'}, {"int8", 'i'}, {"uint16", 'u'}, {"int16", 'I'},
|
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'}
|
{"uint32", 'm'}, {"int32", 'l'}, {"uint64", 'M'}, {"int64", 'L'}, {"single", 'd'}, {"double", 'D'},
|
||||||
|
{"char", 'C'}, {"byte", 'B'}
|
||||||
};
|
};
|
||||||
|
|
||||||
string_t key = "_ArrayType_";
|
string_t key = "_ArrayType_";
|
||||||
@ -1633,7 +1645,7 @@ class binary_writer
|
|||||||
std::size_t len = (value.at(key).empty() ? 0 : 1);
|
std::size_t len = (value.at(key).empty() ? 0 : 1);
|
||||||
for (const auto& el : value.at(key))
|
for (const auto& el : value.at(key))
|
||||||
{
|
{
|
||||||
len *= static_cast<std::size_t>(el.m_value.number_unsigned);
|
len *= static_cast<std::size_t>(el.m_data.m_value.number_unsigned);
|
||||||
}
|
}
|
||||||
|
|
||||||
key = "_ArrayData_";
|
key = "_ArrayData_";
|
||||||
@ -1648,77 +1660,77 @@ class binary_writer
|
|||||||
oa->write_character('#');
|
oa->write_character('#');
|
||||||
|
|
||||||
key = "_ArraySize_";
|
key = "_ArraySize_";
|
||||||
write_ubjson(value.at(key), use_count, use_type, true, true);
|
write_ubjson(value.at(key), use_count, use_type, true, true, bjdata_version);
|
||||||
|
|
||||||
key = "_ArrayData_";
|
key = "_ArrayData_";
|
||||||
if (dtype == 'U' || dtype == 'C')
|
if (dtype == 'U' || dtype == 'C' || dtype == 'B')
|
||||||
{
|
{
|
||||||
for (const auto& el : value.at(key))
|
for (const auto& el : value.at(key))
|
||||||
{
|
{
|
||||||
write_number(static_cast<std::uint8_t>(el.m_value.number_unsigned), true);
|
write_number(static_cast<std::uint8_t>(el.m_data.m_value.number_unsigned), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dtype == 'i')
|
else if (dtype == 'i')
|
||||||
{
|
{
|
||||||
for (const auto& el : value.at(key))
|
for (const auto& el : value.at(key))
|
||||||
{
|
{
|
||||||
write_number(static_cast<std::int8_t>(el.m_value.number_integer), true);
|
write_number(static_cast<std::int8_t>(el.m_data.m_value.number_integer), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dtype == 'u')
|
else if (dtype == 'u')
|
||||||
{
|
{
|
||||||
for (const auto& el : value.at(key))
|
for (const auto& el : value.at(key))
|
||||||
{
|
{
|
||||||
write_number(static_cast<std::uint16_t>(el.m_value.number_unsigned), true);
|
write_number(static_cast<std::uint16_t>(el.m_data.m_value.number_unsigned), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dtype == 'I')
|
else if (dtype == 'I')
|
||||||
{
|
{
|
||||||
for (const auto& el : value.at(key))
|
for (const auto& el : value.at(key))
|
||||||
{
|
{
|
||||||
write_number(static_cast<std::int16_t>(el.m_value.number_integer), true);
|
write_number(static_cast<std::int16_t>(el.m_data.m_value.number_integer), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dtype == 'm')
|
else if (dtype == 'm')
|
||||||
{
|
{
|
||||||
for (const auto& el : value.at(key))
|
for (const auto& el : value.at(key))
|
||||||
{
|
{
|
||||||
write_number(static_cast<std::uint32_t>(el.m_value.number_unsigned), true);
|
write_number(static_cast<std::uint32_t>(el.m_data.m_value.number_unsigned), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dtype == 'l')
|
else if (dtype == 'l')
|
||||||
{
|
{
|
||||||
for (const auto& el : value.at(key))
|
for (const auto& el : value.at(key))
|
||||||
{
|
{
|
||||||
write_number(static_cast<std::int32_t>(el.m_value.number_integer), true);
|
write_number(static_cast<std::int32_t>(el.m_data.m_value.number_integer), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dtype == 'M')
|
else if (dtype == 'M')
|
||||||
{
|
{
|
||||||
for (const auto& el : value.at(key))
|
for (const auto& el : value.at(key))
|
||||||
{
|
{
|
||||||
write_number(static_cast<std::uint64_t>(el.m_value.number_unsigned), true);
|
write_number(static_cast<std::uint64_t>(el.m_data.m_value.number_unsigned), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dtype == 'L')
|
else if (dtype == 'L')
|
||||||
{
|
{
|
||||||
for (const auto& el : value.at(key))
|
for (const auto& el : value.at(key))
|
||||||
{
|
{
|
||||||
write_number(static_cast<std::int64_t>(el.m_value.number_integer), true);
|
write_number(static_cast<std::int64_t>(el.m_data.m_value.number_integer), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dtype == 'd')
|
else if (dtype == 'd')
|
||||||
{
|
{
|
||||||
for (const auto& el : value.at(key))
|
for (const auto& el : value.at(key))
|
||||||
{
|
{
|
||||||
write_number(static_cast<float>(el.m_value.number_float), true);
|
write_number(static_cast<float>(el.m_data.m_value.number_float), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dtype == 'D')
|
else if (dtype == 'D')
|
||||||
{
|
{
|
||||||
for (const auto& el : value.at(key))
|
for (const auto& el : value.at(key))
|
||||||
{
|
{
|
||||||
write_number(static_cast<double>(el.m_value.number_float), true);
|
write_number(static_cast<double>(el.m_data.m_value.number_float), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2008-2009 Björn Hoehrmann <bjoern@hoehrmann.de>
|
// SPDX-FileCopyrightText: 2008 - 2009 Björn Hoehrmann <bjoern@hoehrmann.de>
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -110,11 +110,11 @@ class serializer
|
|||||||
const unsigned int indent_step,
|
const unsigned int indent_step,
|
||||||
const unsigned int current_indent = 0)
|
const unsigned int current_indent = 0)
|
||||||
{
|
{
|
||||||
switch (val.m_type)
|
switch (val.m_data.m_type)
|
||||||
{
|
{
|
||||||
case value_t::object:
|
case value_t::object:
|
||||||
{
|
{
|
||||||
if (val.m_value.object->empty())
|
if (val.m_data.m_value.object->empty())
|
||||||
{
|
{
|
||||||
o->write_characters("{}", 2);
|
o->write_characters("{}", 2);
|
||||||
return;
|
return;
|
||||||
@ -132,8 +132,8 @@ class serializer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// first n-1 elements
|
// first n-1 elements
|
||||||
auto i = val.m_value.object->cbegin();
|
auto i = val.m_data.m_value.object->cbegin();
|
||||||
for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
|
for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
|
||||||
{
|
{
|
||||||
o->write_characters(indent_string.c_str(), new_indent);
|
o->write_characters(indent_string.c_str(), new_indent);
|
||||||
o->write_character('\"');
|
o->write_character('\"');
|
||||||
@ -144,8 +144,8 @@ class serializer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// last element
|
// last element
|
||||||
JSON_ASSERT(i != val.m_value.object->cend());
|
JSON_ASSERT(i != val.m_data.m_value.object->cend());
|
||||||
JSON_ASSERT(std::next(i) == val.m_value.object->cend());
|
JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
|
||||||
o->write_characters(indent_string.c_str(), new_indent);
|
o->write_characters(indent_string.c_str(), new_indent);
|
||||||
o->write_character('\"');
|
o->write_character('\"');
|
||||||
dump_escaped(i->first, ensure_ascii);
|
dump_escaped(i->first, ensure_ascii);
|
||||||
@ -161,8 +161,8 @@ class serializer
|
|||||||
o->write_character('{');
|
o->write_character('{');
|
||||||
|
|
||||||
// first n-1 elements
|
// first n-1 elements
|
||||||
auto i = val.m_value.object->cbegin();
|
auto i = val.m_data.m_value.object->cbegin();
|
||||||
for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
|
for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
|
||||||
{
|
{
|
||||||
o->write_character('\"');
|
o->write_character('\"');
|
||||||
dump_escaped(i->first, ensure_ascii);
|
dump_escaped(i->first, ensure_ascii);
|
||||||
@ -172,8 +172,8 @@ class serializer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// last element
|
// last element
|
||||||
JSON_ASSERT(i != val.m_value.object->cend());
|
JSON_ASSERT(i != val.m_data.m_value.object->cend());
|
||||||
JSON_ASSERT(std::next(i) == val.m_value.object->cend());
|
JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
|
||||||
o->write_character('\"');
|
o->write_character('\"');
|
||||||
dump_escaped(i->first, ensure_ascii);
|
dump_escaped(i->first, ensure_ascii);
|
||||||
o->write_characters("\":", 2);
|
o->write_characters("\":", 2);
|
||||||
@ -187,7 +187,7 @@ class serializer
|
|||||||
|
|
||||||
case value_t::array:
|
case value_t::array:
|
||||||
{
|
{
|
||||||
if (val.m_value.array->empty())
|
if (val.m_data.m_value.array->empty())
|
||||||
{
|
{
|
||||||
o->write_characters("[]", 2);
|
o->write_characters("[]", 2);
|
||||||
return;
|
return;
|
||||||
@ -205,8 +205,8 @@ class serializer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// first n-1 elements
|
// first n-1 elements
|
||||||
for (auto i = val.m_value.array->cbegin();
|
for (auto i = val.m_data.m_value.array->cbegin();
|
||||||
i != val.m_value.array->cend() - 1; ++i)
|
i != val.m_data.m_value.array->cend() - 1; ++i)
|
||||||
{
|
{
|
||||||
o->write_characters(indent_string.c_str(), new_indent);
|
o->write_characters(indent_string.c_str(), new_indent);
|
||||||
dump(*i, true, ensure_ascii, indent_step, new_indent);
|
dump(*i, true, ensure_ascii, indent_step, new_indent);
|
||||||
@ -214,9 +214,9 @@ class serializer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// last element
|
// last element
|
||||||
JSON_ASSERT(!val.m_value.array->empty());
|
JSON_ASSERT(!val.m_data.m_value.array->empty());
|
||||||
o->write_characters(indent_string.c_str(), new_indent);
|
o->write_characters(indent_string.c_str(), new_indent);
|
||||||
dump(val.m_value.array->back(), true, ensure_ascii, indent_step, new_indent);
|
dump(val.m_data.m_value.array->back(), true, ensure_ascii, indent_step, new_indent);
|
||||||
|
|
||||||
o->write_character('\n');
|
o->write_character('\n');
|
||||||
o->write_characters(indent_string.c_str(), current_indent);
|
o->write_characters(indent_string.c_str(), current_indent);
|
||||||
@ -227,16 +227,16 @@ class serializer
|
|||||||
o->write_character('[');
|
o->write_character('[');
|
||||||
|
|
||||||
// first n-1 elements
|
// first n-1 elements
|
||||||
for (auto i = val.m_value.array->cbegin();
|
for (auto i = val.m_data.m_value.array->cbegin();
|
||||||
i != val.m_value.array->cend() - 1; ++i)
|
i != val.m_data.m_value.array->cend() - 1; ++i)
|
||||||
{
|
{
|
||||||
dump(*i, false, ensure_ascii, indent_step, current_indent);
|
dump(*i, false, ensure_ascii, indent_step, current_indent);
|
||||||
o->write_character(',');
|
o->write_character(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
// last element
|
// last element
|
||||||
JSON_ASSERT(!val.m_value.array->empty());
|
JSON_ASSERT(!val.m_data.m_value.array->empty());
|
||||||
dump(val.m_value.array->back(), false, ensure_ascii, indent_step, current_indent);
|
dump(val.m_data.m_value.array->back(), false, ensure_ascii, indent_step, current_indent);
|
||||||
|
|
||||||
o->write_character(']');
|
o->write_character(']');
|
||||||
}
|
}
|
||||||
@ -247,7 +247,7 @@ class serializer
|
|||||||
case value_t::string:
|
case value_t::string:
|
||||||
{
|
{
|
||||||
o->write_character('\"');
|
o->write_character('\"');
|
||||||
dump_escaped(*val.m_value.string, ensure_ascii);
|
dump_escaped(*val.m_data.m_value.string, ensure_ascii);
|
||||||
o->write_character('\"');
|
o->write_character('\"');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -269,24 +269,24 @@ class serializer
|
|||||||
|
|
||||||
o->write_characters("\"bytes\": [", 10);
|
o->write_characters("\"bytes\": [", 10);
|
||||||
|
|
||||||
if (!val.m_value.binary->empty())
|
if (!val.m_data.m_value.binary->empty())
|
||||||
{
|
{
|
||||||
for (auto i = val.m_value.binary->cbegin();
|
for (auto i = val.m_data.m_value.binary->cbegin();
|
||||||
i != val.m_value.binary->cend() - 1; ++i)
|
i != val.m_data.m_value.binary->cend() - 1; ++i)
|
||||||
{
|
{
|
||||||
dump_integer(*i);
|
dump_integer(*i);
|
||||||
o->write_characters(", ", 2);
|
o->write_characters(", ", 2);
|
||||||
}
|
}
|
||||||
dump_integer(val.m_value.binary->back());
|
dump_integer(val.m_data.m_value.binary->back());
|
||||||
}
|
}
|
||||||
|
|
||||||
o->write_characters("],\n", 3);
|
o->write_characters("],\n", 3);
|
||||||
o->write_characters(indent_string.c_str(), new_indent);
|
o->write_characters(indent_string.c_str(), new_indent);
|
||||||
|
|
||||||
o->write_characters("\"subtype\": ", 11);
|
o->write_characters("\"subtype\": ", 11);
|
||||||
if (val.m_value.binary->has_subtype())
|
if (val.m_data.m_value.binary->has_subtype())
|
||||||
{
|
{
|
||||||
dump_integer(val.m_value.binary->subtype());
|
dump_integer(val.m_data.m_value.binary->subtype());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -300,21 +300,21 @@ class serializer
|
|||||||
{
|
{
|
||||||
o->write_characters("{\"bytes\":[", 10);
|
o->write_characters("{\"bytes\":[", 10);
|
||||||
|
|
||||||
if (!val.m_value.binary->empty())
|
if (!val.m_data.m_value.binary->empty())
|
||||||
{
|
{
|
||||||
for (auto i = val.m_value.binary->cbegin();
|
for (auto i = val.m_data.m_value.binary->cbegin();
|
||||||
i != val.m_value.binary->cend() - 1; ++i)
|
i != val.m_data.m_value.binary->cend() - 1; ++i)
|
||||||
{
|
{
|
||||||
dump_integer(*i);
|
dump_integer(*i);
|
||||||
o->write_character(',');
|
o->write_character(',');
|
||||||
}
|
}
|
||||||
dump_integer(val.m_value.binary->back());
|
dump_integer(val.m_data.m_value.binary->back());
|
||||||
}
|
}
|
||||||
|
|
||||||
o->write_characters("],\"subtype\":", 12);
|
o->write_characters("],\"subtype\":", 12);
|
||||||
if (val.m_value.binary->has_subtype())
|
if (val.m_data.m_value.binary->has_subtype())
|
||||||
{
|
{
|
||||||
dump_integer(val.m_value.binary->subtype());
|
dump_integer(val.m_data.m_value.binary->subtype());
|
||||||
o->write_character('}');
|
o->write_character('}');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -327,7 +327,7 @@ class serializer
|
|||||||
|
|
||||||
case value_t::boolean:
|
case value_t::boolean:
|
||||||
{
|
{
|
||||||
if (val.m_value.boolean)
|
if (val.m_data.m_value.boolean)
|
||||||
{
|
{
|
||||||
o->write_characters("true", 4);
|
o->write_characters("true", 4);
|
||||||
}
|
}
|
||||||
@ -340,19 +340,19 @@ class serializer
|
|||||||
|
|
||||||
case value_t::number_integer:
|
case value_t::number_integer:
|
||||||
{
|
{
|
||||||
dump_integer(val.m_value.number_integer);
|
dump_integer(val.m_data.m_value.number_integer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
case value_t::number_unsigned:
|
case value_t::number_unsigned:
|
||||||
{
|
{
|
||||||
dump_integer(val.m_value.number_unsigned);
|
dump_integer(val.m_data.m_value.number_unsigned);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
case value_t::number_float:
|
case value_t::number_float:
|
||||||
{
|
{
|
||||||
dump_float(val.m_value.number_float);
|
dump_float(val.m_data.m_value.number_float);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -643,7 +643,7 @@ class serializer
|
|||||||
@param[in] x unsigned integer number to count its digits
|
@param[in] x unsigned integer number to count its digits
|
||||||
@return number of decimal digits
|
@return number of decimal digits
|
||||||
*/
|
*/
|
||||||
inline unsigned int count_digits(number_unsigned_t x) noexcept
|
unsigned int count_digits(number_unsigned_t x) noexcept
|
||||||
{
|
{
|
||||||
unsigned int n_digits = 1;
|
unsigned int n_digits = 1;
|
||||||
for (;;)
|
for (;;)
|
||||||
@ -926,8 +926,8 @@ class serializer
|
|||||||
? (byte & 0x3fu) | (codep << 6u)
|
? (byte & 0x3fu) | (codep << 6u)
|
||||||
: (0xFFu >> type) & (byte);
|
: (0xFFu >> type) & (byte);
|
||||||
|
|
||||||
std::size_t index = 256u + static_cast<size_t>(state) * 16u + static_cast<size_t>(type);
|
const std::size_t index = 256u + (static_cast<size_t>(state) * 16u) + static_cast<size_t>(type);
|
||||||
JSON_ASSERT(index < 400);
|
JSON_ASSERT(index < utf8d.size());
|
||||||
state = utf8d[index];
|
state = utf8d[index];
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@ -952,7 +952,7 @@ class serializer
|
|||||||
* absolute values of INT_MIN and INT_MAX are usually not the same. See
|
* absolute values of INT_MIN and INT_MAX are usually not the same. See
|
||||||
* #1708 for details.
|
* #1708 for details.
|
||||||
*/
|
*/
|
||||||
inline number_unsigned_t remove_sign(number_integer_t x) noexcept
|
number_unsigned_t remove_sign(number_integer_t x) noexcept
|
||||||
{
|
{
|
||||||
JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)()); // NOLINT(misc-redundant-expression)
|
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;
|
return static_cast<number_unsigned_t>(-(x + 1)) + 1;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -25,28 +25,28 @@ inline std::size_t concat_length()
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
inline std::size_t concat_length(const char* cstr, Args&& ... rest);
|
inline std::size_t concat_length(const char* cstr, const Args& ... rest);
|
||||||
|
|
||||||
template<typename StringType, typename... Args>
|
template<typename StringType, typename... Args>
|
||||||
inline std::size_t concat_length(const StringType& str, Args&& ... rest);
|
inline std::size_t concat_length(const StringType& str, const Args& ... rest);
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
inline std::size_t concat_length(const char /*c*/, Args&& ... rest)
|
inline std::size_t concat_length(const char /*c*/, const Args& ... rest)
|
||||||
{
|
{
|
||||||
return 1 + concat_length(std::forward<Args>(rest)...);
|
return 1 + concat_length(rest...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
inline std::size_t concat_length(const char* cstr, Args&& ... rest)
|
inline std::size_t concat_length(const char* cstr, const Args& ... rest)
|
||||||
{
|
{
|
||||||
// cppcheck-suppress ignoredReturnValue
|
// cppcheck-suppress ignoredReturnValue
|
||||||
return ::strlen(cstr) + concat_length(std::forward<Args>(rest)...);
|
return ::strlen(cstr) + concat_length(rest...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename StringType, typename... Args>
|
template<typename StringType, typename... Args>
|
||||||
inline std::size_t concat_length(const StringType& str, Args&& ... rest)
|
inline std::size_t concat_length(const StringType& str, const Args& ... rest)
|
||||||
{
|
{
|
||||||
return str.size() + concat_length(std::forward<Args>(rest)...);
|
return str.size() + concat_length(rest...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename OutStringType>
|
template<typename OutStringType>
|
||||||
@ -137,7 +137,7 @@ template<typename OutStringType = std::string, typename... Args>
|
|||||||
inline OutStringType concat(Args && ... args)
|
inline OutStringType concat(Args && ... args)
|
||||||
{
|
{
|
||||||
OutStringType str;
|
OutStringType str;
|
||||||
str.reserve(concat_length(std::forward<Args>(args)...));
|
str.reserve(concat_length(args...));
|
||||||
concat_into(str, std::forward<Args>(args)...);
|
concat_into(str, std::forward<Args>(args)...);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
37
external/json/include/nlohmann/detail/string_utils.hpp
vendored
Normal file
37
external/json/include/nlohmann/detail/string_utils.hpp
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// __ _____ _____ _____
|
||||||
|
// __| | __| | | | JSON for Modern C++
|
||||||
|
// | | |__ | | | | | | version 3.12.0
|
||||||
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
|
//
|
||||||
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstddef> // size_t
|
||||||
|
#include <string> // string, to_string
|
||||||
|
|
||||||
|
#include <nlohmann/detail/abi_macros.hpp>
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
template<typename StringType>
|
||||||
|
void int_to_string(StringType& target, std::size_t value)
|
||||||
|
{
|
||||||
|
// For ADL
|
||||||
|
using std::to_string;
|
||||||
|
target = to_string(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename StringType>
|
||||||
|
StringType to_string(std::size_t value)
|
||||||
|
{
|
||||||
|
StringType result;
|
||||||
|
int_to_string(result, value);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
977
external/json/include/nlohmann/json.hpp
vendored
977
external/json/include/nlohmann/json.hpp
vendored
File diff suppressed because it is too large
Load Diff
9
external/json/include/nlohmann/json_fwd.hpp
vendored
9
external/json/include/nlohmann/json_fwd.hpp
vendored
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
|
#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
|
||||||
@ -46,12 +46,13 @@ template<template<typename U, typename V, typename... Args> class ObjectType =
|
|||||||
template<typename U> class AllocatorType = std::allocator,
|
template<typename U> class AllocatorType = std::allocator,
|
||||||
template<typename T, typename SFINAE = void> class JSONSerializer =
|
template<typename T, typename SFINAE = void> class JSONSerializer =
|
||||||
adl_serializer,
|
adl_serializer,
|
||||||
class BinaryType = std::vector<std::uint8_t>>
|
class BinaryType = std::vector<std::uint8_t>, // cppcheck-suppress syntaxError
|
||||||
|
class CustomBaseClass = void>
|
||||||
class basic_json;
|
class basic_json;
|
||||||
|
|
||||||
/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document
|
/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document
|
||||||
/// @sa https://json.nlohmann.me/api/json_pointer/
|
/// @sa https://json.nlohmann.me/api/json_pointer/
|
||||||
template<typename BasicJsonType>
|
template<typename RefStringType>
|
||||||
class json_pointer;
|
class json_pointer;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
18
external/json/include/nlohmann/ordered_map.hpp
vendored
18
external/json/include/nlohmann/ordered_map.hpp
vendored
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -26,7 +26,7 @@ NLOHMANN_JSON_NAMESPACE_BEGIN
|
|||||||
/// for use within nlohmann::basic_json<ordered_map>
|
/// for use within nlohmann::basic_json<ordered_map>
|
||||||
template <class Key, class T, class IgnoredLess = std::less<Key>,
|
template <class Key, class T, class IgnoredLess = std::less<Key>,
|
||||||
class Allocator = std::allocator<std::pair<const Key, T>>>
|
class Allocator = std::allocator<std::pair<const Key, T>>>
|
||||||
struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>
|
struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>
|
||||||
{
|
{
|
||||||
using key_type = Key;
|
using key_type = Key;
|
||||||
using mapped_type = T;
|
using mapped_type = T;
|
||||||
@ -118,7 +118,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
|
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
T & at(KeyType && key)
|
T & at(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
|
||||||
{
|
{
|
||||||
for (auto it = this->begin(); it != this->end(); ++it)
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
{
|
{
|
||||||
@ -146,7 +146,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
|
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
const T & at(KeyType && key) const
|
const T & at(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
|
||||||
{
|
{
|
||||||
for (auto it = this->begin(); it != this->end(); ++it)
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
{
|
{
|
||||||
@ -180,7 +180,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
|
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
size_type erase(KeyType && key)
|
size_type erase(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
|
||||||
{
|
{
|
||||||
for (auto it = this->begin(); it != this->end(); ++it)
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
{
|
{
|
||||||
@ -271,7 +271,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
|
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
size_type count(KeyType && key) const
|
size_type count(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
|
||||||
{
|
{
|
||||||
for (auto it = this->begin(); it != this->end(); ++it)
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
{
|
{
|
||||||
@ -297,7 +297,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
|
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
iterator find(KeyType && key)
|
iterator find(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
|
||||||
{
|
{
|
||||||
for (auto it = this->begin(); it != this->end(); ++it)
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
{
|
{
|
||||||
@ -341,7 +341,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
|
|
||||||
template<typename InputIt>
|
template<typename InputIt>
|
||||||
using require_input_iter = typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
|
using require_input_iter = typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
|
||||||
std::input_iterator_tag>::value>::type;
|
std::input_iterator_tag>::value>::type;
|
||||||
|
|
||||||
template<typename InputIt, typename = require_input_iter<InputIt>>
|
template<typename InputIt, typename = require_input_iter<InputIt>>
|
||||||
void insert(InputIt first, InputIt last)
|
void insert(InputIt first, InputIt last)
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-FileCopyrightText: 2016-2021 Evan Nemerson <evan@nemerson.com>
|
// SPDX-FileCopyrightText: 2016 - 2021 Evan Nemerson <evan@nemerson.com>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
/* Hedley - https://nemequ.github.io/hedley
|
/* Hedley - https://nemequ.github.io/hedley
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
// | | |__ | | | | | | version 3.11.1
|
// | | |__ | | | | | | version 3.12.0
|
||||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
3
external/json/meson.build
vendored
3
external/json/meson.build
vendored
@ -1,6 +1,6 @@
|
|||||||
project('nlohmann_json',
|
project('nlohmann_json',
|
||||||
'cpp',
|
'cpp',
|
||||||
version : '3.11.1',
|
version : '3.11.2',
|
||||||
license : 'MIT',
|
license : 'MIT',
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,6 +14,7 @@ nlohmann_json_multiple_headers = declare_dependency(
|
|||||||
|
|
||||||
if not meson.is_subproject()
|
if not meson.is_subproject()
|
||||||
install_headers('single_include/nlohmann/json.hpp', subdir: 'nlohmann')
|
install_headers('single_include/nlohmann/json.hpp', subdir: 'nlohmann')
|
||||||
|
install_headers('single_include/nlohmann/json_fwd.hpp', subdir: 'nlohmann')
|
||||||
|
|
||||||
pkgc = import('pkgconfig')
|
pkgc = import('pkgconfig')
|
||||||
pkgc.generate(name: 'nlohmann_json',
|
pkgc.generate(name: 'nlohmann_json',
|
||||||
|
278
external/json/nlohmann_json.natvis
vendored
Normal file
278
external/json/nlohmann_json.natvis
vendored
Normal file
@ -0,0 +1,278 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!-- * * * * * * * * AUTO-GENERATED FILE * * * * * * * * -->
|
||||||
|
<!-- Edit ./tools/generate_natvis/nlohmann_json.natvis.j2 -->
|
||||||
|
<!-- * * * * * * * * AUTO-GENERATED FILE * * * * * * * * -->
|
||||||
|
|
||||||
|
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
|
||||||
|
<!-- Namespace nlohmann -->
|
||||||
|
<Type Name="nlohmann::basic_json<*>">
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::detail::value_t::null">null</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::detail::value_t::object">{*(m_data.m_value.object)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::detail::value_t::array">{*(m_data.m_value.array)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::detail::value_t::string">{*(m_data.m_value.string)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::detail::value_t::boolean">{m_data.m_value.boolean}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::detail::value_t::number_integer">{m_data.m_value.number_integer}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::detail::value_t::number_unsigned">{m_data.m_value.number_unsigned}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::detail::value_t::number_float">{m_data.m_value.number_float}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::detail::value_t::discarded">discarded</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<ExpandedItem Condition="m_data.m_type == nlohmann::detail::value_t::object">
|
||||||
|
*(m_data.m_value.object),view(simple)
|
||||||
|
</ExpandedItem>
|
||||||
|
<ExpandedItem Condition="m_data.m_type == nlohmann::detail::value_t::array">
|
||||||
|
*(m_data.m_value.array),view(simple)
|
||||||
|
</ExpandedItem>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
|
||||||
|
<!-- Skip the pair first/second members in the treeview while traversing a map.
|
||||||
|
Only works in VS 2015 Update 2 and beyond using the new visualization -->
|
||||||
|
<Type Name="std::pair<*, nlohmann::basic_json<*>>" IncludeView="MapHelper">
|
||||||
|
<DisplayString>{second}</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<ExpandedItem>second</ExpandedItem>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
|
||||||
|
<!-- Namespace nlohmann::json_abi -->
|
||||||
|
<Type Name="nlohmann::json_abi::basic_json<*>">
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi::detail::value_t::null">null</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi::detail::value_t::object">{*(m_data.m_value.object)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi::detail::value_t::array">{*(m_data.m_value.array)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi::detail::value_t::string">{*(m_data.m_value.string)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi::detail::value_t::boolean">{m_data.m_value.boolean}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi::detail::value_t::number_integer">{m_data.m_value.number_integer}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi::detail::value_t::number_unsigned">{m_data.m_value.number_unsigned}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi::detail::value_t::number_float">{m_data.m_value.number_float}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi::detail::value_t::discarded">discarded</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<ExpandedItem Condition="m_data.m_type == nlohmann::json_abi::detail::value_t::object">
|
||||||
|
*(m_data.m_value.object),view(simple)
|
||||||
|
</ExpandedItem>
|
||||||
|
<ExpandedItem Condition="m_data.m_type == nlohmann::json_abi::detail::value_t::array">
|
||||||
|
*(m_data.m_value.array),view(simple)
|
||||||
|
</ExpandedItem>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
|
||||||
|
<!-- Skip the pair first/second members in the treeview while traversing a map.
|
||||||
|
Only works in VS 2015 Update 2 and beyond using the new visualization -->
|
||||||
|
<Type Name="std::pair<*, nlohmann::json_abi::basic_json<*>>" IncludeView="MapHelper">
|
||||||
|
<DisplayString>{second}</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<ExpandedItem>second</ExpandedItem>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
|
||||||
|
<!-- Namespace nlohmann::json_abi_v3_12_0 -->
|
||||||
|
<Type Name="nlohmann::json_abi_v3_12_0::basic_json<*>">
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_v3_12_0::detail::value_t::null">null</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_v3_12_0::detail::value_t::object">{*(m_data.m_value.object)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_v3_12_0::detail::value_t::array">{*(m_data.m_value.array)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_v3_12_0::detail::value_t::string">{*(m_data.m_value.string)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_v3_12_0::detail::value_t::boolean">{m_data.m_value.boolean}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_v3_12_0::detail::value_t::number_integer">{m_data.m_value.number_integer}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_v3_12_0::detail::value_t::number_unsigned">{m_data.m_value.number_unsigned}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_v3_12_0::detail::value_t::number_float">{m_data.m_value.number_float}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_v3_12_0::detail::value_t::discarded">discarded</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<ExpandedItem Condition="m_data.m_type == nlohmann::json_abi_v3_12_0::detail::value_t::object">
|
||||||
|
*(m_data.m_value.object),view(simple)
|
||||||
|
</ExpandedItem>
|
||||||
|
<ExpandedItem Condition="m_data.m_type == nlohmann::json_abi_v3_12_0::detail::value_t::array">
|
||||||
|
*(m_data.m_value.array),view(simple)
|
||||||
|
</ExpandedItem>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
|
||||||
|
<!-- Skip the pair first/second members in the treeview while traversing a map.
|
||||||
|
Only works in VS 2015 Update 2 and beyond using the new visualization -->
|
||||||
|
<Type Name="std::pair<*, nlohmann::json_abi_v3_12_0::basic_json<*>>" IncludeView="MapHelper">
|
||||||
|
<DisplayString>{second}</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<ExpandedItem>second</ExpandedItem>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
|
||||||
|
<!-- Namespace nlohmann::json_abi_diag -->
|
||||||
|
<Type Name="nlohmann::json_abi_diag::basic_json<*>">
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag::detail::value_t::null">null</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag::detail::value_t::object">{*(m_data.m_value.object)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag::detail::value_t::array">{*(m_data.m_value.array)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag::detail::value_t::string">{*(m_data.m_value.string)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag::detail::value_t::boolean">{m_data.m_value.boolean}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag::detail::value_t::number_integer">{m_data.m_value.number_integer}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag::detail::value_t::number_unsigned">{m_data.m_value.number_unsigned}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag::detail::value_t::number_float">{m_data.m_value.number_float}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag::detail::value_t::discarded">discarded</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<ExpandedItem Condition="m_data.m_type == nlohmann::json_abi_diag::detail::value_t::object">
|
||||||
|
*(m_data.m_value.object),view(simple)
|
||||||
|
</ExpandedItem>
|
||||||
|
<ExpandedItem Condition="m_data.m_type == nlohmann::json_abi_diag::detail::value_t::array">
|
||||||
|
*(m_data.m_value.array),view(simple)
|
||||||
|
</ExpandedItem>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
|
||||||
|
<!-- Skip the pair first/second members in the treeview while traversing a map.
|
||||||
|
Only works in VS 2015 Update 2 and beyond using the new visualization -->
|
||||||
|
<Type Name="std::pair<*, nlohmann::json_abi_diag::basic_json<*>>" IncludeView="MapHelper">
|
||||||
|
<DisplayString>{second}</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<ExpandedItem>second</ExpandedItem>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
|
||||||
|
<!-- Namespace nlohmann::json_abi_diag_v3_12_0 -->
|
||||||
|
<Type Name="nlohmann::json_abi_diag_v3_12_0::basic_json<*>">
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_v3_12_0::detail::value_t::null">null</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_v3_12_0::detail::value_t::object">{*(m_data.m_value.object)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_v3_12_0::detail::value_t::array">{*(m_data.m_value.array)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_v3_12_0::detail::value_t::string">{*(m_data.m_value.string)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_v3_12_0::detail::value_t::boolean">{m_data.m_value.boolean}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_v3_12_0::detail::value_t::number_integer">{m_data.m_value.number_integer}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_v3_12_0::detail::value_t::number_unsigned">{m_data.m_value.number_unsigned}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_v3_12_0::detail::value_t::number_float">{m_data.m_value.number_float}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_v3_12_0::detail::value_t::discarded">discarded</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<ExpandedItem Condition="m_data.m_type == nlohmann::json_abi_diag_v3_12_0::detail::value_t::object">
|
||||||
|
*(m_data.m_value.object),view(simple)
|
||||||
|
</ExpandedItem>
|
||||||
|
<ExpandedItem Condition="m_data.m_type == nlohmann::json_abi_diag_v3_12_0::detail::value_t::array">
|
||||||
|
*(m_data.m_value.array),view(simple)
|
||||||
|
</ExpandedItem>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
|
||||||
|
<!-- Skip the pair first/second members in the treeview while traversing a map.
|
||||||
|
Only works in VS 2015 Update 2 and beyond using the new visualization -->
|
||||||
|
<Type Name="std::pair<*, nlohmann::json_abi_diag_v3_12_0::basic_json<*>>" IncludeView="MapHelper">
|
||||||
|
<DisplayString>{second}</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<ExpandedItem>second</ExpandedItem>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
|
||||||
|
<!-- Namespace nlohmann::json_abi_ldvcmp -->
|
||||||
|
<Type Name="nlohmann::json_abi_ldvcmp::basic_json<*>">
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_ldvcmp::detail::value_t::null">null</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_ldvcmp::detail::value_t::object">{*(m_data.m_value.object)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_ldvcmp::detail::value_t::array">{*(m_data.m_value.array)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_ldvcmp::detail::value_t::string">{*(m_data.m_value.string)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_ldvcmp::detail::value_t::boolean">{m_data.m_value.boolean}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_ldvcmp::detail::value_t::number_integer">{m_data.m_value.number_integer}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_ldvcmp::detail::value_t::number_unsigned">{m_data.m_value.number_unsigned}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_ldvcmp::detail::value_t::number_float">{m_data.m_value.number_float}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_ldvcmp::detail::value_t::discarded">discarded</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<ExpandedItem Condition="m_data.m_type == nlohmann::json_abi_ldvcmp::detail::value_t::object">
|
||||||
|
*(m_data.m_value.object),view(simple)
|
||||||
|
</ExpandedItem>
|
||||||
|
<ExpandedItem Condition="m_data.m_type == nlohmann::json_abi_ldvcmp::detail::value_t::array">
|
||||||
|
*(m_data.m_value.array),view(simple)
|
||||||
|
</ExpandedItem>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
|
||||||
|
<!-- Skip the pair first/second members in the treeview while traversing a map.
|
||||||
|
Only works in VS 2015 Update 2 and beyond using the new visualization -->
|
||||||
|
<Type Name="std::pair<*, nlohmann::json_abi_ldvcmp::basic_json<*>>" IncludeView="MapHelper">
|
||||||
|
<DisplayString>{second}</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<ExpandedItem>second</ExpandedItem>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
|
||||||
|
<!-- Namespace nlohmann::json_abi_ldvcmp_v3_12_0 -->
|
||||||
|
<Type Name="nlohmann::json_abi_ldvcmp_v3_12_0::basic_json<*>">
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_ldvcmp_v3_12_0::detail::value_t::null">null</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_ldvcmp_v3_12_0::detail::value_t::object">{*(m_data.m_value.object)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_ldvcmp_v3_12_0::detail::value_t::array">{*(m_data.m_value.array)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_ldvcmp_v3_12_0::detail::value_t::string">{*(m_data.m_value.string)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_ldvcmp_v3_12_0::detail::value_t::boolean">{m_data.m_value.boolean}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_ldvcmp_v3_12_0::detail::value_t::number_integer">{m_data.m_value.number_integer}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_ldvcmp_v3_12_0::detail::value_t::number_unsigned">{m_data.m_value.number_unsigned}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_ldvcmp_v3_12_0::detail::value_t::number_float">{m_data.m_value.number_float}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_ldvcmp_v3_12_0::detail::value_t::discarded">discarded</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<ExpandedItem Condition="m_data.m_type == nlohmann::json_abi_ldvcmp_v3_12_0::detail::value_t::object">
|
||||||
|
*(m_data.m_value.object),view(simple)
|
||||||
|
</ExpandedItem>
|
||||||
|
<ExpandedItem Condition="m_data.m_type == nlohmann::json_abi_ldvcmp_v3_12_0::detail::value_t::array">
|
||||||
|
*(m_data.m_value.array),view(simple)
|
||||||
|
</ExpandedItem>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
|
||||||
|
<!-- Skip the pair first/second members in the treeview while traversing a map.
|
||||||
|
Only works in VS 2015 Update 2 and beyond using the new visualization -->
|
||||||
|
<Type Name="std::pair<*, nlohmann::json_abi_ldvcmp_v3_12_0::basic_json<*>>" IncludeView="MapHelper">
|
||||||
|
<DisplayString>{second}</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<ExpandedItem>second</ExpandedItem>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
|
||||||
|
<!-- Namespace nlohmann::json_abi_diag_ldvcmp -->
|
||||||
|
<Type Name="nlohmann::json_abi_diag_ldvcmp::basic_json<*>">
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp::detail::value_t::null">null</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp::detail::value_t::object">{*(m_data.m_value.object)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp::detail::value_t::array">{*(m_data.m_value.array)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp::detail::value_t::string">{*(m_data.m_value.string)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp::detail::value_t::boolean">{m_data.m_value.boolean}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp::detail::value_t::number_integer">{m_data.m_value.number_integer}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp::detail::value_t::number_unsigned">{m_data.m_value.number_unsigned}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp::detail::value_t::number_float">{m_data.m_value.number_float}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp::detail::value_t::discarded">discarded</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<ExpandedItem Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp::detail::value_t::object">
|
||||||
|
*(m_data.m_value.object),view(simple)
|
||||||
|
</ExpandedItem>
|
||||||
|
<ExpandedItem Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp::detail::value_t::array">
|
||||||
|
*(m_data.m_value.array),view(simple)
|
||||||
|
</ExpandedItem>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
|
||||||
|
<!-- Skip the pair first/second members in the treeview while traversing a map.
|
||||||
|
Only works in VS 2015 Update 2 and beyond using the new visualization -->
|
||||||
|
<Type Name="std::pair<*, nlohmann::json_abi_diag_ldvcmp::basic_json<*>>" IncludeView="MapHelper">
|
||||||
|
<DisplayString>{second}</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<ExpandedItem>second</ExpandedItem>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
|
||||||
|
<!-- Namespace nlohmann::json_abi_diag_ldvcmp_v3_12_0 -->
|
||||||
|
<Type Name="nlohmann::json_abi_diag_ldvcmp_v3_12_0::basic_json<*>">
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp_v3_12_0::detail::value_t::null">null</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp_v3_12_0::detail::value_t::object">{*(m_data.m_value.object)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp_v3_12_0::detail::value_t::array">{*(m_data.m_value.array)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp_v3_12_0::detail::value_t::string">{*(m_data.m_value.string)}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp_v3_12_0::detail::value_t::boolean">{m_data.m_value.boolean}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp_v3_12_0::detail::value_t::number_integer">{m_data.m_value.number_integer}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp_v3_12_0::detail::value_t::number_unsigned">{m_data.m_value.number_unsigned}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp_v3_12_0::detail::value_t::number_float">{m_data.m_value.number_float}</DisplayString>
|
||||||
|
<DisplayString Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp_v3_12_0::detail::value_t::discarded">discarded</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<ExpandedItem Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp_v3_12_0::detail::value_t::object">
|
||||||
|
*(m_data.m_value.object),view(simple)
|
||||||
|
</ExpandedItem>
|
||||||
|
<ExpandedItem Condition="m_data.m_type == nlohmann::json_abi_diag_ldvcmp_v3_12_0::detail::value_t::array">
|
||||||
|
*(m_data.m_value.array),view(simple)
|
||||||
|
</ExpandedItem>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
|
||||||
|
<!-- Skip the pair first/second members in the treeview while traversing a map.
|
||||||
|
Only works in VS 2015 Update 2 and beyond using the new visualization -->
|
||||||
|
<Type Name="std::pair<*, nlohmann::json_abi_diag_ldvcmp_v3_12_0::basic_json<*>>" IncludeView="MapHelper">
|
||||||
|
<DisplayString>{second}</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<ExpandedItem>second</ExpandedItem>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
|
||||||
|
</AutoVisualizer>
|
4782
external/json/single_include/nlohmann/json.hpp
vendored
4782
external/json/single_include/nlohmann/json.hpp
vendored
File diff suppressed because it is too large
Load Diff
187
external/json/single_include/nlohmann/json_fwd.hpp
vendored
Normal file
187
external/json/single_include/nlohmann/json_fwd.hpp
vendored
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
// __ _____ _____ _____
|
||||||
|
// __| | __| | | | JSON for Modern C++
|
||||||
|
// | | |__ | | | | | | version 3.12.0
|
||||||
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
|
//
|
||||||
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
|
||||||
|
#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
|
||||||
|
|
||||||
|
#include <cstdint> // int64_t, uint64_t
|
||||||
|
#include <map> // map
|
||||||
|
#include <memory> // allocator
|
||||||
|
#include <string> // string
|
||||||
|
#include <vector> // vector
|
||||||
|
|
||||||
|
// #include <nlohmann/detail/abi_macros.hpp>
|
||||||
|
// __ _____ _____ _____
|
||||||
|
// __| | __| | | | JSON for Modern C++
|
||||||
|
// | | |__ | | | | | | version 3.12.0
|
||||||
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
|
//
|
||||||
|
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 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 != 12 || NLOHMANN_JSON_VERSION_PATCH != 0
|
||||||
|
#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 12 // NOLINT(modernize-macro-to-enum)
|
||||||
|
#define NLOHMANN_JSON_VERSION_PATCH 0 // NOLINT(modernize-macro-to-enum)
|
||||||
|
|
||||||
|
#ifndef JSON_DIAGNOSTICS
|
||||||
|
#define JSON_DIAGNOSTICS 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef JSON_DIAGNOSTIC_POSITIONS
|
||||||
|
#define JSON_DIAGNOSTIC_POSITIONS 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_DIAGNOSTIC_POSITIONS
|
||||||
|
#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS _dp
|
||||||
|
#else
|
||||||
|
#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
|
||||||
|
#define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
|
||||||
|
#else
|
||||||
|
#define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
|
||||||
|
#define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Construct the namespace ABI tags component
|
||||||
|
#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c) json_abi ## a ## b ## c
|
||||||
|
#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b, c) \
|
||||||
|
NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c)
|
||||||
|
|
||||||
|
#define NLOHMANN_JSON_ABI_TAGS \
|
||||||
|
NLOHMANN_JSON_ABI_TAGS_CONCAT( \
|
||||||
|
NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
|
||||||
|
NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON, \
|
||||||
|
NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS)
|
||||||
|
|
||||||
|
// Construct the namespace version component
|
||||||
|
#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
|
||||||
|
_v ## major ## _ ## minor ## _ ## patch
|
||||||
|
#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
|
||||||
|
NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
|
||||||
|
|
||||||
|
#if NLOHMANN_JSON_NAMESPACE_NO_VERSION
|
||||||
|
#define NLOHMANN_JSON_NAMESPACE_VERSION
|
||||||
|
#else
|
||||||
|
#define NLOHMANN_JSON_NAMESPACE_VERSION \
|
||||||
|
NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
|
||||||
|
NLOHMANN_JSON_VERSION_MINOR, \
|
||||||
|
NLOHMANN_JSON_VERSION_PATCH)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Combine namespace components
|
||||||
|
#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
|
||||||
|
#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
|
||||||
|
NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
|
||||||
|
|
||||||
|
#ifndef NLOHMANN_JSON_NAMESPACE
|
||||||
|
#define NLOHMANN_JSON_NAMESPACE \
|
||||||
|
nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
|
||||||
|
NLOHMANN_JSON_ABI_TAGS, \
|
||||||
|
NLOHMANN_JSON_NAMESPACE_VERSION)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
#define NLOHMANN_JSON_NAMESPACE_BEGIN \
|
||||||
|
namespace nlohmann \
|
||||||
|
{ \
|
||||||
|
inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
|
||||||
|
NLOHMANN_JSON_ABI_TAGS, \
|
||||||
|
NLOHMANN_JSON_NAMESPACE_VERSION) \
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
#define NLOHMANN_JSON_NAMESPACE_END \
|
||||||
|
} /* namespace (inline namespace) NOLINT(readability/namespace) */ \
|
||||||
|
} // namespace nlohmann
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief namespace for Niels Lohmann
|
||||||
|
@see https://github.com/nlohmann
|
||||||
|
@since version 1.0.0
|
||||||
|
*/
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief default JSONSerializer template argument
|
||||||
|
|
||||||
|
This serializer ignores the template arguments and uses ADL
|
||||||
|
([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl))
|
||||||
|
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,
|
||||||
|
class StringType = std::string, class BooleanType = bool,
|
||||||
|
class NumberIntegerType = std::int64_t,
|
||||||
|
class NumberUnsignedType = std::uint64_t,
|
||||||
|
class NumberFloatType = double,
|
||||||
|
template<typename U> class AllocatorType = std::allocator,
|
||||||
|
template<typename T, typename SFINAE = void> class JSONSerializer =
|
||||||
|
adl_serializer,
|
||||||
|
class BinaryType = std::vector<std::uint8_t>, // cppcheck-suppress syntaxError
|
||||||
|
class CustomBaseClass = void>
|
||||||
|
class basic_json;
|
||||||
|
|
||||||
|
/// @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;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@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 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>;
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_
|
237
external/physfs/CMakeLists.txt
vendored
237
external/physfs/CMakeLists.txt
vendored
@ -1,235 +1,6 @@
|
|||||||
# file taken from offical physfs repo and modified
|
cmake_minimum_required(VERSION 3.9...3.16 FATAL_ERROR)
|
||||||
|
|
||||||
|
set(PHYSFS_BUILD_SHARED FALSE CACHE INTERNAL "")
|
||||||
|
set(PHYSFS_BUILD_TEST FALSE CACHE INTERNAL "")
|
||||||
# PhysicsFS; a portable, flexible file i/o abstraction.
|
add_subdirectory("physfs")
|
||||||
#
|
|
||||||
# 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 ...
|
|
||||||
|
|
||||||
|
2
external/physfs/physfs
vendored
2
external/physfs/physfs
vendored
Submodule external/physfs/physfs updated: a0dfe220ff...adfdec6af1
27
external/soloud/CMakeLists.txt
vendored
27
external/soloud/CMakeLists.txt
vendored
@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.9...3.16 FATAL_ERROR)
|
||||||
|
|
||||||
project(soloud CXX)
|
project(soloud CXX)
|
||||||
|
|
||||||
@ -29,6 +29,7 @@ set(CPP_FILES
|
|||||||
soloud/src/backend/alsa/soloud_alsa.cpp
|
soloud/src/backend/alsa/soloud_alsa.cpp
|
||||||
soloud/src/backend/coreaudio/soloud_coreaudio.cpp
|
soloud/src/backend/coreaudio/soloud_coreaudio.cpp
|
||||||
soloud/src/backend/null/soloud_null.cpp
|
soloud/src/backend/null/soloud_null.cpp
|
||||||
|
soloud/src/backend/nosound/soloud_nosound.cpp
|
||||||
#soloud/src/backend/openal/soloud_openal.cpp
|
#soloud/src/backend/openal/soloud_openal.cpp
|
||||||
#soloud/src/backend/openal/soloud_openal_dll.c
|
#soloud/src/backend/openal/soloud_openal_dll.c
|
||||||
soloud/src/backend/opensles/soloud_opensles.cpp
|
soloud/src/backend/opensles/soloud_opensles.cpp
|
||||||
@ -156,32 +157,38 @@ set(HPP_FILES
|
|||||||
add_library(soloud ${CPP_FILES} ${HPP_FILES})
|
add_library(soloud ${CPP_FILES} ${HPP_FILES})
|
||||||
|
|
||||||
target_compile_definitions(soloud PRIVATE WITH_NULL)
|
target_compile_definitions(soloud PRIVATE WITH_NULL)
|
||||||
|
target_compile_definitions(soloud PRIVATE WITH_NOSOUND)
|
||||||
#target_compile_definitions(soloud PRIVATE WITH_SDL2)
|
#target_compile_definitions(soloud PRIVATE WITH_SDL2)
|
||||||
target_compile_definitions(soloud PRIVATE WITH_SDL2_STATIC)
|
target_compile_definitions(soloud PRIVATE WITH_SDL2_STATIC)
|
||||||
|
|
||||||
target_include_directories(soloud SYSTEM PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/soloud/include")
|
target_include_directories(soloud SYSTEM PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/soloud/include")
|
||||||
|
|
||||||
#if not android or emscripten
|
if(EMSCRIPTEN)
|
||||||
if(VCPKG_TARGET_TRIPLET)
|
target_compile_options(soloud PUBLIC -sUSE_SDL=2)
|
||||||
target_link_libraries(soloud SDL2::SDL2 SDL2::SDL2main SDL2::SDL2-static)
|
target_link_libraries(soloud PUBLIC -sUSE_SDL=2)
|
||||||
|
elseif(VCPKG_TARGET_TRIPLET)
|
||||||
|
target_link_libraries(soloud
|
||||||
|
PUBLIC
|
||||||
|
SDL2::SDL2
|
||||||
|
#PRIVATE
|
||||||
|
#SDL2::SDL2main
|
||||||
|
#SDL2::SDL2-static
|
||||||
|
)
|
||||||
else()
|
else()
|
||||||
target_include_directories(soloud PUBLIC "${SDL2_INCLUDE_DIR}")
|
target_include_directories(soloud PUBLIC "${SDL2_INCLUDE_DIR}")
|
||||||
target_link_libraries(soloud ${SDL2_LIBRARY})
|
target_link_libraries(soloud PUBLIC ${SDL2_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#if not android or emscripten
|
||||||
#if android
|
#if android
|
||||||
#target_link_libraries(soloud SDL)
|
#target_link_libraries(soloud SDL)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(EMSCRIPTEN)
|
|
||||||
set_target_properties(soloud PROPERTIES COMPILE_FLAGS "-s USE_SDL=2")
|
|
||||||
set_target_properties(soloud PROPERTIES LINK_FLAGS "-s USE_SDL=2")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: remove
|
# TODO: remove
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
target_link_libraries(soloud
|
target_link_libraries(soloud PUBLIC
|
||||||
-ldl
|
-ldl
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
2
external/soloud/soloud
vendored
2
external/soloud/soloud
vendored
Submodule external/soloud/soloud updated: 4d72336a88...1157475881
2
external/spdlog
vendored
2
external/spdlog
vendored
Submodule external/spdlog updated: 76fb40d954...6fa36017cf
7
external/stb/CMakeLists.txt
vendored
7
external/stb/CMakeLists.txt
vendored
@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.9...3.16 FATAL_ERROR)
|
||||||
|
|
||||||
project(stb CXX)
|
project(stb CXX)
|
||||||
|
|
||||||
@ -11,9 +11,8 @@ target_link_libraries(stb_image stb)
|
|||||||
add_library(stb_image_write "stb/stb_image_write.h" "stb_image_write.cpp")
|
add_library(stb_image_write "stb/stb_image_write.h" "stb_image_write.cpp")
|
||||||
target_link_libraries(stb_image_write stb)
|
target_link_libraries(stb_image_write stb)
|
||||||
|
|
||||||
# lel TODO: add back in when patent expires
|
add_library(stb_perlin "stb/stb_perlin.h" "stb_perlin.cpp")
|
||||||
#add_library(stb_perlin "stb/stb_perlin.h" "stb_perlin.cpp")
|
target_link_libraries(stb_perlin stb)
|
||||||
#target_link_libraries(stb_perlin stb)
|
|
||||||
|
|
||||||
add_library(stb_rect_pack "stb/stb_rect_pack.h" "stb_rect_pack.cpp")
|
add_library(stb_rect_pack "stb/stb_rect_pack.h" "stb_rect_pack.cpp")
|
||||||
target_link_libraries(stb_rect_pack stb)
|
target_link_libraries(stb_rect_pack stb)
|
||||||
|
2
external/stb/stb
vendored
2
external/stb/stb
vendored
Submodule external/stb/stb updated: af1a5bc352...802cd454f2
18
external/tracy/CMakeLists.txt
vendored
18
external/tracy/CMakeLists.txt
vendored
@ -1,15 +1,17 @@
|
|||||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.9...3.16 FATAL_ERROR)
|
||||||
|
|
||||||
if(NOT EMSCRIPTEN)
|
if(NOT EMSCRIPTEN)
|
||||||
add_library(tracy_client
|
add_library(tracy_client
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/tracy/Tracy.hpp"
|
"${CMAKE_CURRENT_LIST_DIR}/tracy/public/tracy/Tracy.hpp"
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/tracy/TracyLua.hpp"
|
"${CMAKE_CURRENT_LIST_DIR}/tracy/public/tracy/TracyLua.hpp"
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/tracy/TracyVulkan.hpp"
|
"${CMAKE_CURRENT_LIST_DIR}/tracy/public/tracy/TracyVulkan.hpp"
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/tracy/TracyOpenGL.hpp"
|
"${CMAKE_CURRENT_LIST_DIR}/tracy/public/tracy/TracyOpenGL.hpp"
|
||||||
|
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/tracy/TracyClient.cpp"
|
"${CMAKE_CURRENT_LIST_DIR}/tracy/public/TracyClient.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
option(TRACY_ENABLE "Enable tracy profiling" OFF)
|
||||||
|
|
||||||
if(TRACY_ENABLE)
|
if(TRACY_ENABLE)
|
||||||
target_compile_definitions(tracy_client PUBLIC TRACY_ENABLE)
|
target_compile_definitions(tracy_client PUBLIC TRACY_ENABLE)
|
||||||
#target_compile_definitions(tracy_client PUBLIC TRACY_NO_SYSTEM_TRACING)
|
#target_compile_definitions(tracy_client PUBLIC TRACY_NO_SYSTEM_TRACING)
|
||||||
@ -18,7 +20,7 @@ if(NOT EMSCRIPTEN)
|
|||||||
|
|
||||||
target_compile_features(tracy_client PUBLIC cxx_std_17)
|
target_compile_features(tracy_client PUBLIC cxx_std_17)
|
||||||
|
|
||||||
target_include_directories(tracy_client PUBLIC "${CMAKE_CURRENT_LIST_DIR}")
|
target_include_directories(tracy_client PUBLIC "${CMAKE_CURRENT_LIST_DIR}/tracy/public")
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
target_link_libraries(tracy_client dl)
|
target_link_libraries(tracy_client dl)
|
||||||
@ -32,7 +34,7 @@ else() # EMSCRIPTEN
|
|||||||
|
|
||||||
target_compile_features(tracy_client INTERFACE cxx_std_17)
|
target_compile_features(tracy_client INTERFACE cxx_std_17)
|
||||||
|
|
||||||
target_include_directories(tracy_client INTERFACE "${CMAKE_CURRENT_LIST_DIR}")
|
target_include_directories(tracy_client INTERFACE "${CMAKE_CURRENT_LIST_DIR}/tracy/public")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
2
external/tracy/tracy
vendored
2
external/tracy/tracy
vendored
Submodule external/tracy/tracy updated: 9ba7171c3d...897aec5b06
@ -1,10 +1,11 @@
|
|||||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.9...3.16 FATAL_ERROR)
|
||||||
|
|
||||||
project(framework)
|
project(framework)
|
||||||
|
|
||||||
add_subdirectory(engine)
|
add_subdirectory(engine)
|
||||||
add_subdirectory(logger)
|
add_subdirectory(logger)
|
||||||
add_subdirectory(resource_manager)
|
add_subdirectory(resource_manager)
|
||||||
|
add_subdirectory(s6zer)
|
||||||
add_subdirectory(common_components)
|
add_subdirectory(common_components)
|
||||||
add_subdirectory(std_utils)
|
add_subdirectory(std_utils)
|
||||||
add_subdirectory(random)
|
add_subdirectory(random)
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.9...3.16 FATAL_ERROR)
|
||||||
|
|
||||||
project(common_components CXX)
|
project(common_components CXX)
|
||||||
|
|
||||||
add_library(common_components INTERFACE)
|
add_library(common_components INTERFACE)
|
||||||
|
|
||||||
|
add_library(MM::common_components ALIAS common_components)
|
||||||
|
|
||||||
target_include_directories(common_components INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
target_include_directories(common_components INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
||||||
|
|
||||||
target_link_libraries(common_components INTERFACE
|
target_link_libraries(common_components INTERFACE
|
||||||
@ -13,8 +15,23 @@ target_link_libraries(common_components INTERFACE
|
|||||||
|
|
||||||
##########################
|
##########################
|
||||||
|
|
||||||
|
add_library(common_components_serialize_s6zer INTERFACE)
|
||||||
|
|
||||||
|
add_library(MM::common_components_serialize_s6zer ALIAS common_components_serialize_s6zer)
|
||||||
|
|
||||||
|
target_include_directories(common_components_serialize_s6zer INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
||||||
|
|
||||||
|
target_link_libraries(common_components_serialize_s6zer INTERFACE
|
||||||
|
common_components
|
||||||
|
s6zer
|
||||||
|
)
|
||||||
|
|
||||||
|
##########################
|
||||||
|
|
||||||
add_library(common_components_serialize_json INTERFACE)
|
add_library(common_components_serialize_json INTERFACE)
|
||||||
|
|
||||||
|
add_library(MM::common_components_serialize_json ALIAS common_components_serialize_json)
|
||||||
|
|
||||||
target_include_directories(common_components_serialize_json INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
target_include_directories(common_components_serialize_json INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
||||||
|
|
||||||
target_link_libraries(common_components_serialize_json INTERFACE
|
target_link_libraries(common_components_serialize_json INTERFACE
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
namespace MM::Components {
|
namespace MM::Components {
|
||||||
struct Name {
|
struct Name {
|
||||||
static const size_t max_str_len = 64;
|
static const size_t max_str_len {64u};
|
||||||
std::string str;
|
std::string str;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ namespace MM::Components {
|
|||||||
|
|
||||||
// used to lift 2D into 3D space. like a z-index in css/svg
|
// used to lift 2D into 3D space. like a z-index in css/svg
|
||||||
struct Position2D_ZOffset {
|
struct Position2D_ZOffset {
|
||||||
float z_offset = 500.f; // default camera allows values to be between 0 and 1000
|
float z_offset {500.f}; // default camera allows values to be between 0 and 1000
|
||||||
};
|
};
|
||||||
|
|
||||||
} // MM::Components
|
} // MM::Components
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
#include "./json_glm.hpp"
|
#include "./json_glm.hpp"
|
||||||
|
|
||||||
namespace MM::Components {
|
namespace MM::Components {
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Color, color)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Color, color)
|
||||||
} // MM::Components
|
} // MM::Components
|
||||||
|
|
||||||
|
@ -9,12 +9,12 @@
|
|||||||
|
|
||||||
namespace glm {
|
namespace glm {
|
||||||
|
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(vec2, x, y)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(vec2, x, y)
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(vec3, x, y, z)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(vec3, x, y, z)
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(vec4, x, y, z, w)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(vec4, x, y, z, w)
|
||||||
|
|
||||||
//NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(mat4x4, [0], 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) {
|
inline void to_json(nlohmann::json& nlohmann_json_j, const mat4x4& nlohmann_json_t) {
|
||||||
// TODO: make 2d array?
|
// TODO: make 2d array?
|
||||||
nlohmann_json_j = nlohmann::json::array_t{};
|
nlohmann_json_j = nlohmann::json::array_t{};
|
||||||
nlohmann_json_j[0] = nlohmann_json_t[0];
|
nlohmann_json_j[0] = nlohmann_json_t[0];
|
||||||
@ -22,7 +22,7 @@ namespace glm {
|
|||||||
nlohmann_json_j[2] = nlohmann_json_t[2];
|
nlohmann_json_j[2] = nlohmann_json_t[2];
|
||||||
nlohmann_json_j[3] = nlohmann_json_t[3];
|
nlohmann_json_j[3] = nlohmann_json_t[3];
|
||||||
}
|
}
|
||||||
inline void from_json(const nlohmann::json& nlohmann_json_j, mat4x4& nlohmann_json_t) {
|
inline void from_json(const nlohmann::json& nlohmann_json_j, mat4x4& nlohmann_json_t) {
|
||||||
if (!nlohmann_json_j.is_array()) {
|
if (!nlohmann_json_j.is_array()) {
|
||||||
//throw nlohmann::json::type_error::create(0, "", nlohmann_json_j);
|
//throw nlohmann::json::type_error::create(0, "", nlohmann_json_j);
|
||||||
assert(false && "expected array");
|
assert(false && "expected array");
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <mm/components/name.hpp>
|
#include <mm/components/name.hpp>
|
||||||
|
|
||||||
namespace MM::Components {
|
namespace MM::Components {
|
||||||
|
// TODO: manual with str len limit
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Name, str)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Name, str)
|
||||||
} // MM::Components
|
} // MM::Components
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
#include "./json_glm.hpp"
|
#include "./json_glm.hpp"
|
||||||
|
|
||||||
namespace MM::Components {
|
namespace MM::Components {
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Position2D, pos)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Position2D, pos)
|
||||||
} // MM::Components
|
} // MM::Components
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
#include "./json_glm.hpp"
|
#include "./json_glm.hpp"
|
||||||
|
|
||||||
namespace MM::Components {
|
namespace MM::Components {
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Position2D_ZOffset, z_offset)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Position2D_ZOffset, z_offset)
|
||||||
} // MM::Components
|
} // MM::Components
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
#include "./json_glm.hpp"
|
#include "./json_glm.hpp"
|
||||||
|
|
||||||
namespace MM::Components {
|
namespace MM::Components {
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Position3D, pos)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Position3D, pos)
|
||||||
} // MM::Components
|
} // MM::Components
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
#include "./json_glm.hpp"
|
#include "./json_glm.hpp"
|
||||||
|
|
||||||
namespace MM::Components {
|
namespace MM::Components {
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Rotation2D, rot)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Rotation2D, rot)
|
||||||
} // MM::Components
|
} // MM::Components
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
#include "./json_glm.hpp"
|
#include "./json_glm.hpp"
|
||||||
|
|
||||||
namespace MM::Components {
|
namespace MM::Components {
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Scale2D, scale)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Scale2D, scale)
|
||||||
} // MM::Components
|
} // MM::Components
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
#include "./json_glm.hpp"
|
#include "./json_glm.hpp"
|
||||||
|
|
||||||
namespace MM::Components {
|
namespace MM::Components {
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Transform4x4, trans)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Transform4x4, trans)
|
||||||
} // MM::Components
|
} // MM::Components
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
#include "./json_glm.hpp"
|
#include "./json_glm.hpp"
|
||||||
|
|
||||||
namespace MM::Components {
|
namespace MM::Components {
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity2DPosition, pos_vel)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Velocity2DPosition, pos_vel)
|
||||||
} // MM::Components
|
} // MM::Components
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
#include "./json_glm.hpp"
|
#include "./json_glm.hpp"
|
||||||
|
|
||||||
namespace MM::Components {
|
namespace MM::Components {
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity2DPositionIntent, intent)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Velocity2DPositionIntent, intent)
|
||||||
} // MM::Components
|
} // MM::Components
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
#include "./json_glm.hpp"
|
#include "./json_glm.hpp"
|
||||||
|
|
||||||
namespace MM::Components {
|
namespace MM::Components {
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity2DRotation, rot_vel)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Velocity2DRotation, rot_vel)
|
||||||
} // MM::Components
|
} // MM::Components
|
||||||
|
|
||||||
|
@ -5,6 +5,6 @@
|
|||||||
#include <mm/components/view_dir2d.hpp>
|
#include <mm/components/view_dir2d.hpp>
|
||||||
|
|
||||||
namespace MM::Components {
|
namespace MM::Components {
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ViewDir2D, dir)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(ViewDir2D, dir)
|
||||||
} // MM::Components
|
} // MM::Components
|
||||||
|
|
||||||
|
@ -5,6 +5,6 @@
|
|||||||
#include <mm/components/view_dir3d.hpp>
|
#include <mm/components/view_dir3d.hpp>
|
||||||
|
|
||||||
namespace MM::Components {
|
namespace MM::Components {
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ViewDir3D, yaw, pitch, roll)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(ViewDir3D, yaw, pitch, roll)
|
||||||
} // MM::Components
|
} // MM::Components
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user