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,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/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 
00097         Xapian::docid operator *() const;
00098 
00108         Xapian::termcount get_doclength() const;
00109 
00113         Xapian::termcount get_wdf() const;
00114 
00118         PositionIterator positionlist_begin() const;
00119 
00123         PositionIterator positionlist_end() const {
00124             return PositionIterator(NULL);
00125         }
00126 
00127         // Don't expose these methods here.  A container iterator doesn't
00128         // provide a method to find the size of the container...
00129         // Xapian::doccount get_termfreq() const;
00130         // Xapian::termcount get_collection_freq() const;
00131 
00133         std::string get_description() const;
00134 
00136 
00137         typedef std::input_iterator_tag iterator_category;
00138         typedef Xapian::docid value_type;
00139         typedef Xapian::doccount_diff difference_type;
00140         typedef Xapian::docid * pointer;
00141         typedef Xapian::docid & reference;
00143 };
00144 
00146 inline bool operator==(const PostingIterator &a, const PostingIterator &b)
00147 {
00148     return (a.internal.get() == b.internal.get());
00149 }
00150 
00152 inline bool operator!=(const PostingIterator &a, const PostingIterator &b)
00153 {
00154     return !(a == b);
00155 }
00156 
00157 }
00158 
00159 #endif /* XAPIAN_INCLUDED_POSTINGITERATOR_H */

Documentation for Xapian (version 1.1.1).
Generated on 10 Jun 2009 by Doxygen 1.5.2.