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 Types

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.

 ~hk_database ()

~hk_database

[virtual]

bool  set_name (const hk_string& n)

set_name

name of the database.

hk_string  name (void)

name

vector<hk_string>*  tablelist (bool with_systemtable=false)

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>*  viewlist ()

viewlist

vector<hk_string>*  tableviewlist (bool with_systemtable=false)

tableviewlist

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*  new_view (const hk_string& name="",hk_presentation* p=NULL)

new_view

hk_datasource*  load_datasource (const hk_string& name,datasourcetype dt=dt_table,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  delete_view (const hk_string& view, enum_interaction x=interactive)

delete_view

bool  table_exists (const hk_string& tablename)

table_exists

checks whether a table exists

bool  view_exists (const hk_string& viewname)

view_exists

bool  query_exists (const hk_string& queryname)

query_exists

hk_connection*  connection (void)

connection

[const]

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

stringstream*  savestringstream (filetype type)

savestringstream

strstream*  savestringstream (filetype type)

savestringstream

stringstream*  savestringstream (filetype type,bool with_header)

savestringstream

strstream*  savestringstream (filetype type,bool with_header)

savestringstream

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

hk_form*  existing_form (const hk_string name)

existing_form

hk_report*  existing_report (const hk_string name)

existing_report

void  save (const hk_string& statement,const hk_string& name,filetype type,bool ask_before_overwrite=true,bool ask_for_new_name=false )

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

hk_string  fileendings (objecttype 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

bool  copy_view (hk_datasource* fromdatasource,progress_dialogtype* progressdialog=NULL,const hk_string& newname="")

copy_view

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 (hk_class*)

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

void  disable (void)

disable

informs the datasources and visible objects that the database shuts down and sets the database name to ""

enum enum_storagemode {central,local}

enum_storagemode

void  set_storagemode (filetype, enum_storagemode load,enum_storagemode store)

set_storagemode

enum_storagemode  storagemode (filetype)

storagemode

enum_storagemode  loadmode (filetype)

loadmode

bool  create_centralstoragetable (void)

create_centralstoragetable

bool  has_centralstoragetable (void)

has_centralstoragetable

hk_string  load_local (const hk_string& name,filetype type)

load_local

hk_string  load_central (const hk_string& name,filetype type)

load_central

void  save_local (const hk_string& statement,const hk_string& name,filetype type,bool ask_before_overwrite,bool ask_for_new_name)

save_local

void  save_central (const hk_string& statement,const hk_string& name,filetype type,bool ask_before_overwrite,bool ask_for_new_name)

save_central

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

delete_localfile

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

delete_centralfile

vector<hk_string>*  filelist (filetype type)

filelist

vector<hk_string>*  local_filelist (filetype type)

local_filelist

vector<hk_string>*  central_filelist (filetype type)

central_filelist

void  save_configuration (void)

save_configuration

 hk_database (hk_connection* c)

hk_database

[protected]

bool  select_db ( const hk_string& newname)

select_db

[protected]

void  inform_datasources_before_closing (void)

inform_datasources_before_closing

[protected]

void  driver_specific_tablelist (void)

driver_specific_tablelist

[protected virtual]

driver_specific_tablelist has to set the protected variable p_tablelist

void  driver_specific_viewlist (void)

driver_specific_viewlist

[protected virtual]

hk_datasource*  driver_specific_new_table (hk_presentation* p)

driver_specific_new_table

[protected virtual]

hk_datasource*  driver_specific_new_view (hk_presentation* p)

driver_specific_new_view

[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]

vector<hk_string> p_viewlist

p_viewlist

[protected]

vector<hk_string> p_tableviewlist

p_tableviewlist

[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]

void  load_configuration (void)

load_configuration

[protected]

void  savedata (ostream& s)

savedata

[protected virtual]

Reimplemented from hk_class.

void  loaddata (const hk_string& definition)

loaddata

[protected virtual]

Reimplemented from hk_class.

hk_url p_url

p_url

[protected]