Databaseconnectionclasses  0.5.3
hk_class.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_CLASS
12 #define HK_CLASS
13 #include "hk_definitions.h"
14 #ifdef HAVE_CONFIG_H
15 #include "config.h"
16 #endif
17 #ifdef NO_IOSTREAM
18 #include <iostream.h>
19 #include <fstream.h>
20 #else
21 #include <fstream>
22 #include <iostream>
23 #endif //HAVE_IOSTREAM
24 
25 #include <libxml/xmlmemory.h>
26 #include <libxml/parser.h>
27 
28 
29 using namespace std;
30 class hk_connection;
31 class hk_presentation;
32 class hk_interpreter;
33 
34 typedef void messagewindowtype(const hk_string&);
35 typedef bool yesno_dialogtype(const hk_string&, bool );
36 typedef hk_string translatefunctiontype(const hk_string&);
37 typedef void password_dialogtype(hk_connection*,struct_connectionfields*);
38 typedef bool newpassword_dialogtype(hk_string&);
39 typedef hk_string stringvalue_dialogtype(const hk_string&);
40 enum enum_operationmode{file_open,file_save};
41 typedef hk_string file_dialogtype(const hk_string&,enum_operationmode);
42 //to display the progress of an action,returns true if cancel is pressed progress(currentposition,max);
43 typedef bool progress_dialogtype(long int,long int,const hk_string&);
52 class hk_class
53 {
54  public:
60 enum enum_interaction {noninteractive,interactive};
61 #ifdef HK_DEBUG
62 
66  void hkclassname(const hk_string& n);
67  hk_string hkclassname(void)const ;
72  void hkdebug(const hk_string& d)const ;
73  void hkdebug(const hk_string& d, const hk_string& e)const ;
74  void hkdebug(const hk_string& d, int i)const ;
75  void hkdebug(const hk_string& d, double i)const ;
79  void wanna_debug(bool d);
80  bool wanna_debug(void)const ;
85  static void set_generaldebug(bool d);
86  bool generaldebug(void){return p_generaldebug;}
87 #endif
88 
92  static hk_string hk_translate(const hk_string& t);
97  static void show_warningmessage(const hk_string& m);
102  static void set_warningmessage(messagewindowtype* m);
110  static bool show_yesnodialog(const hk_string& m, bool default_value);
115  static void set_yesnodialog(yesno_dialogtype* d);
123  static hk_string show_stringvaluedialog(const hk_string& t);
128  static void set_stringvaluedialog(stringvalue_dialogtype* t);
129  static void set_translatefunction(translatefunctiontype* t);
130 
131  static void set_filedialog(file_dialogtype* f);
132  static hk_string show_filedialog(const hk_string& f="",enum_operationmode m=file_open);
133 
134  static void set_directorydialog(stringvalue_dialogtype* f);
135  static hk_string show_directorydialog(const hk_string& f="");
136 
137 
143  static void set_showpedantic(bool s);
144  static bool showpedantic(void){return p_showpedantic;}
145  enum enum_measuresystem{cm,inch};
146  static void set_measuresystem(enum_measuresystem);
147  static enum_measuresystem measuresystem(void);
151  virtual void savedata(ostream& s);
155 // virtual void loaddata(const hk_string& definition);
156  virtual void loaddata(xmlNodePtr definition);
157  enum enum_tagtype{normaltag,mastertag};
171  static xmlNodePtr get_tagvalue(xmlNodePtr where, const hk_string &tag, hk_string &value, int position=1,enum_tagtype tagtype=normaltag);
172  static xmlNodePtr get_tagvalue(xmlNodePtr where, const hk_string &tag, unsigned long &value, int position=1);
173  static xmlNodePtr get_tagvalue(xmlNodePtr where, const hk_string &tag, unsigned int &value, int position=1);
174  static xmlNodePtr get_tagvalue(xmlNodePtr where, const hk_string &tag, long &value, int position=1);
175  static xmlNodePtr get_tagvalue(xmlNodePtr where, const hk_string &tag, int &value, int position=1);
176  static xmlNodePtr get_tagvalue(xmlNodePtr where, const hk_string &tag, bool &value, int position=1);
177  static xmlNodePtr get_tagvalue(xmlNodePtr &where, const hk_string &tag);
178 
179 
186  static void set_tagvalue(ostream& stream,const hk_string& tag,const hk_string& value);
187  static void set_tagvalue(ostream& stream,const hk_string& tag,unsigned long value);
188  static void set_tagvalue(ostream& stream,const hk_string& tag,unsigned int value);
189  static void set_tagvalue(ostream& stream,const hk_string& tag,long value);
190  static void set_tagvalue(ostream& stream,const hk_string& tag,int value);
191  static void set_tagvalue(ostream& stream,const hk_string& tag,bool value);
197  static void start_mastertag(ostream& stream,const hk_string& tag);
201  static void end_mastertag(ostream& stream,const hk_string& tag);
202  static void set_defaultdatetimeformat(const hk_string& timeformat,const hk_string& dateformat,const hk_string&datetimeformat);
203  static hk_string defaultdateformat(void);
204  static hk_string defaulttimeformat(void);
205  static hk_string defaultdatetimeformat(void);
206 
211  static void save_preferences(void);
215  static bool runtime_only(void);
220  static void set_locale(const hk_string& locale);
221  static hk_string locale(void);
222 
223  static void set_defaultdriver(const hk_string& d);
224  static hk_string defaultdriver(void) ;
225 
226  static void set_default_automatic_data_update(bool);
227  static bool default_automatic_data_update(void);
228 
229  protected:
230 
231  hk_class(void);
232  virtual ~hk_class(void);
233  hk_interpreter* new_interpreter(const hk_string& interpreter,hk_presentation*);
234  static hk_string p_defaulttimeformat;
235  static hk_string p_defaultdateformat;
236  static hk_string p_defaultdatetimeformat;
237  static bool p_runtime_only;
238 
239  private:
240  static void set_tag(const hk_string& tag);
241  static void set_levelspace(ostream& stream);
242  hk_string p_classname;
243 #ifdef HK_DEBUG
244  bool p_debug;
245 #endif
246  static yesno_dialogtype* p_yesno;
247  static messagewindowtype* p_warning;
248  static stringvalue_dialogtype* p_stringvalue;
249  static translatefunctiontype* p_translate;
250  static file_dialogtype* p_filedialog;
251  static stringvalue_dialogtype* p_directorydialog;
252  static hk_string p_begintag_begin;
253  static hk_string p_begintag_end;
254  static hk_string p_endtag_begin;
255  static hk_string p_endtag_end;
256  static hk_string p_begintag;
257  static hk_string p_endtag;
258  static hk_string p_emptytag;
259  static hk_string p_emptytag_begin;
260  static hk_string p_emptytag_end;
261  static unsigned int p_taglevel;
262 
263  static bool p_showpedantic;
264  static bool p_generaldebug;
265  static hk_string p_locale;
266  static hk_string p_defaultdriver;
267  static bool p_default_automatic_data_update;
268  static enum_measuresystem p_defaultmeasuresystem;
269 
270 };
271 
272  void show_warningmessage(const hk_string& m);
273  bool show_yesnodialog(const hk_string& m, bool default_value);
274  hk_string show_filedialog(const hk_string& f="",enum_operationmode m=file_open);
275  hk_string show_directorydialog(const hk_string& t);
276  hk_string show_stringvaluedialog(const hk_string& t);
277 
278 
279 
280 #endif
basic class for all other defined classes.
Definition: hk_class.h:52
connects to the SQL Server
Definition: hk_connection.h:31
enum_interaction
Definition: hk_class.h:60
Definition: hk_definitions.h:131
base class for multidatasource based classes like forms and reports
Definition: hk_presentation.h:40
basic class for script handling
Definition: hk_interpreter.h:44