libwreport
2.4
|
00001 /* 00002 * Copyright (C) 2005--2010 ARPA-SIM <urpsim@smr.arpa.emr.it> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License. 00007 * 00008 * This program is distributed in the hope that it will be useful, 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 * GNU General Public License for more details. 00012 * 00013 * You should have received a copy of the GNU General Public License 00014 * along with this program; if not, write to the Free Software 00015 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00016 * 00017 * Author: Enrico Zini <enrico@enricozini.com> 00018 */ 00019 00020 #ifndef WREPORT_DTABLE_H 00021 #define WREPORT_DTABLE_H 00022 00023 #include <wreport/opcode.h> 00024 #include <string> 00025 #include <vector> 00026 00027 namespace wreport { 00028 00034 namespace dtable { 00038 struct Entry 00039 { 00041 Varcode code; 00043 unsigned begin; 00045 unsigned end; 00046 00047 protected: 00049 Entry(Varcode code, unsigned begin, unsigned end) 00050 : code(code), begin(begin), end(end) {} 00051 00052 friend class wreport::DTable; 00053 }; 00054 } 00055 00059 struct DTable 00060 { 00061 protected: 00063 std::string m_id; 00064 00065 public: 00070 std::vector<Varcode> varcodes; 00071 00075 std::vector<dtable::Entry> entries; 00076 00077 DTable(); 00078 ~DTable(); 00079 00081 const std::string& id() const throw () { return m_id; } 00082 00084 bool loaded() const throw () { return !m_id.empty(); } 00085 00092 void load(const std::pair<std::string, std::string>& idfile); 00093 00103 Opcodes query(Varcode var) const; 00104 00117 static const DTable* get(const char* id); 00118 00125 static const DTable* get(const std::pair<std::string, std::string>& idfile); 00126 }; 00127 00128 } 00129 00130 #endif 00131 /* vim:set ts=4 sw=4: */