include/xapian/valueiterator.h

Go to the documentation of this file.
00001 
00004 /* Copyright (C) 2008 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 XAPIAN_VISIBILITY_DEFAULT ValueIterator {
00037   public:
00039     class Internal;
00041     Xapian::Internal::RefCntPtr<Internal> internal;
00042 
00044     explicit ValueIterator(Internal *internal_);
00045 
00047     ValueIterator(const ValueIterator & o);
00048 
00050     ValueIterator & operator=(const ValueIterator & o);
00051 
00057     ValueIterator();
00058 
00060     ~ValueIterator();
00061 
00063     std::string operator*() const;
00064 
00066     ValueIterator & operator++();
00067 
00069     DerefStringWrapper_ operator++(int) {
00070         std::string value(**this);
00071         operator++();
00072         return DerefStringWrapper_(value);
00073     }
00074 
00080     Xapian::docid get_docid() const;
00081 
00088     Xapian::valueno get_valueno() const;
00089 
00106     void skip_to(Xapian::docid docid_or_slot);
00107 
00130     bool check(Xapian::docid docid);
00131 
00133     std::string get_description() const;
00134 
00145     // @{
00147     typedef std::input_iterator_tag iterator_category;
00149     typedef std::string value_type;
00151     typedef Xapian::doccount_diff difference_type;
00153     typedef std::string * pointer;
00155     typedef std::string & reference;
00156     // @}
00157 };
00158 
00159 inline bool
00160 operator==(const ValueIterator &a, const ValueIterator &b)
00161 {
00162     // Use a pointer comparison - this ensures both that (a == a) and correct
00163     // handling of end iterators (which we ensure have NULL internals).
00164     return a.internal.get() == b.internal.get();
00165 }
00166 
00167 inline bool
00168 operator!=(const ValueIterator &a, const ValueIterator &b)
00169 {
00170     return !(a == b);
00171 }
00172 
00173 }
00174 
00175 #endif // XAPIAN_INCLUDED_VALUEITERATOR_H

Documentation for Xapian (version 1.1.0).
Generated on 22 Apr 2009 by Doxygen 1.5.2.