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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// SqlId

#define DOID(x) SqlId ADD_SCHEMA_PREFIX_CPP(x)(#x);
//#define DOID(x) SqlId x(#x);

#include SCHEMADIALECT

// constructor

#define TYPE(x) S_##x::S_##x() {
#define COLUMN(type, ctype, name, width, prec) SqlSchemaInitClear(ADD_SCHEMA_PREFIX_CPP(name));
#define COLUMN_ARRAY(type, ctype, name, width, prec, items) SqlSchemaInitClear(ADD_SCHEMA_PREFIX_CPP(name), items);
#define END_TYPE }

#include SCHEMADIALECT

// constructor, ColumnSet, TableName, SqlField

#define TYPECODE(x, y) \
const char S_##x::TableName[] = #x; \
const SqlSet& S_##x::ColumnSet() { \
static SqlSet set = ColumnSet(""); \
return set; \
} \
SqlSet S_##x::Of(SqlId id) { \
return ColumnSet(id.ToString() + '.'); \
} \
SqlSet S_##x::ColumnSet(const String& prefix) { \
SqlSet set; \
y \

#define TYPE(x) TYPECODE(x, __NIL)

#define BASECODE(b) \
set.Cat(S_##b::ColumnSet(prefix));
#define TYPE_I(x, b) TYPECODE(x, BASECODE(b))

#define BASE2CODE(b1, b2)\
set.Cat(S_##b1::ColumnSet(prefix)); \
set.Cat(S_##b2::ColumnSet(prefix));
#define TYPE_II(x, b1, b2) TYPECODE(x, BASE2CODE(b1, b2))

#define BASE3CODE(b1, b2, b3)\
set.Cat(S_##b1::ColumnSet(prefix)); \
set.Cat(S_##b2::ColumnSet(prefix)); \
set.Cat(S_##b3::ColumnSet(prefix));
#define TYPE_III(x, b1, b2, b3) TYPECODE(x, BASE3CODE(b1, b2, b3))

#define VAR(type, x) td_var(set, prefix, #x, &S_##type::ColumnSet);

#define COLUMN(type, ctype, name, width, prec) td_scalar(set, prefix, #name);
#define COLUMN_ARRAY(type, ctype, name, width, prec, items) td_array(set, prefix, #name, items);

#define END_TYPE return set; }

#include SCHEMADIALECT

#undef TYPECODE
#undef BASECODE
#undef BASE2CODE
#undef BASE3CODE

// Clear

#define TYPE(x)\
void S_##x::Clear() {

#define TYPE_I(x, b)\
void S_##x::Clear() { S_##b::Clear();

#define TYPE_II(x, b1, b2)\
void S_##x::Clear() { S_##b1::Clear(); S_##b2::Clear();

#define TYPE_III(x, b1, b2, b3)\
void S_##x::Clear() { S_##b1::Clear(); S_##b2::Clear(); S_##b3::Clear();

#define VAR(type, x) x.Clear();

#define COLUMN(type, ctype, name, width, prec) SqlSchemaClear(ADD_SCHEMA_PREFIX_CPP(name));
#define COLUMN_ARRAY(type, ctype, name, width, prec, items) SqlSchemaClear(ADD_SCHEMA_PREFIX_CPP(name), items);

#define END_TYPE }

#include SCHEMADIALECT

// FieldLayout

#define TYPE(x) \
void S_##x::FieldLayout(FieldOperator& fo) {\
fo.Table(#x);\
FieldLayoutRaw(fo);\
}

#include SCHEMADIALECT

// FieldLayoutRaw

#define TYPE(x) \
void S_##x::FieldLayoutRaw(FieldOperator& fo, const String& prefix) {

#define TYPE_I(x, b) \
void S_##x::FieldLayoutRaw(FieldOperator& fo, const String& prefix) {\
S_##b::FieldLayoutRaw(fo, prefix);

#define TYPE_II(x, b1, b2) \
void S_##x::FieldLayoutRaw(FieldOperator& fo, const String& prefix) {\
S_##b1::FieldLayoutRaw(fo, prefix);\
S_##b2::FieldLayoutRaw(fo, prefix);

#define TYPE_III(x, b1, b2, b3) \
void S_##x::FieldLayoutRaw(FieldOperator& fo, const String& prefix) {\
S_##b1::FieldLayoutRaw(fo, prefix);\
S_##b2::FieldLayoutRaw(fo, prefix);\
S_##b3::FieldLayoutRaw(fo, prefix);

#define COLUMN(type, ctype, name, width, prec) fo(prefix + #name, ADD_SCHEMA_PREFIX_CPP(name));
#define COLUMN_ARRAY(type, ctype, name, width, prec, items) \
{ \
for(int i = 0; i < items; i++)\
fo(Format("%s%s%d", ~prefix, #name, i), ADD_SCHEMA_PREFIX_CPP(name)[i]); \
}

#define VAR(type, x) x.FieldLayoutRaw(fo, prefix + #x + "$");

#define END_TYPE }

#include SCHEMADIALECT

// Introspection

#define TYPE(x) void SchDbInfo##x() {
#define TYPE_I(x, b) void SchDbInfo##x() { SchDbInfo##b();
#define TYPE_II(x, b1, b2) void SchDbInfo##x() { SchDbInfo##b1(); SchDbInfo##b2();
#define TYPE_III(x, b1, b2, b3) void SchDbInfo##x() { SchDbInfo##b1(); SchDbInfo##b2(); SchDbInfo##b3();
#define COLUMN(type, ctype, name, width, prec) SchDbInfoColumn(#name);
#define VAR(type, name) SchDbInfoVar(SchDbInfo##type, #name);
#define REFERENCES(table) SchDbInfoReferences(#table);
#define REFERENCES_CASCADE(table) SchDbInfoReferences(#table);
#define REFERENCES_(table, column) SchDbInfoReferences(#table, #column);
#define REFERENCES_CASCADE_(table, column) SchDbInfoReferences(#table, #column);
#define PRIMARY_KEY SchDbInfoPrimaryKey();
#define COLUMN_ARRAY(type, ctype, name, width, prec, items) SchDbInfoColumnArray(#name, items);
#define END_TYPE }

#include SCHEMADIALECT

#define TYPE(x) struct SINS_##x##_ { SINS_##x##_(); } SINS_##x##__; SINS_##x##_::SINS_##x##_() {\
SchDbInfoTable(#x); SchDbInfo##x();
#define TYPE_I(x, b) TYPE(x)
#define TYPE_II(x, b1, b2) TYPE(x)
#define TYPE_III(x, b1, b2, b3) TYPE(x)
#define END_TYPE }

#include SCHEMADIALECT

Change log

r4275 by cxl on Dec 8, 2011   Diff
Sql: More adjustments of sch introspection
Go to: 
Project members, sign in to write a code review

Older revisions

r4274 by cxl on Dec 8, 2011   Diff
*Sql: Fix of introspection of
TYPE/END_TABLE pair
r4269 by cxl on Dec 7, 2011   Diff
Sql: finalizing JoinRef and
introspection
r4264 by cxl on Dec 6, 2011   Diff
Sql: JoinRef (first iteration)
All revisions of this file

File info

Size: 5039 bytes, 154 lines

File properties

svn:eol-style
native
Powered by Google Project Hosting