include/xapian/postingiterator.h

Go to the documentation of this file.
00001 
00004 /* Copyright 1999,2000,2001 BrightStation PLC
00005  * Copyright 2002 Ananova Ltd
00006  * Copyright 2003,2004,2005,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 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/types.h>
00032 #include <xapian/positioniterator.h>
00033 #include <xapian/visibility.h>
00034 
00035 namespace Xapian {
00036 
00037 class Database;
00038 
00042 class DocIDWrapper {
00043     private:
00044         docid did;
00045     public:
00046         explicit DocIDWrapper(docid did_) : did(did_) { }
00047         docid operator*() const { return did; }
00048 };
00049 
00052 class XAPIAN_VISIBILITY_DEFAULT PostingIterator {
00053     public:
00054         class Internal;
00056         Xapian::Internal::RefCntPtr<Internal> internal;
00057 
00058     private:
00059         friend class Database; // So Database can construct us
00060 
00061         explicit PostingIterator(Internal *internal_);
00062 
00063     public:
00064         friend bool operator==(const PostingIterator &a,
00065                                const PostingIterator &b);
00066 
00068         PostingIterator();
00069 
00071         ~PostingIterator();
00072 
00076         PostingIterator(const PostingIterator &other);
00077 
00081         void operator=(const PostingIterator &other);
00082 
00083         PostingIterator & operator++();
00084 
00085         DocIDWrapper operator++(int) {
00086             Xapian::docid tmp = **this;
00087             operator++();
00088             return DocIDWrapper(tmp);
00089         }
00090 
00094         void skip_to(Xapian::docid did);
00095 
00096 // Get the weight of the posting at the current position: will
00097 // need to set a weight object for this to work.
00098 // Xapian::weight get_weight() const;
00099 
00101         Xapian::docid operator *() const;
00102 
00112         Xapian::doclength get_doclength() const;
00113 
00117         Xapian::termcount get_wdf() const;
00118 
00122         PositionIterator positionlist_begin() const;
00123 
00127         PositionIterator positionlist_end() const {
00128             return PositionIterator(NULL);
00129         }
00130 
00131         // Don't expose these methods here.  A container iterator doesn't
00132         // provide a method to find the size of the container...
00133         // Xapian::doccount get_termfreq() const;
00134         // Xapian::termcount get_collection_freq() const;
00135 
00137         std::string get_description() const;
00138 
00140 
00141         typedef std::input_iterator_tag iterator_category;
00142         typedef Xapian::docid value_type;
00143         typedef Xapian::doccount_diff difference_type;
00144         typedef Xapian::docid * pointer;
00145         typedef Xapian::docid & reference;
00147 };
00148 
00150 inline bool operator==(const PostingIterator &a, const PostingIterator &b)
00151 {
00152     return (a.internal.get() == b.internal.get());
00153 }
00154 
00156 inline bool operator!=(const PostingIterator &a, const PostingIterator &b)
00157 {
00158     return !(a == b);
00159 }
00160 
00161 }
00162 
00163 #endif /* XAPIAN_INCLUDED_POSTINGITERATOR_H */

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