- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# 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
    00095         Xapian::termcount get_wdf() const;
    00096
    00099         Xapian::doccount get_termfreq() const;
    00100
    00103         Xapian::termcount positionlist_count() const;
    00104
    00108         PositionIterator positionlist_begin() const;
    00109
    00113         PositionIterator positionlist_end() const {
    00114             return PositionIterator(NULL);
    00115         }
    00116
    00120         std::string get_description() const;
    00121
    00123
    00124         typedef std::input_iterator_tag iterator_category;
    00125         typedef std::string value_type;
    00126         typedef Xapian::termcount_diff difference_type;
    00127         typedef std::string * pointer;
    00128         typedef std::string & reference;
    00130 };
    00131
    00132 inline bool
    00133 operator==(const TermIterator &a, const TermIterator &b)
    00134 {
    00135     return (a.internal.get() == b.internal.get());
    00136 }
    00137
    00138 inline bool
    00139 operator!=(const TermIterator &a, const TermIterator &b)
    00140 {
    00141     return !(a == b);
    00142 }
    00143
    00144 }
    00145
    00146 #endif /* XAPIAN_INCLUDED_TERMITERATOR_H */