Databaseconnectionclasses
0.5.3
|
represents one column of a datasource. More...
#include <hk_column.h>
Public Types | |
enum | enum_columntype { textcolumn, auto_inccolumn, smallintegercolumn, integercolumn, smallfloatingcolumn, floatingcolumn, datecolumn, datetimecolumn, timecolumn, timestampcolumn, binarycolumn, memocolumn, boolcolumn, othercolumn } |
![]() | |
enum | enum_interaction { noninteractive, interactive } |
enum | enum_measuresystem { cm, inch } |
enum | enum_tagtype { normaltag, mastertag } |
Public Member Functions | |
hk_string | name (void) const |
void | set_name (const hk_string &n) |
bool | is_readonly (void) const |
void | set_readonly (bool r) |
enum_columntype | columntype (void) const |
void | set_columntype (enum_columntype f) |
long | size (void) |
void | set_size (long s) |
hk_string | columntype_name (void) |
bool | is_primary (void) |
bool | set_primary (bool i) |
bool | is_notnull (void) |
hk_string | get_delimiter (void) |
bool | set_notnull (bool i) |
bool | has_changed (void) |
hk_string | asstring (bool as_locale=true) |
void | set_asstring (const hk_string &s, bool registerchange=true) |
void | set_asstring (const hk_string &s, bool registerchange, bool is_locale) |
const char * | transformed_asstring (void) |
const char * | transformed_asstring_at (unsigned long position) |
hk_string | changed_data_asstring (bool as_locale=true) |
void | set_asbinary (const struct_raw_data *rd) |
const struct_raw_data * | asbinary (void) |
const struct_raw_data * | asbinary_at (unsigned long a) |
void | set_asbool (bool b) |
bool | asbool (void) |
bool | asbool_at (unsigned long a) |
bool | changed_data_asbool (void) |
void | set_asinteger (long int s, bool registerchange=true) |
long int | asinteger (void) |
long int | asinteger_at (unsigned long) |
long int | changed_data_asinteger (void) |
void | set_asdouble (double s, bool registerchange=true) |
double | asdouble (void) |
double | asdouble_at (unsigned long) |
double | changed_data_asdouble (void) |
unsigned int | fieldnumber (void) |
hk_string | asstring_at (unsigned long a, bool as_locale=true) |
bool | is_nullvalue (void) |
bool | changed_data_is_nullvalue (void) |
bool | is_nullvalue_at (unsigned long a) |
void | set_asnullvalue (bool registerchange=true) |
long int | count (unsigned int from, unsigned int to) |
double | sum (unsigned int from, unsigned int to) |
long int | count () |
double | sum () |
unsigned int | find (unsigned int from, unsigned int to, const hk_string &searchtext, bool wholephrase=false, bool casesensitive=false, bool backwards=false) |
unsigned int | find (const hk_string &searchtext, bool wholephrase=false, bool casesensitive=false, bool backwards=false) |
bool | is_findstring (unsigned int pos, const hk_string &searchtext, bool wholephrase=false, bool casesensitive=false) |
const struct_raw_data * | changed_data (void) |
const struct_raw_data * | transformed_changed_data (void) |
void | reset_changed_data (void) |
void | set_boolvalues (const hk_string &TRUESTRING, const hk_string &FALSESTRING) |
hk_string | bool_truevalue (void) |
hk_string | bool_falsevalue (void) |
void | set_dateformat (const hk_string &df) |
hk_string | dateformat (void) const |
void | set_timeformat (const hk_string &tf) |
hk_string | timeformat (void) const |
void | set_datetimeformat (const hk_string &dtf) |
hk_string | datetimeformat (void) const |
bool | save_to_file (const hk_string &filename) |
bool | load_from_file (const hk_string &filename) |
void | save_columndefinition (ostream &) |
void | load_columndefinition (xmlNodePtr) |
hk_datasource * | datasource (void) |
void | set_allow_autoincwrite (bool r) |
bool | allow_autoincwrite (void) |
bool | in_definitionmode (void) |
hk_string | curval_asstring (void) |
double | curval_asdouble (void) |
long int | curval_asinteger (void) |
bool | curval_asbool (void) |
void | set_definitionmode (bool def) |
hk_string | tableorigin (void) |
![]() | |
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) |
Protected Member Functions | |
hk_column (hk_datasource *ds, const hk_string &TRUESTRING, const hk_string &FALSESTRING) | |
virtual bool | driver_specific_asstring (const hk_string &d) |
virtual hk_string | driver_specific_asstring_at (unsigned long a) |
virtual const char * | driver_specific_transformed_asstring_at (unsigned long) |
virtual const struct_raw_data * | driver_specific_asbinary_at (unsigned long a) |
virtual bool | driver_specific_asbinary (const char *b) |
virtual void | driver_specific_asbool (bool b) |
virtual bool | driver_specific_asbool_at (unsigned long a) |
virtual bool | driver_specific_is_nullvalue_at (unsigned long) |
virtual void | data_has_changed (void) |
void | datavisible_add (hk_dsdatavisible *) |
void | datavisible_remove (hk_dsdatavisible *) |
![]() | |
hk_interpreter * | new_interpreter (const hk_string &interpreter, hk_presentation *) |
Protected Attributes | |
hk_datasource * | p_datasource |
unsigned int | p_fieldnr |
bool | p_readonly |
bool | p_driver_specific_delimit_bool |
unsigned long | p_driver_specific_data_size |
char * | p_driver_specific_data |
char * | p_original_new_data |
unsigned long | p_original_new_data_size |
hk_string | p_sqltextdelimiter |
hk_string | p_sqlnulldelimiter |
hk_string | p_new_data_asstring |
hk_string | p_true |
hk_string | p_false |
hk_string | p_dateformat |
hk_string | p_timeformat |
hk_string | p_datetimeformat |
hk_string | p_driverspecific_dateformat |
hk_string | p_driverspecific_timeformat |
hk_string | p_driverspecific_datetimeformat |
hk_string | p_driverspecific_timestampformat |
hk_string | p_driverspecific_locale |
int | p_driverspecific_digits |
Friends | |
class | hk_datasource |
class | hk_dsdatavisible |
Additional Inherited Members | |
![]() | |
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) |
![]() | |
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 one column of a datasource.
represents one column of a datasource. The data of the current row (set in hk_datasource) can be modified by using the functions set_asstring, set_asbool and set_asbinary and read by using the functions asstring, asbool and asbinary.
If the the datasource is in alter or create mode you can change the column definition by using the following functions: set_name, set_columntype, set_size, set_notnull, set_primary
used from hk_column to define of what type it is. For details how the different column types are interpreted look up the documentation of your database server and the database driver.
textcolumn : fixed length (usually in SQL defined as CHAR(size))
auto_inccolumn: if the databasedriver supports this columntype it will get a unique number automatically, whenever a new row will be added. Usually a readonly column
smallintegercolumn: a integer range of at least -32768 to 32767
integercolumn: a integer with the maximum range the database server can handle
smallfloatingcolumn: a floating column with a range of at least ????
floatingcolumn: a floating column with the maximum range the database server can handle
datecolumn: a column to keep the day,month and year of a date
datetimecolumn: a column to keep the day,month and year of a date PLUS the hour,minute and second of a time
timecolumn: a column to keep the hour,minute and second of a time.
binarycolumn: a column to store binary data of more or less any size.
memocolumn: a column to store text data of more or less any size.
boolcolumn: a column that has 2 states 'true' or 'false'
othercolumn: a column hk_classes does not know, but tries to handle as good as it can.
const struct_raw_data * hk_column::asbinary | ( | void | ) |
returns the value of the column as raw data.
References asbinary_at(), and hk_datasource::row_position().
Referenced by save_to_file().
const struct_raw_data * hk_column::asbinary_at | ( | unsigned long | a | ) |
returns the value of the column at a specific rowposition as raw data.
Referenced by asbinary().
bool hk_column::asbool | ( | void | ) |
returns the value of this column, type converted to a bool. (All columntypes except Binary).
References hk_datasource::row_position().
Referenced by curval_asbool().
hk_string hk_column::asstring | ( | bool | as_locale = true | ) |
returns the value of this column, type converted to a hk_string. (All columntypes except BINARY).
as_locale | if true numbers, times and dates will be displayed in the users localized version |
References asstring_at(), hk_datasource::is_enabled(), hk_datasource::max_rows(), and hk_datasource::row_position().
Referenced by hk_reportdata::count(), curval_asstring(), hk_mysqldatabase::driver_specific_tablelist(), hk_reportsection::new_uniquevalue(), save_to_file(), hk_mysqlconnection::server_supports(), and hk_datasource::setmode_insertrow().
hk_string hk_column::asstring_at | ( | unsigned long | a, |
bool | as_locale = true |
||
) |
returns the value at a specific position in the column. The row selector will not be changed, so the visible objects will not be informed. Use asstring in combination with hk_datasource::goto_row instead.
References columntype(), hk_class::hk_translate(), hk_datasource::is_enabled(), and hk_datasource::max_rows().
Referenced by asstring(), is_findstring(), hk_reportsection::new_uniquevalue(), hk_dscombobox::value_at(), and hk_dsdatavisible::value_at().
const struct_raw_data * hk_column::changed_data | ( | void | ) |
returns the new data set by a function like asstring(hk_string& n);
hk_string hk_column::changed_data_asstring | ( | bool | as_locale = true | ) |
if new data was inserted with the method asstring and the changes have not yet been stored this method returns the changed data
Referenced by curval_asstring(), and hk_dsdatavisible::value_at().
hk_column::enum_columntype hk_column::columntype | ( | void | ) | const |
If you need the column type as a hk_string use columntype_name to translate.
Referenced by asstring_at(), hk_database::copy_table(), hk_dsdatavisible::defaultvalue(), save_to_file(), hk_dsdatavisible::use_defaultvalue(), and hk_dsdatavisible::value_at().
hk_string hk_column::columntype_name | ( | void | ) |
to translate the columntype into a hk_string.
References hk_class::hk_translate().
bool hk_column::curval_asbool | ( | void | ) |
returns the current value as a boolean value. The difference to asbool is, that it will return the changed_data if the current data was changed by setting the data with e.g. set_asbool()
References asbool(), and has_changed().
double hk_column::curval_asdouble | ( | void | ) |
returns the current value as a floating point number . The difference to asdouble is, that it will return the changed_data if the current data was changed by setting the data with e.g. set_asdouble()
References has_changed().
long int hk_column::curval_asinteger | ( | void | ) |
returns the current value as a integer. The difference to asinteger is, that it will return the changed_data if the current data was changed by setting the data with e.g. set_asinteger()
References has_changed().
hk_string hk_column::curval_asstring | ( | void | ) |
returns the current value as a string. The difference to asstring is, that it will return the changed_data if the current data was changed by setting the data with e.g. set_asstring()
References asstring(), changed_data_asstring(), and has_changed().
unsigned int hk_column::fieldnumber | ( | void | ) |
A temporarily given unique number of this row
unsigned int hk_column::find | ( | unsigned int | from, |
unsigned int | to, | ||
const hk_string & | searchtext, | ||
bool | wholephrase = false , |
||
bool | casesensitive = false , |
||
bool | backwards = false |
||
) |
search for a specific value in a column
from | number of the first row where the search has to start. First row is number 0 |
to | number of the last row where the search has to end. Last row is number max_rows-1; |
searchtext | value as hk_string to look for |
wholephrase | if false the searchtext is part of columnvalue, if true it has to be an exact match |
casesensitive | if true a case sensitive compararation is used |
backwards | searching backwards, default is forward |
References hk_class::hkdebug(), is_findstring(), and hk_datasource::max_rows().
Referenced by find(), hk_database::rename_file(), and hk_dscombobox::value_at().
unsigned int hk_column::find | ( | const hk_string & | searchtext, |
bool | wholephrase = false , |
||
bool | casesensitive = false , |
||
bool | backwards = false |
||
) |
search from the beginning to the end for searchtext
searchtext | value as hk_string to look for |
References find(), hk_class::hkdebug(), and hk_datasource::max_rows().
hk_string hk_column::get_delimiter | ( | void | ) |
bool hk_column::has_changed | ( | void | ) |
Referenced by curval_asbool(), curval_asdouble(), curval_asinteger(), curval_asstring(), and hk_dsdatavisible::value_at().
bool hk_column::in_definitionmode | ( | void | ) |
data type, name and some other metadata can only be changed if the datasource is either in create_mode or alter_mode (or while the datasource enables and automatically creates columns)
References hk_datasource::mode().
Referenced by set_columntype(), set_name(), set_notnull(), set_primary(), set_readonly(), and set_size().
bool hk_column::is_findstring | ( | unsigned int | pos, |
const hk_string & | searchtext, | ||
bool | wholephrase = false , |
||
bool | casesensitive = false |
||
) |
an internal used function which compares the column value at row number "pos"
References asstring_at(), and hk_class::hkdebug().
Referenced by find().
bool hk_column::is_notnull | ( | void | ) |
Referenced by hk_datasource::alter_column().
bool hk_column::is_primary | ( | void | ) |
Referenced by hk_datasource::alter_column().
bool hk_column::is_readonly | ( | void | ) | const |
References hk_datasource::is_readonly().
Referenced by set_asbinary(), and set_asbool().
bool hk_column::load_from_file | ( | const hk_string & | filename | ) |
changes the value of the column with the content of the file"filename". Very useful for binary columns.
References hk_class::hkdebug().
hk_string hk_column::name | ( | void | ) | const |
name of the column
Referenced by hk_datasource::column_by_name(), and hk_datasource::columnname_occurance().
void hk_column::reset_changed_data | ( | void | ) |
set all changed data back to it's default value. Usually you donīt have to call this function
References hk_class::hkdebug().
bool hk_column::save_to_file | ( | const hk_string & | filename | ) |
save the value of this column in a file. Very useful for binary-columns
References asbinary(), asstring(), columntype(), and hk_class::hkdebug().
void hk_column::set_allow_autoincwrite | ( | bool | r | ) |
a column of type autoinc is usually readonly. if allow_autoincwrite is set to true it will be writeable if the database driver supports it
void hk_column::set_asbinary | ( | const struct_raw_data * | rd | ) |
changes the value of the column in native form.(i.e. Binary data)
References hk_class::hkdebug(), and is_readonly().
Referenced by hk_database::copy_table().
void hk_column::set_asbool | ( | bool | b | ) |
b | new value of the column. |
References hk_class::hkdebug(), and is_readonly().
Referenced by hk_database::copy_table().
void hk_column::set_asdouble | ( | double | s, |
bool | registerchange = true |
||
) |
s | new value of the column. |
References set_asstring().
void hk_column::set_asinteger | ( | long int | s, |
bool | registerchange = true |
||
) |
s | new value of the column. |
References set_asstring().
void hk_column::set_asstring | ( | const hk_string & | s, |
bool | registerchange = true |
||
) |
s | new value of the column. |
Referenced by hk_database::copy_table(), hk_database::rename_file(), set_asdouble(), set_asinteger(), hk_dsdatavisible::set_value(), and hk_datasource::setmode_insertrow().
void hk_column::set_boolvalues | ( | const hk_string & | TRUESTRING, |
const hk_string & | FALSESTRING | ||
) |
you have the possibility to set the values which the column will accept as true and false. i.e. 0 and 1 for numeric columns or for text columns yes and no, or true and false.
void hk_column::set_columntype | ( | enum_columntype | f | ) |
can just be edited if the datasource is in the mode ALTER or CREATE.
References hk_class::hkdebug(), in_definitionmode(), and hk_class::show_warningmessage().
|
inline |
if the column is of type date, time or datetime you can specify the wished format with this function. See hk_datetime for details.
|
inline |
if the column is of type date, time or datetime you can specify the wished format with this function. See hk_datetime for details.
void hk_column::set_name | ( | const hk_string & | n | ) |
name of the column. Can just be edited if the datasource is in the mode ALTER or CREATE.
References hk_class::hkdebug(), in_definitionmode(), and hk_class::show_warningmessage().
bool hk_column::set_notnull | ( | bool | i | ) |
can just be edited if the datasource is in the mode ALTER or CREATE.
References hk_class::hkdebug(), in_definitionmode(), and hk_class::show_warningmessage().
bool hk_column::set_primary | ( | bool | i | ) |
can only be edited if the datasource is in the mode ALTER or CREATE.
References hk_class::hkdebug(), in_definitionmode(), and hk_class::show_warningmessage().
void hk_column::set_readonly | ( | bool | r | ) |
If the datasource is of type ds_table you can allow or disallow data changes in this column.
References hk_class::hkdebug(), in_definitionmode(), and hk_class::show_warningmessage().
void hk_column::set_size | ( | long | s | ) |
can just be edited if the datasource is in the mode ALTER or CREATE.
References hk_class::hkdebug(), in_definitionmode(), and hk_class::show_warningmessage().
|
inline |
if the column is of type date, time or datetime you can specify the wished format with this function. See hk_datetime for details.
long hk_column::size | ( | void | ) |
column length in bytes
const char * hk_column::transformed_asstring | ( | void | ) |
Columns can contain characters such as \0, \n, ' and so on. Some SQL Servers need to encode this data, so this function delivers the encoded and nonlocalized version.
References hk_datasource::row_position().
const struct_raw_data * hk_column::transformed_changed_data | ( | void | ) |
returns the new data set by a function like asstring(hk_string& n) in SQL server native form.