1 #ifndef DBALLE_RECORD_H 2 #define DBALLE_RECORD_H 4 #include <wreport/var.h> 21 virtual std::unique_ptr<Record>
clone()
const = 0;
24 static std::unique_ptr<Record>
create();
27 virtual void clear() = 0;
40 virtual void seti(
const char* key,
int val) = 0;
45 virtual void setd(
const char* key,
double val) = 0;
55 virtual void setc(
const char* key,
const char* val) = 0;
65 virtual void sets(
const char* key,
const std::string& val) = 0;
77 virtual void setf(
const char* key,
const char* val) = 0;
94 virtual void set_var(
const wreport::Var& var) = 0;
98 void set(
const char* key,
int val) {
seti(key, val); }
99 void set(
const char* key,
double val) {
setd(key, val); }
100 void set(
const char* key,
const char* val) {
setc(key, val); }
101 void set(
const char* key,
const std::string& val) {
sets(key, val); }
109 void set(
const wreport::Var& var) {
set_var(var); }
110 void set(std::unique_ptr<wreport::Var>&& var) {
set_var_acquire(std::move(var)); }
113 virtual void unset(
const char* key) = 0;
116 virtual const wreport::Var*
get(
const char* key)
const = 0;
119 virtual bool isset(
const char* key)
const;
131 const wreport::Var&
operator[](
const char* key)
const;
133 const char* enq(
const char* key,
const char* def)
const 135 if (
const wreport::Var* var =
get(key))
136 return var->enq(def);
141 T enq(
const char* key,
const T& def)
const 143 if (
const wreport::Var* var =
get(key))
144 return var->enq(def);
157 virtual void add(
const Record& source) = 0;
169 void foreach_key(std::function<
void(
const char*,
const wreport::Var&)> dest)
const { foreach_key_ref(dest); }
175 void foreach_key(std::function<
void(
const char*, std::unique_ptr<wreport::Var>&&)> dest)
const { foreach_key_copy(dest); }
178 virtual void print(FILE* out)
const = 0;
186 static wreport::Varinfo
key_info(
const char* key);
194 static wreport::Varinfo
key_info(
const std::string& key);
197 virtual void foreach_key_ref(std::function<
void(
const char*,
const wreport::Var&)> dest)
const = 0;
198 virtual void foreach_key_copy(std::function<
void(
const char*, std::unique_ptr<wreport::Var>&&)> dest)
const = 0;
virtual void set_trange(const Trange &tr)=0
Set pindicator, p1, p2.
virtual void sets(const char *key, const std::string &val)=0
Set a key to a string value.
virtual void setd(const char *key, double val)=0
Set a key to a double value.
virtual bool isset(const char *key) const
Check if a value is set.
Common base types used by most of DB-All.e code.
bool operator!=(const Record &rec) const
Check if two records differ.
static wreport::Varinfo key_info(const char *key)
Return informations about a key.
virtual void set_var_acquire(std::unique_ptr< wreport::Var > &&var)=0
Set var.code() == var.
virtual void setc(const char *key, const char *val)=0
Set a key to a string value.
virtual void setf(const char *key, const char *val)=0
Set a key to a string value.
virtual void clear_vars()=0
Remove all Bxxyyy keys from the record, leaving the rest intact.
virtual void set_datetime(const Datetime &dt)=0
Set year, month, day, hour, min, sec.
Coordinates.
Definition: types.h:320
virtual void set_coords(const Coords &c)=0
Set lat, lon.
virtual void set_datetimerange(const DatetimeRange &lr)=0
Set datetime-min and datetime-max values.
virtual void clear()=0
Remove all contents from the record.
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:565
Key/value store where keys are strings and values are wreport variables.
Definition: record.h:16
virtual void add(const Record &source)=0
Copy all data from the record source into dest.
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
Vertical level or layer.
Definition: types.h:515
virtual bool equals(const Record &rec) const =0
Check if two records are the same.
static std::unique_ptr< Record > create()
Create a new Record.
virtual void set_var(const wreport::Var &var)=0
Set var.code() == var.value()
Range of datetimes.
Definition: types.h:255
virtual void set_latrange(const LatRange &lr)=0
Set latmin, latmax.
Range of latitudes.
Definition: types.h:390
virtual void print(FILE *out) const =0
Print the contents of this record to the given stream.
Date and time.
Definition: types.h:147
virtual void seti(const char *key, int val)=0
Set a key to an integer value.
bool operator==(const Record &rec) const
Check if two records are the same.
virtual bool contains(const Record &subset) const =0
Return true if all elements of subset are present in this record, with the same value.
virtual std::unique_ptr< Record > clone() const =0
Return a copy of this record.
void foreach_key(std::function< void(const char *, const wreport::Var &)> dest) const
Generate a sequence of key names and const Var& for all the contents of the record.
Definition: record.h:169
void foreach_key(std::function< void(const char *, std::unique_ptr< wreport::Var > &&)> dest) const
Generate a sequence of key names and unique_ptr<Var> for all the contents of the record.
Definition: record.h:175
const wreport::Var & operator[](const char *key) const
Get a value, if set, or throw an exception if not.
Range of longitudes.
Definition: types.h:464
virtual void unset(const char *key)=0
Remove/unset a key from the record.
virtual void set_level(const Level &lev)=0
Set leveltype1, l1, leveltype2, l2.
virtual void set_lonrange(const LonRange &lr)=0
Set lonmin, lonmax.