-
Notifications
You must be signed in to change notification settings - Fork 1
/
Interface.h
81 lines (67 loc) · 1.82 KB
/
Interface.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
77
78
79
80
81
#pragma once
struct IAlloc
{
virtual void my_free() = 0;
};
typedef struct _CSimpleTypeVar CSimpleTypeVar;
typedef struct _IArray : public IAlloc
{
virtual int get_count() = 0;
virtual bool get_item(int i, CSimpleTypeVar* var) = 0;
virtual int get_key() = 0;
virtual bool get_value(CSimpleTypeVar* var) = 0;
virtual bool get_valid() = 0;
virtual void reset() = 0;
virtual bool next(CSimpleTypeVar* var) = 0;
} IArray;
typedef struct _IDict : public IAlloc
{
virtual int get_count() = 0;
virtual bool get_item(char* name, CSimpleTypeVar* var) = 0;
virtual char* get_key() = 0;
virtual bool get_value(CSimpleTypeVar* var) = 0;
virtual bool get_valid() = 0;
virtual void reset() = 0;
virtual bool next(char** name, CSimpleTypeVar* var) = 0;
} IDict;
typedef struct _CSimpleTypeVar
{
typedef enum {VAR_LONG, VAR_FLOAT, VAR_STRING, VAR_NULL, VAR_ARRAY, VAR_DICT} VarType;
VarType type;
union
{
long lval;
double fval;
IArray* aval;
IDict* dval;
struct
{
char* str;
size_t str_l;
} sval;
};
} CSimpleTypeVar;
struct IDbConnectionCursor : public IAlloc
{
virtual IArray* get_description() = 0;
virtual long get_rowcount() = 0;
virtual void close() = 0;
virtual int execute(char* querytempl, IArray* params) = 0;
virtual int executemany(char* querytempl, IArray* params) = 0;
virtual IArray* fetchone() = 0;
virtual IArray* fetchmany(long arraysize = -1) = 0;
virtual IArray* fetchall() = 0;
};
struct IDbConnection
{
virtual bool rollback() = 0;
virtual bool commit() = 0;
virtual IDbConnectionCursor* cursor() = 0;
};
struct IPyCountext
{
virtual int write(const char* buff, int length) = 0;
virtual void flush() = 0;
virtual IDbConnection* get_connection() = 0;
virtual bool get_data(CSimpleTypeVar* var) = 0;
};