summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal <amlal@nekernel.org>2025-04-25 13:17:33 +0200
committerAmlal <amlal@nekernel.org>2025-04-25 13:17:33 +0200
commit7927f01e875ef76185535d209c14230fe9be183d (patch)
tree129eecf026edf7e8a47d1a3c49716c74b6caa985
parent72f132b8fb9f2a47b0f723f4dc4eaa4fdb0c45bd (diff)
dev: update clang-fornat, and codebase.
Signed-off-by: Amlal <amlal@nekernel.org>
-rw-r--r--.clang-format43
-rw-r--r--cli/CommandLine.cc143
-rw-r--r--examples/example_01/example.cc9
-rw-r--r--lib/IManifestBuilder.h40
-rw-r--r--lib/Includes.h10
-rw-r--r--lib/JSONManifestBuilder.h38
-rw-r--r--lib/Macros.h27
-rw-r--r--src/JSONManifestBuilder.cc283
-rw-r--r--vendor/json_fwd.h121
9 files changed, 333 insertions, 381 deletions
diff --git a/.clang-format b/.clang-format
index fb3cacb..3943f55 100644
--- a/.clang-format
+++ b/.clang-format
@@ -1,16 +1,29 @@
----
-BasedOnStyle: Microsoft
-AccessModifierOffset: '-4'
-AlignAfterOpenBracket: Align
-AlignConsecutiveMacros: 'true'
-AlignConsecutiveAssignments: 'true'
-AlignConsecutiveDeclarations: 'true'
-BinPackParameters: 'false'
-ColumnLimit: '0'
-Language: Cpp
-NamespaceIndentation: All
+BasedOnStyle: Google
+IndentWidth: 2
+TabWidth: 2
+UseTab: Never
+ColumnLimit: 100
+DerivePointerAlignment: false
PointerAlignment: Left
-ReflowComments: 'true'
-SortIncludes: 'false'
-UseTab: Always
-...
+AllowShortFunctionsOnASingleLine: Inline
+AllowShortIfStatementsOnASingleLine: true
+AllowShortLoopsOnASingleLine: true
+SortIncludes: true
+IncludeBlocks: Preserve
+SpaceAfterCStyleCast: true
+SpaceBeforeParens: ControlStatements
+SpacesInAngles: false
+SpacesInContainerLiterals: true
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+BreakBeforeBraces: Attach
+ConstructorInitializerAllOnOneLineOrOnePerLine: true
+Cpp11BracedListStyle: true
+NamespaceIndentation: Inner
+ReflowComments: true
+AlignConsecutiveAssignments: true
+AlignConsecutiveDeclarations: true
+AlignTrailingComments: true
+FixNamespaceComments: true
+IncludeIsMainRegex: '(Test)?$'
+SortUsingDeclarations: true
diff --git a/cli/CommandLine.cc b/cli/CommandLine.cc
index 5c522e7..419f146 100644
--- a/cli/CommandLine.cc
+++ b/cli/CommandLine.cc
@@ -4,87 +4,74 @@
// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
// ============================================================= //
-#include <JSONManifestBuilder.h>
#include <Includes.h>
+#include <JSONManifestBuilder.h>
static bool kFailed = false;
static bool kDryRun = false;
-int main(int argc, char** argv)
-{
- if (argc <= 1)
- return EXIT_FAILURE;
-
- for (size_t index = 1; index < argc; ++index)
- {
- std::string index_path = argv[index];
-
- if (index_path == "-v" ||
- index_path == "--version")
- {
- BTB::Logger::info() << "Brought to you by Amlal El Mahrouss for the NeKernel project.\n";
- BTB::Logger::info() << "© 2024-2025 Amlal El Mahrouss, all rights reserved.\n";
-
- BTB::Logger::info() << "Bugs, issues? Check out: https://github.com/nekernel-org/btb/issues\n";
-
- return EXIT_SUCCESS;
- }
- else if (index_path == "--dry-run")
- {
- kDryRun = true;
- continue;
- }
- else if (index_path == "-h" ||
- index_path == "--help")
- {
- BTB::Logger::info() << "Usage: btb <file>\n";
-
- return EXIT_SUCCESS;
- }
-
- if (index_path.starts_with("-"))
- {
- BTB::Logger::info() << "error: unknown option '" << index_path << "'\n";
-
- return EXIT_FAILURE;
- }
-
- std::thread job_build_thread([](std::string index_path) -> void {
- BTB::IManifestBuilder* builder = nullptr;
-
- const auto kJsonExtension = ".json";
-
- if (index_path.ends_with(kJsonExtension))
- {
- builder = new BTB::JSONManifestBuilder();
-
- if (!builder)
- {
- kFailed = true;
- return;
- }
- }
- else
- {
- BTB::Logger::info() << "error: file '" << index_path << "' is not a JSON file!" << std::endl;
- kFailed = true;
- return;
- }
-
- BTB::Logger::info() << "building manifest: " << index_path << std::endl;
-
- if (builder && !builder->buildTarget(index_path.size(), index_path.c_str(), kDryRun))
- {
- kFailed = true;
- }
-
- delete builder;
- builder = nullptr;
- },
- index_path);
-
- job_build_thread.join();
- }
-
- return kFailed ? EXIT_FAILURE : EXIT_SUCCESS;
+int main(int argc, char** argv) {
+ if (argc <= 1) return EXIT_FAILURE;
+
+ for (size_t index = 1; index < argc; ++index) {
+ std::string index_path = argv[index];
+
+ if (index_path == "-v" || index_path == "--version") {
+ BTB::Logger::info() << "Brought to you by Amlal El Mahrouss for the NeKernel project.\n";
+ BTB::Logger::info() << "© 2024-2025 Amlal El Mahrouss, all rights reserved.\n";
+
+ BTB::Logger::info()
+ << "Bugs, issues? Check out: https://github.com/nekernel-org/btb/issues\n";
+
+ return EXIT_SUCCESS;
+ } else if (index_path == "--dry-run") {
+ kDryRun = true;
+ continue;
+ } else if (index_path == "-h" || index_path == "--help") {
+ BTB::Logger::info() << "Usage: btb <file>\n";
+
+ return EXIT_SUCCESS;
+ }
+
+ if (index_path.starts_with("-")) {
+ BTB::Logger::info() << "error: unknown option '" << index_path << "'\n";
+
+ return EXIT_FAILURE;
+ }
+
+ std::thread job_build_thread(
+ [](std::string index_path) -> void {
+ BTB::IManifestBuilder* builder = nullptr;
+
+ const auto kJsonExtension = ".json";
+
+ if (index_path.ends_with(kJsonExtension)) {
+ builder = new BTB::JSONManifestBuilder();
+
+ if (!builder) {
+ kFailed = true;
+ return;
+ }
+ } else {
+ BTB::Logger::info() << "error: file '" << index_path << "' is not a JSON file!"
+ << std::endl;
+ kFailed = true;
+ return;
+ }
+
+ BTB::Logger::info() << "building manifest: " << index_path << std::endl;
+
+ if (builder && !builder->buildTarget(index_path.size(), index_path.c_str(), kDryRun)) {
+ kFailed = true;
+ }
+
+ delete builder;
+ builder = nullptr;
+ },
+ index_path);
+
+ job_build_thread.join();
+ }
+
+ return kFailed ? EXIT_FAILURE : EXIT_SUCCESS;
}
diff --git a/examples/example_01/example.cc b/examples/example_01/example.cc
index aa2d8b0..ae47ce8 100644
--- a/examples/example_01/example.cc
+++ b/examples/example_01/example.cc
@@ -1,8 +1,7 @@
-#include <string>
#include <iostream>
+#include <string>
-int main(int argc, char** argv)
-{
- std::cout << "hello, world!\n";
- return 0;
+int main(int argc, char** argv) {
+ std::cout << "hello, world!\n";
+ return 0;
}
diff --git a/lib/IManifestBuilder.h b/lib/IManifestBuilder.h
index a48511c..ed3c30f 100644
--- a/lib/IManifestBuilder.h
+++ b/lib/IManifestBuilder.h
@@ -5,29 +5,27 @@
#pragma once
-#include <Macros.h>
#include <Includes.h>
+#include <Macros.h>
-namespace BTB
-{
- /// @brief Builder interface class.
- /// @note This class is meant to be used as an interface.
- class IManifestBuilder
- {
- public:
- explicit IManifestBuilder() = default;
- virtual ~IManifestBuilder() = default;
+namespace BTB {
+/// @brief Builder interface class.
+/// @note This class is meant to be used as an interface.
+class IManifestBuilder {
+ public:
+ explicit IManifestBuilder() = default;
+ virtual ~IManifestBuilder() = default;
- IManifestBuilder& operator=(const IManifestBuilder&) = default;
- IManifestBuilder(const IManifestBuilder&) = default;
+ IManifestBuilder& operator=(const IManifestBuilder&) = default;
+ IManifestBuilder(const IManifestBuilder&) = default;
- /// @brief Builds a target using the implemented laguage.
- /// @param arg_sz filename size
- /// @param arg_val filename path.
- /// @retval true succeeded.
- /// @retval false failed.
- virtual bool buildTarget(int arg_sz, const char* arg_val, const bool dry_run = false) = 0;
+ /// @brief Builds a target using the implemented laguage.
+ /// @param arg_sz filename size
+ /// @param arg_val filename path.
+ /// @retval true succeeded.
+ /// @retval false failed.
+ virtual bool buildTarget(int arg_sz, const char* arg_val, const bool dry_run = false) = 0;
- virtual const char* buildSystem() = 0;
- };
-} // namespace BTB \ No newline at end of file
+ virtual const char* buildSystem() = 0;
+};
+} // namespace BTB \ No newline at end of file
diff --git a/lib/Includes.h b/lib/Includes.h
index 3f035f3..3695d53 100644
--- a/lib/Includes.h
+++ b/lib/Includes.h
@@ -6,12 +6,12 @@
#ifndef BTB_INCLUDES_H
#define BTB_INCLUDES_H
-#include <cstdio>
#include <cstddef>
-#include <string>
+#include <cstdio>
+#include <fstream>
#include <iostream>
-#include <thread>
#include <sstream>
-#include <fstream>
+#include <string>
+#include <thread>
-#endif // BTB_INCLUDES_H
+#endif // BTB_INCLUDES_H
diff --git a/lib/JSONManifestBuilder.h b/lib/JSONManifestBuilder.h
index fef5baf..93c86e9 100644
--- a/lib/JSONManifestBuilder.h
+++ b/lib/JSONManifestBuilder.h
@@ -8,26 +8,24 @@
#include <IManifestBuilder.h>
#include <json.h>
-namespace BTB
-{
- /// @brief JSON builder
- class JSONManifestBuilder final : public IManifestBuilder
- {
- public:
- explicit JSONManifestBuilder() = default;
- virtual ~JSONManifestBuilder() override = default;
+namespace BTB {
+/// @brief JSON builder
+class JSONManifestBuilder final : public IManifestBuilder {
+ public:
+ explicit JSONManifestBuilder() = default;
+ virtual ~JSONManifestBuilder() override = default;
- JSONManifestBuilder& operator=(const JSONManifestBuilder&) = default;
- JSONManifestBuilder(const JSONManifestBuilder&) = default;
+ JSONManifestBuilder& operator=(const JSONManifestBuilder&) = default;
+ JSONManifestBuilder(const JSONManifestBuilder&) = default;
- public:
- /// @brief Builds a JSON target.
- /// @param arg_sz filename size
- /// @param arg_val filename path.
- /// @retval true build succeeded.
- /// @retval false failed to build.
- virtual bool buildTarget(int arg_sz, const char* arg_val, const bool dry_run = false) override;
+ public:
+ /// @brief Builds a JSON target.
+ /// @param arg_sz filename size
+ /// @param arg_val filename path.
+ /// @retval true build succeeded.
+ /// @retval false failed to build.
+ virtual bool buildTarget(int arg_sz, const char* arg_val, const bool dry_run = false) override;
- virtual const char* buildSystem() override;
- };
-} // namespace BTB \ No newline at end of file
+ virtual const char* buildSystem() override;
+};
+} // namespace BTB \ No newline at end of file
diff --git a/lib/Macros.h b/lib/Macros.h
index 35a44a1..9d51a2f 100644
--- a/lib/Macros.h
+++ b/lib/Macros.h
@@ -5,14 +5,13 @@
#pragma once
-extern "C"
-{
+extern "C" {
#include <assert.h>
}
#include <rang.h>
-#define LIKELY(ARG) (ARG) ? assert(false) : ((void)0)
+#define LIKELY(ARG) (ARG) ? assert(false) : ((void) 0)
#define UNLIKELY(ARG) LIKELY(!(ARG))
#define LIBBTB_VERSION "1.1.0"
@@ -23,15 +22,13 @@ extern "C"
#define LIBBTB_VERSION_MINOR 1
#define LIBBTB_VERSION_PATCH 0
-#define LIBBTB_UNUSED(X) ((void)X)
-
-namespace BTB::Logger
-{
- /// @brief replacement for std::cout for BTB logging.
- inline std::ostream& info() noexcept
- {
- auto& out = std::cout;
- out << rang::fg::red << "btb: " << rang::style::reset;
- return out;
- }
-} // namespace BTB::Logger
+#define LIBBTB_UNUSED(X) ((void) X)
+
+namespace BTB::Logger {
+/// @brief replacement for std::cout for BTB logging.
+inline std::ostream& info() noexcept {
+ auto& out = std::cout;
+ out << rang::fg::red << "btb: " << rang::style::reset;
+ return out;
+}
+} // namespace BTB::Logger
diff --git a/src/JSONManifestBuilder.cc b/src/JSONManifestBuilder.cc
index d268724..f70450d 100644
--- a/src/JSONManifestBuilder.cc
+++ b/src/JSONManifestBuilder.cc
@@ -7,7 +7,7 @@
#include <initializer_list>
using String = std::string;
-using JSON = nlohmann::json;
+using JSON = nlohmann::json;
namespace FS = std::filesystem;
using namespace BTB;
@@ -17,164 +17,137 @@ using namespace BTB;
/// @param arg_val filename path (must be a valid JSON file).
/// @retval true succeeded building.
/// @retval false fail to build, see error message.
-bool JSONManifestBuilder::buildTarget(int arg_sz, const char* arg_val, const bool dry_run)
-{
- String path;
-
- if (arg_sz < 0)
- {
- BTB::Logger::info() << "btb: error: file path is empty" << std::endl;
- return false;
- }
- else
- {
- path = arg_val;
-
- if (!FS::exists(path))
- {
- BTB::Logger::info() << "btb: error: file '" << path << "' does not exist" << std::endl;
- return false;
- }
- }
-
- try
- {
- std::ifstream json(path);
-
- if (!json.good())
- {
- BTB::Logger::info() << "btb: error: file '" << path << "' is not a valid JSON" << std::endl;
- return false;
- }
-
- JSON json_obj = JSON::parse(json);
-
- String compiler = json_obj["compiler_path"].get<String>();
-
- JSON header_search_path = json_obj["headers_path"];
- JSON sources_files = json_obj["sources_path"];
-
- String command = compiler + " ";
-
- for (auto& sources : sources_files)
- {
- command += sources.get<String>() + " ";
- }
-
- for (auto& headers : header_search_path)
- {
- command += "-I" + headers.get<String>() + " ";
- }
-
- JSON macros_list = json_obj["cpp_macros"];
-
- for (auto& macro : macros_list)
- {
- command += "-D" + macro.get<String>() + " ";
- }
-
- JSON compiler_flags = json_obj["compiler_flags"];
-
- for (auto& flag : compiler_flags)
- {
- command += flag.get<String>() + " ";
- }
-
- if (json_obj["compiler_std"].is_string())
- command += "-std=" + json_obj["compiler_std"].get<String>() + " ";
-
- command += "-o " + json_obj["output_name"].get<String>();
-
- auto target = json_obj["output_name"].get<String>();
-
- BTB::Logger::info() << "output path: " << target << "\n";
- BTB::Logger::info() << "command: " << command << "\n";
-
- try
- {
- if (json_obj["dry_run"].get<bool>())
- return true;
- }
- catch (...)
- {
- }
-
- if (dry_run)
- {
- return true;
- }
-
- auto ret_exec = std::system(command.c_str());
-
- if (ret_exec > 0)
- {
- BTB::Logger::info() << "error: exec exit with code: " << ret_exec << "" << std::endl;
- return false;
- }
-
- try
- {
- if (json_obj["run_after_build"].get<bool>())
- {
- if (target.ends_with(".so"))
- {
- BTB::Logger::info() << "error: can't open dynamic library, it mayn't have an entrypoint" << std::endl;
-
- return true;
- }
- else if (target.ends_with(".dylib") ||
- target.ends_with(".dll"))
- {
- std::ifstream file = std::ifstream(target);
- std::stringstream ss;
-
- ss << file.rdbuf();
-
- if (ss.str()[0] == 'J' &&
- ss.str()[1] == 'o' &&
- ss.str()[2] == 'y' &&
- ss.str()[3] == '!')
- BTB::Logger::info() << "error: can't open PEF dynamic library, it mayn't contain an entrypoint" << std::endl;
- else if (ss.str()[0] == '!' &&
- ss.str()[1] == 'y' &&
- ss.str()[2] == 'o' &&
- ss.str()[3] == 'J')
- BTB::Logger::info() << "error: can't open FEP dynamic library, it mayn't contain an entrypoint" << std::endl;
- else if (ss.str()[0] == 'M' &&
- ss.str()[1] == 'Z')
- BTB::Logger::info() << "error: can't open MZ dynamic library, it mayn't contain an entrypoint" << std::endl;
- else if (ss.str()[0] == 0x7F &&
- ss.str()[1] == 'E')
- {
- BTB::Logger::info() << "error: can't open ELF dynamic library, it mayn't contain an entrypoint" << std::endl;
- }
-
- return true;
- }
+bool JSONManifestBuilder::buildTarget(int arg_sz, const char* arg_val, const bool dry_run) {
+ String path;
+
+ if (arg_sz < 0) {
+ BTB::Logger::info() << "btb: error: file path is empty" << std::endl;
+ return false;
+ } else {
+ path = arg_val;
+
+ if (!FS::exists(path)) {
+ BTB::Logger::info() << "btb: error: file '" << path << "' does not exist" << std::endl;
+ return false;
+ }
+ }
+
+ try {
+ std::ifstream json(path);
+
+ if (!json.good()) {
+ BTB::Logger::info() << "btb: error: file '" << path << "' is not a valid JSON" << std::endl;
+ return false;
+ }
+
+ JSON json_obj = JSON::parse(json);
+
+ String compiler = json_obj["compiler_path"].get<String>();
+
+ JSON header_search_path = json_obj["headers_path"];
+ JSON sources_files = json_obj["sources_path"];
+
+ String command = compiler + " ";
+
+ for (auto& sources : sources_files) {
+ command += sources.get<String>() + " ";
+ }
+
+ for (auto& headers : header_search_path) {
+ command += "-I" + headers.get<String>() + " ";
+ }
+
+ JSON macros_list = json_obj["cpp_macros"];
+
+ for (auto& macro : macros_list) {
+ command += "-D" + macro.get<String>() + " ";
+ }
+
+ JSON compiler_flags = json_obj["compiler_flags"];
+
+ for (auto& flag : compiler_flags) {
+ command += flag.get<String>() + " ";
+ }
+
+ if (json_obj["compiler_std"].is_string())
+ command += "-std=" + json_obj["compiler_std"].get<String>() + " ";
+
+ command += "-o " + json_obj["output_name"].get<String>();
+
+ auto target = json_obj["output_name"].get<String>();
+
+ BTB::Logger::info() << "output path: " << target << "\n";
+ BTB::Logger::info() << "command: " << command << "\n";
+
+ try {
+ if (json_obj["dry_run"].get<bool>()) return true;
+ } catch (...) {
+ }
+
+ if (dry_run) {
+ return true;
+ }
+
+ auto ret_exec = std::system(command.c_str());
+
+ if (ret_exec > 0) {
+ BTB::Logger::info() << "error: exec exit with code: " << ret_exec << "" << std::endl;
+ return false;
+ }
+
+ try {
+ if (json_obj["run_after_build"].get<bool>()) {
+ if (target.ends_with(".so")) {
+ BTB::Logger::info() << "error: can't open dynamic library, it mayn't have an entrypoint"
+ << std::endl;
+
+ return true;
+ } else if (target.ends_with(".dylib") || target.ends_with(".dll")) {
+ std::ifstream file = std::ifstream(target);
+ std::stringstream ss;
+
+ ss << file.rdbuf();
+
+ if (ss.str()[0] == 'J' && ss.str()[1] == 'o' && ss.str()[2] == 'y' && ss.str()[3] == '!')
+ BTB::Logger::info()
+ << "error: can't open PEF dynamic library, it mayn't contain an entrypoint"
+ << std::endl;
+ else if (ss.str()[0] == '!' && ss.str()[1] == 'y' && ss.str()[2] == 'o' &&
+ ss.str()[3] == 'J')
+ BTB::Logger::info()
+ << "error: can't open FEP dynamic library, it mayn't contain an entrypoint"
+ << std::endl;
+ else if (ss.str()[0] == 'M' && ss.str()[1] == 'Z')
+ BTB::Logger::info()
+ << "error: can't open MZ dynamic library, it mayn't contain an entrypoint"
+ << std::endl;
+ else if (ss.str()[0] == 0x7F && ss.str()[1] == 'E') {
+ BTB::Logger::info()
+ << "error: can't open ELF dynamic library, it mayn't contain an entrypoint"
+ << std::endl;
+ }
+
+ return true;
+ }
#if defined(BTB_WINDOWS)
- std::system((".\\" + target).c_str());
+ std::system((".\\" + target).c_str());
#else
- std::system(("./" + target).c_str());
+ std::system(("./" + target).c_str());
#endif
- }
- }
- catch (...)
- {
- return true;
- }
- }
- catch (std::runtime_error& err)
- {
- BTB::Logger::info() << "error: " << err.what() << std::endl;
-
- return false;
- }
-
- return true;
+ }
+ } catch (...) {
+ return true;
+ }
+ } catch (std::runtime_error& err) {
+ BTB::Logger::info() << "error: " << err.what() << std::endl;
+
+ return false;
+ }
+
+ return true;
}
-const char* JSONManifestBuilder::buildSystem()
-{
- return "json";
+const char* JSONManifestBuilder::buildSystem() {
+ return "json";
}
diff --git a/vendor/json_fwd.h b/vendor/json_fwd.h
index 29a6036..a1c70f3 100644
--- a/vendor/json_fwd.h
+++ b/vendor/json_fwd.h
@@ -9,11 +9,11 @@
#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
-#include <cstdint> // int64_t, uint64_t
-#include <map> // map
-#include <memory> // allocator
-#include <string> // string
-#include <vector> // vector
+#include <cstdint> // int64_t, uint64_t
+#include <map> // map
+#include <memory> // allocator
+#include <string> // string
+#include <vector> // vector
// #include <nlohmann/detail/abi_macros.hpp>
// __ _____ _____ _____
@@ -24,16 +24,16 @@
// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann <https://nlohmann.me>
// SPDX-License-Identifier: MIT
-
-
// This file contains all macro definitions affecting or depending on the ABI
#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
- #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
- #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 3
- #warning "Already included a different version of the library!"
- #endif
- #endif
+#if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && \
+ defined(NLOHMANN_JSON_VERSION_PATCH)
+#if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || \
+ NLOHMANN_JSON_VERSION_PATCH != 3
+#warning "Already included a different version of the library!"
+#endif
+#endif
#endif
#define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum)
@@ -41,83 +41,72 @@
#define NLOHMANN_JSON_VERSION_PATCH 3 // NOLINT(modernize-macro-to-enum)
#ifndef JSON_DIAGNOSTICS
- #define JSON_DIAGNOSTICS 0
+#define JSON_DIAGNOSTICS 0
#endif
#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
- #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
+#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
#endif
#if JSON_DIAGNOSTICS
- #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
+#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
#else
- #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
+#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
#endif
#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
- #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
+#define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
#else
- #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
+#define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
#endif
#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
- #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
+#define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
#endif
// Construct the namespace ABI tags component
-#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b
-#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \
- NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b)
+#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi##a##b
+#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b)
-#define NLOHMANN_JSON_ABI_TAGS \
- NLOHMANN_JSON_ABI_TAGS_CONCAT( \
- NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
- NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON)
+#define NLOHMANN_JSON_ABI_TAGS \
+ NLOHMANN_JSON_ABI_TAGS_CONCAT(NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
+ NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON)
// Construct the namespace version component
-#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
- _v ## major ## _ ## minor ## _ ## patch
+#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) _v##major##_##minor##_##patch
#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
- NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
+ NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
#if NLOHMANN_JSON_NAMESPACE_NO_VERSION
#define NLOHMANN_JSON_NAMESPACE_VERSION
#else
-#define NLOHMANN_JSON_NAMESPACE_VERSION \
- NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
- NLOHMANN_JSON_VERSION_MINOR, \
- NLOHMANN_JSON_VERSION_PATCH)
+#define NLOHMANN_JSON_NAMESPACE_VERSION \
+ NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, \
+ NLOHMANN_JSON_VERSION_PATCH)
#endif
// Combine namespace components
-#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
-#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
- NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
+#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a##b
+#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
#ifndef NLOHMANN_JSON_NAMESPACE
-#define NLOHMANN_JSON_NAMESPACE \
- nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
- NLOHMANN_JSON_ABI_TAGS, \
- NLOHMANN_JSON_NAMESPACE_VERSION)
+#define NLOHMANN_JSON_NAMESPACE \
+ nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT(NLOHMANN_JSON_ABI_TAGS, NLOHMANN_JSON_NAMESPACE_VERSION)
#endif
#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
-#define NLOHMANN_JSON_NAMESPACE_BEGIN \
- namespace nlohmann \
- { \
- inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
- NLOHMANN_JSON_ABI_TAGS, \
- NLOHMANN_JSON_NAMESPACE_VERSION) \
- {
+#define NLOHMANN_JSON_NAMESPACE_BEGIN \
+ namespace nlohmann { \
+ inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT(NLOHMANN_JSON_ABI_TAGS, \
+ NLOHMANN_JSON_NAMESPACE_VERSION) {
#endif
#ifndef NLOHMANN_JSON_NAMESPACE_END
-#define NLOHMANN_JSON_NAMESPACE_END \
- } /* namespace (inline namespace) NOLINT(readability/namespace) */ \
- } // namespace nlohmann
+#define NLOHMANN_JSON_NAMESPACE_END \
+ } /* namespace (inline namespace) NOLINT(readability/namespace) */ \
+ } // namespace nlohmann
#endif
-
/*!
@brief namespace for Niels Lohmann
@see https://github.com/nlohmann
@@ -132,28 +121,26 @@ This serializer ignores the template arguments and uses ADL
([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl))
for serialization.
*/
-template<typename T = void, typename SFINAE = void>
+template <typename T = void, typename SFINAE = void>
struct adl_serializer;
/// a class to store JSON values
/// @sa https://json.nlohmann.me/api/basic_json/
-template<template<typename U, typename V, typename... Args> class ObjectType =
- std::map,
- template<typename U, typename... Args> class ArrayType = std::vector,
- class StringType = std::string, class BooleanType = bool,
- class NumberIntegerType = std::int64_t,
- class NumberUnsignedType = std::uint64_t,
- class NumberFloatType = double,
- template<typename U> class AllocatorType = std::allocator,
- template<typename T, typename SFINAE = void> class JSONSerializer =
- adl_serializer,
- class BinaryType = std::vector<std::uint8_t>, // cppcheck-suppress syntaxError
- class CustomBaseClass = void>
+template <template <typename U, typename V, typename... Args> class ObjectType = std::map,
+ template <typename U, typename... Args> class ArrayType = std::vector,
+ class StringType = std::string, class BooleanType = bool,
+ class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t,
+ class NumberFloatType = double,
+ template <typename U> class AllocatorType = std::allocator,
+ template <typename T, typename SFINAE = void> class JSONSerializer = adl_serializer,
+ class BinaryType = std::vector<std::uint8_t>, // cppcheck-suppress syntaxError
+ class CustomBaseClass = void>
class basic_json;
-/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document
+/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON
+/// document
/// @sa https://json.nlohmann.me/api/json_pointer/
-template<typename RefStringType>
+template <typename RefStringType>
class json_pointer;
/*!
@@ -164,7 +151,7 @@ using json = basic_json<>;
/// @brief a minimal map-like container that preserves insertion order
/// @sa https://json.nlohmann.me/api/ordered_map/
-template<class Key, class T, class IgnoredLess, class Allocator>
+template <class Key, class T, class IgnoredLess, class Allocator>
struct ordered_map;
/// @brief specialization that maintains the insertion order of object keys