00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef XAPIAN_INCLUDED_POSTINGITERATOR_H
00025 #define XAPIAN_INCLUDED_POSTINGITERATOR_H
00026
00027 #include <iterator>
00028 #include <string>
00029
00030 #include <xapian/base.h>
00031 #include <xapian/types.h>
00032 #include <xapian/positioniterator.h>
00033 #include <xapian/visibility.h>
00034
00035 namespace Xapian {
00036
00037 class Database;
00038
00042 class DocIDWrapper {
00043 private:
00044 docid did;
00045 public:
00046 explicit DocIDWrapper(docid did_) : did(did_) { }
00047 docid operator*() const { return did; }
00048 };
00049
00052 class XAPIAN_VISIBILITY_DEFAULT PostingIterator {
00053 public:
00054 class Internal;
00056 Xapian::Internal::RefCntPtr<Internal> internal;
00057
00058 private:
00059 friend class Database;
00060
00061 explicit PostingIterator(Internal *internal_);
00062
00063 public:
00064 friend bool operator==(const PostingIterator &a,
00065 const PostingIterator &b);
00066
00068 PostingIterator();
00069
00071 ~PostingIterator();
00072
00076 PostingIterator(const PostingIterator &other);
00077
00081 void operator=(const PostingIterator &other);
00082
00083 PostingIterator & operator++();
00084
00085 DocIDWrapper operator++(int) {
00086 Xapian::docid tmp = **this;
00087 operator++();
00088 return DocIDWrapper(tmp);
00089 }
00090
00094 void skip_to(Xapian::docid did);
00095
00096
00097
00098
00099
00101 Xapian::docid operator *() const;
00102
00112 Xapian::doclength get_doclength() const;
00113
00117 Xapian::termcount get_wdf() const;
00118
00122 PositionIterator positionlist_begin() const;
00123
00127 PositionIterator positionlist_end() const {
00128 return PositionIterator(NULL);
00129 }
00130
00131
00132
00133
00134
00135
00137 std::string get_description() const;
00138
00140
00141 typedef std::input_iterator_tag iterator_category;
00142 typedef Xapian::docid value_type;
00143 typedef Xapian::doccount_diff difference_type;
00144 typedef Xapian::docid * pointer;
00145 typedef Xapian::docid & reference;
00147 };
00148
00150 inline bool operator==(const PostingIterator &a, const PostingIterator &b)
00151 {
00152 return (a.internal.get() == b.internal.get());
00153 }
00154
00156 inline bool operator!=(const PostingIterator &a, const PostingIterator &b)
00157 {
00158 return !(a == b);
00159 }
00160
00161 }
00162
00163 #endif