32 #include <dballe/core/matcher.h>
63 DBA_KEY_MONTHMAX = 21,
64 DBA_KEY_MONTHMIN = 22,
73 DBA_KEY_LEVELTYPE1 = 31,
75 DBA_KEY_LEVELTYPE2 = 33,
77 DBA_KEY_PINDICATOR = 35,
82 DBA_KEY_CONTEXT_ID = 40,
84 DBA_KEY_ANA_FILTER = 42,
85 DBA_KEY_DATA_FILTER = 43,
86 DBA_KEY_ATTR_FILTER = 44,
88 DBA_KEY_VAR_RELATED = 46,
92 typedef enum _dba_keyword dba_keyword;
94 std::ostream& operator<<(std::ostream& o, dba_keyword k);
106 wreport::Var* keydata[DBA_KEY_COUNT];
109 std::vector<wreport::Var*> m_vars;
112 int find_item(wreport::Varcode code)
const throw ();
115 wreport::Var&
get_item(wreport::Varcode code);
118 const wreport::Var&
get_item(wreport::Varcode code)
const;
130 bool operator==(
const Record& rec)
const;
131 bool operator!=(
const Record& rec)
const {
return !operator==(rec); }
159 bool contains(dba_keyword parameter)
const throw();
164 bool contains(wreport::Varcode parameter)
const throw();
195 const wreport::Var*
key_peek(dba_keyword parameter)
const throw ();
204 const wreport::Var*
var_peek(wreport::Varcode code)
const throw ();
212 const wreport::Var*
peek(
const char* name)
const;
215 const wreport::Var*
peek(dba_keyword parameter)
const throw () {
return key_peek(parameter); }
218 const wreport::Var*
peek(wreport::Varcode code)
const throw () {
return var_peek(code); }
246 const char*
peek_value(
const char* name)
const;
257 const wreport::Var&
key(dba_keyword parameter)
const;
262 const wreport::Var&
var(wreport::Varcode code)
const;
267 wreport::Var&
key(dba_keyword parameter);
272 wreport::Var&
var(wreport::Varcode code);
276 const wreport::Var&
get(dba_keyword parameter)
const {
return key(parameter); }
277 const wreport::Var&
get(wreport::Varcode code)
const {
return var(code); }
278 const wreport::Var&
get(
const char* name)
const;
279 wreport::Var&
get(dba_keyword parameter) {
return key(parameter); }
280 wreport::Var&
get(wreport::Varcode code) {
return var(code); }
281 wreport::Var&
get(
const char* name);
282 template<
typename K,
typename T>
283 T
get(K name, T default_value)
const
285 if (
const wreport::Var* v =
peek(name))
286 return v->enq(default_value);
288 return default_value;
290 const wreport::Var&
operator[](dba_keyword parameter)
const {
return key(parameter); }
291 const wreport::Var&
operator[](wreport::Varcode code)
const {
return var(code); }
292 const wreport::Var&
operator[](
const char* name)
const {
return get(name); }
295 wreport::Var&
operator[](
const char* name) {
return get(name); }
296 template<
typename P,
typename V>
297 void set(
const P& field,
const V& val) {
get(field).
set(val); }
298 void set(
const wreport::Var&
var) {
get(var.code()).copy_val(var); }
303 void unset(
const char* name);
307 const wreport::Var* val = rec.
peek(parameter);
311 set(parameter, *val);
316 const wreport::Var* mine =
peek(parameter);
317 const wreport::Var* theirs = rec.
peek(parameter);
318 if (!mine and !theirs)
return true;
319 if (!mine or !theirs)
return false;
320 return *mine == *theirs;
324 Level get_level()
const;
325 Trange get_trange()
const;
330 void unset_datetime();
331 void unset_datetimemin();
332 void unset_datetimemax();
333 void get_datetime(
int (&val)[6])
const;
334 void get_datetimemin(
int (&val)[6])
const;
335 void get_datetimemax(
int (&val)[6])
const;
336 void set_datetime(
const int (&val)[6]);
337 void set_datetimemin(
const int (&val)[6]);
338 void set_datetimemax(
const int (&val)[6]);
339 void set_datetime(
int ye,
int mo=1,
int da=1,
int ho=0,
int mi=0,
int se=0);
351 const std::vector<wreport::Var*>&
vars()
const;
430 void print(FILE* out)
const;
446 static wreport::Varinfo
keyword_info(dba_keyword keyword);
485 void dba_record_diff(dba_record rec1, dba_record rec2,
int* diffs, FILE* out);
498 virtual matcher::Result
match_date(
const int* min,
const int* max)
const;
499 virtual matcher::Result
match_coords(
int latmin,
int latmax,
int lonmin,
int lonmax)
const;
wreport::Var & operator[](wreport::Varcode code)
Shortcuts.
Definition: record.h:294
const char * var_peek_value(wreport::Varcode code) const
Look at the raw value of a variable in the record, without raising errors.
const wreport::Var * peek(dba_keyword parameter) const
Shortcut for key_peek.
Definition: record.h:215
const wreport::Var * key_peek(dba_keyword parameter) const
Look at the value of a parameter.
bool contains(const Record &rec, K parameter)
Shortcuts.
Definition: record.h:314
const wreport::Var & operator[](dba_keyword parameter) const
Shortcuts.
Definition: record.h:290
Common interface for things that are matched.
Definition: matcher.h:48
Implement ::dba_var, an encapsulation of a measured variable.
void set_ana_context()
Set the date, level and timerange values to match the anagraphical context.
bool contains_level() const
Return true if some level attribute is set in this record.
const char * key_peek_value(dba_keyword parameter) const
Look at the raw value of a keyword in the record, without raising errors.
void parse_date(int *values) const
Parse the date set in the Record.
const wreport::Var & operator[](const char *name) const
Shortcuts.
Definition: record.h:292
virtual matcher::Result match_station_id(int val) const
Match station ID.
void unset(wreport::Varcode code)
Shortcuts.
Definition: record.h:302
DB-All.E record.
Definition: record.h:102
const char * peek_value(dba_keyword parameter) const
Shortcut for key_peek_value.
Definition: record.h:249
bool contains_trange() const
Return true if some time range attribute is set in this record.
bool contains_datetime() const
Return true if some datetime information is set in this record.
wreport::Var & operator[](const char *name)
Shortcuts.
Definition: record.h:295
wreport::Var & operator[](dba_keyword parameter)
Shortcuts.
Definition: record.h:293
virtual matcher::Result match_date(const int *min, const int *max) const
Match date.
void set(const wreport::Var &var)
Shortcuts.
Definition: record.h:298
void var_unset(wreport::Varcode code)
Remove a parameter from the record.
int find_item(wreport::Varcode code) const
Find an item by wreport::Varcode, returning -1 if not found.
const wreport::Var & key(dba_keyword parameter) const
Return the Var for a key, throwing an error it if it missing.
const std::vector< wreport::Var * > & vars() const
Return the varcode-sorted vector with the variables.
wreport::Var & get_item(wreport::Varcode code)
Find an item by wreport::Varcode, raising an exception if not found.
void parse_date_extremes(int *minvalues, int *maxvalues) const
Parse the date extremes set in Record.
const wreport::Var * var_peek(wreport::Varcode code) const
Look at the value of a variable.
void print(FILE *out) const
Print the contents of this record to the given file descriptor.
const wreport::Var & operator[](wreport::Varcode code) const
Shortcuts.
Definition: record.h:291
static dba_keyword keyword_byname_len(const char *tag, int len)
Get the dba_keyword corresponding to the given name.
const char * peek_value(const char *name) const
Get the string value for an item.
static const char * keyword_name(dba_keyword keyword)
Return the name of a dba_keyword.
void clear()
Remove all data from the record.
bool contains(const Record &subset) const
Return true if all elements of subset are present in this record, with the same value.
Coordinates.
Definition: defs.h:167
void unset(dba_keyword parameter)
Shortcuts.
Definition: record.h:301
virtual matcher::Result match_station_wmo(int block, int station=-1) const
Match station WMO code.
static dba_keyword keyword_byname(const char *tag)
Get the dba_keyword corresponding to the given name.
void copy(const Record &rec, K parameter)
Shortcuts.
Definition: record.h:305
Simple datetime structure.
Definition: defs.h:276
static wreport::Varinfo keyword_info(dba_keyword keyword)
Return informations about a keyword.
const wreport::Var * peek(const char *name) const
Get the variable for an item.
virtual matcher::Result match_rep_memo(const char *memo) const
Match rep_memo.
void set_from_string(const char *str)
Set a value in the record according to an assignment encoded in a string.
bool is_ana_context() const
Check if this record is set to the ana context.
void remove_item(wreport::Varcode code)
Remove an item by wreport::Varcode.
void set_to_difference(const Record &source1, const Record &source2)
Set the record to contain only those fields that change source1 into source2.
void clear_vars()
Remove all variables from the record, leaving the keywords intact.
const char * peek_value(wreport::Varcode code) const
Shortcut for var_peek_value.
Definition: record.h:252
void set(const P &field, const V &val)
Shortcuts.
Definition: record.h:297
void add(const Record &source)
Copy all data from the record source into dest.
void key_unset(dba_keyword parameter)
Remove a parameter from the record.
virtual matcher::Result match_coords(int latmin, int latmax, int lonmin, int lonmax) const
Match coordinates, with bounds in 1/100000 of degree.
virtual matcher::Result match_var_id(int val) const
Match variable ID.
const wreport::Var & var(wreport::Varcode code) const
Return the Var for a variable, throwing an error it if it missing.
const wreport::Var * peek(wreport::Varcode code) const
Shortcut for var_peek.
Definition: record.h:218
std::string to_string() const
Encode in a one-liner of comma-separated assignments.