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_EMPTY_SEQUENCE_API_H 00017 #define ZORBA_EMPTY_SEQUENCE_API_H 00018 00019 #include <zorba/config.h> 00020 #include <zorba/item_sequence.h> 00021 #include <zorba/item.h> 00022 #include <zorba/iterator.h> 00023 00024 namespace zorba { 00025 00026 /** \brief This class is an implementation of the ItemSequence. 00027 * Objects of this class return, on the first next call, 00028 * an empty sequence. 00029 * 00030 * See ItemSequence 00031 */ 00032 class ZORBA_DLL_PUBLIC EmptySequence : public ItemSequence 00033 { 00034 class InternalIterator : public Iterator 00035 { 00036 private: 00037 ItemSequence *theItemSequence; 00038 bool is_open; 00039 public: 00040 InternalIterator(ItemSequence *item_sequence); 00041 00042 /** \brief Start iterating. 00043 * 00044 * This function needs to be called before calling next(). 00045 * 00046 */ 00047 virtual void open(); 00048 /** \brief Get the next Item of the sequence. 00049 * 00050 * This function returns false with no item. 00051 * @param aItem not used 00052 * @return false always 00053 * @throw ZorbaException if iterator is not open. 00054 * 00055 */ 00056 virtual bool next(Item& aItem); 00057 /** \brief Stop iterating. 00058 * 00059 * Not mandatory. 00060 */ 00061 virtual void close(); 00062 /** 00063 * brief Check whether the iterator is open or not 00064 */ 00065 virtual bool isOpen() const; 00066 }; 00067 public: 00068 /** \brief Constructor 00069 */ 00070 EmptySequence() { } 00071 00072 /** \brief Destructor 00073 */ 00074 virtual ~EmptySequence() { } 00075 00076 /** \brief get the void Iterator 00077 * @return a void iterator 00078 */ 00079 virtual Iterator_t getIterator(); 00080 00081 }; /* class EmptySequence */ 00082 00083 } // namespace zorba 00084 00085 #endif /* ZORBA_EMPTY_SEQUENCE_API_H */ 00086 /* vim:set et sw=2 ts=2: */