Skip to content

Commit 29f591d

Browse files
Integrate Boost.Json patching 1.82 for no exception (#1662)
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>
1 parent 76c63df commit 29f591d

8 files changed

Lines changed: 139 additions & 6 deletions

File tree

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 & 3 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.
@@ -25,6 +25,7 @@ ExternalProject_Add(boost-download
2525
GIT_REPOSITORY @OLP_SDK_CPP_BOOST_URL@
2626
GIT_TAG @OLP_SDK_CPP_BOOST_TAG@
2727
GIT_SUBMODULES libs/algorithm
28+
libs/align
2829
libs/any
2930
libs/array
3031
libs/assert
@@ -34,18 +35,20 @@ ExternalProject_Add(boost-download
3435
libs/container_hash
3536
libs/core
3637
libs/date_time
37-
libs/detail
3838
libs/describe
39+
libs/detail
3940
libs/format
4041
libs/function_types
4142
libs/headers
4243
libs/integer
44+
libs/intrusive
4345
libs/io
4446
libs/iterator
47+
libs/json
4548
libs/lexical_cast
4649
libs/move
47-
libs/mpl
4850
libs/mp11
51+
libs/mpl
4952
libs/numeric/conversion
5053
libs/optional
5154
libs/predef
@@ -55,18 +58,21 @@ ExternalProject_Add(boost-download
5558
libs/serialization
5659
libs/smart_ptr
5760
libs/static_assert
61+
libs/system
5862
libs/throw_exception
5963
libs/tokenizer
6064
libs/tti
6165
libs/type_index
6266
libs/type_traits
6367
libs/utility
6468
libs/uuid
69+
libs/variant2
6570
libs/winapi
6671
tools/build
6772
tools/boost_install
6873
GIT_SHALLOW 1
6974
SOURCE_DIR "@CMAKE_CURRENT_BINARY_DIR@/external_boost"
75+
PATCH_COMMAND @PATCH_BOOST_CMD@
7076
BUILD_IN_SOURCE 1
7177
UPDATE_COMMAND ""
7278
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)