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_ITERATOR_API_H
00017 #define ZORBA_ITERATOR_API_H
00018 
00019 #include <zorba/api_shared_types.h>
00020 #include <zorba/item_sequence.h>
00021 
00022 namespace zorba {
00023 
00024   /** \brief Interface for an Iterator over an instance of the XML Data Model.
00025    */
00026   class Iterator : public ItemSequence
00027   {
00028     public:
00029       /** \brief Destructor
00030        */
00031       virtual ~Iterator() {}
00032 
00033       /** \brief Start iterating
00034        *
00035        * This function needs to be called before calling next.
00036        * @throw ZorbaException if an error occurs.
00037        */
00038       virtual void 
00039       open() = 0;
00040 
00041       /** \brief Get the next Item of the sequence.
00042        * @param aItem the next Item of the result sequence if true is returned by the function.
00043        * @return true if the sequence is not exhausted, false otherwise.
00044        * @throw ZorbaException if an error occurs during query execution or the Iterator has
00045        *        not been opened.
00046        */
00047       virtual bool
00048       next(Item& aItem) = 0;
00049 
00050       /** \brief Stop iterating.
00051        *
00052        * In order to call Iterator::next, open has to been called.
00053        */
00054       virtual void 
00055       close() = 0;
00056 
00057   };
00058 
00059 } /* namespace zorba */
00060 #endif