libdballe 9.6
querybuf.h
Go to the documentation of this file.
1
4#ifndef DBA_SQL_QUERYBUF_H
5#define DBA_SQL_QUERYBUF_H
6
7#include <wreport/varinfo.h>
8#include <string>
9#include <set>
10
11namespace dballe {
12namespace sql {
13
15struct Querybuf : public std::string
16{
17 bool list_first;
18 char list_sep[10];
19
26 Querybuf(size_t reserve = 512);
27 ~Querybuf();
28
30 void clear();
31
39 void start_list(const char* sep);
40
45
49 void append_int(int val);
50
57 void appendf(const char* fmt, ...) __attribute__((format(printf, 2, 3)));
58
68 void append_list(const char* str);
69
78 void append_listf(const char* fmt, ...) __attribute__((format(printf, 2, 3)));
79
84 void append_varlist(const std::string& varlist);
85
87 void append_varlist(const std::set<wreport::Varcode>& varlist);
88};
89
90}
91}
92#endif
String buffer for composing database queries.
Definition: querybuf.h:16
void void append_list(const char *str)
Append a string to the querybuf, as part of a list.
void void append_varlist(const std::string &varlist)
Append a comma-separated list of integer varcodes parsed from a varlist=B12101,B12013 query parameter...
void clear()
Reset the querybuf to contain the empty string.
void start_list_item()
Notify the start of a new list item.
void appendf(const char *fmt,...) __attribute__((format(printf
Append a formatted string to the querybuf.
void append_int(int val)
Append an integer value.
void append_listf(const char *fmt,...) __attribute__((format(printf
Append a formatted string to the querybuf, as part of a list.
Querybuf(size_t reserve=512)
void start_list(const char *sep)
Begin a list of items separated by the given separator.