Update CI (#3088)
* 👷 prepare GitHub actions for new Docker image * 👷 use experimental docker image * 👷 use Clang-Analyzer 14 * 🔇 suppress readability-identifier-length * 🔇 suppress more Clang-Tidy warnings * ♻️ simplify code * 🔇 suppress more Clang-Tidy warnings * 🔇 suppress more Clang-Tidy warnings * 🚨 fix warning * 🚨 fix warning * 🚨 fix warning * 👷 use new Docker image
This commit is contained in:
parent
c4a4e672fd
commit
7440786b81
@ -1,6 +1,9 @@
|
||||
Checks: '*,
|
||||
-altera-id-dependent-backward-branch,
|
||||
-altera-struct-pack-align,
|
||||
-altera-unroll-loops,
|
||||
-android-cloexec-fopen,
|
||||
-bugprone-easily-swappable-parameters,
|
||||
-concurrency-mt-unsafe,
|
||||
-cppcoreguidelines-avoid-goto,
|
||||
-cppcoreguidelines-avoid-magic-numbers,
|
||||
@ -11,6 +14,7 @@ Checks: '*,
|
||||
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
|
||||
-cppcoreguidelines-pro-type-reinterpret-cast,
|
||||
-cppcoreguidelines-pro-type-union-access,
|
||||
-cppcoreguidelines-virtual-class-destructor,
|
||||
-fuchsia-default-arguments-calls,
|
||||
-fuchsia-default-arguments-declarations,
|
||||
-fuchsia-overloaded-operator,
|
||||
@ -33,6 +37,7 @@ Checks: '*,
|
||||
-modernize-use-trailing-return-type,
|
||||
-readability-function-size,
|
||||
-readability-function-cognitive-complexity,
|
||||
-readability-identifier-length,
|
||||
-readability-magic-numbers,
|
||||
-readability-redundant-access-specifiers,
|
||||
-readability-uppercase-literal-suffix'
|
||||
|
16
.github/workflows/ubuntu.yml
vendored
16
.github/workflows/ubuntu.yml
vendored
@ -11,7 +11,7 @@ on:
|
||||
jobs:
|
||||
ci_test_clang:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v1.0.0
|
||||
container: ghcr.io/nlohmann/json-ci:v2.0.0
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: cmake
|
||||
@ -21,7 +21,7 @@ jobs:
|
||||
|
||||
ci_test_gcc:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v1.0.0
|
||||
container: ghcr.io/nlohmann/json-ci:v2.0.0
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: cmake
|
||||
@ -31,7 +31,7 @@ jobs:
|
||||
|
||||
ci_static_analysis:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v1.0.0
|
||||
container: ghcr.io/nlohmann/json-ci:v2.0.0
|
||||
strategy:
|
||||
matrix:
|
||||
target: [ci_clang_tidy, ci_cppcheck, ci_test_valgrind, ci_test_clang_sanitizer, ci_test_amalgamation, ci_clang_analyze, ci_cpplint, ci_cmake_flags, ci_single_binaries, ci_reproducible_tests, ci_non_git_tests, ci_offline_testdata, ci_infer]
|
||||
@ -44,7 +44,7 @@ jobs:
|
||||
|
||||
ci_cmake_options:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v1.0.0
|
||||
container: ghcr.io/nlohmann/json-ci:v2.0.0
|
||||
strategy:
|
||||
matrix:
|
||||
target: [ci_test_diagnostics, ci_test_noexceptions, ci_test_noimplicitconversions]
|
||||
@ -57,7 +57,7 @@ jobs:
|
||||
|
||||
ci_test_coverage:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v1.0.0
|
||||
container: ghcr.io/nlohmann/json-ci:v2.0.0
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: cmake
|
||||
@ -77,10 +77,10 @@ jobs:
|
||||
|
||||
ci_test_compilers:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v1.0.0
|
||||
container: ghcr.io/nlohmann/json-ci:v2.0.0
|
||||
strategy:
|
||||
matrix:
|
||||
compiler: [g++-4.8, g++-4.9, g++-5, g++-7, g++-8, g++-9, g++-10, clang++-3.5, clang++-3.6, clang++-3.7, clang++-3.8, clang++-3.9, clang++-4.0, clang++-5.0, clang++-6.0, clang++-7, clang++-8, clang++-9, clang++-10, clang++-11, clang++-12]
|
||||
compiler: [g++-4.8, g++-4.9, g++-5, g++-6, g++-7, g++-8, g++-9, g++-10, clang++-3.5, clang++-3.6, clang++-3.7, clang++-3.8, clang++-3.9, clang++-4.0, clang++-5.0, clang++-6.0, clang++-7, clang++-8, clang++-9, clang++-10, clang++-11, clang++-12, clang++-13]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: cmake
|
||||
@ -90,7 +90,7 @@ jobs:
|
||||
|
||||
ci_test_standards:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v1.0.0
|
||||
container: ghcr.io/nlohmann/json-ci:v2.0.0
|
||||
strategy:
|
||||
matrix:
|
||||
standard: [11, 14, 17, 20]
|
||||
|
48
README.md
48
README.md
@ -1083,36 +1083,38 @@ The following compilers are currently used in continuous integration at [Travis]
|
||||
| Apple Clang 12.0.0 (clang-1200.0.32.27); Xcode 12.2 | macOS 10.15.7 | GitHub Actions |
|
||||
| Apple Clang 12.0.0 (clang-1200.0.32.28); Xcode 12.3 | macOS 10.15.7 | GitHub Actions |
|
||||
| Apple Clang 12.0.0 (clang-1200.0.32.29); Xcode 12.4 | macOS 10.15.7 | GitHub Actions |
|
||||
| GCC 4.8.5 (Ubuntu 4.8.5-4ubuntu2) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| GCC 4.9.3 (Ubuntu 4.9.3-13ubuntu2) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| GCC 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| GCC 4.8.5 (Ubuntu 4.8.5-4ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 4.9.3 (Ubuntu 4.9.3-13ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 6.4.0 (Ubuntu 6.4.0-17ubuntu1) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 6.5.0 (Ubuntu 6.5.0-2ubuntu1~14.04.1) | Ubuntu 14.04.5 LTS | Travis |
|
||||
| GCC 7.5.0 (Ubuntu 7.5.0-6ubuntu2) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| GCC 7.5.0 (Ubuntu 7.5.0-6ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) | Windows-10.0.17763 | GitHub Actions |
|
||||
| GCC 8.1.0 (i686-posix-dwarf-rev0, Built by MinGW-W64 project) | Windows-10.0.17763 | GitHub Actions |
|
||||
| GCC 8.4.0 (Ubuntu 8.4.0-3ubuntu2) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| GCC 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| GCC 10.2.0 (Ubuntu 10.2.0-5ubuntu1~20.04) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| GCC 11.0.1 20210321 (experimental) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| GCC 8.4.0 (Ubuntu 8.4.0-3ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 10.2.0 (Ubuntu 10.2.0-5ubuntu1~20.04) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 11.0.1 20210321 (experimental) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| GCC 11.1.0 | Ubuntu (aarch64) | Drone CI |
|
||||
| Clang 3.5.2 (3.5.2-3ubuntu1) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| Clang 3.6.2 (3.6.2-3ubuntu2) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| Clang 3.7.1 (3.7.1-2ubuntu2) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| Clang 3.8.0 (3.8.0-2ubuntu4) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| Clang 3.9.1 (3.9.1-4ubuntu3\~16.04.2) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| Clang 4.0.0 (4.0.0-1ubuntu1\~16.04.2) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| Clang 5.0.0 (5.0.0-3\~16.04.1) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| Clang 6.0.1 (6.0.1-14) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| Clang 7.0.1 (7.0.1-12) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| Clang 8.0.1 (8.0.1-9) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| Clang 9.0.1 (9.0.1-12) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| Clang 10.0.0 (10.0.0-4ubuntu1) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| Clang 3.5.2 (3.5.2-3ubuntu1) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 3.6.2 (3.6.2-3ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 3.7.1 (3.7.1-2ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 3.8.0 (3.8.0-2ubuntu4) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 3.9.1 (3.9.1-4ubuntu3\~16.04.2) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 4.0.0 (4.0.0-1ubuntu1\~16.04.2) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 5.0.0 (5.0.0-3\~16.04.1) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 6.0.1 (6.0.1-14) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 7.0.1 (7.0.1-12) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 8.0.1 (8.0.1-9) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 9.0.1 (9.0.1-12) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 10.0.0 (10.0.0-4ubuntu1) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 10.0.0 with GNU-like command-line | Windows-10.0.17763 | GitHub Actions |
|
||||
| Clang 11.0.0 with GNU-like command-line | Windows-10.0.17763 | GitHub Actions |
|
||||
| Clang 11.0.0 with MSVC-like command-line | Windows-10.0.17763 | GitHub Actions |
|
||||
| Clang 11.0.0 (11.0.0-2~ubuntu20.04.1) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| Clang 12.0.0 (12.0.0-3ubuntu1~20.04.3) | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| Clang 13.0.0 (13.0.0-++20210828094952+9c49fee5e7ac-1exp120210828075752.71 | Ubuntu 20.04.2 LTS | GitHub Actions |
|
||||
| Clang 11.0.0 (11.0.0-2~ubuntu20.04.1) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 12.0.0 (12.0.0-3ubuntu1~20.04.3) | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 13.0.1 (13.0.1-++20211015123032+cf15ccdeb6d5-1~exp1~20211015003613.5 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Clang 14.0.0 (14.0.0-++20211015062452+81e9c90686f7-1~exp1~20211015063048.20 | Ubuntu 20.04.3 LTS | GitHub Actions |
|
||||
| Visual Studio 14 2015 MSVC 19.0.24241.7 (Build Engine version 14.0.25420.1) | Windows-6.3.9600 | AppVeyor |
|
||||
| Visual Studio 15 2017 MSVC 19.16.27035.0 (Build Engine version 15.9.21+g9802d43bc3 for .NET Framework) | Windows-10.0.14393 | AppVeyor |
|
||||
| Visual Studio 15 2017 MSVC 19.16.27045.0 (Build Engine version 15.9.21+g9802d43bc3 for .NET Framework) | Windows-10.0.14393 | GitHub Actions |
|
||||
|
@ -13,12 +13,12 @@ execute_process(COMMAND ${ASTYLE_TOOL} --version OUTPUT_VARIABLE ASTYLE_TOOL_VER
|
||||
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" ASTYLE_TOOL_VERSION "${ASTYLE_TOOL_VERSION}")
|
||||
message(STATUS "🔖 Artistic Style ${ASTYLE_TOOL_VERSION} (${ASTYLE_TOOL})")
|
||||
|
||||
find_program(CLANG_TOOL NAMES clang++-HEAD clang++-13 clang++-12 clang++-11 clang++)
|
||||
find_program(CLANG_TOOL NAMES clang++-HEAD clang++-14 clang++-13 clang++-12 clang++-11 clang++)
|
||||
execute_process(COMMAND ${CLANG_TOOL} --version OUTPUT_VARIABLE CLANG_TOOL_VERSION ERROR_VARIABLE CLANG_TOOL_VERSION)
|
||||
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CLANG_TOOL_VERSION "${CLANG_TOOL_VERSION}")
|
||||
message(STATUS "🔖 Clang ${CLANG_TOOL_VERSION} (${CLANG_TOOL})")
|
||||
|
||||
find_program(CLANG_TIDY_TOOL NAMES clang-tidy-12 clang-tidy-11 clang-tidy)
|
||||
find_program(CLANG_TIDY_TOOL NAMES clang-tidy-14 clang-tidy-13 clang-tidy-12 clang-tidy-11 clang-tidy)
|
||||
execute_process(COMMAND ${CLANG_TIDY_TOOL} --version OUTPUT_VARIABLE CLANG_TIDY_TOOL_VERSION ERROR_VARIABLE CLANG_TIDY_TOOL_VERSION)
|
||||
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CLANG_TIDY_TOOL_VERSION "${CLANG_TIDY_TOOL_VERSION}")
|
||||
message(STATUS "🔖 Clang-Tidy ${CLANG_TIDY_TOOL_VERSION} (${CLANG_TIDY_TOOL})")
|
||||
@ -79,7 +79,7 @@ message(STATUS "🔖 Valgrind ${VALGRIND_TOOL_VERSION} (${VALGRIND_TOOL})")
|
||||
find_program(GENHTML_TOOL NAMES genhtml)
|
||||
find_program(PLOG_CONVERTER_TOOL NAMES plog-converter)
|
||||
find_program(PVS_STUDIO_ANALYZER_TOOL NAMES pvs-studio-analyzer)
|
||||
find_program(SCAN_BUILD_TOOL NAMES scan-build-12 scan-build-11 scan-build)
|
||||
find_program(SCAN_BUILD_TOOL NAMES scan-build-14 scan-build-13 scan-build-12 scan-build-11 scan-build)
|
||||
|
||||
# the individual source files
|
||||
file(GLOB_RECURSE SRC_FILES ${PROJECT_SOURCE_DIR}/include/nlohmann/*.hpp)
|
||||
@ -811,7 +811,7 @@ add_custom_target(ci_cmake_flags
|
||||
# Use more installed compilers.
|
||||
###############################################################################
|
||||
|
||||
foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-7 g++-8 g++-9 g++-10 clang++-3.5 clang++-3.6 clang++-3.7 clang++-3.8 clang++-3.9 clang++-4.0 clang++-5.0 clang++-6.0 clang++-7 clang++-8 clang++-9 clang++-10 clang++-11 clang++-12)
|
||||
foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-6 g++-7 g++-8 g++-9 g++-10 clang++-3.5 clang++-3.6 clang++-3.7 clang++-3.8 clang++-3.9 clang++-4.0 clang++-5.0 clang++-6.0 clang++-7 clang++-8 clang++-9 clang++-10 clang++-11 clang++-12 clang++-13)
|
||||
find_program(COMPILER_TOOL NAMES ${COMPILER})
|
||||
if (COMPILER_TOOL)
|
||||
add_custom_target(ci_test_compiler_${COMPILER}
|
||||
|
@ -60,7 +60,7 @@ class exception : public std::exception
|
||||
|
||||
protected:
|
||||
JSON_HEDLEY_NON_NULL(3)
|
||||
exception(int id_, const char* what_arg) : id(id_), m(what_arg) {}
|
||||
exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} // NOLINT(bugprone-throw-keyword-missing)
|
||||
|
||||
static std::string name(const std::string& ename, int id_)
|
||||
{
|
||||
@ -198,7 +198,7 @@ class parse_error : public exception
|
||||
{
|
||||
std::string w = exception::name("parse_error", id_) + "parse error" +
|
||||
position_string(pos) + ": " + exception::diagnostics(context) + what_arg;
|
||||
return parse_error(id_, pos.chars_read_total, w.c_str());
|
||||
return {id_, pos.chars_read_total, w.c_str()};
|
||||
}
|
||||
|
||||
template<typename BasicJsonType>
|
||||
@ -207,7 +207,7 @@ class parse_error : public exception
|
||||
std::string w = exception::name("parse_error", id_) + "parse error" +
|
||||
(byte_ != 0 ? (" at byte " + std::to_string(byte_)) : "") +
|
||||
": " + exception::diagnostics(context) + what_arg;
|
||||
return parse_error(id_, byte_, w.c_str());
|
||||
return {id_, byte_, w.c_str()};
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -276,7 +276,7 @@ class invalid_iterator : public exception
|
||||
static invalid_iterator create(int id_, const std::string& what_arg, const BasicJsonType& context)
|
||||
{
|
||||
std::string w = exception::name("invalid_iterator", id_) + exception::diagnostics(context) + what_arg;
|
||||
return invalid_iterator(id_, w.c_str());
|
||||
return {id_, w.c_str()};
|
||||
}
|
||||
|
||||
private:
|
||||
@ -331,7 +331,7 @@ class type_error : public exception
|
||||
static type_error create(int id_, const std::string& what_arg, const BasicJsonType& context)
|
||||
{
|
||||
std::string w = exception::name("type_error", id_) + exception::diagnostics(context) + what_arg;
|
||||
return type_error(id_, w.c_str());
|
||||
return {id_, w.c_str()};
|
||||
}
|
||||
|
||||
private:
|
||||
@ -379,7 +379,7 @@ class out_of_range : public exception
|
||||
static out_of_range create(int id_, const std::string& what_arg, const BasicJsonType& context)
|
||||
{
|
||||
std::string w = exception::name("out_of_range", id_) + exception::diagnostics(context) + what_arg;
|
||||
return out_of_range(id_, w.c_str());
|
||||
return {id_, w.c_str()};
|
||||
}
|
||||
|
||||
private:
|
||||
@ -418,7 +418,7 @@ class other_error : public exception
|
||||
static other_error create(int id_, const std::string& what_arg, const BasicJsonType& context)
|
||||
{
|
||||
std::string w = exception::name("other_error", id_) + exception::diagnostics(context) + what_arg;
|
||||
return other_error(id_, w.c_str());
|
||||
return {id_, w.c_str()};
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -36,7 +36,7 @@ This class implements a both iterators (iterator and const_iterator) for the
|
||||
iterators in version 3.0.0 (see https://github.com/nlohmann/json/issues/593)
|
||||
*/
|
||||
template<typename BasicJsonType>
|
||||
class iter_impl
|
||||
class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions)
|
||||
{
|
||||
/// the iterator with BasicJsonType of different const-ness
|
||||
using other_iter_impl = iter_impl<typename std::conditional<std::is_const<BasicJsonType>::value, typename std::remove_const<BasicJsonType>::type, const BasicJsonType>::type>;
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include <cstdio> // snprintf
|
||||
#include <limits> // numeric_limits
|
||||
#include <string> // string, char_traits
|
||||
#include <iomanip> // setfill, setw
|
||||
#include <sstream> // stringstream
|
||||
#include <type_traits> // is_same
|
||||
#include <utility> // move
|
||||
|
||||
@ -499,10 +501,9 @@ class serializer
|
||||
{
|
||||
case error_handler_t::strict:
|
||||
{
|
||||
std::string sn(9, '\0');
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
||||
(std::snprintf)(&sn[0], sn.size(), "%.2X", byte);
|
||||
JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + sn, BasicJsonType()));
|
||||
std::stringstream ss;
|
||||
ss << std::uppercase << std::setfill('0') << std::setw(2) << std::hex << (byte | 0);
|
||||
JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + ss.str(), BasicJsonType()));
|
||||
}
|
||||
|
||||
case error_handler_t::ignore:
|
||||
@ -594,10 +595,9 @@ class serializer
|
||||
{
|
||||
case error_handler_t::strict:
|
||||
{
|
||||
std::string sn(9, '\0');
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
||||
(std::snprintf)(&sn[0], sn.size(), "%.2X", static_cast<std::uint8_t>(s.back()));
|
||||
JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + sn, BasicJsonType()));
|
||||
std::stringstream ss;
|
||||
ss << std::uppercase << std::setfill('0') << std::setw(2) << std::hex << (static_cast<std::uint8_t>(s.back()) | 0);
|
||||
JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + ss.str(), BasicJsonType()));
|
||||
}
|
||||
|
||||
case error_handler_t::ignore:
|
||||
|
@ -1073,64 +1073,34 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
}
|
||||
|
||||
/// constructor for strings
|
||||
json_value(const string_t& value)
|
||||
{
|
||||
string = create<string_t>(value);
|
||||
}
|
||||
json_value(const string_t& value) : string(create<string_t>(value)) {}
|
||||
|
||||
/// constructor for rvalue strings
|
||||
json_value(string_t&& value)
|
||||
{
|
||||
string = create<string_t>(std::move(value));
|
||||
}
|
||||
json_value(string_t&& value) : string(create<string_t>(std::move(value))) {}
|
||||
|
||||
/// constructor for objects
|
||||
json_value(const object_t& value)
|
||||
{
|
||||
object = create<object_t>(value);
|
||||
}
|
||||
json_value(const object_t& value) : object(create<object_t>(value)) {}
|
||||
|
||||
/// constructor for rvalue objects
|
||||
json_value(object_t&& value)
|
||||
{
|
||||
object = create<object_t>(std::move(value));
|
||||
}
|
||||
json_value(object_t&& value) : object(create<object_t>(std::move(value))) {}
|
||||
|
||||
/// constructor for arrays
|
||||
json_value(const array_t& value)
|
||||
{
|
||||
array = create<array_t>(value);
|
||||
}
|
||||
json_value(const array_t& value) : array(create<array_t>(value)) {}
|
||||
|
||||
/// constructor for rvalue arrays
|
||||
json_value(array_t&& value)
|
||||
{
|
||||
array = create<array_t>(std::move(value));
|
||||
}
|
||||
json_value(array_t&& value) : array(create<array_t>(std::move(value))) {}
|
||||
|
||||
/// constructor for binary arrays
|
||||
json_value(const typename binary_t::container_type& value)
|
||||
{
|
||||
binary = create<binary_t>(value);
|
||||
}
|
||||
json_value(const typename binary_t::container_type& value) : binary(create<binary_t>(value)) {}
|
||||
|
||||
/// constructor for rvalue binary arrays
|
||||
json_value(typename binary_t::container_type&& value)
|
||||
{
|
||||
binary = create<binary_t>(std::move(value));
|
||||
}
|
||||
json_value(typename binary_t::container_type&& value) : binary(create<binary_t>(std::move(value))) {}
|
||||
|
||||
/// constructor for binary arrays (internal type)
|
||||
json_value(const binary_t& value)
|
||||
{
|
||||
binary = create<binary_t>(value);
|
||||
}
|
||||
json_value(const binary_t& value) : binary(create<binary_t>(value)) {}
|
||||
|
||||
/// constructor for rvalue binary arrays (internal type)
|
||||
json_value(binary_t&& value)
|
||||
{
|
||||
binary = create<binary_t>(std::move(value));
|
||||
}
|
||||
json_value(binary_t&& value) : binary(create<binary_t>(std::move(value))) {}
|
||||
|
||||
void destroy(value_t t)
|
||||
{
|
||||
|
@ -2776,7 +2776,7 @@ class exception : public std::exception
|
||||
|
||||
protected:
|
||||
JSON_HEDLEY_NON_NULL(3)
|
||||
exception(int id_, const char* what_arg) : id(id_), m(what_arg) {}
|
||||
exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} // NOLINT(bugprone-throw-keyword-missing)
|
||||
|
||||
static std::string name(const std::string& ename, int id_)
|
||||
{
|
||||
@ -2914,7 +2914,7 @@ class parse_error : public exception
|
||||
{
|
||||
std::string w = exception::name("parse_error", id_) + "parse error" +
|
||||
position_string(pos) + ": " + exception::diagnostics(context) + what_arg;
|
||||
return parse_error(id_, pos.chars_read_total, w.c_str());
|
||||
return {id_, pos.chars_read_total, w.c_str()};
|
||||
}
|
||||
|
||||
template<typename BasicJsonType>
|
||||
@ -2923,7 +2923,7 @@ class parse_error : public exception
|
||||
std::string w = exception::name("parse_error", id_) + "parse error" +
|
||||
(byte_ != 0 ? (" at byte " + std::to_string(byte_)) : "") +
|
||||
": " + exception::diagnostics(context) + what_arg;
|
||||
return parse_error(id_, byte_, w.c_str());
|
||||
return {id_, byte_, w.c_str()};
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -2992,7 +2992,7 @@ class invalid_iterator : public exception
|
||||
static invalid_iterator create(int id_, const std::string& what_arg, const BasicJsonType& context)
|
||||
{
|
||||
std::string w = exception::name("invalid_iterator", id_) + exception::diagnostics(context) + what_arg;
|
||||
return invalid_iterator(id_, w.c_str());
|
||||
return {id_, w.c_str()};
|
||||
}
|
||||
|
||||
private:
|
||||
@ -3047,7 +3047,7 @@ class type_error : public exception
|
||||
static type_error create(int id_, const std::string& what_arg, const BasicJsonType& context)
|
||||
{
|
||||
std::string w = exception::name("type_error", id_) + exception::diagnostics(context) + what_arg;
|
||||
return type_error(id_, w.c_str());
|
||||
return {id_, w.c_str()};
|
||||
}
|
||||
|
||||
private:
|
||||
@ -3095,7 +3095,7 @@ class out_of_range : public exception
|
||||
static out_of_range create(int id_, const std::string& what_arg, const BasicJsonType& context)
|
||||
{
|
||||
std::string w = exception::name("out_of_range", id_) + exception::diagnostics(context) + what_arg;
|
||||
return out_of_range(id_, w.c_str());
|
||||
return {id_, w.c_str()};
|
||||
}
|
||||
|
||||
private:
|
||||
@ -3134,7 +3134,7 @@ class other_error : public exception
|
||||
static other_error create(int id_, const std::string& what_arg, const BasicJsonType& context)
|
||||
{
|
||||
std::string w = exception::name("other_error", id_) + exception::diagnostics(context) + what_arg;
|
||||
return other_error(id_, w.c_str());
|
||||
return {id_, w.c_str()};
|
||||
}
|
||||
|
||||
private:
|
||||
@ -11621,7 +11621,7 @@ This class implements a both iterators (iterator and const_iterator) for the
|
||||
iterators in version 3.0.0 (see https://github.com/nlohmann/json/issues/593)
|
||||
*/
|
||||
template<typename BasicJsonType>
|
||||
class iter_impl
|
||||
class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions)
|
||||
{
|
||||
/// the iterator with BasicJsonType of different const-ness
|
||||
using other_iter_impl = iter_impl<typename std::conditional<std::is_const<BasicJsonType>::value, typename std::remove_const<BasicJsonType>::type, const BasicJsonType>::type>;
|
||||
@ -15315,6 +15315,8 @@ class binary_writer
|
||||
#include <cstdio> // snprintf
|
||||
#include <limits> // numeric_limits
|
||||
#include <string> // string, char_traits
|
||||
#include <iomanip> // setfill, setw
|
||||
#include <sstream> // stringstream
|
||||
#include <type_traits> // is_same
|
||||
#include <utility> // move
|
||||
|
||||
@ -16923,10 +16925,9 @@ class serializer
|
||||
{
|
||||
case error_handler_t::strict:
|
||||
{
|
||||
std::string sn(9, '\0');
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
||||
(std::snprintf)(&sn[0], sn.size(), "%.2X", byte);
|
||||
JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + sn, BasicJsonType()));
|
||||
std::stringstream ss;
|
||||
ss << std::uppercase << std::setfill('0') << std::setw(2) << std::hex << (byte | 0);
|
||||
JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + ss.str(), BasicJsonType()));
|
||||
}
|
||||
|
||||
case error_handler_t::ignore:
|
||||
@ -17018,10 +17019,9 @@ class serializer
|
||||
{
|
||||
case error_handler_t::strict:
|
||||
{
|
||||
std::string sn(9, '\0');
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
||||
(std::snprintf)(&sn[0], sn.size(), "%.2X", static_cast<std::uint8_t>(s.back()));
|
||||
JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + sn, BasicJsonType()));
|
||||
std::stringstream ss;
|
||||
ss << std::uppercase << std::setfill('0') << std::setw(2) << std::hex << (static_cast<std::uint8_t>(s.back()) | 0);
|
||||
JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + ss.str(), BasicJsonType()));
|
||||
}
|
||||
|
||||
case error_handler_t::ignore:
|
||||
@ -18574,64 +18574,34 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
}
|
||||
|
||||
/// constructor for strings
|
||||
json_value(const string_t& value)
|
||||
{
|
||||
string = create<string_t>(value);
|
||||
}
|
||||
json_value(const string_t& value) : string(create<string_t>(value)) {}
|
||||
|
||||
/// constructor for rvalue strings
|
||||
json_value(string_t&& value)
|
||||
{
|
||||
string = create<string_t>(std::move(value));
|
||||
}
|
||||
json_value(string_t&& value) : string(create<string_t>(std::move(value))) {}
|
||||
|
||||
/// constructor for objects
|
||||
json_value(const object_t& value)
|
||||
{
|
||||
object = create<object_t>(value);
|
||||
}
|
||||
json_value(const object_t& value) : object(create<object_t>(value)) {}
|
||||
|
||||
/// constructor for rvalue objects
|
||||
json_value(object_t&& value)
|
||||
{
|
||||
object = create<object_t>(std::move(value));
|
||||
}
|
||||
json_value(object_t&& value) : object(create<object_t>(std::move(value))) {}
|
||||
|
||||
/// constructor for arrays
|
||||
json_value(const array_t& value)
|
||||
{
|
||||
array = create<array_t>(value);
|
||||
}
|
||||
json_value(const array_t& value) : array(create<array_t>(value)) {}
|
||||
|
||||
/// constructor for rvalue arrays
|
||||
json_value(array_t&& value)
|
||||
{
|
||||
array = create<array_t>(std::move(value));
|
||||
}
|
||||
json_value(array_t&& value) : array(create<array_t>(std::move(value))) {}
|
||||
|
||||
/// constructor for binary arrays
|
||||
json_value(const typename binary_t::container_type& value)
|
||||
{
|
||||
binary = create<binary_t>(value);
|
||||
}
|
||||
json_value(const typename binary_t::container_type& value) : binary(create<binary_t>(value)) {}
|
||||
|
||||
/// constructor for rvalue binary arrays
|
||||
json_value(typename binary_t::container_type&& value)
|
||||
{
|
||||
binary = create<binary_t>(std::move(value));
|
||||
}
|
||||
json_value(typename binary_t::container_type&& value) : binary(create<binary_t>(std::move(value))) {}
|
||||
|
||||
/// constructor for binary arrays (internal type)
|
||||
json_value(const binary_t& value)
|
||||
{
|
||||
binary = create<binary_t>(value);
|
||||
}
|
||||
json_value(const binary_t& value) : binary(create<binary_t>(value)) {}
|
||||
|
||||
/// constructor for rvalue binary arrays (internal type)
|
||||
json_value(binary_t&& value)
|
||||
{
|
||||
binary = create<binary_t>(std::move(value));
|
||||
}
|
||||
json_value(binary_t&& value) : binary(create<binary_t>(std::move(value))) {}
|
||||
|
||||
void destroy(value_t t)
|
||||
{
|
||||
|
@ -648,7 +648,7 @@ TEST_CASE("JSON patch")
|
||||
CHECK(target == R"({ "D": "Berlin", "F": "Paris", "GB": "London" })"_json);
|
||||
|
||||
// create a diff from two JSONs
|
||||
json p2 = json::diff(target, source);
|
||||
json p2 = json::diff(target, source); // NOLINT(readability-suspicious-call-argument)
|
||||
// p2 = [{"op": "delete", "path": "/GB"}]
|
||||
CHECK(p2 == R"([{"op":"remove","path":"/GB"}])"_json);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ TEST_CASE("tests on very large JSONs")
|
||||
{
|
||||
const auto depth = 5000000;
|
||||
|
||||
std::string s(2 * depth, '[');
|
||||
std::string s(static_cast<std::size_t>(2 * depth), '[');
|
||||
std::fill(s.begin() + depth, s.end(), ']');
|
||||
|
||||
json _;
|
||||
|
@ -349,7 +349,7 @@ TEST_CASE("MessagePack")
|
||||
{
|
||||
for (uint64_t i :
|
||||
{
|
||||
4294967296lu, 9223372036854775807lu
|
||||
4294967296LU, 9223372036854775807LU
|
||||
})
|
||||
{
|
||||
CAPTURE(i)
|
||||
@ -719,7 +719,7 @@ TEST_CASE("MessagePack")
|
||||
{
|
||||
for (uint64_t i :
|
||||
{
|
||||
4294967296lu, 18446744073709551615lu
|
||||
4294967296LU, 18446744073709551615LU
|
||||
})
|
||||
{
|
||||
CAPTURE(i)
|
||||
|
Loading…
Reference in New Issue
Block a user