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/config.h>
00020 #include <zorba/api_shared_types.h>
00021 #include <zorba/iterator.h>
00022 
00023 namespace zorba {
00024 
00025   /** \brief A ResultIterator can be used to compute and retrieve the result of
00026    * an XQuery in a one-item-at-a-time fashion. 
00027    *
00028    * Several ResultIterators can be created over the same compiled XQuery instance. 
00029    * However, given that the XQuery class is not thread-safe, the ResultIterators
00030    * should not be operated upon by multiple threads.
00031    */
00032   class ZORBA_EXTERN_DECL ResultIterator  : public Iterator
00033   {
00034     public:
00035       /** \brief Destructor
00036        */
00037       virtual ~ResultIterator() {}
00038 
00039       /** \brief Start iterating. 
00040        *
00041        * This function needs to be called before calling next.
00042        * @throw ZorbaException if an error occurs.
00043        */
00044       virtual void 
00045       open() = 0;
00046 
00047       /** \brief Get the next Item of the result sequence.
00048        *
00049        * @param aItem the next Item of the result sequence if true is returned by the function.
00050        * @return true if the sequence is not exhausted, false otherwise.
00051        * @throw ZorbaException if an error occured during query execution or the ResultIterator has
00052        *        not been opened..
00053        */
00054       virtual bool
00055       next(Item& aItem) = 0;
00056 
00057       /** \brief Stop iterating.
00058        *
00059        * In order to call ResultIterator::next, open has to been called again.
00060        */
00061       virtual void 
00062       close() = 0;
00063   };
00064 
00065 } /* namespace zorba */
00066 #endif