#include <vocabulary.h>
Public Member Functions | |
Vocabulary (bool empty=false) | |
Instantiate the Debtags vocabulary. | |
~Vocabulary () | |
time_t | timestamp () const |
Get the timestamp of when the index was last updated. | |
bool | hasData () const |
Return true if this data source has data, false if it's empty. | |
bool | empty () const |
Check if there is any data in the merged vocabulary. | |
bool | hasFacet (const std::string &name) const |
Check if the vocabulary contains the facet `name'. | |
bool | hasTag (const std::string &name) const |
Check if the vocabulary contains the tag `fullname'. | |
const voc::FacetData * | facetData (const std::string &name) const |
Return the facet with the given name. | |
const voc::TagData * | tagData (const std::string &fullname) const |
Return the tag with the given full name. | |
std::set< std::string > | facets () const |
Return all the facets in the vocabulary. | |
std::set< std::string > | tags () const |
Return all the tags in the vocabulary. | |
std::set< std::string > | tags (const std::string &facet) const |
Return the tags in the given facet. | |
void | read (tagcoll::input::Input &input) |
Parse and import the vocabulary from `input', merging the data with the previously imported ones. | |
void | write () |
Atomically update the system vocabulary. | |
void | write (const std::string &fname) |
Atomically write the vocabulary data to the given file. | |
void | write (FILE *out) |
Write the vocabulary data to the given output stream. | |
Protected Member Functions | |
void | parseVocBuf (std::map< std::string, std::string > &res, size_t ofs, size_t len) const |
voc::FacetData & | obtainFacet (const std::string &name) |
voc::TagData & | obtainTag (const std::string &fullname) |
Protected Attributes | |
std::map< std::string, voc::FacetData > | m_facets |
time_t | m_timestamp |
std::map< std::string, std::string > | emptyData |
ept::debtags::Vocabulary::Vocabulary | ( | bool | empty = false |
) |
Instantiate the Debtags vocabulary.
empty | false if the Debtags vocabulary should be loaded, true if it should start as an empty vocabulary |
References ept::debtags::Path::debtagsSourceDir(), ept::debtags::Path::debtagsUserSourceDir(), m_timestamp, ept::debtags::SourceDir::readVocabularies(), and ept::debtags::SourceDir::vocTimestamp().
ept::debtags::Vocabulary::~Vocabulary | ( | ) |
bool ept::debtags::Vocabulary::empty | ( | ) | const [inline] |
Check if there is any data in the merged vocabulary.
References m_facets.
const voc::FacetData * ept::debtags::Vocabulary::facetData | ( | const std::string & | name | ) | const |
std::set< std::string > ept::debtags::Vocabulary::facets | ( | ) | const |
bool ept::debtags::Vocabulary::hasData | ( | ) | const [inline] |
Return true if this data source has data, false if it's empty.
References m_timestamp.
Referenced by TestVocabulary::_21().
bool ept::debtags::Vocabulary::hasFacet | ( | const std::string & | name | ) | const |
Check if the vocabulary contains the facet `name'.
References m_facets.
bool ept::debtags::Vocabulary::hasTag | ( | const std::string & | name | ) | const |
Check if the vocabulary contains the tag `fullname'.
References facetData(), ept::debtags::voc::getfacet(), and ept::debtags::voc::FacetData::hasTag().
voc::FacetData & ept::debtags::Vocabulary::obtainFacet | ( | const std::string & | name | ) | [protected] |
References m_facets.
Referenced by obtainTag(), and read().
voc::TagData & ept::debtags::Vocabulary::obtainTag | ( | const std::string & | fullname | ) | [protected] |
References ept::debtags::voc::getfacet(), obtainFacet(), and ept::debtags::voc::FacetData::obtainTag().
Referenced by read().
void ept::debtags::Vocabulary::parseVocBuf | ( | std::map< std::string, std::string > & | res, | |
size_t | ofs, | |||
size_t | len | |||
) | const [protected] |
void ept::debtags::Vocabulary::read | ( | tagcoll::input::Input & | input | ) |
Parse and import the vocabulary from `input', merging the data with the previously imported ones.
References ept::debtags::voc::Data::name, ept::debtags::DebDBParser::nextRecord(), obtainFacet(), and obtainTag().
Referenced by ept::debtags::SourceDir::readVocabularies().
const voc::TagData * ept::debtags::Vocabulary::tagData | ( | const std::string & | fullname | ) | const |
Return the tag with the given full name.
References facetData(), ept::debtags::voc::getfacet(), and ept::debtags::voc::FacetData::tagData().
Referenced by TestVocabulary::_13().
std::set< std::string > ept::debtags::Vocabulary::tags | ( | const std::string & | facet | ) | const |
Return the tags in the given facet.
References facetData(), and ept::debtags::voc::FacetData::tags().
std::set< std::string > ept::debtags::Vocabulary::tags | ( | ) | const |
time_t ept::debtags::Vocabulary::timestamp | ( | ) | const [inline] |
Get the timestamp of when the index was last updated.
References m_timestamp.
void ept::debtags::Vocabulary::write | ( | FILE * | out | ) |
Write the vocabulary data to the given output stream.
References m_facets.
void ept::debtags::Vocabulary::write | ( | const std::string & | fname | ) |
Atomically write the vocabulary data to the given file.
References write().
void ept::debtags::Vocabulary::write | ( | ) |
Atomically update the system vocabulary.
References ept::debtags::Path::debtagsSourceDir(), ept::debtags::Path::debtagsUserSourceDir(), ept::debtags::Path::userVocabulary(), ept::debtags::Path::vocabulary(), and ept::debtags::SourceDir::vocTimestamp().
Referenced by write().
std::map<std::string, std::string> ept::debtags::Vocabulary::emptyData [protected] |
std::map<std::string, voc::FacetData> ept::debtags::Vocabulary::m_facets [protected] |
Referenced by empty(), facetData(), facets(), hasFacet(), obtainFacet(), tags(), and write().
time_t ept::debtags::Vocabulary::m_timestamp [protected] |
Referenced by hasData(), timestamp(), and Vocabulary().