Databaseconnectionclasses
0.5.3
|
represents a resultquery or a table of a database. More...
#include <hk_datasource.h>
Classes | |
class | class_altercolumns |
class | fieldoriginclass |
class | indexclass |
class | struct_parsed_sql |
Public Types | |
enum | enum_tablemodes { mode_normal, mode_createtable, mode_altertable, mode_disabled, mode_insertrow, mode_deleterow, mode_unknown } |
enum | enum_accessmode { standard, batchread, batchwrite } |
enum | enum_dependingmodes { depending_nohandle, depending_standard, depending_change, depending_delete, depending_changedelete } |
![]() | |
enum | enum_datasourcetypes { ds_table, ds_query, ds_actionquery, ds_view, ds_unknown } |
![]() | |
enum | enum_interaction { noninteractive, interactive } |
enum | enum_measuresystem { cm, inch } |
enum | enum_tagtype { normaltag, mastertag } |
Public Member Functions | |
virtual void | set_name (const hk_string &n, bool registerchange=true) |
virtual hk_string | name (void) |
enum_tablemodes | mode (void) |
void | setmode_insertrow (void) |
void | delete_actualrow (enum_interaction c=interactive) |
void | setmode_normal (void) |
void | setmode_createtable (void) |
void | setmode_altertable (void) |
hk_column * | new_column (void) |
bool | alter_column (const hk_string &col, const hk_string *name=NULL, hk_column::enum_columntype *newtype=NULL, long *size=NULL, const hk_string *defaultvalue=NULL, const bool *primary=NULL, const bool *notnull=NULL) |
bool | delete_column (const hk_string &col) |
bool | create_table_now (void) |
bool | alter_table_now (void) |
bool | create_view_now (void) |
bool | alter_view_now (void) |
virtual bool | goto_row (unsigned long r) |
bool | while_goto_row (void) const |
bool | goto_first (void) |
bool | goto_last (void) |
bool | goto_next (void) |
bool | goto_previous (void) |
bool | goto_random (void) |
unsigned long | row_position (void) |
unsigned long | max_rows (void) |
bool | set_accessmode (enum_accessmode) |
enum_accessmode | accessmode (void) const |
bool | enable (void) |
bool | while_enabling (void) const |
bool | disable (void) |
bool | while_disabling (void) const |
bool | set_enabled (bool e) |
bool | is_enabled (void) const |
bool | is_readonly (void) const |
void | set_readonly (bool r) |
list< hk_column * > * | columns (void) |
list< hk_string > * | columnnames (void) |
hk_column * | column_by_name (const hk_string &c) |
hk_column * | column_by_name (const hk_string &c, int colnumber) |
int | columnname_occurances (const hk_string &colname) |
int | columnname_occurance (hk_column *) |
bool | set_sql (const hk_string &s, bool rawsql=false, bool registerchange=true) |
virtual bool | set_query (hk_qbe *, bool registerchange=true) |
hk_string | sql (void) const |
bool | is_rawsql (void) |
hk_string | backendsql (void) const |
list< indexclass > * | indices (void) |
bool | index_exists (const hk_string &) |
bool | drop_index (const hk_string &i) |
bool | create_index (const hk_string &name, bool unique, list< hk_string > &fields) |
bool | alter_index (const hk_string &name, bool unique, list< hk_string > &fields) |
enum_dependingmodes | dependingmode (void) |
bool | set_depending_on (hk_datasource *d, bool react_on_data_changes=false, enum_dependingmodes mode=depending_standard) |
hk_datasource * | depending_on (void) |
void | set_depending_on_is_left_join (bool, bool registerchange=true) |
bool | depending_on_is_left_join (void) |
bool | depending_on_react_on_data_changes (void) |
list< hk_string > * | depending_on_thisfields (void) |
list< hk_string > * | depending_on_masterfields (void) |
bool | set_depending_on_presentationdatasource (long d, bool react_on_data_changes=false, enum_dependingmodes mode=depending_standard, bool registerchange=true) |
long | depending_on_presentationdatasource (void) |
void | add_depending_fields (const hk_string &this_ds_field, const hk_string &master_ds_field, bool registerchange=true) |
void | clear_depending_fields (bool registerchange=true) |
bool | store_changed_data (enum_interaction c=interactive) |
void | set_ignore_changed_data (void) |
bool | ignore_changed_data (void) const |
void | set_filter (const hk_string &f, bool registerchange=true) |
hk_string | filter (void) |
void | set_temporaryfilter (const hk_string &f) |
hk_string | temporaryfilter (void) |
void | set_use_temporaryfilter (bool use) |
bool | use_temporaryfilter (void) |
void | set_internalfilter (const hk_string &f) |
hk_string | internalfilter (void) |
void | set_use_internalfilter (bool use) |
bool | use_internalfilter (void) |
void | clear_filter (bool registerchange=true) |
void | set_sorting (const hk_string &s, bool registerchange=true) |
hk_string | sorting (void) |
void | set_temporarysorting (const hk_string &s) |
hk_string | temporarysorting (void) |
void | set_use_temporarysorting (bool use) |
bool | use_temporarysorting (void) |
void | clear_sorting (bool registerchange=true) |
void | set_automatic_data_update (bool u) |
bool | is_automatic_data_update (void) |
void | set_sqldelimiter (const hk_string &) |
void | set_datetimeformat (const hk_string &datetime, const hk_string &date, const hk_string &time) |
hk_string | dateformat (void) const |
hk_string | datetimeformat (void) const |
hk_string | timeformat (void) const |
hk_database * | database (void) |
void | savedata (ostream &s, bool saveall=true) |
void | loaddata (xmlNodePtr definition, bool loadsql=true) |
long | presentationnumber (void) const |
bool | datasource_used (void) const |
virtual void | dump_data () |
bool | ask_name (void) |
virtual bool | delete_rows (unsigned long from, unsigned long to, bool check_depending_datasources=true, enum_interaction c=interactive) |
void | transaction_begin (hk_string name="") |
void | transaction_commit (hk_string name="") |
void | transaction_rollback (hk_string name="") |
void | set_blockvisiblesignals (bool v) |
bool | blockvisiblesignals (void) |
void | set_blockserversignals (bool) |
bool | blockserversignals (void) |
void | set_blockdatasourcesignals (bool) |
bool | blockdatasourcesignals (void) |
void | save_datasourcedefinition (ostream &s) |
bool | load_datasourcedefinition (xmlNodePtr definition, bool use_xmltablename=true, bool ask=true) |
hk_presentation * | presentation (void) |
void | set_position (int x, int y, bool registerchange=true) |
void | set_size (int width, int height, bool registerchange=true) |
int | x (void) const |
int | y (void) const |
int | width (void) const |
int | height (void) const |
void | set_designsize (int w, int h, bool registerchange=true) |
int | designwidth () const |
int | designheight () const |
void | automatic_position_datasource (void) |
list< hk_datasource * > * | dependinglist (void) |
bool | previous_enable_problems (void) const |
list< referentialclass > * | referenceslist (void) |
bool | add_reference (const referentialclass &) |
bool | drop_reference (const hk_string &) |
hk_string | fieldorigin (const hk_string &) |
hk_string | totalfieldorigin (const hk_string &) |
void | reset_changed_data (void) |
bool | has_changed (void) const |
hk_string | systemcolumnname (const hk_string &n) |
bool | depending_on_datasource_deleterow_ok (void) |
bool | depending_on_datasource_before_delete_row (void) |
bool | depending_on_datasource_updaterow_ok (void) |
bool | check_store_changed_data () |
void | set_progressdialog (progress_dialogtype *progressdialog) |
progress_dialogtype * | progressdialog (void) const |
void | set_progressinterval (int) |
int | progressinterval (void) const |
![]() | |
virtual hk_string | name (void) const |
virtual void | set_name (const hk_string &n) |
virtual enum_datasourcetypes | type (void) const |
hk_string | identifierdelimiter (void) const |
hk_string | textdelimiter (void) const |
![]() | |
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) |
virtual void | savedata (ostream &s) |
virtual void | loaddata (xmlNodePtr definition) |
Static Public Member Functions | |
static void | set_enablefunction (voidfunction *, long counter) |
![]() | |
static bool | print_sqlstatements (void) |
static void | set_print_sqlstatements (bool p) |
![]() | |
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_datasource (hk_database *db, hk_presentation *p=NULL) | |
void | column_remove (hk_column *col) |
void | visible_add (hk_dsvisible *v) |
void | visible_remove (hk_dsvisible *v) |
virtual void | driver_specific_transaction_begin (hk_string) |
virtual void | driver_specific_transaction_commit (hk_string) |
virtual void | driver_specific_transaction_rollback (hk_string) |
virtual unsigned long | driver_specific_max_rows (void) |
virtual bool | driver_specific_set_accessmode (enum_accessmode) |
virtual bool | driver_specific_batch_enable (void) |
virtual bool | driver_specific_batch_disable (void) |
virtual bool | driver_specific_batch_goto_next (void) |
virtual bool | driver_specific_batch_goto_previous (void) |
virtual bool | driver_specific_enable (void) |
virtual bool | driver_specific_disable (void) |
virtual list< hk_column * > * | driver_specific_columns (void) |
virtual bool | driver_specific_goto_row (unsigned long r) |
virtual hk_column * | driver_specific_new_column (void) |
virtual bool | driver_specific_update_data (void) |
virtual bool | driver_specific_delete_data_at (unsigned long) |
virtual bool | driver_specific_insert_data (void) |
virtual bool | driver_specific_create_table_now (void) |
virtual bool | driver_specific_alter_table_now (void) |
virtual bool | driver_specific_create_view_now (void) |
virtual bool | driver_specific_alter_view_now (void) |
virtual void | driver_specific_before_drop_table (void) |
virtual void | filelist_changes (listtype t) |
virtual list< indexclass > * | driver_specific_indices (void) |
virtual bool | driver_specific_drop_index (const hk_string &i) |
virtual bool | driver_specific_create_index (const hk_string &name, bool unique, list< hk_string > &fields) |
virtual void | before_connection_disconnects (void) |
virtual void | before_source_vanishes (void) |
virtual void | driver_specific_after_copy_table () |
virtual bool | driver_specific_load_view () |
virtual void | driver_specific_create_viewsql () |
virtual bool | driver_specific_add_reference (const referentialclass &) |
virtual bool | driver_specific_drop_reference (const hk_string &) |
virtual void | driver_specific_referenceslist (void) |
void | depending_ds_add (hk_datasource *d) |
void | depending_ds_remove (hk_datasource *d) |
void | depending_on_datasource_row_change (bool take_changed_data=false) |
void | depending_on_datasource_data_has_changed (void) |
void | depending_on_datasource_after_store_changed_data (void) |
void | depending_on_datasource_insertmode (void) |
void | depending_on_datasource_before_update_row (void) |
void | depending_on_datasource_after_update_row (void) |
void | reload_data (bool take_changed_data=false) |
void | create_actual_row_where_statement (void) |
hk_string | create_row_where_statement_at (unsigned long int position, bool withwhere=true) |
void | create_new_sql_statement (bool take_changed_data=false) |
hk_string | whole_datasource_where_statement (bool take_changed_data=false) |
void | print_sql (void) |
void | clear_columnlist (void) |
void | clear_modecolumnlists (void) |
void | clear_visiblelist (void) |
void | parse_sql (void) |
virtual bool | update_row (enum_interaction c=interactive) |
virtual bool | insert_row (enum_interaction c=interactive) |
virtual bool | delete_row (enum_interaction c=interactive) |
void | parse_fieldpart (void) |
void | parse_tablepart (void) |
void | set_has_changed (void) |
void | set_has_not_changed (void) |
hk_string | delimit_identifier (const hk_string &) |
void | inform_before_row_change (void) |
void | inform_visible_objects_batch_goto_next (void) |
void | inform_visible_objects_batch_goto_previous (void) |
void | inform_visible_objects_before_store_changed_data (void) |
void | inform_visible_objects_after_store_changed_data (void) |
void | inform_visible_objects_row_change (void) |
void | inform_visible_objects_row_add (void) |
void | inform_visible_objects_row_delete (void) |
void | inform_visible_objects_before_insert_row (void) |
void | inform_before_enable (void) |
void | inform_before_disable (void) |
void | inform_visible_objects_ds_disable (void) |
void | inform_visible_objects_ds_enable (void) |
void | inform_depending_ds_goto_row (void) |
void | inform_depending_ds_store_data (void) |
void | inform_depending_ds_data_has_changed (void) |
void | inform_depending_ds_after_store_changed_data (void) |
void | inform_depending_ds_before_update_row (void) |
void | inform_depending_ds_after_update_row (void) |
void | inform_depending_ds_disable (void) |
void | inform_depending_ds_enable (void) |
void | inform_depending_ds_insertmode (void) |
void | inform_visible_objects_new_columns_created (void) |
void | inform_visible_objects_before_columns_deleted (void) |
void | inform_visible_objects_insertmode (void) |
void | inform_when_table_structure_changes (void) |
void | inform_when_indexlist_changes (void) |
void | execute_visible_object_script_before_update (void) |
void | execute_visible_object_script_after_update (void) |
void | execute_visible_object_before_row_change (void) |
void | execute_visible_object_after_row_change (void) |
void | execute_visible_object_before_delete (void) |
void | execute_visible_object_after_delete (void) |
void | execute_visible_object_before_insert (void) |
void | execute_visible_object_after_insert (void) |
hk_string | new_referencename (const referentialclass &) |
bool | is_newreferencename (const hk_string &) |
hk_string | replace_dates (const hk_string &) |
![]() | |
virtual bool | driver_specific_name (const hk_string &n) |
![]() | |
hk_interpreter * | new_interpreter (const hk_string &interpreter, hk_presentation *) |
Protected Attributes | |
bool | p_casesensitive |
bool | p_enabled |
bool | p_readonly |
bool | p_primary_key_used |
bool | p_ignore_changed_data |
unsigned long | p_counter |
hk_database * | p_database |
list< hk_column * > * | p_columns |
list< class_altercolumns > | p_altercolumns |
list< hk_string > | p_deletecolumns |
list< hk_column * > | p_newcolumns |
list< hk_string > | depending_this_fields |
list< hk_string > | depending_master_fields |
struct_parsed_sql * | p_parsed_sql |
hk_string | p_sql |
hk_string | p_viewsql |
hk_string | p_actual_row_where |
bool | p_automatic_data_update |
hk_actionquery * | p_actionquery |
hk_string | p_datetimeformat |
hk_string | p_dateformat |
hk_string | p_timeformat |
hk_string | p_sql_delimiter |
hk_string | p_true |
hk_string | p_false |
bool | p_depending_on_is_left_join |
bool | p_tablesql_set |
list< hk_datasource * > | p_dependinglist |
enum_tablemodes | p_mode |
list< referentialclass > | p_references |
![]() | |
hk_string | p_name |
hk_string | p_sqltextdelimiter |
hk_string | p_identifierdelimiter |
Static Protected Attributes | |
static voidfunction * | p_enablefunction =NULL |
static long | p_enablefunctioncounter =0 |
![]() | |
static bool | p_print_sqlstatements =false |
![]() | |
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 |
Friends | |
class | hk_column |
class | hk_dsvisible |
class | hk_database |
class | hk_presentation |
represents a resultquery or a table of a database.
hk_datasource is the basic class which represents a resultquery or a table of a database. Never create this table directly. Use the hk_database::new_table method instead.
Two types of this class can be distinguished. Tables and Resultqueries.
Resultqueries are Queries with a SELECT - SQL-statement. The resulting data cannot be edited or manipulated.
Tables are a special form of resultqueries. The SQL-statement is fixed ("SELECT * FROM <tablename>), but the resulting dataset can be edited.
the accessmode regulates the behaviour of the datasource. In mode 'standard' the datasource is readable and writeable, but usually first loads all the data from the SQL server. This is in some cases not necessary. If you just need to serially read one row after another, you can use the 'batchread' mode. In this case random access is not possible and it is not possible to edit the data or insert rows (e.g. this is used in hk_report). In 'batchwrite' mode data can't be read and is only used for inserting data (e.g. used hk_importcsv) The batchmodes do not need as much memory as the standard mode.
See dependingmode for details
void hk_datasource::add_depending_fields | ( | const hk_string & | this_ds_field, |
const hk_string & | master_ds_field, | ||
bool | registerchange = true |
||
) |
use this method in connection with depending_on.
this_ds_field | fieldname of a column of this datasource which has to be connected to the master datasource. |
master_ds_field | columnname of the masterdatasource which value has to be equal with the value of this_ds_field. |
registerchange | if this class is part of a hk_presentation object (i.e. a form or a report) and registerchange is true, then the changes will be stored when the hk_presentation object is closed. |
References hk_class::hkdebug().
Referenced by loaddata().
bool hk_datasource::add_reference | ( | const referentialclass & | c | ) |
will try to add a new reference to a table
References hk_database::connection(), hk_class::hk_translate(), hk_connection::server_supports(), and hk_class::show_warningmessage().
Referenced by hk_connection::copy_database().
bool hk_datasource::alter_column | ( | const hk_string & | col, |
const hk_string * | name = NULL , |
||
hk_column::enum_columntype * | newtype = NULL , |
||
long * | size = NULL , |
||
const hk_string * | defaultvalue = NULL , |
||
const bool * | primary = NULL , |
||
const bool * | notnull = NULL |
||
) |
if this datasource is of type "table" and in mode "alter" you can alter an existing column. NULL values mean, that this part will not be changed
References column_by_name(), hk_class::hkdebug(), hk_column::is_notnull(), and hk_column::is_primary().
bool hk_datasource::alter_index | ( | const hk_string & | name, |
bool | unique, | ||
list< hk_string > & | fields | ||
) |
Alters an existing index by first dropping it with drop_index and then by trying to recreate it with create_index
References create_index(), drop_index(), and hk_class::hkdebug().
bool hk_datasource::alter_table_now | ( | void | ) |
After altering an existing table with setmode_altertable, new_column ,alter_column and delete_column this function alters physically the table
References columns(), hk_class::hkdebug(), and hk_class::show_warningmessage().
Referenced by setmode_normal().
bool hk_datasource::ask_name | ( | void | ) |
asks interactively for a name
References hk_class::hk_translate(), hk_class::hkdebug(), set_name(), and hk_class::show_stringvaluedialog().
Referenced by load_datasourcedefinition().
hk_string hk_datasource::backendsql | ( | void | ) | const |
returns the SQL statement as it is sent to the SQL server
void hk_datasource::clear_depending_fields | ( | bool | registerchange = true | ) |
clears the depending list.
References hk_class::hkdebug().
Referenced by loaddata(), and hk_reportsection::set_subreport().
void hk_datasource::clear_filter | ( | bool | registerchange = true | ) |
clears the filter which was set with set_filter
registerchange | if this class is part of a hk_presentation object (i.e. a form or a report) and registerchange is true, then the changes will be stored when the hk_presentation object is closed. |
References hk_class::hkdebug().
void hk_datasource::clear_sorting | ( | bool | registerchange = true | ) |
clears the sorting instruction
registerchange | if this class is part of a hk_presentation object (i.e. a form or a report) and registerchange is true, then the changes will be stored when the hk_presentation object is closed. |
References hk_class::hkdebug().
hk_column * hk_datasource::column_by_name | ( | const hk_string & | c | ) |
if the datasource is enabled, you can reach a particular column by name
References hk_class::hkdebug().
Referenced by alter_column(), hk_database::copy_table(), hk_listvisible::datasource_enable(), hk_mysqldatabase::driver_specific_tablelist(), hk_database::rename_file(), hk_mysqlconnection::server_supports(), and setmode_insertrow().
hk_column * hk_datasource::column_by_name | ( | const hk_string & | c, |
int | colnumber | ||
) |
if the datasource is enabled, you can reach a particular column by name.
colnumber | If there are more than 1 columns with the same name this parameter tells which one to take (1 is the first column) |
References columns(), hk_database::connection(), hk_class::hkdebug(), mode(), hk_column::name(), and p_casesensitive.
int hk_datasource::columnname_occurance | ( | hk_column * | col | ) |
returns if this is the first, second ... nth column with this name
References columns(), hk_column::name(), and p_casesensitive.
Referenced by hk_database::copy_table().
int hk_datasource::columnname_occurances | ( | const hk_string & | colname | ) |
returns how many columns exist in this datasource with the name 'colname'. Usually columnnames should be unique, but it is unfortunately technically possible to create SQL statements that return ambigous columnnames
References columns(), hk_database::connection(), and p_casesensitive.
list< hk_column * > * hk_datasource::columns | ( | void | ) |
if the datasource is enabled you get a list of all columns. The fields can be reached by columns. See hk_column for details. returns NULL if no columns are defined yet (e.g. non-enabled queries)
References driver_specific_columns().
Referenced by alter_table_now(), column_by_name(), columnname_occurance(), columnname_occurances(), hk_database::copy_table(), hk_storagedatasource::delete_data(), hk_importcsv::execute(), hk_storagedatasource::insert_data(), save_datasourcedefinition(), and setmode_altertable().
bool hk_datasource::create_index | ( | const hk_string & | name, |
bool | unique, | ||
list< hk_string > & | fields | ||
) |
creates an index of a table. returns true if successful otherwise false; make sure you have set the tablename first.
name | new name of the index |
unique | true if this should be a unique index |
fields | the field(column) names used by this index |
References hk_class::hkdebug().
Referenced by alter_index(), and load_datasourcedefinition().
bool hk_datasource::create_table_now | ( | void | ) |
After defining a new table with setmode_createtable and new_column this function creates physically the table
References hk_database::connection(), hk_class::hk_translate(), hk_class::hkdebug(), and hk_class::show_warningmessage().
Referenced by load_datasourcedefinition(), and setmode_normal().
bool hk_datasource::datasource_used | ( | void | ) | const |
References hk_class::hkdebug().
void hk_datasource::delete_actualrow | ( | enum_interaction | c = interactive | ) |
this function tries to delete the actual row. If there is a depending datasource with equivalent rows the actual row will not be deleted.
References hk_class::hkdebug(), and store_changed_data().
bool hk_datasource::delete_column | ( | const hk_string & | col | ) |
if this datasource is of type "table" and in mode "alter" you can delete an existing column.Just enter the name here.
References hk_class::hkdebug().
|
virtual |
Delete rows beginning from row number "from" to row number "to"
References hk_actionquery::execute(), goto_row(), hk_class::hk_translate(), hk_class::hkdebug(), is_readonly(), max_rows(), hk_database::new_actionquery(), hk_actionquery::set_sql(), hk_class::show_warningmessage(), hk_class::show_yesnodialog(), transaction_begin(), transaction_commit(), and transaction_rollback().
list< hk_string > * hk_datasource::depending_on_masterfields | ( | void | ) |
a list of the depending on columns of the master datasource set with add_depending_fields
bool hk_datasource::depending_on_react_on_data_changes | ( | void | ) |
See dependingmode for details
list< hk_string > * hk_datasource::depending_on_thisfields | ( | void | ) |
a list of the depending on columns of this datasource set with add_depending_fields
hk_datasource::enum_dependingmodes hk_datasource::dependingmode | ( | void | ) |
depending_nohandle = ignore that this is a depending datasource depending_standard = can't delete a master row when there are depending rows in the depending datasource and can't change the value of a master connection field. depending_change = if a master connection field is changed, the equivalent depending fields will change their values too. depending_delete = if the master row is deleted the depending rows will also be deleted depending_changedelete = combination of depending_change and depending_delete
See also set_depending_on for details
bool hk_datasource::disable | ( | void | ) |
if the datasource is enabled, this function will disable it. The columnlist will be deleted.
References hk_class::hkdebug(), set_sql(), and store_changed_data().
Referenced by hk_presentation::clear_datasourcelist(), hk_database::copy_table(), hk_dscombobox::datasource_disable(), load_datasourcedefinition(), save_datasourcedefinition(), set_depending_on(), set_enabled(), setmode_altertable(), and setmode_createtable().
|
inlineprotectedvirtual |
will be called from hk_database
Referenced by hk_database::copy_table().
|
inlineprotectedvirtual |
returns a list of the columns of the datasource. If the datasource is a table the list hast to be created even if the datasource is disabled. Fill the p_columns list for this reason and then return it. If necessary has to create one hk_column object per column and to add them to p_columns. Each column object has to get a unique number in its (protected) hk_column::p_fieldnr .
Reimplemented in hk_storagedatasource, and hk_mysqldatasource.
Referenced by columns().
|
inlineprotectedvirtual |
has to make sure that the columns-list has been created. It also has to provide access to the data of the datasource
Reimplemented in hk_storagedatasource, hk_mysqldatasource, and hk_mysqltable.
Referenced by enable().
bool hk_datasource::drop_index | ( | const hk_string & | i | ) |
deletes an index of a table. returns true if successful otherwise false;
i | name of the index |
References hk_database::connection(), hk_class::hk_translate(), hk_class::hkdebug(), and hk_class::show_warningmessage().
Referenced by alter_index().
bool hk_datasource::enable | ( | void | ) |
if hk_connection is connected, this method will enable the datasource. The SQL-Statement in SQL will be executed. If the SQL-statement is ok, the resulting data can be reached via the columns in columns. You can browse the data by using the methods goto_row, goto_first, goto_last, goto_next and goto_previous.
References hk_connection::connect(), driver_specific_enable(), hk_class::hkdebug(), hk_connection::is_connected(), is_enabled(), max_rows(), mode(), set_depending_on_presentationdatasource(), setmode_insertrow(), and setmode_normal().
Referenced by hk_database::copy_table(), hk_dscombobox::datasource_enable(), hk_mysqldatabase::driver_specific_tablelist(), hk_database::rename_file(), save_datasourcedefinition(), hk_mysqlconnection::server_supports(), set_depending_on(), set_enabled(), setmode_insertrow(), and setmode_normal().
bool hk_datasource::goto_first | ( | void | ) |
move the row selector to the first row. All depending objects will be informed (visible objects, depending datasources etc)
References goto_row(), and hk_class::hkdebug().
Referenced by hk_database::copy_table().
bool hk_datasource::goto_last | ( | void | ) |
move the row selector to the last row. All depending objects will be informed (visible objects, depending datasources etc)
References goto_row(), and max_rows().
bool hk_datasource::goto_next | ( | void | ) |
move the row selector to the next row. All depending objects will be informed (visible objects, depending datasources etc)
References goto_row(), hk_class::hkdebug(), max_rows(), setmode_insertrow(), setmode_normal(), and store_changed_data().
Referenced by hk_database::copy_table(), and hk_mysqldatabase::driver_specific_tablelist().
bool hk_datasource::goto_previous | ( | void | ) |
move the row selector to the previous row. All depending objects will be informed (visible objects, depending datasources etc)
References goto_row(), and hk_class::hkdebug().
bool hk_datasource::goto_random | ( | void | ) |
moves the rowselector to a random row.
References goto_row(), hk_class::hkdebug(), and max_rows().
|
virtual |
Goto a specific row. The first row number is 0, the last n-1 where n is the number of rows as delivered from max_rows().All depending objects will be informed (visible objects, depending datasources etc)
r | is the wished new row number to go. |
References hk_class::hkdebug(), setmode_normal(), and store_changed_data().
Referenced by hk_database::copy_table(), delete_rows(), goto_first(), goto_last(), goto_next(), goto_previous(), goto_random(), hk_database::rename_file(), and store_changed_data().
list< hk_datasource::indexclass > * hk_datasource::indices | ( | void | ) |
returns the list of all existing indices of a table or NULL in case of an error (i.e. not a table)
Referenced by save_datasourcedefinition().
bool hk_datasource::is_enabled | ( | void | ) | const |
shows whether the datasource is enabled.
Referenced by hk_column::asstring(), hk_column::asstring_at(), hk_dsdatavisible::column(), hk_database::copy_table(), hk_dscombobox::datasource_enable(), enable(), save_datasourcedefinition(), hk_dscombobox::set_datasource(), hk_dsdatavisible::set_datasource(), set_depending_on(), setmode_altertable(), setmode_createtable(), setmode_insertrow(), and setmode_normal().
bool hk_datasource::is_readonly | ( | void | ) | const |
Referenced by delete_rows(), hk_column::is_readonly(), setmode_insertrow(), and store_changed_data().
bool hk_datasource::load_datasourcedefinition | ( | xmlNodePtr | definition, |
bool | use_xmltablename = true , |
||
bool | ask = true |
||
) |
loads the structure of the datasource (fields,indices) in an xml format file and creates the tableand is database driver independent
References ask_name(), create_index(), create_table_now(), disable(), hk_class::get_tagvalue(), hk_class::hk_translate(), hk_class::hkdebug(), new_column(), set_name(), setmode_createtable(), and hk_class::show_warningmessage().
Referenced by hk_database::copy_table().
void hk_datasource::loaddata | ( | xmlNodePtr | definition, |
bool | loadsql = true |
||
) |
loads the object's values out of the definition string.
References add_depending_fields(), clear_depending_fields(), hk_class::get_tagvalue(), hk_class::hkdebug(), hk_qbe::loaddata(), hk_presentation::set_database(), and set_depending_on().
Referenced by hk_database::load_datasource(), hk_dsvisible::loaddata(), and hk_presentation::loaddata().
unsigned long hk_datasource::max_rows | ( | void | ) |
number of rows in this query.
Referenced by hk_column::asstring(), hk_column::asstring_at(), hk_database::copy_table(), delete_rows(), hk_mysqldatabase::driver_specific_tablelist(), enable(), hk_column::find(), goto_last(), goto_next(), goto_random(), hk_reportsection::new_uniquevalue(), hk_database::rename_file(), store_changed_data(), and hk_dsdatavisible::value_at().
hk_datasource::enum_tablemodes hk_datasource::mode | ( | void | ) |
if this datasource is a table, it can be in different "modes". For example if you want to create a new table and define the different columns, the table has to be in "mode_create" See enum_tablemodes for the different modetypes.
Referenced by column_by_name(), enable(), hk_column::in_definitionmode(), and hk_dsdatavisible::value_at().
hk_column * hk_datasource::new_column | ( | void | ) |
if this datasource is of type "table" and in mode "create" or "alter" you can create a new column to define its parameters.
References hk_class::hkdebug().
Referenced by load_datasourcedefinition().
|
inline |
stores the datasource as a query file
bool hk_datasource::previous_enable_problems | ( | void | ) | const |
returns true, if this datasource could not be enabled last time when tried
unsigned long hk_datasource::row_position | ( | void | ) |
number of the current row.
Referenced by hk_column::asbinary(), hk_column::asbool(), hk_column::asstring(), hk_database::copy_table(), hk_reportdata::count(), hk_reportsection::new_uniquevalue(), hk_column::transformed_asstring(), and hk_dsdatavisible::value_at().
void hk_datasource::save_datasourcedefinition | ( | ostream & | s | ) |
stores the structure of the datasource (fields,indices) in an xml format file and is database driver independent
References columns(), disable(), enable(), hk_class::end_mastertag(), indices(), is_enabled(), hk_class::set_tagvalue(), set_temporaryfilter(), and hk_class::start_mastertag().
Referenced by hk_database::copy_table().
void hk_datasource::savedata | ( | ostream & | s, |
bool | saveall = true |
||
) |
stores the object's values to stream s. The following tags will be used
<TYPE> either QUERY or TABLE
<DATASOURCENAME> the name set with set_name
<SQL> the used sql statement
Additionally the section <DATASOURCEEXTRA> has the following tags
<FILTER> the filter set with set_filter
<SORTING> the sorting direction set with set_sorting
<DATETIMEFORMAT>
<DATEFORMAT>
<TIMEFORMAT>
if this datasource is part of a hk_presentation also the following tags will be stored
<UPN> the unique presentation number. See presentationnumber
<DEPENDING_ON> the depending on datasource set with set_depending_on_presentationdatasource
one or more <DEPENDINGFIELDS> sections with the following tags
<THISFIELD> set with add_depending_fields
<MASTERFIELD> set with add_depending_fields
s | the stream to which the data will be written |
saveall | if true the section <DATASOURCEEXTRA> will be stored additionally to the normal data |
References hk_class::end_mastertag(), hk_class::hkdebug(), hk_class::set_tagvalue(), and hk_class::start_mastertag().
void hk_datasource::set_automatic_data_update | ( | bool | u | ) |
when data has changed and the row selector is moved to another row, usually the datasource will be automatically updated. If the value is set to false, you have to update the data manually by calling store_changed_data.
u | If you don't want the automatic update of data changes, set this paramter to false. The default value is true. |
References hk_class::hkdebug().
void hk_datasource::set_blockdatasourcesignals | ( | bool | ) |
if true no depending datasources will be informed when data changes in any kind Default is false
void hk_datasource::set_blockserversignals | ( | bool | s | ) |
if true no data will be sent to the database server when data changes in any kind Default is false
void hk_datasource::set_blockvisiblesignals | ( | bool | v | ) |
if true no visual objects will be informed when data changes in any kind, except the datasource will be deleted Default is false
Referenced by hk_database::copy_table(), and hk_importcsv::execute().
|
inline |
sets the default date and timeformats for new created columns
bool hk_datasource::set_depending_on | ( | hk_datasource * | d, |
bool | react_on_data_changes = false , |
||
enum_dependingmodes | mode = depending_standard |
||
) |
if there are 2 datasources in a 1:n relation it is possible to connect the 2 datasources. Add the master datasource here ( it's the '1'-datasource in the '1:n'-relation). Except of the master datasource you also have to add the connected fields with add_depending_fields This (the depending) datasource will enable/disable automatically when the master datasource will enable/disable. if this datasource is part of a hk_presentation use set_depending_on_presentationdatasource instead
d | is the master datasource |
react_on_data_changes | true if the datasource should react when a value of the masterdatasource is changed but not yet stored |
mode | how to react when the masterdatasource changes its data. See enum_dependingmodes for details. |
References disable(), enable(), hk_class::hk_translate(), hk_class::hkdebug(), is_enabled(), and hk_class::show_warningmessage().
Referenced by loaddata(), set_depending_on_presentationdatasource(), and hk_reportsection::set_subreport().
bool hk_datasource::set_depending_on_presentationdatasource | ( | long | d, |
bool | react_on_data_changes = false , |
||
enum_dependingmodes | mode = depending_standard , |
||
bool | registerchange = true |
||
) |
if this datasource is part of a hk_presentation object (form or report) then set the depending on datasource with this function. You can get the unique datasource number of a datasource with presentationnumber
d | the presentationnumber of the master datasource |
registerchange | if this class is part of a hk_presentation object (i.e. a form or a report) and registerchange is true, then the changes will be stored when the hk_presentation object is closed. |
References hk_presentation::get_datasource(), hk_class::hk_translate(), hk_class::hkdebug(), set_depending_on(), and hk_class::show_warningmessage().
Referenced by enable().
bool hk_datasource::set_enabled | ( | bool | e | ) |
convenience function: if e is true the datasource will be enabled by calling enable else it will disable the datasource by calling disable.
References disable(), and enable().
Referenced by hk_dscombobox::set_listdatasource().
void hk_datasource::set_filter | ( | const hk_string & | f, |
bool | registerchange = true |
||
) |
it is possible to filter only specific rows from a datasource by setting this filter. just add the conditions with this function.
f | same syntax as a SQL statement in the 'WHERE' section, but without the word 'WHERE' |
registerchange | if this class is part of a hk_presentation object (i.e. a form or a report) and registerchange is true, then the changes will be stored when the hk_presentation object is closed. Example: SELECT * from addresses WHERE city="Mnchen", so you would call set_filter("city=\"Mnchen""); |
References hk_class::hkdebug().
Referenced by hk_database::rename_file().
|
virtual |
sets the name of the datasource
n | the name |
registerchange | if this class is part of a hk_presentation object (i.e. a form or a report) and registerchange is true, then the changes will be stored when the hk_presentation object is closed. |
Reimplemented in hk_mysqldatasource.
References hk_class::hkclassname(), hk_class::hkdebug(), and set_sql().
Referenced by ask_name(), hk_database::delete_table(), load_datasourcedefinition(), hk_presentation::loaddata(), hk_presentation::new_datasource(), hk_database::new_table(), and hk_mysqldatasource::set_name().
void hk_datasource::set_position | ( | int | x, |
int | y, | ||
bool | registerchange = true |
||
) |
the position will be used for the database designer GUI. Mostly you don't have to manipulate the values
void hk_datasource::set_readonly | ( | bool | r | ) |
If the datasource is of type ds_table you can allow or disallow data changes.
References hk_class::hkdebug().
void hk_datasource::set_size | ( | int | width, |
int | height, | ||
bool | registerchange = true |
||
) |
the size will be used for the database designer GUI. Mostly you don't have to manipulate the values
void hk_datasource::set_sorting | ( | const hk_string & | s, |
bool | registerchange = true |
||
) |
it is possible to sort the datasource. just add the conditions with this function.
f | same syntax as a SQL statement in the "ORDER BY" section, but without the word "ORDER BY" |
registerchange | if this class is part of a hk_presentation object (i.e. a form or a report) and registerchange is true, then the changes will be stored when the hk_presentation object is closed. Example: SELECT * from addresses ORDER BY city DESC , so you would call set_sorting("city DESC"); |
References hk_class::hkdebug().
bool hk_datasource::set_sql | ( | const hk_string & | s, |
bool | rawsql = false , |
||
bool | registerchange = true |
||
) |
set your own SQL statement, that will be executed when you enable the datasource. if this datasource is of type "table" it will be automatically created.
s | is the sql statement |
rawsql | if true the sql statement will used as is (otherwise it may be changed ) |
registerchange | if this class is part of a hk_presentation object (i.e. a form or a report) and registerchange is true, then the changes will be stored when the hk_presentation object is closed. sorting, filtering or depending on statements). So it is possible to execute driver specific result queries which do not contain the "SELECT" statement, i.e. SHOW FIELDS in Mysql. |
References hk_class::hkdebug().
Referenced by disable(), hk_mysqldatabase::driver_specific_tablelist(), hk_mysqlconnection::server_supports(), and set_name().
void hk_datasource::set_temporaryfilter | ( | const hk_string & | f | ) |
temporary filters just work like filters (see set_filter ), but have to be manually activated with set_use_temporaryfilter. When loaded with loaddata temporaryfilters are deactivated by default.
Referenced by save_datasourcedefinition().
void hk_datasource::setmode_altertable | ( | void | ) |
If you want to alter an existing table first bring the table in altermode. Define new columns with new_column. Alter it with alter_column and delete a column by calling alter_column. Afterwards you can alter the table by calling alter_table_now
References columns(), disable(), hk_class::hkdebug(), is_enabled(), and hk_database::table_exists().
void hk_datasource::setmode_createtable | ( | void | ) |
If you want to create a new table first bring the table in createmode. Define new columns with new_column. Afterwards you can create the table by calling create_table_now
References disable(), hk_class::hkdebug(), is_enabled(), and hk_class::runtime_only().
Referenced by load_datasourcedefinition().
void hk_datasource::setmode_insertrow | ( | void | ) |
brings the datasource in insertmode. To add a new row call this function, set the data of the new row as usual in the columns (i.e.with hk_column::as_string ) and finally call either setmode_normal or store_changed_data.
References hk_column::asstring(), column_by_name(), enable(), hk_class::hkdebug(), is_enabled(), is_readonly(), hk_column::set_asstring(), and store_changed_data().
Referenced by hk_database::copy_table(), enable(), hk_importcsv::execute(), and goto_next().
void hk_datasource::setmode_normal | ( | void | ) |
This is the usual mode, where you can browse the data and if the data is not readonly change the data.
References alter_table_now(), create_table_now(), enable(), hk_class::hkdebug(), and is_enabled().
Referenced by enable(), goto_next(), and goto_row().
bool hk_datasource::store_changed_data | ( | enum_interaction | c = interactive | ) |
if the data of the actual row has changed you can manually send the changes to the SQL Server by calling this function. The function will be called automatically before the datasource disables or the row selector will be moved to another row.
References hk_database::connection(), goto_row(), hk_class::hkdebug(), hk_connection::is_connected(), is_readonly(), and max_rows().
Referenced by hk_presentation::clear_datasourcelist(), hk_database::copy_table(), delete_actualrow(), disable(), hk_importcsv::execute(), goto_next(), goto_row(), hk_database::rename_file(), and setmode_insertrow().
hk_string hk_datasource::systemcolumnname | ( | const hk_string & | n | ) |
returns a transformed column name in case the driver does only support e.g. ASCII characters
References hk_database::connection(), and hk_connection::server_supports().
Referenced by hk_database::copy_table().
void hk_datasource::transaction_begin | ( | hk_string | name = "" | ) |
Start a transaction. If the SQL server does not support transaction this function does nothing
name | the name of the transaction |
Referenced by delete_rows().
void hk_datasource::transaction_commit | ( | hk_string | name = "" | ) |
Commits a transaction. If the SQL server does not support transaction this function does nothing
name | the name of the transaction |
Referenced by delete_rows().
void hk_datasource::transaction_rollback | ( | hk_string | name = "" | ) |
Undo a transaction. If the SQL server does not support transaction this function does nothing
name | the name of the transaction |
Referenced by delete_rows().
|
protected |
if database driver supports cassensitive column and table names p_casesensitive is true else p_casesensitive is false. Then internally column_by_name() and name() return values in small letters
Referenced by column_by_name(), columnname_occurance(), and columnname_occurances().