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