include/xapian/valueiterator.h

Go to the documentation of this file.
00001 
00004 /* Copyright (C) 2008,2009 Olly Betts
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License as
00008  * published by the Free Software Foundation; either version 2 of the
00009  * License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00019  * USA
00020  */
00021 
00022 #ifndef XAPIAN_INCLUDED_VALUEITERATOR_H
00023 #define XAPIAN_INCLUDED_VALUEITERATOR_H
00024 
00025 #include <iterator>
00026 #include <string>
00027 
00028 #include <xapian/base.h>
00029 #include <xapian/derefwrapper.h>
00030 #include <xapian/types.h>
00031 #include <xapian/visibility.h>
00032 
00033 namespace Xapian {
00034 
00036 class ValueIteratorEnd_ { };
00037 
00039 class XAPIAN_VISIBILITY_DEFAULT ValueIterator {
00040   public:
00042     class Internal;
00044     Xapian::Internal::RefCntPtr<Internal> internal;
00045 
00047     explicit ValueIterator(Internal *internal_);
00048 
00050     ValueIterator(const ValueIterator & o);
00051 
00053     ValueIterator(const ValueIteratorEnd_ &);
00054 
00056     ValueIterator & operator=(const ValueIterator & o);
00057 
00059     ValueIterator & operator=(const ValueIteratorEnd_ &);
00060 
00066     ValueIterator();
00067 
00069     ~ValueIterator();
00070 
00072     std::string operator*() const;
00073 
00075     ValueIterator & operator++();
00076 
00078     DerefStringWrapper_ operator++(int) {
00079         std::string value(**this);
00080         operator++();
00081         return DerefStringWrapper_(value);
00082     }
00083 
00089     Xapian::docid get_docid() const;
00090 
00097     Xapian::valueno get_valueno() const;
00098 
00115     void skip_to(Xapian::docid docid_or_slot);
00116 
00139     bool check(Xapian::docid docid);
00140 
00142     std::string get_description() const;
00143 
00154     // @{
00156     typedef std::input_iterator_tag iterator_category;
00158     typedef std::string value_type;
00160     typedef Xapian::doccount_diff difference_type;
00162     typedef std::string * pointer;
00164     typedef std::string & reference;
00165     // @}
00166 };
00167 
00168 inline bool
00169 operator==(const ValueIterator &a, const ValueIterator &b)
00170 {
00171     // Use a pointer comparison - this ensures both that (a == a) and correct
00172     // handling of end iterators (which we ensure have NULL internals).
00173     return a.internal.get() == b.internal.get();
00174 }
00175 
00176 inline bool
00177 operator==(const ValueIterator &a, const ValueIteratorEnd_ &)
00178 {
00179     return a.internal.get() == NULL;
00180 }
00181 
00182 inline bool
00183 operator==(const ValueIteratorEnd_ &a, const ValueIterator &b)
00184 {
00185     return b == a;
00186 }
00187 
00188 inline bool
00189 operator==(const ValueIteratorEnd_ &, const ValueIteratorEnd_ &)
00190 {
00191     return true;
00192 }
00193 
00194 inline bool
00195 operator!=(const ValueIterator &a, const ValueIterator &b)
00196 {
00197     return !(a == b);
00198 }
00199 
00200 inline bool
00201 operator!=(const ValueIterator &a, const ValueIteratorEnd_ &b)
00202 {
00203     return !(a == b);
00204 }
00205 
00206 inline bool
00207 operator!=(const ValueIteratorEnd_ &a, const ValueIterator &b)
00208 {
00209     return !(a == b);
00210 }
00211 
00212 inline bool
00213 operator!=(const ValueIteratorEnd_ &a, const ValueIteratorEnd_ &b)
00214 {
00215     return !(a == b);
00216 }
00217 
00218 }
00219 
00220 #endif // XAPIAN_INCLUDED_VALUEITERATOR_H

Documentation for Xapian (version 1.1.2).
Generated on 23 Jul 2009 by Doxygen 1.5.2.