Skip to content

Commit 288f250

Browse files
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>
1 parent df55ff5 commit 288f250

File tree

6 files changed

+80
-2
lines changed

6 files changed

+80
-2
lines changed

external/boost/CMakeLists.txt.boost.in

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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,13 +51,15 @@ 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

olp-cpp-sdk-core/CMakeLists.txt

Lines changed: 5 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,10 @@ 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_CONTAINER_NO_LIB)
462+
target_compile_definitions(${PROJECT_NAME} PRIVATE BOOST_JSON_NO_LIB)
463+
459464
target_include_directories(${PROJECT_NAME} PUBLIC
460465
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
461466
$<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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ if (ANDROID OR IOS)
114114

115115
else()
116116
add_executable(olp-cpp-sdk-core-tests ${OLP_CPP_SDK_CORE_TESTS_SOURCES})
117+
# target_compile_definitions(olp-cpp-sdk-core-tests PRIVATE BOOST_CONTAINER_NO_LIB)
118+
# target_compile_definitions(olp-cpp-sdk-core-tests PRIVATE BOOST_JSON_NO_LIB)
117119
target_link_libraries(olp-cpp-sdk-core-tests
118120
PRIVATE
119121
custom-params

olp-cpp-sdk-core/tests/utils/UtilsTest.cpp

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2023 HERE Europe B.V.
2+
* Copyright (C) 2023-2026 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,12 +21,46 @@
2121

2222
#include <string>
2323

24+
#include <boost/json/parse.hpp>
25+
2426
#include <olp/core/utils/Credentials.h>
2527

2628
namespace {
2729

2830
using UtilsTest = testing::Test;
2931

32+
const std::string kJsonData = R"json(
33+
{
34+
"catalogs": [
35+
{
36+
"hrn": "hrn:here:data::olp-here:ocm",
37+
"version": 63,
38+
"dependencies": [],
39+
"metadata_type": "partitions"
40+
}
41+
],
42+
"regions": [
43+
{
44+
"id": 20187401,
45+
"parent_id": 20147700,
46+
"catalogs": [
47+
{
48+
"hrn": "hrn:here:data::olp-here:ocm",
49+
"status": "pending",
50+
"size_raw_bytes": 17349848,
51+
"layer_groups": [
52+
"rendering"
53+
],
54+
"tiles": [
55+
5904589,
56+
5904600
57+
]
58+
}
59+
]
60+
}
61+
]
62+
})json";
63+
3064
TEST(UtilsTest, Credentials) {
3165
{
3266
SCOPED_TRACE("Empty url");
@@ -88,4 +122,12 @@ TEST(UtilsTest, Credentials) {
88122
EXPECT_EQ(result.find(appKey, 0), std::string::npos);
89123
}
90124
}
125+
126+
TEST(UtilsTest, BoostJson) {
127+
boost::system::error_code error_code;
128+
auto parsed_json = boost::json::parse(kJsonData, error_code);
129+
130+
EXPECT_FALSE(error_code.failed());
131+
}
132+
91133
} // namespace

tests/common/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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)