PACK WOC  $VERSION$
proctable.h
Go to the documentation of this file.
1 // Copyright (C) 2009-2011 by Konrad Rosenbaum <konrad@silmor.de>
2 // protected under the GNU GPL version 3 or at your option any newer.
3 // See COPYING.GPL file that comes with this distribution.
4 //
5 
6 #ifndef WOC_PROCESSOR_TABLE_H
7 #define WOC_PROCESSOR_TABLE_H
8 
9 #include <QList>
10 #include <QMap>
11 #include <QObject>
12 #include <QPair>
13 #include <QStringList>
14 
15 class QDomElement;
16 class WocEnum;
17 
19 class WocTable
20 {
21  public:
23  WocTable();
25  WocTable(const QDomElement&);
26 
28  bool isValid()const{return m_valid;}
29 
31  QString name()const{return m_name;}
33  QString baseClass()const{return m_base;}
34 
36  bool inBackup()const{return m_backup;}
38  QString backupKey()const{return m_backupkey;}
40  int backupGroupSize()const{return m_backupsize;}
41 
43  bool hasColumn(QString)const;
45  QStringList columns()const;
47  QStringList primaryColumns()const;
49  QString columnType(QString)const;
51  bool columnIsNull(QString)const;
53  bool columnIsPrimary(QString)const;
55  bool columnHasDefault(QString)const;
57  QString columnDefault(QString)const;
59  bool columnIsForeign(QString)const;
61  QString columnForeign(QString)const;
63  bool columnIsIndexed(QString)const;
65  bool columnIsUnique(QString)const;
67  QList<WocEnum> columnEnums(QString)const;
69  QString columnCall(QString col,QString lang)const;
70 
72  QList<WocEnum> getEnums()const;
73 
75  QStringList foreigns()const;
77  QString foreignQuery(QString)const;
79  bool haveForeign(QString)const;
80 
83  QList<QMap<QString,QString> > presets()const{return m_presets;}
84 
86  static void parseAuditStatic(const QDomElement&);
88  bool isAuditable()const{return m_audit;}
90  WocTable auditTable()const;
92  QStringList auditColumns()const;
93 
95  QStringList uniqueConstraints()const{return m_uniquecols;}
96 
98  QStringList docStrings()const{return m_docstrings;}
100  QString columnDoc(QString c)const;
102  QString foreignDoc(QString c)const
103  {if(m_fordocs.contains(c))return m_fordocs[c];else return "";}
104 
105  private:
109  struct s_col {
112  QList<WocEnum>enumvals;
113  QMap<QString,QString>methodcalls;
114  };
116  static QList<s_col>m_staticauditcolumns;
117  QList<QPair<QString,QString> >m_foreign;
118  QList<QMap<QString,QString> >m_presets;
119  int m_backupsize=-1;
120 
122  QMap<QString,QString>m_fordocs;
123 
124  //helper method: parses a single column element
125  static QPair<bool,s_col> parseColumn(const QDomElement&,QString);
126 };
127 
128 
129 #endif
QStringList m_uniquecols
Definition: proctable.h:121
static QList< s_col > m_staticauditcolumns
Definition: proctable.h:116
QList< QMap< QString, QString > > m_presets
Definition: proctable.h:118
QString name() const
returns the table name
Definition: proctable.h:31
QList< QMap< QString, QString > > presets() const
returns a list of all preset values (to be generated when the DB is created); each entry in the list ...
Definition: proctable.h:83
stores the internal representation of a database table and its abstraction class
Definition: proctable.h:19
QList< QPair< QString, QString > > m_foreign
Definition: proctable.h:117
bool columnHasDefault(QString) const
returns whether the column has a default
Definition: proctable.cpp:299
QString type
Definition: proctable.h:110
QStringList docStrings() const
returns table documentation
Definition: proctable.h:98
QMap< QString, QString > methodcalls
Definition: proctable.h:113
bool isunique
Definition: proctable.h:111
bool columnIsIndexed(QString) const
returns whether the column has an index
Definition: proctable.cpp:355
QStringList primaryColumns() const
returns the list of all primary key columns
Definition: proctable.cpp:266
QString columnDefault(QString) const
returns the default value of the column (empty string if there is none)
Definition: proctable.cpp:307
QString columnType(QString) const
returns the data type of the column
Definition: proctable.cpp:275
static void parseAuditStatic(const QDomElement &)
parses the static part of auditing
Definition: proctable.cpp:417
QList< s_col > m_columns
Definition: proctable.h:115
QString backupKey() const
returns which column the table uses for backup grouping
Definition: proctable.h:38
bool inBackup() const
returns whether the table is marked for backup
Definition: proctable.h:36
QList< WocEnum > getEnums() const
returns all enum definitions of the table; see also columnEnums
Definition: proctable.cpp:331
int m_backupsize
Definition: proctable.h:119
bool isValid() const
returns whether this instance is valid, ie.
Definition: proctable.h:28
WocTable auditTable() const
creates and returns the table instance that represents the audit table
Definition: proctable.cpp:432
bool m_audit
Definition: proctable.h:106
QList< WocEnum > enumvals
Definition: proctable.h:112
QString m_backupkey
Definition: proctable.h:107
int backupGroupSize() const
returns the default group size for backup or <=0 if default is to be used
Definition: proctable.h:40
WocTable()
initializes an invalid table
Definition: proctable.cpp:24
QStringList uniqueConstraints() const
returns all complex Unique constraints (those not defined for a single column)
Definition: proctable.h:95
QString doc
Definition: proctable.h:110
bool isindex
Definition: proctable.h:111
QString defaultval
Definition: proctable.h:110
bool isnull
Definition: proctable.h:111
QString baseClass() const
returns the parent class of the table class - default: WobTable
Definition: proctable.h:33
bool columnIsPrimary(QString) const
returns whether the column is part of the primary key
Definition: proctable.cpp:291
QStringList foreigns() const
returns a list of all foreign definitions - methods that return data from other tables ...
Definition: proctable.cpp:380
QString name
Definition: proctable.h:110
QList< WocEnum > columnEnums(QString) const
returns enum definitions of the column - each pair contains the symbolic name in first and the assign...
Definition: proctable.cpp:323
QString foreignQuery(QString) const
returns the definition of a specific foreign table query method
Definition: proctable.cpp:388
bool haveForeign(QString) const
returns whether a foreign table query method exists
Definition: proctable.cpp:396
QString foreignDoc(QString c) const
returns foreign getter documentation
Definition: proctable.h:102
bool isAuditable() const
returns whether the table is auditable
Definition: proctable.h:88
QList< s_col > m_auditcolumns
Definition: proctable.h:115
QMap< QString, QString > m_fordocs
Definition: proctable.h:122
helper structure to store enums in classes and tables
Definition: procclass.h:18
holds data for a DB table column
Definition: proctable.h:109
QString m_name
Definition: proctable.h:107
QString columnCall(QString col, QString lang) const
returns the insert call of a column for a specific language; empty string if there is none ...
Definition: proctable.cpp:404
bool columnIsNull(QString) const
returns whether the column allows NULLs
Definition: proctable.cpp:283
QString columnDoc(QString c) const
returns column documentation
Definition: proctable.cpp:371
QStringList auditColumns() const
returns the names of audit columns (except auditid)
Definition: proctable.cpp:256
QString foreign
Definition: proctable.h:110
bool m_backup
Definition: proctable.h:106
QString m_base
Definition: proctable.h:107
QString columnForeign(QString) const
returns the foreign key reference of the column in the format table:column
Definition: proctable.cpp:347
bool m_valid
Definition: proctable.h:106
bool hasColumn(QString) const
returns whether the table has a column with this name
Definition: proctable.cpp:315
bool columnIsUnique(QString) const
returns whether the column has a unique constraint
Definition: proctable.cpp:363
bool columnIsForeign(QString) const
returns whether the column is a foreign key
Definition: proctable.cpp:339
QStringList m_docstrings
Definition: proctable.h:121
bool isprime
Definition: proctable.h:111
QStringList columns() const
returns a list of all defined column names
Definition: proctable.cpp:248
static QPair< bool, s_col > parseColumn(const QDomElement &, QString)
Definition: proctable.cpp:166