1 /* 2 * Copyright 2006-2008 The FLWOR Foundation. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #ifndef ZORBA_EMPTY_SEQUENCE_API_H 17 #define ZORBA_EMPTY_SEQUENCE_API_H 18 19 #include <zorba/config.h> 20 #include <zorba/item_sequence.h> 21 #include <zorba/item.h> 22 #include <zorba/iterator.h> 23 24 namespace zorba { 25 26 /** \brief This class is an implementation of the ItemSequence. 27 * Objects of this class return, on the first next call, 28 * an empty sequence. 29 * 30 * See ItemSequence 31 */ 32 class ZORBA_DLL_PUBLIC EmptySequence : public ItemSequence 33 { 34 class InternalIterator : public Iterator 35 { 36 private: 37 ItemSequence *theItemSequence; 38 bool is_open; 39 public: 40 InternalIterator(ItemSequence *item_sequence); 41 42 /** \brief Start iterating. 43 * 44 * This function needs to be called before calling next(). 45 * 46 */ 47 virtual void open(); 48 /** \brief Get the next Item of the sequence. 49 * 50 * This function returns false with no item. 51 * @param aItem not used 52 * @return false always 53 * @throw ZorbaException if iterator is not open. 54 * 55 */ 56 virtual bool next(Item& aItem); 57 /** \brief Stop iterating. 58 * 59 * Not mandatory. 60 */ 61 virtual void close(); 62 /** 63 * brief Check whether the iterator is open or not 64 */ 65 virtual bool isOpen() const; 66 }; 67 public: 68 /** \brief Constructor 69 */ EmptySequence()70 EmptySequence() { } 71 72 /** \brief Destructor 73 */ ~EmptySequence()74 virtual ~EmptySequence() { } 75 76 /** \brief get the void Iterator 77 * @return a void iterator 78 */ 79 virtual Iterator_t getIterator(); 80 81 }; /* class EmptySequence */ 82 83 } // namespace zorba 84 85 #endif /* ZORBA_EMPTY_SEQUENCE_API_H */ 86 /* vim:set et sw=2 ts=2: */ 87