00001 00004 /* Copyright 1999,2000,2001 BrightStation PLC 00005 * Copyright 2002 Ananova Ltd 00006 * Copyright 2003,2004,2005,2007,2008,2009 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 XAPIAN_INCLUDED_POSTINGITERATOR_H 00025 #define XAPIAN_INCLUDED_POSTINGITERATOR_H 00026 00027 #include <iterator> 00028 #include <string> 00029 00030 #include <xapian/base.h> 00031 #include <xapian/derefwrapper.h> 00032 #include <xapian/types.h> 00033 #include <xapian/positioniterator.h> 00034 #include <xapian/visibility.h> 00035 00036 namespace Xapian { 00037 00038 class Database; 00039 00042 class XAPIAN_VISIBILITY_DEFAULT PostingIterator { 00043 public: 00044 class Internal; 00046 Xapian::Internal::RefCntPtr<Internal> internal; 00047 00048 private: 00049 friend class Database; // So Database can construct us 00050 00051 explicit PostingIterator(Internal *internal_); 00052 00053 public: 00054 friend bool operator==(const PostingIterator &a, 00055 const PostingIterator &b); 00056 00058 PostingIterator(); 00059 00061 ~PostingIterator(); 00062 00066 PostingIterator(const PostingIterator &other); 00067 00071 void operator=(const PostingIterator &other); 00072 00073 PostingIterator & operator++(); 00074 00075 DerefWrapper_<docid> operator++(int) { 00076 Xapian::docid tmp = **this; 00077 operator++(); 00078 return DerefWrapper_<docid>(tmp); 00079 } 00080 00087 void skip_to(Xapian::docid did); 00088 00090 Xapian::docid operator *() const; 00091 00101 Xapian::termcount get_doclength() const; 00102 00106 Xapian::termcount get_wdf() const; 00107 00111 PositionIterator positionlist_begin() const; 00112 00116 PositionIterator positionlist_end() const { 00117 return PositionIterator(); 00118 } 00119 00120 // Don't expose these methods here. A container iterator doesn't 00121 // provide a method to find the size of the container... 00122 // Xapian::doccount get_termfreq() const; 00123 // Xapian::termcount get_collection_freq() const; 00124 00126 std::string get_description() const; 00127 00129 00130 typedef std::input_iterator_tag iterator_category; 00131 typedef Xapian::docid value_type; 00132 typedef Xapian::doccount_diff difference_type; 00133 typedef Xapian::docid * pointer; 00134 typedef Xapian::docid & reference; 00136 }; 00137 00139 inline bool operator==(const PostingIterator &a, const PostingIterator &b) 00140 { 00141 return (a.internal.get() == b.internal.get()); 00142 } 00143 00145 inline bool operator!=(const PostingIterator &a, const PostingIterator &b) 00146 { 00147 return !(a == b); 00148 } 00149 00150 } 00151 00152 #endif /* XAPIAN_INCLUDED_POSTINGITERATOR_H */