libwreport  2.8
dtable.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005--2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Author: Enrico Zini <enrico@enricozini.com>
18  */
19 
20 #ifndef WREPORT_DTABLE_H
21 #define WREPORT_DTABLE_H
22 
23 #include <wreport/opcode.h>
24 #include <string>
25 #include <vector>
26 
27 namespace wreport {
28 
34 namespace dtable {
38 struct Entry
39 {
43  unsigned begin;
45  unsigned end;
46 
47 protected:
49  Entry(Varcode code, unsigned begin, unsigned end)
50  : code(code), begin(begin), end(end) {}
51 
52  friend class wreport::DTable;
53 };
54 }
55 
59 struct DTable
60 {
61 protected:
63  std::string m_id;
64 
65 public:
70  std::vector<Varcode> varcodes;
71 
75  std::vector<dtable::Entry> entries;
76 
77  DTable();
78  ~DTable();
79 
81  const std::string& id() const throw () { return m_id; }
82 
84  bool loaded() const throw () { return !m_id.empty(); }
85 
92  void load(const std::pair<std::string, std::string>& idfile);
93 
103  Opcodes query(Varcode var) const;
104 
117  static const DTable* get(const char* id);
118 
125  static const DTable* get(const std::pair<std::string, std::string>& idfile);
126 };
127 
128 }
129 
130 #endif
131 /* vim:set ts=4 sw=4: */