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_POSITIONITERATOR_H
00025 #define XAPIAN_INCLUDED_POSITIONITERATOR_H
00026
00027 #include <iterator>
00028 #include <string>
00029
00030 #include <xapian/base.h>
00031 #include <xapian/types.h>
00032 #include <xapian/visibility.h>
00033
00034 namespace Xapian {
00035
00036 class Database;
00037 class PostingIterator;
00038 class TermIterator;
00039
00043 class TermPosWrapper {
00044 private:
00045 termpos pos;
00046 public:
00047 explicit TermPosWrapper(termpos pos_) : pos(pos_) { }
00048 termpos operator*() const { return pos; }
00049 };
00050
00053 class XAPIAN_VISIBILITY_DEFAULT PositionIterator {
00054 private:
00055
00056 friend class PostingIterator;
00057 friend class TermIterator;
00058 friend class Database;
00059
00060 public:
00061 class Internal;
00063 Xapian::Internal::RefCntPtr<Internal> internal;
00064
00065 friend bool operator==(const PositionIterator &a, const PositionIterator &b);
00066
00067
00068 explicit PositionIterator(Internal *internal_);
00069
00071 PositionIterator();
00072
00074 ~PositionIterator();
00075
00079 PositionIterator(const PositionIterator &o);
00080
00084 void operator=(const PositionIterator &o);
00085
00086 Xapian::termpos operator *() const;
00087
00088 PositionIterator & operator++();
00089
00090 TermPosWrapper operator++(int) {
00091 Xapian::termpos tmp = **this;
00092 operator++();
00093 return TermPosWrapper(tmp);
00094 }
00095
00096
00097 void skip_to(Xapian::termpos pos);
00098
00100 std::string get_description() const;
00101
00102
00103 typedef std::input_iterator_tag iterator_category;
00104 typedef Xapian::termpos value_type;
00105 typedef Xapian::termpos_diff difference_type;
00106 typedef Xapian::termpos * pointer;
00107 typedef Xapian::termpos & reference;
00108 };
00109
00111 inline bool
00112 operator==(const PositionIterator &a, const PositionIterator &b)
00113 {
00114 return (a.internal.get() == b.internal.get());
00115 }
00116
00118 inline bool
00119 operator!=(const PositionIterator &a, const PositionIterator &b)
00120 {
00121 return !(a == b);
00122 }
00123
00124 }
00125
00126 #endif