field.h

Go to the documentation of this file.
00001 /* Data fields.
00002  *
00003  * PegSoft databases library (c) 2005 PegSoft
00004  * Contact us at pegsoft@pegsoft.net
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program (see the file COPYING); if not, write to the
00018  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00024 #ifndef DATABASES_FIELD_H
00025 #define DATABASES_FIELD_H
00026 
00027 /*************************************************************************/
00028 
00029 #include <databases/record.h>
00030 #include <misc/string.h>
00031 
00032 /*************************************************************************/
00033     
00034 namespace databases
00035 {
00036 
00037 /*************************************************************************/
00038 
00040 
00055 class Field
00056 {
00057     public:
00059         Field() : m_name(0), m_minver(0), m_maxver(0), m_type(0), m_size(0),
00060                 m_attrs(0), m_default(0), m_utdefault(0), m_tag(0),
00061                 m_setup(false) { }
00063         virtual ~Field() { }
00064     
00066 
00075         virtual bool setup();
00076     
00078         char const *name() const { return m_name; }
00080 
00086         char const *name(char const *name);
00087         
00089 
00110         uint16_t version(int type) const;
00111         
00113 
00123         uint16_t version(int type, uint16_t ver);
00124         
00126         static uint16_t const ftString = 1;
00128         static uint16_t const ftInteger = 2;
00130         static uint16_t const ftUnsigned = 3;
00132         static uint16_t const ftUnixTime = 4;
00134         static uint16_t const ftIdentifier = 5; 
00136         static uint16_t const ftCount = 5;
00137         
00139         uint16_t type() const { return m_type; }
00141 
00159         uint16_t type(uint16_t type);
00160         
00162         size_t size() const { return m_size; }
00164 
00173         size_t size(size_t size);
00174         
00176         enum
00177         {
00179             faCase = 0x0001,
00181             faOwner = 0x0002,
00183             faOwnerUnique = 0x0004
00184         };
00185         
00187 
00198         uint16_t attrs() const { return m_attrs; }
00200         uint16_t attrs_add(uint16_t attrs);
00202         uint16_t attrs_remove(uint16_t attrs);
00203         
00205         char const *default_value() const { return m_default; }
00207 
00217         char const *default_value(char const *defval); 
00218         
00220 
00225         int32_t idefault_value() const { return m_idefault; }
00226         
00228 
00233         uint32_t uidefault_value() const { return m_uidefault; }
00234         
00236 
00241         time_t utdefault_value() const { return m_utdefault; }
00242         
00244 
00249         Record::identifier_type ridefault_value() const { return m_ridefault; }
00250         
00252         uint16_t tag() const { return m_tag; }
00254 
00262         uint16_t tag(uint16_t tag);
00263     protected:
00265         misc::cstring m_name;
00266         
00268         uint16_t m_minver;
00270         uint16_t m_maxver;
00271         
00273         uint16_t m_type;
00275         size_t m_size;
00277         uint16_t m_attrs;
00278         
00280         misc::cstring m_default;
00281         
00283         union
00284         {
00286             int32_t m_idefault;
00288             uint32_t m_uidefault;
00290             time_t m_utdefault;
00292             Record::identifier_type m_ridefault;
00293         };
00294         
00296         uint16_t m_tag;
00297         
00299         bool m_setup;
00300     private:
00301         Field(Field const &);
00302         Field &operator=(Field const &);
00303 };
00304 
00305 /*************************************************************************/
00306 
00307 } /* namespace databases */
00308 
00309 /*************************************************************************/
00310 
00311 #endif /* DATABASES_FIELD_H */

Generated on Wed Aug 15 00:37:22 2007 for Epona API by  doxygen 1.5.2