Merge branch 'develop' of https://github.com/nlohmann/json into bon8
Conflicts: docs/examples/to_bon8.cpp docs/examples/to_bon8.output docs/mkdocs/docs/api/basic_json/to_bon8.md include/nlohmann/detail/input/binary_reader.hpp include/nlohmann/detail/input/input_adapters.hpp include/nlohmann/detail/output/binary_writer.hpp single_include/nlohmann/json.hpp test/CMakeLists.txt tests/src/unit-binary_formats.cpp tests/src/unit-bon8.cpp
@ -4,6 +4,7 @@ Checks: '*,
|
||||
-altera-unroll-loops,
|
||||
-android-cloexec-fopen,
|
||||
-bugprone-easily-swappable-parameters,
|
||||
-cert-err58-cpp,
|
||||
-concurrency-mt-unsafe,
|
||||
-cppcoreguidelines-avoid-goto,
|
||||
-cppcoreguidelines-avoid-magic-numbers,
|
||||
|
57
.github/ISSUE_TEMPLATE/Bug_report.md
vendored
@ -1,57 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: 'kind: bug'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Provide a concise summary of the issue in the title above. -->
|
||||
|
||||
#### What is the issue you have?
|
||||
|
||||
<!-- Provide a detailed introduction to the issue itself, and why you consider it to be a bug. -->
|
||||
<!-- If possible, be specific and add stack traces, error messages, etc. Avoid vague terms like "crash" or "doesn't work". -->
|
||||
|
||||
#### Please describe the steps to reproduce the issue.
|
||||
|
||||
<!-- Provide a link to a live example, or an unambiguous set of steps to -->
|
||||
<!-- reproduce this bug. Include code to reproduce, if relevant -->
|
||||
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
#### Can you provide a small but working code example?
|
||||
|
||||
<!-- Please understand that we cannot analyze and debug large code bases. -->
|
||||
|
||||
#### What is the expected behavior?
|
||||
|
||||
<!-- Tell us what should happen -->
|
||||
|
||||
#### And what is the actual behavior instead?
|
||||
|
||||
<!-- Tell us what happens instead. -->
|
||||
|
||||
#### Which compiler and operating system are you using?
|
||||
|
||||
<!-- Include as many relevant details about the environment you experienced the bug in. -->
|
||||
<!-- Make sure you use a supported compiler, see https://github.com/nlohmann/json#supported-compilers. -->
|
||||
|
||||
- Compiler: ___
|
||||
- Operating system: ___
|
||||
|
||||
#### Which version of the library did you use?
|
||||
|
||||
<!-- Please add an `x` to the respective line. -->
|
||||
|
||||
- [ ] latest release version 3.10.4
|
||||
- [ ] other release - please state the version: ___
|
||||
- [ ] the `develop` branch
|
||||
|
||||
#### If you experience a compilation error: can you [compile and run the unit tests](https://github.com/nlohmann/json#execute-unit-tests)?
|
||||
|
||||
- [ ] yes
|
||||
- [ ] no - please copy/paste the error message below
|
93
.github/ISSUE_TEMPLATE/bug.yaml
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
name: Bug Report
|
||||
description: Create a bug report
|
||||
labels:
|
||||
- 'kind: bug'
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: >
|
||||
Thanks for taking the time to fill out this bug report!
|
||||
|
||||
Make sure you give it a short and specific **title** so that the report
|
||||
is searchable and uniquely identifiable.
|
||||
|
||||
Note that this form is for bug reports only. Please
|
||||
[open a discussion](https://github.com/nlohmann/json/discussions/new)
|
||||
for questions, feature requests, or support requests
|
||||
- type: textarea
|
||||
id: summary
|
||||
attributes:
|
||||
label: Description
|
||||
description: >
|
||||
Please provide an abstract description of the issue to the developers,
|
||||
and why you consider it to be a bug. Please include any specific links
|
||||
to the documentation, JSON specification, or code.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: reproduce
|
||||
attributes:
|
||||
label: Reproduction steps
|
||||
description: >
|
||||
How do you trigger the bug? Please walk us through step by step. Be as
|
||||
specific as possible.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: results
|
||||
attributes:
|
||||
label: Expected vs. actual results
|
||||
description: >
|
||||
Please describe what you expected to happen after the steps above and
|
||||
what actually happened.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: code
|
||||
attributes:
|
||||
label: Minimal code example
|
||||
description: >
|
||||
If possible, provide a small and self-contained example that triggers
|
||||
the bug. Please understand that we cannot analyze and debug large code
|
||||
bases. Please do not paste screenshots here.
|
||||
render: Shell
|
||||
- type: textarea
|
||||
id: output
|
||||
attributes:
|
||||
label: Error messages
|
||||
description: >
|
||||
Please provide any kind of error output (compilation errors, exception
|
||||
messages, stack traces, etc.) which can help to diagnose the error.
|
||||
render: Shell
|
||||
- type: input
|
||||
id: compiler
|
||||
attributes:
|
||||
label: Compiler and operating system
|
||||
description: >
|
||||
On which operating systems and compilers have you observed the issue?
|
||||
Include as many relevant details about the environment you experienced
|
||||
the bug in. Make sure you use a
|
||||
[supported compiler](https://github.com/nlohmann/json#supported-compilers).
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: Library version
|
||||
description: >
|
||||
Which version of the library did you use? If it is a released version,
|
||||
please enter the version number (e.g., 3.10.5). Otherwise, please enter
|
||||
the commit hash. If you got the library from another source as the
|
||||
GitHub repository (e.g., via a package manager), please also state
|
||||
this.
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: validation
|
||||
attributes:
|
||||
label: Validation
|
||||
description: >
|
||||
Please check these additional steps:
|
||||
options:
|
||||
- label: The bug also occurs if the latest version from the [`develop`](https://github.com/nlohmann/json/tree/develop) branch is used.
|
||||
- label: I can successfully [compile and run the unit tests](https://github.com/nlohmann/json#execute-unit-tests).
|
2
.drone.yml → .github/external_ci/.drone.yml
vendored
@ -18,5 +18,5 @@ steps:
|
||||
- cd build
|
||||
- ../cmake-3.20.2/bin/cmake .. -DJSON_FastTests=ON
|
||||
- make -j10
|
||||
- cd test
|
||||
- cd tests
|
||||
- ../../cmake-3.20.2/bin/ctest -j10
|
@ -66,15 +66,15 @@ before_build:
|
||||
- cmake . -G "%GENERATOR%" -A "%GENERATOR_PLATFORM%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" -DJSON_BuildTests=On "%CMAKE_OPTIONS%"
|
||||
|
||||
build_script:
|
||||
- cmake --build . --config "%configuration%"
|
||||
- cmake --build . --config "%configuration%" --parallel 2
|
||||
|
||||
test_script:
|
||||
- if "%configuration%"=="Release" ctest -C "%configuration%" -V -j
|
||||
- if "%configuration%"=="Release" ctest -C "%configuration%" --parallel 2 --output-on-failure
|
||||
# On Debug builds, skip test-unicode_all
|
||||
# as it is extremely slow to run and cause
|
||||
# occasional timeouts on AppVeyor.
|
||||
# More info: https://github.com/nlohmann/json/pull/1570
|
||||
- if "%configuration%"=="Debug" ctest --exclude-regex "test-unicode" -C "%configuration%" -V -j
|
||||
- if "%configuration%"=="Debug" ctest --exclude-regex "test-unicode" -C "%configuration%" --parallel 2 --output-on-failure
|
||||
|
||||
# only build PRs and commits to develop branch
|
||||
# (see https://help.appveyor.com/discussions/questions/55079-two-builds-per-commit-to-pull-request)
|
11
.github/workflows/codeql-analysis.yml
vendored
@ -9,6 +9,7 @@ on:
|
||||
pull_request:
|
||||
schedule:
|
||||
- cron: '0 19 * * 1'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
CodeQL-Build:
|
||||
@ -17,10 +18,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
# We must fetch at least the immediate parents so that if this is
|
||||
# a pull request then we can checkout the head.
|
||||
# a pull request then we can check out the head.
|
||||
fetch-depth: 2
|
||||
|
||||
# If this run was triggered by a pull request event, then checkout
|
||||
@ -30,7 +31,7 @@ jobs:
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
uses: github/codeql-action/init@v2
|
||||
# Override language selection by uncommenting this and choosing your languages
|
||||
# with:
|
||||
# languages: go, javascript, csharp, python, cpp, java
|
||||
@ -38,7 +39,7 @@ jobs:
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
@ -52,4 +53,4 @@ jobs:
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
uses: github/codeql-action/analyze@v2
|
||||
|
7
.github/workflows/macos.yml
vendored
@ -7,6 +7,7 @@ on:
|
||||
- master
|
||||
- release/*
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
xcode:
|
||||
@ -18,7 +19,7 @@ jobs:
|
||||
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
|
||||
- name: build
|
||||
@ -35,9 +36,9 @@ jobs:
|
||||
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DCMAKE_CXX_STANDARD=${{ matrix.standard }} -DCMAKE_CXX_STANDARD_REQUIRED=ON
|
||||
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_TestStandards=${{ matrix.standard }}
|
||||
- name: build
|
||||
run: cmake --build build --parallel 10
|
||||
- name: test
|
||||
|
37
.github/workflows/ubuntu.yml
vendored
@ -7,13 +7,14 @@ on:
|
||||
- master
|
||||
- release/*
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
ci_test_clang:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v2.2.0
|
||||
container: ghcr.io/nlohmann/json-ci:v2.3.0
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: build
|
||||
@ -21,9 +22,9 @@ jobs:
|
||||
|
||||
ci_test_gcc:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v2.2.0
|
||||
container: ghcr.io/nlohmann/json-ci:v2.3.0
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: build
|
||||
@ -31,12 +32,12 @@ jobs:
|
||||
|
||||
ci_static_analysis:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v2.2.0
|
||||
container: ghcr.io/nlohmann/json-ci:v2.3.0
|
||||
strategy:
|
||||
matrix:
|
||||
target: [ci_clang_tidy, ci_cppcheck, ci_test_valgrind, ci_test_clang_sanitizer, ci_test_amalgamation, ci_clang_analyze, ci_cpplint, ci_cmake_flags, ci_single_binaries, ci_reproducible_tests, ci_non_git_tests, ci_offline_testdata, ci_infer]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: build
|
||||
@ -44,12 +45,12 @@ jobs:
|
||||
|
||||
ci_cmake_options:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v2.2.0
|
||||
container: ghcr.io/nlohmann/json-ci:v2.3.0
|
||||
strategy:
|
||||
matrix:
|
||||
target: [ci_test_diagnostics, ci_test_noexceptions, ci_test_noimplicitconversions]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: build
|
||||
@ -57,15 +58,15 @@ jobs:
|
||||
|
||||
ci_test_coverage:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v2.2.0
|
||||
container: ghcr.io/nlohmann/json-ci:v2.3.0
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: build
|
||||
run: cmake --build build --target ci_test_coverage
|
||||
- name: archive coverage report
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: code-coverage-report
|
||||
path: /__w/json/json/build/html
|
||||
@ -77,12 +78,12 @@ jobs:
|
||||
|
||||
ci_test_compilers:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v2.2.0
|
||||
container: ghcr.io/nlohmann/json-ci:v2.3.0
|
||||
strategy:
|
||||
matrix:
|
||||
compiler: [g++-4.8, g++-4.9, g++-5, g++-6, g++-7, g++-8, g++-9, g++-10, clang++-3.5, clang++-3.6, clang++-3.7, clang++-3.8, clang++-3.9, clang++-4.0, clang++-5.0, clang++-6.0, clang++-7, clang++-8, clang++-9, clang++-10, clang++-11, clang++-12, clang++-13]
|
||||
compiler: [g++-4.8, g++-4.9, g++-5, g++-6, g++-7, g++-8, g++-9, g++-10, clang++-3.5, clang++-3.6, clang++-3.7, clang++-3.8, clang++-3.9, clang++-4.0, clang++-5.0, clang++-6.0, clang++-7, clang++-8, clang++-9, clang++-10, clang++-11, clang++-12, clang++-13, clang++-14]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: build
|
||||
@ -90,13 +91,13 @@ jobs:
|
||||
|
||||
ci_test_standards:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v2.2.0
|
||||
container: ghcr.io/nlohmann/json-ci:v2.3.0
|
||||
strategy:
|
||||
matrix:
|
||||
standard: [11, 14, 17, 20]
|
||||
compiler: [gcc, clang]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: build
|
||||
@ -104,9 +105,9 @@ jobs:
|
||||
|
||||
ci_cuda_example:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v2.2.0
|
||||
container: ghcr.io/nlohmann/json-ci:v2.3.0
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: build
|
||||
|
86
.github/workflows/windows.yml
vendored
@ -7,6 +7,7 @@ on:
|
||||
- master
|
||||
- release/*
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
mingw:
|
||||
@ -16,7 +17,7 @@ jobs:
|
||||
architecture: [x64, x86]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up MinGW
|
||||
uses: egor-tensin/setup-mingw@v2
|
||||
with:
|
||||
@ -28,50 +29,15 @@ jobs:
|
||||
- name: test
|
||||
run: cd build ; ctest -j 10 -C Debug --output-on-failure
|
||||
|
||||
msvc2017:
|
||||
runs-on: windows-2016
|
||||
strategy:
|
||||
matrix:
|
||||
build_type: [Debug, Release]
|
||||
architecture: [Win32, x64]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -G "Visual Studio 15 2017" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/W4 /WX"
|
||||
if: matrix.build_type == 'Release' && matrix.architecture == 'x64'
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -G "Visual Studio 15 2017" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/W4 /WX"
|
||||
if: matrix.build_type == 'Release' && matrix.architecture != 'x64'
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -G "Visual Studio 15 2017" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DJSON_FastTests=ON -DCMAKE_CXX_FLAGS="/W4 /WX"
|
||||
if: matrix.build_type == 'Debug'
|
||||
- name: build
|
||||
run: cmake --build build --config ${{ matrix.build_type }} --parallel 10
|
||||
- name: test
|
||||
run: cd build ; ctest -j 10 -C ${{ matrix.build_type }} --output-on-failure
|
||||
|
||||
msvc2017_latest:
|
||||
runs-on: windows-2016
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -G "Visual Studio 15 2017" -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /W4 /WX"
|
||||
- name: build
|
||||
run: cmake --build build --config Release --parallel 10
|
||||
- name: test
|
||||
run: cd build ; ctest -j 10 -C Release --output-on-failure
|
||||
|
||||
msvc2019:
|
||||
runs-on: windows-latest
|
||||
runs-on: windows-2019
|
||||
strategy:
|
||||
matrix:
|
||||
build_type: [Debug, Release]
|
||||
architecture: [Win32, x64]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/W4 /WX"
|
||||
if: matrix.build_type == 'Release'
|
||||
@ -84,10 +50,10 @@ jobs:
|
||||
run: cd build ; ctest -j 10 -C ${{ matrix.build_type }} --output-on-failure
|
||||
|
||||
msvc2019_latest:
|
||||
runs-on: windows-latest
|
||||
runs-on: windows-2019
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -G "Visual Studio 16 2019" -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /W4 /WX"
|
||||
- name: build
|
||||
@ -95,14 +61,46 @@ jobs:
|
||||
- name: test
|
||||
run: cd build ; ctest -j 10 -C Release --output-on-failure
|
||||
|
||||
msvc2022:
|
||||
runs-on: windows-2022
|
||||
strategy:
|
||||
matrix:
|
||||
build_type: [Debug, Release]
|
||||
architecture: [Win32, x64]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/W4 /WX"
|
||||
if: matrix.build_type == 'Release'
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DJSON_FastTests=ON -DCMAKE_CXX_FLAGS="/W4 /WX"
|
||||
if: matrix.build_type == 'Debug'
|
||||
- name: build
|
||||
run: cmake --build build --config ${{ matrix.build_type }} --parallel 10
|
||||
- name: test
|
||||
run: cd build ; ctest -j 10 -C ${{ matrix.build_type }} --output-on-failure
|
||||
|
||||
msvc2022_latest:
|
||||
runs-on: windows-2022
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -G "Visual Studio 17 2022" -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /W4 /WX"
|
||||
- name: build
|
||||
run: cmake --build build --config Release --parallel 10
|
||||
- name: test
|
||||
run: cd build ; ctest -j 10 -C Release --output-on-failure
|
||||
|
||||
clang:
|
||||
runs-on: windows-latest
|
||||
runs-on: windows-2019
|
||||
strategy:
|
||||
matrix:
|
||||
version: [11, 12]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: install Clang
|
||||
run: curl -fsSL -o LLVM${{ matrix.version }}.exe https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ matrix.version }}.0.0/LLVM-${{ matrix.version }}.0.0-win64.exe ; 7z x LLVM${{ matrix.version }}.exe -y -o"C:/Program Files/LLVM"
|
||||
- name: cmake
|
||||
@ -113,13 +111,13 @@ jobs:
|
||||
run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure
|
||||
|
||||
clang-cl-11:
|
||||
runs-on: windows-latest
|
||||
runs-on: windows-2019
|
||||
strategy:
|
||||
matrix:
|
||||
architecture: [Win32, x64]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -T ClangCL -DJSON_BuildTests=On
|
||||
- name: build
|
||||
|
43
.gitignore
vendored
@ -1,32 +1,33 @@
|
||||
json_unit
|
||||
json_benchmarks
|
||||
json_benchmarks_simple
|
||||
fuzz-testing
|
||||
|
||||
*.dSYM
|
||||
*.o
|
||||
*.gcno
|
||||
*.gcda
|
||||
|
||||
build
|
||||
build_coverage
|
||||
clang_analyze_build
|
||||
|
||||
benchmarks/files/numbers/*.json
|
||||
.DS_Store
|
||||
|
||||
.wsjcpp-logs/*
|
||||
.wsjcpp/*
|
||||
|
||||
.idea
|
||||
/.idea
|
||||
/cmake-build-*
|
||||
|
||||
test/test-*
|
||||
/.vs
|
||||
/.vs/
|
||||
/.vscode/
|
||||
|
||||
doc/html
|
||||
doc/mkdocs/venv/
|
||||
doc/mkdocs/docs/examples
|
||||
doc/mkdocs/site
|
||||
doc/mkdocs/docs/__pycache__/
|
||||
/doc/docset/JSON_for_Modern_C++.docset/
|
||||
/doc/docset/JSON_for_Modern_C++.tgz
|
||||
# clangd cache
|
||||
/.cache/
|
||||
|
||||
# build directories (vscode-cmake-tools, user-defined, ...)
|
||||
/build*/
|
||||
|
||||
/docs/mkdocs/docs/examples/
|
||||
/docs/mkdocs/docs/__pycache__/
|
||||
/docs/mkdocs/site/
|
||||
/docs/mkdocs/venv/
|
||||
/docs/docset/JSON_for_Modern_C++.docset/
|
||||
/docs/docset/JSON_for_Modern_C++.tgz
|
||||
/docs/mkdocs/docs/images/json.gif
|
||||
|
||||
# serve_header
|
||||
/serve_header.yml
|
||||
/localhost.pem
|
||||
/localhost-key.pem
|
||||
|
@ -1,14 +1,14 @@
|
||||
cff-version: 1.1.0
|
||||
cff-version: 1.2.0
|
||||
message: "If you use this software, please cite it as below."
|
||||
authors:
|
||||
authors:
|
||||
- family-names: Lohmann
|
||||
given-names: Niels
|
||||
orcid: https://orcid.org/0000-0001-9037-795X
|
||||
email: mail@nlohmann.me
|
||||
website: https://nlohmann.me
|
||||
title: "JSON for Modern C++"
|
||||
version: 3.10.4
|
||||
date-released: 2021
|
||||
version: 3.10.5
|
||||
date-released: 2022-01-03
|
||||
license: MIT
|
||||
repository-code: "https://github.com/nlohmann"
|
||||
url: https://json.nlohmann.me
|
||||
|
@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.1)
|
||||
## PROJECT
|
||||
## name and version
|
||||
##
|
||||
project(nlohmann_json VERSION 3.10.4 LANGUAGES CXX)
|
||||
project(nlohmann_json VERSION 3.10.5 LANGUAGES CXX)
|
||||
|
||||
##
|
||||
## MAIN_PROJECT CHECK
|
||||
@ -19,6 +19,7 @@ endif()
|
||||
## INCLUDE
|
||||
##
|
||||
##
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
|
||||
include(ExternalProject)
|
||||
|
||||
##
|
||||
@ -30,7 +31,13 @@ if (POLICY CMP0077)
|
||||
cmake_policy(SET CMP0077 NEW)
|
||||
endif ()
|
||||
|
||||
option(JSON_BuildTests "Build the unit tests when BUILD_TESTING is enabled." ${MAIN_PROJECT})
|
||||
# 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_ImplicitConversions "Enable implicit conversions." ON)
|
||||
@ -39,7 +46,7 @@ option(JSON_MultipleHeaders "Use non-amalgamated version of the library." OF
|
||||
option(JSON_SystemInclude "Include as system headers (skip for clang-tidy)." OFF)
|
||||
|
||||
if (JSON_CI)
|
||||
include(cmake/ci.cmake)
|
||||
include(ci)
|
||||
endif ()
|
||||
|
||||
##
|
||||
@ -129,7 +136,7 @@ CONFIGURE_FILE(
|
||||
if (JSON_BuildTests)
|
||||
include(CTest)
|
||||
enable_testing()
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
##
|
||||
|
72
ChangeLog.md
@ -1,22 +1,55 @@
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [3.10.4](https://github.com/nlohmann/json/releases/tag/3.10.4) (2021-10-16)
|
||||
## [3.10.5](https://github.com/nlohmann/json/releases/tag/3.10.5) (2022-01-02)
|
||||
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v3.10.3...3.10.4)
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v3.10.4...3.10.5)
|
||||
|
||||
- Compiler error in output serializer due to 'incompatible initializer' [\#3081](https://github.com/nlohmann/json/issues/3081)
|
||||
- Strange behaviour when using std::sort on std::vector\<json\> [\#3080](https://github.com/nlohmann/json/issues/3080)
|
||||
- Unhandled exception: nlohmann::detail::parse\_error [\#3078](https://github.com/nlohmann/json/issues/3078)
|
||||
- explicit constructor with default does not compile [\#3077](https://github.com/nlohmann/json/issues/3077)
|
||||
- Parse an object but get an array using GCC [\#3076](https://github.com/nlohmann/json/issues/3076)
|
||||
- Version 3.10.3 breaks backward-compatibility with 3.10.2 [\#3070](https://github.com/nlohmann/json/issues/3070)
|
||||
- Feature request, Add to\_json/from\_json to align with other to/from binary api. [\#3067](https://github.com/nlohmann/json/issues/3067)
|
||||
- vcpkg is out of date [\#3066](https://github.com/nlohmann/json/issues/3066)
|
||||
- \#include \<filesystem\> doesn't work with gcc-7 when `-std=c++17` is specified. [\#3203](https://github.com/nlohmann/json/issues/3203)
|
||||
- Not able to use nlohmann json with c++ code built using emscripten to wasm [\#3200](https://github.com/nlohmann/json/issues/3200)
|
||||
- Warning for shadowed variables [\#3188](https://github.com/nlohmann/json/issues/3188)
|
||||
- Accessing missing keys on const json object leads to assert [\#3183](https://github.com/nlohmann/json/issues/3183)
|
||||
- Data member is available, but null is reported, and program throws error [\#3173](https://github.com/nlohmann/json/issues/3173)
|
||||
- serialization problem, from\_json need construct new object [\#3169](https://github.com/nlohmann/json/issues/3169)
|
||||
- std::filesystem unavailable on macOS lower deployment targets [\#3156](https://github.com/nlohmann/json/issues/3156)
|
||||
- \[json.exception.type\_error.305\] cannot use operator\[\] with a string argument with string [\#3151](https://github.com/nlohmann/json/issues/3151)
|
||||
- json::dump\(\) is not compatible with C++ standards [\#3147](https://github.com/nlohmann/json/issues/3147)
|
||||
- Issue with json::parse decoding codepoints [\#3142](https://github.com/nlohmann/json/issues/3142)
|
||||
- Simple parse of json object thinks it should be an array [\#3136](https://github.com/nlohmann/json/issues/3136)
|
||||
- How to properly read a Json string that may be null in some cases? [\#3135](https://github.com/nlohmann/json/issues/3135)
|
||||
- Deadlock on create json - windows only [\#3129](https://github.com/nlohmann/json/issues/3129)
|
||||
- Wrong parsing of int64 values nearest of limit [\#3126](https://github.com/nlohmann/json/issues/3126)
|
||||
- ordered\_json doesn't support range based erase [\#3108](https://github.com/nlohmann/json/issues/3108)
|
||||
- Apple build failed with json/single\_include/nlohmann/json.hpp:4384:57: 'path' is unavailable [\#3097](https://github.com/nlohmann/json/issues/3097)
|
||||
- GCC 7.5.0 with --std=c++17: filesystem: No such file or directory [\#3090](https://github.com/nlohmann/json/issues/3090)
|
||||
- Drop Travis CI [\#3087](https://github.com/nlohmann/json/issues/3087)
|
||||
- ordered\_json::reset\(\) compile error with nvcc [\#3013](https://github.com/nlohmann/json/issues/3013)
|
||||
- Support for unordered\_map as object\_t [\#2932](https://github.com/nlohmann/json/issues/2932)
|
||||
- Compiler warning with Intel compiler, same as \#755 [\#2712](https://github.com/nlohmann/json/issues/2712)
|
||||
- Compiler warnings with NVCC 11.2 [\#2676](https://github.com/nlohmann/json/issues/2676)
|
||||
- some static analysis warning at line 11317 [\#1390](https://github.com/nlohmann/json/issues/1390)
|
||||
- Compiling with icpc [\#755](https://github.com/nlohmann/json/issues/755)
|
||||
|
||||
- Fix compilation error with NVCC [\#3234](https://github.com/nlohmann/json/pull/3234) ([nlohmann](https://github.com/nlohmann))
|
||||
- Remove Travis CI [\#3233](https://github.com/nlohmann/json/pull/3233) ([nlohmann](https://github.com/nlohmann))
|
||||
- Add build step for NVCC and fix a warning [\#3227](https://github.com/nlohmann/json/pull/3227) ([nlohmann](https://github.com/nlohmann))
|
||||
- Update cpplint [\#3225](https://github.com/nlohmann/json/pull/3225) ([nlohmann](https://github.com/nlohmann))
|
||||
- Fix: Warning for shadowed variables \(\#3188\) [\#3193](https://github.com/nlohmann/json/pull/3193) ([kernie](https://github.com/kernie))
|
||||
- Fix FAQ hyperlink typo in readme [\#3148](https://github.com/nlohmann/json/pull/3148) ([Prince-Mendiratta](https://github.com/Prince-Mendiratta))
|
||||
- Docs: Update `skip_comments` to `ignore_comments` [\#3145](https://github.com/nlohmann/json/pull/3145) ([daniel-kun](https://github.com/daniel-kun))
|
||||
- fix typos in documentation [\#3140](https://github.com/nlohmann/json/pull/3140) ([striezel](https://github.com/striezel))
|
||||
- Fix spelling [\#3125](https://github.com/nlohmann/json/pull/3125) ([axic](https://github.com/axic))
|
||||
- Extend std specializations [\#3121](https://github.com/nlohmann/json/pull/3121) ([nlohmann](https://github.com/nlohmann))
|
||||
- Add missing erase\(first, last\) function to ordered\_map [\#3109](https://github.com/nlohmann/json/pull/3109) ([nlohmann](https://github.com/nlohmann))
|
||||
- Fix typos in operator\[\] documentation [\#3102](https://github.com/nlohmann/json/pull/3102) ([axnsan12](https://github.com/axnsan12))
|
||||
- Add C++17 copies of the test binaries [\#3101](https://github.com/nlohmann/json/pull/3101) ([nlohmann](https://github.com/nlohmann))
|
||||
- Add examples for parsing from iterator pair [\#3100](https://github.com/nlohmann/json/pull/3100) ([nlohmann](https://github.com/nlohmann))
|
||||
- Update CI [\#3088](https://github.com/nlohmann/json/pull/3088) ([nlohmann](https://github.com/nlohmann))
|
||||
- Revert invalid fix [\#3082](https://github.com/nlohmann/json/pull/3082) ([nlohmann](https://github.com/nlohmann))
|
||||
- Allow to use get with explicit constructor [\#3079](https://github.com/nlohmann/json/pull/3079) ([nlohmann](https://github.com/nlohmann))
|
||||
- fix std::filesystem::path regression [\#3073](https://github.com/nlohmann/json/pull/3073) ([theodelrieu](https://github.com/theodelrieu))
|
||||
- Consolidate documentation [\#3071](https://github.com/nlohmann/json/pull/3071) ([nlohmann](https://github.com/nlohmann))
|
||||
- Add recursive update function [\#3069](https://github.com/nlohmann/json/pull/3069) ([nlohmann](https://github.com/nlohmann))
|
||||
- Fix Clang version [\#3040](https://github.com/nlohmann/json/pull/3040) ([nlohmann](https://github.com/nlohmann))
|
||||
- Fix assertion failure for JSON\_DIAGNOSTICS [\#3037](https://github.com/nlohmann/json/pull/3037) ([carlsmedstad](https://github.com/carlsmedstad))
|
||||
- meta: fix is\_compatible/constructible traits [\#3020](https://github.com/nlohmann/json/pull/3020) ([theodelrieu](https://github.com/theodelrieu))
|
||||
@ -27,6 +60,19 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Fix -Wunused warnings on JSON\_DIAGNOSTICS [\#2976](https://github.com/nlohmann/json/pull/2976) ([gcerretani](https://github.com/gcerretani))
|
||||
- Update docset generation script [\#2967](https://github.com/nlohmann/json/pull/2967) ([nlohmann](https://github.com/nlohmann))
|
||||
|
||||
## [v3.10.4](https://github.com/nlohmann/json/releases/tag/v3.10.4) (2021-10-16)
|
||||
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v3.10.3...v3.10.4)
|
||||
|
||||
- Compiler error in output serializer due to 'incompatible initializer' [\#3081](https://github.com/nlohmann/json/issues/3081)
|
||||
- Strange behaviour when using std::sort on std::vector\<json\> [\#3080](https://github.com/nlohmann/json/issues/3080)
|
||||
- Unhandled exception: nlohmann::detail::parse\_error [\#3078](https://github.com/nlohmann/json/issues/3078)
|
||||
- explicit constructor with default does not compile [\#3077](https://github.com/nlohmann/json/issues/3077)
|
||||
- Parse an object but get an array using GCC [\#3076](https://github.com/nlohmann/json/issues/3076)
|
||||
- Version 3.10.3 breaks backward-compatibility with 3.10.2 [\#3070](https://github.com/nlohmann/json/issues/3070)
|
||||
- Feature request, Add to\_json/from\_json to align with other to/from binary api. [\#3067](https://github.com/nlohmann/json/issues/3067)
|
||||
- vcpkg is out of date [\#3066](https://github.com/nlohmann/json/issues/3066)
|
||||
|
||||
## [v3.10.3](https://github.com/nlohmann/json/releases/tag/v3.10.3) (2021-10-08)
|
||||
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v3.10.2...v3.10.3)
|
||||
@ -768,7 +814,7 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- catch exceptions for json\_pointer : ..../+99 [\#1990](https://github.com/nlohmann/json/pull/1990) ([dota17](https://github.com/dota17))
|
||||
- Modify the document about operator== [\#1984](https://github.com/nlohmann/json/pull/1984) ([dota17](https://github.com/dota17))
|
||||
- Rename argument array\_index to array\_indx in json\_pointer methods [\#1980](https://github.com/nlohmann/json/pull/1980) ([linev](https://github.com/linev))
|
||||
- README: Fix string representation of `dump`ed `json` [\#1979](https://github.com/nlohmann/json/pull/1979) ([alex-weej](https://github.com/alex-weej))
|
||||
- README: Fix string representation of `dump`ed `json` [\#1979](https://github.com/nlohmann/json/pull/1979) ([alexweej](https://github.com/alexweej))
|
||||
- fix warnings in serializer.hpp for VS2019 [\#1969](https://github.com/nlohmann/json/pull/1969) ([dota17](https://github.com/dota17))
|
||||
- Fix C26451 warnnings in to\_chars.hpp [\#1967](https://github.com/nlohmann/json/pull/1967) ([dota17](https://github.com/dota17))
|
||||
- appveyor.yml: Compile and test with latest version for \_\_cplusplus ma… [\#1958](https://github.com/nlohmann/json/pull/1958) ([t-b](https://github.com/t-b))
|
||||
@ -1224,7 +1270,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Copyconstructor inserts original into array with single element [\#1397](https://github.com/nlohmann/json/issues/1397)
|
||||
- Get value without explicit typecasting [\#1395](https://github.com/nlohmann/json/issues/1395)
|
||||
- Big file parsing [\#1393](https://github.com/nlohmann/json/issues/1393)
|
||||
- some static analysis warning at line 11317 [\#1390](https://github.com/nlohmann/json/issues/1390)
|
||||
- Adding Structured Binding Support [\#1388](https://github.com/nlohmann/json/issues/1388)
|
||||
- map\<json::value\_t, string\> exhibits unexpected behavior [\#1387](https://github.com/nlohmann/json/issues/1387)
|
||||
- Error Code Return [\#1386](https://github.com/nlohmann/json/issues/1386)
|
||||
@ -1812,7 +1857,7 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- UTF8 encoding enhancement [\#534](https://github.com/nlohmann/json/pull/534) ([TedLyngmo](https://github.com/TedLyngmo))
|
||||
- Fix typo [\#530](https://github.com/nlohmann/json/pull/530) ([berkus](https://github.com/berkus))
|
||||
- Make exception base class visible in basic\_json [\#526](https://github.com/nlohmann/json/pull/526) ([krzysztofwos](https://github.com/krzysztofwos))
|
||||
- :art: Namespace `uint8_t` from the C++ stdlib [\#510](https://github.com/nlohmann/json/pull/510) ([alex-weej](https://github.com/alex-weej))
|
||||
- :art: Namespace `uint8_t` from the C++ stdlib [\#510](https://github.com/nlohmann/json/pull/510) ([alexweej](https://github.com/alexweej))
|
||||
- add to\_json method for C arrays [\#508](https://github.com/nlohmann/json/pull/508) ([theodelrieu](https://github.com/theodelrieu))
|
||||
- Fix -Weffc++ warnings \(GNU 6.3.1\) [\#496](https://github.com/nlohmann/json/pull/496) ([TedLyngmo](https://github.com/TedLyngmo))
|
||||
|
||||
@ -1901,7 +1946,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Compilation error with unordered\_map\< int, int \> [\#758](https://github.com/nlohmann/json/issues/758)
|
||||
- CBOR string [\#757](https://github.com/nlohmann/json/issues/757)
|
||||
- Proposal: out\_of\_range should be a subclass of std::out\_of\_range [\#756](https://github.com/nlohmann/json/issues/756)
|
||||
- Compiling with icpc [\#755](https://github.com/nlohmann/json/issues/755)
|
||||
- Getter is setting the value to null if the key does not exist [\#754](https://github.com/nlohmann/json/issues/754)
|
||||
- parsing works sometimes and crashes others [\#752](https://github.com/nlohmann/json/issues/752)
|
||||
- Static\_assert failed "incompatible pointer type" with Xcode [\#751](https://github.com/nlohmann/json/issues/751)
|
||||
|
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2013-2021 Niels Lohmann
|
||||
Copyright (c) 2013-2022 Niels Lohmann
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
85
Makefile
@ -4,9 +4,6 @@
|
||||
# configuration
|
||||
##########################################################################
|
||||
|
||||
# directory to recent compiler binaries
|
||||
COMPILER_DIR=/usr/local/opt/llvm/bin
|
||||
|
||||
# find GNU sed to use `-i` parameter
|
||||
SED:=$(shell command -v gsed || which sed)
|
||||
|
||||
@ -48,7 +45,7 @@ all:
|
||||
|
||||
# compile example files and check output
|
||||
doctest:
|
||||
$(MAKE) check_output -C doc
|
||||
$(MAKE) check_output -C docs
|
||||
|
||||
|
||||
##########################################################################
|
||||
@ -58,10 +55,11 @@ doctest:
|
||||
run_benchmarks:
|
||||
rm -fr cmake-build-benchmarks
|
||||
mkdir cmake-build-benchmarks
|
||||
cd cmake-build-benchmarks ; cmake ../benchmarks -GNinja -DCMAKE_BUILD_TYPE=Release -DJSON_BuildTests=On
|
||||
cd cmake-build-benchmarks ; cmake ../tests/benchmarks -GNinja -DCMAKE_BUILD_TYPE=Release
|
||||
cd cmake-build-benchmarks ; ninja
|
||||
cd cmake-build-benchmarks ; ./json_benchmarks
|
||||
|
||||
|
||||
##########################################################################
|
||||
# fuzzing
|
||||
##########################################################################
|
||||
@ -70,41 +68,41 @@ run_benchmarks:
|
||||
fuzz_testing:
|
||||
rm -fr fuzz-testing
|
||||
mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out
|
||||
$(MAKE) parse_afl_fuzzer -C test CXX=afl-clang++
|
||||
mv test/parse_afl_fuzzer fuzz-testing/fuzzer
|
||||
find test/data/json_tests -size -5k -name *json | xargs -I{} cp "{}" fuzz-testing/testcases
|
||||
$(MAKE) parse_afl_fuzzer -C tests CXX=afl-clang++
|
||||
mv tests/parse_afl_fuzzer fuzz-testing/fuzzer
|
||||
find tests/data/json_tests -size -5k -name *json | xargs -I{} cp "{}" fuzz-testing/testcases
|
||||
@echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer"
|
||||
|
||||
fuzz_testing_bson:
|
||||
rm -fr fuzz-testing
|
||||
mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out
|
||||
$(MAKE) parse_bson_fuzzer -C test CXX=afl-clang++
|
||||
mv test/parse_bson_fuzzer fuzz-testing/fuzzer
|
||||
find test/data -size -5k -name *.bson | xargs -I{} cp "{}" fuzz-testing/testcases
|
||||
$(MAKE) parse_bson_fuzzer -C tests CXX=afl-clang++
|
||||
mv tests/parse_bson_fuzzer fuzz-testing/fuzzer
|
||||
find tests/data -size -5k -name *.bson | xargs -I{} cp "{}" fuzz-testing/testcases
|
||||
@echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer"
|
||||
|
||||
fuzz_testing_cbor:
|
||||
rm -fr fuzz-testing
|
||||
mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out
|
||||
$(MAKE) parse_cbor_fuzzer -C test CXX=afl-clang++
|
||||
mv test/parse_cbor_fuzzer fuzz-testing/fuzzer
|
||||
find test/data -size -5k -name *.cbor | xargs -I{} cp "{}" fuzz-testing/testcases
|
||||
$(MAKE) parse_cbor_fuzzer -C tests CXX=afl-clang++
|
||||
mv tests/parse_cbor_fuzzer fuzz-testing/fuzzer
|
||||
find tests/data -size -5k -name *.cbor | xargs -I{} cp "{}" fuzz-testing/testcases
|
||||
@echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer"
|
||||
|
||||
fuzz_testing_msgpack:
|
||||
rm -fr fuzz-testing
|
||||
mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out
|
||||
$(MAKE) parse_msgpack_fuzzer -C test CXX=afl-clang++
|
||||
mv test/parse_msgpack_fuzzer fuzz-testing/fuzzer
|
||||
find test/data -size -5k -name *.msgpack | xargs -I{} cp "{}" fuzz-testing/testcases
|
||||
$(MAKE) parse_msgpack_fuzzer -C tests CXX=afl-clang++
|
||||
mv tests/parse_msgpack_fuzzer fuzz-testing/fuzzer
|
||||
find tests/data -size -5k -name *.msgpack | xargs -I{} cp "{}" fuzz-testing/testcases
|
||||
@echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer"
|
||||
|
||||
fuzz_testing_ubjson:
|
||||
rm -fr fuzz-testing
|
||||
mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out
|
||||
$(MAKE) parse_ubjson_fuzzer -C test CXX=afl-clang++
|
||||
mv test/parse_ubjson_fuzzer fuzz-testing/fuzzer
|
||||
find test/data -size -5k -name *.ubjson | xargs -I{} cp "{}" fuzz-testing/testcases
|
||||
$(MAKE) parse_ubjson_fuzzer -C tests CXX=afl-clang++
|
||||
mv tests/parse_ubjson_fuzzer fuzz-testing/fuzzer
|
||||
find tests/data -size -5k -name *.ubjson | xargs -I{} cp "{}" fuzz-testing/testcases
|
||||
@echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer"
|
||||
|
||||
fuzzing-start:
|
||||
@ -135,6 +133,7 @@ pvs_studio:
|
||||
cd cmake-build-pvs-studio ; plog-converter -a'GA:1,2;64:1;CS' -t fullhtml PVS-Studio.log -o pvs
|
||||
open cmake-build-pvs-studio/pvs/index.html
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Code format and source amalgamation
|
||||
##########################################################################
|
||||
@ -160,18 +159,18 @@ pretty:
|
||||
--preserve-date \
|
||||
--suffix=none \
|
||||
--formatted \
|
||||
$(SRCS) $(AMALGAMATED_FILE) test/src/*.cpp test/src/*.hpp benchmarks/src/benchmarks.cpp doc/examples/*.cpp
|
||||
$(SRCS) $(AMALGAMATED_FILE) tests/src/*.cpp tests/src/*.hpp tests/benchmarks/src/benchmarks.cpp docs/examples/*.cpp
|
||||
|
||||
# call the Clang-Format on all source files
|
||||
pretty_format:
|
||||
for FILE in $(SRCS) $(AMALGAMATED_FILE) test/src/*.cpp test/src/*.hpp benchmarks/src/benchmarks.cpp doc/examples/*.cpp; do echo $$FILE; clang-format -i $$FILE; done
|
||||
for FILE in $(SRCS) $(AMALGAMATED_FILE) tests/src/*.cpp tests/src/*.hpp benchmarks/src/benchmarks.cpp docs/examples/*.cpp; do echo $$FILE; clang-format -i $$FILE; done
|
||||
|
||||
# create single header file
|
||||
amalgamate: $(AMALGAMATED_FILE)
|
||||
|
||||
# call the amalgamation tool and pretty print
|
||||
$(AMALGAMATED_FILE): $(SRCS)
|
||||
third_party/amalgamate/amalgamate.py -c third_party/amalgamate/config.json -s . --verbose=yes
|
||||
tools/amalgamate/amalgamate.py -c tools/amalgamate/config.json -s . --verbose=yes
|
||||
$(MAKE) pretty
|
||||
|
||||
# check if file single_include/nlohmann/json.hpp has been amalgamated from the nlohmann sources
|
||||
@ -203,20 +202,29 @@ ChangeLog.md:
|
||||
# Release files
|
||||
##########################################################################
|
||||
|
||||
# Create the files for a release and add signatures and hashes. We use `-X` to make the resulting ZIP file
|
||||
# reproducible, see <https://content.pivotal.io/blog/barriers-to-deterministic-reproducible-zip-files>.
|
||||
# Create a tar.gz archive that contains sufficient files to be used as CMake project (e.g., using FetchContent). The
|
||||
# archive is created according to the advices of <https://reproducible-builds.org/docs/archives/>.
|
||||
json.tar.xz:
|
||||
mkdir json
|
||||
rsync -R $(shell find LICENSE.MIT nlohmann_json.natvis CMakeLists.txt cmake/*.in include single_include -type f) json
|
||||
gtar --sort=name --mtime="@$(shell git log -1 --pretty=%ct)" --owner=0 --group=0 --numeric-owner --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime --create --file - json | xz --compress -9e --threads=2 - > json.tar.xz
|
||||
rm -fr json
|
||||
|
||||
release:
|
||||
# We use `-X` to make the resulting ZIP file reproducible, see
|
||||
# <https://content.pivotal.io/blog/barriers-to-deterministic-reproducible-zip-files>.
|
||||
include.zip:
|
||||
zip -9 --recurse-paths -X include.zip $(SRCS) $(AMALGAMATED_FILE) meson.build LICENSE.MIT
|
||||
|
||||
# Create the files for a release and add signatures and hashes.
|
||||
release: include.zip json.tar.xz
|
||||
rm -fr release_files
|
||||
mkdir release_files
|
||||
zip -9 --recurse-paths -X include.zip $(SRCS) $(AMALGAMATED_FILE) meson.build LICENSE.MIT
|
||||
gpg --armor --detach-sig include.zip
|
||||
mv include.zip include.zip.asc release_files
|
||||
gpg --armor --detach-sig $(AMALGAMATED_FILE)
|
||||
gpg --armor --detach-sig json.tar.xz
|
||||
cp $(AMALGAMATED_FILE) release_files
|
||||
mv $(AMALGAMATED_FILE).asc release_files
|
||||
cd release_files ; shasum -a 256 json.hpp > hashes.txt
|
||||
cd release_files ; shasum -a 256 include.zip >> hashes.txt
|
||||
mv $(AMALGAMATED_FILE).asc json.tar.xz json.tar.xz.asc include.zip include.zip.asc release_files
|
||||
cd release_files ; shasum -a 256 json.hpp include.zip json.tar.xz > hashes.txt
|
||||
|
||||
|
||||
##########################################################################
|
||||
@ -225,11 +233,11 @@ release:
|
||||
|
||||
# clean up
|
||||
clean:
|
||||
rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM test/*.dSYM oclint_report.html
|
||||
rm -fr fuzz fuzz-testing *.dSYM tests/*.dSYM
|
||||
rm -fr benchmarks/files/numbers/*.json
|
||||
rm -fr cmake-3.1.0-Darwin64.tar.gz cmake-3.1.0-Darwin64
|
||||
rm -fr cmake-build-benchmarks cmake-build-pedantic fuzz-testing cmake-build-clang-analyze cmake-build-pvs-studio cmake-build-infer cmake_build
|
||||
$(MAKE) clean -Cdoc
|
||||
rm -fr cmake-build-benchmarks fuzz-testing cmake-build-pvs-studio release_files
|
||||
$(MAKE) clean -Cdocs
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Thirdparty code
|
||||
@ -243,3 +251,10 @@ update_hedley:
|
||||
$(SED) -i '1s/^/#pragma once\n\n/' include/nlohmann/thirdparty/hedley/hedley.hpp
|
||||
$(SED) -i '1s/^/#pragma once\n\n/' include/nlohmann/thirdparty/hedley/hedley_undef.hpp
|
||||
$(MAKE) amalgamate
|
||||
|
||||
##########################################################################
|
||||
# serve_header.py
|
||||
##########################################################################
|
||||
|
||||
serve_header:
|
||||
./tools/serve_header/serve_header.py --make $(MAKE)
|
||||
|
81
README.md
@ -1,4 +1,4 @@
|
||||
[![JSON for Modern C++](https://raw.githubusercontent.com/nlohmann/json/master/doc/json.gif)](https://github.com/nlohmann/json/releases)
|
||||
[![JSON for Modern C++](docs/json.gif)](https://github.com/nlohmann/json/releases)
|
||||
|
||||
[![Build Status](https://ci.appveyor.com/api/projects/status/1acb366xfyg3qybk/branch/develop?svg=true)](https://ci.appveyor.com/project/nlohmann/json)
|
||||
[![Ubuntu](https://github.com/nlohmann/json/workflows/Ubuntu/badge.svg)](https://github.com/nlohmann/json/actions?query=workflow%3AUbuntu)
|
||||
@ -10,7 +10,7 @@
|
||||
[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/nlohmann/json.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/nlohmann/json/context:cpp)
|
||||
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/json.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:json)
|
||||
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/1mp10JbaANo6FUc7)
|
||||
[![Documentation](https://img.shields.io/badge/docs-doxygen-blue.svg)](https://nlohmann.github.io/json/doxygen/index.html)
|
||||
[![Documentation](https://img.shields.io/badge/docs-mkdocs-blue.svg)](https://json.nlohmann.me)
|
||||
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nlohmann/json/master/LICENSE.MIT)
|
||||
[![GitHub Releases](https://img.shields.io/github/release/nlohmann/json.svg)](https://github.com/nlohmann/json/releases)
|
||||
[![GitHub Downloads](https://img.shields.io/github/downloads/nlohmann/json/total)](https://github.com/nlohmann/json/releases)
|
||||
@ -32,7 +32,7 @@
|
||||
- [Implicit conversions](#implicit-conversions)
|
||||
- [Conversions to/from arbitrary types](#arbitrary-types-conversions)
|
||||
- [Specializing enum conversion](#specializing-enum-conversion)
|
||||
- [Binary formats (BSON, CBOR, MessagePack, and UBJSON)](#binary-formats-bson-cbor-messagepack-and-ubjson)
|
||||
- [Binary formats (BSON, CBOR, MessagePack, UBJSON, and BJData)](#binary-formats-bson-cbor-messagepack-ubjson-and-bjdata)
|
||||
- [Supported compilers](#supported-compilers)
|
||||
- [Integration](#integration)
|
||||
- [CMake](#cmake)
|
||||
@ -54,7 +54,7 @@ There are myriads of [JSON](https://json.org) libraries out there, and each may
|
||||
|
||||
- **Trivial integration**. Our whole code consists of a single header file [`json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp). That's it. No library, no subproject, no dependencies, no complex build system. The class is written in vanilla C++11. All in all, everything should require no adjustment of your compiler flags or project settings.
|
||||
|
||||
- **Serious testing**. Our class is heavily [unit-tested](https://github.com/nlohmann/json/tree/develop/test/src) and covers [100%](https://coveralls.io/r/nlohmann/json) of the code, including all exceptional behavior. Furthermore, we checked with [Valgrind](https://valgrind.org) and the [Clang Sanitizers](https://clang.llvm.org/docs/index.html) that there are no memory leaks. [Google OSS-Fuzz](https://github.com/google/oss-fuzz/tree/master/projects/json) additionally runs fuzz tests against all parsers 24/7, effectively executing billions of tests so far. To maintain high quality, the project is following the [Core Infrastructure Initiative (CII) best practices](https://bestpractices.coreinfrastructure.org/projects/289).
|
||||
- **Serious testing**. Our class is heavily [unit-tested](https://github.com/nlohmann/json/tree/develop/tests/src) and covers [100%](https://coveralls.io/r/nlohmann/json) of the code, including all exceptional behavior. Furthermore, we checked with [Valgrind](https://valgrind.org) and the [Clang Sanitizers](https://clang.llvm.org/docs/index.html) that there are no memory leaks. [Google OSS-Fuzz](https://github.com/google/oss-fuzz/tree/master/projects/json) additionally runs fuzz tests against all parsers 24/7, effectively executing billions of tests so far. To maintain high quality, the project is following the [Core Infrastructure Initiative (CII) best practices](https://bestpractices.coreinfrastructure.org/projects/289).
|
||||
|
||||
Other aspects were not so important to us:
|
||||
|
||||
@ -83,9 +83,9 @@ Thanks everyone!
|
||||
|
||||
:question: If you have a **question**, please check if it is already answered in the [**FAQ**](https://json.nlohmann.me/home/faq/) or the [**Q&A**](https://github.com/nlohmann/json/discussions/categories/q-a) section. If not, please [**ask a new question**](https://github.com/nlohmann/json/discussions/new) there.
|
||||
|
||||
:books: If you want to **learn more** about how to use the library, check out the rest of the [**README**](#examples), have a look at [**code examples**](https://github.com/nlohmann/json/tree/develop/doc/examples), or browse through the [**help pages**](https://json.nlohmann.me).
|
||||
:books: If you want to **learn more** about how to use the library, check out the rest of the [**README**](#examples), have a look at [**code examples**](https://github.com/nlohmann/json/tree/develop/docs/examples), or browse through the [**help pages**](https://json.nlohmann.me).
|
||||
|
||||
:construction: If you want to understand the **API** better, check out the [**API Reference**](https://json.nlohmann.me/api/basic_json/) or the [**Doxygen documentation**](https://json.nlohmann.me/doxygen/index.html).
|
||||
:construction: If you want to understand the **API** better, check out the [**API Reference**](https://json.nlohmann.me/api/basic_json/).
|
||||
|
||||
:bug: If you found a **bug**, please check the [**FAQ**](https://json.nlohmann.me/home/faq/) if it is a known issue or the result of a design decision. Please also have a look at the [**issue list**](https://github.com/nlohmann/json/issues) before you [**create a new issue**](https://github.com/nlohmann/json/issues/new/choose). Please provide as much information as possible to help us understand and reproduce your issue.
|
||||
|
||||
@ -93,7 +93,7 @@ There is also a [**docset**](https://github.com/Kapeli/Dash-User-Contributions/t
|
||||
|
||||
## Examples
|
||||
|
||||
Beside the examples below, you may want to check the [documentation](https://nlohmann.github.io/json/) where each function contains a separate code example (e.g., check out [`emplace()`](https://nlohmann.github.io/json/api/basic_json/emplace/)). All [example files](https://github.com/nlohmann/json/tree/develop/doc/examples) can be compiled and executed on their own (e.g., file [emplace.cpp](https://github.com/nlohmann/json/blob/develop/doc/examples/emplace.cpp)).
|
||||
Beside the examples below, you may want to check the [documentation](https://json.nlohmann.me/) where each function contains a separate code example (e.g., check out [`emplace()`](https://json.nlohmann.me/api/basic_json/emplace/)). All [example files](https://github.com/nlohmann/json/tree/develop/docs/examples) can be compiled and executed on their own (e.g., file [emplace.cpp](https://github.com/nlohmann/json/blob/develop/docs/examples/emplace.cpp)).
|
||||
|
||||
### JSON as first-class data type
|
||||
|
||||
@ -162,7 +162,7 @@ json j2 = {
|
||||
};
|
||||
```
|
||||
|
||||
Note that in all these cases, you never need to "tell" the compiler which JSON value type you want to use. If you want to be explicit or express some edge cases, the functions [`json::array()`](https://nlohmann.github.io/json/api/basic_json/array/) and [`json::object()`](https://nlohmann.github.io/json/api/basic_json/object/) will help:
|
||||
Note that in all these cases, you never need to "tell" the compiler which JSON value type you want to use. If you want to be explicit or express some edge cases, the functions [`json::array()`](https://json.nlohmann.me/api/basic_json/array/) and [`json::object()`](https://json.nlohmann.me/api/basic_json/object/) will help:
|
||||
|
||||
```cpp
|
||||
// a way to express the empty array []
|
||||
@ -197,7 +197,7 @@ auto j2 = R"(
|
||||
|
||||
Note that without appending the `_json` suffix, the passed string literal is not parsed, but just used as JSON string value. That is, `json j = "{ \"happy\": true, \"pi\": 3.141 }"` would just store the string `"{ "happy": true, "pi": 3.141 }"` rather than parsing the actual object.
|
||||
|
||||
The above example can also be expressed explicitly using [`json::parse()`](https://nlohmann.github.io/json/api/basic_json/parse/):
|
||||
The above example can also be expressed explicitly using [`json::parse()`](https://json.nlohmann.me/api/basic_json/parse/):
|
||||
|
||||
```cpp
|
||||
// parse explicitly
|
||||
@ -240,9 +240,9 @@ std::cout << cpp_string << " == " << cpp_string2 << " == " << j_string.get<std::
|
||||
std::cout << j_string << " == " << serialized_string << std::endl;
|
||||
```
|
||||
|
||||
[`.dump()`](https://nlohmann.github.io/json/api/basic_json/dump/) returns the originally stored string value.
|
||||
[`.dump()`](https://json.nlohmann.me/api/basic_json/dump/) returns the originally stored string value.
|
||||
|
||||
Note the library only supports UTF-8. When you store strings with different encodings in the library, calling [`dump()`](https://nlohmann.github.io/json/api/basic_json/dump/) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers.
|
||||
Note the library only supports UTF-8. When you store strings with different encodings in the library, calling [`dump()`](https://json.nlohmann.me/api/basic_json/dump/) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers.
|
||||
|
||||
#### To/from streams (e.g. files, string streams)
|
||||
|
||||
@ -730,7 +730,7 @@ Some important things:
|
||||
* Those methods **MUST** be in your type's namespace (which can be the global namespace), or the library will not be able to locate them (in this example, they are in namespace `ns`, where `person` is defined).
|
||||
* Those methods **MUST** be available (e.g., proper headers must be included) everywhere you use these conversions. Look at [issue 1108](https://github.com/nlohmann/json/issues/1108) for errors that may occur otherwise.
|
||||
* When using `get<your_type>()`, `your_type` **MUST** be [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). (There is a way to bypass this requirement described later.)
|
||||
* In function `from_json`, use function [`at()`](https://nlohmann.github.io/json/api/basic_json/at/) to access the object values rather than `operator[]`. In case a key does not exist, `at` throws an exception that you can handle, whereas `operator[]` exhibits undefined behavior.
|
||||
* In function `from_json`, use function [`at()`](https://json.nlohmann.me/api/basic_json/at/) to access the object values rather than `operator[]`. In case a key does not exist, `at` throws an exception that you can handle, whereas `operator[]` exhibits undefined behavior.
|
||||
* You do not need to add serializers or deserializers for STL types like `std::vector`: the library already implements these.
|
||||
|
||||
#### Simplify your life with macros
|
||||
@ -857,7 +857,7 @@ namespace nlohmann {
|
||||
|
||||
#### Can I write my own serializer? (Advanced use)
|
||||
|
||||
Yes. You might want to take a look at [`unit-udt.cpp`](https://github.com/nlohmann/json/blob/develop/test/src/unit-udt.cpp) in the test suite, to see a few examples.
|
||||
Yes. You might want to take a look at [`unit-udt.cpp`](https://github.com/nlohmann/json/blob/develop/tests/src/unit-udt.cpp) in the test suite, to see a few examples.
|
||||
|
||||
If you write your own serializer, you'll need to do a few things:
|
||||
|
||||
@ -961,9 +961,9 @@ Other Important points:
|
||||
- When using `get<ENUM_TYPE>()`, undefined JSON values will default to the first pair specified in your map. Select this default pair carefully.
|
||||
- If an enum or JSON value is specified more than once in your map, the first matching occurrence from the top of the map will be returned when converting to or from JSON.
|
||||
|
||||
### Binary formats (BSON, CBOR, MessagePack, and UBJSON)
|
||||
### Binary formats (BSON, CBOR, MessagePack, UBJSON, and BJData)
|
||||
|
||||
Though JSON is a ubiquitous data format, it is not a very compact format suitable for data exchange, for instance over a network. Hence, the library supports [BSON](https://bsonspec.org) (Binary JSON), [CBOR](https://cbor.io) (Concise Binary Object Representation), [MessagePack](https://msgpack.org), and [UBJSON](https://ubjson.org) (Universal Binary JSON Specification) to efficiently encode JSON values to byte vectors and to decode such vectors.
|
||||
Though JSON is a ubiquitous data format, it is not a very compact format suitable for data exchange, for instance over a network. Hence, the library supports [BSON](https://bsonspec.org) (Binary JSON), [CBOR](https://cbor.io) (Concise Binary Object Representation), [MessagePack](https://msgpack.org), [UBJSON](https://ubjson.org) (Universal Binary JSON Specification) and [BJData](https://neurojson.org/bjdata) (Binary JData) to efficiently encode JSON values to byte vectors and to decode such vectors.
|
||||
|
||||
```cpp
|
||||
// create a JSON value
|
||||
@ -1035,16 +1035,17 @@ auto cbor = json::to_msgpack(j); // 0xD5 (fixext2), 0x10, 0xCA, 0xFE
|
||||
|
||||
## Supported compilers
|
||||
|
||||
Though it's 2021 already, the support for C++11 is still a bit sparse. Currently, the following compilers are known to work:
|
||||
Though it's 2022 already, the support for C++11 is still a bit sparse. Currently, the following compilers are known to work:
|
||||
|
||||
- GCC 4.8 - 11.0 (and possibly later)
|
||||
- Clang 3.4 - 13.0 (and possibly later)
|
||||
- Apple Clang 9.1 - 13.0 (and possibly later)
|
||||
- GCC 4.8 - 12.0 (and possibly later)
|
||||
- Clang 3.4 - 15.0 (and possibly later)
|
||||
- Apple Clang 9.1 - 13.1 (and possibly later)
|
||||
- Intel C++ Compiler 17.0.2 (and possibly later)
|
||||
- Nvidia CUDA Compiler 11.0.221 (and possibly later)
|
||||
- Microsoft Visual C++ 2015 / Build Tools 14.0.25123.0 (and possibly later)
|
||||
- Microsoft Visual C++ 2017 / Build Tools 15.5.180.51428 (and possibly later)
|
||||
- Microsoft Visual C++ 2019 / Build Tools 16.3.1+1def00d3d (and possibly later)
|
||||
- Microsoft Visual C++ 2022 / Build Tools 19.30.30709.0 (and possibly later)
|
||||
|
||||
I would be happy to learn about other compilers/versions.
|
||||
|
||||
@ -1092,8 +1093,8 @@ The following compilers are currently used in continuous integration at [AppVeyo
|
||||
| GCC 8.4.0 (Ubuntu 8.4.0-3ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 10.2.0 (Ubuntu 10.2.0-5ubuntu1~20.04) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 11.0.1 20210321 (experimental) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 11.1.0 | Ubuntu (aarch64) | Drone CI |
|
||||
| GCC 12.0.0 20211219 (experimental) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 3.5.2 (3.5.2-3ubuntu1) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 3.6.2 (3.6.2-3ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 3.7.1 (3.7.1-2ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
@ -1113,12 +1114,13 @@ The following compilers are currently used in continuous integration at [AppVeyo
|
||||
| Clang 12.0.0 (12.0.0-3ubuntu1~20.04.3) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 13.0.1 (13.0.1-++20211015123032+cf15ccdeb6d5-1exp120211015003613.5) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 14.0.0 (14.0.0-++20211221052852+55c71c9eac9b-1exp120211221172954.95) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 15.0.0 (15.0.0-++20220403052648+896770c9a92e-1~exp1~20220403172744.209) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| NVCC 11.0.221 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Visual Studio 14 2015 MSVC 19.0.24241.7 (Build Engine version 14.0.25420.1) | Windows-6.3.9600 | AppVeyor |
|
||||
| Visual Studio 15 2017 MSVC 19.16.27035.0 (Build Engine version 15.9.21+g9802d43bc3 for .NET Framework) | Windows-10.0.14393 | AppVeyor |
|
||||
| Visual Studio 15 2017 MSVC 19.16.27045.0 (Build Engine version 15.9.21+g9802d43bc3 for .NET Framework) | Windows-10.0.14393 | GitHub Actions |
|
||||
| Visual Studio 16 2019 MSVC 19.28.29912.0 (Build Engine version 16.9.0+57a23d249 for .NET Framework) | Windows-10.0.17763 | GitHub Actions |
|
||||
| Visual Studio 16 2019 MSVC 19.28.29912.0 (Build Engine version 16.9.0+57a23d249 for .NET Framework) | Windows-10.0.17763 | AppVeyor |
|
||||
| Visual Studio 17 2022 MSVC 19.30.30709.0 (Build Engine version 17.0.31804.368 for .NET Framework) | Windows-10.0.20348 | GitHub Actions |
|
||||
|
||||
|
||||
## Integration
|
||||
@ -1183,29 +1185,20 @@ target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json)
|
||||
|
||||
Since CMake v3.11,
|
||||
[FetchContent](https://cmake.org/cmake/help/v3.11/module/FetchContent.html) can
|
||||
be used to automatically download the repository as a dependency at configure time.
|
||||
be used to automatically download a release as a dependency at configure time.
|
||||
|
||||
Example:
|
||||
```cmake
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(json
|
||||
GIT_REPOSITORY https://github.com/nlohmann/json.git
|
||||
GIT_TAG v3.7.3)
|
||||
|
||||
FetchContent_GetProperties(json)
|
||||
if(NOT json_POPULATED)
|
||||
FetchContent_Populate(json)
|
||||
add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.10.5/json.tar.xz)
|
||||
FetchContent_MakeAvailable(json)
|
||||
|
||||
target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json)
|
||||
```
|
||||
|
||||
**Note**: The repository https://github.com/nlohmann/json download size is huge.
|
||||
It contains all the dataset used for the benchmarks. You might want to depend on
|
||||
a smaller repository. For instance, you might want to replace the URL above by
|
||||
https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent
|
||||
**Note**: It is recommended to use the URL approach described above which is supported as of version 3.10.0. See
|
||||
<https://json.nlohmann.me/integration/cmake/#fetchcontent> for more information.
|
||||
|
||||
#### Supporting Both
|
||||
|
||||
@ -1304,7 +1297,7 @@ json = dependency('nlohmann_json', required: true)
|
||||
|
||||
The class is licensed under the [MIT License](https://opensource.org/licenses/MIT):
|
||||
|
||||
Copyright © 2013-2021 [Niels Lohmann](https://nlohmann.me)
|
||||
Copyright © 2013-2022 [Niels Lohmann](https://nlohmann.me)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
@ -1336,7 +1329,7 @@ Only if your request would contain confidential information, please [send me an
|
||||
|
||||
I deeply appreciate the help of the following people.
|
||||
|
||||
<img src="https://raw.githubusercontent.com/nlohmann/json/develop/doc/avatars.png" align="right">
|
||||
<img src="https://raw.githubusercontent.com/nlohmann/json/develop/docs/avatars.png" align="right">
|
||||
|
||||
- [Teemperor](https://github.com/Teemperor) implemented CMake support and lcov integration, realized escape and Unicode handling in the string parser, and fixed the JSON serialization.
|
||||
- [elliotgoodrich](https://github.com/elliotgoodrich) fixed an issue with double deletion in the iterator classes.
|
||||
@ -1598,6 +1591,13 @@ I deeply appreciate the help of the following people.
|
||||
- [Giovanni Cerretani](https://github.com/gcerretani) fixed `-Wunused` warnings on `JSON_DIAGNOSTICS`.
|
||||
- [Bogdan Popescu](https://github.com/Kapeli) hosts the [docset](https://github.com/Kapeli/Dash-User-Contributions/tree/master/docsets/JSON_for_Modern_C%2B%2B) for offline documentation viewers.
|
||||
- [Carl Smedstad](https://github.com/carlsmedstad) fixed an assertion error when using `JSON_DIAGNOSTICS`.
|
||||
- [miikka75](https://github.com/miikka75) provided an important fix to compile C++17 code with Clang 9.
|
||||
- [Maarten Becker](https://github.com/kernie) fixed a warning for shadowed variables.
|
||||
- [Cristi Vîjdea](https://github.com/axnsan12) fixed typos in the `operator[]` documentation.
|
||||
- [Alex Beregszaszi](https://github.com/axic) fixed spelling mistakes in comments.
|
||||
- [Dirk Stolle](https://github.com/striezel) fixed typos in documentation.
|
||||
- [Daniel Albuschat](https://github.com/daniel-kun) corrected the parameter name in the `parse` documentation.
|
||||
- [Prince Mendiratta](https://github.com/Prince-Mendiratta) fixed a link to the FAQ.
|
||||
|
||||
Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I forgot someone.
|
||||
|
||||
@ -1617,13 +1617,14 @@ The library itself consists of a single header file licensed under the MIT licen
|
||||
- [**Coverity Scan**](https://scan.coverity.com) for [static analysis](https://scan.coverity.com/projects/nlohmann-json)
|
||||
- [**cppcheck**](http://cppcheck.sourceforge.net) for static analysis
|
||||
- [**doctest**](https://github.com/onqtam/doctest) for the unit tests
|
||||
- [**Doxygen**](https://www.doxygen.nl/index.html) to generate [documentation](https://nlohmann.github.io/json/doxygen/index.html)
|
||||
- [**git-update-ghpages**](https://github.com/rstacruz/git-update-ghpages) to upload the documentation to gh-pages
|
||||
- [**GitHub Changelog Generator**](https://github.com/skywinder/github-changelog-generator) to generate the [ChangeLog](https://github.com/nlohmann/json/blob/develop/ChangeLog.md)
|
||||
- [**Google Benchmark**](https://github.com/google/benchmark) to implement the benchmarks
|
||||
- [**Hedley**](https://nemequ.github.io/hedley/) to avoid re-inventing several compiler-agnostic feature macros
|
||||
- [**lcov**](http://ltp.sourceforge.net/coverage/lcov.php) to process coverage information and create an HTML view
|
||||
- [**libFuzzer**](https://llvm.org/docs/LibFuzzer.html) to implement fuzz testing for OSS-Fuzz
|
||||
- [**Material for MkDocs**](https://squidfunk.github.io/mkdocs-material/) for the style of the documentation site
|
||||
- [**MkDocs**](https://www.mkdocs.org) for the documentation site
|
||||
- [**OSS-Fuzz**](https://github.com/google/oss-fuzz) for continuous fuzz testing of the library ([project repository](https://github.com/google/oss-fuzz/tree/master/projects/json))
|
||||
- [**Probot**](https://probot.github.io) for automating maintainer tasks such as closing stale issues, requesting missing information, or detecting toxic comments.
|
||||
- [**Valgrind**](https://valgrind.org) to check for correct memory management
|
||||
@ -1646,7 +1647,7 @@ The library supports **Unicode input** as follows:
|
||||
- [Unicode noncharacters](https://www.unicode.org/faq/private_use.html#nonchar1) will not be replaced by the library.
|
||||
- Invalid surrogates (e.g., incomplete pairs such as `\uDEAD`) will yield parse errors.
|
||||
- The strings stored in the library are UTF-8 encoded. When using the default string type (`std::string`), note that its length/size functions return the number of stored bytes rather than the number of characters or glyphs.
|
||||
- When you store strings with different encodings in the library, calling [`dump()`](https://nlohmann.github.io/json/api/basic_json/dump/) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers.
|
||||
- When you store strings with different encodings in the library, calling [`dump()`](https://json.nlohmann.me/api/basic_json/dump/) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers.
|
||||
- To store wide strings (e.g., `std::wstring`), you need to convert them to a UTF-8 encoded `std::string` before, see [an example](https://json.nlohmann.me/home/faq/#wide-string-handling).
|
||||
|
||||
### Comments in JSON
|
||||
@ -1681,7 +1682,7 @@ Here is a related issue [#1924](https://github.com/nlohmann/json/issues/1924).
|
||||
|
||||
### Further notes
|
||||
|
||||
- The code contains numerous debug **assertions** which can be switched off by defining the preprocessor macro `NDEBUG`, see the [documentation of `assert`](https://en.cppreference.com/w/cpp/error/assert). In particular, note [`operator[]`](https://nlohmann.github.io/json/api/basic_json/operator%5B%5D/) implements **unchecked access** for const objects: If the given key is not present, the behavior is undefined (think of a dereferenced null pointer) and yields an [assertion failure](https://github.com/nlohmann/json/issues/289) if assertions are switched on. If you are not sure whether an element in an object exists, use checked access with the [`at()` function](https://nlohmann.github.io/json/api/basic_json/at/). Furthermore, you can define `JSON_ASSERT(x)` to replace calls to `assert(x)`.
|
||||
- The code contains numerous debug **assertions** which can be switched off by defining the preprocessor macro `NDEBUG`, see the [documentation of `assert`](https://en.cppreference.com/w/cpp/error/assert). In particular, note [`operator[]`](https://json.nlohmann.me/api/basic_json/operator%5B%5D/) implements **unchecked access** for const objects: If the given key is not present, the behavior is undefined (think of a dereferenced null pointer) and yields an [assertion failure](https://github.com/nlohmann/json/issues/289) if assertions are switched on. If you are not sure whether an element in an object exists, use checked access with the [`at()` function](https://json.nlohmann.me/api/basic_json/at/). Furthermore, you can define `JSON_ASSERT(x)` to replace calls to `assert(x)`.
|
||||
- As the exact number type is not defined in the [JSON specification](https://tools.ietf.org/html/rfc8259.html), this library tries to choose the best fitting C++ number type automatically. As a result, the type `double` may be used to store numbers which may yield [**floating-point exceptions**](https://github.com/nlohmann/json/issues/181) in certain rare situations if floating-point exceptions have been unmasked in the calling code. These exceptions are not caused by the library and need to be fixed in the calling code, such as by re-masking the exceptions prior to calling library functions.
|
||||
- The code can be compiled without C++ **runtime type identification** features; that is, you can use the `-fno-rtti` compiler flag.
|
||||
- **Exceptions** are used widely within the library. They can, however, be switched off with either using the compiler flag `-fno-exceptions` or by defining the symbol `JSON_NOEXCEPTION`. In this case, exceptions are replaced by `abort()` calls. You can further control this behavior by defining `JSON_THROW_USER` (overriding `throw`), `JSON_TRY_USER` (overriding `try`), and `JSON_CATCH_USER` (overriding `catch`). Note that `JSON_THROW_USER` should leave the current scope (e.g., by throwing or aborting), as continuing after it may yield undefined behavior. Note the explanatory [`what()`](https://en.cppreference.com/w/cpp/error/exception/what) string of exceptions is not available for MSVC if exceptions are disabled, see [#2824](https://github.com/nlohmann/json/discussions/2824).
|
||||
|
722
cmake/ci.cmake
@ -13,12 +13,12 @@ execute_process(COMMAND ${ASTYLE_TOOL} --version OUTPUT_VARIABLE ASTYLE_TOOL_VER
|
||||
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" ASTYLE_TOOL_VERSION "${ASTYLE_TOOL_VERSION}")
|
||||
message(STATUS "🔖 Artistic Style ${ASTYLE_TOOL_VERSION} (${ASTYLE_TOOL})")
|
||||
|
||||
find_program(CLANG_TOOL NAMES clang++-HEAD clang++-14 clang++-13 clang++-12 clang++-11 clang++)
|
||||
find_program(CLANG_TOOL NAMES clang++-HEAD clang++-15 clang++-14 clang++-13 clang++-12 clang++-11 clang++)
|
||||
execute_process(COMMAND ${CLANG_TOOL} --version OUTPUT_VARIABLE CLANG_TOOL_VERSION ERROR_VARIABLE CLANG_TOOL_VERSION)
|
||||
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CLANG_TOOL_VERSION "${CLANG_TOOL_VERSION}")
|
||||
message(STATUS "🔖 Clang ${CLANG_TOOL_VERSION} (${CLANG_TOOL})")
|
||||
|
||||
find_program(CLANG_TIDY_TOOL NAMES clang-tidy-14 clang-tidy-13 clang-tidy-12 clang-tidy-11 clang-tidy)
|
||||
find_program(CLANG_TIDY_TOOL NAMES clang-tidy-15 clang-tidy-14 clang-tidy-13 clang-tidy-12 clang-tidy-11 clang-tidy)
|
||||
execute_process(COMMAND ${CLANG_TIDY_TOOL} --version OUTPUT_VARIABLE CLANG_TIDY_TOOL_VERSION ERROR_VARIABLE CLANG_TIDY_TOOL_VERSION)
|
||||
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CLANG_TIDY_TOOL_VERSION "${CLANG_TIDY_TOOL_VERSION}")
|
||||
message(STATUS "🔖 Clang-Tidy ${CLANG_TIDY_TOOL_VERSION} (${CLANG_TIDY_TOOL})")
|
||||
@ -30,7 +30,7 @@ execute_process(COMMAND ${CPPCHECK_TOOL} --version OUTPUT_VARIABLE CPPCHECK_TOOL
|
||||
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CPPCHECK_TOOL_VERSION "${CPPCHECK_TOOL_VERSION}")
|
||||
message(STATUS "🔖 Cppcheck ${CPPCHECK_TOOL_VERSION} (${CPPCHECK_TOOL})")
|
||||
|
||||
find_program(GCC_TOOL NAMES g++-HEAD g++-11 g++-latest)
|
||||
find_program(GCC_TOOL NAMES g++-latest g++-HEAD g++-11)
|
||||
execute_process(COMMAND ${GCC_TOOL} --version OUTPUT_VARIABLE GCC_TOOL_VERSION ERROR_VARIABLE GCC_TOOL_VERSION)
|
||||
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" GCC_TOOL_VERSION "${GCC_TOOL_VERSION}")
|
||||
message(STATUS "🔖 GCC ${GCC_TOOL_VERSION} (${GCC_TOOL})")
|
||||
@ -79,7 +79,7 @@ message(STATUS "🔖 Valgrind ${VALGRIND_TOOL_VERSION} (${VALGRIND_TOOL})")
|
||||
find_program(GENHTML_TOOL NAMES genhtml)
|
||||
find_program(PLOG_CONVERTER_TOOL NAMES plog-converter)
|
||||
find_program(PVS_STUDIO_ANALYZER_TOOL NAMES pvs-studio-analyzer)
|
||||
find_program(SCAN_BUILD_TOOL NAMES scan-build-14 scan-build-13 scan-build-12 scan-build-11 scan-build)
|
||||
find_program(SCAN_BUILD_TOOL NAMES scan-build-15 scan-build-14 scan-build-13 scan-build-12 scan-build-11 scan-build)
|
||||
|
||||
# the individual source files
|
||||
file(GLOB_RECURSE SRC_FILES ${PROJECT_SOURCE_DIR}/include/nlohmann/*.hpp)
|
||||
@ -98,19 +98,20 @@ file(GLOB_RECURSE SRC_FILES ${PROJECT_SOURCE_DIR}/include/nlohmann/*.hpp)
|
||||
# -Wno-weak-vtables The library is header-only.
|
||||
# -Wreserved-identifier See https://github.com/onqtam/doctest/issues/536.
|
||||
|
||||
set(CLANG_CXXFLAGS "-std=c++11 \
|
||||
-Werror \
|
||||
-Weverything \
|
||||
-Wno-c++98-compat \
|
||||
-Wno-c++98-compat-pedantic \
|
||||
-Wno-deprecated-declarations \
|
||||
-Wno-extra-semi-stmt \
|
||||
-Wno-padded \
|
||||
-Wno-covered-switch-default \
|
||||
-Wno-weak-vtables \
|
||||
-Wno-reserved-identifier \
|
||||
")
|
||||
set(CLANG_CXXFLAGS
|
||||
-Werror
|
||||
-Weverything
|
||||
-Wno-c++98-compat
|
||||
-Wno-c++98-compat-pedantic
|
||||
-Wno-deprecated-declarations
|
||||
-Wno-extra-semi-stmt
|
||||
-Wno-padded
|
||||
-Wno-covered-switch-default
|
||||
-Wno-weak-vtables
|
||||
-Wno-reserved-identifier
|
||||
)
|
||||
|
||||
# Warning flags determined for GCC 12.0 (experimental) with https://github.com/nlohmann/gcc_flags:
|
||||
# Ignored GCC warnings:
|
||||
# -Wno-abi-tag We do not care about ABI tags.
|
||||
# -Wno-aggregate-return The library uses aggregate returns.
|
||||
@ -120,283 +121,295 @@ set(CLANG_CXXFLAGS "-std=c++11 \
|
||||
# -Wno-system-headers We do not care about warnings in system headers.
|
||||
# -Wno-templates The library uses templates.
|
||||
|
||||
set(GCC_CXXFLAGS "-std=c++11 \
|
||||
-pedantic \
|
||||
-Werror \
|
||||
--all-warnings \
|
||||
--extra-warnings \
|
||||
-W \
|
||||
-WNSObject-attribute \
|
||||
-Wno-abi-tag \
|
||||
-Waddress \
|
||||
-Waddress-of-packed-member \
|
||||
-Wno-aggregate-return \
|
||||
-Waggressive-loop-optimizations \
|
||||
-Waligned-new=all \
|
||||
-Wall \
|
||||
-Walloc-zero \
|
||||
-Walloca \
|
||||
-Wanalyzer-double-fclose \
|
||||
-Wanalyzer-double-free \
|
||||
-Wanalyzer-exposure-through-output-file \
|
||||
-Wanalyzer-file-leak \
|
||||
-Wanalyzer-free-of-non-heap \
|
||||
-Wanalyzer-malloc-leak \
|
||||
-Wanalyzer-mismatching-deallocation \
|
||||
-Wanalyzer-null-argument \
|
||||
-Wanalyzer-null-dereference \
|
||||
-Wanalyzer-possible-null-argument \
|
||||
-Wanalyzer-possible-null-dereference \
|
||||
-Wanalyzer-shift-count-negative \
|
||||
-Wanalyzer-shift-count-overflow \
|
||||
-Wanalyzer-stale-setjmp-buffer \
|
||||
-Wanalyzer-tainted-array-index \
|
||||
-Wanalyzer-too-complex \
|
||||
-Wanalyzer-unsafe-call-within-signal-handler \
|
||||
-Wanalyzer-use-after-free \
|
||||
-Wanalyzer-use-of-pointer-in-stale-stack-frame \
|
||||
-Wanalyzer-write-to-const \
|
||||
-Wanalyzer-write-to-string-literal \
|
||||
-Warith-conversion \
|
||||
-Warray-bounds \
|
||||
-Warray-bounds=2 \
|
||||
-Warray-parameter=2 \
|
||||
-Wattribute-alias=2 \
|
||||
-Wattribute-warning \
|
||||
-Wattributes \
|
||||
-Wbool-compare \
|
||||
-Wbool-operation \
|
||||
-Wbuiltin-declaration-mismatch \
|
||||
-Wbuiltin-macro-redefined \
|
||||
-Wc++0x-compat \
|
||||
-Wc++11-compat \
|
||||
-Wc++14-compat \
|
||||
-Wc++17-compat \
|
||||
-Wc++1z-compat \
|
||||
-Wc++20-compat \
|
||||
-Wc++2a-compat \
|
||||
-Wcannot-profile \
|
||||
-Wcast-align \
|
||||
-Wcast-align=strict \
|
||||
-Wcast-function-type \
|
||||
-Wcast-qual \
|
||||
-Wcatch-value=3 \
|
||||
-Wchar-subscripts \
|
||||
-Wclass-conversion \
|
||||
-Wclass-memaccess \
|
||||
-Wclobbered \
|
||||
-Wcomma-subscript \
|
||||
-Wcomment \
|
||||
-Wcomments \
|
||||
-Wconditionally-supported \
|
||||
-Wconversion \
|
||||
-Wconversion-null \
|
||||
-Wcoverage-mismatch \
|
||||
-Wcpp \
|
||||
-Wctad-maybe-unsupported \
|
||||
-Wctor-dtor-privacy \
|
||||
-Wdangling-else \
|
||||
-Wdate-time \
|
||||
-Wdelete-incomplete \
|
||||
-Wdelete-non-virtual-dtor \
|
||||
-Wdeprecated \
|
||||
-Wdeprecated-copy \
|
||||
-Wdeprecated-copy-dtor \
|
||||
-Wdeprecated-declarations \
|
||||
-Wdeprecated-enum-enum-conversion \
|
||||
-Wdeprecated-enum-float-conversion \
|
||||
-Wdisabled-optimization \
|
||||
-Wdiv-by-zero \
|
||||
-Wdouble-promotion \
|
||||
-Wduplicated-branches \
|
||||
-Wduplicated-cond \
|
||||
-Weffc++ \
|
||||
-Wempty-body \
|
||||
-Wendif-labels \
|
||||
-Wenum-compare \
|
||||
-Wenum-conversion \
|
||||
-Wexpansion-to-defined \
|
||||
-Wextra \
|
||||
-Wextra-semi \
|
||||
-Wfloat-conversion \
|
||||
-Wfloat-equal \
|
||||
-Wformat-contains-nul \
|
||||
-Wformat-diag \
|
||||
-Wformat-extra-args \
|
||||
-Wformat-nonliteral \
|
||||
-Wformat-overflow=2 \
|
||||
-Wformat-security \
|
||||
-Wformat-signedness \
|
||||
-Wformat-truncation=2 \
|
||||
-Wformat-y2k \
|
||||
-Wformat-zero-length \
|
||||
-Wformat=2 \
|
||||
-Wframe-address \
|
||||
-Wfree-nonheap-object \
|
||||
-Whsa \
|
||||
-Wif-not-aligned \
|
||||
-Wignored-attributes \
|
||||
-Wignored-qualifiers \
|
||||
-Wimplicit-fallthrough=5 \
|
||||
-Winaccessible-base \
|
||||
-Winherited-variadic-ctor \
|
||||
-Winit-list-lifetime \
|
||||
-Winit-self \
|
||||
-Winline \
|
||||
-Wint-in-bool-context \
|
||||
-Wint-to-pointer-cast \
|
||||
-Winvalid-memory-model \
|
||||
-Winvalid-offsetof \
|
||||
-Winvalid-pch \
|
||||
-Wliteral-suffix \
|
||||
-Wlogical-not-parentheses \
|
||||
-Wlogical-op \
|
||||
-Wno-long-long \
|
||||
-Wlto-type-mismatch \
|
||||
-Wmain \
|
||||
-Wmaybe-uninitialized \
|
||||
-Wmemset-elt-size \
|
||||
-Wmemset-transposed-args \
|
||||
-Wmisleading-indentation \
|
||||
-Wmismatched-dealloc \
|
||||
-Wmismatched-new-delete \
|
||||
-Wmismatched-tags \
|
||||
-Wmissing-attributes \
|
||||
-Wmissing-braces \
|
||||
-Wmissing-declarations \
|
||||
-Wmissing-field-initializers \
|
||||
-Wmissing-include-dirs \
|
||||
-Wmissing-profile \
|
||||
-Wmultichar \
|
||||
-Wmultiple-inheritance \
|
||||
-Wmultistatement-macros \
|
||||
-Wno-namespaces \
|
||||
-Wnarrowing \
|
||||
-Wnoexcept \
|
||||
-Wnoexcept-type \
|
||||
-Wnon-template-friend \
|
||||
-Wnon-virtual-dtor \
|
||||
-Wnonnull \
|
||||
-Wnonnull-compare \
|
||||
-Wnormalized=nfkc \
|
||||
-Wnull-dereference \
|
||||
-Wodr \
|
||||
-Wold-style-cast \
|
||||
-Wopenmp-simd \
|
||||
-Woverflow \
|
||||
-Woverlength-strings \
|
||||
-Woverloaded-virtual \
|
||||
-Wpacked \
|
||||
-Wpacked-bitfield-compat \
|
||||
-Wpacked-not-aligned \
|
||||
-Wno-padded \
|
||||
-Wparentheses \
|
||||
-Wpedantic \
|
||||
-Wpessimizing-move \
|
||||
-Wplacement-new=2 \
|
||||
-Wpmf-conversions \
|
||||
-Wpointer-arith \
|
||||
-Wpointer-compare \
|
||||
-Wpragmas \
|
||||
-Wprio-ctor-dtor \
|
||||
-Wpsabi \
|
||||
-Wrange-loop-construct \
|
||||
-Wredundant-decls \
|
||||
-Wredundant-move \
|
||||
-Wredundant-tags \
|
||||
-Wregister \
|
||||
-Wreorder \
|
||||
-Wrestrict \
|
||||
-Wreturn-local-addr \
|
||||
-Wreturn-type \
|
||||
-Wscalar-storage-order \
|
||||
-Wsequence-point \
|
||||
-Wshadow=compatible-local \
|
||||
-Wshadow=global \
|
||||
-Wshadow=local \
|
||||
-Wshift-count-negative \
|
||||
-Wshift-count-overflow \
|
||||
-Wshift-negative-value \
|
||||
-Wshift-overflow=2 \
|
||||
-Wsign-compare \
|
||||
-Wsign-conversion \
|
||||
-Wsign-promo \
|
||||
-Wsized-deallocation \
|
||||
-Wsizeof-array-argument \
|
||||
-Wsizeof-array-div \
|
||||
-Wsizeof-pointer-div \
|
||||
-Wsizeof-pointer-memaccess \
|
||||
-Wstack-protector \
|
||||
-Wstrict-aliasing \
|
||||
-Wstrict-aliasing=3 \
|
||||
-Wstrict-null-sentinel \
|
||||
-Wstrict-overflow \
|
||||
-Wstrict-overflow=5 \
|
||||
-Wstring-compare \
|
||||
-Wstringop-overflow=4 \
|
||||
-Wstringop-overread \
|
||||
-Wstringop-truncation \
|
||||
-Wsubobject-linkage \
|
||||
-Wsuggest-attribute=cold \
|
||||
-Wsuggest-attribute=const \
|
||||
-Wsuggest-attribute=format \
|
||||
-Wsuggest-attribute=malloc \
|
||||
-Wsuggest-attribute=noreturn \
|
||||
-Wsuggest-attribute=pure \
|
||||
-Wsuggest-final-methods \
|
||||
-Wsuggest-final-types \
|
||||
-Wsuggest-override \
|
||||
-Wswitch \
|
||||
-Wswitch-bool \
|
||||
-Wswitch-default \
|
||||
-Wswitch-enum \
|
||||
-Wswitch-outside-range \
|
||||
-Wswitch-unreachable \
|
||||
-Wsync-nand \
|
||||
-Wsynth \
|
||||
-Wno-system-headers \
|
||||
-Wtautological-compare \
|
||||
-Wno-templates \
|
||||
-Wterminate \
|
||||
-Wtrampolines \
|
||||
-Wtrigraphs \
|
||||
-Wtsan \
|
||||
-Wtype-limits \
|
||||
-Wundef \
|
||||
-Wuninitialized \
|
||||
-Wunknown-pragmas \
|
||||
-Wunreachable-code \
|
||||
-Wunsafe-loop-optimizations \
|
||||
-Wunused \
|
||||
-Wunused-but-set-parameter \
|
||||
-Wunused-but-set-variable \
|
||||
-Wunused-const-variable=2 \
|
||||
-Wunused-function \
|
||||
-Wunused-label \
|
||||
-Wunused-local-typedefs \
|
||||
-Wunused-macros \
|
||||
-Wunused-parameter \
|
||||
-Wunused-result \
|
||||
-Wunused-value \
|
||||
-Wunused-variable \
|
||||
-Wuseless-cast \
|
||||
-Wvarargs \
|
||||
-Wvariadic-macros \
|
||||
-Wvector-operation-performance \
|
||||
-Wvexing-parse \
|
||||
-Wvirtual-inheritance \
|
||||
-Wvirtual-move-assign \
|
||||
-Wvla \
|
||||
-Wvla-parameter \
|
||||
-Wvolatile \
|
||||
-Wvolatile-register-var \
|
||||
-Wwrite-strings \
|
||||
-Wzero-as-null-pointer-constant \
|
||||
-Wzero-length-bounds \
|
||||
")
|
||||
set(GCC_CXXFLAGS
|
||||
-pedantic
|
||||
-Werror
|
||||
--all-warnings
|
||||
--extra-warnings
|
||||
-W
|
||||
-WNSObject-attribute
|
||||
-Wno-abi-tag
|
||||
-Waddress
|
||||
-Waddress-of-packed-member
|
||||
-Wno-aggregate-return
|
||||
-Waggressive-loop-optimizations
|
||||
-Waligned-new=all
|
||||
-Wall
|
||||
-Walloc-zero
|
||||
-Walloca
|
||||
-Wanalyzer-double-fclose
|
||||
-Wanalyzer-double-free
|
||||
-Wanalyzer-exposure-through-output-file
|
||||
-Wanalyzer-file-leak
|
||||
-Wanalyzer-free-of-non-heap
|
||||
-Wanalyzer-malloc-leak
|
||||
-Wanalyzer-mismatching-deallocation
|
||||
-Wanalyzer-null-argument
|
||||
-Wanalyzer-null-dereference
|
||||
-Wanalyzer-possible-null-argument
|
||||
-Wanalyzer-possible-null-dereference
|
||||
-Wanalyzer-shift-count-negative
|
||||
-Wanalyzer-shift-count-overflow
|
||||
-Wanalyzer-stale-setjmp-buffer
|
||||
-Wanalyzer-tainted-allocation-size
|
||||
-Wanalyzer-tainted-array-index
|
||||
-Wanalyzer-tainted-divisor
|
||||
-Wanalyzer-tainted-offset
|
||||
-Wanalyzer-tainted-size
|
||||
-Wanalyzer-too-complex
|
||||
-Wanalyzer-unsafe-call-within-signal-handler
|
||||
-Wanalyzer-use-after-free
|
||||
-Wanalyzer-use-of-pointer-in-stale-stack-frame
|
||||
-Wanalyzer-use-of-uninitialized-value
|
||||
-Wanalyzer-write-to-const
|
||||
-Wanalyzer-write-to-string-literal
|
||||
-Warith-conversion
|
||||
-Warray-bounds
|
||||
-Warray-bounds=2
|
||||
-Warray-compare
|
||||
-Warray-parameter=2
|
||||
-Wattribute-alias=2
|
||||
-Wattribute-warning
|
||||
-Wattributes
|
||||
-Wbool-compare
|
||||
-Wbool-operation
|
||||
-Wbuiltin-declaration-mismatch
|
||||
-Wbuiltin-macro-redefined
|
||||
-Wc++0x-compat
|
||||
-Wc++11-compat
|
||||
-Wc++11-extensions
|
||||
-Wc++14-compat
|
||||
-Wc++14-extensions
|
||||
-Wc++17-compat
|
||||
-Wc++17-extensions
|
||||
-Wc++1z-compat
|
||||
-Wc++20-compat
|
||||
-Wc++20-extensions
|
||||
-Wc++23-extensions
|
||||
-Wc++2a-compat
|
||||
-Wcannot-profile
|
||||
-Wcast-align
|
||||
-Wcast-align=strict
|
||||
-Wcast-function-type
|
||||
-Wcast-qual
|
||||
-Wcatch-value=3
|
||||
-Wchar-subscripts
|
||||
-Wclass-conversion
|
||||
-Wclass-memaccess
|
||||
-Wclobbered
|
||||
-Wcomma-subscript
|
||||
-Wcomment
|
||||
-Wcomments
|
||||
-Wconditionally-supported
|
||||
-Wconversion
|
||||
-Wconversion-null
|
||||
-Wcoverage-invalid-line-number
|
||||
-Wcoverage-mismatch
|
||||
-Wcpp
|
||||
-Wctad-maybe-unsupported
|
||||
-Wctor-dtor-privacy
|
||||
-Wdangling-else
|
||||
-Wdate-time
|
||||
-Wdelete-incomplete
|
||||
-Wdelete-non-virtual-dtor
|
||||
-Wdeprecated
|
||||
-Wdeprecated-copy
|
||||
-Wdeprecated-copy-dtor
|
||||
-Wdeprecated-declarations
|
||||
-Wdeprecated-enum-enum-conversion
|
||||
-Wdeprecated-enum-float-conversion
|
||||
-Wdisabled-optimization
|
||||
-Wdiv-by-zero
|
||||
-Wdouble-promotion
|
||||
-Wduplicated-branches
|
||||
-Wduplicated-cond
|
||||
-Weffc++
|
||||
-Wempty-body
|
||||
-Wendif-labels
|
||||
-Wenum-compare
|
||||
-Wenum-conversion
|
||||
-Wexceptions
|
||||
-Wexpansion-to-defined
|
||||
-Wextra
|
||||
-Wextra-semi
|
||||
-Wfloat-conversion
|
||||
-Wfloat-equal
|
||||
-Wformat-diag
|
||||
-Wformat-overflow=2
|
||||
-Wformat-signedness
|
||||
-Wformat-truncation=2
|
||||
-Wformat=2
|
||||
-Wframe-address
|
||||
-Wfree-nonheap-object
|
||||
-Whsa
|
||||
-Wif-not-aligned
|
||||
-Wignored-attributes
|
||||
-Wignored-qualifiers
|
||||
-Wimplicit-fallthrough=5
|
||||
-Winaccessible-base
|
||||
-Winfinite-recursion
|
||||
-Winherited-variadic-ctor
|
||||
-Winit-list-lifetime
|
||||
-Winit-self
|
||||
-Winline
|
||||
-Wint-in-bool-context
|
||||
-Wint-to-pointer-cast
|
||||
-Winterference-size
|
||||
-Winvalid-imported-macros
|
||||
-Winvalid-memory-model
|
||||
-Winvalid-offsetof
|
||||
-Winvalid-pch
|
||||
-Wliteral-suffix
|
||||
-Wlogical-not-parentheses
|
||||
-Wlogical-op
|
||||
-Wno-long-long
|
||||
-Wlto-type-mismatch
|
||||
-Wmain
|
||||
-Wmaybe-uninitialized
|
||||
-Wmemset-elt-size
|
||||
-Wmemset-transposed-args
|
||||
-Wmisleading-indentation
|
||||
-Wmismatched-dealloc
|
||||
-Wmismatched-new-delete
|
||||
-Wmismatched-tags
|
||||
-Wmissing-attributes
|
||||
-Wmissing-braces
|
||||
-Wmissing-declarations
|
||||
-Wmissing-field-initializers
|
||||
-Wmissing-include-dirs
|
||||
-Wmissing-profile
|
||||
-Wmissing-requires
|
||||
-Wmultichar
|
||||
-Wmultiple-inheritance
|
||||
-Wmultistatement-macros
|
||||
-Wno-namespaces
|
||||
-Wnarrowing
|
||||
-Wnoexcept
|
||||
-Wnoexcept-type
|
||||
-Wnon-template-friend
|
||||
-Wnon-virtual-dtor
|
||||
-Wnonnull
|
||||
-Wnonnull-compare
|
||||
-Wnormalized=nfkc
|
||||
-Wnull-dereference
|
||||
-Wodr
|
||||
-Wold-style-cast
|
||||
-Wopenacc-parallelism
|
||||
-Wopenmp-simd
|
||||
-Woverflow
|
||||
-Woverlength-strings
|
||||
-Woverloaded-virtual
|
||||
-Wpacked
|
||||
-Wpacked-bitfield-compat
|
||||
-Wpacked-not-aligned
|
||||
-Wno-padded
|
||||
-Wparentheses
|
||||
-Wpedantic
|
||||
-Wpessimizing-move
|
||||
-Wplacement-new=2
|
||||
-Wpmf-conversions
|
||||
-Wpointer-arith
|
||||
-Wpointer-compare
|
||||
-Wpragmas
|
||||
-Wprio-ctor-dtor
|
||||
-Wpsabi
|
||||
-Wrange-loop-construct
|
||||
-Wredundant-decls
|
||||
-Wredundant-move
|
||||
-Wredundant-tags
|
||||
-Wregister
|
||||
-Wreorder
|
||||
-Wrestrict
|
||||
-Wreturn-local-addr
|
||||
-Wreturn-type
|
||||
-Wscalar-storage-order
|
||||
-Wsequence-point
|
||||
-Wshadow=compatible-local
|
||||
-Wshadow=global
|
||||
-Wshadow=local
|
||||
-Wshift-count-negative
|
||||
-Wshift-count-overflow
|
||||
-Wshift-negative-value
|
||||
-Wshift-overflow=2
|
||||
-Wsign-compare
|
||||
-Wsign-conversion
|
||||
-Wsign-promo
|
||||
-Wsized-deallocation
|
||||
-Wsizeof-array-argument
|
||||
-Wsizeof-array-div
|
||||
-Wsizeof-pointer-div
|
||||
-Wsizeof-pointer-memaccess
|
||||
-Wstack-protector
|
||||
-Wstrict-aliasing
|
||||
-Wstrict-aliasing=3
|
||||
-Wstrict-null-sentinel
|
||||
-Wstrict-overflow
|
||||
-Wstrict-overflow=5
|
||||
-Wstring-compare
|
||||
-Wstringop-overflow=4
|
||||
-Wstringop-overread
|
||||
-Wstringop-truncation
|
||||
-Wsubobject-linkage
|
||||
-Wsuggest-attribute=cold
|
||||
-Wsuggest-attribute=const
|
||||
-Wsuggest-attribute=format
|
||||
-Wsuggest-attribute=malloc
|
||||
-Wsuggest-attribute=noreturn
|
||||
-Wsuggest-attribute=pure
|
||||
-Wsuggest-final-methods
|
||||
-Wsuggest-final-types
|
||||
-Wsuggest-override
|
||||
-Wswitch
|
||||
-Wswitch-bool
|
||||
-Wswitch-default
|
||||
-Wswitch-enum
|
||||
-Wswitch-outside-range
|
||||
-Wswitch-unreachable
|
||||
-Wsync-nand
|
||||
-Wsynth
|
||||
-Wno-system-headers
|
||||
-Wtautological-compare
|
||||
-Wno-templates
|
||||
-Wterminate
|
||||
-Wtrampolines
|
||||
-Wtrigraphs
|
||||
-Wtsan
|
||||
-Wtype-limits
|
||||
-Wundef
|
||||
-Wuninitialized
|
||||
-Wunknown-pragmas
|
||||
-Wunreachable-code
|
||||
-Wunsafe-loop-optimizations
|
||||
-Wunused
|
||||
-Wunused-but-set-parameter
|
||||
-Wunused-but-set-variable
|
||||
-Wunused-const-variable=2
|
||||
-Wunused-function
|
||||
-Wunused-label
|
||||
-Wunused-local-typedefs
|
||||
-Wunused-macros
|
||||
-Wunused-parameter
|
||||
-Wunused-result
|
||||
-Wunused-value
|
||||
-Wunused-variable
|
||||
-Wuseless-cast
|
||||
-Wvarargs
|
||||
-Wvariadic-macros
|
||||
-Wvector-operation-performance
|
||||
-Wvexing-parse
|
||||
-Wvirtual-inheritance
|
||||
-Wvirtual-move-assign
|
||||
-Wvla
|
||||
-Wvla-parameter
|
||||
-Wvolatile
|
||||
-Wvolatile-register-var
|
||||
-Wwrite-strings
|
||||
-Wzero-as-null-pointer-constant
|
||||
-Wzero-length-bounds
|
||||
)
|
||||
|
||||
add_custom_target(ci_test_gcc
|
||||
COMMAND CXX=${GCC_TOOL} CXXFLAGS=${GCC_CXXFLAGS} ${CMAKE_COMMAND}
|
||||
COMMAND CXX=${GCC_TOOL} CXXFLAGS="${GCC_CXXFLAGS}" ${CMAKE_COMMAND}
|
||||
-DCMAKE_BUILD_TYPE=Debug -GNinja
|
||||
-DJSON_BuildTests=ON -DJSON_MultipleHeaders=ON
|
||||
-S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_gcc
|
||||
@ -406,7 +419,7 @@ add_custom_target(ci_test_gcc
|
||||
)
|
||||
|
||||
add_custom_target(ci_test_clang
|
||||
COMMAND CXX=${CLANG_TOOL} CXXFLAGS=${CLANG_CXXFLAGS} ${CMAKE_COMMAND}
|
||||
COMMAND CXX=${CLANG_TOOL} CXXFLAGS="${CLANG_CXXFLAGS}" ${CMAKE_COMMAND}
|
||||
-DCMAKE_BUILD_TYPE=Debug -GNinja
|
||||
-DJSON_BuildTests=ON -DJSON_MultipleHeaders=ON
|
||||
-S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_clang
|
||||
@ -421,10 +434,10 @@ add_custom_target(ci_test_clang
|
||||
|
||||
foreach(CXX_STANDARD 11 14 17 20)
|
||||
add_custom_target(ci_test_gcc_cxx${CXX_STANDARD}
|
||||
COMMAND CXX=${GCC_TOOL} ${CMAKE_COMMAND}
|
||||
COMMAND CXX=${GCC_TOOL} CXXFLAGS="${GCC_CXXFLAGS}" ${CMAKE_COMMAND}
|
||||
-DCMAKE_BUILD_TYPE=Debug -GNinja
|
||||
-DCMAKE_CXX_STANDARD=${CXX_STANDARD} -DCMAKE_CXX_STANDARD_REQUIRED=ON
|
||||
-DJSON_BuildTests=ON -DJSON_FastTests=ON
|
||||
-DJSON_TestStandards=${CXX_STANDARD}
|
||||
-S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_gcc_cxx${CXX_STANDARD}
|
||||
COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_gcc_cxx${CXX_STANDARD}
|
||||
COMMAND cd ${PROJECT_BINARY_DIR}/build_gcc_cxx${CXX_STANDARD} && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure
|
||||
@ -432,10 +445,10 @@ foreach(CXX_STANDARD 11 14 17 20)
|
||||
)
|
||||
|
||||
add_custom_target(ci_test_clang_cxx${CXX_STANDARD}
|
||||
COMMAND CXX=${CLANG_TOOL} ${CMAKE_COMMAND}
|
||||
COMMAND CXX=${CLANG_TOOL} CXXFLAGS="${CLANG_CXXFLAGS}" ${CMAKE_COMMAND}
|
||||
-DCMAKE_BUILD_TYPE=Debug -GNinja
|
||||
-DCMAKE_CXX_STANDARD=${CXX_STANDARD} -DCMAKE_CXX_STANDARD_REQUIRED=ON
|
||||
-DJSON_BuildTests=ON
|
||||
-DJSON_BuildTests=ON -DJSON_FastTests=ON
|
||||
-DJSON_TestStandards=${CXX_STANDARD}
|
||||
-S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_clang_cxx${CXX_STANDARD}
|
||||
COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_clang_cxx${CXX_STANDARD}
|
||||
COMMAND cd ${PROJECT_BINARY_DIR}/build_clang_cxx${CXX_STANDARD} && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure
|
||||
@ -499,7 +512,7 @@ add_custom_target(ci_test_coverage
|
||||
|
||||
COMMAND ${LCOV_TOOL} --directory . --capture --output-file json.info --rc lcov_branch_coverage=1
|
||||
COMMAND ${LCOV_TOOL} -e json.info ${SRC_FILES} --output-file json.info.filtered --rc lcov_branch_coverage=1
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/imapdl/filterbr.py json.info.filtered > json.info.filtered.noexcept
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/tests/thirdparty/imapdl/filterbr.py json.info.filtered > json.info.filtered.noexcept
|
||||
COMMAND genhtml --title "JSON for Modern C++" --legend --demangle-cpp --output-directory html --show-details --branch-coverage json.info.filtered.noexcept
|
||||
|
||||
COMMENT "Compile and test with coverage"
|
||||
@ -529,16 +542,16 @@ set(ASTYLE_FLAGS --style=allman --indent=spaces=4 --indent-modifiers --indent-sw
|
||||
|
||||
file(GLOB_RECURSE INDENT_FILES
|
||||
${PROJECT_SOURCE_DIR}/include/nlohmann/*.hpp
|
||||
${PROJECT_SOURCE_DIR}/test/src/*.cpp
|
||||
${PROJECT_SOURCE_DIR}/test/src/*.hpp
|
||||
${PROJECT_SOURCE_DIR}/benchmarks/src/benchmarks.cpp
|
||||
${PROJECT_SOURCE_DIR}/doc/examples/*.cpp
|
||||
${PROJECT_SOURCE_DIR}/tests/src/*.cpp
|
||||
${PROJECT_SOURCE_DIR}/tests/src/*.hpp
|
||||
${PROJECT_SOURCE_DIR}/tests/benchmarks/src/benchmarks.cpp
|
||||
${PROJECT_SOURCE_DIR}/docs/examples/*.cpp
|
||||
)
|
||||
|
||||
add_custom_target(ci_test_amalgamation
|
||||
COMMAND rm -fr ${PROJECT_SOURCE_DIR}/single_include/nlohmann/json.hpp~
|
||||
COMMAND cp ${PROJECT_SOURCE_DIR}/single_include/nlohmann/json.hpp ${PROJECT_SOURCE_DIR}/single_include/nlohmann/json.hpp~
|
||||
COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/third_party/amalgamate/amalgamate.py -c ${PROJECT_SOURCE_DIR}/third_party/amalgamate/config.json -s .
|
||||
COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/amalgamate/amalgamate.py -c ${PROJECT_SOURCE_DIR}/tools/amalgamate/config.json -s .
|
||||
COMMAND ${ASTYLE_TOOL} ${ASTYLE_FLAGS} --suffix=none --quiet ${PROJECT_SOURCE_DIR}/single_include/nlohmann/json.hpp
|
||||
COMMAND diff ${PROJECT_SOURCE_DIR}/single_include/nlohmann/json.hpp~ ${PROJECT_SOURCE_DIR}/single_include/nlohmann/json.hpp
|
||||
|
||||
@ -546,7 +559,7 @@ add_custom_target(ci_test_amalgamation
|
||||
COMMAND cd ${PROJECT_SOURCE_DIR} && for FILE in `find . -name '*.orig'`\; do false \; done
|
||||
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
COMMENT "Check amalagamation and indentation"
|
||||
COMMENT "Check amalgamation and indentation"
|
||||
)
|
||||
|
||||
###############################################################################
|
||||
@ -592,7 +605,7 @@ add_custom_target(ci_cppcheck
|
||||
###############################################################################
|
||||
|
||||
add_custom_target(ci_cpplint
|
||||
COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/third_party/cpplint/cpplint.py --filter=-whitespace,-legal,-runtime/references,-runtime/explicit,-runtime/indentation_namespace,-readability/casting,-readability/nolint --quiet --recursive ${SRC_FILES}
|
||||
COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/cpplint/cpplint.py --filter=-whitespace,-legal,-runtime/references,-runtime/explicit,-runtime/indentation_namespace,-readability/casting,-readability/nolint --quiet --recursive ${SRC_FILES}
|
||||
COMMENT "Check code with cpplint"
|
||||
)
|
||||
|
||||
@ -670,7 +683,7 @@ add_custom_target(ci_infer
|
||||
|
||||
add_custom_target(ci_offline_testdata
|
||||
COMMAND mkdir -p ${PROJECT_BINARY_DIR}/build_offline_testdata/test_data
|
||||
COMMAND cd ${PROJECT_BINARY_DIR}/build_offline_testdata/test_data && ${GIT_TOOL} clone -c advice.detachedHead=false --branch v3.0.0 https://github.com/nlohmann/json_test_data.git --quiet --depth 1
|
||||
COMMAND cd ${PROJECT_BINARY_DIR}/build_offline_testdata/test_data && ${GIT_TOOL} clone -c advice.detachedHead=false --branch v3.1.0 https://github.com/nlohmann/json_test_data.git --quiet --depth 1
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DCMAKE_BUILD_TYPE=Debug -GNinja
|
||||
-DJSON_BuildTests=ON -DJSON_FastTests=ON -DJSON_TestDataDirectory=${PROJECT_BINARY_DIR}/build_offline_testdata/test_data/json_test_data
|
||||
@ -756,50 +769,67 @@ add_custom_target(ci_benchmarks
|
||||
# CMake flags
|
||||
###############################################################################
|
||||
|
||||
if (APPLE)
|
||||
set(CMAKE_310_BINARY ${PROJECT_BINARY_DIR}/cmake-3.1.0-Darwin64/CMake.app/Contents/bin/cmake)
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_310_BINARY}
|
||||
COMMAND wget https://github.com/Kitware/CMake/releases/download/v3.1.0/cmake-3.1.0-Darwin64.tar.gz
|
||||
COMMAND tar xfz cmake-3.1.0-Darwin64.tar.gz
|
||||
COMMAND rm cmake-3.1.0-Darwin64.tar.gz
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
COMMENT "Download CMake 3.1.0"
|
||||
)
|
||||
else()
|
||||
set(CMAKE_310_BINARY ${PROJECT_BINARY_DIR}/cmake-3.1.0-Linux-x86_64/bin/cmake)
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_310_BINARY}
|
||||
COMMAND wget https://github.com/Kitware/CMake/releases/download/v3.1.0/cmake-3.1.0-Linux-x86_64.tar.gz
|
||||
COMMAND tar xfz cmake-3.1.0-Linux-x86_64.tar.gz
|
||||
COMMAND rm cmake-3.1.0-Linux-x86_64.tar.gz
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
COMMENT "Download CMake 3.1.0"
|
||||
)
|
||||
endif()
|
||||
function(ci_get_cmake version var)
|
||||
if (APPLE)
|
||||
set(${var} ${PROJECT_BINARY_DIR}/cmake-${version}-Darwin64/CMake.app/Contents/bin/cmake)
|
||||
add_custom_command(
|
||||
OUTPUT ${${var}}
|
||||
COMMAND wget -nc https://github.com/Kitware/CMake/releases/download/v${version}/cmake-${version}-Darwin64.tar.gz
|
||||
COMMAND tar xfz cmake-${version}-Darwin64.tar.gz
|
||||
COMMAND rm cmake-${version}-Darwin64.tar.gz
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
COMMENT "Download CMake ${version}"
|
||||
)
|
||||
else()
|
||||
set(${var} ${PROJECT_BINARY_DIR}/cmake-${version}-Linux-x86_64/bin/cmake)
|
||||
add_custom_command(
|
||||
OUTPUT ${${var}}
|
||||
COMMAND wget -nc https://github.com/Kitware/CMake/releases/download/v${version}/cmake-${version}-Linux-x86_64.tar.gz
|
||||
COMMAND tar xfz cmake-${version}-Linux-x86_64.tar.gz
|
||||
COMMAND rm cmake-${version}-Linux-x86_64.tar.gz
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
COMMENT "Download CMake ${version}"
|
||||
)
|
||||
endif()
|
||||
set(${var} ${${var}} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
set(JSON_CMAKE_FLAGS "JSON_BuildTests;JSON_Install;JSON_MultipleHeaders;JSON_ImplicitConversions;JSON_Valgrind;JSON_Diagnostics;JSON_SystemInclude")
|
||||
ci_get_cmake(3.1.0 CMAKE_3_1_0_BINARY)
|
||||
ci_get_cmake(3.13.0 CMAKE_3_13_0_BINARY)
|
||||
|
||||
foreach(JSON_CMAKE_FLAG ${JSON_CMAKE_FLAGS})
|
||||
string(TOLOWER "ci_cmake_flag_${JSON_CMAKE_FLAG}" JSON_CMAKE_FLAG_TARGET)
|
||||
add_custom_target("${JSON_CMAKE_FLAG_TARGET}"
|
||||
COMMENT "Check CMake flag ${JSON_CMAKE_FLAG} (CMake ${CMAKE_VERSION})"
|
||||
set(JSON_CMAKE_FLAGS_3_1_0 "JSON_Install;JSON_MultipleHeaders;JSON_ImplicitConversions;JSON_Valgrind;JSON_Diagnostics;JSON_SystemInclude")
|
||||
set(JSON_CMAKE_FLAGS_3_13_0 "JSON_BuildTests")
|
||||
|
||||
function(ci_add_cmake_flags_targets flag min_version)
|
||||
string(TOLOWER "ci_cmake_flag_${flag}" flag_target)
|
||||
string(REPLACE . _ min_version_var ${min_version})
|
||||
set(cmake_binary ${CMAKE_${min_version_var}_BINARY})
|
||||
add_custom_target(${flag_target}
|
||||
COMMENT "Check CMake flag ${flag} (CMake ${CMAKE_VERSION})"
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-Werror=dev
|
||||
-D${JSON_CMAKE_FLAG}=ON
|
||||
-S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_${JSON_CMAKE_FLAG_TARGET}
|
||||
-D${flag}=ON
|
||||
-S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_${flag_target}
|
||||
)
|
||||
add_custom_target("${JSON_CMAKE_FLAG_TARGET}_31"
|
||||
COMMENT "Check CMake flag ${JSON_CMAKE_FLAG} (CMake 3.1)"
|
||||
COMMAND mkdir ${PROJECT_BINARY_DIR}/build_${JSON_CMAKE_FLAG_TARGET}_31
|
||||
COMMAND cd ${PROJECT_BINARY_DIR}/build_${JSON_CMAKE_FLAG_TARGET}_31 && ${CMAKE_310_BINARY}
|
||||
-Werror=dev ${PROJECT_SOURCE_DIR}
|
||||
-D${JSON_CMAKE_FLAG}=ON
|
||||
-DCMAKE_CXX_COMPILE_FEATURES="cxx_range_for" -DCMAKE_CXX_FLAGS="-std=gnu++11"
|
||||
DEPENDS ${CMAKE_310_BINARY}
|
||||
add_custom_target(${flag_target}_${min_version_var}
|
||||
COMMENT "Check CMake flag ${JSON_CMAKE_FLAG} (CMake ${min_version})"
|
||||
COMMAND mkdir -pv ${PROJECT_BINARY_DIR}/build_${flag_target}_${min_version_var}
|
||||
COMMAND cd ${PROJECT_BINARY_DIR}/build_${flag_target}_${min_version_var}
|
||||
&& ${cmake_binary} -Werror=dev ${PROJECT_SOURCE_DIR} -D${flag}=ON
|
||||
DEPENDS ${cmake_binary}
|
||||
)
|
||||
list(APPEND JSON_CMAKE_FLAG_TARGETS ${JSON_CMAKE_FLAG_TARGET} ${JSON_CMAKE_FLAG_TARGET}_31)
|
||||
list(APPEND JSON_CMAKE_FLAG_BUILD_DIRS ${PROJECT_BINARY_DIR}/build_${JSON_CMAKE_FLAG_TARGET} ${PROJECT_BINARY_DIR}/build_${JSON_CMAKE_FLAG_TARGET}_31)
|
||||
list(APPEND JSON_CMAKE_FLAG_TARGETS ${JSON_CMAKE_FLAG_TARGET} ${flag_target}_${min_version_var})
|
||||
list(APPEND JSON_CMAKE_FLAG_BUILD_DIRS ${PROJECT_BINARY_DIR}/build_${flag_target} ${PROJECT_BINARY_DIR}/build_${flag_target}_${min_version_var})
|
||||
set(JSON_CMAKE_FLAG_TARGETS ${JSON_CMAKE_FLAG_TARGETS} PARENT_SCOPE)
|
||||
set(JSON_CMAKE_FLAG_BUILD_DIRS ${JSON_CMAKE_FLAG_BUILD_DIRS} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
foreach(JSON_CMAKE_FLAG ${JSON_CMAKE_FLAGS_3_1_0})
|
||||
ci_add_cmake_flags_targets(${JSON_CMAKE_FLAG} 3.1.0)
|
||||
endforeach()
|
||||
|
||||
foreach(JSON_CMAKE_FLAG ${JSON_CMAKE_FLAGS_3_13_0})
|
||||
ci_add_cmake_flags_targets(${JSON_CMAKE_FLAG} 3.13.0)
|
||||
endforeach()
|
||||
|
||||
add_custom_target(ci_cmake_flags
|
||||
@ -811,7 +841,7 @@ add_custom_target(ci_cmake_flags
|
||||
# Use more installed compilers.
|
||||
###############################################################################
|
||||
|
||||
foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-6 g++-7 g++-8 g++-9 g++-10 clang++-3.5 clang++-3.6 clang++-3.7 clang++-3.8 clang++-3.9 clang++-4.0 clang++-5.0 clang++-6.0 clang++-7 clang++-8 clang++-9 clang++-10 clang++-11 clang++-12 clang++-13)
|
||||
foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-6 g++-7 g++-8 g++-9 g++-10 clang++-3.5 clang++-3.6 clang++-3.7 clang++-3.8 clang++-3.9 clang++-4.0 clang++-5.0 clang++-6.0 clang++-7 clang++-8 clang++-9 clang++-10 clang++-11 clang++-12 clang++-13 clang++-14)
|
||||
find_program(COMPILER_TOOL NAMES ${COMPILER})
|
||||
if (COMPILER_TOOL)
|
||||
if ("${COMPILER}" STREQUAL "clang++-9")
|
||||
@ -843,7 +873,7 @@ add_custom_target(ci_cuda_example
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DCMAKE_BUILD_TYPE=Debug -GNinja
|
||||
-DCMAKE_CUDA_HOST_COMPILER=g++-8
|
||||
-S${PROJECT_SOURCE_DIR}/test/cuda_example -B${PROJECT_BINARY_DIR}/build_cuda_example
|
||||
-S${PROJECT_SOURCE_DIR}/tests/cuda_example -B${PROJECT_BINARY_DIR}/build_cuda_example
|
||||
COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_cuda_example
|
||||
)
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
set(JSON_TEST_DATA_URL https://github.com/nlohmann/json_test_data)
|
||||
set(JSON_TEST_DATA_VERSION 3.0.0)
|
||||
set(JSON_TEST_DATA_VERSION 3.1.0)
|
||||
|
||||
# if variable is set, use test data from given directory rather than downloading them
|
||||
if(JSON_TestDataDirectory)
|
||||
|
204
cmake/test.cmake
Normal file
@ -0,0 +1,204 @@
|
||||
set(_json_test_cmake_list_file ${CMAKE_CURRENT_LIST_FILE})
|
||||
|
||||
#############################################################################
|
||||
# download test data
|
||||
#############################################################################
|
||||
|
||||
include(download_test_data)
|
||||
|
||||
# test fixture to download test data
|
||||
add_test(NAME "download_test_data" COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}
|
||||
--target download_test_data
|
||||
)
|
||||
set_tests_properties(download_test_data PROPERTIES FIXTURES_SETUP TEST_DATA)
|
||||
|
||||
if(JSON_Valgrind)
|
||||
find_program(CMAKE_MEMORYCHECK_COMMAND valgrind)
|
||||
message(STATUS "Executing test suite with Valgrind (${CMAKE_MEMORYCHECK_COMMAND})")
|
||||
set(memcheck_command "${CMAKE_MEMORYCHECK_COMMAND} ${CMAKE_MEMORYCHECK_COMMAND_OPTIONS} --error-exitcode=1 --leak-check=full")
|
||||
separate_arguments(memcheck_command)
|
||||
endif()
|
||||
|
||||
#############################################################################
|
||||
# detect standard support
|
||||
#############################################################################
|
||||
|
||||
# C++11 is the minimum required
|
||||
set(compiler_supports_cpp_11 TRUE)
|
||||
|
||||
foreach(feature ${CMAKE_CXX_COMPILE_FEATURES})
|
||||
if (${feature} STREQUAL cxx_std_14)
|
||||
set(compiler_supports_cpp_14 TRUE)
|
||||
elseif (${feature} STREQUAL cxx_std_17)
|
||||
set(compiler_supports_cpp_17 TRUE)
|
||||
elseif (${feature} STREQUAL cxx_std_20)
|
||||
set(compiler_supports_cpp_20 TRUE)
|
||||
elseif (${feature} STREQUAL cxx_std_23)
|
||||
set(compiler_supports_cpp_23 TRUE)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
#############################################################################
|
||||
# test functions
|
||||
#############################################################################
|
||||
|
||||
#############################################################################
|
||||
# json_test_set_test_options(
|
||||
# all|<tests>
|
||||
# [CXX_STANDARDS all|<args>...]
|
||||
# [COMPILE_DEFINITIONS <args>...]
|
||||
# [COMPILE_FEATURES <args>...]
|
||||
# [COMPILE_OPTIONS <args>...]
|
||||
# [LINK_LIBRARIES <args>...]
|
||||
# [LINK_OPTIONS <args>...])
|
||||
#
|
||||
# Supply test- and standard-specific build settings.
|
||||
# Specify multiple tests using a list e.g., "test-foo;test-bar".
|
||||
#
|
||||
# Must be called BEFORE the test is created.
|
||||
#############################################################################
|
||||
|
||||
function(json_test_set_test_options tests)
|
||||
cmake_parse_arguments(args "" ""
|
||||
"CXX_STANDARDS;COMPILE_DEFINITIONS;COMPILE_FEATURES;COMPILE_OPTIONS;LINK_LIBRARIES;LINK_OPTIONS"
|
||||
${ARGN})
|
||||
|
||||
if(NOT args_CXX_STANDARDS)
|
||||
set(args_CXX_STANDARDS "all")
|
||||
endif()
|
||||
|
||||
foreach(test ${tests})
|
||||
if("${test}" STREQUAL "all")
|
||||
set(test "")
|
||||
endif()
|
||||
|
||||
foreach(cxx_standard ${args_CXX_STANDARDS})
|
||||
if("${cxx_standard}" STREQUAL "all")
|
||||
if("${test}" STREQUAL "")
|
||||
message(FATAL_ERROR "Not supported. Change defaults in: ${_json_test_cmake_list_file}")
|
||||
endif()
|
||||
set(test_interface _json_test_interface_${test})
|
||||
else()
|
||||
set(test_interface _json_test_interface_${test}_cpp_${cxx_standard})
|
||||
endif()
|
||||
|
||||
if(NOT TARGET ${test_interface})
|
||||
add_library(${test_interface} INTERFACE)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(${test_interface} INTERFACE ${args_COMPILE_DEFINITIONS})
|
||||
target_compile_features(${test_interface} INTERFACE ${args_COMPILE_FEATURES})
|
||||
target_compile_options(${test_interface} INTERFACE ${args_COMPILE_OPTIONS})
|
||||
target_link_libraries (${test_interface} INTERFACE ${args_LINK_LIBRARIES})
|
||||
target_link_options(${test_interface} INTERFACE ${args_LINK_OPTIONS})
|
||||
endforeach()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
# for internal use by json_test_add_test_for()
|
||||
function(_json_test_add_test test_name file main cxx_standard)
|
||||
set(test_target ${test_name}_cpp${cxx_standard})
|
||||
|
||||
if(TARGET ${test_target})
|
||||
message(FATAL_ERROR "Target ${test_target} has already been added.")
|
||||
endif()
|
||||
|
||||
add_executable(${test_target} ${file})
|
||||
target_link_libraries(${test_target} PRIVATE ${main})
|
||||
|
||||
# set and require C++ standard
|
||||
set_target_properties(${test_target} PROPERTIES
|
||||
CXX_STANDARD ${cxx_standard}
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
)
|
||||
|
||||
# apply standard-specific build settings
|
||||
if(TARGET _json_test_interface__cpp_${cxx_standard})
|
||||
target_link_libraries(${test_target} PRIVATE _json_test_interface__cpp_${cxx_standard})
|
||||
endif()
|
||||
|
||||
# apply test-specific build settings
|
||||
if(TARGET _json_test_interface_${test_name})
|
||||
target_link_libraries(${test_target} PRIVATE _json_test_interface_${test_name})
|
||||
endif()
|
||||
|
||||
# apply test- and standard-specific build settings
|
||||
if(TARGET _json_test_interface_${test_name}_cpp_${cxx_standard})
|
||||
target_link_libraries(${test_target} PRIVATE
|
||||
_json_test_interface_${test_name}_cpp_${cxx_standard}
|
||||
)
|
||||
endif()
|
||||
|
||||
if (JSON_FastTests)
|
||||
add_test(NAME ${test_target}
|
||||
COMMAND ${test_target} ${DOCTEST_TEST_FILTER}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
else()
|
||||
add_test(NAME ${test_target}
|
||||
COMMAND ${test_target} ${DOCTEST_TEST_FILTER} --no-skip
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
endif()
|
||||
set_tests_properties(${test_target} PROPERTIES LABELS "all" FIXTURES_REQUIRED TEST_DATA)
|
||||
|
||||
if(JSON_Valgrind)
|
||||
add_test(NAME ${test_target}_valgrind
|
||||
COMMAND ${memcheck_command} $<TARGET_FILE:${test_target}> ${DOCTEST_TEST_FILTER}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
set_tests_properties(${test_target}_valgrind PROPERTIES
|
||||
LABELS "valgrind" FIXTURES_REQUIRED TEST_DATA
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#############################################################################
|
||||
# json_test_add_test_for(
|
||||
# <file>
|
||||
# MAIN <main>
|
||||
# [CXX_STANDARDS <version_number>...] [FORCE])
|
||||
#
|
||||
# Given a <file> unit-foo.cpp, produces
|
||||
#
|
||||
# test-foo_cpp<version_number>
|
||||
#
|
||||
# if C++ standard <version_number> is supported by the compiler and the
|
||||
# source file contains JSON_HAS_CPP_<version_number>.
|
||||
# Use FORCE to create the test regardless of the file containing
|
||||
# JSON_HAS_CPP_<version_number>.
|
||||
# Test targets are linked against <main>.
|
||||
# CXX_STANDARDS defaults to "11".
|
||||
#############################################################################
|
||||
|
||||
function(json_test_add_test_for file)
|
||||
cmake_parse_arguments(args "FORCE" "MAIN" "CXX_STANDARDS" ${ARGN})
|
||||
|
||||
get_filename_component(file_basename ${file} NAME_WE)
|
||||
string(REGEX REPLACE "unit-([^$]+)" "test-\\1" test_name ${file_basename})
|
||||
|
||||
if("${args_MAIN}" STREQUAL "")
|
||||
message(FATAL_ERROR "Required argument MAIN <main> missing.")
|
||||
endif()
|
||||
|
||||
if("${args_CXX_STANDARDS}" STREQUAL "")
|
||||
set(args_CXX_STANDARDS 11)
|
||||
endif()
|
||||
|
||||
file(READ ${file} file_content)
|
||||
foreach(cxx_standard ${args_CXX_STANDARDS})
|
||||
if(NOT compiler_supports_cpp_${cxx_standard})
|
||||
continue()
|
||||
endif()
|
||||
|
||||
# add unconditionally if C++11 (default) or forced
|
||||
if(NOT ("${cxx_standard}" STREQUAL 11 OR args_FORCE))
|
||||
string(FIND "${file_content}" JSON_HAS_CPP_${cxx_standard} has_cpp_found)
|
||||
if(${has_cpp_found} EQUAL -1)
|
||||
continue()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
_json_test_add_test(${test_name} ${file} ${args_MAIN} ${cxx_standard})
|
||||
endforeach()
|
||||
endfunction()
|
BIN
doc/avatars.png
Before Width: | Height: | Size: 1.3 MiB |
BIN
doc/json.gif
Before Width: | Height: | Size: 1.6 MiB |
@ -1,55 +0,0 @@
|
||||
# <small>nlohmann::basic_json::</small>count
|
||||
|
||||
```cpp
|
||||
template<typename KeyT>
|
||||
size_type count(KeyT&& key) const;
|
||||
```
|
||||
|
||||
Returns the number of elements with key `key`. If `ObjectType` is the default `std::map` type, the return value will
|
||||
always be `0` (`key` was not found) or `1` (`key` was found).
|
||||
|
||||
## Template parameters
|
||||
|
||||
`KeyT`
|
||||
: A type for an object key.
|
||||
|
||||
## Parameters
|
||||
|
||||
`key` (in)
|
||||
: key value of the element to count.
|
||||
|
||||
## Return value
|
||||
|
||||
Number of elements with key `key`. If the JSON value is not an object, the return value will be `0`.
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong exception safety: if an exception occurs, the original value stays intact.
|
||||
|
||||
## Complexity
|
||||
|
||||
Logarithmic in the size of the JSON object.
|
||||
|
||||
## Notes
|
||||
|
||||
This method always returns `0` when executed on a JSON type that is not an object.
|
||||
|
||||
## Examples
|
||||
|
||||
??? example
|
||||
|
||||
The example shows how `count()` is used.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/count.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/count.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
@ -1,63 +0,0 @@
|
||||
# <small>nlohmann::basic_json::</small>find
|
||||
|
||||
```cpp
|
||||
template<typename KeyT>
|
||||
iterator find(KeyT&& key);
|
||||
|
||||
template<typename KeyT>
|
||||
const_iterator find(KeyT&& key) const;
|
||||
```
|
||||
|
||||
Finds an element in a JSON object with key equivalent to `key`. If the element is not found or the JSON value is not an
|
||||
object, `end()` is returned.
|
||||
|
||||
## Template parameters
|
||||
|
||||
`KeyT`
|
||||
: A type for an object key.
|
||||
|
||||
## Parameters
|
||||
|
||||
`key` (in)
|
||||
: key value of the element to search for.
|
||||
|
||||
## Return value
|
||||
|
||||
Iterator to an element with key equivalent to `key`. If no such element is found or the JSON value is not an object,
|
||||
past-the-end (see `end()`) iterator is returned.
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong exception safety: if an exception occurs, the original value stays intact.
|
||||
|
||||
## Complexity
|
||||
|
||||
Logarithmic in the size of the JSON object.
|
||||
|
||||
## Notes
|
||||
|
||||
This method always returns `end()` when executed on a JSON type that is not an object.
|
||||
|
||||
## Examples
|
||||
|
||||
??? example
|
||||
|
||||
The example shows how `find()` is used.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/find__key_type.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/find__key_type.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [contains](contains.md) checks whether a key exists
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
@ -1,16 +0,0 @@
|
||||
# <small>nlohmann::basic_json::</small>object_comparator_t
|
||||
|
||||
```cpp
|
||||
using object_comparator_t = std::less<StringType>; // until C++14
|
||||
|
||||
using object_comparator_t = std::less<>; // since C++14
|
||||
```
|
||||
|
||||
The comparator used in [`object_t`](object_t.md).
|
||||
|
||||
When C++14 is detected, a transparent com parator is used which, when combined with perfect forwarding on find() and
|
||||
count() calls, prevents unnecessary string construction.
|
||||
|
||||
## Version history
|
||||
|
||||
- Unknown.
|
@ -1,72 +0,0 @@
|
||||
# <small>nlohmann::basic_json::</small>operator ValueType
|
||||
|
||||
```cpp
|
||||
template<typename ValueType>
|
||||
JSON_EXPLICIT operator ValueType() const;
|
||||
```
|
||||
|
||||
Implicit type conversion between the JSON value and a compatible value. The call is realized by calling
|
||||
[`get()`](get.md). See [Notes](#notes) for the meaning of `JSON_EXPLICIT`.
|
||||
|
||||
## Template parameters
|
||||
|
||||
`ValueType`
|
||||
: the value type to return
|
||||
|
||||
## Return value
|
||||
|
||||
copy of the JSON value, converted to `ValueType`
|
||||
|
||||
## Exceptions
|
||||
|
||||
Depends on what `json_serializer<ValueType>` `from_json()` method throws
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the size of the JSON value.
|
||||
|
||||
## Notes
|
||||
|
||||
By default `JSON_EXPLICIT` defined to the empty string, so the signature is:
|
||||
|
||||
```cpp
|
||||
template<typename ValueType>
|
||||
operator ValueType() const;
|
||||
```
|
||||
|
||||
If [`JSON_USE_IMPLICIT_CONVERSIONS`](../../features/macros.md#json_use_implicit_conversions) is set to `0`,
|
||||
`JSON_EXPLICIT` is defined to `#!cpp explicit`:
|
||||
|
||||
```cpp
|
||||
template<typename ValueType>
|
||||
explicit operator ValueType() const;
|
||||
```
|
||||
|
||||
That is, implicit conversions can be switched off by defining
|
||||
[`JSON_USE_IMPLICIT_CONVERSIONS`](../../features/macros.md#json_use_implicit_conversions) to `0`.
|
||||
|
||||
## Examples
|
||||
|
||||
??? example
|
||||
|
||||
The example below shows several conversions from JSON values
|
||||
to other types. There a few things to note: (1) Floating-point numbers can
|
||||
be converted to integers, (2) A JSON array can be converted to a standard
|
||||
`std::vector<short>`, (3) A JSON object can be converted to C++
|
||||
associative containers such as `std::unordered_map<std::string, json>`.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/operator__ValueType.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/operator__ValueType.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 1.0.0.
|
||||
- Macros `JSON_EXPLICIT`/[`JSON_USE_IMPLICIT_CONVERSIONS`](../../features/macros.md#json_use_implicit_conversions) added
|
||||
in version 3.9.0.
|
@ -1,18 +0,0 @@
|
||||
# Macros
|
||||
|
||||
Some aspects of the library can be configured by defining preprocessor macros before including the `json.hpp` header.
|
||||
|
||||
- [`JSON_ASSERT(x)`](json_assert.md)
|
||||
- `JSON_CATCH_USER(exception)`
|
||||
- `JSON_DIAGNOSTICS`
|
||||
- `JSON_HAS_CPP_11`, `JSON_HAS_CPP_14`, `JSON_HAS_CPP_17`, `JSON_HAS_CPP_20`
|
||||
- `JSON_NOEXCEPTION`
|
||||
- `JSON_NO_IO`
|
||||
- `JSON_SKIP_UNSUPPORTED_COMPILER_CHECK`
|
||||
- `JSON_THROW_USER(exception)`
|
||||
- `JSON_TRY_USER`
|
||||
- `JSON_USE_IMPLICIT_CONVERSIONS`
|
||||
- `NLOHMANN_DEFINE_TYPE_INTRUSIVE(type, member...)`
|
||||
- `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(type, member...)`
|
||||
- `NLOHMANN_JSON_SERIALIZE_ENUM(type, ...)`
|
||||
- `NLOHMANN_JSON_VERSION_MAJOR`, `NLOHMANN_JSON_VERSION_MINOR`, `NLOHMANN_JSON_VERSION_PATCH`
|
@ -1,11 +0,0 @@
|
||||
# JSON_ASSERT(x)
|
||||
|
||||
```cpp
|
||||
JSON_ASSERT(x)
|
||||
```
|
||||
|
||||
## Default implementation
|
||||
|
||||
```cpp
|
||||
assert(x);
|
||||
```
|
@ -1,19 +0,0 @@
|
||||
# JSON Pointer
|
||||
|
||||
The library supports **JSON Pointer** ([RFC 6901](https://tools.ietf.org/html/rfc6901)) as alternative means to address structured values.
|
||||
|
||||
```cpp
|
||||
// a JSON value
|
||||
json j_original = R"({
|
||||
"baz": ["one", "two", "three"],
|
||||
"foo": "bar"
|
||||
})"_json;
|
||||
|
||||
// access members with a JSON pointer (RFC 6901)
|
||||
j_original["/baz/1"_json_pointer];
|
||||
// "two"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- Class [`json_pointer`](../api/json_pointer/index.md)
|
@ -1,138 +0,0 @@
|
||||
# CMake
|
||||
|
||||
## Integration
|
||||
|
||||
You can also use the `nlohmann_json::nlohmann_json` interface target in CMake. This target populates the appropriate usage requirements for `INTERFACE_INCLUDE_DIRECTORIES` to point to the appropriate include directories and `INTERFACE_COMPILE_FEATURES` for the necessary C++11 flags.
|
||||
|
||||
### External
|
||||
|
||||
To use this library from a CMake project, you can locate it directly with `find_package()` and use the namespaced imported target from the generated package configuration:
|
||||
|
||||
```cmake
|
||||
# CMakeLists.txt
|
||||
find_package(nlohmann_json 3.2.0 REQUIRED)
|
||||
...
|
||||
add_library(foo ...)
|
||||
...
|
||||
target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json)
|
||||
```
|
||||
|
||||
The package configuration file, `nlohmann_jsonConfig.cmake`, can be used either from an install tree or directly out of the build tree.
|
||||
|
||||
### Embedded
|
||||
|
||||
To embed the library directly into an existing CMake project, place the entire source tree in a subdirectory and call `add_subdirectory()` in your `CMakeLists.txt` file:
|
||||
|
||||
```cmake
|
||||
# If you only include this third party in PRIVATE source files, you do not
|
||||
# need to install it when your main project gets installed.
|
||||
# set(JSON_Install OFF CACHE INTERNAL "")
|
||||
|
||||
# Don't use include(nlohmann_json/CMakeLists.txt) since that carries with it
|
||||
# unintended consequences that will break the build. It's generally
|
||||
# discouraged (although not necessarily well documented as such) to use
|
||||
# include(...) for pulling in other CMake projects anyways.
|
||||
add_subdirectory(nlohmann_json)
|
||||
...
|
||||
add_library(foo ...)
|
||||
...
|
||||
target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json)
|
||||
```
|
||||
|
||||
### Embedded (FetchContent)
|
||||
|
||||
Since CMake v3.11,
|
||||
[FetchContent](https://cmake.org/cmake/help/v3.11/module/FetchContent.html) can
|
||||
be used to automatically download the repository as a dependency at configure type.
|
||||
|
||||
Example:
|
||||
```cmake
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(json
|
||||
GIT_REPOSITORY https://github.com/nlohmann/json
|
||||
GIT_TAG v3.7.3)
|
||||
|
||||
FetchContent_GetProperties(json)
|
||||
if(NOT json_POPULATED)
|
||||
FetchContent_Populate(json)
|
||||
add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json)
|
||||
```
|
||||
|
||||
!!! Note
|
||||
The repository <https://github.com/nlohmann/json> download size is quite large.
|
||||
You might want to depend on a smaller repository. For instance, you might want to replace the URL above by
|
||||
<https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent>.
|
||||
|
||||
### Supporting Both
|
||||
|
||||
To allow your project to support either an externally supplied or an embedded JSON library, you can use a pattern akin to the following:
|
||||
|
||||
``` cmake
|
||||
# Top level CMakeLists.txt
|
||||
project(FOO)
|
||||
...
|
||||
option(FOO_USE_EXTERNAL_JSON "Use an external JSON library" OFF)
|
||||
...
|
||||
add_subdirectory(thirdparty)
|
||||
...
|
||||
add_library(foo ...)
|
||||
...
|
||||
# Note that the namespaced target will always be available regardless of the
|
||||
# import method
|
||||
target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json)
|
||||
```
|
||||
```cmake
|
||||
# thirdparty/CMakeLists.txt
|
||||
...
|
||||
if(FOO_USE_EXTERNAL_JSON)
|
||||
find_package(nlohmann_json 3.2.0 REQUIRED)
|
||||
else()
|
||||
set(JSON_BuildTests OFF CACHE INTERNAL "")
|
||||
add_subdirectory(nlohmann_json)
|
||||
endif()
|
||||
...
|
||||
```
|
||||
|
||||
`thirdparty/nlohmann_json` is then a complete copy of this source tree.
|
||||
|
||||
## CMake Options
|
||||
|
||||
### `JSON_BuildTests`
|
||||
|
||||
Build the unit tests when [`BUILD_TESTING`](https://cmake.org/cmake/help/latest/command/enable_testing.html) is enabled. This option is `ON` by default if the library's CMake project is the top project. That is, when integrating the library as described above, the test suite is not built unless explicitly switched on with this option.
|
||||
|
||||
### `JSON_CI`
|
||||
|
||||
Enable CI build targets. The exact targets are used during the several CI steps and are subject to change without notice. This option is `OFF` by default.
|
||||
|
||||
### `JSON_Diagnostics`
|
||||
|
||||
Enable [extended diagnostic messages](../home/exceptions.md#extended-diagnostic-messages) by defining macro [`JSON_DIAGNOSTICS`](../features/macros.md#json_diagnostics). This option is `OFF` by default.
|
||||
|
||||
### `JSON_FastTests`
|
||||
|
||||
Skip expensive/slow test suites. This option is `OFF` by default. Depends on `JSON_BuildTests`.
|
||||
|
||||
### `JSON_ImplicitConversions`
|
||||
|
||||
Enable implicit conversions by defining macro [`JSON_USE_IMPLICIT_CONVERSIONS`](../features/macros.md#json_use_implicit_conversions). This option is `ON` by default.
|
||||
|
||||
### `JSON_Install`
|
||||
|
||||
Install CMake targets during install step. This option is `ON` by default if the library's CMake project is the top project.
|
||||
|
||||
### `JSON_MultipleHeaders`
|
||||
|
||||
Use non-amalgamated version of the library. This option is `OFF` by default.
|
||||
|
||||
### `JSON_SystemInclude`
|
||||
|
||||
Treat the library headers like system headers (i.e., adding `SYSTEM` to the [`target_include_directories`](https://cmake.org/cmake/help/latest/command/target_include_directories.html) call) to checks for this library by tools like Clang-Tidy. This option is `OFF` by default.
|
||||
|
||||
### `JSON_Valgrind`
|
||||
|
||||
Execute test suite with [Valgrind](https://valgrind.org). This option is `OFF` by default. Depends on `JSON_BuildTests`.
|
@ -1,14 +0,0 @@
|
||||
# Header only
|
||||
|
||||
[`json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp) is the single required file in `single_include/nlohmann` or [released here](https://github.com/nlohmann/json/releases). You need to add
|
||||
|
||||
```cpp
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
// for convenience
|
||||
using json = nlohmann::json;
|
||||
```
|
||||
|
||||
to the files you want to process JSON and set the necessary switches to enable C++11 (e.g., `-std=c++11` for GCC and Clang).
|
||||
|
||||
You can further use file [`include/nlohmann/json_fwd.hpp`](https://github.com/nlohmann/json/blob/develop/include/nlohmann/json_fwd.hpp) for forward-declarations. The installation of `json_fwd.hpp` (as part of CMake's install step), can be achieved by setting `-DJSON_MultipleHeaders=ON`.
|
@ -1,29 +0,0 @@
|
||||
click>=7.1.2
|
||||
future>=0.18.2
|
||||
htmlmin>=0.1.12
|
||||
httplib2>=0.18.1
|
||||
importlib-metadata>=1.6.0
|
||||
Jinja2>=2.11.2
|
||||
joblib>=0.15.1
|
||||
jsmin>=2.2.2
|
||||
livereload>=2.6.1
|
||||
lunr>=0.5.8
|
||||
Markdown>=3.2.2
|
||||
markdown-include>=0.5.1
|
||||
MarkupSafe>=1.1.1
|
||||
mkdocs>=1.1.2
|
||||
mkdocs-material>=5.2.1
|
||||
mkdocs-material-extensions>=1.0
|
||||
mkdocs-minify-plugin>=0.3.0
|
||||
mkdocs-simple-hooks>=0.1.1
|
||||
nltk>=3.5
|
||||
plantuml>=0.3.0
|
||||
plantuml-markdown>=3.2.2
|
||||
Pygments>=2.6.1
|
||||
pymdown-extensions>=7.1
|
||||
PyYAML>=5.3.1
|
||||
regex>=2020.5.14
|
||||
six>=1.15.0
|
||||
tornado>=6.0.4
|
||||
tqdm>=4.46.0
|
||||
zipp>=3.1.0
|
@ -13,7 +13,7 @@ If you want to see the documentation for a specific tag or commit hash, you can
|
||||
git clone https://github.com/nlohmann/json.git
|
||||
cd json
|
||||
git checkout v3.10.2
|
||||
make install_venv serve -C doc/mkdocs
|
||||
make install_venv serve -C docs/mkdocs
|
||||
```
|
||||
|
||||
Open URL <http://127.0.0.1:8000/> in your browser. Replace from any URL from the source code `https://json.nlohmann.me`
|
BIN
docs/avatars.png
Normal file
After Width: | Height: | Size: 1.3 MiB |
@ -13,7 +13,6 @@ JSON_for_Modern_C++.docset: Info.plist docSet.sql
|
||||
# remove "JSON for Modern C++" from page titles
|
||||
find JSON_for_Modern_C++.docset/Contents/Resources/Documents -type f -exec gsed -i 's| - JSON for Modern C++</title>|</title>|' {} +
|
||||
# clean up
|
||||
rm JSON_for_Modern_C++.docset/Contents/Resources/Documents/hooks.py
|
||||
rm JSON_for_Modern_C++.docset/Contents/Resources/Documents/sitemap.*
|
||||
# generate index
|
||||
sqlite3 JSON_for_Modern_C++.docset/Contents/Resources/docSet.dsidx < docSet.sql
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "JSON for Modern C++",
|
||||
"version": "3.10.0",
|
||||
"version": "3.10.5",
|
||||
"archive": "JSON_for_Modern_C++.tgz",
|
||||
"author": {
|
||||
"name": "Niels Lohmann",
|
Before Width: | Height: | Size: 700 B After Width: | Height: | Size: 700 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |