diff --git a/.github/workflows/psv_pipelines.yml b/.github/workflows/psv_pipelines.yml index cf0a61215..0dc55efae 100644 --- a/.github/workflows/psv_pipelines.yml +++ b/.github/workflows/psv_pipelines.yml @@ -27,7 +27,7 @@ jobs: run: ./scripts/misc/cpplint_ci.sh shell: bash - name: Install Ubuntu dependencies - run: sudo apt-get update && sudo apt-get install -y libboost-all-dev ccache libssl-dev libcurl4-openssl-dev gcc-7 g++-7 --no-install-recommends + run: sudo apt-get update && sudo apt-get install -y ccache libssl-dev libcurl4-openssl-dev gcc-7 g++-7 --no-install-recommends shell: bash - name: Compile project with cmake and ccache run: gcc --version && ./scripts/linux/psv/build_psv.sh @@ -44,7 +44,7 @@ jobs: - name: Check out repository uses: actions/checkout@v4 - name: Install Ubuntu dependencies - run: sudo apt-get update && sudo apt-get install -y libboost-all-dev ccache libssl-dev libcurl4-openssl-dev gcc-9 g++-9 --no-install-recommends + run: sudo apt-get update && sudo apt-get install -y ccache libssl-dev libcurl4-openssl-dev gcc-9 g++-9 --no-install-recommends shell: bash - name: Compile project with cmake and ccache run: gcc --version && ./scripts/linux/psv/build_psv.sh @@ -72,7 +72,7 @@ jobs: - name: Check out repository uses: actions/checkout@v4 - name: Install Ubuntu dependencies - run: sudo apt-get update && sudo apt-get install -y libboost-all-dev libssl-dev libcurl4-openssl-dev gcc-7 g++-7 --no-install-recommends + run: sudo apt-get update && sudo apt-get install -y libssl-dev libcurl4-openssl-dev gcc-7 g++-7 --no-install-recommends shell: bash - name: Compile project without cache run: ./scripts/linux/psv/build_psv_no_cache.sh @@ -87,7 +87,7 @@ jobs: - name: Check out repository uses: actions/checkout@v4 - name: Install Ubuntu dependencies - run: sudo apt-get update && sudo apt-get install -y libboost-all-dev ccache libssl-dev libcurl4-openssl-dev --no-install-recommends + run: sudo apt-get update && sudo apt-get install -y ccache libssl-dev libcurl4-openssl-dev --no-install-recommends shell: bash - name: Compile project with cmake and ccache run: gcc --version && ./scripts/linux/psv/build_psv.sh @@ -104,7 +104,7 @@ jobs: - name: Check out repository uses: actions/checkout@v4 - name: Install Ubuntu dependencies - run: sudo rm /etc/apt/sources.list.d/microsoft-prod.list && sudo add-apt-repository ppa:ubuntu-toolchain-r/test && sudo apt-get update && sudo apt-get install -y libboost-all-dev libssl-dev libcurl4-openssl-dev gcc-13 g++-13 --no-install-recommends + run: sudo rm /etc/apt/sources.list.d/microsoft-prod.list && sudo add-apt-repository ppa:ubuntu-toolchain-r/test && sudo apt-get update && sudo apt-get install -y libssl-dev libcurl4-openssl-dev gcc-13 g++-13 --no-install-recommends shell: bash - name: Compile project without cache run: ./scripts/linux/psv/build_psv_no_cache.sh @@ -121,7 +121,7 @@ jobs: - name: Check out repository uses: actions/checkout@v4 - name: Install Ubuntu dependencies - run: sudo add-apt-repository ppa:ubuntu-toolchain-r/test && sudo apt-get update && sudo apt-get install -y libboost-all-dev ccache libssl-dev libcurl4-openssl-dev gcc-13 g++-13 --no-install-recommends + run: sudo add-apt-repository ppa:ubuntu-toolchain-r/test && sudo apt-get update && sudo apt-get install -y ccache libssl-dev libcurl4-openssl-dev gcc-13 g++-13 --no-install-recommends shell: bash - name: Compile project with cmake and ccache run: gcc --version && ./scripts/linux/psv/build_psv.sh @@ -136,7 +136,7 @@ jobs: - name: Check out repository uses: actions/checkout@v4 - name: Install Ubuntu dependencies - run: sudo apt-get update && sudo apt-get install -y libboost-all-dev libssl-dev libcurl4-openssl-dev --no-install-recommends + run: sudo apt-get update && sudo apt-get install -y libssl-dev libcurl4-openssl-dev --no-install-recommends shell: bash - name: Compile project without cache run: ./scripts/linux/psv/build_psv_no_cache.sh diff --git a/README.md b/README.md index 6e4ebf78d..e265c1909 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,6 @@ The table below lists the dependencies of the Data SDK. | Boost (headers only) | 1.82.0 | | LevelDB | 1.21 | | Snappy | 1.1.7 | -| RapidJSON | latest | | Zlib | 1.3.1 | ### Linux dependencies diff --git a/docs/get-started.md b/docs/get-started.md index 18d274384..334aa65e1 100644 --- a/docs/get-started.md +++ b/docs/get-started.md @@ -71,7 +71,7 @@ cmake --build . --target install CMake is the main build system. The minimal required version of CMake is 3.9. -CMake downloads LevelDB, Snappy, RapidJSON, and Boost. To disable downloading, set `OLP_SDK_BUILD_EXTERNAL_DEPS` to `OFF`. For details on CMake flags, see the [related](#cmake-flags) section. +CMake downloads LevelDB, Snappy, and Boost. To disable downloading, set `OLP_SDK_BUILD_EXTERNAL_DEPS` to `OFF`. For details on CMake flags, see the [related](#cmake-flags) section. **To build the Data SDK:** @@ -175,4 +175,4 @@ HERE Data SDK for C++ contains several example programs that demonstrate some of - [Read example](dataservice-read-catalog-example.md) – demonstrates how to get catalog and partition metadata, as well as partition data. - [Read example for a stream layer](dataservice-read-from-stream-layer-example.md) – demonstrates how to get data from a stream layer. - [Cache example](dataservice-cache-example.md) – demonstrates how to get partition data and work with a mutable and protected cache. -- [Write example](dataservice-write-example.md) – demonstrates how to publish data to the HERE platform. \ No newline at end of file +- [Write example](dataservice-write-example.md) – demonstrates how to publish data to the HERE platform. diff --git a/docs/work-with-data-apis.md b/docs/work-with-data-apis.md index 9ce4de074..4d727a4b9 100644 --- a/docs/work-with-data-apis.md +++ b/docs/work-with-data-apis.md @@ -59,7 +59,7 @@ The example below demonstrates how to use the `olp::client::OlpClient` class fro } ``` -5. If the check passed and the status of the received `olp::client::HttpResponse` is `olp::http::HttpStatusCode::OK` (that is 200 OK), extract the encoded JSON from the response and parse it using RapidJSON or any other JSON parsing library. +5. If the check passed and the status of the received `olp::client::HttpResponse` is `olp::http::HttpStatusCode::OK` (that is 200 OK), extract the encoded JSON from the response and parse it using JSON parsing library. ```cpp std::string response_json; diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index a7d07e2a0..3a0c8bcd5 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -48,10 +48,6 @@ set(OLP_SDK_CPP_SNAPPY_TAG "1.1.7") set(OLP_SDK_CPP_LEVELDB_URL "https://github.com/google/leveldb.git") set(OLP_SDK_CPP_LEVELDB_TAG "1.21") -set(OLP_SDK_CPP_RAPIDJSON_URL "https://github.com/Tencent/rapidjson.git") -# Next commit after that breaks our build -set(OLP_SDK_CPP_RAPIDJSON_TAG "d621dc9e9c77f81e5c8a35b8dcc16dcd63351321") - set(OLP_SDK_CPP_BOOST_URL "https://github.com/boostorg/boost.git") set(OLP_SDK_CPP_BOOST_TAG "boost-1.82.0") @@ -73,11 +69,6 @@ if(NOT TARGET GTest AND NOT GTest_FOUND) add_subdirectory(googletest) endif() -find_package(RapidJSON 1.1.0 QUIET) -if(NOT TARGET RapidJSON AND NOT RapidJSON_FOUND) - add_subdirectory(rapidjson) -endif() - if(OLP_SDK_ENABLE_DEFAULT_CACHE) find_package(leveldb QUIET) if(NOT TARGET leveldb AND NOT leveldb_FOUND) @@ -97,7 +88,7 @@ if(OLP_SDK_ENABLE_DEFAULT_CACHE_LMDB) endif() endif() -find_package(Boost QUIET) +find_package(Boost 1.82.0 QUIET) if(NOT TARGET Boost AND NOT Boost_FOUND) add_subdirectory(boost) set(BOOST_ROOT ${EXTERNAL_BOOST_ROOT} PARENT_SCOPE) diff --git a/external/boost/CMakeLists.txt.boost.in b/external/boost/CMakeLists.txt.boost.in index 562b89335..eefa47952 100644 --- a/external/boost/CMakeLists.txt.boost.in +++ b/external/boost/CMakeLists.txt.boost.in @@ -24,9 +24,11 @@ include(ExternalProject) ExternalProject_Add(boost-download GIT_REPOSITORY @OLP_SDK_CPP_BOOST_URL@ GIT_TAG @OLP_SDK_CPP_BOOST_TAG@ - GIT_SUBMODULES libs/any + GIT_SUBMODULES libs/align + libs/any libs/assert libs/config + libs/container libs/container_hash libs/core libs/detail @@ -35,8 +37,10 @@ ExternalProject_Add(boost-download libs/function_types libs/headers libs/integer + libs/intrusive libs/io libs/iterator + libs/json libs/move libs/mpl libs/mp11 @@ -48,12 +52,14 @@ ExternalProject_Add(boost-download libs/serialization libs/smart_ptr libs/static_assert + libs/system libs/throw_exception libs/tti libs/type_index libs/type_traits libs/utility libs/uuid + libs/variant2 libs/winapi tools/build tools/boost_install diff --git a/external/rapidjson/CMakeLists.txt b/external/rapidjson/CMakeLists.txt deleted file mode 100644 index b3f504c04..000000000 --- a/external/rapidjson/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (C) 2019-2021 HERE Europe B.V. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# License-Filename: LICENSE - -# RapidJSON -# Download and unpack rapidjson at configure time - -configure_file(CMakeLists.txt.rapidjson.in download/CMakeLists.txt) - -execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . ${COMMON_GENERATE_FLAGS} - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/download) -if(result) - message(FATAL_ERROR "CMake step for rapidjson failed: ${result}") -endif() - -execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/download) -if(result) - message(FATAL_ERROR "Build step for rapidjson failed: ${result}") -endif() diff --git a/external/rapidjson/CMakeLists.txt.rapidjson.in b/external/rapidjson/CMakeLists.txt.rapidjson.in deleted file mode 100644 index e8a3fc727..000000000 --- a/external/rapidjson/CMakeLists.txt.rapidjson.in +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (C) 2019 HERE Europe B.V. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# License-Filename: LICENSE - -cmake_minimum_required(VERSION 3.9) - -project(rapidjson-download NONE) - -include(ExternalProject) -ExternalProject_Add(rapidjson - GIT_REPOSITORY @OLP_SDK_CPP_RAPIDJSON_URL@ - GIT_TAG @OLP_SDK_CPP_RAPIDJSON_TAG@ - GIT_SHALLOW 0 - INSTALL_DIR "@EXTERNAL_BINARY_INSTALL_DIR@" - CMAKE_ARGS @COMMON_PLATFORM_FLAGS@ - -DCMAKE_INSTALL_PREFIX= - -DCMAKE_BUILD_TYPE=@CMAKE_BUILD_TYPE@ - -DRAPIDJSON_BUILD_DOC=OFF - -DRAPIDJSON_BUILD_EXAMPLES=OFF - -DRAPIDJSON_BUILD_TESTS=OFF - -DRAPIDJSON_BUILD_THIRDPARTY_GTEST=OFF - -DRAPIDJSON_ENABLE_INSTRUMENTATION_OPT=OFF - -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON - TEST_COMMAND "" -) diff --git a/olp-cpp-sdk-authentication/src/AuthenticationClientImpl.cpp b/olp-cpp-sdk-authentication/src/AuthenticationClientImpl.cpp index eec62c650..0ca44f93c 100644 --- a/olp-cpp-sdk-authentication/src/AuthenticationClientImpl.cpp +++ b/olp-cpp-sdk-authentication/src/AuthenticationClientImpl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2024 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,10 +26,9 @@ #include #include -#include -#include -#include -#include +#include +#include +#include #include #include #include @@ -116,17 +115,13 @@ void RetryDelay(const client::RetrySettings& retry_settings, size_t retry) { client::OlpClient::RequestBodyType GenerateAppleSignInBody( const AppleSignInProperties& sign_in_properties) { - rapidjson::StringBuffer data; - rapidjson::Writer writer(data); - writer.StartObject(); + boost::json::object json_object; - writer.Key(kGrantType); - writer.String(kAppleGrantType); + json_object[kGrantType] = kAppleGrantType; - auto write_field = [&writer](const char* key, const std::string& value) { + auto write_field = [&json_object](const char* key, const std::string& value) { if (!value.empty()) { - writer.Key(key); - writer.String(value.c_str()); + json_object[key] = value; } }; @@ -137,9 +132,8 @@ client::OlpClient::RequestBodyType GenerateAppleSignInBody( write_field(kCountryCode, sign_in_properties.GetCountryCode()); write_field(kLanguage, sign_in_properties.GetLanguage()); - writer.EndObject(); - auto content = data.GetString(); - return std::make_shared(content, content + data.GetSize()); + auto content = boost::json::serialize(json_object); + return std::make_shared(content.begin(), content.end()); } client::HttpResponse CallApi(const client::OlpClient& client, @@ -203,20 +197,26 @@ olp::client::HttpResponse AuthenticationClientImpl::CallAuth( SignInResult AuthenticationClientImpl::ParseAuthResponse( int status, std::stringstream& auth_response) { - auto document = std::make_shared(); - rapidjson::IStreamWrapper stream(auth_response); - document->ParseStream(stream); + boost::json::error_code ec; + auto document = boost::json::parse(auth_response, ec); return std::make_shared( - status, olp::http::HttpErrorToString(status), document); + status, olp::http::HttpErrorToString(status), + ec.failed() || !document.is_object() + ? nullptr + : std::make_shared( + std::move(document.as_object()))); } SignInUserResult AuthenticationClientImpl::ParseUserAuthResponse( int status, std::stringstream& auth_response) { - auto document = std::make_shared(); - rapidjson::IStreamWrapper stream(auth_response); - document->ParseStream(stream); + boost::json::error_code ec; + auto document = boost::json::parse(auth_response, ec); return std::make_shared( - status, olp::http::HttpErrorToString(status), document); + status, olp::http::HttpErrorToString(status), + ec.failed() || !document.is_object() + ? nullptr + : std::make_shared( + std::move(document.as_object()))); } template @@ -361,23 +361,24 @@ client::CancellationToken AuthenticationClientImpl::SignInClient( TimeResponse AuthenticationClientImpl::ParseTimeResponse( std::stringstream& payload) { - rapidjson::Document document; - rapidjson::IStreamWrapper stream(payload); - document.ParseStream(stream); + boost::json::error_code ec; + auto json_value = boost::json::parse(payload, ec); - if (!document.IsObject()) { + if (ec.failed() || !json_value.is_object()) { return client::ApiError(client::ErrorCode::InternalFailure, "JSON document root is not an Object type"); } - const auto timestamp_it = document.FindMember("timestamp"); - if (timestamp_it == document.MemberEnd() || !timestamp_it->value.IsUint()) { + auto& object = json_value.as_object(); + const auto timestamp_it = object.find("timestamp"); + if (timestamp_it == object.end() || (!timestamp_it->value().is_uint64() && + !timestamp_it->value().is_int64())) { return client::ApiError( client::ErrorCode::InternalFailure, "JSON document must contain timestamp integer field"); } - return timestamp_it->value.GetUint(); + return timestamp_it->value().to_number(); } TimeResponse AuthenticationClientImpl::GetTimeFromServer( @@ -586,10 +587,14 @@ client::CancellationToken AuthenticationClientImpl::SignUpHereUser( return client::ApiError(status, response_text); } - auto document = std::make_shared(); - document->Parse(response_text.c_str()); + boost::json::error_code ec; + auto document = boost::json::parse(response_text, ec); return {std::make_shared( - status, olp::http::HttpErrorToString(status), document)}; + status, olp::http::HttpErrorToString(status), + ec.failed() || !document.is_object() + ? nullptr + : std::make_shared( + std::move(document.as_object())))}; }; return AddTask(settings_.task_scheduler, pending_requests_, @@ -631,10 +636,14 @@ client::CancellationToken AuthenticationClientImpl::SignOut( return client::ApiError(status, response_text); } - auto document = std::make_shared(); - document->Parse(response_text.c_str()); + boost::json::error_code ec; + auto document = boost::json::parse(response_text, ec); return {std::make_shared( - status, olp::http::HttpErrorToString(status), document)}; + status, olp::http::HttpErrorToString(status), + ec.failed() || !document.is_object() + ? nullptr + : std::make_shared( + std::move(document.as_object())))}; }; return AddTask(settings_.task_scheduler, pending_requests_, @@ -664,24 +673,23 @@ client::CancellationToken AuthenticationClientImpl::IntrospectApp( auto http_result = client.CallApi(kIntrospectAppEndpoint, "GET", {}, {}, {}, nullptr, {}, context); - rapidjson::Document document; - rapidjson::IStreamWrapper stream(http_result.GetRawResponse()); - document.ParseStream(stream); + boost::json::error_code ec; + auto document = boost::json::parse(http_result.GetRawResponse(), ec); if (http_result.GetStatus() != http::HttpStatusCode::OK) { // HttpResult response can be error message or valid json with it. std::string msg = http_result.GetResponseAsString(); - if (!document.HasParseError() && document.HasMember(Constants::MESSAGE)) { - msg = document[Constants::MESSAGE].GetString(); + if (!ec.failed() && document.as_object().contains(Constants::MESSAGE)) { + msg = document.as_object()[Constants::MESSAGE].as_string().c_str(); } return client::ApiError({http_result.GetStatus(), msg}); } - if (document.HasParseError()) { + if (ec.failed() || !document.is_object()) { return client::ApiError({static_cast(http::ErrorCode::UNKNOWN_ERROR), "Failed to parse response"}); } - return GetIntrospectAppResult(document); + return GetIntrospectAppResult(document.as_object()); }; return AddTask(settings_.task_scheduler, pending_requests_, @@ -711,25 +719,27 @@ client::CancellationToken AuthenticationClientImpl::Authorize( GenerateAuthorizeBody(request), kApplicationJson, context); - rapidjson::Document document; - rapidjson::IStreamWrapper stream(http_result.GetRawResponse()); - document.ParseStream(stream); + boost::json::error_code ec; + auto document = boost::json::parse(http_result.GetRawResponse(), ec); if (http_result.GetStatus() != http::HttpStatusCode::OK) { // HttpResult response can be error message or valid json with it. std::string msg = http_result.GetResponseAsString(); - if (!document.HasParseError() && document.HasMember(Constants::MESSAGE)) { - msg = document[Constants::MESSAGE].GetString(); + if (!ec.failed() && document.as_object().contains(Constants::MESSAGE)) { + msg = document.as_object()[Constants::MESSAGE].as_string().c_str(); } return client::ApiError({http_result.GetStatus(), msg}); - } else if (!document.HasParseError() && - document.HasMember(Constants::ERROR_CODE) && - document[Constants::ERROR_CODE].IsInt()) { + } + + if (!ec.failed() && document.as_object().contains(Constants::ERROR_CODE) && + document.as_object()[Constants::ERROR_CODE].is_int64()) { std::string msg = "Error code: " + - std::to_string(document[Constants::ERROR_CODE].GetInt()); - if (document.HasMember(Constants::MESSAGE)) { + std::to_string( + document.as_object()[Constants::ERROR_CODE].as_int64()); + if (document.as_object().contains(Constants::MESSAGE)) { msg.append(" ("); - msg.append(document[Constants::MESSAGE].GetString()); + msg.append( + document.as_object()[Constants::MESSAGE].as_string().c_str()); msg.append(")"); } @@ -737,12 +747,12 @@ client::CancellationToken AuthenticationClientImpl::Authorize( {static_cast(http::ErrorCode::UNKNOWN_ERROR), msg}); } - if (document.HasParseError()) { + if (ec.failed() || !document.is_object()) { return client::ApiError({static_cast(http::ErrorCode::UNKNOWN_ERROR), "Failed to parse response"}); } - return GetAuthorizeResult(document); + return GetAuthorizeResult(document.as_object()); }; return AddTask(settings_.task_scheduler, pending_requests_, std::move(task), @@ -778,237 +788,186 @@ client::CancellationToken AuthenticationClientImpl::GetMyAccount( client::OlpClient::RequestBodyType AuthenticationClientImpl::GenerateClientBody( const SignInProperties& properties) { - rapidjson::StringBuffer data; - rapidjson::Writer writer(data); - writer.StartObject(); + boost::json::object object; - writer.Key(kGrantType); - writer.String(kClientGrantType); + object[kGrantType] = kClientGrantType; auto expires_in = static_cast(properties.expires_in.count()); if (expires_in > 0) { - writer.Key(Constants::EXPIRES_IN); - writer.Uint(expires_in); + object[Constants::EXPIRES_IN] = expires_in; } if (properties.scope) { - writer.Key(kScope); - writer.String(properties.scope.get().c_str()); + object[kScope] = properties.scope.get(); } if (properties.device_id) { - writer.Key(kDeviceId); - writer.String(properties.device_id.get().c_str()); + object[kDeviceId] = properties.device_id.get(); } - writer.EndObject(); - auto content = data.GetString(); - return std::make_shared(content, content + data.GetSize()); + auto content = boost::json::serialize(object); + return std::make_shared(content.begin(), content.end()); } client::OlpClient::RequestBodyType AuthenticationClientImpl::GenerateUserBody( const UserProperties& properties) { - rapidjson::StringBuffer data; - rapidjson::Writer writer(data); - writer.StartObject(); + boost::json::object object; - writer.Key(kGrantType); - writer.String(kUserGrantType); + object[kGrantType] = kUserGrantType; if (!properties.email.empty()) { - writer.Key(kEmail); - writer.String(properties.email.c_str()); + object[kEmail] = properties.email; } if (!properties.password.empty()) { - writer.Key(kPassword); - writer.String(properties.password.c_str()); + object[kPassword] = properties.password; } if (properties.expires_in > 0) { - writer.Key(Constants::EXPIRES_IN); - writer.Uint(properties.expires_in); + object[Constants::EXPIRES_IN] = properties.expires_in; } - writer.EndObject(); - auto content = data.GetString(); - return std::make_shared(content, content + data.GetSize()); + + auto content = boost::json::serialize(object); + return std::make_shared(content.begin(), content.end()); } client::OlpClient::RequestBodyType AuthenticationClientImpl::GenerateFederatedBody( const FederatedSignInType type, const FederatedProperties& properties) { - rapidjson::StringBuffer data; - rapidjson::Writer writer(data); - writer.StartObject(); + boost::json::object object; - writer.Key(kGrantType); switch (type) { case FederatedSignInType::FacebookSignIn: - writer.String(kFacebookGrantType); + object[kGrantType] = kFacebookGrantType; break; case FederatedSignInType::ArcgisSignIn: - writer.String(kArcgisGrantType); + object[kGrantType] = kArcgisGrantType; break; default: return nullptr; } if (!properties.access_token.empty()) { - writer.Key(Constants::ACCESS_TOKEN); - writer.String(properties.access_token.c_str()); + object[Constants::ACCESS_TOKEN] = properties.access_token; } if (!properties.country_code.empty()) { - writer.Key(kCountryCode); - writer.String(properties.country_code.c_str()); + object[kCountryCode] = properties.country_code; } if (!properties.language.empty()) { - writer.Key(kLanguage); - writer.String(properties.language.c_str()); + object[kLanguage] = properties.language; } if (!properties.email.empty()) { - writer.Key(kEmail); - writer.String(properties.email.c_str()); + object[kEmail] = properties.email; } if (properties.expires_in > 0) { - writer.Key(Constants::EXPIRES_IN); - writer.Uint(properties.expires_in); + object[Constants::EXPIRES_IN] = properties.expires_in; } - writer.EndObject(); - auto content = data.GetString(); - return std::make_shared(content, content + data.GetSize()); + auto content = boost::json::serialize(object); + return std::make_shared(content.begin(), content.end()); } client::OlpClient::RequestBodyType AuthenticationClientImpl::GenerateRefreshBody( const RefreshProperties& properties) { - rapidjson::StringBuffer data; - rapidjson::Writer writer(data); - writer.StartObject(); + boost::json::object object; - writer.Key(kGrantType); - writer.String(kRefreshGrantType); + object[kGrantType] = kRefreshGrantType; if (!properties.access_token.empty()) { - writer.Key(Constants::ACCESS_TOKEN); - writer.String(properties.access_token.c_str()); + object[Constants::ACCESS_TOKEN] = properties.access_token; } if (!properties.refresh_token.empty()) { - writer.Key(Constants::REFRESH_TOKEN); - writer.String(properties.refresh_token.c_str()); + object[Constants::REFRESH_TOKEN] = properties.refresh_token; } if (properties.expires_in > 0) { - writer.Key(Constants::EXPIRES_IN); - writer.Uint(properties.expires_in); + object[Constants::EXPIRES_IN] = properties.expires_in; } - writer.EndObject(); - auto content = data.GetString(); - return std::make_shared(content, content + data.GetSize()); + + auto content = boost::json::serialize(object); + return std::make_shared(content.begin(), content.end()); } client::OlpClient::RequestBodyType AuthenticationClientImpl::GenerateSignUpBody( const SignUpProperties& properties) { - rapidjson::StringBuffer data; - rapidjson::Writer writer(data); - writer.StartObject(); + boost::json::object object; if (!properties.email.empty()) { - writer.Key(kEmail); - writer.String(properties.email.c_str()); + object[kEmail] = properties.email; } if (!properties.password.empty()) { - writer.Key(kPassword); - writer.String(properties.password.c_str()); + object[kPassword] = properties.password; } if (!properties.date_of_birth.empty()) { - writer.Key(kDateOfBirth); - writer.String(properties.date_of_birth.c_str()); + object[kDateOfBirth] = properties.date_of_birth; } if (!properties.first_name.empty()) { - writer.Key(kFirstName); - writer.String(properties.first_name.c_str()); + object[kFirstName] = properties.first_name; } if (!properties.last_name.empty()) { - writer.Key(kLastName); - writer.String(properties.last_name.c_str()); + object[kLastName] = properties.last_name; } if (!properties.country_code.empty()) { - writer.Key(kCountryCode); - writer.String(properties.country_code.c_str()); + object[kCountryCode] = properties.country_code; } if (!properties.language.empty()) { - writer.Key(kLanguage); - writer.String(properties.language.c_str()); + object[kLanguage] = properties.language; } if (properties.marketing_enabled) { - writer.Key(kMarketingEnabled); - writer.Bool(true); + object[kMarketingEnabled] = true; } if (!properties.phone_number.empty()) { - writer.Key(kPhoneNumber); - writer.String(properties.phone_number.c_str()); + object[kPhoneNumber] = properties.phone_number; } if (!properties.realm.empty()) { - writer.Key(kRealm); - writer.String(properties.realm.c_str()); + object[kRealm] = properties.realm; } if (!properties.invite_token.empty()) { - writer.Key(kInviteToken); - writer.String(properties.invite_token.c_str()); + object[kInviteToken] = properties.invite_token; } - writer.EndObject(); - auto content = data.GetString(); - return std::make_shared(content, content + data.GetSize()); + auto content = boost::json::serialize(object); + return std::make_shared(content.begin(), content.end()); } client::OlpClient::RequestBodyType AuthenticationClientImpl::GenerateAcceptTermBody( const std::string& reacceptance_token) { - rapidjson::StringBuffer data; - rapidjson::Writer writer(data); - writer.StartObject(); + boost::json::object object; - writer.Key(kTermsReacceptanceToken); - writer.String(reacceptance_token.c_str()); + object[kTermsReacceptanceToken] = reacceptance_token; - writer.EndObject(); - auto content = data.GetString(); - return std::make_shared(content, content + data.GetSize()); + auto content = boost::json::serialize(object); + return std::make_shared(content.begin(), content.end()); } client::OlpClient::RequestBodyType AuthenticationClientImpl::GenerateAuthorizeBody( const AuthorizeRequest& properties) { - rapidjson::StringBuffer data; - rapidjson::Writer writer(data); - writer.StartObject(); - writer.Key(kServiceId); - writer.String(properties.GetServiceId().c_str()); - writer.Key(kActions); - writer.StartArray(); - for (const auto& action : properties.GetActions()) { - writer.StartObject(); - writer.Key(kAction); - writer.String(action.first.c_str()); - if (!action.second.empty()) { - writer.Key(kResource); - writer.String(action.second.c_str()); + boost::json::object object; + + object[kServiceId] = properties.GetServiceId(); + + { + boost::json::array actions; + for (const auto& action : properties.GetActions()) { + boost::json::object action_value; + action_value[kAction] = action.first; + if (!action.second.empty()) { + action_value.emplace(kResource, action.second); + } + actions.emplace_back(std::move(action_value)); } - writer.EndObject(); + object.emplace(kActions, std::move(actions)); } - writer.EndArray(); - writer.Key(kDiagnostics); - writer.Bool(properties.GetDiagnostics()); + object[kDiagnostics] = properties.GetDiagnostics(); // default value is 'and', ignore parameter if operator type is 'and' if (properties.GetOperatorType() == AuthorizeRequest::DecisionOperatorType::kOr) { - writer.Key(kOperator); - writer.String("or"); + object[kOperator] = "or"; } - writer.EndObject(); - auto content = data.GetString(); - return std::make_shared(content, content + data.GetSize()); + auto content = boost::json::serialize(object); + return std::make_shared(content.begin(), content.end()); } std::string AuthenticationClientImpl::GenerateUid() const { diff --git a/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.cpp b/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.cpp index 3ff6616c2..ac265fee5 100644 --- a/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.cpp +++ b/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2024 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,10 +24,9 @@ #include #include -#include -#include -#include -#include +#include +#include +#include #include "Constants.h" #include "ResponseFromJsonBuilder.h" #include "olp/core/http/NetworkResponse.h" @@ -70,25 +69,25 @@ std::string Base64Encode(const Crypto::Sha256Digest& digest) { return ret; } -Response Parse(client::HttpResponse& http_response) { - rapidjson::IStreamWrapper stream(http_response.GetRawResponse()); - rapidjson::Document document; - document.ParseStream(stream); +Response Parse(client::HttpResponse& http_response) { + boost::json::error_code ec; + auto document = boost::json::parse(http_response.GetRawResponse(), ec); if (http_response.GetStatus() != http::HttpStatusCode::OK) { // HttpResult response can be error message or valid json with it. std::string msg = http_response.GetResponseAsString(); - if (!document.HasParseError() && document.HasMember(Constants::MESSAGE)) { - msg = document[Constants::MESSAGE].GetString(); + if (!ec.failed() && document.is_object() && + document.as_object().contains(Constants::MESSAGE)) { + msg = document.as_object()[Constants::MESSAGE].get_string().c_str(); } return client::ApiError({http_response.GetStatus(), msg}); } - if (document.HasParseError()) { + if (ec.failed() || !document.is_object()) { return client::ApiError({static_cast(http::ErrorCode::UNKNOWN_ERROR), "Failed to parse response"}); } - return Response(std::move(document)); + return {std::move(document).as_object()}; } } // namespace @@ -137,7 +136,7 @@ boost::optional GetTimestampFromHeaders( return boost::none; } -IntrospectAppResult GetIntrospectAppResult(const rapidjson::Document& doc) { +IntrospectAppResult GetIntrospectAppResult(const boost::json::object& doc) { return ResponseFromJsonBuilder::Build(doc) .Value(Constants::CLIENT_ID, &IntrospectAppResult::SetClientId) .Value(Constants::NAME, &IntrospectAppResult::SetName) @@ -168,22 +167,25 @@ DecisionType GetDecision(const std::string& str) { : DecisionType::kDeny; } -std::vector GetDiagnostics(rapidjson::Document& doc) { +std::vector GetDiagnostics(boost::json::object& doc) { std::vector results; - const auto& array = doc[Constants::DIAGNOSTICS].GetArray(); - for (auto& element : array) { + auto& array = doc[Constants::DIAGNOSTICS].get_array(); + for (auto& element_value : array) { + auto& element = element_value.get_object(); ActionResult action; - if (element.HasMember(Constants::DECISION)) { - action.SetDecision(GetDecision(element[Constants::DECISION].GetString())); + if (element.contains(Constants::DECISION)) { + action.SetDecision( + GetDecision(element[Constants::DECISION].get_string().c_str())); // get permissions if avialible - if (element.HasMember(Constants::PERMISSIONS) && - element[Constants::PERMISSIONS].IsArray()) { + if (element.contains(Constants::PERMISSIONS) && + element[Constants::PERMISSIONS].is_array()) { std::vector permissions; const auto& permissions_array = - element[Constants::PERMISSIONS].GetArray(); + element[Constants::PERMISSIONS].get_array(); for (auto& permission_element : permissions_array) { Permission permission = - ResponseFromJsonBuilder::Build(permission_element) + ResponseFromJsonBuilder::Build( + permission_element.get_object()) .Value(Constants::ACTION, &Permission::SetAction) .Value(Constants::DECISION, &Permission::SetDecision, &GetDecision) @@ -200,26 +202,27 @@ std::vector GetDiagnostics(rapidjson::Document& doc) { return results; } -AuthorizeResult GetAuthorizeResult(rapidjson::Document& doc) { +AuthorizeResult GetAuthorizeResult(boost::json::object& doc) { AuthorizeResult result; - if (doc.HasMember(Constants::IDENTITY)) { - auto uris = doc[Constants::IDENTITY].GetObject(); + if (doc.contains(Constants::IDENTITY)) { + auto uris = doc[Constants::IDENTITY].get_object(); - if (uris.HasMember(Constants::CLIENT_ID)) { - result.SetClientId(uris[Constants::CLIENT_ID].GetString()); - } else if (uris.HasMember(Constants::USER_ID)) { - result.SetClientId(uris[Constants::USER_ID].GetString()); + if (uris.contains(Constants::CLIENT_ID)) { + result.SetClientId(uris[Constants::CLIENT_ID].get_string().c_str()); + } else if (uris.contains(Constants::USER_ID)) { + result.SetClientId(uris[Constants::USER_ID].get_string().c_str()); } } - if (doc.HasMember(Constants::DECISION)) { - result.SetDecision(GetDecision(doc[Constants::DECISION].GetString())); + if (doc.contains(Constants::DECISION)) { + result.SetDecision( + GetDecision(doc[Constants::DECISION].get_string().c_str())); } // get diagnostics if available - if (doc.HasMember(Constants::DIAGNOSTICS) && - doc[Constants::DIAGNOSTICS].IsArray()) { + if (doc.contains(Constants::DIAGNOSTICS) && + doc[Constants::DIAGNOSTICS].is_array()) { result.SetActionResults(GetDiagnostics(doc)); } return result; diff --git a/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.h b/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.h index 2b5af2fc4..e80a76736 100644 --- a/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.h +++ b/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ #include #include -#include +#include #include "olp/authentication/AuthenticationCredentials.h" #include "olp/authentication/AuthenticationSettings.h" @@ -78,7 +78,7 @@ boost::optional GetTimestampFromHeaders( * @param doc json document. * @return result for introspect app. */ -IntrospectAppResult GetIntrospectAppResult(const rapidjson::Document& doc); +IntrospectAppResult GetIntrospectAppResult(const boost::json::object& value); /* * @brief Convert string representation of decision to DecisionType. @@ -92,14 +92,14 @@ DecisionType GetDecision(const std::string& str); * @param doc json document. * @return result of ActionResults. */ -std::vector GetDiagnostics(rapidjson::Document& doc); +std::vector GetDiagnostics(boost::json::object& value); /* * @brief Parse json document to AuthorizeResult type. * @param doc json document. * @return result for authorize. */ -AuthorizeResult GetAuthorizeResult(rapidjson::Document& doc); +AuthorizeResult GetAuthorizeResult(boost::json::object& value); /* * @brief Parse HTTP response to UserAccountInfoResponse type or error message. diff --git a/olp-cpp-sdk-authentication/src/BaseResult.cpp b/olp-cpp-sdk-authentication/src/BaseResult.cpp index edd86f7c9..5f07690d6 100644 --- a/olp-cpp-sdk-authentication/src/BaseResult.cpp +++ b/olp-cpp-sdk-authentication/src/BaseResult.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,8 +19,8 @@ #include "BaseResult.h" -#include -#include +#include +#include #include "Constants.h" #include "olp/core/http/HttpStatusCode.h" @@ -35,52 +35,49 @@ static const char* ERROR_MESSAGE = "message"; static const char* LINE_END = "."; BaseResult::BaseResult(int status, std::string error, - std::shared_ptr json_document) + std::shared_ptr json_document) : status_() { status_ = status; error_.message = std::move(error); - is_valid_ = (json_document && !json_document->HasParseError()); + is_valid_ = json_document != nullptr; // If HTTP error, try to get error details - if (!HasError() || !is_valid_ || !json_document->HasMember(ERROR_CODE)) { + if (!HasError() || !is_valid_ || !json_document->contains(ERROR_CODE)) { return; } // The JSON document has an error code member, so save full JSON content to // the `full_message_` string. - rapidjson::StringBuffer buffer; - rapidjson::Writer writer(buffer); - json_document->Accept(writer); - full_message_ = buffer.GetString(); + full_message_ = boost::json::serialize(*json_document); - if (json_document->HasMember(ERROR_ID)) { - error_.error_id = (*json_document)[ERROR_ID].GetString(); + if (json_document->contains(ERROR_ID)) { + error_.error_id = (*json_document)[ERROR_ID].get_string().c_str(); } // Enhance error message with network response error details - error_.code = (*json_document)[ERROR_CODE].GetUint(); + error_.code = (*json_document)[ERROR_CODE].to_number(); - if (!json_document->HasMember(ERROR_MESSAGE)) { + if (!json_document->contains(ERROR_MESSAGE)) { return; } - std::string message = (*json_document)[ERROR_MESSAGE].GetString(); - if (!json_document->HasMember(ERROR_FIELDS)) { + std::string message = (*json_document)[ERROR_MESSAGE].get_string().c_str(); + if (!json_document->contains(ERROR_FIELDS)) { error_.message = message; return; } error_.message = message.substr(0, message.find_first_of(LINE_END) + 1); - const rapidjson::Value& fields = (*json_document)[ERROR_FIELDS]; - if (fields.GetType() == rapidjson::kArrayType) { - for (rapidjson::SizeType i = 0u; i < fields.Size(); i++) { - const rapidjson::Value& field = fields[i]; - if (field.HasMember(ERROR_MESSAGE)) { + auto& fields = (*json_document)[ERROR_FIELDS]; + if (auto* fields_array = fields.if_array()) { + for (auto& field : *fields_array) { + if (field.is_object() && field.as_object().contains(ERROR_MESSAGE)) { ErrorField error_field; - error_field.name = field[FIELD_NAME].GetString(); - error_field.code = field[ERROR_CODE].GetUint(); - error_field.message = field[ERROR_MESSAGE].GetString(); + error_field.name = field.as_object()[FIELD_NAME].get_string().c_str(); + error_field.code = field.as_object()[ERROR_CODE].to_number(); + error_field.message = + field.as_object()[ERROR_MESSAGE].get_string().c_str(); error_fields_.emplace_back(error_field); } } diff --git a/olp-cpp-sdk-authentication/src/BaseResult.h b/olp-cpp-sdk-authentication/src/BaseResult.h index cd581275f..802bb2605 100644 --- a/olp-cpp-sdk-authentication/src/BaseResult.h +++ b/olp-cpp-sdk-authentication/src/BaseResult.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ #include #include -#include +#include #include "olp/authentication/ErrorResponse.h" @@ -33,7 +33,7 @@ namespace authentication { class BaseResult { public: BaseResult(int status, std::string error, - std::shared_ptr json_document = nullptr); + std::shared_ptr json_document = nullptr); virtual ~BaseResult(); /** diff --git a/olp-cpp-sdk-authentication/src/ResponseFromJsonBuilder.h b/olp-cpp-sdk-authentication/src/ResponseFromJsonBuilder.h index 8d4ee37d5..49764d7ca 100644 --- a/olp-cpp-sdk-authentication/src/ResponseFromJsonBuilder.h +++ b/olp-cpp-sdk-authentication/src/ResponseFromJsonBuilder.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,8 @@ struct Identity { template class ResponseFromJsonBuilder { - using JsonValue = rapidjson::Document::ValueType; + using JsonDoc = boost::json::object; + using JsonValue = boost::json::value; public: template @@ -46,16 +47,16 @@ class ResponseFromJsonBuilder { const std::string kLogTag = "ResponseFromJsonBuilder"; public: - explicit BuilderHelper(const JsonValue& json_value) : json_{json_value} {} + explicit BuilderHelper(const JsonDoc& json_value) : json_{json_value} {} template BuilderHelper& Value(const char* name, void (TargetType::*set_fn)(ArgType), Projection projection = {}) { using CompatibleType = decltype(GetCompatibleType()); fields_.emplace(name, [=](TargetType& target_obj, - const JsonValue& value) { - if (value.Is()) { - (target_obj.*set_fn)(projection(value.Get())); + const JsonValue& json_value) { + if (auto value = If(json_value)) { + (target_obj.*set_fn)(projection(*value)); } else { OLP_SDK_LOG_WARNING_F(kLogTag, "Wrong type, response=%s, field=%s", kTargetTypeName.c_str(), name); @@ -71,13 +72,13 @@ class ResponseFromJsonBuilder { decltype(GetCompatibleType()); fields_.emplace(name, [=](TargetType& target_obj, const JsonValue& value) { - if (value.IsArray()) { - const auto& array = value.GetArray(); + if (value.is_array()) { + const auto& array = value.get_array(); ArrayType array_result; - array_result.reserve(array.Size()); + array_result.reserve(array.size()); for (const auto& element : array) { - if (element.Is()) { - array_result.push_back(element.Get()); + if (auto element_value = If(element)) { + array_result.push_back(*element_value); } } (target_obj.*set_fn)(std::move(array_result)); @@ -92,12 +93,12 @@ class ResponseFromJsonBuilder { TargetType Finish() { TargetType result; - auto it = json_.MemberBegin(); - auto it_end = json_.MemberEnd(); + auto it = json_.cbegin(); + auto it_end = json_.cend(); for (; it != it_end; ++it) { - auto find_it = fields_.find(std::string{it->name.GetString()}); + auto find_it = fields_.find(std::string{it->key_c_str()}); if (find_it != fields_.end()) { - find_it->second(result, it->value); + find_it->second(result, it->value()); // erasing already processed value fields_.erase(find_it); continue; @@ -105,7 +106,7 @@ class ResponseFromJsonBuilder { OLP_SDK_LOG_WARNING_F(kLogTag, "Unexpected value, response=%s, field=%s", - kTargetTypeName.c_str(), it->name.GetString()); + kTargetTypeName.c_str(), it->key_c_str()); } // in the ideal scenario all fields should be processed @@ -133,11 +134,39 @@ class ResponseFromJsonBuilder { std::is_same::value>::type> int64_t GetCompatibleType(); + template ::value>::type> + const bool* If(const JsonValue& value) { + return value.if_bool(); + } + + template ::value || + std::is_same::value>::type> + const int64_t* If(const JsonValue& value) { + return value.if_int64(); + } + + template ::value>::type> + const uint64_t* If(const JsonValue& value) { + return value.if_uint64(); + } + + template ::value>::type> + boost::optional If(const JsonValue& value) { + if (auto* str = value.if_string()) { + return str->c_str(); + } + return nullptr; + } + using Fields = std::unordered_map>; - const JsonValue& json_; + const JsonDoc& json_; Fields fields_; }; diff --git a/olp-cpp-sdk-authentication/src/SignInResultImpl.cpp b/olp-cpp-sdk-authentication/src/SignInResultImpl.cpp index da162ab2c..e3f614130 100644 --- a/olp-cpp-sdk-authentication/src/SignInResultImpl.cpp +++ b/olp-cpp-sdk-authentication/src/SignInResultImpl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,14 +37,14 @@ SignInResultImpl::SignInResultImpl() noexcept SignInResultImpl::SignInResultImpl( int status, std::string error, - std::shared_ptr json_document) noexcept + std::shared_ptr json_document) noexcept : BaseResult(status, std::move(error), json_document), expiry_time_(), expires_in_() { is_valid_ = this->BaseResult::IsValid() && - json_document->HasMember(Constants::ACCESS_TOKEN) && - json_document->HasMember(kTokenType) && - json_document->HasMember(Constants::EXPIRES_IN); + json_document->contains(Constants::ACCESS_TOKEN) && + json_document->contains(kTokenType) && + json_document->contains(Constants::EXPIRES_IN); // Extra response data if no errors reported if (!HasError()) { @@ -52,22 +52,25 @@ SignInResultImpl::SignInResultImpl( status_ = http::HttpStatusCode::SERVICE_UNAVAILABLE; error_.message = Constants::ERROR_HTTP_SERVICE_UNAVAILABLE; } else { - if (json_document->HasMember(Constants::ACCESS_TOKEN)) - access_token_ = (*json_document)[Constants::ACCESS_TOKEN].GetString(); - if (json_document->HasMember(kTokenType)) - token_type_ = (*json_document)[kTokenType].GetString(); - if (json_document->HasMember(Constants::REFRESH_TOKEN)) - refresh_token_ = (*json_document)[Constants::REFRESH_TOKEN].GetString(); - if (json_document->HasMember(Constants::EXPIRES_IN)) { - expiry_time_ = std::time(nullptr) + - (*json_document)[Constants::EXPIRES_IN].GetUint(); + if (json_document->contains(Constants::ACCESS_TOKEN)) + access_token_ = + (*json_document)[Constants::ACCESS_TOKEN].get_string().c_str(); + if (json_document->contains(kTokenType)) + token_type_ = (*json_document)[kTokenType].get_string().c_str(); + if (json_document->contains(Constants::REFRESH_TOKEN)) + refresh_token_ = + (*json_document)[Constants::REFRESH_TOKEN].get_string().c_str(); + if (json_document->contains(Constants::EXPIRES_IN)) { + expiry_time_ = + std::time(nullptr) + + (*json_document)[Constants::EXPIRES_IN].to_number(); expires_in_ = std::chrono::seconds( - (*json_document)[Constants::EXPIRES_IN].GetUint()); + (*json_document)[Constants::EXPIRES_IN].to_number()); } - if (json_document->HasMember(kUserId)) - user_identifier_ = (*json_document)[kUserId].GetString(); - if (json_document->HasMember(kScope)) - scope_ = (*json_document)[kScope].GetString(); + if (json_document->contains(kUserId)) + user_identifier_ = (*json_document)[kUserId].get_string().c_str(); + if (json_document->contains(kScope)) + scope_ = (*json_document)[kScope].get_string().c_str(); } } } diff --git a/olp-cpp-sdk-authentication/src/SignInResultImpl.h b/olp-cpp-sdk-authentication/src/SignInResultImpl.h index 1712f443f..0ad6e02e6 100644 --- a/olp-cpp-sdk-authentication/src/SignInResultImpl.h +++ b/olp-cpp-sdk-authentication/src/SignInResultImpl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,10 +19,10 @@ #pragma once +#include #include #include #include -#include #include "BaseResult.h" @@ -34,7 +34,7 @@ class SignInResultImpl : public BaseResult { SignInResultImpl( int status, std::string error, - std::shared_ptr json_document = nullptr) noexcept; + std::shared_ptr json_document = nullptr) noexcept; ~SignInResultImpl() override; @@ -65,7 +65,7 @@ class SignInResultImpl : public BaseResult { */ time_t GetExpiryTime() const; - /** + /** * @brief Gets the access token expiry time in seconds. * @return Duration for which token stays valid. */ diff --git a/olp-cpp-sdk-authentication/src/SignInUserResultImpl.cpp b/olp-cpp-sdk-authentication/src/SignInUserResultImpl.cpp index 36530f40d..c15941619 100644 --- a/olp-cpp-sdk-authentication/src/SignInUserResultImpl.cpp +++ b/olp-cpp-sdk-authentication/src/SignInUserResultImpl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,23 +40,24 @@ SignInUserResultImpl::SignInUserResultImpl() noexcept SignInUserResultImpl::SignInUserResultImpl( int status, std::string error, - std::shared_ptr json_document) noexcept + std::shared_ptr json_document) noexcept : SignInResultImpl(status, std::move(error), json_document) { if (BaseResult::IsValid()) { - if (json_document->HasMember(kTermsReacceptanceToken)) + if (json_document->contains(kTermsReacceptanceToken)) term_acceptance_token_ = - (*json_document)[kTermsReacceptanceToken].GetString(); - if (json_document->HasMember(kTermsUrls)) { - rapidjson::Document::Object obj = - (*json_document)[kTermsUrls].GetObject(); - if (obj.HasMember(kTermsOfServiceUrl)) - terms_of_service_url_ = obj[kTermsOfServiceUrl].GetString(); - if (obj.HasMember(kTermsOfServiceUrlJson)) - terms_of_service_url_json_ = obj[kTermsOfServiceUrlJson].GetString(); - if (obj.HasMember(kPrivatePolicyUrl)) - private_policy_url_ = obj[kPrivatePolicyUrl].GetString(); - if (obj.HasMember(kPrivatePolicyUrlJson)) - private_policy_url_json_ = obj[kPrivatePolicyUrlJson].GetString(); + (*json_document)[kTermsReacceptanceToken].get_string().c_str(); + if (json_document->contains(kTermsUrls)) { + auto& obj = (*json_document)[kTermsUrls].get_object(); + if (obj.contains(kTermsOfServiceUrl)) + terms_of_service_url_ = obj[kTermsOfServiceUrl].get_string().c_str(); + if (obj.contains(kTermsOfServiceUrlJson)) + terms_of_service_url_json_ = + obj[kTermsOfServiceUrlJson].get_string().c_str(); + if (obj.contains(kPrivatePolicyUrl)) + private_policy_url_ = obj[kPrivatePolicyUrl].get_string().c_str(); + if (obj.contains(kPrivatePolicyUrlJson)) + private_policy_url_json_ = + obj[kPrivatePolicyUrlJson].get_string().c_str(); } } } diff --git a/olp-cpp-sdk-authentication/src/SignInUserResultImpl.h b/olp-cpp-sdk-authentication/src/SignInUserResultImpl.h index c6fd5218c..020a7d106 100644 --- a/olp-cpp-sdk-authentication/src/SignInUserResultImpl.h +++ b/olp-cpp-sdk-authentication/src/SignInUserResultImpl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ class SignInUserResultImpl : public SignInResultImpl { SignInUserResultImpl( int status, std::string error, - std::shared_ptr json_document = nullptr) noexcept; + std::shared_ptr json_document = nullptr) noexcept; ~SignInUserResultImpl() override; diff --git a/olp-cpp-sdk-authentication/src/SignOutResultImpl.cpp b/olp-cpp-sdk-authentication/src/SignOutResultImpl.cpp index d223919f4..447471d06 100644 --- a/olp-cpp-sdk-authentication/src/SignOutResultImpl.cpp +++ b/olp-cpp-sdk-authentication/src/SignOutResultImpl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ SignOutResultImpl::SignOutResultImpl() noexcept SignOutResultImpl::SignOutResultImpl( int status, std::string error, - std::shared_ptr json_document) noexcept + std::shared_ptr json_document) noexcept : BaseResult(status, std::move(error), json_document) {} SignOutResultImpl::~SignOutResultImpl() = default; diff --git a/olp-cpp-sdk-authentication/src/SignOutResultImpl.h b/olp-cpp-sdk-authentication/src/SignOutResultImpl.h index 8c13229db..6a7c8baf3 100644 --- a/olp-cpp-sdk-authentication/src/SignOutResultImpl.h +++ b/olp-cpp-sdk-authentication/src/SignOutResultImpl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ class SignOutResultImpl : public BaseResult { SignOutResultImpl( int status, std::string error, - std::shared_ptr json_document = nullptr) noexcept; + std::shared_ptr json_document = nullptr) noexcept; ~SignOutResultImpl() override; }; diff --git a/olp-cpp-sdk-authentication/src/SignUpResultImpl.cpp b/olp-cpp-sdk-authentication/src/SignUpResultImpl.cpp index 27ea17db3..4fb5fadb3 100644 --- a/olp-cpp-sdk-authentication/src/SignUpResultImpl.cpp +++ b/olp-cpp-sdk-authentication/src/SignUpResultImpl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,11 +35,11 @@ SignUpResultImpl::SignUpResultImpl() noexcept SignUpResultImpl::SignUpResultImpl( int status, std::string error, - std::shared_ptr json_document) noexcept + std::shared_ptr json_document) noexcept : BaseResult(status, std::move(error), json_document) { if (BaseResult::IsValid()) { - if (json_document->HasMember(kUserId)) - user_identifier_ = (*json_document)[kUserId].GetString(); + if (json_document->contains(kUserId)) + user_identifier_ = (*json_document)[kUserId].get_string().c_str(); } } diff --git a/olp-cpp-sdk-authentication/src/SignUpResultImpl.h b/olp-cpp-sdk-authentication/src/SignUpResultImpl.h index 7434d8e0a..9eca11bbd 100644 --- a/olp-cpp-sdk-authentication/src/SignUpResultImpl.h +++ b/olp-cpp-sdk-authentication/src/SignUpResultImpl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ #include #include -#include +#include #include "BaseResult.h" @@ -35,7 +35,7 @@ class SignUpResultImpl : public BaseResult { SignUpResultImpl( int status, std::string error, - std::shared_ptr json_document = nullptr) noexcept; + std::shared_ptr json_document = nullptr) noexcept; ~SignUpResultImpl() override; diff --git a/olp-cpp-sdk-authentication/src/TokenEndpointImpl.cpp b/olp-cpp-sdk-authentication/src/TokenEndpointImpl.cpp index 5e38439d9..148d761c6 100644 --- a/olp-cpp-sdk-authentication/src/TokenEndpointImpl.cpp +++ b/olp-cpp-sdk-authentication/src/TokenEndpointImpl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2024 HERE Europe B.V. + * Copyright (C) 2021-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,10 +29,9 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include #include #include #include "AuthenticationClientUtils.h" @@ -102,22 +101,24 @@ void RetryDelay(const client::RetrySettings& retry_settings, size_t retry) { } TimeResponse ParseTimeResponse(const std::string& payload) { - rapidjson::Document document; - document.Parse(payload.c_str()); + boost::json::error_code ec; + auto document = boost::json::parse(payload, ec); - if (!document.IsObject()) { + if (!document.is_object()) { return client::ApiError(client::ErrorCode::InternalFailure, "JSON document root is not an Object type"); } - const auto timestamp_it = document.FindMember("timestamp"); - if (timestamp_it == document.MemberEnd() || !timestamp_it->value.IsUint()) { + const auto timestamp_it = document.as_object().find("timestamp"); + if (timestamp_it == document.as_object().end() || + (!timestamp_it->value().is_uint64() && + !timestamp_it->value().is_int64())) { return client::ApiError( client::ErrorCode::InternalFailure, "JSON document must contain timestamp integer field"); } - return timestamp_it->value.GetUint(); + return timestamp_it->value().to_number(); } std::string GenerateUid() { @@ -130,28 +131,22 @@ std::string GenerateUid() { client::OlpClient::RequestBodyType GenerateClientBody( const TokenRequest& token_request, const boost::optional& scope) { - rapidjson::StringBuffer data; - rapidjson::Writer writer(data); - writer.StartObject(); + boost::json::object object; - writer.Key(kGrantType); - writer.String(kClientGrantType); + object[kGrantType] = kClientGrantType; auto expires_in = static_cast(token_request.GetExpiresIn().count()); if (expires_in > 0) { - writer.Key(Constants::EXPIRES_IN); - writer.Uint(expires_in); + object[Constants::EXPIRES_IN] = expires_in; } if (scope) { - writer.Key(kScope); - writer.String(scope.get().c_str()); + object[kScope] = scope.get(); } - writer.EndObject(); - auto content = data.GetString(); - return std::make_shared(content, content + data.GetSize()); + auto content = boost::json::serialize(object); + return std::make_shared(content.begin(), content.end()); } TimeResponse GetTimeFromServer(client::CancellationContext& context, @@ -333,11 +328,13 @@ SignInResponse TokenEndpointImpl::SignInClient( SignInResult TokenEndpointImpl::ParseAuthResponse( int status, std::stringstream& auth_response) { - auto document = std::make_shared(); - rapidjson::IStreamWrapper stream(auth_response); - document->ParseStream(stream); + boost::json::error_code ec; + auto document = boost::json::parse(auth_response, ec); return std::make_shared( - status, http::HttpErrorToString(status), document); + status, http::HttpErrorToString(status), + ec.failed() || !document.is_object() + ? nullptr + : std::make_shared(document.as_object())); } client::HttpResponse TokenEndpointImpl::CallAuth( diff --git a/olp-cpp-sdk-core/CMakeLists.txt b/olp-cpp-sdk-core/CMakeLists.txt index 8264461dc..195f170c5 100644 --- a/olp-cpp-sdk-core/CMakeLists.txt +++ b/olp-cpp-sdk-core/CMakeLists.txt @@ -19,7 +19,6 @@ project(olp-cpp-sdk-core VERSION 1.21.0) set(DESCRIPTION "Core network and utility library for the HERE OLP SDK C++") -find_package(RapidJSON 1.1.0 REQUIRED) find_package(Boost REQUIRED) find_package(Threads REQUIRED) @@ -350,6 +349,7 @@ endif() set(OLP_SDK_UTILS_SOURCES ./src/utils/Base64.cpp ./src/utils/BoostExceptionHandle.cpp + ./src/utils/BoostJsonSrc.cpp ./src/utils/Credentials.cpp ./src/utils/Dir.cpp ./src/utils/Thread.cpp @@ -436,14 +436,15 @@ if (OLP_SDK_NO_EXCEPTION AND NOT OLP_SDK_BOOST_THROW_EXCEPTION_EXTERNAL) PRIVATE OLP_SDK_BOOST_THROW_EXCEPTION=1) endif() +target_compile_definitions(${PROJECT_NAME} + PRIVATE BOOST_ALL_NO_LIB) + target_include_directories(${PROJECT_NAME} PUBLIC $ $ $ $ - $ - $) if (ANDROID) diff --git a/olp-cpp-sdk-core/include/olp/core/generated/parser/JsonParser.h b/olp-cpp-sdk-core/include/olp/core/generated/parser/JsonParser.h index d5127e61e..b373e4d45 100644 --- a/olp-cpp-sdk-core/include/olp/core/generated/parser/JsonParser.h +++ b/olp-cpp-sdk-core/include/olp/core/generated/parser/JsonParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2024 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +24,7 @@ #include #include -#include -#include +#include #include "ParserWrapper.h" @@ -33,11 +32,11 @@ namespace olp { namespace parser { template inline T parse(const std::string& json) { - rapidjson::Document doc; - doc.Parse(json.c_str()); + boost::json::error_code ec; + auto value = boost::json::parse(json, ec); T result{}; - if (doc.IsObject() || doc.IsArray()) { - from_json(doc, result); + if (value.is_object() || value.is_array()) { + from_json(value, result); } return result; } @@ -45,12 +44,11 @@ inline T parse(const std::string& json) { template inline T parse(std::stringstream& json_stream, bool& res) { res = false; - rapidjson::Document doc; - rapidjson::IStreamWrapper stream(json_stream); - doc.ParseStream(stream); + boost::json::error_code ec; + auto value = boost::json::parse(json_stream, ec); T result{}; - if (doc.IsObject() || doc.IsArray()) { - from_json(doc, result); + if (value.is_object() || value.is_array()) { + from_json(value, result); res = true; } return result; @@ -64,11 +62,13 @@ inline T parse(std::stringstream& json_stream) { template inline T parse(const std::shared_ptr>& json_bytes) { - rapidjson::Document doc; - doc.Parse(reinterpret_cast(json_bytes->data()), json_bytes->size()); + boost::json::string_view json(reinterpret_cast(json_bytes->data()), + json_bytes->size()); + boost::json::error_code ec; + auto value = boost::json::parse(json, ec); T result{}; - if (doc.IsObject() || doc.IsArray()) { - from_json(doc, result); + if (value.is_object() || value.is_array()) { + from_json(value, result); } return result; } diff --git a/olp-cpp-sdk-core/include/olp/core/generated/parser/ParserWrapper.h b/olp-cpp-sdk-core/include/olp/core/generated/parser/ParserWrapper.h index 0a17b7bab..540e5110a 100644 --- a/olp-cpp-sdk-core/include/olp/core/generated/parser/ParserWrapper.h +++ b/olp-cpp-sdk-core/include/olp/core/generated/parser/ParserWrapper.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2023 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,72 +24,74 @@ #include #include -#include +#include #include namespace olp { namespace parser { -inline void from_json(const rapidjson::Value& value, std::string& x) { - x = value.GetString(); +inline void from_json(const boost::json::value& value, std::string& x) { + const auto& str = value.get_string(); + x.assign(str.begin(), str.end()); } -inline void from_json(const rapidjson::Value& value, int32_t& x) { - x = value.GetInt(); +inline void from_json(const boost::json::value& value, int32_t& x) { + x = static_cast(value.to_number()); } -inline void from_json(const rapidjson::Value& value, int64_t& x) { - x = value.GetInt64(); +inline void from_json(const boost::json::value& value, int64_t& x) { + x = value.to_number(); } -inline void from_json(const rapidjson::Value& value, double& x) { - x = value.GetDouble(); +inline void from_json(const boost::json::value& value, double& x) { + x = value.to_number(); } -inline void from_json(const rapidjson::Value& value, bool& x) { - x = value.GetBool(); +inline void from_json(const boost::json::value& value, bool& x) { + x = value.get_bool(); } -inline void from_json(const rapidjson::Value& value, +inline void from_json(const boost::json::value& value, std::shared_ptr>& x) { - std::string s = value.GetString(); + const auto& s = value.get_string(); x = std::make_shared>(s.begin(), s.end()); } template -inline void from_json(const rapidjson::Value& value, boost::optional& x) { +inline void from_json(const boost::json::value& value, boost::optional& x) { T result = T(); from_json(value, result); x = result; } template -inline void from_json(const rapidjson::Value& value, +inline void from_json(const boost::json::value& value, std::map& results) { - for (rapidjson::Value::ConstMemberIterator itr = value.MemberBegin(); - itr != value.MemberEnd(); ++itr) { - std::string key; - from_json(itr->name, key); - from_json(itr->value, results[key]); + const auto& object = value.get_object(); + for (const auto& object_value : object) { + std::string key = object_value.key(); + from_json(object_value.value(), results[key]); } } template -inline void from_json(const rapidjson::Value& value, std::vector& results) { - for (rapidjson::Value::ConstValueIterator itr = value.Begin(); - itr != value.End(); ++itr) { +inline void from_json(const boost::json::value& value, + std::vector& results) { + const auto& array = value.get_array(); + for (const auto& array_value : array) { T result; - from_json(*itr, result); + from_json(array_value, result); results.emplace_back(std::move(result)); } } template -inline T parse(const rapidjson::Value& value, const std::string& name) { +inline T parse(const boost::json::value& value, const std::string& name) { T result = T(); - rapidjson::Value::ConstMemberIterator itr = value.FindMember(name.c_str()); - if (itr != value.MemberEnd()) { - from_json(itr->value, result); + const auto& object = value.get_object(); + auto itr = object.find(name); + if (itr != object.end()) { + from_json(itr->value(), result); } return result; } diff --git a/olp-cpp-sdk-core/include/olp/core/generated/serializer/SerializerWrapper.h b/olp-cpp-sdk-core/include/olp/core/generated/serializer/SerializerWrapper.h index 5bec32f3e..0f8cf32d7 100644 --- a/olp-cpp-sdk-core/include/olp/core/generated/serializer/SerializerWrapper.h +++ b/olp-cpp-sdk-core/include/olp/core/generated/serializer/SerializerWrapper.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,91 +22,79 @@ #include #include #include -#include #include +#include +#include #include -#include namespace olp { namespace serializer { -inline void to_json(const std::string& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetString(rapidjson::StringRef(x.c_str(), x.size()), allocator); +inline void to_json(const std::string& x, boost::json::value& value) { + value.emplace_string() = x; } -inline void to_json(int32_t x, rapidjson::Value& value, - rapidjson::Document::AllocatorType&) { - value.SetInt(x); +inline void to_json(int32_t x, boost::json::value& value) { + value.emplace_int64() = x; } -inline void to_json(int64_t x, rapidjson::Value& value, - rapidjson::Document::AllocatorType&) { - value.SetInt64(x); +inline void to_json(int64_t x, boost::json::value& value) { + value.emplace_int64() = x; } -inline void to_json(double x, rapidjson::Value& value, - rapidjson::Document::AllocatorType&) { - value.SetDouble(x); +inline void to_json(double x, boost::json::value& value) { + value.emplace_double() = x; } -inline void to_json(bool x, rapidjson::Value& value, - rapidjson::Document::AllocatorType&) { - value.SetBool(x); +inline void to_json(bool x, boost::json::value& value) { + value.emplace_bool() = x; } inline void to_json(const std::shared_ptr>& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetString(reinterpret_cast(x->data()), - static_cast(x->size()), allocator); + boost::json::value& value) { + value.emplace_string().assign(x->begin(), x->end()); } template -inline void to_json(const boost::optional& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { +inline void to_json(const boost::optional& x, boost::json::value& value) { if (x) { - to_json(x.get(), value, allocator); + to_json(x.get(), value); } else { - value.SetNull(); + value.emplace_null(); } } template -inline void to_json(const std::map& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); +inline void to_json(const std::map& x, + boost::json::value& value) { + auto& object = value.emplace_object(); for (auto itr = x.begin(); itr != x.end(); ++itr) { const auto& key = itr->first; - rapidjson::Value item_value; - to_json(itr->second, item_value, allocator); - value.AddMember(rapidjson::StringRef(key.c_str(), key.size()), - std::move(item_value), allocator); + boost::json::value item_value; + to_json(itr->second, item_value); + object.emplace(key, std::move(item_value)); } } template -inline void to_json(const std::vector& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetArray(); +inline void to_json(const std::vector& x, boost::json::value& value) { + auto& array = value.emplace_array(); + array.reserve(x.size()); for (typename std::vector::const_iterator itr = x.begin(); itr != x.end(); ++itr) { - rapidjson::Value item_value; - to_json(*itr, item_value, allocator); - value.PushBack(std::move(item_value), allocator); + boost::json::value item_value; + to_json(*itr, item_value); + array.emplace_back(std::move(item_value)); } } template inline void serialize(const std::string& key, const T& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - rapidjson::Value key_value; - to_json(key, key_value, allocator); - rapidjson::Value item_value; - to_json(x, item_value, allocator); - if (!item_value.IsNull()) { - value.AddMember(std::move(key_value), std::move(item_value), allocator); + boost::json::object& value) { + boost::json::value item_value; + to_json(x, item_value); + if (!item_value.is_null()) { + value.emplace(key, std::move(item_value)); } } diff --git a/olp-cpp-sdk-core/src/client/parser/ApiParser.cpp b/olp-cpp-sdk-core/src/client/parser/ApiParser.cpp index 2942198b4..80a278773 100644 --- a/olp-cpp-sdk-core/src/client/parser/ApiParser.cpp +++ b/olp-cpp-sdk-core/src/client/parser/ApiParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, olp::client::Api& x) { +void from_json(const boost::json::value& value, olp::client::Api& x) { x.SetApi(parse(value, "api")); x.SetVersion(parse(value, "version")); x.SetBaseUrl(parse(value, "baseURL")); diff --git a/olp-cpp-sdk-core/src/client/parser/ApiParser.h b/olp-cpp-sdk-core/src/client/parser/ApiParser.h index bbed3eac7..653d4627a 100644 --- a/olp-cpp-sdk-core/src/client/parser/ApiParser.h +++ b/olp-cpp-sdk-core/src/client/parser/ApiParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,11 +20,11 @@ #pragma once #include -#include +#include namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, olp::client::Api& x); +void from_json(const boost::json::value& value, olp::client::Api& x); } // namespace parser } // namespace olp diff --git a/olp-cpp-sdk-core/src/utils/BoostJsonSrc.cpp b/olp-cpp-sdk-core/src/utils/BoostJsonSrc.cpp new file mode 100644 index 000000000..c725b0c36 --- /dev/null +++ b/olp-cpp-sdk-core/src/utils/BoostJsonSrc.cpp @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2025 HERE Europe B.V. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * License-Filename: LICENSE + */ + +#include diff --git a/olp-cpp-sdk-dataservice-read/include/olp/dataservice/read/model/StreamOffsets.h b/olp-cpp-sdk-dataservice-read/include/olp/dataservice/read/model/StreamOffsets.h index c84691a8a..cee2c63a0 100644 --- a/olp-cpp-sdk-dataservice-read/include/olp/dataservice/read/model/StreamOffsets.h +++ b/olp-cpp-sdk-dataservice-read/include/olp/dataservice/read/model/StreamOffsets.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ #pragma once +#include #include #include diff --git a/olp-cpp-sdk-dataservice-read/src/generated/api/MetadataApi.cpp b/olp-cpp-sdk-dataservice-read/src/generated/api/MetadataApi.cpp index 9e10447f6..15d249def 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/api/MetadataApi.cpp +++ b/olp-cpp-sdk-dataservice-read/src/generated/api/MetadataApi.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2024 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,10 +78,12 @@ MetadataApi::LayerVersionsResponse MetadataApi::GetLayerVersions( {}, nullptr, "", context); if (api_response.GetStatus() != http::HttpStatusCode::OK) { - return client::ApiError(api_response.GetStatus(), api_response.GetResponseAsString()); + return client::ApiError(api_response.GetStatus(), + api_response.GetResponseAsString()); } - return parser::parse_result(api_response.GetRawResponse()); + return parser::parse_result( + api_response.GetRawResponse()); } MetadataApi::PartitionsExtendedResponse MetadataApi::GetPartitions( @@ -117,7 +119,8 @@ MetadataApi::PartitionsExtendedResponse MetadataApi::GetPartitions( if (http_response.GetStatus() != olp::http::HttpStatusCode::OK) { return PartitionsExtendedResponse( - client::ApiError(http_response.GetStatus(), http_response.GetResponseAsString()), + client::ApiError(http_response.GetStatus(), + http_response.GetResponseAsString()), http_response.GetNetworkStatistics()); } @@ -192,7 +195,8 @@ MetadataApi::CatalogVersionResponse MetadataApi::GetLatestCatalogVersion( return {{api_response.GetStatus(), api_response.GetResponseAsString()}}; } - return parser::parse_result(api_response.GetRawResponse()); + return parser::parse_result( + api_response.GetRawResponse()); } MetadataApi::VersionsResponse MetadataApi::ListVersions( @@ -231,8 +235,6 @@ MetadataApi::CompatibleVersionsResponse MetadataApi::GetCompatibleVersions( std::multimap query_params; query_params.emplace("limit", std::to_string(limit)); - rapidjson::Value value; - const auto serialized_dependencies = serializer::serialize(dependencies); const auto data = std::make_shared>( diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/ApiParser.cpp b/olp-cpp-sdk-dataservice-read/src/generated/parser/ApiParser.cpp index 632c25d45..da3aa34b9 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/ApiParser.cpp +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/ApiParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::Api& x) { x.SetApi(parse(value, "api")); x.SetVersion(parse(value, "version")); diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/ApiParser.h b/olp-cpp-sdk-dataservice-read/src/generated/parser/ApiParser.h index d7d79f42b..f1c079d51 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/ApiParser.h +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/ApiParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,14 +19,15 @@ #pragma once -#include +#include #include "generated/model/Api.h" #include namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, olp::dataservice::read::model::Api& x); +void from_json(const boost::json::value& value, + olp::dataservice::read::model::Api& x); } // namespace parser diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/CatalogParser.cpp b/olp-cpp-sdk-dataservice-read/src/generated/parser/CatalogParser.cpp index aad08dcef..8fdeee8d2 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/CatalogParser.cpp +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/CatalogParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,44 +23,44 @@ namespace olp { namespace parser { -using namespace olp::dataservice::read; +namespace model = olp::dataservice::read::model; -void from_json(const rapidjson::Value& value, model::Coverage& x) { +void from_json(const boost::json::value& value, model::Coverage& x) { x.SetAdminAreas(parse>(value, "adminAreas")); } -void from_json(const rapidjson::Value& value, model::IndexDefinition& x) { +void from_json(const boost::json::value& value, model::IndexDefinition& x) { x.SetName(parse(value, "name")); x.SetType(parse(value, "type")); x.SetDuration(parse(value, "duration")); x.SetZoomLevel(parse(value, "zoomLevel")); } -void from_json(const rapidjson::Value& value, model::IndexProperties& x) { +void from_json(const boost::json::value& value, model::IndexProperties& x) { x.SetTtl(parse(value, "ttl")); x.SetIndexDefinitions( parse>(value, "indexDefinitions")); } -void from_json(const rapidjson::Value& value, model::Creator& x) { +void from_json(const boost::json::value& value, model::Creator& x) { x.SetId(parse(value, "id")); } -void from_json(const rapidjson::Value& value, model::Owner& x) { +void from_json(const boost::json::value& value, model::Owner& x) { x.SetCreator(parse(value, "creator")); x.SetOrganisation(parse(value, "organisation")); } -void from_json(const rapidjson::Value& value, model::Partitioning& x) { +void from_json(const boost::json::value& value, model::Partitioning& x) { x.SetScheme(parse(value, "scheme")); x.SetTileLevels(parse>(value, "tileLevels")); } -void from_json(const rapidjson::Value& value, model::Schema& x) { +void from_json(const boost::json::value& value, model::Schema& x) { x.SetHrn(parse(value, "hrn")); } -void from_json(const rapidjson::Value& value, model::StreamProperties& x) { +void from_json(const boost::json::value& value, model::StreamProperties& x) { // Parsing these as double even though OepnAPI sepcs says int64 because // Backend returns the value in decimal format (e.g. 1.0) and this triggers an // assert in RapidJSON when parsing. @@ -70,18 +70,18 @@ void from_json(const rapidjson::Value& value, model::StreamProperties& x) { static_cast(parse(value, "dataOutThroughputMbps"))); } -void from_json(const rapidjson::Value& value, model::Encryption& x) { +void from_json(const boost::json::value& value, model::Encryption& x) { x.SetAlgorithm(parse(value, "algorithm")); } -void from_json(const rapidjson::Value& value, model::Volume& x) { +void from_json(const boost::json::value& value, model::Volume& x) { x.SetVolumeType(parse(value, "volumeType")); x.SetMaxMemoryPolicy(parse(value, "maxMemoryPolicy")); x.SetPackageType(parse(value, "packageType")); x.SetEncryption(parse(value, "encryption")); } -void from_json(const rapidjson::Value& value, model::Layer& x) { +void from_json(const boost::json::value& value, model::Layer& x) { x.SetId(parse(value, "id")); x.SetName(parse(value, "name")); x.SetSummary(parse(value, "summary")); @@ -103,11 +103,11 @@ void from_json(const rapidjson::Value& value, model::Layer& x) { x.SetVolume(parse(value, "volume")); } -void from_json(const rapidjson::Value& value, model::Notifications& x) { +void from_json(const boost::json::value& value, model::Notifications& x) { x.SetEnabled(parse(value, "enabled")); } -void from_json(const rapidjson::Value& value, model::Catalog& x) { +void from_json(const boost::json::value& value, model::Catalog& x) { x.SetId(parse(value, "id")); x.SetHrn(parse(value, "hrn")); x.SetName(parse(value, "name")); diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/CatalogParser.h b/olp-cpp-sdk-dataservice-read/src/generated/parser/CatalogParser.h index fde7f7cb7..a85ff1083 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/CatalogParser.h +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/CatalogParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,50 +19,50 @@ #pragma once -#include +#include #include "olp/dataservice/read/model/Catalog.h" #include namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::Coverage& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::IndexDefinition& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::IndexProperties& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::Creator& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::Owner& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::Partitioning& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::Schema& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::StreamProperties& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::Encryption& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::Volume& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::Layer& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::Notifications& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::Catalog& x); } // namespace parser } // namespace olp diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/IndexParser.cpp b/olp-cpp-sdk-dataservice-read/src/generated/parser/IndexParser.cpp index 6737d6d80..67bf40216 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/IndexParser.cpp +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/IndexParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +23,10 @@ namespace olp { namespace parser { -using namespace olp::dataservice::read; -void from_json(const rapidjson::Value& value, +namespace model = olp::dataservice::read::model; + +void from_json(const boost::json::value& value, std::shared_ptr& x) { auto quad = std::make_shared(); @@ -47,7 +48,7 @@ void from_json(const rapidjson::Value& value, x.swap(quad); } -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, std::shared_ptr& x) { auto quad = std::make_shared(); @@ -69,7 +70,7 @@ void from_json(const rapidjson::Value& value, x.swap(quad); } -void from_json(const rapidjson::Value& value, model::Index& x) { +void from_json(const boost::json::value& value, model::Index& x) { x.SetParentQuads(parse>>( value, "parentQuads")); x.SetSubQuads( diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/IndexParser.h b/olp-cpp-sdk-dataservice-read/src/generated/parser/IndexParser.h index 9cb7f0f4f..6977a011d 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/IndexParser.h +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/IndexParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ #pragma once -#include +#include #include "generated/model/Index.h" #include @@ -27,11 +27,11 @@ namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, std::shared_ptr& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, std::shared_ptr& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::Index& x); } // namespace parser } // namespace olp diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/LayerVersionsParser.cpp b/olp-cpp-sdk-dataservice-read/src/generated/parser/LayerVersionsParser.cpp index 6b6920418..31019e978 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/LayerVersionsParser.cpp +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/LayerVersionsParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,15 +23,15 @@ namespace olp { namespace parser { -using namespace olp::dataservice::read; +namespace model = olp::dataservice::read::model; -void from_json(const rapidjson::Value& value, model::LayerVersion& x) { +void from_json(const boost::json::value& value, model::LayerVersion& x) { x.SetLayer(parse(value, "layer")); x.SetVersion(parse(value, "version")); x.SetTimestamp(parse(value, "timestamp")); } -void from_json(const rapidjson::Value& value, model::LayerVersions& x) { +void from_json(const boost::json::value& value, model::LayerVersions& x) { x.SetLayerVersions( parse>(value, "layerVersions")); x.SetVersion(parse(value, "version")); diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/LayerVersionsParser.h b/olp-cpp-sdk-dataservice-read/src/generated/parser/LayerVersionsParser.h index ca5136176..3dd82bc30 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/LayerVersionsParser.h +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/LayerVersionsParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,17 +19,17 @@ #pragma once -#include +#include #include "generated/model/LayerVersions.h" #include namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::LayerVersion& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::LayerVersions& x); } // namespace parser diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/MessagesParser.cpp b/olp-cpp-sdk-dataservice-read/src/generated/parser/MessagesParser.cpp index 138e2b98f..b14c543a8 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/MessagesParser.cpp +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/MessagesParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,9 +26,9 @@ namespace olp { namespace parser { -using namespace olp::dataservice::read; +namespace model = olp::dataservice::read::model; -void from_json(const rapidjson::Value& value, model::Metadata& x) { +void from_json(const boost::json::value& value, model::Metadata& x) { x.SetPartition(parse(value, "partition")); x.SetChecksum(parse>(value, "checksum")); x.SetCompressedDataSize( @@ -39,12 +39,12 @@ void from_json(const rapidjson::Value& value, model::Metadata& x) { x.SetTimestamp(parse>(value, "timestamp")); } -void from_json(const rapidjson::Value& value, model::Message& x) { +void from_json(const boost::json::value& value, model::Message& x) { x.SetMetaData(parse(value, "metaData")); x.SetOffset(parse(value, "offset")); } -void from_json(const rapidjson::Value& value, model::Messages& x) { +void from_json(const boost::json::value& value, model::Messages& x) { x.SetMessages(parse>(value, "messages")); } diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/MessagesParser.h b/olp-cpp-sdk-dataservice-read/src/generated/parser/MessagesParser.h index 270a8dc36..0c5051031 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/MessagesParser.h +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/MessagesParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,19 +19,19 @@ #pragma once -#include #include +#include namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::Metadata& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::Message& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::Messages& x); } // namespace parser diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/PartitionsParser.cpp b/olp-cpp-sdk-dataservice-read/src/generated/parser/PartitionsParser.cpp index ca924c20c..c93606bcd 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/PartitionsParser.cpp +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/PartitionsParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +23,9 @@ namespace olp { namespace parser { -using namespace olp::dataservice::read; +namespace model = olp::dataservice::read::model; -void from_json(const rapidjson::Value& value, model::Partition& x) { +void from_json(const boost::json::value& value, model::Partition& x) { x.SetChecksum(parse>(value, "checksum")); x.SetCompressedDataSize( parse>(value, "compressedDataSize")); @@ -36,7 +36,7 @@ void from_json(const rapidjson::Value& value, model::Partition& x) { x.SetVersion(parse>(value, "version")); } -void from_json(const rapidjson::Value& value, model::Partitions& x) { +void from_json(const boost::json::value& value, model::Partitions& x) { x.SetPartitions(parse>(value, "partitions")); } diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/PartitionsParser.h b/olp-cpp-sdk-dataservice-read/src/generated/parser/PartitionsParser.h index 120e1129f..0eee91833 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/PartitionsParser.h +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/PartitionsParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,17 +19,17 @@ #pragma once -#include +#include #include "olp/dataservice/read/model/Partitions.h" #include namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::Partition& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::Partitions& x); } // namespace parser diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/StreamOffsetParser.cpp b/olp-cpp-sdk-dataservice-read/src/generated/parser/StreamOffsetParser.cpp index d11ba87e6..87248e62a 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/StreamOffsetParser.cpp +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/StreamOffsetParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +23,9 @@ namespace olp { namespace parser { -using namespace olp::dataservice::read; +namespace model = olp::dataservice::read::model; -void from_json(const rapidjson::Value& value, model::StreamOffset& x) { +void from_json(const boost::json::value& value, model::StreamOffset& x) { x.SetPartition(parse(value, "partition")); x.SetOffset(parse(value, "offset")); } diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/StreamOffsetParser.h b/olp-cpp-sdk-dataservice-read/src/generated/parser/StreamOffsetParser.h index fdefafc65..81de313e2 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/StreamOffsetParser.h +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/StreamOffsetParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,13 +19,13 @@ #pragma once -#include #include +#include namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::StreamOffset& x); } // namespace parser diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/SubscribeResponseParser.cpp b/olp-cpp-sdk-dataservice-read/src/generated/parser/SubscribeResponseParser.cpp index 68d7c7ef8..e13f9c5d9 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/SubscribeResponseParser.cpp +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/SubscribeResponseParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +23,9 @@ namespace olp { namespace parser { -using namespace olp::dataservice::read; +namespace model = olp::dataservice::read::model; -void from_json(const rapidjson::Value& value, model::SubscribeResponse& x) { +void from_json(const boost::json::value& value, model::SubscribeResponse& x) { x.SetNodeBaseURL(parse(value, "nodeBaseURL")); x.SetSubscriptionId(parse(value, "subscriptionId")); } diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/SubscribeResponseParser.h b/olp-cpp-sdk-dataservice-read/src/generated/parser/SubscribeResponseParser.h index 226922b5a..00afd3a38 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/SubscribeResponseParser.h +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/SubscribeResponseParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,13 +19,13 @@ #pragma once -#include +#include #include "generated/model/SubscribeResponse.h" namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::SubscribeResponse& x); } // namespace parser diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionInfosParser.cpp b/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionInfosParser.cpp index dc71aebac..b70f707bf 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionInfosParser.cpp +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionInfosParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,13 +28,13 @@ namespace olp { namespace parser { namespace model = olp::dataservice::read::model; -void from_json(const rapidjson::Value& value, model::VersionDependency& x) { +void from_json(const boost::json::value& value, model::VersionDependency& x) { x.SetHrn(parse(value, "hrn")); x.SetVersion(parse(value, "version")); x.SetDirect(parse(value, "direct")); } -void from_json(const rapidjson::Value& value, model::VersionInfo& x) { +void from_json(const boost::json::value& value, model::VersionInfo& x) { x.SetDependencies( parse>(value, "dependencies")); x.SetTimestamp(parse(value, "timestamp")); @@ -43,7 +43,7 @@ void from_json(const rapidjson::Value& value, model::VersionInfo& x) { parse>(value, "partitionCounts")); } -void from_json(const rapidjson::Value& value, model::VersionInfos& x) { +void from_json(const boost::json::value& value, model::VersionInfos& x) { x.SetVersions(parse>(value, "versions")); } diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionInfosParser.h b/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionInfosParser.h index bd692e6a8..4846205c4 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionInfosParser.h +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionInfosParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,18 +19,18 @@ #pragma once -#include +#include #include "olp/dataservice/read/model/VersionInfos.h" namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::VersionDependency& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::VersionInfo& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::VersionInfos& x); } // namespace parser diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionResponseParser.cpp b/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionResponseParser.cpp index 107594f85..ed3087006 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionResponseParser.cpp +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionResponseParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +23,9 @@ namespace olp { namespace parser { -using namespace olp::dataservice::read; +namespace model = olp::dataservice::read::model; -void from_json(const rapidjson::Value& value, model::VersionResponse& x) { +void from_json(const boost::json::value& value, model::VersionResponse& x) { x.SetVersion(parse(value, "version")); } diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionResponseParser.h b/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionResponseParser.h index 4c57d9344..e4cf56775 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionResponseParser.h +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionResponseParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,14 +19,14 @@ #pragma once -#include +#include #include "olp/dataservice/read/model/VersionResponse.h" #include namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::VersionResponse& x); } // namespace parser diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionsResponseParser.cpp b/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionsResponseParser.cpp index 708f7e277..b627b8413 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionsResponseParser.cpp +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionsResponseParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 HERE Europe B.V. + * Copyright (C) 2022-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,18 +29,18 @@ using VersionsResponseEntry = olp::dataservice::read::model::VersionsResponseEntry; using CatalogVersion = olp::dataservice::read::model::CatalogVersion; -void from_json(const rapidjson::Value& value, CatalogVersion& x) { +void from_json(const boost::json::value& value, CatalogVersion& x) { x.SetHrn(parse(value, "hrn")); x.SetVersion(parse(value, "version")); } -void from_json(const rapidjson::Value& value, VersionsResponseEntry& x) { +void from_json(const boost::json::value& value, VersionsResponseEntry& x) { x.SetVersion(parse(value, "version")); x.SetCatalogVersions( parse>(value, "sharedDependencies")); } -void from_json(const rapidjson::Value& value, VersionsResponse& x) { +void from_json(const boost::json::value& value, VersionsResponse& x) { x.SetVersionResponseEntries( parse>(value, "versions")); } diff --git a/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionsResponseParser.h b/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionsResponseParser.h index 8d9eb783e..a28a853eb 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionsResponseParser.h +++ b/olp-cpp-sdk-dataservice-read/src/generated/parser/VersionsResponseParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 HERE Europe B.V. + * Copyright (C) 2022-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,18 +21,17 @@ #include -#include +#include #include "olp/dataservice/read/model/VersionsResponse.h" - namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::CatalogVersion& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::VersionsResponseEntry& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::read::model::VersionsResponse& x); } // namespace parser diff --git a/olp-cpp-sdk-dataservice-read/src/generated/serializer/ApiSerializer.cpp b/olp-cpp-sdk-dataservice-read/src/generated/serializer/ApiSerializer.cpp index 91a3eae4a..08689c46b 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/serializer/ApiSerializer.cpp +++ b/olp-cpp-sdk-dataservice-read/src/generated/serializer/ApiSerializer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ * License-Filename: LICENSE */ -#include +#include #include "ApiSerializer.h" @@ -25,13 +25,13 @@ namespace olp { namespace serializer { -void to_json(const dataservice::read::model::Api& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("api", x.GetApi(), value, allocator); - serialize("version", x.GetVersion(), value, allocator); - serialize("baseURL", x.GetBaseUrl(), value, allocator); - serialize("parameters", x.GetParameters(), value, allocator); +void to_json(const dataservice::read::model::Api& x, + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("api", x.GetApi(), object); + serialize("version", x.GetVersion(), object); + serialize("baseURL", x.GetBaseUrl(), object); + serialize("parameters", x.GetParameters(), object); } } // namespace serializer } // namespace olp diff --git a/olp-cpp-sdk-dataservice-read/src/generated/serializer/ApiSerializer.h b/olp-cpp-sdk-dataservice-read/src/generated/serializer/ApiSerializer.h index 0e5b9bc06..5f7159370 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/serializer/ApiSerializer.h +++ b/olp-cpp-sdk-dataservice-read/src/generated/serializer/ApiSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,14 +21,12 @@ #include -#include +#include #include "generated/model/Api.h" namespace olp { namespace serializer { -void to_json(const dataservice::read::model::Api& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); +void to_json(const dataservice::read::model::Api& x, boost::json::value& value); } // namespace serializer } // namespace olp diff --git a/olp-cpp-sdk-dataservice-read/src/generated/serializer/CatalogSerializer.cpp b/olp-cpp-sdk-dataservice-read/src/generated/serializer/CatalogSerializer.cpp index 8ca3a88d1..acfda5d4c 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/serializer/CatalogSerializer.cpp +++ b/olp-cpp-sdk-dataservice-read/src/generated/serializer/CatalogSerializer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ * License-Filename: LICENSE */ -#include +#include #include "CatalogSerializer.h" @@ -26,131 +26,120 @@ namespace olp { namespace serializer { void to_json(const dataservice::read::model::Coverage& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("adminAreas", x.GetAdminAreas(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("adminAreas", x.GetAdminAreas(), object); } void to_json(const dataservice::read::model::IndexDefinition& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("name", x.GetName(), value, allocator); - serialize("type", x.GetType(), value, allocator); - serialize("duration", x.GetDuration(), value, allocator); - serialize("zoomLevel", x.GetZoomLevel(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("name", x.GetName(), object); + serialize("type", x.GetType(), object); + serialize("duration", x.GetDuration(), object); + serialize("zoomLevel", x.GetZoomLevel(), object); } void to_json(const dataservice::read::model::IndexProperties& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("ttl", x.GetTtl(), value, allocator); - serialize("indexDefinitions", x.GetIndexDefinitions(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("ttl", x.GetTtl(), object); + serialize("indexDefinitions", x.GetIndexDefinitions(), object); } void to_json(const dataservice::read::model::Creator& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("id", x.GetId(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("id", x.GetId(), object); } -void to_json(const dataservice::read::model::Owner& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("creator", x.GetCreator(), value, allocator); - serialize("organisation", x.GetOrganisation(), value, allocator); +void to_json(const dataservice::read::model::Owner& x, + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("creator", x.GetCreator(), object); + serialize("organisation", x.GetOrganisation(), object); } void to_json(const dataservice::read::model::Partitioning& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("scheme", x.GetScheme(), value, allocator); - serialize("tileLevels", x.GetTileLevels(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("scheme", x.GetScheme(), object); + serialize("tileLevels", x.GetTileLevels(), object); } -void to_json(const dataservice::read::model::Schema& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("hrn", x.GetHrn(), value, allocator); +void to_json(const dataservice::read::model::Schema& x, + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("hrn", x.GetHrn(), object); } void to_json(const dataservice::read::model::StreamProperties& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("dataInThroughputMbps", x.GetDataInThroughputMbps(), value, - allocator); - serialize("dataOutThroughputMbps", x.GetDataOutThroughputMbps(), value, - allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("dataInThroughputMbps", x.GetDataInThroughputMbps(), object); + serialize("dataOutThroughputMbps", x.GetDataOutThroughputMbps(), object); } void to_json(const dataservice::read::model::Encryption& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("algorithm", x.GetAlgorithm(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("algorithm", x.GetAlgorithm(), object); } -void to_json(const dataservice::read::model::Volume& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("volumeType", x.GetVolumeType(), value, allocator); - serialize("maxMemoryPolicy", x.GetMaxMemoryPolicy(), value, allocator); - serialize("packageType", x.GetPackageType(), value, allocator); - serialize("encryption", x.GetEncryption(), value, allocator); +void to_json(const dataservice::read::model::Volume& x, + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("volumeType", x.GetVolumeType(), object); + serialize("maxMemoryPolicy", x.GetMaxMemoryPolicy(), object); + serialize("packageType", x.GetPackageType(), object); + serialize("encryption", x.GetEncryption(), object); } -void to_json(const dataservice::read::model::Layer& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("id", x.GetId(), value, allocator); - serialize("name", x.GetName(), value, allocator); - serialize("summary", x.GetSummary(), value, allocator); - serialize("description", x.GetDescription(), value, allocator); - serialize("owner", x.GetOwner(), value, allocator); - serialize("coverage", x.GetCoverage(), value, allocator); - serialize("schema", x.GetSchema(), value, allocator); - serialize("contentType", x.GetContentType(), value, allocator); - serialize("contentEncoding", x.GetContentEncoding(), value, allocator); - serialize("partitioning", x.GetPartitioning(), value, allocator); - serialize("layerType", x.GetLayerType(), value, allocator); - serialize("digest", x.GetDigest(), value, allocator); - serialize("tags", x.GetTags(), value, allocator); - serialize("billingTags", x.GetBillingTags(), value, allocator); - serialize("ttl", x.GetTtl(), value, allocator); - serialize("indexProperties", x.GetIndexProperties(), value, allocator); - serialize("streamProperties", x.GetStreamProperties(), value, allocator); - serialize("volume", x.GetVolume(), value, allocator); +void to_json(const dataservice::read::model::Layer& x, + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("id", x.GetId(), object); + serialize("name", x.GetName(), object); + serialize("summary", x.GetSummary(), object); + serialize("description", x.GetDescription(), object); + serialize("owner", x.GetOwner(), object); + serialize("coverage", x.GetCoverage(), object); + serialize("schema", x.GetSchema(), object); + serialize("contentType", x.GetContentType(), object); + serialize("contentEncoding", x.GetContentEncoding(), object); + serialize("partitioning", x.GetPartitioning(), object); + serialize("layerType", x.GetLayerType(), object); + serialize("digest", x.GetDigest(), object); + serialize("tags", x.GetTags(), object); + serialize("billingTags", x.GetBillingTags(), object); + serialize("ttl", x.GetTtl(), object); + serialize("indexProperties", x.GetIndexProperties(), object); + serialize("streamProperties", x.GetStreamProperties(), object); + serialize("volume", x.GetVolume(), object); } void to_json(const dataservice::read::model::Notifications& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("enabled", x.GetEnabled(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("enabled", x.GetEnabled(), object); } void to_json(const dataservice::read::model::Catalog& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("id", x.GetId(), value, allocator); - serialize("hrn", x.GetHrn(), value, allocator); - serialize("name", x.GetName(), value, allocator); - serialize("summary", x.GetSummary(), value, allocator); - serialize("description", x.GetDescription(), value, allocator); - serialize("coverage", x.GetCoverage(), value, allocator); - serialize("owner", x.GetOwner(), value, allocator); - serialize("tags", x.GetTags(), value, allocator); - serialize("billingTags", x.GetBillingTags(), value, allocator); - serialize("created", x.GetCreated(), value, allocator); - serialize("layers", x.GetLayers(), value, allocator); - serialize("version", x.GetVersion(), value, allocator); - serialize("notifications", x.GetNotifications(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("id", x.GetId(), object); + serialize("hrn", x.GetHrn(), object); + serialize("name", x.GetName(), object); + serialize("summary", x.GetSummary(), object); + serialize("description", x.GetDescription(), object); + serialize("coverage", x.GetCoverage(), object); + serialize("owner", x.GetOwner(), object); + serialize("tags", x.GetTags(), object); + serialize("billingTags", x.GetBillingTags(), object); + serialize("created", x.GetCreated(), object); + serialize("layers", x.GetLayers(), object); + serialize("version", x.GetVersion(), object); + serialize("notifications", x.GetNotifications(), object); } } // namespace serializer diff --git a/olp-cpp-sdk-dataservice-read/src/generated/serializer/CatalogSerializer.h b/olp-cpp-sdk-dataservice-read/src/generated/serializer/CatalogSerializer.h index 6d9417162..3826888e2 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/serializer/CatalogSerializer.h +++ b/olp-cpp-sdk-dataservice-read/src/generated/serializer/CatalogSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,63 +19,50 @@ #pragma once -#include +#include #include "olp/dataservice/read/model/Catalog.h" namespace olp { namespace serializer { void to_json(const dataservice::read::model::Coverage& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::read::model::IndexDefinition& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::read::model::IndexProperties& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::read::model::Creator& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::read::model::Owner& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::read::model::Partitioning& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::read::model::Schema& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::read::model::StreamProperties& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::read::model::Encryption& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::read::model::Volume& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::read::model::Layer& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::read::model::Notifications& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::read::model::Catalog& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); } // namespace serializer } // namespace olp diff --git a/olp-cpp-sdk-dataservice-read/src/generated/serializer/CatalogVersionsSerializer.h b/olp-cpp-sdk-dataservice-read/src/generated/serializer/CatalogVersionsSerializer.h index 50bd3898e..902156495 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/serializer/CatalogVersionsSerializer.h +++ b/olp-cpp-sdk-dataservice-read/src/generated/serializer/CatalogVersionsSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 HERE Europe B.V. + * Copyright (C) 2022-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,33 +21,32 @@ #include #include -#include +#include namespace olp { namespace serializer { inline void to_json(const dataservice::read::model::CatalogVersion& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("hrn", x.GetHrn(), value, allocator); - serialize("version", x.GetVersion(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("hrn", x.GetHrn(), object); + serialize("version", x.GetVersion(), object); } template <> inline void to_json( const std::vector& x, - rapidjson::Value& value, rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - - rapidjson::Value array_value; - array_value.SetArray(); - for (auto itr = x.begin(); itr != x.end(); ++itr) { - rapidjson::Value item_value; - to_json(*itr, item_value, allocator); - array_value.PushBack(std::move(item_value), allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + + boost::json::array array_value; + for (const auto& version : x) { + boost::json::value item_value; + to_json(version, item_value); + array_value.emplace_back(std::move(item_value)); } - value.AddMember("dependencies", std::move(array_value), allocator); + + object.emplace("dependencies", std::move(array_value)); } } // namespace serializer diff --git a/olp-cpp-sdk-dataservice-read/src/generated/serializer/ConsumerPropertiesSerializer.h b/olp-cpp-sdk-dataservice-read/src/generated/serializer/ConsumerPropertiesSerializer.h index 1dea7c2fe..998c922cd 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/serializer/ConsumerPropertiesSerializer.h +++ b/olp-cpp-sdk-dataservice-read/src/generated/serializer/ConsumerPropertiesSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,9 +19,9 @@ #pragma once -#include #include #include +#include namespace olp { namespace serializer { @@ -29,18 +29,17 @@ namespace serializer { template <> inline void to_json( const std::vector& x, - rapidjson::Value& value, rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - for (auto itr = x.begin(); itr != x.end(); ++itr) { - serialize(itr->GetKey(), itr->GetValue(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + for (const auto& option : x) { + serialize(option.GetKey(), option.GetValue(), object); } } inline void to_json(const dataservice::read::ConsumerProperties& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("kafkaConsumerProperties", x.GetProperties(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("kafkaConsumerProperties", x.GetProperties(), object); } } // namespace serializer diff --git a/olp-cpp-sdk-dataservice-read/src/generated/serializer/JsonSerializer.h b/olp-cpp-sdk-dataservice-read/src/generated/serializer/JsonSerializer.h index 399346219..48aaaadc3 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/serializer/JsonSerializer.h +++ b/olp-cpp-sdk-dataservice-read/src/generated/serializer/JsonSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2024 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,9 +19,9 @@ #pragma once -#include -#include -#include +#include +#include +#include #include "ByteVectorBuffer.h" @@ -29,30 +29,28 @@ namespace olp { namespace serializer { template inline std::string serialize(const T& object) { - rapidjson::Document doc; - auto& allocator = doc.GetAllocator(); - - doc.SetObject(); - to_json(object, doc, allocator); - - rapidjson::StringBuffer buffer; - rapidjson::Writer writer(buffer); - doc.Accept(writer); - return buffer.GetString(); + boost::json::value value; + to_json(object, value); + return boost::json::serialize(value); } template inline ByteVectorBuffer::Buffer serialize_bytes(const T& object) { - rapidjson::Document doc; - auto& allocator = doc.GetAllocator(); + boost::json::value value; + to_json(object, value); + + boost::json::serializer serializer; + serializer.reset(&value); + + auto buffer = std::make_shared>(); - doc.SetObject(); - to_json(object, doc, allocator); + while (!serializer.done()) { + char temp[4096]; + auto result = serializer.read(temp); + buffer->insert(buffer->end(), temp, temp + result.size()); + } - ByteVectorBuffer buffer; - rapidjson::Writer writer(buffer); - doc.Accept(writer); - return buffer.GetBuffer(); + return buffer; } } // namespace serializer diff --git a/olp-cpp-sdk-dataservice-read/src/generated/serializer/LayerVersionsSerializer.cpp b/olp-cpp-sdk-dataservice-read/src/generated/serializer/LayerVersionsSerializer.cpp index 935fab9fc..94fd0b8f5 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/serializer/LayerVersionsSerializer.cpp +++ b/olp-cpp-sdk-dataservice-read/src/generated/serializer/LayerVersionsSerializer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ * License-Filename: LICENSE */ -#include +#include #include "LayerVersionsSerializer.h" @@ -26,19 +26,17 @@ namespace olp { namespace serializer { void to_json(const dataservice::read::model::LayerVersion& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("layer", x.GetLayer(), value, allocator); - serialize("version", x.GetVersion(), value, allocator); - serialize("timestamp", x.GetTimestamp(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("layer", x.GetLayer(), object); + serialize("version", x.GetVersion(), object); + serialize("timestamp", x.GetTimestamp(), object); } void to_json(const dataservice::read::model::LayerVersions& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("layerVersions", x.GetLayerVersions(), value, allocator); - serialize("version", x.GetVersion(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("layerVersions", x.GetLayerVersions(), object); + serialize("version", x.GetVersion(), object); } } // namespace serializer } // namespace olp diff --git a/olp-cpp-sdk-dataservice-read/src/generated/serializer/LayerVersionsSerializer.h b/olp-cpp-sdk-dataservice-read/src/generated/serializer/LayerVersionsSerializer.h index bff03a181..88ebd1da8 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/serializer/LayerVersionsSerializer.h +++ b/olp-cpp-sdk-dataservice-read/src/generated/serializer/LayerVersionsSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,19 +19,16 @@ #pragma once -#include +#include #include "generated/model/LayerVersions.h" - namespace olp { namespace serializer { void to_json(const dataservice::read::model::LayerVersion& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::read::model::LayerVersions& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); } // namespace serializer } // namespace olp diff --git a/olp-cpp-sdk-dataservice-read/src/generated/serializer/PartitionsSerializer.cpp b/olp-cpp-sdk-dataservice-read/src/generated/serializer/PartitionsSerializer.cpp index b7bd4009e..a19b0af34 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/serializer/PartitionsSerializer.cpp +++ b/olp-cpp-sdk-dataservice-read/src/generated/serializer/PartitionsSerializer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ * License-Filename: LICENSE */ -#include +#include #include "PartitionsSerializer.h" @@ -26,23 +26,21 @@ namespace olp { namespace serializer { void to_json(const dataservice::read::model::Partition& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("checksum", x.GetChecksum(), value, allocator); - serialize("compressedDataSize", x.GetCompressedDataSize(), value, allocator); - serialize("dataHandle", x.GetDataHandle(), value, allocator); - serialize("dataSize", x.GetDataSize(), value, allocator); - serialize("crc", x.GetCrc(), value, allocator); - serialize("partition", x.GetPartition(), value, allocator); - serialize("version", x.GetVersion(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("checksum", x.GetChecksum(), object); + serialize("compressedDataSize", x.GetCompressedDataSize(), object); + serialize("dataHandle", x.GetDataHandle(), object); + serialize("dataSize", x.GetDataSize(), object); + serialize("crc", x.GetCrc(), object); + serialize("partition", x.GetPartition(), object); + serialize("version", x.GetVersion(), object); } void to_json(const dataservice::read::model::Partitions& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("partitions", x.GetPartitions(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("partitions", x.GetPartitions(), object); } } // namespace serializer } // namespace olp diff --git a/olp-cpp-sdk-dataservice-read/src/generated/serializer/PartitionsSerializer.h b/olp-cpp-sdk-dataservice-read/src/generated/serializer/PartitionsSerializer.h index 0870aa75c..cfc54578a 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/serializer/PartitionsSerializer.h +++ b/olp-cpp-sdk-dataservice-read/src/generated/serializer/PartitionsSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,18 +19,16 @@ #pragma once -#include +#include #include "olp/dataservice/read/model/Partitions.h" namespace olp { namespace serializer { void to_json(const dataservice::read::model::Partition& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::read::model::Partitions& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); } // namespace serializer } // namespace olp diff --git a/olp-cpp-sdk-dataservice-read/src/generated/serializer/StreamOffsetsSerializer.cpp b/olp-cpp-sdk-dataservice-read/src/generated/serializer/StreamOffsetsSerializer.cpp index a2e750d63..1d395495e 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/serializer/StreamOffsetsSerializer.cpp +++ b/olp-cpp-sdk-dataservice-read/src/generated/serializer/StreamOffsetsSerializer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,18 +25,16 @@ namespace olp { namespace serializer { void to_json(const dataservice::read::model::StreamOffset& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("partition", x.GetPartition(), value, allocator); - serialize("offset", x.GetOffset(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("partition", x.GetPartition(), object); + serialize("offset", x.GetOffset(), object); } void to_json(const dataservice::read::model::StreamOffsets& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("offsets", x.GetOffsets(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("offsets", x.GetOffsets(), object); } } // namespace serializer diff --git a/olp-cpp-sdk-dataservice-read/src/generated/serializer/StreamOffsetsSerializer.h b/olp-cpp-sdk-dataservice-read/src/generated/serializer/StreamOffsetsSerializer.h index f301dfc33..614c05d9d 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/serializer/StreamOffsetsSerializer.h +++ b/olp-cpp-sdk-dataservice-read/src/generated/serializer/StreamOffsetsSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,19 +19,17 @@ #pragma once -#include #include +#include namespace olp { namespace serializer { void to_json(const dataservice::read::model::StreamOffset& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::read::model::StreamOffsets& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); } // namespace serializer } // namespace olp diff --git a/olp-cpp-sdk-dataservice-read/src/generated/serializer/VersionInfosSerializer.cpp b/olp-cpp-sdk-dataservice-read/src/generated/serializer/VersionInfosSerializer.cpp index d24b124da..3eb8d3cf9 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/serializer/VersionInfosSerializer.cpp +++ b/olp-cpp-sdk-dataservice-read/src/generated/serializer/VersionInfosSerializer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,29 +25,26 @@ namespace olp { namespace serializer { void to_json(const dataservice::read::model::VersionDependency& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("hrn", x.GetHrn(), value, allocator); - serialize("version", x.GetVersion(), value, allocator); - serialize("direct", x.GetDirect(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("hrn", x.GetHrn(), object); + serialize("version", x.GetVersion(), object); + serialize("direct", x.GetDirect(), object); } void to_json(const dataservice::read::model::VersionInfo& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("dependencies", x.GetDependencies(), value, allocator); - serialize("timestamp", x.GetTimestamp(), value, allocator); - serialize("version", x.GetVersion(), value, allocator); - serialize("partitionCounts", x.GetPartitionCounts(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("dependencies", x.GetDependencies(), object); + serialize("timestamp", x.GetTimestamp(), object); + serialize("version", x.GetVersion(), object); + serialize("partitionCounts", x.GetPartitionCounts(), object); } void to_json(const dataservice::read::model::VersionInfos& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("versions", x.GetVersions(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("versions", x.GetVersions(), object); } } // namespace serializer } // namespace olp diff --git a/olp-cpp-sdk-dataservice-read/src/generated/serializer/VersionInfosSerializer.h b/olp-cpp-sdk-dataservice-read/src/generated/serializer/VersionInfosSerializer.h index 2d950baf0..7a89f4966 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/serializer/VersionInfosSerializer.h +++ b/olp-cpp-sdk-dataservice-read/src/generated/serializer/VersionInfosSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,22 +19,19 @@ #pragma once -#include +#include #include "olp/dataservice/read/model/VersionInfos.h" namespace olp { namespace serializer { void to_json(const dataservice::read::model::VersionDependency& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::read::model::VersionInfo& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::read::model::VersionInfos& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); } // namespace serializer } // namespace olp diff --git a/olp-cpp-sdk-dataservice-read/src/generated/serializer/VersionResponseSerializer.cpp b/olp-cpp-sdk-dataservice-read/src/generated/serializer/VersionResponseSerializer.cpp index ec4e2a4d8..f1dcca8ec 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/serializer/VersionResponseSerializer.cpp +++ b/olp-cpp-sdk-dataservice-read/src/generated/serializer/VersionResponseSerializer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ * License-Filename: LICENSE */ -#include +#include #include "VersionResponseSerializer.h" @@ -26,10 +26,9 @@ namespace olp { namespace serializer { void to_json(const dataservice::read::model::VersionResponse& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("version", x.GetVersion(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("version", x.GetVersion(), object); } } // namespace serializer } // namespace olp diff --git a/olp-cpp-sdk-dataservice-read/src/generated/serializer/VersionResponseSerializer.h b/olp-cpp-sdk-dataservice-read/src/generated/serializer/VersionResponseSerializer.h index af3c4f774..264bb099c 100644 --- a/olp-cpp-sdk-dataservice-read/src/generated/serializer/VersionResponseSerializer.h +++ b/olp-cpp-sdk-dataservice-read/src/generated/serializer/VersionResponseSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,14 +19,13 @@ #pragma once -#include +#include #include "olp/dataservice/read/model/VersionResponse.h" namespace olp { namespace serializer { void to_json(const dataservice::read::model::VersionResponse& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); } // namespace serializer } // namespace olp diff --git a/olp-cpp-sdk-dataservice-read/src/repositories/PartitionsRepository.cpp b/olp-cpp-sdk-dataservice-read/src/repositories/PartitionsRepository.cpp index de36fff53..37e6acc81 100644 --- a/olp-cpp-sdk-dataservice-read/src/repositories/PartitionsRepository.cpp +++ b/olp-cpp-sdk-dataservice-read/src/repositories/PartitionsRepository.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2024 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,9 @@ #include #include #include +#include +#include + #include "CatalogRepository.h" #include "generated/api/MetadataApi.h" #include "generated/api/QueryApi.h" @@ -170,6 +173,35 @@ bool CheckAdditionalFields( return true; } + +class StreamParser { + public: + explicit StreamParser(const olp::dataservice::read::PartitionsStreamCallback& + partition_callback) + : parser_({}, partition_callback) {} + + boost::json::error_code ParseStream( + olp::dataservice::read::repository::RapidJsonByteStream& stream) { + parser_.reset(); + + // Default error to handle empty stream + auto result = boost::json::make_error_code(boost::json::error::incomplete); + + while (stream.Peek() != '\0') { + auto ch = stream.Take(); + parser_.write_some(true, &ch, 1u, result); + } + return result; + } + + void Abort() { parser_.handler().Abort(); } + + private: + boost::json::basic_parser< + olp::dataservice::read::repository::PartitionsSaxHandler> + parser_; +}; + } // namespace namespace olp { @@ -232,8 +264,8 @@ PartitionsRepository::GetPartitionsExtendedResponse( const auto& partition_ids = request.GetPartitionIds(); - // Temporary workaround for merging the same requests. Should be removed after - // OlpClient could handle that. + // Temporary workaround for merging the same requests. Should be removed + // after OlpClient could handle that. const auto detail = partition_ids.empty() ? "" : HashPartitions(partition_ids); const auto version_str = version ? std::to_string(*version) : ""; @@ -649,16 +681,14 @@ client::ApiNoResponse PartitionsRepository::ParsePartitionsStream( const std::shared_ptr& async_stream, const PartitionsStreamCallback& partition_callback, client::CancellationContext context) { - rapidjson::ParseResult parse_result; + boost::json::error_code parse_result; // We must perform at least one attempt to parse. do { - rapidjson::Reader reader; - auto partitions_handler = - std::make_shared(partition_callback); + auto parser = std::make_shared(partition_callback); auto reader_cancellation_token = client::CancellationToken([=]() { - partitions_handler->Abort(); + parser->Abort(); async_stream->CloseStream(client::ApiError::Cancelled()); }); @@ -668,21 +698,23 @@ client::ApiNoResponse PartitionsRepository::ParsePartitionsStream( } auto json_stream = async_stream->GetCurrentStream(); + parse_result = parser->ParseStream(*json_stream); - parse_result = reader.Parse( - *json_stream, *partitions_handler); // Retry to parse the stream until it's closed. } while (!async_stream->IsClosed()); - auto error = async_stream->GetError(); - - if (error) { + if (auto error = async_stream->GetError()) { return {*error}; - } else if (!parse_result) { - return client::ApiError(parse_result.Code(), "Parsing error"); - } else { - return client::ApiNoResult{}; } + + if (parse_result.failed()) { + OLP_SDK_LOG_WARNING_F( + kLogTag, "ParsePartitionsStream: Failed to parse the stream, error=%s", + parse_result.message().c_str()); + return client::ApiError(parse_result.value(), "Parsing error"); + } + + return client::ApiNoResult{}; } void PartitionsRepository::StreamPartitions( @@ -701,8 +733,8 @@ void PartitionsRepository::StreamPartitions( std::size_t length) mutable { const char* json_chunk = reinterpret_cast(data); if (!offset) { - // TODO: we can use ranges to avoid reseting the stream, instead continue - // download from the last offset + length. + // TODO: we can use ranges to avoid reseting the stream, instead + // continue download from the last offset + length. async_stream->ResetStream(json_chunk, length); } else { async_stream->AppendContent(json_chunk, length); diff --git a/olp-cpp-sdk-dataservice-read/src/repositories/PartitionsSaxHandler.cpp b/olp-cpp-sdk-dataservice-read/src/repositories/PartitionsSaxHandler.cpp index 146c34e6c..d3d6256f7 100644 --- a/olp-cpp-sdk-dataservice-read/src/repositories/PartitionsSaxHandler.cpp +++ b/olp-cpp-sdk-dataservice-read/src/repositories/PartitionsSaxHandler.cpp @@ -19,6 +19,8 @@ #include "PartitionsSaxHandler.h" +#include + namespace olp { namespace dataservice { namespace read { @@ -35,7 +37,38 @@ constexpr unsigned long long int HashStringToInt( PartitionsSaxHandler::PartitionsSaxHandler(PartitionCallback partition_callback) : partition_callback_(std::move(partition_callback)) {} -bool PartitionsSaxHandler::StartObject() { +bool PartitionsSaxHandler::on_document_begin(boost::json::error_code&) { + return continue_parsing_; +} + +bool PartitionsSaxHandler::on_document_end(boost::json::error_code&) { + return continue_parsing_; +} + +bool PartitionsSaxHandler::on_array_begin(boost::json::error_code&) { + // We expect only a single array in the whole response + if (state_ != State::kWaitPartitionsArray) { + return false; + } + + state_ = State::kWaitForNextPartition; + + return continue_parsing_; +} + +bool PartitionsSaxHandler::on_array_end(std::size_t, boost::json::error_code&) { + key_.clear(); + value_.clear(); + + if (state_ != State::kWaitForNextPartition) { + return false; + } + + state_ = State::kWaitForRootObjectEnd; + return continue_parsing_; +} + +bool PartitionsSaxHandler::on_object_begin(boost::json::error_code&) { if (state_ == State::kWaitForRootObject) { state_ = State::kWaitForRootPartitions; return continue_parsing_; @@ -50,36 +83,62 @@ bool PartitionsSaxHandler::StartObject() { return continue_parsing_; } -bool PartitionsSaxHandler::String(const char* str, unsigned int length, bool) { - switch (state_) { - case State::kProcessingAttribute: - state_ = ProcessNextAttribute(str, length); - return continue_parsing_; +bool PartitionsSaxHandler::on_object_end(std::size_t, + boost::json::error_code&) { + key_.clear(); + value_.clear(); - case State::kWaitForRootPartitions: - if (HashStringToInt("partitions") == HashStringToInt(str)) { - state_ = State::kWaitPartitionsArray; - return continue_parsing_; - } else { - return false; - } + if (state_ == State::kWaitForRootObjectEnd) { + state_ = State::kParsingComplete; + return true; // complete + } + + if (state_ != State::kProcessingAttribute) { + return false; + } + + if (partition_.GetDataHandle().empty() || partition_.GetPartition().empty()) { + return false; // partition is not valid + } + + partition_callback_(std::move(partition_)); + state_ = State::kWaitForNextPartition; + + return continue_parsing_; +} + +bool PartitionsSaxHandler::on_string_part(boost::json::string_view s, + std::size_t, + boost::json::error_code&) { + value_ += s; + return continue_parsing_; +} + +bool PartitionsSaxHandler::on_string(boost::json::string_view s, std::size_t, + boost::json::error_code&) { + value_ += s; + + switch (state_) { case State::kParsingPartitionName: - partition_.SetPartition(std::string(str, length)); + partition_.SetPartition(value_); break; case State::kParsingDataHandle: - partition_.SetDataHandle(std::string(str, length)); + partition_.SetDataHandle(value_); break; case State::kParsingChecksum: - partition_.SetChecksum(std::string(str, length)); + partition_.SetChecksum(value_); break; case State::kParsingCrc: - partition_.SetCrc(std::string(str, length)); + partition_.SetCrc(value_); break; case State::kParsingIgnoreAttribute: break; + case State::kProcessingAttribute: // Not expected + case State::kWaitForRootPartitions: // Not expected case State::kWaitForRootObject: // Not expected + case State::kWaitPartitionsArray: // Not expected case State::kWaitForNextPartition: // Not expected case State::kWaitForRootObjectEnd: // Not expected case State::kParsingVersion: // Version is not a string @@ -92,16 +151,66 @@ bool PartitionsSaxHandler::String(const char* str, unsigned int length, bool) { state_ = State::kProcessingAttribute; + value_.clear(); + + return continue_parsing_; +} + +bool PartitionsSaxHandler::on_key_part(boost::json::string_view s, std::size_t, + boost::json::error_code&) { + key_ += s; return continue_parsing_; } -bool PartitionsSaxHandler::Uint(unsigned int value) { +bool PartitionsSaxHandler::on_key(boost::json::string_view s, std::size_t, + boost::json::error_code&) { + key_ += s; + + switch (state_) { + case State::kProcessingAttribute: + state_ = ProcessNextAttribute(key_.data(), key_.size()); + break; + + case State::kWaitForRootPartitions: + if (HashStringToInt("partitions") != HashStringToInt(key_.data())) { + return false; + } + state_ = State::kWaitPartitionsArray; + break; + + case State::kParsingPartitionName: // Not expected + case State::kParsingDataHandle: // Not expected + case State::kParsingChecksum: // Not expected + case State::kParsingCrc: // Not expected + case State::kParsingIgnoreAttribute: // Not expected + case State::kWaitForRootObject: // Not expected + case State::kWaitForNextPartition: // Not expected + case State::kWaitForRootObjectEnd: // Not expected + case State::kParsingVersion: // Not expected + case State::kParsingDataSize: // Not expected + case State::kParsingCompressedDataSize: // Not expected + default: + return false; + }; + + key_.clear(); + + return continue_parsing_; +} + +bool PartitionsSaxHandler::on_number_part(boost::json::string_view, + boost::json::error_code&) { + return continue_parsing_; +} + +bool PartitionsSaxHandler::on_int64(int64_t i, boost::json::string_view, + boost::json::error_code&) { if (state_ == State::kParsingVersion) { - partition_.SetVersion(value); + partition_.SetVersion(i); } else if (state_ == State::kParsingDataSize) { - partition_.SetDataSize(value); + partition_.SetDataSize(i); } else if (state_ == State::kParsingCompressedDataSize) { - partition_.SetCompressedDataSize(value); + partition_.SetCompressedDataSize(i); } else { return false; } @@ -110,48 +219,44 @@ bool PartitionsSaxHandler::Uint(unsigned int value) { return continue_parsing_; } -bool PartitionsSaxHandler::EndObject(unsigned int) { - if (state_ == State::kWaitForRootObjectEnd) { - state_ = State::kParsingComplete; - return true; // complete - } - - if (state_ != State::kProcessingAttribute) { +bool PartitionsSaxHandler::on_uint64(uint64_t u, boost::json::string_view, + boost::json::error_code&) { + if (state_ == State::kParsingVersion) { + partition_.SetVersion(u); + } else if (state_ == State::kParsingDataSize) { + partition_.SetDataSize(u); + } else if (state_ == State::kParsingCompressedDataSize) { + partition_.SetCompressedDataSize(u); + } else { return false; } - if (partition_.GetDataHandle().empty() || partition_.GetPartition().empty()) { - return false; // partition is not valid - } - - partition_callback_(std::move(partition_)); - - state_ = State::kWaitForNextPartition; - + state_ = State::kProcessingAttribute; return continue_parsing_; } -bool PartitionsSaxHandler::StartArray() { - // We expect only a single array in whol response - if (state_ != State::kWaitPartitionsArray) { - return false; - } - - state_ = State::kWaitForNextPartition; +bool PartitionsSaxHandler::on_double(double, boost::json::string_view, + boost::json::error_code&) { + return continue_parsing_; +} +bool PartitionsSaxHandler::on_bool(bool, boost::json::error_code&) { return continue_parsing_; } -bool PartitionsSaxHandler::EndArray(unsigned int) { - if (state_ != State::kWaitForNextPartition) { - return false; - } +bool PartitionsSaxHandler::on_null(boost::json::error_code&) { + return continue_parsing_; +} - state_ = State::kWaitForRootObjectEnd; +bool PartitionsSaxHandler::on_comment_part(boost::json::string_view, + boost::json::error_code&) { return continue_parsing_; } -bool PartitionsSaxHandler::Default() { return false; } +bool PartitionsSaxHandler::on_comment(boost::json::string_view, + boost::json::error_code&) { + return continue_parsing_; +} void PartitionsSaxHandler::Abort() { continue_parsing_.store(false); } diff --git a/olp-cpp-sdk-dataservice-read/src/repositories/PartitionsSaxHandler.h b/olp-cpp-sdk-dataservice-read/src/repositories/PartitionsSaxHandler.h index 1e5f1f905..22e8cb8dd 100644 --- a/olp-cpp-sdk-dataservice-read/src/repositories/PartitionsSaxHandler.h +++ b/olp-cpp-sdk-dataservice-read/src/repositories/PartitionsSaxHandler.h @@ -22,7 +22,7 @@ #include #include -#include "rapidjson/reader.h" +#include #include @@ -31,26 +31,175 @@ namespace dataservice { namespace read { namespace repository { -class PartitionsSaxHandler - : public rapidjson::BaseReaderHandler, - PartitionsSaxHandler> { +class PartitionsSaxHandler { public: using PartitionCallback = std::function; explicit PartitionsSaxHandler(PartitionCallback partition_callback); - /// Json object events - bool StartObject(); - bool EndObject(unsigned int); - - /// Json array events - bool StartArray(); - bool EndArray(unsigned int); - - /// Json attributes events - bool String(const char* str, unsigned int length, bool); - bool Uint(unsigned int value); - bool Default(); + static constexpr std::size_t max_object_size = + boost::json::object::max_size(); + + static constexpr std::size_t max_array_size = boost::json::array::max_size(); + + static constexpr std::size_t max_key_size = boost::json::string::max_size(); + + static constexpr std::size_t max_string_size = + boost::json::string::max_size(); + + /// Called once when the JSON parsing begins. + /// + /// @return `true` on success. + /// @param ec Set to the error, if any occurred. + /// + bool on_document_begin(boost::json::error_code& ec); + + /// Called when the JSON parsing is done. + /// + /// @return `true` on success. + /// @param ec Set to the error, if any occurred. + /// + bool on_document_end(boost::json::error_code& ec); + + /// Called when the beginning of an array is encountered. + /// + /// @return `true` on success. + /// @param ec Set to the error, if any occurred. + /// + bool on_array_begin(boost::json::error_code& ec); + + /// Called when the end of the current array is encountered. + /// + /// @return `true` on success. + /// @param n The number of elements in the array. + /// @param ec Set to the error, if any occurred. + /// + bool on_array_end(std::size_t n, boost::json::error_code& ec); + + /// Called when the beginning of an object is encountered. + /// + /// @return `true` on success. + /// @param ec Set to the error, if any occurred. + /// + bool on_object_begin(boost::json::error_code& ec); + + /// Called when the end of the current object is encountered. + /// + /// @return `true` on success. + /// @param n The number of elements in the object. + /// @param ec Set to the error, if any occurred. + /// + bool on_object_end(std::size_t n, boost::json::error_code& ec); + + /// Called with characters corresponding to part of the current string. + /// + /// @return `true` on success. + /// @param s The partial characters + /// @param n The total size of the string thus far + /// @param ec Set to the error, if any occurred. + /// + bool on_string_part(boost::json::string_view s, std::size_t n, + boost::json::error_code& ec); + + /// Called with the last characters corresponding to the current string. + /// + /// @return `true` on success. + /// @param s The remaining characters + /// @param n The total size of the string + /// @param ec Set to the error, if any occurred. + /// + bool on_string(boost::json::string_view s, std::size_t n, + boost::json::error_code& ec); + + /// Called with characters corresponding to part of the current key. + /// + /// @return `true` on success. + /// @param s The partial characters + /// @param n The total size of the key thus far + /// @param ec Set to the error, if any occurred. + /// + bool on_key_part(boost::json::string_view s, std::size_t n, + boost::json::error_code& ec); + + /// Called with the last characters corresponding to the current key. + /// + /// @return `true` on success. + /// @param s The remaining characters + /// @param n The total size of the key + /// @param ec Set to the error, if any occurred. + /// + bool on_key(boost::json::string_view s, std::size_t n, + boost::json::error_code& ec); + + /// Called with the characters corresponding to part of the current number. + /// + /// @return `true` on success. + /// @param s The partial characters + /// @param ec Set to the error, if any occurred. + /// + bool on_number_part(boost::json::string_view s, boost::json::error_code& ec); + + /// Called when a signed integer is parsed. + /// + /// @return `true` on success. + /// @param i The value + /// @param s The remaining characters + /// @param ec Set to the error, if any occurred. + /// + bool on_int64(int64_t i, boost::json::string_view s, + boost::json::error_code& ec); + + /// Called when an unsigend integer is parsed. + /// + /// @return `true` on success. + /// @param u The value + /// @param s The remaining characters + /// @param ec Set to the error, if any occurred. + /// + bool on_uint64(uint64_t u, boost::json::string_view s, + boost::json::error_code& ec); + + /// Called when a double is parsed. + /// + /// @return `true` on success. + /// @param d The value + /// @param s The remaining characters + /// @param ec Set to the error, if any occurred. + /// + bool on_double(double d, boost::json::string_view s, + boost::json::error_code& ec); + + /// Called when a boolean is parsed. + /// + /// @return `true` on success. + /// @param b The value + /// @param s The remaining characters + /// @param ec Set to the error, if any occurred. + /// + bool on_bool(bool b, boost::json::error_code& ec); + + /// Called when a null is parsed. + /// + /// @return `true` on success. + /// @param ec Set to the error, if any occurred. + /// + bool on_null(boost::json::error_code& ec); + + /// Called with characters corresponding to part of the current comment. + /// + /// @return `true` on success. + /// @param s The partial characters. + /// @param ec Set to the error, if any occurred. + /// + bool on_comment_part(boost::json::string_view s, boost::json::error_code& ec); + + /// Called with the last characters corresponding to the current comment. + /// + /// @return `true` on success. + /// @param s The remaining characters + /// @param ec Set to the error, if any occurred. + /// + bool on_comment(boost::json::string_view s, boost::json::error_code& ec); /// Abort parsing void Abort(); @@ -77,9 +226,11 @@ class PartitionsSaxHandler kParsingComplete, }; - State ProcessNextAttribute(const char* name, unsigned int length); + static State ProcessNextAttribute(const char* name, unsigned int length); State state_{State::kWaitForRootObject}; + std::string key_; + std::string value_; model::Partition partition_; PartitionCallback partition_callback_; std::atomic_bool continue_parsing_{true}; diff --git a/olp-cpp-sdk-dataservice-read/src/repositories/QuadTreeIndex.cpp b/olp-cpp-sdk-dataservice-read/src/repositories/QuadTreeIndex.cpp index b72748757..92790b312 100644 --- a/olp-cpp-sdk-dataservice-read/src/repositories/QuadTreeIndex.cpp +++ b/olp-cpp-sdk-dataservice-read/src/repositories/QuadTreeIndex.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2024 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +23,8 @@ #include #include -#include -#include -#include +#include +#include #include "BlobDataReader.h" #include "BlobDataWriter.h" @@ -47,33 +46,37 @@ constexpr auto kCrcKey = "crc"; constexpr auto kLogTag = "QuadTreeIndex"; olp::dataservice::read::QuadTreeIndex::IndexData ParseCommonIndexData( - rapidjson::Value& value) { + boost::json::object& obj) { olp::dataservice::read::QuadTreeIndex::IndexData data; - auto obj = value.GetObject(); - if (obj.HasMember(kAdditionalMetadataKey) && - obj[kAdditionalMetadataKey].IsString()) { - data.additional_metadata = obj[kAdditionalMetadataKey].GetString(); + if (obj.contains(kAdditionalMetadataKey) && + obj[kAdditionalMetadataKey].is_string()) { + data.additional_metadata = obj[kAdditionalMetadataKey].get_string().c_str(); } - if (obj.HasMember(kChecksumKey) && obj[kChecksumKey].IsString()) { - data.checksum = obj[kChecksumKey].GetString(); + if (obj.contains(kChecksumKey) && obj[kChecksumKey].is_string()) { + data.checksum = obj[kChecksumKey].get_string().c_str(); } - if (obj.HasMember(kCrcKey) && obj[kCrcKey].IsString()) { - data.crc = obj[kCrcKey].GetString(); + if (obj.contains(kCrcKey) && obj[kCrcKey].is_string()) { + data.crc = obj[kCrcKey].get_string().c_str(); } - if (obj.HasMember(kDataSizeKey) && obj[kDataSizeKey].IsInt64()) { - data.data_size = obj[kDataSizeKey].GetInt64(); + if (auto* data_size = obj.if_contains(kDataSizeKey)) { + if (data_size->is_uint64() || data_size->is_int64()) { + data.data_size = data_size->to_number(); + } } - if (obj.HasMember(kCompressedDataSizeKey) && - obj[kCompressedDataSizeKey].IsInt64()) { - data.compressed_data_size = obj[kCompressedDataSizeKey].GetInt64(); + if (auto* data_size = obj.if_contains(kCompressedDataSizeKey)) { + if (data_size->is_uint64() || data_size->is_int64()) { + data.compressed_data_size = data_size->to_number(); + } } - if (obj.HasMember(kVersionKey) && obj[kVersionKey].IsUint64()) { - data.version = obj[kVersionKey].GetUint64(); + if (auto* version = obj.if_contains(kVersionKey)) { + if (version->is_uint64() || version->is_int64()) { + data.version = version->to_number(); + } } return data; } @@ -102,60 +105,62 @@ QuadTreeIndex::QuadTreeIndex(const cache::KeyValueCache::ValueTypePtr& data) { QuadTreeIndex::QuadTreeIndex(const olp::geo::TileKey& root, int depth, std::stringstream& json_stream) { - static thread_local rapidjson::CrtAllocator crt_allocator; - static thread_local rapidjson::MemoryPoolAllocator<> pool_allocator; - rapidjson::Document doc(&pool_allocator, 4096, &crt_allocator); + boost::json::error_code ec; + auto parsed_value = boost::json::parse(json_stream, ec); - rapidjson::IStreamWrapper stream(json_stream); - doc.ParseStream(stream); - - if (!doc.IsObject()) { + if (!parsed_value.is_object()) { return; } - std::vector subs; - std::vector parents; + auto& top_object = parsed_value.as_object(); - auto parent_quads_value = doc.FindMember(kParentQuadsKey); - auto sub_quads_value = doc.FindMember(kSubQuadsKey); + auto parent_quads_value = top_object.find(kParentQuadsKey); + auto sub_quads_value = top_object.find(kSubQuadsKey); - if (parent_quads_value == doc.MemberEnd() && - sub_quads_value == doc.MemberEnd()) { + if (parent_quads_value == top_object.end() && + sub_quads_value == top_object.end()) { return; } - if (parent_quads_value != doc.MemberEnd() && - parent_quads_value->value.IsArray()) { - parents.reserve(parent_quads_value->value.Size()); - for (auto& value : parent_quads_value->value.GetArray()) { - auto obj = value.GetObject(); + std::vector subs; + std::vector parents; + + if (parent_quads_value != top_object.end() && + parent_quads_value->value().is_array()) { + auto& parent_quads = parent_quads_value->value().as_array(); + parents.reserve(parent_quads.size()); + for (auto& value : parent_quads) { + auto& obj = value.as_object(); - if (!obj.HasMember(kDataHandleKey) || !obj[kDataHandleKey].IsString() || - !obj.HasMember(kPartitionKey) || !obj[kPartitionKey].IsString()) { + if (!obj.contains(kDataHandleKey) || !obj[kDataHandleKey].is_string() || + !obj.contains(kPartitionKey) || !obj[kPartitionKey].is_string()) { continue; } - IndexData data = ParseCommonIndexData(value); - data.data_handle = obj[kDataHandleKey].GetString(); - data.tile_key = - olp::geo::TileKey::FromHereTile(obj[kPartitionKey].GetString()); + IndexData data = ParseCommonIndexData(obj); + data.data_handle = obj[kDataHandleKey].as_string().c_str(); + data.tile_key = olp::geo::TileKey::FromHereTile( + obj[kPartitionKey].as_string().c_str()); parents.push_back(std::move(data)); } } - if (sub_quads_value != doc.MemberEnd() && sub_quads_value->value.IsArray()) { - subs.reserve(sub_quads_value->value.Size()); - for (auto& value : sub_quads_value->value.GetArray()) { - auto obj = value.GetObject(); + if (sub_quads_value != top_object.end() && + sub_quads_value->value().is_array()) { + auto& sub_quads = sub_quads_value->value().as_array(); + subs.reserve(sub_quads.size()); + for (auto& value : sub_quads) { + auto obj = value.as_object(); - if (!obj.HasMember(kDataHandleKey) || !obj[kDataHandleKey].IsString() || - !obj.HasMember(kSubQuadKeyKey) || !obj[kSubQuadKeyKey].IsString()) { + if (!obj.contains(kDataHandleKey) || !obj[kDataHandleKey].is_string() || + !obj.contains(kSubQuadKeyKey) || !obj[kSubQuadKeyKey].is_string()) { continue; } - IndexData data = ParseCommonIndexData(value); - data.data_handle = obj[kDataHandleKey].GetString(); - data.tile_key = root.AddedSubHereTile(obj[kSubQuadKeyKey].GetString()); + IndexData data = ParseCommonIndexData(obj); + data.data_handle = obj[kDataHandleKey].as_string().c_str(); + data.tile_key = + root.AddedSubHereTile(obj[kSubQuadKeyKey].as_string().c_str()); subs.push_back(std::move(data)); } } diff --git a/olp-cpp-sdk-dataservice-read/tests/PartitionsSaxHandlerTest.cpp b/olp-cpp-sdk-dataservice-read/tests/PartitionsSaxHandlerTest.cpp index 9126599d0..5e9e29346 100644 --- a/olp-cpp-sdk-dataservice-read/tests/PartitionsSaxHandlerTest.cpp +++ b/olp-cpp-sdk-dataservice-read/tests/PartitionsSaxHandlerTest.cpp @@ -51,31 +51,33 @@ TEST(PartitionsSaxHandlerTest, NormalFlow) { parsed_partition = partition; }; + boost::json::error_code ec; repository::PartitionsSaxHandler handler(callback); - ASSERT_TRUE(handler.StartObject()); - ASSERT_TRUE(handler.String(kPartitions, len(kPartitions), true)); - ASSERT_TRUE(handler.StartArray()); - - ASSERT_TRUE(handler.StartObject()); - ASSERT_TRUE(handler.String(kDataHandle, len(kDataHandle), true)); - ASSERT_TRUE(handler.String(kDataHandleValue, len(kDataHandleValue), true)); - ASSERT_TRUE(handler.String(kPartition, len(kPartition), true)); - ASSERT_TRUE(handler.String(kPartitionValue, len(kPartitionValue), true)); - ASSERT_TRUE(handler.String(kChecksum, len(kChecksum), true)); - ASSERT_TRUE(handler.String(kChecksumValue, len(kChecksumValue), true)); - ASSERT_TRUE(handler.String(kDataSize, len(kDataSize), true)); - ASSERT_TRUE(handler.Uint(150)); - ASSERT_TRUE(handler.String(kCompressedDataSize, len(kCompressedDataSize), true)); - ASSERT_TRUE(handler.Uint(100)); - ASSERT_TRUE(handler.String(kVersion, len(kVersion), true)); - ASSERT_TRUE(handler.Uint(6)); - ASSERT_TRUE(handler.String(kCrc, len(kCrc), true)); - ASSERT_TRUE(handler.String(kCrcValue, len(kCrcValue), true)); - ASSERT_TRUE(handler.EndObject(0)); - - ASSERT_TRUE(handler.EndArray(0)); - ASSERT_TRUE(handler.EndObject(0)); + ASSERT_TRUE(handler.on_object_begin(ec)); + ASSERT_TRUE(handler.on_key(kPartitions, len(kPartitions), ec)); + ASSERT_TRUE(handler.on_array_begin(ec)); + + ASSERT_TRUE(handler.on_object_begin(ec)); + ASSERT_TRUE(handler.on_key(kDataHandle, len(kDataHandle), ec)); + ASSERT_TRUE(handler.on_string(kDataHandleValue, len(kDataHandleValue), ec)); + ASSERT_TRUE(handler.on_key(kPartition, len(kPartition), ec)); + ASSERT_TRUE(handler.on_string(kPartitionValue, len(kPartitionValue), ec)); + ASSERT_TRUE(handler.on_key(kChecksum, len(kChecksum), ec)); + ASSERT_TRUE(handler.on_string(kChecksumValue, len(kChecksumValue), ec)); + ASSERT_TRUE(handler.on_key(kDataSize, len(kDataSize), ec)); + ASSERT_TRUE(handler.on_uint64(150, {}, ec)); + ASSERT_TRUE( + handler.on_key(kCompressedDataSize, len(kCompressedDataSize), ec)); + ASSERT_TRUE(handler.on_uint64(100, {}, ec)); + ASSERT_TRUE(handler.on_key(kVersion, len(kVersion), ec)); + ASSERT_TRUE(handler.on_uint64(6, {}, ec)); + ASSERT_TRUE(handler.on_key(kCrc, len(kCrc), ec)); + ASSERT_TRUE(handler.on_string(kCrcValue, len(kCrcValue), ec)); + ASSERT_TRUE(handler.on_object_end(0, ec)); + + ASSERT_TRUE(handler.on_array_end(0, ec)); + ASSERT_TRUE(handler.on_object_end(0, ec)); EXPECT_EQ(parsed_partition.GetDataHandle(), std::string(kDataHandleValue)); EXPECT_EQ(parsed_partition.GetPartition(), std::string(kPartitionValue)); @@ -90,93 +92,94 @@ TEST(PartitionsSaxHandlerTest, NormalFlow) { TEST(PartitionsSaxHandlerTest, WrongJSONStructure) { auto callback = [&](model::Partition) {}; + boost::json::error_code ec; repository::PartitionsSaxHandler handler(callback); // Initial state expects an object - ASSERT_FALSE(handler.String(kPartitions, len(kPartitions), true)); - ASSERT_FALSE(handler.Uint(6)); - ASSERT_FALSE(handler.StartArray()); - ASSERT_FALSE(handler.EndArray(0)); - ASSERT_FALSE(handler.EndObject(0)); + ASSERT_FALSE(handler.on_key(kPartitions, len(kPartitions), ec)); + ASSERT_FALSE(handler.on_uint64(6, {}, ec)); + ASSERT_FALSE(handler.on_array_begin(ec)); + ASSERT_FALSE(handler.on_array_end(0, ec)); + ASSERT_FALSE(handler.on_object_end(0, ec)); - ASSERT_TRUE(handler.StartObject()); + ASSERT_TRUE(handler.on_object_begin(ec)); // next state expects a partitions string - ASSERT_FALSE(handler.String(kDataHandle, len(kDataHandle), true)); - ASSERT_FALSE(handler.Uint(6)); - ASSERT_FALSE(handler.StartArray()); - ASSERT_FALSE(handler.StartObject()); - ASSERT_FALSE(handler.EndObject(0)); - ASSERT_FALSE(handler.EndArray(0)); + ASSERT_FALSE(handler.on_key(kDataHandle, len(kDataHandle), ec)); + ASSERT_FALSE(handler.on_uint64(6, {}, ec)); + ASSERT_FALSE(handler.on_array_begin(ec)); + ASSERT_FALSE(handler.on_object_begin(ec)); + ASSERT_FALSE(handler.on_object_end(0, ec)); + ASSERT_FALSE(handler.on_array_end(0, ec)); - ASSERT_TRUE(handler.String(kPartitions, len(kPartitions), true)); + ASSERT_TRUE(handler.on_key(kPartitions, len(kPartitions), ec)); // expect partitions array - ASSERT_FALSE(handler.String(kDataHandle, len(kDataHandle), true)); - ASSERT_FALSE(handler.Uint(6)); - ASSERT_FALSE(handler.StartObject()); - ASSERT_FALSE(handler.EndObject(0)); - ASSERT_FALSE(handler.EndArray(0)); + ASSERT_FALSE(handler.on_key(kDataHandle, len(kDataHandle), ec)); + ASSERT_FALSE(handler.on_uint64(6, {}, ec)); + ASSERT_FALSE(handler.on_object_begin(ec)); + ASSERT_FALSE(handler.on_object_end(0, ec)); + ASSERT_FALSE(handler.on_array_end(0, ec)); - ASSERT_TRUE(handler.StartArray()); + ASSERT_TRUE(handler.on_array_begin(ec)); // expect partition object - ASSERT_FALSE(handler.String(kDataHandle, len(kDataHandle), true)); - ASSERT_FALSE(handler.Uint(6)); - ASSERT_FALSE(handler.StartArray()); - ASSERT_FALSE(handler.EndObject(0)); + ASSERT_FALSE(handler.on_key(kDataHandle, len(kDataHandle), ec)); + ASSERT_FALSE(handler.on_uint64(6, {}, ec)); + ASSERT_FALSE(handler.on_array_begin(ec)); + ASSERT_FALSE(handler.on_object_end(0, ec)); - ASSERT_TRUE(handler.StartObject()); + ASSERT_TRUE(handler.on_object_begin(ec)); // object is not valid - ASSERT_FALSE(handler.EndObject(0)); + ASSERT_FALSE(handler.on_object_end(0, ec)); // expect partition attribute - ASSERT_FALSE(handler.Uint(6)); - ASSERT_FALSE(handler.StartArray()); + ASSERT_FALSE(handler.on_uint64(6, {}, ec)); + ASSERT_FALSE(handler.on_array_begin(ec)); - ASSERT_TRUE(handler.String(kDataHandle, len(kDataHandle), true)); + ASSERT_TRUE(handler.on_key(kDataHandle, len(kDataHandle), ec)); // expect string attribute value - ASSERT_FALSE(handler.Uint(6)); - ASSERT_FALSE(handler.StartArray()); - ASSERT_FALSE(handler.EndObject(0)); + ASSERT_FALSE(handler.on_uint64(6, {}, ec)); + ASSERT_FALSE(handler.on_array_begin(ec)); + ASSERT_FALSE(handler.on_object_end(0, ec)); - ASSERT_TRUE(handler.String(kDataHandleValue, len(kDataHandleValue), true)); + ASSERT_TRUE(handler.on_string(kDataHandleValue, len(kDataHandleValue), ec)); // object is not valid - ASSERT_FALSE(handler.EndObject(0)); + ASSERT_FALSE(handler.on_object_end(0, ec)); // integer properties - ASSERT_TRUE(handler.String(kDataSize, len(kDataSize), true)); + ASSERT_TRUE(handler.on_key(kDataSize, len(kDataSize), ec)); - ASSERT_FALSE(handler.String(kDataHandle, len(kDataHandle), true)); - ASSERT_FALSE(handler.StartArray()); - ASSERT_FALSE(handler.EndArray(0)); - ASSERT_FALSE(handler.StartObject()); - ASSERT_FALSE(handler.EndObject(0)); + ASSERT_FALSE(handler.on_key(kDataHandle, len(kDataHandle), ec)); + ASSERT_FALSE(handler.on_array_begin(ec)); + ASSERT_FALSE(handler.on_array_end(0, ec)); + ASSERT_FALSE(handler.on_object_begin(ec)); + ASSERT_FALSE(handler.on_object_end(0, ec)); - ASSERT_TRUE(handler.Uint(6)); + ASSERT_TRUE(handler.on_uint64(6, {}, ec)); - ASSERT_TRUE(handler.String(kPartition, len(kPartition), true)); - ASSERT_TRUE(handler.String(kPartitionValue, len(kPartitionValue), true)); + ASSERT_TRUE(handler.on_key(kPartition, len(kPartition), ec)); + ASSERT_TRUE(handler.on_string(kPartitionValue, len(kPartitionValue), ec)); // complete partition - ASSERT_TRUE(handler.EndObject(0)); + ASSERT_TRUE(handler.on_object_end(0, ec)); // complete partitions array - ASSERT_TRUE(handler.EndArray(0)); + ASSERT_TRUE(handler.on_array_end(0, ec)); // complete the json - ASSERT_TRUE(handler.EndObject(0)); + ASSERT_TRUE(handler.on_object_end(0, ec)); // nothing works anymore - ASSERT_FALSE(handler.String(kDataHandle, len(kDataHandle), true)); - ASSERT_FALSE(handler.Uint(6)); - ASSERT_FALSE(handler.StartArray()); - ASSERT_FALSE(handler.EndArray(0)); - ASSERT_FALSE(handler.StartObject()); - ASSERT_FALSE(handler.EndObject(0)); + ASSERT_FALSE(handler.on_key(kDataHandle, len(kDataHandle), ec)); + ASSERT_FALSE(handler.on_uint64(6, {}, ec)); + ASSERT_FALSE(handler.on_array_begin(ec)); + ASSERT_FALSE(handler.on_array_end(0, ec)); + ASSERT_FALSE(handler.on_object_begin(ec)); + ASSERT_FALSE(handler.on_object_end(0, ec)); } } // namespace diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/ApiParser.cpp b/olp-cpp-sdk-dataservice-write/src/generated/parser/ApiParser.cpp index 5f47acdad..a8a3b80ba 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/ApiParser.cpp +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/ApiParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::Api& x) { x.SetApi(parse(value, "api")); x.SetVersion(parse(value, "version")); diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/ApiParser.h b/olp-cpp-sdk-dataservice-write/src/generated/parser/ApiParser.h index e3b949c79..f9dd5faf7 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/ApiParser.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/ApiParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,14 +19,14 @@ #pragma once -#include +#include #include "generated/model/Api.h" #include namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::Api& x); } // namespace parser diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/CatalogParser.cpp b/olp-cpp-sdk-dataservice-write/src/generated/parser/CatalogParser.cpp index 8e019993b..5ff20aa0b 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/CatalogParser.cpp +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/CatalogParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,44 +23,44 @@ namespace olp { namespace parser { -using namespace olp::dataservice::write; +namespace model = olp::dataservice::write::model; -void from_json(const rapidjson::Value& value, model::Coverage& x) { +void from_json(const boost::json::value& value, model::Coverage& x) { x.SetAdminAreas(parse >(value, "adminAreas")); } -void from_json(const rapidjson::Value& value, model::IndexDefinition& x) { +void from_json(const boost::json::value& value, model::IndexDefinition& x) { x.SetName(parse(value, "name")); x.SetType(parse(value, "type")); x.SetDuration(parse(value, "duration")); x.SetZoomLevel(parse(value, "zoomLevel")); } -void from_json(const rapidjson::Value& value, model::IndexProperties& x) { +void from_json(const boost::json::value& value, model::IndexProperties& x) { x.SetTtl(parse(value, "ttl")); x.SetIndexDefinitions( parse >(value, "indexDefinitions")); } -void from_json(const rapidjson::Value& value, model::Creator& x) { +void from_json(const boost::json::value& value, model::Creator& x) { x.SetId(parse(value, "id")); } -void from_json(const rapidjson::Value& value, model::Owner& x) { +void from_json(const boost::json::value& value, model::Owner& x) { x.SetCreator(parse(value, "creator")); x.SetOrganisation(parse(value, "organisation")); } -void from_json(const rapidjson::Value& value, model::Partitioning& x) { +void from_json(const boost::json::value& value, model::Partitioning& x) { x.SetScheme(parse(value, "scheme")); x.SetTileLevels(parse >(value, "tileLevels")); } -void from_json(const rapidjson::Value& value, model::Schema& x) { +void from_json(const boost::json::value& value, model::Schema& x) { x.SetHrn(parse(value, "hrn")); } -void from_json(const rapidjson::Value& value, model::StreamProperties& x) { +void from_json(const boost::json::value& value, model::StreamProperties& x) { // Parsing these as double even though OepnAPI sepcs says int64 because // Backend returns the value in decimal format (e.g. 1.0) and this triggers an // assert in RapidJSON when parsing. @@ -70,18 +70,18 @@ void from_json(const rapidjson::Value& value, model::StreamProperties& x) { static_cast(parse(value, "dataOutThroughputMbps"))); } -void from_json(const rapidjson::Value& value, model::Encryption& x) { +void from_json(const boost::json::value& value, model::Encryption& x) { x.SetAlgorithm(parse(value, "algorithm")); } -void from_json(const rapidjson::Value& value, model::Volume& x) { +void from_json(const boost::json::value& value, model::Volume& x) { x.SetVolumeType(parse(value, "volumeType")); x.SetMaxMemoryPolicy(parse(value, "maxMemoryPolicy")); x.SetPackageType(parse(value, "packageType")); x.SetEncryption(parse(value, "encryption")); } -void from_json(const rapidjson::Value& value, model::Layer& x) { +void from_json(const boost::json::value& value, model::Layer& x) { x.SetId(parse(value, "id")); x.SetName(parse(value, "name")); x.SetSummary(parse(value, "summary")); @@ -103,11 +103,11 @@ void from_json(const rapidjson::Value& value, model::Layer& x) { x.SetVolume(parse(value, "volume")); } -void from_json(const rapidjson::Value& value, model::Notifications& x) { +void from_json(const boost::json::value& value, model::Notifications& x) { x.SetEnabled(parse(value, "enabled")); } -void from_json(const rapidjson::Value& value, model::Catalog& x) { +void from_json(const boost::json::value& value, model::Catalog& x) { x.SetId(parse(value, "id")); x.SetHrn(parse(value, "hrn")); x.SetName(parse(value, "name")); diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/CatalogParser.h b/olp-cpp-sdk-dataservice-write/src/generated/parser/CatalogParser.h index 5200ce64c..5a08a0fb3 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/CatalogParser.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/CatalogParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,49 +21,49 @@ #include -#include +#include #include namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::Coverage& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::IndexDefinition& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::IndexProperties& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::Creator& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::Owner& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::Partitioning& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::Schema& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::StreamProperties& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::Encryption& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::Volume& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::Layer& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::Notifications& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::Catalog& x); } // namespace parser } // namespace olp diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/DetailsParser.cpp b/olp-cpp-sdk-dataservice-write/src/generated/parser/DetailsParser.cpp index 25a613b02..076ef0e91 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/DetailsParser.cpp +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/DetailsParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::Details& x) { x.SetState(parse(value, "state")); x.SetMessage(parse(value, "message")); diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/DetailsParser.h b/olp-cpp-sdk-dataservice-write/src/generated/parser/DetailsParser.h index f61d37a2f..be2cc2144 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/DetailsParser.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/DetailsParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,13 +19,13 @@ #pragma once -#include +#include #include namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, dataservice::write::model::Details& x); } // namespace parser } // namespace olp diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/LayerVersionsParser.cpp b/olp-cpp-sdk-dataservice-write/src/generated/parser/LayerVersionsParser.cpp index 424bdcd6f..96d3309e1 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/LayerVersionsParser.cpp +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/LayerVersionsParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,15 +23,15 @@ namespace olp { namespace parser { -using namespace olp::dataservice::write; +namespace model = olp::dataservice::write::model; -void from_json(const rapidjson::Value& value, model::LayerVersion& x) { +void from_json(const boost::json::value& value, model::LayerVersion& x) { x.SetLayer(parse(value, "layer")); x.SetVersion(parse(value, "version")); x.SetTimestamp(parse(value, "timestamp")); } -void from_json(const rapidjson::Value& value, model::LayerVersions& x) { +void from_json(const boost::json::value& value, model::LayerVersions& x) { x.SetLayerVersions( parse>(value, "layerVersions")); x.SetVersion(parse(value, "version")); diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/LayerVersionsParser.h b/olp-cpp-sdk-dataservice-write/src/generated/parser/LayerVersionsParser.h index b3fd60089..e6b1d28f6 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/LayerVersionsParser.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/LayerVersionsParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,17 +19,17 @@ #pragma once -#include +#include #include "generated/model/LayerVersions.h" #include namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::LayerVersion& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::LayerVersions& x); } // namespace parser diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/PartitionParser.h b/olp-cpp-sdk-dataservice-write/src/generated/parser/PartitionParser.h index b087c6094..6e936622c 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/PartitionParser.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/PartitionParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,17 +19,17 @@ #pragma once -#include +#include #include "olp/dataservice/write/model/Partitions.h" #include namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::Partition& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::Partitions& x); } // namespace parser diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/PartitionsParser.cpp b/olp-cpp-sdk-dataservice-write/src/generated/parser/PartitionsParser.cpp index 600341425..9f2052221 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/PartitionsParser.cpp +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/PartitionsParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +23,9 @@ namespace olp { namespace parser { -using namespace olp::dataservice::write; +namespace model = olp::dataservice::write::model; -void from_json(const rapidjson::Value& value, model::Partition& x) { +void from_json(const boost::json::value& value, model::Partition& x) { x.SetChecksum(parse>(value, "checksum")); x.SetCompressedDataSize( parse>(value, "compressedDataSize")); @@ -35,7 +35,7 @@ void from_json(const rapidjson::Value& value, model::Partition& x) { x.SetVersion(parse>(value, "version")); } -void from_json(const rapidjson::Value& value, model::Partitions& x) { +void from_json(const boost::json::value& value, model::Partitions& x) { x.SetPartitions(parse>(value, "partitions")); } diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/PartitionsParser.h b/olp-cpp-sdk-dataservice-write/src/generated/parser/PartitionsParser.h index 9f45ba291..c80278a21 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/PartitionsParser.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/PartitionsParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,17 +19,17 @@ #pragma once -#include +#include #include "generated/model/Partitions.h" #include namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::Partition& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::Partitions& x); } // namespace parser diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/PublicationParser.cpp b/olp-cpp-sdk-dataservice-write/src/generated/parser/PublicationParser.cpp index 2eff59a0d..aa45a02c3 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/PublicationParser.cpp +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/PublicationParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::Publication& x) { x.SetId(parse(value, "id")); x.SetDetails( diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/PublicationParser.h b/olp-cpp-sdk-dataservice-write/src/generated/parser/PublicationParser.h index eb2f67a69..c52d08ff7 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/PublicationParser.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/PublicationParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,13 +19,13 @@ #pragma once -#include +#include #include namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, dataservice::write::model::Publication& x); } // namespace parser } // namespace olp diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishDataRequestParser.cpp b/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishDataRequestParser.cpp index 45f514774..2f7ab8197 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishDataRequestParser.cpp +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishDataRequestParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::PublishDataRequest& x) { x.WithData( (parse>>(value, "data"))); diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishDataRequestParser.h b/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishDataRequestParser.h index 7dd60e032..5a52fcebe 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishDataRequestParser.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishDataRequestParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,13 +19,13 @@ #pragma once -#include +#include #include namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, dataservice::write::model::PublishDataRequest& x); } // namespace parser } // namespace olp diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishPartitionParser.cpp b/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishPartitionParser.cpp index 4e4b620af..28d797cce 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishPartitionParser.cpp +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishPartitionParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::PublishPartition& x) { x.SetPartition(parse(value, "partition")); x.SetChecksum(parse(value, "checksum")); diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishPartitionParser.h b/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishPartitionParser.h index 80ad26a18..87f00a600 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishPartitionParser.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishPartitionParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,13 +19,13 @@ #pragma once -#include +#include #include "generated/model/PublishPartition.h" namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, dataservice::write::model::PublishPartition& x); } // namespace parser } // namespace olp diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishPartitionsParser.cpp b/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishPartitionsParser.cpp index 77fa92dcd..96667a4a0 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishPartitionsParser.cpp +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishPartitionsParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::PublishPartitions& x) { x.SetPartitions( parse>( diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishPartitionsParser.h b/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishPartitionsParser.h index c7b02a402..92abf712b 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishPartitionsParser.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/PublishPartitionsParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,13 +19,13 @@ #pragma once -#include +#include #include "generated/model/PublishPartitions.h" namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, dataservice::write::model::PublishPartitions& x); } // namespace parser } // namespace olp diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/ResponseOkParser.cpp b/olp-cpp-sdk-dataservice-write/src/generated/parser/ResponseOkParser.cpp index 77a770f1e..44f9bf377 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/ResponseOkParser.cpp +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/ResponseOkParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,17 +21,17 @@ #include -using namespace olp::dataservice::write::model; +namespace model = olp::dataservice::write::model; namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, TraceID& x) { +void from_json(const boost::json::value& value, model::TraceID& x) { x.SetParentID(parse(value, "ParentID")); x.SetGeneratedIDs(parse >(value, "GeneratedIDs")); } -void from_json(const rapidjson::Value& value, ResponseOk& x) { - x.SetTraceID(parse(value, "TraceID")); +void from_json(const boost::json::value& value, model::ResponseOk& x) { + x.SetTraceID(parse(value, "TraceID")); } } // namespace parser diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/ResponseOkParser.h b/olp-cpp-sdk-dataservice-write/src/generated/parser/ResponseOkParser.h index f545cd854..6a2c9f822 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/ResponseOkParser.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/ResponseOkParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,16 +19,16 @@ #pragma once -#include +#include #include namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, dataservice::write::model::TraceID& x); -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, dataservice::write::model::ResponseOk& x); } // namespace parser diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/ResponseOkSingleParser.cpp b/olp-cpp-sdk-dataservice-write/src/generated/parser/ResponseOkSingleParser.cpp index 3ee2b9a09..4b4c867de 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/ResponseOkSingleParser.cpp +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/ResponseOkSingleParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, dataservice::write::model::ResponseOkSingle& x) { x.SetTraceID(parse(value, "TraceID")); } diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/ResponseOkSingleParser.h b/olp-cpp-sdk-dataservice-write/src/generated/parser/ResponseOkSingleParser.h index 96b463708..dafdb4506 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/ResponseOkSingleParser.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/ResponseOkSingleParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,13 +19,13 @@ #pragma once -#include +#include #include namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, dataservice::write::model::ResponseOkSingle& x); } // namespace parser diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/VersionDependencyParser.cpp b/olp-cpp-sdk-dataservice-write/src/generated/parser/VersionDependencyParser.cpp index c5992657f..c00becbb3 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/VersionDependencyParser.cpp +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/VersionDependencyParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::VersionDependency& x) { x.SetDirect(parse(value, "direct")); x.SetHrn(parse(value, "hrn")); diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/VersionDependencyParser.h b/olp-cpp-sdk-dataservice-write/src/generated/parser/VersionDependencyParser.h index 7a69b4105..da9179112 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/VersionDependencyParser.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/VersionDependencyParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,13 +19,13 @@ #pragma once -#include +#include #include namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, dataservice::write::model::VersionDependency& x); } // namespace parser } // namespace olp diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/VersionResponseParser.cpp b/olp-cpp-sdk-dataservice-write/src/generated/parser/VersionResponseParser.cpp index 723463a62..c77315390 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/VersionResponseParser.cpp +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/VersionResponseParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +23,9 @@ namespace olp { namespace parser { -using namespace olp::dataservice::write; +namespace model = olp::dataservice::write::model; -void from_json(const rapidjson::Value& value, model::VersionResponse& x) { +void from_json(const boost::json::value& value, model::VersionResponse& x) { x.SetVersion(parse(value, "version")); } diff --git a/olp-cpp-sdk-dataservice-write/src/generated/parser/VersionResponseParser.h b/olp-cpp-sdk-dataservice-write/src/generated/parser/VersionResponseParser.h index f24794631..ca05e39d9 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/parser/VersionResponseParser.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/parser/VersionResponseParser.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,14 +19,14 @@ #pragma once -#include +#include #include "olp/dataservice/write/model/VersionResponse.h" #include namespace olp { namespace parser { -void from_json(const rapidjson::Value& value, +void from_json(const boost::json::value& value, olp::dataservice::write::model::VersionResponse& x); } // namespace parser diff --git a/olp-cpp-sdk-dataservice-write/src/generated/serializer/ApiSerializer.cpp b/olp-cpp-sdk-dataservice-write/src/generated/serializer/ApiSerializer.cpp index 3e14d9a14..139a28745 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/serializer/ApiSerializer.cpp +++ b/olp-cpp-sdk-dataservice-write/src/generated/serializer/ApiSerializer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ * License-Filename: LICENSE */ -#include +#include #include "ApiSerializer.h" @@ -25,13 +25,13 @@ namespace olp { namespace serializer { -void to_json(const dataservice::write::model::Api& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("api", x.GetApi(), value, allocator); - serialize("version", x.GetVersion(), value, allocator); - serialize("baseURL", x.GetBaseUrl(), value, allocator); - serialize("parameters", x.GetParameters(), value, allocator); +void to_json(const dataservice::write::model::Api& x, + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("api", x.GetApi(), object); + serialize("version", x.GetVersion(), object); + serialize("baseURL", x.GetBaseUrl(), object); + serialize("parameters", x.GetParameters(), object); } } // namespace serializer } // namespace olp diff --git a/olp-cpp-sdk-dataservice-write/src/generated/serializer/ApiSerializer.h b/olp-cpp-sdk-dataservice-write/src/generated/serializer/ApiSerializer.h index 57ad803f3..049564851 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/serializer/ApiSerializer.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/serializer/ApiSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,14 +21,13 @@ #include -#include +#include #include "generated/model/Api.h" namespace olp { namespace serializer { void to_json(const dataservice::write::model::Api& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); } // namespace serializer } // namespace olp diff --git a/olp-cpp-sdk-dataservice-write/src/generated/serializer/CatalogSerializer.cpp b/olp-cpp-sdk-dataservice-write/src/generated/serializer/CatalogSerializer.cpp index ed6cf3643..284d7aa4d 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/serializer/CatalogSerializer.cpp +++ b/olp-cpp-sdk-dataservice-write/src/generated/serializer/CatalogSerializer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ * License-Filename: LICENSE */ -#include +#include #include "CatalogSerializer.h" @@ -26,133 +26,120 @@ namespace olp { namespace serializer { void to_json(const dataservice::write::model::Coverage& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("adminAreas", x.GetAdminAreas(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("adminAreas", x.GetAdminAreas(), object); } void to_json(const dataservice::write::model::IndexDefinition& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("name", x.GetName(), value, allocator); - serialize("type", x.GetType(), value, allocator); - serialize("duration", x.GetDuration(), value, allocator); - serialize("zoomLevel", x.GetZoomLevel(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("name", x.GetName(), object); + serialize("type", x.GetType(), object); + serialize("duration", x.GetDuration(), object); + serialize("zoomLevel", x.GetZoomLevel(), object); } void to_json(const dataservice::write::model::IndexProperties& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("ttl", x.GetTtl(), value, allocator); - serialize("indexDefinitions", x.GetIndexDefinitions(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("ttl", x.GetTtl(), object); + serialize("indexDefinitions", x.GetIndexDefinitions(), object); } void to_json(const dataservice::write::model::Creator& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("id", x.GetId(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("id", x.GetId(), object); } -void to_json(const dataservice::write::model::Owner& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("creator", x.GetCreator(), value, allocator); - serialize("organisation", x.GetOrganisation(), value, allocator); +void to_json(const dataservice::write::model::Owner& x, + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("creator", x.GetCreator(), object); + serialize("organisation", x.GetOrganisation(), object); } void to_json(const dataservice::write::model::Partitioning& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("scheme", x.GetScheme(), value, allocator); - serialize("tileLevels", x.GetTileLevels(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("scheme", x.GetScheme(), object); + serialize("tileLevels", x.GetTileLevels(), object); } void to_json(const dataservice::write::model::Schema& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("hrn", x.GetHrn(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("hrn", x.GetHrn(), object); } void to_json(const dataservice::write::model::StreamProperties& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("dataInThroughputMbps", x.GetDataInThroughputMbps(), value, - allocator); - serialize("dataOutThroughputMbps", x.GetDataOutThroughputMbps(), value, - allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("dataInThroughputMbps", x.GetDataInThroughputMbps(), object); + serialize("dataOutThroughputMbps", x.GetDataOutThroughputMbps(), object); } void to_json(const dataservice::write::model::Encryption& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("algorithm", x.GetAlgorithm(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("algorithm", x.GetAlgorithm(), object); } void to_json(const dataservice::write::model::Volume& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("volumeType", x.GetVolumeType(), value, allocator); - serialize("maxMemoryPolicy", x.GetMaxMemoryPolicy(), value, allocator); - serialize("packageType", x.GetPackageType(), value, allocator); - serialize("encryption", x.GetEncryption(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("volumeType", x.GetVolumeType(), object); + serialize("maxMemoryPolicy", x.GetMaxMemoryPolicy(), object); + serialize("packageType", x.GetPackageType(), object); + serialize("encryption", x.GetEncryption(), object); } -void to_json(const dataservice::write::model::Layer& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("id", x.GetId(), value, allocator); - serialize("name", x.GetName(), value, allocator); - serialize("summary", x.GetSummary(), value, allocator); - serialize("description", x.GetDescription(), value, allocator); - serialize("owner", x.GetOwner(), value, allocator); - serialize("coverage", x.GetCoverage(), value, allocator); - serialize("schema", x.GetSchema(), value, allocator); - serialize("contentType", x.GetContentType(), value, allocator); - serialize("contentEncoding", x.GetContentEncoding(), value, allocator); - serialize("partitioning", x.GetPartitioning(), value, allocator); - serialize("layerType", x.GetLayerType(), value, allocator); - serialize("digest", x.GetDigest(), value, allocator); - serialize("tags", x.GetTags(), value, allocator); - serialize("billingTags", x.GetBillingTags(), value, allocator); - serialize("ttl", x.GetTtl(), value, allocator); - serialize("indexProperties", x.GetIndexProperties(), value, allocator); - serialize("streamProperties", x.GetStreamProperties(), value, allocator); - serialize("volume", x.GetVolume(), value, allocator); +void to_json(const dataservice::write::model::Layer& x, + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("id", x.GetId(), object); + serialize("name", x.GetName(), object); + serialize("summary", x.GetSummary(), object); + serialize("description", x.GetDescription(), object); + serialize("owner", x.GetOwner(), object); + serialize("coverage", x.GetCoverage(), object); + serialize("schema", x.GetSchema(), object); + serialize("contentType", x.GetContentType(), object); + serialize("contentEncoding", x.GetContentEncoding(), object); + serialize("partitioning", x.GetPartitioning(), object); + serialize("layerType", x.GetLayerType(), object); + serialize("digest", x.GetDigest(), object); + serialize("tags", x.GetTags(), object); + serialize("billingTags", x.GetBillingTags(), object); + serialize("ttl", x.GetTtl(), object); + serialize("indexProperties", x.GetIndexProperties(), object); + serialize("streamProperties", x.GetStreamProperties(), object); + serialize("volume", x.GetVolume(), object); } void to_json(const dataservice::write::model::Notifications& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("enabled", x.GetEnabled(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("enabled", x.GetEnabled(), object); } void to_json(const dataservice::write::model::Catalog& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("id", x.GetId(), value, allocator); - serialize("hrn", x.GetHrn(), value, allocator); - serialize("name", x.GetName(), value, allocator); - serialize("summary", x.GetSummary(), value, allocator); - serialize("description", x.GetDescription(), value, allocator); - serialize("coverage", x.GetCoverage(), value, allocator); - serialize("owner", x.GetOwner(), value, allocator); - serialize("tags", x.GetTags(), value, allocator); - serialize("billingTags", x.GetBillingTags(), value, allocator); - serialize("created", x.GetCreated(), value, allocator); - serialize("layers", x.GetLayers(), value, allocator); - serialize("version", x.GetVersion(), value, allocator); - serialize("notifications", x.GetNotifications(), value, allocator); + boost::json::value& value) { + auto& object = value.emplace_object(); + serialize("id", x.GetId(), object); + serialize("hrn", x.GetHrn(), object); + serialize("name", x.GetName(), object); + serialize("summary", x.GetSummary(), object); + serialize("description", x.GetDescription(), object); + serialize("coverage", x.GetCoverage(), object); + serialize("owner", x.GetOwner(), object); + serialize("tags", x.GetTags(), object); + serialize("billingTags", x.GetBillingTags(), object); + serialize("created", x.GetCreated(), object); + serialize("layers", x.GetLayers(), object); + serialize("version", x.GetVersion(), object); + serialize("notifications", x.GetNotifications(), object); } } // namespace serializer diff --git a/olp-cpp-sdk-dataservice-write/src/generated/serializer/CatalogSerializer.h b/olp-cpp-sdk-dataservice-write/src/generated/serializer/CatalogSerializer.h index 934b6f516..7fb88aa0e 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/serializer/CatalogSerializer.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/serializer/CatalogSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,61 +19,50 @@ #pragma once -#include +#include #include "../model/Catalog.h" namespace olp { namespace serializer { void to_json(const dataservice::write::model::Coverage& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::write::model::IndexDefinition& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::write::model::IndexProperties& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::write::model::Creator& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); -void to_json(const dataservice::write::model::Owner& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); +void to_json(const dataservice::write::model::Owner& x, + boost::json::value& value); void to_json(const dataservice::write::model::Partitioning& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::write::model::Schema& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::write::model::StreamProperties& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::write::model::Encryption& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::write::model::Volume& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); -void to_json(const dataservice::write::model::Layer& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); +void to_json(const dataservice::write::model::Layer& x, + boost::json::value& value); void to_json(const dataservice::write::model::Notifications& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); void to_json(const dataservice::write::model::Catalog& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); } // namespace serializer } // namespace olp diff --git a/olp-cpp-sdk-dataservice-write/src/generated/serializer/IndexInfoSerializer.cpp b/olp-cpp-sdk-dataservice-write/src/generated/serializer/IndexInfoSerializer.cpp index c9b0ca34c..e57c2a814 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/serializer/IndexInfoSerializer.cpp +++ b/olp-cpp-sdk-dataservice-write/src/generated/serializer/IndexInfoSerializer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,64 +21,55 @@ namespace olp { namespace serializer { -void to_json(const dataservice::write::model::Index &x, rapidjson::Value &value, - rapidjson::Document::AllocatorType &allocator) { - rapidjson::Value jsonValue(rapidjson::kObjectType); - value.SetArray(); - jsonValue.AddMember("id", rapidjson::StringRef(x.GetId().c_str()), allocator); +void to_json(const dataservice::write::model::Index &x, + boost::json::value &value) { + boost::json::object jsonValue; + value.emplace_array(); + jsonValue.emplace("id", x.GetId()); - rapidjson::Value indexFields(rapidjson::kObjectType); + boost::json::object indexFields; for (auto &field_pair : x.GetIndexFields()) { - using namespace dataservice::write::model; + namespace model = dataservice::write::model; const auto &field = field_pair.second; - const auto key = rapidjson::StringRef(field_pair.first.c_str()); + const auto &key = field_pair.first; auto index_type = field->getIndexType(); - if (index_type == IndexType::String) { - auto s = std::static_pointer_cast(field); - rapidjson::Value str_val; - const auto &str = s->GetValue(); - str_val.SetString( - str.c_str(), static_cast(str.size()), allocator); - indexFields.AddMember(key, str_val, allocator); - } else if (index_type == IndexType::Int) { - auto s = std::static_pointer_cast(field); - indexFields.AddMember(key, s->GetValue(), allocator); - } else if (index_type == IndexType::Bool) { - auto s = std::static_pointer_cast(field); - indexFields.AddMember(key, s->GetValue(), allocator); - } else if (index_type == IndexType::Heretile) { - auto s = std::static_pointer_cast(field); - indexFields.AddMember(key, s->GetValue(), allocator); - } else if (index_type == IndexType::TimeWindow) { - auto s = std::static_pointer_cast(field); - indexFields.AddMember(key, s->GetValue(), allocator); + if (index_type == model::IndexType::String) { + auto s = std::static_pointer_cast(field); + boost::json::string str_val{s->GetValue()}; + indexFields.emplace(key, std::move(str_val)); + } else if (index_type == model::IndexType::Int) { + auto s = std::static_pointer_cast(field); + indexFields.emplace(key, s->GetValue()); + } else if (index_type == model::IndexType::Bool) { + auto s = std::static_pointer_cast(field); + indexFields.emplace(key, s->GetValue()); + } else if (index_type == model::IndexType::Heretile) { + auto s = std::static_pointer_cast(field); + indexFields.emplace(key, s->GetValue()); + } else if (index_type == model::IndexType::TimeWindow) { + auto s = std::static_pointer_cast(field); + indexFields.emplace(key, s->GetValue()); } } - jsonValue.AddMember("fields", indexFields, allocator); + jsonValue.emplace("fields", std::move(indexFields)); // TODO: Separate Metadata Model serialization into its own file when needed // by another model. if (x.GetMetadata()) { - rapidjson::Value metadatas(rapidjson::kObjectType); - for (auto metadata : x.GetMetadata().get()) { - auto metadata_value = metadata.second; - auto metadata_key = metadata.first.c_str(); - indexFields.AddMember( - rapidjson::StringRef(metadata_key), - rapidjson::StringRef(metadata_value.c_str(), metadata_value.size()), - allocator); + for (auto &metadata : x.GetMetadata().get()) { + auto &metadata_value = metadata.second; + auto &metadata_key = metadata.first; + indexFields.emplace(metadata_key, metadata_value); } } if (x.GetCheckSum()) { - jsonValue.AddMember("checksum", - rapidjson::StringRef(x.GetCheckSum().get().c_str()), - allocator); + jsonValue.emplace("checksum", x.GetCheckSum().get()); } if (x.GetSize()) { - jsonValue.AddMember("size", x.GetSize().get(), allocator); + jsonValue.emplace("size", x.GetSize().get()); } - value.PushBack(jsonValue, allocator); + value.as_array().emplace_back(std::move(jsonValue)); } } // namespace serializer diff --git a/olp-cpp-sdk-dataservice-write/src/generated/serializer/IndexInfoSerializer.h b/olp-cpp-sdk-dataservice-write/src/generated/serializer/IndexInfoSerializer.h index e7732b763..77dea4dd0 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/serializer/IndexInfoSerializer.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/serializer/IndexInfoSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,13 +19,13 @@ #pragma once -#include +#include #include namespace olp { namespace serializer { -void to_json(const dataservice::write::model::Index& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); +void to_json(const dataservice::write::model::Index& x, + boost::json::value& value); } // namespace serializer } // namespace olp diff --git a/olp-cpp-sdk-dataservice-write/src/generated/serializer/JsonSerializer.h b/olp-cpp-sdk-dataservice-write/src/generated/serializer/JsonSerializer.h index 504c6c12a..99fe7d810 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/serializer/JsonSerializer.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/serializer/JsonSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,24 +19,17 @@ #pragma once -#include -#include -#include +#include +#include namespace olp { namespace serializer { template inline std::string serialize(const T& object) { - rapidjson::Document doc; - auto& allocator = doc.GetAllocator(); - - doc.SetObject(); - to_json(object, doc, allocator); - - rapidjson::StringBuffer buffer; - rapidjson::Writer writer(buffer); - doc.Accept(writer); - return buffer.GetString(); + boost::json::value value; + value.emplace_object(); + to_json(object, value); + return boost::json::serialize(value); } } // namespace serializer diff --git a/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublicationSerializer.cpp b/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublicationSerializer.cpp index aa8de56c3..85f879aeb 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublicationSerializer.cpp +++ b/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublicationSerializer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,57 +22,49 @@ namespace olp { namespace serializer { void to_json(const dataservice::write::model::Publication& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { + boost::json::value& value) { + auto& object = value.emplace_object(); if (x.GetId()) { - value.AddMember("id", rapidjson::StringRef(x.GetId().get().c_str()), - allocator); + object.emplace("id", x.GetId().get()); } // TODO: Separate Details Model serializtion into it's own file when needed by // another model. if (x.GetDetails()) { - rapidjson::Value details(rapidjson::kObjectType); - details.AddMember("state", - rapidjson::StringRef(x.GetDetails()->GetState().c_str()), - allocator); - details.AddMember( - "message", rapidjson::StringRef(x.GetDetails()->GetMessage().c_str()), - allocator); - details.AddMember("started", x.GetDetails()->GetStarted(), allocator); - details.AddMember("modified", x.GetDetails()->GetModified(), allocator); - details.AddMember("expires", x.GetDetails()->GetExpires(), allocator); - value.AddMember("details", details, allocator); + boost::json::object details; + details.emplace("state", x.GetDetails()->GetState()); + details.emplace("message", x.GetDetails()->GetMessage()); + details.emplace("started", x.GetDetails()->GetStarted()); + details.emplace("modified", x.GetDetails()->GetModified()); + details.emplace("expires", x.GetDetails()->GetExpires()); + object.emplace("details", std::move(details)); } if (x.GetLayerIds()) { - rapidjson::Value layer_ids(rapidjson::kArrayType); + boost::json::array layer_ids; for (auto& layer_id : x.GetLayerIds().get()) { - layer_ids.PushBack(rapidjson::StringRef(layer_id.c_str()), allocator); + layer_ids.emplace_back(layer_id); } - value.AddMember("layerIds", layer_ids, allocator); + object.emplace("layerIds", std::move(layer_ids)); } if (x.GetCatalogVersion()) { - value.AddMember("catalogVersion", x.GetCatalogVersion().get(), allocator); + object.emplace("catalogVersion", x.GetCatalogVersion().get()); } if (x.GetVersionDependencies()) { - rapidjson::Value version_dependencies(rapidjson::kArrayType); + boost::json::array version_dependencies; for (auto& version_dependency : x.GetVersionDependencies().get()) { // TODO: Separate VersionDependency Model serializtion into it's own file // when needed by another model. - rapidjson::Value version_dependency_json(rapidjson::kObjectType); - version_dependency_json.AddMember( - "direct", version_dependency.GetDirect(), allocator); - version_dependency_json.AddMember( - "hrn", rapidjson::StringRef(version_dependency.GetHrn().c_str()), - allocator); - version_dependency_json.AddMember( - "version", version_dependency.GetVersion(), allocator); - version_dependencies.PushBack(version_dependency_json, allocator); + boost::json::object version_dependency_json; + version_dependency_json.emplace("direct", version_dependency.GetDirect()); + version_dependency_json.emplace("hrn", version_dependency.GetHrn()); + version_dependency_json.emplace("version", + version_dependency.GetVersion()); + version_dependencies.emplace_back(std::move(version_dependency_json)); } - value.AddMember("versionDependencies", version_dependencies, allocator); + object.emplace("versionDependencies", std::move(version_dependencies)); } } diff --git a/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublicationSerializer.h b/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublicationSerializer.h index c00df9918..bdaad7cb3 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublicationSerializer.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublicationSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,14 +19,13 @@ #pragma once -#include +#include #include namespace olp { namespace serializer { void to_json(const dataservice::write::model::Publication& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); } // namespace serializer } // namespace olp diff --git a/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishDataRequestSerializer.cpp b/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishDataRequestSerializer.cpp index d5814e351..ac00ea7a4 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishDataRequestSerializer.cpp +++ b/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishDataRequestSerializer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,34 +22,27 @@ namespace olp { namespace serializer { void to_json(const dataservice::write::model::PublishDataRequest& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { + boost::json::value& value) { + auto& object = value.emplace_object(); if (x.GetData()) { const auto& data = x.GetData().get(); - auto data_stringref = rapidjson::StringRef( + auto data_stringref = boost::json::string_view( reinterpret_cast(data->data()), data->size()); - value.AddMember("data", std::move(data_stringref), allocator); + object.emplace("data", data_stringref); } - value.AddMember("layerId", rapidjson::StringRef(x.GetLayerId().c_str()), - allocator); + object.emplace("layerId", x.GetLayerId()); if (x.GetTraceId()) { - value.AddMember("traceId", - rapidjson::StringRef(x.GetTraceId().get().c_str()), - allocator); + object.emplace("traceId", x.GetTraceId().get()); } if (x.GetBillingTag()) { - value.AddMember("billingTag", - rapidjson::StringRef(x.GetBillingTag().get().c_str()), - allocator); + object.emplace("billingTag", x.GetBillingTag().get()); } if (x.GetChecksum()) { - value.AddMember("checksum", - rapidjson::StringRef(x.GetChecksum().get().c_str()), - allocator); + object.emplace("checksum", x.GetChecksum().get()); } } diff --git a/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishDataRequestSerializer.h b/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishDataRequestSerializer.h index 687349e27..9be1868c3 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishDataRequestSerializer.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishDataRequestSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,14 +19,13 @@ #pragma once -#include +#include #include namespace olp { namespace serializer { void to_json(const dataservice::write::model::PublishDataRequest& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); } // namespace serializer } // namespace olp diff --git a/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishPartitionSerializer.cpp b/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishPartitionSerializer.cpp index bf5a2aa6b..967792ed7 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishPartitionSerializer.cpp +++ b/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishPartitionSerializer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,44 +22,37 @@ namespace olp { namespace serializer { void to_json(const dataservice::write::model::PublishPartition& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { + boost::json::value& value) { + auto& object = value.emplace_object(); if (x.GetPartition()) { - value.AddMember("partition", - rapidjson::StringRef(x.GetPartition().get().c_str()), - allocator); + object.emplace("partition", x.GetPartition().get()); } if (x.GetChecksum()) { - value.AddMember("checksum", - rapidjson::StringRef(x.GetChecksum().get().c_str()), - allocator); + object.emplace("checksum", x.GetChecksum().get()); } if (x.GetCompressedDataSize()) { - value.AddMember("compressedDataSize", x.GetCompressedDataSize().get(), - allocator); + object.emplace("compressedDataSize", x.GetCompressedDataSize().get()); } if (x.GetDataSize()) { - value.AddMember("dataSize", x.GetDataSize().get(), allocator); + object.emplace("dataSize", x.GetDataSize().get()); } if (x.GetData()) { const auto& data = x.GetData().get(); - auto data_stringref = rapidjson::StringRef( + auto data_stringref = boost::json::string_view( reinterpret_cast(data->data()), data->size()); - value.AddMember("data", std::move(data_stringref), allocator); + object.emplace("data", data_stringref); } if (x.GetDataHandle()) { - value.AddMember("dataHandle", - rapidjson::StringRef(x.GetDataHandle().get().c_str()), - allocator); + object.emplace("dataHandle", x.GetDataHandle().get()); } if (x.GetTimestamp()) { - value.AddMember("timestamp", x.GetTimestamp().get(), allocator); + object.emplace("timestamp", x.GetTimestamp().get()); } } diff --git a/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishPartitionSerializer.h b/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishPartitionSerializer.h index 158b8d0df..d9b8ed764 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishPartitionSerializer.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishPartitionSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,14 +19,13 @@ #pragma once -#include +#include #include "generated/model/PublishPartition.h" namespace olp { namespace serializer { void to_json(const dataservice::write::model::PublishPartition& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); } // namespace serializer } // namespace olp diff --git a/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishPartitionsSerializer.cpp b/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishPartitionsSerializer.cpp index f88315014..e38c5f7ff 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishPartitionsSerializer.cpp +++ b/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishPartitionsSerializer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,16 +24,15 @@ namespace olp { namespace serializer { void to_json(const dataservice::write::model::PublishPartitions& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { + boost::json::value& value) { if (x.GetPartitions()) { - rapidjson::Value partitions(rapidjson::kArrayType); + boost::json::array partitions; for (auto& partition : x.GetPartitions().get()) { - rapidjson::Value partition_value(rapidjson::kObjectType); - to_json(partition, partition_value, allocator); - partitions.PushBack(partition_value, allocator); + boost::json::value partition_value(boost::json::object_kind_t{}); + to_json(partition, partition_value); + partitions.emplace_back(std::move(partition_value)); } - value.AddMember("partitions", partitions, allocator); + value.as_object().emplace("partitions", std::move(partitions)); } } diff --git a/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishPartitionsSerializer.h b/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishPartitionsSerializer.h index 583ee4e2d..d0710bce9 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishPartitionsSerializer.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/serializer/PublishPartitionsSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,14 +19,13 @@ #pragma once -#include +#include #include "generated/model/PublishPartitions.h" namespace olp { namespace serializer { void to_json(const dataservice::write::model::PublishPartitions& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); } // namespace serializer } // namespace olp diff --git a/olp-cpp-sdk-dataservice-write/src/generated/serializer/UpdateIndexRequestSerializer.cpp b/olp-cpp-sdk-dataservice-write/src/generated/serializer/UpdateIndexRequestSerializer.cpp index 7886e7af5..75307ed87 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/serializer/UpdateIndexRequestSerializer.cpp +++ b/olp-cpp-sdk-dataservice-write/src/generated/serializer/UpdateIndexRequestSerializer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,76 +22,64 @@ namespace olp { namespace serializer { void to_json(const dataservice::write::model::UpdateIndexRequest &x, - rapidjson::Value &value, - rapidjson::Document::AllocatorType &allocator) { - rapidjson::Value additions(rapidjson::kArrayType); + boost::json::value &value) { + boost::json::array additions; + value.emplace_object(); for (auto &addition : x.GetIndexAdditions()) { - rapidjson::Value additionValue(rapidjson::kObjectType); - additionValue.AddMember( - "id", rapidjson::StringRef(addition.GetId().c_str()), allocator); + boost::json::object additionValue; + additionValue.emplace("id", addition.GetId()); - rapidjson::Value indexFields(rapidjson::kObjectType); + boost::json::object indexFields; for (const auto &field_pair : addition.GetIndexFields()) { - using namespace dataservice::write::model; + namespace model = dataservice::write::model; const auto &field = field_pair.second; - const auto key = rapidjson::StringRef(field_pair.first.c_str()); + const auto &key = field_pair.first; auto index_type = field->getIndexType(); - if (index_type == IndexType::String) { - auto s = std::static_pointer_cast(field); - rapidjson::Value str_val; - const auto &str = s->GetValue(); - str_val.SetString(str.c_str(), - static_cast(str.size()), - allocator); - indexFields.AddMember(key, str_val, allocator); - } else if (index_type == IndexType::Int) { - auto s = std::static_pointer_cast(field); - indexFields.AddMember(key, s->GetValue(), allocator); - } else if (index_type == IndexType::Bool) { - auto s = std::static_pointer_cast(field); - indexFields.AddMember(key, s->GetValue(), allocator); - } else if (index_type == IndexType::Heretile) { - auto s = std::static_pointer_cast(field); - indexFields.AddMember(key, s->GetValue(), allocator); - } else if (index_type == IndexType::TimeWindow) { - auto s = std::static_pointer_cast(field); - indexFields.AddMember(key, s->GetValue(), allocator); + if (index_type == model::IndexType::String) { + auto s = std::static_pointer_cast(field); + boost::json::value str_val{s->GetValue()}; + indexFields.emplace(key, std::move(str_val)); + } else if (index_type == model::IndexType::Int) { + auto s = std::static_pointer_cast(field); + indexFields.emplace(key, s->GetValue()); + } else if (index_type == model::IndexType::Bool) { + auto s = std::static_pointer_cast(field); + indexFields.emplace(key, s->GetValue()); + } else if (index_type == model::IndexType::Heretile) { + auto s = std::static_pointer_cast(field); + indexFields.emplace(key, s->GetValue()); + } else if (index_type == model::IndexType::TimeWindow) { + auto s = std::static_pointer_cast(field); + indexFields.emplace(key, s->GetValue()); } } - additionValue.AddMember("fields", indexFields, allocator); + additionValue.emplace("fields", indexFields); // TODO: Separate Details Model serializtion into it's own file when needed // by another model. if (addition.GetMetadata()) { - rapidjson::Value metadatas(rapidjson::kObjectType); - for (const auto& metadata : addition.GetMetadata().get()) { - const auto& metadata_value = metadata.second; - const auto& metadata_key = metadata.first.c_str(); - indexFields.AddMember( - rapidjson::StringRef(metadata_key), - rapidjson::StringRef(metadata_value.c_str(), metadata_value.size()), - allocator); + for (const auto &metadata : addition.GetMetadata().get()) { + const auto &metadata_value = metadata.second; + const auto &metadata_key = metadata.first; + indexFields.emplace(metadata_key, metadata_value); } } if (addition.GetCheckSum()) { - additionValue.AddMember( - "checksum", - rapidjson::StringRef(addition.GetCheckSum().get().c_str()), - allocator); + additionValue.emplace("checksum", addition.GetCheckSum().get()); } if (addition.GetSize()) { - additionValue.AddMember("size", addition.GetSize().get(), allocator); + additionValue.emplace("size", addition.GetSize().get()); } - additions.PushBack(additionValue, allocator); + additions.emplace_back(additionValue); } - value.AddMember("additions", additions, allocator); - rapidjson::Value removals(rapidjson::kArrayType); + value.as_object().emplace("additions", std::move(additions)); + boost::json::array removals; for (auto &removal : x.GetIndexRemovals()) { - removals.PushBack(rapidjson::StringRef(removal.c_str()), allocator); + removals.emplace_back(removal); } - value.AddMember("removals", removals, allocator); + value.as_object().emplace("removals", std::move(removals)); } } // namespace serializer diff --git a/olp-cpp-sdk-dataservice-write/src/generated/serializer/UpdateIndexRequestSerializer.h b/olp-cpp-sdk-dataservice-write/src/generated/serializer/UpdateIndexRequestSerializer.h index dd8b8b5e4..21fa201a4 100644 --- a/olp-cpp-sdk-dataservice-write/src/generated/serializer/UpdateIndexRequestSerializer.h +++ b/olp-cpp-sdk-dataservice-write/src/generated/serializer/UpdateIndexRequestSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,15 +19,14 @@ #pragma once -#include +#include #include namespace olp { namespace serializer { void to_json(const dataservice::write::model::UpdateIndexRequest& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); } // namespace serializer } // namespace olp diff --git a/tests/common/ReadDefaultResponses.cpp b/tests/common/ReadDefaultResponses.cpp index 835206f19..0307b7da1 100644 --- a/tests/common/ReadDefaultResponses.cpp +++ b/tests/common/ReadDefaultResponses.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2024 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,65 +25,57 @@ #include #include -#include -#include + +#include +#include namespace { void WriteSubquadsToJson( - rapidjson::Document& doc, const olp::geo::TileKey& root_tile, - const std::map& sub_quads, - rapidjson::Document::AllocatorType& allocator) { - rapidjson::Value sub_quads_value; - sub_quads_value.SetArray(); + boost::json::object& doc, const olp::geo::TileKey& root_tile, + const std::map& sub_quads) { + boost::json::array sub_quads_value; for (const auto& quad : sub_quads) { const mockserver::TileMetadata& metadata = quad.second; const auto partition = root_tile.AddedSubkey64(quad.first).ToHereTile(); - rapidjson::Value item; - item.SetObject(); - olp::serializer::serialize("subQuadKey", std::to_string(quad.first), item, - allocator); - olp::serializer::serialize("version", metadata.version, item, allocator); - olp::serializer::serialize("dataHandle", metadata.data_handle, item, - allocator); - olp::serializer::serialize("crc", metadata.crc, item, allocator); - olp::serializer::serialize("checksum", metadata.checksum, item, allocator); - olp::serializer::serialize("dataSize", metadata.data_size, item, allocator); + boost::json::object item; + olp::serializer::serialize("subQuadKey", std::to_string(quad.first), item); + olp::serializer::serialize("version", metadata.version, item); + olp::serializer::serialize("dataHandle", metadata.data_handle, item); + olp::serializer::serialize("crc", metadata.crc, item); + olp::serializer::serialize("checksum", metadata.checksum, item); + olp::serializer::serialize("dataSize", metadata.data_size, item); olp::serializer::serialize("compressedDataSize", - metadata.compressed_data_size, item, allocator); + metadata.compressed_data_size, item); - sub_quads_value.PushBack(std::move(item), allocator); + sub_quads_value.emplace_back(std::move(item)); } - doc.AddMember("subQuads", std::move(sub_quads_value), allocator); + doc.emplace("subQuads", std::move(sub_quads_value)); } void WriteParentquadsToJson( - rapidjson::Document& doc, - const std::map& parent_quads, - rapidjson::Document::AllocatorType& allocator) { - rapidjson::Value parent_quads_value; - parent_quads_value.SetArray(); + boost::json::object& doc, + const std::map& parent_quads) { + boost::json::array parent_quads_value; for (const auto& parent : parent_quads) { const auto partition = std::to_string(parent.first); const mockserver::TileMetadata& metadata = parent.second; - rapidjson::Value item; - item.SetObject(); - olp::serializer::serialize("partition", partition, item, allocator); - olp::serializer::serialize("version", metadata.version, item, allocator); - olp::serializer::serialize("dataHandle", metadata.data_handle, item, - allocator); - olp::serializer::serialize("crc", metadata.crc, item, allocator); - olp::serializer::serialize("checksum", metadata.checksum, item, allocator); - olp::serializer::serialize("dataSize", metadata.data_size, item, allocator); + boost::json::object item; + olp::serializer::serialize("partition", partition, item); + olp::serializer::serialize("version", metadata.version, item); + olp::serializer::serialize("dataHandle", metadata.data_handle, item); + olp::serializer::serialize("crc", metadata.crc, item); + olp::serializer::serialize("checksum", metadata.checksum, item); + olp::serializer::serialize("dataSize", metadata.data_size, item); olp::serializer::serialize("compressedDataSize", - metadata.compressed_data_size, item, allocator); - parent_quads_value.PushBack(std::move(item), allocator); + metadata.compressed_data_size, item); + parent_quads_value.emplace_back(std::move(item)); } - doc.AddMember("parentQuads", std::move(parent_quads_value), allocator); + doc.emplace("parentQuads", std::move(parent_quads_value)); } std::string GenerateRandomString(size_t length) { @@ -160,16 +152,11 @@ std::string ReadDefaultResponses::GenerateQuadTreeResponse( } } - rapidjson::Document doc; - auto& allocator = doc.GetAllocator(); - doc.SetObject(); - WriteSubquadsToJson(doc, root_tile, sub_quads, allocator); - WriteParentquadsToJson(doc, parent_quads, allocator); + boost::json::object doc; + WriteSubquadsToJson(doc, root_tile, sub_quads); + WriteParentquadsToJson(doc, parent_quads); - rapidjson::StringBuffer buffer; - rapidjson::Writer writer(buffer); - doc.Accept(writer); - return buffer.GetString(); + return boost::json::serialize(doc); } QuadTreeBuilder::QuadTreeBuilder(olp::geo::TileKey root_tile, @@ -228,16 +215,11 @@ QuadTreeBuilder& QuadTreeBuilder::WithSubQuad( } std::string QuadTreeBuilder::BuildJson() const { - rapidjson::Document doc; - auto& allocator = doc.GetAllocator(); - doc.SetObject(); - WriteSubquadsToJson(doc, root_tile_, sub_quads_, allocator); - WriteParentquadsToJson(doc, parent_quads_, allocator); - - rapidjson::StringBuffer buffer; - rapidjson::Writer writer(buffer); - doc.Accept(writer); - return buffer.GetString(); + boost::json::object doc; + WriteSubquadsToJson(doc, root_tile_, sub_quads_); + WriteParentquadsToJson(doc, parent_quads_); + + return boost::json::serialize(doc); } olp::geo::TileKey QuadTreeBuilder::Root() const { return root_tile_; } diff --git a/tests/common/WriteDefaultResponses.h b/tests/common/WriteDefaultResponses.h index 93d151389..5d04b22f8 100644 --- a/tests/common/WriteDefaultResponses.h +++ b/tests/common/WriteDefaultResponses.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,11 +24,8 @@ #include #include -#include #include -#include -#include -#include +#include #include "generated/model/Api.h" @@ -87,7 +84,8 @@ class DefaultResponses { static olp::dataservice::write::model::Publication GeneratePublicationResponse( const std::vector& layer_ids, - const std::vector dependencies) { + const std::vector + dependencies) { olp::dataservice::write::model::Publication publication; std::string id = "abcdefghijklmnopqrstuvwxyz0123456789-"; diff --git a/tests/functional/olp-cpp-sdk-authentication/AuthenticationTestUtils.cpp b/tests/functional/olp-cpp-sdk-authentication/AuthenticationTestUtils.cpp index ce5b2c7bd..2a2cd7507 100644 --- a/tests/functional/olp-cpp-sdk-authentication/AuthenticationTestUtils.cpp +++ b/tests/functional/olp-cpp-sdk-authentication/AuthenticationTestUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 HERE Europe B.V. + * Copyright (C) 2019-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,26 +19,25 @@ #include "AuthenticationTestUtils.h" -#include #include +#include #ifndef WIN32 #include #endif -#include -#include -#include -#include #include #include #include + +#include +#include #include #include "TestConstants.h" -using namespace ::olp::authentication; - namespace { +namespace auth = olp::authentication; + constexpr auto kFacebookUrl = "https://graph.facebook.com/v2.12"; constexpr auto kId = "id"; @@ -61,16 +60,16 @@ bool AuthenticationTestUtils::CreateFacebookTestUser( std::string url = std::string() + kFacebookUrl + "/" + CustomParameters::getArgument("facebook_app_id") + kTestUserPath; - url.append(kQuestionParam); - url.append(kAccessToken + kEqualsParam + + url.append(auth::kQuestionParam); + url.append(auth::kAccessToken + auth::kEqualsParam + CustomParameters::getArgument("facebook_access_token")); - url.append(kAndParam); - url.append("installed" + kEqualsParam + "true"); - url.append(kAndParam); - url.append("name" + kEqualsParam + kTestUserName); + url.append(auth::kAndParam); + url.append("installed" + auth::kEqualsParam + "true"); + url.append(auth::kAndParam); + url.append("name" + auth::kEqualsParam + auth::kTestUserName); if (!permissions.empty()) { - url.append(kAndParam); - url.append("permissions" + kEqualsParam + permissions); + url.append(auth::kAndParam); + url.append("permissions" + auth::kEqualsParam + permissions); } olp::http::NetworkRequest request(url); request.WithVerb(olp::http::NetworkRequest::HttpVerb::POST); @@ -79,39 +78,39 @@ bool AuthenticationTestUtils::CreateFacebookTestUser( unsigned int retry = 0u; do { if (retry > 0u) { - OLP_SDK_LOG_WARNING(__func__, "Request retry attempted (" << retry - << ")"); + OLP_SDK_LOG_WARNING(__func__, + "Request retry attempted (" << retry << ")"); std::this_thread::sleep_for( - std::chrono::seconds(retry * kRetryDelayInSecs)); + std::chrono::seconds(retry * auth::kRetryDelayInSecs)); } auto payload = std::make_shared(); std::promise promise; auto future = promise.get_future(); - network.Send(request, payload, - [payload, &promise, - &user](const olp::http::NetworkResponse &network_response) { - user.token.status = network_response.GetStatus(); - if (user.token.status == olp::http::HttpStatusCode::OK) { - auto document = std::make_shared(); - rapidjson::IStreamWrapper stream(*payload); - document->ParseStream(stream); - const bool is_valid = - !document->HasParseError() && - document->HasMember(kAccessToken.c_str()) && - document->HasMember(kId); - - if (is_valid) { - user.token.access_token = - (*document)[kAccessToken.c_str()].GetString(); - user.id = (*document)[kId].GetString(); - } - } - promise.set_value(); - }); + network.Send( + request, payload, + [payload, &promise, + &user](const olp::http::NetworkResponse &network_response) { + user.token.status = network_response.GetStatus(); + if (user.token.status == olp::http::HttpStatusCode::OK) { + boost::json::error_code ec; + auto document = boost::json::parse(*payload, ec); + const bool is_valid = + !ec.failed() && document.is_object() && + document.as_object().contains(auth::kAccessToken) && + document.as_object().contains(kId); + + if (is_valid) { + user.token.access_token = + document.as_object()[auth::kAccessToken].get_string().c_str(); + user.id = document.as_object()[kId].get_string().c_str(); + } + } + promise.set_value(); + }); future.wait(); - } while ((user.token.status < 0) && (++retry < kMaxRetryCount)); + } while ((user.token.status < 0) && (++retry < auth::kMaxRetryCount)); return !user.id.empty() && !user.token.access_token.empty(); } @@ -121,8 +120,8 @@ bool AuthenticationTestUtils::DeleteFacebookTestUser( const olp::http::NetworkSettings &network_settings, const std::string &user_id) { std::string url = std::string() + kFacebookUrl + "/" + user_id; - url.append(kQuestionParam); - url.append(kAccessToken + kEqualsParam + + url.append(auth::kQuestionParam); + url.append(auth::kAccessToken + auth::kEqualsParam + CustomParameters::getArgument("facebook_access_token")); olp::http::NetworkRequest request(url); request.WithVerb(olp::http::NetworkRequest::HttpVerb::DEL); @@ -132,10 +131,10 @@ bool AuthenticationTestUtils::DeleteFacebookTestUser( unsigned int retry = 0u; do { if (retry > 0u) { - OLP_SDK_LOG_WARNING(__func__, "Request retry attempted (" << retry - << ")"); + OLP_SDK_LOG_WARNING(__func__, + "Request retry attempted (" << retry << ")"); std::this_thread::sleep_for( - std::chrono::seconds(retry * kRetryDelayInSecs)); + std::chrono::seconds(retry * auth::kRetryDelayInSecs)); } auto payload = std::make_shared(); @@ -149,7 +148,7 @@ bool AuthenticationTestUtils::DeleteFacebookTestUser( promise.set_value(); }); future.wait(); - } while ((status < 0) && (++retry < kMaxRetryCount)); + } while ((status < 0) && (++retry < auth::kMaxRetryCount)); return (status == olp::http::HttpStatusCode::OK); } @@ -159,16 +158,16 @@ bool AuthenticationTestUtils::GetGoogleAccessToken( const olp::http::NetworkSettings &network_settings, AccessTokenResponse &token) { std::string url = std::string() + kGoogleApiUrl + kGoogleOauth2Endpoint; - url.append(kQuestionParam); - url.append(kGoogleClientIdParam + kEqualsParam + + url.append(auth::kQuestionParam); + url.append(kGoogleClientIdParam + auth::kEqualsParam + CustomParameters::getArgument("google_client_id")); - url.append(kAndParam); - url.append(kGoogleClientSecretParam + kEqualsParam + + url.append(auth::kAndParam); + url.append(kGoogleClientSecretParam + auth::kEqualsParam + CustomParameters::getArgument("google_client_secret")); - url.append(kAndParam); - url.append(kGoogleRefreshTokenParam + kEqualsParam + + url.append(auth::kAndParam); + url.append(kGoogleRefreshTokenParam + auth::kEqualsParam + CustomParameters::getArgument("google_client_token")); - url.append(kAndParam); + url.append(auth::kAndParam); url.append(kGoogleRefreshTokenGrantType); olp::http::NetworkRequest request(url); @@ -186,15 +185,15 @@ AuthenticationTestUtils::GenerateArcGisClientBody() { std::string data; data.append(kClientId) - .append(kEqualsParam) + .append(auth::kEqualsParam) .append(CustomParameters::getArgument("arcgis_app_id")) - .append(kAndParam); + .append(auth::kAndParam); data.append(kGrantType) - .append(kEqualsParam) + .append(auth::kEqualsParam) .append(kRefreshToken) - .append(kAndParam); + .append(auth::kAndParam); data.append(kRefreshToken) - .append(kEqualsParam) + .append(auth::kEqualsParam) .append(CustomParameters::getArgument("arcgis_access_token")); return std::make_shared>(data.begin(), data.end()); } @@ -220,35 +219,35 @@ bool AuthenticationTestUtils::GetAccessTokenImpl( unsigned int retry = 0u; do { if (retry > 0u) { - OLP_SDK_LOG_WARNING(__func__, "Request retry attempted (" << retry - << ")"); + OLP_SDK_LOG_WARNING(__func__, + "Request retry attempted (" << retry << ")"); std::this_thread::sleep_for( - std::chrono::seconds(retry * kRetryDelayInSecs)); + std::chrono::seconds(retry * auth::kRetryDelayInSecs)); } auto payload = std::make_shared(); std::promise promise; auto future = promise.get_future(); - network.Send(request, payload, - [payload, &promise, - &token](const olp::http::NetworkResponse &network_response) { - token.status = network_response.GetStatus(); - if (token.status == olp::http::HttpStatusCode::OK) { - auto document = std::make_shared(); - rapidjson::IStreamWrapper stream(*payload); - document->ParseStream(stream); - bool is_valid = !document->HasParseError() && - document->HasMember(kAccessToken.c_str()); - if (is_valid) { - token.access_token = - (*document)[kAccessToken.c_str()].GetString(); - } - } - promise.set_value(); - }); + network.Send( + request, payload, + [payload, &promise, + &token](const olp::http::NetworkResponse &network_response) { + token.status = network_response.GetStatus(); + if (token.status == olp::http::HttpStatusCode::OK) { + boost::json::error_code ec; + auto document = boost::json::parse(*payload, ec); + bool is_valid = !ec.failed() && document.is_object() && + document.as_object().contains(auth::kAccessToken); + if (is_valid) { + token.access_token = + document.as_object()[auth::kAccessToken].get_string().c_str(); + } + } + promise.set_value(); + }); future.wait(); - } while ((token.status < 0) && (++retry < kMaxRetryCount)); + } while ((token.status < 0) && (++retry < auth::kMaxRetryCount)); return !token.access_token.empty(); } @@ -263,7 +262,7 @@ void AuthenticationTestUtils::DeleteHereUser( constexpr auto kApplicationJson = "application/json"; constexpr auto kDeleteUserEndpoint = "/user/me"; - std::string url = kHereAccountStagingURL; + std::string url = auth::kHereAccountStagingURL; url.append(kDeleteUserEndpoint); olp::http::NetworkRequest request(url); diff --git a/tests/functional/olp-cpp-sdk-authentication/FederatedAuthenticationTest.cpp b/tests/functional/olp-cpp-sdk-authentication/FederatedAuthenticationTest.cpp index 9003077f8..6e28366e3 100644 --- a/tests/functional/olp-cpp-sdk-authentication/FederatedAuthenticationTest.cpp +++ b/tests/functional/olp-cpp-sdk-authentication/FederatedAuthenticationTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,18 +17,15 @@ * License-Filename: LICENSE */ -#include -#include -#include - #include #include +#include +#include + #include "AuthenticationCommonTestFixture.h" #include "AuthenticationTestUtils.h" #include "TestConstants.h" -using namespace ::olp::authentication; - namespace { class FederatedAuthenticationTest : public AuthenticationCommonTestFixture { @@ -65,23 +62,14 @@ class FederatedAuthenticationTest : public AuthenticationCommonTestFixture { std::string GoogleAuthenticationBody(const std::string& email, const std::string& access_token) { - rapidjson::StringBuffer data; - - rapidjson::Writer writer(data); - writer.StartObject(); - writer.Key("grantType"); - writer.String("google"); - writer.Key("accessToken"); - writer.String(access_token.c_str()); - writer.Key("countryCode"); - writer.String("USA"); - writer.Key("language"); - writer.String("en"); - writer.Key("email"); - writer.String(email.c_str()); - writer.EndObject(); - - return data.GetString(); + boost::json::object object; + object.emplace("grantType", "google"); + object.emplace("accessToken", access_token); + object.emplace("countryCode", "USA"); + object.emplace("language", "en"); + object.emplace("email", email); + + return boost::json::serialize(object); } protected: diff --git a/tests/utils/mock-server-client/Client.h b/tests/utils/mock-server-client/Client.h index 9f15e0c8b..14d47d87b 100644 --- a/tests/utils/mock-server-client/Client.h +++ b/tests/utils/mock-server-client/Client.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2024 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -150,17 +150,11 @@ inline void Client::Reset() { inline bool Client::RemoveMockResponse(const std::string& method_matcher, const std::string& path_matcher) { - rapidjson::StringBuffer buffer; - rapidjson::Writer writer(buffer); + boost::json::object object; + object.emplace("method", method_matcher); + object.emplace("path", path_matcher); - writer.StartObject(); - writer.Key("method"); - writer.String(method_matcher.c_str()); - writer.Key("path"); - writer.String(path_matcher.c_str()); - writer.EndObject(); - - const auto data = std::string{buffer.GetString()}; + const auto data = boost::json::serialize(object); const auto request_body = std::make_shared>(data.begin(), data.end()); @@ -187,21 +181,16 @@ inline void Client::CreateExpectation(const Expectation& expectation) { inline bool Client::VerifySequence( const std::vector& pathes) const { - rapidjson::StringBuffer buffer; - rapidjson::Writer writer(buffer); - - writer.StartObject(); - writer.Key("httpRequests"); - writer.StartArray(); + boost::json::array array; for (const auto& str : pathes) { - writer.StartObject(); - writer.Key("path"); - writer.String(str.c_str()); - writer.EndObject(); + boost::json::object array_value; + array_value.emplace("path", str); + array.emplace_back(std::move(array_value)); } - writer.EndArray(); - writer.EndObject(); - const auto data = std::string{buffer.GetString()}; + boost::json::object object; + object.emplace("httpRequests", std::move(array)); + + const auto data = boost::json::serialize(object); const auto request_body = std::make_shared>(data.begin(), data.end()); diff --git a/tests/utils/mock-server-client/Expectation.h b/tests/utils/mock-server-client/Expectation.h index c263574bf..fa132b9a6 100644 --- a/tests/utils/mock-server-client/Expectation.h +++ b/tests/utils/mock-server-client/Expectation.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2024 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,8 @@ #include #include +#include +#include #include #include "JsonHelpers.h" @@ -68,108 +70,88 @@ struct Expectation { boost::optional times = boost::none; }; -void to_json(const Expectation& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); +void to_json(const Expectation& x, boost::json::value& value); void to_json(const Expectation::QueryStringParameter& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); -void to_json(const Expectation::RequestMatcher& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); -void to_json(const Expectation::BinaryResponse& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); -void to_json(const Expectation::ResponseDelay& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); -void to_json(const Expectation::ResponseAction& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); -void to_json(const Expectation::ResponseTimes& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator); + boost::json::value& value); +void to_json(const Expectation::RequestMatcher& x, boost::json::value& value); +void to_json(const Expectation::BinaryResponse& x, boost::json::value& value); +void to_json(const Expectation::ResponseDelay& x, boost::json::value& value); +void to_json(const Expectation::ResponseAction& x, boost::json::value& value); +void to_json(const Expectation::ResponseTimes& x, boost::json::value& value); std::string serialize(const Expectation& object); -inline void to_json(const Expectation& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("httpRequest", x.request, value, allocator); +inline void to_json(const Expectation& x, boost::json::value& value) { + value.emplace_object(); + serialize("httpRequest", x.request, value); if (x.action != boost::none) { - serialize("httpResponse", x.action, value, allocator); + serialize("httpResponse", x.action, value); } if (x.times != boost::none) { - serialize("times", x.times, value, allocator); + serialize("times", x.times, value); } } inline void to_json(const Expectation::QueryStringParameter& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("name", x.name, value, allocator); - serialize("values", x.values, value, allocator); + boost::json::value& value) { + value.emplace_object(); + serialize("name", x.name, value); + serialize("values", x.values, value); } inline void to_json(const Expectation::RequestMatcher& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("path", x.path, value, allocator); - serialize("method", x.method, value, allocator); - serialize("queryStringParameters", x.query_string_parameters, value, - allocator); + boost::json::value& value) { + value.emplace_object(); + serialize("path", x.path, value); + serialize("method", x.method, value); + serialize("queryStringParameters", x.query_string_parameters, value); } inline void to_json(const Expectation::BinaryResponse& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("type", x.type, value, allocator); - serialize("base64Bytes", x.base64_string, value, allocator); + boost::json::value& value) { + value.emplace_object(); + serialize("type", x.type, value); + serialize("base64Bytes", x.base64_string, value); } inline void to_json(const Expectation::ResponseDelay& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("timeUnit", x.time_unit, value, allocator); - serialize("value", x.value, value, allocator); + boost::json::value& value) { + value.emplace_object(); + serialize("timeUnit", x.time_unit, value); + serialize("value", x.value, value); } inline void to_json(const Expectation::ResponseAction& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("statusCode", x.status_code, value, allocator); + boost::json::value& value) { + value.emplace_object(); + serialize("statusCode", x.status_code, value); if (x.body.type() == typeid(std::string)) { - serialize("body", boost::any_cast(x.body), value, allocator); + serialize("body", boost::any_cast(x.body), value); } else if (x.body.type() == typeid(Expectation::BinaryResponse)) { serialize("body", boost::any_cast(x.body), - value, allocator); + value); } if (x.delay) { - serialize("delay", x.delay.get(), value, allocator); + serialize("delay", x.delay.get(), value); } } inline void to_json(const Expectation::ResponseTimes& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - serialize("remainingTimes", x.remaining_times, value, allocator); - serialize("unlimited", x.unlimited, value, allocator); + boost::json::value& value) { + value.emplace_object(); + serialize("remainingTimes", x.remaining_times, value); + serialize("unlimited", x.unlimited, value); } inline std::string serialize(const Expectation& object) { - rapidjson::Document doc; - auto& allocator = doc.GetAllocator(); + boost::json::value doc; + doc.emplace_object(); + to_json(object, doc); - doc.SetObject(); - to_json(object, doc, allocator); - - rapidjson::StringBuffer buffer; - rapidjson::Writer writer(buffer); - doc.Accept(writer); - return buffer.GetString(); + return boost::json::serialize(doc); }; } // namespace mockserver diff --git a/tests/utils/mock-server-client/JsonHelpers.h b/tests/utils/mock-server-client/JsonHelpers.h index d2756f939..8b79b8e5d 100644 --- a/tests/utils/mock-server-client/JsonHelpers.h +++ b/tests/utils/mock-server-client/JsonHelpers.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,126 +19,109 @@ #pragma once +#include #include -#include -#include -#include -#include +#include namespace mockserver { -inline void to_json(const std::string& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetString(rapidjson::StringRef(x.c_str(), x.size()), allocator); +inline void to_json(const std::string& x, boost::json::value& value) { + value.emplace_string() = x; } -inline void to_json(int32_t x, rapidjson::Value& value, - rapidjson::Document::AllocatorType&) { - value.SetInt(x); +inline void to_json(int32_t x, boost::json::value& value) { + value.emplace_int64() = x; } -inline void to_json(int64_t x, rapidjson::Value& value, - rapidjson::Document::AllocatorType&) { - value.SetInt64(x); +inline void to_json(int64_t x, boost::json::value& value) { + value.emplace_int64() = x; } -inline void to_json(double x, rapidjson::Value& value, - rapidjson::Document::AllocatorType&) { - value.SetDouble(x); +inline void to_json(double x, boost::json::value& value) { + value.emplace_double() = x; } -inline void to_json(bool x, rapidjson::Value& value, - rapidjson::Document::AllocatorType&) { - value.SetBool(x); +inline void to_json(bool x, boost::json::value& value) { + value.emplace_bool() = x; } inline void to_json(const std::shared_ptr>& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetString(reinterpret_cast(x->data()), - static_cast(x->size()), allocator); + boost::json::value& value) { + value.emplace_string() = + boost::json::string_view{reinterpret_cast(x->data()), x->size()}; } template -inline void to_json(const boost::optional& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { +inline void to_json(const boost::optional& x, boost::json::value& value) { if (x) { - to_json(x.get(), value, allocator); + to_json(x.get(), value); } else { - value.SetNull(); + value.emplace_null(); } } template -inline void to_json(const std::map& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetObject(); - for (auto itr = x.begin(); itr != x.end(); ++itr) { - const auto& key = itr->first; - rapidjson::Value item_value; - to_json(itr->second, item_value, allocator); - value.AddMember(rapidjson::StringRef(key.c_str(), key.size()), - std::move(item_value), allocator); +inline void to_json(const std::map& x, + boost::json::value& value) { + auto& object = value.emplace_object(); + for (const auto& entry : x) { + boost::json::value item_value; + to_json(entry.second, item_value); + object.emplace(entry.first, std::move(item_value)); } } template -inline void to_json(const std::vector& x, rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - value.SetArray(); - for (typename std::vector::const_iterator itr = x.begin(); itr != x.end(); - ++itr) { - rapidjson::Value item_value; - to_json(*itr, item_value, allocator); - value.PushBack(std::move(item_value), allocator); +inline void to_json(const std::vector& x, boost::json::value& value) { + auto& array = value.emplace_array(); + for (const auto& entry : x) { + boost::json::value item_value; + to_json(entry, item_value); + array.emplace_back(std::move(item_value)); } } template inline void serialize(const std::string& key, const T& x, - rapidjson::Value& value, - rapidjson::Document::AllocatorType& allocator) { - rapidjson::Value key_value; - to_json(key, key_value, allocator); - rapidjson::Value item_value; - to_json(x, item_value, allocator); - if (!item_value.IsNull()) { - value.AddMember(std::move(key_value), std::move(item_value), allocator); + boost::json::value& value) { + boost::json::value item_value; + to_json(x, item_value); + if (!item_value.is_null()) { + value.emplace_object().emplace(key, std::move(item_value)); } } -inline void from_json(const rapidjson::Value& value, int32_t& x) { - x = value.GetInt(); +inline void from_json(const boost::json::value& value, int32_t& x) { + x = static_cast(value.to_number()); } template -inline void from_json(const rapidjson::Value& value, std::vector& results) { - for (rapidjson::Value::ConstValueIterator itr = value.Begin(); - itr != value.End(); ++itr) { +inline void from_json(const boost::json::value& value, + std::vector& results) { + const auto& array = value.get_array(); + for (const auto& array_value : array) { T result; - from_json(*itr, result); - results.push_back(result); + from_json(array_value, result); + results.emplace_back(std::move(result)); } } template -inline T parse(const rapidjson::Value& value, const std::string& name) { +inline T parse(const boost::json::value& value, const std::string& name) { T result = T(); - rapidjson::Value::ConstMemberIterator itr = value.FindMember(name.c_str()); - if (itr != value.MemberEnd()) { - from_json(itr->value, result); + if (auto* found_value = value.as_object().if_contains(name)) { + from_json(*found_value, result); } return result; } template inline T parse(std::stringstream& json_stream) { - rapidjson::Document doc; - rapidjson::IStreamWrapper stream(json_stream); - doc.ParseStream(stream); + boost::json::error_code ec; + auto doc = boost::json::parse(json_stream, ec); T result{}; - if (doc.IsObject() || doc.IsArray()) { + if (doc.is_object() || doc.is_array()) { from_json(doc, result); } return result; diff --git a/tests/utils/mock-server-client/Status.h b/tests/utils/mock-server-client/Status.h index 9ed0a0cf4..4a01395ea 100644 --- a/tests/utils/mock-server-client/Status.h +++ b/tests/utils/mock-server-client/Status.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 HERE Europe B.V. + * Copyright (C) 2020-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,9 +31,9 @@ struct Status { Ports ports; }; -void from_json(const rapidjson::Value& value, Status& x); +void from_json(const boost::json::value& value, Status& x); -inline void from_json(const rapidjson::Value& value, Status& x) { +inline void from_json(const boost::json::value& value, Status& x) { x.ports = parse(value, "ports"); }