libdballe  7.7
querybuf.h
Go to the documentation of this file.
1 /*
2  * db/querybuf - Buffer used to build SQL queries
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 DBA_DB_QUERYBUF_H
23 #define DBA_DB_QUERYBUF_H
24 
30 #include <wreport/varinfo.h>
31 #include <string>
32 #include <set>
33 
34 namespace dballe {
35 
37 struct Querybuf : public std::string
38 {
39  bool list_first;
40  char list_sep[10];
41 
48  Querybuf(size_t reserve = 512);
49  ~Querybuf();
50 
52  void clear();
53 
61  void start_list(const char* sep);
62 
69  void appendf(const char* fmt, ...) __attribute__((format(printf, 2, 3)));
70 
80  void append_list(const char* str);
81 
91  void append_listf(const char* fmt, ...) __attribute__((format(printf, 2, 3)));
92 
97  void append_varlist(const std::string& varlist);
98 
100  void append_varlist(const std::set<wreport::Varcode>& varlist);
101 };
102 
103 } // namespace dballe
104 
105 #endif
void start_list(const char *sep)
Begin a list of items separated by the given separator.
void void append_list(const char *str)
Append a string to the querybuf, as part of a list.
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
String buffer for composing database queries.
Definition: querybuf.h:37
void appendf(const char *fmt,...) __attribute__((format(printf
Append a formatted string to the querybuf.
void append_listf(const char *fmt,...) __attribute__((format(printf
Append a formatted string to the querybuf, as part of a list.
void clear()
Reset the querybuf to contain the empty string.
Querybuf(size_t reserve=512)
void void append_varlist(const std::string &varlist)
Append a comma-separated list of integer varcodes parsed from a varlist=B12101,B12013 query parameter...