Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

hk_classes/hk_classes/hk_column.h

Go to the documentation of this file.
00001 // ****************************************************************************
00002 // copyright (c) 2000-2005 Horst Knorr <hk_classes@knoda.org>
00003 // This file is part of the hk_classes library.
00004 // This file may be distributed and/or modified under the terms of the
00005 // GNU Library Public License version 2 as published by the Free Software
00006 // Foundation and appearing in the file COPYING included in the
00007 // packaging of this file.
00008 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00009 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00010 // ****************************************************************************
00011 #ifndef HK_COLUMN
00012 #define HK_COLUMN
00013 #include "hk_class.h"
00014 #include <list>
00015 using namespace std;
00016 
00017 class hk_datasource;
00018 class hk_dsdatavisible;
00034 class hk_column:public hk_class
00035 
00036 {
00037     friend class hk_datasource;
00038     friend class hk_dsdatavisible;
00039     public:
00043         hk_string    name(void) const;
00047         void    set_name(const hk_string& n);
00048 
00054         bool    is_readonly(void) const;
00058         void    set_readonly(bool r);
00059 
00093         enum enum_columntype {textcolumn,auto_inccolumn,smallintegercolumn,integercolumn,smallfloatingcolumn,floatingcolumn,datecolumn,datetimecolumn,timecolumn,timestampcolumn,binarycolumn,memocolumn,boolcolumn,othercolumn};
00094 
00100         enum_columntype     columntype(void) const;
00105         void    set_columntype(enum_columntype f);
00109         long    size(void);
00113         void    set_size(long s);
00117         hk_string   columntype_name(void);
00121         bool    is_primary(void);
00125         bool    set_primary(bool i);
00129         bool    is_notnull(void);
00130 
00134         hk_string    get_delimiter(void);
00135 
00139         bool    set_notnull(bool i);
00143         bool    has_changed(void);
00148         hk_string   asstring(bool as_locale=true);
00152         void    set_asstring(const hk_string& s, bool registerchange=true);
00153         void    set_asstring(const hk_string& s,bool registerchange,bool is_locale);
00159         const   char*   transformed_asstring(void);
00160         const   char*   transformed_asstring_at(unsigned long position);
00165         hk_string   changed_data_asstring(bool as_locale=true);
00171         void    set_asbinary(const struct_raw_data* rd);
00176         const   struct_raw_data* asbinary(void);
00180         const   struct_raw_data* asbinary_at(unsigned long a);
00181 
00185         void    set_asbool(bool b);
00189         bool    asbool(void);
00190         bool    asbool_at(unsigned long a);
00191         bool    changed_data_asbool(void);
00192 
00193 
00197         void set_asinteger(long int s, bool registerchange=true);
00198         long int asinteger(void);
00199         long int asinteger_at(unsigned long );
00200         long int changed_data_asinteger(void);
00201 
00205         void set_asdouble(double s, bool registerchange=true);
00206         double asdouble(void);
00207         double asdouble_at(unsigned long );
00208         double changed_data_asdouble(void);
00209 
00213         unsigned int    fieldnumber(void);
00214 
00220         hk_string   asstring_at(unsigned long a,bool as_locale=true);
00221 
00222         bool is_nullvalue(void);
00223         bool changed_data_is_nullvalue(void);
00224         bool is_nullvalue_at(unsigned long a);
00225         void set_asnullvalue(bool registerchange=true);
00226 
00227         long int count(unsigned int from,unsigned int to);
00228         double sum(unsigned int from,unsigned int to);
00229         long int count();
00230         double sum();
00231 
00242         unsigned int find(unsigned int from,unsigned int to,const hk_string& searchtext,bool wholephrase=false,bool casesensitive=false,bool backwards=false);
00248         unsigned int find(const hk_string& searchtext,bool wholephrase=false,bool casesensitive=false,bool backwards=false);
00252         bool is_findstring(unsigned int pos,const hk_string& searchtext,bool wholephrase=false,bool casesensitive=false);
00253 
00257         const   struct_raw_data*    changed_data(void);
00258 
00263         const   struct_raw_data*    transformed_changed_data(void);
00268         void    reset_changed_data(void);
00269 
00275         void set_boolvalues(const hk_string& TRUESTRING, const hk_string& FALSESTRING);
00276         hk_string bool_truevalue(void);
00277         hk_string bool_falsevalue(void);
00282         void set_dateformat(const hk_string& df){p_dateformat=df;}
00287         void set_timeformat(const hk_string& tf){p_timeformat=tf;}
00292         void set_datetimeformat(const hk_string& dtf){p_datetimeformat=dtf;}
00296         bool save_to_file(const hk_string& filename);
00301         bool load_from_file(const hk_string& filename);
00302 
00303         void save_columndefinition(ostream&);
00304         void load_columndefinition(const hk_string& );
00305         hk_datasource* datasource(void);
00310         void    set_allow_autoincwrite(bool r);
00311         bool    allow_autoincwrite(void);
00317         bool in_definitionmode(void);
00322 hk_string curval_asstring(void);
00327 double curval_asdouble(void);
00332 long int curval_asinteger(void);
00337 bool      curval_asbool(void);
00338 
00339 void set_definitionmode(bool def);
00340 
00341 hk_string tableorigin(void);
00342 
00343     protected:
00344         hk_column(hk_datasource* ds, const hk_string& TRUESTRING,const hk_string& FALSESTRING);
00345         virtual ~hk_column();
00346         virtual bool        driver_specific_asstring(const hk_string& d);
00347         virtual hk_string driver_specific_asstring_at(unsigned long a);
00348         virtual const char* driver_specific_transformed_asstring_at(unsigned long ){return "";}
00349         virtual const struct_raw_data* driver_specific_asbinary_at(unsigned long a);
00350         virtual bool        driver_specific_asbinary(const char* b);
00351         virtual void        driver_specific_asbool(bool b);
00352         virtual bool        driver_specific_asbool_at(unsigned long a);
00353         virtual bool        driver_specific_is_nullvalue_at(unsigned long);
00354         virtual void data_has_changed(void);
00355         void datavisible_add(hk_dsdatavisible*);
00356         void datavisible_remove(hk_dsdatavisible*);
00357         hk_datasource*  p_datasource;
00358         unsigned int    p_fieldnr;
00359         bool        p_readonly;
00360         bool        p_driver_specific_delimit_bool;
00361         unsigned long   p_driver_specific_data_size;
00362         char*       p_driver_specific_data;
00363         char*       p_original_new_data;          // where datachanges are stored temporarily
00364         unsigned long   p_original_new_data_size;
00365         hk_string   p_sqltextdelimiter;
00366         hk_string   p_sqlnulldelimiter;
00367         hk_string   p_new_data_asstring;
00368         hk_string   p_true;
00369         hk_string   p_false;
00370         hk_string   p_dateformat;
00371         hk_string   p_timeformat;
00372         hk_string   p_datetimeformat;
00373         hk_string   p_driverspecific_dateformat;
00374         hk_string   p_driverspecific_timeformat;
00375         hk_string   p_driverspecific_datetimeformat;
00376         hk_string   p_driverspecific_timestampformat;
00377         hk_string   p_driverspecific_locale;
00378         int         p_driverspecific_digits;
00379     private:
00380        void before_alter_table();
00381         hk_string       p_columnname,p_originalcolumnname, p_tableorigin;
00382         enum_columntype p_columntype,p_originalcolumntype;
00383         long        p_size,p_originalsize;
00384         bool        p_primary_index,p_originalprimary_index;
00385         bool        p_notnull,p_originalnotnull;
00386         bool        p_has_changed;
00387         bool        p_allow_autoincwrite;
00388         bool        p_table_origin_already_set;
00389         struct_raw_data p_binary;
00390         struct_raw_data p_changed_data_struct;
00391         struct_raw_data p_transformed_changed_data_struct;
00392         list<hk_dsdatavisible*> p_datavisibles;
00393         void set_has_changed();
00394         void set_has_not_changed();
00395         bool p_definitionmode;
00396 
00397 } ;
00398 #endif

Generated on Thu Mar 9 18:40:40 2006 for hk_classes by  doxygen 1.4.1