Skip to content

Commit 382e9cf

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 e0ce5a8 commit 382e9cf

2 files changed

Lines changed: 18 additions & 16 deletions

File tree

  • olp-cpp-sdk-dataservice-read/include/olp/dataservice/read
  • olp-cpp-sdk-dataservice-write/include/olp/dataservice/write/generated/model

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class DATASERVICE_READ_API CatalogRequest final {
4646
* @return The `BillingTag` string or `olp::porting::none` if the billing tag
4747
* is not set.
4848
*/
49-
inline const olp::porting::optional<std::string>& GetBillingTag() const {
49+
const olp::porting::optional<std::string>& GetBillingTag() const {
5050
return billing_tag_;
5151
}
5252

@@ -59,7 +59,7 @@ class DATASERVICE_READ_API CatalogRequest final {
5959
*
6060
* @return A reference to the updated `CatalogRequest` instance.
6161
*/
62-
inline CatalogRequest& WithBillingTag(olp::porting::optional<std::string> tag) {
62+
CatalogRequest& WithBillingTag(porting::optional<std::string> tag) {
6363
billing_tag_ = std::move(tag);
6464
return *this;
6565
}
@@ -74,7 +74,7 @@ class DATASERVICE_READ_API CatalogRequest final {
7474
*
7575
* @return A reference to the updated `CatalogRequest` instance.
7676
*/
77-
inline CatalogRequest& WithBillingTag(std::string&& tag) {
77+
CatalogRequest& WithBillingTag(std::string&& tag) {
7878
billing_tag_ = std::move(tag);
7979
return *this;
8080
}
@@ -87,7 +87,7 @@ class DATASERVICE_READ_API CatalogRequest final {
8787
*
8888
* @return The fetch option.
8989
*/
90-
inline FetchOptions GetFetchOption() const { return fetch_option_; }
90+
FetchOptions GetFetchOption() const { return fetch_option_; }
9191

9292
/**
9393
* @brief Sets the fetch option that you can use to set the source from
@@ -99,7 +99,7 @@ class DATASERVICE_READ_API CatalogRequest final {
9999
*
100100
* @return A reference to the updated `CatalogVersionRequest` instance.
101101
*/
102-
inline CatalogRequest& WithFetchOption(FetchOptions fetch_option) {
102+
CatalogRequest& WithFetchOption(const FetchOptions fetch_option) {
103103
fetch_option_ = fetch_option;
104104
return *this;
105105
}
@@ -109,7 +109,7 @@ class DATASERVICE_READ_API CatalogRequest final {
109109
*
110110
* @return A string representation of the request.
111111
*/
112-
inline std::string CreateKey() const {
112+
std::string CreateKey() const {
113113
std::stringstream out;
114114
if (GetBillingTag()) {
115115
out << "$" << *GetBillingTag();
@@ -119,7 +119,7 @@ class DATASERVICE_READ_API CatalogRequest final {
119119
}
120120

121121
private:
122-
olp::porting::optional<std::string> billing_tag_;
122+
porting::optional<std::string> billing_tag_;
123123
FetchOptions fetch_option_{OnlineIfNotFound};
124124
};
125125

olp-cpp-sdk-dataservice-write/include/olp/dataservice/write/generated/model/Index.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,9 @@ class DATASERVICE_WRITE_API Index final {
324324
: id_(std::move(uuid)), indexFields_(std::move(indexFields)) {}
325325

326326
private:
327-
olp::porting::optional<std::string> checksum_;
328-
olp::porting::optional<std::map<std::string, std::string>> metadata_;
329-
olp::porting::optional<int64_t> size_;
327+
porting::optional<std::string> checksum_;
328+
porting::optional<std::map<std::string, std::string>> metadata_;
329+
porting::optional<int64_t> size_;
330330
std::string id_;
331331
std::map<IndexName, std::shared_ptr<IndexValue>> indexFields_;
332332

@@ -336,14 +336,16 @@ class DATASERVICE_WRITE_API Index final {
336336
*
337337
* @return The checksum.
338338
*/
339-
const olp::porting::optional<std::string>& GetCheckSum() const { return checksum_; }
339+
const porting::optional<std::string>& GetCheckSum() const {
340+
return checksum_;
341+
}
340342

341343
/**
342344
* @brief Gets a mutable reference to the checksum of the index layer.
343345
*
344346
* @return The mutable reference to the checksum.
345347
*/
346-
olp::porting::optional<std::string>& GetMutableCheckSum() { return checksum_; }
348+
porting::optional<std::string>& GetMutableCheckSum() { return checksum_; }
347349

348350
/**
349351
* @brief Sets the checksum.
@@ -357,7 +359,7 @@ class DATASERVICE_WRITE_API Index final {
357359
*
358360
* @return The metadata of the index layer.
359361
*/
360-
const olp::porting::optional<std::map<std::string, std::string>>& GetMetadata()
362+
const porting::optional<std::map<std::string, std::string>>& GetMetadata()
361363
const {
362364
return metadata_;
363365
}
@@ -367,7 +369,7 @@ class DATASERVICE_WRITE_API Index final {
367369
*
368370
* @return The mutable reference to the metadata.
369371
*/
370-
olp::porting::optional<std::map<std::string, std::string>>& GetMutableMetadata() {
372+
porting::optional<std::map<std::string, std::string>>& GetMutableMetadata() {
371373
return metadata_;
372374
}
373375

@@ -435,14 +437,14 @@ class DATASERVICE_WRITE_API Index final {
435437
*
436438
* @return The size of the index layer.
437439
*/
438-
const olp::porting::optional<int64_t>& GetSize() const { return size_; }
440+
const porting::optional<int64_t>& GetSize() const { return size_; }
439441

440442
/**
441443
* @brief Gets a mutable reference to the size of the index layer.
442444
*
443445
* @return The mutable reference to the size of the index layer.
444446
*/
445-
olp::porting::optional<int64_t>& GetMutableSize() { return size_; }
447+
porting::optional<int64_t>& GetMutableSize() { return size_; }
446448

447449
/**
448450
* @brief Sets the size of the index layer.

0 commit comments

Comments
 (0)