libdballe  7.19
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  Querybuf(size_t reserve = 512);
27  ~Querybuf();
28 
30  void clear();
31 
39  void start_list(const char* sep);
40 
44  void start_list_item();
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
void start_list_item()
Notify the start of a new list item.
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
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