40 #define MAGIC_XOR_VALUE 96 45 if (last_term.empty())
return;
47 if (last_synonyms.empty()) {
52 set<string>::const_iterator i;
53 for (i = last_synonyms.begin(); i != last_synonyms.end(); ++i) {
54 const string & synonym = *i;
60 last_synonyms.clear();
68 if (last_term != term) {
73 if (get_exact_entry(term, tag)) {
74 const char * p = tag.data();
75 const char * end = p + tag.size();
82 last_synonyms.insert(
string(p, len));
88 last_synonyms.insert(synonym);
94 if (last_term != term) {
99 if (get_exact_entry(term, tag)) {
100 const char * p = tag.data();
101 const char * end = p + tag.size();
108 last_synonyms.insert(
string(p, len));
114 last_synonyms.erase(synonym);
125 if (last_term == term) {
126 last_synonyms.clear();
136 vector<string> synonyms;
138 if (last_term == term) {
139 if (last_synonyms.empty())
return NULL;
141 synonyms.reserve(last_synonyms.size());
142 set<string>::const_iterator i;
143 for (i = last_synonyms.begin(); i != last_synonyms.end(); ++i) {
144 synonyms.push_back(*i);
148 if (!get_exact_entry(term, tag))
return NULL;
150 const char * p = tag.data();
151 const char * end = p + tag.size();
158 synonyms.push_back(
string(p, len));
177 LOGCALL(DB,
string,
"ChertSynonymTermList::get_termname", NO_ARGS);
179 Assert(!cursor->current_key.empty());
181 RETURN(cursor->current_key);
197 if (!cursor->after_end() && !
startswith(cursor->current_key, prefix)) {
211 if (!cursor->find_entry_ge(tname)) {
214 if (!cursor->after_end() && !
startswith(cursor->current_key, prefix)) {
225 LOGCALL(DB,
bool,
"ChertSynonymTermList::at_end", NO_ARGS);
226 RETURN(cursor->after_end());
~ChertSynonymTermList()
Destructor.
void clear_synonyms(const std::string &term)
Remove all synonyms for term.
TermList * skip_to(const string &tname)
Advance to the first term which is >= tname.
InvalidOperationError indicates the API was used in an invalid way.
#define LOGCALL_DTOR(CATEGORY, CLASS)
Abstract base class for termlists.
Synonym data for a chert database.
TermList * open_termlist(const std::string &term)
Open synonym termlist for a term.
A vector-like container of terms which can be iterated.
string get_termname() const
Returns the current termname.
Hierarchy of classes which Xapian can throw as exceptions.
void add_synonym(const std::string &term, const std::string &synonym)
Add a synonym for term.
TermList * next()
Advance to the next term in the list.
Interface to Btree cursors.
bool startswith(const std::string &s, char pfx)
bool at_end() const
True if we're off the end of the list.
DatabaseCorruptError indicates database corruption was detected.
This class stores a list of terms.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
Various handy helpers which std::string really should provide.
#define LOGCALL(CATEGORY, TYPE, FUNC, PARAMS)
void remove_synonym(const std::string &term, const std::string &synonym)
Remove a synonym for term.