Skip to content

Commit e0ce5a8

Browse files
committed
Use std::optional if available.
Currently, SDK requires C++11 minimum. So, boost::optional type is used for optional values. For C++17 and above more convenient is to use std::optional instead. This PR makes the optional type used configurable. Suppress Linter complains. Relates-To: NLAM-23 Signed-off-by: sopov <ext-alexander.sopov@here.com>
1 parent f6dbff1 commit e0ce5a8

13 files changed

Lines changed: 149 additions & 146 deletions

File tree

olp-cpp-sdk-dataservice-read/include/olp/dataservice/read/CatalogRequest.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ class DATASERVICE_READ_API CatalogRequest final {
4343
* billing records together. If supplied, it must be 4–16 characters
4444
* long and contain only alphanumeric ASCII characters [A-Za-z0-9].
4545
*
46-
* @return The `BillingTag` string or `olp::porting::none` if the billing tag is not
47-
* set.
46+
* @return The `BillingTag` string or `olp::porting::none` if the billing tag
47+
* is not set.
4848
*/
4949
inline const olp::porting::optional<std::string>& GetBillingTag() const {
5050
return billing_tag_;

olp-cpp-sdk-dataservice-read/include/olp/dataservice/read/PartitionsRequest.h

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class DATASERVICE_READ_API PartitionsRequest final {
6969
*
7070
* @return A reference to the updated `PartitionsRequest` instance.
7171
*/
72-
inline PartitionsRequest& WithPartitionIds(PartitionIds partition_ids) {
72+
PartitionsRequest& WithPartitionIds(PartitionIds partition_ids) {
7373
partition_ids_ = std::move(partition_ids);
7474
return *this;
7575
}
@@ -79,7 +79,7 @@ class DATASERVICE_READ_API PartitionsRequest final {
7979
*
8080
* @return The vector of strings that represent partitions.
8181
*/
82-
inline const PartitionIds& GetPartitionIds() const { return partition_ids_; }
82+
const PartitionIds& GetPartitionIds() const { return partition_ids_; }
8383

8484
/**
8585
* @brief Sets the list of additional fields.
@@ -95,8 +95,7 @@ class DATASERVICE_READ_API PartitionsRequest final {
9595
*
9696
* @return A reference to the updated `PartitionsRequest` instance.
9797
*/
98-
inline PartitionsRequest& WithAdditionalFields(
99-
AdditionalFields additional_fields) {
98+
PartitionsRequest& WithAdditionalFields(AdditionalFields additional_fields) {
10099
additional_fields_ = std::move(additional_fields);
101100
return *this;
102101
}
@@ -106,7 +105,7 @@ class DATASERVICE_READ_API PartitionsRequest final {
106105
*
107106
* @return The set of additional fields.
108107
*/
109-
inline const AdditionalFields& GetAdditionalFields() const {
108+
const AdditionalFields& GetAdditionalFields() const {
110109
return additional_fields_;
111110
}
112111

@@ -117,10 +116,10 @@ class DATASERVICE_READ_API PartitionsRequest final {
117116
* billing records together. If supplied, it must be 4–16 characters
118117
* long and contain only alphanumeric ASCII characters [A-Za-z0-9].
119118
*
120-
* @return The `BillingTag` string or `olp::porting::none` if the billing tag is not
121-
* set.
119+
* @return The `BillingTag` string or `olp::porting::none` if the billing tag
120+
* is not set.
122121
*/
123-
inline const olp::porting::optional<std::string>& GetBillingTag() const {
122+
const porting::optional<std::string>& GetBillingTag() const {
124123
return billing_tag_;
125124
}
126125

@@ -133,8 +132,7 @@ class DATASERVICE_READ_API PartitionsRequest final {
133132
*
134133
* @return A reference to the updated `PrefetchTilesRequest` instance.
135134
*/
136-
inline PartitionsRequest& WithBillingTag(
137-
olp::porting::optional<std::string> billingTag) {
135+
PartitionsRequest& WithBillingTag(porting::optional<std::string> billingTag) {
138136
billing_tag_ = std::move(billingTag);
139137
return *this;
140138
}
@@ -149,7 +147,7 @@ class DATASERVICE_READ_API PartitionsRequest final {
149147
*
150148
* @return A reference to the updated `PrefetchTilesRequest` instance.
151149
*/
152-
inline PartitionsRequest& WithBillingTag(std::string&& billingTag) {
150+
PartitionsRequest& WithBillingTag(std::string&& billingTag) {
153151
billing_tag_ = std::move(billingTag);
154152
return *this;
155153
}
@@ -162,7 +160,7 @@ class DATASERVICE_READ_API PartitionsRequest final {
162160
*
163161
* @return The fetch option.
164162
*/
165-
inline FetchOptions GetFetchOption() const { return fetch_option_; }
163+
FetchOptions GetFetchOption() const { return fetch_option_; }
166164

167165
/**
168166
* @brief Sets the fetch option that you can use to set the source from
@@ -174,7 +172,7 @@ class DATASERVICE_READ_API PartitionsRequest final {
174172
*
175173
* @return A reference to the updated `PrefetchTilesRequest` instance.
176174
*/
177-
inline PartitionsRequest& WithFetchOption(FetchOptions fetch_option) {
175+
PartitionsRequest& WithFetchOption(FetchOptions fetch_option) {
178176
fetch_option_ = fetch_option;
179177
return *this;
180178
}
@@ -187,8 +185,9 @@ class DATASERVICE_READ_API PartitionsRequest final {
187185
*
188186
* @return A string representation of the request.
189187
*/
190-
std::string CreateKey(const std::string& layer_id,
191-
olp::porting::optional<int64_t> version = olp::porting::none) const {
188+
std::string CreateKey(
189+
const std::string& layer_id,
190+
porting::optional<int64_t> version = porting::none) const {
192191
std::stringstream out;
193192
out << layer_id;
194193
if (version) {
@@ -204,7 +203,7 @@ class DATASERVICE_READ_API PartitionsRequest final {
204203
private:
205204
PartitionIds partition_ids_;
206205
AdditionalFields additional_fields_;
207-
olp::porting::optional<std::string> billing_tag_;
206+
porting::optional<std::string> billing_tag_;
208207
FetchOptions fetch_option_{OnlineIfNotFound};
209208
};
210209

olp-cpp-sdk-dataservice-read/include/olp/dataservice/read/PrefetchPartitionsRequest.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ class DATASERVICE_READ_API PrefetchPartitionsRequest final {
7474
* billing records together. If supplied, it must be 4–16 characters
7575
* long and contain only alphanumeric ASCII characters [A-Za-z0-9].
7676
*
77-
* @return The `BillingTag` string or `olp::porting::none` if the billing tag is not
78-
* set.
77+
* @return The `BillingTag` string or `olp::porting::none` if the billing tag
78+
* is not set.
7979
*/
8080
inline const olp::porting::optional<std::string>& GetBillingTag() const {
8181
return billing_tag_;
@@ -140,8 +140,9 @@ class DATASERVICE_READ_API PrefetchPartitionsRequest final {
140140
*
141141
* @return A string representation of the request.
142142
*/
143-
std::string CreateKey(const std::string& layer_id,
144-
olp::porting::optional<int64_t> version = olp::porting::none) const {
143+
std::string CreateKey(
144+
const std::string& layer_id,
145+
porting::optional<int64_t> version = porting::none) const {
145146
std::stringstream out;
146147
out << layer_id;
147148
if (version) {

olp-cpp-sdk-dataservice-read/include/olp/dataservice/read/SubscribeRequest.h

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class DATASERVICE_READ_API SubscribeRequest final {
6161
*
6262
* @return A reference to the updated `SubscribeRequest` instance.
6363
*/
64-
inline SubscribeRequest& WithSubscriptionMode(SubscriptionMode mode) {
64+
SubscribeRequest& WithSubscriptionMode(SubscriptionMode mode) {
6565
subscription_mode_ = mode;
6666
return *this;
6767
}
@@ -71,22 +71,20 @@ class DATASERVICE_READ_API SubscribeRequest final {
7171
*
7272
* @return The subscription mode.
7373
*/
74-
inline SubscriptionMode GetSubscriptionMode() const {
75-
return subscription_mode_;
76-
}
74+
SubscriptionMode GetSubscriptionMode() const { return subscription_mode_; }
7775

7876
/**
7977
* @brief (Optional) Sets the subscription ID used for the request.
8078
*
81-
* Generated by the HERE platform if missing. Must be UUID. Must be unique within
82-
* subscriptions.
79+
* Generated by the HERE platform if missing. Must be UUID. Must be unique
80+
* within subscriptions.
8381
*
8482
* @param subscription_id The subscription ID.
8583
*
8684
* @return A reference to the updated `SubscribeRequest` instance.
8785
*/
88-
inline SubscribeRequest& WithSubscriptionId(
89-
olp::porting::optional<SubscriptionId> subscription_id) {
86+
SubscribeRequest& WithSubscriptionId(
87+
porting::optional<SubscriptionId> subscription_id) {
9088
subscription_id_ = std::move(subscription_id);
9189
return *this;
9290
}
@@ -96,7 +94,7 @@ class DATASERVICE_READ_API SubscribeRequest final {
9694
*
9795
* @return The subscription ID.
9896
*/
99-
inline const olp::porting::optional<SubscriptionId>& GetSubscriptionId() const {
97+
const porting::optional<SubscriptionId>& GetSubscriptionId() const {
10098
return subscription_id_;
10199
}
102100

@@ -122,23 +120,23 @@ class DATASERVICE_READ_API SubscribeRequest final {
122120
*
123121
* @return The consumer ID.
124122
*/
125-
inline const olp::porting::optional<std::string>& GetConsumerId() const {
123+
const porting::optional<std::string>& GetConsumerId() const {
126124
return consumer_id_;
127125
}
128126

129127
/**
130128
* @brief Sets the consumer properties for the request.
131129
*
132-
* @see The [Get Data from a Stream
133-
* Layer](https://developer.here.com/documentation/data-api/data_dev_guide/rest/getting-data-stream.html)
130+
* @see The [Get Data from a Stream Layer]
131+
* (https://developer.here.com/documentation/data-api/data_dev_guide/rest/getting-data-stream.html)
134132
* section in the Data API Developer Guide.
135133
*
136134
* @param properties The consumer properties.
137135
*
138136
* @return A reference to the updated `SubscribeRequest` instance.
139137
*/
140-
inline SubscribeRequest& WithConsumerProperties(
141-
olp::porting::optional<ConsumerProperties> properties) {
138+
SubscribeRequest& WithConsumerProperties(
139+
porting::optional<ConsumerProperties> properties) {
142140
consumer_properties_ = std::move(properties);
143141
return *this;
144142
}
@@ -148,16 +146,15 @@ class DATASERVICE_READ_API SubscribeRequest final {
148146
*
149147
* @return The consumer properties.
150148
*/
151-
inline const olp::porting::optional<ConsumerProperties>& GetConsumerProperties()
152-
const {
149+
const porting::optional<ConsumerProperties>& GetConsumerProperties() const {
153150
return consumer_properties_;
154151
}
155152

156153
private:
157154
SubscriptionMode subscription_mode_{SubscriptionMode::kSerial};
158-
olp::porting::optional<SubscriptionId> subscription_id_;
159-
olp::porting::optional<std::string> consumer_id_;
160-
olp::porting::optional<ConsumerProperties> consumer_properties_;
155+
porting::optional<SubscriptionId> subscription_id_;
156+
porting::optional<std::string> consumer_id_;
157+
porting::optional<ConsumerProperties> consumer_properties_;
161158
};
162159

163160
} // namespace read

olp-cpp-sdk-dataservice-read/include/olp/dataservice/read/VersionsRequest.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class DATASERVICE_READ_API VersionsRequest final {
5151
* @return A reference to the updated `VersionsRequest` instance.
5252
*
5353
*/
54-
inline VersionsRequest& WithStartVersion(std::int64_t version) {
54+
VersionsRequest& WithStartVersion(std::int64_t version) {
5555
start_version_ = version;
5656
return *this;
5757
}
@@ -79,7 +79,7 @@ class DATASERVICE_READ_API VersionsRequest final {
7979
* @return A reference to the updated `VersionsRequest` instance.
8080
*
8181
*/
82-
inline VersionsRequest& WithEndVersion(std::int64_t version) {
82+
VersionsRequest& WithEndVersion(std::int64_t version) {
8383
end_version_ = version;
8484
return *this;
8585
}
@@ -91,7 +91,7 @@ class DATASERVICE_READ_API VersionsRequest final {
9191
* @return The catalog metadata end version.
9292
*
9393
*/
94-
inline std::int64_t GetEndVersion() const { return end_version_; }
94+
std::int64_t GetEndVersion() const { return end_version_; }
9595

9696
/**
9797
* @brief Gets the billing tag to group billing records together.
@@ -100,10 +100,10 @@ class DATASERVICE_READ_API VersionsRequest final {
100100
* billing records together. If supplied, it must be 4–16 characters
101101
* long and contain only alphanumeric ASCII characters [A-Za-z0-9].
102102
*
103-
* @return The `BillingTag` string or `olp::porting::none` if the billing tag is not
104-
* set.
103+
* @return The `BillingTag` string or `olp::porting::none` if the billing tag
104+
* is not set.
105105
*/
106-
inline const olp::porting::optional<std::string>& GetBillingTag() const {
106+
const porting::optional<std::string>& GetBillingTag() const {
107107
return billing_tag_;
108108
}
109109

@@ -116,7 +116,7 @@ class DATASERVICE_READ_API VersionsRequest final {
116116
*
117117
* @return A reference to the updated `VersionsRequest` instance.
118118
*/
119-
inline VersionsRequest& WithBillingTag(olp::porting::optional<std::string> tag) {
119+
VersionsRequest& WithBillingTag(porting::optional<std::string> tag) {
120120
billing_tag_ = std::move(tag);
121121
return *this;
122122
}
@@ -131,7 +131,7 @@ class DATASERVICE_READ_API VersionsRequest final {
131131
*
132132
* @return A reference to the updated `VersionsRequest` instance.
133133
*/
134-
inline VersionsRequest& WithBillingTag(std::string tag) {
134+
VersionsRequest& WithBillingTag(std::string tag) {
135135
billing_tag_ = std::move(tag);
136136
return *this;
137137
}
@@ -141,7 +141,7 @@ class DATASERVICE_READ_API VersionsRequest final {
141141
*
142142
* @return A string representation of the request.
143143
*/
144-
inline std::string CreateKey() const {
144+
std::string CreateKey() const {
145145
std::stringstream out;
146146
out << "[";
147147
out << GetStartVersion() << ", " << GetEndVersion();
@@ -153,9 +153,9 @@ class DATASERVICE_READ_API VersionsRequest final {
153153
}
154154

155155
private:
156-
std::int64_t start_version_;
157-
std::int64_t end_version_;
158-
olp::porting::optional<std::string> billing_tag_;
156+
std::int64_t start_version_ = -1;
157+
std::int64_t end_version_ = -1;
158+
porting::optional<std::string> billing_tag_;
159159
};
160160

161161
} // namespace read

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ class DATASERVICE_READ_API Layer {
736736
std::string digest_;
737737
std::vector<std::string> tags_;
738738
std::vector<std::string> billing_tags_;
739-
olp::porting::optional<int64_t> ttl_;
739+
porting::optional<int64_t> ttl_;
740740
IndexProperties index_properties_;
741741
StreamProperties stream_properties_;
742742
Volume volume_;
@@ -1070,7 +1070,7 @@ class DATASERVICE_READ_API Layer {
10701070
*
10711071
* @return The expiry time (in milliseconds) for data in this layer.
10721072
*/
1073-
const olp::porting::optional<int64_t>& GetTtl() const { return ttl_; }
1073+
const porting::optional<int64_t>& GetTtl() const { return ttl_; }
10741074
/**
10751075
* @brief Gets a mutable reference to the expiry time for data in this layer.
10761076
*
@@ -1079,15 +1079,15 @@ class DATASERVICE_READ_API Layer {
10791079
* @return The mutable reference to the expiry time for data in
10801080
* this layer.
10811081
*/
1082-
olp::porting::optional<int64_t>& GetMutableTtl() { return ttl_; }
1082+
porting::optional<int64_t>& GetMutableTtl() { return ttl_; }
10831083
/**
10841084
* @brief Sets the expiry time for data in this layer.
10851085
*
10861086
* @see `GetTtl` for information on the expiry time.
10871087
*
10881088
* @param value The expiry time for data in this layer.
10891089
*/
1090-
void SetTtl(const olp::porting::optional<int64_t>& value) { this->ttl_ = value; }
1090+
void SetTtl(const porting::optional<int64_t>& value) { this->ttl_ = value; }
10911091

10921092
/**
10931093
* @brief Gets the `IndexProperties` instance.

0 commit comments

Comments
 (0)