38 KeyMaker::~KeyMaker() { }
51 "searches - name() method not implemented");
55 KeyMaker::serialise()
const
58 "searches - serialise() method not implemented");
62 KeyMaker::unserialise(
const string&,
const Registry&)
const
65 "searches - unserialise() method not implemented");
73 auto i = slots.begin();
75 if (
rare(i == slots.end()))
return result;
77 size_t last_not_empty_forwards = 0;
84 bool reverse_sort = i->reverse;
90 if (reverse_sort || !v.empty())
91 last_not_empty_forwards = result.size();
93 if (++i == slots.end() && !reverse_sort) {
96 result.resize(last_not_empty_forwards);
108 for (string::const_iterator j = v.begin(); j != v.end(); ++j) {
109 unsigned char ch =
static_cast<unsigned char>(*j);
110 result += char(255 - ch);
111 if (ch == 0) result +=
'\0';
113 result.append(
"\xff\xff", 2);
114 if (i == slots.end())
break;
115 last_not_empty_forwards = result.size();
120 string::size_type j = 0, nul;
121 while ((nul = v.find(
'\0', j)) != string::npos) {
123 result.append(v, j, nul - j);
127 result.append(v, j, string::npos);
129 last_not_empty_forwards = result.size();
130 result.append(
"\0", 2);
139 return "Xapian::MultiValueKeyMaker";
146 MultiValueKeyMaker::serialise()
const
149 for (
auto& keyspec : slots) {
151 if (keyspec.defvalue.empty()) {
163 MultiValueKeyMaker::unserialise(
const string& serialised,
166 const char*
p = serialised.data();
167 const char* end =
p + serialised.size();
175 unsigned char bits = *
p++;
182 result->add_value(slot, reverse, defvalue);
184 result->add_value(slot, reverse);
187 return result.release();
Class representing a document.
std::string get_value(Xapian::valueno slot) const
Read a value slot in this document.
Virtual base class for key making functors.
KeyMaker subclass which combines several values.
Registry for user subclasses.
UnimplementedError indicates an attempt to use an unimplemented feature.
Class representing a document.
Hierarchy of classes which Xapian can throw as exceptions.
Build key strings for MSet ordering or collapsing.
The Xapian namespace contains public interfaces for the Xapian library.
unsigned valueno
The number for a value slot in a document.
static constexpr unsigned char KEYSPEC_REVERSE
static void throw_unimplemented(const char *message)
static constexpr unsigned char KEYSPEC_DEFVALUE
void unpack_throw_serialisation_error(const char *p)
Throw appropriate SerialisationError.
Pack types into strings and unpack them again.
bool unpack_string(const char **p, const char *end, std::string &result)
Decode a std::string from a string.
bool unpack_uint(const char **p, const char *end, U *result)
Decode an unsigned integer from a string.
void pack_uint(std::string &s, U value)
Append an encoded unsigned integer to a string.
void pack_string(std::string &s, std::string_view value)
Append an encoded std::string to a string.