-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathCatalogParser.cpp
More file actions
130 lines (111 loc) · 5.12 KB
/
CatalogParser.cpp
File metadata and controls
130 lines (111 loc) · 5.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
* Copyright (C) 2019-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
* License-Filename: LICENSE
*/
#include "CatalogParser.h"
#include <vector>
#include <generated/parser/ParserWrapper.h>
namespace olp {
namespace parser {
namespace model = olp::dataservice::write::model;
void from_json(const boost::json::value& value, model::Coverage& x) {
x.SetAdminAreas(parse<std::vector<std::string> >(value, "adminAreas"));
}
void from_json(const boost::json::value& value, model::IndexDefinition& x) {
x.SetName(parse<std::string>(value, "name"));
x.SetType(parse<std::string>(value, "type"));
x.SetDuration(parse<int64_t>(value, "duration"));
x.SetZoomLevel(parse<int64_t>(value, "zoomLevel"));
}
void from_json(const boost::json::value& value, model::IndexProperties& x) {
x.SetTtl(parse<std::string>(value, "ttl"));
x.SetIndexDefinitions(
parse<std::vector<model::IndexDefinition> >(value, "indexDefinitions"));
}
void from_json(const boost::json::value& value, model::Creator& x) {
x.SetId(parse<std::string>(value, "id"));
}
void from_json(const boost::json::value& value, model::Owner& x) {
x.SetCreator(parse<model::Creator>(value, "creator"));
x.SetOrganisation(parse<model::Creator>(value, "organisation"));
}
void from_json(const boost::json::value& value, model::Partitioning& x) {
x.SetScheme(parse<std::string>(value, "scheme"));
x.SetTileLevels(parse<std::vector<int64_t> >(value, "tileLevels"));
}
void from_json(const boost::json::value& value, model::Schema& x) {
x.SetHrn(parse<std::string>(value, "hrn"));
}
void from_json(const boost::json::value& value, model::StreamProperties& x) {
// Parsing these as double even though OepnAPI sepcs says int64 because
// Backend returns the value in decimal format (e.g. 1.0) and this triggers an
// assert in RapidJSON when parsing.
x.SetDataInThroughputMbps(
static_cast<int64_t>(parse<double>(value, "dataInThroughputMbps")));
x.SetDataOutThroughputMbps(
static_cast<int64_t>(parse<double>(value, "dataOutThroughputMbps")));
}
void from_json(const boost::json::value& value, model::Encryption& x) {
x.SetAlgorithm(parse<std::string>(value, "algorithm"));
}
void from_json(const boost::json::value& value, model::Volume& x) {
x.SetVolumeType(parse<std::string>(value, "volumeType"));
x.SetMaxMemoryPolicy(parse<std::string>(value, "maxMemoryPolicy"));
x.SetPackageType(parse<std::string>(value, "packageType"));
x.SetEncryption(parse<model::Encryption>(value, "encryption"));
}
void from_json(const boost::json::value& value, model::Layer& x) {
x.SetId(parse<std::string>(value, "id"));
x.SetName(parse<std::string>(value, "name"));
x.SetSummary(parse<std::string>(value, "summary"));
x.SetDescription(parse<std::string>(value, "description"));
x.SetOwner(parse<model::Owner>(value, "owner"));
x.SetCoverage(parse<model::Coverage>(value, "coverage"));
x.SetSchema(parse<model::Schema>(value, "schema"));
x.SetContentType(parse<std::string>(value, "contentType"));
x.SetContentEncoding(parse<std::string>(value, "contentEncoding"));
x.SetPartitioning(parse<model::Partitioning>(value, "partitioning"));
x.SetLayerType(parse<std::string>(value, "layerType"));
x.SetDigest(parse<std::string>(value, "digest"));
x.SetTags(parse<std::vector<std::string> >(value, "tags"));
x.SetBillingTags(parse<std::vector<std::string> >(value, "billingTags"));
x.SetTtl(parse<int64_t>(value, "ttl"));
x.SetIndexProperties(parse<model::IndexProperties>(value, "indexProperties"));
x.SetStreamProperties(
parse<model::StreamProperties>(value, "streamProperties"));
x.SetVolume(parse<model::Volume>(value, "volume"));
}
void from_json(const boost::json::value& value, model::Notifications& x) {
x.SetEnabled(parse<bool>(value, "enabled"));
}
void from_json(const boost::json::value& value, model::Catalog& x) {
x.SetId(parse<std::string>(value, "id"));
x.SetHrn(parse<std::string>(value, "hrn"));
x.SetName(parse<std::string>(value, "name"));
x.SetSummary(parse<std::string>(value, "summary"));
x.SetDescription(parse<std::string>(value, "description"));
x.SetCoverage(parse<model::Coverage>(value, "coverage"));
x.SetOwner(parse<model::Owner>(value, "owner"));
x.SetTags(parse<std::vector<std::string> >(value, "tags"));
x.SetBillingTags(parse<std::vector<std::string> >(value, "billingTags"));
x.SetCreated(parse<std::string>(value, "created"));
x.SetLayers(parse<std::vector<model::Layer> >(value, "layers"));
x.SetVersion(parse<int64_t>(value, "version"));
x.SetNotifications(parse<model::Notifications>(value, "notifications"));
}
} // namespace parser
} // namespace olp