diff options
Diffstat (limited to 'src/cppc4group.hpp')
| -rw-r--r-- | src/cppc4group.hpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/cppc4group.hpp b/src/cppc4group.hpp index 420893c..7f51629 100644 --- a/src/cppc4group.hpp +++ b/src/cppc4group.hpp @@ -14,6 +14,7 @@ #include <optional> #include <cstdio> #include <functional> +#include <type_traits> class CppC4Group { // all C-related stuff is hidden from this header so it doesn't land in the precious C++-only code this might be used in... @@ -111,12 +112,18 @@ public: using WriteCallback = bool(*)(const void* const data, size_t const size, void* const arg); // these enums are just mapped to their C-counterparts internally - enum TmpMemoryStrategy { + enum class TmpMemoryStrategy { Memory, File, Auto }; + enum class AllowedEntryTypes { + File, + Directory, + All = File | Directory + }; + // use this to set one of the predefined strategies static void setTmpMemoryStrategy(const TmpMemoryStrategy strategy); @@ -167,6 +174,8 @@ public: bool deleteEntry(const std::string& path, const bool recursive = false); bool renameEntry(const std::string& oldPath, const std::string& newPath); + bool addFromDisk(const std::string& path, const std::string& targetPath, const AllowedEntryTypes allowedEntryTypes = AllowedEntryTypes::All); + bool createDirectory(const std::string& path); bool createFile(const std::string& path); @@ -176,3 +185,20 @@ public: // 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); }; + +inline bool operator&(CppC4Group::AllowedEntryTypes lhs, CppC4Group::AllowedEntryTypes rhs) +{ + using T = std::underlying_type_t <CppC4Group::AllowedEntryTypes>; + return static_cast<T>(lhs) & static_cast<T>(rhs); +} + +inline CppC4Group::AllowedEntryTypes operator|(CppC4Group::AllowedEntryTypes lhs, CppC4Group::AllowedEntryTypes rhs) +{ + using T = std::underlying_type_t <CppC4Group::AllowedEntryTypes>; + return static_cast<CppC4Group::AllowedEntryTypes>(static_cast<T>(lhs) | static_cast<T>(rhs)); +} + +inline CppC4Group::AllowedEntryTypes& operator|=(CppC4Group::AllowedEntryTypes& lhs, CppC4Group::AllowedEntryTypes rhs) +{ + return lhs = lhs | rhs; +} |
