libdballe 9.13
var.h
Go to the documentation of this file.
1#ifndef DBALLE_VAR_H
2#define DBALLE_VAR_H
3
9
10#include <memory>
11#include <string>
12#include <wreport/var.h>
13
14namespace dballe {
15
17wreport::Varinfo varinfo(wreport::Varcode code);
18
20wreport::Varinfo varinfo(const char* code);
21
23wreport::Varinfo varinfo(const std::string& code);
24
29wreport::Varcode resolve_varcode(const char* name);
30
35wreport::Varcode resolve_varcode(const std::string& name);
36
38template <typename C> static inline wreport::Var var(C code)
39{
40 return wreport::Var(varinfo(code));
41}
42
44template <typename C, typename T>
45static inline wreport::Var var(C code, const T& val)
46{
47 return wreport::Var(varinfo(code), val);
48}
49
51static inline std::unique_ptr<wreport::Var> newvar(const wreport::Var& var)
52{
53 return std::unique_ptr<wreport::Var>(new wreport::Var(var));
54}
55
57template <typename C> static inline std::unique_ptr<wreport::Var> newvar(C code)
58{
59 return std::unique_ptr<wreport::Var>(new wreport::Var(varinfo(code)));
60}
61
63template <typename C, typename T>
64std::unique_ptr<wreport::Var> newvar(C code, const T& val)
65{
66 return std::unique_ptr<wreport::Var>(new wreport::Var(varinfo(code), val));
67}
68
69} // namespace dballe
70
71#endif
wreport::Varinfo varinfo(wreport::Varcode code)
Return a Varinfo entry from the DB-All.e B table.
wreport::Varcode resolve_varcode(const char *name)
Resolve a variable name to a varcode proper, dealing with aliases and validation.