libdballe  6.8
v6/data.h
Go to the documentation of this file.
1 /*
2  * db/v6/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_V6_DATA_H
23 #define DBALLE_DB_V6_DATA_H
24 
32 #include <wreport/var.h>
33 #include <sqltypes.h>
34 #include <cstdio>
35 
36 namespace dballe {
37 struct Record;
38 
39 namespace db {
40 struct Statement;
41 
42 namespace v6 {
43 struct DB;
44 
48 struct Data
49 {
52 
63 
65  DBALLE_SQL_C_SINT_TYPE id;
66 
68  DBALLE_SQL_C_SINT_TYPE id_station;
70  DBALLE_SQL_C_SINT_TYPE id_report;
72  DBALLE_SQL_C_SINT_TYPE id_lev_tr;
74  SQL_TIMESTAMP_STRUCT date;
76  wreport::Varcode id_var;
78  char value[255];
80  SQLLEN value_ind;
81 
82  Data(v6::DB& conn);
83  ~Data();
84 
88  void set_date(const Record& rec);
89 
93  void set_station_info();
94 
98  void set_id_lev_tr(int id);
99 
103  void set(const wreport::Var& var);
104 
108  void set_value(const char* value);
109 
115  void insert_or_fail(bool want_id=false);
116 
124  bool insert_or_ignore(bool want_id=false);
125 
135  void insert_or_overwrite(bool want_id=false);
136 
140  void dump(FILE* out);
141 
142 private:
143  // disallow copy
144  Data(const Data&);
145  Data& operator=(const Data&);
146 };
147 
148 } // namespace v6
149 } // namespace db
150 } // namespace dballe
151 
152 /* vim:set ts=4 sw=4: */
153 #endif
void set_date(const Record &rec)
Set the date from the date information in the record.
db::Statement * ustm
Precompiled update statement.
Definition: v6/data.h:56
char value[255]
Variable value SQL parameter.
Definition: v6/data.h:78
void set(const wreport::Var &var)
Set the value input fields using a wreport::Var.
void set_value(const char *value)
Set the value input fields using a string value.
DBALLE_SQL_C_SINT_TYPE id
data ID SQL parameter
Definition: v6/data.h:65
db::Statement * iistm
Precompiled insert or ignore statement.
Definition: v6/data.h:60
The ODBC specification is imperfect with regards to integer sizes on 64bit platforms, and different ODBC drivers are currently interpreting it differently.
DB-All.E record.
Definition: record.h:102
Definition: cmdline.h:34
void set_id_lev_tr(int id)
Set id_lev_tr to a valid value.
void insert_or_overwrite(bool want_id=false)
Insert an entry into the data table, overwriting on conflicts.
DBALLE_SQL_C_SINT_TYPE id_lev_tr
Context ID SQL parameter.
Definition: v6/data.h:72
DBALLE_SQL_C_SINT_TYPE id_report
Report ID SQL parameter.
Definition: v6/data.h:70
void dump(FILE *out)
Dump the entire contents of the table to an output stream.
DBALLE_SQL_C_SINT_TYPE id_station
Station ID SQL parameter.
Definition: v6/data.h:68
void set_station_info()
Set id_lev_tr and datetime to mean 'station information'.
wreport::Varcode id_var
Variable type SQL parameter.
Definition: v6/data.h:76
ODBC statement.
Definition: internals.h:220
v6::DB & db
DB connection.
Definition: v6/data.h:51
void insert_or_fail(bool want_id=false)
Insert an entry into the data table, failing on conflicts.
SQL_TIMESTAMP_STRUCT date
Date SQL parameter.
Definition: v6/data.h:74
DB-ALLe database connection.
Definition: v6/db.h:87
SQLLEN value_ind
Variable value indicator.
Definition: v6/data.h:80
db::Statement * ioustm
Precompiled insert or update statement, for DBs where it is available.
Definition: v6/data.h:58
db::Statement * sidstm
Precompiled select ID statement.
Definition: v6/data.h:62
bool insert_or_ignore(bool want_id=false)
Insert an entry into the data table, ignoring conflicts.
db::Statement * istm
Precompiled insert statement.
Definition: v6/data.h:54
Precompiled query to manipulate the data table.
Definition: v6/data.h:48