libdballe  5.18
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 
35 namespace dballe {
36 
41 
42 wreport::Varinfo varinfo(wreport::Varcode code);
43 
44 
46 static inline wreport::Var var(wreport::Varcode code) { return wreport::Var(varinfo(code)); }
47 
49 template<typename T>
50 wreport::Var var(wreport::Varcode code, const T& val) { return wreport::Var(varinfo(code), val); }
51 
52 
54 static inline std::auto_ptr<wreport::Var> newvar(wreport::Varcode code)
55 {
56  return std::auto_ptr<wreport::Var>(new wreport::Var(varinfo(code)));
57 }
58 
60 template<typename T>
61 std::auto_ptr<wreport::Var> newvar(wreport::Varcode code, const T& val)
62 {
63  return std::auto_ptr<wreport::Var>(new wreport::Var(varinfo(code), val));
64 }
65 
67 std::auto_ptr<wreport::Var> var_copy_without_unset_attrs(const wreport::Var& var);
68 
73 std::auto_ptr<wreport::Var> var_copy_without_unset_attrs(const wreport::Var& var, wreport::Varcode code);
74 
80 void format_code(wreport::Varcode code, char* buf);
81 
83 std::string format_code(wreport::Varcode code);
84 
86 wreport::Varcode map_code_to_dballe(wreport::Varcode code);
87 
88 }
89 
90 #endif
91 /* vim:set ts=4 sw=4: */