blob: bb6ac73bd025ab68027285fa158c82476158c3f9 (
plain)
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
|
#include "aopacket.h"
AOPacket::AOPacket(QString p_packet_string)
{
QStringList packet_contents = p_packet_string.split("#");
m_header = packet_contents.first();
m_contents = packet_contents.mid(1, packet_contents.size()-2); // trims %
}
QString AOPacket::to_string()
{
return m_header + "#" + m_contents.join("#") + "#%";
}
void AOPacket::net_encode()
{
m_contents.replaceInStrings("#", "<num>")
.replaceInStrings("%", "<percent>")
.replaceInStrings("$", "<dollar>")
.replaceInStrings("&", "<and>");
}
void AOPacket::net_decode()
{
m_contents.replaceInStrings("<num>", "#")
.replaceInStrings("<percent>", "%")
.replaceInStrings("<dollar>", "$")
.replaceInStrings("<and>", "&");
}
|