00001 #ifndef VOCABULARY_MERGER_H
00002 #define VOCABULARY_MERGER_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <tagcoll/ParserBase.h>
00025 #include <stdio.h>
00026
00027 #include <string>
00028 #include <map>
00029
00030 namespace Debtags
00031 {
00032 class VocabularyMerger
00033 {
00034 protected:
00035 class TagData : public std::map<std::string, std::string>
00036 {
00037 public:
00038 std::string name;
00039
00040 long ofs;
00041 int len;
00042
00043 TagData() throw () : ofs(0), len(0) {}
00044 };
00045 class FacetData : public std::map<std::string, std::string>
00046 {
00047 public:
00048 std::string name;
00049 std::map<std::string, TagData> tags;
00050
00051 long ofs;
00052 int len;
00053
00054 FacetData() throw () : ofs(0), len(0) {}
00055
00056 TagData& obtainTag(const std::string& fullname) throw ();
00057 };
00058 std::map<std::string, FacetData> facets;
00059
00060 FacetData& obtainFacet(const std::string& name) throw ();
00061 TagData& obtainTag(const std::string& fullname) throw ();
00062
00063 public:
00068 void read(Tagcoll::ParserInput& input) throw (Tagcoll::ParserException);
00069
00073 void write(const std::string& fname) throw (Tagcoll::SystemException);
00074
00078 void write(FILE* out) throw (Tagcoll::SystemException);
00079
00091 void writeIndex(const std::string& fname, long base_ofs = 0) throw (Tagcoll::SystemException);
00092
00093
00097 bool hasFacet(const std::string& name) const throw ()
00098 {
00099 return facets.find(name) != facets.end();
00100 }
00101
00105 bool hasTag(const std::string& fullname) const throw ();
00106
00107 #if 0
00108
00109 Facet findFacet(const std::string& facet) const throw () { return find(facet); }
00110
00112 const FacetSet& getFacets() const throw () { return *this; }
00113
00115 FacetSet getFacets(const FacetMatcher& filter) const throw () { return getFiltered(filter); }
00116
00118 void read() throw (FileException, ParserException);
00119
00121 void readVocabularies() throw (SystemException, FileException, ParserException);
00122
00124 void write() throw (FileException);
00125
00126
00127
00128
00129
00130 #endif
00131 };
00132
00133 };
00134
00135
00136 #endif