-
Notifications
You must be signed in to change notification settings - Fork 0
/
Server.cpp
58 lines (47 loc) · 1.51 KB
/
Server.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
#include "Server.hpp"
using namespace CCC;
Server::Server(std::shared_ptr<DataBaseConnection> connection) {
this->data.connection = connection;
}
bool Server::up() {
return this->data.connection->up();
}
Server::Meta Server::meta(){
Meta result;
auto mdata = this->data.connection->meta();
result.uuid = mdata["uuid"s].as_string();
result.version = mdata["version"s].as_string();
return result;
}
std::vector<Database> Server::databases(const DataBaseConnection::AllDBsOptiions &options) {
const auto result = this->data.connection->allDBs(options);
std::vector<Database> dbs;
for (const auto ¤t : result.array_range()) {
const auto temp = Database(this->data.connection, current.as_string());
dbs.push_back(temp);
}
return dbs;
}
bool Server::databaseExists(const std::string &name) {
return this->data.connection->dbExists(name);
}
std::vector<std::string> Server::uuids(long count) {
std::vector<std::string> uuids;
const auto result = this->data.connection->uuids(count);
for (const auto ¤t : result["uuids"].array_range()){
uuids.push_back(current.as_string());
}
return uuids;
}
std::string Server::uuid() {
return this->uuids(1ul).at(0ul);
}
std::string Server::favicon() {
return this->data.connection->favicon();
}
std::optional<DBC::CreateDatabaseResult> Server::createDatabase(const std::string &name) {
return this->data.connection->createdDB(name);
}
Server::DeleteDatabaseResult Server::deleteDatabase(const std::string &name) {
return this->data.connection->deleteDB(name);
}