api/omvalueiterator.cc

Go to the documentation of this file.
00001 /* omvalueiterator.cc
00002  *
00003  * Copyright 1999,2000,2001 BrightStation PLC
00004  * Copyright 2003,2007,2008 Olly Betts
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License as
00008  * published by the Free Software Foundation; either version 2 of the
00009  * License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00019  * USA
00020  */
00021 
00022 #include <config.h>
00023 #include <xapian/valueiterator.h>
00024 #include "document.h"
00025 #include "omassert.h"
00026 #include "omdebug.h"
00027 #include "utils.h"
00028 
00029 namespace Xapian {
00030 
00031 const string &
00032 ValueIterator::operator *() const
00033 {
00034     DEBUGAPICALL(const string &, "ValueIterator::operator*", "");
00035     Xapian::Internal::RefCntPtr<Xapian::Document::Internal> d(doc.internal);
00036     if (d->value_nos.empty()) {
00037         d->value_nos.reserve(d->values.size());
00038         map<Xapian::valueno, string>::const_iterator i;
00039         for (i = d->values.begin(); i != d->values.end(); ++i) {
00040             d->value_nos.push_back(i->first);
00041         }
00042     }
00043     Assert(index < d->value_nos.size());
00044     RETURN(d->values[d->value_nos[index]]);
00045 }
00046 
00047 const string *
00048 ValueIterator::operator->() const
00049 {
00050     DEBUGAPICALL(const string *, "ValueIterator::operator->", "");
00051     Xapian::Internal::RefCntPtr<Xapian::Document::Internal> d(doc.internal);
00052     if (d->value_nos.empty()) {
00053         d->value_nos.reserve(d->values.size());
00054         map<Xapian::valueno, string>::const_iterator i;
00055         for (i = d->values.begin(); i != d->values.end(); ++i) {
00056             d->value_nos.push_back(i->first);
00057         }
00058     }
00059     Assert(index < d->value_nos.size());
00060     RETURN(&(d->values[d->value_nos[index]]));
00061 }
00062 
00063 Xapian::valueno
00064 ValueIterator::get_valueno() const
00065 {
00066     DEBUGAPICALL(Xapian::valueno, "ValueIterator::get_valueno", "");
00067     Xapian::Internal::RefCntPtr<Xapian::Document::Internal> d(doc.internal);
00068     if (d->value_nos.empty()) {
00069         d->value_nos.reserve(d->values.size());
00070         map<Xapian::valueno, string>::const_iterator i;
00071         for (i = d->values.begin(); i != d->values.end(); ++i) {
00072             d->value_nos.push_back(i->first);
00073         }
00074     }
00075     Assert(index < d->value_nos.size());
00076     RETURN(d->value_nos[index]);
00077 }
00078 
00079 std::string
00080 ValueIterator::get_description() const
00081 {
00082     return "ValueIterator(" + om_tostring(index) + ")";
00083 }
00084 
00085 }

Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.