libdballe 5.10
data.h
Go to the documentation of this file.
00001 /*
00002  * db/data - data table management
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 
00022 #ifndef DBALLE_DB_DATA_H
00023 #define DBALLE_DB_DATA_H
00024 
00031 #include <dballe/db/odbcworkarounds.h>
00032 #include <wreport/var.h>
00033 #include <sqltypes.h>
00034 #include <cstdio>
00035 
00036 namespace dballe {
00037 struct DB;
00038 
00039 namespace db {
00040 struct Connection;
00041 struct Statement;
00042 
00046 struct Data
00047 {
00049     db::Connection& conn;
00050 
00052     db::Statement* istm;
00054     db::Statement* ustm;
00056     db::Statement* iistm;
00057 
00059     DBALLE_SQL_C_SINT_TYPE id_context;
00061     wreport::Varcode id_var;
00063     char value[255];
00065     SQLLEN value_ind;
00066 
00067     Data(Connection& conn);
00068     ~Data();
00069 
00073     void set(const wreport::Var& var);
00074 
00078     void set_value(const char* value);
00079 
00085     void insert_or_fail();
00086 
00094     bool insert_or_ignore();
00095 
00102     void insert_or_overwrite();
00103 
00107     void dump(FILE* out);
00108 
00109 private:
00110     // disallow copy
00111     Data(const Data&);
00112     Data& operator=(const Data&);
00113 };
00114 
00115 } // namespace db
00116 } // namespace dballe
00117 
00118 /* vim:set ts=4 sw=4: */
00119 #endif