xapian-core  1.4.25
postingiterator.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2007,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_POSTINGITERATOR_H
23 #define XAPIAN_INCLUDED_POSTINGITERATOR_H
24 
25 #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
26 # error Never use <xapian/postingiterator.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>
35 #include <xapian/types.h>
36 #include <xapian/visibility.h>
37 
38 namespace Xapian {
39 
42  public:
44  class Internal;
46  Internal * internal;
47 
49  explicit PostingIterator(Internal *internal_);
50 
53 
55  PostingIterator & operator=(const PostingIterator & o);
56 
57 #ifdef XAPIAN_MOVE_SEMANTICS
60  : internal(o.internal) {
61  o.internal = nullptr;
62  }
63 
65  PostingIterator & operator=(PostingIterator && o) {
66  if (this != &o) {
67  if (internal) decref();
68  internal = o.internal;
69  o.internal = nullptr;
70  }
71  return *this;
72  }
73 #endif
74 
80  XAPIAN_NOTHROW(PostingIterator())
81  : internal() { }
82 
85  if (internal) decref();
86  }
87 
89  Xapian::docid operator*() const;
90 
92  Xapian::termcount get_wdf() const;
93 
95  Xapian::termcount get_doclength() const;
96 
98  Xapian::termcount get_unique_terms() const;
99 
100 #if 0 // FIXME: TermIterator supports this, so PostingIterator really ought to.
101  Xapian::termcount positionlist_count() const;
103 #endif
104 
106  PositionIterator positionlist_begin() const;
107 
109  PositionIterator XAPIAN_NOTHROW(positionlist_end() const) {
110  return PositionIterator();
111  }
112 
114  PostingIterator & operator++();
115 
118  Xapian::docid did(**this);
119  operator++();
120  return DerefWrapper_<Xapian::docid>(did);
121  }
122 
129  void skip_to(Xapian::docid did);
130 
132  std::string get_description() const;
133 
144  // @{
146  typedef std::input_iterator_tag iterator_category;
155  // @}
156 
157  private:
158  void decref();
159 
160  void post_advance(Internal * res);
161 };
162 
163 bool
164 XAPIAN_NOTHROW(operator==(const PostingIterator &a, const PostingIterator &b));
165 
167 inline bool
169 {
170  // Use a pointer comparison - this ensures both that (a == a) and correct
171  // handling of end iterators (which we ensure have NULL internals).
172  return a.internal == b.internal;
173 }
174 
175 inline bool
176 XAPIAN_NOTHROW(operator!=(const PostingIterator &a, const PostingIterator &b));
177 
179 inline bool
181 {
182  return !(a == b);
183 }
184 
185 }
186 
187 #endif // XAPIAN_INCLUDED_POSTINGITERATOR_H
The Xapian namespace contains public interfaces for the Xapian library.
Definition: compactor.cc:80
Abstract base class for postlists.
Definition: postlist.h:37
typedefs for Xapian
Compiler attribute macros.
PositionIterator positionlist_end() const
Return an end PositionIterator for the current document.
bool operator!=(const ESetIterator &a, const ESetIterator &b)
Inequality test for ESetIterator objects.
Definition: eset.h:287
Xapian::doccount_diff difference_type
bool operator==(const ESetIterator &a, const ESetIterator &b)
Equality test for ESetIterator objects.
Definition: eset.h:277
Class for iterating over term positions.
#define XAPIAN_VISIBILITY_DEFAULT
Definition: visibility.h:28
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:72
Class for iterating over a list of terms.
XAPIAN_DOCID_BASE_TYPE doccount_diff
A signed difference between two counts of documents.
Definition: types.h:45
Define XAPIAN_VISIBILITY_* macros.
Xapian::docid & reference
PostingIterator()
Default constructor.
std::input_iterator_tag iterator_category
~PostingIterator()
Destructor.
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
Class for wrapping type returned by an input_iterator.
DerefWrapper_< Xapian::docid > operator++(int)
Advance the iterator to the next position (postfix version).
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Definition: types.h:52
#define XAPIAN_NOEXCEPT
Definition: attributes.h:39