include/xapian/termiterator.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,2006,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_TERMITERATOR_H
00025 #define XAPIAN_INCLUDED_TERMITERATOR_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 TermNameWrapper {
00043     private:
00044         std::string tname;
00045     public:
00046         explicit TermNameWrapper(const std::string & tname_) : tname(tname_) { }
00047         const std::string & operator*() const { return tname; }
00048 };
00049 
00052 class XAPIAN_VISIBILITY_DEFAULT TermIterator {
00053     public:
00054         class Internal;
00056         Xapian::Internal::RefCntPtr<Internal> internal;
00057 
00059         explicit TermIterator(Internal *internal_);
00060 
00062         TermIterator();
00063 
00065         ~TermIterator();
00066 
00070         TermIterator(const TermIterator &other);
00071 
00075         void operator=(const TermIterator &other);
00076 
00078         std::string operator *() const;
00079 
00080         TermIterator & operator++();
00081 
00082         TermNameWrapper operator++(int) {
00083             std::string tmp = **this;
00084             operator++();
00085             return TermNameWrapper(tmp);
00086         }
00087 
00091         void skip_to(const std::string & tname);
00092 
00098         Xapian::termcount get_wdf() const;
00099 
00104         Xapian::doccount get_termfreq() const;
00105 
00108         Xapian::termcount positionlist_count() const;
00109 
00113         PositionIterator positionlist_begin() const;
00114 
00118         PositionIterator positionlist_end() const {
00119             return PositionIterator(NULL);
00120         }
00121 
00123         std::string get_description() const;
00124 
00126 
00127         typedef std::input_iterator_tag iterator_category;
00128         typedef std::string value_type;
00129         typedef Xapian::termcount_diff difference_type;
00130         typedef std::string * pointer;
00131         typedef std::string & reference;
00133 };
00134 
00135 inline bool
00136 operator==(const TermIterator &a, const TermIterator &b)
00137 {
00138     return (a.internal.get() == b.internal.get());
00139 }
00140 
00141 inline bool
00142 operator!=(const TermIterator &a, const TermIterator &b)
00143 {
00144     return !(a == b);
00145 }
00146 
00147 }
00148 
00149 #endif /* XAPIAN_INCLUDED_TERMITERATOR_H */

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