00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022
00023 #include "xapian/valueiterator.h"
00024
00025 #include "debuglog.h"
00026 #include "omassert.h"
00027 #include "valuelist.h"
00028
00029 using namespace std;
00030
00031 namespace Xapian {
00032
00033 ValueIterator::ValueIterator() : internal(NULL) { }
00034
00035 ValueIterator::~ValueIterator() { }
00036
00037 ValueIterator::ValueIterator(Internal *internal_) : internal(internal_)
00038 {
00039 internal->next();
00040 if (internal->at_end()) internal = NULL;
00041 }
00042
00043 ValueIterator::ValueIterator(const ValueIterator & o)
00044 : internal(o.internal) { }
00045
00046 ValueIterator::ValueIterator(const ValueIteratorEnd_ &)
00047 : internal(NULL) { }
00048
00049 ValueIterator &
00050 ValueIterator::operator=(const ValueIterator & o)
00051 {
00052 internal = o.internal;
00053 return *this;
00054 }
00055
00056 ValueIterator &
00057 ValueIterator::operator=(const ValueIteratorEnd_ &)
00058 {
00059 internal = NULL;
00060 return *this;
00061 }
00062
00063 string
00064 ValueIterator::operator*() const
00065 {
00066 LOGCALL(API, string, "ValueIterator::operator*", NO_ARGS);
00067 Assert(internal.get());
00068 RETURN(internal->get_value());
00069 }
00070
00071 ValueIterator &
00072 ValueIterator::operator++()
00073 {
00074 LOGCALL(API, ValueIterator &, "ValueIterator::operator++", NO_ARGS);
00075 Assert(internal.get());
00076 internal->next();
00077 if (internal->at_end()) internal = NULL;
00078 RETURN(*this);
00079 }
00080
00081 Xapian::docid
00082 ValueIterator::get_docid() const
00083 {
00084 LOGCALL(API, Xapian::docid, "ValueIterator::get_docid", NO_ARGS);
00085 Assert(internal.get());
00086 RETURN(internal->get_docid());
00087 }
00088
00089 Xapian::valueno
00090 ValueIterator::get_valueno() const
00091 {
00092 LOGCALL(API, Xapian::valueno, "ValueIterator::get_valueno", NO_ARGS);
00093 Assert(internal.get());
00094 RETURN(internal->get_valueno());
00095 }
00096
00097 void
00098 ValueIterator::skip_to(Xapian::docid docid_or_slot)
00099 {
00100 LOGCALL_VOID(API, "ValueIterator::skip_to", docid_or_slot);
00101 Assert(internal.get());
00102 internal->skip_to(docid_or_slot);
00103 if (internal->at_end()) internal = NULL;
00104 }
00105
00106 bool
00107 ValueIterator::check(Xapian::docid did)
00108 {
00109 LOGCALL(API, bool, "ValueIterator::check", did);
00110 Assert(internal.get());
00111 if (!internal->check(did)) return false;
00112 if (internal->at_end()) internal = NULL;
00113 return true;
00114 }
00115
00116 std::string
00117 ValueIterator::get_description() const
00118 {
00119 string desc = "ValueIterator(";
00120 if (internal.get()) desc += internal->get_description();
00121 desc += ')';
00122 return desc;
00123 }
00124
00125 }