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,
"GlassSynonymTermList::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,
"GlassSynonymTermList::at_end", NO_ARGS);
226 RETURN(cursor->after_end());
void add_synonym(const std::string &term, const std::string &synonym)
Add a synonym for term.
InvalidOperationError indicates the API was used in an invalid way.
bool at_end() const
True if we're off the end of the list.
#define LOGCALL_DTOR(CATEGORY, CLASS)
Abstract base class for termlists.
TermList * open_termlist(const std::string &term)
Open synonym termlist for a term.
A vector-like container of terms which can be iterated.
TermList * next()
Advance to the next term in the list.
Hierarchy of classes which Xapian can throw as exceptions.
~GlassSynonymTermList()
Destructor.
bool startswith(const std::string &s, char pfx)
DatabaseCorruptError indicates database corruption was detected.
This class stores a list of terms.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Interface to Btree cursors.
void remove_synonym(const std::string &term, const std::string &synonym)
Remove a synonym for term.
Various handy helpers which std::string really should provide.
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
string get_termname() const
Returns the current termname.
TermList * skip_to(const string &tname)
Advance to the first term which is >= tname.
Synonym data for a glass database.
#define LOGCALL(CATEGORY, TYPE, FUNC, PARAMS)
void clear_synonyms(const std::string &term)
Remove all synonyms for term.