diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2016-12-27 17:15:42 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2016-12-30 14:31:22 +0100 |
| commit | d008a9b64331c466703c0687e7e353789903c1ff (patch) | |
| tree | 862142d8d1b23c9e002b2a152271f105519d020a /src/fs | |
| parent | 986fc3a59bfaf1a38a9e694fa438b9506c303baa (diff) | |
| download | extfs-d008a9b64331c466703c0687e7e353789903c1ff.tar.xz extfs-d008a9b64331c466703c0687e7e353789903c1ff.zip | |
superblock: Define predefined enums
Diffstat (limited to 'src/fs')
| -rw-r--r-- | src/fs/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | src/fs/detail/superblock.cpp | 65 |
2 files changed, 67 insertions, 1 deletions
diff --git a/src/fs/CMakeLists.txt b/src/fs/CMakeLists.txt index 3ca33b8..4e2d1d6 100644 --- a/src/fs/CMakeLists.txt +++ b/src/fs/CMakeLists.txt @@ -6,5 +6,6 @@ endif() add_library(extfs ${LIBRARY_TYPE} - extfs.cpp + "extfs.cpp" + "detail/superblock.cpp" ) diff --git a/src/fs/detail/superblock.cpp b/src/fs/detail/superblock.cpp new file mode 100644 index 0000000..f238098 --- /dev/null +++ b/src/fs/detail/superblock.cpp @@ -0,0 +1,65 @@ +#include "fs/detail/superblock.hpp" + +#include <algorithm> + +namespace fs::detail + { + + bool superblock::has(superblock::compatible_feature const feature) const + { + return compatible_features_bitmap & static_cast<decltype(compatible_features_bitmap)>(feature); + } + + bool superblock::has_all(std::initializer_list<superblock::compatible_feature> const features) const + { + return std::all_of(features.begin(), features.end(), [&](auto const feature){ + return compatible_features_bitmap & static_cast<decltype(compatible_features_bitmap)>(feature); + }); + } + + bool superblock::has_any(std::initializer_list<superblock::compatible_feature> const features) const + { + return std::any_of(features.begin(), features.end(), [&](auto const feature){ + return compatible_features_bitmap & static_cast<decltype(compatible_features_bitmap)>(feature); + }); + } + + bool superblock::has(superblock::incompatible_feature const feature) const + { + return incompatible_features_bitmap & static_cast<decltype(incompatible_features_bitmap)>(feature); + } + + bool superblock::has_all(std::initializer_list<superblock::incompatible_feature> const features) const + { + return std::all_of(features.begin(), features.end(), [&](auto const feature){ + return incompatible_features_bitmap & static_cast<decltype(incompatible_features_bitmap)>(feature); + }); + } + + bool superblock::has_any(std::initializer_list<superblock::incompatible_feature> const features) const + { + return std::any_of(features.begin(), features.end(), [&](auto const feature){ + return incompatible_features_bitmap & static_cast<decltype(incompatible_features_bitmap)>(feature); + }); + } + + bool superblock::has(superblock::read_only_compatible_feature const feature) const + { + return read_only_compatible_features_bitmap & static_cast<decltype(read_only_compatible_features_bitmap)>(feature); + } + + bool superblock::has_all(std::initializer_list<superblock::read_only_compatible_feature> const features) const + { + return std::all_of(features.begin(), features.end(), [&](auto const feature){ + return read_only_compatible_features_bitmap & static_cast<decltype(read_only_compatible_features_bitmap)>(feature); + }); + } + + bool superblock::has_any(std::initializer_list<superblock::read_only_compatible_feature> const features) const + { + return std::any_of(features.begin(), features.end(), [&](auto const feature){ + return read_only_compatible_features_bitmap & static_cast<decltype(read_only_compatible_features_bitmap)>(feature); + }); + } + + } |
