|
Databaseconnectionclasses
0.5.3
|
represents a particular database on the SQL Server More...
#include <hk_database.h>


Public Types | |
| enum | enum_storage { st_overwrite, st_storechanges } |
| enum | enum_storagemode { central, local } |
Public Types inherited from hk_class | |
| enum | enum_interaction { noninteractive, interactive } |
| enum | enum_measuresystem { cm, inch } |
| enum | enum_tagtype { normaltag, mastertag } |
Public Member Functions | |
| virtual bool | set_name (const hk_string &n) |
| hk_string | name (void) |
| vector< hk_string > * | tablelist (bool with_systemtable=false) |
| vector< hk_string > * | viewlist () |
| vector< hk_string > * | tableviewlist (bool with_systemtable=false) |
| vector< hk_string > * | querylist (void) |
| vector< hk_string > * | formlist (void) |
| vector< hk_string > * | reportlist (void) |
| vector< hk_string > * | modulelist (void) |
| hk_datasource * | new_table (const hk_string &name="", hk_presentation *p=NULL) |
| hk_datasource * | new_resultquery (hk_presentation *p=NULL) |
| hk_actionquery * | new_actionquery (void) |
| hk_datasource * | new_view (const hk_string &name="", hk_presentation *p=NULL) |
| hk_datasource * | load_datasource (const hk_string &name, datasourcetype dt=dt_table, hk_presentation *p=NULL) |
| virtual bool | delete_table (const hk_string &table, enum_interaction x=interactive) |
| virtual bool | delete_view (const hk_string &view, enum_interaction x=interactive) |
| bool | table_exists (const hk_string &tablename) |
| bool | view_exists (const hk_string &viewname) |
| bool | query_exists (const hk_string &queryname) |
| bool | form_exists (const hk_string &formname) |
| bool | report_exists (const hk_string &reportname) |
| hk_connection * | connection (void) const |
| ofstream * | savestream (const hk_string &name, filetype type, bool ask_before_overwrite=true) |
| ofstream * | savestream (const hk_string &name, filetype type, bool ask_before_overwrite, bool with_header, bool ask_for_new_name=false) |
| ofstream * | savestream (enum_storage storage, const hk_string &name, filetype type, bool ask_before_overwrite, bool with_header, bool ask_for_new_name) |
| STRINGSTREAM * | savestringstream (filetype type) |
| STRINGSTREAM * | savestringstream (filetype type, bool with_header) |
| bool | delete_file (const hk_string &name, filetype type, enum_interaction x=interactive) |
| hk_presentation * | existing_presentation (const hk_string &name, hk_presentation::enum_presentationtype t) |
| hk_form * | existing_form (const hk_string name) |
| hk_report * | existing_report (const hk_string name) |
| void | save (const hk_string &statement, const hk_string &name, filetype type, bool ask_before_overwrite=true, bool ask_for_new_name=false) |
| void | save (enum_storage storage, const hk_string &statement, const hk_string &name, filetype type, bool ask_before_overwrite=true, bool ask_for_new_name=false) |
| hk_string | load (const hk_string &name, filetype type) |
| xmlNodePtr | xmlload (const hk_string &name, filetype type) |
| hk_string | database_path (void) |
| hk_string | fileendings (filetype e) |
| hk_string | fileendings (objecttype e) |
| bool | copy_table (hk_datasource *fromdatasource, bool schema_and_data, bool replacetable, bool ask, progress_dialogtype *progressdialog=NULL) |
| bool | copy_view (hk_datasource *fromdatasource, progress_dialogtype *progressdialog=NULL, const hk_string &newname="") |
| hk_form * | new_formvisible (void) |
| hk_form * | new_dialogformvisible (void) |
| hk_report * | new_reportvisible (void) |
| hk_dstable * | new_tablevisible (void) |
| hk_dsquery * | new_queryvisible (void) |
| void | set_usewidgetparent (hk_class *) |
| bool | rename_table (const hk_string &originalname, const hk_string &newname, enum_interaction x=interactive) |
| bool | rename_file (const hk_string &originalname, const hk_string &newname, filetype type, enum_interaction x=interactive) |
| void | disable (void) |
| bool | store_connectionfile (const hk_url &url, bool store_password=false) |
| void | set_storagemode (filetype, enum_storagemode load, enum_storagemode store) |
| enum_storagemode | storagemode (filetype) |
| enum_storagemode | loadmode (filetype) |
| bool | create_centralstoragetable (void) |
| bool | has_centralstoragetable (void) |
| hk_string | load_local (const hk_string &name, filetype type) |
| hk_string | load_central (const hk_string &name, filetype type) |
| xmlNodePtr | xmlload_local (const hk_string &name, filetype type) |
| xmlNodePtr | xmlload_central (const hk_string &name, filetype type) |
| void | save_local (enum_storage storage, const hk_string &statement, const hk_string &name, filetype type, bool ask_before_overwrite, bool ask_for_new_name) |
| void | save_local (const hk_string &statement, const hk_string &name, filetype type, bool ask_before_overwrite, bool ask_for_new_name) |
| void | save_central (const hk_string &statement, const hk_string &name, filetype type, bool ask_before_overwrite, bool ask_for_new_name) |
| void | save_central (enum_storage storage, const hk_string &statement, const hk_string &name, filetype type, bool ask_before_overwrite, bool ask_for_new_name) |
| bool | delete_localfile (const hk_string &name, filetype type, enum_interaction x=interactive) |
| bool | delete_centralfile (const hk_string &name, filetype type, enum_interaction x=interactive) |
| vector< hk_string > * | filelist (filetype type) |
| vector< hk_string > * | local_filelist (filetype type) |
| vector< hk_string > * | central_filelist (filetype type) |
| void | save_configuration (void) |
| list< hk_presentation * > * | presentationlist () const |
| void | set_databasecharset (const hk_string &charset) |
| hk_string | databasecharset (void) const |
| void | set_automatic_data_update (bool u) |
| bool | is_automatic_data_update (void) |
Public Member Functions inherited from hk_class | |
| void | hkclassname (const hk_string &n) |
| hk_string | hkclassname (void) const |
| void | hkdebug (const hk_string &d) const |
| void | hkdebug (const hk_string &d, const hk_string &e) const |
| void | hkdebug (const hk_string &d, int i) const |
| void | hkdebug (const hk_string &d, double i) const |
| void | wanna_debug (bool d) |
| bool | wanna_debug (void) const |
| bool | generaldebug (void) |
Static Public Member Functions | |
| static void | set_new_formvisiblefunction (newform_type *) |
| static void | set_new_dialogformvisiblefunction (newform_type *) |
| static void | set_new_reportvisiblefunction (newreport_type *) |
| static void | set_new_tablevisiblefunction (newtable_type *) |
| static void | set_new_queryvisiblefunction (newquery_type *) |
Static Public Member Functions inherited from hk_class | |
| static void | set_generaldebug (bool d) |
| static hk_string | hk_translate (const hk_string &t) |
| static void | show_warningmessage (const hk_string &m) |
| static void | set_warningmessage (messagewindowtype *m) |
| static bool | show_yesnodialog (const hk_string &m, bool default_value) |
| static void | set_yesnodialog (yesno_dialogtype *d) |
| static hk_string | show_stringvaluedialog (const hk_string &t) |
| static void | set_stringvaluedialog (stringvalue_dialogtype *t) |
| static void | set_translatefunction (translatefunctiontype *t) |
| static void | set_filedialog (file_dialogtype *f) |
| static hk_string | show_filedialog (const hk_string &f="", enum_operationmode m=file_open) |
| static void | set_directorydialog (stringvalue_dialogtype *f) |
| static hk_string | show_directorydialog (const hk_string &f="") |
| static void | set_showpedantic (bool s) |
| static bool | showpedantic (void) |
| static void | set_measuresystem (enum_measuresystem) |
| static enum_measuresystem | measuresystem (void) |
| static xmlNodePtr | get_tagvalue (xmlNodePtr where, const hk_string &tag, hk_string &value, int position=1, enum_tagtype tagtype=normaltag) |
| static xmlNodePtr | get_tagvalue (xmlNodePtr where, const hk_string &tag, unsigned long &value, int position=1) |
| static xmlNodePtr | get_tagvalue (xmlNodePtr where, const hk_string &tag, unsigned int &value, int position=1) |
| static xmlNodePtr | get_tagvalue (xmlNodePtr where, const hk_string &tag, long &value, int position=1) |
| static xmlNodePtr | get_tagvalue (xmlNodePtr where, const hk_string &tag, int &value, int position=1) |
| static xmlNodePtr | get_tagvalue (xmlNodePtr where, const hk_string &tag, bool &value, int position=1) |
| static xmlNodePtr | get_tagvalue (xmlNodePtr &where, const hk_string &tag) |
| static void | set_tagvalue (ostream &stream, const hk_string &tag, const hk_string &value) |
| static void | set_tagvalue (ostream &stream, const hk_string &tag, unsigned long value) |
| static void | set_tagvalue (ostream &stream, const hk_string &tag, unsigned int value) |
| static void | set_tagvalue (ostream &stream, const hk_string &tag, long value) |
| static void | set_tagvalue (ostream &stream, const hk_string &tag, int value) |
| static void | set_tagvalue (ostream &stream, const hk_string &tag, bool value) |
| static void | start_mastertag (ostream &stream, const hk_string &tag) |
| static void | end_mastertag (ostream &stream, const hk_string &tag) |
| static void | set_defaultdatetimeformat (const hk_string &timeformat, const hk_string &dateformat, const hk_string &datetimeformat) |
| static hk_string | defaultdateformat (void) |
| static hk_string | defaulttimeformat (void) |
| static hk_string | defaultdatetimeformat (void) |
| static void | save_preferences (void) |
| static bool | runtime_only (void) |
| static void | set_locale (const hk_string &locale) |
| static hk_string | locale (void) |
| static void | set_defaultdriver (const hk_string &d) |
| static hk_string | defaultdriver (void) |
| static void | set_default_automatic_data_update (bool) |
| static bool | default_automatic_data_update (void) |
Protected Member Functions | |
| hk_database (hk_connection *c) | |
| bool | select_db (const hk_string &newname) |
| void | inform_datasources_before_closing (void) |
| virtual void | driver_specific_tablelist (void) |
| virtual void | driver_specific_viewlist (void) |
| virtual hk_datasource * | driver_specific_new_table (hk_presentation *p) |
| virtual hk_datasource * | driver_specific_new_view (hk_presentation *p) |
| virtual hk_datasource * | driver_specific_new_resultquery (hk_presentation *p) |
| virtual hk_actionquery * | driver_specific_new_actionquery (void) |
| virtual bool | driver_specific_rename_table (const hk_string &, const hk_string &) |
| virtual bool | driver_specific_select_db (void) |
| virtual void | driver_specific_set_name (void) |
| void | ds_remove (hk_data *ds) |
| virtual void | connection_connected (void) |
| virtual void | connection_disconnected (void) |
| void | dbvisible_add (hk_dbvisible *v) |
| void | dbvisible_remove (hk_dbvisible *v) |
| void | clear_visiblelist (void) |
| virtual void | before_source_vanishes (void) |
| void | presentation_add (hk_presentation *p) |
| void | presentation_remove (hk_presentation *p) |
| void | load_configuration (void) |
| virtual void | savedata (ostream &s) |
| virtual void | loaddata (xmlNodePtr definition) |
| void | inform_datasources_filelist_changes (listtype type) |
Protected Member Functions inherited from hk_class | |
| hk_interpreter * | new_interpreter (const hk_string &interpreter, hk_presentation *) |
Protected Attributes | |
| hk_connection * | p_connection |
| vector< hk_string > | p_tablelist |
| vector< hk_string > | p_viewlist |
| vector< hk_string > | p_tableviewlist |
| hk_url | p_url |
Friends | |
| class | hk_datasource |
| class | hk_actionquery |
| class | hk_connection |
| class | hk_dbvisible |
| class | hk_presentation |
Additional Inherited Members | |
Static Protected Attributes inherited from hk_class | |
| static hk_string | p_defaulttimeformat ="h:m:s" |
| static hk_string | p_defaultdateformat ="D.M.Y" |
| static hk_string | p_defaultdatetimeformat ="D.M.Y h:m:s" |
| static bool | p_runtime_only =false |
represents a particular database on the SQL Server
represents a particular existing database on the SQL Server. To use it set the name of an existing database with set_name To create a new database use hk_connection::create_database.
|
inline |
Referenced by hk_datasource::add_reference(), hk_datasource::column_by_name(), hk_datasource::columnname_occurances(), hk_connection::copy_database(), copy_table(), hk_datasource::create_table_now(), delete_table(), hk_datasource::drop_index(), hk_datasource::store_changed_data(), and hk_datasource::systemcolumnname().
| bool hk_database::copy_table | ( | hk_datasource * | fromdatasource, |
| bool | schema_and_data, | ||
| bool | replacetable, | ||
| bool | ask, | ||
| progress_dialogtype * | progressdialog = NULL |
||
| ) |
creates a new table and uses an existing datasource as a template
| fromdatasource | the datasource which is used as a template |
| schema_and_data | if true the table will be created and the data copied, if false the data will be not copied |
| replacetable | see parameter ask for details |
| ask | ask=true and replacetable=true => you will be warned before overwriting an old table ask=true and replacetable=false => a new name will be asked ask=false and replacetable=true => an old table will be overwritten without warning ask=false and replacetable=false => copy_table immediately stops and returns false, if a table already exists |
References hk_datasource::column_by_name(), hk_datasource::columnname_occurance(), hk_datasource::columns(), hk_column::columntype(), connection(), hk_datasource::disable(), hk_datasource::driver_specific_after_copy_table(), hk_datasource::enable(), hk_datasource::goto_first(), hk_datasource::goto_next(), hk_datasource::goto_row(), hk_class::hk_translate(), hk_class::hkdebug(), hk_datasource::is_enabled(), hk_datasource::load_datasourcedefinition(), hk_datasource::max_rows(), new_table(), hk_datasource::row_position(), hk_class::runtime_only(), hk_datasource::save_datasourcedefinition(), hk_connection::server_supports(), hk_column::set_asbinary(), hk_column::set_asbool(), hk_column::set_asstring(), hk_datasource::set_blockvisiblesignals(), hk_datasource::setmode_insertrow(), hk_class::show_warningmessage(), hk_class::show_yesnodialog(), hk_datasource::store_changed_data(), hk_datasource::systemcolumnname(), and table_exists().
Referenced by hk_connection::copy_database().
| hk_string hk_database::database_path | ( | void | ) |
returns the path where hk_classes stores forms, queries, and reports usually ~/.hk_classes/dbdriver/host/dbname
| bool hk_database::delete_file | ( | const hk_string & | name, |
| filetype | type, | ||
| enum_interaction | x = interactive |
||
| ) |
deletes a file physically. Usually you don't have to use this function
| name | name of the file |
| type | type of the file (i.e. query or form) |
References hk_class::hk_translate(), hk_class::hkdebug(), and hk_class::show_yesnodialog().
Referenced by rename_file().
|
virtual |
removes a table from the database and deletes all data.
References connection(), hk_actionquery::execute(), hk_class::hk_translate(), hk_class::hkdebug(), hk_connection::is_connected(), hk_data::name(), new_actionquery(), new_table(), hk_datasource::set_name(), hk_actionquery::set_sql(), hk_class::show_warningmessage(), and hk_class::show_yesnodialog().
| void hk_database::disable | ( | void | ) |
informs the datasources and visible objects that the database shuts down and sets the database name to ""
Referenced by rename_table().
|
inlineprotectedvirtual |
driver_specific_tablelist has to set the protected variable p_tablelist
Reimplemented in hk_mysqldatabase.
Referenced by tablelist().
| hk_presentation * hk_database::existing_presentation | ( | const hk_string & | name, |
| hk_presentation::enum_presentationtype | t | ||
| ) |
looks whether there is a already created hk_presentation object (form or report) usefull if you need a handle to an already opened form
| name | name of the presentation |
| t | type of the presentation( form or report) |
References hk_class::hkdebug().
| vector< hk_string > * hk_database::formlist | ( | void | ) |
| hk_string hk_database::load | ( | const hk_string & | name, |
| filetype | type | ||
| ) |
load physically from a file. Usually you don't have to use this function
| name | the name of the file |
| type | the type of the file (i.e. form or query) |
References hk_class::hkdebug().
| hk_datasource * hk_database::load_datasource | ( | const hk_string & | name, |
| datasourcetype | dt = dt_table, |
||
| hk_presentation * | p = NULL |
||
| ) |
loads an existing table or resultquery
| name | name of the query or table |
| query | if true this function tries to load a query with the name "name" else a table |
| p | <internal use="" only>=""> if this datasource is part of a form or a report this is the pointer to this hk_presentation object |
References hk_class::hkdebug(), hk_datasource::loaddata(), new_resultquery(), and new_table().
Referenced by hk_presentation::new_datasource().
|
protectedvirtual |
loads the object's values out of the definition string. Especially used to load queries, forms and reports
Reimplemented from hk_class.
References hk_class::get_tagvalue().
| vector< hk_string > * hk_database::modulelist | ( | void | ) |
| hk_actionquery * hk_database::new_actionquery | ( | void | ) |
If you want to work with your own ddl queries, create a hk_action element with this function. A ddlquery (ddl= Data Definition Language) allows you to execute all non-SELECT queries (i.e. UPDATE, INSERT queries). This type of query has no result.
References hk_class::hkdebug().
Referenced by hk_connection::create_database(), hk_datasource::delete_rows(), and delete_table().
| hk_datasource * hk_database::new_resultquery | ( | hk_presentation * | p = NULL | ) |
if you want to work with your own dmlquery ( a SELECT ... statement), create a hk_datasource element with this function (dml= data manipulation language). All Select queries are possible (i.e. GROUP BY). The resulting data cant be edited.
References hk_connection::database_exists(), hk_class::hkdebug(), and hk_connection::server_needs().
Referenced by hk_mysqldatabase::driver_specific_tablelist(), load_datasource(), and hk_mysqlconnection::server_supports().
| hk_datasource * hk_database::new_table | ( | const hk_string & | name = "", |
| hk_presentation * | p = NULL |
||
| ) |
if you want to work with a particular table, create a hk_datasource element with this function. In a table, the data can be edited.
References hk_connection::database_exists(), hk_class::hk_translate(), hk_connection::server_needs(), hk_datasource::set_name(), and hk_class::show_warningmessage().
Referenced by hk_connection::copy_database(), copy_table(), delete_table(), load_datasource(), and rename_file().
| vector< hk_string > * hk_database::querylist | ( | void | ) |
| bool hk_database::rename_file | ( | const hk_string & | originalname, |
| const hk_string & | newname, | ||
| filetype | type, | ||
| enum_interaction | x = interactive |
||
| ) |
renames files (queries, forms and reports) and also handles table renaming
| originaltable | old name of the table |
| newname | new name of the tbale, |
| filetype | the type of file, see hk_definitions::filetype for details |
| x | if set to interactive warningmessages wil be displayed in case of an error |
References hk_datasource::column_by_name(), delete_file(), hk_datasource::enable(), hk_column::find(), hk_datasource::goto_row(), hk_class::hk_translate(), hk_datasource::max_rows(), new_table(), rename_table(), savestream(), hk_column::set_asstring(), hk_datasource::set_filter(), hk_class::show_warningmessage(), and hk_datasource::store_changed_data().
| bool hk_database::rename_table | ( | const hk_string & | originalname, |
| const hk_string & | newname, | ||
| enum_interaction | x = interactive |
||
| ) |
renames the table
| originaltable | old name of the table |
| newname | new name of the tbale, |
| x | if set to interactive warningmessages wil be displayed in case of an error |
References disable().
Referenced by rename_file().
| vector< hk_string > * hk_database::reportlist | ( | void | ) |
| void hk_database::save | ( | const hk_string & | statement, |
| const hk_string & | name, | ||
| filetype | type, | ||
| bool | ask_before_overwrite = true, |
||
| bool | ask_for_new_name = false |
||
| ) |
save physically in a file. Usually you don't have to use this function
| statement | the content to store |
| name | the name of the file |
| type | the type of the file (i.e. form or query) |
Referenced by hk_form::save_form().
|
protectedvirtual |
stores the object's values to stream s. Especially used to store queries, forms and reports
Reimplemented from hk_class.
References hk_class::end_mastertag(), hk_class::set_tagvalue(), and hk_class::start_mastertag().
| ofstream * hk_database::savestream | ( | const hk_string & | name, |
| filetype | type, | ||
| bool | ask_before_overwrite = true |
||
| ) |
creates a stream object to store a file. Usually you don't have to use this function
| name | the name of the file |
| type | the type of the file (i.e. query or form) |
| ask_before_overwrite | if true and a file of this type and this name already exists you will be asked whether or not to overwrite this file |
Referenced by rename_file(), and hk_form::save_form().
|
virtual |
name of the database.
References hk_class::hkdebug(), and hk_connection::server_supports().
Referenced by hk_connection::copy_database(), and hk_connection::new_database().
| bool hk_database::table_exists | ( | const hk_string & | tablename | ) |
checks whether a table exists
References hk_class::hkdebug(), and tablelist().
Referenced by hk_connection::copy_database(), copy_table(), and hk_datasource::setmode_altertable().
| vector< hk_string > * hk_database::tablelist | ( | bool | with_systemtable = false | ) |
if hk_connection is connected, the tablelist shows all existing tables in this database after you set the name of an existing database with set_name. The list will be created new every time you call this function. So be careful. Never use i.e. for_each(tablelist()->begin(),tablelist()->end(),anyfunction) Use instead: vector<hk_string>* mylist=tablelist(); for_each(mylist->begin(),mylist->end(),anyfunction)
References driver_specific_tablelist().
Referenced by hk_connection::copy_database(), and table_exists().
1.8.5