35 #include <string_view>
43 #define MAGIC_XOR_VALUE 96
48 if (last_term.empty())
return;
50 if (last_synonyms.empty()) {
54 for (
const auto& synonym : last_synonyms) {
59 last_synonyms.clear();
67 if (last_term !=
term) {
72 if (get_exact_entry(
term, tag)) {
73 const char *
p = tag.data();
74 const char * end =
p + tag.size();
81 last_synonyms.insert(
string(
p, len));
87 last_synonyms.emplace(synonym);
93 if (last_term !=
term) {
98 if (get_exact_entry(
term, tag)) {
99 const char *
p = tag.data();
100 const char * end =
p + tag.size();
107 last_synonyms.emplace(
p, len);
113 #ifdef __cpp_lib_associative_heterogeneous_erasure
114 last_synonyms.erase(synonym);
116 last_synonyms.erase(
string(synonym));
128 if (last_term ==
term) {
129 last_synonyms.clear();
139 vector<string> synonyms;
141 if (last_term ==
term) {
142 if (last_synonyms.empty())
return NULL;
144 synonyms.reserve(last_synonyms.size());
145 for (
const auto& i : last_synonyms) {
146 synonyms.push_back(i);
150 if (!get_exact_entry(
term, tag))
return NULL;
152 const char *
p = tag.data();
153 const char * end =
p + tag.size();
160 synonyms.push_back(
string(
p, len));
181 auto entry_count = database->synonym_table.get_entry_count();
182 return clamp_cast<Xapian::termcount>(entry_count);
195 Assert(!cursor->after_end());
197 if (!cursor->next() || !
startswith(cursor->current_key, prefix)) {
201 current_term = cursor->current_key;
210 Assert(!cursor->after_end());
212 if (cursor->find_entry_ge(
term)) {
218 if (cursor->after_end() || !
startswith(cursor->current_key, prefix)) {
222 current_term = cursor->current_key;
Cast a value to a type, clamping out of range values.
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.
~GlassSynonymTermList()
Destructor.
TermList * next()
Advance to the next term in the list.
TermList * skip_to(std::string_view term)
Advance to the first term which is >= term.
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.