-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathcheck_flags.cpp
More file actions
60 lines (55 loc) · 1.66 KB
/
check_flags.cpp
File metadata and controls
60 lines (55 loc) · 1.66 KB
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
59
60
#include <cstdint>
#include <iostream>
enum class CheckFlags : uint8_t {
NONE = 0,
TIME = (1 << 0),
DATE = (1 << 1),
USER = (1 << 2),
CERT = (1 << 3),
KEYS = (1 << 4),
DEST = (1 << 5),
ALL = TIME | DATE | USER | CERT | KEYS | DEST
};
void PrintCheckFlags(CheckFlags flags) {
if (flags == CheckFlags::NONE) {
std::cout << "[]";
return;
}
if ((static_cast<uint8_t>(flags) & ~static_cast<uint8_t>(CheckFlags::ALL)) != 0) {
std::cout << "";
return;
}
std::cout << "[";
bool first = true;
if ((static_cast<uint8_t>(flags) & static_cast<uint8_t>(CheckFlags::TIME)) != 0) {
if (!first) std::cout << ",";
std::cout << "TIME";
first = false;
}
if ((static_cast<uint8_t>(flags) & static_cast<uint8_t>(CheckFlags::DATE)) != 0) {
if (!first) std::cout << ",";
std::cout << "DATE";
first = false;
}
if ((static_cast<uint8_t>(flags) & static_cast<uint8_t>(CheckFlags::USER)) != 0) {
if (!first) std::cout << ",";
std::cout << "USER";
first = false;
}
if ((static_cast<uint8_t>(flags) & static_cast<uint8_t>(CheckFlags::CERT)) != 0) {
if (!first) std::cout << ",";
std::cout << "CERT";
first = false;
}
if ((static_cast<uint8_t>(flags) & static_cast<uint8_t>(CheckFlags::KEYS)) != 0) {
if (!first) std::cout << ",";
std::cout << "KEYS";
first = false;
}
if ((static_cast<uint8_t>(flags) & static_cast<uint8_t>(CheckFlags::DEST)) != 0) {
if (!first) std::cout << ",";
std::cout << "DEST";
first = false;
}
std::cout << "]";
}