Skip to content

Commit 41997b2

Browse files
Use Boost::json in olp-cpp-sdk-dataservice-read (#1684)
* Use Boost::json in olp-cpp-sdk-dataservice-read Migrating from RapidJSON Relates-To: OCMAM-444 Signed-off-by: Rustam Gamidov <ext-rustam.gamidov@here.com> * Copy json implementation wrappers to read lib This allows to keep other libs untouched until fully migrated to the boost::json and remove read 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-444 Signed-off-by: Rustam Gamidov <ext-rustam.gamidov@here.com> --------- Signed-off-by: Rustam Gamidov <ext-rustam.gamidov@here.com>
1 parent 2b8f6c6 commit 41997b2

Some content is hidden

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

52 files changed

+747
-480
lines changed

olp-cpp-sdk-dataservice-read/include/olp/dataservice/read/model/StreamOffsets.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2021 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,7 @@
1919

2020
#pragma once
2121

22+
#include <cstdint>
2223
#include <utility>
2324
#include <vector>
2425

olp-cpp-sdk-dataservice-read/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-read/src/generated/api/MetadataApi.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2024 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.
@@ -22,6 +22,8 @@
2222
#include <algorithm>
2323
#include <map>
2424
#include <sstream>
25+
#include <utility>
26+
#include <vector>
2527

2628
#include <olp/core/client/HttpResponse.h>
2729
#include <olp/core/client/OlpClient.h>
@@ -235,8 +237,6 @@ MetadataApi::CompatibleVersionsResponse MetadataApi::GetCompatibleVersions(
235237
std::multimap<std::string, std::string> query_params;
236238
query_params.emplace("limit", std::to_string(limit));
237239

238-
rapidjson::Value value;
239-
240240
const auto serialized_dependencies = serializer::serialize(dependencies);
241241

242242
const auto data = std::make_shared<std::vector<unsigned char>>(

olp-cpp-sdk-dataservice-read/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::read::model::Api& x) {
2830
x.SetApi(parse<std::string>(value, "api"));
2931
x.SetVersion(parse<std::string>(value, "version"));

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

Lines changed: 4 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,15 @@
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, olp::dataservice::read::model::Api& x);
29+
void from_json(const boost::json::value& value,
30+
olp::dataservice::read::model::Api& x);
3031

3132
} // namespace parser
3233

olp-cpp-sdk-dataservice-read/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-
namespace model = dataservice::read::model;
28+
namespace model = olp::dataservice::read::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.
@@ -19,50 +19,50 @@
1919

2020
#pragma once
2121

22-
#include <rapidjson/document.h>
22+
#include <boost/json/value.hpp>
2323
#include "olp/dataservice/read/model/Catalog.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::read::model::Coverage& x);
3131

32-
void from_json(const rapidjson::Value& value,
32+
void from_json(const boost::json::value& value,
3333
olp::dataservice::read::model::IndexDefinition& x);
3434

35-
void from_json(const rapidjson::Value& value,
35+
void from_json(const boost::json::value& value,
3636
olp::dataservice::read::model::IndexProperties& x);
3737

38-
void from_json(const rapidjson::Value& value,
38+
void from_json(const boost::json::value& value,
3939
olp::dataservice::read::model::Creator& x);
4040

41-
void from_json(const rapidjson::Value& value,
41+
void from_json(const boost::json::value& value,
4242
olp::dataservice::read::model::Owner& x);
4343

44-
void from_json(const rapidjson::Value& value,
44+
void from_json(const boost::json::value& value,
4545
olp::dataservice::read::model::Partitioning& x);
4646

47-
void from_json(const rapidjson::Value& value,
47+
void from_json(const boost::json::value& value,
4848
olp::dataservice::read::model::Schema& x);
4949

50-
void from_json(const rapidjson::Value& value,
50+
void from_json(const boost::json::value& value,
5151
olp::dataservice::read::model::StreamProperties& x);
5252

53-
void from_json(const rapidjson::Value& value,
53+
void from_json(const boost::json::value& value,
5454
olp::dataservice::read::model::Encryption& x);
5555

56-
void from_json(const rapidjson::Value& value,
56+
void from_json(const boost::json::value& value,
5757
olp::dataservice::read::model::Volume& x);
5858

59-
void from_json(const rapidjson::Value& value,
59+
void from_json(const boost::json::value& value,
6060
olp::dataservice::read::model::Layer& x);
6161

62-
void from_json(const rapidjson::Value& value,
62+
void from_json(const boost::json::value& value,
6363
olp::dataservice::read::model::Notifications& x);
6464

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

olp-cpp-sdk-dataservice-read/src/generated/parser/IndexParser.cpp

Lines changed: 10 additions & 6 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,17 @@
1919

2020
#include "IndexParser.h"
2121

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

2427
namespace olp {
2528
namespace parser {
26-
namespace model = dataservice::read::model;
2729

28-
void from_json(const rapidjson::Value& value,
30+
namespace model = olp::dataservice::read::model;
31+
32+
void from_json(const boost::json::value& value,
2933
std::shared_ptr<model::SubQuad>& x) {
3034
auto quad = std::make_shared<model::SubQuad>();
3135

@@ -47,7 +51,7 @@ void from_json(const rapidjson::Value& value,
4751
x.swap(quad);
4852
}
4953

50-
void from_json(const rapidjson::Value& value,
54+
void from_json(const boost::json::value& value,
5155
std::shared_ptr<model::ParentQuad>& x) {
5256
auto quad = std::make_shared<model::ParentQuad>();
5357

@@ -69,7 +73,7 @@ void from_json(const rapidjson::Value& value,
6973
x.swap(quad);
7074
}
7175

72-
void from_json(const rapidjson::Value& value, model::Index& x) {
76+
void from_json(const boost::json::value& value, model::Index& x) {
7377
x.SetParentQuads(parse<std::vector<std::shared_ptr<model::ParentQuad>>>(
7478
value, "parentQuads"));
7579
x.SetSubQuads(

olp-cpp-sdk-dataservice-read/src/generated/parser/IndexParser.h

Lines changed: 6 additions & 5 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,19 +19,20 @@
1919

2020
#pragma once
2121

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

25+
#include <memory>
2526
#include <string>
2627

2728
namespace olp {
2829
namespace parser {
2930

30-
void from_json(const rapidjson::Value& value,
31+
void from_json(const boost::json::value& value,
3132
std::shared_ptr<olp::dataservice::read::model::SubQuad>& x);
32-
void from_json(const rapidjson::Value& value,
33+
void from_json(const boost::json::value& value,
3334
std::shared_ptr<olp::dataservice::read::model::ParentQuad>& x);
34-
void from_json(const rapidjson::Value& value,
35+
void from_json(const boost::json::value& value,
3536
olp::dataservice::read::model::Index& x);
3637
} // namespace parser
3738
} // namespace olp

0 commit comments

Comments
 (0)