-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.cpp
64 lines (49 loc) · 1.36 KB
/
debug.cpp
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
61
62
63
#include <vector>
#include <sstream>
#include <map>
map <string, bool> debug_flags;
vector<string> curr_debug_flag = {"Main"};
#define sstream stringstream
sstream ss;
void debug (string message, string flag = ""){
if (flag == "") flag = curr_debug_flag.back();
if (debug_flags.count(flag) == 0 ) {
cerr << "[" + flag + "]: " + message << endl;
return;
}
if (!debug_flags[flag]) return;
cerr << "[" + flag + "]: " + message << endl;
}
void debug (){
string flag = curr_debug_flag.back();
string temp = ss.str();
ss.str("");
if (debug_flags.count(flag) == 0 ) {
cerr << "[" + flag + "]: " + temp << endl;
return;
}
if (!debug_flags[flag]) return;
cerr << "[" + flag + "]: " + temp << endl;
}
void debug_init (){
debug_flags["Main"] = true;
debug_flags["Initialize"] = true;
debug_flags["Actualize"] = true;
debug_flags["Target select"] = true;
debug_flags["Clock"] = true;
debug_flags["Path finding"] = true;
debug_flags["BFS 1"] = false;
debug_flags["Make beware"] = true;
}
void set_debug_flag (string flag){
curr_debug_flag.back() = flag;
}
void add_debug_flag (string flag){
curr_debug_flag.push_back(flag);
}
void undo_debug_flag (){
curr_debug_flag.pop_back();
}
#define setdf set_debug_flag
#define adddf add_debug_flag
#define unddf undo_debug_flag