mirror of
https://github.com/nlohmann/json.git
synced 2026-04-12 02:59:00 +00:00
Merge branches 'develop' and 'feature/optional' of https://github.com/nlohmann/json into feature/optional
This commit is contained in:
@@ -8,23 +8,17 @@ jobs:
|
||||
- checkout
|
||||
|
||||
- run:
|
||||
name: Install sudo
|
||||
command: 'apt-get update && apt-get install -y sudo && rm -rf /var/lib/apt/lists/*'
|
||||
name: Install required tools
|
||||
command: 'apt-get update && apt-get install -y gcc g++ git cmake'
|
||||
- run:
|
||||
name: Install GCC
|
||||
command: 'apt-get update && apt-get install -y gcc g++'
|
||||
name: Show versions
|
||||
command: 'g++ --version ; uname -a; cmake --version'
|
||||
- run:
|
||||
name: Install CMake
|
||||
command: 'apt-get update && sudo apt-get install -y cmake'
|
||||
- run:
|
||||
name: Create build files
|
||||
name: Run CMake
|
||||
command: 'mkdir build ; cd build ; cmake ..'
|
||||
- run:
|
||||
name: Versions
|
||||
command: 'g++ --version ; uname -a'
|
||||
- run:
|
||||
name: Compile
|
||||
command: 'cmake --build build'
|
||||
- run:
|
||||
name: Execute test suite
|
||||
command: 'cd build ; ctest -j 2'
|
||||
command: 'cd build ; ctest --output-on-failure -j 2'
|
||||
|
||||
82
.doozer.json
82
.doozer.json
@@ -1,82 +0,0 @@
|
||||
{
|
||||
"targets": {
|
||||
"raspbian-jessie": {
|
||||
"buildenv": "raspbian-jessie",
|
||||
"builddeps": ["build-essential", "wget"],
|
||||
"buildcmd": [
|
||||
"uname -a",
|
||||
"cat /etc/os-release",
|
||||
"g++ --version",
|
||||
"cd",
|
||||
"wget https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz",
|
||||
"tar xfz cmake-3.14.0.tar.gz",
|
||||
"cd cmake-3.14.0",
|
||||
"./bootstrap",
|
||||
"make -j8",
|
||||
"cd",
|
||||
"mkdir build",
|
||||
"cd build",
|
||||
"../cmake-3.14.0/bin/cmake /project/repo/checkout",
|
||||
"make -j8",
|
||||
"../cmake-3.14.0/bin/ctest -VV -j4 --timeout 10000"
|
||||
]
|
||||
},
|
||||
"xenial-armhf": {
|
||||
"buildenv": "xenial-armhf",
|
||||
"builddeps": ["build-essential", "wget"],
|
||||
"buildcmd": [
|
||||
"uname -a",
|
||||
"lsb_release -a",
|
||||
"g++ --version",
|
||||
"cd",
|
||||
"wget --no-check-certificate https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz",
|
||||
"tar xfz cmake-3.14.0.tar.gz",
|
||||
"cd cmake-3.14.0",
|
||||
"./bootstrap",
|
||||
"make -j8",
|
||||
"cd",
|
||||
"mkdir build",
|
||||
"cd build",
|
||||
"../cmake-3.14.0/bin/cmake /project/repo/checkout",
|
||||
"make -j8",
|
||||
"../cmake-3.14.0/bin/ctest -VV -j4 --timeout 10000"
|
||||
]
|
||||
},
|
||||
"fedora24-x86_64": {
|
||||
"buildenv": "fedora24-x86_64",
|
||||
"builddeps": ["cmake", "make", "gcc gcc-c++"],
|
||||
"buildcmd": [
|
||||
"uname -a",
|
||||
"cat /etc/fedora-release",
|
||||
"g++ --version",
|
||||
"cd",
|
||||
"mkdir build",
|
||||
"cd build",
|
||||
"cmake /project/repo/checkout",
|
||||
"make -j8",
|
||||
"ctest -VV -j8"
|
||||
]
|
||||
},
|
||||
"centos7-x86_64": {
|
||||
"buildenv": "centos7-x86_64",
|
||||
"builddeps": ["make", "wget", "gcc-c++"],
|
||||
"buildcmd": [
|
||||
"uname -a",
|
||||
"rpm -q centos-release",
|
||||
"g++ --version",
|
||||
"cd",
|
||||
"wget https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz",
|
||||
"tar xfz cmake-3.14.0.tar.gz",
|
||||
"cd cmake-3.14.0",
|
||||
"./bootstrap",
|
||||
"make -j8",
|
||||
"cd",
|
||||
"mkdir build",
|
||||
"cd build",
|
||||
"../cmake-3.14.0/bin/cmake /project/repo/checkout",
|
||||
"make -j8",
|
||||
"../cmake-3.14.0/bin/ctest -VV -j8"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
@@ -1,6 +1,6 @@
|
||||
# JSON for Modern C++ has been originally written by Niels Lohmann.
|
||||
# Since 2013 over 140 contributors have helped to improve the library.
|
||||
# This CODEOWNERS file is only to make sure that @nlohmann is requsted
|
||||
# This CODEOWNERS file is only to make sure that @nlohmann is requested
|
||||
# for a code review in case of a pull request.
|
||||
|
||||
* @nlohmann
|
||||
|
||||
2
.github/CONTRIBUTING.md
vendored
2
.github/CONTRIBUTING.md
vendored
@@ -56,7 +56,7 @@ To make changes, you need to edit the following files:
|
||||
|
||||
- The C++11 support varies between different **compilers** and versions. Please note the [list of supported compilers](https://github.com/nlohmann/json/blob/master/README.md#supported-compilers). Some compilers like GCC 4.7 (and earlier), Clang 3.3 (and earlier), or Microsoft Visual Studio 13.0 and earlier are known not to work due to missing or incomplete C++11 support. Please refrain from proposing changes that work around these compiler's limitations with `#ifdef`s or other means.
|
||||
- Specifically, I am aware of compilation problems with **Microsoft Visual Studio** (there even is an [issue label](https://github.com/nlohmann/json/issues?utf8=✓&q=label%3A%22visual+studio%22+) for these kind of bugs). I understand that even in 2016, complete C++11 support isn't there yet. But please also understand that I do not want to drop features or uglify the code just to make Microsoft's sub-standard compiler happy. The past has shown that there are ways to express the functionality such that the code compiles with the most recent MSVC - unfortunately, this is not the main objective of the project.
|
||||
- Please refrain from proposing changes that would **break [JSON](http://json.org) conformance**. If you propose a conformant extension of JSON to be supported by the library, please motivate this extension.
|
||||
- Please refrain from proposing changes that would **break [JSON](https://json.org) conformance**. If you propose a conformant extension of JSON to be supported by the library, please motivate this extension.
|
||||
- We shall not extend the library to **support comments**. There is quite some [controversy](https://www.reddit.com/r/programming/comments/4v6chu/why_json_doesnt_support_comments_douglas_crockford/) around this topic, and there were quite some [issues](https://github.com/nlohmann/json/issues/376) on this. We believe that JSON is fine without comments.
|
||||
- We do not preserve the **insertion order of object elements**. The [JSON standard](https://tools.ietf.org/html/rfc7159.html) defines objects as "an unordered collection of zero or more name/value pairs". To this end, this library does not preserve insertion order of name/value pairs. (In fact, keys will be traversed in alphabetical order as `std::map` with `std::less` is used by default.) Note this behavior conforms to the standard, and we shall not change it to any other order. If you do want to preserve the insertion order, you can specialize the object type with containers like [`tsl::ordered_map`](https://github.com/Tessil/ordered-map) or [`nlohmann::fifo_map`](https://github.com/nlohmann/fifo_map).
|
||||
|
||||
|
||||
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -15,5 +15,5 @@ Read the [Contribution Guidelines](https://github.com/nlohmann/json/blob/develop
|
||||
|
||||
- The C++11 support varies between different **compilers** and versions. Please note the [list of supported compilers](https://github.com/nlohmann/json/blob/master/README.md#supported-compilers). Some compilers like GCC 4.7 (and earlier), Clang 3.3 (and earlier), or Microsoft Visual Studio 13.0 and earlier are known not to work due to missing or incomplete C++11 support. Please refrain from proposing changes that work around these compiler's limitations with `#ifdef`s or other means.
|
||||
- Specifically, I am aware of compilation problems with **Microsoft Visual Studio** (there even is an [issue label](https://github.com/nlohmann/json/issues?utf8=✓&q=label%3A%22visual+studio%22+) for these kind of bugs). I understand that even in 2016, complete C++11 support isn't there yet. But please also understand that I do not want to drop features or uglify the code just to make Microsoft's sub-standard compiler happy. The past has shown that there are ways to express the functionality such that the code compiles with the most recent MSVC - unfortunately, this is not the main objective of the project.
|
||||
- Please refrain from proposing changes that would **break [JSON](http://json.org) conformance**. If you propose a conformant extension of JSON to be supported by the library, please motivate this extension.
|
||||
- Please refrain from proposing changes that would **break [JSON](https://json.org) conformance**. If you propose a conformant extension of JSON to be supported by the library, please motivate this extension.
|
||||
- Please do not open pull requests that address **multiple issues**.
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -18,6 +18,9 @@ me.nlohmann.json.docset
|
||||
|
||||
benchmarks/files/numbers/*.json
|
||||
|
||||
.wsjcpp-logs/*
|
||||
.wsjcpp/*
|
||||
|
||||
.idea
|
||||
cmake-build-debug
|
||||
|
||||
|
||||
19
.travis.yml
19
.travis.yml
@@ -95,16 +95,17 @@ matrix:
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-4.9', 'ninja-build']
|
||||
packages: ['g++-7', 'ninja-build']
|
||||
before_script:
|
||||
- pip install --user cpp-coveralls
|
||||
after_success:
|
||||
- coveralls --build-root test --include include/nlohmann --gcov 'gcov-4.9' --gcov-options '\-lp'
|
||||
- coveralls --build-root test --include include/nlohmann --gcov 'gcov-7' --gcov-options '\-lp'
|
||||
env:
|
||||
- COMPILER=g++-4.9
|
||||
- COMPILER=g++-7
|
||||
- CMAKE_OPTIONS=-DJSON_Coverage=ON
|
||||
- MULTIPLE_HEADERS=ON
|
||||
|
||||
@@ -131,18 +132,6 @@ matrix:
|
||||
|
||||
# OSX / Clang
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode8.3
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode9
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode9.1
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode9.2
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode9.3
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"checkRunSettings": {
|
||||
"vulnerableCheckRunConclusionLevel": "failure"
|
||||
},
|
||||
"issueSettings": {
|
||||
"minSeverityLevel": "LOW"
|
||||
}
|
||||
}
|
||||
@@ -89,8 +89,13 @@ endif()
|
||||
## install header files, generate and install cmake config files for find_package()
|
||||
##
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file(
|
||||
${NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE} COMPATIBILITY SameMajorVersion
|
||||
# use a custom package version config file instead of
|
||||
# write_basic_package_version_file to ensure that it's architecture-independent
|
||||
# https://github.com/nlohmann/json/issues/1697
|
||||
configure_file(
|
||||
"cmake/nlohmann_jsonConfigVersion.cmake.in"
|
||||
${NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE}
|
||||
@ONLY
|
||||
)
|
||||
configure_file(
|
||||
${NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2013-2019 Niels Lohmann
|
||||
Copyright (c) 2013-2020 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
|
||||
|
||||
23
Makefile
23
Makefile
@@ -32,10 +32,8 @@ all:
|
||||
@echo "ChangeLog.md - generate ChangeLog file"
|
||||
@echo "check - compile and execute test suite"
|
||||
@echo "check-amalgamation - check whether sources have been amalgamated"
|
||||
@echo "check-fast - compile and execute test suite (skip long-running tests)"
|
||||
@echo "clean - remove built files"
|
||||
@echo "coverage - create coverage information with lcov"
|
||||
@echo "coverage-fast - create coverage information with fastcov"
|
||||
@echo "cppcheck - analyze code with cppcheck"
|
||||
@echo "cpplint - analyze code with cpplint"
|
||||
@echo "clang_tidy - analyze code with Clang-Tidy"
|
||||
@@ -65,10 +63,6 @@ json_unit:
|
||||
check:
|
||||
$(MAKE) check -C test
|
||||
|
||||
# run unit tests and skip expensive tests
|
||||
check-fast:
|
||||
$(MAKE) check -C test TEST_PATTERN=""
|
||||
|
||||
|
||||
##########################################################################
|
||||
# coverage
|
||||
@@ -77,21 +71,12 @@ check-fast:
|
||||
coverage:
|
||||
rm -fr build_coverage
|
||||
mkdir build_coverage
|
||||
cd build_coverage ; CXX=g++-8 cmake .. -GNinja -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON
|
||||
cd build_coverage ; cmake .. -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON
|
||||
cd build_coverage ; ninja
|
||||
cd build_coverage ; ctest -E '.*_default' -j10
|
||||
cd build_coverage ; ctest -j10
|
||||
cd build_coverage ; ninja lcov_html
|
||||
open build_coverage/test/html/index.html
|
||||
|
||||
coverage-fast:
|
||||
rm -fr build_coverage
|
||||
mkdir build_coverage
|
||||
cd build_coverage ; CXX=g++-9 cmake .. -GNinja -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON
|
||||
cd build_coverage ; ninja
|
||||
cd build_coverage ; ctest -E '.*_default' -j10
|
||||
cd build_coverage ; ninja fastcov_html
|
||||
open build_coverage/test/html/index.html
|
||||
|
||||
##########################################################################
|
||||
# documentation tests
|
||||
##########################################################################
|
||||
@@ -485,7 +470,7 @@ clang_sanitize:
|
||||
mkdir clang_sanitize_build
|
||||
cd clang_sanitize_build ; CXX=$(COMPILER_DIR)/clang++ cmake .. -DJSON_Sanitizer=On -DJSON_MultipleHeaders=ON -GNinja
|
||||
cd clang_sanitize_build ; ninja
|
||||
cd clang_sanitize_build ; ctest -E '.*_default' -j10
|
||||
cd clang_sanitize_build ; ctest -j10
|
||||
|
||||
|
||||
##########################################################################
|
||||
@@ -579,7 +564,7 @@ check_cmake_flags:
|
||||
NEXT_VERSION ?= "unreleased"
|
||||
|
||||
ChangeLog.md:
|
||||
github_changelog_generator -o ChangeLog.md --simple-list --release-url https://github.com/nlohmann/json/releases/tag/%s --future-release $(NEXT_VERSION)
|
||||
github_changelog_generator -o ChangeLog.md --user nlohmann --project json --simple-list --release-url https://github.com/nlohmann/json/releases/tag/%s --future-release $(NEXT_VERSION)
|
||||
$(SED) -i 's|https://github.com/nlohmann/json/releases/tag/HEAD|https://github.com/nlohmann/json/tree/HEAD|' ChangeLog.md
|
||||
$(SED) -i '2i All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).' ChangeLog.md
|
||||
|
||||
|
||||
91
README.md
91
README.md
@@ -8,9 +8,10 @@
|
||||
[](https://www.codacy.com/app/nlohmann/json?utm_source=github.com&utm_medium=referral&utm_content=nlohmann/json&utm_campaign=Badge_Grade)
|
||||
[](https://lgtm.com/projects/g/nlohmann/json/context:cpp)
|
||||
[](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:json)
|
||||
[](https://wandbox.org/permlink/TarF5pPn9NtHQjhf)
|
||||
[](https://wandbox.org/permlink/3lCHrFUZANONKv7a)
|
||||
[](http://nlohmann.github.io/json)
|
||||
[](https://raw.githubusercontent.com/nlohmann/json/master/LICENSE.MIT)
|
||||
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fnlohmann%2Fjson?ref=badge_shield)
|
||||
[](https://github.com/nlohmann/json/releases)
|
||||
[](https://github.com/nlohmann/json/releases)
|
||||
[](http://github.com/nlohmann/json/issues)
|
||||
@@ -19,6 +20,7 @@
|
||||
[](https://github.com/sponsors/nlohmann)
|
||||
|
||||
- [Design goals](#design-goals)
|
||||
- [Sponsors](#sponsors)
|
||||
- [Integration](#integration)
|
||||
- [CMake](#cmake)
|
||||
- [Package Managers](#package-managers)
|
||||
@@ -44,7 +46,7 @@
|
||||
|
||||
## Design goals
|
||||
|
||||
There are myriads of [JSON](http://json.org) libraries out there, and each may even have its reason to exist. Our class had these design goals:
|
||||
There are myriads of [JSON](https://json.org) libraries out there, and each may even have its reason to exist. Our class had these design goals:
|
||||
|
||||
- **Intuitive syntax**. In languages such as Python, JSON feels like a first class data type. We used all the operator magic of modern C++ to achieve the same feeling in your code. Check out the [examples below](#examples) and you'll know what I mean.
|
||||
|
||||
@@ -61,6 +63,19 @@ Other aspects were not so important to us:
|
||||
See the [contribution guidelines](https://github.com/nlohmann/json/blob/master/.github/CONTRIBUTING.md#please-dont) for more information.
|
||||
|
||||
|
||||
## Sponsors
|
||||
|
||||
You can sponsor this library at [GitHub Sponsors](https://github.com/sponsors/nlohmann).
|
||||
|
||||
### :label: Named Sponsors
|
||||
|
||||
- [Michael Hartmann](https://github.com/reFX-Mike)
|
||||
- [Stefan Hagen](https://github.com/sthagen)
|
||||
- [Steve Sperandeo](https://github.com/homer6)
|
||||
|
||||
Thanks everyone!
|
||||
|
||||
|
||||
## Integration
|
||||
|
||||
[`json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp) is the single required file in `single_include/nlohmann` or [released here](https://github.com/nlohmann/json/releases). You need to add
|
||||
@@ -119,6 +134,34 @@ 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 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
|
||||
|
||||
#### 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:
|
||||
@@ -159,11 +202,11 @@ If you are using the [Meson Build System](http://mesonbuild.com), add this sourc
|
||||
|
||||
The provided meson.build can also be used as an alternative to cmake for installing `nlohmann_json` system-wide in which case a pkg-config file is installed. To use it, simply have your build system require the `nlohmann_json` pkg-config dependency. In Meson, it is preferred to use the [`dependency()`](https://mesonbuild.com/Reference-manual.html#dependency) object with a subproject fallback, rather than using the subproject directly.
|
||||
|
||||
If you are using [Conan](https://www.conan.io/) to manage your dependencies, merely add `jsonformoderncpp/x.y.z@vthiery/stable` to your `conanfile.py`'s requires, where `x.y.z` is the release version you want to use. Please file issues [here](https://github.com/vthiery/conan-jsonformoderncpp/issues) if you experience problems with the packages.
|
||||
If you are using [Conan](https://www.conan.io/) to manage your dependencies, merely add `nlohmann_json/x.y.z` to your `conanfile`'s requires, where `x.y.z` is the release version you want to use. Please file issues [here](https://github.com/conan-io/conan-center-index/issues) if you experience problems with the packages.
|
||||
|
||||
If you are using [Spack](https://www.spack.io/) to manage your dependencies, you can use the [`nlohmann-json` package](https://spack.readthedocs.io/en/latest/package_list.html#nlohmann-json). Please see the [spack project](https://github.com/spack/spack) for any issues regarding the packaging.
|
||||
|
||||
If you are using [hunter](https://github.com/ruslo/hunter/) on your project for external dependencies, then you can use the [nlohmann_json package](https://docs.hunter.sh/en/latest/packages/pkg/nlohmann_json.html). Please see the hunter project for any issues regarding the packaging.
|
||||
If you are using [hunter](https://github.com/cpp-pm/hunter) on your project for external dependencies, then you can use the [nlohmann_json package](https://hunter.readthedocs.io/en/latest/packages/pkg/nlohmann_json.html). Please see the hunter project for any issues regarding the packaging.
|
||||
|
||||
If you are using [Buckaroo](https://buckaroo.pm), you can install this library's module with `buckaroo add github.com/buckaroo-pm/nlohmann-json`. Please file issues [here](https://github.com/buckaroo-pm/nlohmann-json). There is a demo repo [here](https://github.com/njlr/buckaroo-nholmann-json-example).
|
||||
|
||||
@@ -177,7 +220,12 @@ If you are using [NuGet](https://www.nuget.org), you can use the package [nlohma
|
||||
|
||||
If you are using [conda](https://conda.io/), you can use the package [nlohmann_json](https://github.com/conda-forge/nlohmann_json-feedstock) from [conda-forge](https://conda-forge.org) executing `conda install -c conda-forge nlohmann_json`. Please file issues [here](https://github.com/conda-forge/nlohmann_json-feedstock/issues).
|
||||
|
||||
If you are using [MSYS2](http://www.msys2.org/), your can use the [mingw-w64-nlohmann_json](https://packages.msys2.org/base/mingw-w64-nlohmann_json) package, just type `pacman -S mingw-w64-i686-nlohmann_json` or `pacman -S mingw-w64-x86_64-nlohmann_json` for installation. Please file issues [here](https://github.com/msys2/MINGW-packages/issues/new?title=%5Bnlohmann_json%5D) if you experience problems with the packages.
|
||||
If you are using [MSYS2](http://www.msys2.org/), your can use the [mingw-w64-nlohmann-json](https://packages.msys2.org/base/mingw-w64-nlohmann-json) package, just type `pacman -S mingw-w64-i686-nlohmann-json` or `pacman -S mingw-w64-x86_64-nlohmann-json` for installation. Please file issues [here](https://github.com/msys2/MINGW-packages/issues/new?title=%5Bnlohmann-json%5D) if you experience problems with the packages.
|
||||
|
||||
If you are using [`build2`](https://build2.org), you can use the [`nlohmann-json`](https://cppget.org/nlohmann-json) package from the public repository http://cppget.org or directly from the [package's sources repository](https://github.com/build2-packaging/nlohmann-json). In your project's `manifest` file, just add `depends: nlohmann-json` (probably with some [version constraints](https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml#guide-add-remove-deps)). If you are not familiar with using dependencies in `build2`, [please read this introduction](https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml).
|
||||
Please file issues [here](https://github.com/build2-packaging/nlohmann-json) if you experience problems with the packages.
|
||||
|
||||
If you are using [`wsjcpp`](http://wsjcpp.org), you can use the command `wsjcpp install "https://github.com/nlohmann/json:develop"` to get the latest version. Note you can change the branch ":develop" to an existing tag or another branch.
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -285,7 +333,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/classnlohmann_1_1basic__json_afd4ef1ac8ad50a5894a9afebca69140a.html#afd4ef1ac8ad50a5894a9afebca69140a):
|
||||
The above example can also be expressed explicitly using [`json::parse()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a265a473e939184aa42655c9ccdf34e58.html#a265a473e939184aa42655c9ccdf34e58):
|
||||
|
||||
```cpp
|
||||
// parse explicitly
|
||||
@@ -296,7 +344,7 @@ You can also get a string representation of a JSON value (serialize):
|
||||
|
||||
```cpp
|
||||
// explicit conversion to string
|
||||
std::string s = j.dump(); // {\"happy\":true,\"pi\":3.141}
|
||||
std::string s = j.dump(); // {"happy":true,"pi":3.141}
|
||||
|
||||
// serialization with pretty printing
|
||||
// pass in the amount of spaces to indent
|
||||
@@ -452,7 +500,7 @@ j[1] = 42;
|
||||
bool foo = j.at(2);
|
||||
|
||||
// comparison
|
||||
j == "[\"foo\", 1, true]"_json; // true
|
||||
j == "[\"foo\", 42, true]"_json; // true
|
||||
|
||||
// other stuff
|
||||
j.size(); // 3 entries
|
||||
@@ -1026,22 +1074,18 @@ Please note:
|
||||
|
||||
The code compiles successfully with [Android NDK](https://developer.android.com/ndk/index.html?hl=ml), Revision 9 - 11 (and possibly later) and [CrystaX's Android NDK](https://www.crystax.net/en/android/ndk) version 10.
|
||||
|
||||
- For GCC running on MinGW or Android SDK, the error `'to_string' is not a member of 'std'` (or similarly, for `strtod`) may occur. Note this is not an issue with the code, but rather with the compiler itself. On Android, see above to build with a newer environment. For MinGW, please refer to [this site](http://tehsausage.com/mingw-to-string) and [this discussion](https://github.com/nlohmann/json/issues/136) for information on how to fix this bug. For Android NDK using `APP_STL := gnustl_static`, please refer to [this discussion](https://github.com/nlohmann/json/issues/219).
|
||||
- For GCC running on MinGW or Android SDK, the error `'to_string' is not a member of 'std'` (or similarly, for `strtod` or `strtof`) may occur. Note this is not an issue with the code, but rather with the compiler itself. On Android, see above to build with a newer environment. For MinGW, please refer to [this site](http://tehsausage.com/mingw-to-string) and [this discussion](https://github.com/nlohmann/json/issues/136) for information on how to fix this bug. For Android NDK using `APP_STL := gnustl_static`, please refer to [this discussion](https://github.com/nlohmann/json/issues/219).
|
||||
|
||||
- Unsupported versions of GCC and Clang are rejected by `#error` directives. This can be switched off by defining `JSON_SKIP_UNSUPPORTED_COMPILER_CHECK`. Note that you can expect no support in this case.
|
||||
|
||||
The following compilers are currently used in continuous integration at [Travis](https://travis-ci.org/nlohmann/json), [AppVeyor](https://ci.appveyor.com/project/nlohmann/json), [CircleCI](https://circleci.com/gh/nlohmann/json), and [Doozer](https://doozer.io):
|
||||
The following compilers are currently used in continuous integration at [Travis](https://travis-ci.org/nlohmann/json), [AppVeyor](https://ci.appveyor.com/project/nlohmann/json), and [CircleCI](https://circleci.com/gh/nlohmann/json):
|
||||
|
||||
| Compiler | Operating System | Version String |
|
||||
|-----------------------|------------------------------|----------------|
|
||||
| GCC 4.8.5 | Ubuntu 14.04.5 LTS | g++-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.2) 4.8.5 |
|
||||
| GCC 4.8.5 | CentOS Release-7-6.1810.2.el7.centos.x86_64 | g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36) |
|
||||
| GCC 4.9.2 (armv7l) | Raspbian GNU/Linux 8 (jessie) | g++ (Raspbian 4.9.2-10+deb8u2) 4.9.2 |
|
||||
| GCC 4.9.4 | Ubuntu 14.04.1 LTS | g++-4.9 (Ubuntu 4.9.4-2ubuntu1~14.04.1) 4.9.4 |
|
||||
| GCC 5.3.1 (armv7l) | Ubuntu 16.04 LTS | g++ (Ubuntu/Linaro 5.3.1-14ubuntu2) 5.3.1 20160413 |
|
||||
| GCC 5.5.0 | Ubuntu 14.04.1 LTS | g++-5 (Ubuntu 5.5.0-12ubuntu1~14.04) 5.5.0 20171010 |
|
||||
| GCC 6.3.0 | Debian 9 (stretch) | g++ (Debian 6.3.0-18+deb9u1) 6.3.0 20170516 |
|
||||
| GCC 6.3.1 | Fedora release 24 (Twenty Four) | g++ (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1) |
|
||||
| GCC 6.4.0 | Ubuntu 14.04.1 LTS | g++-6 (Ubuntu 6.4.0-17ubuntu1~14.04) 6.4.0 20180424 |
|
||||
| GCC 7.3.0 | Ubuntu 14.04.1 LTS | g++-7 (Ubuntu 7.3.0-21ubuntu1~14.04) 7.3.0 |
|
||||
| GCC 7.3.0 | Windows Server 2012 R2 (x64) | g++ (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 7.3.0 |
|
||||
@@ -1056,10 +1100,6 @@ The following compilers are currently used in continuous integration at [Travis]
|
||||
| Clang 5.0.2 | Ubuntu 14.04.1 LTS | clang version 5.0.2-svn328729-1~exp1~20180509123505.100 (branches/release_50) |
|
||||
| Clang 6.0.1 | Ubuntu 14.04.1 LTS | clang version 6.0.1-svn334776-1~exp1~20180726133705.85 (branches/release_60) |
|
||||
| Clang 7.0.1 | Ubuntu 14.04.1 LTS | clang version 7.0.1-svn348686-1~exp1~20181213084532.54 (branches/release_70) |
|
||||
| Clang Xcode 8.3 | OSX 10.11.6 | Apple LLVM version 8.1.0 (clang-802.0.38) |
|
||||
| Clang Xcode 9.0 | OSX 10.12.6 | Apple LLVM version 9.0.0 (clang-900.0.37) |
|
||||
| Clang Xcode 9.1 | OSX 10.12.6 | Apple LLVM version 9.0.0 (clang-900.0.38) |
|
||||
| Clang Xcode 9.2 | OSX 10.13.3 | Apple LLVM version 9.1.0 (clang-902.0.39.1) |
|
||||
| Clang Xcode 9.3 | OSX 10.13.3 | Apple LLVM version 9.1.0 (clang-902.0.39.2) |
|
||||
| Clang Xcode 10.0 | OSX 10.13.3 | Apple LLVM version 10.0.0 (clang-1000.11.45.2) |
|
||||
| Clang Xcode 10.1 | OSX 10.13.3 | Apple LLVM version 10.0.0 (clang-1000.11.45.5) |
|
||||
@@ -1303,16 +1343,14 @@ The library itself consists of a single header file licensed under the MIT licen
|
||||
- [**AppVeyor**](https://www.appveyor.com) for [continuous integration](https://ci.appveyor.com/project/nlohmann/json) on Windows
|
||||
- [**Artistic Style**](http://astyle.sourceforge.net) for automatic source code indentation
|
||||
- [**CircleCI**](http://circleci.com) for [continuous integration](https://circleci.com/gh/nlohmann/json).
|
||||
- [**Clang**](http://clang.llvm.org) for compilation with code sanitizers
|
||||
- [**Clang**](https://clang.llvm.org) for compilation with code sanitizers
|
||||
- [**CMake**](https://cmake.org) for build automation
|
||||
- [**Codacity**](https://www.codacy.com) for further [code analysis](https://www.codacy.com/app/nlohmann/json)
|
||||
- [**Coveralls**](https://coveralls.io) to measure [code coverage](https://coveralls.io/github/nlohmann/json)
|
||||
- [**Coverity Scan**](https://scan.coverity.com) for [static analysis](https://scan.coverity.com/projects/nlohmann-json)
|
||||
- [**cppcheck**](http://cppcheck.sourceforge.net) for static analysis
|
||||
- [**doctest**](https://github.com/onqtam/doctest) for the unit tests
|
||||
- [**Doozer**](https://doozer.io) for [continuous integration](https://doozer.io/nlohmann/json) on Linux (CentOS, Raspbian, Fedora)
|
||||
- [**Doxygen**](http://www.stack.nl/~dimitri/doxygen/) to generate [documentation](https://nlohmann.github.io/json/)
|
||||
- [**fastcov**](https://github.com/RPGillespie6/fastcov) to process coverage information
|
||||
- [**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
|
||||
@@ -1324,7 +1362,7 @@ The library itself consists of a single header file licensed under the MIT licen
|
||||
- [**send_to_wandbox**](https://github.com/nlohmann/json/blob/develop/doc/scripts/send_to_wandbox.py) to send code examples to [Wandbox](http://melpon.org/wandbox)
|
||||
- [**Travis**](https://travis-ci.org) for [continuous integration](https://travis-ci.org/nlohmann/json) on Linux and macOS
|
||||
- [**Valgrind**](http://valgrind.org) to check for correct memory management
|
||||
- [**Wandbox**](http://melpon.org/wandbox) for [online examples](https://wandbox.org/permlink/TarF5pPn9NtHQjhf)
|
||||
- [**Wandbox**](http://melpon.org/wandbox) for [online examples](https://wandbox.org/permlink/3lCHrFUZANONKv7a)
|
||||
|
||||
|
||||
## Projects using JSON for Modern C++
|
||||
@@ -1369,6 +1407,15 @@ This library will not support comments in the future. If you wish to use comment
|
||||
|
||||
By default, the library does not preserve the **insertion order of object elements**. This is standards-compliant, as the [JSON standard](https://tools.ietf.org/html/rfc8259.html) defines objects as "an unordered collection of zero or more name/value pairs". If you do want to preserve the insertion order, you can specialize the object type with containers like [`tsl::ordered_map`](https://github.com/Tessil/ordered-map) ([integration](https://github.com/nlohmann/json/issues/546#issuecomment-304447518)) or [`nlohmann::fifo_map`](https://github.com/nlohmann/fifo_map) ([integration](https://github.com/nlohmann/json/issues/485#issuecomment-333652309)).
|
||||
|
||||
### Memory Release
|
||||
|
||||
We checked with Valgrind and the Address Sanitizer (ASAN) that there are no memory leaks.
|
||||
|
||||
If you find that a parsing program with this library does not release memory, please consider the following case and it maybe unrelated to this library.
|
||||
|
||||
**Your program is compiled with glibc.** There is a tunable threshold that glibc uses to decide whether to actually return memory to the system or whether to cache it for later reuse. If in your program you make lots of small allocations and those small allocations are not a contiguous block and are presumably below the threshold, then they will not get returned to the OS.
|
||||
Here is a related issue [#1924](https://github.com/nlohmann/json/issues/1924).
|
||||
|
||||
### Further notes
|
||||
|
||||
- The code contains numerous debug **assertions** which can be switched off by defining the preprocessor macro `NDEBUG`, see the [documentation of `assert`](https://en.cppreference.com/w/cpp/error/assert). In particular, note [`operator[]`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a233b02b0839ef798942dd46157cc0fe6.html#a233b02b0839ef798942dd46157cc0fe6) 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/classnlohmann_1_1basic__json_a73ae333487310e3302135189ce8ff5d8.html#a73ae333487310e3302135189ce8ff5d8).
|
||||
|
||||
@@ -85,7 +85,7 @@ environment:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
configuration: Release
|
||||
platform: x64
|
||||
CXX_FLAGS: "/permissive- /std:c++latest /utf-8 /F4000000"
|
||||
CXX_FLAGS: "/permissive- /std:c++latest /Zc:__cplusplus /utf-8 /F4000000"
|
||||
LINKER_FLAGS: "/STACK:4000000"
|
||||
GENERATOR: Visual Studio 15 2017
|
||||
|
||||
@@ -123,4 +123,4 @@ test_script:
|
||||
# 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_all" -C "%configuration%" -V -j
|
||||
- if "%configuration%"=="Debug" ctest --exclude-regex "test-unicode" -C "%configuration%" -V -j
|
||||
|
||||
@@ -14,15 +14,12 @@ add_subdirectory(thirdparty/benchmark)
|
||||
include_directories(thirdparty)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/../single_include)
|
||||
|
||||
# copy test files to build folder
|
||||
file(COPY ${CMAKE_SOURCE_DIR}/data DESTINATION .)
|
||||
file(COPY ${CMAKE_SOURCE_DIR}/../test/data/regression/floats.json
|
||||
${CMAKE_SOURCE_DIR}/../test/data/regression/unsigned_ints.json
|
||||
${CMAKE_SOURCE_DIR}/../test/data/regression/signed_ints.json
|
||||
${CMAKE_SOURCE_DIR}/../test/data/regression/small_signed_ints.json
|
||||
DESTINATION data/numbers)
|
||||
# download test data
|
||||
include(${CMAKE_SOURCE_DIR}/../cmake/download_test_data.cmake)
|
||||
|
||||
# benchmark binary
|
||||
add_executable(json_benchmarks src/benchmarks.cpp)
|
||||
target_compile_features(json_benchmarks PRIVATE cxx_std_11)
|
||||
target_link_libraries(json_benchmarks benchmark ${CMAKE_THREAD_LIBS_INIT})
|
||||
add_dependencies(json_benchmarks download_test_data)
|
||||
target_include_directories(json_benchmarks PRIVATE ${CMAKE_BINARY_DIR}/include)
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
#include "benchmark/benchmark.h"
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <fstream>
|
||||
#include <test_data.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@@ -28,14 +29,14 @@ static void ParseFile(benchmark::State& state, const char* filename)
|
||||
std::ifstream file(filename, std::ios::binary | std::ios::ate);
|
||||
state.SetBytesProcessed(state.iterations() * file.tellg());
|
||||
}
|
||||
BENCHMARK_CAPTURE(ParseFile, jeopardy, "data/jeopardy/jeopardy.json");
|
||||
BENCHMARK_CAPTURE(ParseFile, canada, "data/nativejson-benchmark/canada.json");
|
||||
BENCHMARK_CAPTURE(ParseFile, citm_catalog, "data/nativejson-benchmark/citm_catalog.json");
|
||||
BENCHMARK_CAPTURE(ParseFile, twitter, "data/nativejson-benchmark/twitter.json");
|
||||
BENCHMARK_CAPTURE(ParseFile, floats, "data/numbers/floats.json");
|
||||
BENCHMARK_CAPTURE(ParseFile, signed_ints, "data/numbers/signed_ints.json");
|
||||
BENCHMARK_CAPTURE(ParseFile, unsigned_ints, "data/numbers/unsigned_ints.json");
|
||||
BENCHMARK_CAPTURE(ParseFile, small_signed_ints, "data/numbers/small_signed_ints.json");
|
||||
BENCHMARK_CAPTURE(ParseFile, jeopardy, TEST_DATA_DIRECTORY "/jeopardy/jeopardy.json");
|
||||
BENCHMARK_CAPTURE(ParseFile, canada, TEST_DATA_DIRECTORY "/nativejson-benchmark/canada.json");
|
||||
BENCHMARK_CAPTURE(ParseFile, citm_catalog, TEST_DATA_DIRECTORY "/nativejson-benchmark/citm_catalog.json");
|
||||
BENCHMARK_CAPTURE(ParseFile, twitter, TEST_DATA_DIRECTORY "/nativejson-benchmark/twitter.json");
|
||||
BENCHMARK_CAPTURE(ParseFile, floats, TEST_DATA_DIRECTORY "/regression/floats.json");
|
||||
BENCHMARK_CAPTURE(ParseFile, signed_ints, TEST_DATA_DIRECTORY "/regression/signed_ints.json");
|
||||
BENCHMARK_CAPTURE(ParseFile, unsigned_ints, TEST_DATA_DIRECTORY "/regression/unsigned_ints.json");
|
||||
BENCHMARK_CAPTURE(ParseFile, small_signed_ints, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// parse JSON from string
|
||||
@@ -61,14 +62,14 @@ static void ParseString(benchmark::State& state, const char* filename)
|
||||
|
||||
state.SetBytesProcessed(state.iterations() * str.size());
|
||||
}
|
||||
BENCHMARK_CAPTURE(ParseString, jeopardy, "data/jeopardy/jeopardy.json");
|
||||
BENCHMARK_CAPTURE(ParseString, canada, "data/nativejson-benchmark/canada.json");
|
||||
BENCHMARK_CAPTURE(ParseString, citm_catalog, "data/nativejson-benchmark/citm_catalog.json");
|
||||
BENCHMARK_CAPTURE(ParseString, twitter, "data/nativejson-benchmark/twitter.json");
|
||||
BENCHMARK_CAPTURE(ParseString, floats, "data/numbers/floats.json");
|
||||
BENCHMARK_CAPTURE(ParseString, signed_ints, "data/numbers/signed_ints.json");
|
||||
BENCHMARK_CAPTURE(ParseString, unsigned_ints, "data/numbers/unsigned_ints.json");
|
||||
BENCHMARK_CAPTURE(ParseString, small_signed_ints, "data/numbers/small_signed_ints.json");
|
||||
BENCHMARK_CAPTURE(ParseString, jeopardy, TEST_DATA_DIRECTORY "/jeopardy/jeopardy.json");
|
||||
BENCHMARK_CAPTURE(ParseString, canada, TEST_DATA_DIRECTORY "/nativejson-benchmark/canada.json");
|
||||
BENCHMARK_CAPTURE(ParseString, citm_catalog, TEST_DATA_DIRECTORY "/nativejson-benchmark/citm_catalog.json");
|
||||
BENCHMARK_CAPTURE(ParseString, twitter, TEST_DATA_DIRECTORY "/nativejson-benchmark/twitter.json");
|
||||
BENCHMARK_CAPTURE(ParseString, floats, TEST_DATA_DIRECTORY "/regression/floats.json");
|
||||
BENCHMARK_CAPTURE(ParseString, signed_ints, TEST_DATA_DIRECTORY "/regression/signed_ints.json");
|
||||
BENCHMARK_CAPTURE(ParseString, unsigned_ints, TEST_DATA_DIRECTORY "/regression/unsigned_ints.json");
|
||||
BENCHMARK_CAPTURE(ParseString, small_signed_ints, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json");
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -88,22 +89,22 @@ static void Dump(benchmark::State& state, const char* filename, int indent)
|
||||
|
||||
state.SetBytesProcessed(state.iterations() * j.dump(indent).size());
|
||||
}
|
||||
BENCHMARK_CAPTURE(Dump, jeopardy / -, "data/jeopardy/jeopardy.json", -1);
|
||||
BENCHMARK_CAPTURE(Dump, jeopardy / 4, "data/jeopardy/jeopardy.json", 4);
|
||||
BENCHMARK_CAPTURE(Dump, canada / -, "data/nativejson-benchmark/canada.json", -1);
|
||||
BENCHMARK_CAPTURE(Dump, canada / 4, "data/nativejson-benchmark/canada.json", 4);
|
||||
BENCHMARK_CAPTURE(Dump, citm_catalog / -, "data/nativejson-benchmark/citm_catalog.json", -1);
|
||||
BENCHMARK_CAPTURE(Dump, citm_catalog / 4, "data/nativejson-benchmark/citm_catalog.json", 4);
|
||||
BENCHMARK_CAPTURE(Dump, twitter / -, "data/nativejson-benchmark/twitter.json", -1);
|
||||
BENCHMARK_CAPTURE(Dump, twitter / 4, "data/nativejson-benchmark/twitter.json", 4);
|
||||
BENCHMARK_CAPTURE(Dump, floats / -, "data/numbers/floats.json", -1);
|
||||
BENCHMARK_CAPTURE(Dump, floats / 4, "data/numbers/floats.json", 4);
|
||||
BENCHMARK_CAPTURE(Dump, signed_ints / -, "data/numbers/signed_ints.json", -1);
|
||||
BENCHMARK_CAPTURE(Dump, signed_ints / 4, "data/numbers/signed_ints.json", 4);
|
||||
BENCHMARK_CAPTURE(Dump, unsigned_ints / -, "data/numbers/unsigned_ints.json", -1);
|
||||
BENCHMARK_CAPTURE(Dump, unsigned_ints / 4, "data/numbers/unsigned_ints.json", 4);
|
||||
BENCHMARK_CAPTURE(Dump, small_signed_ints / -, "data/numbers/small_signed_ints.json", -1);
|
||||
BENCHMARK_CAPTURE(Dump, small_signed_ints / 4, "data/numbers/small_signed_ints.json", 4);
|
||||
BENCHMARK_CAPTURE(Dump, jeopardy / -, TEST_DATA_DIRECTORY "/jeopardy/jeopardy.json", -1);
|
||||
BENCHMARK_CAPTURE(Dump, jeopardy / 4, TEST_DATA_DIRECTORY "/jeopardy/jeopardy.json", 4);
|
||||
BENCHMARK_CAPTURE(Dump, canada / -, TEST_DATA_DIRECTORY "/nativejson-benchmark/canada.json", -1);
|
||||
BENCHMARK_CAPTURE(Dump, canada / 4, TEST_DATA_DIRECTORY "/nativejson-benchmark/canada.json", 4);
|
||||
BENCHMARK_CAPTURE(Dump, citm_catalog / -, TEST_DATA_DIRECTORY "/nativejson-benchmark/citm_catalog.json", -1);
|
||||
BENCHMARK_CAPTURE(Dump, citm_catalog / 4, TEST_DATA_DIRECTORY "/nativejson-benchmark/citm_catalog.json", 4);
|
||||
BENCHMARK_CAPTURE(Dump, twitter / -, TEST_DATA_DIRECTORY "/nativejson-benchmark/twitter.json", -1);
|
||||
BENCHMARK_CAPTURE(Dump, twitter / 4, TEST_DATA_DIRECTORY "/nativejson-benchmark/twitter.json", 4);
|
||||
BENCHMARK_CAPTURE(Dump, floats / -, TEST_DATA_DIRECTORY "/regression/floats.json", -1);
|
||||
BENCHMARK_CAPTURE(Dump, floats / 4, TEST_DATA_DIRECTORY "/regression/floats.json", 4);
|
||||
BENCHMARK_CAPTURE(Dump, signed_ints / -, TEST_DATA_DIRECTORY "/regression/signed_ints.json", -1);
|
||||
BENCHMARK_CAPTURE(Dump, signed_ints / 4, TEST_DATA_DIRECTORY "/regression/signed_ints.json", 4);
|
||||
BENCHMARK_CAPTURE(Dump, unsigned_ints / -, TEST_DATA_DIRECTORY "/regression/unsigned_ints.json", -1);
|
||||
BENCHMARK_CAPTURE(Dump, unsigned_ints / 4, TEST_DATA_DIRECTORY "/regression/unsigned_ints.json", 4);
|
||||
BENCHMARK_CAPTURE(Dump, small_signed_ints / -, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json", -1);
|
||||
BENCHMARK_CAPTURE(Dump, small_signed_ints / 4, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json", 4);
|
||||
|
||||
|
||||
BENCHMARK_MAIN();
|
||||
|
||||
14
cmake/download_test_data.cmake
Normal file
14
cmake/download_test_data.cmake
Normal file
@@ -0,0 +1,14 @@
|
||||
find_package(Git)
|
||||
|
||||
set(JSON_TEST_DATA_URL https://github.com/nlohmann/json_test_data)
|
||||
set(JSON_TEST_DATA_VERSION 2.0.0)
|
||||
|
||||
# target to download test data
|
||||
add_custom_target(download_test_data
|
||||
COMMAND test -d json_test_data || ${GIT_EXECUTABLE} clone -c advice.detachedHead=false --branch v${JSON_TEST_DATA_VERSION} ${JSON_TEST_DATA_URL}.git --quiet --depth 1
|
||||
COMMENT "Downloading test data from ${JSON_TEST_DATA_URL} (v${JSON_TEST_DATA_VERSION})"
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
|
||||
# create a header with the path to the downloaded test data
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/include/test_data.hpp "#define TEST_DATA_DIRECTORY \"${CMAKE_BINARY_DIR}/json_test_data\"\n")
|
||||
20
cmake/nlohmann_jsonConfigVersion.cmake.in
Normal file
20
cmake/nlohmann_jsonConfigVersion.cmake.in
Normal file
@@ -0,0 +1,20 @@
|
||||
# This is essentially cmake's BasicConfigVersion-SameMajorVersion.cmake.in but
|
||||
# without the 32/64-bit check. Since json is a header-only library, it doesn't
|
||||
# matter if it was built on a different platform than what it is used on (see
|
||||
# https://github.com/nlohmann/json/issues/1697).
|
||||
set(PACKAGE_VERSION "@PROJECT_VERSION@")
|
||||
|
||||
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
|
||||
if(PACKAGE_FIND_VERSION_MAJOR STREQUAL "@PROJECT_VERSION_MAJOR@")
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
else()
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
endif()
|
||||
|
||||
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
|
||||
set(PACKAGE_VERSION_EXACT TRUE)
|
||||
endif()
|
||||
endif()
|
||||
12
doc/Doxyfile
12
doc/Doxyfile
@@ -1,4 +1,4 @@
|
||||
# Doxyfile 1.8.16
|
||||
# Doxyfile 1.8.19
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
@@ -23,6 +23,7 @@ STRIP_FROM_PATH =
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
JAVADOC_BANNER = NO
|
||||
QT_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
INHERIT_DOCS = YES
|
||||
@@ -33,7 +34,6 @@ ALIASES = "complexity=@par Complexity^^" \
|
||||
"requirement=@par Requirements^^" \
|
||||
"exceptionsafety=@par Exception safety^^" \
|
||||
"iterators=@par Iterator validity^^"
|
||||
TCL_SUBST =
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
OPTIMIZE_FOR_FORTRAN = NO
|
||||
@@ -59,6 +59,7 @@ LOOKUP_CACHE_SIZE = 0
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = YES
|
||||
EXTRACT_PRIVATE = NO
|
||||
EXTRACT_PRIV_VIRTUAL = NO
|
||||
EXTRACT_PACKAGE = YES
|
||||
EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
@@ -140,9 +141,6 @@ REFERENCES_LINK_SOURCE = NO
|
||||
SOURCE_TOOLTIPS = YES
|
||||
USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = NO
|
||||
CLANG_ASSISTED_PARSING = YES
|
||||
CLANG_OPTIONS = -std=c++11
|
||||
CLANG_DATABASE_PATH =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -194,8 +192,10 @@ GENERATE_TREEVIEW = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
TREEVIEW_WIDTH = 250
|
||||
EXT_LINKS_IN_WINDOW = NO
|
||||
HTML_FORMULA_FORMAT = png
|
||||
FORMULA_FONTSIZE = 10
|
||||
FORMULA_TRANSPARENT = YES
|
||||
FORMULA_MACROFILE =
|
||||
USE_MATHJAX = NO
|
||||
MATHJAX_FORMAT = HTML-CSS
|
||||
MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
|
||||
@@ -293,12 +293,10 @@ GENERATE_TAGFILE = html/nlohmann_json.tag
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
EXTERNAL_PAGES = YES
|
||||
PERL_PATH = /usr/bin/perl
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = NO
|
||||
MSCGEN_PATH =
|
||||
DIA_PATH =
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = YES
|
||||
|
||||
@@ -6,7 +6,7 @@ using json = nlohmann::json;
|
||||
int main()
|
||||
{
|
||||
// create JSON object
|
||||
json object =
|
||||
const json object =
|
||||
{
|
||||
{"the good", "il buono"},
|
||||
{"the bad", "il cattivo"},
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="https://wandbox.org/permlink/Zh3iTnZNxsSgBvm3"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/PjhAXOF8TTuwibn6"><b>online</b></a>
|
||||
@@ -8,7 +8,7 @@ int main()
|
||||
// create an array value
|
||||
json array = {1, 2, 3, 4, 5};
|
||||
|
||||
// get am iterator to the first element
|
||||
// get an iterator to the first element
|
||||
json::iterator it = array.begin();
|
||||
|
||||
// serialize the element that the iterator points to
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="https://wandbox.org/permlink/xKAi3HGAdCU5y2dS"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/I1e2Y91igQv2vxbo"><b>online</b></a>
|
||||
@@ -8,7 +8,7 @@ int main()
|
||||
// create an array value
|
||||
const json array = {1, 2, 3, 4, 5};
|
||||
|
||||
// get am iterator to the first element
|
||||
// get an iterator to the first element
|
||||
json::const_iterator it = array.cbegin();
|
||||
|
||||
// serialize the element that the iterator points to
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="https://wandbox.org/permlink/oKNo3GDUa9cxjgVB"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/tGoAEO2RoudxXWUz"><b>online</b></a>
|
||||
@@ -8,7 +8,7 @@ int main()
|
||||
// create an array value
|
||||
json array = {1, 2, 3, 4, 5};
|
||||
|
||||
// get am iterator to one past the last element
|
||||
// get an iterator to one past the last element
|
||||
json::const_iterator it = array.cend();
|
||||
|
||||
// decrement the iterator to point to the last element
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="https://wandbox.org/permlink/mP4cOSG4MtXmXlFw"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/KtW1m39B30RYkl5h"><b>online</b></a>
|
||||
@@ -14,14 +14,12 @@ int main()
|
||||
std::cout << std::boolalpha
|
||||
<< j.contains("/number"_json_pointer) << '\n'
|
||||
<< j.contains("/string"_json_pointer) << '\n'
|
||||
<< j.contains("/string"_json_pointer) << '\n'
|
||||
<< j.contains("/array"_json_pointer) << '\n'
|
||||
<< j.contains("/array/1"_json_pointer) << '\n'
|
||||
<< j.contains("/array/-"_json_pointer) << '\n'
|
||||
<< j.contains("/array/4"_json_pointer) << '\n'
|
||||
<< j.contains("/baz"_json_pointer) << std::endl;
|
||||
|
||||
// out_of_range.106
|
||||
try
|
||||
{
|
||||
// try to use an array index with leading '0'
|
||||
@@ -32,7 +30,6 @@ int main()
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
|
||||
// out_of_range.109
|
||||
try
|
||||
{
|
||||
// try to use an array index that is not a number
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="https://wandbox.org/permlink/3TJ79OzHP4vmN1Nb"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/aIuHXNvIdSGowMgG"><b>online</b></a>
|
||||
@@ -2,9 +2,6 @@ true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
[json.exception.parse_error.106] parse error: array index '01' must not begin with '0'
|
||||
[json.exception.parse_error.109] parse error: array index 'one' is not a number
|
||||
|
||||
@@ -8,7 +8,7 @@ int main()
|
||||
// create a JSON object
|
||||
json j_object = {{"one", 1}, {"two", 2}};
|
||||
|
||||
// call find
|
||||
// call count()
|
||||
auto count_two = j_object.count("two");
|
||||
auto count_three = j_object.count("three");
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="https://wandbox.org/permlink/4qmbLSA75stzPgtZ"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/k52yOvuKAXPQl1ou"><b>online</b></a>
|
||||
@@ -8,7 +8,7 @@ int main()
|
||||
// create an array value
|
||||
json array = {1, 2, 3, 4, 5};
|
||||
|
||||
// get am iterator to one past the last element
|
||||
// get an iterator to one past the last element
|
||||
json::iterator it = array.end();
|
||||
|
||||
// decrement the iterator to point to the last element
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="https://wandbox.org/permlink/rSTMI3VXUFtNCWNc"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/65ClUAO2rdvXIuKi"><b>online</b></a>
|
||||
@@ -13,7 +13,7 @@ int main()
|
||||
json j_array = {1, 2, 4, 8, 16};
|
||||
json j_string = "Hello, world";
|
||||
|
||||
// call erase
|
||||
// call erase()
|
||||
j_boolean.erase(j_boolean.begin());
|
||||
j_number_integer.erase(j_number_integer.begin());
|
||||
j_number_float.erase(j_number_float.begin());
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="https://wandbox.org/permlink/nh51Nho7iuAAAPyk"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/x9qygfrgrfjgjNpC"><b>online</b></a>
|
||||
@@ -13,7 +13,7 @@ int main()
|
||||
json j_array = {1, 2, 4, 8, 16};
|
||||
json j_string = "Hello, world";
|
||||
|
||||
// call erase
|
||||
// call erase()
|
||||
j_boolean.erase(j_boolean.begin(), j_boolean.end());
|
||||
j_number_integer.erase(j_number_integer.begin(), j_number_integer.end());
|
||||
j_number_float.erase(j_number_float.begin(), j_number_float.end());
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="https://wandbox.org/permlink/xqf45a27zQqgthtB"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/G48ghomtqfwbG4OB"><b>online</b></a>
|
||||
@@ -8,7 +8,7 @@ int main()
|
||||
// create a JSON object
|
||||
json j_object = {{"one", 1}, {"two", 2}};
|
||||
|
||||
// call erase
|
||||
// call erase()
|
||||
auto count_one = j_object.erase("one");
|
||||
auto count_three = j_object.erase("three");
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="https://wandbox.org/permlink/lMcaGzTQuWn44ly1"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/8OiyguvJR3l15ail"><b>online</b></a>
|
||||
@@ -8,7 +8,7 @@ int main()
|
||||
// create a JSON array
|
||||
json j_array = {0, 1, 2, 3, 4, 5};
|
||||
|
||||
// call erase
|
||||
// call erase()
|
||||
j_array.erase(2);
|
||||
|
||||
// print values
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="https://wandbox.org/permlink/7fA2QoclBNAGZprY"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/099bRQB6gKnhVuVl"><b>online</b></a>
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="https://wandbox.org/permlink/eFzRNyod3g4aVkvl"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/Q7kpLxPf3Gh3jA4c"><b>online</b></a>
|
||||
@@ -2,7 +2,7 @@
|
||||
"compiler": {
|
||||
"c++": "201103",
|
||||
"family": "clang",
|
||||
"version": "11.0.0 (clang-1100.0.33.8)"
|
||||
"version": "11.0.3 (clang-1103.0.32.59)"
|
||||
},
|
||||
"copyright": "(C) 2013-2017 Niels Lohmann",
|
||||
"name": "JSON for Modern C++",
|
||||
|
||||
@@ -6,7 +6,7 @@ using json = nlohmann::json;
|
||||
int main()
|
||||
{
|
||||
// create JSON array
|
||||
json array = {"first", "2nd", "third", "fourth"};
|
||||
const json array = {"first", "2nd", "third", "fourth"};
|
||||
|
||||
// output element at index 2 (third element)
|
||||
std::cout << array.at(2) << '\n';
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="https://wandbox.org/permlink/K8peAfoiWbp1wSqq"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/SWqjjMQTNClOhE08"><b>online</b></a>
|
||||
@@ -79,6 +79,12 @@ class sax_event_consumer : public json::json_sax_t
|
||||
return true;
|
||||
}
|
||||
|
||||
bool binary(binary_t& val) override
|
||||
{
|
||||
events.push_back("binary");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
|
||||
{
|
||||
events.push_back("error: " + std::string(ex.what()));
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="https://wandbox.org/permlink/fGkQLWbQn7enKkIG"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/AoOilNQQoDbzgBYz"><b>online</b></a>
|
||||
@@ -80,8 +80,8 @@ Note that this table only lists those exceptions thrown due to the type. For ins
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th rowspan="2">group</td>
|
||||
<th rowspan="2">function</td>
|
||||
<th rowspan="2">group</th>
|
||||
<th rowspan="2">function</th>
|
||||
<th colspan="6">JSON value type</th>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -24,7 +24,7 @@ import urllib2
|
||||
|
||||
# Strips C and C++ comments from the given string.
|
||||
#
|
||||
# Copied from http://stackoverflow.com/a/241506/627587.
|
||||
# Copied from https://stackoverflow.com/a/241506/627587.
|
||||
def strip_comments(text):
|
||||
def replacer(match):
|
||||
s = match.group(0)
|
||||
@@ -42,7 +42,7 @@ def strip_comments(text):
|
||||
# Post the given JSON data to Wandbox's API, and return the result
|
||||
# as a JSON object.
|
||||
def upload(options):
|
||||
request = urllib2.Request('http://melpon.org/wandbox/api/compile.json')
|
||||
request = urllib2.Request('https://melpon.org/wandbox/api/compile.json')
|
||||
request.add_header('Content-Type', 'application/json')
|
||||
response = urllib2.urlopen(request, json.dumps(options))
|
||||
return json.loads(response.read())
|
||||
|
||||
@@ -990,11 +990,11 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent,
|
||||
// digits[000]
|
||||
// len <= max_exp + 2
|
||||
|
||||
std::memset(buf + k, '0', static_cast<size_t>(n - k));
|
||||
std::memset(buf + k, '0', static_cast<size_t>(n) - static_cast<size_t>(k));
|
||||
// Make it look like a floating-point number (#362, #378)
|
||||
buf[n + 0] = '.';
|
||||
buf[n + 1] = '0';
|
||||
return buf + (n + 2);
|
||||
return buf + (static_cast<size_t>(n) + 2);
|
||||
}
|
||||
|
||||
if (0 < n and n <= max_exp)
|
||||
@@ -1004,9 +1004,9 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent,
|
||||
|
||||
assert(k > n);
|
||||
|
||||
std::memmove(buf + (n + 1), buf + n, static_cast<size_t>(k - n));
|
||||
std::memmove(buf + (static_cast<size_t>(n) + 1), buf + n, static_cast<size_t>(k) - static_cast<size_t>(n));
|
||||
buf[n] = '.';
|
||||
return buf + (k + 1);
|
||||
return buf + (static_cast<size_t>(k) + 1U);
|
||||
}
|
||||
|
||||
if (min_exp < n and n <= 0)
|
||||
@@ -1014,11 +1014,11 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent,
|
||||
// 0.[000]digits
|
||||
// len <= 2 + (-min_exp - 1) + max_digits10
|
||||
|
||||
std::memmove(buf + (2 + -n), buf, static_cast<size_t>(k));
|
||||
std::memmove(buf + (2 + static_cast<size_t>(-n)), buf, static_cast<size_t>(k));
|
||||
buf[0] = '0';
|
||||
buf[1] = '.';
|
||||
std::memset(buf + 2, '0', static_cast<size_t>(-n));
|
||||
return buf + (2 + (-n) + k);
|
||||
return buf + (2U + static_cast<size_t>(-n) + static_cast<size_t>(k));
|
||||
}
|
||||
|
||||
if (k == 1)
|
||||
@@ -1033,9 +1033,9 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent,
|
||||
// d.igitsE+123
|
||||
// len <= max_digits10 + 1 + 5
|
||||
|
||||
std::memmove(buf + 2, buf + 1, static_cast<size_t>(k - 1));
|
||||
std::memmove(buf + 2, buf + 1, static_cast<size_t>(k) - 1);
|
||||
buf[1] = '.';
|
||||
buf += 1 + k;
|
||||
buf += 1 + static_cast<size_t>(k);
|
||||
}
|
||||
|
||||
*buf++ = 'e';
|
||||
|
||||
@@ -67,6 +67,28 @@ struct external_constructor<value_t::string>
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct external_constructor<value_t::binary>
|
||||
{
|
||||
template<typename BasicJsonType>
|
||||
static void construct(BasicJsonType& j, const typename BasicJsonType::binary_t& b)
|
||||
{
|
||||
j.m_type = value_t::binary;
|
||||
typename BasicJsonType::internal_binary_t value{b};
|
||||
j.m_value = value;
|
||||
j.assert_invariant();
|
||||
}
|
||||
|
||||
template<typename BasicJsonType>
|
||||
static void construct(BasicJsonType& j, typename BasicJsonType::binary_t&& b)
|
||||
{
|
||||
j.m_type = value_t::binary;
|
||||
typename BasicJsonType::internal_binary_t value{std::move(b)};
|
||||
j.m_value = value;
|
||||
j.assert_invariant();
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct external_constructor<value_t::number_float>
|
||||
{
|
||||
|
||||
@@ -24,6 +24,20 @@ namespace nlohmann
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
/*!
|
||||
@brief determine system byte order
|
||||
|
||||
@return true if and only if system's byte order is little endian
|
||||
|
||||
@note from https://stackoverflow.com/a/1001328/266378
|
||||
*/
|
||||
static bool little_endianess(int num = 1) noexcept
|
||||
{
|
||||
return *reinterpret_cast<char*>(&num) == 1;
|
||||
}
|
||||
|
||||
|
||||
///////////////////
|
||||
// binary reader //
|
||||
///////////////////
|
||||
@@ -31,13 +45,14 @@ namespace detail
|
||||
/*!
|
||||
@brief deserialization of CBOR, MessagePack, and UBJSON values
|
||||
*/
|
||||
template<typename BasicJsonType, typename SAX = json_sax_dom_parser<BasicJsonType>>
|
||||
template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType>>
|
||||
class binary_reader
|
||||
{
|
||||
using number_integer_t = typename BasicJsonType::number_integer_t;
|
||||
using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
|
||||
using number_float_t = typename BasicJsonType::number_float_t;
|
||||
using string_t = typename BasicJsonType::string_t;
|
||||
using internal_binary_t = typename BasicJsonType::internal_binary_t;
|
||||
using json_sax_t = SAX;
|
||||
|
||||
public:
|
||||
@@ -46,10 +61,9 @@ class binary_reader
|
||||
|
||||
@param[in] adapter input adapter to read from
|
||||
*/
|
||||
explicit binary_reader(input_adapter_t adapter) : ia(std::move(adapter))
|
||||
explicit binary_reader(InputAdapterType&& adapter) : ia(std::move(adapter))
|
||||
{
|
||||
(void)detail::is_sax_static_asserts<SAX, BasicJsonType> {};
|
||||
assert(ia);
|
||||
}
|
||||
|
||||
// make class move-only
|
||||
@@ -118,18 +132,6 @@ class binary_reader
|
||||
return result;
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief determine system byte order
|
||||
|
||||
@return true if and only if system's byte order is little endian
|
||||
|
||||
@note from http://stackoverflow.com/a/1001328/266378
|
||||
*/
|
||||
static constexpr bool little_endianess(int num = 1) noexcept
|
||||
{
|
||||
return *reinterpret_cast<char*>(&num) == 1;
|
||||
}
|
||||
|
||||
private:
|
||||
//////////
|
||||
// BSON //
|
||||
@@ -207,6 +209,30 @@ class binary_reader
|
||||
return get_string(input_format_t::bson, len - static_cast<NumberType>(1), result) and get() != std::char_traits<char>::eof();
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief Parses a byte array input of length @a len from the BSON input.
|
||||
@param[in] len The length of the byte array to be read.
|
||||
@param[in, out] result A reference to the binary variable where the read
|
||||
array is to be stored.
|
||||
@tparam NumberType The type of the length @a len
|
||||
@pre len >= 0
|
||||
@return `true` if the byte array was successfully parsed
|
||||
*/
|
||||
template<typename NumberType>
|
||||
bool get_bson_binary(const NumberType len, internal_binary_t& result)
|
||||
{
|
||||
if (JSON_HEDLEY_UNLIKELY(len < 0))
|
||||
{
|
||||
auto last_token = get_token_string();
|
||||
return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "byte array length cannot be negative, is " + std::to_string(len), "binary")));
|
||||
}
|
||||
|
||||
result.has_subtype = true; // All BSON binary values have a subtype
|
||||
get_number<std::uint8_t>(input_format_t::bson, result.subtype);
|
||||
|
||||
return get_binary(input_format_t::bson, len, result);
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief Read a BSON document element of the given @a element_type.
|
||||
@param[in] element_type The BSON element type, c.f. http://bsonspec.org/spec.html
|
||||
@@ -245,6 +271,13 @@ class binary_reader
|
||||
return parse_bson_array();
|
||||
}
|
||||
|
||||
case 0x05: // binary
|
||||
{
|
||||
std::int32_t len;
|
||||
internal_binary_t value;
|
||||
return get_number<std::int32_t, true>(input_format_t::bson, len) and get_bson_binary(len, value) and sax->binary(value);
|
||||
}
|
||||
|
||||
case 0x08: // boolean
|
||||
{
|
||||
return sax->boolean(get() != 0);
|
||||
@@ -291,6 +324,7 @@ class binary_reader
|
||||
bool parse_bson_element_list(const bool is_array)
|
||||
{
|
||||
string_t key;
|
||||
|
||||
while (int element_type = get())
|
||||
{
|
||||
if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "element list")))
|
||||
@@ -465,6 +499,41 @@ class binary_reader
|
||||
- static_cast<number_integer_t>(number));
|
||||
}
|
||||
|
||||
// Binary data (0x00..0x17 bytes follow)
|
||||
case 0x40:
|
||||
case 0x41:
|
||||
case 0x42:
|
||||
case 0x43:
|
||||
case 0x44:
|
||||
case 0x45:
|
||||
case 0x46:
|
||||
case 0x47:
|
||||
case 0x48:
|
||||
case 0x49:
|
||||
case 0x4A:
|
||||
case 0x4B:
|
||||
case 0x4C:
|
||||
case 0x4D:
|
||||
case 0x4E:
|
||||
case 0x4F:
|
||||
case 0x50:
|
||||
case 0x51:
|
||||
case 0x52:
|
||||
case 0x53:
|
||||
case 0x54:
|
||||
case 0x55:
|
||||
case 0x56:
|
||||
case 0x57:
|
||||
case 0x58: // Binary data (one-byte uint8_t for n follows)
|
||||
case 0x59: // Binary data (two-byte uint16_t for n follow)
|
||||
case 0x5A: // Binary data (four-byte uint32_t for n follow)
|
||||
case 0x5B: // Binary data (eight-byte uint64_t for n follow)
|
||||
case 0x5F: // Binary data (indefinite length)
|
||||
{
|
||||
internal_binary_t b;
|
||||
return get_cbor_binary(b) and sax->binary(b);
|
||||
}
|
||||
|
||||
// UTF-8 string (0x00..0x17 bytes follow)
|
||||
case 0x60:
|
||||
case 0x61:
|
||||
@@ -780,6 +849,101 @@ class binary_reader
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief reads a CBOR byte array
|
||||
|
||||
This function first reads starting bytes to determine the expected
|
||||
byte array length and then copies this number of bytes into the byte array.
|
||||
Additionally, CBOR's byte arrays with indefinite lengths are supported.
|
||||
|
||||
@param[out] result created byte array
|
||||
|
||||
@return whether byte array creation completed
|
||||
*/
|
||||
bool get_cbor_binary(internal_binary_t& result)
|
||||
{
|
||||
if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "binary")))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (current)
|
||||
{
|
||||
// Binary data (0x00..0x17 bytes follow)
|
||||
case 0x40:
|
||||
case 0x41:
|
||||
case 0x42:
|
||||
case 0x43:
|
||||
case 0x44:
|
||||
case 0x45:
|
||||
case 0x46:
|
||||
case 0x47:
|
||||
case 0x48:
|
||||
case 0x49:
|
||||
case 0x4A:
|
||||
case 0x4B:
|
||||
case 0x4C:
|
||||
case 0x4D:
|
||||
case 0x4E:
|
||||
case 0x4F:
|
||||
case 0x50:
|
||||
case 0x51:
|
||||
case 0x52:
|
||||
case 0x53:
|
||||
case 0x54:
|
||||
case 0x55:
|
||||
case 0x56:
|
||||
case 0x57:
|
||||
{
|
||||
return get_binary(input_format_t::cbor, static_cast<unsigned int>(current) & 0x1Fu, result);
|
||||
}
|
||||
|
||||
case 0x58: // Binary data (one-byte uint8_t for n follows)
|
||||
{
|
||||
std::uint8_t len;
|
||||
return get_number(input_format_t::cbor, len) and get_binary(input_format_t::cbor, len, result);
|
||||
}
|
||||
|
||||
case 0x59: // Binary data (two-byte uint16_t for n follow)
|
||||
{
|
||||
std::uint16_t len;
|
||||
return get_number(input_format_t::cbor, len) and get_binary(input_format_t::cbor, len, result);
|
||||
}
|
||||
|
||||
case 0x5A: // Binary data (four-byte uint32_t for n follow)
|
||||
{
|
||||
std::uint32_t len;
|
||||
return get_number(input_format_t::cbor, len) and get_binary(input_format_t::cbor, len, result);
|
||||
}
|
||||
|
||||
case 0x5B: // Binary data (eight-byte uint64_t for n follow)
|
||||
{
|
||||
std::uint64_t len;
|
||||
return get_number(input_format_t::cbor, len) and get_binary(input_format_t::cbor, len, result);
|
||||
}
|
||||
|
||||
case 0x5F: // Binary data (indefinite length)
|
||||
{
|
||||
while (get() != 0xFF)
|
||||
{
|
||||
internal_binary_t chunk;
|
||||
if (not get_cbor_binary(chunk))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
result.insert(result.end(), chunk.begin(), chunk.end());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
auto last_token = get_token_string();
|
||||
return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, "expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x" + last_token, "binary")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@param[in] len the length of the array or std::size_t(-1) for an
|
||||
array of indefinite size
|
||||
@@ -1100,6 +1264,22 @@ class binary_reader
|
||||
case 0xC3: // true
|
||||
return sax->boolean(true);
|
||||
|
||||
case 0xC4: // bin 8
|
||||
case 0xC5: // bin 16
|
||||
case 0xC6: // bin 32
|
||||
case 0xC7: // ext 8
|
||||
case 0xC8: // ext 16
|
||||
case 0xC9: // ext 32
|
||||
case 0xD4: // fixext 1
|
||||
case 0xD5: // fixext 2
|
||||
case 0xD6: // fixext 4
|
||||
case 0xD7: // fixext 8
|
||||
case 0xD8: // fixext 16
|
||||
{
|
||||
internal_binary_t b;
|
||||
return get_msgpack_binary(b) and sax->binary(b);
|
||||
}
|
||||
|
||||
case 0xCA: // float 32
|
||||
{
|
||||
float number;
|
||||
@@ -1309,6 +1489,100 @@ class binary_reader
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief reads a MessagePack byte array
|
||||
|
||||
This function first reads starting bytes to determine the expected
|
||||
byte array length and then copies this number of bytes into a byte array.
|
||||
|
||||
@param[out] result created byte array
|
||||
|
||||
@return whether byte array creation completed
|
||||
*/
|
||||
bool get_msgpack_binary(internal_binary_t& result)
|
||||
{
|
||||
switch (current)
|
||||
{
|
||||
case 0xC4: // bin 8
|
||||
{
|
||||
std::uint8_t len;
|
||||
return get_number(input_format_t::msgpack, len) and get_binary(input_format_t::msgpack, len, result);
|
||||
}
|
||||
|
||||
case 0xC5: // bin 16
|
||||
{
|
||||
std::uint16_t len;
|
||||
return get_number(input_format_t::msgpack, len) and get_binary(input_format_t::msgpack, len, result);
|
||||
}
|
||||
|
||||
case 0xC6: // bin 32
|
||||
{
|
||||
std::uint32_t len;
|
||||
return get_number(input_format_t::msgpack, len) and get_binary(input_format_t::msgpack, len, result);
|
||||
}
|
||||
|
||||
case 0xC7: // ext 8
|
||||
{
|
||||
std::uint8_t len;
|
||||
result.has_subtype = true;
|
||||
return get_number(input_format_t::msgpack, len) and
|
||||
get_number(input_format_t::msgpack, result.subtype) and
|
||||
get_binary(input_format_t::msgpack, len, result);
|
||||
}
|
||||
|
||||
case 0xC8: // ext 16
|
||||
{
|
||||
std::uint16_t len;
|
||||
result.has_subtype = true;
|
||||
return get_number(input_format_t::msgpack, len) and
|
||||
get_number(input_format_t::msgpack, result.subtype) and
|
||||
get_binary(input_format_t::msgpack, len, result);
|
||||
}
|
||||
|
||||
case 0xC9: // ext 32
|
||||
{
|
||||
std::uint32_t len;
|
||||
result.has_subtype = true;
|
||||
return get_number(input_format_t::msgpack, len) and
|
||||
get_number(input_format_t::msgpack, result.subtype) and
|
||||
get_binary(input_format_t::msgpack, len, result);
|
||||
}
|
||||
|
||||
case 0xD4: // fixext 1
|
||||
{
|
||||
result.has_subtype = true;
|
||||
return get_number(input_format_t::msgpack, result.subtype) and get_binary(input_format_t::msgpack, 1, result);
|
||||
}
|
||||
|
||||
case 0xD5: // fixext 2
|
||||
{
|
||||
result.has_subtype = true;
|
||||
return get_number(input_format_t::msgpack, result.subtype) and get_binary(input_format_t::msgpack, 2, result);
|
||||
}
|
||||
|
||||
case 0xD6: // fixext 4
|
||||
{
|
||||
result.has_subtype = true;
|
||||
return get_number(input_format_t::msgpack, result.subtype) and get_binary(input_format_t::msgpack, 4, result);
|
||||
}
|
||||
|
||||
case 0xD7: // fixext 8
|
||||
{
|
||||
result.has_subtype = true;
|
||||
return get_number(input_format_t::msgpack, result.subtype) and get_binary(input_format_t::msgpack, 8, result);
|
||||
}
|
||||
|
||||
case 0xD8: // fixext 16
|
||||
{
|
||||
result.has_subtype = true;
|
||||
return get_number(input_format_t::msgpack, result.subtype) and get_binary(input_format_t::msgpack, 16, result);
|
||||
}
|
||||
|
||||
default: // LCOV_EXCL_LINE
|
||||
return false; // LCOV_EXCL_LINE
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@param[in] len the length of the array
|
||||
@return whether array creation completed
|
||||
@@ -1793,6 +2067,9 @@ class binary_reader
|
||||
return sax->end_object();
|
||||
}
|
||||
|
||||
// Note, no reader for UBJSON binary types is implemented because they do
|
||||
// not exist
|
||||
|
||||
///////////////////////
|
||||
// Utility functions //
|
||||
///////////////////////
|
||||
@@ -1809,7 +2086,7 @@ class binary_reader
|
||||
int get()
|
||||
{
|
||||
++chars_read;
|
||||
return current = ia->get_character();
|
||||
return current = ia.get_character();
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1900,6 +2177,38 @@ class binary_reader
|
||||
return success;
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief create a byte array by reading bytes from the input
|
||||
|
||||
@tparam NumberType the type of the number
|
||||
@param[in] format the current format (for diagnostics)
|
||||
@param[in] len number of bytes to read
|
||||
@param[out] result byte array created by reading @a len bytes
|
||||
|
||||
@return whether byte array creation completed
|
||||
|
||||
@note We can not reserve @a len bytes for the result, because @a len
|
||||
may be too large. Usually, @ref unexpect_eof() detects the end of
|
||||
the input before we run out of memory.
|
||||
*/
|
||||
template<typename NumberType>
|
||||
bool get_binary(const input_format_t format,
|
||||
const NumberType len,
|
||||
internal_binary_t& result)
|
||||
{
|
||||
bool success = true;
|
||||
std::generate_n(std::back_inserter(result), len, [this, &success, &format]()
|
||||
{
|
||||
get();
|
||||
if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(format, "binary")))
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
return static_cast<std::uint8_t>(current);
|
||||
});
|
||||
return success;
|
||||
}
|
||||
|
||||
/*!
|
||||
@param[in] format the current format (for diagnostics)
|
||||
@param[in] context further context information (for diagnostics)
|
||||
@@ -1965,7 +2274,7 @@ class binary_reader
|
||||
|
||||
private:
|
||||
/// input adapter
|
||||
input_adapter_t ia = nullptr;
|
||||
InputAdapterType ia;
|
||||
|
||||
/// the current character
|
||||
int current = std::char_traits<char>::eof();
|
||||
|
||||
@@ -27,32 +27,11 @@ enum class input_format_t { json, cbor, msgpack, ubjson, bson };
|
||||
// input adapters //
|
||||
////////////////////
|
||||
|
||||
/*!
|
||||
@brief abstract input adapter interface
|
||||
|
||||
Produces a stream of std::char_traits<char>::int_type characters from a
|
||||
std::istream, a buffer, or some other input type. Accepts the return of
|
||||
exactly one non-EOF character for future input. The int_type characters
|
||||
returned consist of all valid char values as positive values (typically
|
||||
unsigned char), plus an EOF value outside that range, specified by the value
|
||||
of the function std::char_traits<char>::eof(). This value is typically -1, but
|
||||
could be any arbitrary value which is not a valid char value.
|
||||
*/
|
||||
struct input_adapter_protocol
|
||||
{
|
||||
/// get a character [0,255] or std::char_traits<char>::eof().
|
||||
virtual std::char_traits<char>::int_type get_character() = 0;
|
||||
virtual ~input_adapter_protocol() = default;
|
||||
};
|
||||
|
||||
/// a type to simplify interfaces
|
||||
using input_adapter_t = std::shared_ptr<input_adapter_protocol>;
|
||||
|
||||
/*!
|
||||
Input adapter for stdio file access. This adapter read only 1 byte and do not use any
|
||||
buffer. This adapter is a very low level adapter.
|
||||
*/
|
||||
class file_input_adapter : public input_adapter_protocol
|
||||
class file_input_adapter
|
||||
{
|
||||
public:
|
||||
JSON_HEDLEY_NON_NULL(2)
|
||||
@@ -64,10 +43,9 @@ class file_input_adapter : public input_adapter_protocol
|
||||
file_input_adapter(const file_input_adapter&) = delete;
|
||||
file_input_adapter(file_input_adapter&&) = default;
|
||||
file_input_adapter& operator=(const file_input_adapter&) = delete;
|
||||
file_input_adapter& operator=(file_input_adapter&&) = default;
|
||||
~file_input_adapter() override = default;
|
||||
file_input_adapter& operator=(file_input_adapter&&) = delete;
|
||||
|
||||
std::char_traits<char>::int_type get_character() noexcept override
|
||||
std::char_traits<char>::int_type get_character() noexcept
|
||||
{
|
||||
return std::fgetc(m_file);
|
||||
}
|
||||
@@ -87,48 +65,56 @@ characters following those used in parsing the JSON input. Clears the
|
||||
std::istream flags; any input errors (e.g., EOF) will be detected by the first
|
||||
subsequent call for input from the std::istream.
|
||||
*/
|
||||
class input_stream_adapter : public input_adapter_protocol
|
||||
class input_stream_adapter
|
||||
{
|
||||
public:
|
||||
~input_stream_adapter() override
|
||||
~input_stream_adapter()
|
||||
{
|
||||
// clear stream flags; we use underlying streambuf I/O, do not
|
||||
// maintain ifstream flags, except eof
|
||||
is.clear(is.rdstate() & std::ios::eofbit);
|
||||
if (is)
|
||||
{
|
||||
is->clear(is->rdstate() & std::ios::eofbit);
|
||||
}
|
||||
}
|
||||
|
||||
explicit input_stream_adapter(std::istream& i)
|
||||
: is(i), sb(*i.rdbuf())
|
||||
: is(&i), sb(i.rdbuf())
|
||||
{}
|
||||
|
||||
// delete because of pointer members
|
||||
input_stream_adapter(const input_stream_adapter&) = delete;
|
||||
input_stream_adapter& operator=(input_stream_adapter&) = delete;
|
||||
input_stream_adapter(input_stream_adapter&&) = delete;
|
||||
input_stream_adapter& operator=(input_stream_adapter&&) = delete;
|
||||
input_stream_adapter& operator=(input_stream_adapter&& rhs) = delete;
|
||||
|
||||
input_stream_adapter(input_stream_adapter&& rhs) : is(rhs.is), sb(rhs.sb)
|
||||
{
|
||||
rhs.is = nullptr;
|
||||
rhs.sb = nullptr;
|
||||
}
|
||||
|
||||
// std::istream/std::streambuf use std::char_traits<char>::to_int_type, to
|
||||
// ensure that std::char_traits<char>::eof() and the character 0xFF do not
|
||||
// end up as the same value, eg. 0xFFFFFFFF.
|
||||
std::char_traits<char>::int_type get_character() override
|
||||
std::char_traits<char>::int_type get_character()
|
||||
{
|
||||
auto res = sb.sbumpc();
|
||||
auto res = sb->sbumpc();
|
||||
// set eof manually, as we don't use the istream interface.
|
||||
if (res == EOF)
|
||||
{
|
||||
is.clear(is.rdstate() | std::ios::eofbit);
|
||||
is->clear(is->rdstate() | std::ios::eofbit);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private:
|
||||
/// the associated input stream
|
||||
std::istream& is;
|
||||
std::streambuf& sb;
|
||||
std::istream* is = nullptr;
|
||||
std::streambuf* sb = nullptr;
|
||||
};
|
||||
|
||||
/// input adapter for buffer input
|
||||
class input_buffer_adapter : public input_adapter_protocol
|
||||
class input_buffer_adapter
|
||||
{
|
||||
public:
|
||||
input_buffer_adapter(const char* b, const std::size_t l) noexcept
|
||||
@@ -138,11 +124,10 @@ class input_buffer_adapter : public input_adapter_protocol
|
||||
// delete because of pointer members
|
||||
input_buffer_adapter(const input_buffer_adapter&) = delete;
|
||||
input_buffer_adapter& operator=(input_buffer_adapter&) = delete;
|
||||
input_buffer_adapter(input_buffer_adapter&&) = delete;
|
||||
input_buffer_adapter(input_buffer_adapter&&) = default;
|
||||
input_buffer_adapter& operator=(input_buffer_adapter&&) = delete;
|
||||
~input_buffer_adapter() override = default;
|
||||
|
||||
std::char_traits<char>::int_type get_character() noexcept override
|
||||
std::char_traits<char>::int_type get_character() noexcept
|
||||
{
|
||||
if (JSON_HEDLEY_LIKELY(cursor < limit))
|
||||
{
|
||||
@@ -285,14 +270,14 @@ struct wide_string_input_helper<WideStringType, 2>
|
||||
};
|
||||
|
||||
template<typename WideStringType>
|
||||
class wide_string_input_adapter : public input_adapter_protocol
|
||||
class wide_string_input_adapter
|
||||
{
|
||||
public:
|
||||
explicit wide_string_input_adapter(const WideStringType& w) noexcept
|
||||
: str(w)
|
||||
{}
|
||||
|
||||
std::char_traits<char>::int_type get_character() noexcept override
|
||||
std::char_traits<char>::int_type get_character() noexcept
|
||||
{
|
||||
// check if buffer needs to be filled
|
||||
if (utf8_bytes_index == utf8_bytes_filled)
|
||||
@@ -331,112 +316,164 @@ class wide_string_input_adapter : public input_adapter_protocol
|
||||
std::size_t utf8_bytes_filled = 0;
|
||||
};
|
||||
|
||||
class input_adapter
|
||||
inline file_input_adapter input_adapter(std::FILE* file)
|
||||
{
|
||||
return file_input_adapter(file);
|
||||
}
|
||||
|
||||
inline input_stream_adapter input_adapter(std::istream& stream)
|
||||
{
|
||||
return input_stream_adapter(stream);
|
||||
}
|
||||
|
||||
inline input_stream_adapter input_adapter(std::istream&& stream)
|
||||
{
|
||||
return input_stream_adapter(stream);
|
||||
}
|
||||
|
||||
template<typename CharT,
|
||||
typename std::enable_if<
|
||||
std::is_pointer<CharT>::value and
|
||||
std::is_integral<typename std::remove_pointer<CharT>::type>::value and
|
||||
sizeof(typename std::remove_pointer<CharT>::type) == 1,
|
||||
int>::type = 0>
|
||||
input_buffer_adapter input_adapter(CharT b, std::size_t l)
|
||||
{
|
||||
return input_buffer_adapter(reinterpret_cast<const char*>(b), l);
|
||||
}
|
||||
|
||||
template<typename CharT,
|
||||
typename std::enable_if<
|
||||
std::is_pointer<CharT>::value and
|
||||
std::is_integral<typename std::remove_pointer<CharT>::type>::value and
|
||||
sizeof(typename std::remove_pointer<CharT>::type) == 1,
|
||||
int>::type = 0>
|
||||
input_buffer_adapter input_adapter(CharT b)
|
||||
{
|
||||
return input_adapter(reinterpret_cast<const char*>(b),
|
||||
std::strlen(reinterpret_cast<const char*>(b)));
|
||||
}
|
||||
|
||||
template<class IteratorType,
|
||||
typename std::enable_if<
|
||||
std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value,
|
||||
int>::type = 0>
|
||||
input_buffer_adapter input_adapter(IteratorType first, IteratorType last)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
// assertion to check that the iterator range is indeed contiguous,
|
||||
// see https://stackoverflow.com/a/35008842/266378 for more discussion
|
||||
const auto is_contiguous = std::accumulate(
|
||||
first, last, std::pair<bool, int>(true, 0),
|
||||
[&first](std::pair<bool, int> res, decltype(*first) val)
|
||||
{
|
||||
res.first &= (val == *(std::next(std::addressof(*first), res.second++)));
|
||||
return res;
|
||||
}).first;
|
||||
assert(is_contiguous);
|
||||
#endif
|
||||
|
||||
// assertion to check that each element is 1 byte long
|
||||
static_assert(
|
||||
sizeof(typename iterator_traits<IteratorType>::value_type) == 1,
|
||||
"each element in the iterator range must have the size of 1 byte");
|
||||
|
||||
const auto len = static_cast<size_t>(std::distance(first, last));
|
||||
if (JSON_HEDLEY_LIKELY(len > 0))
|
||||
{
|
||||
// there is at least one element: use the address of first
|
||||
return input_buffer_adapter(reinterpret_cast<const char*>(&(*first)), len);
|
||||
}
|
||||
else
|
||||
{
|
||||
// the address of first cannot be used: use nullptr
|
||||
return input_buffer_adapter(nullptr, len);
|
||||
}
|
||||
}
|
||||
|
||||
inline wide_string_input_adapter<std::wstring> input_adapter(const std::wstring& ws)
|
||||
{
|
||||
return wide_string_input_adapter<std::wstring>(ws);
|
||||
}
|
||||
|
||||
|
||||
inline wide_string_input_adapter<std::u16string> input_adapter(const std::u16string& ws)
|
||||
{
|
||||
return wide_string_input_adapter<std::u16string>(ws);
|
||||
}
|
||||
|
||||
inline wide_string_input_adapter<std::u32string> input_adapter(const std::u32string& ws)
|
||||
{
|
||||
return wide_string_input_adapter<std::u32string>(ws);
|
||||
}
|
||||
|
||||
template<class ContiguousContainer, typename
|
||||
std::enable_if<not std::is_pointer<ContiguousContainer>::value and
|
||||
std::is_base_of<std::random_access_iterator_tag, typename iterator_traits<decltype(std::begin(std::declval<ContiguousContainer const>()))>::iterator_category>::value,
|
||||
int>::type = 0>
|
||||
input_buffer_adapter input_adapter(const ContiguousContainer& c)
|
||||
{
|
||||
return input_adapter(std::begin(c), std::end(c));
|
||||
}
|
||||
|
||||
|
||||
template<class T, std::size_t N>
|
||||
input_buffer_adapter input_adapter(T (&array)[N])
|
||||
{
|
||||
return input_adapter(std::begin(array), std::end(array));
|
||||
}
|
||||
|
||||
// This class only handles inputs of input_buffer_adapter type.
|
||||
// It's required so that expressions like {ptr, len} can be implicitely casted
|
||||
// to the correct adapter.
|
||||
class span_input_adapter
|
||||
{
|
||||
public:
|
||||
// native support
|
||||
JSON_HEDLEY_NON_NULL(2)
|
||||
input_adapter(std::FILE* file)
|
||||
: ia(std::make_shared<file_input_adapter>(file)) {}
|
||||
/// input adapter for input stream
|
||||
input_adapter(std::istream& i)
|
||||
: ia(std::make_shared<input_stream_adapter>(i)) {}
|
||||
|
||||
/// input adapter for input stream
|
||||
input_adapter(std::istream&& i)
|
||||
: ia(std::make_shared<input_stream_adapter>(i)) {}
|
||||
|
||||
input_adapter(const std::wstring& ws)
|
||||
: ia(std::make_shared<wide_string_input_adapter<std::wstring>>(ws)) {}
|
||||
|
||||
input_adapter(const std::u16string& ws)
|
||||
: ia(std::make_shared<wide_string_input_adapter<std::u16string>>(ws)) {}
|
||||
|
||||
input_adapter(const std::u32string& ws)
|
||||
: ia(std::make_shared<wide_string_input_adapter<std::u32string>>(ws)) {}
|
||||
|
||||
/// input adapter for buffer
|
||||
template<typename CharT,
|
||||
typename std::enable_if<
|
||||
std::is_pointer<CharT>::value and
|
||||
std::is_integral<typename std::remove_pointer<CharT>::type>::value and
|
||||
sizeof(typename std::remove_pointer<CharT>::type) == 1,
|
||||
int>::type = 0>
|
||||
input_adapter(CharT b, std::size_t l)
|
||||
: ia(std::make_shared<input_buffer_adapter>(reinterpret_cast<const char*>(b), l)) {}
|
||||
span_input_adapter(CharT b, std::size_t l)
|
||||
: ia(reinterpret_cast<const char*>(b), l) {}
|
||||
|
||||
// derived support
|
||||
|
||||
/// input adapter for string literal
|
||||
template<typename CharT,
|
||||
typename std::enable_if<
|
||||
std::is_pointer<CharT>::value and
|
||||
std::is_integral<typename std::remove_pointer<CharT>::type>::value and
|
||||
sizeof(typename std::remove_pointer<CharT>::type) == 1,
|
||||
int>::type = 0>
|
||||
input_adapter(CharT b)
|
||||
: input_adapter(reinterpret_cast<const char*>(b),
|
||||
std::strlen(reinterpret_cast<const char*>(b))) {}
|
||||
span_input_adapter(CharT b)
|
||||
: span_input_adapter(reinterpret_cast<const char*>(b),
|
||||
std::strlen(reinterpret_cast<const char*>(b))) {}
|
||||
|
||||
/// input adapter for iterator range with contiguous storage
|
||||
template<class IteratorType,
|
||||
typename std::enable_if<
|
||||
std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value,
|
||||
int>::type = 0>
|
||||
input_adapter(IteratorType first, IteratorType last)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
// assertion to check that the iterator range is indeed contiguous,
|
||||
// see http://stackoverflow.com/a/35008842/266378 for more discussion
|
||||
const auto is_contiguous = std::accumulate(
|
||||
first, last, std::pair<bool, int>(true, 0),
|
||||
[&first](std::pair<bool, int> res, decltype(*first) val)
|
||||
{
|
||||
res.first &= (val == *(std::next(std::addressof(*first), res.second++)));
|
||||
return res;
|
||||
}).first;
|
||||
assert(is_contiguous);
|
||||
#endif
|
||||
span_input_adapter(IteratorType first, IteratorType last)
|
||||
: ia(input_adapter(first, last)) {}
|
||||
|
||||
// assertion to check that each element is 1 byte long
|
||||
static_assert(
|
||||
sizeof(typename iterator_traits<IteratorType>::value_type) == 1,
|
||||
"each element in the iterator range must have the size of 1 byte");
|
||||
|
||||
const auto len = static_cast<size_t>(std::distance(first, last));
|
||||
if (JSON_HEDLEY_LIKELY(len > 0))
|
||||
{
|
||||
// there is at least one element: use the address of first
|
||||
ia = std::make_shared<input_buffer_adapter>(reinterpret_cast<const char*>(&(*first)), len);
|
||||
}
|
||||
else
|
||||
{
|
||||
// the address of first cannot be used: use nullptr
|
||||
ia = std::make_shared<input_buffer_adapter>(nullptr, len);
|
||||
}
|
||||
}
|
||||
|
||||
/// input adapter for array
|
||||
template<class T, std::size_t N>
|
||||
input_adapter(T (&array)[N])
|
||||
: input_adapter(std::begin(array), std::end(array)) {}
|
||||
span_input_adapter(T (&array)[N])
|
||||
: span_input_adapter(std::begin(array), std::end(array)) {}
|
||||
|
||||
/// input adapter for contiguous container
|
||||
template<class ContiguousContainer, typename
|
||||
std::enable_if<not std::is_pointer<ContiguousContainer>::value and
|
||||
std::is_base_of<std::random_access_iterator_tag, typename iterator_traits<decltype(std::begin(std::declval<ContiguousContainer const>()))>::iterator_category>::value,
|
||||
int>::type = 0>
|
||||
input_adapter(const ContiguousContainer& c)
|
||||
: input_adapter(std::begin(c), std::end(c)) {}
|
||||
span_input_adapter(const ContiguousContainer& c)
|
||||
: span_input_adapter(std::begin(c), std::end(c)) {}
|
||||
|
||||
operator input_adapter_t()
|
||||
input_buffer_adapter&& get()
|
||||
{
|
||||
return ia;
|
||||
return std::move(ia);
|
||||
}
|
||||
|
||||
private:
|
||||
/// the actual adapter
|
||||
input_adapter_t ia = nullptr;
|
||||
input_buffer_adapter ia;
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace nlohmann
|
||||
|
||||
@@ -31,6 +31,7 @@ struct json_sax
|
||||
using number_float_t = typename BasicJsonType::number_float_t;
|
||||
/// type for strings
|
||||
using string_t = typename BasicJsonType::string_t;
|
||||
using binary_t = typename BasicJsonType::binary_t;
|
||||
|
||||
/*!
|
||||
@brief a null value was read
|
||||
@@ -75,6 +76,14 @@ struct json_sax
|
||||
*/
|
||||
virtual bool string(string_t& val) = 0;
|
||||
|
||||
/*!
|
||||
@brief a binary string was read
|
||||
@param[in] val binary value
|
||||
@return whether parsing should proceed
|
||||
@note It is safe to move the passed binary.
|
||||
*/
|
||||
virtual bool binary(binary_t& val) = 0;
|
||||
|
||||
/*!
|
||||
@brief the beginning of an object was read
|
||||
@param[in] elements number of object elements or -1 if unknown
|
||||
@@ -149,6 +158,7 @@ class json_sax_dom_parser
|
||||
using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
|
||||
using number_float_t = typename BasicJsonType::number_float_t;
|
||||
using string_t = typename BasicJsonType::string_t;
|
||||
using binary_t = typename BasicJsonType::binary_t;
|
||||
|
||||
/*!
|
||||
@param[in, out] r reference to a JSON value that is manipulated while
|
||||
@@ -202,6 +212,12 @@ class json_sax_dom_parser
|
||||
return true;
|
||||
}
|
||||
|
||||
bool binary(binary_t& val)
|
||||
{
|
||||
handle_value(BasicJsonType::binary_array(std::move(val)));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool start_object(std::size_t len)
|
||||
{
|
||||
ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
|
||||
@@ -331,6 +347,7 @@ class json_sax_dom_callback_parser
|
||||
using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
|
||||
using number_float_t = typename BasicJsonType::number_float_t;
|
||||
using string_t = typename BasicJsonType::string_t;
|
||||
using binary_t = typename BasicJsonType::binary_t;
|
||||
using parser_callback_t = typename BasicJsonType::parser_callback_t;
|
||||
using parse_event_t = typename BasicJsonType::parse_event_t;
|
||||
|
||||
@@ -385,6 +402,12 @@ class json_sax_dom_callback_parser
|
||||
return true;
|
||||
}
|
||||
|
||||
bool binary(binary_t& val)
|
||||
{
|
||||
handle_value(BasicJsonType::binary_array(val));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool start_object(std::size_t len)
|
||||
{
|
||||
// check callback for object start
|
||||
@@ -635,6 +658,7 @@ class json_sax_acceptor
|
||||
using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
|
||||
using number_float_t = typename BasicJsonType::number_float_t;
|
||||
using string_t = typename BasicJsonType::string_t;
|
||||
using binary_t = typename BasicJsonType::binary_t;
|
||||
|
||||
bool null()
|
||||
{
|
||||
@@ -666,7 +690,12 @@ class json_sax_acceptor
|
||||
return true;
|
||||
}
|
||||
|
||||
bool start_object(std::size_t /*unused*/ = std::size_t(-1))
|
||||
bool binary(binary_t& /*unused*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool start_object(std::size_t /*unused*/ = std::size_t(-1))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -681,7 +710,7 @@ class json_sax_acceptor
|
||||
return true;
|
||||
}
|
||||
|
||||
bool start_array(std::size_t /*unused*/ = std::size_t(-1))
|
||||
bool start_array(std::size_t /*unused*/ = std::size_t(-1))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -22,19 +22,9 @@ namespace detail
|
||||
// lexer //
|
||||
///////////
|
||||
|
||||
/*!
|
||||
@brief lexical analysis
|
||||
|
||||
This class organizes the lexical analysis during JSON deserialization.
|
||||
*/
|
||||
template<typename BasicJsonType>
|
||||
class lexer
|
||||
class lexer_base
|
||||
{
|
||||
using number_integer_t = typename BasicJsonType::number_integer_t;
|
||||
using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
|
||||
using number_float_t = typename BasicJsonType::number_float_t;
|
||||
using string_t = typename BasicJsonType::string_t;
|
||||
|
||||
public:
|
||||
/// token types for the parser
|
||||
enum class token_type
|
||||
@@ -75,9 +65,9 @@ class lexer
|
||||
return "null literal";
|
||||
case token_type::value_string:
|
||||
return "string literal";
|
||||
case lexer::token_type::value_unsigned:
|
||||
case lexer::token_type::value_integer:
|
||||
case lexer::token_type::value_float:
|
||||
case token_type::value_unsigned:
|
||||
case token_type::value_integer:
|
||||
case token_type::value_float:
|
||||
return "number literal";
|
||||
case token_type::begin_array:
|
||||
return "'['";
|
||||
@@ -103,15 +93,31 @@ class lexer
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
}
|
||||
};
|
||||
/*!
|
||||
@brief lexical analysis
|
||||
|
||||
explicit lexer(detail::input_adapter_t&& adapter)
|
||||
This class organizes the lexical analysis during JSON deserialization.
|
||||
*/
|
||||
template<typename BasicJsonType, typename InputAdapterType>
|
||||
class lexer : public lexer_base<BasicJsonType>
|
||||
{
|
||||
using number_integer_t = typename BasicJsonType::number_integer_t;
|
||||
using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
|
||||
using number_float_t = typename BasicJsonType::number_float_t;
|
||||
using string_t = typename BasicJsonType::string_t;
|
||||
|
||||
public:
|
||||
using token_type = typename lexer_base<BasicJsonType>::token_type;
|
||||
|
||||
explicit lexer(InputAdapterType&& adapter)
|
||||
: ia(std::move(adapter)), decimal_point_char(get_decimal_point()) {}
|
||||
|
||||
// delete because of pointer members
|
||||
lexer(const lexer&) = delete;
|
||||
lexer(lexer&&) = delete;
|
||||
lexer(lexer&&) = default;
|
||||
lexer& operator=(lexer&) = delete;
|
||||
lexer& operator=(lexer&&) = delete;
|
||||
lexer& operator=(lexer&&) = default;
|
||||
~lexer() = default;
|
||||
|
||||
private:
|
||||
@@ -338,13 +344,13 @@ class lexer
|
||||
}
|
||||
else
|
||||
{
|
||||
error_message = "invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF";
|
||||
error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error_message = "invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF";
|
||||
error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
}
|
||||
@@ -853,7 +859,7 @@ class lexer
|
||||
minus | zero | any1 | [error] | [error] | [error] | [error] | [error]
|
||||
zero | done | done | exponent | done | done | decimal1 | done
|
||||
any1 | any1 | any1 | exponent | done | done | decimal1 | done
|
||||
decimal1 | decimal2 | [error] | [error] | [error] | [error] | [error] | [error]
|
||||
decimal1 | decimal2 | decimal2 | [error] | [error] | [error] | [error] | [error]
|
||||
decimal2 | decimal2 | decimal2 | exponent | done | done | done | done
|
||||
exponent | any2 | any2 | [error] | sign | sign | [error] | [error]
|
||||
sign | any2 | any2 | [error] | [error] | [error] | [error] | [error]
|
||||
@@ -1256,7 +1262,7 @@ scan_number_done:
|
||||
}
|
||||
else
|
||||
{
|
||||
current = ia->get_character();
|
||||
current = ia.get_character();
|
||||
}
|
||||
|
||||
if (JSON_HEDLEY_LIKELY(current != std::char_traits<char>::eof()))
|
||||
@@ -1480,7 +1486,7 @@ scan_number_done:
|
||||
|
||||
private:
|
||||
/// input adapter
|
||||
detail::input_adapter_t ia = nullptr;
|
||||
InputAdapterType ia;
|
||||
|
||||
/// the current character
|
||||
std::char_traits<char>::int_type current = std::char_traits<char>::eof();
|
||||
|
||||
@@ -24,44 +24,45 @@ namespace detail
|
||||
// parser //
|
||||
////////////
|
||||
|
||||
enum class parse_event_t : uint8_t
|
||||
{
|
||||
/// the parser read `{` and started to process a JSON object
|
||||
object_start,
|
||||
/// the parser read `}` and finished processing a JSON object
|
||||
object_end,
|
||||
/// the parser read `[` and started to process a JSON array
|
||||
array_start,
|
||||
/// the parser read `]` and finished processing a JSON array
|
||||
array_end,
|
||||
/// the parser read a key of a value in an object
|
||||
key,
|
||||
/// the parser finished reading a JSON value
|
||||
value
|
||||
};
|
||||
|
||||
template<typename BasicJsonType>
|
||||
using parser_callback_t =
|
||||
std::function<bool(int depth, parse_event_t event, BasicJsonType& parsed)>;
|
||||
|
||||
/*!
|
||||
@brief syntax analysis
|
||||
|
||||
This class implements a recursive decent parser.
|
||||
This class implements a recursive descent parser.
|
||||
*/
|
||||
template<typename BasicJsonType>
|
||||
template<typename BasicJsonType, typename InputAdapterType>
|
||||
class parser
|
||||
{
|
||||
using number_integer_t = typename BasicJsonType::number_integer_t;
|
||||
using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
|
||||
using number_float_t = typename BasicJsonType::number_float_t;
|
||||
using string_t = typename BasicJsonType::string_t;
|
||||
using lexer_t = lexer<BasicJsonType>;
|
||||
using lexer_t = lexer<BasicJsonType, InputAdapterType>;
|
||||
using token_type = typename lexer_t::token_type;
|
||||
|
||||
public:
|
||||
enum class parse_event_t : uint8_t
|
||||
{
|
||||
/// the parser read `{` and started to process a JSON object
|
||||
object_start,
|
||||
/// the parser read `}` and finished processing a JSON object
|
||||
object_end,
|
||||
/// the parser read `[` and started to process a JSON array
|
||||
array_start,
|
||||
/// the parser read `]` and finished processing a JSON array
|
||||
array_end,
|
||||
/// the parser read a key of a value in an object
|
||||
key,
|
||||
/// the parser finished reading a JSON value
|
||||
value
|
||||
};
|
||||
|
||||
using parser_callback_t =
|
||||
std::function<bool(int depth, parse_event_t event, BasicJsonType& parsed)>;
|
||||
|
||||
/// a parser reading from an input adapter
|
||||
explicit parser(detail::input_adapter_t&& adapter,
|
||||
const parser_callback_t cb = nullptr,
|
||||
explicit parser(InputAdapterType&& adapter,
|
||||
const parser_callback_t<BasicJsonType> cb = nullptr,
|
||||
const bool allow_exceptions_ = true)
|
||||
: callback(cb), m_lexer(std::move(adapter)), allow_exceptions(allow_exceptions_)
|
||||
{
|
||||
@@ -486,7 +487,7 @@ class parser
|
||||
|
||||
private:
|
||||
/// callback function
|
||||
const parser_callback_t callback = nullptr;
|
||||
const parser_callback_t<BasicJsonType> callback = nullptr;
|
||||
/// the type of the last read token
|
||||
token_type last_token = token_type::uninitialized;
|
||||
/// the lexer
|
||||
|
||||
@@ -18,6 +18,8 @@ template<typename BasicJsonType> struct internal_iterator
|
||||
typename BasicJsonType::object_t::iterator object_iterator {};
|
||||
/// iterator for JSON arrays
|
||||
typename BasicJsonType::array_t::iterator array_iterator {};
|
||||
/// iterator for JSON binary arrays
|
||||
typename BasicJsonType::binary_t::iterator binary_iterator {};
|
||||
/// generic iterator for all other types
|
||||
primitive_iterator_t primitive_iterator {};
|
||||
};
|
||||
|
||||
@@ -126,8 +126,8 @@ class json_pointer
|
||||
/*!
|
||||
@brief append an array index at the end of this JSON pointer
|
||||
|
||||
@param[in] array_index array index to append
|
||||
@return JSON pointer with @a array_index appended
|
||||
@param[in] array_idx array index to append
|
||||
@return JSON pointer with @a array_idx appended
|
||||
|
||||
@liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add}
|
||||
|
||||
@@ -139,9 +139,9 @@ class json_pointer
|
||||
|
||||
@since version 3.6.0
|
||||
*/
|
||||
json_pointer& operator/=(std::size_t array_index)
|
||||
json_pointer& operator/=(std::size_t array_idx)
|
||||
{
|
||||
return *this /= std::to_string(array_index);
|
||||
return *this /= std::to_string(array_idx);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -189,8 +189,8 @@ class json_pointer
|
||||
@brief create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
|
||||
|
||||
@param[in] ptr JSON pointer
|
||||
@param[in] array_index array index
|
||||
@return a new JSON pointer with @a array_index appended to @a ptr
|
||||
@param[in] array_idx array index
|
||||
@return a new JSON pointer with @a array_idx appended to @a ptr
|
||||
|
||||
@liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary}
|
||||
|
||||
@@ -200,9 +200,9 @@ class json_pointer
|
||||
|
||||
@since version 3.6.0
|
||||
*/
|
||||
friend json_pointer operator/(const json_pointer& ptr, std::size_t array_index)
|
||||
friend json_pointer operator/(const json_pointer& ptr, std::size_t array_idx)
|
||||
{
|
||||
return json_pointer(ptr) /= array_index;
|
||||
return json_pointer(ptr) /= array_idx;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -329,8 +329,30 @@ class json_pointer
|
||||
*/
|
||||
static int array_index(const std::string& s)
|
||||
{
|
||||
// error condition (cf. RFC 6901, Sect. 4)
|
||||
if (JSON_HEDLEY_UNLIKELY(s.size() > 1 and s[0] == '0'))
|
||||
{
|
||||
JSON_THROW(detail::parse_error::create(106, 0,
|
||||
"array index '" + s +
|
||||
"' must not begin with '0'"));
|
||||
}
|
||||
|
||||
// error condition (cf. RFC 6901, Sect. 4)
|
||||
if (JSON_HEDLEY_UNLIKELY(s.size() > 1 and not (s[0] >= '1' and s[0] <= '9')))
|
||||
{
|
||||
JSON_THROW(detail::parse_error::create(109, 0, "array index '" + s + "' is not a number"));
|
||||
}
|
||||
|
||||
std::size_t processed_chars = 0;
|
||||
const int res = std::stoi(s, &processed_chars);
|
||||
int res = 0;
|
||||
JSON_TRY
|
||||
{
|
||||
res = std::stoi(s, &processed_chars);
|
||||
}
|
||||
JSON_CATCH(std::out_of_range&)
|
||||
{
|
||||
JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'"));
|
||||
}
|
||||
|
||||
// check if the string was completely read
|
||||
if (JSON_HEDLEY_UNLIKELY(processed_chars != s.size()))
|
||||
@@ -397,14 +419,7 @@ class json_pointer
|
||||
case detail::value_t::array:
|
||||
{
|
||||
// create an entry in the array
|
||||
JSON_TRY
|
||||
{
|
||||
result = &result->operator[](static_cast<size_type>(array_index(reference_token)));
|
||||
}
|
||||
JSON_CATCH(std::invalid_argument&)
|
||||
{
|
||||
JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number"));
|
||||
}
|
||||
result = &result->operator[](static_cast<size_type>(array_index(reference_token)));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -474,14 +489,6 @@ class json_pointer
|
||||
|
||||
case detail::value_t::array:
|
||||
{
|
||||
// error condition (cf. RFC 6901, Sect. 4)
|
||||
if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0'))
|
||||
{
|
||||
JSON_THROW(detail::parse_error::create(106, 0,
|
||||
"array index '" + reference_token +
|
||||
"' must not begin with '0'"));
|
||||
}
|
||||
|
||||
if (reference_token == "-")
|
||||
{
|
||||
// explicitly treat "-" as index beyond the end
|
||||
@@ -490,15 +497,8 @@ class json_pointer
|
||||
else
|
||||
{
|
||||
// convert array index to number; unchecked access
|
||||
JSON_TRY
|
||||
{
|
||||
ptr = &ptr->operator[](
|
||||
static_cast<size_type>(array_index(reference_token)));
|
||||
}
|
||||
JSON_CATCH(std::invalid_argument&)
|
||||
{
|
||||
JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number"));
|
||||
}
|
||||
ptr = &ptr->operator[](
|
||||
static_cast<size_type>(array_index(reference_token)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -541,23 +541,8 @@ class json_pointer
|
||||
") is out of range"));
|
||||
}
|
||||
|
||||
// error condition (cf. RFC 6901, Sect. 4)
|
||||
if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0'))
|
||||
{
|
||||
JSON_THROW(detail::parse_error::create(106, 0,
|
||||
"array index '" + reference_token +
|
||||
"' must not begin with '0'"));
|
||||
}
|
||||
|
||||
// note: at performs range check
|
||||
JSON_TRY
|
||||
{
|
||||
ptr = &ptr->at(static_cast<size_type>(array_index(reference_token)));
|
||||
}
|
||||
JSON_CATCH(std::invalid_argument&)
|
||||
{
|
||||
JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number"));
|
||||
}
|
||||
ptr = &ptr->at(static_cast<size_type>(array_index(reference_token)));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -606,24 +591,9 @@ class json_pointer
|
||||
") is out of range"));
|
||||
}
|
||||
|
||||
// error condition (cf. RFC 6901, Sect. 4)
|
||||
if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0'))
|
||||
{
|
||||
JSON_THROW(detail::parse_error::create(106, 0,
|
||||
"array index '" + reference_token +
|
||||
"' must not begin with '0'"));
|
||||
}
|
||||
|
||||
// use unchecked array access
|
||||
JSON_TRY
|
||||
{
|
||||
ptr = &ptr->operator[](
|
||||
static_cast<size_type>(array_index(reference_token)));
|
||||
}
|
||||
JSON_CATCH(std::invalid_argument&)
|
||||
{
|
||||
JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number"));
|
||||
}
|
||||
ptr = &ptr->operator[](
|
||||
static_cast<size_type>(array_index(reference_token)));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -665,23 +635,8 @@ class json_pointer
|
||||
") is out of range"));
|
||||
}
|
||||
|
||||
// error condition (cf. RFC 6901, Sect. 4)
|
||||
if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0'))
|
||||
{
|
||||
JSON_THROW(detail::parse_error::create(106, 0,
|
||||
"array index '" + reference_token +
|
||||
"' must not begin with '0'"));
|
||||
}
|
||||
|
||||
// note: at performs range check
|
||||
JSON_TRY
|
||||
{
|
||||
ptr = &ptr->at(static_cast<size_type>(array_index(reference_token)));
|
||||
}
|
||||
JSON_CATCH(std::invalid_argument&)
|
||||
{
|
||||
JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number"));
|
||||
}
|
||||
ptr = &ptr->at(static_cast<size_type>(array_index(reference_token)));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -723,31 +678,36 @@ class json_pointer
|
||||
// "-" always fails the range check
|
||||
return false;
|
||||
}
|
||||
|
||||
// error condition (cf. RFC 6901, Sect. 4)
|
||||
if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0'))
|
||||
if (JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 and not ("0" <= reference_token and reference_token <= "9")))
|
||||
{
|
||||
JSON_THROW(detail::parse_error::create(106, 0,
|
||||
"array index '" + reference_token +
|
||||
"' must not begin with '0'"));
|
||||
// invalid char
|
||||
return false;
|
||||
}
|
||||
|
||||
JSON_TRY
|
||||
if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1))
|
||||
{
|
||||
const auto idx = static_cast<size_type>(array_index(reference_token));
|
||||
if (idx >= ptr->size())
|
||||
if (JSON_HEDLEY_UNLIKELY(not ('1' <= reference_token[0] and reference_token[0] <= '9')))
|
||||
{
|
||||
// index out of range
|
||||
// first char should be between '1' and '9'
|
||||
return false;
|
||||
}
|
||||
for (std::size_t i = 1; i < reference_token.size(); i++)
|
||||
{
|
||||
if (JSON_HEDLEY_UNLIKELY(not ('0' <= reference_token[i] and reference_token[i] <= '9')))
|
||||
{
|
||||
// other char should be between '0' and '9'
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ptr = &ptr->operator[](idx);
|
||||
break;
|
||||
}
|
||||
JSON_CATCH(std::invalid_argument&)
|
||||
const auto idx = static_cast<size_type>(array_index(reference_token));
|
||||
if (idx >= ptr->size())
|
||||
{
|
||||
JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number"));
|
||||
// index out of range
|
||||
return false;
|
||||
}
|
||||
|
||||
ptr = &ptr->operator[](idx);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -121,9 +121,10 @@
|
||||
class StringType, class BooleanType, class NumberIntegerType, \
|
||||
class NumberUnsignedType, class NumberFloatType, \
|
||||
template<typename> class AllocatorType, \
|
||||
template<typename, typename = void> class JSONSerializer>
|
||||
template<typename, typename = void> class JSONSerializer, \
|
||||
class BinaryType>
|
||||
|
||||
#define NLOHMANN_BASIC_JSON_TPL \
|
||||
basic_json<ObjectType, ArrayType, StringType, BooleanType, \
|
||||
NumberIntegerType, NumberUnsignedType, NumberFloatType, \
|
||||
AllocatorType, JSONSerializer>
|
||||
AllocatorType, JSONSerializer, BinaryType>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <nlohmann/detail/meta/void_t.hpp>
|
||||
|
||||
// http://en.cppreference.com/w/cpp/experimental/is_detected
|
||||
// https://en.cppreference.com/w/cpp/experimental/is_detected
|
||||
namespace nlohmann
|
||||
{
|
||||
namespace detail
|
||||
|
||||
@@ -41,6 +41,19 @@ template<typename> struct is_basic_json : std::false_type {};
|
||||
NLOHMANN_BASIC_JSON_TPL_DECLARATION
|
||||
struct is_basic_json<NLOHMANN_BASIC_JSON_TPL> : std::true_type {};
|
||||
|
||||
//////////////////////
|
||||
// json_ref helpers //
|
||||
//////////////////////
|
||||
|
||||
template <typename>
|
||||
class json_ref;
|
||||
|
||||
template<typename>
|
||||
struct is_json_ref : std::false_type {};
|
||||
|
||||
template <typename T>
|
||||
struct is_json_ref<json_ref<T>> : std::true_type {};
|
||||
|
||||
//////////////////////////
|
||||
// aliases for detected //
|
||||
//////////////////////////
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <cstring> // memcpy
|
||||
#include <limits> // numeric_limits
|
||||
#include <string> // string
|
||||
#include <cmath> // isnan, isinf
|
||||
|
||||
#include <nlohmann/detail/input/binary_reader.hpp>
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
@@ -26,6 +27,7 @@ template<typename BasicJsonType, typename CharType>
|
||||
class binary_writer
|
||||
{
|
||||
using string_t = typename BasicJsonType::string_t;
|
||||
using internal_binary_t = typename BasicJsonType::internal_binary_t;
|
||||
|
||||
public:
|
||||
/*!
|
||||
@@ -176,8 +178,35 @@ class binary_writer
|
||||
|
||||
case value_t::number_float:
|
||||
{
|
||||
oa->write_character(get_cbor_float_prefix(j.m_value.number_float));
|
||||
write_number(j.m_value.number_float);
|
||||
if (std::isnan(j.m_value.number_float))
|
||||
{
|
||||
// NaN is 0xf97e00 in CBOR
|
||||
oa->write_character(to_char_type(0xF9));
|
||||
oa->write_character(to_char_type(0x7E));
|
||||
oa->write_character(to_char_type(0x00));
|
||||
}
|
||||
else if (std::isinf(j.m_value.number_float))
|
||||
{
|
||||
// Infinity is 0xf97c00, -Infinity is 0xf9fc00
|
||||
oa->write_character(to_char_type(0xf9));
|
||||
oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
|
||||
oa->write_character(to_char_type(0x00));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (j.m_value.number_float >= std::numeric_limits<float>::lowest() and
|
||||
j.m_value.number_float <= std::numeric_limits<float>::max() and
|
||||
static_cast<double>(static_cast<float>(j.m_value.number_float)) == j.m_value.number_float)
|
||||
{
|
||||
oa->write_character(get_cbor_float_prefix(static_cast<float>(j.m_value.number_float)));
|
||||
write_number(static_cast<float>(j.m_value.number_float));
|
||||
}
|
||||
else
|
||||
{
|
||||
oa->write_character(get_cbor_float_prefix(j.m_value.number_float));
|
||||
write_number(j.m_value.number_float);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -258,6 +287,45 @@ class binary_writer
|
||||
break;
|
||||
}
|
||||
|
||||
case value_t::binary:
|
||||
{
|
||||
// step 1: write control byte and the binary array size
|
||||
const auto N = j.m_value.binary->size();
|
||||
if (N <= 0x17)
|
||||
{
|
||||
write_number(static_cast<std::uint8_t>(0x40 + N));
|
||||
}
|
||||
else if (N <= (std::numeric_limits<std::uint8_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0x58));
|
||||
write_number(static_cast<std::uint8_t>(N));
|
||||
}
|
||||
else if (N <= (std::numeric_limits<std::uint16_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0x59));
|
||||
write_number(static_cast<std::uint16_t>(N));
|
||||
}
|
||||
else if (N <= (std::numeric_limits<std::uint32_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0x5A));
|
||||
write_number(static_cast<std::uint32_t>(N));
|
||||
}
|
||||
// LCOV_EXCL_START
|
||||
else if (N <= (std::numeric_limits<std::uint64_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0x5B));
|
||||
write_number(static_cast<std::uint64_t>(N));
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
|
||||
// step 2: write each element
|
||||
oa->write_characters(
|
||||
reinterpret_cast<const CharType*>(j.m_value.binary->data()),
|
||||
N);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case value_t::object:
|
||||
{
|
||||
// step 1: write control byte and the object size
|
||||
@@ -506,6 +574,101 @@ class binary_writer
|
||||
break;
|
||||
}
|
||||
|
||||
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
|
||||
const bool use_ext = j.m_value.binary->has_subtype;
|
||||
|
||||
// step 1: write control byte and the byte string length
|
||||
const auto N = j.m_value.binary->size();
|
||||
if (N <= (std::numeric_limits<std::uint8_t>::max)())
|
||||
{
|
||||
std::uint8_t output_type;
|
||||
bool fixed = true;
|
||||
if (use_ext)
|
||||
{
|
||||
switch (N)
|
||||
{
|
||||
case 1:
|
||||
output_type = 0xD4; // fixext 1
|
||||
break;
|
||||
case 2:
|
||||
output_type = 0xD5; // fixext 2
|
||||
break;
|
||||
case 4:
|
||||
output_type = 0xD6; // fixext 4
|
||||
break;
|
||||
case 8:
|
||||
output_type = 0xD7; // fixext 8
|
||||
break;
|
||||
case 16:
|
||||
output_type = 0xD8; // fixext 16
|
||||
break;
|
||||
default:
|
||||
output_type = 0xC7; // ext 8
|
||||
fixed = false;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
output_type = 0xC4; // bin 8
|
||||
fixed = false;
|
||||
}
|
||||
|
||||
oa->write_character(to_char_type(output_type));
|
||||
if (not fixed)
|
||||
{
|
||||
write_number(static_cast<std::uint8_t>(N));
|
||||
}
|
||||
}
|
||||
else if (N <= (std::numeric_limits<std::uint16_t>::max)())
|
||||
{
|
||||
std::uint8_t output_type;
|
||||
if (use_ext)
|
||||
{
|
||||
output_type = 0xC8; // ext 16
|
||||
}
|
||||
else
|
||||
{
|
||||
output_type = 0xC5; // bin 16
|
||||
}
|
||||
|
||||
oa->write_character(to_char_type(output_type));
|
||||
write_number(static_cast<std::uint16_t>(N));
|
||||
}
|
||||
else if (N <= (std::numeric_limits<std::uint32_t>::max)())
|
||||
{
|
||||
std::uint8_t output_type;
|
||||
if (use_ext)
|
||||
{
|
||||
output_type = 0xC9; // ext 32
|
||||
}
|
||||
else
|
||||
{
|
||||
output_type = 0xC6; // bin 32
|
||||
}
|
||||
|
||||
oa->write_character(to_char_type(output_type));
|
||||
write_number(static_cast<std::uint32_t>(N));
|
||||
}
|
||||
|
||||
// step 1.5: if this is an ext type, write the subtype
|
||||
if (use_ext)
|
||||
{
|
||||
write_number(j.m_value.binary->subtype);
|
||||
}
|
||||
|
||||
// step 2: write the byte string
|
||||
oa->write_characters(
|
||||
reinterpret_cast<const CharType*>(j.m_value.binary->data()),
|
||||
N);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case value_t::object:
|
||||
{
|
||||
// step 1: write control byte and the object size
|
||||
@@ -649,6 +812,49 @@ class binary_writer
|
||||
break;
|
||||
}
|
||||
|
||||
case value_t::binary:
|
||||
{
|
||||
if (add_prefix)
|
||||
{
|
||||
oa->write_character(to_char_type('['));
|
||||
}
|
||||
|
||||
if (use_type and not j.m_value.binary->empty())
|
||||
{
|
||||
assert(use_count);
|
||||
oa->write_character(to_char_type('$'));
|
||||
oa->write_character('U');
|
||||
}
|
||||
|
||||
if (use_count)
|
||||
{
|
||||
oa->write_character(to_char_type('#'));
|
||||
write_number_with_ubjson_prefix(j.m_value.binary->size(), true);
|
||||
}
|
||||
|
||||
if (use_type)
|
||||
{
|
||||
oa->write_characters(
|
||||
reinterpret_cast<const CharType*>(j.m_value.binary->data()),
|
||||
j.m_value.binary->size());
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t i = 0; i < j.m_value.binary->size(); ++i)
|
||||
{
|
||||
oa->write_character(to_char_type('U'));
|
||||
oa->write_character(j.m_value.binary->data()[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (not use_count)
|
||||
{
|
||||
oa->write_character(to_char_type(']'));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case value_t::object:
|
||||
{
|
||||
if (add_prefix)
|
||||
@@ -871,6 +1077,14 @@ class binary_writer
|
||||
return sizeof(std::int32_t) + embedded_document_size + 1ul;
|
||||
}
|
||||
|
||||
/*!
|
||||
@return The size of the BSON-encoded binary array @a value
|
||||
*/
|
||||
static std::size_t calc_bson_binary_size(const typename BasicJsonType::internal_binary_t& value)
|
||||
{
|
||||
return sizeof(std::int32_t) + value.size() + 1ul;
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief Writes a BSON element with key @a name and array @a value
|
||||
*/
|
||||
@@ -890,6 +1104,25 @@ class binary_writer
|
||||
oa->write_character(to_char_type(0x00));
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief Writes a BSON element with key @a name and binary value @a value
|
||||
*/
|
||||
void write_bson_binary(const string_t& name,
|
||||
const internal_binary_t& value)
|
||||
{
|
||||
write_bson_entry_header(name, 0x05);
|
||||
|
||||
write_number<std::int32_t, true>(static_cast<std::int32_t>(value.size()));
|
||||
std::uint8_t subtype = 0x00; // Generic Binary Subtype
|
||||
if (value.has_subtype)
|
||||
{
|
||||
subtype = value.subtype;
|
||||
}
|
||||
write_number(subtype);
|
||||
|
||||
oa->write_characters(reinterpret_cast<const CharType*>(value.data()), value.size());
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief Calculates the size necessary to serialize the JSON value @a j with its @a name
|
||||
@return The calculated size for the BSON document entry for @a j with the given @a name.
|
||||
@@ -906,6 +1139,9 @@ class binary_writer
|
||||
case value_t::array:
|
||||
return header_size + calc_bson_array_size(*j.m_value.array);
|
||||
|
||||
case value_t::binary:
|
||||
return header_size + calc_bson_binary_size(*j.m_value.binary);
|
||||
|
||||
case value_t::boolean:
|
||||
return header_size + 1ul;
|
||||
|
||||
@@ -950,6 +1186,9 @@ class binary_writer
|
||||
case value_t::array:
|
||||
return write_bson_array(name, *j.m_value.array);
|
||||
|
||||
case value_t::binary:
|
||||
return write_bson_binary(name, *j.m_value.binary);
|
||||
|
||||
case value_t::boolean:
|
||||
return write_bson_boolean(name, j.m_value.boolean);
|
||||
|
||||
@@ -1230,7 +1469,8 @@ class binary_writer
|
||||
case value_t::string:
|
||||
return 'S';
|
||||
|
||||
case value_t::array:
|
||||
case value_t::array: // fallthrough
|
||||
case value_t::binary:
|
||||
return '[';
|
||||
|
||||
case value_t::object:
|
||||
@@ -1300,7 +1540,7 @@ class binary_writer
|
||||
static CharType to_char_type(std::uint8_t x) noexcept
|
||||
{
|
||||
static_assert(sizeof(std::uint8_t) == sizeof(CharType), "size of CharType must be equal to std::uint8_t");
|
||||
static_assert(std::is_pod<CharType>::value, "CharType must be POD");
|
||||
static_assert(std::is_trivial<CharType>::value, "CharType must be trivial");
|
||||
CharType result;
|
||||
std::memcpy(&result, &x, sizeof(x));
|
||||
return result;
|
||||
@@ -1326,7 +1566,7 @@ class binary_writer
|
||||
|
||||
private:
|
||||
/// whether we can assume little endianess
|
||||
const bool is_little_endian = binary_reader<BasicJsonType>::little_endianess();
|
||||
const bool is_little_endian = little_endianess();
|
||||
|
||||
/// the output
|
||||
output_adapter_t<CharType> oa = nullptr;
|
||||
|
||||
@@ -45,6 +45,7 @@ class serializer
|
||||
using number_float_t = typename BasicJsonType::number_float_t;
|
||||
using number_integer_t = typename BasicJsonType::number_integer_t;
|
||||
using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
|
||||
using binary_t = typename BasicJsonType::binary_t;
|
||||
static constexpr std::uint8_t UTF8_ACCEPT = 0;
|
||||
static constexpr std::uint8_t UTF8_REJECT = 1;
|
||||
|
||||
@@ -83,16 +84,19 @@ class serializer
|
||||
- strings and object keys are escaped using `escape_string()`
|
||||
- integer numbers are converted implicitly via `operator<<`
|
||||
- floating-point numbers are converted to a string using `"%g"` format
|
||||
- if specified to, binary values are output using the syntax `b[]`, otherwise an exception is thrown
|
||||
|
||||
@param[in] val value to serialize
|
||||
@param[in] pretty_print whether the output shall be pretty-printed
|
||||
@param[in] indent_step the indent level
|
||||
@param[in] current_indent the current indent level (only used internally)
|
||||
@param[in] val value to serialize
|
||||
@param[in] pretty_print whether the output shall be pretty-printed
|
||||
@param[in] indent_step the indent level
|
||||
@param[in] current_indent the current indent level (only used internally)
|
||||
@param[in] serialize_binary whether the output shall include non-standard binary output
|
||||
*/
|
||||
void dump(const BasicJsonType& val, const bool pretty_print,
|
||||
const bool ensure_ascii,
|
||||
const unsigned int indent_step,
|
||||
const unsigned int current_indent = 0)
|
||||
const unsigned int current_indent = 0,
|
||||
const bool serialize_binary = false)
|
||||
{
|
||||
switch (val.m_type)
|
||||
{
|
||||
@@ -123,7 +127,7 @@ class serializer
|
||||
o->write_character('\"');
|
||||
dump_escaped(i->first, ensure_ascii);
|
||||
o->write_characters("\": ", 3);
|
||||
dump(i->second, true, ensure_ascii, indent_step, new_indent);
|
||||
dump(i->second, true, ensure_ascii, indent_step, new_indent, serialize_binary);
|
||||
o->write_characters(",\n", 2);
|
||||
}
|
||||
|
||||
@@ -134,7 +138,7 @@ class serializer
|
||||
o->write_character('\"');
|
||||
dump_escaped(i->first, ensure_ascii);
|
||||
o->write_characters("\": ", 3);
|
||||
dump(i->second, true, ensure_ascii, indent_step, new_indent);
|
||||
dump(i->second, true, ensure_ascii, indent_step, new_indent, serialize_binary);
|
||||
|
||||
o->write_character('\n');
|
||||
o->write_characters(indent_string.c_str(), current_indent);
|
||||
@@ -151,7 +155,7 @@ class serializer
|
||||
o->write_character('\"');
|
||||
dump_escaped(i->first, ensure_ascii);
|
||||
o->write_characters("\":", 2);
|
||||
dump(i->second, false, ensure_ascii, indent_step, current_indent);
|
||||
dump(i->second, false, ensure_ascii, indent_step, current_indent, serialize_binary);
|
||||
o->write_character(',');
|
||||
}
|
||||
|
||||
@@ -161,7 +165,7 @@ class serializer
|
||||
o->write_character('\"');
|
||||
dump_escaped(i->first, ensure_ascii);
|
||||
o->write_characters("\":", 2);
|
||||
dump(i->second, false, ensure_ascii, indent_step, current_indent);
|
||||
dump(i->second, false, ensure_ascii, indent_step, current_indent, serialize_binary);
|
||||
|
||||
o->write_character('}');
|
||||
}
|
||||
@@ -193,14 +197,14 @@ class serializer
|
||||
i != val.m_value.array->cend() - 1; ++i)
|
||||
{
|
||||
o->write_characters(indent_string.c_str(), new_indent);
|
||||
dump(*i, true, ensure_ascii, indent_step, new_indent);
|
||||
dump(*i, true, ensure_ascii, indent_step, new_indent, serialize_binary);
|
||||
o->write_characters(",\n", 2);
|
||||
}
|
||||
|
||||
// last element
|
||||
assert(not val.m_value.array->empty());
|
||||
o->write_characters(indent_string.c_str(), new_indent);
|
||||
dump(val.m_value.array->back(), true, ensure_ascii, indent_step, new_indent);
|
||||
dump(val.m_value.array->back(), true, ensure_ascii, indent_step, new_indent, serialize_binary);
|
||||
|
||||
o->write_character('\n');
|
||||
o->write_characters(indent_string.c_str(), current_indent);
|
||||
@@ -214,13 +218,13 @@ class serializer
|
||||
for (auto i = val.m_value.array->cbegin();
|
||||
i != val.m_value.array->cend() - 1; ++i)
|
||||
{
|
||||
dump(*i, false, ensure_ascii, indent_step, current_indent);
|
||||
dump(*i, false, ensure_ascii, indent_step, current_indent, serialize_binary);
|
||||
o->write_character(',');
|
||||
}
|
||||
|
||||
// last element
|
||||
assert(not val.m_value.array->empty());
|
||||
dump(val.m_value.array->back(), false, ensure_ascii, indent_step, current_indent);
|
||||
dump(val.m_value.array->back(), false, ensure_ascii, indent_step, current_indent, serialize_binary);
|
||||
|
||||
o->write_character(']');
|
||||
}
|
||||
@@ -236,6 +240,33 @@ class serializer
|
||||
return;
|
||||
}
|
||||
|
||||
case value_t::binary:
|
||||
{
|
||||
if (not serialize_binary)
|
||||
{
|
||||
JSON_THROW(type_error::create(317, "cannot serialize binary data to text JSON"));
|
||||
}
|
||||
|
||||
if (val.m_value.binary->empty())
|
||||
{
|
||||
o->write_characters("b[]", 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
o->write_characters("b[", 2);
|
||||
for (auto i = val.m_value.binary->cbegin();
|
||||
i != val.m_value.binary->cend() - 1; ++i)
|
||||
{
|
||||
dump_integer(*i);
|
||||
o->write_character(',');
|
||||
}
|
||||
|
||||
dump_integer(val.m_value.binary->back());
|
||||
o->write_character(']');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
case value_t::boolean:
|
||||
{
|
||||
if (val.m_value.boolean)
|
||||
@@ -592,7 +623,8 @@ class serializer
|
||||
*/
|
||||
template<typename NumberType, detail::enable_if_t<
|
||||
std::is_same<NumberType, number_unsigned_t>::value or
|
||||
std::is_same<NumberType, number_integer_t>::value,
|
||||
std::is_same<NumberType, number_integer_t>::value or
|
||||
std::is_same<NumberType, typename binary_t::value_type>::value,
|
||||
int> = 0>
|
||||
void dump_integer(NumberType x)
|
||||
{
|
||||
@@ -630,7 +662,7 @@ class serializer
|
||||
if (is_negative)
|
||||
{
|
||||
*buffer_ptr = '-';
|
||||
abs_value = remove_sign(x);
|
||||
abs_value = remove_sign(static_cast<number_integer_t>(x));
|
||||
|
||||
// account one more byte for the minus sign
|
||||
n_chars = 1 + count_digits(abs_value);
|
||||
@@ -807,7 +839,9 @@ class serializer
|
||||
? (byte & 0x3fu) | (codep << 6u)
|
||||
: (0xFFu >> type) & (byte);
|
||||
|
||||
state = utf8d[256u + state * 16u + type];
|
||||
std::size_t index = 256u + static_cast<size_t>(state) * 16u + static_cast<size_t>(type);
|
||||
assert(index < 400);
|
||||
state = utf8d[index];
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,24 +48,29 @@ enum class value_t : std::uint8_t
|
||||
number_integer, ///< number value (signed integer)
|
||||
number_unsigned, ///< number value (unsigned integer)
|
||||
number_float, ///< number value (floating-point)
|
||||
discarded ///< discarded by the the parser callback function
|
||||
binary, ///< binary array (ordered collection of bytes)
|
||||
discarded ///< discarded by the parser callback function
|
||||
};
|
||||
|
||||
/*!
|
||||
@brief comparison operator for JSON types
|
||||
|
||||
Returns an ordering that is similar to Python:
|
||||
- order: null < boolean < number < object < array < string
|
||||
- order: null < boolean < number < object < array < string < binary
|
||||
- furthermore, each type is not smaller than itself
|
||||
- discarded values are not comparable
|
||||
- binary is represented as a b"" string in python and directly comparable to a
|
||||
string; however, making a binary array directly comparable with a string would
|
||||
be surprising behavior in a JSON file.
|
||||
|
||||
@since version 1.0.0
|
||||
*/
|
||||
inline bool operator<(const value_t lhs, const value_t rhs) noexcept
|
||||
{
|
||||
static constexpr std::array<std::uint8_t, 8> order = {{
|
||||
static constexpr std::array<std::uint8_t, 9> order = {{
|
||||
0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */,
|
||||
1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */
|
||||
1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */,
|
||||
6 /* binary */
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -33,7 +33,8 @@ template<template<typename U, typename V, typename... Args> class ObjectType =
|
||||
class NumberFloatType = double,
|
||||
template<typename U> class AllocatorType = std::allocator,
|
||||
template<typename T, typename SFINAE = void> class JSONSerializer =
|
||||
adl_serializer>
|
||||
adl_serializer,
|
||||
class BinaryType = std::vector<std::uint8_t>>
|
||||
class basic_json;
|
||||
|
||||
/*!
|
||||
|
||||
676
include/nlohmann/thirdparty/hedley/hedley.hpp
vendored
676
include/nlohmann/thirdparty/hedley/hedley.hpp
vendored
@@ -10,11 +10,11 @@
|
||||
* SPDX-License-Identifier: CC0-1.0
|
||||
*/
|
||||
|
||||
#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 11)
|
||||
#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 13)
|
||||
#if defined(JSON_HEDLEY_VERSION)
|
||||
#undef JSON_HEDLEY_VERSION
|
||||
#endif
|
||||
#define JSON_HEDLEY_VERSION 11
|
||||
#define JSON_HEDLEY_VERSION 13
|
||||
|
||||
#if defined(JSON_HEDLEY_STRINGIFY_EX)
|
||||
#undef JSON_HEDLEY_STRINGIFY_EX
|
||||
@@ -36,6 +36,16 @@
|
||||
#endif
|
||||
#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
|
||||
|
||||
#if defined(JSON_HEDLEY_CONCAT3_EX)
|
||||
#undef JSON_HEDLEY_CONCAT3_EX
|
||||
#endif
|
||||
#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
|
||||
|
||||
#if defined(JSON_HEDLEY_CONCAT3)
|
||||
#undef JSON_HEDLEY_CONCAT3
|
||||
#endif
|
||||
#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
|
||||
|
||||
#if defined(JSON_HEDLEY_VERSION_ENCODE)
|
||||
#undef JSON_HEDLEY_VERSION_ENCODE
|
||||
#endif
|
||||
@@ -211,9 +221,17 @@
|
||||
#if defined(JSON_HEDLEY_TI_VERSION)
|
||||
#undef JSON_HEDLEY_TI_VERSION
|
||||
#endif
|
||||
#if defined(__TI_COMPILER_VERSION__)
|
||||
#if \
|
||||
defined(__TI_COMPILER_VERSION__) && \
|
||||
( \
|
||||
defined(__TMS470__) || defined(__TI_ARM__) || \
|
||||
defined(__MSP430__) || \
|
||||
defined(__TMS320C2000__) \
|
||||
)
|
||||
#if (__TI_COMPILER_VERSION__ >= 16000000)
|
||||
#define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
|
||||
#undef JSON_HEDLEY_TI_VERSION_CHECK
|
||||
@@ -224,6 +242,102 @@
|
||||
#define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
|
||||
#undef JSON_HEDLEY_TI_CL2000_VERSION
|
||||
#endif
|
||||
#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
|
||||
#define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
|
||||
#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
|
||||
#endif
|
||||
#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
|
||||
#define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
|
||||
#else
|
||||
#define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_TI_CL430_VERSION)
|
||||
#undef JSON_HEDLEY_TI_CL430_VERSION
|
||||
#endif
|
||||
#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
|
||||
#define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
|
||||
#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
|
||||
#endif
|
||||
#if defined(JSON_HEDLEY_TI_CL430_VERSION)
|
||||
#define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
|
||||
#else
|
||||
#define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
|
||||
#undef JSON_HEDLEY_TI_ARMCL_VERSION
|
||||
#endif
|
||||
#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
|
||||
#define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
|
||||
#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
|
||||
#endif
|
||||
#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
|
||||
#define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
|
||||
#else
|
||||
#define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
|
||||
#undef JSON_HEDLEY_TI_CL6X_VERSION
|
||||
#endif
|
||||
#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
|
||||
#define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
|
||||
#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
|
||||
#endif
|
||||
#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
|
||||
#define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
|
||||
#else
|
||||
#define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
|
||||
#undef JSON_HEDLEY_TI_CL7X_VERSION
|
||||
#endif
|
||||
#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
|
||||
#define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
|
||||
#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
|
||||
#endif
|
||||
#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
|
||||
#define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
|
||||
#else
|
||||
#define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
|
||||
#undef JSON_HEDLEY_TI_CLPRU_VERSION
|
||||
#endif
|
||||
#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
|
||||
#define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
|
||||
#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
|
||||
#endif
|
||||
#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
|
||||
#define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
|
||||
#else
|
||||
#define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_CRAY_VERSION)
|
||||
#undef JSON_HEDLEY_CRAY_VERSION
|
||||
#endif
|
||||
@@ -338,6 +452,12 @@
|
||||
!defined(JSON_HEDLEY_PGI_VERSION) && \
|
||||
!defined(JSON_HEDLEY_ARM_VERSION) && \
|
||||
!defined(JSON_HEDLEY_TI_VERSION) && \
|
||||
!defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
|
||||
!defined(JSON_HEDLEY_TI_CL430_VERSION) && \
|
||||
!defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
|
||||
!defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
|
||||
!defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
|
||||
!defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
|
||||
!defined(__COMPCERT__)
|
||||
#define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
|
||||
#endif
|
||||
@@ -397,6 +517,7 @@
|
||||
#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
|
||||
#elif \
|
||||
!defined(JSON_HEDLEY_PGI_VERSION) && \
|
||||
!defined(JSON_HEDLEY_IAR_VERSION) && \
|
||||
(!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
|
||||
(!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
|
||||
#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
|
||||
@@ -562,14 +683,85 @@
|
||||
#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
|
||||
#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
|
||||
#endif
|
||||
#if defined(__cplusplus) && JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
|
||||
# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
|
||||
#if defined(__cplusplus)
|
||||
# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
|
||||
# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
|
||||
# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
|
||||
JSON_HEDLEY_DIAGNOSTIC_PUSH \
|
||||
_Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
|
||||
_Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
|
||||
xpr \
|
||||
JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
# else
|
||||
# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
|
||||
JSON_HEDLEY_DIAGNOSTIC_PUSH \
|
||||
_Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
|
||||
xpr \
|
||||
JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_CONST_CAST)
|
||||
#undef JSON_HEDLEY_CONST_CAST
|
||||
#endif
|
||||
#if defined(__cplusplus)
|
||||
# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
|
||||
#elif \
|
||||
JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
|
||||
# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
|
||||
JSON_HEDLEY_DIAGNOSTIC_PUSH \
|
||||
JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
|
||||
((T) (expr)); \
|
||||
JSON_HEDLEY_DIAGNOSTIC_POP \
|
||||
}))
|
||||
#else
|
||||
# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
|
||||
# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_REINTERPRET_CAST)
|
||||
#undef JSON_HEDLEY_REINTERPRET_CAST
|
||||
#endif
|
||||
#if defined(__cplusplus)
|
||||
#define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
|
||||
#else
|
||||
#define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_STATIC_CAST)
|
||||
#undef JSON_HEDLEY_STATIC_CAST
|
||||
#endif
|
||||
#if defined(__cplusplus)
|
||||
#define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
|
||||
#else
|
||||
#define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_CPP_CAST)
|
||||
#undef JSON_HEDLEY_CPP_CAST
|
||||
#endif
|
||||
#if defined(__cplusplus)
|
||||
# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
|
||||
# define JSON_HEDLEY_CPP_CAST(T, expr) \
|
||||
JSON_HEDLEY_DIAGNOSTIC_PUSH \
|
||||
_Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
|
||||
((T) (expr)) \
|
||||
JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
|
||||
# define JSON_HEDLEY_CPP_CAST(T, expr) \
|
||||
JSON_HEDLEY_DIAGNOSTIC_PUSH \
|
||||
_Pragma("diag_suppress=Pe137") \
|
||||
JSON_HEDLEY_DIAGNOSTIC_POP \
|
||||
# else
|
||||
# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
|
||||
# endif
|
||||
#else
|
||||
# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
|
||||
#endif
|
||||
|
||||
#if \
|
||||
@@ -580,7 +772,13 @@
|
||||
JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
|
||||
JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
|
||||
JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
|
||||
JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
|
||||
@@ -613,7 +811,13 @@
|
||||
#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
|
||||
#elif JSON_HEDLEY_TI_VERSION_CHECK(8,1,0)
|
||||
#elif \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
|
||||
#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
|
||||
@@ -637,7 +841,18 @@
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
|
||||
#elif JSON_HEDLEY_TI_VERSION_CHECK(8,0,0)
|
||||
#elif \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
|
||||
(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
|
||||
(JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
|
||||
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
|
||||
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
|
||||
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
|
||||
@@ -664,7 +879,13 @@
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
|
||||
#elif JSON_HEDLEY_TI_VERSION_CHECK(8,0,0)
|
||||
#elif \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
|
||||
#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
|
||||
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
|
||||
@@ -687,8 +908,13 @@
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
|
||||
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
|
||||
#elif JSON_HEDLEY_TI_VERSION_CHECK(8,0,0)
|
||||
#elif \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
|
||||
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
|
||||
#else
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
|
||||
#endif
|
||||
@@ -712,7 +938,10 @@
|
||||
#if defined(JSON_HEDLEY_DEPRECATED_FOR)
|
||||
#undef JSON_HEDLEY_DEPRECATED_FOR
|
||||
#endif
|
||||
#if defined(__cplusplus) && (__cplusplus >= 201402L)
|
||||
#if JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0)
|
||||
#define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
|
||||
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
|
||||
#elif defined(__cplusplus) && (__cplusplus >= 201402L)
|
||||
#define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
|
||||
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
|
||||
#elif \
|
||||
@@ -722,20 +951,30 @@
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
|
||||
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(8,3,0)
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
|
||||
#define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
|
||||
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
|
||||
#elif \
|
||||
JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \
|
||||
(JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__))
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
|
||||
(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
|
||||
(JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
|
||||
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
|
||||
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
|
||||
#define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
|
||||
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0)
|
||||
#define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
|
||||
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
|
||||
#elif \
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
|
||||
JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0)
|
||||
@@ -764,21 +1003,40 @@
|
||||
#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
|
||||
#undef JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||
#endif
|
||||
#if defined(__cplusplus) && (__cplusplus >= 201703L)
|
||||
#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
|
||||
#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
|
||||
#endif
|
||||
#if (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
|
||||
#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
|
||||
#elif \
|
||||
JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \
|
||||
(JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
|
||||
(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
|
||||
(JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
|
||||
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
|
||||
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
|
||||
(JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
|
||||
#elif defined(_Check_return_) /* SAL */
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
|
||||
#else
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||
#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_SENTINEL)
|
||||
@@ -811,14 +1069,23 @@
|
||||
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(18,0,0) || \
|
||||
(JSON_HEDLEY_TI_VERSION_CHECK(17,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__))
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
|
||||
(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
|
||||
(JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
|
||||
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
|
||||
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
|
||||
#define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
|
||||
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
|
||||
#define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0)
|
||||
#define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
|
||||
#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus)
|
||||
#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
|
||||
#define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
|
||||
#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
|
||||
#define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
|
||||
@@ -843,31 +1110,6 @@
|
||||
#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
|
||||
#undef JSON_HEDLEY_UNREACHABLE_RETURN
|
||||
#endif
|
||||
#if \
|
||||
(JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5)
|
||||
#define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0)
|
||||
#define JSON_HEDLEY_UNREACHABLE() __assume(0)
|
||||
#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0)
|
||||
#if defined(__cplusplus)
|
||||
#define JSON_HEDLEY_UNREACHABLE() std::_nassert(0)
|
||||
#else
|
||||
#define JSON_HEDLEY_UNREACHABLE() _nassert(0)
|
||||
#endif
|
||||
#define JSON_HEDLEY_UNREACHABLE_RETURN(value) return value
|
||||
#elif defined(EXIT_FAILURE)
|
||||
#define JSON_HEDLEY_UNREACHABLE() abort()
|
||||
#else
|
||||
#define JSON_HEDLEY_UNREACHABLE()
|
||||
#define JSON_HEDLEY_UNREACHABLE_RETURN(value) return value
|
||||
#endif
|
||||
#if !defined(JSON_HEDLEY_UNREACHABLE_RETURN)
|
||||
#define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_ASSUME)
|
||||
#undef JSON_HEDLEY_ASSUME
|
||||
#endif
|
||||
@@ -877,20 +1119,45 @@
|
||||
#define JSON_HEDLEY_ASSUME(expr) __assume(expr)
|
||||
#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
|
||||
#define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
|
||||
#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0)
|
||||
#elif \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
|
||||
#if defined(__cplusplus)
|
||||
#define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
|
||||
#else
|
||||
#define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
|
||||
#endif
|
||||
#elif \
|
||||
(JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && !defined(JSON_HEDLEY_ARM_VERSION)) || \
|
||||
#endif
|
||||
#if \
|
||||
(JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5)
|
||||
#define JSON_HEDLEY_ASSUME(expr) ((void) ((expr) ? 1 : (__builtin_unreachable(), 1)))
|
||||
#define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
|
||||
#elif defined(JSON_HEDLEY_ASSUME)
|
||||
#define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
|
||||
#endif
|
||||
#if !defined(JSON_HEDLEY_ASSUME)
|
||||
#if defined(JSON_HEDLEY_UNREACHABLE)
|
||||
#define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
|
||||
#else
|
||||
#define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
|
||||
#endif
|
||||
#endif
|
||||
#if defined(JSON_HEDLEY_UNREACHABLE)
|
||||
#if \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
|
||||
#define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
|
||||
#else
|
||||
#define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
|
||||
#endif
|
||||
#else
|
||||
#define JSON_HEDLEY_ASSUME(expr) ((void) (expr))
|
||||
#define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
|
||||
#endif
|
||||
#if !defined(JSON_HEDLEY_UNREACHABLE)
|
||||
#define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
|
||||
#endif
|
||||
|
||||
JSON_HEDLEY_DIAGNOSTIC_PUSH
|
||||
@@ -934,8 +1201,17 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \
|
||||
(JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__))
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
|
||||
(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
|
||||
(JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
|
||||
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
|
||||
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
|
||||
#define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
|
||||
#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
|
||||
#define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
|
||||
@@ -968,19 +1244,16 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#undef JSON_HEDLEY_UNPREDICTABLE
|
||||
#endif
|
||||
#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
|
||||
#define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable(!!(expr))
|
||||
#define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
|
||||
#endif
|
||||
#if \
|
||||
JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0)
|
||||
# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability(expr, value, probability)
|
||||
# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1, probability)
|
||||
# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0, probability)
|
||||
# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
|
||||
# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
|
||||
#if !defined(JSON_HEDLEY_BUILTIN_UNPREDICTABLE)
|
||||
#define JSON_HEDLEY_BUILTIN_UNPREDICTABLE(expr) __builtin_expect_with_probability(!!(expr), 1, 0.5)
|
||||
#endif
|
||||
# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
|
||||
# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
|
||||
# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
|
||||
# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
|
||||
# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
|
||||
#elif \
|
||||
JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
|
||||
@@ -988,24 +1261,31 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
(JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(6,1,0) || \
|
||||
JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27)
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
|
||||
JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
|
||||
JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0)
|
||||
# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
|
||||
(((probability) >= 0.9) ? __builtin_expect(!!(expr), (expected)) : (((void) (expected)), !!(expr)))
|
||||
(((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
|
||||
# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
|
||||
(__extension__ ({ \
|
||||
JSON_HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \
|
||||
double hedley_probability_ = (probability); \
|
||||
((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
|
||||
}))
|
||||
# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
|
||||
(__extension__ ({ \
|
||||
JSON_HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \
|
||||
double hedley_probability_ = (probability); \
|
||||
((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
|
||||
}))
|
||||
# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
|
||||
# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
|
||||
#else
|
||||
# define JSON_HEDLEY_PREDICT(expr, expected, probability) (((void) (expected)), !!(expr))
|
||||
# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
|
||||
# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
|
||||
# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
|
||||
# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
|
||||
@@ -1025,8 +1305,17 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \
|
||||
(JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__))
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
|
||||
(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
|
||||
(JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
|
||||
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
|
||||
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
|
||||
#define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
|
||||
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
|
||||
#define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
|
||||
@@ -1040,22 +1329,36 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#undef JSON_HEDLEY_PURE
|
||||
#endif
|
||||
#if \
|
||||
JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \
|
||||
(JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
|
||||
#define JSON_HEDLEY_PURE __attribute__((__pure__))
|
||||
JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
|
||||
(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
|
||||
(JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
|
||||
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
|
||||
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
|
||||
# define JSON_HEDLEY_PURE __attribute__((__pure__))
|
||||
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
|
||||
#define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
|
||||
#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus)
|
||||
#define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
|
||||
# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
|
||||
#elif defined(__cplusplus) && \
|
||||
( \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
|
||||
)
|
||||
# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
|
||||
#else
|
||||
#define JSON_HEDLEY_PURE
|
||||
# define JSON_HEDLEY_PURE
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_CONST)
|
||||
@@ -1068,8 +1371,17 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \
|
||||
(JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
|
||||
(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
|
||||
(JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
|
||||
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
|
||||
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
|
||||
#define JSON_HEDLEY_CONST __attribute__((__const__))
|
||||
#elif \
|
||||
@@ -1091,7 +1403,10 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
(JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
|
||||
JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
|
||||
defined(__clang__)
|
||||
@@ -1116,7 +1431,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#elif \
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0)
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
|
||||
#define JSON_HEDLEY_INLINE __inline
|
||||
#else
|
||||
#define JSON_HEDLEY_INLINE
|
||||
@@ -1126,23 +1446,40 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#undef JSON_HEDLEY_ALWAYS_INLINE
|
||||
#endif
|
||||
#if \
|
||||
JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \
|
||||
(JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__))
|
||||
#define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
|
||||
JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
|
||||
(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
|
||||
(JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
|
||||
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
|
||||
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
|
||||
# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0)
|
||||
#define JSON_HEDLEY_ALWAYS_INLINE __forceinline
|
||||
#elif JSON_HEDLEY_TI_VERSION_CHECK(7,0,0) && defined(__cplusplus)
|
||||
#define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
|
||||
# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
|
||||
#elif defined(__cplusplus) && \
|
||||
( \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
|
||||
)
|
||||
# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
|
||||
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
|
||||
#define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
|
||||
# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
|
||||
#else
|
||||
#define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
|
||||
# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_NEVER_INLINE)
|
||||
@@ -1155,14 +1492,23 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \
|
||||
(JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__))
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
|
||||
(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
|
||||
(JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
|
||||
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
|
||||
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
|
||||
#define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0)
|
||||
#define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
|
||||
#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
|
||||
#define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
|
||||
#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus)
|
||||
#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
|
||||
#define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
|
||||
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
|
||||
#define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
|
||||
@@ -1184,26 +1530,31 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#undef JSON_HEDLEY_IMPORT
|
||||
#endif
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
#define JSON_HEDLEY_PRIVATE
|
||||
#define JSON_HEDLEY_PUBLIC __declspec(dllexport)
|
||||
#define JSON_HEDLEY_IMPORT __declspec(dllimport)
|
||||
# define JSON_HEDLEY_PRIVATE
|
||||
# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
|
||||
# define JSON_HEDLEY_IMPORT __declspec(dllimport)
|
||||
#else
|
||||
#if \
|
||||
JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
|
||||
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \
|
||||
(JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_EABI__) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__))
|
||||
#define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
|
||||
#define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
|
||||
#else
|
||||
#define JSON_HEDLEY_PRIVATE
|
||||
#define JSON_HEDLEY_PUBLIC
|
||||
#endif
|
||||
#define JSON_HEDLEY_IMPORT extern
|
||||
# if \
|
||||
JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
|
||||
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
|
||||
( \
|
||||
defined(__TI_EABI__) && \
|
||||
( \
|
||||
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
|
||||
) \
|
||||
)
|
||||
# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
|
||||
# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
|
||||
# else
|
||||
# define JSON_HEDLEY_PRIVATE
|
||||
# define JSON_HEDLEY_PUBLIC
|
||||
# endif
|
||||
# define JSON_HEDLEY_IMPORT extern
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_NO_THROW)
|
||||
@@ -1225,7 +1576,9 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#if defined(JSON_HEDLEY_FALL_THROUGH)
|
||||
#undef JSON_HEDLEY_FALL_THROUGH
|
||||
#endif
|
||||
#if JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(fallthrough,7,0,0) && !defined(JSON_HEDLEY_PGI_VERSION)
|
||||
#if \
|
||||
JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0)
|
||||
#define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
|
||||
#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
|
||||
#define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
|
||||
@@ -1282,7 +1635,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(6,1,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
|
||||
(JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
|
||||
JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0)
|
||||
#define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
|
||||
@@ -1303,7 +1656,11 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
|
||||
#endif
|
||||
# elif \
|
||||
(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(JSON_HEDLEY_SUNPRO_VERSION) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
|
||||
( \
|
||||
defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
|
||||
!defined(JSON_HEDLEY_SUNPRO_VERSION) && \
|
||||
!defined(JSON_HEDLEY_PGI_VERSION) && \
|
||||
!defined(JSON_HEDLEY_IAR_VERSION)) || \
|
||||
JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
|
||||
@@ -1319,7 +1676,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
defined(JSON_HEDLEY_GCC_VERSION) || \
|
||||
defined(JSON_HEDLEY_INTEL_VERSION) || \
|
||||
defined(JSON_HEDLEY_TINYC_VERSION) || \
|
||||
defined(JSON_HEDLEY_TI_VERSION) || \
|
||||
defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
|
||||
defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
|
||||
defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
|
||||
defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
|
||||
defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
|
||||
defined(__clang__)
|
||||
# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
|
||||
sizeof(void) != \
|
||||
@@ -1377,59 +1739,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
|
||||
#elif \
|
||||
(defined(__cplusplus) && (__cplusplus >= 201103L)) || \
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
|
||||
(defined(__cplusplus) && JSON_HEDLEY_TI_VERSION_CHECK(8,3,0))
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0)
|
||||
# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
|
||||
#else
|
||||
# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_CONST_CAST)
|
||||
#undef JSON_HEDLEY_CONST_CAST
|
||||
#endif
|
||||
#if defined(__cplusplus)
|
||||
# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
|
||||
#elif \
|
||||
JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
|
||||
# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
|
||||
JSON_HEDLEY_DIAGNOSTIC_PUSH \
|
||||
JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
|
||||
((T) (expr)); \
|
||||
JSON_HEDLEY_DIAGNOSTIC_POP \
|
||||
}))
|
||||
#else
|
||||
# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_REINTERPRET_CAST)
|
||||
#undef JSON_HEDLEY_REINTERPRET_CAST
|
||||
#endif
|
||||
#if defined(__cplusplus)
|
||||
#define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
|
||||
#else
|
||||
#define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (*((T*) &(expr)))
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_STATIC_CAST)
|
||||
#undef JSON_HEDLEY_STATIC_CAST
|
||||
#endif
|
||||
#if defined(__cplusplus)
|
||||
#define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
|
||||
#else
|
||||
#define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_CPP_CAST)
|
||||
#undef JSON_HEDLEY_CPP_CAST
|
||||
#endif
|
||||
#if defined(__cplusplus)
|
||||
#define JSON_HEDLEY_CPP_CAST(T, expr) static_cast<T>(expr)
|
||||
#else
|
||||
#define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HEDLEY_NULL)
|
||||
#undef JSON_HEDLEY_NULL
|
||||
#endif
|
||||
@@ -1481,7 +1796,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#elif \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0)
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
|
||||
# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
|
||||
# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#undef JSON_HEDLEY_ARRAY_PARAM
|
||||
#undef JSON_HEDLEY_ASSUME
|
||||
#undef JSON_HEDLEY_BEGIN_C_DECLS
|
||||
#undef JSON_HEDLEY_C_DECL
|
||||
#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
|
||||
#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
|
||||
#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
|
||||
@@ -15,13 +14,16 @@
|
||||
#undef JSON_HEDLEY_COMPCERT_VERSION
|
||||
#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
|
||||
#undef JSON_HEDLEY_CONCAT
|
||||
#undef JSON_HEDLEY_CONCAT3
|
||||
#undef JSON_HEDLEY_CONCAT3_EX
|
||||
#undef JSON_HEDLEY_CONCAT_EX
|
||||
#undef JSON_HEDLEY_CONST
|
||||
#undef JSON_HEDLEY_CONST_CAST
|
||||
#undef JSON_HEDLEY_CONSTEXPR
|
||||
#undef JSON_HEDLEY_CONST_CAST
|
||||
#undef JSON_HEDLEY_CPP_CAST
|
||||
#undef JSON_HEDLEY_CRAY_VERSION
|
||||
#undef JSON_HEDLEY_CRAY_VERSION_CHECK
|
||||
#undef JSON_HEDLEY_C_DECL
|
||||
#undef JSON_HEDLEY_DEPRECATED
|
||||
#undef JSON_HEDLEY_DEPRECATED_FOR
|
||||
#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
|
||||
@@ -37,7 +39,6 @@
|
||||
#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
|
||||
#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
|
||||
#undef JSON_HEDLEY_END_C_DECLS
|
||||
#undef JSON_HEDLEY_FALL_THROUGH
|
||||
#undef JSON_HEDLEY_FLAGS
|
||||
#undef JSON_HEDLEY_FLAGS_CAST
|
||||
#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
|
||||
@@ -83,8 +84,8 @@
|
||||
#undef JSON_HEDLEY_MSVC_VERSION
|
||||
#undef JSON_HEDLEY_MSVC_VERSION_CHECK
|
||||
#undef JSON_HEDLEY_NEVER_INLINE
|
||||
#undef JSON_HEDLEY_NO_ESCAPE
|
||||
#undef JSON_HEDLEY_NON_NULL
|
||||
#undef JSON_HEDLEY_NO_ESCAPE
|
||||
#undef JSON_HEDLEY_NO_RETURN
|
||||
#undef JSON_HEDLEY_NO_THROW
|
||||
#undef JSON_HEDLEY_NULL
|
||||
@@ -112,6 +113,18 @@
|
||||
#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
|
||||
#undef JSON_HEDLEY_TINYC_VERSION
|
||||
#undef JSON_HEDLEY_TINYC_VERSION_CHECK
|
||||
#undef JSON_HEDLEY_TI_ARMCL_VERSION
|
||||
#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
|
||||
#undef JSON_HEDLEY_TI_CL2000_VERSION
|
||||
#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
|
||||
#undef JSON_HEDLEY_TI_CL430_VERSION
|
||||
#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
|
||||
#undef JSON_HEDLEY_TI_CL6X_VERSION
|
||||
#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
|
||||
#undef JSON_HEDLEY_TI_CL7X_VERSION
|
||||
#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
|
||||
#undef JSON_HEDLEY_TI_CLPRU_VERSION
|
||||
#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
|
||||
#undef JSON_HEDLEY_TI_VERSION
|
||||
#undef JSON_HEDLEY_TI_VERSION_CHECK
|
||||
#undef JSON_HEDLEY_UNAVAILABLE
|
||||
@@ -126,3 +139,5 @@
|
||||
#undef JSON_HEDLEY_VERSION_ENCODE
|
||||
#undef JSON_HEDLEY_WARNING
|
||||
#undef JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||
#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
|
||||
#undef JSON_HEDLEY_FALL_THROUGH
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,13 @@ option(JSON_Valgrind "Execute test suite with Valgrind" OFF)
|
||||
option(JSON_NoExceptions "Build test suite without exceptions" OFF)
|
||||
option(JSON_Coverage "Build test suite with coverage information" OFF)
|
||||
|
||||
# download test data
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/download_test_data.cmake)
|
||||
|
||||
# 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_Sanitizer)
|
||||
message(STATUS "Building test suite with Clang sanitizer")
|
||||
if(NOT MSVC)
|
||||
@@ -27,12 +34,6 @@ endif()
|
||||
|
||||
if(JSON_Coverage)
|
||||
message(STATUS "Building test suite with coverage information")
|
||||
if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
message(FATAL_ERROR "JSON_Coverage requires GCC.")
|
||||
endif()
|
||||
|
||||
# enable profiling
|
||||
set(CMAKE_CXX_FLAGS "--coverage -g -O0 -fprofile-arcs -ftest-coverage")
|
||||
|
||||
# from https://github.com/RWTH-HPC/CMake-codecov/blob/master/cmake/FindGcov.cmake
|
||||
get_filename_component(COMPILER_PATH "${CMAKE_CXX_COMPILER}" PATH)
|
||||
@@ -51,22 +52,13 @@ if(JSON_Coverage)
|
||||
COMMAND genhtml --title "JSON for Modern C++" --legend --demangle-cpp --output-directory html --show-details --branch-coverage json.info.filtered.noexcept
|
||||
COMMENT "Generating HTML report test/html/index.html"
|
||||
)
|
||||
|
||||
add_custom_target(fastcov_html
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/fastcov/fastcov.py --branch-coverage --lcov -o json.info --gcov ${GCOV_BIN} --compiler-directory ${CMAKE_BINARY_DIR} --source-files ${SOURCE_FILES}
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/imapdl/filterbr.py json.info > json.info.noexcept
|
||||
COMMAND genhtml --title "JSON for Modern C++" --legend --demangle-cpp --output-directory html --show-details --branch-coverage json.info.noexcept
|
||||
COMMENT "Generating HTML report test/html/index.html"
|
||||
)
|
||||
endif()
|
||||
|
||||
#############################################################################
|
||||
# doctest library with the main function to speed up build
|
||||
#############################################################################
|
||||
|
||||
add_library(doctest_main OBJECT
|
||||
"src/unit.cpp"
|
||||
)
|
||||
add_library(doctest_main OBJECT src/unit.cpp)
|
||||
set_target_properties(doctest_main PROPERTIES
|
||||
COMPILE_DEFINITIONS "$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>"
|
||||
COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>"
|
||||
@@ -148,44 +140,50 @@ foreach(file ${files})
|
||||
string(REGEX REPLACE "unit-([^$]+)" "test-\\1" testcase ${file_basename})
|
||||
|
||||
add_executable(${testcase} $<TARGET_OBJECTS:doctest_main> ${file})
|
||||
target_compile_definitions(${testcase} PRIVATE
|
||||
DOCTEST_CONFIG_SUPER_FAST_ASSERTS
|
||||
)
|
||||
target_compile_definitions(${testcase} PRIVATE DOCTEST_CONFIG_SUPER_FAST_ASSERTS)
|
||||
target_compile_options(${testcase} PRIVATE
|
||||
$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>
|
||||
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-deprecated;-Wno-float-equal>
|
||||
$<$<CXX_COMPILER_ID:GNU>:-Wno-deprecated-declarations>
|
||||
)
|
||||
target_include_directories(${testcase} PRIVATE
|
||||
thirdparty/doctest
|
||||
thirdparty/fifo_map
|
||||
)
|
||||
target_link_libraries(${testcase} ${NLOHMANN_JSON_TARGET_NAME})
|
||||
target_include_directories(${testcase} PRIVATE ${CMAKE_BINARY_DIR}/include thirdparty/doctest thirdparty/fifo_map)
|
||||
target_link_libraries(${testcase} PRIVATE ${NLOHMANN_JSON_TARGET_NAME})
|
||||
|
||||
add_test(NAME "${testcase}_default"
|
||||
COMMAND ${testcase} ${DOCTEST_TEST_FILTER}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
set_tests_properties("${testcase}_default" PROPERTIES LABELS "default")
|
||||
if (JSON_Coverage)
|
||||
target_compile_options(${testcase} PRIVATE --coverage)
|
||||
target_link_libraries(${testcase} PRIVATE --coverage)
|
||||
endif()
|
||||
|
||||
add_test(NAME "${testcase}_all"
|
||||
COMMAND ${testcase} ${DOCTEST_TEST_FILTER} --no-skip
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
add_test(NAME "${testcase}"
|
||||
COMMAND ${testcase} ${DOCTEST_TEST_FILTER} --no-skip
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
set_tests_properties("${testcase}_all" PROPERTIES LABELS "all")
|
||||
set_tests_properties("${testcase}" PROPERTIES LABELS "all" FIXTURES_REQUIRED TEST_DATA)
|
||||
|
||||
if(JSON_Valgrind)
|
||||
add_test(NAME "${testcase}_valgrind"
|
||||
COMMAND ${memcheck_command} ${CMAKE_CURRENT_BINARY_DIR}/${testcase} ${DOCTEST_TEST_FILTER}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
COMMAND ${memcheck_command} ${CMAKE_CURRENT_BINARY_DIR}/${testcase} ${DOCTEST_TEST_FILTER}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
set_tests_properties("${testcase}_valgrind" PROPERTIES LABELS "valgrind")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
add_executable(json_unit EXCLUDE_FROM_ALL $<TARGET_OBJECTS:doctest_main> ${files})
|
||||
target_compile_definitions(json_unit PRIVATE DOCTEST_CONFIG_SUPER_FAST_ASSERTS)
|
||||
target_compile_options(json_unit PRIVATE
|
||||
$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>
|
||||
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-deprecated;-Wno-float-equal>
|
||||
$<$<CXX_COMPILER_ID:GNU>:-Wno-deprecated-declarations>
|
||||
)
|
||||
target_include_directories(json_unit PRIVATE ${CMAKE_BINARY_DIR}/include thirdparty/doctest thirdparty/fifo_map)
|
||||
target_link_libraries(json_unit ${NLOHMANN_JSON_TARGET_NAME})
|
||||
add_dependencies(json_unit download_test_data)
|
||||
|
||||
#############################################################################
|
||||
# Test the generated build configs
|
||||
#############################################################################
|
||||
add_subdirectory(cmake_import)
|
||||
add_subdirectory(cmake_import_minver)
|
||||
add_subdirectory(cmake_add_subdirectory)
|
||||
add_subdirectory(cmake_fetch_content)
|
||||
|
||||
@@ -57,7 +57,10 @@ TESTCASES = $(patsubst src/unit-%.cpp,test-%,$(wildcard src/unit-*.cpp))
|
||||
all: $(TESTCASES)
|
||||
|
||||
clean:
|
||||
rm -fr json_unit $(OBJECTS) $(SOURCES:.cpp=.gcno) $(SOURCES:.cpp=.gcda) $(TESTCASES) $(FUZZERS)
|
||||
rm -fr json_unit $(OBJECTS) $(SOURCES:.cpp=.gcno) $(SOURCES:.cpp=.gcda) $(TESTCASES) $(FUZZERS) test_data.hpp
|
||||
|
||||
test_data.hpp:
|
||||
@echo "#define TEST_DATA_DIRECTORY" > $@
|
||||
|
||||
##############################################################################
|
||||
# single test file
|
||||
@@ -67,7 +70,7 @@ json_unit: $(OBJECTS) ../single_include/nlohmann/json.hpp thirdparty/doctest/doc
|
||||
@echo "[CXXLD] $@"
|
||||
@$(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJECTS) -o $@
|
||||
|
||||
%.o: %.cpp ../single_include/nlohmann/json.hpp thirdparty/doctest/doctest.h
|
||||
%.o: %.cpp ../single_include/nlohmann/json.hpp thirdparty/doctest/doctest.h test_data.hpp
|
||||
@echo "[CXX] $@"
|
||||
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
|
||||
|
||||
@@ -76,7 +79,7 @@ json_unit: $(OBJECTS) ../single_include/nlohmann/json.hpp thirdparty/doctest/doc
|
||||
# individual test cases
|
||||
##############################################################################
|
||||
|
||||
test-%: src/unit-%.o src/unit.o ../single_include/nlohmann/json.hpp thirdparty/doctest/doctest.h
|
||||
test-%: src/unit-%.o src/unit.o ../single_include/nlohmann/json.hpp thirdparty/doctest/doctest.h test_data.hpp
|
||||
@echo "[CXXLD] $@"
|
||||
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $< src/unit.o -o $@
|
||||
|
||||
|
||||
18
test/cmake_fetch_content/CMakeLists.txt
Normal file
18
test/cmake_fetch_content/CMakeLists.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
if (${CMAKE_VERSION} VERSION_GREATER "3.11.0")
|
||||
add_test(NAME cmake_fetch_content_configure
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-G "${CMAKE_GENERATOR}"
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
-Dnlohmann_json_source=${PROJECT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/project
|
||||
)
|
||||
add_test(NAME cmake_fetch_content_build
|
||||
COMMAND ${CMAKE_COMMAND} --build .
|
||||
)
|
||||
set_tests_properties(cmake_fetch_content_configure PROPERTIES
|
||||
FIXTURES_SETUP cmake_fetch_content
|
||||
)
|
||||
set_tests_properties(cmake_fetch_content_build PROPERTIES
|
||||
FIXTURES_REQUIRED cmake_fetch_content
|
||||
)
|
||||
endif()
|
||||
21
test/cmake_fetch_content/project/CMakeLists.txt
Normal file
21
test/cmake_fetch_content/project/CMakeLists.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
cmake_minimum_required(VERSION 3.11)
|
||||
|
||||
project(DummyImport CXX)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(json
|
||||
GIT_REPOSITORY ${CMAKE_CURRENT_SOURCE_DIR}/../../..
|
||||
GIT_TAG HEAD)
|
||||
|
||||
FetchContent_GetProperties(json)
|
||||
if(NOT json_POPULATED)
|
||||
FetchContent_Populate(json)
|
||||
add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
add_executable(with_namespace_target main.cpp)
|
||||
target_link_libraries(with_namespace_target nlohmann_json::nlohmann_json)
|
||||
|
||||
add_executable(without_namespace_target main.cpp)
|
||||
target_link_libraries(without_namespace_target nlohmann_json)
|
||||
8
test/cmake_fetch_content/project/main.cpp
Normal file
8
test/cmake_fetch_content/project/main.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
nlohmann::json j;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Max Woolf
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
@@ -1,496 +0,0 @@
|
||||
[
|
||||
"",
|
||||
"undefined",
|
||||
"undef",
|
||||
"null",
|
||||
"NULL",
|
||||
"(null)",
|
||||
"nil",
|
||||
"NIL",
|
||||
"true",
|
||||
"false",
|
||||
"True",
|
||||
"False",
|
||||
"TRUE",
|
||||
"FALSE",
|
||||
"None",
|
||||
"hasOwnProperty",
|
||||
"\\",
|
||||
"\\\\",
|
||||
"0",
|
||||
"1",
|
||||
"1.00",
|
||||
"$1.00",
|
||||
"1/2",
|
||||
"1E2",
|
||||
"1E02",
|
||||
"1E+02",
|
||||
"-1",
|
||||
"-1.00",
|
||||
"-$1.00",
|
||||
"-1/2",
|
||||
"-1E2",
|
||||
"-1E02",
|
||||
"-1E+02",
|
||||
"1/0",
|
||||
"0/0",
|
||||
"-2147483648/-1",
|
||||
"-9223372036854775808/-1",
|
||||
"0.00",
|
||||
"0..0",
|
||||
".",
|
||||
"0.0.0",
|
||||
"0,00",
|
||||
"0,,0",
|
||||
",",
|
||||
"0,0,0",
|
||||
"0.0/0",
|
||||
"1.0/0.0",
|
||||
"0.0/0.0",
|
||||
"1,0/0,0",
|
||||
"0,0/0,0",
|
||||
"--1",
|
||||
"-",
|
||||
"-.",
|
||||
"-,",
|
||||
"999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999",
|
||||
"NaN",
|
||||
"Infinity",
|
||||
"-Infinity",
|
||||
"INF",
|
||||
"1#INF",
|
||||
"-1#IND",
|
||||
"1#QNAN",
|
||||
"1#SNAN",
|
||||
"1#IND",
|
||||
"0x0",
|
||||
"0xffffffff",
|
||||
"0xffffffffffffffff",
|
||||
"0xabad1dea",
|
||||
"123456789012345678901234567890123456789",
|
||||
"1,000.00",
|
||||
"1 000.00",
|
||||
"1'000.00",
|
||||
"1,000,000.00",
|
||||
"1 000 000.00",
|
||||
"1'000'000.00",
|
||||
"1.000,00",
|
||||
"1 000,00",
|
||||
"1'000,00",
|
||||
"1.000.000,00",
|
||||
"1 000 000,00",
|
||||
"1'000'000,00",
|
||||
"01000",
|
||||
"08",
|
||||
"09",
|
||||
"2.2250738585072011e-308",
|
||||
",./;'[]\\-=",
|
||||
"<>?:\"{}|_+",
|
||||
"!@#$%^&*()`~",
|
||||
"Ω≈ç√∫˜µ≤≥÷",
|
||||
"åß∂ƒ©˙∆˚¬…æ",
|
||||
"œ∑´®†¥¨ˆøπ“‘",
|
||||
"¡™£¢∞§¶•ªº–≠",
|
||||
"¸˛Ç◊ı˜Â¯˘¿",
|
||||
"ÅÍÎÏ˝ÓÔÒÚÆ☃",
|
||||
"Œ„´‰ˇÁ¨ˆØ∏”’",
|
||||
"`⁄€‹›fifl‡°·‚—±",
|
||||
"⅛⅜⅝⅞",
|
||||
"ЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя",
|
||||
"٠١٢٣٤٥٦٧٨٩",
|
||||
"⁰⁴⁵",
|
||||
"₀₁₂",
|
||||
"⁰⁴⁵₀₁₂",
|
||||
"ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็ ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็ ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็",
|
||||
"'",
|
||||
"\"",
|
||||
"''",
|
||||
"\"\"",
|
||||
"'\"'",
|
||||
"\"''''\"'\"",
|
||||
"\"'\"'\"''''\"",
|
||||
"<foo val=“bar” />",
|
||||
"<foo val=“bar” />",
|
||||
"<foo val=”bar“ />",
|
||||
"<foo val=`bar' />",
|
||||
"田中さんにあげて下さい",
|
||||
"パーティーへ行かないか",
|
||||
"和製漢語",
|
||||
"部落格",
|
||||
"사회과학원 어학연구소",
|
||||
"찦차를 타고 온 펲시맨과 쑛다리 똠방각하",
|
||||
"社會科學院語學研究所",
|
||||
"울란바토르",
|
||||
"𠜎𠜱𠝹𠱓𠱸𠲖𠳏",
|
||||
"ヽ༼ຈل͜ຈ༽ノ ヽ༼ຈل͜ຈ༽ノ ",
|
||||
"(。◕ ∀ ◕。)",
|
||||
"`ィ(´∀`∩",
|
||||
"__ロ(,_,*)",
|
||||
"・( ̄∀ ̄)・:*:",
|
||||
"゚・✿ヾ╲(。◕‿◕。)╱✿・゚",
|
||||
",。・:*:・゜’( ☻ ω ☻ )。・:*:・゜’",
|
||||
"(╯°□°)╯︵ ┻━┻) ",
|
||||
"(ノಥ益ಥ)ノ ┻━┻",
|
||||
"┬─┬ノ( º _ ºノ)",
|
||||
"( ͡° ͜ʖ ͡°)",
|
||||
"😍",
|
||||
"👩🏽",
|
||||
"👾 🙇 💁 🙅 🙆 🙋 🙎 🙍 ",
|
||||
"🐵 🙈 🙉 🙊",
|
||||
"❤️ 💔 💌 💕 💞 💓 💗 💖 💘 💝 💟 💜 💛 💚 💙",
|
||||
"✋🏿 💪🏿 👐🏿 🙌🏿 👏🏿 🙏🏿",
|
||||
"🚾 🆒 🆓 🆕 🆖 🆗 🆙 🏧",
|
||||
"0️⃣ 1️⃣ 2️⃣ 3️⃣ 4️⃣ 5️⃣ 6️⃣ 7️⃣ 8️⃣ 9️⃣ 🔟",
|
||||
"🇺🇸🇷🇺🇸 🇦🇫🇦🇲🇸 ",
|
||||
"🇺🇸🇷🇺🇸🇦🇫🇦🇲",
|
||||
"🇺🇸🇷🇺🇸🇦",
|
||||
"123",
|
||||
"١٢٣",
|
||||
"ثم نفس سقطت وبالتحديد،, جزيرتي باستخدام أن دنو. إذ هنا؟ الستار وتنصيب كان. أهّل ايطاليا، بريطانيا-فرنسا قد أخذ. سليمان، إتفاقية بين ما, يذكر الحدود أي بعد, معاملة بولندا، الإطلاق عل إيو.",
|
||||
"בְּרֵאשִׁית, בָּרָא אֱלֹהִים, אֵת הַשָּׁמַיִם, וְאֵת הָאָרֶץ",
|
||||
"הָיְתָהtestالصفحات التّحول",
|
||||
"﷽",
|
||||
"ﷺ",
|
||||
"مُنَاقَشَةُ سُبُلِ اِسْتِخْدَامِ اللُّغَةِ فِي النُّظُمِ الْقَائِمَةِ وَفِيم يَخُصَّ التَّطْبِيقَاتُ الْحاسُوبِيَّةُ، ",
|
||||
"",
|
||||
" ",
|
||||
"",
|
||||
" ",
|
||||
"",
|
||||
"␣",
|
||||
"␢",
|
||||
"␡",
|
||||
"test",
|
||||
"test",
|
||||
"
test
",
|
||||
"testtest",
|
||||
"test",
|
||||
"Ṱ̺̺̕o͞ ̷i̲̬͇̪͙n̝̗͕v̟̜̘̦͟o̶̙̰̠kè͚̮̺̪̹̱̤ ̖t̝͕̳̣̻̪͞h̼͓̲̦̳̘̲e͇̣̰̦̬͎ ̢̼̻̱̘h͚͎͙̜̣̲ͅi̦̲̣̰̤v̻͍e̺̭̳̪̰-m̢iͅn̖̺̞̲̯̰d̵̼̟͙̩̼̘̳ ̞̥̱̳̭r̛̗̘e͙p͠r̼̞̻̭̗e̺̠̣͟s̘͇̳͍̝͉e͉̥̯̞̲͚̬͜ǹ̬͎͎̟̖͇̤t͍̬̤͓̼̭͘ͅi̪̱n͠g̴͉ ͏͉ͅc̬̟h͡a̫̻̯͘o̫̟̖͍̙̝͉s̗̦̲.̨̹͈̣",
|
||||
"̡͓̞ͅI̗̘̦͝n͇͇͙v̮̫ok̲̫̙͈i̖͙̭̹̠̞n̡̻̮̣̺g̲͈͙̭͙̬͎ ̰t͔̦h̞̲e̢̤ ͍̬̲͖f̴̘͕̣è͖ẹ̥̩l͖͔͚i͓͚̦͠n͖͍̗͓̳̮g͍ ̨o͚̪͡f̘̣̬ ̖̘͖̟͙̮c҉͔̫͖͓͇͖ͅh̵̤̣͚͔á̗̼͕ͅo̼̣̥s̱͈̺̖̦̻͢.̛̖̞̠̫̰",
|
||||
"̗̺͖̹̯͓Ṯ̤͍̥͇͈h̲́e͏͓̼̗̙̼̣͔ ͇̜̱̠͓͍ͅN͕͠e̗̱z̘̝̜̺͙p̤̺̹͍̯͚e̠̻̠͜r̨̤͍̺̖͔̖̖d̠̟̭̬̝͟i̦͖̩͓͔̤a̠̗̬͉̙n͚͜ ̻̞̰͚ͅh̵͉i̳̞v̢͇ḙ͎͟-҉̭̩̼͔m̤̭̫i͕͇̝̦n̗͙ḍ̟ ̯̲͕͞ǫ̟̯̰̲͙̻̝f ̪̰̰̗̖̭̘͘c̦͍̲̞͍̩̙ḥ͚a̮͎̟̙͜ơ̩̹͎s̤.̝̝ ҉Z̡̖̜͖̰̣͉̜a͖̰͙̬͡l̲̫̳͍̩g̡̟̼̱͚̞̬ͅo̗͜.̟",
|
||||
"̦H̬̤̗̤͝e͜ ̜̥̝̻͍̟́w̕h̖̯͓o̝͙̖͎̱̮ ҉̺̙̞̟͈W̷̼̭a̺̪͍į͈͕̭͙̯̜t̶̼̮s̘͙͖̕ ̠̫̠B̻͍͙͉̳ͅe̵h̵̬͇̫͙i̹͓̳̳̮͎̫̕n͟d̴̪̜̖ ̰͉̩͇͙̲͞ͅT͖̼͓̪͢h͏͓̮̻e̬̝̟ͅ ̤̹̝W͙̞̝͔͇͝ͅa͏͓͔̹̼̣l̴͔̰̤̟͔ḽ̫.͕",
|
||||
"Z̮̞̠͙͔ͅḀ̗̞͈̻̗Ḷ͙͎̯̹̞͓G̻O̭̗̮",
|
||||
"˙ɐnbᴉlɐ ɐuƃɐɯ ǝɹolop ʇǝ ǝɹoqɐl ʇn ʇunpᴉpᴉɔuᴉ ɹodɯǝʇ poɯsnᴉǝ op pǝs 'ʇᴉlǝ ƃuᴉɔsᴉdᴉpɐ ɹnʇǝʇɔǝsuoɔ 'ʇǝɯɐ ʇᴉs ɹolop ɯnsdᴉ ɯǝɹo˥",
|
||||
"00˙Ɩ$-",
|
||||
"The quick brown fox jumps over the lazy dog",
|
||||
"𝐓𝐡𝐞 𝐪𝐮𝐢𝐜𝐤 𝐛𝐫𝐨𝐰𝐧 𝐟𝐨𝐱 𝐣𝐮𝐦𝐩𝐬 𝐨𝐯𝐞𝐫 𝐭𝐡𝐞 𝐥𝐚𝐳𝐲 𝐝𝐨𝐠",
|
||||
"𝕿𝖍𝖊 𝖖𝖚𝖎𝖈𝖐 𝖇𝖗𝖔𝖜𝖓 𝖋𝖔𝖝 𝖏𝖚𝖒𝖕𝖘 𝖔𝖛𝖊𝖗 𝖙𝖍𝖊 𝖑𝖆𝖟𝖞 𝖉𝖔𝖌",
|
||||
"𝑻𝒉𝒆 𝒒𝒖𝒊𝒄𝒌 𝒃𝒓𝒐𝒘𝒏 𝒇𝒐𝒙 𝒋𝒖𝒎𝒑𝒔 𝒐𝒗𝒆𝒓 𝒕𝒉𝒆 𝒍𝒂𝒛𝒚 𝒅𝒐𝒈",
|
||||
"𝓣𝓱𝓮 𝓺𝓾𝓲𝓬𝓴 𝓫𝓻𝓸𝔀𝓷 𝓯𝓸𝔁 𝓳𝓾𝓶𝓹𝓼 𝓸𝓿𝓮𝓻 𝓽𝓱𝓮 𝓵𝓪𝔃𝔂 𝓭𝓸𝓰",
|
||||
"𝕋𝕙𝕖 𝕢𝕦𝕚𝕔𝕜 𝕓𝕣𝕠𝕨𝕟 𝕗𝕠𝕩 𝕛𝕦𝕞𝕡𝕤 𝕠𝕧𝕖𝕣 𝕥𝕙𝕖 𝕝𝕒𝕫𝕪 𝕕𝕠𝕘",
|
||||
"𝚃𝚑𝚎 𝚚𝚞𝚒𝚌𝚔 𝚋𝚛𝚘𝚠𝚗 𝚏𝚘𝚡 𝚓𝚞𝚖𝚙𝚜 𝚘𝚟𝚎𝚛 𝚝𝚑𝚎 𝚕𝚊𝚣𝚢 𝚍𝚘𝚐",
|
||||
"⒯⒣⒠ ⒬⒰⒤⒞⒦ ⒝⒭⒪⒲⒩ ⒡⒪⒳ ⒥⒰⒨⒫⒮ ⒪⒱⒠⒭ ⒯⒣⒠ ⒧⒜⒵⒴ ⒟⒪⒢",
|
||||
"<script>alert(123)</script>",
|
||||
"<script>alert('123');</script>",
|
||||
"<img src=x onerror=alert(123) />",
|
||||
"<svg><script>123<1>alert(123)</script> ",
|
||||
"\"><script>alert(123)</script>",
|
||||
"'><script>alert(123)</script>",
|
||||
"><script>alert(123)</script>",
|
||||
"</script><script>alert(123)</script>",
|
||||
"< / script >< script >alert(123)< / script >",
|
||||
" onfocus=JaVaSCript:alert(123) autofocus ",
|
||||
"\" onfocus=JaVaSCript:alert(123) autofocus ",
|
||||
"' onfocus=JaVaSCript:alert(123) autofocus ",
|
||||
"<script>alert(123)</script>",
|
||||
"<sc<script>ript>alert(123)</sc</script>ript>",
|
||||
"--><script>alert(123)</script>",
|
||||
"\";alert(123);t=\"",
|
||||
"';alert(123);t='",
|
||||
"JavaSCript:alert(123)",
|
||||
";alert(123);",
|
||||
"src=JaVaSCript:prompt(132)",
|
||||
"\"><script>alert(123);</script x=\"",
|
||||
"'><script>alert(123);</script x='",
|
||||
"><script>alert(123);</script x=",
|
||||
"\" autofocus onkeyup=\"javascript:alert(123)",
|
||||
"' autofocus onkeyup='javascript:alert(123)",
|
||||
"<script\\x20type=\"text/javascript\">javascript:alert(1);</script>",
|
||||
"<script\\x3Etype=\"text/javascript\">javascript:alert(1);</script>",
|
||||
"<script\\x0Dtype=\"text/javascript\">javascript:alert(1);</script>",
|
||||
"<script\\x09type=\"text/javascript\">javascript:alert(1);</script>",
|
||||
"<script\\x0Ctype=\"text/javascript\">javascript:alert(1);</script>",
|
||||
"<script\\x2Ftype=\"text/javascript\">javascript:alert(1);</script>",
|
||||
"<script\\x0Atype=\"text/javascript\">javascript:alert(1);</script>",
|
||||
"'`\"><\\x3Cscript>javascript:alert(1)</script> ",
|
||||
"'`\"><\\x00script>javascript:alert(1)</script>",
|
||||
"ABC<div style=\"x\\x3Aexpression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:expression\\x5C(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:expression\\x00(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:exp\\x00ression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:exp\\x5Cression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\x0Aexpression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\x09expression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\xE3\\x80\\x80expression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\xE2\\x80\\x84expression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\xC2\\xA0expression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\xE2\\x80\\x80expression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\xE2\\x80\\x8Aexpression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\x0Dexpression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\x0Cexpression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\xE2\\x80\\x87expression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\xEF\\xBB\\xBFexpression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\x20expression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\xE2\\x80\\x88expression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\x00expression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\xE2\\x80\\x8Bexpression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\xE2\\x80\\x86expression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\xE2\\x80\\x85expression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\xE2\\x80\\x82expression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\x0Bexpression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\xE2\\x80\\x81expression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\xE2\\x80\\x83expression(javascript:alert(1)\">DEF",
|
||||
"ABC<div style=\"x:\\xE2\\x80\\x89expression(javascript:alert(1)\">DEF",
|
||||
"<a href=\"\\x0Bjavascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x0Fjavascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\xC2\\xA0javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x05javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\xE1\\xA0\\x8Ejavascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x18javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x11javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\xE2\\x80\\x88javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\xE2\\x80\\x89javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\xE2\\x80\\x80javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x17javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x03javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x0Ejavascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x1Ajavascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x00javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x10javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\xE2\\x80\\x82javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x20javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x13javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x09javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\xE2\\x80\\x8Ajavascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x14javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x19javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\xE2\\x80\\xAFjavascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x1Fjavascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\xE2\\x80\\x81javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x1Djavascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\xE2\\x80\\x87javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x07javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\xE1\\x9A\\x80javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\xE2\\x80\\x83javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x04javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x01javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x08javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\xE2\\x80\\x84javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\xE2\\x80\\x86javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\xE3\\x80\\x80javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x12javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x0Djavascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x0Ajavascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x0Cjavascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x15javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\xE2\\x80\\xA8javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x16javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x02javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x1Bjavascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x06javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\xE2\\x80\\xA9javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\xE2\\x80\\x85javascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x1Ejavascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\xE2\\x81\\x9Fjavascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"\\x1Cjavascript:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"javascript\\x00:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"javascript\\x3A:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"javascript\\x09:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"javascript\\x0D:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"<a href=\"javascript\\x0A:javascript:alert(1)\" id=\"fuzzelement1\">test</a>",
|
||||
"`\"'><img src=xxx:x \\x0Aonerror=javascript:alert(1)>",
|
||||
"`\"'><img src=xxx:x \\x22onerror=javascript:alert(1)>",
|
||||
"`\"'><img src=xxx:x \\x0Bonerror=javascript:alert(1)>",
|
||||
"`\"'><img src=xxx:x \\x0Donerror=javascript:alert(1)>",
|
||||
"`\"'><img src=xxx:x \\x2Fonerror=javascript:alert(1)>",
|
||||
"`\"'><img src=xxx:x \\x09onerror=javascript:alert(1)>",
|
||||
"`\"'><img src=xxx:x \\x0Conerror=javascript:alert(1)>",
|
||||
"`\"'><img src=xxx:x \\x00onerror=javascript:alert(1)>",
|
||||
"`\"'><img src=xxx:x \\x27onerror=javascript:alert(1)>",
|
||||
"`\"'><img src=xxx:x \\x20onerror=javascript:alert(1)>",
|
||||
"\"`'><script>\\x3Bjavascript:alert(1)</script>",
|
||||
"\"`'><script>\\x0Djavascript:alert(1)</script>",
|
||||
"\"`'><script>\\xEF\\xBB\\xBFjavascript:alert(1)</script>",
|
||||
"\"`'><script>\\xE2\\x80\\x81javascript:alert(1)</script>",
|
||||
"\"`'><script>\\xE2\\x80\\x84javascript:alert(1)</script>",
|
||||
"\"`'><script>\\xE3\\x80\\x80javascript:alert(1)</script>",
|
||||
"\"`'><script>\\x09javascript:alert(1)</script>",
|
||||
"\"`'><script>\\xE2\\x80\\x89javascript:alert(1)</script>",
|
||||
"\"`'><script>\\xE2\\x80\\x85javascript:alert(1)</script>",
|
||||
"\"`'><script>\\xE2\\x80\\x88javascript:alert(1)</script>",
|
||||
"\"`'><script>\\x00javascript:alert(1)</script>",
|
||||
"\"`'><script>\\xE2\\x80\\xA8javascript:alert(1)</script>",
|
||||
"\"`'><script>\\xE2\\x80\\x8Ajavascript:alert(1)</script>",
|
||||
"\"`'><script>\\xE1\\x9A\\x80javascript:alert(1)</script>",
|
||||
"\"`'><script>\\x0Cjavascript:alert(1)</script>",
|
||||
"\"`'><script>\\x2Bjavascript:alert(1)</script>",
|
||||
"\"`'><script>\\xF0\\x90\\x96\\x9Ajavascript:alert(1)</script>",
|
||||
"\"`'><script>-javascript:alert(1)</script>",
|
||||
"\"`'><script>\\x0Ajavascript:alert(1)</script>",
|
||||
"\"`'><script>\\xE2\\x80\\xAFjavascript:alert(1)</script>",
|
||||
"\"`'><script>\\x7Ejavascript:alert(1)</script>",
|
||||
"\"`'><script>\\xE2\\x80\\x87javascript:alert(1)</script>",
|
||||
"\"`'><script>\\xE2\\x81\\x9Fjavascript:alert(1)</script>",
|
||||
"\"`'><script>\\xE2\\x80\\xA9javascript:alert(1)</script>",
|
||||
"\"`'><script>\\xC2\\x85javascript:alert(1)</script>",
|
||||
"\"`'><script>\\xEF\\xBF\\xAEjavascript:alert(1)</script>",
|
||||
"\"`'><script>\\xE2\\x80\\x83javascript:alert(1)</script>",
|
||||
"\"`'><script>\\xE2\\x80\\x8Bjavascript:alert(1)</script>",
|
||||
"\"`'><script>\\xEF\\xBF\\xBEjavascript:alert(1)</script>",
|
||||
"\"`'><script>\\xE2\\x80\\x80javascript:alert(1)</script>",
|
||||
"\"`'><script>\\x21javascript:alert(1)</script>",
|
||||
"\"`'><script>\\xE2\\x80\\x82javascript:alert(1)</script>",
|
||||
"\"`'><script>\\xE2\\x80\\x86javascript:alert(1)</script>",
|
||||
"\"`'><script>\\xE1\\xA0\\x8Ejavascript:alert(1)</script>",
|
||||
"\"`'><script>\\x0Bjavascript:alert(1)</script>",
|
||||
"\"`'><script>\\x20javascript:alert(1)</script>",
|
||||
"\"`'><script>\\xC2\\xA0javascript:alert(1)</script>",
|
||||
"<img \\x00src=x onerror=\"alert(1)\">",
|
||||
"<img \\x47src=x onerror=\"javascript:alert(1)\">",
|
||||
"<img \\x11src=x onerror=\"javascript:alert(1)\">",
|
||||
"<img \\x12src=x onerror=\"javascript:alert(1)\">",
|
||||
"<img\\x47src=x onerror=\"javascript:alert(1)\">",
|
||||
"<img\\x10src=x onerror=\"javascript:alert(1)\">",
|
||||
"<img\\x13src=x onerror=\"javascript:alert(1)\">",
|
||||
"<img\\x32src=x onerror=\"javascript:alert(1)\">",
|
||||
"<img\\x47src=x onerror=\"javascript:alert(1)\">",
|
||||
"<img\\x11src=x onerror=\"javascript:alert(1)\">",
|
||||
"<img \\x47src=x onerror=\"javascript:alert(1)\">",
|
||||
"<img \\x34src=x onerror=\"javascript:alert(1)\">",
|
||||
"<img \\x39src=x onerror=\"javascript:alert(1)\">",
|
||||
"<img \\x00src=x onerror=\"javascript:alert(1)\">",
|
||||
"<img src\\x09=x onerror=\"javascript:alert(1)\">",
|
||||
"<img src\\x10=x onerror=\"javascript:alert(1)\">",
|
||||
"<img src\\x13=x onerror=\"javascript:alert(1)\">",
|
||||
"<img src\\x32=x onerror=\"javascript:alert(1)\">",
|
||||
"<img src\\x12=x onerror=\"javascript:alert(1)\">",
|
||||
"<img src\\x11=x onerror=\"javascript:alert(1)\">",
|
||||
"<img src\\x00=x onerror=\"javascript:alert(1)\">",
|
||||
"<img src\\x47=x onerror=\"javascript:alert(1)\">",
|
||||
"<img src=x\\x09onerror=\"javascript:alert(1)\">",
|
||||
"<img src=x\\x10onerror=\"javascript:alert(1)\">",
|
||||
"<img src=x\\x11onerror=\"javascript:alert(1)\">",
|
||||
"<img src=x\\x12onerror=\"javascript:alert(1)\">",
|
||||
"<img src=x\\x13onerror=\"javascript:alert(1)\">",
|
||||
"<img[a][b][c]src[d]=x[e]onerror=[f]\"alert(1)\">",
|
||||
"<img src=x onerror=\\x09\"javascript:alert(1)\">",
|
||||
"<img src=x onerror=\\x10\"javascript:alert(1)\">",
|
||||
"<img src=x onerror=\\x11\"javascript:alert(1)\">",
|
||||
"<img src=x onerror=\\x12\"javascript:alert(1)\">",
|
||||
"<img src=x onerror=\\x32\"javascript:alert(1)\">",
|
||||
"<img src=x onerror=\\x00\"javascript:alert(1)\">",
|
||||
"<a href=javascript:javascript:alert(1)>XXX</a>",
|
||||
"<img src=\"x` `<script>javascript:alert(1)</script>\"` `>",
|
||||
"<img src onerror /\" '\"= alt=javascript:alert(1)//\">",
|
||||
"<title onpropertychange=javascript:alert(1)></title><title title=>",
|
||||
"<a href=http://foo.bar/#x=`y></a><img alt=\"`><img src=x:x onerror=javascript:alert(1)></a>\">",
|
||||
"<!--[if]><script>javascript:alert(1)</script -->",
|
||||
"<!--[if<img src=x onerror=javascript:alert(1)//]> -->",
|
||||
"<script src=\"/\\%(jscript)s\"></script>",
|
||||
"<script src=\"\\\\%(jscript)s\"></script>",
|
||||
"<IMG \"\"\"><SCRIPT>alert(\"XSS\")</SCRIPT>\">",
|
||||
"<IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>",
|
||||
"<IMG SRC=# onmouseover=\"alert('xxs')\">",
|
||||
"<IMG SRC= onmouseover=\"alert('xxs')\">",
|
||||
"<IMG onmouseover=\"alert('xxs')\">",
|
||||
"<IMG SRC=javascript:alert('XSS')>",
|
||||
"<IMG SRC=javascript:alert('XSS')>",
|
||||
"<IMG SRC=javascript:alert('XSS')>",
|
||||
"<IMG SRC=\"jav ascript:alert('XSS');\">",
|
||||
"<IMG SRC=\"jav	ascript:alert('XSS');\">",
|
||||
"<IMG SRC=\"jav
ascript:alert('XSS');\">",
|
||||
"<IMG SRC=\"jav
ascript:alert('XSS');\">",
|
||||
"perl -e 'print \"<IMG SRC=java\\0script:alert(\\\"XSS\\\")>\";' > out",
|
||||
"<IMG SRC=\"  javascript:alert('XSS');\">",
|
||||
"<SCRIPT/XSS SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>",
|
||||
"<BODY onload!#$%&()*~+-_.,:;?@[/|\\]^`=alert(\"XSS\")>",
|
||||
"<SCRIPT/SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>",
|
||||
"<<SCRIPT>alert(\"XSS\");//<</SCRIPT>",
|
||||
"<SCRIPT SRC=http://ha.ckers.org/xss.js?< B >",
|
||||
"<SCRIPT SRC=//ha.ckers.org/.j>",
|
||||
"<IMG SRC=\"javascript:alert('XSS')\"",
|
||||
"<iframe src=http://ha.ckers.org/scriptlet.html <",
|
||||
"\\\";alert('XSS');//",
|
||||
"<u oncopy=alert()> Copy me</u>",
|
||||
"<i onwheel=alert(1)> Scroll over me </i>",
|
||||
"<plaintext>",
|
||||
"http://a/%%30%30",
|
||||
"</textarea><script>alert(123)</script>",
|
||||
"1;DROP TABLE users",
|
||||
"1'; DROP TABLE users-- 1",
|
||||
"' OR 1=1 -- 1",
|
||||
"' OR '1'='1",
|
||||
" ",
|
||||
"%",
|
||||
"_",
|
||||
"-",
|
||||
"--",
|
||||
"--version",
|
||||
"--help",
|
||||
"$USER",
|
||||
"/dev/null; touch /tmp/blns.fail ; echo",
|
||||
"`touch /tmp/blns.fail`",
|
||||
"$(touch /tmp/blns.fail)",
|
||||
"@{[system \"touch /tmp/blns.fail\"]}",
|
||||
"eval(\"puts 'hello world'\")",
|
||||
"System(\"ls -al /\")",
|
||||
"`ls -al /`",
|
||||
"Kernel.exec(\"ls -al /\")",
|
||||
"Kernel.exit(1)",
|
||||
"%x('ls -al /')",
|
||||
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><!DOCTYPE foo [ <!ELEMENT foo ANY ><!ENTITY xxe SYSTEM \"file:///etc/passwd\" >]><foo>&xxe;</foo>",
|
||||
"$HOME",
|
||||
"$ENV{'HOME'}",
|
||||
"%d",
|
||||
"%s",
|
||||
"{0}",
|
||||
"%*.*s",
|
||||
"../../../../../../../../../../../etc/passwd%00",
|
||||
"../../../../../../../../../../../etc/hosts",
|
||||
"() { 0; }; touch /tmp/blns.shellshock1.fail;",
|
||||
"() { _; } >_[$($())] { touch /tmp/blns.shellshock2.fail; }",
|
||||
"+++ATH0",
|
||||
"<<< %s(un='%s') = %u",
|
||||
"CON",
|
||||
"PRN",
|
||||
"AUX",
|
||||
"CLOCK$",
|
||||
"NUL",
|
||||
"A:",
|
||||
"ZZ:",
|
||||
"COM1",
|
||||
"LPT1",
|
||||
"LPT2",
|
||||
"LPT3",
|
||||
"COM2",
|
||||
"COM3",
|
||||
"COM4",
|
||||
"DCC SEND STARTKEYLOGGER 0 0 0",
|
||||
"Scunthorpe General Hospital",
|
||||
"Penistone Community Church",
|
||||
"Lightwater Country Park",
|
||||
"Jimmy Clitheroe",
|
||||
"Horniman Museum",
|
||||
"shitake mushrooms",
|
||||
"RomansInSussex.co.uk",
|
||||
"http://www.cum.qc.ca/",
|
||||
"Craig Cockburn, Software Specialist",
|
||||
"Linda Callahan",
|
||||
"Dr. Herman I. Libshitz",
|
||||
"magna cum laude",
|
||||
"Super Bowl XXX",
|
||||
"medieval erection of parapets",
|
||||
"evaluate",
|
||||
"mocha",
|
||||
"expression",
|
||||
"Arsenal canal",
|
||||
"classic",
|
||||
"Tyson Gay",
|
||||
"Dick Van Dyke",
|
||||
"basement",
|
||||
"If you're reading this, you've been in a coma for almost 20 years now. We're trying a new technique. We don't know where this message will end up in your dream, but we hope it works. Please wake up, we miss you.",
|
||||
"Roses are \u001b[0;31mred\u001b[0m, violets are \u001b[0;34mblue. Hope you enjoy terminal hue",
|
||||
"But now...\u001b[20Cfor my greatest trick...\u001b[8m",
|
||||
"The quic\b\b\b\b\b\bk brown fo\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007x... [Beeeep]",
|
||||
"Powerلُلُصّبُلُلصّبُررً ॣ ॣh ॣ ॣ冗"
|
||||
]
|
||||
@@ -1 +0,0 @@
|
||||
亄<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +0,0 @@
|
||||
”{˙˙˙˙˙˙˙˙˙’˙˙˙˙˙˙˙˙úúúúúúúúúúúúetú
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user