00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <config.h>
00023 #include <xapian/termiterator.h>
00024 #include "termlist.h"
00025 #include "positionlist.h"
00026 #include "omassert.h"
00027 #include "omdebug.h"
00028
00029 using namespace std;
00030
00031
00032 inline void
00033 handle_prune(Xapian::Internal::RefCntPtr<TermList>& old, TermList * result)
00034 {
00035 if (result) {
00036 old = result;
00037 }
00038 }
00039
00040 Xapian::TermIterator::TermIterator(Internal *internal_)
00041 : internal(internal_)
00042 {
00043 if (internal.get()) {
00044
00045 handle_prune(internal, internal->next());
00046 if (internal->at_end()) internal = 0;
00047 }
00048 }
00049
00050 Xapian::TermIterator::TermIterator() : internal(0)
00051 {
00052 DEBUGAPICALL(void, "Xapian::TermIterator::TermIterator", "");
00053 }
00054
00055 Xapian::TermIterator::~TermIterator() {
00056 DEBUGAPICALL(void, "Xapian::TermIterator::~TermIterator", "");
00057 }
00058
00059 Xapian::TermIterator::TermIterator(const Xapian::TermIterator &other)
00060 : internal(other.internal)
00061 {
00062 DEBUGAPICALL(void, "Xapian::TermIterator::TermIterator", other);
00063 }
00064
00065 void
00066 Xapian::TermIterator::operator=(const Xapian::TermIterator &other)
00067 {
00068 DEBUGAPICALL(void, "Xapian::TermIterator::operator=", other);
00069 internal = other.internal;
00070 }
00071
00072 string
00073 Xapian::TermIterator::operator *() const
00074 {
00075 DEBUGAPICALL(string, "Xapian::TermIterator::operator*", "");
00076 Assert(internal.get());
00077 Assert(!internal->at_end());
00078 RETURN(internal->get_termname());
00079 }
00080
00081 Xapian::termcount
00082 Xapian::TermIterator::get_wdf() const
00083 {
00084 DEBUGAPICALL(Xapian::termcount, "Xapian::TermIterator::get_wdf", "");
00085 Assert(internal.get());
00086 Assert(!internal->at_end());
00087 RETURN(internal->get_wdf());
00088 }
00089
00090 Xapian::doccount
00091 Xapian::TermIterator::get_termfreq() const
00092 {
00093 DEBUGAPICALL(Xapian::doccount, "Xapian::TermIterator::get_termfreq", "");
00094 Assert(internal.get());
00095 Assert(!internal->at_end());
00096 RETURN(internal->get_termfreq());
00097 }
00098
00099 Xapian::TermIterator &
00100 Xapian::TermIterator::operator++()
00101 {
00102 DEBUGAPICALL(void, "Xapian::TermIterator::operator++", "");
00103 Assert(internal.get());
00104 Assert(!internal->at_end());
00105 handle_prune(internal, internal->next());
00106 if (internal->at_end()) internal = 0;
00107 return *this;
00108 }
00109
00110
00111 void
00112 Xapian::TermIterator::skip_to(const string & tname)
00113 {
00114 DEBUGAPICALL(void, "Xapian::TermIterator::skip_to", tname);
00115 if (internal.get()) {
00116 Assert(!internal->at_end());
00117 handle_prune(internal, internal->skip_to(tname));
00118 if (internal->at_end()) internal = 0;
00119 }
00120 }
00121
00122 Xapian::termcount
00123 Xapian::TermIterator::positionlist_count() const
00124 {
00125 DEBUGAPICALL(Xapian::termcount, "Xapian::TermIterator::positionlist_count", "");
00126 Assert(internal.get());
00127 Assert(!internal->at_end());
00128 RETURN(internal->positionlist_count());
00129 }
00130
00131 Xapian::PositionIterator
00132 Xapian::TermIterator::positionlist_begin() const
00133 {
00134 DEBUGAPICALL(Xapian::PositionIterator, "Xapian::TermIterator::positionlist_begin", "");
00135 Assert(internal.get());
00136 Assert(!internal->at_end());
00137 RETURN(internal->positionlist_begin());
00138 }
00139
00140 std::string
00141 Xapian::TermIterator::get_description() const
00142 {
00144 return "Xapian::TermIterator()";
00145 }