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
|
/** @file inmemory_positionlist.h
* @brief Iterate positions in an inmemory db
*/
/* Copyright 1999,2000,2001 BrightStation PLC
* Copyright 2003,2008,2009,2011 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 OM_HGUARD_INMEMORY_POSITIONLIST_H
#define OM_HGUARD_INMEMORY_POSITIONLIST_H
#include <xapian/types.h>
#include <xapian/error.h>
#include <vector>
#include "backends/positionlist.h"
#include "api/documentterm.h"
using namespace std;
/** A position list in a inmemory database. */
class InMemoryPositionList : public PositionList
{
private:
/// The list of positions.
vector<Xapian::termpos> positions;
/// Position of iteration through positions
vector<Xapian::termpos>::const_iterator mypos;
/// True if we have started iterating
bool iterating_in_progress;
/// Copying is not allowed.
InMemoryPositionList(const InMemoryPositionList &);
/// Assignment is not allowed.
void operator=(const InMemoryPositionList &);
public:
/// Default constructor.
InMemoryPositionList() : iterating_in_progress(false) { }
/// Construct an empty InMemoryPositionList.
explicit InMemoryPositionList(bool)
: mypos(positions.begin()), iterating_in_progress(false) { }
/// Construct, fill list with data, and move the position to the start.
explicit
InMemoryPositionList(const OmDocumentTerm::term_positions & positions_);
/// Fill list with data, and move the position to the start.
void set_data(const OmDocumentTerm::term_positions & positions_);
/// Gets size of position list.
Xapian::termcount get_size() const;
/// Gets current position.
Xapian::termpos get_position() const;
/** Move to the next item in the list.
* Either next() or skip_to() must be called before any other
* methods.
*/
void next();
/** Move to the next item in the list.
* Either next() or skip_to() must be called before any other
* methods.
*/
void skip_to(Xapian::termpos termpos);
/// True if we're off the end of the list
bool at_end() const;
};
#endif /* OM_HGUARD_INMEMORY_POSITIONLIST_H */
|