libdballe  5.18
querybuf.h
Go to the documentation of this file.
1 /*
2  * db/querybuf - Buffer used to build SQL queries
3  *
4  * Copyright (C) 2005--2010 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 <string>
31 
32 namespace dballe {
33 
35 struct Querybuf : public std::string
36 {
37  bool list_first;
38  char list_sep[10];
39 
46  Querybuf(size_t reserve = 512);
47  ~Querybuf();
48 
50  void clear();
51 
59  void start_list(const char* sep);
60 
67  void appendf(const char* fmt, ...) __attribute__((format(printf, 2, 3)));
68 
78  void append_list(const char* str);
79 
89  void append_listf(const char* fmt, ...) __attribute__((format(printf, 2, 3)));
90 };
91 
92 } // namespace dballe
93 
94 #endif