Eneboo - Documentación para desarrolladores
src/sqlite/qry_dat.h
Ir a la documentación de este archivo.
00001 /**********************************************************************
00002  * Copyright (c) 2004, Leo Seib, Hannover
00003  *
00004  * Project:Dataset C++ Dynamic Library
00005  * Module: FieldValue class and result sets classes header file
00006  * Author: Leo Seib      E-Mail: leoseib@web.de
00007  * Begin: 5/04/2002
00008  *
00009  * Permission is hereby granted, free of charge, to any person obtaining a copy
00010  * of this software and associated documentation files (the "Software"), to deal
00011  * in the Software without restriction, including without limitation the rights
00012  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00013  * copies of the Software, and to permit persons to whom the Software is
00014  * furnished to do so, subject to the following conditions:
00015  *
00016  * The above copyright notice and this permission notice shall be included in
00017  * all copies or substantial portions of the Software.
00018  *
00019  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00020  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00022  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00024  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00025  * THE SOFTWARE.
00026  *
00027  **********************************************************************/
00028 
00029 #include <stdio.h>
00030 
00031 #include <map>
00032 #include <vector>
00033 #include <iostream>
00034 #include <string>
00035 
00036 #ifndef _QRYDAT_H
00037 #define _QRYDAT_H
00038 
00039 
00040 using namespace std;
00041 
00042 namespace dbiplus {
00043 
00044 enum fType { 
00045         ft_String,
00046         ft_Boolean,
00047         ft_Char,
00048         ft_WChar,
00049         ft_WideString,
00050         ft_Short,
00051         ft_UShort,
00052         ft_Long,
00053         ft_ULong,
00054         ft_Float,
00055         ft_Double,
00056         ft_LongDouble,
00057         ft_Object
00058     };
00059 
00060 class FL_EXPORT field_value {
00061 private:
00062   fType field_type;
00063   string str_value;
00064   union {
00065     bool   bool_value;
00066     char   char_value;
00067     short  short_value;
00068     unsigned short ushort_value;
00069     long   long_value;
00070     unsigned long  ulong_value;
00071     float  float_value;
00072     double double_value;
00073     void   *object_value;
00074   } ;
00075 
00076   bool is_null;
00077 
00078 public:
00079   field_value();
00080   field_value(const char *s);
00081   field_value(const bool b);
00082   field_value(const char c);
00083   field_value(const short s);
00084   field_value(const unsigned short us);
00085   field_value(const long l);
00086   field_value(const unsigned long ul);
00087   field_value(const int i);
00088   field_value(const float f);
00089   field_value(const double d);
00090   field_value(const field_value & fv);
00091   ~field_value();
00092   
00093 
00094   fType get_fType() const {return field_type;}
00095   bool get_isNull() const {return is_null;}
00096   string get_asString() const;
00097   bool get_asBool() const;
00098   char get_asChar() const;
00099   short get_asShort() const;
00100   unsigned short get_asUShort() const;
00101   long get_asLong() const;
00102   int get_asInteger() const;
00103   unsigned long get_asULong() const;
00104   float get_asFloat() const;
00105   double get_asDouble() const;
00106 
00107   field_value& operator= (const char *s)
00108     {set_asString(s); return *this;}
00109   field_value& operator= (const string &s)
00110     {set_asString(s); return *this;}
00111   field_value& operator= (const bool b)
00112     {set_asBool(b); return *this;}
00113   field_value& operator= (const short s)
00114     {set_asShort(s); return *this;}
00115   field_value& operator= (const unsigned short us)
00116     {set_asUShort(us); return *this;}
00117   field_value& operator= (const long l)
00118     {set_asLong(l); return *this;}
00119   field_value& operator= (const unsigned long l)
00120     {set_asULong(l); return *this;}
00121   field_value& operator= (const int i)
00122     {set_asLong(i); return *this;}
00123   field_value& operator= (const float f)
00124     {set_asFloat(f); return *this;}
00125   field_value& operator= (const double d)
00126     {set_asDouble(d); return *this;}
00127   field_value& operator= (const field_value & fv);
00128   
00129   //class ostream;
00130   friend inline ostream& operator<< (ostream& os, const field_value &fv);
00131 
00132   void set_isNull(){is_null=true;}
00133   void set_asString(const char *s);
00134   void set_asString(const string & s);
00135   void set_asBool(const bool b);
00136   void set_asChar(const char c);
00137   void set_asShort(const short s);
00138   void set_asUShort(const unsigned short us);
00139   void set_asInteger(const int i);
00140   void set_asLong(const long l);
00141   void set_asULong(const unsigned long l);
00142   void set_asFloat(const float f);
00143   void set_asDouble(const double d);
00144 
00145   fType get_field_type();
00146   string gft();
00147 };
00148 
00149 struct field_prop {
00150   string name,display_name;
00151   fType type;
00152   string field_table; //?
00153   bool read_only;
00154   unsigned int field_len;
00155   unsigned int field_flags;
00156   int idx;
00157 };
00158 
00159 struct field {
00160   field_prop props;
00161   field_value val;
00162 }; 
00163 
00164 
00165 typedef map<int,field> Fields;
00166 typedef map<int,field_value> sql_record;
00167 typedef map<int,field_prop> record_prop;
00168 typedef map<int,sql_record> query_data;
00169 typedef field_value variant;
00170 
00171 //typedef Fields::iterator fld_itor;
00172 typedef sql_record::iterator rec_itor;
00173 typedef record_prop::iterator recprop_itor;
00174 typedef query_data::iterator qry_itor;
00175 
00176 struct result_set {
00177   record_prop record_header;
00178   query_data records;
00179 };
00180 
00181 } // namespace
00182 
00183 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'