gSAFE  1.3.8
hfactory.h
1 /* gSAFE - LIB
2  general Sql dAtabase FrontEnd
3  http://hyperprog.com/gsafe/
4 
5  (C) 2005-2013 Peter Deak (hyper80@gmail.com)
6 
7  License: GPLv2 http://www.gnu.org/licenses/gpl-2.0.html
8 
9  hfactory.h
10 */
11 
12 #ifndef GSAFE__HFACTORY_LIB_HEADER_FILE_X_
13 #define GSAFE__HFACTORY_LIB_HEADER_FILE_X_
14 
15 #include <QtCore>
16 #include <QtXml>
17 
19 /* @{ */
20 
21 #define TABLE 0
22 #define LIST 1
23 #define FIELDS 2
24 
25 class HTable;
26 class HList;
27 class HTableBase;
28 class HDataField;
29 
30 /* NOT DOCUMENTED: Helper class of HFactory. Do not use directly! */
31 class Hff_node
32 {
33 public:
34  QString name;
35  HDataField *f;
36 
37  Hff_node(QString namep,HDataField *fp);
38  ~Hff_node(void);
39 
40 };
41 
105 class HFactory : public QObject , QXmlDefaultHandler //, QXmlErrorHandler
106 {
107  Q_OBJECT
108 
109  public:
112  HFactory(QString rdata="");
114  ~HFactory(void);
115 
117  void appendTemplateData(QString rdata);
119  void clearTemplateData(void);
120 
124  int readFromFile(QFile *f);
129  int readFromFile(QString fn);
130 
134  HTableBase *genTable (QString part,int mode=TABLE);
135 
140  HTable *genHTable(QString part,QString inRole="");
141 
146  HList *genHList (QString part,QString inRole="");
147 
150  QString sqlCreateString(QString part);
151 
152  private:
153  int ttype; //HTable || HList = TABLE || LIST
154  int level; //deep in XML
155  bool fields_readed;
156  bool mainblock,read_on,fieldread_on; //Where I am, main block or in the requested part
157  QString pname; //the name of the requested part
158  QString fname; //the name of the currently read element
159  QString fpar_att,fpar_def,fpar_sql;
160  QString errstr;
161 
162  QString rawdata; //The raw XML data
163 
164  HTableBase *t; //I build this
165  HDataField *f; //..with these.
166 
167  QList<Hff_node *> *fieldlist;
168 
169  //buffer:
170  QString buffer,
171  buffer_sql,
172  buffer_exp,
173  buffer_tit,
174  buffer_tail,
175  buffer_def,
176  buffer_func,
177  buffer_valid,
178  buffer_hashf,
179  buffer_specsort,
180  buffer_popuptitle,
181  buffer_minimum,
182  buffer_maximum,
183  buffer_1,
184  buffer_2,
185  buffer_3,
186  buffer_4,
187  buffer_5,
188  buffer_6,
189  buffer_7;
190 
191  QStringList buffer_k,
192  buffer_v,
193  buffer_notvalid;
194 
195  QStringList markers;
196 
197  QStringList rolename;
198  QStringList rolemod;
199  QStringList roleval;
200 
201  bool default_readonly,
202  default_hide,
203  default_logging,
204  default_color;
205  int default_color_r,default_color_g,default_color_b;
206 
207 
208  bool easy,
209  editable,readonly,
210  show,hide,
211  logging,nologging,
212  color,
213  meldwithnext,
214  nomiddlestretch,
215  showprogress;
216  int guieditmaxwidth;
217  int r,g,b;
218  int sortc;
219  int fmin,fmax,fgroup;
220 
221  void insertDF(HDataField *df);
222 
223  public:
225  bool startDocument(void);
227  bool endDocument(void);
229  bool startElement( const QString& ns, const QString& ln, const QString& name,
230  const QXmlAttributes& atts);
232  bool endElement( const QString& ns, const QString& ln, const QString& name);
234  bool characters(const QString& ch);
236  QString errorString(void);
237 
239  bool warning(const QXmlParseException& exception);
241  bool error(const QXmlParseException& exception);
243  bool fatalError(const QXmlParseException& exception);
244 
245  private:
246  void setHDataFieldAttributes(HDataField * d);
247  void emptyBuffer(void);
248 
249  signals:
250  void errorSignal(QString err);
251 
252 };
253 
254 /* @} */
255 
256 #endif
HList * genHList(QString part, QString inRole="")
Definition: hfactory.cpp:73
QString errorString(void)
Definition: hfactory.cpp:122
bool characters(const QString &ch)
Definition: hfactory.cpp:647
bool startDocument(void)
Definition: hfactory.cpp:220
~HFactory(void)
Definition: hfactory.cpp:46
int readFromFile(QFile *f)
Definition: hfactory.cpp:94
bool endDocument(void)
Definition: hfactory.cpp:226
bool endElement(const QString &ns, const QString &ln, const QString &name)
Definition: hfactory.cpp:701
void appendTemplateData(QString rdata)
Definition: hfactory.cpp:111
HFactory(QString rdata="")
Definition: hfactory.cpp:30
bool fatalError(const QXmlParseException &exception)
Definition: hfactory.cpp:153
bool error(const QXmlParseException &exception)
Definition: hfactory.cpp:140
HTableBase * genTable(QString part, int mode=TABLE)
Definition: hfactory.cpp:166
bool warning(const QXmlParseException &exception)
Definition: hfactory.cpp:127
QString sqlCreateString(QString part)
Definition: hfactory.cpp:82
void clearTemplateData(void)
Definition: hfactory.cpp:117
HTable * genHTable(QString part, QString inRole="")
Definition: hfactory.cpp:64
bool startElement(const QString &ns, const QString &ln, const QString &name, const QXmlAttributes &atts)
Definition: hfactory.cpp:232