-
Notifications
You must be signed in to change notification settings - Fork 1
/
db.cc
55 lines (42 loc) · 932 Bytes
/
db.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
#include "unisrv-config.h"
#include "srv.h"
using namespace std;
using namespace Unisrv;
DbRegistry registry;
Unisrv::View *getView(const std::string& name,
const std::string& driver_,
const std::string& path)
{
Unisrv::View *view = registry.newView(name, driver_, path);
if (!view)
return nullptr;
if (!view->open()) {
delete view;
return nullptr;
}
return view;
}
bool register_db_drivers()
{
#ifdef HAVE_GDBM_H
Unisrv::DbDriver *new_gdbm_driver();
registry.add(new_gdbm_driver());
#endif
#ifdef HAVE_ROCKSDB_DB_H
Unisrv::DbDriver *new_rocksdb_driver();
registry.add(new_rocksdb_driver());
#endif
return true;
}
void list_db_drivers(std::vector<std::string>& names)
{
registry.nameList(names);
}
void dump_drivers()
{
vector<string> driverNames;
list_db_drivers(driverNames);
for (auto it = driverNames.begin(); it != driverNames.end(); it++) {
printf("%s\n", (*it).c_str());
}
}