34 #include <string_view>
42 #define MAGIC_XOR_VALUE 96
47 if (last_term.empty())
return;
49 if (last_synonyms.empty()) {
53 for (
const auto& synonym : last_synonyms) {
58 last_synonyms.clear();
66 if (last_term !=
term) {
71 if (get_exact_entry(
term, tag)) {
72 const char *
p = tag.data();
73 const char * end =
p + tag.size();
80 last_synonyms.insert(
string(
p, len));
86 last_synonyms.emplace(synonym);
92 if (last_term !=
term) {
97 if (get_exact_entry(
term, tag)) {
98 const char *
p = tag.data();
99 const char * end =
p + tag.size();
106 last_synonyms.emplace(
p, len);
112 #ifdef __cpp_lib_associative_heterogeneous_erasure
113 last_synonyms.erase(synonym);
115 last_synonyms.erase(
string(synonym));
127 if (last_term ==
term) {
128 last_synonyms.clear();
138 vector<string> synonyms;
140 if (last_term ==
term) {
141 if (last_synonyms.empty())
return NULL;
143 synonyms.reserve(last_synonyms.size());
144 for (
const auto& i : last_synonyms) {
145 synonyms.push_back(i);
149 if (!get_exact_entry(
term, tag))
return NULL;
151 const char *
p = tag.data();
152 const char * end =
p + tag.size();
159 synonyms.push_back(
string(
p, len));
180 return database->synonym_table.get_entry_count();
193 Assert(!cursor->after_end());
195 if (!cursor->next() || !
startswith(cursor->current_key, prefix)) {
199 current_term = cursor->current_key;
208 Assert(!cursor->after_end());
210 if (cursor->find_entry_ge(tname)) {
212 current_term = tname;
216 if (cursor->after_end() || !
startswith(cursor->current_key, prefix)) {
220 current_term = cursor->current_key;
void clear_synonyms(std::string_view term)
Remove all synonyms for term.
void add_synonym(std::string_view term, std::string_view synonym)
Add a synonym for term.
TermList * open_termlist(std::string_view term)
Open synonym termlist for a term.
void remove_synonym(std::string_view term, std::string_view synonym)
Remove a synonym for term.
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
Xapian::termcount get_approx_size() const
Return approximate size of this termlist.
TermList * skip_to(std::string_view tname)
Advance to the first term which is >= tname.
~GlassSynonymTermList()
Destructor.
TermList * next()
Advance to the next term in the list.
This class stores a list of terms.
DatabaseCorruptError indicates database corruption was detected.
InvalidOperationError indicates the API was used in an invalid way.
Abstract base class for termlists.
#define LOGCALL(CATEGORY, TYPE, FUNC, PARAMS)
#define LOGCALL_DTOR(CATEGORY, CLASS)
Hierarchy of classes which Xapian can throw as exceptions.
Interface to Btree cursors.
C++ class definition for glass database.
Synonym data for a glass database.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Various handy string-related helpers.
bool startswith(std::string_view s, char pfx)
A vector-like container of terms which can be iterated.