Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

VocabularyMerger.h

Go to the documentation of this file.
00001 #ifndef VOCABULARY_MERGER_H
00002 #define VOCABULARY_MERGER_H
00003 
00004 /*
00005  * Merge different vocabularies together
00006  *
00007  * Copyright (C) 2003,2004,2005  Enrico Zini <enrico@debian.org>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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         // Offset in the last written file (used for indexing)
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         // Offset in the last written file (used for indexing)
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     void outputImplications(TagcollConsumer<std::string>& consumer) const throw ();
00128     void outputDerivedTags(DerivedTagList& dtlist) const throw ();
00129     */
00130 #endif
00131 };
00132 
00133 };
00134 
00135 // vim:set ts=4 sw=4:
00136 #endif

Generated on Sat Sep 10 03:47:41 2005 for libdebtags by  doxygen 1.4.4