Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ endif()
option(OLP_SDK_ENABLE_TESTING "Flag to enable/disable building unit and integration tests" ON)
option(OLP_SDK_BUILD_DOC "Build SDK documentation" OFF)
option(OLP_SDK_NO_EXCEPTION "Disable exception handling" OFF)
option(OLP_SDK_FORCE_BOOST_OPTIONAL "Use boost::optional instead of std::optional with C++17 and above" OFF)
option(OLP_SDK_BOOST_THROW_EXCEPTION_EXTERNAL "The boost::throw_exception() is defined externally" OFF)
option(OLP_SDK_BUILD_EXTERNAL_DEPS "Download and build external dependencies" ON)
option(OLP_SDK_BUILD_EXAMPLES "Enable examples targets" OFF)
Expand Down
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,13 @@ inline PublishDataRequest& WithLayerId(std::string&& layer_id) {

#### API optional parameters

The SDK uses `boost::optional` for optional members, parameters, or return types. Also, function comments should indicate whether the parameter is optional or required.
The SDK uses `porting::optional` mapped to either `boost::optional` or `std::optional` for optional members,
parameters, or return types. Also, function comments should indicate whether the parameter is optional or required.

Example:

```cpp
inline const boost::optional<std::string>& GetBillingTag() const {
inline const porting::optional<std::string>& GetBillingTag() const {
return billing_tag_;
}

Expand Down
1 change: 1 addition & 0 deletions docs/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ cmake --build . --target docs
| `OLP_SDK_ENABLE_TESTING` | Defaults to `ON`. If enabled, unit tests are built for each library. |
| `OLP_SDK_BUILD_EXTERNAL_DEPS` | Defaults to `ON`. If enabled, CMake downloads and compiles dependencies. |
| `OLP_SDK_NO_EXCEPTION` | Defaults to `OFF`. If enabled, all libraries are built without exceptions. |
| `OLP_SDK_FORCE_BOOST_OPTIONAL` | Defaults to `OFF`. If enabled, all libraries are built with boost::optional type even when std::optional is available. |
| `OLP_SDK_BOOST_THROW_EXCEPTION_EXTERNAL` | Defaults to `OFF`. When `OLP_SDK_NO_EXCEPTION` is `ON`, `boost` requires `boost::throw_exception()` to be defined. If enabled, the external definition of `boost::throw_exception()` is used. Otherwise, the library uses own definition. |
| `OLP_SDK_MSVC_PARALLEL_BUILD_ENABLE` (Windows Only) | Defaults to `ON`. If enabled, the `/MP` compilation flag is added to build the Data SDK using multiple cores. |
| `OLP_SDK_DISABLE_DEBUG_LOGGING`| Defaults to `OFF`. If enabled, the debug and trace level log messages are not printed. |
Expand Down
2 changes: 1 addition & 1 deletion external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ if(OLP_SDK_ENABLE_DEFAULT_CACHE_LMDB)
endif()
endif()

find_package(Boost QUIET)
find_package(Boost 1.82.0 QUIET)
if(NOT TARGET Boost AND NOT Boost_FOUND)
add_subdirectory(boost)
set(BOOST_ROOT ${EXTERNAL_BOOST_ROOT} PARENT_SCOPE)
Expand Down
6 changes: 6 additions & 0 deletions olp-cpp-sdk-core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ set(OLP_SDK_PORTING_HEADERS
./include/olp/core/porting/deprecated.h
./include/olp/core/porting/export.h
./include/olp/core/porting/make_unique.h
./include/olp/core/porting/optional.hpp
./include/olp/core/porting/platform.h
./include/olp/core/porting/shared_mutex.h
./include/olp/core/porting/try_emplace.h
Expand Down Expand Up @@ -439,6 +440,11 @@ if (OLP_SDK_NO_EXCEPTION AND NOT OLP_SDK_BOOST_THROW_EXCEPTION_EXTERNAL)
PRIVATE OLP_SDK_BOOST_THROW_EXCEPTION=1)
endif()

if (OLP_SDK_FORCE_BOOST_OPTIONAL)
target_compile_definitions(${PROJECT_NAME}
PUBLIC OLP_CPP_SDK_USE_BOOST_OPTIONAL)
endif()

target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
Expand Down
8 changes: 3 additions & 5 deletions olp-cpp-sdk-core/include/olp/core/cache/CacheSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@

#include <olp/core/Config.h>
#include <olp/core/CoreApi.h>

#include <olp/core/porting/deprecated.h>
#include <boost/optional.hpp>
#include <olp/core/porting/optional.hpp>

namespace olp {
namespace cache {
Expand Down Expand Up @@ -72,7 +70,7 @@ struct CORE_API CacheSettings {
* If this parameter is not set, the downloaded data is stored
* only in the memory cache that is limited by `#max_memory_cache_size`.
*/
boost::optional<std::string> disk_path_mutable = boost::none;
porting::optional<std::string> disk_path_mutable = porting::none;

/**
* @brief Sets the upper limit (in bytes) of the disk space that is used for
Expand Down Expand Up @@ -161,7 +159,7 @@ struct CORE_API CacheSettings {
* have a stable fallback state or offline data that you can always access
* regardless of the network state.
*/
boost::optional<std::string> disk_path_protected = boost::none;
porting::optional<std::string> disk_path_protected = porting::none;

/**
* @brief The extend permissions flag (applicable for Unix systems).
Expand Down
9 changes: 4 additions & 5 deletions olp-cpp-sdk-core/include/olp/core/cache/KeyGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
#include <string>

#include <olp/core/CoreApi.h>
#include <olp/core/client/HRN.h>
#include <olp/core/geo/tiling/TileKey.h>
#include <boost/optional.hpp>
#include <olp/core/porting/optional.hpp>

namespace olp {
namespace cache {
Expand Down Expand Up @@ -77,7 +76,7 @@ class CORE_API KeyGenerator {
*/
static std::string CreatePartitionKey(
const std::string& hrn, const std::string& layer_id,
const std::string& partition_id, const boost::optional<int64_t>& version);
const std::string& partition_id, const porting::optional<int64_t>& version);

/**
* @brief Generates cache key for storing list of partitions.
Expand All @@ -90,7 +89,7 @@ class CORE_API KeyGenerator {
*/
static std::string CreatePartitionsKey(
const std::string& hrn, const std::string& layer_id,
const boost::optional<int64_t>& version);
const porting::optional<int64_t>& version);

/**
* @brief Generates cache key for storing list of available layer versions.
Expand All @@ -117,7 +116,7 @@ class CORE_API KeyGenerator {
static std::string CreateQuadTreeKey(const std::string& hrn,
const std::string& layer_id,
olp::geo::TileKey root,
const boost::optional<int64_t>& version,
const porting::optional<int64_t>& version,
int32_t depth);

/**
Expand Down
14 changes: 7 additions & 7 deletions olp-cpp-sdk-core/include/olp/core/client/OlpClientSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,14 @@
#include <memory>
#include <string>

#include <boost/optional.hpp>

#include <olp/core/client/CancellationContext.h>
#include <olp/core/client/CancellationToken.h>
#include <olp/core/client/DefaultLookupEndpointProvider.h>
#include <olp/core/client/HRN.h>
#include <olp/core/client/HttpResponse.h>
#include <olp/core/client/OauthToken.h>
#include <olp/core/client/RetrySettings.h>
#include <olp/core/http/Network.h>
#include <olp/core/porting/optional.hpp>

namespace olp {
namespace cache {
Expand Down Expand Up @@ -191,16 +189,18 @@ struct CORE_API OlpClientSettings {
/**
* @brief The network proxy settings.
*
* To remove any existing proxy settings, set to `boost::none`.
* To remove any existing proxy settings, set to `olp::porting::none`.
*/
boost::optional<http::NetworkProxySettings> proxy_settings = boost::none;
porting::optional<http::NetworkProxySettings> proxy_settings = porting::none;

/**
* @brief The authentication settings.
*
* To remove any existing authentication settings, set to `boost::none`.
* To remove any existing authentication settings, set to
* `olp::porting::none`.
*/
boost::optional<AuthenticationSettings> authentication_settings = boost::none;
porting::optional<AuthenticationSettings> authentication_settings =
porting::none;

/**
* @brief The `TaskScheduler` instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#include <memory>
#include <string>

#include <boost/optional.hpp>

#include "olp/core/CoreApi.h"
#include "olp/core/http/Network.h"
#include "olp/core/http/NetworkInitializationSettings.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include <string>
#include <vector>

#include <olp/core/porting/optional.hpp>
#include <rapidjson/rapidjson.h>
#include <boost/optional.hpp>

namespace olp {
namespace parser {
Expand Down Expand Up @@ -57,7 +57,7 @@ inline void from_json(const rapidjson::Value& value,
}

template <typename T>
inline void from_json(const rapidjson::Value& value, boost::optional<T>& x) {
inline void from_json(const rapidjson::Value& value, porting::optional<T>& x) {
T result = T();
from_json(value, result);
x = result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <vector>
#include <utility>

#include <boost/optional.hpp>
#include <olp/core/porting/optional.hpp>
#include <rapidjson/document.h>

namespace olp {
Expand Down Expand Up @@ -63,10 +63,10 @@ inline void to_json(const std::shared_ptr<std::vector<unsigned char>>& x,
}

template <typename T>
inline void to_json(const boost::optional<T>& x, rapidjson::Value& value,
inline void to_json(const porting::optional<T>& x, rapidjson::Value& value,
rapidjson::Document::AllocatorType& allocator) {
if (x) {
to_json(x.get(), value, allocator);
to_json(*x, value, allocator);
} else {
value.SetNull();
}
Expand Down
6 changes: 3 additions & 3 deletions olp-cpp-sdk-core/include/olp/core/geo/tiling/PathTiling.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <olp/core/geo/coordinates/GeoCoordinates.h>
#include <olp/core/geo/tiling/TileKey.h>
#include <olp/core/geo/tiling/TileKeyUtils.h>
#include <boost/optional/optional.hpp>
#include <olp/core/porting/optional.hpp>

namespace olp {
namespace geo {
Expand Down Expand Up @@ -378,7 +378,7 @@ class LineSliceIterator {

LineSliceIterator& operator++() {
if (!line_state_ || !detail::LineEvaluator::Iterate(*line_state_)) {
line_state_ = boost::none;
line_state_ = porting::none;
++segment_it_;
}
return *this;
Expand All @@ -397,7 +397,7 @@ class LineSliceIterator {
private:
InputIterator segment_it_;
int32_t half_line_width_;
boost::optional<detail::LineEvaluator::State> line_state_;
porting::optional<detail::LineEvaluator::State> line_state_;
};

/**
Expand Down
11 changes: 5 additions & 6 deletions olp-cpp-sdk-core/include/olp/core/geo/tiling/TileKey.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
#include <cstdint>
#include <string>

#include <boost/optional.hpp>

#include <olp/core/CoreApi.h>
#include <olp/core/porting/optional.hpp>

namespace olp {
namespace geo {
Expand Down Expand Up @@ -66,7 +65,7 @@ class CORE_API TileKey {
enum { MaxLevel = LevelCount - 1 };

/**
* @brief The main direction used to find a child node or
* @brief The main direction used to find a child node or
* the relationship to the parent.
*
* Corresponds directly to the index in the `GetChild` function.
Expand Down Expand Up @@ -504,7 +503,7 @@ using TileKeyLevels = std::bitset<TileKey::LevelCount>;
*
* @return The minimum level or `core::None` if the set is empty.
*/
CORE_API boost::optional<std::uint32_t> GetMinTileKeyLevel(
CORE_API porting::optional<std::uint32_t> GetMinTileKeyLevel(
const TileKeyLevels& levels);

/**
Expand All @@ -514,7 +513,7 @@ CORE_API boost::optional<std::uint32_t> GetMinTileKeyLevel(
*
* @return The maximum level or `core::None` if the set is empty.
*/
CORE_API boost::optional<std::uint32_t> GetMaxTileKeyLevel(
CORE_API porting::optional<std::uint32_t> GetMaxTileKeyLevel(
const TileKeyLevels& levels);

/**
Expand All @@ -526,7 +525,7 @@ CORE_API boost::optional<std::uint32_t> GetMaxTileKeyLevel(
*
* @return The nearest level or `core::None` if the set is empty.
*/
CORE_API boost::optional<std::uint32_t> GetNearestAvailableTileKeyLevel(
CORE_API porting::optional<std::uint32_t> GetNearestAvailableTileKeyLevel(
const TileKeyLevels& levels, const std::uint32_t reference_level);

/**
Expand Down
7 changes: 3 additions & 4 deletions olp-cpp-sdk-core/include/olp/core/http/NetworkResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
#include <chrono>
#include <string>

#include <boost/optional/optional.hpp>

#include <olp/core/CoreApi.h>
#include <olp/core/http/NetworkTypes.h>
#include <olp/core/porting/optional.hpp>

namespace olp {
namespace http {
Expand Down Expand Up @@ -162,7 +161,7 @@ class CORE_API NetworkResponse final {
*
* @return Diagnostic values.
*/
const boost::optional<Diagnostics>& GetDiagnostics() const;
const porting::optional<Diagnostics>& GetDiagnostics() const;

/**
* @brief Sets the request diagnostics.
Expand All @@ -185,7 +184,7 @@ class CORE_API NetworkResponse final {
/// The number of bytes downloaded during the network request.
uint64_t bytes_downloaded_{0};
/// Diagnostics
boost::optional<Diagnostics> diagnostics_;
porting::optional<Diagnostics> diagnostics_;
};

} // namespace http
Expand Down
Loading
Loading