-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDatagram.cpp
67 lines (63 loc) · 1.22 KB
/
Datagram.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
#include "Datagram.h"
namespace Tool
{
namespace Network
{
Datagram::Datagram(b8 data, u32 size)
{
unt i;
for(i = 0; i < size; ++i)
this->data.push(data[i]);
}
Datagram::Datagram(void){}
Datagram::~Datagram(void)
{
}
b8 Datagram::Data(b8 data, u32 size)
{
unt dsize = Size();
unt i;
for(i = 0; i < dsize && i < size; ++i)
{
data[i] = this->data.front();
this->data.pop();
}
return data;
}
b8 Datagram::Data(void)
{
unt size = Size();
b8 data = new w8[size];
unt i;
for(i = 0; i < size; ++i)
{
data[i] = this->data.front();
this->data.pop();
}
return data;
}
//template<typename t> void Datagram::Write(t & value) ===> Datagram.inl
//template<typename t> t Datagram::Read(void) ===> Datagram.inl
void Datagram::Writeb8(b8 value, u32 size)
{
unt i;
for(i = 0; i < size; ++i)
data.push(value[i]);
}
u32 Datagram::Readb8 (b8 value, u32 size)
{
unt dsize = data.size();
u32 i;
for(i = 0; i < size && dsize; ++i)
{
value[i] = data.front();
data.pop();
}
return i + 1;
}
u32 Datagram::Size(void) const
{
return data.size();
}
}
}