From d008a9b64331c466703c0687e7e353789903c1ff Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Tue, 27 Dec 2016 17:15:42 +0100 Subject: superblock: Define predefined enums --- src/fs/CMakeLists.txt | 3 +- src/fs/detail/superblock.cpp | 65 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 src/fs/detail/superblock.cpp (limited to 'src') 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 + +namespace fs::detail + { + + bool superblock::has(superblock::compatible_feature const feature) const + { + return compatible_features_bitmap & static_cast(feature); + } + + bool superblock::has_all(std::initializer_list const features) const + { + return std::all_of(features.begin(), features.end(), [&](auto const feature){ + return compatible_features_bitmap & static_cast(feature); + }); + } + + bool superblock::has_any(std::initializer_list const features) const + { + return std::any_of(features.begin(), features.end(), [&](auto const feature){ + return compatible_features_bitmap & static_cast(feature); + }); + } + + bool superblock::has(superblock::incompatible_feature const feature) const + { + return incompatible_features_bitmap & static_cast(feature); + } + + bool superblock::has_all(std::initializer_list const features) const + { + return std::all_of(features.begin(), features.end(), [&](auto const feature){ + return incompatible_features_bitmap & static_cast(feature); + }); + } + + bool superblock::has_any(std::initializer_list const features) const + { + return std::any_of(features.begin(), features.end(), [&](auto const feature){ + return incompatible_features_bitmap & static_cast(feature); + }); + } + + bool superblock::has(superblock::read_only_compatible_feature const feature) const + { + return read_only_compatible_features_bitmap & static_cast(feature); + } + + bool superblock::has_all(std::initializer_list const features) const + { + return std::all_of(features.begin(), features.end(), [&](auto const feature){ + return read_only_compatible_features_bitmap & static_cast(feature); + }); + } + + bool superblock::has_any(std::initializer_list const features) const + { + return std::any_of(features.begin(), features.end(), [&](auto const feature){ + return read_only_compatible_features_bitmap & static_cast(feature); + }); + } + + } -- cgit v1.2.3