Go to the documentation of this file.00001 #ifndef EPT_DEBTAGS_VOCABULARY_H
00002 #define EPT_DEBTAGS_VOCABULARY_H
00003
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <string>
00028 #include <vector>
00029 #include <set>
00030 #include <map>
00031
00032 namespace tagcoll {
00033 namespace input {
00034 struct Input;
00035 }
00036 }
00037
00038 namespace ept {
00039 namespace debtags {
00040 namespace voc {
00041
00043 std::string getfacet(const std::string& tagname);
00044
00046 struct Data : public std::map<std::string, std::string>
00047 {
00048 protected:
00049
00050 mutable std::string m_desc;
00051
00052 public:
00053 std::string name;
00054
00059 std::string shortDescription() const;
00060
00066 std::string longDescription() const;
00067 };
00068
00092 struct TagData : public Data
00093 {
00094 TagData() {}
00095
00096
00097 };
00098
00122 class FacetData : public Data
00123 {
00124 public:
00125 std::map<std::string, TagData> m_tags;
00126
00127 FacetData() {}
00128
00129 TagData& obtainTag(const std::string& fullname);
00130
00134 bool hasTag(const std::string& name) const;
00135
00139 const TagData* tagData(const std::string& name) const;
00140
00144 std::set<std::string> tags() const;
00145 };
00146
00147 }
00148
00149 class Vocabulary
00150 {
00151 protected:
00152 std::map<std::string, voc::FacetData> m_facets;
00153
00154 time_t m_timestamp;
00155
00156
00157 std::map<std::string, std::string> emptyData;
00158
00159 void parseVocBuf(std::map<std::string, std::string>& res, size_t ofs, size_t len) const;
00160
00161 voc::FacetData& obtainFacet(const std::string& name);
00162 voc::TagData& obtainTag(const std::string& fullname);
00163
00164 public:
00172 Vocabulary(bool empty=false);
00173 ~Vocabulary();
00174
00176 time_t timestamp() const { return m_timestamp; }
00177
00179 bool hasData() const { return m_timestamp != 0; }
00180
00184 bool empty() const { return m_facets.empty(); }
00185
00189 bool hasFacet(const std::string& name) const;
00190
00194 bool hasTag(const std::string& name) const;
00195
00199 const voc::FacetData* facetData(const std::string& name) const;
00200
00204 const voc::TagData* tagData(const std::string& fullname) const;
00205
00209 std::set<std::string> facets() const;
00210
00214 std::set<std::string> tags() const;
00215
00219 std::set<std::string> tags(const std::string& facet) const;
00220
00221 #if 0
00222
00223 const DerivedTagList& getEquations() const throw () { return equations; }
00224
00226 FacetSet facets(const FacetMatcher& filter) const throw () { return getFiltered(filter); }
00227 #endif
00228
00233 void read(tagcoll::input::Input& input);
00234
00238 void write();
00239
00243 void write(const std::string& fname);
00244
00248 void write(FILE* out);
00249 };
00250
00251 }
00252 }
00253
00254
00255 #endif