PACK WOC  $VERSION$
qtout.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_QTOUT_H
7 #define WOC_QTOUT_H
8 
9 #include "processor.h"
10 
11 #include "mfile.h"
12 
13 class QDomElement;
14 
15 class WocQtOut;
16 
18 class WocQtTransaction:public QObject
19 {
20  Q_OBJECT
21  public:
23  explicit WocQtTransaction(WocQtOut*);
24  virtual ~WocQtTransaction(){}
26  virtual void newTransaction(const WocTransaction&)=0;
28  virtual void finalize()=0;
29  signals:
31  void errorFound();
32  protected:
34 };
35 
36 class WocQtClass;
37 class WocQtTable;
38 
44 class WocQtOut:public WocOutput
45 {
46  public:
49  explicit WocQtOut(QDomElement&);
51  ~WocQtOut()=0;
52 
55  void addIfaceHeaderPrefix(const QString&s){m_iface_prefix+=s;}
58  void addIfaceHeaderClass(const QString&s){m_iface_class+=s;}
60  void addIfaceImpl(const QString&);
61 
62  protected:
64  virtual void finalize();
66  virtual void newClass(const WocClass&);
68  virtual void newTable(const WocTable&);
70  virtual void newTransaction(const WocTransaction&);
71 
72  public:
74  enum FileType{
77  };
78 
80  QString qttype(const WocClass&,QString,bool dolist=true);
81  enum InOut{In,Out};
83  QString qttype(const WocTransaction&,QString,InOut);
85  QString qtobjtype(const WocTransaction&,QString,InOut);
88  void addFile(QString basename);
92  void addFile(FileType kind,QString fname);
94  void addProjectLine(QString);
96  void addPostIface(QString);
98  QString ifaceClassName()const{return m_prefix+"Interface";}
99 
101  inline QString namePrefix()const{return m_prefix;}
103  inline QString sharedPrefix()const{return m_cprefix;}
105  inline QString languageSpec()const{return m_lang;}
107  inline QString baseDir()const{return m_basedir;}
109  inline QString subDir()const{return m_subdir;}
111  inline QString destinationPath()const{return m_basedir+"/"+m_subdir;}
113  inline QString transactionBase()const{return m_transbase;}
114 
116  QByteArray exportLines()const;
118  QString exportSymbol()const;
119 
120  private:
122  void initVersionH();
123 
124  private:
126  mutable QString m_exportsym;
130  protected:
131  QString m_lang;
135 };
136 
139 {
140  public:
141  explicit WocQtClientOut(QDomElement&);
142 };
143 
146 {
147  public:
148  explicit WocQtServerOut(QDomElement&);
149 };
150 
151 #endif
QString sharedPrefix() const
returns the class name prefix for shared or unshared classes
Definition: qtout.h:103
virtual void newTransaction(const WocTransaction &)
overloaded slot, called for each new transaction
Definition: qtout.cpp:152
Definition: qtout.h:76
QString m_subdir
Definition: qtout.h:125
overwrites QFile to only generate a file if its new version differs from an existing one...
Definition: mfile.h:15
QString baseDir() const
returns the base directory of the project
Definition: qtout.h:107
virtual void finalize()
overloaded slot, called when parsing is finished
Definition: qtout.cpp:101
QString m_prefix
Definition: qtout.h:125
WocQtClientOut(QDomElement &)
Definition: qtout.cpp:234
virtual void newTable(const WocTable &)
overloaded slot, called for each new table
Definition: qtout.cpp:142
Definition: qtout.h:81
void addIfaceHeaderPrefix(const QString &s)
adds data to the prefix section of the interface class header, this is for #include's and forward dec...
Definition: qtout.h:55
Abstract base class for Qt client and server output.
Definition: qtout.h:44
stores the internal representation of a database table and its abstraction class
Definition: proctable.h:19
InOut
Definition: qtout.h:81
base class of all output generators
Definition: processor.h:35
WocQtServerOut(QDomElement &)
Definition: qtout.cpp:243
QString m_iface_prefix
Definition: qtout.h:129
FileType
types of files generated
Definition: qtout.h:74
void addIfaceImpl(const QString &)
adds code to the implementation file of the interface class
Definition: qtout.cpp:319
specialization that generates adequate output for Qt servers
Definition: qtout.h:145
Specialization that outputs classes for WocQtOut and its sub-classes.
Definition: qtclass.h:17
WocQtClass * qclass
Definition: qtout.h:132
bool m_clean
Definition: qtout.h:127
QString m_cprefix
Definition: qtout.h:125
QString m_basedir
Definition: qtout.h:125
QString transactionBase() const
returns the base class of all transactions
Definition: qtout.h:113
virtual void newTransaction(const WocTransaction &)=0
abstract helper: called for each new transaction
QString destinationPath() const
returns the complete path for files, baseDir()+subDir()
Definition: qtout.h:111
WocQtOut(QDomElement &)
creates a Qt output object from the corresponding XML tag that specifies what kind of output is desir...
Definition: qtout.cpp:19
void errorFound()
emitted if something goes wrong, this will cause the parser process to abort
void addFile(QString basename)
helper: adds a file to the project file
Definition: qtout.cpp:157
WocQtTransaction(WocQtOut *)
instantiates the transaction generator
Definition: qtout.cpp:254
void addProjectLine(QString)
helper: add a line to the project file
Definition: qtout.cpp:178
MFile m_pri
Definition: qtout.h:128
QString subDir() const
returns the sub directory relative to the project where to store files
Definition: qtout.h:109
virtual void newClass(const WocClass &)
overloaded slot, called for each new class
Definition: qtout.cpp:147
WocQtTransaction * qtrans
Definition: qtout.h:134
MFile m_ifacecpp
Definition: qtout.h:128
QString qttype(const WocClass &, QString, bool dolist=true)
helper: generate a proper Qt type for a property
Definition: qtout.cpp:184
MFile m_iface
Definition: qtout.h:128
QString m_exportsym
Definition: qtout.h:126
Definition: qtout.h:81
QString languageSpec() const
returns the language output spec
Definition: qtout.h:105
generates code for DB table wrappers in Qt so far this class is non-functional
Definition: qtdb.h:18
QString m_lang
Definition: qtout.h:131
Definition: qtout.h:75
internal representation of a transaction
Definition: proctrans.h:16
QString namePrefix() const
returns the class name prefix configured for this output
Definition: qtout.h:101
QString ifaceClassName() const
helper: returns the class name of the interface class
Definition: qtout.h:98
MFile m_hdr
Definition: qtout.h:128
void addIfaceHeaderClass(const QString &s)
adds data to the class body of the interface class header, this is for method declarations ...
Definition: qtout.h:58
WocQtOut * m_parent
Definition: qtout.h:33
QString exportSymbol() const
returns the name of the preprocessor symbol used for export
Definition: qtout.cpp:333
void initVersionH()
internal: generate the static header for version info
Definition: qtout.cpp:269
abstract base class for Qt transaction generator
Definition: qtout.h:18
QString qtobjtype(const WocTransaction &, QString, InOut)
helper: generate a proper QT type for a transaction variable, WO* only
Definition: qtout.cpp:223
QByteArray exportLines() const
returns some lines of code to define an export symbol
Definition: qtout.cpp:324
QString m_postiface
Definition: qtout.h:125
virtual ~WocQtTransaction()
Definition: qtout.h:24
WocQtTable * qtable
Definition: qtout.h:133
QString m_iface_class
Definition: qtout.h:129
bool m_export
Definition: qtout.h:127
specialization that generates adequate output for Qt clients
Definition: qtout.h:138
virtual void finalize()=0
abstract helper: called when parsing is about to finish
~WocQtOut()=0
deletes the output object
Definition: qtout.cpp:99
stores a communication class including serialization and deserialization information ...
Definition: procclass.h:26
void addPostIface(QString)
helper: adds a line after the class definition of the interface class
Definition: qtout.cpp:136
QString m_transbase
Definition: qtout.h:125