[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [ksecrets] src/runtime/ksecrets_store: All API calls should return the status along with the returne
From: Valentin Rusu <kde () rusu ! info>
Date: 2015-08-13 15:47:31
Message-ID: E1ZPuj5-00028K-2k () scm ! kde ! org
[Download RAW message or body]
Git commit e4b5b8dab07fc9b803c8b2800069c1b5bd20a267 by Valentin Rusu.
Committed on 13/08/2015 at 10:57.
Pushed by vrusu into branch 'master'.
All API calls should return the status along with the returned value
M +10 -10 src/runtime/ksecrets_store/ksecrets_store.cpp
M +29 -15 src/runtime/ksecrets_store/ksecrets_store.h
http://commits.kde.org/ksecrets/e4b5b8dab07fc9b803c8b2800069c1b5bd20a267
diff --git a/src/runtime/ksecrets_store/ksecrets_store.cpp b/src/runtime/ksecrets_store/ksecrets_store.cpp
index c3bf0d1..edeb777 100644
--- a/src/runtime/ksecrets_store/ksecrets_store.cpp
+++ b/src/runtime/ksecrets_store/ksecrets_store.cpp
@@ -201,33 +201,33 @@ KSecretsStorePrivate::SecretsFile::~SecretsFile()
}
}
-KSecretsStore::CollectionNames KSecretsStore::dirCollections() const noexcept
+KSecretsStore::DirCollectionsResult KSecretsStore::dirCollections() const noexcept
{
// TODO
- return CollectionNames();
+ return DirCollectionsResult();
}
-KSecretsStore::CollectionPtr KSecretsStore::createCollection(const char*) noexcept
+KSecretsStore::CreateCollectionResult KSecretsStore::createCollection(const char*) noexcept
{
// TODO
- return CollectionPtr();
+ return CreateCollectionResult();
}
-KSecretsStore::CollectionPtr KSecretsStore::readCollection(const char*) const noexcept
+KSecretsStore::ReadCollectionResult KSecretsStore::readCollection(const char*) const noexcept
{
// TODO
- return CollectionPtr();
+ return ReadCollectionResult();
}
-bool KSecretsStore::deleteCollection(CollectionPtr) noexcept
+KSecretsStore::DeleteCollectionResult KSecretsStore::deleteCollection(CollectionPtr) noexcept
{
// TODO
- return false;
+ return DeleteCollectionResult();
}
-bool KSecretsStore::deleteCollection(const char*) noexcept
+KSecretsStore::DeleteCollectionResult KSecretsStore::deleteCollection(const char*) noexcept
{
// TODO
- return false;
+ return DeleteCollectionResult();
}
// vim: tw=220:ts=4
diff --git a/src/runtime/ksecrets_store/ksecrets_store.h b/src/runtime/ksecrets_store/ksecrets_store.h
index bf5296d..dacdedc 100644
--- a/src/runtime/ksecrets_store/ksecrets_store.h
+++ b/src/runtime/ksecrets_store/ksecrets_store.h
@@ -106,6 +106,7 @@ public:
std::time_t createdTime() const noexcept;
std::time_t modifiedTime() const noexcept;
+
protected:
Item();
friend class KSecretsStore;
@@ -164,7 +165,7 @@ public:
* possible. So please check it via it's operator bool() before using
* it.
*/
- ItemPtr createItem(const char *label, ItemValue&&) noexcept;
+ ItemPtr createItem(const char* label, ItemValue&&) noexcept;
bool deleteItem(ItemPtr) noexcept;
@@ -215,13 +216,19 @@ public:
* It introduces a bool() operator client applications could use to check the correct
* issue of the respective API call.
*/
- template <StoreStatus G>
- struct CallResult {
+ template <StoreStatus G> struct CallResult {
StoreStatus status_;
int errno_;
operator bool() const { return status_ == G; }
};
+ /**
+ * @brief Small structure returned by API calls that create things
+ */
+ template <StoreStatus G, typename R> struct CallResultWithValue : public CallResult<G> {
+ R result_;
+ };
+
using SetupResult = CallResult<StoreStatus::Good>;
/**
@@ -233,7 +240,7 @@ public:
*
* @return SetupResult whose operator bool could be used to check the error condition
*/
- std::future<SetupResult> setup(const char* path, bool readOnly =true);
+ std::future<SetupResult> setup(const char* path, bool readOnly = true);
using CredentialsResult = CallResult<StoreStatus::CredentialsSet>;
@@ -249,22 +256,29 @@ public:
bool isGood() const noexcept;
using CollectionNames = std::vector<std::string>;
- CollectionNames dirCollections() const noexcept;
- /*
- * @return CollectionPtr which can empty if the call did not succeed.
- * Please check that with operator bool().
- * If it fails, have you already called setup()?
+ using DirCollectionsResult = CallResultWithValue<StoreStatus::Good, CollectionNames>;
+ DirCollectionsResult dirCollections() const noexcept;
+
+ using CreateCollectionResult = CallResultWithValue<StoreStatus::Good, CollectionPtr>;
+ /**
+ * @return CollectionPtr which can empty if the call did not succeed
+ * Please check that with operator bool()
+ * If it fails, have you already called setup()?
+ *
*/
- CollectionPtr createCollection(const char*) noexcept;
- /*
+ CreateCollectionResult createCollection(const char*) noexcept;
+
+ using ReadCollectionResult = CallResultWithValue<StoreStatus::Good, CollectionPtr>;
+ /**
* @return CollectionPtr which can empty if the call did not succeed, e.g.
- * the collection was not found.
+ * the collection was not found
* Please check that with operator bool()
*/
- CollectionPtr readCollection(const char*) const noexcept;
+ ReadCollectionResult readCollection(const char*) const noexcept;
- bool deleteCollection(CollectionPtr) noexcept;
- bool deleteCollection(const char*) noexcept;
+ using DeleteCollectionResult = CallResultWithValue<StoreStatus::Good, bool>;
+ DeleteCollectionResult deleteCollection(CollectionPtr) noexcept;
+ DeleteCollectionResult deleteCollection(const char*) noexcept;
private:
std::unique_ptr<KSecretsStorePrivate> d;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic