-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathutils.h
39 lines (33 loc) · 772 Bytes
/
utils.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
#ifndef UTILS_H
#define UTILS_H
#include <iostream>
#include <cstdio>
void PrintSeparator() {
std::cout << "//---------------------------------------------------------------------------" << std::endl;
}
enum class LineEnd {
Empty,
New,
Space
};
template<typename T>
void PrintAsBits(T val, LineEnd end = LineEnd::New) {
static T one = 1;
for (short i = sizeof(T) * 8 - 1; 0 <= i;) {
printf("%c", (val & (one << i)) ? '1' : '0');
--i;
if (0 == (i + 1) % 8)
printf(" ");
}
switch (end) {
case LineEnd::New:
printf("\r\n");
break;
case LineEnd::Space:
printf(" ");
break;
default:
break;
}
}
#endif /* UTILS_H */