1 /**********************************************************************
2 * Copyright (c) 2004, Leo Seib, Hannover
4 * Project:Dataset C++ Dynamic Library
5 * Module: FieldValue class and result sets classes header file
6 * Author: Leo Seib E-Mail: leoseib@web.de
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 **********************************************************************/
62 std::string str_value;
67 unsigned short ushort_value;
69 unsigned int uint_value;
80 field_value(const char *s);
81 field_value(const bool b);
82 field_value(const char c);
83 field_value(const short s);
84 field_value(const unsigned short us);
85 field_value(const int l);
86 field_value(const unsigned int ul);
87 field_value(const float f);
88 field_value(const double d);
89 field_value(const int64_t i);
90 field_value(const field_value & fv);
93 fType get_fType() const {return field_type;}
94 bool get_isNull() const {return is_null;}
95 std::string get_asString() const;
96 bool get_asBool() const;
97 char get_asChar() const;
98 short get_asShort() const;
99 unsigned short get_asUShort() const;
100 int get_asInt() const;
101 unsigned int get_asUInt() const;
102 float get_asFloat() const;
103 double get_asDouble() const;
104 int64_t get_asInt64() const;
106 field_value& operator= (const char *s)
107 {set_asString(s); return *this;}
108 field_value& operator= (const std::string &s)
109 {set_asString(s); return *this;}
110 field_value& operator= (const bool b)
111 {set_asBool(b); return *this;}
112 field_value& operator= (const short s)
113 {set_asShort(s); return *this;}
114 field_value& operator= (const unsigned short us)
115 {set_asUShort(us); return *this;}
116 field_value& operator= (const int l)
117 {set_asInt(l); return *this;}
118 field_value& operator= (const unsigned int l)
119 {set_asUInt(l); return *this;}
120 field_value& operator= (const float f)
121 {set_asFloat(f); return *this;}
122 field_value& operator= (const double d)
123 {set_asDouble(d); return *this;}
124 field_value& operator= (const int64_t i)
125 {set_asInt64(i); return *this;}
126 field_value& operator= (const field_value & fv);
129 friend std::ostream& operator<< (std::ostream& os, const field_value &fv)
130 {switch (fv.get_fType()) {
132 return os << fv.get_asString();
136 return os << fv.get_asBool();
140 return os << fv.get_asChar();
144 return os << fv.get_asShort();
148 return os << fv.get_asUShort();
152 return os << fv.get_asInt();
156 return os << fv.get_asUInt();
160 return os << fv.get_asFloat();
164 return os << fv.get_asDouble();
168 return os << fv.get_asInt64();
178 void set_isNull(){is_null=true;}
179 void set_asString(const char *s);
180 void set_asString(const std::string & s);
181 void set_asBool(const bool b);
182 void set_asChar(const char c);
183 void set_asShort(const short s);
184 void set_asUShort(const unsigned short us);
185 void set_asInt(const int l);
186 void set_asUInt(const unsigned int l);
187 void set_asFloat(const float f);
188 void set_asDouble(const double d);
189 void set_asInt64(const int64_t i);
191 fType get_field_type();
196 std::string name,display_name;
198 std::string field_table; //?
200 unsigned int field_len;
201 unsigned int field_flags;
211 typedef std::vector<field> Fields;
212 typedef std::vector<field_value> sql_record;
213 typedef std::vector<field_prop> record_prop;
214 typedef std::vector<sql_record*> query_data;
215 typedef field_value variant;
217 //typedef Fields::iterator fld_itor;
218 typedef sql_record::iterator rec_itor;
219 typedef record_prop::iterator recprop_itor;
220 typedef query_data::iterator qry_itor;
234 for (unsigned int i = 0; i < records.size(); i++)
238 record_header.clear();
241 record_prop record_header;