-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathschema.cc
57 lines (46 loc) · 1.06 KB
/
schema.cc
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
#include "schema.h"
Schema::Schema(const char *szDatabase, const char *szTable)
{
strncpy(m_szDatabase, szDatabase, sizeof(m_szDatabase));
strncpy(m_szTable, szTable, sizeof(m_szTable));
}
Schema::~Schema()
{
vector<Column *>::iterator it = m_vColumn.begin();
for (; it != m_vColumn.end(); it++)
{
if (*it != NULL)
{
delete *it;
*it = NULL;
}
}
}
int Schema::Init()
{
m_pDatabaseRegex = new Regex();
if (m_pDatabaseRegex->Init(m_szDatabase) != 0)
return -1;
m_pTableRegex = new Regex();
if (m_pTableRegex->Init(m_szTable) != 0)
return -1;
return 0;
}
bool Schema::CheckSchema(const char *szDatabase, const char *szTable)
{
if (m_pDatabaseRegex->Check(szDatabase) == false
|| m_pTableRegex->Check(szTable) == false)
return false;
return true;
}
int Schema::AddColumn(Column *pColumn)
{
if (pColumn == NULL)
return -1;
m_vColumn.push_back(pColumn);
return 0;
}
vector<Column *>& Schema::GetColumn()
{
return m_vColumn;
}