libdballe  6.8
v5/attr.h
Go to the documentation of this file.
1 /*
2  * db/attr - attr 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_ATTR_H
23 #define DBALLE_DB_V5_ATTR_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 Attr
49 {
52 
59 
61  DBALLE_SQL_C_SINT_TYPE id_context;
63  wreport::Varcode id_var;
65  wreport::Varcode type;
67  char value[255];
69  SQLLEN value_ind;
70 
71  Attr(Connection& conn);
72  ~Attr();
73 
80  void set(const wreport::Var& var);
81 
88  void set_value(const char* value);
89 
98  void insert();
99 
108  void load(wreport::Var& var);
109 
113  void dump(FILE* out);
114 
115 private:
116  // disallow copy
117  Attr(const Attr&);
118  Attr& operator=(const Attr&);
119 };
120 
121 } // namespace v5
122 } // namespace db
123 } // namespace dballe
124 
125 /* vim:set ts=4 sw=4: */
126 #endif
db::Statement * sstm
Precompiled select statement.
Definition: v5/attr.h:54
void load(wreport::Var &var)
Load from the database all the attributes for var.
db::Statement * rstm
Precompiled replace statement.
Definition: v5/attr.h:58
Database connection.
Definition: internals.h:124
Precompiled queries to manipulate the attr table.
Definition: v5/attr.h:48
DBALLE_SQL_C_SINT_TYPE id_context
context id SQL parameter
Definition: v5/attr.h:61
The ODBC specification is imperfect with regards to integer sizes on 64bit platforms, and different ODBC drivers are currently interpreting it differently.
Definition: cmdline.h:34
char value[255]
attribute value SQL parameter
Definition: v5/attr.h:67
void set_value(const char *value)
Set the value input field from a string.
db::Connection & conn
DB connection.
Definition: v5/attr.h:51
void set(const wreport::Var &var)
Set the input fields using the values in a wreport::Var.
ODBC statement.
Definition: internals.h:220
SQLLEN value_ind
attribute value indicator
Definition: v5/attr.h:69
void insert()
Insert an entry into the attr table.
void dump(FILE *out)
Dump the entire contents of the table to an output stream.
wreport::Varcode id_var
variable id SQL parameter
Definition: v5/attr.h:63
db::Statement * istm
Precompiled insert statement.
Definition: v5/attr.h:56
wreport::Varcode type
attribute id SQL parameter
Definition: v5/attr.h:65