Skip to content

Commit 2b8f6c6

Browse files
Use Boost::json in olp-cpp-sdk-dataservice-write (#1681)
* Use Boost::json in olp-cpp-sdk-dataservice-write Migrating from RapidJSON Relates-To: OCMAM-445 Signed-off-by: Rustam Gamidov <ext-rustam.gamidov@here.com> * Copy json implementation wrappers to write lib This allows to keep other libs untouched until fully migrated to the boost::json and remove write lib dependency from public json wrappers. Alternative solutions tried are: - add boost json wrappers to the same files in the core but to additional namespace - changes in core, json still exposed - move boost json wrappers from core to internal for the repository include location and add it to all DataSDK projects - huge change Relates-To: OCMAM-445 Signed-off-by: Rustam Gamidov <ext-rustam.gamidov@here.com> --------- Signed-off-by: Rustam Gamidov <ext-rustam.gamidov@here.com>
1 parent 9a5efa0 commit 2b8f6c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+753
-483
lines changed

olp-cpp-sdk-dataservice-write/CMakeLists.txt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
project(olp-cpp-sdk-dataservice-write VERSION 1.24.0)
1919
set(DESCRIPTION "C++ API library for writing data to OLP")
2020

21+
find_package(Boost REQUIRED)
22+
2123
set(OLP_SDK_DATASERVICE_WRITE_API_HEADERS
2224
./include/olp/dataservice/write/DataServiceWriteApi.h
2325
./include/olp/dataservice/write/IndexLayerClient.h
@@ -159,16 +161,21 @@ set(OLP_SDK_DATASERVICE_WRITE_SOURCES
159161
./src/generated/serializer/PublishPartitionsSerializer.h
160162
./src/generated/serializer/UpdateIndexRequestSerializer.cpp
161163
./src/generated/serializer/UpdateIndexRequestSerializer.h
164+
165+
./src/utils/BoostJsonSrc.cpp
162166
)
163167

164168
add_library(${PROJECT_NAME}
165169
${OLP_SDK_DATASERVICE_WRITE_INCLUDES}
166170
${OLP_SDK_DATASERVICE_WRITE_SOURCES})
167171

168-
target_include_directories(${PROJECT_NAME} PUBLIC
169-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
170-
$<INSTALL_INTERFACE:include>
171-
PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src>)
172+
target_include_directories(${PROJECT_NAME}
173+
PUBLIC
174+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
175+
$<INSTALL_INTERFACE:include>
176+
PRIVATE
177+
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src>
178+
$<BUILD_INTERFACE:${Boost_INCLUDE_DIRS}>)
172179

173180
target_compile_definitions(${PROJECT_NAME}
174181
PRIVATE DATASERVICE_WRITE_LIBRARY)
@@ -177,6 +184,11 @@ if(BUILD_SHARED_LIBS)
177184
PUBLIC DATASERVICE_WRITE_SHARED_LIBRARY)
178185
endif()
179186

187+
target_compile_definitions(${PROJECT_NAME}
188+
PRIVATE
189+
BOOST_ALL_NO_LIB
190+
BOOST_JSON_NO_LIB)
191+
180192
# Used also in the package config file
181193
set(PROJECT_LIBS olp-cpp-sdk-core)
182194

olp-cpp-sdk-dataservice-write/src/CatalogSettings.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 HERE Europe B.V.
2+
* Copyright (C) 2020-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.
@@ -19,6 +19,8 @@
1919

2020
#include "CatalogSettings.h"
2121

22+
#include <utility>
23+
2224
#include <olp/core/cache/CacheSettings.h>
2325
#include <olp/core/client/OlpClientSettingsFactory.h>
2426
#include <boost/format.hpp>
@@ -29,7 +31,7 @@
2931
#include <generated/serializer/CatalogSerializer.h>
3032
#include <generated/serializer/JsonSerializer.h>
3133
#include <generated/parser/CatalogParser.h>
32-
#include <olp/core/generated/parser/JsonParser.h>
34+
#include <generated/parser/JsonParser.h>
3335
// clang-format on
3436

3537
namespace olp {

olp-cpp-sdk-dataservice-write/src/JsonResultParser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 HERE Europe B.V.
2+
* Copyright (C) 2020-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.
@@ -23,8 +23,8 @@
2323
#include <string>
2424
#include <utility>
2525

26+
#include <generated/parser/JsonParser.h>
2627
#include <olp/core/client/ApiError.h>
27-
#include <olp/core/generated/parser/JsonParser.h>
2828
#include <olp/core/logging/Log.h>
2929

3030
namespace olp {

olp-cpp-sdk-dataservice-write/src/generated/parser/ApiParser.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-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.
@@ -19,11 +19,13 @@
1919

2020
#include "ApiParser.h"
2121

22-
#include <olp/core/generated/parser/ParserWrapper.h>
22+
#include <map>
23+
24+
#include <generated/parser/ParserWrapper.h>
2325

2426
namespace olp {
2527
namespace parser {
26-
void from_json(const rapidjson::Value& value,
28+
void from_json(const boost::json::value& value,
2729
olp::dataservice::write::model::Api& x) {
2830
x.SetApi(parse<std::string>(value, "api"));
2931
x.SetVersion(parse<std::string>(value, "version"));

olp-cpp-sdk-dataservice-write/src/generated/parser/ApiParser.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-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.
@@ -19,14 +19,14 @@
1919

2020
#pragma once
2121

22-
#include <rapidjson/document.h>
22+
#include <boost/json/value.hpp>
2323
#include "generated/model/Api.h"
2424

2525
#include <string>
2626

2727
namespace olp {
2828
namespace parser {
29-
void from_json(const rapidjson::Value& value,
29+
void from_json(const boost::json::value& value,
3030
olp::dataservice::write::model::Api& x);
3131

3232
} // namespace parser

olp-cpp-sdk-dataservice-write/src/generated/parser/CatalogParser.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-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.
@@ -19,48 +19,50 @@
1919

2020
#include "CatalogParser.h"
2121

22-
#include <olp/core/generated/parser/ParserWrapper.h>
22+
#include <vector>
23+
24+
#include <generated/parser/ParserWrapper.h>
2325

2426
namespace olp {
2527
namespace parser {
26-
using namespace olp::dataservice::write;
28+
namespace model = olp::dataservice::write::model;
2729

28-
void from_json(const rapidjson::Value& value, model::Coverage& x) {
30+
void from_json(const boost::json::value& value, model::Coverage& x) {
2931
x.SetAdminAreas(parse<std::vector<std::string> >(value, "adminAreas"));
3032
}
3133

32-
void from_json(const rapidjson::Value& value, model::IndexDefinition& x) {
34+
void from_json(const boost::json::value& value, model::IndexDefinition& x) {
3335
x.SetName(parse<std::string>(value, "name"));
3436
x.SetType(parse<std::string>(value, "type"));
3537
x.SetDuration(parse<int64_t>(value, "duration"));
3638
x.SetZoomLevel(parse<int64_t>(value, "zoomLevel"));
3739
}
3840

39-
void from_json(const rapidjson::Value& value, model::IndexProperties& x) {
41+
void from_json(const boost::json::value& value, model::IndexProperties& x) {
4042
x.SetTtl(parse<std::string>(value, "ttl"));
4143
x.SetIndexDefinitions(
4244
parse<std::vector<model::IndexDefinition> >(value, "indexDefinitions"));
4345
}
4446

45-
void from_json(const rapidjson::Value& value, model::Creator& x) {
47+
void from_json(const boost::json::value& value, model::Creator& x) {
4648
x.SetId(parse<std::string>(value, "id"));
4749
}
4850

49-
void from_json(const rapidjson::Value& value, model::Owner& x) {
51+
void from_json(const boost::json::value& value, model::Owner& x) {
5052
x.SetCreator(parse<model::Creator>(value, "creator"));
5153
x.SetOrganisation(parse<model::Creator>(value, "organisation"));
5254
}
5355

54-
void from_json(const rapidjson::Value& value, model::Partitioning& x) {
56+
void from_json(const boost::json::value& value, model::Partitioning& x) {
5557
x.SetScheme(parse<std::string>(value, "scheme"));
5658
x.SetTileLevels(parse<std::vector<int64_t> >(value, "tileLevels"));
5759
}
5860

59-
void from_json(const rapidjson::Value& value, model::Schema& x) {
61+
void from_json(const boost::json::value& value, model::Schema& x) {
6062
x.SetHrn(parse<std::string>(value, "hrn"));
6163
}
6264

63-
void from_json(const rapidjson::Value& value, model::StreamProperties& x) {
65+
void from_json(const boost::json::value& value, model::StreamProperties& x) {
6466
// Parsing these as double even though OepnAPI sepcs says int64 because
6567
// Backend returns the value in decimal format (e.g. 1.0) and this triggers an
6668
// assert in RapidJSON when parsing.
@@ -70,18 +72,18 @@ void from_json(const rapidjson::Value& value, model::StreamProperties& x) {
7072
static_cast<int64_t>(parse<double>(value, "dataOutThroughputMbps")));
7173
}
7274

73-
void from_json(const rapidjson::Value& value, model::Encryption& x) {
75+
void from_json(const boost::json::value& value, model::Encryption& x) {
7476
x.SetAlgorithm(parse<std::string>(value, "algorithm"));
7577
}
7678

77-
void from_json(const rapidjson::Value& value, model::Volume& x) {
79+
void from_json(const boost::json::value& value, model::Volume& x) {
7880
x.SetVolumeType(parse<std::string>(value, "volumeType"));
7981
x.SetMaxMemoryPolicy(parse<std::string>(value, "maxMemoryPolicy"));
8082
x.SetPackageType(parse<std::string>(value, "packageType"));
8183
x.SetEncryption(parse<model::Encryption>(value, "encryption"));
8284
}
8385

84-
void from_json(const rapidjson::Value& value, model::Layer& x) {
86+
void from_json(const boost::json::value& value, model::Layer& x) {
8587
x.SetId(parse<std::string>(value, "id"));
8688
x.SetName(parse<std::string>(value, "name"));
8789
x.SetSummary(parse<std::string>(value, "summary"));
@@ -103,11 +105,11 @@ void from_json(const rapidjson::Value& value, model::Layer& x) {
103105
x.SetVolume(parse<model::Volume>(value, "volume"));
104106
}
105107

106-
void from_json(const rapidjson::Value& value, model::Notifications& x) {
108+
void from_json(const boost::json::value& value, model::Notifications& x) {
107109
x.SetEnabled(parse<bool>(value, "enabled"));
108110
}
109111

110-
void from_json(const rapidjson::Value& value, model::Catalog& x) {
112+
void from_json(const boost::json::value& value, model::Catalog& x) {
111113
x.SetId(parse<std::string>(value, "id"));
112114
x.SetHrn(parse<std::string>(value, "hrn"));
113115
x.SetName(parse<std::string>(value, "name"));
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-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,49 +21,49 @@
2121

2222
#include <string>
2323

24-
#include <rapidjson/document.h>
24+
#include <boost/json/value.hpp>
2525

2626
#include <generated/model/Catalog.h>
2727

2828
namespace olp {
2929
namespace parser {
30-
void from_json(const rapidjson::Value& value,
30+
void from_json(const boost::json::value& value,
3131
olp::dataservice::write::model::Coverage& x);
3232

33-
void from_json(const rapidjson::Value& value,
33+
void from_json(const boost::json::value& value,
3434
olp::dataservice::write::model::IndexDefinition& x);
3535

36-
void from_json(const rapidjson::Value& value,
36+
void from_json(const boost::json::value& value,
3737
olp::dataservice::write::model::IndexProperties& x);
3838

39-
void from_json(const rapidjson::Value& value,
39+
void from_json(const boost::json::value& value,
4040
olp::dataservice::write::model::Creator& x);
4141

42-
void from_json(const rapidjson::Value& value,
42+
void from_json(const boost::json::value& value,
4343
olp::dataservice::write::model::Owner& x);
4444

45-
void from_json(const rapidjson::Value& value,
45+
void from_json(const boost::json::value& value,
4646
olp::dataservice::write::model::Partitioning& x);
4747

48-
void from_json(const rapidjson::Value& value,
48+
void from_json(const boost::json::value& value,
4949
olp::dataservice::write::model::Schema& x);
5050

51-
void from_json(const rapidjson::Value& value,
51+
void from_json(const boost::json::value& value,
5252
olp::dataservice::write::model::StreamProperties& x);
5353

54-
void from_json(const rapidjson::Value& value,
54+
void from_json(const boost::json::value& value,
5555
olp::dataservice::write::model::Encryption& x);
5656

57-
void from_json(const rapidjson::Value& value,
57+
void from_json(const boost::json::value& value,
5858
olp::dataservice::write::model::Volume& x);
5959

60-
void from_json(const rapidjson::Value& value,
60+
void from_json(const boost::json::value& value,
6161
olp::dataservice::write::model::Layer& x);
6262

63-
void from_json(const rapidjson::Value& value,
63+
void from_json(const boost::json::value& value,
6464
olp::dataservice::write::model::Notifications& x);
6565

66-
void from_json(const rapidjson::Value& value,
66+
void from_json(const boost::json::value& value,
6767
olp::dataservice::write::model::Catalog& x);
6868
} // namespace parser
6969
} // namespace olp

olp-cpp-sdk-dataservice-write/src/generated/parser/DetailsParser.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-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.
@@ -19,11 +19,13 @@
1919

2020
#include "DetailsParser.h"
2121

22-
#include <olp/core/generated/parser/ParserWrapper.h>
22+
#include <string>
23+
24+
#include <generated/parser/ParserWrapper.h>
2325

2426
namespace olp {
2527
namespace parser {
26-
void from_json(const rapidjson::Value& value,
28+
void from_json(const boost::json::value& value,
2729
olp::dataservice::write::model::Details& x) {
2830
x.SetState(parse<std::string>(value, "state"));
2931
x.SetMessage(parse<std::string>(value, "message"));

olp-cpp-sdk-dataservice-write/src/generated/parser/DetailsParser.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-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.
@@ -19,13 +19,13 @@
1919

2020
#pragma once
2121

22-
#include <rapidjson/document.h>
22+
#include <boost/json/value.hpp>
2323

2424
#include <olp/dataservice/write/generated/model/Details.h>
2525

2626
namespace olp {
2727
namespace parser {
28-
void from_json(const rapidjson::Value& value,
28+
void from_json(const boost::json::value& value,
2929
dataservice::write::model::Details& x);
3030
} // namespace parser
3131
} // namespace olp

0 commit comments

Comments
 (0)