summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2018-08-13 16:29:14 -0700
committerKonstantin Käfer <mail@kkaefer.com>2018-08-14 17:03:46 -0700
commit6e06e55b95fdb9070d32d44786441255871dbb0b (patch)
treed9e074da720f8339966c99ded803f4f59a83b68e /include
parent89515de769aea0b54a800514f7deaf65649d9d54 (diff)
downloadqtlocation-mapboxgl-6e06e55b95fdb9070d32d44786441255871dbb0b.tar.gz
WIP: use expected<T, E> for passing on errors
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/storage/default_file_source.hpp15
-rw-r--r--include/mbgl/storage/offline.hpp2
2 files changed, 9 insertions, 8 deletions
diff --git a/include/mbgl/storage/default_file_source.hpp b/include/mbgl/storage/default_file_source.hpp
index b9c8de5052..e048d82af2 100644
--- a/include/mbgl/storage/default_file_source.hpp
+++ b/include/mbgl/storage/default_file_source.hpp
@@ -5,6 +5,7 @@
#include <mbgl/storage/offline.hpp>
#include <mbgl/util/constants.hpp>
#include <mbgl/util/optional.hpp>
+#include <mbgl/util/expected.hpp>
#include <vector>
#include <mutex>
@@ -55,8 +56,7 @@ public:
* callback, which will be executed on the database thread; it is the responsibility
* of the SDK bindings to re-execute a user-provided callback on the main thread.
*/
- void listOfflineRegions(std::function<void (std::exception_ptr,
- optional<std::vector<OfflineRegion>>)>);
+ void listOfflineRegions(std::function<void (expected<OfflineRegions, std::exception_ptr>)>);
/*
* Create an offline region in the database.
@@ -71,16 +71,14 @@ public:
*/
void createOfflineRegion(const OfflineRegionDefinition& definition,
const OfflineRegionMetadata& metadata,
- std::function<void (std::exception_ptr,
- optional<OfflineRegion>)>);
+ std::function<void (expected<OfflineRegion, std::exception_ptr>)>);
/*
* Update an offline region metadata in the database.
*/
void updateOfflineMetadata(const int64_t regionID,
const OfflineRegionMetadata& metadata,
- std::function<void (std::exception_ptr,
- optional<OfflineRegionMetadata>)>);
+ std::function<void (expected<OfflineRegionMetadata, std::exception_ptr>)>);
/*
* Register an observer to be notified when the state of the region changes.
*/
@@ -97,8 +95,9 @@ public:
* executed on the database thread; it is the responsibility of the SDK bindings
* to re-execute a user-provided callback on the main thread.
*/
- void getOfflineRegionStatus(OfflineRegion&, std::function<void (std::exception_ptr,
- optional<OfflineRegionStatus>)>) const;
+ void getOfflineRegionStatus(
+ OfflineRegion&,
+ std::function<void (expected<OfflineRegionStatus, std::exception_ptr>)>) const;
/*
* Remove an offline region from the database and perform any resources evictions
diff --git a/include/mbgl/storage/offline.hpp b/include/mbgl/storage/offline.hpp
index 2193f8d09e..62353446fa 100644
--- a/include/mbgl/storage/offline.hpp
+++ b/include/mbgl/storage/offline.hpp
@@ -210,4 +210,6 @@ private:
const OfflineRegionMetadata metadata;
};
+using OfflineRegions = std::vector<OfflineRegion>;
+
} // namespace mbgl