-
Notifications
You must be signed in to change notification settings - Fork 23
/
ldb.h
77 lines (60 loc) · 1.41 KB
/
ldb.h
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
#ifndef LDB_H_
#define LDB_H_
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <regex>
#include <getopt.h>
#include <sys/ioctl.h>
#define LDB_VERSION "0.0.2"
extern "C" {
#include "deps/linenoise/linenoise.h"
}
#include "leveldb/db.h"
using namespace std;
//
// Colors for formatting completions
//
#define BRIGHT 1
#define RED 31
namespace ldb {
struct command {
size_t id;
string rest;
};
struct cDef {
int id;
string name;
string alias;
string desc;
};
extern leveldb::DB *db;
extern vector<cDef> cmds;
extern vector<string> key_cache;
extern string key_start;
extern string key_end;
extern int key_limit;
extern string COLOR_RED;
extern string COLOR_YELLOW;
extern string COLOR_BLUE;
extern string COLOR_GRAY;
extern string COLOR_NONE;
extern string hi_start;
extern string hi_end;
extern int json;
string JSON(string str, int indent);
void startREPL();
void find(string exp, int type);
void auto_completion(const char *buf, linenoiseCompletions *lc);
void put_value(string key, string value);
void get_value(string key);
void del_value(string key);
void get_size();
void range(string prefix, bool surpress_output);
command parse_cmd(const string& line, const vector<cDef>& cmds);
vector<string> parse_rest(const string& rest, const char& splitter);
}
#endif // LDB_H_