libdballe 9.9
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 explicit Querybuf(size_t reserve = 512);
27 Querybuf(const Querybuf&) = default;
28 Querybuf(Querybuf&&) = default;
29 virtual ~Querybuf();
30
31 Querybuf& operator=(const Querybuf& o) = default;
32 Querybuf& operator=(Querybuf&& o) = default;
33
35 void clear();
36
44 void start_list(const char* sep);
45
50
54 void append_int(int val);
55
62 void appendf(const char* fmt, ...) __attribute__((format(printf, 2, 3)));
63
73 void append_list(const char* str);
74
83 void append_listf(const char* fmt, ...) __attribute__((format(printf, 2, 3)));
84
89 void append_varlist(const std::string& varlist);
90
92 void append_varlist(const std::set<wreport::Varcode>& varlist);
93};
94
95}
96}
97#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.