-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathcheck_flags.cpp
More file actions
59 lines (53 loc) · 1.56 KB
/
check_flags.cpp
File metadata and controls
59 lines (53 loc) · 1.56 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
#include <cstdint>
#include <stdexcept>
#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::ALL) {
std::cout << "";
return;
}
bool the_first = true;
std::string str_flags = "[";
if (static_cast<uint8_t>(flags) &
static_cast<uint8_t>(CheckFlags::TIME)) {
str_flags += "TIME";
the_first = false;
}
if (static_cast<uint8_t>(flags) &
static_cast<uint8_t>(CheckFlags::DATE)) {
the_first ? str_flags += "DATE" : str_flags += ",DATE";
the_first = false;
}
if (static_cast<int8_t>(flags) &
static_cast<int8_t>(CheckFlags::USER) ) {
the_first ? str_flags += "USER" : str_flags += ",USER";
the_first = false;
}
if (static_cast<int8_t>(flags) &
static_cast<int8_t>(CheckFlags::CERT)) {
the_first ? str_flags += "CERT" : str_flags += ",CERT";
the_first = false;
}
if (static_cast<int8_t>(flags) &
static_cast<int8_t>(CheckFlags::KEYS)) {
the_first ? str_flags += "KEYS" : str_flags += ",KEYS";
the_first = false;
}
if (static_cast<int8_t>(flags) &
static_cast<int8_t>(CheckFlags::DEST)) {
the_first ? str_flags += "DEST" : str_flags += ",DEST";
the_first = false;
}
str_flags += "]";
std::cout << str_flags;
}