# class hk_column

represents one column of a datasource. More...

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

Annotated List
Files
Globals
Hierarchy
Index

#### Public Types

- enum enum_columntype {textcolumn,auto_inccolumn,smallintegercolumn,integercolumn,smallfloatingcolumn,floatingcolumn,datecolumn,datetimecolumn,timecolumn,timestampcolumn,binarycolumn,memocolumn,boolcolumn,othercolumn}

#### Public Methods

- hk_string name (void)
- void set_name (const hk_string& n)
- bool is_readonly (void)
- void set_readonly (bool r)
- enum_columntype columntype (void)
- 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&, 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, bool registerchange=true)
- long int asinteger (void)
- long int asinteger_at (unsigned long )
- long int changed_data_asinteger (void)
- void set_asdouble (double, 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 is_nullvalue_at (unsigned long a)
- void set_asnullvalue (bool registerchange=true)
- 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)
- void set_timeformat (const hk_string& tf)
- void set_datetimeformat (const hk_string& dtf)
- bool save_to_file (const hk_string& filename)
- bool load_from_file (const hk_string& filename)
- void save_columndefinition (ostream&)
- void load_columndefinition (const hk_string& )
- 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)

#### Protected Methods

- hk_column (hk_datasource* ds, const hk_string& TRUESTRING,const hk_string& FALSESTRING)
- virtual ~hk_column ()
- 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*)

#### Protected Members

- 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

## Detailed Description

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

hk_string name (void)

### name

name of the column

void set_name (const hk_string& n)

### set_name

name of the column. Can just be edited if the datasource is in the mode ALTER or CREATE.

bool is_readonly (void)

### is_readonly

Returns: true if data in this column can be changed. Always false if the datasource is a result_query.

void set_readonly (bool r)

### set_readonly

If the datasource is of type ds_table you can allow or disallow data changes in this column.

enum enum_columntype {textcolumn,auto_inccolumn,smallintegercolumn,integercolumn,smallfloatingcolumn,floatingcolumn,datecolumn,datetimecolumn,timecolumn,timestampcolumn,binarycolumn,memocolumn,boolcolumn,othercolumn}

### enum_columntype

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.

enum_columntype columntype (void)

### columntype

If you need the column type as a hk_string use columntype_name to translate.

Returns: the type of the column of type enum_columntype.

void set_columntype (enum_columntype f)

### set_columntype

can just be edited if the datasource is in the mode ALTER or CREATE.

long size (void)

### size

column length in bytes

void set_size (long s)

### set_size

can just be edited if the datasource is in the mode ALTER or CREATE.

hk_string columntype_name (void)

### columntype_name

to translate the columntype into a hk_string.

bool is_primary (void)

### is_primary

Returns: true if this column is part of the primary key (primary index).

bool set_primary (bool i)

### set_primary

can only be edited if the datasource is in the mode ALTER or CREATE.

bool is_notnull (void)

### is_notnull

Returns: true if this column has to have a value.

hk_string get_delimiter (void)

### get_delimiter

Returns: A string value representing the proper delimiter to use.

bool set_notnull (bool i)

### set_notnull

can just be edited if the datasource is in the mode ALTER or CREATE.

bool has_changed (void)

### has_changed

Returns: true if the value of the column has changed and not yet saved in the database.

hk_string asstring (bool as_locale=true)

### asstring

returns the value of this column, type converted to a hk_string. (All columntypes except BINARY).

Parameters:

as_locale | if true numbers, times and dates will be displayed in the users localized version

void set_asstring (const hk_string&, bool registerchange=true)

### set_asstring

Parameters:

s | new value of the column.

void set_asstring (const hk_string& s,bool registerchange,bool is_locale)

### set_asstring

const char* transformed_asstring (void)

### transformed_asstring

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.

const char* transformed_asstring_at (unsigned long position)

### transformed_asstring_at

hk_string changed_data_asstring (bool as_locale=true)

### changed_data_asstring

if new data was inserted with the method asstring and the changes have not yet been stored this method returns the changed data

void set_asbinary (const struct_raw_data* rd)

### set_asbinary

changes the value of the column in native form.(i.e. Binary data)

See also: load_from_file

const struct_raw_data* asbinary (void)

### asbinary

returns the value of the column as raw data.

See also: save_to_file.

const struct_raw_data* asbinary_at (unsigned long a)

### asbinary_at

returns the value of the column at a specific rowposition as raw data.

void set_asbool (bool b)

### set_asbool

Parameters:

b | new value of the column.

bool asbool (void)

### asbool

returns the value of this column, type converted to a bool. (All columntypes except Binary).

bool asbool_at (unsigned long a)

### asbool_at

bool changed_data_asbool (void)

### changed_data_asbool

void set_asinteger (long int, bool registerchange=true)

### set_asinteger

Parameters:

s | new value of the column.

long int asinteger (void)

### asinteger

long int asinteger_at (unsigned long )

### asinteger_at

long int changed_data_asinteger (void)

### changed_data_asinteger

void set_asdouble (double, bool registerchange=true)

### set_asdouble

Parameters:

s | new value of the column.

double asdouble (void)

### asdouble

double asdouble_at (unsigned long )

### asdouble_at

double changed_data_asdouble (void)

### changed_data_asdouble

unsigned int fieldnumber (void)

### fieldnumber

A temporarily given unique number of this row

hk_string asstring_at (unsigned long a,bool as_locale=true)

### asstring_at

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.

bool is_nullvalue (void)

### is_nullvalue

bool is_nullvalue_at (unsigned long a)

### is_nullvalue_at

void set_asnullvalue (bool registerchange=true)

### set_asnullvalue

unsigned int find (unsigned int from,unsigned int to,const hk_string& searchtext,bool wholephrase=false,bool casesensitive=false,bool backwards=false)

### find

search for a specific value in a column

Parameters:

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

Returns: row number if found, max_rows()+1 if not found

unsigned int find (const hk_string& searchtext,bool wholephrase=false,bool casesensitive=false,bool backwards=false)

### find

search from the beginning to the end for searchtext

Parameters:

searchtext | value as hk_string to look for

Returns: row number if found, max_rows()+1 if not found

bool is_findstring (unsigned int pos,const hk_string& searchtext,bool wholephrase=false,bool casesensitive=false)

### is_findstring

an internal used function which compares the column value at row number "pos"

const struct_raw_data* changed_data (void)

### changed_data

returns the new data set by a function like asstring(hk_string& n);

const struct_raw_data* transformed_changed_data (void)

### transformed_changed_data

returns the new data set by a function like asstring(hk_string& n) in SQL server native form.

void reset_changed_data (void)

### reset_changed_data

set all changed data back to itīs default value. Usually you donīt have to call this function

void set_boolvalues (const hk_string& TRUESTRING, const hk_string& FALSESTRING)

### set_boolvalues

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.

hk_string bool_truevalue (void)

### bool_truevalue

hk_string bool_falsevalue (void)

### bool_falsevalue

void set_dateformat (const hk_string& df)

### set_dateformat

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 set_timeformat (const hk_string& tf)

### set_timeformat

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 set_datetimeformat (const hk_string& dtf)

### set_datetimeformat

if the column is of type date, time or datetime you can specify the wished format with this function. See hk_datetime for details.

bool save_to_file (const hk_string& filename)

### save_to_file

save the value of this column in a file. Very useful for binary-columns

bool load_from_file (const hk_string& filename)

### load_from_file

changes the value of the column with the content of the file"filename". Very useful for binary columns.

void save_columndefinition (ostream&)

### save_columndefinition

void load_columndefinition (const hk_string& )

### load_columndefinition

hk_datasource* datasource (void)

### datasource

void set_allow_autoincwrite (bool r)

### set_allow_autoincwrite

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

bool allow_autoincwrite (void)

### allow_autoincwrite

bool in_definitionmode (void)

### in_definitionmode

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)

Returns: true if metadata can be modified, else false

hk_string curval_asstring (void)

### curval_asstring

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

double curval_asdouble (void)

### curval_asdouble

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

long int curval_asinteger (void)

### curval_asinteger

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

bool curval_asbool (void)

### curval_asbool

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

void set_definitionmode (bool def)

### set_definitionmode

hk_column (hk_datasource* ds, const hk_string& TRUESTRING,const hk_string& FALSESTRING)

### hk_column

[protected]

~hk_column ()

### ~hk_column

[protected virtual]

bool driver_specific_asstring (const hk_string& d)

### driver_specific_asstring

[protected virtual]

hk_string driver_specific_asstring_at (unsigned long a)

### driver_specific_asstring_at

[protected virtual]

const char* driver_specific_transformed_asstring_at (unsigned long )

### driver_specific_transformed_asstring_at

[protected virtual]

const struct_raw_data* driver_specific_asbinary_at (unsigned long a)

### driver_specific_asbinary_at

[protected virtual]

bool driver_specific_asbinary (const char* b)

### driver_specific_asbinary

[protected virtual]

void driver_specific_asbool (bool b)

### driver_specific_asbool

[protected virtual]

bool driver_specific_asbool_at (unsigned long a)

### driver_specific_asbool_at

[protected virtual]

bool driver_specific_is_nullvalue_at (unsigned long)

### driver_specific_is_nullvalue_at

[protected virtual]

void data_has_changed (void)

### data_has_changed

[protected virtual]

void datavisible_add (hk_dsdatavisible*)

### datavisible_add

[protected]

void datavisible_remove (hk_dsdatavisible*)

### datavisible_remove

[protected]

hk_datasource* p_datasource

### p_datasource

[protected]

unsigned int p_fieldnr

### p_fieldnr

[protected]

bool p_readonly

### p_readonly

[protected]

bool p_driver_specific_delimit_bool

### p_driver_specific_delimit_bool

[protected]

unsigned long p_driver_specific_data_size

### p_driver_specific_data_size

[protected]

char* p_driver_specific_data

### p_driver_specific_data

[protected]

char* p_original_new_data

### p_original_new_data

[protected]

unsigned long p_original_new_data_size

### p_original_new_data_size

[protected]

hk_string p_sqltextdelimiter

### p_sqltextdelimiter

[protected]

hk_string p_sqlnulldelimiter

### p_sqlnulldelimiter

[protected]

hk_string p_new_data_asstring

### p_new_data_asstring

[protected]

hk_string p_true

### p_true

[protected]

hk_string p_false

### p_false

[protected]

hk_string p_dateformat

### p_dateformat

[protected]

hk_string p_timeformat

### p_timeformat

[protected]

hk_string p_datetimeformat

### p_datetimeformat

[protected]

hk_string p_driverspecific_dateformat

### p_driverspecific_dateformat

[protected]

hk_string p_driverspecific_timeformat

### p_driverspecific_timeformat

[protected]

hk_string p_driverspecific_datetimeformat

### p_driverspecific_datetimeformat

[protected]

hk_string p_driverspecific_timestampformat

### p_driverspecific_timestampformat

[protected]

hk_string p_driverspecific_locale

### p_driverspecific_locale

[protected]

int p_driverspecific_digits

### p_driverspecific_digits

[protected]

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