api/ompositionlistiterator.cc

Go to the documentation of this file.
00001 /* ompositionlistiterator.cc
00002  *
00003  * Copyright 1999,2000,2001 BrightStation PLC
00004  * Copyright 2003,2004,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/positioniterator.h>
00024 #include "positionlist.h"
00025 #include "omassert.h"
00026 #include "omdebug.h"
00027 
00028 Xapian::PositionIterator::PositionIterator(Internal *internal_)
00029         : internal(internal_)
00030 {
00031     if (internal.get()) {
00032         internal->next();
00033         if (internal->at_end()) internal = 0;
00034     }
00035 }
00036 
00037 Xapian::PositionIterator::PositionIterator() : internal(0)
00038 {
00039 }
00040 
00041 Xapian::PositionIterator::PositionIterator(const Xapian::PositionIterator &o)
00042         : internal(o.internal)
00043 {
00044 }
00045 
00046 Xapian::PositionIterator::~PositionIterator()
00047 {
00048 }
00049 
00050 void
00051 Xapian::PositionIterator::operator=(const Xapian::PositionIterator &o)
00052 {
00053     internal = o.internal;
00054 }
00055 
00056 Xapian::termpos
00057 Xapian::PositionIterator::operator *() const
00058 {
00059     DEBUGAPICALL(Xapian::termpos, "Xapian::PositionIterator::operator*", "");
00060     Assert(internal.get());
00061     Assert(!internal->at_end());
00062     RETURN(internal->get_position());
00063 }
00064 
00065 Xapian::PositionIterator &
00066 Xapian::PositionIterator::operator++()
00067 {
00068     DEBUGAPICALL(void, "Xapian::PositionIterator::operator++", "");
00069     Assert(internal.get());
00070     Assert(!internal->at_end());
00071     internal->next();
00072     if (internal->at_end()) internal = 0;
00073     return *this;
00074 }
00075 
00076 // extra method, not required to be an input_iterator
00077 void
00078 Xapian::PositionIterator::skip_to(Xapian::termpos pos)
00079 {
00080     DEBUGAPICALL(void, "Xapian::PositionIterator::skip_to", pos);
00081     Assert(internal.get());
00082     Assert(!internal->at_end());
00083     internal->skip_to(pos);
00084     if (internal->at_end()) internal = 0;
00085 }    
00086 
00087 std::string
00088 Xapian::PositionIterator::get_description() const
00089 {
00091     return "Xapian::PositionIterator()";
00092 }

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