-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbufferobj.h
More file actions
73 lines (57 loc) · 1.3 KB
/
bufferobj.h
File metadata and controls
73 lines (57 loc) · 1.3 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#pragma once
namespace std {
#ifndef to_string
inline string to_string(int _Val)
{ // convert int to string
char _Buf[256];
sprintf(_Buf, "%d", _Val);
return (string(_Buf));
}
inline string to_string(long _Val)
{ // convert int to string
char _Buf[256];
sprintf(_Buf, "%D", _Val);
return (string(_Buf));
}
inline string to_string(float _Val)
{ // convert int to string
char _Buf[256];
sprintf(_Buf, "%f", _Val);
return (string(_Buf));
}
#endif
#ifndef stoi
inline int stoi(const char * str)
{
return String(str).toInt();
}
inline float stof(const char * str)
{
return String(str).toFloat();
}
inline int stoi(string str)
{
return String(str.c_str()).toInt();
}
inline float stof(string str)
{
return String(str.c_str()).toFloat();
}
#endif
}
struct CBufferObj {
byte buffer[500];
int len=0;
std::string str;
CBufferObj(const byte * buf,int l){
memcpy(buffer,buf,l);
len=l;
}
CBufferObj(std::string s){
str=s;
}
bool isAck(){
if (str.length()<4) return false;
if ((str.substr(0,4)=="ACK:")||(str.substr(0,4)=="ack:")||(str.substr(0,4)=="Ack:")) return true;
}
};