00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef OM_HGUARD_OMVALUEITERATOR_H
00027 #define OM_HGUARD_OMVALUEITERATOR_H
00028
00029 #include <iterator>
00030 #include <string>
00031 #include <xapian/types.h>
00032 #include <xapian/document.h>
00033
00034 namespace Xapian {
00035
00038 class ValueIterator {
00039 private:
00040 friend class Document;
00041 friend bool operator==(const ValueIterator &a, const ValueIterator &b);
00042 friend bool operator!=(const ValueIterator &a, const ValueIterator &b);
00043
00044 ValueIterator(Xapian::valueno index_, const Document & doc_)
00045 : index(index_), doc(doc_) { }
00046
00047 Xapian::valueno index;
00048 Document doc;
00049
00050 public:
00054 ValueIterator() : index(0), doc() { }
00055
00056 ~ValueIterator() { }
00057
00059 ValueIterator(const ValueIterator &other) {
00060 index = other.index;
00061 doc = other.doc;
00062 }
00063
00065 void operator=(const ValueIterator &other) {
00066 index = other.index;
00067 doc = other.doc;
00068 }
00069
00071 ValueIterator & operator++() {
00072 ++index;
00073 return *this;
00074 }
00075
00077 ValueIterator operator++(int) {
00078 ValueIterator tmp = *this;
00079 ++index;
00080 return tmp;
00081 }
00082
00084 const std::string & operator*() const;
00085
00087 const std::string * operator->() const;
00088
00090 Xapian::valueno get_valueno() const;
00091
00095 std::string get_description() const;
00096
00098
00099 typedef std::input_iterator_tag iterator_category;
00100 typedef std::string value_type;
00101 typedef Xapian::valueno_diff difference_type;
00102 typedef std::string * pointer;
00103 typedef std::string & reference;
00105 };
00106
00107 inline bool operator==(const ValueIterator &a, const ValueIterator &b)
00108 {
00109 return (a.index == b.index);
00110 }
00111
00112 inline bool operator!=(const ValueIterator &a, const ValueIterator &b)
00113 {
00114 return (a.index != b.index);
00115 }
00116
00117 }
00118
00119 #endif