- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLog.h
More file actions
Latest commit
58 lines (56 loc) · 1.22 KB
/
Copy pathLog.h
File metadata and controls
58 lines (56 loc) · 1.22 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
#pragma once
#include<stdio.h>
#include<cstdarg>
#include<string>
#include<sstream>
usingnamespacestd;
namespaceyfpeg {
staticboolsNodeEatDebug = false;
#defineMAX_LOG_LENGTH16*1024
staticvoid_LOG(constchar* fmt, va_list args) {
char buf[MAX_LOG_LENGTH];
vsnprintf(buf, MAX_LOG_LENGTH - 3, fmt, args);
fprintf(stdout, "%s", buf);
fflush(stdout);
}
staticvoidLOG(constchar* fmt, ...) {
if (sNodeEatDebug) {
va_list args;
string fmt_line(fmt);
fmt_line += "\n";
va_start(args, fmt);
_LOG(fmt_line.c_str(),args);
va_end(args);
}
};
static string getIndent(int level,int blank = 0) {
string ret = "";
int n = level * 2 - blank;
for (int i = 0; i < n; ++i) {
ret += "";
}
return ret;
};
static string int2str(int i) {
stringstream s;
s << i;
return s.str();
};
static string float2str(float f) {
stringstream s;
s << f;
s.precision(4);
return s.str();
};
static string int2addrStr(int i) {
stringstream s;
s << i;
return"[" + s.str() + "]";
};
static string vec2_2str(float f1, float f2) {
stringstream s1,s2;
s1 << f1;
s2 << f2;
return"Vec2:(" + s1.str() + "," + s2.str() + ")";
};
}