> The XQuery Processor
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_COLLECTION_API_H 00017 #define ZORBA_COLLECTION_API_H 00018 00019 #include <zorba/config.h> 00020 #include <zorba/api_shared_types.h> 00021 #include <zorba/item.h> 00022 00023 namespace zorba { 00024 00025 /** \brief A Collection is a sequence of Node Items. 00026 * 00027 * Each Collection is created by the XmlDataManager and referenced by a URI. 00028 * The URI can be accessed in a query's fn:collection function. 00029 * 00030 * Note: This class is reference counted. When writing multi-threaded clients, 00031 * it is the responibility of the client code to synchronize assignments to the 00032 * SmartPtr holding this object. 00033 */ 00034 class ZORBA_EXTERN_DECL Collection : public SmartObject 00035 { 00036 public: 00037 /** \brief Destructor. 00038 */ 00039 virtual ~Collection() {} 00040 00041 /** \brief Get the URI of a collection as an anyURI Item. 00042 * 00043 * @return Item the anyURI Item of the Collection. 00044 */ 00045 virtual Item 00046 getUri() const = 0; 00047 00048 /** \brief Returns the number of items in the collection. 00049 * 00050 * @return The number of items in the collection. 00051 */ 00052 virtual unsigned long 00053 size() const = 0; 00054 00055 /** \brief Adds a Node Item to the Collection. 00056 * 00057 * @param aNode the Node Item to add. 00058 * @param aPosition the position where the node will be inserted. 00059 * By default the data will be appended at the end. 00060 * @return true if the Node Item was added to the Collection, false otherwise. 00061 */ 00062 virtual bool 00063 addNode(const Item& aNode, long aPosition = -1) = 0; 00064 00065 /** \brief Adds a Node Item to the Collection after the targetNode. 00066 * 00067 * @param aNode the Node Item to add. 00068 * @param aTargetNode the aNode will be added before the aTargetNode. 00069 * @param sOrder if true the aNode will be inserted before the aTarget. 00070 * Otherwise aNode will be inserted after aTarget. 00071 * @return true if the Node Item was added to the Collection, false otherwise. 00072 */ 00073 virtual bool 00074 addNode(const Item& aNode, const Item& aTargetNode, bool aOrder) = 0; 00075 00076 /** \brief Deletes the given Item from the Collection. 00077 * 00078 * @param aNode the Node Item to delete 00079 * @return true if the given Node Item was deleted, false otherwise. 00080 */ 00081 virtual bool 00082 deleteNode(const Item& aNode) = 0; 00083 00084 /** \brief Deletes the Item at the given position from the Collection. 00085 * 00086 * @param aPosition the position of the Node that will be removed from collection. 00087 * By default the last Node will be removed from collection. 00088 * @return true if the given Node Item was deleted, false otherwise. 00089 */ 00090 virtual bool 00091 deleteNode(long aPosition = -1) = 0; 00092 00093 /** \brief Get the node at the given position in the collection as a Node Item. 00094 * 00095 * @param aPosition the position of the Node in the collection. 00096 * @return the Node Item at the given position. 00097 */ 00098 virtual Item 00099 nodeAt(long aPosition) = 0; 00100 00101 /** \brief Adds the Node Items retrieved from the given ResultIterator to the Collection. 00102 * 00103 * @param aResultIterator the ResultIterator that produces the Node Items to add. 00104 * @return true if all the Node Items of the given ResultIterator were added to the Collection, 00105 * false otherwise. 00106 */ 00107 virtual bool 00108 addNodes(const ResultIterator* aResultIterator) = 0; 00109 00110 /** \brief Adds the document retrieved from the given input stream to the Collection. 00111 * 00112 * @param aInStream the input stream from which to parse the document. 00113 * @param aPosition the position where the node will be inserted. 00114 * By default the data will be appended at the end. 00115 * @return true if the document was added to the collection (e.g. was a valid document), 00116 * false otherwise. 00117 */ 00118 virtual bool 00119 addDocument(std::istream& aInStream, long aPosition = -1) = 0; 00120 00121 }; /* class Collection */ 00122 00123 } /* namespace zorba */ 00124 00125 #endif