forked from exclipy/clang_indexer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClicDb.hpp
40 lines (30 loc) · 1009 Bytes
/
ClicDb.hpp
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
#pragma once
#include <db_cxx.h>
#include <set>
class ClicDb {
public:
ClicDb(const char* dbFilename);
~ClicDb();
void clear();
void set(const std::string& usr, const std::set<std::string>& locations);
std::set<std::string> get(const std::string& usr);
void addMultiple(const std::string& usr, const std::set<std::string>& locationsToAdd);
void rmMultiple(const std::string& usr, const std::set<std::string>& locationsToRemove);
private:
class ClicCursor {
public:
ClicCursor(Db& db) {
db.cursor(0, &cursor, 0);
}
void rm(Dbt* key, Dbt* value) {
if (cursor->get(key, value, DB_GET_BOTH) != DB_NOTFOUND)
cursor->del(0);
}
~ClicCursor() {
cursor->close();
}
private:
Dbc* cursor;
};
Db db;
};