xapian-core  2.0.0
iterator.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2014,2016,2017,2019 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, see
18  * <https://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef XAPIAN_INCLUDED_ITERATOR_H
22 #define XAPIAN_INCLUDED_ITERATOR_H
23 
24 /* These functions are not intended to be used from user C++ code - they are
25  * provided to make implementing language-idiomatic wrappers around Xapian's
26  * iterator classes easier in bindings for other languages.
27  *
28  * If you make use of this API, please let us know on xapian-devel so we can
29  * coordinate any incompatible changes which might be required in the future.
30  *
31  * Currently known users:
32  *
33  * * xapian-bindings:
34  * + Java
35  * + PHP
36  * * xapian-core:
37  * + examples/xapian-pos.cc
38  * * xapian-glib
39  */
40 
41 #include <xapian.h>
42 
43 namespace Xapian {
44 
46 inline bool iterator_valid(const Xapian::ESetIterator& it) {
47  return it.off_from_end != 0;
48 }
49 
51 inline bool iterator_valid(const Xapian::MSetIterator& it) {
52  return it.off_from_end != 0;
53 }
54 
57  it.off_from_end = it.eset.size();
58 }
59 
62  it.off_from_end = it.mset.size();
63 }
64 
67  return it.off_from_end == it.eset.size();
68 }
69 
72  return it.off_from_end == it.mset.size();
73 }
74 
76 inline bool iterator_valid(const Xapian::PositionIterator& it) {
77  return it.internal != NULL;
78 }
79 
81 inline bool iterator_valid(const Xapian::PostingIterator& it) {
82  return it.internal != NULL;
83 }
84 
86 inline bool iterator_valid(const Xapian::TermIterator& it) {
87  return it.internal != NULL;
88 }
89 
91 inline bool iterator_valid(const Xapian::ValueIterator& it) {
92  return it.internal != NULL;
93 }
94 
96 inline bool iterator_valid(const Xapian::Utf8Iterator& it) {
97  return it != Xapian::Utf8Iterator();
98 }
99 
100 }
101 
102 #endif // XAPIAN_INCLUDED_ITERATOR_H
Iterator over a Xapian::ESet.
Definition: eset.h:157
Xapian::ESet eset
Definition: eset.h:165
Xapian::ESet::size_type off_from_end
Definition: eset.h:172
Xapian::termcount size() const
Return number of items in this ESet object.
Iterator over a Xapian::MSet.
Definition: mset.h:535
Xapian::MSet::size_type off_from_end
Definition: mset.h:550
Xapian::MSet mset
Definition: mset.h:543
Xapian::doccount size() const
Return number of items in this MSet object.
Definition: mset.cc:374
Class for iterating over term positions.
Class for iterating over a list of terms.
Class for iterating over a list of terms.
Definition: termiterator.h:41
An iterator which returns Unicode character values from a UTF-8 encoded string.
Definition: unicode.h:39
Class for iterating over document values.
Definition: valueiterator.h:39
The Xapian namespace contains public interfaces for the Xapian library.
Definition: compactor.cc:82
bool iterator_rewound(Xapian::ESetIterator &it)
Definition: iterator.h:66
bool iterator_valid(const Xapian::ESetIterator &it)
Definition: iterator.h:46
void iterator_rewind(Xapian::ESetIterator &it)
Definition: iterator.h:56
Public interfaces for the Xapian library.