result_iterator.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2006-2008 The FLWOR Foundation.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  * 
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #ifndef ZORBA_RESULT_ITERATOR_API_H
00017 #define ZORBA_RESULT_ITERATOR_API_H
00018 
00019 #include <zorba/api_shared_types.h>
00020 #include <zorba/iterator.h>
00021 
00022 namespace zorba {
00023 
00024   /** \brief A ResultIterator can be used to iterator over the result sequence of a query.
00025    *
00026    * A ResultIterator is created by calling XQuery::iterator() on a compiled XQuery.
00027    */
00028   class ResultIterator  : public Iterator
00029   {
00030     public:
00031 
00032       /** \brief Destructor
00033        */
00034       virtual ~ResultIterator() {}
00035 
00036       /** \brief Start iterating. 
00037        *
00038        * This function needs to be called before calling next.
00039        * @throw ZorbaException if an error occurs.
00040        */
00041       virtual void 
00042       open() = 0;
00043 
00044       /** \brief Get the next Item of the result sequence.
00045        *
00046        * @param aItem the next Item of the result sequence if true is returned by the function.
00047        * @return true if the sequence is not exhausted, false otherwise.
00048        * @throw ZorbaException if an error occured during query execution or the ResultIterator has
00049        *        not been opened..
00050        */
00051       virtual bool
00052       next(Item& aItem) = 0;
00053 
00054       /** \brief Stop iterating.
00055        *
00056        * In order to call ResultIterator::next, open has to been called.
00057        */
00058       virtual void 
00059       close() = 0;
00060 
00061   };
00062 
00063 } /* namespace zorba */
00064 #endif