libdballe
9.11
|
Standard dballe::Query implementation. More...
#include <query.h>
Public Member Functions | |
bool | operator== (const Query &o) const |
void | validate () |
Check the query fields for consistency, and fill in missing values: More... | |
std::unique_ptr< dballe::Query > | clone () const override |
Return a copy of this query. | |
unsigned | get_modifiers () const |
DatetimeRange | get_datetimerange () const override |
Get the Datetime bounds set in this query. | |
void | set_datetimerange (const DatetimeRange &dt) override |
Set the Datetime range for this query. | |
LatRange | get_latrange () const override |
Get the range of latitudes to be matched. | |
void | set_latrange (const LatRange &lr) override |
Set the range of latitudes to be matched. | |
LonRange | get_lonrange () const override |
Get the range of longitudes to be matched. | |
void | set_lonrange (const LonRange &lr) override |
Set the range of longitudes to be matched. | |
Level | get_level () const override |
Get the level to be matched. | |
void | set_level (const Level &level) override |
Set the level to be matched. | |
Trange | get_trange () const override |
Get the time range to be matched. | |
void | set_trange (const Trange &trange) override |
Set the level to be matched. | |
void | clear () override |
Clear the contents of the query, making it match all data. | |
bool | empty () const override |
Check if the query is empty, that is, it queries everything. | |
void | set_from_string (const char *str) |
Set a value in the record according to an assignment encoded in a string. More... | |
void | set_from_test_string (const std::string &s) |
Set a record from a ", "-separated string of assignments. More... | |
bool | is_subquery (const dballe::Query &other) const override |
Return true if this query matches a subset of the given query. More... | |
void | print (FILE *out) const override |
Print the query contents to stderr. | |
void | serialize (JSONWriter &out) const |
Send the contents to a JSONWriter. | |
![]() | |
Query (const Query &)=default | |
Query (Query &&)=default | |
Query & | operator= (const Query &o)=default |
Query & | operator= (Query &&o)=default |
Static Public Member Functions | |
static unsigned | parse_modifiers (const char *str) |
Parse the modifiers specification given a query=* string, returning the ORed flags. | |
static const Query & | downcast (const dballe::Query &query) |
Return a reference to query downcasted as core::Query. More... | |
static Query & | downcast (dballe::Query &query) |
Return a reference to query downcasted as core::Query. More... | |
static Query | from_json (core::json::Stream &in) |
![]() | |
static std::unique_ptr< Query > | create () |
Create a new Query. | |
Public Attributes | |
uint32_t | want_missing = 0 |
Set a bit a 1 with WANT_MISSING_* constants to specify that the query wants results in which the corresponding field is set to a missing value. | |
int | ana_id = MISSING_INT |
int | priomin = MISSING_INT |
int | priomax = MISSING_INT |
std::string | report |
int | mobile = MISSING_INT |
Ident | ident |
LatRange | latrange |
LonRange | lonrange |
DatetimeRange | dtrange |
Level | level |
Trange | trange |
std::set< wreport::Varcode > | varcodes |
std::string | query |
std::string | ana_filter |
std::string | data_filter |
std::string | attr_filter |
int | limit = MISSING_INT |
int | block = MISSING_INT |
int | station = MISSING_INT |
Protected Member Functions | |
void | setf (const char *key, unsigned len, const char *val) |
void | unset (const char *key, unsigned len) |
Standard dballe::Query implementation.
|
static |
Return a reference to query downcasted as core::Query.
Throws an exception if query is not a core::Query.
|
static |
Return a reference to query downcasted as core::Query.
Throws an exception if query is not a core::Query.
|
overridevirtual |
Return true if this query matches a subset of the given query.
In other words, it returns true if this query is the same as other, plus zero or more extra fields set, or zero or more ranges narrowed.
Implements dballe::Query.
void dballe::core::Query::set_from_string | ( | const char * | str | ) |
Set a value in the record according to an assignment encoded in a string.
String can use keywords, aliases and varcodes. Examples: ana_id=3, name=Bologna, B12012=32.4
In case of numeric parameter, a hyphen ("-") means MISSING_INT (e.g., leveltype2=-
).
str | The string containing the assignment. |
void dballe::core::Query::set_from_test_string | ( | const std::string & | s | ) |
Set a record from a ", "-separated string of assignments.
The implementation is not efficient and the method is not safe for any input, since ", " could appear in a station identifier. It is however useful to quickly create test queries for unit testing.
void dballe::core::Query::validate | ( | ) |
Check the query fields for consistency, and fill in missing values: