# class hk_database

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

Definition | `#include <hk_classes/hk_classes/hk_database.h>`
Inherits | hk_class [public ]
List of all Methods

Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- bool set_name (const hk_string& n)
- hk_string name (void)
- vector<hk_string>* tablelist (void)
- vector<hk_string>* querylist (void)
- vector<hk_string>* formlist (void)
- vector<hk_string>* reportlist (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* load_datasource (const hk_string& name,bool query=false,hk_presentation* p=NULL)
- bool delete_table (const hk_string& table,enum_interaction x=interactive)
- bool table_exists (const hk_string& tablename)
- bool query_exists (const hk_string& queryname)
- hk_connection* connection (void)
- 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 )
- 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)
- void save (const hk_string& statement,const hk_string& name,filetype type)
- hk_string load (const hk_string& name,filetype type)
- hk_string database_path (void)
- hk_string fileendings (filetype e)
- bool copy_table (hk_datasource* fromdatasource,bool schema_and_data,bool replacetable, bool ask,progress_dialogtype* progressdialog=NULL)
- hk_form* new_formvisible (void)
- hk_report* new_reportvisible (void)
- hk_dstable* new_tablevisible (void)
- hk_dsquery* new_queryvisible (void)
- void set_usewidgetparent (void*)
- 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)

#### Public Static Methods

- static void set_new_formvisiblefunction (newform_type*)
- static void set_new_reportvisiblefunction (newreport_type*)
- static void set_new_tablevisiblefunction (newtable_type*)
- static void set_new_queryvisiblefunction (newquery_type*)

#### Protected Methods

- hk_database (hk_connection* c)
- virtual ~hk_database ()
- bool select_db (void)
- void inform_datasources_before_closing (void)
- virtual vector<hk_string>* driver_specific_tablelist (void)
- virtual hk_datasource* driver_specific_new_table (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& oldname,const hk_string& newname)
- 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)

#### Protected Members

- hk_connection* p_connection
- vector<hk_string> p_tablelist

## 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<hk_string>* 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:

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

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:

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

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:

name | name of the file
type | type 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:

name | name of the presentation
t | type 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:

statement | the content to store
name | the name of the file
type | the 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:

name | the name of the file
type | the 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:

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

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:

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

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:

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

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]

- Version: $Revision: 1.34 $
- Author: Horst Knorr (hk_classes@knoda.org)
- Generated: horst on horstnotebook on Tue Mar 30 19:06:43 2004, using kdoc 2.0a54.