From 603ed9911b1768ccb253a80e244dcd6cbd757a0c Mon Sep 17 00:00:00 2001 From: Rustam Gamidov Date: Thu, 5 Feb 2026 10:30:39 +0200 Subject: [PATCH 1/2] Integrate Boost.Json code for further usage No conversion just getting it into the build process Relates-To: OCMAM-442 Signed-off-by: Rustam Gamidov --- external/boost/CMakeLists.txt.boost.in | 10 ++- olp-cpp-sdk-core/CMakeLists.txt | 4 ++ olp-cpp-sdk-core/src/utils/BoostJsonSrc.cpp | 20 ++++++ olp-cpp-sdk-core/tests/CMakeLists.txt | 3 +- olp-cpp-sdk-core/tests/utils/JsonTest.cpp | 67 +++++++++++++++++++++ tests/common/CMakeLists.txt | 5 +- 6 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 olp-cpp-sdk-core/src/utils/BoostJsonSrc.cpp create mode 100644 olp-cpp-sdk-core/tests/utils/JsonTest.cpp diff --git a/external/boost/CMakeLists.txt.boost.in b/external/boost/CMakeLists.txt.boost.in index 562b89335..bb83b6f0f 100644 --- a/external/boost/CMakeLists.txt.boost.in +++ b/external/boost/CMakeLists.txt.boost.in @@ -1,4 +1,4 @@ -# Copyright (C) 2019-2020 HERE Europe B.V. +# Copyright (C) 2019-2026 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,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 @@ -47,6 +51,7 @@ ExternalProject_Add(boost-download libs/random libs/serialization libs/smart_ptr + libs/system libs/static_assert libs/throw_exception libs/tti @@ -54,6 +59,7 @@ ExternalProject_Add(boost-download libs/type_traits libs/utility libs/uuid + libs/variant2 libs/winapi tools/build tools/boost_install diff --git a/olp-cpp-sdk-core/CMakeLists.txt b/olp-cpp-sdk-core/CMakeLists.txt index 6190c13dc..e694436ad 100644 --- a/olp-cpp-sdk-core/CMakeLists.txt +++ b/olp-cpp-sdk-core/CMakeLists.txt @@ -359,6 +359,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 @@ -456,6 +457,9 @@ if (OLP_SDK_USE_STD_ANY) PUBLIC OLP_SDK_USE_STD_ANY) endif() +target_compile_definitions(${PROJECT_NAME} PRIVATE BOOST_ALL_NO_LIB) +target_compile_definitions(${PROJECT_NAME} PRIVATE BOOST_JSON_NO_LIB) + target_include_directories(${PROJECT_NAME} PUBLIC $ $ 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..017758210 --- /dev/null +++ b/olp-cpp-sdk-core/src/utils/BoostJsonSrc.cpp @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2026 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-core/tests/CMakeLists.txt b/olp-cpp-sdk-core/tests/CMakeLists.txt index 2b9d25f2e..fc13fc82e 100644 --- a/olp-cpp-sdk-core/tests/CMakeLists.txt +++ b/olp-cpp-sdk-core/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2019-2025 HERE Europe B.V. +# Copyright (C) 2019-2026 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. @@ -73,6 +73,7 @@ set(OLP_CPP_SDK_CORE_TESTS_SOURCES ./http/NetworkSettingsTest.cpp ./http/NetworkUtils.cpp + ./utils/JsonTest.cpp ./utils/UtilsTest.cpp ./utils/UrlTest.cpp ) diff --git a/olp-cpp-sdk-core/tests/utils/JsonTest.cpp b/olp-cpp-sdk-core/tests/utils/JsonTest.cpp new file mode 100644 index 000000000..ba402a9c3 --- /dev/null +++ b/olp-cpp-sdk-core/tests/utils/JsonTest.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2026 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 + +#include + +namespace { + +using UtilsTest = testing::Test; + +const std::string kJsonData = R"json( + { + "catalogs": [ + { + "hrn": "hrn:here:data::olp:ocm", + "version": 17, + "dependencies": [], + "metadata_type": "partitions" + } + ], + "regions": [ + { + "id": 423423, + "parent_id": 14123411, + "catalogs": [ + { + "hrn": "hrn:here:data::olp:ocm", + "status": "pending", + "size_raw_bytes": 4623545, + "layer_groups": [ + "rendering" + ], + "tiles": [ + 2354325, + 5243252 + ] + } + ] + } + ] + })json"; + +TEST(UtilsTest, BoostJsonAvailable) { + boost::system::error_code error_code; + auto parsed_json = boost::json::parse(kJsonData, error_code); + + EXPECT_FALSE(error_code.failed()); +} + +} // namespace diff --git a/tests/common/CMakeLists.txt b/tests/common/CMakeLists.txt index 90a99c77c..c3331f672 100644 --- a/tests/common/CMakeLists.txt +++ b/tests/common/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2019-2021 HERE Europe B.V. +# Copyright (C) 2019-2026 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. @@ -50,6 +50,9 @@ target_include_directories(olp-cpp-sdk-tests-common ${CMAKE_CURRENT_SOURCE_DIR}/../../olp-cpp-sdk-dataservice-read/src/ ) +target_compile_definitions(olp-cpp-sdk-tests-common PUBLIC BOOST_CONTAINER_NO_LIB) +target_compile_definitions(olp-cpp-sdk-tests-common PUBLIC BOOST_JSON_NO_LIB) + target_link_libraries(olp-cpp-sdk-tests-common PUBLIC gmock From f56ca4af928f6f07931adb060eb632d13487297f Mon Sep 17 00:00:00 2001 From: Rustam Gamidov Date: Wed, 11 Feb 2026 17:58:19 +0200 Subject: [PATCH 2/2] Patch boost::json 1.82 with BOOST_NO_EXCEPTIONS Is is solved in boost::json 1.83 but we preferred to stay at 1.82 Relates-To: OCMAM-442 Signed-off-by: Rustam Gamidov --- external/boost/CMakeLists.txt | 4 ++- external/boost/CMakeLists.txt.boost.in | 1 + .../boost/boost_182_json_noexceptions.diff | 30 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 external/boost/boost_182_json_noexceptions.diff diff --git a/external/boost/CMakeLists.txt b/external/boost/CMakeLists.txt index 618d0fe09..43f9396e9 100644 --- a/external/boost/CMakeLists.txt +++ b/external/boost/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2019-2020 HERE Europe B.V. +# Copyright (C) 2019-2026 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. @@ -32,6 +32,8 @@ else() set(B2_CMD ./b2) endif() +set(PATCH_BOOST_CMD "git apply -v ${CMAKE_CURRENT_SOURCE_DIR}/boost_182_json_noexceptions.diff") + configure_file(CMakeLists.txt.boost.in download/CMakeLists.txt @ONLY) set(CMAKE_VERBOSE_MAKEFILE ON) diff --git a/external/boost/CMakeLists.txt.boost.in b/external/boost/CMakeLists.txt.boost.in index bb83b6f0f..a696562b3 100644 --- a/external/boost/CMakeLists.txt.boost.in +++ b/external/boost/CMakeLists.txt.boost.in @@ -65,6 +65,7 @@ ExternalProject_Add(boost-download tools/boost_install GIT_SHALLOW 1 SOURCE_DIR "@CMAKE_CURRENT_BINARY_DIR@/external_boost" + PATCH_COMMAND @PATCH_BOOST_CMD@ BUILD_IN_SOURCE 1 UPDATE_COMMAND "" CONFIGURE_COMMAND @BOOTSTRAP_CMD@ diff --git a/external/boost/boost_182_json_noexceptions.diff b/external/boost/boost_182_json_noexceptions.diff new file mode 100644 index 000000000..507e3cecf --- /dev/null +++ b/external/boost/boost_182_json_noexceptions.diff @@ -0,0 +1,30 @@ +diff --git a/libs/json/include/boost/json/impl/value.ipp b/libs/json/include/boost/json/impl/value.ipp +index 7460c02..7513b38 100644 +--- a/libs/json/include/boost/json/impl/value.ipp ++++ b/libs/json/include/boost/json/impl/value.ipp +@@ -381,7 +381,9 @@ operator>>( + char read_buf[BOOST_JSON_STACK_BUFFER_SIZE / 2]; + std::streambuf& buf = *is.rdbuf(); + std::ios::iostate err = std::ios::goodbit; ++#ifndef BOOST_NO_EXCEPTIONS + try ++#endif + { + while( true ) + { +@@ -437,6 +439,7 @@ operator>>( + break; + } + } ++#ifndef BOOST_NO_EXCEPTIONS + catch(...) + { + try +@@ -450,6 +453,7 @@ operator>>( + if( is.exceptions() & std::ios::badbit ) + throw; + } ++#endif + + is.setstate(err | std::ios::failbit); + return is;