diff options
| author | Markus Mittendrein <git@maxmitti.tk> | 2019-03-20 17:47:51 +0100 |
|---|---|---|
| committer | Markus Mittendrein <git@maxmitti.tk> | 2019-03-20 17:47:51 +0100 |
| commit | afaebd0407af3f88dfa9c46b74754a1d96f92ab5 (patch) | |
| tree | b67d7985362711f1c73e48f4551b5ccb7c0730f3 /src/cppc4group.hpp | |
| parent | bca1c49cf8aad47f5c1ecc2ba4f92f51115d7329 (diff) | |
| download | cc4group-afaebd0407af3f88dfa9c46b74754a1d96f92ab5.tar.gz cc4group-afaebd0407af3f88dfa9c46b74754a1d96f92ab5.zip | |
Add openAsChild, currently without writing support
Diffstat (limited to 'src/cppc4group.hpp')
| -rw-r--r-- | src/cppc4group.hpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/cppc4group.hpp b/src/cppc4group.hpp index a1bb28a..c30af44 100644 --- a/src/cppc4group.hpp +++ b/src/cppc4group.hpp @@ -5,7 +5,7 @@ // although, when dealing with raw memory (because cc4group can't know the type of the stored data) also users of this wrapper have to deal with some void* // because most methods behave exactly the same, please look at cc4group.h for their description (they are named exactly the same with a few exceptions) // in case their are real differences, they will be noted in this header also -// until now, all examples only use cc4group's C-API, but as a C++-programmer you should have no problems reading them anyway +// until now, all except one example only use cc4group's C-API, but as a C++-programmer you should have no problems reading them anyway // one general difference to the C-API that is not mentioned at the individual methods is that functions actually returning data return an std::optional instead of a bool... // ...the optional will be populated normally and empty in error cases @@ -22,6 +22,9 @@ class CppC4Group { std::unique_ptr<Private> p; + // this is only needed for internal purposes + CppC4Group(std::unique_ptr<Private>&& p); + public: // this struct is used for the getEntryData-method to return them in a uniform way (instead of using reference- or pointer-arguments) struct Data { @@ -100,6 +103,9 @@ public: // the constructor will automatically construct an internal CC4Group, so no new-equivalent method is needed CppC4Group(); + // the move constructor is needed to move the returned group out of the optional from openAsChild + CppC4Group(CppC4Group&& other); + // the destructor will automatically delete the internal CC4Group, so also no extra method needed ~CppC4Group(); @@ -138,4 +144,7 @@ public: bool createFile(const std::string& path); bool setEntryData(const std::string& path, const void* const data = nullptr, const size_t size = 0, const MemoryManagement management = Copy); + + // to get the child group out of the optional in case of success, construct a new CppC4Group with the move constructor: CppC4Group child{std::move(*optionalChild)}; + std::optional<CppC4Group> openAsChild(const std::string& path); }; |
