diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa3aae43e..56c26f74d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: JSON Toolkit +name: Core on: schedule: @@ -68,13 +68,13 @@ jobs: cxx: clang++ type: static shell: sh - options: -DJSONTOOLKIT_ADDRESS_SANITIZER:BOOL=ON + options: -DSOURCEMETA_CORE_ADDRESS_SANITIZER:BOOL=ON - os: ubuntu-latest cc: clang cxx: clang++ type: static shell: sh - options: -DJSONTOOLKIT_UNDEFINED_SANITIZER:BOOL=ON + options: -DSOURCEMETA_CORE_UNDEFINED_SANITIZER:BOOL=ON defaults: run: @@ -96,25 +96,25 @@ jobs: HOMEBREW_NO_ANALYTICS: 1 HOMEBREW_NO_AUTO_UPDATE: 1 - run: cmake --version - - name: Configure JSON Toolkit (static) + - name: Configure (static) if: matrix.platform.type == 'static' run: > cmake -S . -B ./build -DCMAKE_BUILD_TYPE:STRING=Release - -DJSONTOOLKIT_TESTS:BOOL=ON - -DJSONTOOLKIT_BENCHMARK:BOOL=ON - -DJSONTOOLKIT_DOCS:BOOL=OFF + -DSOURCEMETA_CORE_TESTS:BOOL=ON + -DSOURCEMETA_CORE_BENCHMARK:BOOL=ON + -DSOURCEMETA_CORE_DOCS:BOOL=OFF -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_COMPILE_WARNING_AS_ERROR:BOOL=ON ${{ matrix.platform.options }} - - name: Configure JSON Toolkit (shared) + - name: Configure (shared) if: matrix.platform.type == 'shared' run: > cmake -S . -B ./build -DCMAKE_BUILD_TYPE:STRING=Release - -DJSONTOOLKIT_TESTS:BOOL=ON - -DJSONTOOLKIT_BENCHMARK:BOOL=ON - -DJSONTOOLKIT_DOCS:BOOL=OFF + -DSOURCEMETA_CORE_TESTS:BOOL=ON + -DSOURCEMETA_CORE_BENCHMARK:BOOL=ON + -DSOURCEMETA_CORE_DOCS:BOOL=OFF -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_COMPILE_WARNING_AS_ERROR:BOOL=ON ${{ matrix.platform.options }} @@ -128,10 +128,10 @@ jobs: --component sourcemeta_noa_dev - run: > cmake --install ./build --prefix ./build/dist --config Release --verbose - --component sourcemeta_jsontoolkit + --component sourcemeta_core - run: > cmake --install ./build --prefix ./build/dist --config Release --verbose - --component sourcemeta_jsontoolkit_dev + --component sourcemeta_core_dev # Not every CTest version supports the --test-dir option. If such option # is not recognized, `ctest` will successfully exit finding no tests. diff --git a/.github/workflows/website-build.yml b/.github/workflows/website-build.yml index 726e6422b..04e180810 100644 --- a/.github/workflows/website-build.yml +++ b/.github/workflows/website-build.yml @@ -16,13 +16,13 @@ jobs: - run: > cmake -S . -B ./build -DCMAKE_BUILD_TYPE:STRING=Release - -DJSONTOOLKIT_CORE_REGEX:BOOL=OFF - -DJSONTOOLKIT_CORE_URI:BOOL=OFF - -DJSONTOOLKIT_CORE_JSON:BOOL=OFF - -DJSONTOOLKIT_CORE_JSONL:BOOL=OFF - -DJSONTOOLKIT_CORE_JSONSCHEMA:BOOL=OFF - -DJSONTOOLKIT_CORE_JSONPOINTER:BOOL=OFF - -DJSONTOOLKIT_CORE_YAML:BOOL=OFF - -DJSONTOOLKIT_EXTENSION_ALTERSCHEMA:BOOL=OFF - -DJSONTOOLKIT_DOCS:BOOL=ON + -DSOURCEMETA_CORE_REGEX:BOOL=OFF + -DSOURCEMETA_CORE_URI:BOOL=OFF + -DSOURCEMETA_CORE_JSON:BOOL=OFF + -DSOURCEMETA_CORE_JSONL:BOOL=OFF + -DSOURCEMETA_CORE_JSONSCHEMA:BOOL=OFF + -DSOURCEMETA_CORE_JSONPOINTER:BOOL=OFF + -DSOURCEMETA_CORE_YAML:BOOL=OFF + -DSOURCEMETA_CORE_EXTENSION_ALTERSCHEMA:BOOL=OFF + -DSOURCEMETA_CORE_DOCS:BOOL=ON - run: cmake --build ./build --config Release --target doxygen diff --git a/.github/workflows/website-deploy.yml b/.github/workflows/website-deploy.yml index 6de41b389..e2c9baed0 100644 --- a/.github/workflows/website-deploy.yml +++ b/.github/workflows/website-deploy.yml @@ -26,15 +26,15 @@ jobs: - run: > cmake -S . -B ./build -DCMAKE_BUILD_TYPE:STRING=Release - -DJSONTOOLKIT_CORE_REGEX:BOOL=OFF - -DJSONTOOLKIT_CORE_URI:BOOL=OFF - -DJSONTOOLKIT_CORE_JSON:BOOL=OFF - -DJSONTOOLKIT_CORE_JSONL:BOOL=OFF - -DJSONTOOLKIT_CORE_JSONSCHEMA:BOOL=OFF - -DJSONTOOLKIT_CORE_JSONPOINTER:BOOL=OFF - -DJSONTOOLKIT_CORE_YAML:BOOL=OFF - -DJSONTOOLKIT_EXTENSION_ALTERSCHEMA:BOOL=OFF - -DJSONTOOLKIT_DOCS:BOOL=ON + -DSOURCEMETA_CORE_REGEX:BOOL=OFF + -DSOURCEMETA_CORE_URI:BOOL=OFF + -DSOURCEMETA_CORE_JSON:BOOL=OFF + -DSOURCEMETA_CORE_JSONL:BOOL=OFF + -DSOURCEMETA_CORE_JSONSCHEMA:BOOL=OFF + -DSOURCEMETA_CORE_JSONPOINTER:BOOL=OFF + -DSOURCEMETA_CORE_YAML:BOOL=OFF + -DSOURCEMETA_CORE_EXTENSION_ALTERSCHEMA:BOOL=OFF + -DSOURCEMETA_CORE_DOCS:BOOL=ON - run: cmake --build ./build --config Release --target doxygen - name: Setup Pages uses: actions/configure-pages@v5 diff --git a/CMakeLists.txt b/CMakeLists.txt index debe7a444..7857f0346 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,28 +1,26 @@ cmake_minimum_required(VERSION 3.16) -project(jsontoolkit VERSION 0.0.0 LANGUAGES C CXX - DESCRIPTION "The swiss-army knife for JSON programming in C++" - HOMEPAGE_URL "https://jsontoolkit.sourcemeta.com") +project(core VERSION 0.0.0 LANGUAGES C CXX) list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") # Options -option(JSONTOOLKIT_CORE_REGEX "Build the JSON Toolkit Regex library" ON) -option(JSONTOOLKIT_CORE_URI "Build the JSON Toolkit URI library" ON) -option(JSONTOOLKIT_CORE_JSON "Build the JSON Toolkit JSON library" ON) -option(JSONTOOLKIT_CORE_JSONSCHEMA "Build the JSON Toolkit JSON Schema library" ON) -option(JSONTOOLKIT_CORE_JSONPOINTER "Build the JSON Toolkit JSON Pointer library" ON) -option(JSONTOOLKIT_CORE_JSONL "Build the JSON Toolkit JSONL library" ON) -option(JSONTOOLKIT_CORE_YAML "Build the JSON Toolkit YAML library" ON) -option(JSONTOOLKIT_EXTENSION_ALTERSCHEMA "Build the JSON Toolkit AlterSchema library" ON) -option(JSONTOOLKIT_TESTS "Build the JSON Toolkit tests" OFF) -option(JSONTOOLKIT_BENCHMARK "Build the JSON Toolkit benchmarks" OFF) -option(JSONTOOLKIT_DOCS "Build the JSON Toolkit docs" OFF) -option(JSONTOOLKIT_INSTALL "Install the JSON Toolkit library" ON) -option(JSONTOOLKIT_ADDRESS_SANITIZER "Build JSON Toolkit with an address sanitizer" OFF) -option(JSONTOOLKIT_UNDEFINED_SANITIZER "Build JSON Toolkit with an undefined behavior sanitizer" OFF) +option(SOURCEMETA_CORE_REGEX "Build the Sourcemeta Core Regex library" ON) +option(SOURCEMETA_CORE_URI "Build the Sourcemeta Core URI library" ON) +option(SOURCEMETA_CORE_JSON "Build the Sourcemeta Core JSON library" ON) +option(SOURCEMETA_CORE_JSONSCHEMA "Build the Sourcemeta Core JSON Schema library" ON) +option(SOURCEMETA_CORE_JSONPOINTER "Build the Sourcemeta Core JSON Pointer library" ON) +option(SOURCEMETA_CORE_JSONL "Build the Sourcemeta Core JSONL library" ON) +option(SOURCEMETA_CORE_YAML "Build the Sourcemeta Core YAML library" ON) +option(SOURCEMETA_CORE_EXTENSION_ALTERSCHEMA "Build the Sourcemeta Core AlterSchema library" ON) +option(SOURCEMETA_CORE_TESTS "Build the Sourcemeta Core tests" OFF) +option(SOURCEMETA_CORE_BENCHMARK "Build the Sourcemeta Core benchmarks" OFF) +option(SOURCEMETA_CORE_DOCS "Build the Sourcemeta Core docs" OFF) +option(SOURCEMETA_CORE_INSTALL "Install the Sourcemeta Core library" ON) +option(SOURCEMETA_CORE_ADDRESS_SANITIZER "Build Sourcemeta Core with an address sanitizer" OFF) +option(SOURCEMETA_CORE_UNDEFINED_SANITIZER "Build Sourcemeta Core with an undefined behavior sanitizer" OFF) find_package(Noa REQUIRED) -if(JSONTOOLKIT_INSTALL) +if(SOURCEMETA_CORE_INSTALL) include(GNUInstallDirs) include(CMakePackageConfigHelpers) configure_package_config_file( @@ -36,51 +34,51 @@ if(JSONTOOLKIT_INSTALL) "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" - COMPONENT sourcemeta_jsontoolkit_dev) + COMPONENT sourcemeta_core_dev) endif() -if(JSONTOOLKIT_CORE_REGEX) +if(SOURCEMETA_CORE_REGEX) find_package(BoostRegex REQUIRED) add_subdirectory(src/core/regex) endif() -if(JSONTOOLKIT_CORE_URI) +if(SOURCEMETA_CORE_URI) find_package(UriParser REQUIRED) add_subdirectory(src/core/uri) endif() -if(JSONTOOLKIT_CORE_JSON) +if(SOURCEMETA_CORE_JSON) add_subdirectory(src/core/json) endif() -if(JSONTOOLKIT_CORE_JSONPOINTER) +if(SOURCEMETA_CORE_JSONPOINTER) add_subdirectory(src/core/jsonpointer) endif() -if(JSONTOOLKIT_CORE_JSONSCHEMA) +if(SOURCEMETA_CORE_JSONSCHEMA) add_subdirectory(src/core/jsonschema) endif() -if(JSONTOOLKIT_CORE_JSONL) +if(SOURCEMETA_CORE_JSONL) add_subdirectory(src/core/jsonl) endif() -if(JSONTOOLKIT_CORE_YAML) +if(SOURCEMETA_CORE_YAML) find_package(yaml REQUIRED) add_subdirectory(src/core/yaml) endif() -if(JSONTOOLKIT_EXTENSION_ALTERSCHEMA) +if(SOURCEMETA_CORE_EXTENSION_ALTERSCHEMA) add_subdirectory(src/extension/alterschema) endif() -if(JSONTOOLKIT_ADDRESS_SANITIZER) +if(SOURCEMETA_CORE_ADDRESS_SANITIZER) noa_sanitizer(TYPE address) -elseif(JSONTOOLKIT_UNDEFINED_SANITIZER) +elseif(SOURCEMETA_CORE_UNDEFINED_SANITIZER) noa_sanitizer(TYPE undefined) endif() -if(JSONTOOLKIT_DOCS) +if(SOURCEMETA_CORE_DOCS) noa_target_doxygen(CONFIG "${PROJECT_SOURCE_DIR}/doxygen/Doxyfile.in" OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/website") endif() @@ -95,50 +93,50 @@ if(PROJECT_IS_TOP_LEVEL) endif() # Testing -if(JSONTOOLKIT_TESTS) +if(SOURCEMETA_CORE_TESTS) enable_testing() - if(JSONTOOLKIT_CORE_REGEX) + if(SOURCEMETA_CORE_REGEX) add_subdirectory(test/regex) endif() - if(JSONTOOLKIT_CORE_URI) + if(SOURCEMETA_CORE_URI) add_subdirectory(test/uri) endif() - if(JSONTOOLKIT_CORE_JSON) + if(SOURCEMETA_CORE_JSON) add_subdirectory(test/json) endif() - if(JSONTOOLKIT_CORE_JSONPOINTER) + if(SOURCEMETA_CORE_JSONPOINTER) add_subdirectory(test/jsonpointer) endif() - if(JSONTOOLKIT_CORE_JSONSCHEMA) + if(SOURCEMETA_CORE_JSONSCHEMA) add_subdirectory(test/jsonschema) endif() - if(JSONTOOLKIT_CORE_JSONL) + if(SOURCEMETA_CORE_JSONL) add_subdirectory(test/jsonl) endif() - if(JSONTOOLKIT_CORE_YAML) + if(SOURCEMETA_CORE_YAML) add_subdirectory(test/yaml) endif() - if(JSONTOOLKIT_EXTENSION_ALTERSCHEMA) + if(SOURCEMETA_CORE_EXTENSION_ALTERSCHEMA) add_subdirectory(test/alterschema) endif() if(PROJECT_IS_TOP_LEVEL) # Otherwise we need the child project to link # against the sanitizers too. - if(NOT JSONTOOLKIT_ADDRESS_SANITIZER AND NOT JSONTOOLKIT_UNDEFINED_SANITIZER) + if(NOT SOURCEMETA_CORE_ADDRESS_SANITIZER AND NOT SOURCEMETA_CORE_UNDEFINED_SANITIZER) add_subdirectory(test/packaging) endif() endif() - if(JSONTOOLKIT_BENCHMARK) + if(SOURCEMETA_CORE_BENCHMARK) add_subdirectory(benchmark) endif() endif() diff --git a/Makefile b/Makefile index fc40e4de9..884abc82f 100644 --- a/Makefile +++ b/Makefile @@ -12,9 +12,9 @@ configure: .always $(CMAKE) -S . -B ./build \ -DCMAKE_BUILD_TYPE:STRING=$(PRESET) \ -DCMAKE_COMPILE_WARNING_AS_ERROR:BOOL=ON \ - -DJSONTOOLKIT_TESTS:BOOL=ON \ - -DJSONTOOLKIT_BENCHMARK:BOOL=ON \ - -DJSONTOOLKIT_DOCS:BOOL=ON \ + -DSOURCEMETA_CORE_TESTS:BOOL=ON \ + -DSOURCEMETA_CORE_BENCHMARK:BOOL=ON \ + -DSOURCEMETA_CORE_DOCS:BOOL=ON \ -DBUILD_SHARED_LIBS:BOOL=$(SHARED) compile: .always @@ -25,9 +25,9 @@ compile: .always $(CMAKE) --install ./build --prefix ./build/dist --config $(PRESET) --verbose \ --component sourcemeta_noa_dev $(CMAKE) --install ./build --prefix ./build/dist --config $(PRESET) --verbose \ - --component sourcemeta_jsontoolkit + --component sourcemeta_core $(CMAKE) --install ./build --prefix ./build/dist --config $(PRESET) --verbose \ - --component sourcemeta_jsontoolkit_dev + --component sourcemeta_core_dev lint: .always $(CMAKE) --build ./build --config $(PRESET) --target clang_tidy diff --git a/README.markdown b/README.markdown index 606797235..c496a7858 100644 --- a/README.markdown +++ b/README.markdown @@ -1,43 +1,10 @@ -![JSON Toolkit](./assets/banner.png) +Sourcemeta Core +=============== -JSON Toolkit is a swiss-army knife for [JSON](https://www.json.org) programming -in modern C++. It comes with a built-in parser and growing support for -standards such as [JSON Schema](http://json-schema.org), [JSON -Pointer](https://www.rfc-editor.org/rfc/rfc6901), -[JSONL](https://jsonlines.org), and more. For example: - -```cpp -#include -#include - -#include -#include -#include -#include - -auto main() -> int { - // Parsing a JSON document from a string - auto document{sourcemeta::jsontoolkit::parse(R"JSON({ - "name": "John Doe", - "age": 20, - "address": "14 Manchester Road, Coventry CV77 1XN" - })JSON")}; - - // Updating a property using JSON Pointer - const sourcemeta::jsontoolkit::Pointer pointer{"name"}; - sourcemeta::jsontoolkit::JSON new_value{"Jane Doe"}; - sourcemeta::jsontoolkit::set(document, pointer, std::move(new_value)); - - // Pretty-print result - sourcemeta::jsontoolkit::prettify(document, std::cout); - std::cout << "\n"; - - return EXIT_SUCCESS; -} -``` +This project implements a set of foundational C++ libraries to power Sourcemeta projects. Documentation ------------- Refer to the project website for documentation: -[https://jsontoolkit.sourcemeta.com](https://jsontoolkit.sourcemeta.com). +[https://core.sourcemeta.com](https://core.sourcemeta.com). diff --git a/assets/banner.png b/assets/banner.png deleted file mode 100644 index 1f5609415..000000000 Binary files a/assets/banner.png and /dev/null differ diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index da665b3b7..7236e86b9 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -1,48 +1,48 @@ set(BENCHMARK_SOURCES) -if(JSONTOOLKIT_CORE_REGEX) +if(SOURCEMETA_CORE_REGEX) list(APPEND BENCHMARK_SOURCES regex.cc) endif() -if(JSONTOOLKIT_CORE_JSON) +if(SOURCEMETA_CORE_JSON) list(APPEND BENCHMARK_SOURCES json.cc) endif() -if(JSONTOOLKIT_CORE_JSONPOINTER) +if(SOURCEMETA_CORE_JSONPOINTER) list(APPEND BENCHMARK_SOURCES jsonpointer.cc) endif() if(BENCHMARK_SOURCES) - noa_googlebenchmark(NAMESPACE sourcemeta PROJECT jsontoolkit - FOLDER "JSON Toolkit" SOURCES ${BENCHMARK_SOURCES}) + noa_googlebenchmark(NAMESPACE sourcemeta PROJECT core + FOLDER "Core" SOURCES ${BENCHMARK_SOURCES}) - target_compile_definitions(sourcemeta_jsontoolkit_benchmark + target_compile_definitions(sourcemeta_core_benchmark PRIVATE CURRENT_DIRECTORY="${CMAKE_CURRENT_SOURCE_DIR}") - if(JSONTOOLKIT_CORE_REGEX) - target_link_libraries(sourcemeta_jsontoolkit_benchmark - PRIVATE sourcemeta::jsontoolkit::regex) + if(SOURCEMETA_CORE_REGEX) + target_link_libraries(sourcemeta_core_benchmark + PRIVATE sourcemeta::core::regex) endif() - if(JSONTOOLKIT_CORE_JSON) - target_link_libraries(sourcemeta_jsontoolkit_benchmark - PRIVATE sourcemeta::jsontoolkit::json) + if(SOURCEMETA_CORE_JSON) + target_link_libraries(sourcemeta_core_benchmark + PRIVATE sourcemeta::core::json) endif() - if(JSONTOOLKIT_CORE_JSONPOINTER) - target_link_libraries(sourcemeta_jsontoolkit_benchmark - PRIVATE sourcemeta::jsontoolkit::jsonpointer) + if(SOURCEMETA_CORE_JSONPOINTER) + target_link_libraries(sourcemeta_core_benchmark + PRIVATE sourcemeta::core::jsonpointer) endif() add_custom_target(benchmark_all - COMMAND sourcemeta_jsontoolkit_benchmark - DEPENDS sourcemeta_jsontoolkit_benchmark + COMMAND sourcemeta_core_benchmark + DEPENDS sourcemeta_core_benchmark COMMENT "Running benchmark...") add_custom_target(benchmark_json - COMMAND sourcemeta_jsontoolkit_benchmark + COMMAND sourcemeta_core_benchmark --benchmark_format=json --benchmark_out="${PROJECT_BINARY_DIR}/benchmark.json" - DEPENDS sourcemeta_jsontoolkit_benchmark + DEPENDS sourcemeta_core_benchmark COMMENT "Running benchmark...") else() add_custom_target(benchmark_all VERBATIM diff --git a/benchmark/json.cc b/benchmark/json.cc index 0eacdffe3..c3a771ad5 100644 --- a/benchmark/json.cc +++ b/benchmark/json.cc @@ -2,11 +2,11 @@ #include // assert -#include +#include static void JSON_Array_Of_Objects_Unique(benchmark::State &state) { // From Unreal Engine `uproject` files - const auto document{sourcemeta::jsontoolkit::parse(R"JSON([ + const auto document{sourcemeta::core::parse(R"JSON([ { "Enabled": true, "Name": "DDTools" }, { "Enabled": true, "Name": "VideoCore" }, { "Enabled": true, "Name": "EditorScriptingUtilities" }, @@ -86,7 +86,7 @@ static void JSON_Parse_1(benchmark::State &state) { })JSON"}; for (auto _ : state) { - auto result{sourcemeta::jsontoolkit::parse(document)}; + auto result{sourcemeta::core::parse(document)}; assert(result.is_object()); benchmark::DoNotOptimize(result); } @@ -94,7 +94,7 @@ static void JSON_Parse_1(benchmark::State &state) { static void JSON_Fast_Hash_Helm_Chart_Lock(benchmark::State &state) { // From `helm-chart-lock` - const auto document{sourcemeta::jsontoolkit::parse(R"JSON({ + const auto document{sourcemeta::core::parse(R"JSON({ "digest": "sha256:157d6244f0fac36b70be1aecfed8811037504d4e3a1060f50688e93531174040", "generated": "2021-12-23T14:00:42.29198548Z", "dependencies": [ @@ -130,7 +130,7 @@ static void JSON_Fast_Hash_Helm_Chart_Lock(benchmark::State &state) { static void JSON_Equality_Helm_Chart_Lock(benchmark::State &state) { // From `helm-chart-lock` - const auto document_1{sourcemeta::jsontoolkit::parse(R"JSON({ + const auto document_1{sourcemeta::core::parse(R"JSON({ "digest": "sha256:157d6244f0fac36b70be1aecfed8811037504d4e3a1060f50688e93531174040", "generated": "2021-12-23T14:00:42.29198548Z", "dependencies": [ @@ -157,7 +157,7 @@ static void JSON_Equality_Helm_Chart_Lock(benchmark::State &state) { ] })JSON")}; - const auto document_2{sourcemeta::jsontoolkit::parse(R"JSON({ + const auto document_2{sourcemeta::core::parse(R"JSON({ "digest": "sha256:157d6244f0fac36b70be1aecfed8811037504d4e3a1060f50688e93531174040", "generated": "2021-12-23T14:00:42.29198548Z", "dependencies": [ @@ -193,10 +193,10 @@ static void JSON_Equality_Helm_Chart_Lock(benchmark::State &state) { static void JSON_String_Equal(benchmark::State &state) { const auto length{static_cast(state.range(0))}; - sourcemeta::jsontoolkit::JSON::String string_left(length, 'x'); - sourcemeta::jsontoolkit::JSON::String string_right(length, 'x'); - const sourcemeta::jsontoolkit::JSON left{std::move(string_left)}; - const sourcemeta::jsontoolkit::JSON right{std::move(string_right)}; + sourcemeta::core::JSON::String string_left(length, 'x'); + sourcemeta::core::JSON::String string_right(length, 'x'); + const sourcemeta::core::JSON left{std::move(string_left)}; + const sourcemeta::core::JSON right{std::move(string_right)}; for (auto _ : state) { bool result = left == right; assert(result); @@ -206,10 +206,9 @@ static void JSON_String_Equal(benchmark::State &state) { static void JSON_String_Equal_Small_By_Perfect_Hash(benchmark::State &state) { const auto length{static_cast(state.range(0))}; - sourcemeta::jsontoolkit::JSON::String left(length, 'x'); - sourcemeta::jsontoolkit::JSON::String right(length, 'x'); - const sourcemeta::jsontoolkit::KeyHash - hasher; + sourcemeta::core::JSON::String left(length, 'x'); + sourcemeta::core::JSON::String right(length, 'x'); + const sourcemeta::core::KeyHash hasher; const auto hash_left{hasher(left)}; const auto hash_right{hasher(right)}; assert(hasher.is_perfect(hash_left)); @@ -224,10 +223,9 @@ static void JSON_String_Equal_Small_By_Perfect_Hash(benchmark::State &state) { static void JSON_String_Equal_Small_By_Runtime_Perfect_Hash(benchmark::State &state) { const auto length{static_cast(state.range(0))}; - sourcemeta::jsontoolkit::JSON::String left(length, 'x'); - sourcemeta::jsontoolkit::JSON::String right(length, 'x'); - const sourcemeta::jsontoolkit::KeyHash - hasher; + sourcemeta::core::JSON::String left(length, 'x'); + sourcemeta::core::JSON::String right(length, 'x'); + const sourcemeta::core::KeyHash hasher; for (auto _ : state) { const auto hash_left{hasher(left)}; const auto hash_right{hasher(right)}; @@ -241,8 +239,8 @@ JSON_String_Equal_Small_By_Runtime_Perfect_Hash(benchmark::State &state) { static void JSON_String_Fast_Hash(benchmark::State &state) { const auto length{static_cast(state.range(0))}; - sourcemeta::jsontoolkit::JSON::String value(length, 'x'); - const sourcemeta::jsontoolkit::JSON document{std::move(value)}; + sourcemeta::core::JSON::String value(length, 'x'); + const sourcemeta::core::JSON document{std::move(value)}; for (auto _ : state) { benchmark::DoNotOptimize(document.fast_hash()); } @@ -250,23 +248,21 @@ static void JSON_String_Fast_Hash(benchmark::State &state) { static void JSON_String_Key_Hash(benchmark::State &state) { const auto length{static_cast(state.range(0))}; - sourcemeta::jsontoolkit::JSON::String value(length, 'x'); - const sourcemeta::jsontoolkit::KeyHash - hasher; + sourcemeta::core::JSON::String value(length, 'x'); + const sourcemeta::core::KeyHash hasher; for (auto _ : state) { benchmark::DoNotOptimize(hasher(value)); } } static void JSON_Object_Defines_Miss_Same_Length(benchmark::State &state) { - auto document{sourcemeta::jsontoolkit::JSON::make_object()}; - document.assign("abcdefg", sourcemeta::jsontoolkit::JSON{1}); - document.assign("abcdefgh", sourcemeta::jsontoolkit::JSON{2}); - document.assign("abcdefghi", sourcemeta::jsontoolkit::JSON{3}); - const sourcemeta::jsontoolkit::KeyHash - hasher; + auto document{sourcemeta::core::JSON::make_object()}; + document.assign("abcdefg", sourcemeta::core::JSON{1}); + document.assign("abcdefgh", sourcemeta::core::JSON{2}); + document.assign("abcdefghi", sourcemeta::core::JSON{3}); + const sourcemeta::core::KeyHash hasher; const auto &object{document.as_object()}; - const sourcemeta::jsontoolkit::JSON::String key{"foobarbaz"}; + const sourcemeta::core::JSON::String key{"foobarbaz"}; const auto key_hash{hasher(key)}; for (auto _ : state) { auto result = object.defines(key, key_hash); @@ -276,14 +272,13 @@ static void JSON_Object_Defines_Miss_Same_Length(benchmark::State &state) { } static void JSON_Object_Defines_Miss_Too_Small(benchmark::State &state) { - auto document{sourcemeta::jsontoolkit::JSON::make_object()}; - document.assign("abcdefg", sourcemeta::jsontoolkit::JSON{1}); - document.assign("abcdefgh", sourcemeta::jsontoolkit::JSON{2}); - document.assign("abcdefghi", sourcemeta::jsontoolkit::JSON{3}); - const sourcemeta::jsontoolkit::KeyHash - hasher; + auto document{sourcemeta::core::JSON::make_object()}; + document.assign("abcdefg", sourcemeta::core::JSON{1}); + document.assign("abcdefgh", sourcemeta::core::JSON{2}); + document.assign("abcdefghi", sourcemeta::core::JSON{3}); + const sourcemeta::core::KeyHash hasher; const auto &object{document.as_object()}; - const sourcemeta::jsontoolkit::JSON::String key{"foo"}; + const sourcemeta::core::JSON::String key{"foo"}; const auto key_hash{hasher(key)}; for (auto _ : state) { auto result = object.defines(key, key_hash); @@ -293,14 +288,13 @@ static void JSON_Object_Defines_Miss_Too_Small(benchmark::State &state) { } static void JSON_Object_Defines_Miss_Too_Large(benchmark::State &state) { - auto document{sourcemeta::jsontoolkit::JSON::make_object()}; - document.assign("abcdefg", sourcemeta::jsontoolkit::JSON{1}); - document.assign("abcdefgh", sourcemeta::jsontoolkit::JSON{2}); - document.assign("abcdefghi", sourcemeta::jsontoolkit::JSON{3}); - const sourcemeta::jsontoolkit::KeyHash - hasher; + auto document{sourcemeta::core::JSON::make_object()}; + document.assign("abcdefg", sourcemeta::core::JSON{1}); + document.assign("abcdefgh", sourcemeta::core::JSON{2}); + document.assign("abcdefghi", sourcemeta::core::JSON{3}); + const sourcemeta::core::KeyHash hasher; const auto &object{document.as_object()}; - const sourcemeta::jsontoolkit::JSON::String key{"toolargestring"}; + const sourcemeta::core::JSON::String key{"toolargestring"}; const auto key_hash{hasher(key)}; for (auto _ : state) { auto result = object.defines(key, key_hash); diff --git a/benchmark/jsonpointer.cc b/benchmark/jsonpointer.cc index d27e2556d..eb1297486 100644 --- a/benchmark/jsonpointer.cc +++ b/benchmark/jsonpointer.cc @@ -2,11 +2,11 @@ #include // assert -#include -#include +#include +#include static void Pointer_Object_Traverse(benchmark::State &state) { - const auto document{sourcemeta::jsontoolkit::parse(R"JSON({ + const auto document{sourcemeta::core::parse(R"JSON({ "one": { "two": { "three": { @@ -28,12 +28,12 @@ static void Pointer_Object_Traverse(benchmark::State &state) { } })JSON")}; - const sourcemeta::jsontoolkit::Pointer pointer{ - "one", "two", "three", "four", "five", - "six", "seven", "eight", "nine", "ten"}; + const sourcemeta::core::Pointer pointer{"one", "two", "three", "four", + "five", "six", "seven", "eight", + "nine", "ten"}; for (auto _ : state) { - auto result{sourcemeta::jsontoolkit::get(document, pointer)}; + auto result{sourcemeta::core::get(document, pointer)}; assert(result.is_boolean()); assert(result.to_boolean()); benchmark::DoNotOptimize(result); @@ -41,7 +41,7 @@ static void Pointer_Object_Traverse(benchmark::State &state) { } static void Pointer_Object_Try_Traverse(benchmark::State &state) { - const auto document{sourcemeta::jsontoolkit::parse(R"JSON({ + const auto document{sourcemeta::core::parse(R"JSON({ "one": { "two": { "three": { @@ -63,12 +63,12 @@ static void Pointer_Object_Try_Traverse(benchmark::State &state) { } })JSON")}; - const sourcemeta::jsontoolkit::Pointer pointer{ - "one", "two", "three", "four", "five", - "six", "seven", "eight", "nine", "ten"}; + const sourcemeta::core::Pointer pointer{"one", "two", "three", "four", + "five", "six", "seven", "eight", + "nine", "ten"}; for (auto _ : state) { - auto result{sourcemeta::jsontoolkit::try_get(document, pointer)}; + auto result{sourcemeta::core::try_get(document, pointer)}; assert(result); assert(result->is_boolean()); assert(result->to_boolean()); @@ -77,70 +77,70 @@ static void Pointer_Object_Try_Traverse(benchmark::State &state) { } static void Pointer_Push_Back_Pointer_To_Weak_Pointer(benchmark::State &state) { - const sourcemeta::jsontoolkit::Pointer pointer{"QG5", - "hzh4HOy0CDatvDds", - "A2Fmfu3", - "SsDf", - "IWKDjcbspyIi", - "ShnIIXXJ16rJqU", - "kr20Vl0fTl", - "k86GNqPRqYcrshgW", - "MZasv", - "mu12raEM0", - "ERmTaob", - "N4051TZZgmHJxw0kA2", - "JyYLja7uU4rGiPnO0HaF", - "z39HymGubGiCkAj", - "pBTXBPoibBe", - "jO6qKBYc", - "RSYx", - "v5qyRqbc0t1Stb5", - "cNSajmQSUeImEznA", - "86R5NCY4bGJBB", - "7NGrw3bVRH", - "USCmFPlMHJ1bZWi", - "Er9UMJ6yL8ny1x3qj1c", - "260JkYXaCtfYo0QC", - "SPtyuBHw", - "O6QI5wHP1", - "1iDJs1u5i", - "onYiosjbLHA6QuiNidB", - "cetyYrbEvZ", - "KAWwqfXHPMtL", - "NvzaQYhMBmad", - "B68v67OylYcwROoaZxb", - "aG9u12vgak", - "5thqNjai", - "bIOCVt3JEZO2", - "rVZLu42FBk", - "Wjm", - "z23mpKaOHDU7utfy9euC", - "2k9DYyIr4uQKSUfKPV", - "53ITE3Rxdsy862S", - "7NR", - "ByKyUzTz1uLQOt", - "ReSknCy", - "VbD8", - "fHugvDUJe", - "japh5", - "6rhjhRDxhd", - "Q7sX8", - "VtFTA5YnQhbAPhxbdi", - "BuY1vG92USX0Y6NvEGcf", - "y4fs5dRPK", - "5iz39wrHyeQQHb1", - "4GrQCWp74AnBSL9", - "m6KK", - "6buqIqqDVJwu", - "4FSzmT06", - "2CUY", - "f1P3LTAP", - "hlFnm", - "Q6OQxzHNwZsSpM0Fib", - "ltLJ5HS1fUXQIIE"}; + const sourcemeta::core::Pointer pointer{"QG5", + "hzh4HOy0CDatvDds", + "A2Fmfu3", + "SsDf", + "IWKDjcbspyIi", + "ShnIIXXJ16rJqU", + "kr20Vl0fTl", + "k86GNqPRqYcrshgW", + "MZasv", + "mu12raEM0", + "ERmTaob", + "N4051TZZgmHJxw0kA2", + "JyYLja7uU4rGiPnO0HaF", + "z39HymGubGiCkAj", + "pBTXBPoibBe", + "jO6qKBYc", + "RSYx", + "v5qyRqbc0t1Stb5", + "cNSajmQSUeImEznA", + "86R5NCY4bGJBB", + "7NGrw3bVRH", + "USCmFPlMHJ1bZWi", + "Er9UMJ6yL8ny1x3qj1c", + "260JkYXaCtfYo0QC", + "SPtyuBHw", + "O6QI5wHP1", + "1iDJs1u5i", + "onYiosjbLHA6QuiNidB", + "cetyYrbEvZ", + "KAWwqfXHPMtL", + "NvzaQYhMBmad", + "B68v67OylYcwROoaZxb", + "aG9u12vgak", + "5thqNjai", + "bIOCVt3JEZO2", + "rVZLu42FBk", + "Wjm", + "z23mpKaOHDU7utfy9euC", + "2k9DYyIr4uQKSUfKPV", + "53ITE3Rxdsy862S", + "7NR", + "ByKyUzTz1uLQOt", + "ReSknCy", + "VbD8", + "fHugvDUJe", + "japh5", + "6rhjhRDxhd", + "Q7sX8", + "VtFTA5YnQhbAPhxbdi", + "BuY1vG92USX0Y6NvEGcf", + "y4fs5dRPK", + "5iz39wrHyeQQHb1", + "4GrQCWp74AnBSL9", + "m6KK", + "6buqIqqDVJwu", + "4FSzmT06", + "2CUY", + "f1P3LTAP", + "hlFnm", + "Q6OQxzHNwZsSpM0Fib", + "ltLJ5HS1fUXQIIE"}; for (auto _ : state) { - sourcemeta::jsontoolkit::WeakPointer destination; + sourcemeta::core::WeakPointer destination; destination.push_back(pointer); assert(destination.size() == pointer.size()); benchmark::DoNotOptimize(destination); diff --git a/benchmark/regex.cc b/benchmark/regex.cc index da0cb0e70..e9db7df2f 100644 --- a/benchmark/regex.cc +++ b/benchmark/regex.cc @@ -3,15 +3,15 @@ #include // assert #include // std::string -#include +#include #define BENCHMARK_REGEX(name, pattern, input) \ static void name(benchmark::State &state) { \ - const auto regex{sourcemeta::jsontoolkit::to_regex(pattern)}; \ + const auto regex{sourcemeta::core::to_regex(pattern)}; \ assert(regex.has_value()); \ for (auto _ : state) { \ - auto result{sourcemeta::jsontoolkit::matches(regex.value(), \ - input)}; \ + auto result{ \ + sourcemeta::core::matches(regex.value(), input)}; \ assert(result); \ benchmark::DoNotOptimize(result); \ } \ diff --git a/cmake/FindBoostRegex.cmake b/cmake/FindBoostRegex.cmake index ff096693f..ebdc5e8a0 100644 --- a/cmake/FindBoostRegex.cmake +++ b/cmake/FindBoostRegex.cmake @@ -124,7 +124,7 @@ if(NOT BoostRegex_FOUND) target_compile_definitions(boost_regex INTERFACE BOOST_REGEX_STANDALONE) - if(JSONTOOLKIT_UNDEFINED_SANITIZER AND NOA_COMPILER_LLVM) + if(SOURCEMETA_CORE_UNDEFINED_SANITIZER AND NOA_COMPILER_LLVM) # Boost Regex doesn't pass the LLVM Undefined Behavior sanitizer otherwise # vendor/boost-regex/include/boost/regex/v5/cpp_regex_traits.hpp:1022:60: # runtime error: implicit conversion from type 'unsigned char' of value 128 @@ -146,39 +146,39 @@ if(NOT BoostRegex_FOUND) PRIVATE_HEADER "${BOOST_REGEX_PRIVATE_HEADERS}" EXPORT_NAME boost_regex) - if(JSONTOOLKIT_INSTALL) + if(SOURCEMETA_CORE_INSTALL) include(GNUInstallDirs) install(TARGETS boost_regex EXPORT boost_regex PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/boost" - COMPONENT sourcemeta_jsontoolkit + COMPONENT sourcemeta_core PRIVATE_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/boost" - COMPONENT sourcemeta_jsontoolkit + COMPONENT sourcemeta_core RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" - COMPONENT sourcemeta_jsontoolkit + COMPONENT sourcemeta_core LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - COMPONENT sourcemeta_jsontoolkit - NAMELINK_COMPONENT sourcemeta_jsontoolkit_dev + COMPONENT sourcemeta_core + NAMELINK_COMPONENT sourcemeta_core_dev ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" - COMPONENT sourcemeta_jsontoolkit_dev) + COMPONENT sourcemeta_core_dev) install(FILES ${BOOST_REGEX_PRIVATE_HEADERS_REGEX} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/boost/regex" - COMPONENT sourcemeta_jsontoolkit) + COMPONENT sourcemeta_core) install(FILES ${BOOST_REGEX_PRIVATE_HEADERS_REGEX_CONFIG} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/boost/regex/config" - COMPONENT sourcemeta_jsontoolkit) + COMPONENT sourcemeta_core) install(FILES ${BOOST_REGEX_PRIVATE_HEADERS_REGEX_PENDING} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/boost/regex/pending" - COMPONENT sourcemeta_jsontoolkit) + COMPONENT sourcemeta_core) install(FILES ${BOOST_REGEX_PRIVATE_HEADERS_REGEX_V4} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/boost/regex/v4" - COMPONENT sourcemeta_jsontoolkit) + COMPONENT sourcemeta_core) install(FILES ${BOOST_REGEX_PRIVATE_HEADERS_REGEX_V5} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/boost/regex/v5" - COMPONENT sourcemeta_jsontoolkit) + COMPONENT sourcemeta_core) install(EXPORT boost_regex DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/boostregex" - COMPONENT sourcemeta_jsontoolkit_dev) + COMPONENT sourcemeta_core_dev) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/boostregex-config.cmake "include(\"\${CMAKE_CURRENT_LIST_DIR}/boost_regex.cmake\")\n" @@ -186,7 +186,7 @@ if(NOT BoostRegex_FOUND) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/boostregex-config.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/boostregex" - COMPONENT sourcemeta_jsontoolkit_dev) + COMPONENT sourcemeta_core_dev) endif() set(BoostRegex_FOUND ON) diff --git a/cmake/FindNoa.cmake b/cmake/FindNoa.cmake index 57eef05cf..ff709a9dd 100644 --- a/cmake/FindNoa.cmake +++ b/cmake/FindNoa.cmake @@ -1,12 +1,12 @@ if(NOT Noa_FOUND) - if(JSONTOOLKIT_INSTALL) + if(SOURCEMETA_CORE_INSTALL) set(NOA_INSTALL ON CACHE BOOL "enable Noa installation") else() set(NOA_INSTALL OFF CACHE BOOL "disable Noa installation") endif() - set(NOA_GOOGLETEST ${JSONTOOLKIT_TESTS} CACHE BOOL "GoogleTest") - set(NOA_GOOGLEBENCHMARK ${JSONTOOLKIT_BENCHMARK} CACHE BOOL "GoogleBenchmark") + set(NOA_GOOGLETEST ${SOURCEMETA_CORE_TESTS} CACHE BOOL "GoogleTest") + set(NOA_GOOGLEBENCHMARK ${SOURCEMETA_CORE_BENCHMARK} CACHE BOOL "GoogleBenchmark") add_subdirectory("${PROJECT_SOURCE_DIR}/vendor/noa") include("${PROJECT_SOURCE_DIR}/vendor/noa/cmake/noa.cmake") set(Noa_FOUND ON) diff --git a/cmake/FindUriParser.cmake b/cmake/FindUriParser.cmake index 0468e3583..ac6c183b0 100644 --- a/cmake/FindUriParser.cmake +++ b/cmake/FindUriParser.cmake @@ -60,25 +60,25 @@ if(NOT UriParser_FOUND) PRIVATE_HEADER "${URIPARSER_PRIVATE_HEADERS}" EXPORT_NAME uriparser) - if(JSONTOOLKIT_INSTALL) + if(SOURCEMETA_CORE_INSTALL) include(GNUInstallDirs) install(TARGETS uriparser EXPORT uriparser PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/uriparser" - COMPONENT sourcemeta_jsontoolkit_dev + COMPONENT sourcemeta_core_dev PRIVATE_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/uriparser" - COMPONENT sourcemeta_jsontoolkit_dev + COMPONENT sourcemeta_core_dev RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" - COMPONENT sourcemeta_jsontoolkit + COMPONENT sourcemeta_core LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - COMPONENT sourcemeta_jsontoolkit - NAMELINK_COMPONENT sourcemeta_jsontoolkit_dev + COMPONENT sourcemeta_core + NAMELINK_COMPONENT sourcemeta_core_dev ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" - COMPONENT sourcemeta_jsontoolkit_dev) + COMPONENT sourcemeta_core_dev) install(EXPORT uriparser DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/uriparser" NAMESPACE uriparser:: - COMPONENT sourcemeta_jsontoolkit_dev) + COMPONENT sourcemeta_core_dev) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/uriparser-config.cmake "include(\"\${CMAKE_CURRENT_LIST_DIR}/uriparser.cmake\")\n" @@ -86,7 +86,7 @@ if(NOT UriParser_FOUND) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/uriparser-config.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/uriparser" - COMPONENT sourcemeta_jsontoolkit_dev) + COMPONENT sourcemeta_core_dev) endif() set(UriParser_FOUND ON) diff --git a/cmake/Findyaml.cmake b/cmake/Findyaml.cmake index 10918c089..c4cb2cf83 100644 --- a/cmake/Findyaml.cmake +++ b/cmake/Findyaml.cmake @@ -50,23 +50,23 @@ if(NOT Yaml_FOUND) C_VISIBILITY_INLINES_HIDDEN FALSE EXPORT_NAME yaml) - if(JSONTOOLKIT_INSTALL) + if(SOURCEMETA_CORE_INSTALL) include(GNUInstallDirs) install(TARGETS yaml EXPORT yaml PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" - COMPONENT sourcemeta_jsontoolkit_dev + COMPONENT sourcemeta_core_dev RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" - COMPONENT sourcemeta_jsontoolkit + COMPONENT sourcemeta_core LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - COMPONENT sourcemeta_jsontoolkit - NAMELINK_COMPONENT sourcemeta_jsontoolkit_dev + COMPONENT sourcemeta_core + NAMELINK_COMPONENT sourcemeta_core_dev ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" - COMPONENT sourcemeta_jsontoolkit_dev) + COMPONENT sourcemeta_core_dev) install(EXPORT yaml DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/yaml" NAMESPACE yaml:: - COMPONENT sourcemeta_jsontoolkit_dev) + COMPONENT sourcemeta_core_dev) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/yaml-config.cmake "include(\"\${CMAKE_CURRENT_LIST_DIR}/yaml.cmake\")\n" @@ -74,7 +74,7 @@ if(NOT Yaml_FOUND) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/yaml-config.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/yaml" - COMPONENT sourcemeta_jsontoolkit_dev) + COMPONENT sourcemeta_core_dev) endif() set(Yaml_FOUND ON) diff --git a/config.cmake.in b/config.cmake.in index 7071a6424..7d6809b46 100644 --- a/config.cmake.in +++ b/config.cmake.in @@ -1,58 +1,58 @@ @PACKAGE_INIT@ # Support both casing styles -list(APPEND JSONTOOLKIT_COMPONENTS ${JSONToolkit_FIND_COMPONENTS}) -list(APPEND JSONTOOLKIT_COMPONENTS ${jsontoolkit_FIND_COMPONENTS}) -if(NOT JSONTOOLKIT_COMPONENTS) - list(APPEND JSONTOOLKIT_COMPONENTS regex) - list(APPEND JSONTOOLKIT_COMPONENTS uri) - list(APPEND JSONTOOLKIT_COMPONENTS json) - list(APPEND JSONTOOLKIT_COMPONENTS jsonl) - list(APPEND JSONTOOLKIT_COMPONENTS jsonpointer) - list(APPEND JSONTOOLKIT_COMPONENTS jsonschema) - list(APPEND JSONTOOLKIT_COMPONENTS yaml) - list(APPEND JSONTOOLKIT_COMPONENTS alterschema) +list(APPEND SOURCEMETA_CORE_COMPONENTS ${Core_FIND_COMPONENTS}) +list(APPEND SOURCEMETA_CORE_COMPONENTS ${core_FIND_COMPONENTS}) +if(NOT SOURCEMETA_CORE_COMPONENTS) + list(APPEND SOURCEMETA_CORE_COMPONENTS regex) + list(APPEND SOURCEMETA_CORE_COMPONENTS uri) + list(APPEND SOURCEMETA_CORE_COMPONENTS json) + list(APPEND SOURCEMETA_CORE_COMPONENTS jsonl) + list(APPEND SOURCEMETA_CORE_COMPONENTS jsonpointer) + list(APPEND SOURCEMETA_CORE_COMPONENTS jsonschema) + list(APPEND SOURCEMETA_CORE_COMPONENTS yaml) + list(APPEND SOURCEMETA_CORE_COMPONENTS alterschema) endif() include(CMakeFindDependencyMacro) -foreach(component ${JSONTOOLKIT_COMPONENTS}) +foreach(component ${SOURCEMETA_CORE_COMPONENTS}) if(component STREQUAL "regex") find_dependency(BoostRegex) - include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_jsontoolkit_regex.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_regex.cmake") elseif(component STREQUAL "uri") find_dependency(uriparser) - include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_jsontoolkit_uri.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_uri.cmake") elseif(component STREQUAL "json") find_dependency(noa) - include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_jsontoolkit_json.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_json.cmake") elseif(component STREQUAL "jsonl") - include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_jsontoolkit_json.cmake") - include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_jsontoolkit_jsonl.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_json.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_jsonl.cmake") elseif(component STREQUAL "jsonpointer") find_dependency(uriparser) - include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_jsontoolkit_uri.cmake") - include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_jsontoolkit_json.cmake") - include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_jsontoolkit_jsonpointer.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_uri.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_json.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_jsonpointer.cmake") elseif(component STREQUAL "jsonschema") find_dependency(uriparser) - include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_jsontoolkit_uri.cmake") - include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_jsontoolkit_json.cmake") - include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_jsontoolkit_jsonpointer.cmake") - include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_jsontoolkit_jsonschema.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_uri.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_json.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_jsonpointer.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_jsonschema.cmake") elseif(component STREQUAL "yaml") - include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_jsontoolkit_json.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_json.cmake") find_dependency(yaml) - include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_jsontoolkit_yaml.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_yaml.cmake") elseif(component STREQUAL "alterschema") find_dependency(uriparser) - include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_jsontoolkit_uri.cmake") - include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_jsontoolkit_json.cmake") - include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_jsontoolkit_jsonpointer.cmake") - include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_jsontoolkit_jsonschema.cmake") - include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_jsontoolkit_alterschema.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_uri.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_json.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_jsonpointer.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_jsonschema.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_alterschema.cmake") else() - message(FATAL_ERROR "Unknown JSON Toolkit component: ${component}") + message(FATAL_ERROR "Unknown Sourcemeta Core component: ${component}") endif() endforeach() diff --git a/doxygen/Doxyfile.in b/doxygen/Doxyfile.in index 11463c724..26b8db044 100644 --- a/doxygen/Doxyfile.in +++ b/doxygen/Doxyfile.in @@ -42,7 +42,7 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = JSON Toolkit +PROJECT_NAME = Sourcemeta Core # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version @@ -2309,12 +2309,6 @@ INCLUDE_FILE_PATTERNS = # recursively expanded use the := operator instead of the = operator. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -PREDEFINED += SOURCEMETA_JSONTOOLKIT_URI_EXPORT= -PREDEFINED += SOURCEMETA_JSONTOOLKIT_JSON_EXPORT= -PREDEFINED += SOURCEMETA_JSONTOOLKIT_JSONL_EXPORT= -PREDEFINED += SOURCEMETA_JSONTOOLKIT_JSONPOINTER_EXPORT= -PREDEFINED += SOURCEMETA_JSONTOOLKIT_JSONSCHEMA_EXPORT= -PREDEFINED += SOURCEMETA_JSONTOOLKIT_YAML_EXPORT= PREDEFINED += DOXYGEN # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this @@ -2324,12 +2318,7 @@ PREDEFINED += DOXYGEN # definition found in the source code. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_AS_DEFINED += SOURCEMETA_JSONTOOLKIT_URI_EXPORT -EXPAND_AS_DEFINED += SOURCEMETA_JSONTOOLKIT_JSON_EXPORT -EXPAND_AS_DEFINED += SOURCEMETA_JSONTOOLKIT_JSONL_EXPORT -EXPAND_AS_DEFINED += SOURCEMETA_JSONTOOLKIT_JSONPOINTER_EXPORT -EXPAND_AS_DEFINED += SOURCEMETA_JSONTOOLKIT_JSONSCHEMA_EXPORT -EXPAND_AS_DEFINED += SOURCEMETA_JSONTOOLKIT_YAML_EXPORT +EXPAND_AS_DEFINED += # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will # remove all references to function-like macros that are alone on a line, have diff --git a/doxygen/index.markdown b/doxygen/index.markdown index 8b5fcb0c4..806f15eb1 100644 --- a/doxygen/index.markdown +++ b/doxygen/index.markdown @@ -3,13 +3,8 @@ Getting Started @tableofcontents -JSON Toolkit is a swiss-army knife for [JSON](https://www.json.org) programming -in modern C++. It comes with a built-in parser and growing support for -standards such as [JSON Schema](http://json-schema.org), [JSON -Pointer](https://www.rfc-editor.org/rfc/rfc6901), -[JSONL](https://jsonlines.org), and more. It targets C++20 and supports the -Clang, GCC, and MSVC compilers on macOS, GNU/Linux, FreeBSD, Windows, and -Unikraft (through the ELF loader). +This project implements a set of foundational C++ libraries to power Sourcemeta +projects. Live at head ------------ @@ -25,17 +20,17 @@ Installation ### As a git submodule ```sh -# Add the project as a submodule, in this case to deps/jsontoolkit -$ git submodule add https://github.com/sourcemeta/jsontoolkit.git deps/jsontoolkit +# Add the project as a submodule, in this case to deps/core +$ git submodule add https://github.com/sourcemeta/core.git deps/core # Add the project as a CMake subdirectory -add_subdirectory("${PROJECT_SOURCE_DIR}/deps/jsontoolkit") +add_subdirectory("${PROJECT_SOURCE_DIR}/deps/core") # Link your targets accordingly -target_link_libraries(my_executable_or_library PUBLIC sourcemeta::jsontoolkit::json) -target_link_libraries(my_executable_or_library PUBLIC sourcemeta::jsontoolkit::jsonschema) -target_link_libraries(my_executable_or_library PUBLIC sourcemeta::jsontoolkit::jsonpointer) -target_link_libraries(my_executable_or_library PUBLIC sourcemeta::jsontoolkit::jsonl) +target_link_libraries(my_executable_or_library PUBLIC sourcemeta::core::json) +target_link_libraries(my_executable_or_library PUBLIC sourcemeta::core::jsonschema) +target_link_libraries(my_executable_or_library PUBLIC sourcemeta::core::jsonpointer) +target_link_libraries(my_executable_or_library PUBLIC sourcemeta::core::jsonl) ``` ### Using FetchContent @@ -47,34 +42,34 @@ set(CMAKE_CXX_STANDARD 20) include(FetchContent) FetchContent_Declare( - jsontoolkit - URL https://github.com/sourcemeta/jsontoolkit/archive/.zip + core + URL https://github.com/sourcemeta/core/archive/.zip DOWNLOAD_EXTRACT_TIMESTAMP NO) -FetchContent_MakeAvailable(jsontoolkit) +FetchContent_MakeAvailable(core) add_executable(my_example ...) -target_link_libraries(my_example PUBLIC sourcemeta::jsontoolkit::json) -target_link_libraries(my_example PUBLIC sourcemeta::jsontoolkit::jsonschema) -target_link_libraries(my_example PUBLIC sourcemeta::jsontoolkit::jsonpointer) -target_link_libraries(my_example PUBLIC sourcemeta::jsontoolkit::jsonl) +target_link_libraries(my_example PUBLIC sourcemeta::core::json) +target_link_libraries(my_example PUBLIC sourcemeta::core::jsonschema) +target_link_libraries(my_example PUBLIC sourcemeta::core::jsonpointer) +target_link_libraries(my_example PUBLIC sourcemeta::core::jsonl) ``` ### Using find_package -Assuming you have installed JSON Toolkit in a place where CMake can find the +Assuming you have installed Sourcemeta Core in a place where CMake can find the package config file: ```sh -find_package(JSONToolkit REQUIRED) +find_package(Core REQUIRED) # This package also supports component-based inclusion -find_package(JSONToolkit REQUIRED COMPONENTS json jsonschema jsonpointer jsonl) +find_package(Core REQUIRED COMPONENTS json jsonschema jsonpointer jsonl) # Link your targets accordingly -target_link_libraries(my_executable_or_library PUBLIC sourcemeta::jsontoolkit::json) -target_link_libraries(my_executable_or_library PUBLIC sourcemeta::jsontoolkit::jsonschema) -target_link_libraries(my_executable_or_library PUBLIC sourcemeta::jsontoolkit::jsonpointer) -target_link_libraries(my_executable_or_library PUBLIC sourcemeta::jsontoolkit::jsonl) +target_link_libraries(my_executable_or_library PUBLIC sourcemeta::core::json) +target_link_libraries(my_executable_or_library PUBLIC sourcemeta::core::jsonschema) +target_link_libraries(my_executable_or_library PUBLIC sourcemeta::core::jsonpointer) +target_link_libraries(my_executable_or_library PUBLIC sourcemeta::core::jsonl) ``` CMake @@ -83,18 +78,18 @@ CMake ### Options Check the top-level -[`CMakeLists.txt`](https://github.com/sourcemeta/jsontoolkit/blob/main/CMakeLists.txt) +[`CMakeLists.txt`](https://github.com/sourcemeta/core/blob/main/CMakeLists.txt) for the available CMake options. ### Components -If you install JSON Toolkit from source, keep in mind that the project is split +If you install Sourcemeta Core from source, keep in mind that the project is split into a set of CMake components: -| Component | Description | -|----------------------------------|------------------------------------------------| -| `sourcemeta_jsontoolkit` | The core JSON Toolkit libraries | -| `sourcemeta_jsontoolkit_dev` | The JSON Toolkit headers and development files | +| Component | Description | +|-----------------------|---------------------------------------------------| +| `sourcemeta_core` | The Sourcemeta Core libraries | +| `sourcemeta_core_dev` | The Sourcemeta Core headers and development files | Contributing ------------ diff --git a/src/core/json/CMakeLists.txt b/src/core/json/CMakeLists.txt index bffa672f1..64ce9b0bc 100644 --- a/src/core/json/CMakeLists.txt +++ b/src/core/json/CMakeLists.txt @@ -1,11 +1,11 @@ -noa_library(NAMESPACE sourcemeta PROJECT jsontoolkit NAME json - FOLDER "JSON Toolkit/JSON" +noa_library(NAMESPACE sourcemeta PROJECT core NAME json + FOLDER "Core/JSON" PRIVATE_HEADERS array.h error.h object.h value.h hash.h SOURCES grammar.h parser.h stringify.h json.cc json_value.cc) -if(JSONTOOLKIT_INSTALL) - noa_library_install(NAMESPACE sourcemeta PROJECT jsontoolkit NAME json) +if(SOURCEMETA_CORE_INSTALL) + noa_library_install(NAMESPACE sourcemeta PROJECT core NAME json) endif() -target_link_libraries(sourcemeta_jsontoolkit_json +target_link_libraries(sourcemeta_core_json PUBLIC sourcemeta::noa::flat_map) diff --git a/src/core/json/grammar.h b/src/core/json/grammar.h index 745330608..093df10cf 100644 --- a/src/core/json/grammar.h +++ b/src/core/json/grammar.h @@ -1,9 +1,9 @@ -#ifndef SOURCEMETA_JSONTOOLKIT_JSON_GRAMMAR_H_ -#define SOURCEMETA_JSONTOOLKIT_JSON_GRAMMAR_H_ +#ifndef SOURCEMETA_CORE_JSON_GRAMMAR_H_ +#define SOURCEMETA_CORE_JSON_GRAMMAR_H_ #include // std::basic_string_view -namespace sourcemeta::jsontoolkit::internal { +namespace sourcemeta::core::internal { // The six structural tokens: // [ U+005B left square bracket @@ -124,6 +124,6 @@ static constexpr CharT token_whitespace_carriage_return{'\u000D'}; template static constexpr CharT token_whitespace_space{'\u0020'}; -} // namespace sourcemeta::jsontoolkit::internal +} // namespace sourcemeta::core::internal #endif diff --git a/src/core/json/include/sourcemeta/jsontoolkit/json.h b/src/core/json/include/sourcemeta/core/json.h similarity index 65% rename from src/core/json/include/sourcemeta/jsontoolkit/json.h rename to src/core/json/include/sourcemeta/core/json.h index eaa23eb34..40e48b5be 100644 --- a/src/core/json/include/sourcemeta/jsontoolkit/json.h +++ b/src/core/json/include/sourcemeta/core/json.h @@ -1,13 +1,13 @@ -#ifndef SOURCEMETA_JSONTOOLKIT_JSON_H_ -#define SOURCEMETA_JSONTOOLKIT_JSON_H_ +#ifndef SOURCEMETA_CORE_JSON_H_ +#define SOURCEMETA_CORE_JSON_H_ -#ifndef SOURCEMETA_JSONTOOLKIT_JSON_EXPORT -#include +#ifndef SOURCEMETA_CORE_JSON_EXPORT +#include #endif -#include -#include -#include +#include +#include +#include #include // std::uint64_t #include // std::filesystem @@ -24,10 +24,10 @@ /// This functionality is included as follows: /// /// ```cpp -/// #include +/// #include /// ``` -namespace sourcemeta::jsontoolkit { +namespace sourcemeta::core { /// @ingroup json using Hash = FastHash; @@ -51,18 +51,18 @@ using Callback = std::function +/// #include /// #include /// #include /// /// std::istringstream stream{"[ 1, 2, 3 ]"}; -/// const sourcemeta::jsontoolkit::JSON document = -/// sourcemeta::jsontoolkit::parse(stream); +/// const sourcemeta::core::JSON document = +/// sourcemeta::core::parse(stream); /// assert(document.is_array()); /// ``` /// -/// If parsing fails, sourcemeta::jsontoolkit::ParseError will be thrown. -SOURCEMETA_JSONTOOLKIT_JSON_EXPORT +/// If parsing fails, sourcemeta::core::ParseError will be thrown. +SOURCEMETA_CORE_JSON_EXPORT auto parse(std::basic_istream &stream, const Callback &callback = nullptr) -> JSON; @@ -72,16 +72,16 @@ auto parse(std::basic_istream &stream, /// represents an array can be parsed as follows: /// /// ```cpp -/// #include +/// #include /// #include /// -/// const sourcemeta::jsontoolkit::JSON document = -/// sourcemeta::jsontoolkit::parse("[ 1, 2, 3 ]"); +/// const sourcemeta::core::JSON document = +/// sourcemeta::core::parse("[ 1, 2, 3 ]"); /// assert(document.is_array()); /// ``` /// -/// If parsing fails, sourcemeta::jsontoolkit::ParseError will be thrown. -SOURCEMETA_JSONTOOLKIT_JSON_EXPORT +/// If parsing fails, sourcemeta::core::ParseError will be thrown. +SOURCEMETA_CORE_JSON_EXPORT auto parse(const std::basic_string &input, const Callback &callback = nullptr) -> JSON; @@ -91,18 +91,18 @@ auto parse(const std::basic_string &input, /// `line` and `column` read/write position indicators. For example: /// /// ```cpp -/// #include +/// #include /// #include /// #include /// /// std::istringstream stream{"[ 1, 2, 3 ]"}; /// std::uint64_t line{1}; /// std::uint64_t column{0}; -/// const sourcemeta::jsontoolkit::JSON document = -/// sourcemeta::jsontoolkit::parse(stream, line, column); +/// const sourcemeta::core::JSON document = +/// sourcemeta::core::parse(stream, line, column); /// assert(document.is_array()); /// ``` -SOURCEMETA_JSONTOOLKIT_JSON_EXPORT +SOURCEMETA_CORE_JSON_EXPORT auto parse(std::basic_istream &stream, std::uint64_t &line, std::uint64_t &column, const Callback &callback = nullptr) -> JSON; @@ -113,16 +113,16 @@ auto parse(std::basic_istream &stream, /// `line` and `column` read/write position indicators. For example: /// /// ```cpp -/// #include +/// #include /// #include /// /// std::uint64_t line{1}; /// std::uint64_t column{0}; -/// const sourcemeta::jsontoolkit::JSON document = -/// sourcemeta::jsontoolkit::parse("[ 1, 2, 3 ]", line, column); +/// const sourcemeta::core::JSON document = +/// sourcemeta::core::parse("[ 1, 2, 3 ]", line, column); /// assert(document.is_array()); /// ``` -SOURCEMETA_JSONTOOLKIT_JSON_EXPORT +SOURCEMETA_CORE_JSON_EXPORT auto parse(const std::basic_string &input, std::uint64_t &line, std::uint64_t &column, const Callback &callback = nullptr) -> JSON; @@ -132,18 +132,18 @@ auto parse(const std::basic_string &input, /// A convenience function to read a document from a file. For example: /// /// ```cpp -/// #include +/// #include /// #include /// #include /// -/// auto stream = sourcemeta::jsontoolkit::read_file("/tmp/foo.json"); -/// const auto document = sourcemeta::jsontoolkit::parse(stream); -/// sourcemeta::jsontoolkit::stringify(document, std::cout); +/// auto stream = sourcemeta::core::read_file("/tmp/foo.json"); +/// const auto document = sourcemeta::core::parse(stream); +/// sourcemeta::core::stringify(document, std::cout); /// std::cout << std::endl; /// ``` /// -/// If parsing fails, sourcemeta::jsontoolkit::ParseError will be thrown. -SOURCEMETA_JSONTOOLKIT_JSON_EXPORT +/// If parsing fails, sourcemeta::core::ParseError will be thrown. +SOURCEMETA_CORE_JSON_EXPORT auto read_file(const std::filesystem::path &path) -> std::basic_ifstream; @@ -152,18 +152,18 @@ auto read_file(const std::filesystem::path &path) /// A convenience function to create a JSON document from a file. For example: /// /// ```cpp -/// #include +/// #include /// #include /// #include /// -/// const sourcemeta::jsontoolkit::JSON document = -/// sourcemeta::jsontoolkit::from_file("/tmp/foo.json"); -/// sourcemeta::jsontoolkit::stringify(document, std::cout); +/// const sourcemeta::core::JSON document = +/// sourcemeta::core::from_file("/tmp/foo.json"); +/// sourcemeta::core::stringify(document, std::cout); /// std::cout << std::endl; /// ``` /// -/// If parsing fails, sourcemeta::jsontoolkit::ParseError will be thrown. -SOURCEMETA_JSONTOOLKIT_JSON_EXPORT +/// If parsing fails, sourcemeta::core::ParseError will be thrown. +SOURCEMETA_CORE_JSON_EXPORT auto from_file(const std::filesystem::path &path) -> JSON; /// @ingroup json @@ -172,17 +172,17 @@ auto from_file(const std::filesystem::path &path) -> JSON; /// compact mode. For example: /// /// ```cpp -/// #include +/// #include /// #include /// #include /// -/// const sourcemeta::jsontoolkit::JSON document = -/// sourcemeta::jsontoolkit::parse("[ 1, 2, 3 ]"); +/// const sourcemeta::core::JSON document = +/// sourcemeta::core::parse("[ 1, 2, 3 ]"); /// std::ostringstream stream; -/// sourcemeta::jsontoolkit::stringify(document, stream); +/// sourcemeta::core::stringify(document, stream); /// std::cout << stream.str() << std::endl; /// ``` -SOURCEMETA_JSONTOOLKIT_JSON_EXPORT +SOURCEMETA_CORE_JSON_EXPORT auto stringify(const JSON &document, std::basic_ostream &stream) -> void; @@ -193,17 +193,17 @@ auto stringify(const JSON &document, /// pretty mode, indenting the output using 4 spaces. For example: /// /// ```cpp -/// #include +/// #include /// #include /// #include /// -/// const sourcemeta::jsontoolkit::JSON document = -/// sourcemeta::jsontoolkit::parse("[ 1, 2, 3 ]"); +/// const sourcemeta::core::JSON document = +/// sourcemeta::core::parse("[ 1, 2, 3 ]"); /// std::ostringstream stream; -/// sourcemeta::jsontoolkit::prettify(document, stream); +/// sourcemeta::core::prettify(document, stream); /// std::cout << stream.str() << std::endl; /// ``` -SOURCEMETA_JSONTOOLKIT_JSON_EXPORT +SOURCEMETA_CORE_JSON_EXPORT auto prettify(const JSON &document, std::basic_ostream &stream) -> void; @@ -220,23 +220,23 @@ using KeyComparison = /// compact mode, sorting object properties on a specific criteria. For example: /// /// ```cpp -/// #include +/// #include /// #include /// #include /// -/// auto key_compare(const sourcemeta::jsontoolkit::JSON::String &left, -/// const sourcemeta::jsontoolkit::JSON::String &right) +/// auto key_compare(const sourcemeta::core::JSON::String &left, +/// const sourcemeta::core::JSON::String &right) /// -> bool { /// return left < right; /// } /// -/// const sourcemeta::jsontoolkit::JSON document = -/// sourcemeta::jsontoolkit::parse("{ \"foo\": 1, \"bar\": 2, \"baz\": 3 }"); +/// const sourcemeta::core::JSON document = +/// sourcemeta::core::parse("{ \"foo\": 1, \"bar\": 2, \"baz\": 3 }"); /// std::ostringstream stream; -/// sourcemeta::jsontoolkit::stringify(document, stream, key_compare); +/// sourcemeta::core::stringify(document, stream, key_compare); /// std::cout << stream.str() << std::endl; /// ``` -SOURCEMETA_JSONTOOLKIT_JSON_EXPORT +SOURCEMETA_CORE_JSON_EXPORT auto stringify(const JSON &document, std::basic_ostream &stream, const KeyComparison &compare) -> void; @@ -248,23 +248,23 @@ auto stringify(const JSON &document, /// properties on a specific criteria. For example: /// /// ```cpp -/// #include +/// #include /// #include /// #include /// -/// auto key_compare(const sourcemeta::jsontoolkit::JSON::String &left, -/// const sourcemeta::jsontoolkit::JSON::String &right) +/// auto key_compare(const sourcemeta::core::JSON::String &left, +/// const sourcemeta::core::JSON::String &right) /// -> bool { /// return left < right; /// } /// -/// const sourcemeta::jsontoolkit::JSON document = -/// sourcemeta::jsontoolkit::parse("{ \"foo\": 1, \"bar\": 2, \"baz\": 3 }"); +/// const sourcemeta::core::JSON document = +/// sourcemeta::core::parse("{ \"foo\": 1, \"bar\": 2, \"baz\": 3 }"); /// std::ostringstream stream; -/// sourcemeta::jsontoolkit::prettify(document, stream, key_compare); +/// sourcemeta::core::prettify(document, stream, key_compare); /// std::cout << stream.str() << std::endl; /// ``` -SOURCEMETA_JSONTOOLKIT_JSON_EXPORT +SOURCEMETA_CORE_JSON_EXPORT auto prettify(const JSON &document, std::basic_ostream &stream, const KeyComparison &compare) -> void; @@ -276,17 +276,17 @@ auto prettify(const JSON &document, /// presence of the `NDEBUG` define (for debugging purposes). For example: /// /// ```cpp -/// #include +/// #include /// #include /// #include /// -/// const sourcemeta::jsontoolkit::JSON document = -/// sourcemeta::jsontoolkit::parse("[ 1, 2, 3 ]"); +/// const sourcemeta::core::JSON document = +/// sourcemeta::core::parse("[ 1, 2, 3 ]"); /// std::ostringstream stream; /// stream << document; /// std::cout << stream.str() << std::endl; /// ``` -SOURCEMETA_JSONTOOLKIT_JSON_EXPORT +SOURCEMETA_CORE_JSON_EXPORT auto operator<<(std::basic_ostream &stream, const JSON &document) -> std::basic_ostream &; @@ -297,20 +297,20 @@ auto operator<<(std::basic_ostream &stream, /// For example: /// /// ```cpp -/// #include +/// #include /// #include /// #include /// /// std::ostringstream stream; -/// stream << sourcemeta::jsontoolkit::JSON::Type::String; +/// stream << sourcemeta::core::JSON::Type::String; /// // Will print "string" /// std::cout << stream.str() << std::endl; /// ``` -SOURCEMETA_JSONTOOLKIT_JSON_EXPORT +SOURCEMETA_CORE_JSON_EXPORT auto operator<<(std::basic_ostream &stream, const JSON::Type type) -> std::basic_ostream &; -} // namespace sourcemeta::jsontoolkit +} // namespace sourcemeta::core #endif diff --git a/src/core/json/include/sourcemeta/jsontoolkit/json_array.h b/src/core/json/include/sourcemeta/core/json_array.h similarity index 95% rename from src/core/json/include/sourcemeta/jsontoolkit/json_array.h rename to src/core/json/include/sourcemeta/core/json_array.h index e99d07865..5772abac5 100644 --- a/src/core/json/include/sourcemeta/jsontoolkit/json_array.h +++ b/src/core/json/include/sourcemeta/core/json_array.h @@ -1,10 +1,10 @@ -#ifndef SOURCEMETA_JSONTOOLKIT_JSON_ARRAY_H_ -#define SOURCEMETA_JSONTOOLKIT_JSON_ARRAY_H_ +#ifndef SOURCEMETA_CORE_JSON_ARRAY_H_ +#define SOURCEMETA_CORE_JSON_ARRAY_H_ #include // std::initializer_list #include // std::vector -namespace sourcemeta::jsontoolkit { +namespace sourcemeta::core { /// @ingroup json template class JSONArray { @@ -98,6 +98,6 @@ template class JSONArray { #endif }; -} // namespace sourcemeta::jsontoolkit +} // namespace sourcemeta::core #endif diff --git a/src/core/json/include/sourcemeta/jsontoolkit/json_error.h b/src/core/json/include/sourcemeta/core/json_error.h similarity index 81% rename from src/core/json/include/sourcemeta/jsontoolkit/json_error.h rename to src/core/json/include/sourcemeta/core/json_error.h index eb7e90c66..86fe57861 100644 --- a/src/core/json/include/sourcemeta/jsontoolkit/json_error.h +++ b/src/core/json/include/sourcemeta/core/json_error.h @@ -1,15 +1,15 @@ -#ifndef SOURCEMETA_JSONTOOLKIT_JSON_ERROR_H_ -#define SOURCEMETA_JSONTOOLKIT_JSON_ERROR_H_ +#ifndef SOURCEMETA_CORE_JSON_ERROR_H_ +#define SOURCEMETA_CORE_JSON_ERROR_H_ -#ifndef SOURCEMETA_JSONTOOLKIT_JSON_EXPORT -#include +#ifndef SOURCEMETA_CORE_JSON_EXPORT +#include #endif #include // std::uint64_t #include // std::exception #include // std::filesystem::path -namespace sourcemeta::jsontoolkit { +namespace sourcemeta::core { // Exporting symbols that depends on the standard C++ library is considered // safe. @@ -20,7 +20,7 @@ namespace sourcemeta::jsontoolkit { /// @ingroup json /// This class represents a parsing error -class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT ParseError : public std::exception { +class SOURCEMETA_CORE_JSON_EXPORT ParseError : public std::exception { public: /// Create a parsing error ParseError(const std::uint64_t line, const std::uint64_t column) @@ -45,7 +45,7 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT ParseError : public std::exception { /// @ingroup json /// This class represents a parsing error occurring from parsing a file -class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT FileParseError : public ParseError { +class SOURCEMETA_CORE_JSON_EXPORT FileParseError : public ParseError { public: /// Create a file parsing error FileParseError(const std::filesystem::path &path, const std::uint64_t line, @@ -69,6 +69,6 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT FileParseError : public ParseError { #pragma warning(default : 4251 4275) #endif -} // namespace sourcemeta::jsontoolkit +} // namespace sourcemeta::core #endif diff --git a/src/core/json/include/sourcemeta/jsontoolkit/json_hash.h b/src/core/json/include/sourcemeta/core/json_hash.h similarity index 95% rename from src/core/json/include/sourcemeta/jsontoolkit/json_hash.h rename to src/core/json/include/sourcemeta/core/json_hash.h index e3851c18c..eec50c70f 100644 --- a/src/core/json/include/sourcemeta/jsontoolkit/json_hash.h +++ b/src/core/json/include/sourcemeta/core/json_hash.h @@ -1,11 +1,11 @@ -#ifndef SOURCEMETA_JSONTOOLKIT_JSON_HASH_H_ -#define SOURCEMETA_JSONTOOLKIT_JSON_HASH_H_ +#ifndef SOURCEMETA_CORE_JSON_HASH_H_ +#define SOURCEMETA_CORE_JSON_HASH_H_ #include // assert #include // std::uint64_t #include // std::memcpy -namespace sourcemeta::jsontoolkit { +namespace sourcemeta::core { /// @ingroup json template struct FastHash { @@ -140,6 +140,6 @@ template struct KeyHash { } }; -} // namespace sourcemeta::jsontoolkit +} // namespace sourcemeta::core #endif diff --git a/src/core/json/include/sourcemeta/jsontoolkit/json_object.h b/src/core/json/include/sourcemeta/core/json_object.h similarity index 96% rename from src/core/json/include/sourcemeta/jsontoolkit/json_object.h rename to src/core/json/include/sourcemeta/core/json_object.h index e95e0d57a..0b83eab25 100644 --- a/src/core/json/include/sourcemeta/jsontoolkit/json_object.h +++ b/src/core/json/include/sourcemeta/core/json_object.h @@ -1,12 +1,12 @@ -#ifndef SOURCEMETA_JSONTOOLKIT_JSON_OBJECT_H_ -#define SOURCEMETA_JSONTOOLKIT_JSON_OBJECT_H_ +#ifndef SOURCEMETA_CORE_JSON_OBJECT_H_ +#define SOURCEMETA_CORE_JSON_OBJECT_H_ #include // std::equal_to, std::less #include // std::initializer_list #include -namespace sourcemeta::jsontoolkit { +namespace sourcemeta::core { /// @ingroup json template class JSONObject { @@ -128,6 +128,6 @@ template class JSONObject { #endif }; -} // namespace sourcemeta::jsontoolkit +} // namespace sourcemeta::core #endif diff --git a/src/core/json/include/sourcemeta/jsontoolkit/json_value.h b/src/core/json/include/sourcemeta/core/json_value.h similarity index 67% rename from src/core/json/include/sourcemeta/jsontoolkit/json_value.h rename to src/core/json/include/sourcemeta/core/json_value.h index 2eb0e352a..7edbd4921 100644 --- a/src/core/json/include/sourcemeta/jsontoolkit/json_value.h +++ b/src/core/json/include/sourcemeta/core/json_value.h @@ -1,13 +1,13 @@ -#ifndef SOURCEMETA_JSONTOOLKIT_JSON_VALUE_H_ -#define SOURCEMETA_JSONTOOLKIT_JSON_VALUE_H_ +#ifndef SOURCEMETA_CORE_JSON_VALUE_H_ +#define SOURCEMETA_CORE_JSON_VALUE_H_ -#ifndef SOURCEMETA_JSONTOOLKIT_JSON_EXPORT -#include +#ifndef SOURCEMETA_CORE_JSON_EXPORT +#include #endif -#include -#include -#include +#include +#include +#include #include // std::any_of #include // assert @@ -23,10 +23,10 @@ #include // std::enable_if_t, std::is_same_v #include // std::pair -namespace sourcemeta::jsontoolkit { +namespace sourcemeta::core { /// @ingroup json -class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { +class SOURCEMETA_CORE_JSON_EXPORT JSON { public: /// The character type used by the JSON document. using Char = char; @@ -53,9 +53,9 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// - /// const sourcemeta::jsontoolkit::JSON my_integer{4}; + /// const sourcemeta::core::JSON my_integer{4}; /// ``` explicit JSON(const std::int64_t value); @@ -63,9 +63,9 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// - /// const sourcemeta::jsontoolkit::JSON my_integer{4}; + /// const sourcemeta::core::JSON my_integer{4}; /// ``` explicit JSON(const std::size_t value); @@ -73,9 +73,9 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// - /// const sourcemeta::jsontoolkit::JSON my_integer{4}; + /// const sourcemeta::core::JSON my_integer{4}; /// ``` explicit JSON(const int value); @@ -90,9 +90,9 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// - /// const sourcemeta::jsontoolkit::JSON my_real{3.14}; + /// const sourcemeta::core::JSON my_real{3.14}; /// ``` explicit JSON(const double value); @@ -100,54 +100,54 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// - /// const sourcemeta::jsontoolkit::JSON my_real{3.14}; + /// const sourcemeta::core::JSON my_real{3.14}; /// ``` explicit JSON(const float value); /// This constructor creates a JSON document from a boolean type. For example: /// /// ```cpp - /// #include + /// #include /// - /// const sourcemeta::jsontoolkit::JSON my_boolean{true}; + /// const sourcemeta::core::JSON my_boolean{true}; /// ``` explicit JSON(const bool value); /// This constructor creates a JSON document from a null type. For example: /// /// ```cpp - /// #include + /// #include /// - /// const sourcemeta::jsontoolkit::JSON my_null{nullptr}; + /// const sourcemeta::core::JSON my_null{nullptr}; /// ``` explicit JSON(const std::nullptr_t); /// This constructor creates a JSON document from a string type. For example: /// /// ```cpp - /// #include + /// #include /// - /// const sourcemeta::jsontoolkit::JSON my_string{"foo"}; + /// const sourcemeta::core::JSON my_string{"foo"}; /// ``` explicit JSON(const String &value); /// This constructor creates a JSON document from a string type. For example: /// /// ```cpp - /// #include + /// #include /// - /// const sourcemeta::jsontoolkit::JSON my_string{"foo"}; + /// const sourcemeta::core::JSON my_string{"foo"}; /// ``` explicit JSON(const std::basic_string_view &value); /// This constructor creates a JSON document from a string type. For example: /// /// ```cpp - /// #include + /// #include /// - /// const sourcemeta::jsontoolkit::JSON my_string{"foo"}; + /// const sourcemeta::core::JSON my_string{"foo"}; /// ``` explicit JSON(const Char *const value); @@ -155,13 +155,13 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON my_array{ - /// sourcemeta::jsontoolkit::JSON{1}, - /// sourcemeta::jsontoolkit::JSON{2}, - /// sourcemeta::jsontoolkit::JSON{3}}; + /// const sourcemeta::core::JSON my_array{ + /// sourcemeta::core::JSON{1}, + /// sourcemeta::core::JSON{2}, + /// sourcemeta::core::JSON{3}}; /// /// assert(my_array.is_array()); /// ``` @@ -174,13 +174,13 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// documents. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON my_object{ - /// {"foo", sourcemeta::jsontoolkit::JSON{1}}, - /// {"bar", sourcemeta::jsontoolkit::JSON{1}}, - /// {"baz", sourcemeta::jsontoolkit::JSON{1}}}; + /// const sourcemeta::core::JSON my_object{ + /// {"foo", sourcemeta::core::JSON{1}}, + /// {"bar", sourcemeta::core::JSON{1}}, + /// {"baz", sourcemeta::core::JSON{1}}}; /// /// assert(my_object.is_object()); /// ``` @@ -202,11 +202,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// This function creates an empty JSON array. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::JSON::make_array(); + /// const sourcemeta::core::JSON document = + /// sourcemeta::core::JSON::make_array(); /// assert(document.is_array()); /// assert(document.empty()); /// ``` @@ -218,11 +218,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// This function creates an empty JSON object. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::JSON::make_object(); + /// const sourcemeta::core::JSON document = + /// sourcemeta::core::JSON::make_object(); /// assert(document.is_object()); /// assert(document.empty()); /// ``` @@ -235,11 +235,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// JSON specification. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON::String value{"foo"}; - /// assert(sourcemeta::jsontoolkit::JSON::size(value) == 3); + /// const sourcemeta::core::JSON::String value{"foo"}; + /// assert(sourcemeta::core::JSON::size(value) == 3); /// ``` static auto size(const String &value) noexcept -> std::size_t; @@ -258,12 +258,12 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON left{5}; - /// const sourcemeta::jsontoolkit::JSON right{3}; - /// const sourcemeta::jsontoolkit::JSON result{left + right}; + /// const sourcemeta::core::JSON left{5}; + /// const sourcemeta::core::JSON right{3}; + /// const sourcemeta::core::JSON result{left + right}; /// assert(result.is_integer()); /// assert(document.to_integer() == 8); /// ``` @@ -273,12 +273,12 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// result. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON left{5}; - /// const sourcemeta::jsontoolkit::JSON right{3}; - /// const sourcemeta::jsontoolkit::JSON result{left - right}; + /// const sourcemeta::core::JSON left{5}; + /// const sourcemeta::core::JSON right{3}; + /// const sourcemeta::core::JSON result{left - right}; /// assert(result.is_integer()); /// assert(document.to_integer() == 2); /// ``` @@ -289,11 +289,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// numeric JSON instance 5 as follows: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document{5}; - /// const sourcemeta::jsontoolkit::JSON additive{3.2}; + /// sourcemeta::core::JSON document{5}; + /// const sourcemeta::core::JSON additive{3.2}; /// document += additive; /// assert(document.is_real()); /// assert(document.to_real() == 8.2); @@ -305,11 +305,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// a numeric JSON instance 5 as follows: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document{5}; - /// const sourcemeta::jsontoolkit::JSON substractive{3.2}; + /// sourcemeta::core::JSON document{5}; + /// const sourcemeta::core::JSON substractive{3.2}; /// document -= substractive; /// assert(document.is_real()); /// assert(document.to_real() == 1.8); @@ -323,10 +323,10 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// Check if the input JSON document is a boolean. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document{true}; + /// const sourcemeta::core::JSON document{true}; /// assert(document.is_boolean()); /// ``` [[nodiscard]] auto is_boolean() const noexcept -> bool; @@ -334,10 +334,10 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// Check if the input JSON document is null. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document{nullptr}; + /// const sourcemeta::core::JSON document{nullptr}; /// assert(document.is_null()); /// ``` [[nodiscard]] auto is_null() const noexcept -> bool; @@ -345,10 +345,10 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// Check if the input JSON document is an integer. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document{5}; + /// const sourcemeta::core::JSON document{5}; /// assert(document.is_integer()); /// ``` [[nodiscard]] auto is_integer() const noexcept -> bool; @@ -356,10 +356,10 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// Check if the input JSON document is a real type. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document{3.14}; + /// const sourcemeta::core::JSON document{3.14}; /// assert(document.is_real()); /// ``` [[nodiscard]] auto is_real() const noexcept -> bool; @@ -368,10 +368,10 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// integer. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document{5.0}; + /// const sourcemeta::core::JSON document{5.0}; /// assert(document.is_integer_real()); /// ``` [[nodiscard]] auto is_integer_real() const noexcept -> bool; @@ -380,11 +380,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON real{3.14}; - /// const sourcemeta::jsontoolkit::JSON integer{5}; + /// const sourcemeta::core::JSON real{3.14}; + /// const sourcemeta::core::JSON integer{5}; /// assert(real.is_number()); /// assert(integer.is_number()); /// ``` @@ -394,11 +394,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// positive real number. Zero is considered to be positive. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON real{3.14}; - /// const sourcemeta::jsontoolkit::JSON integer{-5}; + /// const sourcemeta::core::JSON real{3.14}; + /// const sourcemeta::core::JSON integer{-5}; /// assert(real.is_positive()); /// assert(!integer.is_positive()); /// ``` @@ -407,10 +407,10 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// Check if the input JSON document is a string. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document{"foo"}; + /// const sourcemeta::core::JSON document{"foo"}; /// assert(document.is_string()); /// ``` [[nodiscard]] auto is_string() const noexcept -> bool; @@ -418,11 +418,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// Check if the input JSON document is an array. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON - /// document=sourcemeta::jsontoolkit::parse("[ 1, 2, 3 ]"); + /// const sourcemeta::core::JSON + /// document=sourcemeta::core::parse("[ 1, 2, 3 ]"); /// assert(document.is_array()); /// ``` [[nodiscard]] auto is_array() const noexcept -> bool; @@ -430,11 +430,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// Check if the input JSON document is an object. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON - /// document=sourcemeta::jsontoolkit::parse("{ \"foo\": 1 }"); + /// const sourcemeta::core::JSON + /// document=sourcemeta::core::parse("{ \"foo\": 1 }"); /// assert(document.is_object()); /// ``` [[nodiscard]] auto is_object() const noexcept -> bool; @@ -454,11 +454,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// Get the type of the JSON document. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document{true}; - /// assert(document.type() == sourcemeta::jsontoolkit::JSON::Type::Boolean); + /// const sourcemeta::core::JSON document{true}; + /// assert(document.type() == sourcemeta::core::JSON::Type::Boolean); /// ``` [[nodiscard]] auto type() const noexcept -> Type; @@ -470,10 +470,10 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// undefined unless the JSON instance holds a boolean value. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document{true}; + /// const sourcemeta::core::JSON document{true}; /// assert(document.is_boolean()); /// assert(document.to_boolean()); /// ``` @@ -484,10 +484,10 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document{5}; + /// const sourcemeta::core::JSON document{5}; /// assert(document.is_integer()); /// assert(document.to_integer() == 5); /// ``` @@ -498,10 +498,10 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// value. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document{3.14}; + /// const sourcemeta::core::JSON document{3.14}; /// assert(document.is_real()); /// assert(document.to_real() == 3.14); /// ``` @@ -512,10 +512,10 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document{"foo"}; + /// const sourcemeta::core::JSON document{"foo"}; /// assert(document.is_string()); /// assert(document.to_string() == "foo"); /// ``` @@ -526,10 +526,10 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document{"foo"}; + /// const sourcemeta::core::JSON document{"foo"}; /// assert(document.is_string()); /// auto stream{document.to_stringstream()}; /// assert(stream.get() == 'f'); @@ -541,12 +541,12 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// for using constant iterators on the array. For example: /// /// ```cpp - /// #include + /// #include /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("[ 1, 2, 3 ]"); + /// const sourcemeta::core::JSON document = + /// sourcemeta::core::parse("[ 1, 2, 3 ]"); /// std::for_each(document.as_array().cbegin(), /// document.as_array().cend(), /// [](const auto &element) { @@ -561,12 +561,12 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// for using mutable iterators on the array. For example: /// /// ```cpp - /// #include + /// #include /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("[ 1, 2, 3 ]"); + /// const sourcemeta::core::JSON document = + /// sourcemeta::core::parse("[ 1, 2, 3 ]"); /// std::sort(document.as_array().begin(), document.as_array().end()); /// ``` [[nodiscard]] auto as_array() noexcept -> Array &; @@ -575,15 +575,15 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// for using constant iterators on the object. For example: /// /// ```cpp - /// #include + /// #include /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::JSON::make_object(); - /// document.assign("foo", sourcemeta::jsontoolkit::JSON{1}); - /// document.assign("bar", sourcemeta::jsontoolkit::JSON{2}); - /// document.assign("baz", sourcemeta::jsontoolkit::JSON{3}); + /// sourcemeta::core::JSON document = + /// sourcemeta::core::JSON::make_object(); + /// document.assign("foo", sourcemeta::core::JSON{1}); + /// document.assign("bar", sourcemeta::core::JSON{2}); + /// document.assign("baz", sourcemeta::core::JSON{3}); /// /// std::for_each(document.as_object().cbegin(), /// document.as_object().cend(), @@ -599,18 +599,18 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// for using mutable iterators on the object. For example: /// /// ```cpp - /// #include + /// #include /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::JSON::make_object(); - /// document.assign("foo", sourcemeta::jsontoolkit::JSON{1}); - /// document.assign("bar", sourcemeta::jsontoolkit::JSON{2}); - /// document.assign("baz", sourcemeta::jsontoolkit::JSON{3}); + /// sourcemeta::core::JSON document = + /// sourcemeta::core::JSON::make_object(); + /// document.assign("foo", sourcemeta::core::JSON{1}); + /// document.assign("bar", sourcemeta::core::JSON{2}); + /// document.assign("baz", sourcemeta::core::JSON{3}); /// /// for (auto &[key, value] : document.as_object()) { - /// value += sourcemeta::jsontoolkit::JSON{1}; + /// value += sourcemeta::core::JSON{1}; /// } /// ``` [[nodiscard]] auto as_object() const noexcept -> const Object &; @@ -619,10 +619,10 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document{5}; + /// const sourcemeta::core::JSON document{5}; /// assert(document.as_real() == 5.0); /// ``` [[nodiscard]] auto as_real() const noexcept -> Real; @@ -632,10 +632,10 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document{5.3}; + /// const sourcemeta::core::JSON document{5.3}; /// assert(document.as_integer() == 5); /// ``` [[nodiscard]] auto as_integer() const noexcept -> Integer; @@ -651,15 +651,15 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON my_array = - /// sourcemeta::jsontoolkit::parse("[ 1, 2 ]"); + /// const sourcemeta::core::JSON my_array = + /// sourcemeta::core::parse("[ 1, 2 ]"); /// assert(my_array.at(1).to_integer() == 2); /// - /// const sourcemeta::jsontoolkit::JSON my_object = - /// sourcemeta::jsontoolkit::parse("{ \"1\": "foo" }"); + /// const sourcemeta::core::JSON my_object = + /// sourcemeta::core::parse("{ \"1\": "foo" }"); /// assert(my_array.at(1).to_string() == "foo"); /// ``` [[nodiscard]] auto at(const typename Array::size_type index) const @@ -672,15 +672,15 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON my_array = - /// sourcemeta::jsontoolkit::parse("[ 1, 2 ]"); + /// sourcemeta::core::JSON my_array = + /// sourcemeta::core::parse("[ 1, 2 ]"); /// assert(my_array.at(1).to_integer() == 2); /// - /// sourcemeta::jsontoolkit::JSON my_object = - /// sourcemeta::jsontoolkit::parse("{ \"1\": "foo" }"); + /// sourcemeta::core::JSON my_object = + /// sourcemeta::core::parse("{ \"1\": "foo" }"); /// assert(my_array.at(1).to_string() == "foo"); /// ``` [[nodiscard]] auto at(const typename Array::size_type index) -> JSON &; @@ -690,11 +690,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON my_object = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": 1, \"bar\": 2 }"); + /// const sourcemeta::core::JSON my_object = + /// sourcemeta::core::parse("{ \"foo\": 1, \"bar\": 2 }"); /// assert(my_object.at("bar").to_integer() == 2); /// ``` [[nodiscard]] auto at(const String &key) const -> const JSON &; @@ -705,12 +705,12 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON my_object = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": 1, \"bar\": 2 }"); - /// const sourcemeta::jsontoolkit::Hash hasher; + /// const sourcemeta::core::JSON my_object = + /// sourcemeta::core::parse("{ \"foo\": 1, \"bar\": 2 }"); + /// const sourcemeta::core::Hash hasher; /// assert(my_object.at("bar", hasher("bar")).to_integer() == 2); /// ``` [[nodiscard]] auto at(const String &key, @@ -722,11 +722,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON my_object = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": 1, \"bar\": 2 }"); + /// sourcemeta::core::JSON my_object = + /// sourcemeta::core::parse("{ \"foo\": 1, \"bar\": 2 }"); /// assert(my_object.at("bar").to_integer() == 2); /// ``` [[nodiscard]] auto at(const String &key) -> JSON &; @@ -737,12 +737,12 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON my_object = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": 1, \"bar\": 2 }"); - /// const sourcemeta::jsontoolkit::Hash hasher; + /// sourcemeta::core::JSON my_object = + /// sourcemeta::core::parse("{ \"foo\": 1, \"bar\": 2 }"); + /// const sourcemeta::core::Hash hasher; /// assert(my_object.at("bar", hasher("bar")).to_integer() == 2); /// ``` [[nodiscard]] auto at(const String &key, @@ -754,11 +754,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("[ 1, 2, 3 ]"); + /// sourcemeta::core::JSON document = + /// sourcemeta::core::parse("[ 1, 2, 3 ]"); /// assert(document.front().to_integer() == 1); /// ``` [[nodiscard]] auto front() -> JSON &; @@ -768,11 +768,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("[ 1, 2, 3 ]"); + /// const sourcemeta::core::JSON document = + /// sourcemeta::core::parse("[ 1, 2, 3 ]"); /// assert(document.front().to_integer() == 1); /// ``` [[nodiscard]] auto front() const -> const JSON &; @@ -782,11 +782,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("[ 1, 2, 3 ]"); + /// sourcemeta::core::JSON document = + /// sourcemeta::core::parse("[ 1, 2, 3 ]"); /// assert(document.back().to_integer() == 3); /// ``` [[nodiscard]] auto back() -> JSON &; @@ -796,11 +796,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("[ 1, 2, 3 ]"); + /// const sourcemeta::core::JSON document = + /// sourcemeta::core::parse("[ 1, 2, 3 ]"); /// assert(document.back().to_integer() == 3); /// ``` [[nodiscard]] auto back() const -> const JSON &; @@ -816,14 +816,14 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON my_object = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": 1 }"); - /// const sourcemeta::jsontoolkit::JSON my_array = - /// sourcemeta::jsontoolkit::parse("[ 1, 2 ]"); - /// const sourcemeta::jsontoolkit::JSON my_string{"foo"}; + /// const sourcemeta::core::JSON my_object = + /// sourcemeta::core::parse("{ \"foo\": 1 }"); + /// const sourcemeta::core::JSON my_array = + /// sourcemeta::core::parse("[ 1, 2 ]"); + /// const sourcemeta::core::JSON my_string{"foo"}; /// /// assert(my_object.size() == 1); /// assert(my_array.size() == 2); @@ -836,10 +836,10 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON my_string{"foo"}; + /// const sourcemeta::core::JSON my_string{"foo"}; /// assert(my_string.string_size() == 3); /// ``` [[nodiscard]] auto string_size() const -> std::size_t; @@ -849,11 +849,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON my_array = - /// sourcemeta::jsontoolkit::parse("[ 1, 2 ]"); + /// const sourcemeta::core::JSON my_array = + /// sourcemeta::core::parse("[ 1, 2 ]"); /// assert(my_array.array_size() == 2); /// ``` [[nodiscard]] auto array_size() const -> std::size_t; @@ -863,11 +863,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON my_object = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": 1 }"); + /// const sourcemeta::core::JSON my_object = + /// sourcemeta::core::parse("{ \"foo\": 1 }"); /// assert(my_object.object_size() == 1); /// ``` [[nodiscard]] auto object_size() const -> std::size_t; @@ -876,11 +876,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// return its number of bytes. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON my_string{ - /// sourcemeta::jsontoolkit::parse("\"\\uD83D\\uDCA9\"")}; + /// const sourcemeta::core::JSON my_string{ + /// sourcemeta::core::parse("\"\\uD83D\\uDCA9\"")}; /// assert(my_string.size() == 2); /// ``` [[nodiscard]] auto byte_size() const -> std::size_t; @@ -890,11 +890,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// this is just a rough estimate. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON value = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": 1 }"); + /// const sourcemeta::core::JSON value = + /// sourcemeta::core::parse("{ \"foo\": 1 }"); /// /// // Byte length of "foo" (3) + byte length of 1 (8) /// assert(value.estimated_byte_size() == 11); @@ -905,14 +905,14 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// but might have a higher chance of collisions. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON value_1 = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": 1 }"); + /// const sourcemeta::core::JSON value_1 = + /// sourcemeta::core::parse("{ \"foo\": 1 }"); /// - /// const sourcemeta::jsontoolkit::JSON value_2 = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": 1 }"); + /// const sourcemeta::core::JSON value_2 = + /// sourcemeta::core::parse("{ \"foo\": 1 }"); /// /// assert(value_1.fast_hash() == value_2.fast_hash()); /// ``` @@ -922,11 +922,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON dividend{6}; - /// const sourcemeta::jsontoolkit::JSON divisor{1.5}; + /// const sourcemeta::core::JSON dividend{6}; + /// const sourcemeta::core::JSON divisor{1.5}; /// /// assert(dividend.divisible_by(divisor)); /// ``` @@ -938,14 +938,14 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON my_object = - /// sourcemeta::jsontoolkit::parse("{}"); - /// const sourcemeta::jsontoolkit::JSON my_array = - /// sourcemeta::jsontoolkit::parse("[]"); - /// const sourcemeta::jsontoolkit::JSON my_string{""}; + /// const sourcemeta::core::JSON my_object = + /// sourcemeta::core::parse("{}"); + /// const sourcemeta::core::JSON my_array = + /// sourcemeta::core::parse("[]"); + /// const sourcemeta::core::JSON my_string{""}; /// /// assert(my_object.empty()); /// assert(my_array.empty()); @@ -957,11 +957,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// and returns the value if it does. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": 1 }"); + /// const sourcemeta::core::JSON document = + /// sourcemeta::core::parse("{ \"foo\": 1 }"); /// EXPECT_TRUE(document.is_object()); /// const auto result = document.try_at("foo"); /// EXPECT_TRUE(result); @@ -973,13 +973,13 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": 1 }"); + /// const sourcemeta::core::JSON document = + /// sourcemeta::core::parse("{ \"foo\": 1 }"); /// EXPECT_TRUE(document.is_object()); - /// const sourcemeta::jsontoolkit::Hash hasher; + /// const sourcemeta::core::Hash hasher; /// const auto result = document.try_at("foo", hasher("foo")); /// EXPECT_TRUE(result); /// EXPECT_EQ(result->to_integer(), 1); @@ -992,11 +992,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": 1 }"); + /// const sourcemeta::core::JSON document = + /// sourcemeta::core::parse("{ \"foo\": 1 }"); /// assert(document.defines("foo")); /// assert(!document.defines("bar")); /// ``` @@ -1006,12 +1006,12 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// given a pre-calculated property hash. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": 1 }"); - /// const sourcemeta::jsontoolkit::Hash hasher; + /// const sourcemeta::core::JSON document = + /// sourcemeta::core::parse("{ \"foo\": 1 }"); + /// const sourcemeta::core::Hash hasher; /// assert(document.defines("foo", hasher("foo"))); /// assert(!document.defines("bar", hasher("bar"))); /// ``` @@ -1023,11 +1023,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// key. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("{ \"0\": 1 }"); + /// const sourcemeta::core::JSON document = + /// sourcemeta::core::parse("{ \"0\": 1 }"); /// assert(document.defines(0)); /// assert(!document.defines(1)); /// ``` @@ -1038,13 +1038,13 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// key. /// /// ```cpp - /// #include + /// #include /// #include /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": true, \"bar\": false }"); + /// const sourcemeta::core::JSON document = + /// sourcemeta::core::parse("{ \"foo\": true, \"bar\": false }"); /// /// const std::vector keys{"foo", "qux"}; /// assert(document.defines_any(keys.cbegin(), keys.cend())); @@ -1060,11 +1060,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// key. /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": true, \"bar\": false }"); + /// const sourcemeta::core::JSON document = + /// sourcemeta::core::parse("{ \"foo\": true, \"bar\": false }"); /// /// assert(document.defines_any({ "foo", "qux" })); /// ``` @@ -1075,13 +1075,13 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("[ 1, 2, 3 ]"); - /// assert(document.contains(sourcemeta::jsontoolkit::JSON{2})); - /// assert(!document.contains(sourcemeta::jsontoolkit::JSON{4})); + /// const sourcemeta::core::JSON document = + /// sourcemeta::core::parse("[ 1, 2, 3 ]"); + /// assert(document.contains(sourcemeta::core::JSON{2})); + /// assert(!document.contains(sourcemeta::core::JSON{4})); /// ``` [[nodiscard]] auto contains(const JSON &element) const -> bool; @@ -1089,10 +1089,10 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document{"foo bar baz"}; + /// const sourcemeta::core::JSON document{"foo bar baz"}; /// assert(document.contains("bar")); /// assert(!document.contains("baz")); /// ``` @@ -1102,10 +1102,10 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document{"foo"}; + /// const sourcemeta::core::JSON document{"foo"}; /// assert(document.contains('f')); /// assert(!document.contains('b')); /// ``` @@ -1115,11 +1115,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// const sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("[ 1, 2, 3 ]"); + /// const sourcemeta::core::JSON document = + /// sourcemeta::core::parse("[ 1, 2, 3 ]"); /// assert(document.unique()); /// ``` [[nodiscard]] auto unique() const -> bool; @@ -1132,12 +1132,12 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("[ 1, 2, 3 ]"); - /// const sourcemeta::jsontoolkit::JSON value{4}; + /// sourcemeta::core::JSON document = + /// sourcemeta::core::parse("[ 1, 2, 3 ]"); + /// const sourcemeta::core::JSON value{4}; /// document.push_back(value); /// assert(document.size() == 4); /// assert(document.back().to_integer() == 4); @@ -1148,12 +1148,12 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("[ 1, 2, 3 ]"); - /// document.push_back(sourcemeta::jsontoolkit::JSON{4}); + /// sourcemeta::core::JSON document = + /// sourcemeta::core::parse("[ 1, 2, 3 ]"); + /// document.push_back(sourcemeta::core::JSON{4}); /// assert(document.size() == 4); /// assert(document.back().to_integer() == 4); /// ``` @@ -1165,12 +1165,12 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// element was inserted or not. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("[ 1, 2, 3 ]"); - /// const sourcemeta::jsontoolkit::JSON new_element{3}; + /// sourcemeta::core::JSON document = + /// sourcemeta::core::parse("[ 1, 2, 3 ]"); + /// const sourcemeta::core::JSON new_element{3}; /// const auto result{document.push_back_if_unique(new_element)}; /// assert(result.first.get().to_integer() == 3); /// assert(!result.second); @@ -1184,13 +1184,13 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// element was inserted or not. For example: /// /// ```cpp - /// #include + /// #include /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("[ 1, 2, 3 ]"); - /// sourcemeta::jsontoolkit::JSON new_element{3}; + /// sourcemeta::core::JSON document = + /// sourcemeta::core::parse("[ 1, 2, 3 ]"); + /// sourcemeta::core::JSON new_element{3}; /// const auto result{document.push_back_if_unique(std::move(new_element)}; /// assert(result.first.get().to_integer() == 3); /// assert(!result.second); @@ -1202,12 +1202,12 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// updated to contain a new `bar` boolean member as follows: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": true }"); - /// const sourcemeta::jsontoolkit::JSON value{false}; + /// sourcemeta::core::JSON document = + /// sourcemeta::core::parse("{ \"foo\": true }"); + /// const sourcemeta::core::JSON value{false}; /// document.assign("bar", value); /// assert(document.defines("foo")); /// assert(document.defines("bar")); @@ -1218,12 +1218,12 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// updated to contain a new `bar` boolean member as follows: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": true }"); - /// document.assign("bar", sourcemeta::jsontoolkit::JSON{false}); + /// sourcemeta::core::JSON document = + /// sourcemeta::core::parse("{ \"foo\": true }"); + /// document.assign("bar", sourcemeta::core::JSON{false}); /// assert(document.defines("foo")); /// assert(document.defines("bar")); /// ``` @@ -1232,14 +1232,14 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// This method sets an object key if it is not already defined. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": true }"); + /// sourcemeta::core::JSON document = + /// sourcemeta::core::parse("{ \"foo\": true }"); /// - /// const sourcemeta::jsontoolkit::JSON value_1{1}; - /// const sourcemeta::jsontoolkit::JSON value_2{2}; + /// const sourcemeta::core::JSON value_1{1}; + /// const sourcemeta::core::JSON value_2{2}; /// /// document.assign_if_missing("foo", value_1); /// document.assign_if_missing("bar", value_2); @@ -1254,14 +1254,14 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// This method sets an object key if it is not already defined. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": true }"); + /// sourcemeta::core::JSON document = + /// sourcemeta::core::parse("{ \"foo\": true }"); /// - /// document.assign_if_missing("foo", sourcemeta::jsontoolkit::JSON{1}); - /// document.assign_if_missing("bar", sourcemeta::jsontoolkit::JSON{2}); + /// document.assign_if_missing("foo", sourcemeta::core::JSON{1}); + /// document.assign_if_missing("bar", sourcemeta::core::JSON{2}); /// /// assert(document.defines("foo")); /// assert(document.at("foo").is_boolean()); @@ -1273,11 +1273,11 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// This method deletes an object key. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": true }"); + /// sourcemeta::core::JSON document = + /// sourcemeta::core::parse("{ \"foo\": true }"); /// document.erase("foo"); /// assert(!document.defines("foo")); /// ``` @@ -1286,16 +1286,16 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// This method deletes a set of object keys. For example: /// /// ```cpp - /// #include + /// #include /// #include /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::JSON::make_object(); - /// document.assign("foo", sourcemeta::jsontoolkit::JSON{true}); - /// document.assign("bar", sourcemeta::jsontoolkit::JSON{false}); - /// document.assign("baz", sourcemeta::jsontoolkit::JSON{true}); + /// sourcemeta::core::JSON document = + /// sourcemeta::core::JSON::make_object(); + /// document.assign("foo", sourcemeta::core::JSON{true}); + /// document.assign("bar", sourcemeta::core::JSON{false}); + /// document.assign("baz", sourcemeta::core::JSON{true}); /// /// const std::vector keys{"foo", "bar"}; /// document.erase_keys(keys.cbegin(), keys.cend()); @@ -1315,14 +1315,14 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// This method deletes a set of object keys. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::JSON::make_object(); - /// document.assign("foo", sourcemeta::jsontoolkit::JSON{true}); - /// document.assign("bar", sourcemeta::jsontoolkit::JSON{false}); - /// document.assign("baz", sourcemeta::jsontoolkit::JSON{true}); + /// sourcemeta::core::JSON document = + /// sourcemeta::core::JSON::make_object(); + /// document.assign("foo", sourcemeta::core::JSON{true}); + /// document.assign("bar", sourcemeta::core::JSON{false}); + /// document.assign("baz", sourcemeta::core::JSON{true}); /// /// document.erase_keys({ "foo", "bar" }); /// @@ -1335,12 +1335,12 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// This method deletes an array element using an iterator. For example: /// /// ```cpp - /// #include + /// #include /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON array = - /// sourcemeta::jsontoolkit::parse("[ 1, 2, 3 ]"); + /// sourcemeta::core::JSON array = + /// sourcemeta::core::parse("[ 1, 2, 3 ]"); /// array.erase(std::next(array.begin())); /// assert(array.size(), 2); /// assert(array.at(0), 1); @@ -1352,12 +1352,12 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// This method deletes a set of array elements using iterators. For example: /// /// ```cpp - /// #include + /// #include /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON array = - /// sourcemeta::jsontoolkit::parse("[ 1, 2, 3 ]"); + /// sourcemeta::core::JSON array = + /// sourcemeta::core::parse("[ 1, 2, 3 ]"); /// array.erase(std::next(array.begin()), array.end()); /// assert(array.size(), 1); /// assert(array.at(0), 1); @@ -1369,13 +1369,13 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// leaving them empty. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON my_object = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": true }"); - /// sourcemeta::jsontoolkit::JSON my_array = - /// sourcemeta::jsontoolkit::parse("[ 1, 2, 3 ]"); + /// sourcemeta::core::JSON my_object = + /// sourcemeta::core::parse("{ \"foo\": true }"); + /// sourcemeta::core::JSON my_array = + /// sourcemeta::core::parse("[ 1, 2, 3 ]"); /// my_object.clear(); /// my_array.clear(); /// assert(my_object.empty()); @@ -1387,16 +1387,16 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// declares as the second argument. For example: /// /// ```cpp - /// #include + /// #include /// #include /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::JSON::make_object(); - /// document.assign("foo", sourcemeta::jsontoolkit::JSON{true}); - /// document.assign("bar", sourcemeta::jsontoolkit::JSON{false}); - /// document.assign("baz", sourcemeta::jsontoolkit::JSON{true}); + /// sourcemeta::core::JSON document = + /// sourcemeta::core::JSON::make_object(); + /// document.assign("foo", sourcemeta::core::JSON{true}); + /// document.assign("bar", sourcemeta::core::JSON{false}); + /// document.assign("baz", sourcemeta::core::JSON{true}); /// /// const std::vector keys{"foo"}; /// document.clear_except(keys.cbegin(), keys.cend()); @@ -1427,14 +1427,14 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// declares as the second argument. For example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::JSON::make_object(); - /// document.assign("foo", sourcemeta::jsontoolkit::JSON{true}); - /// document.assign("bar", sourcemeta::jsontoolkit::JSON{false}); - /// document.assign("baz", sourcemeta::jsontoolkit::JSON{true}); + /// sourcemeta::core::JSON document = + /// sourcemeta::core::JSON::make_object(); + /// document.assign("foo", sourcemeta::core::JSON{true}); + /// document.assign("bar", sourcemeta::core::JSON{false}); + /// document.assign("baz", sourcemeta::core::JSON{true}); /// /// document.clear_except({ "foo" }); /// @@ -1453,12 +1453,12 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// integer as follows: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": true }"); - /// const sourcemeta::jsontoolkit::JSON value{2}; + /// sourcemeta::core::JSON document = + /// sourcemeta::core::parse("{ \"foo\": true }"); + /// const sourcemeta::core::JSON value{2}; /// document.at("foo").into(value); /// assert(document.at("foo").is_integer()); /// ``` @@ -1469,12 +1469,12 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// follows: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document = - /// sourcemeta::jsontoolkit::parse("{ \"foo\": true }"); - /// document.at("foo").into(sourcemeta::jsontoolkit::JSON{2}); + /// sourcemeta::core::JSON document = + /// sourcemeta::core::parse("{ \"foo\": true }"); + /// document.at("foo").into(sourcemeta::core::JSON{2}); /// assert(document.at("foo").is_integer()); /// ``` auto into(JSON &&other) noexcept -> void; @@ -1483,10 +1483,10 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document{true}; + /// sourcemeta::core::JSON document{true}; /// assert(document.is_boolean()); /// document.into_array(); /// assert(document.is_array()); @@ -1498,10 +1498,10 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { /// example: /// /// ```cpp - /// #include + /// #include /// #include /// - /// sourcemeta::jsontoolkit::JSON document{true}; + /// sourcemeta::core::JSON document{true}; /// assert(document.is_boolean()); /// document.into_object(); /// assert(document.is_object()); @@ -1532,6 +1532,6 @@ class SOURCEMETA_JSONTOOLKIT_JSON_EXPORT JSON { auto maybe_destruct_union() -> void; }; -} // namespace sourcemeta::jsontoolkit +} // namespace sourcemeta::core #endif diff --git a/src/core/json/json.cc b/src/core/json/json.cc index f508f0ccb..c97fc5f34 100644 --- a/src/core/json/json.cc +++ b/src/core/json/json.cc @@ -1,13 +1,13 @@ #include "parser.h" #include "stringify.h" -#include +#include #include // assert #include // std::ifstream #include // std::make_error_code, std::errc -namespace sourcemeta::jsontoolkit { +namespace sourcemeta::core { auto parse(std::basic_istream &stream, std::uint64_t &line, std::uint64_t &column, const Callback &callback) @@ -99,19 +99,19 @@ auto operator<<(std::basic_ostream &stream, const JSON::Type type) -> std::basic_ostream & { switch (type) { - case sourcemeta::jsontoolkit::JSON::Type::Null: + case sourcemeta::core::JSON::Type::Null: return stream << "null"; - case sourcemeta::jsontoolkit::JSON::Type::Boolean: + case sourcemeta::core::JSON::Type::Boolean: return stream << "boolean"; - case sourcemeta::jsontoolkit::JSON::Type::Integer: + case sourcemeta::core::JSON::Type::Integer: return stream << "integer"; - case sourcemeta::jsontoolkit::JSON::Type::Real: + case sourcemeta::core::JSON::Type::Real: return stream << "real"; - case sourcemeta::jsontoolkit::JSON::Type::String: + case sourcemeta::core::JSON::Type::String: return stream << "string"; - case sourcemeta::jsontoolkit::JSON::Type::Array: + case sourcemeta::core::JSON::Type::Array: return stream << "array"; - case sourcemeta::jsontoolkit::JSON::Type::Object: + case sourcemeta::core::JSON::Type::Object: return stream << "object"; default: // Should never happen, but some compilers are not happy without this @@ -120,4 +120,4 @@ auto operator<<(std::basic_ostream &stream, } } -} // namespace sourcemeta::jsontoolkit +} // namespace sourcemeta::core diff --git a/src/core/json/json_value.cc b/src/core/json/json_value.cc index 61831b146..5ab9bed36 100644 --- a/src/core/json/json_value.cc +++ b/src/core/json/json_value.cc @@ -1,4 +1,4 @@ -#include +#include #include // std::find #include // assert @@ -9,7 +9,7 @@ #include // std::move #include // std::vector -namespace sourcemeta::jsontoolkit { +namespace sourcemeta::core { JSON::JSON(const std::int64_t value) : current_type{Type::Integer} { this->data_integer = value; @@ -867,4 +867,4 @@ auto JSON::maybe_destruct_union() -> void { this->current_type = Type::Null; } -} // namespace sourcemeta::jsontoolkit +} // namespace sourcemeta::core diff --git a/src/core/json/parser.h b/src/core/json/parser.h index 903312a47..3b14acb0c 100644 --- a/src/core/json/parser.h +++ b/src/core/json/parser.h @@ -1,9 +1,9 @@ -#ifndef SOURCEMETA_JSONTOOLKIT_JSON_PARSER_H_ -#define SOURCEMETA_JSONTOOLKIT_JSON_PARSER_H_ +#ifndef SOURCEMETA_CORE_JSON_PARSER_H_ +#define SOURCEMETA_CORE_JSON_PARSER_H_ #include "grammar.h" -#include +#include #include // assert #include // std::isxdigit @@ -16,7 +16,7 @@ #include // std::out_of_range #include // std::basic_string, std::stol, std::stod, std::stoul -namespace sourcemeta::jsontoolkit::internal { +namespace sourcemeta::core::internal { inline auto parse_null( const std::uint64_t line, std::uint64_t &column, @@ -641,7 +641,7 @@ auto parse_number( } } -} // namespace sourcemeta::jsontoolkit::internal +} // namespace sourcemeta::core::internal // We use "goto" to avoid recursion // NOLINTBEGIN(cppcoreguidelines-avoid-goto) @@ -665,7 +665,7 @@ auto parse_number( value); \ } -namespace sourcemeta::jsontoolkit { +namespace sourcemeta::core { auto internal_parse( std::basic_istream &stream, std::uint64_t &line, std::uint64_t &column, const Callback &callback) @@ -1199,7 +1199,7 @@ auto internal_parse(const std::basic_string +#include #include // std::transform, std::sort #include // std::setprecision @@ -12,7 +12,7 @@ #include // std::basic_ostream #include // std::to_string -namespace sourcemeta::jsontoolkit::internal { +namespace sourcemeta::core::internal { template auto indent(std::basic_ostream &stream, const std::size_t indentation) -> void { @@ -21,9 +21,9 @@ auto indent(std::basic_ostream &stream, stream.put(internal::token_whitespace_space); } } -} // namespace sourcemeta::jsontoolkit::internal +} // namespace sourcemeta::core::internal -namespace sourcemeta::jsontoolkit { +namespace sourcemeta::core { template