include/xapian/valueiterator.h

Go to the documentation of this file.
00001 
00004 /* Copyright 1999,2000,2001 BrightStation PLC
00005  * Copyright 2002 Ananova Ltd
00006  * Copyright 2002,2003,2004,2007 Olly Betts
00007  *
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU General Public License as
00010  * published by the Free Software Foundation; either version 2 of the
00011  * License, or (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00021  * USA
00022  */
00023 
00024 #ifndef OM_HGUARD_OMVALUEITERATOR_H
00025 #define OM_HGUARD_OMVALUEITERATOR_H
00026 
00027 #include <iterator>
00028 #include <string>
00029 #include <xapian/types.h>
00030 #include <xapian/document.h>
00031 #include <xapian/visibility.h>
00032 
00033 namespace Xapian {
00034 
00037 class XAPIAN_VISIBILITY_DEFAULT ValueIterator {
00038     private:
00039         friend class Document;
00040         friend bool operator==(const ValueIterator &a, const ValueIterator &b);
00041         friend bool operator!=(const ValueIterator &a, const ValueIterator &b);
00042 
00043         ValueIterator(Xapian::valueno index_, const Document & doc_)
00044             : index(index_), doc(doc_) { }
00045 
00046         Xapian::valueno index;
00047         Document doc;
00048 
00049     public:
00053         ValueIterator() : index(0), doc() { }
00054 
00055         ~ValueIterator() { }
00056 
00058         ValueIterator(const ValueIterator &other) {
00059             index = other.index;
00060             doc = other.doc;
00061         }
00062 
00064         void operator=(const ValueIterator &other) {
00065             index = other.index;
00066             doc = other.doc;
00067         }
00068 
00070         ValueIterator & operator++() {
00071             ++index;
00072             return *this;
00073         }
00074 
00076         ValueIterator operator++(int) {
00077             ValueIterator tmp = *this;
00078             ++index;
00079             return tmp;
00080         }
00081 
00083         const std::string & operator*() const;
00084 
00086         const std::string * operator->() const;
00087 
00089         Xapian::valueno get_valueno() const;
00090 
00092         std::string get_description() const;
00093 
00095 
00096         typedef std::input_iterator_tag iterator_category;
00097         typedef std::string value_type;
00098         typedef Xapian::valueno_diff difference_type;
00099         typedef std::string * pointer;
00100         typedef std::string & reference;
00102 };
00103 
00104 inline bool operator==(const ValueIterator &a, const ValueIterator &b)
00105 {
00106     return (a.index == b.index);
00107 }
00108 
00109 inline bool operator!=(const ValueIterator &a, const ValueIterator &b)
00110 {
00111     return (a.index != b.index);
00112 }
00113 
00114 }
00115 
00116 #endif /* OM_HGUARD_OMVALUEITERATOR_H */

Documentation for Xapian (version 1.0.10).
Generated on 23 Dec 2008 by Doxygen 1.5.2.