libdballe 9.6
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | List of all members
dballe::core::Query Struct Reference

Standard dballe::Query implementation. More...

#include <query.h>

Inheritance diagram for dballe::core::Query:
dballe::Query

Public Member Functions

bool operator== (const Query &o) const
 
void validate ()
 Check the query fields for consistency, and fill in missing values:
 
std::unique_ptr< dballe::Queryclone () 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.
 
void set_from_test_string (const std::string &s)
 Set a record from a ", "-separated string of assignments.
 
bool is_subquery (const dballe::Query &other) const override
 Return true if this query matches a subset of the given query.
 
void print (FILE *out) const override
 Print the query contents to stderr.
 
void serialize (JSONWriter &out) const
 Send the contents to a JSONWriter.
 
virtual DatetimeRange get_datetimerange () const =0
 Get the Datetime bounds set in this query.
 
virtual void set_datetimerange (const DatetimeRange &dt)=0
 Set the Datetime range for this query.
 
virtual LatRange get_latrange () const =0
 Get the range of latitudes to be matched.
 
virtual void set_latrange (const LatRange &latrange)=0
 Set the range of latitudes to be matched.
 
virtual LonRange get_lonrange () const =0
 Get the range of longitudes to be matched.
 
virtual void set_lonrange (const LonRange &lonrange)=0
 Set the range of longitudes to be matched.
 
virtual Level get_level () const =0
 Get the level to be matched.
 
virtual void set_level (const Level &level)=0
 Set the level to be matched.
 
virtual Trange get_trange () const =0
 Get the time range to be matched.
 
virtual void set_trange (const Trange &trange)=0
 Set the level to be matched.
 
virtual void clear ()=0
 Clear the contents of the query, making it match all data.
 
virtual bool is_subquery (const Query &other) const =0
 Return true if this query matches a subset of the given query.
 
virtual void print (FILE *out) const =0
 Print the query contents to stderr.
 
virtual std::unique_ptr< Queryclone () const =0
 Return a copy of this query.
 
virtual bool empty () const =0
 Check if the query is empty, that is, it queries everything.
 

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 Querydowncast (const dballe::Query &query)
 Return a reference to query downcasted as core::Query.
 
static Querydowncast (dballe::Query &query)
 Return a reference to query downcasted as core::Query.
 
static Query from_json (core::json::Stream &in)
 
- Static Public Member Functions inherited from dballe::Query
static std::unique_ptr< Querycreate ()
 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::Varcodevarcodes
 
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
 

Static Public Attributes

static const uint32_t WANT_MISSING_IDENT = (1 << 0)
 
static const uint32_t WANT_MISSING_LTYPE1 = (1 << 1)
 
static const uint32_t WANT_MISSING_L1 = (1 << 2)
 
static const uint32_t WANT_MISSING_LTYPE2 = (1 << 3)
 
static const uint32_t WANT_MISSING_L2 = (1 << 4)
 
static const uint32_t WANT_MISSING_PIND = (1 << 5)
 
static const uint32_t WANT_MISSING_P1 = (1 << 6)
 
static const uint32_t WANT_MISSING_P2 = (1 << 7)
 

Protected Member Functions

void setf (const char *key, unsigned len, const char *val)
 
void unset (const char *key, unsigned len)
 

Detailed Description

Standard dballe::Query implementation.

Member Function Documentation

◆ clear()

void dballe::core::Query::clear ( )
overridevirtual

Clear the contents of the query, making it match all data.

Implements dballe::Query.

◆ clone()

std::unique_ptr< dballe::Query > dballe::core::Query::clone ( ) const
overridevirtual

Return a copy of this query.

Implements dballe::Query.

◆ downcast() [1/2]

static const Query & dballe::core::Query::downcast ( const dballe::Query query)
static

Return a reference to query downcasted as core::Query.

Throws an exception if query is not a core::Query.

◆ downcast() [2/2]

static Query & dballe::core::Query::downcast ( dballe::Query query)
static

Return a reference to query downcasted as core::Query.

Throws an exception if query is not a core::Query.

◆ empty()

bool dballe::core::Query::empty ( ) const
overridevirtual

Check if the query is empty, that is, it queries everything.

Implements dballe::Query.

◆ get_datetimerange()

DatetimeRange dballe::core::Query::get_datetimerange ( ) const
inlineoverridevirtual

Get the Datetime bounds set in this query.

Implements dballe::Query.

◆ get_latrange()

LatRange dballe::core::Query::get_latrange ( ) const
inlineoverridevirtual

Get the range of latitudes to be matched.

Implements dballe::Query.

◆ get_level()

Level dballe::core::Query::get_level ( ) const
inlineoverridevirtual

Get the level to be matched.

Implements dballe::Query.

◆ get_lonrange()

LonRange dballe::core::Query::get_lonrange ( ) const
inlineoverridevirtual

Get the range of longitudes to be matched.

Implements dballe::Query.

◆ get_trange()

Trange dballe::core::Query::get_trange ( ) const
inlineoverridevirtual

Get the time range to be matched.

Implements dballe::Query.

◆ is_subquery()

bool dballe::core::Query::is_subquery ( const dballe::Query other) const
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.

◆ print()

void dballe::core::Query::print ( FILE *  out) const
overridevirtual

Print the query contents to stderr.

Implements dballe::Query.

◆ set_datetimerange()

void dballe::core::Query::set_datetimerange ( const DatetimeRange dt)
inlineoverridevirtual

Set the Datetime range for this query.

Implements dballe::Query.

◆ set_from_string()

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=-).

Parameters
strThe string containing the assignment.

◆ set_from_test_string()

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.

◆ set_latrange()

void dballe::core::Query::set_latrange ( const LatRange latrange)
inlineoverridevirtual

Set the range of latitudes to be matched.

Implements dballe::Query.

◆ set_level()

void dballe::core::Query::set_level ( const Level level)
inlineoverridevirtual

Set the level to be matched.

Implements dballe::Query.

◆ set_lonrange()

void dballe::core::Query::set_lonrange ( const LonRange lonrange)
inlineoverridevirtual

Set the range of longitudes to be matched.

Implements dballe::Query.

◆ set_trange()

void dballe::core::Query::set_trange ( const Trange trange)
inlineoverridevirtual

Set the level to be matched.

Implements dballe::Query.

◆ validate()

void dballe::core::Query::validate ( )

Check the query fields for consistency, and fill in missing values:

  • month without year, day without month, and so on, cause errors
  • only one longitude extreme without the other causes error
  • min and max datetimes are filled with the actual minimum and maximum values acceptable for that range (year=2017, for example, becomes min=2017-01-01 00:00:00, max=2017-12-31 23:59:59

The documentation for this struct was generated from the following file: