Skip to content

Commit c7e4b7e

Browse files
Switch to Boost.JSON
Complete overhaul Relates-To: DATASDK-58 Signed-off-by: Andrey Kashcheev <ext-andrey.kashcheev@here.com>
1 parent 1c59ee6 commit c7e4b7e

19 files changed

+80
-78
lines changed

external/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ if(OLP_SDK_ENABLE_DEFAULT_CACHE_LMDB)
8888
endif()
8989
endif()
9090

91-
find_package(Boost QUIET)
91+
find_package(Boost 1.82.0 QUIET)
9292
if(NOT TARGET Boost AND NOT Boost_FOUND)
9393
add_subdirectory(boost)
9494
set(BOOST_ROOT ${EXTERNAL_BOOST_ROOT} PARENT_SCOPE)

olp-cpp-sdk-core/src/utils/BoostJsonSrc.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@
1717
* License-Filename: LICENSE
1818
*/
1919

20+
#define BOOST_CONTAINER_NO_LIB
21+
2022
#include <boost/json/src.hpp>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
namespace olp {
2525
namespace parser {
26-
using namespace olp::dataservice::read;
26+
namespace model = olp::dataservice::read::model;
2727

2828
void from_json(const boost::json::value& value, model::Coverage& x) {
2929
x.SetAdminAreas(parse<std::vector<std::string>>(value, "adminAreas"));

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323

2424
namespace olp {
2525
namespace parser {
26-
using namespace olp::dataservice::read;
26+
27+
namespace model = olp::dataservice::read::model;
2728

2829
void from_json(const boost::json::value& value,
2930
std::shared_ptr<model::SubQuad>& x) {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
namespace olp {
2525
namespace parser {
26-
using namespace olp::dataservice::read;
26+
namespace model = olp::dataservice::read::model;
2727

2828
void from_json(const boost::json::value& value, model::LayerVersion& x) {
2929
x.SetLayer(parse<std::string>(value, "layer"));

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
namespace olp {
2828
namespace parser {
29-
using namespace olp::dataservice::read;
29+
namespace model = olp::dataservice::read::model;
3030

3131
void from_json(const boost::json::value& value, model::Metadata& x) {
3232
x.SetPartition(parse<std::string>(value, "partition"));

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
namespace olp {
2525
namespace parser {
26-
using namespace olp::dataservice::read;
26+
namespace model = olp::dataservice::read::model;
2727

2828
void from_json(const boost::json::value& value, model::Partition& x) {
2929
x.SetChecksum(parse<boost::optional<std::string>>(value, "checksum"));

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
namespace olp {
2525
namespace parser {
26-
using namespace olp::dataservice::read;
26+
namespace model = olp::dataservice::read::model;
2727

2828
void from_json(const boost::json::value& value, model::StreamOffset& x) {
2929
x.SetPartition(parse<int32_t>(value, "partition"));

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
namespace olp {
2525
namespace parser {
26-
using namespace olp::dataservice::read;
26+
namespace model = olp::dataservice::read::model;
2727

2828
void from_json(const boost::json::value& value, model::SubscribeResponse& x) {
2929
x.SetNodeBaseURL(parse<std::string>(value, "nodeBaseURL"));

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
namespace olp {
2525
namespace parser {
26-
using namespace olp::dataservice::read;
26+
namespace model = olp::dataservice::read::model;
2727

2828
void from_json(const boost::json::value& value, model::VersionResponse& x) {
2929
x.SetVersion(parse<int64_t>(value, "version"));

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
namespace olp {
2525
namespace parser {
26-
using namespace olp::dataservice::write;
26+
namespace model = olp::dataservice::write::model;
2727

2828
void from_json(const boost::json::value& value, model::Coverage& x) {
2929
x.SetAdminAreas(parse<std::vector<std::string> >(value, "adminAreas"));

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
namespace olp {
2525
namespace parser {
26-
using namespace olp::dataservice::write;
26+
namespace model = olp::dataservice::write::model;
2727

2828
void from_json(const boost::json::value& value, model::LayerVersion& x) {
2929
x.SetLayer(parse<std::string>(value, "layer"));

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
namespace olp {
2525
namespace parser {
26-
using namespace olp::dataservice::write;
26+
namespace model = olp::dataservice::write::model;
2727

2828
void from_json(const boost::json::value& value, model::Partition& x) {
2929
x.SetChecksum(parse<boost::optional<std::string>>(value, "checksum"));

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@
2121

2222
#include <olp/core/generated/parser/ParserWrapper.h>
2323

24-
using namespace olp::dataservice::write::model;
24+
namespace model = olp::dataservice::write::model;
2525

2626
namespace olp {
2727
namespace parser {
28-
void from_json(const boost::json::value& value, TraceID& x) {
28+
void from_json(const boost::json::value& value, model::TraceID& x) {
2929
x.SetParentID(parse<std::string>(value, "ParentID"));
3030
x.SetGeneratedIDs(parse<std::vector<std::string> >(value, "GeneratedIDs"));
3131
}
3232

33-
void from_json(const boost::json::value& value, ResponseOk& x) {
34-
x.SetTraceID(parse<TraceID>(value, "TraceID"));
33+
void from_json(const boost::json::value& value, model::ResponseOk& x) {
34+
x.SetTraceID(parse<model::TraceID>(value, "TraceID"));
3535
}
3636

3737
} // namespace parser

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
namespace olp {
2525
namespace parser {
26-
using namespace olp::dataservice::write;
26+
namespace model = olp::dataservice::write::model;
2727

2828
void from_json(const boost::json::value& value, model::VersionResponse& x) {
2929
x.SetVersion(parse<int64_t>(value, "version"));

olp-cpp-sdk-dataservice-write/src/generated/serializer/IndexInfoSerializer.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,25 @@ void to_json(const dataservice::write::model::Index &x,
2929

3030
boost::json::object indexFields;
3131
for (auto &field_pair : x.GetIndexFields()) {
32-
using namespace dataservice::write::model;
32+
namespace model = dataservice::write::model;
3333
const auto &field = field_pair.second;
3434
const auto &key = field_pair.first;
3535
auto index_type = field->getIndexType();
36-
if (index_type == IndexType::String) {
37-
auto s = std::static_pointer_cast<StringIndexValue>(field);
36+
if (index_type == model::IndexType::String) {
37+
auto s = std::static_pointer_cast<model::StringIndexValue>(field);
3838
boost::json::string str_val{s->GetValue()};
3939
indexFields.emplace(key, std::move(str_val));
40-
} else if (index_type == IndexType::Int) {
41-
auto s = std::static_pointer_cast<IntIndexValue>(field);
40+
} else if (index_type == model::IndexType::Int) {
41+
auto s = std::static_pointer_cast<model::IntIndexValue>(field);
4242
indexFields.emplace(key, s->GetValue());
43-
} else if (index_type == IndexType::Bool) {
44-
auto s = std::static_pointer_cast<BooleanIndexValue>(field);
43+
} else if (index_type == model::IndexType::Bool) {
44+
auto s = std::static_pointer_cast<model::BooleanIndexValue>(field);
4545
indexFields.emplace(key, s->GetValue());
46-
} else if (index_type == IndexType::Heretile) {
47-
auto s = std::static_pointer_cast<HereTileIndexValue>(field);
46+
} else if (index_type == model::IndexType::Heretile) {
47+
auto s = std::static_pointer_cast<model::HereTileIndexValue>(field);
4848
indexFields.emplace(key, s->GetValue());
49-
} else if (index_type == IndexType::TimeWindow) {
50-
auto s = std::static_pointer_cast<TimeWindowIndexValue>(field);
49+
} else if (index_type == model::IndexType::TimeWindow) {
50+
auto s = std::static_pointer_cast<model::TimeWindowIndexValue>(field);
5151
indexFields.emplace(key, s->GetValue());
5252
}
5353
}

olp-cpp-sdk-dataservice-write/src/generated/serializer/UpdateIndexRequestSerializer.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,25 @@ void to_json(const dataservice::write::model::UpdateIndexRequest &x,
3131

3232
boost::json::object indexFields;
3333
for (const auto &field_pair : addition.GetIndexFields()) {
34-
using namespace dataservice::write::model;
34+
namespace model = dataservice::write::model;
3535
const auto &field = field_pair.second;
3636
const auto &key = field_pair.first;
3737
auto index_type = field->getIndexType();
38-
if (index_type == IndexType::String) {
39-
auto s = std::static_pointer_cast<StringIndexValue>(field);
38+
if (index_type == model::IndexType::String) {
39+
auto s = std::static_pointer_cast<model::StringIndexValue>(field);
4040
boost::json::value str_val{s->GetValue()};
4141
indexFields.emplace(key, std::move(str_val));
42-
} else if (index_type == IndexType::Int) {
43-
auto s = std::static_pointer_cast<IntIndexValue>(field);
42+
} else if (index_type == model::IndexType::Int) {
43+
auto s = std::static_pointer_cast<model::IntIndexValue>(field);
4444
indexFields.emplace(key, s->GetValue());
45-
} else if (index_type == IndexType::Bool) {
46-
auto s = std::static_pointer_cast<BooleanIndexValue>(field);
45+
} else if (index_type == model::IndexType::Bool) {
46+
auto s = std::static_pointer_cast<model::BooleanIndexValue>(field);
4747
indexFields.emplace(key, s->GetValue());
48-
} else if (index_type == IndexType::Heretile) {
49-
auto s = std::static_pointer_cast<HereTileIndexValue>(field);
48+
} else if (index_type == model::IndexType::Heretile) {
49+
auto s = std::static_pointer_cast<model::HereTileIndexValue>(field);
5050
indexFields.emplace(key, s->GetValue());
51-
} else if (index_type == IndexType::TimeWindow) {
52-
auto s = std::static_pointer_cast<TimeWindowIndexValue>(field);
51+
} else if (index_type == model::IndexType::TimeWindow) {
52+
auto s = std::static_pointer_cast<model::TimeWindowIndexValue>(field);
5353
indexFields.emplace(key, s->GetValue());
5454
}
5555
}

0 commit comments

Comments
 (0)