PACK WOC  $VERSION$
procclass.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_CLASS_H
7 #define WOC_PROCESSOR_CLASS_H
8 
9 #include <QList>
10 #include <QMap>
11 #include <QObject>
12 #include <QPair>
13 #include <QStringList>
14 
15 class QDomElement;
16 
18 struct WocEnum {
19  QString name,doc;
20  int val;
21  WocEnum(){val=0;}
22  WocEnum(QString n,int v,QString d=""){name=n;val=v;doc=d;}
23 };
24 
26 class WocClass
27 {
28  public:
30  WocClass(const QDomElement&);
31 
33  bool isValid()const{return m_valid;}
34 
36  QString name()const{return m_name;}
40  QString baseClass(QString lang,QString prefix)const;
41 
43  bool hasProperty(QString)const;
45  QStringList propertyNames()const;
47  QString propertyType(QString)const;
49  QString propertyPlainType(QString)const;
51  bool propertyIsIdentity(QString)const;
53  bool propertyIsAbstract(QString)const;
55  bool propertyIsAttribute(QString)const;
57  bool propertyIsElement(QString)const;
59  bool propertyIsSimpleElement(QString)const;
61  bool propertyIsEnum(QString)const;
63  bool propertyIsObject(QString)const;
65  bool propertyIsList(QString)const;
67  bool propertyIsInt(QString p)const{QString pt=propertyPlainType(p);return pt=="int" || pt=="int32" || pt=="int64";}
69  bool propertyIsBool(QString p)const{return propertyPlainType(p)=="bool";}
71  bool propertyIsString(QString p)const{QString pt=propertyPlainType(p);return pt=="string"||pt=="astring";}
73  bool propertyIsBlob(QString p)const{QString pt=propertyPlainType(p);return pt=="blob";}
74 
76  bool isAbstract(QString)const;
78  QStringList abstractLangs()const{return m_cabstract;}
79 
81  QStringList enumTypes()const{return m_enumvals.keys();}
83  bool hasEnumType(QString t)const{return m_enumvals.contains(t);}
85  QList<WocEnum> enumValues(QString t)const{return m_enumvals[t];}
86 
88  bool hasMapping(QString m)const{return m_maps.contains(m);}
90  QStringList mappingTables()const{return m_maps.keys();}
92  QStringList mappingProperties(QString)const;
94  QMap<QString,QString> mapping(QString m)const;
96  QString mapMethod(QString table,QString property,QString lang)const;
97 
99  QStringList docStrings()const{return m_docstrings;}
101  QString propDoc(QString p)const
102  {if(m_propdoc.contains(p))return m_propdoc[p];else return "";}
104  QString enumDoc(QString e)const
105  {if(m_enumdoc.contains(e))return m_enumdoc[e];else return QString();}
106 
107  private:
109  bool m_valid;
113  QStringList m_cabstract;
115  QString m_name;
117  QMap<QString,QString>m_base;
119  struct s_prop{
120  QString name,type;
122  };
123  QList<s_prop> m_props;
125  struct s_map{
126  QString column,property;
127  QMap<QString,QString>method;//lang->method
128  };
129  QMap<QString,QList<s_map> >m_maps;
131  QMap<QString,QList<WocEnum> >m_enumvals;
133  QMap<QString,QString>m_enumdoc;
134 
136  QStringList m_docstrings;
138  QMap<QString,QString>m_propdoc;
139 
140  //helper: contains predefined types sorted by serialization type
141  static const QStringList attrtypes,elemtypes;
142 };
143 
144 #endif
property info
Definition: procclass.h:119
QString column
Definition: procclass.h:126
QMap< QString, QList< s_map > > m_maps
Definition: procclass.h:129
bool propertyIsAbstract(QString) const
returns whether this property is abstract
Definition: procclass.cpp:260
bool propertyIsIdentity(QString) const
returns whether this property identifies the object instance
Definition: procclass.cpp:253
bool propertyIsObject(QString) const
returns whether the property is an object
Definition: procclass.cpp:304
QList< s_prop > m_props
Definition: procclass.h:123
QString enumDoc(QString e) const
returns base documentation for enums
Definition: procclass.h:104
int val
Definition: procclass.h:20
QString baseClass(QString lang, QString prefix) const
returns the name of the class it is derived from - default: WObject
Definition: procclass.cpp:364
QMap< QString, QString > method
Definition: procclass.h:127
QStringList propertyNames() const
returns a list of all property names
Definition: procclass.cpp:238
QList< WocEnum > enumValues(QString t) const
returns a list of enum values as name-value pairs
Definition: procclass.h:85
bool propertyIsSimpleElement(QString) const
returns whether this property is serialized as XML element, but not a class
Definition: procclass.cpp:293
bool propertyIsElement(QString) const
returns whether this property is serialized as XML element
Definition: procclass.cpp:299
QString mapMethod(QString table, QString property, QString lang) const
returns the method for a specific mapping or an empty string if it does not exist in the specified la...
Definition: procclass.cpp:352
QMap< QString, QString > m_propdoc
docu of properties
Definition: procclass.h:138
bool propertyIsBool(QString p) const
returns whether the property type is boolean
Definition: procclass.h:69
QMap< QString, QString > mapping(QString m) const
returns the specific mapping; map key=property, map value=column
Definition: procclass.cpp:332
bool propertyIsInt(QString p) const
returns whether the property type is integer
Definition: procclass.h:67
bool hasMapping(QString m) const
returns true if the given mapping exists
Definition: procclass.h:88
bool isValid() const
returns whether parsing was successful and this instance represents a valid communication class ...
Definition: procclass.h:33
QMap< QString, QString > m_base
name of parent class ("wolf" => the "base" attributes' content)
Definition: procclass.h:117
static const QStringList attrtypes
Definition: procclass.h:141
QString propDoc(QString p) const
returns documentation for a property
Definition: procclass.h:101
QStringList docStrings() const
returns documentation for this class
Definition: procclass.h:99
QString doc
Definition: procclass.h:19
QStringList enumTypes() const
returns the names of all enum types of this class
Definition: procclass.h:81
static const QStringList elemtypes
Definition: procclass.h:141
WocEnum(QString n, int v, QString d="")
Definition: procclass.h:22
QStringList mappingTables() const
returns the names of all tables for which a mapping exists
Definition: procclass.h:90
bool hasEnumType(QString t) const
returns true if the given enum type exists in this class
Definition: procclass.h:83
bool isabstract
Definition: procclass.h:121
QStringList mappingProperties(QString) const
returns the (correctly ordered) properties for a mapping
Definition: procclass.cpp:342
helper structure to store enums in classes and tables
Definition: procclass.h:18
QString propertyPlainType(QString) const
returns the plain type string of the property without "List:"
Definition: procclass.cpp:275
mappings: "table-name" => List of ("column-name","property-name")
Definition: procclass.h:125
QStringList m_docstrings
docu of class itself
Definition: procclass.h:136
bool m_valid
valid: parsing the WOLF succeeded
Definition: procclass.h:109
bool hasProperty(QString) const
returns true of it has a property with this name
Definition: procclass.cpp:231
QMap< QString, QString > m_enumdoc
enum types: "type-name" => "documentation"
Definition: procclass.h:133
QString m_name
class name without prefix
Definition: procclass.h:115
bool propertyIsAttribute(QString) const
returns whether this property is serialized as XML attribute
Definition: procclass.cpp:283
WocEnum()
Definition: procclass.h:21
bool propertyIsString(QString p) const
returns whether the property type is string
Definition: procclass.h:71
QString propertyType(QString) const
returns the type string of the property, including "List:" if applicable
Definition: procclass.cpp:246
QStringList abstractLangs() const
returns the languages in which the class is conditionally abstract
Definition: procclass.h:78
QStringList m_cabstract
cabstract: conditional abstract - just for one or two languages; abstract overrides cabstract! ...
Definition: procclass.h:113
QString name
Definition: procclass.h:19
QString name
Definition: procclass.h:120
bool propertyIsBlob(QString p) const
returns whether the property type is blob
Definition: procclass.h:73
QString name() const
returns the class name
Definition: procclass.h:36
bool m_abstract
abstract: the class is declared abstract (isAbstract may return true even if this is false) ...
Definition: procclass.h:111
QMap< QString, QList< WocEnum > > m_enumvals
enum types: "type-name" => List of ("constant-name",int-constant-value)
Definition: procclass.h:131
bool isid
Definition: procclass.h:121
QString type
Definition: procclass.h:120
WocClass(const QDomElement &)
parses XML to create itself
Definition: procclass.cpp:23
bool propertyIsEnum(QString) const
returns whether this property has an enum type
Definition: procclass.cpp:316
stores a communication class including serialization and deserialization information ...
Definition: procclass.h:26
QString property
Definition: procclass.h:126
bool propertyIsList(QString) const
returns whether the property is a list of values (false for scalars)
Definition: procclass.cpp:326
bool isAbstract(QString) const
returns whether the class is abstract in the requested language (needs to be customized); it is autom...
Definition: procclass.cpp:267