-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.h
42 lines (38 loc) · 956 Bytes
/
db.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
#ifndef DB_H
#define DB_H
#include <string>
#include <exception>
#include "query_result.h"
#include <deque>
#include "morphan_result.h"
typedef struct lexicon{
unsigned int token;
std::string word;
std::string lid;
std::string gcat;
std::string lexeme;
bool lexicon_entry;
query_result *dependencies=NULL;
morphan_result *morphalytics=NULL;
std::deque<unsigned int> tokens;
}lexicon;
class db{
public:
db(){};
virtual ~db(){};
virtual void open(const std::string&)=0;
virtual void close()=0;
virtual const std::string error_message()=0;
virtual query_result *exec_sql(const std::string&)=0;
virtual std::string db_uri()=0;
virtual std::string escape(const std::string& to_escape){
std::string escaped=to_escape;
size_t pos=escaped.find("\'");
while(pos!=std::string::npos){
escaped.replace(pos,1,"\'\'");
pos=escaped.find("\'",pos+2);
}
return escaped;
}
};
#endif