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/postingiterator.h>
00024 #include <xapian/positioniterator.h>
00025 #include "postlist.h"
00026 #include "omassert.h"
00027 #include "omdebug.h"
00028
00029 using namespace std;
00030
00031 Xapian::PostingIterator::PostingIterator(Internal *internal_)
00032 : internal(internal_)
00033 {
00034 if (internal.get()) {
00035
00036 Internal *p = internal->next();
00037 if (p) internal = p;
00038 if (internal->at_end()) internal = 0;
00039 }
00040 }
00041
00042 Xapian::PostingIterator::PostingIterator() : internal(0) {
00043 DEBUGAPICALL(void, "Xapian::PostingIterator::PostingIterator", "");
00044 }
00045
00046 Xapian::PostingIterator::~PostingIterator() {
00047 DEBUGAPICALL(void, "Xapian::PostingIterator::~PostingIterator", "");
00048 }
00049
00050 Xapian::PostingIterator::PostingIterator(const Xapian::PostingIterator &other)
00051 : internal(other.internal)
00052 {
00053 DEBUGAPICALL(void, "Xapian::PostingIterator::Xapian::PostingIterator", other);
00054 }
00055
00056 void
00057 Xapian::PostingIterator::operator=(const Xapian::PostingIterator &other)
00058 {
00059 DEBUGAPICALL(void, "Xapian::PostingIterator::operator=", other);
00060 internal = other.internal;
00061 }
00062
00063 Xapian::docid
00064 Xapian::PostingIterator::operator *() const
00065 {
00066 DEBUGAPICALL(Xapian::docid, "Xapian::PostingIterator::operator*", "");
00067 Assert(internal.get());
00068 Assert(!internal->at_end());
00069 RETURN(internal->get_docid());
00070 }
00071
00072 Xapian::PostingIterator &
00073 Xapian::PostingIterator::operator++()
00074 {
00075 DEBUGAPICALL(void, "Xapian::PostingIterator::operator++", "");
00076 Assert(internal.get());
00077 Assert(!internal->at_end());
00078 Internal *p = internal->next();
00079 if (p) internal = p;
00080 if (internal->at_end()) internal = 0;
00081 return *this;
00082 }
00083
00084
00085 void
00086 Xapian::PostingIterator::skip_to(Xapian::docid did)
00087 {
00088 DEBUGAPICALL(void, "Xapian::PostingIterator::skip_to", did);
00089 Assert(internal.get());
00090 Assert(!internal->at_end());
00091 PostList *p = internal->skip_to(did, 0);
00092 if (p) internal = p;
00093 if (internal->at_end()) internal = 0;
00094 }
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 Xapian::doclength
00105 Xapian::PostingIterator::get_doclength() const
00106 {
00107 DEBUGAPICALL(Xapian::doclength, "Xapian::PostingIterator::get_doclength", "");
00108 Assert(internal.get());
00109 Assert(!internal->at_end());
00110 RETURN(internal->get_doclength());
00111 }
00112
00113 Xapian::termcount
00114 Xapian::PostingIterator::get_wdf() const
00115 {
00116 DEBUGAPICALL(Xapian::termcount, "Xapian::PostingIterator::get_wdf", "");
00117 Assert(internal.get());
00118 Assert(!internal->at_end());
00119 RETURN(internal->get_wdf());
00120 }
00121
00122 Xapian::PositionIterator
00123 Xapian::PostingIterator::positionlist_begin() const
00124 {
00125 DEBUGAPICALL(Xapian::PositionIterator, "Xapian::PostingIterator::positionlist_begin", "");
00126 Assert(internal.get());
00127 Assert(!internal->at_end());
00128 RETURN(Xapian::PositionIterator(internal->open_position_list()));
00129 }
00130
00131 string
00132 Xapian::PostingIterator::get_description() const
00133 {
00135 string desc = "Xapian::PostingIterator([pos=";
00136 if (internal.get() == 0) {
00137 desc += "END";
00138 } else {
00139 desc += internal->get_description();
00140 }
00141 desc += "])";
00142 return desc;
00143 }