xapian-core  1.4.27
positioniterator.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2008,2009,2010,2011,2012,2013,2014,2015 Olly Betts
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
19  * USA
20  */
21 
22 #ifndef XAPIAN_INCLUDED_POSITIONITERATOR_H
23 #define XAPIAN_INCLUDED_POSITIONITERATOR_H
24 
25 #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
26 # error Never use <xapian/positioniterator.h> directly; include <xapian.h> instead.
27 #endif
28 
29 #include <iterator>
30 #include <string>
31 
32 #include <xapian/attributes.h>
33 #include <xapian/derefwrapper.h>
34 #include <xapian/types.h>
35 #include <xapian/visibility.h>
36 
37 namespace Xapian {
38 
41  void decref();
42 
43  public:
45  class Internal;
47  Internal * internal;
48 
50  explicit PositionIterator(Internal *internal_);
51 
54 
56  PositionIterator & operator=(const PositionIterator & o);
57 
58 #ifdef XAPIAN_MOVE_SEMANTICS
61  : internal(o.internal) {
62  o.internal = nullptr;
63  }
64 
66  PositionIterator & operator=(PositionIterator && o) {
67  if (this != &o) {
68  if (internal) decref();
69  internal = o.internal;
70  o.internal = nullptr;
71  }
72  return *this;
73  }
74 #endif
75 
81  XAPIAN_NOTHROW(PositionIterator())
82  : internal() { }
83 
86  if (internal) decref();
87  }
88 
90  Xapian::termpos operator*() const;
91 
93  PositionIterator & operator++();
94 
97  Xapian::termpos pos(**this);
98  operator++();
100  }
101 
108  void skip_to(Xapian::termpos termpos);
109 
111  std::string get_description() const;
112 
123  // @{
125  typedef std::input_iterator_tag iterator_category;
134  // @}
135 };
136 
137 bool
138 XAPIAN_NOTHROW(operator==(const PositionIterator &a, const PositionIterator &b));
139 
141 inline bool
143 {
144  // Use a pointer comparison - this ensures both that (a == a) and correct
145  // handling of end iterators (which we ensure have NULL internals).
146  return a.internal == b.internal;
147 }
148 
149 bool
150 XAPIAN_NOTHROW(operator!=(const PositionIterator &a, const PositionIterator &b));
151 
153 inline bool
155 {
156  return !(a == b);
157 }
158 
159 }
160 
161 #endif // XAPIAN_INCLUDED_POSITIONITERATOR_H
The Xapian namespace contains public interfaces for the Xapian library.
Definition: compactor.cc:80
Xapian::termpos * pointer
typedefs for Xapian
Compiler attribute macros.
std::input_iterator_tag iterator_category
bool operator!=(const ESetIterator &a, const ESetIterator &b)
Inequality test for ESetIterator objects.
Definition: eset.h:287
Xapian::termpos_diff difference_type
~PositionIterator()
Destructor.
bool operator==(const ESetIterator &a, const ESetIterator &b)
Equality test for ESetIterator objects.
Definition: eset.h:277
#define XAPIAN_VISIBILITY_DEFAULT
Definition: visibility.h:28
XAPIAN_TERMPOS_BASE_TYPE termpos_diff
A signed difference between two term positions.
Definition: types.h:90
Define XAPIAN_VISIBILITY_* macros.
Xapian::termpos & reference
Class for iterating over term positions.
const Query operator*(double factor, const Query &q)
Scale a Xapian::Query object using OP_SCALE_WEIGHT.
Definition: query.h:670
DerefWrapper_< Xapian::termpos > operator++(int)
Advance the iterator to the next position (postfix version).
unsigned XAPIAN_TERMPOS_BASE_TYPE termpos
A term position within a document or query.
Definition: types.h:83
Class for wrapping type returned by an input_iterator.
Abstract base class for iterating term positions in a document.
Definition: positionlist.h:31
#define XAPIAN_NOEXCEPT
Definition: attributes.h:39
PositionIterator()
Default constructor.