9#include <dballe/value.h>
18template<
typename Value>
22 typedef typename std::vector<Value>::const_iterator const_iterator;
23 typedef typename std::vector<Value>::iterator iterator;
26 std::vector<Value> m_values;
28 iterator insert_new(
Value&& val);
37 const_iterator begin()
const {
return m_values.begin(); }
38 const_iterator end()
const {
return m_values.end(); }
39 const_iterator cbegin()
const {
return m_values.cbegin(); }
40 const_iterator cend()
const {
return m_values.cend(); }
41 iterator begin() {
return m_values.begin(); }
42 iterator end() {
return m_values.end(); }
45 size_t size()
const {
return m_values.size(); }
46 bool empty()
const {
return m_values.empty(); }
47 void clear() {
return m_values.clear(); }
48 void reserve(
typename std::vector<Value>::size_type size) { m_values.reserve(size); }
56 void set(std::unique_ptr<wreport::Var>&&);
71 template<
typename C,
typename T>
void set(
const C& code,
const T& val) { this->
set(
newvar(code, val)); }
73 template<
typename C,
typename T>
74 void setf(
const C& code,
const T& val)
126 template<
typename C,
typename T> T
enq(C code,
const T& def)
145 void move_to(std::function<
void(std::unique_ptr<wreport::Var>)> dest);
163 static void decode(
const std::vector<uint8_t>& buf, std::function<
void(std::unique_ptr<wreport::Var>)> dest);
178 using ValuesBase<
Value>::ValuesBase;
194 using ValuesBase<
DBValue>::ValuesBase;
211 for (
auto& val : m_values)
212 val.data_id = MISSING_INT;
216std::ostream& operator<<(std::ostream&,
const Values&);
217std::ostream& operator<<(std::ostream&,
const DBValues&);
Container for a wreport::Var pointer.
Definition: value.h:19
void print(FILE *out) const
Print the contents of this Values.
static void decode(const std::vector< uint8_t > &buf, std::function< void(std::unique_ptr< wreport::Var >)> dest)
Decode variables from a DB-All.e specific binary representation.
T enq(C code, const T &def)
Get the value of a variable, or def if it is not set.
Definition: values.h:126
void set(std::unique_ptr< wreport::Var > &&)
Set from a wreport::Var, taking ownership of it.
std::vector< uint8_t > encode() const
Encode these values in a DB-All.e specific binary representation.
const Value * maybe_value(wreport::Varcode code) const
Lookup a value, returning nullptr if not found.
void merge(ValuesBase< Value > &&vals)
Add all the variables from vals.
wreport::Var & var(wreport::Varcode code)
Lookup a wreport::Var, throwing an exception if not found (non-const version)
static std::vector< uint8_t > encode_attrs(const wreport::Var &var)
Encode the attributes of var in a DB-All.e specific binary representation.
void move_to(std::function< void(std::unique_ptr< wreport::Var >)> dest)
Move all the Var passing them to the given function.
const wreport::Var & var(wreport::Varcode code) const
Lookup a wreport::Var, throwing an exception if not found.
wreport::Var * maybe_var(wreport::Varcode code)
Lookup a variable, returning nullptr if not found (non-const version)
void set(const C &code, const T &val)
Set a variable value, creating it if it does not exist.
Definition: values.h:71
const wreport::Var * maybe_var(wreport::Varcode code) const
Lookup a variable, returning nullptr if not found.
const Value & value(wreport::Varcode code) const
Lookup a value, throwing an exception if not found.
void merge(const ValuesBase< Value > &vals)
Add all the variables from vals.
void unset(wreport::Varcode code)
Remove one variable.
void move_to_attributes(wreport::Var &dest)
Move all the Var as attributes to dest.
void set(const wreport::Var &)
Set from a wreport::Var.
void set(Value &&val)
Set with a Value.
void setf(const char *val)
Container for a wreport::Var pointer, and its database ID.
Definition: value.h:72
Collection of DBValue objects, indexed by wreport::Varcode.
Definition: values.h:192
void clear_ids()
Reset all the database IDs.
Definition: values.h:209
bool vars_equal(const DBValues &o) const
Check if the variables are the same, regardless of the data_id.
void set_data_id(wreport::Varcode code, int data_id)
Set the database ID for the Value with this wreport::Varcode.
Collection of Value objects, indexed by wreport::Varcode.
Definition: values.h:177
Create wreport variables from the DB-All.e B table.
std::unique_ptr< wreport::Var > newvar(C code, const T &val)
Create a new Var, from the DB-All.e B table, with value.
Definition: var.h:63
wreport::Varcode resolve_varcode(const char *name)
Resolve a variable name to a varcode proper, dealing with aliases and validation.