plugify 1.0.0.0
Loading...
Searching...
No Matches
prot_flag.hpp
1#pragma once
2
3#include <cstdint>
4#include <type_traits>
5
6namespace plugify {
11 enum ProtFlag {
12 UNSET = 0,
13 X = 1 << 1,
14 R = 1 << 2,
15 W = 1 << 3,
16 S = 1 << 4,
17 P = 1 << 5,
18 N = 1 << 6,
19 RWX = R | W | X
20 };
21
29 inline ProtFlag operator|(ProtFlag lhs, ProtFlag rhs) noexcept {
30 using underlying = typename std::underlying_type<ProtFlag>::type;
31 return static_cast<ProtFlag> (
32 static_cast<underlying>(lhs) | static_cast<underlying>(rhs)
33 );
34 }
35
43 inline bool operator&(ProtFlag lhs, ProtFlag rhs) noexcept {
44 using underlying = typename std::underlying_type<ProtFlag>::type;
45 return static_cast<underlying>(lhs) & static_cast<underlying>(rhs);
46 }
47
55 inline ProtFlag& operator|=(ProtFlag& lhs, ProtFlag rhs) noexcept {
56 lhs = lhs | rhs;
57 return lhs;
58 }
59} // namespace plugify