1#ifndef DBA_DB_V7_QBUILDER_H
2#define DBA_DB_V7_QBUILDER_H
4#include <dballe/core/query.h>
5#include <dballe/db/v7/db.h>
21 std::shared_ptr<v7::Transaction>
tr;
31 bool select_station =
false;
33 bool select_varinfo =
false;
36 bool select_data_id =
false;
39 bool select_data =
false;
42 bool select_summary_details =
false;
64 virtual ~QueryBuilder() {}
70 bool add_pa_where(
const char* tbl);
71 bool add_dt_where(
const char* tbl);
72 bool add_ltr_where(
const char* tbl);
73 bool add_varcode_where(
const char* tbl);
74 bool add_repinfo_where(
const char* tbl);
75 bool add_datafilter_where(
const char* tbl);
77 virtual void build_select() = 0;
78 virtual bool build_where() = 0;
79 virtual void build_order_by() = 0;
82struct StationQueryBuilder :
public QueryBuilder
84 StationQueryBuilder(std::shared_ptr<v7::Transaction>
tr,
90 void build_select()
override;
91 bool build_where()
override;
92 void build_order_by()
override;
95struct DataQueryBuilder :
public QueryBuilder
106 DataQueryBuilder(std::shared_ptr<v7::Transaction>
tr,
116 void build_select()
override;
117 bool build_where()
override;
118 void build_order_by()
override;
121struct IdQueryBuilder :
public DataQueryBuilder
123 IdQueryBuilder(std::shared_ptr<v7::Transaction>
tr,
130 void build_select()
override;
131 void build_order_by()
override;
134struct SummaryQueryBuilder :
public DataQueryBuilder
136 SummaryQueryBuilder(std::shared_ptr<v7::Transaction>
tr,
143 void build_select()
override;
144 void build_order_by()
override;
Buffer used to build SQL queries.
Match a variable code and value.
Definition varmatch.h:13
Standard dballe::Query implementation.
Definition core/query.h:36
Varmatch * attr_filter
Attribute filter, if requested.
Definition qbuilder.h:98
bool query_attrs
True if we also query attributes of data.
Definition qbuilder.h:101
bool match_attrs(const wreport::Var &var) const
Match the attributes of var against attr_filter.
bool select_attrs
True if the select includes the attrs field.
Definition qbuilder.h:104
dballe::sql::Querybuf sql_query
Dynamically generated SQL query.
Definition qbuilder.h:48
const char * bind_in_ident
If defined, it need to point to the identifier to be used as the only bound input parameter.
Definition qbuilder.h:29
std::shared_ptr< v7::Transaction > tr
Database to operate on.
Definition qbuilder.h:21
dballe::sql::Querybuf sql_from
FROM part of the SQL query.
Definition qbuilder.h:51
bool query_station_vars
True if we are querying station information, rather than measured data.
Definition qbuilder.h:60
dballe::sql::Querybuf sql_where
WHERE part of the SQL query.
Definition qbuilder.h:54
const core::Query & query
Query object.
Definition qbuilder.h:45
const unsigned int modifiers
Modifier flags to enable special query behaviours.
Definition qbuilder.h:57
String buffer for composing database queries.
Definition querybuf.h:16