My favorites | Sign in
Project Home Downloads Source
Checkout   Browse   Changes    
 
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// attribute macros
//
// @i array index (or "" when no array)
// @t table name
// @c column name (with index)
// @C column name (without index)
// @T column type
// @x combined column+table up to maxidlen characters (default 24) (for constraint names)

class SqlSchema {
protected:
Vector<String> script;
String schemaname;
String prefix;
String table;
String table_suffix;
String type;
String column;
bool firstcolumn;
String attribute;
int items;
int dialect;

int maxidlen;

public:
virtual void FlushColumn();
virtual void FlushTable();

void Object(const char *text, const char *drop);

void Table(const char *name);
void TableSuffix(const char *suffix);
void Column(const char *type, const char *name);
void ColumnArray(const char *type, const char *name, int items);
void Attribute(const char *attr, const char *drop);
void InlineAttribute(const char *attr);
void EndTable() { FlushTable(); }

void Config(const char *config, const char *drop);
void Upgrade(const char *text);

String CurrentTable() const;
String CurrentColumn() const { return column; }
String CurrentType() const { return Expand(type); }
String Expand(const char *txt, int i = Null) const;

enum {
SCHEMA, DROPSCHEMA, ATTRIBUTES, DROPATTRIBUTES, UPGRADE, DROPUPGRADE, CONFIG, DROPCONFIG
};

String& Script(int si);
String Script(int si) const;

String& Schema();
String& SchemaDrop();
String& Attributes();
String& AttributesDrop();
String& Upgrade();
String& UpgradeDrop();
String& Config();
String& ConfigDrop();

String NormalFileName(int i, const char *dir = NULL, const char *name = NULL) const;
bool ScriptChanged(int i, const char *dir = NULL, const char *name = NULL) const;
bool UpdateNormalFile(int i, const char *dir = NULL, const char *name = NULL) const;
void SaveNormal(const char *dir = NULL, const char *name = NULL) const;

void Var(void (*type)(SqlSchema& s), const char *name);

SqlSchema& SchemaName(String sch) { schemaname = sch; return *this; }
SqlSchema& MaxIDLen(int n) { maxidlen = n; return *this; }

int GetDialect() const { return dialect; }

#ifndef NOAPPSQL
SqlSchema(int dialect = SQL.GetDialect());
#else
SqlSchema(int dialect);
#endif
virtual ~SqlSchema() {}
};

void operator*(SqlSchema& schema, const SqlInsert& insert);

template <class T>
inline void SqlSchemaInitClear(T& a) {}

template <class T>
inline void SqlSchemaInitClear(T *a, int n) {
while(n--)
SqlSchemaInitClear(*a++);
}


template<> inline void SqlSchemaInitClear(int& a) { a = Null; }
template<> inline void SqlSchemaInitClear(double& a) { a = Null; }
template<> inline void SqlSchemaInitClear(int64& a) { a = Null; }
template<> inline void SqlSchemaInitClear(bool& a) { a = false; }

template <class T>
inline void SqlSchemaClear(T& a) { a = Null; }

inline void SqlSchemaClear(bool& a) { a = false; }

template <class T>
inline void SqlSchemaClear(T *a, int n) {
while(n--)
SqlSchemaClear(*a++);
}

void SchDbInfoTable(const char *table);
void SchDbInfoColumn(const char *column);
void SchDbInfoColumnArray(const char *name, int items);
void SchDbInfoVar(void (*fn)(), const char *name);
void SchDbInfoPrimaryKey();
void SchDbInfoReferences(const char *table);
void SchDbInfoReferences(const char *table, const char *column);

SqlBool FindSchJoin(const String& tables);

Vector<String> GetSchColumns(const String& table);

String ExportSch(SqlSession& session, const String& database);
String ExportIds(SqlSession& session, const String& database);

#ifndef NOAPPSQL
String ExportSch(const String& database);
String ExportIds(const String& database);
#endif

Change log

r4513 by cxl on Feb 2, 2012   Diff
ide: Fixed config issue
Go to: 
Project members, sign in to write a code review

Older revisions

r4312 by cxl on Dec 16, 2011   Diff
SqlCtrl: SqlCtrls now support
automatic creation based on schema
introspection
r4275 by cxl on Dec 8, 2011   Diff
Sql: More adjustments of sch
introspection
r4269 by cxl on Dec 7, 2011   Diff
Sql: finalizing JoinRef and
introspection
All revisions of this file

File info

Size: 3950 bytes, 130 lines

File properties

svn:eol-style
native
Powered by Google Project Hosting