-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntity.cpp
42 lines (29 loc) · 830 Bytes
/
Entity.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
#include "Utils.h"
#include "Entity.h"
bool Entity::equals(const Entity &other) const
{
return id() == other.id() && serverUrl() == other.serverUrl();
}
void Entity::setServerUrl(const std::string &host)
{
if (host.substr(0, 7) != "http://") {
_serverUrl = "http://" + host;
}
else {
_serverUrl = host;
}
}
std::string Entity::makeUrl(const std::string& path)
{
return serverUrl() + path;
}
bool SessionEntity::equals(const SessionEntity &other) const
{
return session()->equals(*other.session()) && Entity::equals(other);
}
std::string SessionEntity::makeUrl(const std::string& path)
{
std::string formattedPath = ::sreplace(path, "{0}", session()->id());
formattedPath = ::sreplace(formattedPath, "{1}", id());
return Entity::makeUrl(formattedPath);
}