xapian-core  1.4.27
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, 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_ITERATOR_H
23 #define XAPIAN_INCLUDED_ITERATOR_H
24 
25 /* These functions are not intended to be used from user C++ code - they are
26  * provided to make implementing language-idiomatic wrappers around Xapian's
27  * iterator classes easier in bindings for other languages.
28  *
29  * If you make use of this API, please let us know on xapian-devel so we can
30  * coordinate any incompatible changes which might be required in the future.
31  *
32  * Currently known users:
33  *
34  * * xapian-bindings:
35  * + Java
36  * + PHP
37  * * xapian-core:
38  * + examples/xapian-pos.cc
39  * * xapian-glib
40  */
41 
42 #include <xapian.h>
43 
44 namespace Xapian {
45 
47 inline bool iterator_valid(const Xapian::ESetIterator& it) {
48  return it.off_from_end != 0;
49 }
50 
52 inline bool iterator_valid(const Xapian::MSetIterator& it) {
53  return it.off_from_end != 0;
54 }
55 
58  it.off_from_end = it.eset.size();
59 }
60 
63  it.off_from_end = it.mset.size();
64 }
65 
68  return it.off_from_end == it.eset.size();
69 }
70 
73  return it.off_from_end == it.mset.size();
74 }
75 
77 inline bool iterator_valid(const Xapian::PositionIterator& it) {
78  return it.internal != NULL;
79 }
80 
82 inline bool iterator_valid(const Xapian::PostingIterator& it) {
83  return it.internal != NULL;
84 }
85 
87 inline bool iterator_valid(const Xapian::TermIterator& it) {
88  return it.internal != NULL;
89 }
90 
92 inline bool iterator_valid(const Xapian::ValueIterator& it) {
93  return it.internal != NULL;
94 }
95 
97 inline bool iterator_valid(const Xapian::Utf8Iterator& it) {
98  return it != Xapian::Utf8Iterator();
99 }
100 
101 }
102 
103 #endif // XAPIAN_INCLUDED_ITERATOR_H
The Xapian namespace contains public interfaces for the Xapian library.
Definition: compactor.cc:80
Xapian::doccount size() const
Return number of items in this MSet object.
Definition: omenquire.cc:318
Class for iterating over document values.
Definition: valueiterator.h:40
Xapian::MSet mset
Definition: mset.h:376
Class for iterating over a list of terms.
Definition: termiterator.h:41
Class for iterating over a list of terms.
Xapian::doccount size() const
Return number of items in this ESet object.
Iterator over a Xapian::MSet.
Definition: mset.h:368
Public interfaces for the Xapian library.
bool iterator_valid(const Xapian::ESetIterator &it)
Definition: iterator.h:47
Xapian::ESet eset
Definition: eset.h:168
Class for iterating over term positions.
Iterator over a Xapian::ESet.
Definition: eset.h:160
An iterator which returns Unicode character values from a UTF-8 encoded string.
Definition: unicode.h:38
Xapian::MSet::size_type off_from_end
Definition: mset.h:383
Xapian::ESet::size_type off_from_end
Definition: eset.h:175
void iterator_rewind(Xapian::ESetIterator &it)
Definition: iterator.h:57
bool iterator_rewound(Xapian::ESetIterator &it)
Definition: iterator.h:67