libdballe  9.11
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 
11 namespace dballe {
12 namespace sql {
13 
15 struct 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 
49  void start_list_item();
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
void start_list_item()
Notify the start of a new list item.
Definition: cmdline.h:18
Querybuf(size_t reserve=512)
void void append_list(const char *str)
Append a string to the querybuf, as part of a list.
void clear()
Reset the querybuf to contain the empty string.
void appendf(const char *fmt,...) __attribute__((format(printf
Append a formatted string to the querybuf.
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 append_listf(const char *fmt,...) __attribute__((format(printf
Append a formatted string to the querybuf, as part of a list.
void start_list(const char *sep)
Begin a list of items separated by the given separator.
void append_int(int val)
Append an integer value.
String buffer for composing database queries.
Definition: querybuf.h:15