/usr/include/xapian/keymaker.h is in libxapian-dev 1.4.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | /** @file keymaker.h
* @brief Build key strings for MSet ordering or collapsing.
*/
/* Copyright (C) 2007,2009,2011,2013,2014,2015,2016 Olly Betts
* Copyright (C) 2010 Richard Boulton
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef XAPIAN_INCLUDED_KEYMAKER_H
#define XAPIAN_INCLUDED_KEYMAKER_H
#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
# error "Never use <xapian/keymaker.h> directly; include <xapian.h> instead."
#endif
#include <string>
#include <vector>
#include <xapian/intrusive_ptr.h>
#include <xapian/types.h>
#include <xapian/visibility.h>
namespace Xapian {
class Document;
/** Virtual base class for key making functors. */
class XAPIAN_VISIBILITY_DEFAULT KeyMaker
: public Xapian::Internal::opt_intrusive_base {
/// Don't allow assignment.
void operator=(const KeyMaker &);
/// Don't allow copying.
KeyMaker(const KeyMaker &);
public:
/// Default constructor.
KeyMaker() { }
/** Build a key string for a Document.
*
* These keys can be used for sorting or collapsing matching documents.
*
* @param doc Document object to build a key for.
*/
virtual std::string operator()(const Xapian::Document & doc) const = 0;
/** Virtual destructor, because we have virtual methods. */
virtual ~KeyMaker();
/** Start reference counting this object.
*
* You can hand ownership of a dynamically allocated KeyMaker
* object to Xapian by calling release() and then passing the object to a
* Xapian method. Xapian will arrange to delete the object once it is no
* longer required.
*/
KeyMaker * release() {
opt_intrusive_base::release();
return this;
}
/** Start reference counting this object.
*
* You can hand ownership of a dynamically allocated KeyMaker
* object to Xapian by calling release() and then passing the object to a
* Xapian method. Xapian will arrange to delete the object once it is no
* longer required.
*/
const KeyMaker * release() const {
opt_intrusive_base::release();
return this;
}
};
/** KeyMaker subclass which combines several values.
*
* When the result is used for sorting, results are ordered by the first
* value. In the event of a tie, the second is used. If this is the same for
* both, the third is used, and so on. If @a reverse is true for a value,
* then the sort order for that value is reversed.
*
* When used for collapsing, the documents will only be considered equal if
* all the values specified match. If none of the specified values are set
* then the generated key will be empty, so such documents won't be collapsed
* (which is consistent with the behaviour in the "collapse on a value" case).
* If you'd prefer that documents with none of the keys set are collapsed
* together, then you can set @a reverse for at least one of the values.
* Other than this, it isn't useful to set @a reverse for collapsing.
*/
class XAPIAN_VISIBILITY_DEFAULT MultiValueKeyMaker : public KeyMaker {
struct KeySpec {
Xapian::valueno slot;
bool reverse;
std::string defvalue;
KeySpec(Xapian::valueno slot_, bool reverse_,
const std::string & defvalue_)
: slot(slot_), reverse(reverse_), defvalue(defvalue_)
{}
};
std::vector<KeySpec> slots;
public:
MultiValueKeyMaker() { }
/** Construct a MultiValueKeyMaker from a pair of iterators.
*
* The iterators must be a begin/end pair returning Xapian::valueno (or
* a compatible type) when dereferenced.
*/
template <class Iterator>
MultiValueKeyMaker(Iterator begin, Iterator end) {
while (begin != end) add_value(*begin++);
}
virtual std::string operator()(const Xapian::Document & doc) const;
/** Add a value slot to the list to build a key from.
*
* @param slot The value slot to add
* @param reverse Adjust values from this slot to reverse their sort
* order (default: false)
* @param defvalue Value to use for documents which don't have a value
* set in this slot (default: empty). This can be used
* to make such documents sort after all others by
* passing <code>get_value_upper_bound(slot) + "x"</code>
* - this is guaranteed to be greater than any value in
* this slot.
*/
void add_value(Xapian::valueno slot, bool reverse = false,
const std::string & defvalue = std::string()) {
slots.push_back(KeySpec(slot, reverse, defvalue));
}
};
}
#endif // XAPIAN_INCLUDED_KEYMAKER_H
|