00001 00004 /* ----START-LICENCE---- 00005 * Copyright 1999,2000,2001 BrightStation PLC 00006 * Copyright 2002 Ananova Ltd 00007 * Copyright 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 XAPIAN_INCLUDED_POSTINGITERATOR_H 00027 #define XAPIAN_INCLUDED_POSTINGITERATOR_H 00028 00029 #include <iterator> 00030 #include <string> 00031 00032 #include <xapian/base.h> 00033 #include <xapian/types.h> 00034 00035 namespace Xapian { 00036 00037 class Database; 00038 class PositionIterator; 00039 00042 class 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 void operator++(int); 00076 00077 // extra method, not required for an input_iterator 00078 void skip_to(Xapian::docid did); 00079 00080 // Get the weight of the posting at the current position: will 00081 // need to set a weight object for this to work. 00082 // Xapian::weight get_weight() const; 00083 00085 Xapian::docid operator *() const; 00086 00096 Xapian::doclength get_doclength() const; 00097 00101 Xapian::termcount get_wdf() const; 00102 00103 // allow iteration of positionlist for current term 00104 PositionIterator positionlist_begin(); 00105 PositionIterator positionlist_end(); 00106 00107 // Don't expose these methods here. A container iterator doesn't 00108 // provide a method to find the size of the container... 00109 // Xapian::doccount get_termfreq() const; 00110 // Xapian::termcount get_collection_freq() const; 00111 00115 std::string get_description() const; 00116 00118 00119 typedef std::input_iterator_tag iterator_category; 00120 typedef Xapian::docid value_type; 00121 typedef Xapian::doccount_diff difference_type; 00122 typedef Xapian::docid * pointer; 00123 typedef Xapian::docid & reference; 00125 }; 00126 00128 inline bool operator==(const PostingIterator &a, const PostingIterator &b) 00129 { 00130 return (a.internal.get() == b.internal.get()); 00131 } 00132 00134 inline bool operator!=(const PostingIterator &a, const PostingIterator &b) 00135 { 00136 return !(a == b); 00137 } 00138 00139 } 00140 00141 #endif /* XAPIAN_INCLUDED_POSTINGITERATOR_H */