libdballe  6.8
var.h
Go to the documentation of this file.
1 /*
2  * dballe/var - DB-All.e specialisation of wreport variable
3  *
4  * Copyright (C) 2005--2011 ARPA-SIM <urpsim@smr.arpa.emr.it>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * Author: Enrico Zini <enrico@enricozini.com>
20  */
21 
22 #ifndef DBALLE_CORE_VAR_H
23 #define DBALLE_CORE_VAR_H
24 
31 #include <wreport/var.h>
32 #include <memory>
33 #include <string>
34 #include <set>
35 
36 namespace dballe {
37 
42 wreport::Varinfo varinfo(wreport::Varcode code);
44 
48 wreport::Varcode resolve_varcode(const char* name);
49 
51 wreport::Varcode resolve_varcode_safe(const char* name);
52 
54 wreport::Varcode resolve_varcode_safe(const std::string& name);
55 
57 void resolve_varlist_safe(const std::string& varlist, std::set<wreport::Varcode>& out);
58 
60 static inline wreport::Var var(wreport::Varcode code) { return wreport::Var(varinfo(code)); }
61 
63 template<typename T>
64 wreport::Var var(wreport::Varcode code, const T& val) { return wreport::Var(varinfo(code), val); }
65 
66 
68 static inline std::auto_ptr<wreport::Var> newvar(wreport::Varcode code)
69 {
70  return std::auto_ptr<wreport::Var>(new wreport::Var(varinfo(code)));
71 }
72 
74 template<typename T>
75 std::auto_ptr<wreport::Var> newvar(wreport::Varcode code, const T& val)
76 {
77  return std::auto_ptr<wreport::Var>(new wreport::Var(varinfo(code), val));
78 }
79 
81 std::auto_ptr<wreport::Var> var_copy_without_unset_attrs(const wreport::Var& var);
82 
87 std::auto_ptr<wreport::Var> var_copy_without_unset_attrs(const wreport::Var& var, wreport::Varcode code);
88 
94 void format_code(wreport::Varcode code, char* buf);
95 
97 std::string format_code(wreport::Varcode code);
98 
100 wreport::Varcode map_code_to_dballe(wreport::Varcode code);
101 
102 }
103 
104 #endif
105 /* vim:set ts=4 sw=4: */
Definition: cmdline.h:34