-
Notifications
You must be signed in to change notification settings - Fork 2
/
chord.fs.type.h
59 lines (46 loc) · 1.68 KB
/
chord.fs.type.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once
namespace chord {
namespace fs {
enum class type : unsigned {
none = 0,
not_found = static_cast<unsigned>(-1),
regular = 1,
directory = 2,
unknown = 0xFFFF,
};
constexpr auto value_of(type a) noexcept {
using __utype = typename std::underlying_type<perms>::type;
return static_cast<__utype>(a);
}
constexpr type operator&(type a, type b) noexcept {
using __utype = typename std::underlying_type<type>::type;
return static_cast<type>(static_cast<__utype>(a) & static_cast<__utype>(b));
}
constexpr type operator|(type a, type b) noexcept {
using __utype = typename std::underlying_type<type>::type;
return static_cast<type>(static_cast<__utype>(a) | static_cast<__utype>(b));
}
constexpr type operator^(type a, type b) noexcept {
using __utype = typename std::underlying_type<type>::type;
return static_cast<type>(static_cast<__utype>(a) ^ static_cast<__utype>(b));
}
constexpr type operator~(type a) noexcept {
using __utype = typename std::underlying_type<type>::type;
return static_cast<type>(~static_cast<__utype>(a));
}
inline type& operator&=(type& a, type b) noexcept { return a = a & b; }
inline type& operator|=(type& a, type b) noexcept { return a = a | b; }
inline type& operator^=(type& a, type b) noexcept { return a = a ^ b; }
inline std::ostream &operator<<(std::ostream &os, const type &t) {
switch(t) {
case type::none: return os << "none";
case type::not_found: return os << "not_found";
case type::regular: return os << "file";
case type::directory: return os << "directory";
case type::unknown: return os << "unknown";
default: return os;
}
return os;
}
} // namespace fs
} // namespace chord