-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtil.cpp
47 lines (43 loc) · 982 Bytes
/
Util.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
#include "Util.h"
using namespace std;
char getEscapedChar(char c) {
switch (c) {
case '0':
return '\0';
case '\'':
return '\'';
case '\"':
return '\"';
case '?':
return '?';
case '\\':
return '\\';
case 'a':
return '\a';
case 'b':
return '\b';
case 'f':
return '\f';
case 'n':
return '\n';
case 'r':
return '\r';
case 't':
return '\t';
case 'v':
return '\v';
default:
return c;
}
}
std::vector<unsigned char> intToBytes(int paramInt) {
std::vector<unsigned char> arrayOfByte(4);
for (int i = 0; i < 4; i++)
arrayOfByte[3 - i] = (paramInt >> (i * 8));
return arrayOfByte;
}
void verifyOperand(int op) {
if (op < 0 || op > 15) {
// throw overflow_error("Bad operand");
}
}