-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathEndpointDescriptor.cpp
93 lines (88 loc) · 3.11 KB
/
EndpointDescriptor.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// Created by victor on 11/8/17.
//
#include "EndpointDescriptor.h"
namespace restdbxx {
long EndpointDescriptor::getId() const {
return id;
}
void EndpointDescriptor::setId(long id) {
EndpointDescriptor::id = id;
}
const std::string &EndpointDescriptor::getUrl() const {
return url;
}
void EndpointDescriptor::setUrl(const std::string &url) {
EndpointDescriptor::url = url;
}
int EndpointDescriptor::getCount() const {
return count;
}
void EndpointDescriptor::setCount(int count) {
EndpointDescriptor::count = count;
}
const ptime &EndpointDescriptor::getCreated() const {
return created;
}
void EndpointDescriptor::setCreated(const ptime &created) {
EndpointDescriptor::created = created;
}
const ptime &EndpointDescriptor::getModified() const {
return modified;
}
void EndpointDescriptor::setModified(const ptime &modified) {
EndpointDescriptor::modified = modified;
}
const std::string &EndpointDescriptor::getModification_user() const {
return modification_user;
}
void EndpointDescriptor::setModification_user(const std::string &modification_user) {
EndpointDescriptor::modification_user = modification_user;
}
bool EndpointDescriptor::isEnabled() const {
return enabled;
}
void EndpointDescriptor::setEnabled(bool enabled) {
EndpointDescriptor::enabled = enabled;
}
std::shared_ptr<EndpointDescriptor> EndpointDescriptor::new_endpoint(long id, const std::string &url, const std::string &user) {
return std::make_shared<EndpointDescriptor>(id, url, user);
}
EndpointDescriptor::EndpointDescriptor(long id,
const std::string &url,
const std::string &modification_user,
int count,
const ptime &created,
const ptime &modified,
bool enabled
)
: id(id),
url(url),
count(count),
created(created),
modified(modified),
modification_user(modification_user),
enabled(enabled) {}
std::shared_ptr<EndpointDescriptor> EndpointDescriptor::fromDynamic(folly::dynamic &obj) {
if (obj.isObject()) {
return std::make_shared<EndpointDescriptor>(obj.at("id").asInt(),
obj.at("url").asString(),
obj["modification_user"].asString(),
obj["count"].asInt(),
from_iso_extended_string(obj["created"].asString()),
from_iso_extended_string(obj["modified"].asString()),
obj["enabled"].asBool());
} else {
BOOST_THROW_EXCEPTION(std::invalid_argument("not a json object"));
}
}
folly::dynamic EndpointDescriptor::getDynamic() const {
return folly::dynamic::object("id", id)
("url", url)
("count", count)
("created", to_iso_extended_string(created))
("modified", to_iso_extended_string(modified))
("modification_user", modification_user)
("enabled", enabled);
}
}