libept
|
#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 | load (const std::string &pathname) |
Load vocabulary data from the given file. | |
void | read (FILE *input, const std::string &pathname) |
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. | |
Static Public Member Functions | |
static std::string | pathname () |
Return the default pathname for the vocabulary. | |
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) |
void | write (std::ostream &out) |
Write the vocabulary data to the given output stream. | |
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 empty(), load(), and pathname().
ept::debtags::Vocabulary::~Vocabulary | ( | ) |
|
inline |
Check if there is any data in the merged vocabulary.
References m_facets.
Referenced by Vocabulary().
const voc::FacetData * ept::debtags::Vocabulary::facetData | ( | const std::string & | name | ) | const |
Return the facet with the given name.
std::set< std::string > ept::debtags::Vocabulary::facets | ( | ) | const |
Return all the facets in the vocabulary.
References res.
|
inline |
Return true if this data source has data, false if it's empty.
References m_timestamp.
bool ept::debtags::Vocabulary::hasFacet | ( | const std::string & | name | ) | const |
Check if the vocabulary contains the facet ‘name’.
bool ept::debtags::Vocabulary::hasTag | ( | const std::string & | name | ) | const |
Check if the vocabulary contains the tag ‘fullname’.
References ept::debtags::voc::getfacet(), and ept::debtags::voc::FacetData::hasTag().
void ept::debtags::Vocabulary::load | ( | const std::string & | pathname | ) |
Load vocabulary data from the given file.
References ept::sys::exists(), m_timestamp, pathname(), read(), and ept::sys::timestamp().
Referenced by Vocabulary().
|
protected |
References ept::debtags::voc::Data::name, and res.
|
protected |
References ept::debtags::voc::getfacet().
|
protected |
|
static |
Return the default pathname for the vocabulary.
This returns /var/lib/debtags/vocabulary, unless it has been overridden by setting $DEBTAGS_VOCABULARY
References res.
Referenced by load(), and Vocabulary().
void ept::debtags::Vocabulary::read | ( | FILE * | input, |
const std::string & | pathname | ||
) |
Parse and import the vocabulary from ‘input’, merging the data with the previously imported ones.
References ept::debtags::DebDBParser::fileName(), ept::debtags::voc::Data::name, and ept::debtags::DebDBParser::nextRecord().
Referenced by load().
const voc::TagData * ept::debtags::Vocabulary::tagData | ( | const std::string & | fullname | ) | const |
Return the tag with the given full name.
References ept::debtags::voc::getfacet(), and ept::debtags::voc::FacetData::tagData().
std::set< std::string > ept::debtags::Vocabulary::tags | ( | ) | const |
Return all the tags in the vocabulary.
References res.
std::set< std::string > ept::debtags::Vocabulary::tags | ( | const std::string & | facet | ) | const |
Return the tags in the given facet.
References ept::debtags::voc::FacetData::tags().
|
inline |
Get the timestamp of when the index was last updated.
References m_timestamp.
void ept::debtags::Vocabulary::write | ( | ) |
Atomically update the system vocabulary.
void ept::debtags::Vocabulary::write | ( | const std::string & | fname | ) |
Atomically write the vocabulary data to the given file.
References ept::sys::write_file_atomically().
|
protected |
Write the vocabulary data to the given output stream.
|
protected |
|
protected |
Referenced by empty().
|
protected |
Referenced by hasData(), load(), and timestamp().