Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

/include/xapian/positioniterator.h

Go to the documentation of this file.
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_POSITIONITERATOR_H
00027 #define XAPIAN_INCLUDED_POSITIONITERATOR_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 PostingIterator;
00039 class TermIterator;
00040 
00043 class PositionIterator {
00044     private:
00045         // friend classes which need to be able to construct us
00046         friend class PostingIterator;
00047         friend class TermIterator;
00048         friend class Database;
00049 
00050     public:
00051         class Internal;
00053         Xapian::Internal::RefCntPtr<Internal> internal;
00054 
00055         friend bool operator==(const PositionIterator &a, const PositionIterator &b);
00056 
00057         // FIXME: ought to be private
00058         explicit PositionIterator(Internal *internal_);
00059 
00061         PositionIterator();
00062 
00064         ~PositionIterator();
00065 
00069         PositionIterator(const PositionIterator &o);
00070 
00074         void operator=(const PositionIterator &o);
00075 
00076         Xapian::termpos operator *() const;
00077 
00078         PositionIterator & operator++();
00079 
00080         void operator++(int);
00081 
00082         // extra method, not required for an input_iterator
00083         void skip_to(Xapian::termpos pos);
00084 
00088         std::string get_description() const;
00089 
00090         // Allow use as an STL iterator
00091         typedef std::input_iterator_tag iterator_category;
00092         typedef Xapian::termpos value_type;
00093         typedef Xapian::termpos_diff difference_type;  // "om_termposcount"
00094         typedef Xapian::termpos * pointer;
00095         typedef Xapian::termpos & reference;
00096 };
00097 
00099 inline bool
00100 operator==(const PositionIterator &a, const PositionIterator &b)
00101 {
00102     return (a.internal.get() == b.internal.get());
00103 }
00104 
00106 inline bool
00107 operator!=(const PositionIterator &a, const PositionIterator &b)
00108 {
00109     return !(a == b);
00110 }
00111 
00112 }
00113 
00114 #endif /* XAPIAN_INCLUDED_POSITIONITERATOR_H */

Documentation for Xapian (version 0.8.0).
Generated on 20 Apr 2004 by Doxygen 1.2.15.