-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.h
61 lines (43 loc) · 1.18 KB
/
database.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
#ifndef DATABASE_H
#define DATABASE_H
#include <string>
#include <vector>
#include <map>
#include <cstdio>
#include "sql.h"
using namespace std;
extern string curdb;
struct FeildMeta{
string table;
Type type;
string field;
int index;
FeildMeta() {}
FeildMeta(string table, Type type, string field, int index) : table(table), type(type), field(field), index(index) {}
};
typedef pair<string, string> tableField;
typedef map<tableField, FeildMeta> FeildMap;
// struct TableField {
// string field;
// Type type;
// int length;
// TableField(string field, Type type, int length) : field(field), type(type), length(length) {}
// };
struct DBMeta{
map<string, FeildMap> tableMap;
};
extern DBMeta dbMeta;
extern void init();
extern string dbDir(const string& dbname);
extern void flushMetaFile();
extern bool create_database(const string& dbname);
extern bool drop_database(const string& dbname);
extern bool use_database(const string& dbname);
extern vector<string> showDatabases();
extern vector<string> showTables();
inline void printVector(const vector<string>& vec){
for(auto str : vec){
printf("%s\n", str.c_str());
}
}
#endif