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 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 
00034 namespace Xapian {
00035 
00036 class Database;
00037 
00041 class TermNameWrapper {
00042     private:
00043         std::string tname;
00044     public:
00045         TermNameWrapper(const std::string & tname_) : tname(tname_) { }
00046         const std::string & operator*() const { return tname; }
00047 };
00048 
00051 class TermIterator {
00052     public:
00053         class Internal;
00055         Xapian::Internal::RefCntPtr<Internal> internal;
00056 
00058         explicit TermIterator(Internal *internal_);
00059 
00061         TermIterator();
00062 
00064         ~TermIterator();
00065 
00069         TermIterator(const TermIterator &other);
00070 
00074         void operator=(const TermIterator &other);
00075 
00077         std::string operator *() const;
00078 
00079         TermIterator & operator++();
00080 
00081         TermNameWrapper operator++(int) {
00082             std::string tmp = **this;
00083             operator++();
00084             return TermNameWrapper(tmp);
00085         }
00086 
00090         void skip_to(const std::string & tname);
00091 
00094         Xapian::termcount get_wdf() const;
00095 
00098         Xapian::doccount get_termfreq() const;
00099 
00102         Xapian::termcount positionlist_count() const;
00103 
00107         PositionIterator positionlist_begin() const;
00108 
00112         PositionIterator positionlist_end() const {
00113             return PositionIterator(NULL);
00114         }
00115 
00119         std::string get_description() const;
00120 
00122 
00123         typedef std::input_iterator_tag iterator_category;
00124         typedef std::string value_type;
00125         typedef Xapian::termcount_diff difference_type;
00126         typedef std::string * pointer;
00127         typedef std::string & reference;
00129 };
00130 
00131 inline bool
00132 operator==(const TermIterator &a, const TermIterator &b)
00133 {
00134     return (a.internal.get() == b.internal.get());
00135 }
00136 
00137 inline bool
00138 operator!=(const TermIterator &a, const TermIterator &b)
00139 {
00140     return !(a == b);
00141 }
00142 
00143 }
00144 
00145 #endif /* XAPIAN_INCLUDED_TERMITERATOR_H */

Documentation for Xapian (version 0.9.9).
Generated on 9 Nov 2006 by Doxygen 1.4.6.