Skip to content

Commit a47ef51

Browse files
Integrate Boost.Json patching 1.82 for no exception (#1662)
* 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 <ext-rustam.gamidov@here.com> * 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 <ext-rustam.gamidov@here.com> --------- Signed-off-by: Rustam Gamidov <ext-rustam.gamidov@here.com>
1 parent e7a0373 commit a47ef51

File tree

8 files changed

+139
-5
lines changed

8 files changed

+139
-5
lines changed

external/boost/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2019-2020 HERE Europe B.V.
1+
# Copyright (C) 2019-2026 HERE Europe B.V.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -32,6 +32,8 @@ else()
3232
set(B2_CMD ./b2)
3333
endif()
3434

35+
set(PATCH_BOOST_CMD "git apply -v ${CMAKE_CURRENT_SOURCE_DIR}/boost_182_json_noexceptions.diff")
36+
3537
configure_file(CMakeLists.txt.boost.in download/CMakeLists.txt @ONLY)
3638

3739
set(CMAKE_VERBOSE_MAKEFILE ON)

external/boost/CMakeLists.txt.boost.in

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2019-2020 HERE Europe B.V.
1+
# Copyright (C) 2019-2026 HERE Europe B.V.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -24,9 +24,11 @@ include(ExternalProject)
2424
ExternalProject_Add(boost-download
2525
GIT_REPOSITORY @OLP_SDK_CPP_BOOST_URL@
2626
GIT_TAG @OLP_SDK_CPP_BOOST_TAG@
27-
GIT_SUBMODULES libs/any
27+
GIT_SUBMODULES libs/align
28+
libs/any
2829
libs/assert
2930
libs/config
31+
libs/container
3032
libs/container_hash
3133
libs/core
3234
libs/detail
@@ -35,8 +37,10 @@ ExternalProject_Add(boost-download
3537
libs/function_types
3638
libs/headers
3739
libs/integer
40+
libs/intrusive
3841
libs/io
3942
libs/iterator
43+
libs/json
4044
libs/move
4145
libs/mpl
4246
libs/mp11
@@ -47,18 +51,21 @@ ExternalProject_Add(boost-download
4751
libs/random
4852
libs/serialization
4953
libs/smart_ptr
54+
libs/system
5055
libs/static_assert
5156
libs/throw_exception
5257
libs/tti
5358
libs/type_index
5459
libs/type_traits
5560
libs/utility
5661
libs/uuid
62+
libs/variant2
5763
libs/winapi
5864
tools/build
5965
tools/boost_install
6066
GIT_SHALLOW 1
6167
SOURCE_DIR "@CMAKE_CURRENT_BINARY_DIR@/external_boost"
68+
PATCH_COMMAND @PATCH_BOOST_CMD@
6269
BUILD_IN_SOURCE 1
6370
UPDATE_COMMAND ""
6471
CONFIGURE_COMMAND @BOOTSTRAP_CMD@
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
diff --git a/libs/json/include/boost/json/impl/value.ipp b/libs/json/include/boost/json/impl/value.ipp
2+
index 7460c02..7513b38 100644
3+
--- a/libs/json/include/boost/json/impl/value.ipp
4+
+++ b/libs/json/include/boost/json/impl/value.ipp
5+
@@ -381,7 +381,9 @@ operator>>(
6+
char read_buf[BOOST_JSON_STACK_BUFFER_SIZE / 2];
7+
std::streambuf& buf = *is.rdbuf();
8+
std::ios::iostate err = std::ios::goodbit;
9+
+#ifndef BOOST_NO_EXCEPTIONS
10+
try
11+
+#endif
12+
{
13+
while( true )
14+
{
15+
@@ -437,6 +439,7 @@ operator>>(
16+
break;
17+
}
18+
}
19+
+#ifndef BOOST_NO_EXCEPTIONS
20+
catch(...)
21+
{
22+
try
23+
@@ -450,6 +453,7 @@ operator>>(
24+
if( is.exceptions() & std::ios::badbit )
25+
throw;
26+
}
27+
+#endif
28+
29+
is.setstate(err | std::ios::failbit);
30+
return is;

olp-cpp-sdk-core/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ endif()
359359
set(OLP_SDK_UTILS_SOURCES
360360
./src/utils/Base64.cpp
361361
./src/utils/BoostExceptionHandle.cpp
362+
./src/utils/BoostJsonSrc.cpp
362363
./src/utils/Credentials.cpp
363364
./src/utils/Dir.cpp
364365
./src/utils/Thread.cpp
@@ -456,6 +457,9 @@ if (OLP_SDK_USE_STD_ANY)
456457
PUBLIC OLP_SDK_USE_STD_ANY)
457458
endif()
458459

460+
target_compile_definitions(${PROJECT_NAME} PRIVATE BOOST_ALL_NO_LIB)
461+
target_compile_definitions(${PROJECT_NAME} PRIVATE BOOST_JSON_NO_LIB)
462+
459463
target_include_directories(${PROJECT_NAME} PUBLIC
460464
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
461465
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (C) 2026 HERE Europe B.V.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
* License-Filename: LICENSE
18+
*/
19+
20+
#include <boost/json/src.hpp>

olp-cpp-sdk-core/tests/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2019-2025 HERE Europe B.V.
1+
# Copyright (C) 2019-2026 HERE Europe B.V.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -73,6 +73,7 @@ set(OLP_CPP_SDK_CORE_TESTS_SOURCES
7373
./http/NetworkSettingsTest.cpp
7474
./http/NetworkUtils.cpp
7575

76+
./utils/JsonTest.cpp
7677
./utils/UtilsTest.cpp
7778
./utils/UrlTest.cpp
7879
)
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright (C) 2026 HERE Europe B.V.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
* License-Filename: LICENSE
18+
*/
19+
20+
#include <gtest/gtest.h>
21+
22+
#include <boost/json/parse.hpp>
23+
24+
namespace {
25+
26+
using UtilsTest = testing::Test;
27+
28+
const std::string kJsonData = R"json(
29+
{
30+
"catalogs": [
31+
{
32+
"hrn": "hrn:here:data::olp:ocm",
33+
"version": 17,
34+
"dependencies": [],
35+
"metadata_type": "partitions"
36+
}
37+
],
38+
"regions": [
39+
{
40+
"id": 423423,
41+
"parent_id": 14123411,
42+
"catalogs": [
43+
{
44+
"hrn": "hrn:here:data::olp:ocm",
45+
"status": "pending",
46+
"size_raw_bytes": 4623545,
47+
"layer_groups": [
48+
"rendering"
49+
],
50+
"tiles": [
51+
2354325,
52+
5243252
53+
]
54+
}
55+
]
56+
}
57+
]
58+
})json";
59+
60+
TEST(UtilsTest, BoostJsonAvailable) {
61+
boost::system::error_code error_code;
62+
auto parsed_json = boost::json::parse(kJsonData, error_code);
63+
64+
EXPECT_FALSE(error_code.failed());
65+
}
66+
67+
} // namespace

tests/common/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2019-2021 HERE Europe B.V.
1+
# Copyright (C) 2019-2026 HERE Europe B.V.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -50,6 +50,9 @@ target_include_directories(olp-cpp-sdk-tests-common
5050
${CMAKE_CURRENT_SOURCE_DIR}/../../olp-cpp-sdk-dataservice-read/src/
5151
)
5252

53+
target_compile_definitions(olp-cpp-sdk-tests-common PUBLIC BOOST_CONTAINER_NO_LIB)
54+
target_compile_definitions(olp-cpp-sdk-tests-common PUBLIC BOOST_JSON_NO_LIB)
55+
5356
target_link_libraries(olp-cpp-sdk-tests-common
5457
PUBLIC
5558
gmock

0 commit comments

Comments
 (0)