mirror of
https://github.com/nlohmann/json.git
synced 2025-07-29 23:01:16 +03:00
# Conflicts:
# .github/workflows/macos.yml # include/nlohmann/detail/input/parser.hpp # include/nlohmann/detail/meta/std_fs.hpp # include/nlohmann/json.hpp # single_include/nlohmann/json.hpp
This commit is contained in:
@ -1,4 +1,11 @@
|
||||
# TODO: The first three checks are only removed to get the CI going. They have to be addressed at some point.
|
||||
|
||||
Checks: '*,
|
||||
|
||||
-portability-template-virtual-member-function,
|
||||
-bugprone-use-after-move,
|
||||
-hicpp-invalid-access-moved,
|
||||
|
||||
-altera-id-dependent-backward-branch,
|
||||
-altera-struct-pack-align,
|
||||
-altera-unroll-loops,
|
||||
@ -47,6 +54,7 @@ Checks: '*,
|
||||
-modernize-use-constraints,
|
||||
-modernize-use-designated-initializers,
|
||||
-modernize-use-nodiscard,
|
||||
-modernize-use-ranges,
|
||||
-modernize-use-std-numbers,
|
||||
-modernize-use-trailing-return-type,
|
||||
-performance-enum-size,
|
||||
|
2
.github/workflows/cifuzz.yml
vendored
2
.github/workflows/cifuzz.yml
vendored
@ -23,7 +23,7 @@ jobs:
|
||||
dry-run: false
|
||||
language: c++
|
||||
- name: Upload Crash
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
if: failure() && steps.build.outcome == 'success'
|
||||
with:
|
||||
name: artifacts
|
||||
|
64
.github/workflows/macos.yml
vendored
64
.github/workflows/macos.yml
vendored
@ -17,11 +17,29 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
xcode_1:
|
||||
runs-on: macos-11
|
||||
# macos-11 is deprecated
|
||||
# macos-11:
|
||||
# runs-on: macos-11
|
||||
# strategy:
|
||||
# matrix:
|
||||
# xcode: ['11.7', '12.4', '12.5.1', '13.0']
|
||||
# env:
|
||||
# DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||
#
|
||||
# steps:
|
||||
# - uses: actions/checkout@v4
|
||||
# - name: Run CMake
|
||||
# run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
|
||||
# - name: Build
|
||||
# run: cmake --build build --parallel 10
|
||||
# - name: Test
|
||||
# run: cd build ; ctest -j 10 --output-on-failure
|
||||
|
||||
macos-12:
|
||||
runs-on: macos-12 # https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md
|
||||
strategy:
|
||||
matrix:
|
||||
xcode: ['11.7', '12.4', '12.5.1', '13.0']
|
||||
xcode: ['13.1', '13.2.1', '13.3.1', '13.4.1', '14.0', '14.0.1', '14.1']
|
||||
env:
|
||||
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||
|
||||
@ -34,11 +52,45 @@ jobs:
|
||||
- name: Test
|
||||
run: cd build ; ctest -j 10 --output-on-failure
|
||||
|
||||
xcode_2:
|
||||
runs-on: macos-12
|
||||
macos-13:
|
||||
runs-on: macos-13 # https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md
|
||||
strategy:
|
||||
matrix:
|
||||
xcode: ['13.1', '13.2.1', '13.3.1', '13.4.1', '14.0', '14.0.1', '14.1']
|
||||
xcode: [ '14.2', '14.3', '14.3.1', '15.0.1', '15.1', '15.2']
|
||||
env:
|
||||
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
|
||||
- name: Build
|
||||
run: cmake --build build --parallel 10
|
||||
- name: Test
|
||||
run: cd build ; ctest -j 10 --output-on-failure
|
||||
|
||||
macos-14:
|
||||
runs-on: macos-14 # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md
|
||||
strategy:
|
||||
matrix:
|
||||
xcode: ['15.3', '15.4']
|
||||
env:
|
||||
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
|
||||
- name: Build
|
||||
run: cmake --build build --parallel 10
|
||||
- name: Test
|
||||
run: cd build ; ctest -j 10 --output-on-failure
|
||||
|
||||
macos-15:
|
||||
runs-on: macos-15 # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md
|
||||
strategy:
|
||||
matrix:
|
||||
xcode: ['16.0', '16.1']
|
||||
env:
|
||||
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||
|
||||
|
18
.github/workflows/ubuntu.yml
vendored
18
.github/workflows/ubuntu.yml
vendored
@ -125,11 +125,25 @@ jobs:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
path-to-lcov: ${{ github.workspace }}/build/json.info.filtered.noexcept
|
||||
|
||||
ci_test_compilers_gcc_old:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
compiler: ['4.8', '4.9', '5', '6']
|
||||
container: ghcr.io/nlohmann/json-ci:v2.4.0
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run CMake
|
||||
run: CXX=g++-${{ matrix.compiler }} cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
run: cmake --build build --target ci_test_compiler_g++-${{ matrix.compiler }}
|
||||
|
||||
ci_test_compilers_gcc:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
compiler: ['4', '5', '6', '7', '8', '9', '10', '11', '12', 'latest']
|
||||
# older GCC docker images (4, 5, 6) fail to check out code
|
||||
compiler: ['7', '8', '9', '10', '11', '12', '13', '14', 'latest']
|
||||
container: gcc:${{ matrix.compiler }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@ -144,7 +158,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
compiler: ['3.5', '3.6', '3.7', '3.8', '3.9', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15-bullseye', 'latest']
|
||||
compiler: ['3.5', '3.6', '3.7', '3.8', '3.9', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15-bullseye', '16', '17', '18', '19', 'latest']
|
||||
container: silkeh/clang:${{ matrix.compiler }}
|
||||
steps:
|
||||
- name: Install unzip and git
|
||||
|
@ -49,5 +49,4 @@ cc_library(
|
||||
],
|
||||
includes = ["include"],
|
||||
visibility = ["//visibility:public"],
|
||||
alwayslink = True,
|
||||
)
|
||||
|
@ -210,4 +210,5 @@ if(JSON_Install)
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
|
||||
DESTINATION ${NLOHMANN_JSON_PKGCONFIG_INSTALL_DIR}
|
||||
)
|
||||
include(CPack)
|
||||
endif()
|
||||
|
86
README.md
86
README.md
@ -1113,9 +1113,9 @@ auto cbor = json::to_msgpack(j); // 0xD5 (fixext2), 0x10, 0xCA, 0xFE
|
||||
|
||||
Though it's 2023 already, the support for C++11 is still a bit sparse. Currently, the following compilers are known to work:
|
||||
|
||||
- GCC 4.8 - 12.0 (and possibly later)
|
||||
- Clang 3.4 - 15.0 (and possibly later)
|
||||
- Apple Clang 9.1 - 13.1 (and possibly later)
|
||||
- GCC 4.8 - 14.2 (and possibly later)
|
||||
- Clang 3.4 - 20.0 (and possibly later)
|
||||
- Apple Clang 9.1 - 16.0 (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)
|
||||
@ -1146,29 +1146,35 @@ The following compilers are currently used in continuous integration at [AppVeyo
|
||||
|
||||
| Compiler | Operating System | CI Provider |
|
||||
|--------------------------------------------------------------------------------------------------------|--------------------|----------------|
|
||||
| Apple Clang 11.0.3 (clang-1103.0.32.62); Xcode 11.7 | macOS 11.7.1 | GitHub Actions |
|
||||
| Apple Clang 12.0.0 (clang-1200.0.32.29); Xcode 12.4 | macOS 11.7.1 | GitHub Actions |
|
||||
| Apple Clang 12.0.5 (clang-1205.0.22.11); Xcode 12.5.1 | macOS 11.7.1 | GitHub Actions |
|
||||
| Apple Clang 13.0.0 (clang-1300.0.29.3); Xcode 13.0 | macOS 11.7.1 | GitHub Actions |
|
||||
| Apple Clang 13.0.0 (clang-1300.0.29.3); Xcode 13.1 | macOS 12.6.1 | GitHub Actions |
|
||||
| Apple Clang 13.0.0 (clang-1300.0.29.30); Xcode 13.2.1 | macOS 12.6.1 | GitHub Actions |
|
||||
| Apple Clang 13.1.6 (clang-1316.0.21.2.3); Xcode 13.3.1 | macOS 12.6.1 | GitHub Actions |
|
||||
| Apple Clang 13.1.6 (clang-1316.0.21.2.5); Xcode 13.4.1 | macOS 12.6.1 | GitHub Actions |
|
||||
| Apple Clang 14.0.0 (clang-1400.0.29.102); Xcode 14.0 | macOS 12.6.1 | GitHub Actions |
|
||||
| Apple Clang 14.0.0 (clang-1400.0.29.102); Xcode 14.0.1 | macOS 12.6.1 | GitHub Actions |
|
||||
| Apple Clang 14.0.0 (clang-1400.0.29.202); Xcode 14.1 | macOS 12.6.1 | GitHub Actions |
|
||||
| Clang 3.5.2 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 3.6.2 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 3.7.1 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 3.8.1 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 3.9.1 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 4.0.1 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 5.0.2 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 6.0.1 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 7.0.1 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 8.0.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 9.0.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 10.0.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Apple Clang 13.0.0 (clang-1300.0.29.3); Xcode 13.1 | macOS 12.7.6 | GitHub Actions |
|
||||
| Apple Clang 13.0.0 (clang-1300.0.29.30); Xcode 13.2.1 | macOS 12.7.6 | GitHub Actions |
|
||||
| Apple Clang 13.1.6 (clang-1316.0.21.2.3); Xcode 13.3.1 | macOS 12.7.6 | GitHub Actions |
|
||||
| Apple Clang 13.1.6 (clang-1316.0.21.2.5); Xcode 13.4.1 | macOS 12.7.6 | GitHub Actions |
|
||||
| Apple Clang 14.0.0 (clang-1400.0.29.102); Xcode 14.0 | macOS 12.7.6 | GitHub Actions |
|
||||
| Apple Clang 14.0.0 (clang-1400.0.29.102); Xcode 14.0.1 | macOS 12.7.6 | GitHub Actions |
|
||||
| Apple Clang 14.0.0 (clang-1400.0.29.202); Xcode 14.1 | macOS 12.7.6 | GitHub Actions |
|
||||
| Apple Clang 14.0.0 (clang-1400.0.29.202); Xcode 14.2 | macOS 13.7 | GitHub Actions |
|
||||
| Apple Clang 14.0.3 (clang-1403.0.22.14.1); Xcode 14.3 | macOS 13.7 | GitHub Actions |
|
||||
| Apple Clang 14.0.3 (clang-1403.0.22.14.1); Xcode 14.3.1 | macOS 13.7.1 | GitHub Actions |
|
||||
| Apple Clang 15.0.0 (clang-1500.0.40.1); Xcode 15.0.1 | macOS 13.7 | GitHub Actions |
|
||||
| Apple Clang 15.0.0 (clang-1500.1.0.2.5); Xcode 15.1 | macOS 13.7 | GitHub Actions |
|
||||
| Apple Clang 15.0.0 (clang-1500.1.0.2.5); Xcode 15.2 | macOS 13.7 | GitHub Actions |
|
||||
| Apple Clang 15.0.0 (clang-1500.3.9.4); Xcode 15.3 | macOS 14.7 | GitHub Actions |
|
||||
| Apple Clang 15.0.0 (clang-1500.3.9.4); Xcode 15.4 | macOS 14.7 | GitHub Actions |
|
||||
| Apple Clang 16.0.0 (clang-1600.0.26.3); Xcode 16.0 | macOS 15.0.1 | GitHub Actions |
|
||||
| Apple Clang 16.0.0 (clang-1600.0.26.4); Xcode 16.1 | macOS 15.0.1 | GitHub Actions |
|
||||
| Clang 3.5.2 | Ubuntu 22.04.1 LTS | GitHub Actions |
|
||||
| Clang 3.6.2 | Ubuntu 22.04.1 LTS | GitHub Actions |
|
||||
| Clang 3.7.1 | Ubuntu 22.04.1 LTS | GitHub Actions |
|
||||
| Clang 3.8.1 | Ubuntu 22.04.1 LTS | GitHub Actions |
|
||||
| Clang 3.9.1 | Ubuntu 22.04.1 LTS | GitHub Actions |
|
||||
| Clang 4.0.1 | Ubuntu 22.04.1 LTS | GitHub Actions |
|
||||
| Clang 5.0.2 | Ubuntu 22.04.1 LTS | GitHub Actions |
|
||||
| Clang 6.0.1 | Ubuntu 22.04.1 LTS | GitHub Actions |
|
||||
| Clang 7.0.1 | Ubuntu 22.04.1 LTS | GitHub Actions |
|
||||
| Clang 8.0.0 | Ubuntu 22.04.1 LTS | GitHub Actions |
|
||||
| Clang 9.0.0 | Ubuntu 22.04.1 LTS | GitHub Actions |
|
||||
| Clang 10.0.0 | Ubuntu 22.04.1 LTS | GitHub Actions |
|
||||
| Clang 10.0.0 with GNU-like command-line | Windows-10.0.17763 | GitHub Actions |
|
||||
| Clang 11.0.0 with GNU-like command-line | Windows-10.0.17763 | GitHub Actions |
|
||||
| Clang 11.0.0 with MSVC-like command-line | Windows-10.0.17763 | GitHub Actions |
|
||||
@ -1182,20 +1188,28 @@ The following compilers are currently used in continuous integration at [AppVeyo
|
||||
| Clang 15.0.0 with GNU-like command-line | Windows-10.0.17763 | GitHub Actions |
|
||||
| Clang 15.0.4 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 16.0.0 (16.0.0-++20221031071727+500876226c60-1~exp1~20221031071831.439) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 4.8.5 (Ubuntu 4.8.5-4ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 4.9.4 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 5.5.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 6.5.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 7.5.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 16.0.6 (++20231112084702+7cbf1a259152-1~exp1~20231112084757.16) | Ubuntu 20.04.1 LTS | GitHub Actions |
|
||||
| Clang 17.0.6 (++20231208085813+6009708b4367-1~exp1~20231208085906.81) | Ubuntu 20.04.1 LTS | GitHub Actions |
|
||||
| Clang 18.1.8 (++20240731024826+3b5b5c1ec4a3-1~exp1~20240731144843.145) | Ubuntu 20.04.1 LTS | GitHub Actions |
|
||||
| Clang 19.1.2 (++20241016063422+7ba7d8e2f7b6-1~exp1~20241016063541.55) | Ubuntu 20.04.1 LTS | GitHub Actions |
|
||||
| Clang 20.0.0 (++20241022113049+f1ade1f874db-1~exp1~20241022113104.1036) | Ubuntu 22.04.1 LTS | GitHub Actions |
|
||||
| GCC 4.8.5 (Ubuntu 4.8.5-4ubuntu8) | Ubuntu 20.04.4 LTS | GitHub Actions |
|
||||
| GCC 4.9.3 (Ubuntu 4.9.3-13ubuntu2) | Ubuntu 20.04.4 LTS | GitHub Actions |
|
||||
| GCC 4.8.5 (Ubuntu 4.8.5-4ubuntu2) | Ubuntu 20.04.4 LTS | GitHub Actions |
|
||||
| GCC 5.5.0 (Ubuntu 5.5.0-12ubuntu1) | Ubuntu 20.04.4 LTS | GitHub Actions |
|
||||
| GCC 6.4.0 (Ubuntu 6.4.0-17ubuntu1) | Ubuntu 20.04.4 LTS | GitHub Actions |
|
||||
| GCC 7.5.0 | Ubuntu 22.04.1 LTS | GitHub Actions |
|
||||
| GCC 8.1.0 (i686-posix-dwarf-rev0, Built by MinGW-W64 project) | Windows-10.0.17763 | GitHub Actions |
|
||||
| GCC 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) | Windows-10.0.17763 | GitHub Actions |
|
||||
| GCC 8.5.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 9.5.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 10.4.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 8.5.0 | Ubuntu 22.04.1 LTS | GitHub Actions |
|
||||
| GCC 9.5.0 | Ubuntu 22.04.1 LTS | GitHub Actions |
|
||||
| GCC 10.5.0 | Ubuntu 22.04.1 LTS | GitHub Actions |
|
||||
| GCC 11.1.0 | Ubuntu (aarch64) | Cirrus CI |
|
||||
| GCC 11.3.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 12.2.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 11.5.0 | Ubuntu 22.04.1 LTS | GitHub Actions |
|
||||
| GCC 12.4.0 | Ubuntu 22.04.1 LTS | GitHub Actions |
|
||||
| GCC 13.0.0 20220605 (experimental) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 13.3.0 | Ubuntu 22.04.1 LTS | GitHub Actions |
|
||||
| GCC 14.2.0 | Ubuntu 22.04.1 LTS | GitHub Actions |
|
||||
| Intel C++ Compiler 2021.5.0.20211109 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| NVCC 11.0.221 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Visual Studio 14 2015 MSVC 19.0.24241.7 (Build Engine version 14.0.25420.1) | Windows-6.3.9600 | AppVeyor |
|
||||
|
@ -13,6 +13,9 @@
|
||||
#include <forward_list> // forward_list
|
||||
#include <iterator> // inserter, front_inserter, end
|
||||
#include <map> // map
|
||||
#ifdef JSON_HAS_CPP_17
|
||||
#include <optional> // optional
|
||||
#endif
|
||||
#include <string> // string
|
||||
#include <tuple> // tuple, make_tuple
|
||||
#include <type_traits> // is_arithmetic, is_same, is_enum, underlying_type, is_convertible
|
||||
@ -20,6 +23,7 @@
|
||||
#include <utility> // pair, declval
|
||||
#include <valarray> // valarray
|
||||
|
||||
|
||||
#include <nlohmann/detail/exceptions.hpp>
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
#include <nlohmann/detail/meta/cpp_future.hpp>
|
||||
@ -43,6 +47,24 @@ inline void from_json(const BasicJsonType& j, typename std::nullptr_t& n)
|
||||
n = nullptr;
|
||||
}
|
||||
|
||||
#ifdef JSON_HAS_CPP_17
|
||||
#ifndef JSON_USE_IMPLICIT_CONVERSIONS
|
||||
template<typename BasicJsonType, typename T>
|
||||
void from_json(const BasicJsonType& j, std::optional<T>& opt)
|
||||
{
|
||||
if (j.is_null())
|
||||
{
|
||||
opt = std::nullopt;
|
||||
}
|
||||
else
|
||||
{
|
||||
opt.emplace(j.template get<T>());
|
||||
}
|
||||
}
|
||||
|
||||
#endif // JSON_USE_IMPLICIT_CONVERSIONS
|
||||
#endif // JSON_HAS_CPP_17
|
||||
|
||||
// overloads for basic_json template parameters
|
||||
template < typename BasicJsonType, typename ArithmeticType,
|
||||
enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
|
||||
|
@ -10,6 +10,9 @@
|
||||
|
||||
#include <algorithm> // copy
|
||||
#include <iterator> // begin, end
|
||||
#ifdef JSON_HAS_CPP_17
|
||||
#include <optional> // optional
|
||||
#endif
|
||||
#include <string> // string
|
||||
#include <tuple> // tuple, get
|
||||
#include <type_traits> // is_same, is_constructible, is_floating_point, is_enum, underlying_type
|
||||
@ -260,6 +263,22 @@ struct external_constructor<value_t::object>
|
||||
// to_json //
|
||||
/////////////
|
||||
|
||||
#ifdef JSON_HAS_CPP_17
|
||||
template<typename BasicJsonType, typename T,
|
||||
enable_if_t<std::is_constructible<BasicJsonType, T>::value, int> = 0>
|
||||
void to_json(BasicJsonType& j, const std::optional<T>& opt)
|
||||
{
|
||||
if (opt.has_value())
|
||||
{
|
||||
j = *opt;
|
||||
}
|
||||
else
|
||||
{
|
||||
j = nullptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename BasicJsonType, typename T,
|
||||
enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value, int> = 0>
|
||||
inline void to_json(BasicJsonType& j, T b) noexcept
|
||||
|
@ -353,7 +353,7 @@ class json_sax_dom_callback_parser
|
||||
using parse_event_t = typename BasicJsonType::parse_event_t;
|
||||
|
||||
json_sax_dom_callback_parser(BasicJsonType& r,
|
||||
const parser_callback_t cb,
|
||||
parser_callback_t cb,
|
||||
const bool allow_exceptions_ = true)
|
||||
: root(r), callback(std::move(cb)), allow_exceptions(allow_exceptions_)
|
||||
{
|
||||
|
@ -967,7 +967,7 @@ class lexer : public lexer_base<BasicJsonType>
|
||||
locale's decimal point is used instead of `.` to work with the
|
||||
locale-dependent converters.
|
||||
*/
|
||||
token_type scan_number() // lgtm [cpp/use-of-goto]
|
||||
token_type scan_number() // lgtm [cpp/use-of-goto] `goto` is used in this function to implement the number-parsing state machine described above. By design, any finite input will eventually reach the "done" state or return token_type::parse_error. In each intermediate state, 1 byte of the input is appended to the token_buffer vector, and only the already initialized variables token_buffer, number_type, and error_message are manipulated.
|
||||
{
|
||||
// reset token_buffer to store the number's bytes
|
||||
reset();
|
||||
|
@ -69,10 +69,10 @@ class parser
|
||||
public:
|
||||
/// a parser reading from an input adapter
|
||||
explicit parser(InputAdapterType&& adapter,
|
||||
const parser_callback_t<BasicJsonType>& cb = nullptr,
|
||||
parser_callback_t<BasicJsonType>& cb = nullptr,
|
||||
const bool allow_exceptions_ = true,
|
||||
const bool skip_comments = false)
|
||||
: callback(cb)
|
||||
: callback(std::move(cb))
|
||||
, m_lexer(std::move(adapter), skip_comments)
|
||||
, allow_exceptions(allow_exceptions_)
|
||||
{
|
||||
|
@ -9,7 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef> // size_t
|
||||
#include <iterator> // input_iterator_tag
|
||||
#include <iterator> // forward_iterator_tag
|
||||
#include <string> // string, to_string
|
||||
#include <tuple> // tuple_size, get, tuple_element
|
||||
#include <utility> // move
|
||||
@ -40,7 +40,7 @@ template<typename IteratorType> class iteration_proxy_value
|
||||
using value_type = iteration_proxy_value;
|
||||
using pointer = value_type *;
|
||||
using reference = value_type &;
|
||||
using iterator_category = std::input_iterator_tag;
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
using string_type = typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().key() ) >::type >::type;
|
||||
|
||||
private:
|
||||
|
@ -612,7 +612,7 @@ class binary_writer
|
||||
case value_t::binary:
|
||||
{
|
||||
// step 0: determine if the binary type has a set subtype to
|
||||
// determine whether or not to use the ext or fixext types
|
||||
// determine whether to use the ext or fixext types
|
||||
const bool use_ext = j.m_data.m_value.binary->has_subtype();
|
||||
|
||||
// step 1: write control byte and the byte string length
|
||||
|
@ -131,7 +131,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
template<typename InputAdapterType>
|
||||
static ::nlohmann::detail::parser<basic_json, InputAdapterType> parser(
|
||||
InputAdapterType adapter,
|
||||
detail::parser_callback_t<basic_json>& cb = nullptr,
|
||||
detail::parser_callback_t<basic_json>cb = nullptr,
|
||||
const bool allow_exceptions = true,
|
||||
const bool ignore_comments = false
|
||||
)
|
||||
@ -2114,7 +2114,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
/// @brief access specified object element
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/operator%5B%5D/
|
||||
reference operator[](typename object_t::key_type key)
|
||||
reference operator[](typename object_t::key_type key) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
// implicitly convert null value to an empty object
|
||||
if (is_null())
|
||||
@ -2494,7 +2494,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
template < class IteratorType, detail::enable_if_t <
|
||||
std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
|
||||
std::is_same<IteratorType, typename basic_json_t::const_iterator>::value, int > = 0 >
|
||||
IteratorType erase(IteratorType first, IteratorType last)
|
||||
IteratorType erase(IteratorType first, IteratorType last) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
// make sure iterator fits the current value
|
||||
if (JSON_HEDLEY_UNLIKELY(this != first.m_object || this != last.m_object))
|
||||
@ -3261,7 +3261,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
/// @note: This uses std::distance to support GCC 4.8,
|
||||
/// see https://github.com/nlohmann/json/pull/1257
|
||||
template<typename... Args>
|
||||
iterator insert_iterator(const_iterator pos, Args&& ... args)
|
||||
iterator insert_iterator(const_iterator pos, Args&& ... args) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
iterator result(this);
|
||||
JSON_ASSERT(m_data.m_value.array != nullptr);
|
||||
@ -3280,7 +3280,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
/// @brief inserts element into array
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/insert/
|
||||
iterator insert(const_iterator pos, const basic_json& val)
|
||||
iterator insert(const_iterator pos, const basic_json& val) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
// insert only works for arrays
|
||||
if (JSON_HEDLEY_LIKELY(is_array()))
|
||||
@ -3300,14 +3300,14 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
/// @brief inserts element into array
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/insert/
|
||||
iterator insert(const_iterator pos, basic_json&& val)
|
||||
iterator insert(const_iterator pos, basic_json&& val) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
return insert(pos, val);
|
||||
}
|
||||
|
||||
/// @brief inserts copies of element into array
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/insert/
|
||||
iterator insert(const_iterator pos, size_type cnt, const basic_json& val)
|
||||
iterator insert(const_iterator pos, size_type cnt, const basic_json& val) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
// insert only works for arrays
|
||||
if (JSON_HEDLEY_LIKELY(is_array()))
|
||||
@ -3327,7 +3327,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
/// @brief inserts range of elements into array
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/insert/
|
||||
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
|
||||
iterator insert(const_iterator pos, const_iterator first, const_iterator last) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
// insert only works for arrays
|
||||
if (JSON_HEDLEY_UNLIKELY(!is_array()))
|
||||
@ -3358,7 +3358,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
/// @brief inserts elements from initializer list into array
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/insert/
|
||||
iterator insert(const_iterator pos, initializer_list_t ilist)
|
||||
iterator insert(const_iterator pos, initializer_list_t ilist) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
// insert only works for arrays
|
||||
if (JSON_HEDLEY_UNLIKELY(!is_array()))
|
||||
@ -3378,7 +3378,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
/// @brief inserts range of elements into object
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/insert/
|
||||
void insert(const_iterator first, const_iterator last)
|
||||
void insert(const_iterator first, const_iterator last) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
// insert only works for objects
|
||||
if (JSON_HEDLEY_UNLIKELY(!is_object()))
|
||||
@ -3410,7 +3410,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
/// @brief updates a JSON object from another object, overwriting existing keys
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/update/
|
||||
void update(const_iterator first, const_iterator last, bool merge_objects = false)
|
||||
void update(const_iterator first, const_iterator last, bool merge_objects = false) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
// implicitly convert null value to an empty object
|
||||
if (is_null())
|
||||
@ -4011,12 +4011,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
template<typename InputType>
|
||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||
static basic_json parse(InputType&& i,
|
||||
const parser_callback_t& cb = nullptr,
|
||||
parser_callback_t& cb = nullptr,
|
||||
const bool allow_exceptions = true,
|
||||
const bool ignore_comments = false)
|
||||
{
|
||||
basic_json result;
|
||||
parser(detail::input_adapter(std::forward<InputType>(i)), cb, allow_exceptions, ignore_comments).parse(true, result);
|
||||
parser(detail::input_adapter(std::forward<InputType>(i)), std::move(cb), allow_exceptions, ignore_comments).parse(true, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -4026,24 +4026,24 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||
static basic_json parse(IteratorType first,
|
||||
IteratorType last,
|
||||
const parser_callback_t& cb = nullptr,
|
||||
parser_callback_t& cb = nullptr,
|
||||
const bool allow_exceptions = true,
|
||||
const bool ignore_comments = false)
|
||||
{
|
||||
basic_json result;
|
||||
parser(detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).parse(true, result);
|
||||
parser(detail::input_adapter(std::move(first), std::move(last)), std::move(cb), allow_exceptions, ignore_comments).parse(true, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, parse(ptr, ptr + len))
|
||||
static basic_json parse(detail::span_input_adapter&& i,
|
||||
const parser_callback_t cb = nullptr,
|
||||
parser_callback_t cb = nullptr,
|
||||
const bool allow_exceptions = true,
|
||||
const bool ignore_comments = false)
|
||||
{
|
||||
basic_json result;
|
||||
parser(i.get(), cb, allow_exceptions, ignore_comments).parse(true, result);
|
||||
parser(i.get(), std::move(cb), allow_exceptions, ignore_comments).parse(true, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -4731,7 +4731,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
};
|
||||
|
||||
// wrapper for "add" operation; add value at ptr
|
||||
const auto operation_add = [&result](json_pointer & ptr, basic_json val)
|
||||
const auto operation_add = [&result](json_pointer & ptr, const basic_json & val)
|
||||
{
|
||||
// adding to the root of the target document means replacing it
|
||||
if (ptr.empty())
|
||||
|
@ -162,6 +162,9 @@
|
||||
#include <forward_list> // forward_list
|
||||
#include <iterator> // inserter, front_inserter, end
|
||||
#include <map> // map
|
||||
#ifdef JSON_HAS_CPP_17
|
||||
#include <optional> // optional
|
||||
#endif
|
||||
#include <string> // string
|
||||
#include <tuple> // tuple, make_tuple
|
||||
#include <type_traits> // is_arithmetic, is_same, is_enum, underlying_type, is_convertible
|
||||
@ -169,6 +172,7 @@
|
||||
#include <utility> // pair, declval
|
||||
#include <valarray> // valarray
|
||||
|
||||
|
||||
// #include <nlohmann/detail/exceptions.hpp>
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
@ -4666,7 +4670,7 @@ namespace std_fs = std::experimental::filesystem;
|
||||
} // namespace detail
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
#elif JSON_HAS_FILESYSTEM
|
||||
#include <filesystem> // NOLINT(build/c++17)
|
||||
#include <filesystem> // NOLINT(build/c++17)
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
@ -4696,6 +4700,24 @@ inline void from_json(const BasicJsonType& j, typename std::nullptr_t& n)
|
||||
n = nullptr;
|
||||
}
|
||||
|
||||
#ifdef JSON_HAS_CPP_17
|
||||
#ifndef JSON_USE_IMPLICIT_CONVERSIONS
|
||||
template<typename BasicJsonType, typename T>
|
||||
void from_json(const BasicJsonType& j, std::optional<T>& opt)
|
||||
{
|
||||
if (j.is_null())
|
||||
{
|
||||
opt = std::nullopt;
|
||||
}
|
||||
else
|
||||
{
|
||||
opt.emplace(j.template get<T>());
|
||||
}
|
||||
}
|
||||
|
||||
#endif // JSON_USE_IMPLICIT_CONVERSIONS
|
||||
#endif // JSON_HAS_CPP_17
|
||||
|
||||
// overloads for basic_json template parameters
|
||||
template < typename BasicJsonType, typename ArithmeticType,
|
||||
enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
|
||||
@ -4930,14 +4952,7 @@ template < typename BasicJsonType, typename T, std::size_t... Idx >
|
||||
std::array<T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType&& j,
|
||||
identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/)
|
||||
{
|
||||
return { { std::forward<BasicJsonType>(j).at(Idx).template get < T&& > ()... } };
|
||||
}
|
||||
|
||||
template < typename BasicJsonType, typename T, std::size_t... Idx >
|
||||
std::array<T, sizeof...(Idx)> from_json_inplace_array_impl(const BasicJsonType& j,
|
||||
identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/)
|
||||
{
|
||||
return { { j.at(Idx).template get<T>()... } };
|
||||
return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
|
||||
}
|
||||
|
||||
template < typename BasicJsonType, typename T, std::size_t N >
|
||||
@ -5033,12 +5048,6 @@ inline void from_json(const BasicJsonType& j, ArithmeticType& val)
|
||||
}
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename... Args, std::size_t... Idx>
|
||||
std::tuple<Args...> from_json_tuple_impl_base(const BasicJsonType& j, index_sequence<Idx...> /*unused*/)
|
||||
{
|
||||
return std::make_tuple(j.at(Idx).template get<Args>()...);
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename... Args, std::size_t... Idx>
|
||||
std::tuple<Args...> from_json_tuple_impl_base(BasicJsonType&& j, index_sequence<Idx...> /*unused*/)
|
||||
{
|
||||
@ -5048,14 +5057,8 @@ std::tuple<Args...> from_json_tuple_impl_base(BasicJsonType&& j, index_sequence<
|
||||
template < typename BasicJsonType, class A1, class A2 >
|
||||
std::pair<A1, A2> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::pair<A1, A2>> /*unused*/, priority_tag<0> /*unused*/)
|
||||
{
|
||||
return {std::forward<BasicJsonType>(j).at(0).template get < A1&& > (),
|
||||
std::forward<BasicJsonType>(j).at(1).template get < A2&& > ()};
|
||||
}
|
||||
|
||||
template < typename BasicJsonType, class A1, class A2 >
|
||||
std::pair<A1, A2> from_json_tuple_impl(const BasicJsonType& j, identity_tag<std::pair<A1, A2>> /*unused*/, priority_tag<0> /*unused*/)
|
||||
{
|
||||
return {j.at(0).template get<A1>(), j.at(1).template get<A2>()};
|
||||
return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
|
||||
std::forward<BasicJsonType>(j).at(1).template get<A2>()};
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename A1, typename A2>
|
||||
@ -5181,6 +5184,9 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
|
||||
#include <algorithm> // copy
|
||||
#include <iterator> // begin, end
|
||||
#ifdef JSON_HAS_CPP_17
|
||||
#include <optional> // optional
|
||||
#endif
|
||||
#include <string> // string
|
||||
#include <tuple> // tuple, get
|
||||
#include <type_traits> // is_same, is_constructible, is_floating_point, is_enum, underlying_type
|
||||
@ -5200,7 +5206,7 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
|
||||
|
||||
#include <cstddef> // size_t
|
||||
#include <iterator> // input_iterator_tag
|
||||
#include <iterator> // forward_iterator_tag
|
||||
#include <string> // string, to_string
|
||||
#include <tuple> // tuple_size, get, tuple_element
|
||||
#include <utility> // move
|
||||
@ -5234,7 +5240,7 @@ template<typename IteratorType> class iteration_proxy_value
|
||||
using value_type = iteration_proxy_value;
|
||||
using pointer = value_type *;
|
||||
using reference = value_type &;
|
||||
using iterator_category = std::input_iterator_tag;
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
using string_type = typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().key() ) >::type >::type;
|
||||
|
||||
private:
|
||||
@ -5682,6 +5688,22 @@ struct external_constructor<value_t::object>
|
||||
// to_json //
|
||||
/////////////
|
||||
|
||||
#ifdef JSON_HAS_CPP_17
|
||||
template<typename BasicJsonType, typename T,
|
||||
enable_if_t<std::is_constructible<BasicJsonType, T>::value, int> = 0>
|
||||
void to_json(BasicJsonType& j, const std::optional<T>& opt)
|
||||
{
|
||||
if (opt.has_value())
|
||||
{
|
||||
j = *opt;
|
||||
}
|
||||
else
|
||||
{
|
||||
j = nullptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename BasicJsonType, typename T,
|
||||
enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value, int> = 0>
|
||||
inline void to_json(BasicJsonType& j, T b) noexcept
|
||||
@ -7037,7 +7059,7 @@ class json_sax_dom_callback_parser
|
||||
using parse_event_t = typename BasicJsonType::parse_event_t;
|
||||
|
||||
json_sax_dom_callback_parser(BasicJsonType& r,
|
||||
const parser_callback_t cb,
|
||||
parser_callback_t cb,
|
||||
const bool allow_exceptions_ = true)
|
||||
: root(r), callback(std::move(cb)), allow_exceptions(allow_exceptions_)
|
||||
{
|
||||
@ -8384,7 +8406,7 @@ class lexer : public lexer_base<BasicJsonType>
|
||||
locale's decimal point is used instead of `.` to work with the
|
||||
locale-dependent converters.
|
||||
*/
|
||||
token_type scan_number() // lgtm [cpp/use-of-goto]
|
||||
token_type scan_number() // lgtm [cpp/use-of-goto] `goto` is used in this function to implement the number-parsing state machine described above. By design, any finite input will eventually reach the "done" state or return token_type::parse_error. In each intermediate state, 1 byte of the input is appended to the token_buffer vector, and only the already initialized variables token_buffer, number_type, and error_message are manipulated.
|
||||
{
|
||||
// reset token_buffer to store the number's bytes
|
||||
reset();
|
||||
@ -12283,10 +12305,10 @@ class parser
|
||||
public:
|
||||
/// a parser reading from an input adapter
|
||||
explicit parser(InputAdapterType&& adapter,
|
||||
const parser_callback_t<BasicJsonType>& cb = nullptr,
|
||||
parser_callback_t<BasicJsonType> cb = nullptr,
|
||||
const bool allow_exceptions_ = true,
|
||||
const bool skip_comments = false)
|
||||
: callback(cb)
|
||||
: callback(std::move(cb))
|
||||
, m_lexer(std::move(adapter), skip_comments)
|
||||
, allow_exceptions(allow_exceptions_)
|
||||
{
|
||||
@ -15697,7 +15719,7 @@ class binary_writer
|
||||
case value_t::binary:
|
||||
{
|
||||
// step 0: determine if the binary type has a set subtype to
|
||||
// determine whether or not to use the ext or fixext types
|
||||
// determine whether to use the ext or fixext types
|
||||
const bool use_ext = j.m_data.m_value.binary->has_subtype();
|
||||
|
||||
// step 1: write control byte and the byte string length
|
||||
@ -19479,7 +19501,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
template<typename InputAdapterType>
|
||||
static ::nlohmann::detail::parser<basic_json, InputAdapterType> parser(
|
||||
InputAdapterType adapter,
|
||||
detail::parser_callback_t<basic_json>& cb = nullptr,
|
||||
detail::parser_callback_t<basic_json>cb = nullptr,
|
||||
const bool allow_exceptions = true,
|
||||
const bool ignore_comments = false
|
||||
)
|
||||
@ -20560,13 +20582,15 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
/// @brief move constructor
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/basic_json/
|
||||
basic_json(basic_json&& other) noexcept
|
||||
// check that passed value is valid (has to be done before forwarding)
|
||||
: json_base_class_t((other.assert_invariant(false), std::forward<json_base_class_t>(other))),
|
||||
m_data(std::move(other.m_data))// NOLINT(bugprone-use-after-move,hicpp-invalid-access-moved)
|
||||
: json_base_class_t(std::forward<json_base_class_t>(other)),
|
||||
m_data(std::move(other.m_data))
|
||||
{
|
||||
// check that passed value is valid
|
||||
other.assert_invariant(false);
|
||||
|
||||
// invalidate payload
|
||||
other.m_data.m_type = value_t::null; // NOLINT(bugprone-use-after-move,hicpp-invalid-access-moved)
|
||||
other.m_data.m_value = {};// NOLINT(bugprone-use-after-move,hicpp-invalid-access-moved)
|
||||
other.m_data.m_type = value_t::null;
|
||||
other.m_data.m_value = {};
|
||||
|
||||
set_parents();
|
||||
assert_invariant();
|
||||
@ -21358,7 +21382,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
auto it = m_data.m_value.object->find(std::forward<KeyType>(key));
|
||||
if (it == m_data.m_value.object->end())
|
||||
{
|
||||
JSON_THROW(out_of_range::create(403, "key not found (key is an rvalue and cannot be shown)", this));
|
||||
JSON_THROW(out_of_range::create(403, detail::concat("key '", string_t(std::forward<KeyType>(key)), "' not found"), this));
|
||||
}
|
||||
return set_parent(it->second);
|
||||
}
|
||||
@ -21396,7 +21420,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
auto it = m_data.m_value.object->find(std::forward<KeyType>(key));
|
||||
if (it == m_data.m_value.object->end())
|
||||
{
|
||||
JSON_THROW(out_of_range::create(403, "key not found (key is an rvalue and cannot be shown)", this));
|
||||
JSON_THROW(out_of_range::create(403, detail::concat("key '", string_t(std::forward<KeyType>(key)), "' not found"), this));
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
@ -21462,7 +21486,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
/// @brief access specified object element
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/operator%5B%5D/
|
||||
reference operator[](typename object_t::key_type key)
|
||||
reference operator[](typename object_t::key_type key) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
// implicitly convert null value to an empty object
|
||||
if (is_null())
|
||||
@ -21842,7 +21866,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
template < class IteratorType, detail::enable_if_t <
|
||||
std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
|
||||
std::is_same<IteratorType, typename basic_json_t::const_iterator>::value, int > = 0 >
|
||||
IteratorType erase(IteratorType first, IteratorType last)
|
||||
IteratorType erase(IteratorType first, IteratorType last) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
// make sure iterator fits the current value
|
||||
if (JSON_HEDLEY_UNLIKELY(this != first.m_object || this != last.m_object))
|
||||
@ -22609,7 +22633,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
/// @note: This uses std::distance to support GCC 4.8,
|
||||
/// see https://github.com/nlohmann/json/pull/1257
|
||||
template<typename... Args>
|
||||
iterator insert_iterator(const_iterator pos, Args&& ... args)
|
||||
iterator insert_iterator(const_iterator pos, Args&& ... args) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
iterator result(this);
|
||||
JSON_ASSERT(m_data.m_value.array != nullptr);
|
||||
@ -22628,7 +22652,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
/// @brief inserts element into array
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/insert/
|
||||
iterator insert(const_iterator pos, const basic_json& val)
|
||||
iterator insert(const_iterator pos, const basic_json& val) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
// insert only works for arrays
|
||||
if (JSON_HEDLEY_LIKELY(is_array()))
|
||||
@ -22648,14 +22672,14 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
/// @brief inserts element into array
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/insert/
|
||||
iterator insert(const_iterator pos, basic_json&& val)
|
||||
iterator insert(const_iterator pos, basic_json&& val) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
return insert(pos, val);
|
||||
}
|
||||
|
||||
/// @brief inserts copies of element into array
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/insert/
|
||||
iterator insert(const_iterator pos, size_type cnt, const basic_json& val)
|
||||
iterator insert(const_iterator pos, size_type cnt, const basic_json& val) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
// insert only works for arrays
|
||||
if (JSON_HEDLEY_LIKELY(is_array()))
|
||||
@ -22675,7 +22699,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
/// @brief inserts range of elements into array
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/insert/
|
||||
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
|
||||
iterator insert(const_iterator pos, const_iterator first, const_iterator last) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
// insert only works for arrays
|
||||
if (JSON_HEDLEY_UNLIKELY(!is_array()))
|
||||
@ -22706,7 +22730,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
/// @brief inserts elements from initializer list into array
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/insert/
|
||||
iterator insert(const_iterator pos, initializer_list_t ilist)
|
||||
iterator insert(const_iterator pos, initializer_list_t ilist) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
// insert only works for arrays
|
||||
if (JSON_HEDLEY_UNLIKELY(!is_array()))
|
||||
@ -22726,7 +22750,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
/// @brief inserts range of elements into object
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/insert/
|
||||
void insert(const_iterator first, const_iterator last)
|
||||
void insert(const_iterator first, const_iterator last) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
// insert only works for objects
|
||||
if (JSON_HEDLEY_UNLIKELY(!is_object()))
|
||||
@ -22758,7 +22782,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
/// @brief updates a JSON object from another object, overwriting existing keys
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/update/
|
||||
void update(const_iterator first, const_iterator last, bool merge_objects = false)
|
||||
void update(const_iterator first, const_iterator last, bool merge_objects = false) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
// implicitly convert null value to an empty object
|
||||
if (is_null())
|
||||
@ -23359,12 +23383,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
template<typename InputType>
|
||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||
static basic_json parse(InputType&& i,
|
||||
const parser_callback_t& cb = nullptr,
|
||||
parser_callback_t cb = nullptr,
|
||||
const bool allow_exceptions = true,
|
||||
const bool ignore_comments = false)
|
||||
{
|
||||
basic_json result;
|
||||
parser(detail::input_adapter(std::forward<InputType>(i)), cb, allow_exceptions, ignore_comments).parse(true, result);
|
||||
parser(detail::input_adapter(std::forward<InputType>(i)), std::move(cb), allow_exceptions, ignore_comments).parse(true, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -23374,24 +23398,24 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||
static basic_json parse(IteratorType first,
|
||||
IteratorType last,
|
||||
const parser_callback_t& cb = nullptr,
|
||||
parser_callback_t cb = nullptr,
|
||||
const bool allow_exceptions = true,
|
||||
const bool ignore_comments = false)
|
||||
{
|
||||
basic_json result;
|
||||
parser(detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).parse(true, result);
|
||||
parser(detail::input_adapter(std::move(first), std::move(last)), std::move(cb), allow_exceptions, ignore_comments).parse(true, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, parse(ptr, ptr + len))
|
||||
static basic_json parse(detail::span_input_adapter&& i,
|
||||
const parser_callback_t cb = nullptr,
|
||||
parser_callback_t cb = nullptr,
|
||||
const bool allow_exceptions = true,
|
||||
const bool ignore_comments = false)
|
||||
{
|
||||
basic_json result;
|
||||
parser(i.get(), cb, allow_exceptions, ignore_comments).parse(true, result);
|
||||
parser(i.get(), std::move(cb), allow_exceptions, ignore_comments).parse(true, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -24079,7 +24103,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
};
|
||||
|
||||
// wrapper for "add" operation; add value at ptr
|
||||
const auto operation_add = [&result](json_pointer & ptr, basic_json val)
|
||||
const auto operation_add = [&result](json_pointer & ptr, const basic_json & val)
|
||||
{
|
||||
// adding to the root of the target document means replacing it
|
||||
if (ptr.empty())
|
||||
|
@ -23,7 +23,7 @@ struct trait_test_arg
|
||||
static constexpr bool max_in_range = MaxInRange;
|
||||
};
|
||||
|
||||
TEST_CASE_TEMPLATE_DEFINE("value_in_range_of trait", T, value_in_range_of_test)
|
||||
TEST_CASE_TEMPLATE_DEFINE("value_in_range_of trait", T, value_in_range_of_test) // NOLINT(readability-math-missing-parentheses)
|
||||
{
|
||||
using nlohmann::detail::value_in_range_of;
|
||||
|
||||
|
@ -109,7 +109,7 @@ struct trait_test_arg
|
||||
static constexpr bool max_in_range = MaxInRange;
|
||||
};
|
||||
|
||||
TEST_CASE_TEMPLATE_DEFINE("value_in_range_of trait", T, value_in_range_of_test)
|
||||
TEST_CASE_TEMPLATE_DEFINE("value_in_range_of trait", T, value_in_range_of_test) // NOLINT(readability-math-missing-parentheses)
|
||||
{
|
||||
using nlohmann::detail::value_in_range_of;
|
||||
|
||||
@ -573,7 +573,7 @@ TEST_CASE("BJData")
|
||||
|
||||
// check individual bytes
|
||||
CHECK(result[0] == 'I');
|
||||
auto const restored = static_cast<uint16_t>(static_cast<uint8_t>(result[2]) * 256 + static_cast<uint8_t>(result[1]));
|
||||
auto const restored = static_cast<uint16_t>((static_cast<uint8_t>(result[2]) * 256) + static_cast<uint8_t>(result[1]));
|
||||
CHECK(restored == i);
|
||||
|
||||
// roundtrip
|
||||
@ -613,7 +613,7 @@ TEST_CASE("BJData")
|
||||
|
||||
// check individual bytes
|
||||
CHECK(result[0] == 'u');
|
||||
auto const restored = static_cast<uint16_t>(static_cast<uint8_t>(result[2]) * 256 + static_cast<uint8_t>(result[1]));
|
||||
auto const restored = static_cast<uint16_t>((static_cast<uint8_t>(result[2]) * 256) + static_cast<uint8_t>(result[1]));
|
||||
CHECK(restored == i);
|
||||
|
||||
// roundtrip
|
||||
@ -905,7 +905,7 @@ TEST_CASE("BJData")
|
||||
|
||||
// check individual bytes
|
||||
CHECK(result[0] == 'I');
|
||||
auto const restored = static_cast<uint16_t>(static_cast<uint8_t>(result[2]) * 256 + static_cast<uint8_t>(result[1]));
|
||||
auto const restored = static_cast<uint16_t>((static_cast<uint8_t>(result[2]) * 256) + static_cast<uint8_t>(result[1]));
|
||||
CHECK(restored == i);
|
||||
|
||||
// roundtrip
|
||||
@ -944,7 +944,7 @@ TEST_CASE("BJData")
|
||||
|
||||
// check individual bytes
|
||||
CHECK(result[0] == 'u');
|
||||
auto const restored = static_cast<uint16_t>(static_cast<uint8_t>(result[2]) * 256 + static_cast<uint8_t>(result[1]));
|
||||
auto const restored = static_cast<uint16_t>((static_cast<uint8_t>(result[2]) * 256) + static_cast<uint8_t>(result[1]));
|
||||
CHECK(restored == i);
|
||||
|
||||
// roundtrip
|
||||
|
@ -14,7 +14,6 @@ using nlohmann::json;
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <set>
|
||||
#include "make_test_data_available.hpp"
|
||||
@ -317,7 +316,7 @@ TEST_CASE("CBOR")
|
||||
|
||||
// check individual bytes
|
||||
CHECK(result[0] == 0x39);
|
||||
const auto restored = static_cast<uint16_t>(static_cast<uint8_t>(result[1]) * 256 + static_cast<uint8_t>(result[2]));
|
||||
const auto restored = static_cast<uint16_t>((static_cast<uint8_t>(result[1]) * 256) + static_cast<uint8_t>(result[2]));
|
||||
CHECK(restored == positive);
|
||||
CHECK(-1 - restored == i);
|
||||
|
||||
@ -505,7 +504,7 @@ TEST_CASE("CBOR")
|
||||
|
||||
// check individual bytes
|
||||
CHECK(result[0] == 0x19);
|
||||
const auto restored = static_cast<uint16_t>(static_cast<uint8_t>(result[1]) * 256 + static_cast<uint8_t>(result[2]));
|
||||
const auto restored = static_cast<uint16_t>((static_cast<uint8_t>(result[1]) * 256) + static_cast<uint8_t>(result[2]));
|
||||
CHECK(restored == i);
|
||||
|
||||
// roundtrip
|
||||
@ -744,7 +743,7 @@ TEST_CASE("CBOR")
|
||||
|
||||
// check individual bytes
|
||||
CHECK(result[0] == 0x19);
|
||||
const auto restored = static_cast<uint16_t>(static_cast<uint8_t>(result[1]) * 256 + static_cast<uint8_t>(result[2]));
|
||||
const auto restored = static_cast<uint16_t>((static_cast<uint8_t>(result[1]) * 256) + static_cast<uint8_t>(result[2]));
|
||||
CHECK(restored == i);
|
||||
|
||||
// roundtrip
|
||||
@ -990,7 +989,7 @@ TEST_CASE("CBOR")
|
||||
{
|
||||
0xfa, 0xff, 0x7f, 0xff, 0xff
|
||||
};
|
||||
// the same with lowest float
|
||||
// the same with the lowest float
|
||||
const auto result = json::to_cbor(j);
|
||||
CHECK(result == expected);
|
||||
// roundtrip
|
||||
|
@ -23,7 +23,7 @@ json::lexer::token_type scan_string(const char* s, const bool ignore_comments)
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::string get_error_message(const char* s, bool ignore_comments = false);
|
||||
std::string get_error_message(const char* s, bool ignore_comments = false); // NOLINT(misc-use-internal-linkage)
|
||||
std::string get_error_message(const char* s, const bool ignore_comments)
|
||||
{
|
||||
auto ia = nlohmann::detail::input_adapter(s);
|
||||
|
@ -28,10 +28,30 @@ using nlohmann::json;
|
||||
#include <unordered_set>
|
||||
#include <valarray>
|
||||
|
||||
|
||||
// NLOHMANN_JSON_SERIALIZE_ENUM uses a static std::pair
|
||||
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
|
||||
DOCTEST_CLANG_SUPPRESS_WARNING("-Wexit-time-destructors")
|
||||
|
||||
#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
|
||||
#define JSON_HAS_CPP_17
|
||||
#define JSON_HAS_CPP_14
|
||||
#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
|
||||
#define JSON_HAS_CPP_14
|
||||
#endif
|
||||
|
||||
#ifdef JSON_HAS_CPP_17
|
||||
#if __has_include(<optional>)
|
||||
#include <optional>
|
||||
#elif __has_include(<experimental/optional>)
|
||||
#include <experimental/optional>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HAS_CPP_17)
|
||||
#include <string_view>
|
||||
#endif
|
||||
|
||||
TEST_CASE("value conversion")
|
||||
{
|
||||
SECTION("get an object (explicit)")
|
||||
@ -153,6 +173,7 @@ TEST_CASE("value conversion")
|
||||
}
|
||||
|
||||
#if JSON_USE_IMPLICIT_CONVERSIONS
|
||||
|
||||
SECTION("get an object (implicit)")
|
||||
{
|
||||
const json::object_t o_reference = {{"object", json::object()},
|
||||
@ -1513,7 +1534,7 @@ NLOHMANN_JSON_SERIALIZE_ENUM(cards,
|
||||
{cards::karo, "karo"}
|
||||
})
|
||||
|
||||
enum TaskState
|
||||
enum TaskState // NOLINT(cert-int09-c,readability-enum-initial-value)
|
||||
{
|
||||
TS_STOPPED = 0,
|
||||
TS_RUNNING = 1,
|
||||
@ -1569,4 +1590,73 @@ TEST_CASE("JSON to enum mapping")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef JSON_HAS_CPP_17
|
||||
#ifndef JSON_USE_IMPLICIT_CONVERSIONS
|
||||
TEST_CASE("std::optional")
|
||||
{
|
||||
SECTION("null")
|
||||
{
|
||||
json j_null;
|
||||
std::optional<std::string> opt_null;
|
||||
|
||||
CHECK(json(opt_null) == j_null);
|
||||
CHECK(j_null.get<std::optional<std::string>>() == std::nullopt);
|
||||
}
|
||||
|
||||
SECTION("string")
|
||||
{
|
||||
json j_string = "string";
|
||||
std::optional<std::string> opt_string = "string";
|
||||
|
||||
CHECK(json(opt_string) == j_string);
|
||||
CHECK(std::optional<std::string>(j_string) == opt_string);
|
||||
}
|
||||
|
||||
SECTION("bool")
|
||||
{
|
||||
json j_bool = true;
|
||||
std::optional<bool> opt_bool = true;
|
||||
|
||||
CHECK(json(opt_bool) == j_bool);
|
||||
CHECK(std::optional<bool>(j_bool) == opt_bool);
|
||||
}
|
||||
|
||||
SECTION("number")
|
||||
{
|
||||
json j_number = 1;
|
||||
std::optional<int> opt_int = 1;
|
||||
|
||||
CHECK(json(opt_int) == j_number);
|
||||
CHECK(j_number.get<std::optional<int>>() == opt_int);
|
||||
}
|
||||
|
||||
SECTION("array")
|
||||
{
|
||||
json j_array = {1, 2, nullptr};
|
||||
std::vector<std::optional<int>> opt_array = {{1, 2, std::nullopt}};
|
||||
|
||||
CHECK(json(opt_array) == j_array);
|
||||
CHECK(j_array.get<std::vector<std::optional<int>>>() == opt_array);
|
||||
}
|
||||
|
||||
SECTION("object")
|
||||
{
|
||||
json j_object = {{"one", 1}, {"two", 2}, {"zero", nullptr}};
|
||||
std::map<std::string, std::optional<int>> opt_object {{"one", 1}, {"two", 2}, {"zero", std::nullopt}};
|
||||
|
||||
CHECK(json(opt_object) == j_object);
|
||||
CHECK(std::map<std::string, std::optional<int>>(j_object) == opt_object);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef JSON_HAS_CPP_17
|
||||
#undef JSON_HAS_CPP_17
|
||||
#endif
|
||||
|
||||
#ifdef JSON_HAS_CPP_14
|
||||
#undef JSON_HAS_CPP_14
|
||||
#endif
|
||||
DOCTEST_CLANG_SUPPRESS_WARNING_POP
|
||||
|
@ -1131,7 +1131,7 @@ TEST_CASE("deserialization")
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE_TEMPLATE("deserialization of different character types (ASCII)", T,
|
||||
TEST_CASE_TEMPLATE("deserialization of different character types (ASCII)", T, // NOLINT(readability-math-missing-parentheses)
|
||||
char, unsigned char, signed char,
|
||||
wchar_t,
|
||||
char16_t, char32_t,
|
||||
@ -1149,7 +1149,7 @@ TEST_CASE_TEMPLATE("deserialization of different character types (ASCII)", T,
|
||||
CHECK(l.events == std::vector<std::string>({"boolean(true)"}));
|
||||
}
|
||||
|
||||
TEST_CASE_TEMPLATE("deserialization of different character types (UTF-8)", T,
|
||||
TEST_CASE_TEMPLATE("deserialization of different character types (UTF-8)", T, // NOLINT(readability-math-missing-parentheses)
|
||||
char, unsigned char, std::uint8_t)
|
||||
{
|
||||
// a star emoji
|
||||
@ -1162,7 +1162,7 @@ TEST_CASE_TEMPLATE("deserialization of different character types (UTF-8)", T,
|
||||
CHECK(l.events.size() == 1);
|
||||
}
|
||||
|
||||
TEST_CASE_TEMPLATE("deserialization of different character types (UTF-16)", T,
|
||||
TEST_CASE_TEMPLATE("deserialization of different character types (UTF-16)", T, // NOLINT(readability-math-missing-parentheses)
|
||||
char16_t, std::uint16_t)
|
||||
{
|
||||
// a star emoji
|
||||
@ -1175,7 +1175,7 @@ TEST_CASE_TEMPLATE("deserialization of different character types (UTF-16)", T,
|
||||
CHECK(l.events.size() == 1);
|
||||
}
|
||||
|
||||
TEST_CASE_TEMPLATE("deserialization of different character types (UTF-32)", T,
|
||||
TEST_CASE_TEMPLATE("deserialization of different character types (UTF-32)", T, // NOLINT(readability-math-missing-parentheses)
|
||||
char32_t, std::uint32_t)
|
||||
{
|
||||
// a star emoji
|
||||
|
@ -55,7 +55,7 @@ TEST_CASE("element access 1")
|
||||
SECTION("null")
|
||||
{
|
||||
json j_nonarray(json::value_t::null);
|
||||
const json j_nonarray_const(j_nonarray);
|
||||
const json j_nonarray_const(j_nonarray); // NOLINT(performance-unnecessary-copy-initialization)
|
||||
|
||||
CHECK_THROWS_WITH_AS(j_nonarray.at(0), "[json.exception.type_error.304] cannot use at() with null", json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(j_nonarray_const.at(0), "[json.exception.type_error.304] cannot use at() with null", json::type_error&);
|
||||
@ -64,7 +64,7 @@ TEST_CASE("element access 1")
|
||||
SECTION("boolean")
|
||||
{
|
||||
json j_nonarray(json::value_t::boolean);
|
||||
const json j_nonarray_const(j_nonarray);
|
||||
const json j_nonarray_const(j_nonarray); // NOLINT(performance-unnecessary-copy-initialization)
|
||||
|
||||
CHECK_THROWS_WITH_AS(j_nonarray.at(0), "[json.exception.type_error.304] cannot use at() with boolean", json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(j_nonarray_const.at(0), "[json.exception.type_error.304] cannot use at() with boolean", json::type_error&);
|
||||
@ -73,7 +73,7 @@ TEST_CASE("element access 1")
|
||||
SECTION("string")
|
||||
{
|
||||
json j_nonarray(json::value_t::string);
|
||||
const json j_nonarray_const(j_nonarray);
|
||||
const json j_nonarray_const(j_nonarray); // NOLINT(performance-unnecessary-copy-initialization)
|
||||
|
||||
CHECK_THROWS_WITH_AS(j_nonarray.at(0), "[json.exception.type_error.304] cannot use at() with string", json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(j_nonarray_const.at(0), "[json.exception.type_error.304] cannot use at() with string", json::type_error&);
|
||||
@ -82,7 +82,7 @@ TEST_CASE("element access 1")
|
||||
SECTION("object")
|
||||
{
|
||||
json j_nonarray(json::value_t::object);
|
||||
const json j_nonarray_const(j_nonarray);
|
||||
const json j_nonarray_const(j_nonarray); // NOLINT(performance-unnecessary-copy-initialization)
|
||||
|
||||
CHECK_THROWS_WITH_AS(j_nonarray.at(0), "[json.exception.type_error.304] cannot use at() with object", json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(j_nonarray_const.at(0), "[json.exception.type_error.304] cannot use at() with object", json::type_error&);
|
||||
@ -91,7 +91,7 @@ TEST_CASE("element access 1")
|
||||
SECTION("number (integer)")
|
||||
{
|
||||
json j_nonarray(json::value_t::number_integer);
|
||||
const json j_nonarray_const(j_nonarray);
|
||||
const json j_nonarray_const(j_nonarray); // NOLINT(performance-unnecessary-copy-initialization)
|
||||
|
||||
CHECK_THROWS_WITH_AS(j_nonarray.at(0), "[json.exception.type_error.304] cannot use at() with number", json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(j_nonarray_const.at(0), "[json.exception.type_error.304] cannot use at() with number", json::type_error&);
|
||||
@ -100,7 +100,7 @@ TEST_CASE("element access 1")
|
||||
SECTION("number (unsigned)")
|
||||
{
|
||||
json j_nonarray(json::value_t::number_unsigned);
|
||||
const json j_nonarray_const(j_nonarray);
|
||||
const json j_nonarray_const(j_nonarray); // NOLINT(performance-unnecessary-copy-initialization)
|
||||
|
||||
CHECK_THROWS_WITH_AS(j_nonarray.at(0), "[json.exception.type_error.304] cannot use at() with number", json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(j_nonarray_const.at(0), "[json.exception.type_error.304] cannot use at() with number", json::type_error&);
|
||||
@ -109,7 +109,7 @@ TEST_CASE("element access 1")
|
||||
SECTION("number (floating-point)")
|
||||
{
|
||||
json j_nonarray(json::value_t::number_float);
|
||||
const json j_nonarray_const(j_nonarray);
|
||||
const json j_nonarray_const(j_nonarray); // NOLINT(performance-unnecessary-copy-initialization)
|
||||
|
||||
CHECK_THROWS_WITH_AS(j_nonarray.at(0), "[json.exception.type_error.304] cannot use at() with number", json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(j_nonarray_const.at(0), "[json.exception.type_error.304] cannot use at() with number", json::type_error&);
|
||||
@ -155,7 +155,7 @@ TEST_CASE("element access 1")
|
||||
SECTION("standard tests")
|
||||
{
|
||||
json j_nonarray(json::value_t::null);
|
||||
const json j_nonarray_const(j_nonarray);
|
||||
const json j_nonarray_const(j_nonarray); // NOLINT(performance-unnecessary-copy-initialization)
|
||||
CHECK_NOTHROW(j_nonarray[0]);
|
||||
CHECK_THROWS_WITH_AS(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with null", json::type_error&);
|
||||
}
|
||||
@ -171,7 +171,7 @@ TEST_CASE("element access 1")
|
||||
SECTION("boolean")
|
||||
{
|
||||
json j_nonarray(json::value_t::boolean);
|
||||
const json j_nonarray_const(j_nonarray);
|
||||
const json j_nonarray_const(j_nonarray); // NOLINT(performance-unnecessary-copy-initialization)
|
||||
CHECK_THROWS_WITH_AS(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with boolean", json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with boolean", json::type_error&);
|
||||
}
|
||||
@ -179,7 +179,7 @@ TEST_CASE("element access 1")
|
||||
SECTION("string")
|
||||
{
|
||||
json j_nonarray(json::value_t::string);
|
||||
const json j_nonarray_const(j_nonarray);
|
||||
const json j_nonarray_const(j_nonarray); // NOLINT(performance-unnecessary-copy-initialization)
|
||||
CHECK_THROWS_WITH_AS(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with string", json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with string", json::type_error&);
|
||||
}
|
||||
@ -187,7 +187,7 @@ TEST_CASE("element access 1")
|
||||
SECTION("object")
|
||||
{
|
||||
json j_nonarray(json::value_t::object);
|
||||
const json j_nonarray_const(j_nonarray);
|
||||
const json j_nonarray_const(j_nonarray); // NOLINT(performance-unnecessary-copy-initialization)
|
||||
CHECK_THROWS_WITH_AS(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with object", json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with object", json::type_error&);
|
||||
}
|
||||
@ -195,7 +195,7 @@ TEST_CASE("element access 1")
|
||||
SECTION("number (integer)")
|
||||
{
|
||||
json j_nonarray(json::value_t::number_integer);
|
||||
const json j_nonarray_const(j_nonarray);
|
||||
const json j_nonarray_const(j_nonarray); // NOLINT(performance-unnecessary-copy-initialization)
|
||||
CHECK_THROWS_WITH_AS(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number", json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number", json::type_error&);
|
||||
}
|
||||
@ -203,7 +203,7 @@ TEST_CASE("element access 1")
|
||||
SECTION("number (unsigned)")
|
||||
{
|
||||
json j_nonarray(json::value_t::number_unsigned);
|
||||
const json j_nonarray_const(j_nonarray);
|
||||
const json j_nonarray_const(j_nonarray); // NOLINT(performance-unnecessary-copy-initialization)
|
||||
CHECK_THROWS_WITH_AS(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number", json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number", json::type_error&);
|
||||
}
|
||||
@ -211,7 +211,7 @@ TEST_CASE("element access 1")
|
||||
SECTION("number (floating-point)")
|
||||
{
|
||||
json j_nonarray(json::value_t::number_float);
|
||||
const json j_nonarray_const(j_nonarray);
|
||||
const json j_nonarray_const(j_nonarray); // NOLINT(performance-unnecessary-copy-initialization)
|
||||
CHECK_THROWS_WITH_AS(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number", json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number", json::type_error&);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
// build test with C++14
|
||||
// JSON_HAS_CPP_14
|
||||
|
||||
TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_json)
|
||||
TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_json) // NOLINT(readability-math-missing-parentheses)
|
||||
{
|
||||
SECTION("object")
|
||||
{
|
||||
@ -88,7 +88,7 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j
|
||||
SECTION("null")
|
||||
{
|
||||
Json j_nonobject(Json::value_t::null);
|
||||
const Json j_nonobject_const(j_nonobject);
|
||||
const Json j_nonobject_const(j_nonobject); // NOLINT(performance-unnecessary-copy-initialization)
|
||||
CHECK_THROWS_WITH_AS(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with null", typename Json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with null", typename Json::type_error&);
|
||||
|
||||
@ -101,7 +101,7 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j
|
||||
SECTION("boolean")
|
||||
{
|
||||
Json j_nonobject(Json::value_t::boolean);
|
||||
const Json j_nonobject_const(j_nonobject);
|
||||
const Json j_nonobject_const(j_nonobject); // NOLINT(performance-unnecessary-copy-initialization)
|
||||
CHECK_THROWS_WITH_AS(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with boolean", typename Json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with boolean", typename Json::type_error&);
|
||||
|
||||
@ -114,7 +114,7 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j
|
||||
SECTION("string")
|
||||
{
|
||||
Json j_nonobject(Json::value_t::string);
|
||||
const Json j_nonobject_const(j_nonobject);
|
||||
const Json j_nonobject_const(j_nonobject); // NOLINT(performance-unnecessary-copy-initialization)
|
||||
CHECK_THROWS_WITH_AS(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with string", typename Json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with string", typename Json::type_error&);
|
||||
|
||||
@ -127,7 +127,7 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j
|
||||
SECTION("array")
|
||||
{
|
||||
Json j_nonobject(Json::value_t::array);
|
||||
const Json j_nonobject_const(j_nonobject);
|
||||
const Json j_nonobject_const(j_nonobject); // NOLINT(performance-unnecessary-copy-initialization)
|
||||
CHECK_THROWS_WITH_AS(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with array", typename Json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with array", typename Json::type_error&);
|
||||
|
||||
@ -140,7 +140,7 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j
|
||||
SECTION("number (integer)")
|
||||
{
|
||||
Json j_nonobject(Json::value_t::number_integer);
|
||||
const Json j_nonobject_const(j_nonobject);
|
||||
const Json j_nonobject_const(j_nonobject); // NOLINT(performance-unnecessary-copy-initialization)
|
||||
CHECK_THROWS_WITH_AS(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with number", typename Json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with number", typename Json::type_error&);
|
||||
|
||||
@ -153,7 +153,7 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j
|
||||
SECTION("number (unsigned)")
|
||||
{
|
||||
Json j_nonobject(Json::value_t::number_unsigned);
|
||||
const Json j_nonobject_const(j_nonobject);
|
||||
const Json j_nonobject_const(j_nonobject); // NOLINT(performance-unnecessary-copy-initialization)
|
||||
CHECK_THROWS_WITH_AS(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with number", typename Json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with number", typename Json::type_error&);
|
||||
|
||||
@ -166,7 +166,7 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j
|
||||
SECTION("number (floating-point)")
|
||||
{
|
||||
Json j_nonobject(Json::value_t::number_float);
|
||||
const Json j_nonobject_const(j_nonobject);
|
||||
const Json j_nonobject_const(j_nonobject); // NOLINT(performance-unnecessary-copy-initialization)
|
||||
CHECK_THROWS_WITH_AS(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with number", typename Json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with number", typename Json::type_error&);
|
||||
|
||||
@ -1461,7 +1461,7 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j
|
||||
}
|
||||
|
||||
#if !defined(JSON_NOEXCEPTION)
|
||||
TEST_CASE_TEMPLATE("element access 2 (throwing tests)", Json, nlohmann::json, nlohmann::ordered_json)
|
||||
TEST_CASE_TEMPLATE("element access 2 (throwing tests)", Json, nlohmann::json, nlohmann::ordered_json) // NOLINT(readability-math-missing-parentheses)
|
||||
{
|
||||
SECTION("object")
|
||||
{
|
||||
@ -1497,7 +1497,7 @@ TEST_CASE_TEMPLATE("element access 2 (throwing tests)", Json, nlohmann::json, nl
|
||||
#endif
|
||||
|
||||
// TODO(falbrechtskirchinger) merge with the other test case; clean up
|
||||
TEST_CASE_TEMPLATE("element access 2 (additional value() tests)", Json, nlohmann::json, nlohmann::ordered_json)
|
||||
TEST_CASE_TEMPLATE("element access 2 (additional value() tests)", Json, nlohmann::json, nlohmann::ordered_json) // NOLINT(readability-math-missing-parentheses)
|
||||
{
|
||||
using string_t = typename Json::string_t;
|
||||
using number_integer_t = typename Json::number_integer_t;
|
||||
|
@ -1305,7 +1305,7 @@ TEST_CASE("JSON patch")
|
||||
const auto& doc = test["doc"];
|
||||
const auto& patch = test["patch"];
|
||||
|
||||
if (test.count("error") == 0)
|
||||
if (test.count("error") == 0) // NOLINT(readability-container-contains)
|
||||
{
|
||||
// if an expected value is given, use it; use doc otherwise
|
||||
const auto& expected = test.value("expected", doc);
|
||||
|
@ -281,7 +281,7 @@ TEST_CASE("MessagePack")
|
||||
|
||||
// check individual bytes
|
||||
CHECK(result[0] == 0xcd);
|
||||
auto const restored = static_cast<uint16_t>(static_cast<uint8_t>(result[1]) * 256 + static_cast<uint8_t>(result[2]));
|
||||
auto const restored = static_cast<uint16_t>((static_cast<uint8_t>(result[1]) * 256) + static_cast<uint8_t>(result[2]));
|
||||
CHECK(restored == i);
|
||||
|
||||
// roundtrip
|
||||
@ -671,7 +671,7 @@ TEST_CASE("MessagePack")
|
||||
|
||||
// check individual bytes
|
||||
CHECK(result[0] == 0xcd);
|
||||
auto const restored = static_cast<uint16_t>(static_cast<uint8_t>(result[1]) * 256 + static_cast<uint8_t>(result[2]));
|
||||
auto const restored = static_cast<uint16_t>((static_cast<uint8_t>(result[1]) * 256) + static_cast<uint8_t>(result[2]));
|
||||
CHECK(restored == i);
|
||||
|
||||
// roundtrip
|
||||
|
@ -171,7 +171,7 @@ TEST_CASE("README" * doctest::skip())
|
||||
|
||||
// find an entry
|
||||
CHECK(o.find("foo") != o.end());
|
||||
if (o.find("foo") != o.end())
|
||||
if (o.find("foo") != o.end()) // NOLINT(readability-container-contains)
|
||||
{
|
||||
// there is an entry with key "foo"
|
||||
}
|
||||
|
@ -94,14 +94,14 @@ struct Data
|
||||
std::string b{}; // NOLINT(readability-redundant-member-init)
|
||||
};
|
||||
|
||||
void from_json(const json& j, Data& data);
|
||||
void from_json(const json& j, Data& data); // NOLINT(misc-use-internal-linkage)
|
||||
void from_json(const json& j, Data& data)
|
||||
{
|
||||
j["a"].get_to(data.a);
|
||||
j["b"].get_to(data.b);
|
||||
}
|
||||
|
||||
bool operator==(Data const& lhs, Data const& rhs);
|
||||
bool operator==(Data const& lhs, Data const& rhs); // NOLINT(misc-use-internal-linkage)
|
||||
bool operator==(Data const& lhs, Data const& rhs)
|
||||
{
|
||||
return lhs.a == rhs.a && lhs.b == rhs.b;
|
||||
@ -221,7 +221,7 @@ class FooBar
|
||||
Foo foo{}; // NOLINT(readability-redundant-member-init)
|
||||
};
|
||||
|
||||
inline void from_json(const nlohmann::json& j, FooBar& fb)
|
||||
inline void from_json(const nlohmann::json& j, FooBar& fb) // NOLINT(misc-use-internal-linkage)
|
||||
{
|
||||
j.at("value").get_to(fb.foo.value);
|
||||
}
|
||||
@ -249,7 +249,7 @@ struct for_3171_derived : public for_3171_base
|
||||
explicit for_3171_derived(const std::string& /*unused*/) { }
|
||||
};
|
||||
|
||||
inline void from_json(const json& j, for_3171_base& tb)
|
||||
inline void from_json(const json& j, for_3171_base& tb) // NOLINT(misc-use-internal-linkage)
|
||||
{
|
||||
tb._from_json(j);
|
||||
}
|
||||
@ -264,7 +264,7 @@ struct for_3312
|
||||
std::string name;
|
||||
};
|
||||
|
||||
inline void from_json(const json& j, for_3312& obj)
|
||||
inline void from_json(const json& j, for_3312& obj) // NOLINT(misc-use-internal-linkage)
|
||||
{
|
||||
j.at("name").get_to(obj.name);
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ TEST_CASE("serialization")
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE_TEMPLATE("serialization for extreme integer values", T, int32_t, uint32_t, int64_t, uint64_t)
|
||||
TEST_CASE_TEMPLATE("serialization for extreme integer values", T, int32_t, uint32_t, int64_t, uint64_t) // NOLINT(readability-math-missing-parentheses)
|
||||
{
|
||||
SECTION("minimum")
|
||||
{
|
||||
|
@ -163,7 +163,7 @@ TEST_CASE("compliance tests from nativejson-benchmark")
|
||||
TEST_DOUBLE("[2.2250738585072012e-308]",
|
||||
2.2250738585072014e-308);
|
||||
|
||||
// More closer to normal/subnormal boundary
|
||||
// Closer to normal/subnormal boundary
|
||||
// boundary = 2^-1022 - 2^-1075 = 2.225073858507201136057409796709131975934819546351645648... ¡Á 10^-308
|
||||
TEST_DOUBLE("[2.22507385850720113605740979670913197593481954635164564e-308]",
|
||||
2.2250738585072009e-308);
|
||||
@ -312,7 +312,7 @@ TEST_CASE("test suite from json-test-suite")
|
||||
{
|
||||
SECTION("read all sample.json")
|
||||
{
|
||||
// read a file with all unicode characters stored as single-character
|
||||
// read a file with all Unicode characters stored as single-character
|
||||
// strings in a JSON array
|
||||
std::ifstream f(TEST_DATA_DIRECTORY "/json_testsuite/sample.json");
|
||||
json j;
|
||||
|
@ -450,7 +450,7 @@ TEST_CASE("UBJSON")
|
||||
|
||||
// check individual bytes
|
||||
CHECK(result[0] == 'I');
|
||||
auto const restored = static_cast<uint16_t>(static_cast<uint8_t>(result[1]) * 256 + static_cast<uint8_t>(result[2]));
|
||||
auto const restored = static_cast<uint16_t>((static_cast<uint8_t>(result[1]) * 256) + static_cast<uint8_t>(result[2]));
|
||||
CHECK(restored == i);
|
||||
|
||||
// roundtrip
|
||||
@ -655,7 +655,7 @@ TEST_CASE("UBJSON")
|
||||
|
||||
// check individual bytes
|
||||
CHECK(result[0] == 'I');
|
||||
auto const restored = static_cast<uint16_t>(static_cast<uint8_t>(result[1]) * 256 + static_cast<uint8_t>(result[2]));
|
||||
auto const restored = static_cast<uint16_t>((static_cast<uint8_t>(result[1]) * 256) + static_cast<uint8_t>(result[2]));
|
||||
CHECK(restored == i);
|
||||
|
||||
// roundtrip
|
||||
|
@ -442,7 +442,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(person_without_default_constru
|
||||
|
||||
} // namespace persons
|
||||
|
||||
TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRUSIVE and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE", T,
|
||||
TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRUSIVE and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE", T, // NOLINT(readability-math-missing-parentheses)
|
||||
persons::person_with_private_data,
|
||||
persons::person_without_private_data_1,
|
||||
persons::person_without_private_data_2)
|
||||
@ -498,7 +498,7 @@ TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_DERIVED_TY
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE and NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE", T,
|
||||
TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE and NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE", T, // NOLINT(readability-math-missing-parentheses)
|
||||
persons::derived_person_with_private_data,
|
||||
persons::derived_person_without_private_data_1,
|
||||
persons::derived_person_without_private_data_2)
|
||||
@ -524,7 +524,7 @@ TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_DERIVED_TY
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT", T,
|
||||
TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT", T, // NOLINT(readability-math-missing-parentheses)
|
||||
persons::person_with_private_data_2,
|
||||
persons::person_without_private_data_3)
|
||||
{
|
||||
@ -558,7 +558,7 @@ TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRU
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT and NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT", T,
|
||||
TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT and NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT", T, // NOLINT(readability-math-missing-parentheses)
|
||||
persons::derived_person_with_private_data_2,
|
||||
persons::derived_person_without_private_data_3)
|
||||
{
|
||||
@ -594,7 +594,7 @@ TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_DERIVED_TY
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE_TEMPLATE("Serialization/deserialization of classes with 26 public/private member variables via NLOHMANN_DEFINE_TYPE_INTRUSIVE and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE", T,
|
||||
TEST_CASE_TEMPLATE("Serialization/deserialization of classes with 26 public/private member variables via NLOHMANN_DEFINE_TYPE_INTRUSIVE and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE", T, // NOLINT(readability-math-missing-parentheses)
|
||||
persons::person_with_private_alphabet,
|
||||
persons::person_with_public_alphabet)
|
||||
{
|
||||
@ -666,7 +666,7 @@ TEST_CASE_TEMPLATE("Serialization/deserialization of classes with 26 public/priv
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE_TEMPLATE("Serialization of non-default-constructible classes via NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE", T,
|
||||
TEST_CASE_TEMPLATE("Serialization of non-default-constructible classes via NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE", T, // NOLINT(readability-math-missing-parentheses)
|
||||
persons::person_without_default_constructor_1,
|
||||
persons::person_without_default_constructor_2)
|
||||
{
|
||||
|
@ -155,7 +155,7 @@ TEST_CASE("Unicode (1/5)" * doctest::skip())
|
||||
|
||||
SECTION("read all unicode characters")
|
||||
{
|
||||
// read a file with all unicode characters stored as single-character
|
||||
// read a file with all Unicode characters stored as single-character
|
||||
// strings in a JSON array
|
||||
std::ifstream f(TEST_DATA_DIRECTORY "/json_nlohmann_tests/all_unicode.json");
|
||||
json j;
|
||||
|
Reference in New Issue
Block a user