libdballe  9.11
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
dballe::core::Data Class Reference

Holds data for database I/O. More...

#include <data.h>

Inheritance diagram for dballe::core::Data:
dballe::Data

Public Member Functions

 Data (const Data &rec)=default
 
 Data (Data &&rec)=default
 
Dataoperator= (const Data &rec)=default
 
Dataoperator= (Data &&rec)=default
 
bool operator== (const dballe::Data &rec) const override
 Check if two records are the same.
 
bool operator!= (const dballe::Data &rec) const override
 Check if two records differ.
 
void validate ()
 Check the data fields for consistency, and fill in missing values: More...
 
void clear () override
 Remove all contents from the record.
 
void clear_vars () override
 Remove all Bxxyyy keys from the record, leaving the rest intact.
 
void clear_ids () override
 Unset all database IDs in station and values.
 
void print (FILE *out) const override
 Print the contents of this record to the given stream.
 
void set_from_string (const char *str)
 Set a value according to an assignment encoded in a string. More...
 
void set_from_test_string (const std::string &s)
 Set the Data from a ", "-separated string of assignments. More...
 
std::string to_string () const
 Encode in a one-liner of comma-separated assignments.
 
- Public Member Functions inherited from dballe::Data
 Data (const Data &)=default
 
 Data (Data &&)=default
 
Dataoperator= (const Data &o)=default
 
Dataoperator= (Data &&o)=default
 

Static Public Member Functions

static const Datadowncast (const dballe::Data &data)
 Return a reference to record downcasted as core::Record. More...
 
static Datadowncast (dballe::Data &data)
 Return a reference to record downcasted as core::Record. More...
 
- Static Public Member Functions inherited from dballe::Data
static std::unique_ptr< Datacreate ()
 Create a new Record.
 

Public Attributes

DBStation station
 
Datetime datetime
 
Level level
 
Trange trange
 
DBValues values
 

Protected Member Functions

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

Detailed Description

Holds data for database I/O.

Data is a container for one observation of meteorological values, that includes station informations, physical location of the observation in time and space, and all the observed variables.

Member Function Documentation

◆ downcast() [1/2]

static const Data& dballe::core::Data::downcast ( const dballe::Data data)
static

Return a reference to record downcasted as core::Record.

Throws an exception if record is not a core::Record.

Referenced by dballe::tests::ActualCursor::data_var_matches().

◆ downcast() [2/2]

static Data& dballe::core::Data::downcast ( dballe::Data data)
static

Return a reference to record downcasted as core::Record.

Throws an exception if record is not a core::Record.

◆ set_from_string()

void dballe::core::Data::set_from_string ( const char *  str)

Set a value 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::Data::set_from_test_string ( const std::string &  s)

Set the Data 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.

◆ validate()

void dballe::core::Data::validate ( )

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

  • month without year, day without month, and so on, cause errors
  • 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 class was generated from the following file: