libdballe  6.8
v5/data.h
Go to the documentation of this file.
1 /*
2  * db/data - data table management
3  *
4  * Copyright (C) 2005--2013 ARPA-SIM <urpsim@smr.arpa.emr.it>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * Author: Enrico Zini <enrico@enricozini.com>
20  */
21 
22 #ifndef DBALLE_DB_V5_DATA_H
23 #define DBALLE_DB_V5_DATA_H
24 
32 #include <wreport/var.h>
33 #include <sqltypes.h>
34 #include <cstdio>
35 
36 namespace dballe {
37 struct DB;
38 
39 namespace db {
40 struct Connection;
41 struct Statement;
42 
43 namespace v5 {
44 
48 struct Data
49 {
52 
59 
61  DBALLE_SQL_C_SINT_TYPE id_context;
63  wreport::Varcode id_var;
65  char value[255];
67  SQLLEN value_ind;
68 
69  Data(Connection& conn);
70  ~Data();
71 
75  void set(const wreport::Var& var);
76 
80  void set_value(const char* value);
81 
87  void insert_or_fail();
88 
96  bool insert_or_ignore();
97 
104  void insert_or_overwrite();
105 
109  void dump(FILE* out);
110 
111 private:
112  // disallow copy
113  Data(const Data&);
114  Data& operator=(const Data&);
115 };
116 
117 } // namespace v5
118 } // namespace db
119 } // namespace dballe
120 
121 /* vim:set ts=4 sw=4: */
122 #endif
db::Statement * ustm
Precompiled update statement.
Definition: v5/data.h:56
db::Connection & conn
DB connection.
Definition: v5/data.h:51
db::Statement * istm
Precompiled insert statement.
Definition: v5/data.h:54
Database connection.
Definition: internals.h:124
The ODBC specification is imperfect with regards to integer sizes on 64bit platforms, and different ODBC drivers are currently interpreting it differently.
void set_value(const char *value)
Set the value input fields using a string value.
Definition: cmdline.h:34
void insert_or_overwrite()
Insert an entry into the data table, overwriting on conflicts.
SQLLEN value_ind
Variable value indicator.
Definition: v5/data.h:67
DBALLE_SQL_C_SINT_TYPE id_context
Context ID SQL parameter.
Definition: v5/data.h:61
wreport::Varcode id_var
Variable type SQL parameter.
Definition: v5/data.h:63
ODBC statement.
Definition: internals.h:220
void insert_or_fail()
Insert an entry into the data table, failing on conflicts.
char value[255]
Variable value SQL parameter.
Definition: v5/data.h:65
void set(const wreport::Var &var)
Set the value input fields using a wreport::Var.
bool insert_or_ignore()
Insert an entry into the data table, ignoring conflicts.
Precompiled query to manipulate the data table.
Definition: v5/data.h:48
void dump(FILE *out)
Dump the entire contents of the table to an output stream.
db::Statement * iistm
Precompiled insert or ignore statement.
Definition: v5/data.h:58