libdballe  6.8
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
dballe::Record Class Reference

DB-All.E record. More...

#include <record.h>

Public Member Functions

 Record (const Record &rec)
 
Recordoperator= (const Record &rec)
 
bool operator== (const Record &rec) const
 
bool operator!= (const Record &rec) const
 
void clear ()
 Remove all data from the record.
 
void clear_vars ()
 Remove all variables from the record, leaving the keywords intact.
 
void add (const Record &source)
 Copy all data from the record source into dest. More...
 
bool contains (const Record &subset) const
 Return true if all elements of subset are present in this record, with the same value.
 
bool contains (dba_keyword parameter) const throw ()
 Return true if the given parameter is set in this record.
 
bool contains (wreport::Varcode parameter) const throw ()
 Return true if the given variable is set in this record.
 
bool contains_level () const throw ()
 Return true if some level attribute is set in this record.
 
bool contains_trange () const throw ()
 Return true if some time range attribute is set in this record.
 
bool contains_datetime () const throw ()
 Return true if some datetime information is set in this record.
 
void set_to_difference (const Record &source1, const Record &source2)
 Set the record to contain only those fields that change source1 into source2. More...
 
const wreport::Var * key_peek (dba_keyword parameter) const throw ()
 Look at the value of a parameter. More...
 
const wreport::Var * var_peek (wreport::Varcode code) const throw ()
 Look at the value of a variable. More...
 
const wreport::Var * peek (const char *name) const
 Get the variable for an item. More...
 
const wreport::Var * peek (dba_keyword parameter) const throw ()
 Shortcut for key_peek.
 
const wreport::Var * peek (wreport::Varcode code) const throw ()
 Shortcut for var_peek.
 
const char * key_peek_value (dba_keyword parameter) const throw ()
 Look at the raw value of a keyword in the record, without raising errors. More...
 
const char * var_peek_value (wreport::Varcode code) const throw ()
 Look at the raw value of a variable in the record, without raising errors. More...
 
const char * peek_value (const char *name) const
 Get the string value for an item. More...
 
const char * peek_value (dba_keyword parameter) const throw ()
 Shortcut for key_peek_value.
 
const char * peek_value (wreport::Varcode code) const throw ()
 Shortcut for var_peek_value.
 
const wreport::Var & key (dba_keyword parameter) const
 Return the Var for a key, throwing an error it if it missing.
 
const wreport::Var & var (wreport::Varcode code) const
 Return the Var for a variable, throwing an error it if it missing.
 
wreport::Var & key (dba_keyword parameter)
 Return the Var for a key, creating it if it missing.
 
wreport::Var & var (wreport::Varcode code)
 Return the Var for a variable, creating it if it missing.
 
Level get_level () const
 
Trange get_trange () const
 
Datetime get_datetime () const
 
void set (const Datetime &dt)
 
void setmin (const Datetime &dt)
 
void setmax (const Datetime &dt)
 
void unset_datetime ()
 
void unset_datetimemin ()
 
void unset_datetimemax ()
 
void get_datetime (int(&val)[6]) const
 
void get_datetimemin (int(&val)[6]) const
 
void get_datetimemax (int(&val)[6]) const
 
void set_datetime (const int(&val)[6])
 
void set_datetimemin (const int(&val)[6])
 
void set_datetimemax (const int(&val)[6])
 
void set_datetime (int ye, int mo=1, int da=1, int ho=0, int mi=0, int se=0)
 
void set (const Coord &c)
 
void set_ana_context ()
 Set the date, level and timerange values to match the anagraphical context.
 
bool is_ana_context () const
 Check if this record is set to the ana context.
 
const std::vector< wreport::Var * > & vars () const
 Return the varcode-sorted vector with the variables.
 
void key_unset (dba_keyword parameter)
 Remove a parameter from the record. More...
 
void var_unset (wreport::Varcode code)
 Remove a parameter from the record. More...
 
void parse_date_extremes (int *minvalues, int *maxvalues) const
 Parse the date extremes set in Record. More...
 
void parse_date (int *values) const
 Parse the date set in the Record. More...
 
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_string (const char *key, const char *val)
 Same as set_from_string(str) but takes already split key and val.
 
std::string to_string () const
 Encode in a one-liner of comma-separated assignments.
 
void print (FILE *out) const
 Print the contents of this record to the given file descriptor. More...
 
const wreport::Var & get (dba_keyword parameter) const
 Shortcuts.
 
const wreport::Var & get (wreport::Varcode code) const
 Shortcuts.
 
const wreport::Var & get (const char *name) const
 Shortcuts.
 
wreport::Var & get (dba_keyword parameter)
 Shortcuts.
 
wreport::Var & get (wreport::Varcode code)
 Shortcuts.
 
wreport::Var & get (const char *name)
 Shortcuts.
 
template<typename K , typename T >
get (K name, T default_value) const
 Shortcuts.
 
const wreport::Var & operator[] (dba_keyword parameter) const
 Shortcuts.
 
const wreport::Var & operator[] (wreport::Varcode code) const
 Shortcuts.
 
const wreport::Var & operator[] (const char *name) const
 Shortcuts.
 
wreport::Var & operator[] (dba_keyword parameter)
 Shortcuts.
 
wreport::Var & operator[] (wreport::Varcode code)
 Shortcuts.
 
wreport::Var & operator[] (const char *name)
 Shortcuts.
 
template<typename P , typename V >
void set (const P &field, const V &val)
 Shortcuts.
 
void set (const wreport::Var &var)
 Shortcuts.
 
void set (const Level &lev)
 Shortcuts.
 
void set (const Trange &tr)
 Shortcuts.
 
void unset (dba_keyword parameter)
 Shortcuts.
 
void unset (wreport::Varcode code)
 Shortcuts.
 
void unset (const char *name)
 Shortcuts.
 
template<typename K >
void copy (const Record &rec, K parameter)
 Shortcuts.
 
template<typename K >
bool contains (const Record &rec, K parameter)
 Shortcuts.
 

Static Public Member Functions

static const char * keyword_name (dba_keyword keyword)
 Return the name of a dba_keyword. More...
 
static wreport::Varinfo keyword_info (dba_keyword keyword)
 Return informations about a keyword. More...
 
static dba_keyword keyword_byname (const char *tag)
 Get the dba_keyword corresponding to the given name. More...
 
static dba_keyword keyword_byname_len (const char *tag, int len)
 Get the dba_keyword corresponding to the given name. More...
 

Protected Member Functions

int find_item (wreport::Varcode code) const throw ()
 Find an item by wreport::Varcode, returning -1 if not found.
 
wreport::Var & get_item (wreport::Varcode code)
 Find an item by wreport::Varcode, raising an exception if not found.
 
const wreport::Var & get_item (wreport::Varcode code) const
 Find an item by wreport::Varcode, raising an exception if not found.
 
void remove_item (wreport::Varcode code)
 Remove an item by wreport::Varcode.
 

Protected Attributes

wreport::Var * keydata [DBA_KEY_COUNT]
 
std::vector< wreport::Var * > m_vars
 

Detailed Description

DB-All.E record.

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

Member Function Documentation

void dballe::Record::add ( const Record source)

Copy all data from the record source into dest.

At the end of the function, dest will contain its previous values, plus the values in source. If a value is present both in source and in dest, the one in dest will be overwritten.

Parameters
sourceThe record to copy data from.
const wreport::Var* dballe::Record::key_peek ( dba_keyword  parameter) const
throw (
)

Look at the value of a parameter.

Returns
A const pointer to the internal variable, or NULL if the variable has not been found.

Referenced by peek().

const char* dballe::Record::key_peek_value ( dba_keyword  parameter) const
throw (
)

Look at the raw value of a keyword in the record, without raising errors.

Parameters
parameterThe keyword to get the value for.
Returns
The raw string value, or NULL if the keyword has no value.

Referenced by peek_value().

void dballe::Record::key_unset ( dba_keyword  parameter)

Remove a parameter from the record.

Parameters
parameterThe parameter to remove.

Referenced by unset().

static dba_keyword dballe::Record::keyword_byname ( const char *  tag)
static

Get the dba_keyword corresponding to the given name.

Returns
The corresponding dba_keyword, or DBA_KEY_ERROR if tag does not match a valid keyword.
static dba_keyword dballe::Record::keyword_byname_len ( const char *  tag,
int  len 
)
static

Get the dba_keyword corresponding to the given name.

Parameters
tagThe name to query.
lenThe length of the name in tag.
Returns
The corresponding dba_keyword, or DBA_KEY_ERROR if tag does not match a valid keyword.
static wreport::Varinfo dballe::Record::keyword_info ( dba_keyword  keyword)
static

Return informations about a keyword.

Returns
The wreport::Varinfo structure with the informations.
static const char* dballe::Record::keyword_name ( dba_keyword  keyword)
static

Return the name of a dba_keyword.

Returns
The keyword name, or NULL if keyword is not a valid keyword
void dballe::Record::parse_date ( int *  values) const

Parse the date set in the Record.

This function will examine the values year, month, day, hour, min and sec, and will compute the lower bound of the datetime they represent.

Return values
valuesAn array of 6 integers that will be filled with the minimum year, month, day, hour, minute and seconds.
void dballe::Record::parse_date_extremes ( int *  minvalues,
int *  maxvalues 
) const

Parse the date extremes set in Record.

This function will examine the values yearmin, monthmin, daymin, hourmin, minumin, secmin, yearmax, monthmax, daymax, hourmax, minumax, secmax, year, month, day, hour, min and sec, and will compute the two datetime extremes that bound the interval they represent.

Return values
minvaluesAn array of 6 integers that will be filled with the minimum year, month, day, hour, minute and seconds.
maxvaluesAn array of 6 integers that will be filled with the maximum year, month, day, hour, minute and seconds.
const wreport::Var* dballe::Record::peek ( const char *  name) const

Get the variable for an item.

Parameters
nameThe name of the item to get the value for

Referenced by contains(), copy(), and get().

const char* dballe::Record::peek_value ( const char *  name) const

Get the string value for an item.

Parameters
nameThe name of the item to get the value for
void dballe::Record::print ( FILE *  out) const

Print the contents of this record to the given file descriptor.

Parameters
outThe output file descriptor
void dballe::Record::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
recThe record where the value is to be set.
strThe string containing the assignment.
Returns
The error indicator for the function.
void dballe::Record::set_to_difference ( const Record source1,
const Record source2 
)

Set the record to contain only those fields that change source1 into source2.

If a field has been deleted from source1 to source2, it will not be copied in dest.

Parameters
source1The original record to compute the changes from.
source2The new record that has changes over source1.
const wreport::Var* dballe::Record::var_peek ( wreport::Varcode  code) const
throw (
)

Look at the value of a variable.

Returns
A const pointer to the internal variable, or NULL if the variable has not been found.

Referenced by peek().

const char* dballe::Record::var_peek_value ( wreport::Varcode  code) const
throw (
)

Look at the raw value of a variable in the record, without raising errors.

Parameters
codeThe variable to get the value for. See vartable.h
Returns
The raw string value, or NULL if the variable has no value.

Referenced by peek_value().

void dballe::Record::var_unset ( wreport::Varcode  code)

Remove a parameter from the record.

Parameters
codeThe variable to remove. See vartable.h

Referenced by unset().


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