# include/xapian/valueiterator.h

Go to the documentation of this file.

    00001
    00004 /* ----START-LICENCE----
    00005  * Copyright 1999,2000,2001 BrightStation PLC
    00006  * Copyright 2002 Ananova Ltd
    00007  * Copyright 2002,2003,2004 Olly Betts
    00008  *
    00009  * This program is free software; you can redistribute it and/or
    00010  * modify it under the terms of the GNU General Public License as
    00011  * published by the Free Software Foundation; either version 2 of the
    00012  * License, or (at your option) any later version.
    00013  *
    00014  * This program is distributed in the hope that it will be useful,
    00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00017  * GNU General Public License for more details.
    00018  *
    00019  * You should have received a copy of the GNU General Public License
    00020  * along with this program; if not, write to the Free Software
    00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
    00022  * USA
    00023  * -----END-LICENCE-----
    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 /* OM_HGUARD_OMVALUEITERATOR_H */