00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef HK_CLASS
00012 #define HK_CLASS
00013 #include "hk_definitions.h"
00014 #ifdef HAVE_CONFIG_H
00015 #include "config.h"
00016 #endif
00017 #ifdef NO_IOSTREAM
00018 #include <iostream.h>
00019 #include <fstream.h>
00020 #else
00021 #include <fstream>
00022 #include <iostream>
00023 #endif //HAVE_IOSTREAM
00024
00025 #include <libxml/xmlmemory.h>
00026 #include <libxml/parser.h>
00027
00028
00029 using namespace std;
00030 class hk_connection;
00031 class hk_presentation;
00032 class hk_interpreter;
00033
00034 typedef void messagewindowtype(const hk_string&);
00035 typedef bool yesno_dialogtype(const hk_string&, bool );
00036 typedef hk_string translatefunctiontype(const hk_string&);
00037 typedef void password_dialogtype(hk_connection*,struct_connectionfields*);
00038 typedef bool newpassword_dialogtype(hk_string&);
00039 typedef hk_string stringvalue_dialogtype(const hk_string&);
00040 enum enum_operationmode{file_open,file_save};
00041 typedef hk_string file_dialogtype(const hk_string&,enum_operationmode);
00042
00043 typedef bool progress_dialogtype(long int,long int,const hk_string&);
00052 class hk_class
00053 {
00054 public:
00060 enum enum_interaction {noninteractive,interactive};
00061 #ifdef HK_DEBUG
00062
00066 void hkclassname(const hk_string& n);
00067 hk_string hkclassname(void)const ;
00072 void hkdebug(const hk_string& d)const ;
00073 void hkdebug(const hk_string& d, const hk_string& e)const ;
00074 void hkdebug(const hk_string& d, int i)const ;
00075 void hkdebug(const hk_string& d, double i)const ;
00079 void wanna_debug(bool d);
00080 bool wanna_debug(void)const ;
00085 static void set_generaldebug(bool d);
00086 bool generaldebug(void){return p_generaldebug;}
00087 #endif
00088
00092 static hk_string hk_translate(const hk_string& t);
00097 static void show_warningmessage(const hk_string& m);
00102 static void set_warningmessage(messagewindowtype* m);
00110 static bool show_yesnodialog(const hk_string& m, bool default_value);
00115 static void set_yesnodialog(yesno_dialogtype* d);
00123 static hk_string show_stringvaluedialog(const hk_string& t);
00128 static void set_stringvaluedialog(stringvalue_dialogtype* t);
00129 static void set_translatefunction(translatefunctiontype* t);
00130
00131 static void set_filedialog(file_dialogtype* f);
00132 static hk_string show_filedialog(const hk_string& f="",enum_operationmode m=file_open);
00133
00134 static void set_directorydialog(stringvalue_dialogtype* f);
00135 static hk_string show_directorydialog(const hk_string& f="");
00136
00137
00143 static void set_showpedantic(bool s);
00144 static bool showpedantic(void){return p_showpedantic;}
00145 enum enum_measuresystem{cm,inch};
00146 static void set_measuresystem(enum_measuresystem);
00147 static enum_measuresystem measuresystem(void);
00151 virtual void savedata(ostream& s);
00155
00156 virtual void loaddata(xmlNodePtr definition);
00157 enum enum_tagtype{normaltag,mastertag};
00171 static xmlNodePtr get_tagvalue(xmlNodePtr where, const hk_string &tag, hk_string &value, int position=1,enum_tagtype tagtype=normaltag);
00172 static xmlNodePtr get_tagvalue(xmlNodePtr where, const hk_string &tag, unsigned long &value, int position=1);
00173 static xmlNodePtr get_tagvalue(xmlNodePtr where, const hk_string &tag, unsigned int &value, int position=1);
00174 static xmlNodePtr get_tagvalue(xmlNodePtr where, const hk_string &tag, long &value, int position=1);
00175 static xmlNodePtr get_tagvalue(xmlNodePtr where, const hk_string &tag, int &value, int position=1);
00176 static xmlNodePtr get_tagvalue(xmlNodePtr where, const hk_string &tag, bool &value, int position=1);
00177 static xmlNodePtr get_tagvalue(xmlNodePtr &where, const hk_string &tag);
00178
00179
00186 static void set_tagvalue(ostream& stream,const hk_string& tag,const hk_string& value);
00187 static void set_tagvalue(ostream& stream,const hk_string& tag,unsigned long value);
00188 static void set_tagvalue(ostream& stream,const hk_string& tag,unsigned int value);
00189 static void set_tagvalue(ostream& stream,const hk_string& tag,long value);
00190 static void set_tagvalue(ostream& stream,const hk_string& tag,int value);
00191 static void set_tagvalue(ostream& stream,const hk_string& tag,bool value);
00197 static void start_mastertag(ostream& stream,const hk_string& tag);
00201 static void end_mastertag(ostream& stream,const hk_string& tag);
00202 static void set_defaultdatetimeformat(const hk_string& timeformat,const hk_string& dateformat,const hk_string&datetimeformat);
00203 static hk_string defaultdateformat(void);
00204 static hk_string defaulttimeformat(void);
00205 static hk_string defaultdatetimeformat(void);
00206
00211 static void save_preferences(void);
00215 static bool runtime_only(void);
00220 static void set_locale(const hk_string& locale);
00221 static hk_string locale(void);
00222
00223 static void set_defaultdriver(const hk_string& d);
00224 static hk_string defaultdriver(void) ;
00225
00226 static void set_default_automatic_data_update(bool);
00227 static bool default_automatic_data_update(void);
00228
00229 protected:
00230
00231 hk_class(void);
00232 virtual ~hk_class(void);
00233 hk_interpreter* new_interpreter(const hk_string& interpreter,hk_presentation*);
00234 static hk_string p_defaulttimeformat;
00235 static hk_string p_defaultdateformat;
00236 static hk_string p_defaultdatetimeformat;
00237 static bool p_runtime_only;
00238
00239 private:
00240 static void set_tag(const hk_string& tag);
00241 static void set_levelspace(ostream& stream);
00242 hk_string p_classname;
00243 #ifdef HK_DEBUG
00244 bool p_debug;
00245 #endif
00246 static yesno_dialogtype* p_yesno;
00247 static messagewindowtype* p_warning;
00248 static stringvalue_dialogtype* p_stringvalue;
00249 static translatefunctiontype* p_translate;
00250 static file_dialogtype* p_filedialog;
00251 static stringvalue_dialogtype* p_directorydialog;
00252 static hk_string p_begintag_begin;
00253 static hk_string p_begintag_end;
00254 static hk_string p_endtag_begin;
00255 static hk_string p_endtag_end;
00256 static hk_string p_begintag;
00257 static hk_string p_endtag;
00258 static hk_string p_emptytag;
00259 static hk_string p_emptytag_begin;
00260 static hk_string p_emptytag_end;
00261 static unsigned int p_taglevel;
00262
00263 static bool p_showpedantic;
00264 static bool p_generaldebug;
00265 static hk_string p_locale;
00266 static hk_string p_defaultdriver;
00267 static bool p_default_automatic_data_update;
00268 static enum_measuresystem p_defaultmeasuresystem;
00269
00270 };
00271
00272 void show_warningmessage(const hk_string& m);
00273 bool show_yesnodialog(const hk_string& m, bool default_value);
00274 hk_string show_filedialog(const hk_string& f="",enum_operationmode m=file_open);
00275 hk_string show_directorydialog(const hk_string& t);
00276 hk_string show_stringvaluedialog(const hk_string& t);
00277
00278
00279
00280 #endif