-
Notifications
You must be signed in to change notification settings - Fork 1
/
tools.cpp
113 lines (97 loc) · 2.87 KB
/
tools.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include "tools.h"
void tools_int16tToBuffer(int16_t value, uint8_t* buffer, bool incBuffer){
const uint8_t length = 2;
memcpy(buffer, &value, length);
if(incBuffer) buffer += length;
}
void tools_uint16tToBuffer(uint16_t value, uint8_t* buffer, bool incBuffer){
const uint8_t length = 2;
memcpy(buffer, &value, length);
if(incBuffer) buffer += length;
}
void tools_int32tToBuffer(int32_t value, uint8_t* buffer, bool incBuffer){
const uint8_t length = 4;
memcpy(buffer, &value, length);
if(incBuffer) buffer += length;
}
void tools_uint32tToBuffer(uint32_t value, uint8_t* buffer, bool incBuffer){
const uint8_t length = 4;
memcpy(buffer, &value, length);
if(incBuffer) buffer += length;
}
void tools_int64tToBuffer(int64_t value, uint8_t* buffer, bool incBuffer){
const uint8_t length = 8;
memcpy(buffer, &value, length);
if(incBuffer) buffer += length;
}
void tools_uint64tToBuffer(uint64_t value, uint8_t* buffer, bool incBuffer){
const uint8_t length = 8;
memcpy(buffer, &value, length);
if(incBuffer) buffer += length;
}
void tools_floatToBuffer(float value, uint8_t* buffer, bool incBuffer){
const uint8_t length = 4;
memcpy(buffer, &value, length);
if(incBuffer) buffer += length;
}
void tools_doubleToBuffer(double value, uint8_t* buffer, bool incBuffer){
const uint8_t length = 8;
memcpy(buffer, &value, length);
if(incBuffer) buffer += length;
}
int16_t tools_bufferToInt16t(uint8_t* buffer, bool incBuffer){
const uint8_t length = 2;
int16_t value = 0;
memcpy(&value, buffer, length);
if(incBuffer) buffer += length;
return value;
}
uint16_t tools_bufferToUint16t(uint8_t* buffer, bool incBuffer){
const uint8_t length = 2;
uint16_t value = 0;
memcpy(&value, buffer, length);
if(incBuffer) buffer += length;
return value;
}
int32_t tools_bufferToInt32t(uint8_t* buffer, bool incBuffer){
const uint8_t length = 4;
int32_t value = 0;
memcpy(&value, buffer, length);
if(incBuffer) buffer += length;
return value;
}
uint32_t tools_bufferToUint32t(uint8_t* buffer, bool incBuffer){
const uint8_t length = 4;
uint32_t value = 0;
memcpy(&value, buffer, length);
if(incBuffer) buffer += length;
return value;
}
int64_t tools_bufferToInt64t(uint8_t* buffer, bool incBuffer){
const uint8_t length = 8;
int64_t value = 0;
memcpy(&value, buffer, length);
if(incBuffer) buffer += length;
return value;
}
uint64_t tools_bufferToUint64t(uint8_t* buffer, bool incBuffer){
const uint8_t length = 8;
uint64_t value = 0;
memcpy(&value, buffer, length);
if(incBuffer) buffer += length;
return value;
}
float tools_bufferToFloat(uint8_t* buffer, bool incBuffer){
const uint8_t length = 4;
float value = 0;
memcpy(&value, buffer, length);
if(incBuffer) buffer += length;
return value;
}
double tools_bufferToDouble(uint8_t* buffer, bool incBuffer){
const uint8_t length = 8;
double value = 0;
memcpy(&value, buffer, length);
if(incBuffer) buffer += length;
return value;
}