libwreport  2.4
vartable.h
Go to the documentation of this file.
1 /*
2  * wreport/vartable - Load variable information from on-disk tables
3  *
4  * Copyright (C) 2005--2010 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 WREPORT_VARTABLE_H
23 #define WREPORT_VARTABLE_H
24 
71 #include <wreport/varinfo.h>
72 #include <vector>
73 #include <string>
74 
75 namespace wreport {
76 
84 class Vartable : public std::vector<_Varinfo>
85 {
86 protected:
88  std::string m_id;
89 
90 public:
91  Vartable();
92  ~Vartable();
93 
95  const std::string& id() const { return m_id; }
96 
98  bool loaded() const { return !m_id.empty(); }
99 
101  void load(const std::pair<std::string, std::string>& idfile);
102 
111  Varinfo query(Varcode code) const;
112 
114  bool contains(Varcode code) const;
115 
130  Varinfo query_altered(Varcode var, int scale, unsigned bit_len) const;
131 
144  static const Vartable* get(const char* id);
145 
152  static const Vartable* get(const std::pair<std::string, std::string>& idfile);
153 
163  static std::pair<std::string, std::string> find_table(const std::vector<std::string>& ids);
164 
171  static std::pair<std::string, std::string> find_table(const std::string& id);
172 };
173 
174 }
175 
176 #endif
177 /* vim:set ts=4 sw=4: */