class hk_database

represents a particular database on the SQL Server. More...

Definition#include <hk_classes/hk_classes/hk_database.h>
Inheritshk_class [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Public Static Methods

Protected Methods

Protected Members


Detailed Description

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.

bool  set_name (const hk_string& n)

set_name

name of the database.

hk_string  name (void)

name

vector<hk_string>*  tablelist (void)

tablelist

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* mylist=tablelist(); for_each(mylist->begin(),mylist->end(),anyfunction)

vector<hk_string>*  querylist (void)

querylist

Returns: a list of the names of all existing queries in this database

vector<hk_string>*  formlist (void)

formlist

Returns: a list of the names of all existing form in this database

vector<hk_string>*  reportlist (void)

reportlist

Returns: a list of the names of all existing reports in this database

hk_datasource*  new_table (const hk_string& name="",hk_presentation* p=NULL)

new_table

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.

hk_datasource*  new_resultquery (hk_presentation* p=NULL)

new_resultquery

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 canīt be edited.

hk_actionquery*  new_actionquery (void)

new_actionquery

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.

hk_datasource*  load_datasource (const hk_string& name,bool query=false,hk_presentation* p=NULL)

load_datasource

loads an existing table or resultquery

Parameters:
namename of the query or table
queryif true this function tries to load a query with the name "name" else a table
p if this datasource is part of a form or a report this is the pointer to this hk_presentation object

Returns: a datasource (either a table or a resultquery) if successful else NULL

bool  delete_table (const hk_string& table,enum_interaction x=interactive)

delete_table

removes a table from the database and deletes all data.

bool  table_exists (const hk_string& tablename)

table_exists

checks whether a table exists

bool  query_exists (const hk_string& queryname)

query_exists

hk_connection*  connection (void)

connection

Returns: the parent connection

ofstream*  savestream (const hk_string&name,filetype type,bool ask_before_overwrite=true )

savestream

creates a stream object to store a file. Usually you don't have to use this function

Parameters:
namethe name of the file
typethe type of the file (i.e. query or form)
ask_before_overwriteif true and a file of this type and this name already exists you will be asked whether or not to overwrite this file

Returns: the stream if successful else NULL

ofstream*  savestream (const hk_string&name,filetype type,bool ask_before_overwrite,bool with_header,bool ask_for_new_name=false )

savestream

bool  delete_file (const hk_string& name,filetype type,enum_interaction x=interactive)

delete_file

deletes a file physically. Usually you don't have to use this function

Parameters:
namename of the file
typetype of the file (i.e. query or form)

Returns: true if successful else false

hk_presentation*  existing_presentation (const hk_string& name, hk_presentation::enum_presentationtype t)

existing_presentation

looks whether there is a already created hk_presentation object (form or report) usefull if you need a handle to an already opened form

Parameters:
namename of the presentation
ttype of the presentation( form or report)

Returns: the object if existing else NULL

void  save (const hk_string& statement,const hk_string& name,filetype type)

save

save physically in a file. Usually you don't have to use this function

Parameters:
statementthe content to store
namethe name of the file
typethe type of the file (i.e. form or query)

hk_string  load (const hk_string& name,filetype type)

load

load physically from a file. Usually you don't have to use this function

Parameters:
namethe name of the file
typethe type of the file (i.e. form or query)

Returns: the content of the file

hk_string  database_path (void)

database_path

returns the path where hk_classes stores forms, queries, and reports usually ~/.hk_classes/dbdriver/host/dbname

hk_string  fileendings (filetype e)

fileendings

bool  copy_table (hk_datasource* fromdatasource,bool schema_and_data,bool replacetable, bool ask,progress_dialogtype* progressdialog=NULL)

copy_table

creates a new table and uses an existing datasource as a template

Parameters:
fromdatasourcethe datasource which is used as a template
schema_and_dataif true the table will be created and the data copied, if false the data will be not copied
replacetablesee parameter ask for details
askask=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

hk_form*  new_formvisible (void)

new_formvisible

hk_report*  new_reportvisible (void)

new_reportvisible

hk_dstable*  new_tablevisible (void)

new_tablevisible

hk_dsquery*  new_queryvisible (void)

new_queryvisible

void  set_new_formvisiblefunction (newform_type*)

set_new_formvisiblefunction

[static]

void  set_new_reportvisiblefunction (newreport_type*)

set_new_reportvisiblefunction

[static]

void  set_new_tablevisiblefunction (newtable_type*)

set_new_tablevisiblefunction

[static]

void  set_new_queryvisiblefunction (newquery_type*)

set_new_queryvisiblefunction

[static]

void  set_usewidgetparent (void*)

set_usewidgetparent

bool  rename_table (const hk_string& originalname, const hk_string& newname,enum_interaction x=interactive)

rename_table

renames the table

Parameters:
originaltableold name of the table
newnamenew name of the tbale,
xif set to interactive warningmessages wil be displayed in case of an error

bool  rename_file (const hk_string& originalname, const hk_string& newname,filetype type,enum_interaction x=interactive)

rename_file

renames files (queries, forms and reports) and also handles table renaming

Parameters:
originaltableold name of the table
newnamenew name of the tbale,
filetypethe type of file, see hk_definitions::filetype for details
xif set to interactive warningmessages wil be displayed in case of an error

 hk_database (hk_connection* c)

hk_database

[protected]

 ~hk_database ()

~hk_database

[protected virtual]

bool  select_db (void)

select_db

[protected]

void  inform_datasources_before_closing (void)

inform_datasources_before_closing

[protected]

vector<hk_string>*  driver_specific_tablelist (void)

driver_specific_tablelist

[protected virtual]

hk_datasource*  driver_specific_new_table (hk_presentation* p)

driver_specific_new_table

[protected virtual]

hk_datasource*  driver_specific_new_resultquery (hk_presentation* p)

driver_specific_new_resultquery

[protected virtual]

hk_actionquery*  driver_specific_new_actionquery (void)

driver_specific_new_actionquery

[protected virtual]

bool  driver_specific_rename_table (const hk_string& oldname,const hk_string& newname)

driver_specific_rename_table

[protected virtual]

bool  driver_specific_select_db (void)

driver_specific_select_db

[protected virtual]

void  driver_specific_set_name (void)

driver_specific_set_name

[protected virtual]

hk_connection* p_connection

p_connection

[protected]

void  ds_remove (hk_data* ds)

ds_remove

[protected]

void  connection_connected (void)

connection_connected

[protected virtual]

void  connection_disconnected (void)

connection_disconnected

[protected virtual]

vector<hk_string> p_tablelist

p_tablelist

[protected]

void  dbvisible_add (hk_dbvisible* v)

dbvisible_add

[protected]

void  dbvisible_remove (hk_dbvisible* v)

dbvisible_remove

[protected]

void  clear_visiblelist (void)

clear_visiblelist

[protected]

void  before_source_vanishes (void)

before_source_vanishes

[protected virtual]

void  presentation_add (hk_presentation* p)

presentation_add

[protected]

void  presentation_remove (hk_presentation* p)

presentation_remove

[protected]