> 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_XMLDATAMANAGER_API_H 00017 #define ZORBA_XMLDATAMANAGER_API_H 00018 00019 #include <istream> 00020 #include <zorba/config.h> 00021 #include <zorba/api_shared_types.h> 00022 00023 namespace zorba { 00024 00025 /** \brief Using the XmlDataManager one can manage documents and collections. 00026 * 00027 * The XmlDataManager is a singelton instance. The Zorba object is reponsible 00028 * for maintaining it's lifetime. The instance can be accessed by calling 00029 * getXmlDataManager() on the Zorba object. It may not be accessed anymore 00030 * after Zorba::shutdown() has been called. 00031 * 00032 * XmlDataManager is a thread-safe class. 00033 */ 00034 class ZORBA_EXTERN_DECL XmlDataManager 00035 { 00036 public: 00037 00038 /** \brief Register an ErrorHandler to which errors occuring during the 00039 * management of documents and collections are reported. 00040 * 00041 * If no ErrorHandler has been set using this function then subclasses of 00042 * the ZorbaException class are thrown to report errors. 00043 * 00044 * @param aErrorHandler ErrorHandler to which errors are reported. The 00045 * caller retains ownership over the ErrorHandler passed as 00046 * parameter. 00047 */ 00048 void 00049 registerErrorHandler(ErrorHandler* aErrorHandler); 00050 00051 00052 /** \brief Load a document from an input stream. 00053 * 00054 * This function loads a document from an input stream. The document 00055 * is identified by the given URI. 00056 * 00057 * @param aURI the URI of the document as String. 00058 * @param aStream the document given in an input stream. 00059 * @return Item the document as an Item. 00060 * @throws ZorbaException if an error occurs. 00061 * 00062 */ 00063 virtual Item 00064 loadDocument(const String& aURI, std::istream& aStream) = 0; 00065 00066 /** \brief Load a document from a file. 00067 * 00068 * This function loads a document from a file. The file name is used as 00069 * the URI of the document. 00070 * 00071 * @param aLocalFile the filename of the document as String. 00072 * @return Item the document as an Item. 00073 * @throws ZorbaException if an error occurs. 00074 * 00075 */ 00076 virtual Item 00077 loadDocument(const String& aLocalFile) = 0; 00078 00079 /** \brief Get the document identified by the given URI. 00080 * 00081 * @param aURI the URI of the document to get. 00082 * @return Item the document as an Item (NULL if the document was not found). 00083 * @throws ZorbaException if an error occurs. 00084 */ 00085 virtual Item 00086 getDocument(const String& aURI) = 0; 00087 00088 /** \brief Delete the document identified by the given URI. 00089 * 00090 * @param aURI the URI of the document to delete. 00091 * @return true if the document was found, false otherwise. 00092 * @throws ZorbaException if an error occurs. 00093 */ 00094 virtual bool 00095 deleteDocument(const String& aURI) = 0; 00096 00097 /** \brief Create a collection. 00098 * 00099 * @param aURI the URI of the collection to create. 00100 * @return Collection_t the collection that was created. 00101 * @throws ZorbaException if an error occurs. 00102 */ 00103 virtual Collection_t 00104 createCollection(const String& aURI) = 0; 00105 00106 /** \brief Get a collection. 00107 * 00108 * @param aURI the URI of the collection to get. 00109 * @return Collection_t the collection identified by the given URI 00110 (NULL if the collection was not found). 00111 * @throws ZorbaException if an error occurs. 00112 */ 00113 virtual Collection_t 00114 getCollection(const String& aURI) = 0; 00115 00116 00117 /** \brief Delete a collection, if the colection has been created before. 00118 * 00119 * @param aURI the URI of the collection to delete. 00120 * @return true if the collection was found, false otherwise. 00121 * @throws ZorbaException if an error occurs. 00122 */ 00123 virtual bool 00124 deleteCollection(const String& aURI) = 0; 00125 00126 protected: 00127 /** \brief Destructor 00128 */ 00129 virtual ~XmlDataManager() {} 00130 00131 }; /* class XmlDataManager */ 00132 00133 } /* namespace zorba */ 00134 #endif