-
Notifications
You must be signed in to change notification settings - Fork 0
/
entry.h
102 lines (94 loc) · 2.71 KB
/
entry.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef ENTRY_H
#define ENTRY_H
#include <vector>
#include <string>
#include <set>
#include <sstream>
class Field {
public:
enum Type {
b, c, d, e, f, i, l, p, ss, Wdt, Ws,
INVALID
};
enum Relation {
COLUMN,
BELONGS_TO,
MANY_TO_ONE,
MANY_TO_MANY
};
Type type;
std::string additionalType;
Relation relation;
std::string fieldName;
std::string databaseName;
void getIncludes(std::set<std::string> &s) {
switch(type) {
case Field::c:
case Field::p:
s.insert("class " + additionalType + ";");
break;
case Field::ss:
s.insert("#include <string>");
break;
case Field::Wdt:
s.insert("#include <Wt/WDateTime>");
s.insert("#include <Wt/Dbo/WtSqlTraits>");
break;
case Field::Ws:
s.insert("#include <Wt/WString>");
break;
default:
// built-in types
break;
}
}
void getFieldName(std::ostringstream &oss) {
oss << " ";
//TODO: Check for relation
switch(type) {
case Field::b:
oss << "bool";
break;
case Field::e:
case Field::c:
oss << additionalType;
break;
case Field::d:
oss << "double";
break;
case Field::f:
oss << "float";
break;
case Field::i:
oss << "int";
break;
case Field::l:
oss << "long";
break;
case Field::p:
oss << "Wt::Dbo::ptr<" << additionalType << ">";
break;
case Field::ss:
oss << "std::string";
break;
case Field::Wdt:
oss << "Wt::WDateTime";
break;
case Field::Ws:
oss << "Wt::WString";
break;
default:
// I dont know
break;
}
oss << " " << fieldName << ";" << std::endl;
}
};
class Class {
public:
bool noVersion;
std::string className;
std::string tableName;
std::vector<Field> fields;
};
#endif // ENTRY_H