/usr/include/xapian/keymaker.h is in libxapian-dev 1.2.19-1+deb8u1.
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 | /** @file keymaker.h
* @brief Build key strings for MSet ordering or collapsing.
*/
/* Copyright (C) 2007,2009 Olly Betts
*
* 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
#include <string>
#include <vector>
#include <xapian/deprecated.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:
/** 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();
};
/** 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 {
std::vector<std::pair<Xapian::valueno, bool> > slots;
public:
MultiValueKeyMaker() { }
template <class Iterator>
MultiValueKeyMaker(Iterator begin, Iterator end) {
while (begin != end) add_value(*begin++);
}
virtual std::string operator()(const Xapian::Document & doc) const;
void add_value(Xapian::valueno slot, bool reverse = false) {
slots.push_back(std::make_pair(slot, reverse));
}
};
/** Virtual base class for sorter functor. */
class XAPIAN_VISIBILITY_DEFAULT XAPIAN_DEPRECATED_CLASS Sorter : public KeyMaker { };
/** Sorter subclass which sorts by a several values.
*
* 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.
*
* @deprecated This class is deprecated - you should migrate to using
* MultiValueKeyMaker instead. Note that MultiValueSorter::add() becomes
* MultiValueKeyMaker::add_value(), but the sense of the direction flag
* is reversed (to be consistent with Enquire::set_sort_by_value()).
*
* So:
* <pre>
* MultiValueSorter sorter;
* // Primary ordering is forwards on value 4.
* sorter.add(4);
* // Secondary ordering is reverse on value 5.
* sorter.add(5, false);
* </pre>
* becomes:
* <pre>
* MultiValueKeyMaker sorter;
* // Primary ordering is forwards on value 4.
* sorter.add_value(4);
* // Secondary ordering is reverse on value 5.
* sorter.add_value(5, true);
* </pre>
*/
class XAPIAN_VISIBILITY_DEFAULT XAPIAN_DEPRECATED_CLASS MultiValueSorter : public Sorter {
std::vector<std::pair<Xapian::valueno, bool> > slots;
public:
MultiValueSorter() { }
template <class Iterator>
MultiValueSorter(Iterator begin, Iterator end) {
while (begin != end) add(*begin++);
}
virtual std::string operator()(const Xapian::Document & doc) const;
void add(Xapian::valueno slot, bool forward = true) {
slots.push_back(std::make_pair(slot, forward));
}
};
}
#endif // XAPIAN_INCLUDED_KEYMAKER_H
|