libdballe 5.10
cursor.h
Go to the documentation of this file.
00001 /*
00002  * db/cursor - manage select queries
00003  *
00004  * Copyright (C) 2005--2010  ARPA-SIM <urpsim@smr.arpa.emr.it>
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.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00018  *
00019  * Author: Enrico Zini <enrico@enricozini.com>
00020  */
00021 
00028 #ifndef DBA_DB_CURSOR_H
00029 #define DBA_DB_CURSOR_H
00030 
00031 #include <dballe/db/odbcworkarounds.h>
00032 #include <wreport/varinfo.h>
00033 #include <sqltypes.h>
00034 #include <vector>
00035 
00036 namespace dballe {
00037 struct DB;
00038 struct Record;
00039 
00040 namespace db {
00041 struct Statement;
00042 
00047 struct Cursor
00048 {
00050     DB& db;
00052     db::Statement* stm;
00053 
00055     unsigned int wanted;
00056 
00058     unsigned int modifiers;
00059 
00062     unsigned int from_wanted;
00063 
00067     DBALLE_SQL_C_SINT_TYPE  out_lat;
00068     DBALLE_SQL_C_SINT_TYPE  out_lon;
00069     char    out_ident[64];      SQLLEN out_ident_ind;
00070     DBALLE_SQL_C_SINT_TYPE  out_ltype1;
00071     DBALLE_SQL_C_SINT_TYPE  out_l1;
00072     DBALLE_SQL_C_SINT_TYPE  out_ltype2;
00073     DBALLE_SQL_C_SINT_TYPE  out_l2;
00074     DBALLE_SQL_C_SINT_TYPE  out_pind;
00075     DBALLE_SQL_C_SINT_TYPE  out_p1;
00076     DBALLE_SQL_C_SINT_TYPE  out_p2;
00077     wreport::Varcode        out_varcode;
00078     SQL_TIMESTAMP_STRUCT    out_datetime;
00079     char    out_value[255];
00080     DBALLE_SQL_C_SINT_TYPE  out_rep_cod;
00081     DBALLE_SQL_C_SINT_TYPE  out_ana_id;
00082     DBALLE_SQL_C_SINT_TYPE  out_context_id;
00083     DBALLE_SQL_C_SINT_TYPE  out_priority;
00087     DBALLE_SQL_C_SINT_TYPE count;
00088 
00089     Cursor(DB& db);
00090     ~Cursor();
00091 
00107     int query(const Record& query, unsigned int wanted, unsigned int modifiers);
00108 
00116     int remaining() const;
00117 
00124     bool next();
00125 
00127     void discard_rest();
00128 
00135     void to_record(Record& rec);
00136 
00140     unsigned query_attrs(const std::vector<wreport::Varcode>& qcs, Record& attrs);
00141 
00142 protected:
00144     void reset();
00145 
00147     void add_station_info(Record& rec);
00148 
00158     int getcount(const Record& query, unsigned int wanted, unsigned int modifiers);
00159 };
00160 
00161 } // namespace db
00162 } // namespace dballe
00163 
00164 /* vim:set ts=4 sw=4: */
00165 #endif