-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObjectSerializer.cpp
78 lines (66 loc) · 2.29 KB
/
ObjectSerializer.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
#include "IntactObjects/ObjectSerializer.h"
namespace IntactObjects
{
// TODO: Return bytesWritten for each function!
void ObjectSerializer::WriteMapStringGroupInformation(NetworkLib::SerializeWriter *writer, MapStringGroupInformation &mapStringInformation)
{
writer->WriteInt32((int)mapStringInformation.size());
for(MapStringGroupInformation::iterator it = mapStringInformation.begin(), it_end = mapStringInformation.end(); it != it_end; ++it)
{
writer->WriteString(it->first);
GroupInformation &groupInfo = it->second;
groupInfo.Write(writer);
}
}
void ObjectSerializer::WriteMapStringHostInformation(NetworkLib::SerializeWriter *writer, MapStringHostInformation &mapStringInformation)
{
writer->WriteInt32((int)mapStringInformation.size());
for(MapStringHostInformation::iterator it = mapStringInformation.begin(), it_end = mapStringInformation.end(); it != it_end; ++it)
{
writer->WriteString(it->first);
HostInformation &hostInfo = it->second;
hostInfo.Write(writer);
}
}
void ObjectSerializer::WriteSetGroupHandle(NetworkLib::SerializeWriter *writer, SetGroupHandle &setGroupHandle)
{
writer->WriteInt32((int)setGroupHandle.size());
for(SetGroupHandle::iterator it = setGroupHandle.begin(), it_end = setGroupHandle.end(); it != it_end; ++it)
{
GroupHandle handle = *it;
handle.Write(writer);
}
}
void ObjectSerializer::ReadMapStringGroupInformation(NetworkLib::SerializeReader *reader, MapStringGroupInformation &mapStringInformation)
{
int size = reader->ReadInt32();
for(int i = 0; i < size; i++)
{
string str = reader->ReadString();
GroupInformation info;
info.Read(reader);
mapStringInformation.insert(pair<string, GroupInformation>(str, info));
}
}
void ObjectSerializer::ReadMapStringHostInformation(NetworkLib::SerializeReader *reader, MapStringHostInformation &mapStringInformation)
{
int size = reader->ReadInt32();
for(int i = 0; i < size; i++)
{
string str = reader->ReadString();
HostInformation info;
info.Read(reader);
mapStringInformation.insert(pair<string, HostInformation>(str, info));
}
}
void ObjectSerializer::ReadSetGroupHandle(NetworkLib::SerializeReader *reader, SetGroupHandle &setGroupHandle)
{
int size = reader->ReadInt32();
for(int i = 0; i < size; i++)
{
GroupHandle handle;
handle.Read(reader);
setGroupHandle.insert(handle);
}
}
}