-
Notifications
You must be signed in to change notification settings - Fork 0
/
server_to_server_configuration_pair.cc
81 lines (64 loc) · 1.93 KB
/
server_to_server_configuration_pair.cc
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
#include "server_to_server.hpp"
#include "marshal.hpp"
using namespace dfterm;
using namespace trankesbel;
using namespace std;;
ServerToServerConfigurationPair::ServerToServerConfigurationPair()
{
remoteport = "0";
server_timeout = 120000000000ULL;
}
void ServerToServerConfigurationPair::setTargetUTF8(const std::string &remotehost, const std::string &port)
{
remotehostname = remotehost;
remoteport = port;
}
std::string ServerToServerConfigurationPair::getTargetHostnameUTF8() const
{
return remotehostname;
}
std::string ServerToServerConfigurationPair::getTargetPortUTF8() const
{
return remoteport;
}
void ServerToServerConfigurationPair::setServerTimeout(ui64 nanoseconds)
{
server_timeout = nanoseconds;
}
ui64 ServerToServerConfigurationPair::getServerTimeout() const
{
return server_timeout;
}
void ServerToServerConfigurationPair::setNameUTF8(const std::string &name)
{
this->name = name;
}
std::string ServerToServerConfigurationPair::getNameUTF8() const
{
return name;
}
void ServerToServerConfigurationPair::getNameUTF8(std::string* name) const
{
assert(name);
(*name) = this->name;
}
std::string ServerToServerConfigurationPair::serialize() const
{
return marshalString(name) + marshalString(remoteport) + marshalString(remotehostname) + marshalUnsignedInteger64(server_timeout);
}
bool ServerToServerConfigurationPair::unSerialize(const std::string &stscp)
{
size_t consumed = 0, cursor = 0;
name = unMarshalString(stscp, consumed, &consumed);
if (consumed == 0) return false;
cursor += consumed;
remoteport = unMarshalString(stscp, cursor, &consumed);
if (consumed == 0) return false;
cursor += consumed;
remotehostname = unMarshalString(stscp, cursor, &consumed);
if (consumed == 0) return false;
cursor += consumed;
server_timeout = unMarshalUnsignedInteger64(stscp, cursor, &consumed);
if (consumed == 0) return false;
return true;
}