Databaseconnectionclasses  0.5.3
hk_qbe.h
1 // ****************************************************************************
2 // copyright (c) 2000-2005 Horst Knorr <hk_classes@knoda.org>
3 // This file is part of the hk_classes library.
4 // This file may be distributed and/or modified under the terms of the
5 // GNU Library Public License version 2 as published by the Free Software
6 // Foundation and appearing in the file COPYING included in the
7 // packaging of this file.
8 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
9 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
10 // ****************************************************************************
11 #ifndef HK_QBE
12 #define HK_QBE
13 #include "hk_presentation.h"
14 #include "hk_string.h"
15 #include <list>
16 #include <vector>
17 class hk_qbeprivate;
18 class hk_qbe:public hk_presentation
19 {
20 public:
21 hk_qbe(void);
22 virtual ~hk_qbe();
26 enum enum_querytype{qt_select,qt_groupselect,qt_update,qt_delete};
27 enum enum_functiontype {ft_condition,ft_group,ft_sum,ft_count,ft_avg,ft_min,ft_max};
28 void set_querytype(enum_querytype,bool registerchange=true);
29 enum_querytype querytype(void) const;
30 void set_distinct(bool d,bool registerchange=true);
31 bool distinct(void) const;
32 bool create_sql(hk_string& sql);
33 enum enum_order{none,ascending,descending};
34 typedef class
35 {
36  public:
37  hk_string field;
38  int table;
39  hk_string alias;
40  enum_functiontype functiontype;
41  enum_order order;
42  bool show;
43  hk_string updatevalue;
44  vector<hk_string> conditions;
45 
47 
48 void clear_definition(bool registerchange=true);
49 void add_definition( const hk_string& field,
50  int table,
51  const hk_string& alias,
52  enum_functiontype functiontype,
53  enum_order order,
54  bool show,
55  const hk_string& updatevalue,
56  vector<hk_string>& conditions,
57  bool registerchange=true
58  );
59 void add_definition( hk_qbedataclass*, bool registerchange=true);
60 const list<hk_qbe::hk_qbedataclass>* definitionlist(void) ;
61 
62 
63 
64 virtual void savedata(ostream& s);
65 virtual void loaddata(xmlNodePtr definition);
66 
67 protected:
68  virtual void widget_specific_querytype_has_changed(enum_querytype oldtype,enum_querytype newtype);
69 private:
70  hk_string joindefinition(hk_datasource*);
71 hk_qbeprivate* p_private;
72 hk_string create_where(void);
73 hk_string create_depending_where(void);
74 hk_string create_from(void);
75 hk_string create_what(void);
76 hk_string create_order_by(void);
77 hk_string create_group_by(void);
78 hk_string create_update_set(void);
79 hk_string create_select_sql(bool&);
80 hk_string create_groupselect_sql(bool&);
81 hk_string create_update_sql(bool&);
82 hk_string create_delete_sql(bool&);
83 hk_string fieldname(hk_qbedataclass*,bool withalias=false);
84 //hk_string tablename(hk_qbedataclass*);
85 
86 };
87 
88 #endif //HK_QBE
enum_querytype
Definition: hk_qbe.h:26
represents a resultquery or a table of a database.
Definition: hk_datasource.h:45
base class for multidatasource based classes like forms and reports
Definition: hk_presentation.h:40
Definition: hk_qbe.h:34
virtual void loaddata(xmlNodePtr definition)
Definition: hk_qbe.cpp:162
Definition: hk_qbe.h:18
virtual void savedata(ostream &s)
Definition: hk_qbe.cpp:99
Definition: hk_qbe.cpp:17