-
Notifications
You must be signed in to change notification settings - Fork 3
/
DbTableSchema.h
64 lines (54 loc) · 1.34 KB
/
DbTableSchema.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
#pragma once
#include "WykiDatabaseDriver.h"
#include "DbSession.h"
#include "DbErrors.h"
class DbTableSchema;
class DbTable;
///DbColumn
// Describes a table column
//
class DbColumn
{
friend class DbTableSchema;
public:
DbColumn(void) {}
virtual ~DbColumn(void) {}
const char *get_name() { return _colName; }
JET_COLUMNID get_colid() { return _colId; }
long get_type() { return _colType; }
long get_cb_max() { return _colCbMax; }
short get_code_page() { return _cp; }
short get_collation() { return _colCollate; }
JET_GRBIT get_grbit() { return _colGrbit; }
private:
char _colName[JET_cbNameMost+1];//+1 for null
JET_COLUMNID _colId;
unsigned long _colType;
unsigned long _colCbMax;
unsigned short _cp;
unsigned short _colCollate;
JET_GRBIT _colGrbit;
};
///DbTableSchema
// Describing the columns of a particular table
//
class DbTableSchema
{
public:
DbTableSchema(void);
virtual ~DbTableSchema(void);
JET_ERR load_schema_for_table(DbSession *dbs, DbTable *table, JET_TABLEID tableid);
DbColumn *get_col(const char *name)
{
TABLE_COLS::iterator i = _tbl_cols.find(string(name));
if (i != _tbl_cols.end())
{
return (*i).second;
}
throw wyki_schema_error(wstring(L"Invalid column access - column name not present in table"));
}
private:
typedef map<string, DbColumn *> TABLE_COLS;
TABLE_COLS _tbl_cols;
JET_TABLEID _tmp;
};