xapian-core  1.4.26
valueiterator.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_VALUEITERATOR_H
23 #define XAPIAN_INCLUDED_VALUEITERATOR_H
24 
25 #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
26 # error Never use <xapian/valueiterator.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 ValueIterator(Internal *internal_);
51 
53  ValueIterator(const ValueIterator & o);
54 
56  ValueIterator & operator=(const ValueIterator & o);
57 
58 #ifdef XAPIAN_MOVE_SEMANTICS
61  : internal(o.internal) {
62  o.internal = nullptr;
63  }
64 
66  ValueIterator & operator=(ValueIterator && 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(ValueIterator())
82  : internal() { }
83 
86  if (internal) decref();
87  }
88 
90  std::string operator*() const;
91 
93  ValueIterator & operator++();
94 
97  const std::string & value(**this);
98  operator++();
99  return DerefWrapper_<std::string>(value);
100  }
101 
107  Xapian::docid get_docid() const;
108 
115  Xapian::valueno get_valueno() const;
116 
135  void skip_to(Xapian::docid docid_or_slot);
136 
161 #ifndef check
162  bool check(Xapian::docid docid);
163 #else
164  // The AssertMacros.h header in the macOS SDK currently defines a check
165  // macro. Apple have deprecated check() in favour of __Check() and
166  // plan to remove check() in a "future release", but for now prevent
167  // expansion of check by adding parentheses in the method prototype:
168  // https://www.opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/AssertMacros.h
169  //
170  // We do this conditionally, as these parentheses trip up SWIG's
171  // parser:
172  // https://github.com/swig/swig/issues/45
173  bool (check)(Xapian::docid docid);
174 #endif
175 
177  std::string get_description() const;
178 
189  // @{
191  typedef std::input_iterator_tag iterator_category;
193  typedef std::string value_type;
197  typedef std::string * pointer;
199  typedef std::string & reference;
200  // @}
201 };
202 
203 bool
204 XAPIAN_NOTHROW(operator==(const ValueIterator &a, const ValueIterator &b));
205 
207 inline bool
209 {
210  // Use a pointer comparison - this ensures both that (a == a) and correct
211  // handling of end iterators (which we ensure have NULL internals).
212  return a.internal == b.internal;
213 }
214 
215 bool
216 XAPIAN_NOTHROW(operator!=(const ValueIterator &a, const ValueIterator &b));
217 
219 inline bool
221 {
222  return !(a == b);
223 }
224 
225 }
226 
227 #endif // XAPIAN_INCLUDED_VALUEITERATOR_H
The Xapian namespace contains public interfaces for the Xapian library.
Definition: compactor.cc:80
~ValueIterator()
Destructor.
Definition: valueiterator.h:85
typedefs for Xapian
DerefWrapper_< std::string > operator++(int)
Advance the iterator to the next position (postfix version).
Definition: valueiterator.h:96
Compiler attribute macros.
bool operator!=(const ESetIterator &a, const ESetIterator &b)
Inequality test for ESetIterator objects.
Definition: eset.h:287
Class for iterating over document values.
Definition: valueiterator.h:40
std::string & reference
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::doccount_diff difference_type
XAPIAN_DOCID_BASE_TYPE doccount_diff
A signed difference between two counts of documents.
Definition: types.h:45
Define XAPIAN_VISIBILITY_* macros.
std::input_iterator_tag iterator_category
std::string * pointer
ValueIterator()
Default constructor.
Definition: valueiterator.h:81
Abstract base class for value streams.
Definition: valuelist.h:31
const Query operator*(double factor, const Query &q)
Scale a Xapian::Query object using OP_SCALE_WEIGHT.
Definition: query.h:670
unsigned valueno
The number for a value slot in a document.
Definition: types.h:108
Class for wrapping type returned by an input_iterator.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Definition: types.h:52
#define XAPIAN_NOEXCEPT
Definition: attributes.h:39